• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

If Unit Equal to Pet(1-24)

Status
Not open for further replies.
Level 3
Joined
Apr 21, 2018
Messages
18
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!
 
Level 3
Joined
Apr 21, 2018
Messages
18
  • 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]

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.

That works, thanks!
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,391
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
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,391
I think you understand this, uncle, but in a trigger run by any event that internally uses TriggerRegisterPlayerUnitEvent Triggering Player == Owner of Triggering Unit.
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".
 
Status
Not open for further replies.
Top