• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Crash after several uses of a trigger

Status
Not open for further replies.
Level 2
Joined
Mar 1, 2020
Messages
7
So basically I have a trigger that spawns a circle of power in a circle around the casting unit (in this case a town hall). Before it spawns the circle of power, I check the Z value of the terrain and check for structures that are too close. Its working real well, except after casting the ability between 5 - 15 times the game crashes. Can anyone point me in the right direction?

  • Village Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Village_SpawnRangeMin = 2500.00
      • Set VariableSet Village_SpawnRangeMax = 4500.00
      • Set VariableSet Village_FSPV_Range = 1250.00
  • Village FindSpawnPointValidator
    • Events
    • Conditions
    • Actions
      • -------- CHECK Z --------
      • Custom script: set udg_Village_ZReal = GetLocationZ(udg_Village_FSPV_SpawnPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Village_ZReal Greater than or equal to 550.00
              • Village_ZReal Equal to 0.00
        • Then - Actions
          • Set VariableSet Village_FSPV_IsValidSpawnPoint = False
        • Else - Actions
          • -------- Get all units within a range of the spawn point to check that this spawn point is valid --------
          • Set VariableSet Village_temp_UnitGroup1 = (Units within Village_FSPV_Range of Village_FSPV_SpawnPoint.)
          • -------- Assume the spawn point is valid by default --------
          • Set VariableSet Village_FSPV_IsValidSpawnPoint = True
          • -------- Enumerate the units with range of the spawn point and set FSPV_IsSpawnPointValid to false if any units would invalidate the spawn point --------
          • Unit Group - Pick every unit in Village_temp_UnitGroup1 and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A town-hall-type unit) Equal to True
                • Then - Actions
                  • Set VariableSet Village_FSPV_IsValidSpawnPoint = False
                • Else - Actions
      • -------- Clean up the temp unit group reference --------
      • Custom script: call DestroyGroup(udg_Village_temp_UnitGroup1)

  • Village FindSpawnPoint
    • Events
    • Conditions
    • Actions
      • Set VariableSet Village_FSP_FoundSpawnPoint = False
      • -------- Try 10 times, if its consistently hard to find a point you may need to increase this number --------
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Village_FSP_FoundSpawnPoint Equal to False
            • Then - Actions
              • -------- Find a random point within a min/max radius around the given target point --------
              • Set VariableSet Village_temp_Point1 = (Village_FSP_TargetPoint offset by (Random real number between Village_FSP_RangeMin and Village_FSP_RangeMax) towards (Random angle) degrees.)
              • -------- Run the validation trigger which will set FSP_IsValidSpawnPoint --------
              • Set VariableSet Village_FSPV_SpawnPoint = Village_temp_Point1
              • Trigger - Run Village FindSpawnPointValidator <gen> (ignoring conditions)
              • -------- If FSPV_IsValidSpawnPoint is true we can stop looking --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Village_FSPV_IsValidSpawnPoint Equal to True
                • Then - Actions
                  • Set VariableSet Village_FSP_FoundSpawnPoint = True
                  • Set VariableSet Village_FSP_SpawnPoint = Village_temp_Point1
                • Else - Actions
                  • -------- Clean up the temp location to avoid memory leaks --------
                  • Custom script: call RemoveLocation(udg_Village_temp_Point1)
            • Else - Actions
      • -------- If we couldn't find a spawn point after N tries then we need to increase the range and try again --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Village_FSPV_IsValidSpawnPoint Not equal to True
        • Then - Actions
          • -------- Increase the range by some amount greater than 1.0 --------
          • Set VariableSet Village_FSP_RangeMin = (Village_FSP_RangeMin x 1.50)
          • Set VariableSet Village_FSP_RangeMax = (Village_FSP_RangeMax x 1.50)
          • -------- And try again --------
          • Trigger - Run (This trigger) (ignoring conditions)
        • Else - Actions
  • Village FindSpawnPointValidator
    • Events
    • Conditions
    • Actions
      • -------- CHECK Z --------
      • Custom script: set udg_Village_ZReal = GetLocationZ(udg_Village_FSPV_SpawnPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Village_ZReal Greater than or equal to 550.00
              • Village_ZReal Equal to 0.00
        • Then - Actions
          • Set VariableSet Village_FSPV_IsValidSpawnPoint = False
        • Else - Actions
          • -------- Get all units within a range of the spawn point to check that this spawn point is valid --------
          • Set VariableSet Village_temp_UnitGroup1 = (Units within Village_FSPV_Range of Village_FSPV_SpawnPoint.)
          • -------- Assume the spawn point is valid by default --------
          • Set VariableSet Village_FSPV_IsValidSpawnPoint = True
          • -------- Enumerate the units with range of the spawn point and set FSPV_IsSpawnPointValid to false if any units would invalidate the spawn point --------
          • Unit Group - Pick every unit in Village_temp_UnitGroup1 and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A town-hall-type unit) Equal to True
                • Then - Actions
                  • Set VariableSet Village_FSPV_IsValidSpawnPoint = False
                • Else - Actions
      • -------- Clean up the temp unit group reference --------
      • Custom script: call DestroyGroup(udg_Village_temp_UnitGroup1)
 

