Hi, I needed some assitance with a code I just made up now, not only does it not do what I intended it to, but it seems that the conditions are never met and thus causing an endless loop that cause a imminent CTD.
The trigger is as follows: There are 6 regions in the map, a RNG will determine where a gold mine will spawn in any of those regions, conditioning that the maximum number of gold mines in map are equal to the amount of players playing x 1/2/3, so basically, if there's one player in-game, with a x3 multiplier, there should be only 3 Gold Mines in the whole map, distributed across various regions.
Two other conditions when checking where to spawn the Gold Mine are wheter that region already has 2 Mines in that same region, or that it spawns distanced away from any player's units.
When testing, it seems to spawn a large amount of mines across the map, about 20, when I'm only playing as singleplayer, with a x2 multiplier, however, for some reason when adding the condition that there should be less than 2 gold mines in that region in order to spawn another, it doesn't meet the requirement, thus looping forever and causing a CTD, no fatal errors, just closes the game completely.
I apologize for the tangling paragraphs ahead, but I thought a quick explanation was needed before pasting the whole thing, so here it goes:
The trigger is as follows: There are 6 regions in the map, a RNG will determine where a gold mine will spawn in any of those regions, conditioning that the maximum number of gold mines in map are equal to the amount of players playing x 1/2/3, so basically, if there's one player in-game, with a x3 multiplier, there should be only 3 Gold Mines in the whole map, distributed across various regions.
Two other conditions when checking where to spawn the Gold Mine are wheter that region already has 2 Mines in that same region, or that it spawns distanced away from any player's units.
When testing, it seems to spawn a large amount of mines across the map, about 20, when I'm only playing as singleplayer, with a x2 multiplier, however, for some reason when adding the condition that there should be less than 2 gold mines in that region in order to spawn another, it doesn't meet the requirement, thus looping forever and causing a CTD, no fatal errors, just closes the game completely.
I apologize for the tangling paragraphs ahead, but I thought a quick explanation was needed before pasting the whole thing, so here it goes:
-
Mine Nodes
-
Events
-
Time - MineNodesTimer expires
-
-
Conditions
-
Actions
-
Set MineNodeChance = (Random integer number between 1 and 6)
-
Set PlayerTown = (Units in (Playable map area) matching (((Matching player) controller) Equal to User))
-
Unit Group - Pick every unit in PlayerTown and do (Actions)
-
Loop - Actions
-
Set PlayerTownPoint = (Position of (Picked unit))
-
Custom script: call DestroyGroup (udg_OutsideBoundaryMines)
-
Set OutsideBoundaryMines = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Gold Mine) and (((Mine Node 1 <gen> contains (Matching unit)) Equal to False) and (((Mine Node 2 <gen> contains (Matching unit)) Equal to False) and (((Mine Node 3 <gen> contains
-
Unit Group - Pick every unit in OutsideBoundaryMines and do (Actions)
-
Loop - Actions
-
Set OutsideBoundariesMinePoint = (Position of (Picked unit))
-
Set MinesAwayFromPlayers = (Units in (Playable map area) matching ((((Matching unit) is in OutsideBoundaryMines) Equal to True) and ((Distance between OutsideBoundariesMinePoint and PlayerTownPoint) Greater than 5000.00)))
-
Unit Group - Remove all units of MinesAwayFromPlayers from OutsideBoundaryMines
-
Custom script: call DestroyGroup (udg_MinesAwayFromPlayers)
-
Custom script: call RemoveLocation (udg_OutsideBoundariesMinePoint)
-
-
-
Custom script: call RemoveLocation (udg_PlayerTownPoint)
-
-
-
Unit Group - Pick every unit in OutsideBoundaryMines and do (Unit - Remove (Picked unit) from the game)
-
Custom script: call DestroyGroup (udg_OutsideBoundaryMines)
-
Set RegionMines[1] = (Units in Mine Node 1 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set RegionMines[2] = (Units in Mine Node 2 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set RegionMines[3] = (Units in Mine Node 3 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set RegionMines[4] = (Units in Mine Node 4 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set RegionMines[5] = (Units in Mine Node 5 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set RegionMines[6] = (Units in Mine Node 6 <gen> matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 1
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[1]) Equal to 0
-
(Number of units in RegionMines[1]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[1])
-
Set MineNodePoint = (Random point in Mine Node 1 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 2
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[2]) Equal to 0
-
(Number of units in RegionMines[2]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[2])
-
Set MineNodePoint = (Random point in Mine Node 2 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 3
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[3]) Equal to 0
-
(Number of units in RegionMines[3]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[3])
-
Set MineNodePoint = (Random point in Mine Node 3 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 4
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[4]) Equal to 0
-
(Number of units in RegionMines[4]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[4])
-
Set MineNodePoint = (Random point in Mine Node 4 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 5
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[5]) Equal to 0
-
(Number of units in RegionMines[5]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[5])
-
Set MineNodePoint = (Random point in Mine Node 5 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MineNodeChance Equal to 6
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in RegionMines[6]) Equal to 0
-
(Number of units in RegionMines[6]) Less than 2
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_RegionMines[6])
-
Set MineNodePoint = (Random point in Mine Node 6 <gen>)
-
Unit - Create 1 Gold Mine for Neutral Passive at MineNodePoint facing Default building facing degrees
-
Custom script: call DestroyGroup (udg_TotalMines)
-
Set TotalMines = (Units of type Gold Mine)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Number of units in TotalMines) Equal to ((Number of players in (All players controlled by a User player)) x MineNodesCount)
-
-
Then - Actions
-
Custom script: call DestroyGroup (udg_TotalMines)
-
-
Else - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
-
-
-
-
-
Else - Actions
-
-
-
-
-
-
-
-
-
-
-
-
-