• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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 63
Joined
Aug 10, 2018
Messages
6,456
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 63
Joined
Aug 10, 2018
Messages
6,456
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