- Joined
- Jul 1, 2010
- Messages
- 1,340
So while I was working on a PvP Arena map, I thought of multiple ways to code the same spell in Trigger Editor.
The spell is basically periodic Healing while a unit has a specific buff. Now in my case, there's only 1 Hero with a spell that applies this buff, and it only applies to himself, meaning no other unit type in the game can ever get this buff. At the same time, there are up to 4 players in the game, and each of them can control only 1 Hero at a time, while there can easily be 20 units on the map at a time. Because of this I was asking myself what would be the most optimized way to code a spell?
So I figured a couple of possibilities
1) Running For function, even though most of the times only 1 out of 4 players will have the buff, and even that 1 player does not have it permanently.
Thanks in advance.
The spell is basically periodic Healing while a unit has a specific buff. Now in my case, there's only 1 Hero with a spell that applies this buff, and it only applies to himself, meaning no other unit type in the game can ever get this buff. At the same time, there are up to 4 players in the game, and each of them can control only 1 Hero at a time, while there can easily be 20 units on the map at a time. Because of this I was asking myself what would be the most optimized way to code a spell?
So I figured a couple of possibilities
1) Running For function, even though most of the times only 1 out of 4 players will have the buff, and even that 1 player does not have it permanently.
-
Periodic
-
Events
-
Time - Every 1.00 seconds of game time
-
-
Conditions
-
Actions
-
For each (Integer A) from 1 to 4, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Hero[(Integer A)] has buff Rejuvenation) Equal to True
-
-
Then - Actions
-
Unit - Set life of Hero[(Integer A)] to ((Life of Hero[(Integer A)]) + 5.00)
-
-
Else - Actions
-
-
-
-
-
-
Periodic 2
-
Events
-
Time - Every 1.00 seconds of game time
-
-
Conditions
-
Actions
-
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) has buff Rejuvenation) Equal to True
-
-
Then - Actions
-
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 5.00)
-
-
Else - Actions
-
-
-
-
-
-
Periodic 3
-
Events
-
Time - Every 1.00 seconds of game time
-
-
Conditions
-
Actions
-
Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff Rejuvenation) Equal to True)) and do (Actions)
-
Loop - Actions
-
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 5.00)
-
-
-
-
Thanks in advance.