Revealing Invisible Units

TheLopez

Deity
Joined
Jan 16, 2006
Messages
2,525
Location
Oregon
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?
 
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
 
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
 
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
 
What invisibility are you talking about? the submarine type or the spy type?
 
Bhruic said:
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.
 
@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.
 
TGA? 12monkeys?

any ideas?
 
TheLopez said:
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?
 
The Great Apple said:
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.
 
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.
 
TheLopez said:
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.

TheLopez said:
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.
 
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 said:
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.
 
But the question now is how to make them temporarly visible.
 
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.
 
12monkeys said:
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.
 
12monkeys said:
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. :bounce: :banana:
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!!!
 
Hmmmm.... here's an interesting problem. using those methods reveals all units with the invisibility type on the plot.
 
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.
 
Top Bottom