why doesn't this work correctly

madd_999

New Member
Reaction score
14
i am trying to reduce the height of the ground in a region using the create carter deformation using this trigger:

Trigger:
  • Events
    • terrain
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Xtimes = 0.00
      • Set Ytimes = 0.00
      • -------- Set X --------
      • Set MinX = (Integer((Min X of Region 000 <gen>)))
      • Set MaxX = (Integer((Max X of Region 000 <gen>)))
      • -------- Set Y --------
      • Set MinY = (Integer((Min Y of Region 000 <gen>)))
      • Set MaxY = (Integer((Max Y of Region 000 <gen>)))
      • -------- Calculate lenght --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxY Less than 0
        • Then - Actions
          • Set MaxY = (MaxY x -1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MinY Less than 0
        • Then - Actions
          • Set MinY = (MinY x -1)
        • Else - Actions
      • Set Lenght = (MaxY + MinY)
      • -------- Calculaye width --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxX Less than 0
        • Then - Actions
          • Set MaxX = (MaxX x -1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MinX Less than 0
        • Then - Actions
          • Set MinX = (MinX x -1)
        • Else - Actions
      • Set Width = (MaxX + MinX)
      • For each (Integer A) from 1 to Lenght, do (Actions)
        • Loop - Actions
          • Set Ytimes = (Ytimes + 1.00)
          • Set PointY = ((Min Y of Region 000 <gen>) + Ytimes)
          • For each (Integer B) from 1 to Width, do (Actions)
            • Loop - Actions
              • Set Xtimes = (Xtimes + 1.00)
              • Set PointX = ((Min X of Region 000 <gen>) + Xtimes)
              • Environment - Create a 0.50 second Permanent crater deformation at (Point(PointX, PointY)) with radius 50.00 and depth 10.00

loop A should calculate Y and then run loop B which will create the crater on the right point's by increasing X by 1 every time loop B runs and creates a new crater on the new X,Y .. then Y increases one and and it should do the same... the only thing it does now is run the correct X worth and not the Y..

so i only get 1 line of lowered ground instead of a whole square.
 

Attachments

  • terrain test.w3x
    14.1 KB · Views: 77
Trigger:
  • Region 000 Deformation
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Environment - Create a 0.01 second Permanent crater deformation at (Center of Region 000 <gen>) with radius 512.00 and depth 256.00


Maybe try this much easier approach ^^?
 
that will create 1 crater...

i am trying to abuse it to create a square form..

at the moment it goes fine around the X-axis but it wont do it for every Y on the Y-axis..
well it only does 1 Y and not the whole Y-axis.

if you look at the map.. i want the lower the whole region down and not only 1 point
 
Ok try this instead:

Trigger:
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set Ytimes = (Ytimes + 50.00)
      • Set PointY = ((Min Y of Region 000 <gen>) + Ytimes)
      • Set Xtimes = 0.00
      • Game - Display to (All players) the text: (String(PointY))
      • For each (Integer B) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set Xtimes = (Xtimes + 50.00)
          • Set PointX = ((Min X of Region 000 <gen>) + Xtimes)
          • Environment - Create a 0.50 second Permanent crater deformation at (Point(PointX, PointY)) with radius 50.00 and depth 512.00
          • Game - Display to (All players) the text: (String(Xtimes))
          • Wait 0.01 seconds


you have to null the Xtimes after the first iteration of Loop B
otherwise (in your trigger when PointY = -511.0) Xtimes would be equal to 512 then 1024 and etc.

you dont need to lower the terrain for every x and y with 10
because of the radius(50 in your case) of the cratter you are making
instead you can lower like in the above 512(128 , 256 whatever you like)
with the difference of the x and y being equal to that of the radius of the cratter


hope this helps abit


Edit:

all this seams very inefficient
you should better do it with the terrain palette
 
yes i know i can better do it with the terrain pallet tools.. but i cant use those in game...

I remade your trigger and it only shows me 1 line lower not the whole region..
checked it twice..

I also found an error in my trigger.. if the minimum X or minimum Y is bigger in a positive number then my max.. i will get negative numbers.. and you cant do something from 1 to -X and count upwards...

also found a way to shorten my code and to fix this problem..

the code i am now using:
Trigger:
  • terrain
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Set Xtimes = (Distance between (Point((Min X of Region 000 <gen>), (Min Y of Region 000 <gen>))) and (Point((Max X of Region 000 <gen>), (Min Y of Region 000 <gen>))))
      • Set Ytimes = (Distance between (Point((Min X of Region 000 <gen>), (Min Y of Region 000 <gen>))) and (Point((Min X of Region 000 <gen>), (Max Y of Region 000 <gen>))))
      • Set Width = (Integer(Xtimes))
      • Set Lenght = (Integer(Ytimes))
      • Set Xtimes = 0.00
      • Set Ytimes = 0.00
      • Set PointY = (Min Y of Region 000 <gen>)
      • Set PointX = (Min X of Region 000 <gen>)
      • For each (Integer A) from 1 to Lenght, do (Actions)
        • Loop - Actions
          • Set Ytimes = (Ytimes + 1.00)
          • Set PointY = ((Min Y of Region 000 <gen>) + Ytimes)
          • Environment - Create a 0.50 second Permanent crater deformation at (Point(PointX, PointY)) with radius 10.00 and depth 10.00
      • For each (Integer A) from 1 to Width, do (Actions)
        • Loop - Actions
          • Set Xtimes = (Xtimes + 1.00)
          • Set PointX = ((Min X of Region 000 <gen>) + Xtimes)
          • Environment - Create a 0.50 second Permanent crater deformation at (Point(PointX, PointY)) with radius 10.00 and depth 10.00


i know i am re-using variable Xtimes and Ytimes but I dint want to create new one's..

this code now gives me the following:
____X
____X
____X
XXXXX

where X is the lowered ground and _ is the ground that still needs to get lowered.

for some reason putting loop A inside loop B (or the other way around) doesnt work.. he will do 1 line.. the horizontal or the vertical one..

so it still doesn't fill the _ and still doesn't work correctly..
 
You can't make the game to run some code that much times that you would've want.

512 * 512 = 262 144 <- really big number so the game gives up running the code thinking(^^) it's in an infinite loop or something.

Try adding a message after your loops and see if it is shown(it wont..).
Not sure but I think this is called a thread crash.?


You could try this
JASS:
This is your region
 ________________
|               |
|               |
|               |
|               | length 512
|               |
|               |
|_______________|
       width 512

you can divide it to 64 (8 * 8) smaller squares with 64 width and 64 length ofc.
 _______________
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64  512
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64
|_|_|_|_|_|_|_|_| 64
6464646464646464
         512

You could probably use polar projection to find the each center of those 64 squares and then use the CreateCratter function with radius 64 :/


but still the terrain palette looks more promising
 
but still the terrain palette looks more promising

i cant use that in game

Try adding a message after your loops and see if it is shown(it wont..).
Not sure but I think this is called a thread crash.?

it will just run the outer loop 5 times and the inner loop the amount of time you want it.. so yeah i think your right about the thread crash..

Code:
You could try this
well that works.. hate myself now because i dint thought of that.. thats the most simple way...

now i only need to find the magic math formula behind it so i can use it on bigger squares or even rectangle's :p..
 
Remember that changing the terrain ingame by deformation functions is likely to cause desyncs, so it should only be used in single player maps.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top