ID:169095
 
Can someone tell me how i would go about making a spike trap, like the ones found in the latter Legend of Zelda games on the N64? What i mean is how to make a trap that slides back and forth to given points. If you still don't know what i mean, check out this game:

http://games.byond.com/hub/Unowuero/TheGauntlet

They're the gray things that slide back and forth. Thanks in advance

--Reinhart
Perhaps the step() and bump() procs might be of use.
In response to Sinoflife
well, that half i belive i know. more of the problem is how would i keep it from simply moving past the point i want it to end at, rather than doing what i want it to do and move in the other direction once it reaches the endpoint?
From the looks of it, they probably slide NORTH until movement fails, and then switch direction SOUTH and repeat.

What you could do, as an alternative, is have each spike trap hold a variable of max_y and min_y and then in the map editor you could assign individual instances their own values to max_y and min_y, as well as an initial direction.

Then, say for instance, you could do something like this:

obj
spikeball
var
min_y=1
max_y=8
proc
StartMotion()
while(src)
if(y == min_y)
dir = NORTH
else if(y == max_y)
dir = SOUTH
step(src,dir)
sleep(4)
New()
..()
spawn(1)
StartMotion()


As another alternative, you could set a range variable and a curr_steps variable, and on each step increment the curr_steps and check if it == range.

Hiead (hope I didn't make any confusion or accidental errors)
In response to Hiead
But, saying i use the first example, where you would check if movement fails, how exactly would i CHECK if movement fails?

yeesh. someone should make a demo on this stuff.0.o
In response to Reinhartstar
Reinhartstar wrote:
But, saying i use the first example, where you would check if movement fails, how exactly would i CHECK if movement fails?

yeesh. someone should make a demo on this stuff.0.o

If what Hiead typed was too hard for you try a simpler method.THis method doesn't allow you to set range_max and range_min but it does check for movement distruption.
/obj/spike_ball
{
/obj/spike_ball/proc/Init(null);
/obj/spike_ball/Init(null)
{
while(loc)
{
if(!Move(get_step(src,src.dir),src.dir))src.dir=turn(src.dir,180);
sleep(4);
};
del (src);
};
/obj/spike_ball/New()
{
..()
spawn(world.time/10)Init();
};
};

obj
spiketrap
proc/do_stuff()
walk(src,0)
walk(src,dir)
Bump()
dir=turn(dir,180)
do_stuff()
In response to Ol' Yeller
Ol' Yeller wrote:
 obj
spiketrap
proc/do_stuff()
walk(src,0)
walk(src,dir)
Bump()
dir=turn(dir,180)
do_stuff()


Just one thing. Consider what happens when the spiketrap bumps a mob. A small bug, yet it could cause considerable problems.

Hiead
In response to Reinhartstar
Reinhartstar wrote:
But, saying i use the first example, where you would check if movement fails, how exactly would i CHECK if movement fails?

Look up " . "

Hiead