1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

If Unit Equal to Pet(1-24)

Discussion in 'World Editor Help Zone' started by catlover47, Feb 5, 2020.

  1. catlover47

    catlover47

    Joined:
    Apr 21, 2018
    Messages:
    18
    Resources:
    0
    Resources:
    0
    In my game each player can have 1 pet. It stores the unit ID of each player's pet as the array Pet(1-24), 24 being the max number of players. However, when the pet dies, it needs to set Pet(Player Number) back to no unit so they can get a new one.

    Is there any way in Conditions to have the trigger check if "Dying unit Equal to Pet(Any Number), rather than having to have 24 lines checking Pet(1), Pet(2), Pet(3)..? Or know of a better way to do this?

    Thanks!
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    • Set Pet[(Player number of (Triggering Unit))] = No unit
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Add all pets to a unit group. If the dying unit is in the unit group then it is a pet and can be removed from the unit group and have the array entry for the player set to no unit.
     
  4. catlover47

    catlover47

    Joined:
    Apr 21, 2018
    Messages:
    18
    Resources:
    0
    Resources:
    0
    • Set Pet[(Player number of (Triggering Unit))] = No unit


    Good idea, but I have to differentiate between the player character deaths and their pets and player characters can be many different unit types.[/COLOR][/SIZE]

    That works, thanks!
     
  5. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,471
    Resources:
    0
    Resources:
    0
    He meant Pet[Player number of triggering player], not Triggering Unit. You could also do Pet[Player number of owner of triggering unit].

    Events:
    A unit dies

    Conditions:
    Triggering unit equal to Pet[player number of triggering player]

    Actions:
    Set Pet[player number of triggering player} = No Unit
     
  6. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I think you understand this, uncle, but in a trigger run by any event that internally uses TriggerRegisterPlayerUnitEvent Triggering Player == Owner of Triggering Unit.
     
  7. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,471
    Resources:
    0
    Resources:
    0
    Yeah, that's why I did it the correct way in the trigger example, lol.

    But yeah I should've said that they're the same thing instead of saying "you could also do".