Movement Problems.

ShadowSnipe4

New Member
Reaction score
4
Okay, what the script is supposed to do is make it so that whenever a player preses the up arrow, his unit goes foreward, but if they pres up and left or up and right the unit goes up-left or up-right. As it is now he just keeps going up or turns left or right. Any help?
Code:
function Trig_HeroMovement_Press takes nothing returns nothing
set udg_MoveActive[GetConvertedPlayerId(GetTriggerPlayer())] = true
endfunction

function Trig_HeroMovement_Release takes nothing returns nothing
set udg_MoveActive[GetConvertedPlayerId(GetTriggerPlayer())] = false
endfunction

function Trig_HeroMovement_Actions takes nothing returns nothing
    local integer currentPlayer = 0
    local unit currentUnit = null
    local location currentPosition = null
    local location positionToMoveTo = null
    local real offset = 0.0
    loop
        set currentUnit = udg_MoveUnit[currentPlayer + 1]
        if currentUnit != null and udg_MoveActive[currentPlayer + 1] then
        set currentPosition = GetUnitLoc(currentUnit)
        if udg_MoveActiveLeft[currentPlayer] then
        set offset = 20.0
        elseif udg_MoveActiveRight[currentPlayer] then
        set offset = -20.00
        endif
            set positionToMoveTo = PolarProjectionBJ(currentPosition, 128.0, GetUnitFacing(currentUnit) + offset)
            call RemoveLocation(currentPosition)
            set currentPosition = null
            set currentPosition = null
            call IssuePointOrderLoc(currentUnit, "move", positionToMoveTo)
            call RemoveLocation(positionToMoveTo)
            set positionToMoveTo = null
        endif
        set currentPlayer = currentPlayer + 1
        exitwhen currentPlayer > 9
    endloop
    set currentUnit = null
endfunction


//===========================================================================
function InitTrig_HeroMovement takes nothing returns nothing
    local trigger pressTrigger = CreateTrigger()
    local trigger releaseTrigger = CreateTrigger()
    set gg_trg_HeroMovement = CreateTrigger(  )
    call TriggerAddAction( gg_trg_HeroMovement, function Trig_HeroMovement_Actions )
    call TriggerAddAction( pressTrigger, function Trig_HeroMovement_Press )
    call TriggerAddAction( releaseTrigger, function Trig_HeroMovement_Release )
    call RegisterEventForAllPlayers(pressTrigger, EVENT_PLAYER_ARROW_UP_DOWN)
    call RegisterEventForAllPlayers(releaseTrigger, EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterTimerEventPeriodic(gg_trg_HeroMovement, 0.2)
endfunction
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
GetUnitFacing(currentUnit) + offset

Try to get currentUnit's angle to a variable first, add the offset, and use it the variable in the function call instead. it fixes mine and might fix yours too.
 
H

Heptameron

Guest
Duwenbasden said:
GetUnitFacing(currentUnit) + offset

Try to get currentUnit's angle to a variable first, add the offset, and use it the variable in the function call instead. it fixes mine and might fix yours too.
If that fixes it my faith in all rules of logic will be shattered.
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
Go into your custom maps file and find the blizzard custom maps that came with your game... one that everyone has is called "blizzard grand prix" it is much like mario cart in all that it does... the arrow keys move you, and you can move up and right or up and left and back and right and all the other combo's... check it out in your editor and it should help you fix your problems...

-Dan
 
H

Heptameron

Guest
Dan said:
Go into your custom maps file and find the blizzard custom maps that came with your game... one that everyone has is called "blizzard grand prix" it is much like mario cart in all that it does... the arrow keys move you, and you can move up and right or up and left and back and right and all the other combo's... check it out in your editor and it should help you fix your problems...

-Dan
That's a heck of a lot of work when it already works 98% of the time.
 
General chit-chat
Help Users

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top