Hi, two questions. Any help would be great.
~~~~~~~~~~~~~~~~~~~
1) "this" - where/how is this keyword used in script? I've seen it explained somewhere before but it's one of those words that is impossible to search for and I can't find any usage of it in existing script.
This is quick answer I think so I have included it with the other question...
~~~~~~~~~~~~~~~~~~~
2) I'm looking to add a building that upgrades a particular unit so that it has AP missiles. As far as I can see the only way to do this would be to define a second version of the unit in EDU that has AP, disband the old unit and replace it with the v2 one. The "replacing" would need to be via scripting because, apart from any other reason, these particular units are not recruitable (they are spawned by script in the first place).
Worse case scenario is that the player could disband the old one and the script could handle UnitDisbanded to respawn with a v2 unit. But ideally I would like it so that the unit must be disbanded in the settlement with this building - not just anywhere on the map.
I have two lines of thought but both are hitting walls:
A) The player moves the unit into the settlement containing this building and manually disbands it. Is there any way for the script to determine that this disbanding took place in this particular settlement? As far as I can see UnitDisbanded only exports unit and faction info, not location (settlement).
B) The player moves the unit into the settlement containing this building but does not manually disband it. During end-of-turn the script can check this settlement to see if any of these units are garrisoned there. If so then the script will destroy them. I can use destroy_units using a custom unit attribute as the parameter but this would kill all such units in the faction, not just the one(s) in this settlement.
Am I correct that neither of these can work as desired? Any ideas or alternative approaches?
Thanks.




Reply With Quote





