Cloaking Device Modmod

TC01

Deity
Joined
Jun 28, 2009
Messages
2,216
Location
Irregularly Online
Cloaking Devices 1.2 for Star Trek 2.37 (Now included in 3.0!)

This is a now defunct modmod which expands cloaking devices- by giving you the ability to cloak and decloak your ships. It is defunct because deanej has merged it with the main Star Trek mod and is now standard as of 3.0.

Therefore, the download has been removed, so as not to confuse people. If you want the source code... (the original source code), please either post that in this thread or PM me.

Otherwise, this thread can be used for discussion about Cloaking Devices, as set up in 3.0.

Original Description:

This has been implemented as a python action button (without adding a new mission or command to the SDK). It has been added to all ST scenarios that feature cloaking devices as of the current version, v1.2. There is also AI scripting to make the AI cloak and decloak. It's still being worked on and is extremely basic, but it works. Thanks to apenpaap for the core idea of how it works.

As of v1.2, there is a sound effect triggered on when you cloak and decloak a unit.

Features:
-Cloaking Device Promotion now enables use of the "Cloak" button.
-This button provides the "Cloaked" promotion, which makes the unit invisible.
-It can be removed by pressing the "Decloak" button (which you will only see after your unit has cloaked)
-There is a flat movement cost (1 mp) to cloaking to try and limit the exploitability of this.
-AI scripting that causes the AI to decloak units in solar systems and cloak units outside solar systems.
-New in v1.2, a sound effect triggered when you press the Cloak and Decloak buttons (Cloak On and Cloak Off)

Download removed, due to the mod's integration in 3.0 (and the fixing of several Cloaking Devices bugs in 3.25).

Changelog:

Code:
v1.2 Changelog:
-Added audio effect when cloak or decloak occurs
-Added Cloaks to all remaining Star Trek scenarios
-Fixed bug in ST Galaxy cloaking

v1.1 Changelog:
-Added Cloaks to ST 2.0 scenarios (Millennium, Galaxy, Lost Era)
-Fixed bug where ships start with wrong cloaking promotion
-Made cloaked ships unable to attack (have 0 strength)
-Added AI scripting to make the AI cloak and decloak units

To Install:

1. Unzip the files to a temporary directory (such as Temp/Cloaking Devices... this is defaulted).

2. Copy the Mods folder into your Civilization IV\Beyond the Sword directory (or wherever you installed BTS). This will overwrite the following files in all Star Trek directories SAVE Voyager and Xindi Attack.

-Units.xml (changed in all)
-CIV4PromotionInfos.xml (changed in all)
-CIV4UnitInfos.xml (changed in all save TOS, Millennium, Lost Era).
-CvGameUtils.py (changed in all)
-CvMainInterface.py (changed in all)
-CvFinalFrontierEvents.py (changed in all)
-Audio2DScripts.xml (changed in DS9)
-AudioDefines.xml (changed in DS9)

If you have made changes to any of said files, please back them up or manually copy the code over. All changes are marked with "Cloaking Devices"

3. To test, start a game in any Star Trek scenario, go into Worldbuilder, give yourself a unit with the Cloaking Device promotion. You should have a "Cloak" button you can press (at the end of the movement, kill, sleep, etc. mission buttons). Upon pressing it, you should gain Cloaked, loose 1 movement point, and gain the "Decloak" button where the "Cloak" button was. (Both buttons are identical graphically, mouse-over it to check)

Credits:
TC01 for making the module/modcomp.
deanej for making the Star Trek Mod
The_J for helping me figure out how to make the button display text
apenpaap for suggesting how the AI scripting should work
Whoever made the Cloak button (may have been deanej or Jaydn or someone else...)
Jon Shafer for creating Final Frontier.
Firaxis/2K Games (makers of Civ 4)
Paramount/Viacom (makers of Star Trek)
 
Excellent! IMO this should be added as a standard feature for the races with Cloak ships.:goodjob:
 
I would, but the AI is probably oblivious (unless it's been coded to use it; then again, the AI probably doesn't do much with cloaking now). Is there a way to make it so that units can't engage in combat or pillage while cloaked (except when using a particular unit perhaps? My origional idea for the klingon uu was to be able to fire while cloaked).
 
I would, but the AI is probably oblivious (unless it's been coded to use it; then again, the AI probably doesn't do much with cloaking now). Is there a way to make it so that units can't engage in combat or pillage while cloaked (except when using a particular unit perhaps? My origional idea for the klingon uu was to be able to fire while cloaked).

Well, we were talking about how to make the AI use a python action button in the tutorial I just made:

The easiest way, I think, is to make what you want to do a triggered function somewhere, triggered from the handleInput() code normally.

Then whenever your condition in onUnitMove is satisfied (they are on a tile in their territory without any resources, perhaps?) have the function be triggered and do the effect of pressing the button, without actually pressing the button.

(This was my example in the tutorial, a prospect ability that randomly gave a resource-less plot a resource.)

So the scripting for this would be really really complicated. You'd have to define conditions for the AI to cloak and recloak. Perhaps if they have ships with cloaking devices they should auto-cloak, and if they're in range of an enemy unit they can defeat they should decloak, attack, and recloak? (provided movement points work)


As to preventing use of attacking while cloaking, the easiest way is to set the unit's combat strength to 0 when it has the Cloaked promotion (symbolizing how a cloaked ship cannot use weapons or shields). Doesn't seem to prevent pillaging, but there is a tag in the Unit Infos,

