How would I go about making "Force Push", and "Force Pull", commands to where if you use Push, you'll push any mob or obj thats density = 1 thats in your direction (like straight ahead of you) move one space that direction.
If anyone can help i'd appreciate it.
~C
ID:169864
Apr 21 2005, 11:29 am
|
|
Apr 21 2005, 12:18 pm
|
|
is that possible?
|
In response to Earth_kai
|
|
Yes, Rcet implaments this in his game Star Wars: Jedi Arena, but once again can someone help me plz..
~C |
Would it be something like:
mob I don't think that will work though.. |
Chwgt wrote:
How would I go about making "Force Push", and "Force Pull", commands to where if you use Push, you'll push any mob or obj thats density = 1 thats in your direction (like straight ahead of you) move one space that direction. mob/player/proc The push() proc pushes both the player and the object ahead one tile each, while the pull() proc moves them behind. |
In response to Wizkidd0123
|
|
Another player or the usr?
|
In response to Chwgt
|
|
mob this will also stop people getting traped in walls and stuff |
In response to Wizkidd0123
|
|
And how would I go about putting this into a verb? (Never did anything like this before so i'm trying to learn).
|
In response to Zmadpeter
|
|
Actually I need it almost identical to the one in this game:
http://www.byond.com/hub/Rcet/StarWarsJediArena |
In response to Chwgt
|
|
Chwgt wrote:
Another player or the usr? src. Please don't say "the usr". usr is a variable; not an object. |
In response to Chwgt
|
|
Chwgt wrote:
And how would I go about putting this into a verb? (Never did anything like this before so i'm trying to learn). mob/player/verb |
In response to Chwgt
|
|
Nope, it won't work, but it's close.
mob First, look for all of the atom/movables instead of objs or mobs, because an atom/movable can be either a mob or an object, since they are both movable types of atoms. Then, in the for() loop, you were looking for all the objects in usr.dir, which means "For each object in NORTH", which makes no sense. The get_step() proc gets a turf one space away from the Reference in the Dir. This is what you want, the turf one tile away from the player, in the direction they are facing. Since get_step() returns a turf, we can stick it right in the for() loop, which now reads: "For every movable atom in the turf in front of the player", which is exactly what you want. Next, I removed the == 1 part from your if() statement, since density can only be true or false, it alone can qualify as a conditional statement, meaning, you don't need anything except the variable in your if() statement to see if it is true or not. The == 1 part is redundant here. Finally, instead of writting 8 different if() statements to check the direction of the player, just step() the object the direction the player is facing, which will always be a step away from the player. Since this is the effect you want, it's perfect, and completes the verb. ~X |
In response to Xooxer
|
|
Question, what would you do to make it do the same thing if its at least 1-4 spaces away.
|
In response to Xooxer
|
|
How would I make it 1: Work as a pull verb, and how would I make the verb work if A is 1-4 spaces away?
|
In response to Chwgt
|
|
mob That's how I would do it. >.> ~X |
In response to Xooxer
|
|
Instead of a get_opposite_dir() proc, it's probably better to use get_dir instead:
If atoms A and B are both on the map, then get_dir(A,B) will return the opposite direction of what get_dir(B,A) returns. You could actually avoid the whole issue by using step_towards() anyway, now that I think about it. Also, why are you checking for if(density == 1)? You should be checking for if(density)! |
In response to Wizkidd0123
|
|
Wizkidd0123 wrote:
Instead of a get_opposite_dir() proc, it's probably better to use get_dir instead: Oh, yeah... duh. I knew there was a simpler way. You could actually avoid the whole issue by using step_towards() anyway, now that I think about it. Meh... >.> Also, why are you checking for if(density == 1)? You should be checking for if(density)! I had his original proc saved in a junk project I use to help people diagnose their code problems. I did mention the if(density) check in my first reply, and corrected it, but I guess it slipped my mind when I went back and rewrote it. Thanks for the tips, Wiz. ~X |
Here's my theory. Untested, so take it or leave it!
mob/verb/push() var turf/curTurf atom/A curTurf = usr.loc for(var/i in 1 to world.view) curTurf = get_step(curTurf, usr.dir) if(curTurf) for(A in curTurf.contents) if(A.density) A.Move(get_step(curTurf, usr.dir) |
In response to Xooxer
|
|
rev_dir(var/Dir) // returns the opposite direction of Dir Xoox, a bit of constructive criticism -- you might find it easier to use turn(dir, 180). |
In response to Gughunter
|
|
Gughunter wrote:
for(var/i in 1 to world.view) Just want to mention that this will cause problems unless world.view is equal to a numerical value (as opposed to a text value) =P. |