• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] PUBG Circle Trigger World Bounds Problems

Status
Not open for further replies.
Level 6
Joined
Dec 6, 2009
Messages
168
Hello!

I am in the making of a PUBG/Fortnite/Apex circle that spawn in a random location on the map and then shrinks. My problem is that if part of the circle is out of bounds it doesn't spawn correctly when it has shrunken enough to be inside world bounds. I have uploaded a test map aswell. If you set "CircleSizeMax = 8500" or larger the circle doesn't move at all and it ends the trigger. I guess there is a better way to do this but I'm out of ideas on how to make it work.

I tried my best to describe what everything does.

  • Circle
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- Choose circle unit --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleDummyUnit = Circle Dummy
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- Size of the circle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleSizeMax = 7500.00
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- The speed the circle moves towards the middle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleShrinkSpeed = 10.00
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- Number of circle units that spawn --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleDummyNumber = 20
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- End size of the circle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleSizeMin = 500.00
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- Position of the middle of the circle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleFacing = (Position of CircleDummy)
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- The amount of degrees the circle units will spawn in order to form the circle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • Set CircleSpin = 20.00
      • -------- ------------------------------------------------------------------------------------------------ --------
      • -------- Creating the circle --------
      • -------- ------------------------------------------------------------------------------------------------ --------
      • For each (Integer A) from 1 to CircleDummyNumber, do (Actions)
        • Loop - Actions
          • Set Circle_LoopLocation = (CircleFacing offset by CircleSizeMax towards (CircleSpin x (Real((Integer A)))) degrees)
          • -------- ------------------------------------------------------------------------------------------------ --------
          • -------- Checking World bounds so that the circle doesn't spawn outside of the map --------
          • -------- ------------------------------------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (X of Circle_LoopLocation) Greater than WB_MaxX
                  • (X of Circle_LoopLocation) Less than WB_MinX
                  • (Y of Circle_LoopLocation) Greater than WB_MaxY
                  • (Y of Circle_LoopLocation) Less than WB_MinY
            • Then - Actions
              • -------- ------------------------------------------------------------------------------------------------ --------
              • -------- If out of bounds no unit will spawn yet --------
              • -------- ------------------------------------------------------------------------------------------------ --------
              • Set CircleDummy1[(Integer A)] = No unit
              • Set CircleBoundsPoint[(Integer A)] = Circle_LoopLocation
              • Game - Display to (All players) the text: Dummy = No Unit Tri...
            • Else - Actions
              • -------- ------------------------------------------------------------------------------------------------ --------
              • -------- Spawning the units forming the circle --------
              • -------- ------------------------------------------------------------------------------------------------ --------
              • Unit - Create 1 Circle Dummy for Player 1 (Red) at Circle_LoopLocation facing CircleFacing
              • Set CircleDummy1[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_Circle_LoopLocation)
      • Custom script: call RemoveLocation(udg_Circle_Location)
      • Trigger - Turn on Circle Loop <gen>
  • Circle Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to CircleDummyNumber, do (Actions)
        • Loop - Actions
          • Set Circle_Location = (Position of CircleDummy1[(Integer A)])
          • Set CircleAngle1 = (Facing of CircleDummy1[(Integer A)])
          • -------- ------------------------------------------------------------------------------------------------ --------
          • -------- Setting the new location the circle dummy will move to --------
          • -------- ------------------------------------------------------------------------------------------------ --------
          • Set Circle_LoopLocation = (Circle_Location offset by CircleShrinkSpeed towards CircleAngle1 degrees)
          • -------- ------------------------------------------------------------------------------------------------ --------
          • -------- CircleBoundsPoint is to set a point for the units that spawns when they get inside World Bounds --------
          • -------- ------------------------------------------------------------------------------------------------ --------
          • Set CircleBoundsPoint[(Integer A)] = (CircleBoundsPoint[(Integer A)] offset by CircleSizeMax towards (CircleSpin x (Real((Integer A)))) degrees)
          • -------- ------------------------------------------------------------------------------------------------ --------
          • -------- Checking if the Circle is range of its minimum size --------
          • -------- ------------------------------------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Circle_LoopLocation and CircleFacing) Less than or equal to CircleSizeMin
            • Then - Actions
              • -------- ------------------------------------------------------------------------------------------------ --------
              • -------- --------
              • -------- ------------------------------------------------------------------------------------------------ --------
              • Custom script: call RemoveLocation(udg_Circle_LoopLocation)
              • Custom script: call RemoveLocation(udg_Circle_Location)
              • Set CircleAngle1 = 0.00
              • Game - Display to (All players) the text: (String(CircleSizeMax))
              • For each (Integer A) from 1 to CircleDummyNumber, do (Actions)
                • Loop - Actions
                  • Set CircleDummy1[(Integer A)] = No unit
              • Trigger - Turn off (This trigger)
            • Else - Actions
              • -------- ------------------------------------------------------------------------------------------------ --------
              • -------- Checking if there already is a unit in the circle or if it can spawn one inside World Bounds --------
              • -------- ------------------------------------------------------------------------------------------------ --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CircleDummy1[(Integer A)] Equal to No unit
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (X of CircleBoundsPoint[(Integer A)]) Greater than WB_MaxX
                          • (X of CircleBoundsPoint[(Integer A)]) Less than WB_MinX
                          • (Y of CircleBoundsPoint[(Integer A)]) Greater than WB_MaxY
                          • (Y of CircleBoundsPoint[(Integer A)]) Less than WB_MinY
                    • Then - Actions
                      • -------- ------------------------------------------------------------------------------------------------ --------
                      • -------- If it is still outside of World Bounce no unit will spawn. And the Message "Out of Bounds" will show. --------
                      • -------- ------------------------------------------------------------------------------------------------ --------
                      • Game - Display to (All players) the text: Out of Bounds
                    • Else - Actions
                      • -------- ------------------------------------------------------------------------------------------------ --------
                      • -------- If it is in bounds then the unit shall spawn in the correct order to form a circle --------
                      • -------- ------------------------------------------------------------------------------------------------ --------
                      • Game - Display to (All players) the text: In Bounds
                      • Unit - Create 1 Circle Dummy for Player 1 (Red) at CircleBoundsPoint[(Integer A)] facing CircleFacing
                      • Set CircleDummy1[(Integer A)] = (Last created unit)
                      • Cinematic - Ping minimap for (All players) at CircleBoundsPoint[(Integer A)] for 1.00 seconds
                      • Custom script: call RemoveLocation(udg_CircleBoundsPoint[GetForLoopIndexA()])
                • Else - Actions
                  • Set CircleSizeMax = (CircleSizeMax - 0.25)
                  • Unit - Move CircleDummy1[(Integer A)] instantly to Circle_LoopLocation
                  • Custom script: call RemoveLocation(udg_Circle_LoopLocation)
                  • Custom script: call RemoveLocation(udg_Circle_Location)
 

