• 🏆 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!

Help as Environment

Status
Not open for further replies.
Level 4
Joined
Jun 23, 2017
Messages
74
Hello people again =x,

I'm creating a road system for my map where I use "Environment - Change the type of terrain in (Center of Playable Map Area) for Lordaeron Summer - Solo using variation -1 in an area of size 1 and square shape" With a dummy to make my road. Everything is working properly, but this environment trigger sometimes creates the terrain on the side or on top instead of creating in the center of the dummy.
Is this a war3 bug? An error in this trigger? Or is it possible to correct it somehow, and always create it in the middle of the dummy?


This is my trigger for it.
Code:
Set PointUnit = (Position of (Triggering unit))
Set terrainspeed = Lordaeron Summer - Rock
Environment - Change terrain type at PointUnit to terrainspeed using variation -1 in an area of size 1 and shape Square
Custom script:   call RemoveLocation(udg_PointUnit)
(The dummy is also excluded to leave the path free to walk.)
 
Level 21
Joined
Dec 4, 2007
Messages
1,479
Since tiles can only be placed on the static grid of quadrants, approximation of their location will happen when placed in between those fixed points (press g in the editor to highlight the grid in varying sizes).

Also: Are you using a unit that has its collision set to 0? - if so the location will be centered.
I'd still recommend moving it to PointUnit after setting collision to 0 to prevent initial displacement.
 
Last edited:
Level 4
Joined
Jun 23, 2017
Messages
74
Are you using a unit that has its collision set to 0? - if so the location will be centered
Yes I put it in 0 but it still appears in the middle and other times on top / on the side

Since tiles can only be placed on the static grid of quadrants, approximation of their location will happen when placed in between those fixed points
So this must be the problem that happens, when I create the dummy off the grid it moves the terrain created up until grid.

Maybe I should add a grid system on the map and always turn it on when using this road creation?
It could be a way to fix this, right?
Because when the unit is inside this road it she gains Move Speed, and if the terrain does not created in the right place, buga and the Move speed is given outside the road.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Pre-process the unit's position to produce a grid position aligned in the way you want. That way you are not relying on the automatic alignment of the change terrain type action.

This processing is best done with the position X/Y value and real/integer mathematics. For example a basic alignment would be to divide by 128, convert to integer to discard fractional bits and convert back to a real. You could also try rounding to the nearest grid node by adding a 64 offset. Be aware that point 0,0 is the middle of the map so negative positions are possible and negative numbers might have an effect on rounding behaviour.
 
