*EDIT (again)*
Ok, so I'm an idiot. I just made a stupid error, so disregard my post.
So, I currently have an arrow key movement system that, in theory, should work, but does not. Thus, I believe I am making some kind of stupid mistake in the triggering .
I currently have four triggers to detect the four different arrows being pressed and then to set a boolean var that stores this info:
The others are modeled after this one...
I have four triggers to detect the release of a key and to store the data into teh respective bool var.
Then I have a trigger run every .1 seconds to order a unit (stored in a global var) to move in a direction based on what keys are being held down.
When I load the map, the unit will not move at all, but the camera will move to the unit as per another trigger (thus I figure that the unit is, in fact, stored properly. Any help as to why this may not work would be greatly appreciated.
I have looked for other movement systems, and have found many, but none that will allow the diagonal movement that I desire. So, if you know of one, you could just point me to that, I suppose.
*EDIT*
So, I found out that one of my functions GetConvertedPlayerId() returns 1-12 rather than 0-11... Thus, I was able to fix that problem; however, now that it works, it only does so partially. When I use the arros, none of them seem to respond except for the Left Arrow, and that moves directly to the right... Once again, any help would be appreciated.
Ok, so I'm an idiot. I just made a stupid error, so disregard my post.
So, I currently have an arrow key movement system that, in theory, should work, but does not. Thus, I believe I am making some kind of stupid mistake in the triggering .
I currently have four triggers to detect the four different arrows being pressed and then to set a boolean var that stores this info:
JASS:
function Trig_mPressLeft_Actions takes nothing returns nothing
set udg_leftPressed[GetConvertedPlayerId(GetTriggerPlayer())] = true
endfunction
//===========================================================================
function InitTrig_mPressLeft takes nothing returns nothing
set gg_trg_mPressLeft = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_mPressLeft, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_mPressLeft, function Trig_mPressLeft_Actions )
endfunction
I have four triggers to detect the release of a key and to store the data into teh respective bool var.
JASS:
function Trig_mReleaseLeft_Actions takes nothing returns nothing
set udg_leftPressed[GetConvertedPlayerId(GetTriggerPlayer())] = false
endfunction
//===========================================================================
function InitTrig_mReleaseLeft takes nothing returns nothing
set gg_trg_mReleaseLeft = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_mReleaseLeft, Player(0), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_mReleaseLeft, function Trig_mReleaseLeft_Actions )
endfunction
Then I have a trigger run every .1 seconds to order a unit (stored in a global var) to move in a direction based on what keys are being held down.
JASS:
function Trig_mMove_Actions takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 9
// move right (both down and up should be unpressed)
if ( udg_rightPressed[i] == true and udg_upPressed[i] == false and udg_downPressed[i] == false ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, 0.00) )
// move up-right (both right and up should be pressed)
elseif ( udg_rightPressed[i] == true and udg_upPressed[i] == true ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(45.00)) )
elseif ( udg_upPressed[i] == true and udg_rightPressed[i] == false and udg_leftPressed[i] == false ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(90.00)) )
elseif ( udg_upPressed[i] == true and udg_leftPressed[i] == true ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(135.00)) )
elseif ( udg_leftPressed[i] == true and udg_upPressed[i] == false and udg_downPressed[i] == false ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(180.00)) )
elseif ( udg_leftPressed[i] == true and udg_downPressed[i] == true ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(225.00)) )
elseif ( udg_downPressed[i] == true and udg_rightPressed[i] == false and udg_leftPressed[i] == false ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(270.00)) )
elseif ( udg_downPressed[i] == true and udg_rightPressed[i] == true ) then
call IssuePointOrderLoc( udg_plyrHero[i], "move", PolarProjectionBJ(GetUnitLoc(udg_plyrHero[i]), 50.00, Deg2Rad(315.00)) )
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_mMove takes nothing returns nothing
set gg_trg_mMove = CreateTrigger( )
call DisableTrigger( gg_trg_mMove )
call TriggerRegisterTimerEventPeriodic( gg_trg_mMove, 0.10 )
call TriggerAddAction( gg_trg_mMove, function Trig_mMove_Actions )
endfunction
When I load the map, the unit will not move at all, but the camera will move to the unit as per another trigger (thus I figure that the unit is, in fact, stored properly. Any help as to why this may not work would be greatly appreciated.
I have looked for other movement systems, and have found many, but none that will allow the diagonal movement that I desire. So, if you know of one, you could just point me to that, I suppose.
*EDIT*
So, I found out that one of my functions GetConvertedPlayerId() returns 1-12 rather than 0-11... Thus, I was able to fix that problem; however, now that it works, it only does so partially. When I use the arros, none of them seem to respond except for the Left Arrow, and that moves directly to the right... Once again, any help would be appreciated.
Last edited: