Globals needed by the below script. Note that I didn't add in the up/down/right/left globals to any scripts.
Code: Select all
globalVariable, begin
#remap variables
50, board:a
51, board:b
52, board:X
53, board:Y
54, board:up
55, board:down
56, board:left
57, board:right
58, cont:a
59, cont:b
60, cont:X
61, cont:Y
62, cont:up
63, cont:down
64, cont:left
65, cont:right
end
Code: Select all
script, resetControls, begin
cont:A := joy:A
cont:B := joy:B
cont:X := joy:Y
cont:Y := joy:X
board:A := key:x
board:B := key:z
board:X := key:Enter
board:Y := key:rightShift
end
script, waitForAnyKey, begin
while (anyKeyCheck==false) do (specwait)
end
script, waitForNewKey, begin
while (newKeyCheck==false) do (specwait)
end
script, anyKeyCheck, begin
if (keypressA||keypressB||keypressX||keypressY|| keypress(key:up)|| keypress(key:down)|| keypress(key:left)|| keypress(key:right)) then (return (true))
end
script, newKeyCheck, begin
if (newkeypressA||newkeypressB||newkeypressX||newkeypressY|| newkeypress(key:up)|| newkeypress(key:down)|| newkeypress(key:left)|| newkeypress(key:right)) then (return (true))
end
script, keypressA, begin
if (keypress(cont:A) || keypress(board:A)) then (return (true)) else (return (false))
end
script, keypressB, begin
if (keypress(cont:B) || keypress(board:B)) then (return(true)) else (return (false))
end
script, keypressX, begin
if (keypress(cont:X) || keypress(board:X)) then (return(true)) else (return (false))
end
script, keypressY, begin
if (keypress(cont:Y) || keypress(board:Y)) then (return(true)) else (return (false))
end
script, newkeypressA, begin
if (newkeypress(cont:A) || newkeypress(board:A)) then (return (true)) else (return (false))
end
script, newkeypressB, begin
if (newkeypress(cont:B) || newkeypress(board:B)) then (return(true)) else (return (false))
end
script, newkeypressX, begin
if (newkeypress(cont:X) || newkeypress(board:X)) then (return(true)) else (return (false))
end
script, newkeypressY, begin
if (newkeypress(cont:Y) || newkeypress(board:Y)) then (return(true)) else (return (false))
end
script, keyIsPressedA, begin
if (keyIsPressed(cont:A) || keyIsPressed(board:A)) then (return (true)) else (return (false))
end
script, keyIsPressedB, begin
if (keyIsPressed(cont:B) || keyIsPressed(board:B)) then (return(true)) else (return (false))
end
script, keyIsPressedX, begin
if (keyIsPressed(cont:X) || keyIsPressed(board:X)) then (return(true)) else (return (false))
end
script, keyIsPressedY, begin
if (keyIsPressed(cont:Y) || keyIsPressed(board:Y)) then (return(true)) else (return (false))
end
Code: Select all
script, keypressMovement, begin
variable (x,y, who, cur map, var)
if (movementAllowed==false) then (exitScript)
#checks to see if player should stop for npc event
cur map := current map
x := heroX
y := heroY
if (npc at spot (x,y)) then (suspendMovement, usenpcatspot(), specwait, resumemovement)
if(hero is walking(0)==false && hero is walking(1)==false && hero is walking(2)==false && hero is walking(3)==false) then (
set hero speed(me, 1)
#b button, dashing
if (keyIsPressedB) then (
set hero speed(me, 2)
)
)
#a button, use stuff
if (newkeypressA && hero is walking(me) == false) then (
x := hero X + dirX(hero direction)
y := hero Y + dirY(hero direction)
if (NPC at spot (x,y)) then (
if (activatableNPC(NPC at spot (x,y))) then (
usenpcatspot
exit script
)
)
exit script
)
if (newkeypressX) then (
#mm()
opensettingsmenu()
exitscript
)
#arrow keys, move character
if (hero is walking(me) == false) then (
if (key is pressed(up key)&&key is pressed(left key)) then (
if (read wall bit (heroX(me)--1, heroY(me)--1, south wall)==false&&read wall bit (heroX(me)--1, heroY(me)--1, east wall)==false) then (
walk hero(me, north, 1)
walk hero(me, west, 1), exit script
)
)
if (key is pressed(up key)&&key is pressed(right key)) then (
if (read wall bit (heroX(me)+1, heroY(me)--1, south wall)==false&&read wall bit (heroX(me)+1, heroY(me)--1, west wall)==false) then (
walk hero(me, north, 1)
walk hero(me, east, 1), exit script
)
)
if (key is pressed(down key)&&key is pressed(left key)) then (
if (read wall bit (heroX(me)--1, heroY(me)+1, north wall)==false&&read wall bit (heroX(me)--1, heroY(me)+1, east wall)==false) then (
walk hero(me, south, 1)
walk hero(me, west, 1), exit script
)
)
if (key is pressed(down key)&&key is pressed(right key)) then (
if (read wall bit (heroX(me)+1, heroY(me)+1, north wall)==false&&read wall bit (heroX(me)+1, heroY(me)+1, west wall)==false) then (
walk hero(me, south, 1)
walk hero(me, east, 1), exit script
)
)
)
if (hero is walking(me) == false) then (
if (keypress(up key)) then (
x := heroX(me)
y := heroY(me)--1
if (NPC at spot (x,y)) then (
who := npc at spot (x,y)
if (activatableNPC(who) && read NPC (who, NPCstat:activation)==NPCactivation:touch) then (
set hero direction (me, up)
usenpcatspot
)
exit script
)
)
if (keypress(down key)) then (
x := heroX(me)
y := heroY(me)+1
if (NPC at spot (x,y)) then (
who := npc at spot (x,y)
if (activatableNPC(who) && read NPC (who, NPCstat:activation)==NPCactivation:touch) then (
set hero direction (me, down)
usenpcatspot
)
exit script
)
)
if (keypress(left key)) then (
x := heroX(me)--1
y := heroY(me)
if (NPC at spot (x,y)) then (
who := npc at spot (x,y)
if (activatableNPC(who) && read NPC (who, NPCstat:activation)==NPCactivation:touch) then (
set hero direction (me, left)
usenpcatspot
)
exit script
)
)
if (keypress(right key)) then (
x := heroX(me)+1
y := heroY(me)
if (NPC at spot (x,y)) then (
who := npc at spot (x,y)
if (activatableNPC(who) && read NPC (who, NPCstat:activation)==NPCactivation:touch) then (
set hero direction (me, right)
usenpcatspot
)
exit script
)
)
)
if (hero is walking(me) == false) then (
if (key is pressed(up key)) then (walk hero(me, up, 1), exit script)
if (key is pressed(left key)) then (walk hero(me, left, 1), exit script)
if (key is pressed(down key)) then (walk hero(me, down, 1), exit script)
if (key is pressed(right key)) then (walk hero(me, right, 1), exit script)
)
subscript, usenpcatspot, begin
who := (NPC at spot(x,y))
suspendMovement
if (NPC is walking (who) == false) then (
if (read NPC (who,NPCstat:when activated) <> NPCwhenactivated:donotfaceplayer) then (
switch(hero direction(me)) do, (
case (up) do (set NPC direction (who, down))
case (down) do (set NPC direction (who, up))
case (left) do (set NPC direction (who, right))
case (right) do (set NPC direction (who, left))
)
)
use npc (who)
)
resumeMovement
end
end
script, activatableNPC, who, begin
if (read NPC (who,NPCstat:activation) == NPCactivation:use) then (return (true))
end