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
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top