Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization

Notices

Reply
 
Thread Tools
Old Mar 31, 2006, 08:36 PM   #1
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Revealing Invisible Units

Does anyone know how to programatically reveal an invisible unit?

Here is some pseudo code:

Code:
randNum = <get the random num>

if(<skill amount> >= randNum):
  <reveal player1Spy to player0>
any ideas?
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Mar 31, 2006, 09:29 PM   #2
Bhruic
Emperor
 
Join Date: Nov 2005
Posts: 1,455
Only functions that might affect it would be the PyPlot.changeInvisibleVisibilityCount() and PyPlot.changeVisibilityCount() functions. Although I'll admit to not being entirely sure how they function. All the other invisibility functions look like they only read.

Bh
Bhruic is offline   Reply With Quote
Old Mar 31, 2006, 09:34 PM   #3
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Yeah, that's what I thought, but I can't get those to work. I was hoping someone **cough** TGA **cough** 12monkeys **cough** would have an idea.

Thanks anyways Bhruic
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Mar 31, 2006, 11:59 PM   #4
Bhruic
Emperor
 
Join Date: Nov 2005
Posts: 1,455
Hmm. I did think of a way to reveal/hide them globally, but not by player. Just make a new promotion that grants (or removes, depending how you want to do it) invisibility. Then you just toggle that under the appropriate conditions. However, I'm pretty sure that as I said, that would be globally.

Bh
Bhruic is offline   Reply With Quote
Old Apr 01, 2006, 01:03 AM   #5
Lord Olleus
Deity
 
Lord Olleus's Avatar
 
Join Date: Oct 2005
Location: England
Posts: 4,985
What invisibility are you talking about? the submarine type or the spy type?
__________________
Most zealously I seek for erudition. Much do I know, but to know all is my ambition.
-Faust
Lord Olleus is offline   Reply With Quote
Old Apr 01, 2006, 04:48 AM   #6
snarko
iModify
 
Join Date: Dec 2003
Location: Sweden
Posts: 1,344
Quote:
Originally Posted by Bhruic
Hmm. I did think of a way to reveal/hide them globally, but not by player. Just make a new promotion that grants (or removes, depending how you want to do it) invisibility. Then you just toggle that under the appropriate conditions. However, I'm pretty sure that as I said, that would be globally.
How would you do that? I remember trying to do it a long time ago, not finding any way. Only way I can think of to do it now is recreating the unit as another type which is exactly the same except invisible/not invisible... but having almost exact duplicates of one or several units in the XML file isn't a nice solution.
snarko is offline   Reply With Quote
Old Apr 01, 2006, 05:28 AM   #7
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
@Bhruic - I don't think you can grant invisibility in promotions. You can change how far a unit can see.

@Lord Olleus - Any type of invisibility spy, submarine, etc.

@snarko - yeah, that's what I was planning to do but I want to keep the solution generic.
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 08:33 AM   #8
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
TGA? 12monkeys?

any ideas?
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 08:51 AM   #9
The Great Apple
Big Cheese
 
The Great Apple's Avatar
 
Join Date: Mar 2002
Location: Oxford, England
Posts: 3,361
Quote:
Originally Posted by TheLopez
TGA? 12monkeys?

any ideas?
Sorry, missed this one.

Nope - never played with invisibility. The only way that might work without XML bodges is Bhruic's method... which you've tried.

EDIT: Ok... a pretty far fetched idea here. Subs become visible when they pillage right? Maybe this could be exploited?
__________________
Blobble Wars - use your lovely green blobbles to defeat the evil other colours!
The Great Apple is offline   Reply With Quote
Old Apr 01, 2006, 09:11 AM   #10
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Quote:
Originally Posted by The Great Apple
EDIT: Ok... a pretty far fetched idea here. Subs become visible when they pillage right? Maybe this could be exploited?
Huh, I did know that about subs. I see what I can do there. Do you know if they are visible only during the pillage action or until the end of the turn?

EDIT: It looks like the pillage code is in the core game engine... maybe the SDK will open the invisibility or pillage functionality up.

