1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Cloaking Device Modmod

Discussion in 'Civ4 - Star Trek Mod' started by TC01, Aug 7, 2009.

  1. TC01

    TC01 Chieftain

    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)
     
  2. Agent327

    Agent327 Observer

    Joined:
    Oct 28, 2006
    Messages:
    16,052
    Location:
    In orbit
    Excellent! IMO this should be added as a standard feature for the races with Cloak ships.:goodjob:
     
  3. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    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).
     
  4. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    Well, we were talking about how to make the AI use a python action button in the tutorial I just made:

    (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.
     
  5. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    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?
     
  6. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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).
     
  7. apenpaap

    apenpaap Tsar of all the Internets

    Joined:
    Apr 7, 2008
    Messages:
    1,468
    Location:
    Amsterdam
    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.
     
  8. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    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.
     
  9. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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.
     
  10. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
  11. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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:


    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.
     
  12. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    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.
     
  13. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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.
     
  14. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    Odd stuff seems to happen with the percentages. For example: probes are strength 1 (so they can auto-explore) but have -1000% space defense (and can't attack). They still win a against early barbs.
     
  15. GASherbert

    GASherbert Lurker

    Joined:
    Feb 1, 2009
    Messages:
    67
    Location:
    Maryland
    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%.
     
  16. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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?
     
  17. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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.
     
  18. Pablod

    Pablod Chieftain

    Joined:
    Sep 17, 2005
    Messages:
    294
    where is the sound of the device
    is nothing without it
     
  19. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    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?
     
  20. Pablod

    Pablod Chieftain

    Joined:
    Sep 17, 2005
    Messages:
    294
    still no sound
    promotion show AS2D sound on
    but nothing there is not such sound
    in sound folder
     

Share This Page