• 🏆 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!

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,198
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