Also, Bhruics idea would work but it would break my "any unit with UNITCOMBAT_SNIPER as their unit combat can be a sniper" hopes.
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now

Last edited by TheLopez; Apr 01, 2006 at 09:14 AM.
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 09:31 AM   #11
12monkeys
Prince
 
12monkeys's Avatar
 
Join Date: Nov 2003
Location: Germany, Europe
Posts: 395
There is a difference between the invisibility of a sub and the invisiblity of a spy. When looking into the UnitInfos.XML you can see, that the spy is not invisible, but has the bCounterSpy flag set.
To make the spy visible you have to change that attribute. I don't now, if this is possible with API, so Bhruic's method may be the only solution. I wouldn't wait for help of the SDK.
__________________
:wq
12monkeys is offline   Reply With Quote
Old Apr 01, 2006, 09:35 AM   #12
The Great Apple
Big Cheese
 
The Great Apple's Avatar
 
Join Date: Mar 2002
Location: Oxford, England
Posts: 3,361
Quote:
Originally Posted by TheLopez
Huh, I did know that about subs. I see what I can do there. Do you know if they are visible only during the pillage action or until the end of the turn?
No idea.

Quote:
Originally Posted by TheLopez
EDIT: It looks like the pillage code is in the core game engine... maybe the SDK will open the invisibility or pillage functionality up.
CyUnit.NotifyEntity(MissionTypes.MISSION_PILLAGE)

The unit would have to be able to do the mission in the first place though (have moves, and something to pillage).

EDIT: This doesn't work. Don't even think about it.
__________________
Blobble Wars - use your lovely green blobbles to defeat the evil other colours!

Last edited by The Great Apple; Apr 01, 2006 at 10:43 AM.
The Great Apple is offline   Reply With Quote
Old Apr 01, 2006, 10:01 AM   #13
Zuul
Mod lister!
 
Zuul's Avatar
 
Join Date: Nov 2005
Location: Sweden
Posts: 1,117
Was thinking about this the other day. A poor solution is to have the unit in the city it's built in, and move around a decoy others dont see (too small or something), and when the invisible unit is seen it will move from the city to the decoy.
__________________

Zuul is offline   Reply With Quote
Old Apr 01, 2006, 10:03 AM   #14
The Great Apple
Big Cheese
 
The Great Apple's Avatar
 
Join Date: Mar 2002
Location: Oxford, England
Posts: 3,361
Quote:
Originally Posted by Zuul
Was thinking about this the other day. A poor solution is to have the unit in the city it's built in, and move around a decoy others dont see (too small or something), and when the invisible unit is seen it will move from the city to the decoy.
You can make things invisibly grapically without too much difficulty. The AI doesn't care about the graphics though. He also wants it to be seamless so you only have to add one item to the XML.
__________________
Blobble Wars - use your lovely green blobbles to defeat the evil other colours!
The Great Apple is offline   Reply With Quote
Old Apr 01, 2006, 10:27 AM   #15
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
But the question now is how to make them temporarly visible.
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 11:27 AM   #16
12monkeys
Prince
 
12monkeys's Avatar
 
Join Date: Nov 2003
Location: Germany, Europe
Posts: 395
Here's an idea :

CIV4BasicInfo.XML
- add a new Invisible Type INVISBLE_SPY, similar to the already existing INVISIBLE_SUBMARINE (look for it in there)

UnitInfos.XML
- set the <bInvisible> flag of the spy to 0 -> this makes the spy visible.
- set the <Invisible> of the spy to the new Invisiblity type INVISBLE_SPY -> this makes the spy invisible again and now the above mentioned PyPlot functions should work for spies, as long as you call them with INVISIBLE_SPY

- Optional : set the <SeeInvisible> of the spy to the new Invisiblity type INVISBLE_SPY -> now spies should always be able to see other spies.

Have no time to try that, but it could work.
__________________
:wq
12monkeys is offline   Reply With Quote
Old Apr 01, 2006, 12:27 PM   #17
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Quote:
Originally Posted by 12monkeys
Here's an idea :

CIV4BasicInfo.XML
- add a new Invisible Type INVISBLE_SPY, similar to the already existing INVISIBLE_SUBMARINE (look for it in there)

