PDA

View Full Version : Script Link's movement



idontknow
08-20-2006, 03:38 PM
Would it be possible to have scripted movement for Link? In other words, you could have it so that when Link steps on a certain part of the screen, he takes moves according to whatever the script states about Link's movement. This would be great for cutscenes, or moving platforms where Link steps onto something & then the script makes it so Link automatically moves in the direction of the platform, until reaching a certain point when he can resume movement.

jman2050
08-20-2006, 03:45 PM
Considering that you can affect Link's X/Y position directly, yes.

ShadowTiger
08-20-2006, 04:04 PM
Considering that you can affect Link's X/Y position directly, yes.


I just spent three minutes wracking my brain trying to figure out how, from what I know. Care to elaborate, Mr. Freeform Scripting? :blah: lol thank you. It'd be cool to have a boss who can slam you into a wall telekinetically. :p

jman2050
08-20-2006, 04:45 PM
Um...

SETV lx,50
SETV ly,50

Set's Link's position to 50,50. You can manipulate Link's position, like I said.

The_Amaster
08-20-2006, 05:47 PM
Yeah, but would that just warp him there, or would you see him moving there?

_L_
08-21-2006, 12:16 AM
If you want Link to be pushed downwards to y position 110, just do something like:



WAIT WAITFRAME
ADDV ly,1; move Link down by 1 pixel
COMPAREV ly,110; if Link is not at y position 110,
GOTOLESS WAIT; repeat.

Then he'd move downwards.
Thing is, the above implementation is "conveyor-belt" style movement - the player can still move left and right, and pressing up makes Link resist the forced movement.

If you want to prevent Link from moving left and right, you'll need something like this:


SETR d0,lx; store Link's current x position
WAIT WAITFRAME
ADDV ly,1
SETR lx,d0; reset Link's x position in case the player moved him
COMPAREV ly,110
GOTOLESS WAIT


If you want Link to be unable to resist the y movement by pressing up (or hasten it by pressing down) then:


SETR d0,ly; store Link's y position.
WAIT WAITFRAME
ADDV d0,1; increment the variable containing the y position
SETR ly,d0; explicitly place Link at the y position we want him to be at
COMPAREV ly,110
GOTOLESS WAIT


I leave the combination of both of the latter scripts as an exercise for the reader!

*b*
08-22-2006, 05:59 PM
I have yet to touch the scripting, but it seems to me that would make Link just move, and not really walk? Or does that happen automatically? Also, would he move at the same speed as if the player is controlling him?

Dark Nation
08-22-2006, 08:08 PM
how about:


SET controlsenabled,0
WAIT WAITFRAME
ADDV ly,1; move Link down by 1 pixel
COMPAREV ly,110; if Link is not at y position 110,
GOTOLESS WAIT; repeat.
SET controlsenabled,1

The controlsenabled variable isn't programmed in yet, but is this something that people would want?

Mario's Hat
08-22-2006, 10:20 PM
The problem with that is that it wouldn't play the walking animation - it wouldn't behave as if you, the player had pressed the key

jman2050
08-22-2006, 11:09 PM
Then why don't we add a command that does press a key. Say... PRESSV and PRESSR, where the argument is a bitmask used to determine the pressing of A,B, and the direction keys. And while we're at it, why not use GETPRESS, which gets a bitmask representing the buttons that the player has pressed (both 'pressed' and 'held')

Dark Nation
08-23-2006, 08:52 AM
For instance,


SETV inputsenabled,0
SETV d0,60
SETV forcedright,1
HERE WAITFRAME
SUBV d0,1
COMPAREV d0,0
GOTOMORE HERE
SETV inputsenabled,1
QUIT

would cause Link to walk to the right 5 tiles (there's 12 steps between tiles) and the player couldn't do anything about it. (nam)

_L_
08-23-2006, 09:12 AM
Instead of a "forcedright" variable, how about "leftbutton" and "rightbutton" variables that are TRUE if the player is pressing that button, but can be SETV TRUE by the script?



WAIT WAITFRAME
SETV leftbutton,0; discard the player's input.
SETV upbutton,0; discard the player's input.
SETV downbutton,0; discard the player's input.
SETV rightbutton,1; make Link walk right.
GOTO WAIT


EDIT: Actually, I think you should just make a variable, "button" which contains a bitfield (is that what it's called?) for each of the buttons.

up = 1
down = 2
left = 4
right = 8
A = 16
B = 32

So then we could just do "SETV button,8" to go east, "SETV button,9" to go northeast, and "SETV button,22" to throw the boomerang southeast (if it was in the A button slot.)