Zurtrogx
Active Member
- Reaction score
- 24
Problem status: SOLVED
______________________________________________________________
In my map, the structures automatically spawn units like Footmen Frenzy. However, there is a slight difference beacuse in my map there is a population limit. Once this limit is reached, the structure will stop spawning units.
You are able to construct a building type (light, medium, heavy) and then a unit type (melee, ranged, magic) and the building will start producing the corresponding unit.
However, there seems to be a problem:
Only the first building you create will stop spawning when the population limit is reached.
I did a few tests, modifying the trigger, and it seems like only the first loop will add a unit into the unit group. From 2-50, no units are added into the group.
Why is this occuring?
Pay attention to this trigger only, because I feel that is where the problem is
This trigger causes the unit the spawn and adds it into a unit group
This unit removes the unit from the correct group when it dies
This trigger determines the unit that will be spawned
______________________________________________________________
In my map, the structures automatically spawn units like Footmen Frenzy. However, there is a slight difference beacuse in my map there is a population limit. Once this limit is reached, the structure will stop spawning units.
You are able to construct a building type (light, medium, heavy) and then a unit type (melee, ranged, magic) and the building will start producing the corresponding unit.
However, there seems to be a problem:
Only the first building you create will stop spawning when the population limit is reached.
I did a few tests, modifying the trigger, and it seems like only the first loop will add a unit into the unit group. From 2-50, no units are added into the group.
Why is this occuring?
Pay attention to this trigger only, because I feel that is where the problem is
This trigger causes the unit the spawn and adds it into a unit group
Trigger:
- Unit Spawn
- Events
- Time - Every 0.01 seconds of game time
- Conditions
- Actions
- For each (Integer US_check_loop) from 1 to 50, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_structure[US_check_loop] Not equal to No unit
- Then - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Number of units in US_current_population[US_check_loop]) Less than US_population_cap[US_check_loop]
- Then - Actions
- Set US_spawn_time_left[US_check_loop] = (US_spawn_time_left[US_check_loop] - 0.01)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_spawn_time_left[US_check_loop] Less than or equal to 0.00
- Then - Actions
- Set US_temp_point = (Position of US_structure[US_check_loop])
- Unit - Create 1 (Unit-type(US_unit_type[US_check_loop])) for (Player(US_owner_player_number[US_check_loop])) at US_temp_point facing Default building facing degrees
- Custom script: call RemoveLocation (udg_US_temp_point)
- Unit Group - Add (Last created unit) to US_current_population[US_check_loop]
- Set US_spawn_time_left[US_check_loop] = US_spawn_time_max[US_check_loop]
- Else - Actions
- If - Conditions
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- For each (Integer US_check_loop) from 1 to 50, do (Actions)
- Events
This unit removes the unit from the correct group when it dies
Trigger:
- Unit Death
- Events
- Unit - A unit Dies
- Conditions
- Actions
- For each (Integer US_death_check_loop) from 1 to 50, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- ((Triggering unit) is in US_current_population[US_death_check_loop]) Equal to True
- Then - Actions
- Unit Group - Remove (Triggering unit) from US_current_population[US_death_check_loop]
- Set US_death_check_loop = 51
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- For each (Integer US_death_check_loop) from 1 to 50, do (Actions)
- Events
This trigger determines the unit that will be spawned
Trigger:
- Unit Type upgrade
- Events
- Unit - A unit Begins casting an ability
- Conditions
- Or - Any (Conditions) are true
- Conditions
- (Ability being cast) Equal to Melee
- (Ability being cast) Equal to Ranged
- (Ability being cast) Equal to Magic
- Conditions
- Or - Any (Conditions) are true
- Actions
- Unit - Order (Triggering unit) to Stop
- For each (Integer US_set_loop) from 1 to 50, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_structure[US_set_loop] Equal to No unit
- Then - Actions
- Set US_structure[US_set_loop] = (Triggering unit)
- Set US_structure_type = (Substring((String((Unit-type of (Triggering unit)))), 10, 10))
- Set US_upgrade_selected = (Substring((String((Name of (Ability being cast))) as Lower case), 1, 2))
- Set US_unit_type[US_set_loop] = ((custom_ + US_race_type[(Player number of (Owner of (Triggering unit)))]) + (US_structure_type + US_upgrade_selected))
- Set US_owner_player_number[US_set_loop] = (Player number of (Owner of (Triggering unit)))
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_structure_type Equal to l
- Then - Actions
- Set US_population_cap[US_set_loop] = 5
- Set US_spawn_time_max[US_set_loop] = 15.00
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_structure_type Equal to m
- Then - Actions
- Set US_population_cap[US_set_loop] = 3
- Set US_spawn_time_max[US_set_loop] = 45.00
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_structure_type Equal to h
- Then - Actions
- Set US_population_cap[US_set_loop] = 2
- Set US_spawn_time_max[US_set_loop] = 135.00
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_race_type[(Player number of (Owner of (Triggering unit)))] Equal to b
- Then - Actions
- Set US_spawn_time_max[US_set_loop] = (US_spawn_time_max[US_set_loop] x 1.50)
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_race_type[(Player number of (Owner of (Triggering unit)))] Equal to l
- Then - Actions
- Set US_spawn_time_max[US_set_loop] = (US_spawn_time_max[US_set_loop] x 0.50)
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- US_race_type[(Player number of (Owner of (Triggering unit)))] Equal to x
- Then - Actions
- Set US_spawn_time_max[US_set_loop] = (US_spawn_time_max[US_set_loop] x 0.90)
- Else - Actions
- If - Conditions
- Set US_spawn_time_left[US_set_loop] = US_spawn_time_max[US_set_loop]
- Set US_set_loop = 51
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Loop - Actions
- Unit - Remove Melee from (Triggering unit)
- Unit - Remove Ranged from (Triggering unit)
- Unit - Remove Magic from (Triggering unit)
- Events