Code:
			<bPillage>0</bPillage>

that could be cloned into PromotionInfos, perhaps.
 
Come to think of it, the AI probably doesn't cloak units now (has anyone ever seen them do this?). Their handling of them now is poor at best so it might be better that they not use it. I could clone bOnlyDefensive to the promos to prevent attacking. I'll have to look at it to see how it does the cloaking - maybe I'll be able to make a special version for the Klingon UU (as I'm thinking of having starts with cloaking device as a civ trait).

EDIT: one other question: how do you make it so that units can only get the cloaked promo is the player uses the button?
 
EDIT: one other question: how do you make it so that units can only get the cloaked promo is the player uses the button?

My tutorial on how to do this is here (it's also in my sig), and both changes of how I did it are labeled "Cloaking Devices -- TC01" or somesuch in CvMainInterface.py of the download.

But generally what I did was made one button set the unit to have the Cloaked promotion, and have the other remove the promotion. The buttons only appear to a unit with the Cloaking Device promotion (which is given as usual).
 
Maybe a good way to teach the A.I. how to use it would be to simply tell them to cloak units in space, and uncloak them in solar systems. Like that, they could use it, but still defend.
 
My tutorial on how to do this is here (it's also in my sig), and both changes of how I did it are labeled "Cloaking Devices -- TC01" or somesuch in CvMainInterface.py of the download.

But generally what I did was made one button set the unit to have the Cloaked promotion, and have the other remove the promotion. The buttons only appear to a unit with the Cloaking Device promotion (which is given as usual).

What I ment was, how do you prevent units from getting the cloaked promo by normal means (experience) when the player has researched the cloaking device technology? It doesn't look like there's anything to disable it.
 
Well, what I did was set the <UnitCombat> tag to have no attached UnitCombats, which should prevent any unit from being able to purchase the promotion... this should work? If it doesn't, I can tie this into Future Tech.

I realize that I forgot to change units who started with PROMOTION_CLOAK to start with PROMOTION_CLOAKING_DEVICE. This will be fixed in the future.
 
I've updated this modmod to v1.1. It adds cloaks to three additional scenarios, the 2.0mod/scenarios (Galaxy, Lost Era, and Millennium), prevents you from attacking while cloaked by making your ship have 0 combat strength when it is cloaked, and adds some basic AI scripting as apenpaap described:

Maybe a good way to teach the A.I. how to use it would be to simply tell them to cloak units in space, and uncloak them in solar systems. Like that, they could use it, but still defend.


I think in the future I'm going to make the Klingon UU have a seperate promotion that acts the same way, but doesn't remove the combat strength. I also want to make the AI decloak if they're in the movement range of another unit that is capable of seeing cloaked ships (if they can see it, anyway), and decloak if they are within movement range of a unit they could defeat in combat.

And, of course, update the mod to all other Star Trek scenarios.
 
Have you tested the combat change? I think the way you have it will work fine, but I'm not an expert on how combat works (iCombatPercent is the only modifier that applies directly to the unit at all times - with everything else applying to the defender, I think the only interference will be from combat promotions, as the percents may add instead of multiply). For 3.0 I plan to clone bOnlyDefensive to the promotions.
 
Have you tested the combat change? I think the way you have it will work fine, but I'm not an expert on how combat works (iCombatPercent is the only modifier that applies directly to the unit at all times - with everything else applying to the defender, I think the only interference will be from combat promotions, as the percents may add instead of multiply). For 3.0 I plan to clone bOnlyDefensive to the promotions.

I thought it would work too. But after a few tests it seems like it might not be working... the promotion is definitely giving minus 100% strength, but it doesn't seem to be stopping me from attacking and destroying a 1 strength shuttle with my 5-strength cloaked Prometheus (this was done in Millennium since my Star Trek mod has Wormholes installed and I haven't made the two modcomps compatible) with 99.99% odds. Which shouldn't be happening. But, same cloaked Prometheus (well, a different one, but I did the same thing) has 0.19% odds against a fellow Prometheus that I gave to the barbarians.

Not sure what is happening.
 
The first few barbarian fights are free victories, if I remember correctly. And if the probe is in an asteroid field, I don't believe it suffers from the -1000%.
 
In my testing trying to get a script that makes the AI decloak a unit right next to another unit, attack, and then recloak, I discovered it can still bombard while cloaked (obviously, I hadn't eliminated it).

This might be something else to disable, except I have no idea how. Would simply setting <iBombardRateChange> to -100 fix the issue for the cloaked promotion?
 
Released v1.2, probably the final version. Changelog below:

Code:
-Added audio effect when cloak or decloak occurs
-Added Cloaks to all remaining Star Trek scenarios
-Fixed bug in ST Galaxy cloaking

I think that "ranged attack" while cloaked is the easiest way to represent units decloaking, attacking, and then cloaking, so it doesn't have to be removed.
 
where is the sound of the device
is nothing without it

You don't get a sound effect when using the cloak?

I suggest re-downloading and re-installing v1.2, since that version contains the sound effect (or, rather, the code that triggers the sound effect). My test shows that it works fine.

Anyone else having this issue?
 
still no sound
promotion show AS2D sound on
but nothing there is not such sound
in sound folder
 
Top Bottom