I started making maps for Warcraft sometime ago, but I've never had anyone take a look at my triggers to tell me if they're any good (or absolute rubbish ), so, well, here goes.
These triggers are supposed to detect if a Hero dies, wait for a period of time, and then revive the Hero back at his/her base; it's the typical revive system you see in most AoS style maps.
I'd like to know...
1) Is it any good at all?
2) Is it leak-free?
3) Is it MUI?
4) Any improvements?
(It does work, if that's any help )
Variables used:
Dead_Heroes - Unit[16]
Hero_Is_Dead - Boolean[16]
Seconds_To_Revive - Integer[16]
Num_Dead_Heroes - Integer
Hero_Revive_Timer - Timer[16]
Hero_Revive_Timer_Window - Timer Window[16]
temp_int, temp_unit_group etc are all exactly what they say.
Trigger # 1, Always ON.
Trigger # 2, initially OFF.
Every player has only one Hero, and only one building, by the way.
So, have a look, and give me your opinion .
These triggers are supposed to detect if a Hero dies, wait for a period of time, and then revive the Hero back at his/her base; it's the typical revive system you see in most AoS style maps.
I'd like to know...
1) Is it any good at all?
2) Is it leak-free?
3) Is it MUI?
4) Any improvements?
(It does work, if that's any help )
Variables used:
Dead_Heroes - Unit[16]
Hero_Is_Dead - Boolean[16]
Seconds_To_Revive - Integer[16]
Num_Dead_Heroes - Integer
Hero_Revive_Timer - Timer[16]
Hero_Revive_Timer_Window - Timer Window[16]
temp_int, temp_unit_group etc are all exactly what they say.
Trigger # 1, Always ON.
Trigger:
- Hero Dies
- Events
- Unit - A unit Dies
- Conditions
- ((Dying unit) is A Hero) Equal to True
- Actions
- Set Dead_Heroes[((Player number of (Owner of (Dying unit))) - 1)] = (Dying unit)
- Set Hero_Is_Dead[((Player number of (Owner of (Dying unit))) - 1)] = True
- Set Seconds_To_Revive[((Player number of (Owner of (Dying unit))) - 1)] = (((Hero level of (Dying unit)) / 3) + 10)
- Set Num_Dead_Heroes = (Num_Dead_Heroes + 1)
- Countdown Timer - Start Hero_Revive_Timer[((Player number of (Owner of (Dying unit))) - 1)] as a One-shot timer that will expire in (Real(Seconds_To_Revive[((Player number of (Owner of (Dying unit))) - 1)])) seconds
- Countdown Timer - Create a timer window for (Last started timer) with title Hero Respawns In
- Countdown Timer - Show (Last created timer window) for (Owner of (Dying unit))
- Set Hero_Revive_Timer_Window[((Player number of (Owner of (Dying unit))) - 1)] = (Last created timer window)
- Trigger - Turn on Revive Hero <gen>
- Events
Trigger # 2, initially OFF.
Trigger:
- Revive Hero
- Events
- Time - Every 1.00 seconds of game time
- Conditions
- Actions
- For each (Integer temp_int) from 0 to 15, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Hero_Is_Dead[temp_int] Equal to True
- Then - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- Seconds_To_Revive[temp_int] Greater than 0
- Then - Actions
- Set Seconds_To_Revive[temp_int] = (Seconds_To_Revive[temp_int] - 1)
- Else - Actions
- Countdown Timer - Hide Hero_Revive_Timer_Window[temp_int] for (Player((temp_int + 1)))
- Countdown Timer - Destroy Hero_Revive_Timer_Window[temp_int]
- Set temp_unit_group = (Units owned by (Player((temp_int + 1))) matching (((Matching unit) is A structure) Equal to True))
- Set temp_point = (Position of (First unit of group temp_unit_group))
- Hero - Instantly revive Dead_Heroes[temp_int] at temp_point, Show revival graphics
- Set Hero_Is_Dead[temp_int] = False
- Set Num_Dead_Heroes = (Num_Dead_Heroes - 1)
- Selection - Select Dead_Heroes[temp_int] for (Player((temp_int + 1)))
- Camera - Pan camera for (Player((temp_int + 1))) to temp_point over 0.50 seconds
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
- Do nothing
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- Unit Group - Destroy unit group temp_unit_group
- Point - Remove temp_point
- If (Num_Dead_Heroes Less than 1) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
- For each (Integer temp_int) from 0 to 15, do (Actions)
- Events
Every player has only one Hero, and only one building, by the way.
So, have a look, and give me your opinion .