• 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.

Arena Event problem

Status
Not open for further replies.
Level 2
Joined
Dec 7, 2010
Messages
16
Hi, im creating a survival arena map, and i want to create an "event"

Event: Hero spawn will be disabled, and players must fight to be the last one, but i dont know how to check who is the last ! Please help me : )
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Count the number of heroes who enter the event and store it in a global integer. Every time one of them dies you decrement the integer (reduce by 1). Check if the integer is equal to 1 (1 hero alive) and then do whatever you want to the winner. You can use a unit group to keep track of the heroes in the event, when the integer is at 1 you can check the unit group for the hero that is still alive in the event and so know who won.

You could also use some kind of list structure and remove dying players from it until the list size is 1. In this case you know the last element in the list must be the winner.

If you remove heroes on player leave or there is some event dropout you may want to add a check to decrement the integer or remove from the list in those cases otherwise you might end up with 1 hero alive and it thing there are still more.
 
Status
Not open for further replies.
Top