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. jfby

    jfby Chieftain

    Joined:
    Jun 17, 2008
    Messages:
    196
    I tried to add bNoCloaking to the units and now I am getting a schema issue when launching the mod. I have several questions:
    1- is there a apecific place to add the bnocloaking; I put it after bnoreveal but maybe should I should put it elsewhere
    2- are there some units that do not need or can't accept the bnocloaking?
    Thanks everyone for putting up with my noob questions... I am going to look at the schema file to try and figure it out but help is always greatly appreciated.
     
  2. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    1. Yes, there is a specific place. Tags need to follow the order of the tags in the schema file.

    However, that should be the correct plase for the tag.

    Do you have the right number of tabs? And is it written correctly? Like this?

    Code:
    [TAB][TAB]<bNoCloaking>1</bNoCloaking>
    (No units would be exempt from the tag unless an exception was hardcoded in Python for them.)
     
  3. jfby

    jfby Chieftain

    Joined:
    Jun 17, 2008
    Messages:
    196
    Thanks for the information. After reviewing the file, I found that I added an additional tag to a unit that already had the tag, and the error was cleared up. Again thank you very much.
     
  4. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    There's really no reason for me to keep the download up anymore (now that 3.25 has fixed the Cloaking Device bugs that were present even in Cloaking Devices 1.2), so I've removed it.

    If you really, really, really want the Python source code of how I set things up (as opposed to the modified version in 3.0), just ask and I'll post it. But you probably can figure it out from what is present in 3.0. So... not really necessary.
     
  5. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    Do you still have the AI code you used for the 2.37 version? For 4.0 I was hoping to add cloaking AI for ranged units and ships that pillage.

    Also, does Final Frontier Plus have an AI for sensor stations? I'm hoping to add an AI for building those too, but that will be more complicated.
     
  6. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    The only AI code I used was the "force cloak on normal space, force decloak on solar systems". I was working on something more complicated, but I couldn't get it to work.

    I do still have the former, but not the latter.

    Not at the moment, no. But I did recently take a look about restructuring the construction ship AI so that you could easily swap in additional station types, via functions similar to doStarbaseNeed (and findBestResourcePlot). The code for that is written, yet untested, and I haven't written any specific conditions for sensor stations yet.
     
  7. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    Basically my idea is just a forced cloak when a unit in ranged or has a pillage AI when outside of its own territory. I just don't remember where you had the code for that.

    What I have now for a sensor station AI is to rank plots according to a point value for features within a 2 tile radius: 3 nebula, 2 other damaging feature, 1 asteroids; the idea is to try to detect choke points and put a sensor station on them. Haven't done any thought yet on how to code this.
     
  8. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    Oh. Well, I don't have code for it at the moment but I'm sure I could do it if you want.

    It would be easy to do, if you structure it the same way the starbase construction AI is done. As an example, for Wormholes, I changed the starbase code to add points if the starbase was near a Wormhole.

    I'll take a look at that too, if you want.
     
  9. deanej

    deanej Chieftain

    Joined:
    Apr 8, 2006
    Messages:
    4,859
    Location:
    New York State
    I think I can handle the cloak one myself, but it would be nice to have the old code as a reference. I don't remember which function the AI code was built into, either (was it by any chance onBeginPlayerTurn? That's where the Morning Star AI code is).

    You could work on the sensor AI; what I have probably isn't a complete system, and Final Frontier Plus needs it as much as Star Trek does.
     
  10. TC01

    TC01 Chieftain

    Joined:
    Jun 28, 2009
    Messages:
    2,216
    Location:
    Irregularly Online
    I did it in onUnitMove. However, it would be better to do it in AI_unitUpdate().

    The old code looked like this, but you would want to get rid of the checks for the actual cloaking device.

    Code:
    #Added in Cloaking Devices -- TC01
    		if (gc.getPlayer(pUnit.getOwner())).isHuman() == false:
    			if self.canDecloak(pUnit):
    				if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_SOLAR_SYSTEM'):
    					pUnit.changeMoves(60)
    					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CLOAK'), false)
    			if self.canCloak(pUnit):
    				if not pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_SOLAR_SYSTEM'):
    					pUnit.changeMoves(60)
    					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CLOAK'), true)
    #End of Cloaking Devices
    
    #Cloaking Device functions (used to check if an AI unit can cloak)
    	def canDecloak(self, pUnit):
    		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CLOAK')):
    			if pUnit.getMoves() > 0:
    				return true
    		
    		return false
    	
    	def canCloak(self, pUnit):
    		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CLOAK_DEVICE')):
    			if not pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CLOAK')):
    				if pUnit.getMoves() > 0:
    					return true
    
    		return false
    #End of Cloaking Device Functions
    Alright, I'll work on it.
     
  11. icheben

    icheben Chieftain

    Joined:
    Jan 30, 2007
    Messages:
    15
    let me resurrect this thread...

    I started to think about combining cloaking with defender withdrawal. You have merged defender withdrawal in your FFP mod, TC01. I wonder if it's possible to activate cloaking if the defender withdraws. Is there a chance to do that in the dll without messing up the variables for python? I actually think / hope it should'nt be more than few lines of code i have to add to cvunit.cpp.

    Maybe you can give me some hints. I can understand what a few lines of code are doing but i can't do more than copy-paste, adjust for my purposes and then hope the best.

    Edit: i already merged defender withrawal to deanej's great mod
     

Share This Page