Attachments

  • Pubg Circle Test Map.w3x
    53.7 KB · Views: 33
Level 39
Joined
Feb 27, 2007
Messages
5,012
The way you're going about this is really not the best. The facing of your dummy units is probably changing over time, especially if you try to create them on some sort of impassible terrain and they are moved to the closest pathable location (as GUI does)... then you are depending on this facing angle to move each dummy forward! Not gonna work; instead you want to recompute the point they should be at and then just move them. To fix them being displaced by terrain/units/destructibles you can use SetUnitX and SetUnitY. Also there is no need to define the number of dummy units and the degrees per dummy; right now you have 20 dummies taking 20* each so that's 400*, which is more than a full circle!

I'm pretty sure there's no need to check worldbounds here because the Location() function that point-with-projection ultimately calls only returns points actually inside the map bounds. Creating them at the edge of map bounds shouldn't be a problem. No reason to set the dummy array units = No Unit at the end... then you have no way to refer to and remove those circle units when the round is over.

  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Set CIRCLE_Center = wherever
    • Set CIRCLE_Shrink = 10.00
    • Set CIRCLE_MaxRadius = 7500.00
    • Set CIRCLE_MinRadius = 500.00
    • Set CIRCLE_DummyCount = 20
    • Set CIRCLE_DummyType = whatever
    • -------- --------
    • Set CIRCLE_CurrRadius = CIRCLE_MaxRadius
    • Set CIRCLE_DumAng = 360.00/CIRCLE_DummyCount
    • -------- --------
    • For each (Integer A) from 1 to CIRCLE_DummyCount do (Actions)
      • Loop - Actions
        • Set Point = CIRCLE_Center offset by CIRCLE_CurrRadius towards (CIRCLE_DumAng x Real(Integer A)) degrees
        • Unit - Create 1 CIRCLE_DummyType for PLAYER at Point facing ((CIRCLE_DumAng x Real(Integer A)) + 180.00) //makes it face inward
        • Set CIRCLE_Dummy[(Integer A)]
        • Custom script: call SetUnitX(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationX(udg_Point))
        • Custom script: call SetUnitY(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationY(udg_Point))
        • Custom script: call RemoveLocation(udg_Point)
    • Trigger - Turn on other trigger
  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • Set CIRCLE_CurrRadius = CIRCLE_CurrRadius - CIRCLE_Shrink
    • If (All Conditions are true) then do (Then actions) else do (Else Actions)
      • If - Conditions
        • CIRCLE_CurrRadius less than or equal to CIRCLE_MinRadius
      • Then - Actions
        • Set CIRCLE_CurrRadius = CIRCLE_MinRadius //in case you overshoot by subtracting
        • Trigger - Turn off (This trigger)
      • Else - Actions
    • For each (Integer A) from 1 to CIRCLE_DummyCount do (Actions)
      • Loop - Actions
        • Set Point = CIRCLE_Center offset by CIRCLE_CurrRadius towards (CIRCLE_DumAng x Real(Integer A)) degrees
        • Custom script: call SetUnitX(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationX(udg_Point))
        • Custom script: call SetUnitY(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationY(udg_Point))
        • Custom script: call RemoveLocation(udg_Point)
 