Attachments

  • Init.JPG
    Init.JPG
    51.2 KB · Views: 42
  • InitFindSpawn.JPG
    InitFindSpawn.JPG
    152.3 KB · Views: 63
  • spawnunit.JPG
    spawnunit.JPG
    65.5 KB · Views: 50
  • SPAWNUNIT1.JPG
    SPAWNUNIT1.JPG
    77 KB · Views: 57
  • upload_2020-3-27_21-4-40.png
    upload_2020-3-27_21-4-40.png
    69.5 KB · Views: 29
Last edited:
Level 15
Joined
Feb 7, 2020
Messages
397
The code is a bit hard to follow. I would use the post as trigger method: How To Post Your Trigger

My first suggestion is to implement an integer that counts the number of times the FindSpawnPoint trigger is ran and limit the number to 5 or 10 based on map size. Having a trigger call itself without a safe terminator can cause an infinite loop if it relies on returning a variable that could fail to populate (in this case, grabbing a true boolean).

When you say crash, do you mean a crash to desktop or game freezes? If it's freezing up, I suspect there's an infinite loop issue.
 
Level 2
Joined
Mar 1, 2020
Messages
7
The code is a bit hard to follow. I would use the post as trigger method: How To Post Your Trigger

My first suggestion is to implement an integer that counts the number of times the FindSpawnPoint trigger is ran and limit the number to 5 or 10 based on map size. Having a trigger call itself without a safe terminator can cause an infinite loop if it relies on returning a variable that could fail to populate (in this case, grabbing a true boolean).

When you say crash, do you mean a crash to desktop or game freezes? If it's freezing up, I suspect there's an infinite loop issue.

I was getting a hard freeze and then crash to desktop. I actually was able to debug what was happening and figured out that the validation trigger was running and breaking itself based on one of the conditions checking for structures, which I believe was counting all structures including the ones made with the trigger.

How would I go about assigning an integer to the trigger?
 
Level 15
Joined
Feb 7, 2020
Messages
397
I was getting a hard freeze and then crash to desktop. I actually was able to debug what was happening and figured out that the validation trigger was running and breaking itself based on one of the conditions checking for structures, which I believe was counting all structures including the ones made with the trigger.

How would I go about assigning an integer to the trigger?

I would just increment an integer variable every time the trigger is called. Wrap everything in another if/then block checking for said integer. If less than the max amount, run trigger. If greater than, reset to 0 and do nothing else (maybe print a message to yourself if this happens to help debug).

This is essentially just simple recursion protection.
 
Status
Not open for further replies.
Top