- Joined
- Jun 24, 2024
- Messages
- 59
Hi all,
this may be a bit longer post then usually, i could not wrap my head around it for a couple of days now..
My Idea for a trigger (or multiple co-working) is as followed:
Based on an game idea and a similar map i saw years ago i am currently building a Arena-Survival type map which includes:
Players spawning with one random creep (Main creep, no more non summon units) of level 1 in the beginning.
Players can roam and kill critters to gain points.
Point requirements for level ups are Level 10 for level 2, 20 for 3, 30 for 4,.. ect. - Player kills give 10.
For the point system i'm using a simple integer array with 100-point steps to make counting easier.
Meaning Level 2 is reached with 10+, Level 3 with 120+, Level 4 with 230+ ect.
Now when a player dies, he looses 105 Points which is roundabout 1 level, depending on current score (for safety of exactly hitting cap -5 extra)
He then gets a current score check (not total score - different counter) and should respawn with the correct creep level depending on score.
E.g. Player unit (not summon) dies with 220 Points, it gets reduced to 115 - Player should get one level 2 unit (at random point currently)
But that's the point where my triggers seem to break, i either manage to get multiple respawns for the same player increasing their amounts seemingly random
or they do not respawn at all anymore after dying at certain situations.
My overly complicated code with bad code and gaps in the scoreing...:
Leveling the Main unit

I thought about a Level integer set for every player and reset of the score, checking leveling requirements with "x*level" but had no luck implementing it correctly so far.
Regards
SMOrc
this may be a bit longer post then usually, i could not wrap my head around it for a couple of days now..
My Idea for a trigger (or multiple co-working) is as followed:
Based on an game idea and a similar map i saw years ago i am currently building a Arena-Survival type map which includes:
Players spawning with one random creep (Main creep, no more non summon units) of level 1 in the beginning.
Players can roam and kill critters to gain points.
Point requirements for level ups are Level 10 for level 2, 20 for 3, 30 for 4,.. ect. - Player kills give 10.
For the point system i'm using a simple integer array with 100-point steps to make counting easier.
Meaning Level 2 is reached with 10+, Level 3 with 120+, Level 4 with 230+ ect.
Now when a player dies, he looses 105 Points which is roundabout 1 level, depending on current score (for safety of exactly hitting cap -5 extra)
He then gets a current score check (not total score - different counter) and should respawn with the correct creep level depending on score.
E.g. Player unit (not summon) dies with 220 Points, it gets reduced to 115 - Player should get one level 2 unit (at random point currently)
But that's the point where my triggers seem to break, i either manage to get multiple respawns for the same player increasing their amounts seemingly random
or they do not respawn at all anymore after dying at certain situations.
My overly complicated code with bad code and gaps in the scoreing...:
Leveling the Main unit
-
PlayerLeveling
-
Events
-
Unit - A unit Dies
-
-
Conditions
-
(Player number of (Owner of (Killing unit))) Less than or equal to 8
-
(Owner of (Dying unit)) Equal to Neutral Hostile
-
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 10
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 99
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 120
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 199
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 230
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 299
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 340
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 399
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 450
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 499
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 560
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 599
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 670
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 699
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 780
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 799
-
-
-
And - All (Conditions) are true
-
Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 1000
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 2000
-
-
-
-
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 10
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 99
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 100
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 2
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 2 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 120
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 199
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 200
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 3
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 3 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 230
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 299
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 300
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 4
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 4 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 340
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 399
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 400
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 5
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 5 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 450
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 499
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 500
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 6
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 6 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 560
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 599
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 600
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 7
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 7 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 670
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 699
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 700
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 8
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 8 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 780
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 799
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 900
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 9
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 8 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 990
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 1000
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 1000
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 9
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 9 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Greater than or equal to 1000
-
ScorePlayerArray[(Player number of (Owner of (Killing unit)))] Less than or equal to 2000
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[(Player number of (Owner of (Killing unit)))] = 9999
-
Set VariableSet LevelPlayerArray[(Player number of (Owner of (Killing unit)))] = 10
-
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Killing unit))) and do (Actions)
-
Loop - Actions
-
For each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
-
Hero - Drop (Item carried by (Picked unit) in slot (Integer A)) from (Picked unit).
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is Summoned) Equal to False
-
-
Then - Actions
-
Unit - Replace (Picked unit) with a (Random level 10 creep unit-type) using The old unit's relative life and mana
-
Unit - Add Inventory (Hero) to (Last replaced unit)
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
-
Else - Actions
-
-
-
Else - Actions
-
Skip remaining actions
-
-
-
-
-
PlayerDying new
-
Events
-
Unit - A unit owned by Player 1 (Red) Dies
-
Unit - A unit owned by Player 2 (Blue) Dies
-
Unit - A unit owned by Player 3 (Teal) Dies
-
Unit - A unit owned by Player 4 (Purple) Dies
-
Unit - A unit owned by Player 5 (Yellow) Dies
-
Unit - A unit owned by Player 6 (Orange) Dies
-
Unit - A unit owned by Player 7 (Green) Dies
-
Unit - A unit owned by Player 8 (Pink) Dies
-
-
Conditions
-
((Dying unit) is Summoned) Equal to False
-
-
Actions
-
Custom script: local integer playerNum
-
Set VariableSet TempIntegerNew[0] = (Player number of (Owner of (Dying unit)))
-
Custom script: set playerNum = udg_TempIntegerNew[0]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
ScorePlayerArray[TempIntegerNew[0]] Less than 0
-
ScorePlayerArray[TempIntegerNew[0]] Greater than or equal to 1000
-
-
-
-
Then - Actions
-
Set VariableSet ScorePlayerArray[TempIntegerNew[0]] = 0
-
Set VariableSet LevelPlayerArray[TempIntegerNew[0]] = 1
-
-
Else - Actions
-
-
Custom script: set udg_TempIntegerNew[0] = playerNum
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
ScorePlayerArray[TempIntegerNew[0]] Less than 900
-
-
Then - Actions
-
Wait 4.00 seconds
-
Game - Display to (All players) for 5.00 seconds the text: (respawning + (String(TempIntegerNew[0])))
-
Unit - Create 1 (Random level LevelPlayerArray[TempIntegerNew[0]] creep unit-type) for (Player(TempIntegerNew[0])) at (Random point in Trees <gen>) facing Default building facing degrees
-
Unit - Add Inventory (Hero) to (Last created unit)
-
Camera - Pan camera for (Owner of (Last created unit)) to (Position of (Last created unit)) over 1.00 seconds
-
Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
-
-
Else - Actions
-
Game - Display to (All players) for 5.00 seconds the text: (Error on respawning + (String(TempIntegerNew[0])))
-
-
-
-
I thought about a Level integer set for every player and reset of the score, checking leveling requirements with "x*level" but had no luck implementing it correctly so far.
Regards
SMOrc