Results 1 to 3 of 3

Thread: 1) "this" keyword and 2) killing a unit type in a settlement

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default 1) "this" keyword and 2) killing a unit type in a settlement

    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.

  2. #2
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: 1) "this" keyword and 2) killing a unit type in a settlement

    1) A parameter for some commands, it means 'do it to the selected character'. I don't have a list of commands it works with, I think it's mostly the console commands 'give_trait', 'remove_trait', 'give_ancillary', etc.

    2) Neither A nor B look doable and I've no suggestions.
    Last edited by Taiji; February 28, 2011 at 04:34 PM.

  3. #3
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: 1) "this" keyword and 2) killing a unit type in a settlement

    Thanks Taiji.

    1) Ah, yes, I remember now. I was hoping that it could be used inside monitors, referring to the the 'thing' being monitored. Like...
    Code:
    monitor_event SettlementTurnEnd
      if I_NumberUnitsInSettlement this {unit-type} > 0
    where "this" would be the settlement. But no go.

    2) Oh well, never mind. Thanks for the confirmation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •