• 🏆 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] JASS WASD Movement working only for Player(0)

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
Hello when i test this script with two istances of warcraft the player blue unit ( PXHero[1] ) does not move. It plays the walk animation tho. I don't know what to do anymore. Can someone help me

JASS:
globals
 


    boolean array WASD_IsKeyDown_W
    boolean array WASD_IsKeyDown_A
    boolean array WASD_IsKeyDown_S
    boolean array WASD_IsKeyDown_D



    constant oskeytype WASD_KEY_W = ConvertOsKeyType($57)
    constant oskeytype WASD_KEY_A = ConvertOsKeyType($41)
    constant oskeytype WASD_KEY_S = ConvertOsKeyType($53)
    constant oskeytype WASD_KEY_D = ConvertOsKeyType($44)

 

    constant real WASD_MoveDistance = 10.0
 
    real array Fangl 

endglobals

function PlayerMoveEvent_Actions takes nothing returns nothing
    //local integer i = GetPlayerId(GetTriggerPlayer())
    local integer i = GetPlayerId(GetOwningPlayer(  udg_PXHero[GetPlayerId(GetTriggerPlayer())] ))
    local real array dx
    local real array dy
    local real array angle
    local real array angleDEG
    local location array TerrainCheck
    local location array BlockPoint
    //local real array angle

     
   
        set dx[i] = 0.
        set dy[i] = 0.

 

        if WASD_IsKeyDown_W[i] and (not ( WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_D[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i]))  then
            set dy[i] = dy[i] + 1.
     
        elseif WASD_IsKeyDown_S[i] and (not ( WASD_IsKeyDown_W[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_D[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dy[i] = dy[i] - 1.
     
        elseif WASD_IsKeyDown_A[i] and (not ( WASD_IsKeyDown_S[i] or WASD_IsKeyDown_W[i] or WASD_IsKeyDown_D[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dx[i] = dx[i] - 1.
     
        elseif WASD_IsKeyDown_D[i] and (not ( WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_W[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dx[i] = dx[i] + 1.

        elseif WASD_IsKeyDown_W[i] and WASD_IsKeyDown_D[i] and (not ( WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dy[i] = dy[i] + 0.5
            set dx[i] = dx[i] + 0.5
        elseif WASD_IsKeyDown_W[i] and WASD_IsKeyDown_A[i] and (not ( WASD_IsKeyDown_S[i] or WASD_IsKeyDown_D[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dy[i] = dy[i] + 0.5
            set dx[i] = dx[i] - 0.5
        elseif WASD_IsKeyDown_S[i] and WASD_IsKeyDown_D[i] and (not ( WASD_IsKeyDown_W[i] or WASD_IsKeyDown_A[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dy[i] = dy[i] - 0.5
            set dx[i] = dx[i] + 0.5
        elseif WASD_IsKeyDown_S[i] and WASD_IsKeyDown_A[i] and (not ( WASD_IsKeyDown_W[i] or WASD_IsKeyDown_D[i])) and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
            set dy[i] = dy[i] - 0.5
            set dx[i] = dx[i] - 0.5

        endif
       
     
   set angle[i] = Atan2(dy[i], dx[i]) //gives the angle, in radians not degrees

    if WASD_IsKeyDown_W[i] or WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_D[i] and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) then
         
        set udg_Temp_Point_A[i] = Location( (GetUnitX(udg_PXHero[i]) + 100*Cos(angle[i])) ,(GetUnitY(udg_PXHero[i]) + 100*Sin(angle[i])) )
             


       if IsPointWalkable(GetLocationX(udg_Temp_Point_A[i]), GetLocationY(udg_Temp_Point_A[i])) then
           
       
        call SetUnitX(udg_PXHero[i], GetUnitX(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Cos(angle[i]))
        call SetUnitY(udg_PXHero[i], GetUnitY(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Sin(angle[i]))
   
               

        elseif IsTerrainPathable( GetLocationX(udg_Temp_Point_A[i]), GetLocationY(udg_Temp_Point_A[i]), PATHING_TYPE_FLOATABILITY) then
                       
        elseif GetUnitAbilityLevel(udg_PXHero[i], 'A00M') > 0 then

          call SetUnitX(udg_PXHero[i], GetUnitX(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Cos(angle[i]))
          call SetUnitY(udg_PXHero[i], GetUnitY(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Sin(angle[i]))
          call BJDebugMsg(I2S(i))     
                       
           else

          call SetUnitX(udg_PXHero[i], GetUnitX(udg_PXHero[i]))
          call SetUnitY(udg_PXHero[i], GetUnitY(udg_PXHero[i]))
     
        endif

    endif

         
    call RemoveLocation ( udg_Temp_Point_A[i]
   
endfunction

function PlayerKeyEvent_Actions takes nothing returns nothing
    local oskeytype osKeyPressed = BlzGetTriggerPlayerKey() // What key was pressed or released?
    local boolean isKeyDown = BlzGetTriggerPlayerIsKeyDown() // Was the event key pressed or released?
    local integer i=GetPlayerId(GetTriggerPlayer())

    local effect testef 

    //Not used here, but this way we can detect the meta-key.
    local integer metaKeyPressed = BlzGetTriggerPlayerMetaKey()
   
     call DisplayTimedTextToForce( GetPlayersAll(), 1.00, I2S(BlzGetTriggerPlayerMetaKey())  )
 
     //loop
    //exitwhen (i > 24)
    if (osKeyPressed == WASD_KEY_W) then
        set WASD_IsKeyDown_W[i] = isKeyDown
     
    elseif (osKeyPressed == WASD_KEY_A) then
        set WASD_IsKeyDown_A[i] = isKeyDown

    elseif (osKeyPressed == WASD_KEY_S) then
        set WASD_IsKeyDown_S[i] = isKeyDown

    elseif (osKeyPressed == WASD_KEY_D) then
        set WASD_IsKeyDown_D[i] = isKeyDown
    endif


    if isKeyDown and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) and ( isLeftMbDown[i] or not(isLeftMbDown[i])) then
         
           call SetUnitAnimationByIndex (udg_PXHero[i], udg_AnimationIndexArray[i])

           call BlzUnitDisableAbility ( udg_PXHero[i], 'Aatk' , true, false)

           call BJDebugMsg(I2S(i))

       else
         call BlzUnitDisableAbility ( udg_PXHero[i], 'Aatk' , false, false)
         
        if WASD_IsKeyDown_W[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_S[i] or WASD_IsKeyDown_D[i] and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) then
     
            else
           
            call ResetUnitAnimation( udg_PXHero[i] )
           
            endif

    endif   
endfunction

//===========================================================================
function InitTrig_WASD_PlayerKeyEvent_8_direMetakeytest takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
   
    //takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event

    /* metaKey = In order to fire the event the player must press down another key at the same time,
       0 = No additional key required.
       1 = Shift-key required
       2 = Ctrl-key required
       3 = ????
       4 = Alt-key required
       5+ = ????

    */

    loop
 
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 0, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 0, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 0, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 0, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 0, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 0, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 0, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 0, false )// Releases the "D"-key.


    //METAKEY 1 SHIFT


        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 1, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 1, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 1, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 1, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 1, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 1, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 1, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 1, false )// Releases the "D"-key.

    //METAKEY 2 CTRL

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 2, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 2, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 2, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 2, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 2, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 2, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 2, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 2, false )// Releases the "D"-key.

    //MEETAKEY 3 ??

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 3, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 3, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 3, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 3, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 3, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 3, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 3, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 3, false )// Releases the "D"-key.

    //METAKEY 4 ALT

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 4, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 4, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 4, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 4, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 4, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 4, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 4, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 4, false )// Releases the "D"-key.

    //METAKEY 5 ???


        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 5, true ) // Presses the "W"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_W, 5, false )// Releases the "W"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 5, true ) // Presses the "A"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_A, 5, false )// Releases the "A"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 5, true ) // Presses the "S"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_S, 5, false )// Releases the "S"-key.

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 5, true ) // Presses the "D"-key.
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_D, 5, false )// Releases the "D"-key.



 
    set i = i + 1
    exitwhen(i > 24)
    endloop

    call TriggerAddAction( t, function PlayerKeyEvent_Actions )

    //set t = null

    call TimerStart(CreateTimer(), 0.03, true, function PlayerMoveEvent_Actions)

    //set t = CreateTrigger(  )
    //call TriggerRegisterTimerEvent( t, 0.03, true )
    //call TriggerAddAction( t, function PlayerMoveEvent_Actions )

endfunction

Thanks in advance
 
Last edited:
Level 9
Joined
Sep 20, 2015
Messages
385
I edited the code a little. Well basically i thought this trigger worked for all players but the timer actions ( function PlayerMoveEvent_Actions, when the unit PXHero is moved) seems to work only for player red.
I added a walkability check with udg_Temp_Point_A and then if the unit has an ability it can walk on water.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
4,992
  • It only works for one player because you're not actually looping over i... you're setting i = GetPlayerId(GetOwningPlayer( udg_PXHero[GetPlayerId(GetTriggerPlayer())] )) which makes absolutely no sense. There is no triggering player because the event is being run by a timer, so that returns null. GetPlayerId on a null player returns 0, so it's looking at index 0 of udg_PXHero, and then returning the player that owns that unit (and ultimately its player number). Again I refer you to my post in the other thread, where you can see I looped the variable i from 0 to 24 (should have been 23 not 24, though).

  • Your massive if block to set dy and dx is wholly unnecessary. The reason I suggested you do it that way before was that you no longer have to check for any combination of up/down, left/right that need to cancel each other out. If W is held dx goes up by 1, and if S is held dx goes down by 1; if both are held then logically dx stays at 0. Same for A/D.

  • There is no reason to make all of your variables arrays and index them to [i]. dx, dy, angle, angleDEG, TerrainCheck, and BlockPoint can all be non-array variables; these variables are only used in passing and do not store data between timer cycles.

  • This comparison line is super weird: if WASD_IsKeyDown_W[i] or WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_D[i] and (IsKeyDown_SHIFT[i] or not ( IsKeyDown_SHIFT[i])) then. It translates to "one of W, A, S, or D is pressed... and shift is either pressed or not pressed". The shift comparison is useless as P or not P will always return true in binary logic, and instead of checking that at least one key is pressed it would be simpler to check that both dx and dy are not 0: if (dx != 0.) and (dy != 0) then, since that would mean that no motion should be happening.

  • Why are the animations set in the keypress trigger instead of the motion trigger? That doesn't make sense to me.

  • Your pathing check there is wonky; think about how it would proceed. 1) Is the point walkable? 2) If not, is it floatable? 3) If not does the unit have this ability? So if the point is not walkable or floatable but the unit has the ability then it will be able to move there! That's not what you intend. What you need to check is: Is Walkable or (Is floatable and has ability).

  • The else block is useless: there's no reason to set the unit's position = the position it's already in... just don't set it in the first place.

  • Instead of computing the new xy coordinates in each part of your pathability check (or computing them, saving them into a location, and then loading GetLocationX/Y like you have done! holy shit that is inefficient), just do it once and re-use the coordinates (you can overwrite the dx and dy variables simply to save allocating more variables):
    JASS:
    set dx = GetUnitX(udg_PXHero) + udg_WASD_PlayerMoveDistance[i]*Cos(angle)
    set dy = GetUnitY(udg_PXHero) + udg_WASD_PlayerMoveDistance[i]*Sin(angle)
    
    if IsPointWalkable(dx, dy) or (IsTerrainPathable(dx, dy, PATHING_TYPE_FLOATABILITY) and GetUnitAbilityLevel(udg_PXHero[i], 'A00M') > 0) then
      call SetUnitX(udg_PXHero[i], dx)
      call SetUnitY(udg_PXHero[i], dy)
    endif
 
Level 9
Joined
Sep 20, 2015
Messages
385
- I tried to set a loop in the timer actions the reuslts is that the game freezes as soon as the map is loaded.
JASS:
i = GetPlayerId(GetOwningPlayer(  udg_PXHero[GetPlayerId(GetTriggerPlayer())] ))
i know this is silly i just ran out of options and i was tired.


- Well from my tests the problem is in how the trigger detects the keys. With this

JASS:
         if WASD_IsKeyDown_W[i] then
            set dy = dy + 1.
        elseif WASD_IsKeyDown_S[i] then
            set dy = dy - 1.
        elseif WASD_IsKeyDown_A[i] then
            set dy = dx + 1.
        elseif WASD_IsKeyDown_D[i] then
            set dy = dx - 1.
        endif

it detects only one key at a time and the unit cannot move in diagonal directions.
Probably i didn't understood completely what you mean so if you don't mind to explain in a more simple way.

- I know i just wanted to see if there were some differences

- I added the comparison with shift because if i don't and i press shift the unit stops moving and there are some wierd interacions. The comparison is to allow the sprint effect in the other trigger.

- Well the loop is every 0.03 seconds and and the animations last more.

- I will change that thanks for the tips

- That was to keep the unit in the same position, but you are right it doesnt make sense.

- I will try this thank you.


But the main problem is the loop. If i create a loop in PlayerMoveEvent function the fps drops istantly and the game freezes on map start.
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
The direction stuff will be fixed by using separate if blocks instead of elseifs

if w then
...
elseif a then
..
elseif s then
..
elseif d then
..
endif


Becomes:
if w then
...
endif
if a then
..
endif
if s then
..
endif
if d then
..
endif
 
Level 9
Joined
Sep 20, 2015
Messages
385
It works. But the walkability does not.

JASS:
function PlayerMoveEvent_Actions takes nothing returns nothing
    local integer i = 0 
   
    local real  dx
    local real  dy
    local real  angle
    local real array angleDEG


        loop
   
     
        set dx = 0.
        set dy = 0.

   

        if WASD_IsKeyDown_W[i]  then
            set dy = dy + 1.
          endif
        if WASD_IsKeyDown_S[i]  then
            set dy = dy - 1.
        endif   
        if WASD_IsKeyDown_A[i]   then
            set dx = dx - 1.
        endif
        if WASD_IsKeyDown_D[i]  then
            set dx = dx + 1.
    endif   
       
       
        set angle = Atan2(dy, dx) //gives the angle, in radians not degrees 
       

 

    if WASD_IsKeyDown_W[i] or WASD_IsKeyDown_S[i] or WASD_IsKeyDown_A[i] or WASD_IsKeyDown_D[i]  then
         

                          //call BJDebugMsg(I2S(i))       
 
          set dx = GetUnitX(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Cos(angle)
      set dy = GetUnitY(udg_PXHero[i]) + udg_WASD_PlayerMoveDistance[i]*Sin(angle)

    if IsPointWalkable(dx, dy) or (IsTerrainPathable(dx, dy, PATHING_TYPE_FLOATABILITY) and GetUnitAbilityLevel(udg_PXHero[i], 'A00M') > 0)   then
         call SetUnitX(udg_PXHero[i], dx)
         call SetUnitY(udg_PXHero[i], dy)
   
   
    endif     
       
           
    endif

    exitwhen ( i > 23 )   
    set i = i+1 
   
    endloop

Like this the unit can walk into deep water even if it does not have the ability. Also the point for checking walkability is too close to the unit (becasue udg_WASD_PlayerMoveDistance = 12 by default) , and sometimes it wlaks into trees and buildings.
Also any tips to make the unit collied with enemies units that are not buildings?

Thank you again
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
I guess I would suggest that you project and check two points: udg_WASD_PlayerMoveDistance ahead, and maybe 2-4 times that far ahead. If either of those points aren't walkable or float+ability then don't move the unit. That should probably give you some sort of a buffer:

JASS:
set dx = GetUnitX(udg_PXHero[i])
set dy = GetUnitY(udg_PXHero[i])

set p1x = dx + udg_WASD_PlayerMoveDistance[i]*Cos(angle)
set p1y = dy + udg_WASD_PlayerMoveDistance[i]*Sin(angle)
set p2x = dx + 3*udg_WASD_PlayerMoveDistance[i]*Cos(angle)
set p2y = dy + 3*udg_WASD_PlayerMoveDistance[i]*Sin(angle)

set wwb = GetUnitAbilityLevel(udg_PXHero[i], 'A00M') > 0 //water walk boolean
set p1b = IsPointWalkable(p1x, p2y) or (IsTerrainPathable(p1x, p2y, PATHING_TYPE_FLOATABILITY) and wwb) //point 1 boolean
set p2b = IsPointWalkable(p2x, p2y) or (IsTerrainPathable(p1x, p2y, PATHING_TYPE_FLOATABILITY) and wwb) //point 2 boolean

if p1b and p2b then
   call SetUnitX(udg_PXHero[i], p1x) //move to point 1, point 2 is just for checking
   call SetUnitY(udg_PXHero[i], p1y)
endif
 
Level 9
Joined
Sep 20, 2015
Messages
385
I see thanks. The unit can walk on deep water with out the ability and even if it has the ability it can't walk on it. Something is not working with the boolean checks. But I will try to solve this myself, i don't want to bother you more.

Thanks

Edit: I solved it but there is another problem, i don't know if it is fine to discuss it there since the thread is already solved. But

BfAZgFH.png


That works for the right water lake, for the left the unit can still walk on the deep water. The left pool has ramps in both terrain levels, the other only on one.
I don't really know what to do here, those looks the same, both have a purple non walkable area below them..
 
Last edited:
Status
Not open for further replies.
Top