Level 6
Joined
Dec 6, 2009
Messages
168
Thank you, that is alot smoother and less code than in my trigger. Now I remember that "SetUnitX" and "SetUnitY" is the better way to do it. If I put MaxRadius out of world bounds the game instantly crashes. But if I put in World Bounds it doesn't crash and works just like I want it to. I did this and it works

EDIT: Another thing I noticed is that the Circle doesn't stop if I use Neutral Player units (Neutral Hostile/Neutral Passive) but it works aslong as the Dummy unit is spawned for a Player. Changing this one line from "Player 24 (Peanut)" to "Neutral Passive" makes the circle bounce out when it reaches its center point even tho the trigger is off. What's up with that? :O
  • Unit - Create 1 CIRCLE_DummyUnit for Player 24 (Peanut) at CIRCLE_Point facing ((CIRCLE_DummyAngle x (Real((Integer A)))) + 180.00) degrees
  • Circle Init
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set CIRCLE_DummyUnit = Circle Dummy
      • Set CIRCLE_Center = (Center of (Playable map area))
      • Set CIRCLE_ShrinkSpeed = 10.00
      • Set CIRCLE_MaxRadius = 8500.00
      • Set CIRCLE_MinRadius = 500.00
      • Set CIRCLE_DummyCount = 40
      • -------- - --------
      • Set CIRCLE_CurrRadius = CIRCLE_MaxRadius
      • Set CIRCLE_DummyAngle = (360.00 / (Real(CIRCLE_DummyCount)))
      • -------- - --------
      • For each (Integer A) from 1 to CIRCLE_DummyCount, do (Actions)
        • Loop - Actions
          • Set CIRCLE_Point = (CIRCLE_Center offset by CIRCLE_CurrRadius towards (CIRCLE_DummyAngle x (Real((Integer A)))) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (X of CIRCLE_Point) Greater than WB_MaxX
                  • (X of CIRCLE_Point) Less than WB_MinX
                  • (Y of CIRCLE_Point) Greater than WB_MaxY
                  • (Y of CIRCLE_Point) Less than WB_MinY
            • Then - Actions
              • Set CIRCLE_Dummy[(Integer A)] = No unit
            • Else - Actions
              • Unit - Create 1 CIRCLE_DummyUnit for Player 1 (Red) at CIRCLE_Point facing ((CIRCLE_DummyAngle x (Real((Integer A)))) + 180.00) degrees
              • Set CIRCLE_Dummy[(Integer A)] = (Last created unit)
              • Custom script: call SetUnitX(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationX(udg_CIRCLE_Point))
              • Custom script: call SetUnitY(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationY(udg_CIRCLE_Point))
              • Custom script: call RemoveLocation(udg_CIRCLE_Point)
      • Trigger - Turn on Circle Loop <gen>
  • Circle Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set CIRCLE_CurrRadius = (CIRCLE_CurrRadius - CIRCLE_ShrinkSpeed)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CIRCLE_CurrRadius Less than or equal to CIRCLE_MinRadius
        • Then - Actions
          • Set CIRCLE_CurrRadius = CIRCLE_MinRadius
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • For each (Integer A) from 1 to CIRCLE_DummyCount, do (Actions)
            • Loop - Actions
              • Set CIRCLE_Point = (CIRCLE_Center offset by CIRCLE_CurrRadius towards (CIRCLE_DummyAngle x (Real((Integer A)))) degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (X of CIRCLE_Point) Greater than WB_MaxX
                      • (X of CIRCLE_Point) Less than WB_MinX
                      • (Y of CIRCLE_Point) Greater than WB_MaxY
                      • (Y of CIRCLE_Point) Less than WB_MinY
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_CIRCLE_Point)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CIRCLE_Dummy[(Integer A)] Equal to No unit
                    • Then - Actions
                      • Unit - Create 1 CIRCLE_DummyUnit for Player 1 (Red) at CIRCLE_Point facing ((CIRCLE_DummyAngle x (Real((Integer A)))) + 180.00) degrees
                      • Set CIRCLE_Dummy[(Integer A)] = (Last created unit)
                      • Custom script: call SetUnitX(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationX(udg_CIRCLE_Point))
                      • Custom script: call SetUnitY(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationY(udg_CIRCLE_Point))
                      • Custom script: call RemoveLocation(udg_CIRCLE_Point)
                    • Else - Actions
                      • Custom script: call SetUnitX(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationX(udg_CIRCLE_Point))
                      • Custom script: call SetUnitY(udg_CIRCLE_Dummy[bj_forLoopAIndex], GetLocationY(udg_CIRCLE_Point))
                      • Custom script: call RemoveLocation(udg_CIRCLE_Point)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,012
You actually want the For Each... in the loop trigger to be outside/after the if-block as I have it. The way you have it actually doesn't stop it at min radius, it stops one 'step' before (granted, the most you're off by is ShrinkSpeed). In my opinion it's more reasonable to keep the dummy AT the worldbounds if it should be 'outside' of it, rather than not creating one at all, but I suppose that is really up to you. The dummy movement is probably because there's some neutral AI associated with those units; try pausing them after you create them or permastunning them with something.
 
Level 6
Joined
Dec 6, 2009
Messages
168
Pausing the units worked. I moved the For Each outside but it still stops at one step before min radius. Doesn't really matter tho. If I used your trigger it crashed the game instantly if the units spawns out of bounds. So I had to use World Bounds to make sure it didn't crash.
 
Level 39
Joined
Feb 27, 2007
Messages
5,012
Right, it doesn't matter but it should actually stop it at the min radius just based on what I see. Turning the trigger off doesn't stop the current execution of the trigger, so it should still proceed after that line and at that point CurrRadius = MinRadius.
 
Status
Not open for further replies.
Top