ID:179278
Jan 25 2002, 9:38 am
|
|
given a direction (N,E,S,W) which an icon or player might be facing, how would make a subroutine to move the player forward 1-3 spaces or backward.
|
Jan 25 2002, 9:45 am
|
|
Look up Walk and also make sure you set it in a proc or you will get errors.
|
In response to Super16
|
|
if I want to move a square I can apparently use step, if I want to step backwards (keeping direction the same I hope) I need to identify a target to step away from: I want to step away from the square directly in front of me. i.e.
get_step(M,M.dir) now how do I assign the result to a value to be used as the target in: step_away(Ref,Trg,Max=5) and how would I reference that target once it is found?? |
In response to Illyena
|
|
get_step() returns the location in that direction. Each location is a turf so you'd do it like this:
var/turf/T = get_step(src,dir) step_away(src,T) dir = get_dir(src,T) Of course if you want to use M just replace src with M. |
In response to English
|
|
worked perfectly but if I back into the edge of the board it changes usr.dir to NE, SE, NW, or SW. directions I don't want to exist in the game, is there a way to prevent this from happening??
If they go off the edge of the board they are supposed to die, can I make a barrier at the edgeof the board, create an obstacle so that they will just Bump into it?? So Many little bugs so Much to think about. it seemed so much less complicated as a board game. Illya |
In response to Illyena
|
|
Hmmmm...the only way I can think of to do that would be the long way. You'd have to do something like this:
if(x == 1 && dir == EAST) return if(x == world.maxx && dir == WEST) return if(y == 1 && dir == NORTH) return if(y == world.maxy && dir == SOUTH) return It isn't very pretty but I think it should work. If you want them to die when they try to back off the edge just add your fall() proc or whatever in each of those if statements. [Edit] I just noticed that this will act strangly when your facing the edge of the map because there is no turf to target! I'm not sure how to solve that problem simply. |
In response to English
|
|
what if I added turn around the entire outer edge of a map,
turf mew //map edge west Exit(atom/O) if (O.dir == WEST) usr.FallOffMap() else return mob/proc FallOffMap() usr << "You fell off the map!" var/damage = 10 world << "[usr] has fallen off the map!" usr.hp -= damage usr.DeathCheck() create them for the seperate edges og the map and corners?? I cant get this to work and the effort may be futile but it is the only thouht I had, I will try the method you suggested, I don't mind long, I just want functional :) THANKYOU Illya |
In response to Illyena
|
|
get_step(Ref,Dir) will return a location. If it returns null, then the location is off of the map. At least that's what my pseudo-scientific test program led me to believe.
It may be easier to just put an if check in to make sure your location is not null (whether or not you use get_step()). PS: A turf has a location, but it is not exactly a location itself in program-gibberish. |
In response to ACWraith
|
|
Well I will keep working on it but for now I just expanded the map size and put pits all the way around the edge, the effect is the same :)
Illya |
In response to Illyena
|
|
That might be your best option. The only other way that might be ok is to use imbedded ifs to figure out the opposite direction and have the player step in that direction, then face their original direction.
var/initial_dir = dir back_dir = get_opposite() if(!get_step(src,back_dir)) //sees if it's edge damage(src) //or however you want deal with pits return step(src,back_dir) dir = initial_dir proc get_opposite() if(dir == NORTH) return SOUTH if(dir == SOUTH) return NORTH if(dir == EAST) return WEST if(dir == WEST) return EAST |