Level 4
Joined
Jun 23, 2017
Messages
74
This processing is best done with the position X/Y value and real/integer mathematics. For example a basic alignment would be to divide by 128, convert to integer to discard fractional bits and convert back to a real.
I have not yet come to this point of fiddling with math, real/integer in the World editor. I'll take a look and see if I can understand anything, there anything that can give me an idea of how to use it?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I'll take a look and see if I can understand anything, there anything that can give me an idea of how to use it?
Integer type in WC3 is a signed (two's complement) 32 bit integer. The real type is a 32 bit IEEE style floating point. Both types are commonly used in practical programming applications so are heavily written about online, including mathematical hacks and shortcuts one can do with them. For this reason there is no much documentation regarding them specifically relating to JASS (what GUI compiles to on map save, and the scripting language used by WC3).

The sort version is that integer stores whole numbers (hence "integer") and real stores numbers with a fractional component (hence "real). Conversion from real to integer works by discarding the fractional part (always round towards 0). There are differences in the numeric range that can be represented, reals can store much larger numbers than integers however they suffer from rounding error (only accurate to a certain number of significant figures).
 
Level 4
Joined
Jun 23, 2017
Messages
74
Thanks for the technical explanation of how it works, I will use this to rationalize to make the triggers. But I'm still lost, how to put this into practice in the trigger, i'm not sure where to start.
I made this variable (REAL)
Code:
Set ExReal = (((Min((X of PointUnit), (Y of PointUnit))) + (Max((X of PointUnit), (Y of PointUnit)))) / 128.00)
But, I could not find a use for this and it must be all wrong :xxd: PointUnit = (Position of (Triggering unit))
I really don't know where to start.
 
Level 21
Joined
Dec 4, 2007
Messages
1,479
I think you would have to start from something like this:

  • defendTileplacement
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (==) (Order(defend))
    • Actions
      • Custom script: set udg_x = GetUnitX(GetTriggerUnit())
      • Game - Display to (All players) the text: (String(x))
      • Custom script: set udg_y = GetUnitY(GetTriggerUnit())
      • Game - Display to (All players) the text: (String(y))
      • Environment - Change terrain type at (Point(x, y)) to Lordaeron Winter - Snow using variation -1 in an area of size 1 and shape Circle
I store the coordinates of the unit in global variables x and y so that i can alter them.
But i don't know how to prevent unwanted tile displacement. How can we decipher when the placement is unwanted?

Maybe it's easier for you to simply make 2 abilities, place road/clear road?
 
Level 4
Joined
Jun 23, 2017
Messages
74
I could not do this "(==)" that you did in conditions, and I also could not put it "(Point (x, y))" in this way in the environment, it is necessary to put some number.
I created it even without these details, but it gives error in this "custom script", i tried to add something inside its parentheses, but the error continued
Sorry, I don't understand much about custom script, I only know the one to remove point and region
I'm using a tower like "dummy" to mark "1 square" terrain, here is my code
Code:
Terrain
    Events
        Unit - A unit Finishes construction
    Conditions
        (Unit-type of (Triggering unit)) Equal to Stone road
    Actions
        Set PointUnit = (Position of (Triggering unit))
        Set terrainspeed = Lordaeron Summer - Rock
        Set RegionSpeed = (Region centered at PointUnit with size (100.00, 100.00))
        Unit - Move (Triggering unit) instantly to PointUnit
        Unit - Remove (Triggering unit) from the game
        Environment - Change terrain type at PointUnit to terrainspeed using variation -1 in an area of size 1 and shape Square
        Custom script:   call RemoveLocation(udg_PointUnit)
        Trigger - Run region speed <gen> (ignoring conditions)
Maybe it's easier for you to simply make 2 abilities, place road/clear road?
I'll add clear road. But there is the move speed that adds when you steps on the road (only on top of it), which is working, but buga if the road is pulled to some side.
This is move Speed
Code:
region speed
    Events
    Conditions
    Actions
        Set unitspeed = (Entering unit)
        Trigger - Add to (This trigger) the event (Unit - A unit enters RegionSpeed)
        Unit - Add Speed aura to unitspeed
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Peasant Not equal to (Unit-type of (Leaving unit))
            Then - Actions
                Trigger - Add to (This trigger) the event (Unit - A unit leaves RegionSpeed)
            Else - Actions
                Unit - Remove Speed aura from (Leaving unit)
                Unit - Remove All buffs from (Leaving unit)
        Custom script:   call RemoveRect(udg_RegionSpeed)
(I stayed all day to make this move speed work.) : /
 
Level 4
Joined
Jun 23, 2017
Messages
74
Well, looking at some maps that use integer, for example to give random, I managed to know little of how to handle such an integer, I was able to map a small system of random items that were set in the variables.
But for this specific system, I can not really do it. I set the point X and Y
Code:
Set PointUnit = (Position of (Triggering unit))
Set RealSpeed[0] = (X of PointUnit)
Set RealSpeed[1] = (Y of PointUnit)
(Actually I do not know if it is so, but this is what I could find about X and Y)

And just below I tried this
Code:
Set IntegerSpeed[0] = (((Integer(RealSpeed[0])) + (Integer(RealSpeed[1]))) / 128)
Set IntegerSpeed[1] = IntegerSpeed[0]
Set RealSpeed[2] = (Real(IntegerSpeed[0]))
I tried to use what Dr Super Good said, i tried this and other ways, changing 'integer' and 'real' places (similar), but none of them I have had success

The environment was thus, where the real value is repeated 'RealSpeed' says to be "X", "Y", but putting the real of X and Y I would not be able to use the accounts. But even changing did not work.
Code:
Environment - Change terrain type at (PointUnit offset by (RealSpeed[2], RealSpeed[2])) to terrainspeed using variation -1 in an area of size 1 and shape Square
 
Status
Not open for further replies.
Top