UnitInfos.XML
- set the <bInvisible> flag of the spy to 0 -> this makes the spy visible.
- set the <Invisible> of the spy to the new Invisiblity type INVISBLE_SPY -> this makes the spy invisible again and now the above mentioned PyPlot functions should work for spies, as long as you call them with INVISIBLE_SPY

- Optional : set the <SeeInvisible> of the spy to the new Invisiblity type INVISBLE_SPY -> now spies should always be able to see other spies.

Have no time to try that, but it could work.
I've tried that already, I have a new invisible type: INVISIBLE_SNIPER. But I did set the <bInvisible> flag to 1. I'll try setting the <bInvisible> flag to 0 and calling the methods to see if it works and report back.
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 01:02 PM   #18
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Quote:
Originally Posted by 12monkeys
Here's an idea :

CIV4BasicInfo.XML
- add a new Invisible Type INVISBLE_SPY, similar to the already existing INVISIBLE_SUBMARINE (look for it in there)

UnitInfos.XML
- set the <bInvisible> flag of the spy to 0 -> this makes the spy visible.
- set the <Invisible> of the spy to the new Invisiblity type INVISBLE_SPY -> this makes the spy invisible again and now the above mentioned PyPlot functions should work for spies, as long as you call them with INVISIBLE_SPY

- Optional : set the <SeeInvisible> of the spy to the new Invisiblity type INVISBLE_SPY -> now spies should always be able to see other spies.

Have no time to try that, but it could work.

As promised, I am reporting back my results.
It worked!!!

Code:
# Show the hidden unit
objTargetPlot.changeInvisibleVisibilityCount(gc.getPlayer(0).getTeam(), gc.getInfoTypeForString("INVISIBLE_SNIPER"), 1)

# Hide the hidden unit
objTargetPlot.changeInvisibleVisibilityCount(gc.getPlayer(0).getTeam(), gc.getInfoTypeForString("INVISIBLE_SNIPER"), -1)
Thanks 12monkeys for providing that great lead and to everyone else for all your help!!!
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 01:15 PM   #19
TheLopez
Deity
 
TheLopez's Avatar
 
Join Date: Jan 2006
Location: Oregon
Posts: 2,525
Hmmmm.... here's an interesting problem. using those methods reveals all units with the invisibility type on the plot.
__________________
Currently working on: Civ4 City Resource Stockpiling thread here
On Deck: Unit Crews

"With time and money anything is possible."

Mod Component Library Threads: Civ 4 | Civ 5

1st Modder in training: Then | Now || 2nd Modder in training: Now
TheLopez is offline   Reply With Quote
Old Apr 01, 2006, 02:32 PM   #20
12monkeys
Prince
 
12monkeys's Avatar
 
Join Date: Nov 2003
Location: Germany, Europe
Posts: 395
Doesn't suprise me, tbh. The method definition doesn't restrict something to a single unit. Only team and invisibility type as parameters.

I have an idea, which MAY work :
- lets say you have 3 units of the same ivisibility type and you want to reveal only one of them.
- first you have to determine the unit you want to reveal.
- then move away (with CyUnit.setXY()) the other two to any plot (eg: x+1, y+1).
- next apply the CyPlot.changeInvisibleVisibilityCount() methods
- move back the two other units.

I used that solution on a similar problem in my plot list enhancements. But it could be, that it will not work here, it the changeInvisibleVisibilityCount() sets a plot attribute.
__________________
:wq
12monkeys is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Revealing Invisible Units

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invisible units karso Civ4Col - Technical Support 7 May 02, 2010 11:52 PM
invisible units Darkshadow1st Civ4Col - Technical Support 3 Jul 22, 2009 08:15 PM
invisible units...? (help me!) mipe Civ4 - Fall from Heaven 2 Dec 16, 2007 04:39 AM
All Units are invisible CIM Civ4 - Technical Support 3 Nov 13, 2007 02:17 PM
Invisible Units eric_A Civ - Ideas & Suggestions 10 Mar 10, 2007 03:26 PM


Advertisement

All times are GMT -6. The time now is 04:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR