ID:141738
 
Code:
This is a snippet from the movement code i use. It works so that if the user is in the field (defined by the var "speed") then it waits 4 seconds before it will allow you to move. at least thats what im hoping its doing XD.
(walking var to stop player holding in the arrow keys defeating the purpose of waiting)
    North()
if(usr.stunned>=1)
return
if(usr.walking==1)
return
if(usr.speed==1)
usr.walking=1
spawn(40)
usr.walking=0
if(cont) step(cont,NORTH)
else..()


And this is the actual field. It works as if you enter it your "speed" var =1, therefor in the movement code, you wait 4 seconds before each step. The "Speed" var with a capital S is in my projectile code and has nothing to do with the movement code. (I know it might get confusing lol)
        dialationfield
icon='field.dmi'
layer=98
Entered(mob/m)
m.speed=1
return
Entered(obj/Bullet/b)
b.Speed = 6
return

Problem description:

Ive been trying to do this for days now. I want it to so if someone fires a gun and its bullet enters the field, the bullet slows down.
Also i want it to if a person enters the field, the person slows down.

Now, i have changed the field code over and over and over, from fors to ifs to enters absolutely everywhere, trying to get it to work. The closest ive gotten is having the bullets slow down but not any mobs.

when i tryed using...
        dialationfield
icon='field.dmi'
layer=98
Entered(atom/moveable)
for(var/mob/m)
m.speed=1
for(var/obj/Bullet/b)
b.speed=6

(or something along those lines, it was a few days ago.) I get runtime errors. i tweaked it a bit and any time a bullet would enter, the mob would slow down to, even if the mob didnt enter the field.

Anyhoo, any help whatso ever would be appreciated.

=P
What is the bullets speed code? If the bullet entered the dilation field (I did not misspell 'dilation', you did), you should make it sleep() between movements, by adding some sleep code into the bullets Move() proc based on it's speed var. For example, you could make it if the bullet entered the dilation field, it's speed would be increased to 6, thus adding a sleep(6) before every Move().
In response to Armiris
Its really more to do with slowing down players(mobs) that im having trouble with. With the bullets its simple as in the projectile code you define the speed of a bullet, so its a simple case of editing that var. However when i try to slow downn players ASWELL as bullets it starts giving me problems.
You cant Enter an Object, and you cant have two Turfs on the same location. What i suggest is having a turf speed variable and a general turf/Enter() proc that if the speed variable is default it immediately ..() and otherwise it implements whatever code it is your trying to accomplish. You can then drop an object on these turfs for visual effect but yeah, thats how i would handle that.
In response to Masterdan
Masterdan wrote:
You cant Enter an Object

Yes you can. It just requires calling /atom/movable.Move(m) where m is an /obj.
This is probably a better way to handle your delay mechanism.
mob
var/locked = 0 //If true, the player can't move. Otherwise,
//they can.

Move()
if(locked)
//If the locked var is true, indicate failure.
return 0

return ..() //If not, pass the parent proc.

proc
Lock(d = 0)
if(locked)
//If the mob is already locked, indicate
//that the proc failed to lock them.
return 0

locked = 1 //Lock the mob.
if(d > 0)
//If the delay is greater than zero, wait
//that amount of time, then unlock them.
spawn(d) Unlock()

return 1 //Indicate that they were locked
//successfully.

Unlock()
if(!locked)
//If they are unlocked, indicate that the
//proc failed to unlock them.
return 0

locked = 0
return 1 //Indicate they were successfully
//unlocked.

turf
var/delay = 0

Entered(mob/m)
if(istype(m) && delay)
//If the thing entering is a mob and the turf
//has a delay, lock them for that amount of
//time.
Lock(delay)

return ..() //Call the parent proc.
In response to Gamer1
Only clients have North, South, East, West, etc. procs. What you want is what Popisfizzy said. It's much easier than using the same system for each client.Direction proc.

Have the speed variable change the delay between movements by.. changing the delay between movements based on the speed. Durh.
In response to Popisfizzy
Thanks very much, its working great =P

Thanks to everyone for replying lol.
Now, onto making some funky icons for visual effect :P

Thanks again =)