ID:1104861
 
(See the best response by NNAAAAHH.)
Code:


Problem description: How can be maked a push people system? I searched here in byond about push people but i didn't find anithing, i will explain it more, if a player looks to another player and move to he if Player 1 are on 1,y,z and Player 2 are on 2,y,z and Player 1 moves up and pushes Player 2 from 2,y,z to 3,y,z

Look into Bump() and step() in the reference.
Best response
ok NNAAAAHH answer is very good, but in this demo you move the enemy with verb, how i get push the enemy only walking to he?
mob
Move(mob/enemy/e) //I know this is bad because i tried it.
src.PushEnemy(e, 1, 4)
mob
Bump(mob/M)
if(M.client)
step_away(M,usr)


Assuming you only want to push players away.

EDIT: My version above is not ideal since it just makes the person step away from the user in almost any direction.

mob
Bump(mob/M)
if(M.client)
step(M,usr.dir)


This one is better if you're looking for Cow RP style pushing.
Ok if someone more need the code for push is this.
mob
// Note that in this method we will move the enemy by pixels. That way
// we don't get a choppy push animation. You can call this method
// Rasengan or something cool like that (I just call it the PushEnemy function.
// Use your imagination though!
// mob/enemy/e is the enemy in question
// tileOffset is the amount of tiles you want to push the enemy
// pixelOffset is the amount of pixels you want to move the enemy by to reach
// its tile goal.
proc/PushEnemy(mob/e, tileOffset, pixelOffset)
var/static/step = 0 // How far we have moved (not in pixels).
var/static/pixel_step = 0 // How far we have moved in pixels.

pixel_step += pixelOffset // Update the amount of pixel movement.

// Here you should check the tile offset. If we only want to move the player
// by 1 tile then this is pretty pointless. If we want to move the player
// more than 1 tile, then we'll have something really interesting going on.
if (tileOffset == 1)
step++
else if(32 - pixel_step <= 0)
step++
pixel_step = 0

// Here we'll just wait 1/10 of a second before we call the function again. Also,
// we base the movement of the enemy from our direction.
spawn(1)
if (step != tileOffset)
switch (src.dir)
if (NORTH)
e.pixel_y += pixelOffset
if (SOUTH)
e.pixel_y -= pixelOffset
if (EAST)
e.pixel_x += pixelOffset
if (WEST)
e.pixel_x -= pixelOffset
PushEnemy(e, tileOffset, pixelOffset)
else
switch (src.dir)
if (NORTH)
e.loc = locate(e.loc.x, e.loc.y+step, 1)
if (SOUTH)
e.loc = locate(e.loc.x, e.loc.y-step, 1)
if (EAST)
e.loc = locate(e.loc.x+step, e.loc.y, 1)
if (WEST)
e.loc = locate(e.loc.x-step, e.loc.y, 1)

// We want to reset these variables. The pixel_x and pixel_y distort the
// location of the character and we want to make sure we set them back to 0.
// Furthermore we want to set step and pixel_step back to 0 since they are
// static variables.
e.pixel_x = 0
e.pixel_y = 0
step = 0
pixel_step = 0


// Yea, I know, you can resengan yourself... should be an easy fix right?
mob
Bump(mob/e)
// Here we will move the enemy 2 tiles at a rate of 4 pixels per 1/10 seconds.
src.PushEnemy(e, 1, 4)

Real code owner : Goten84, PushTechniqueDemo