ID:178041
 
how do i make it so when the usr gets within 1 tile of an obj his/her str gets decreased by one every 2 seconds
for grass you could do someting like this

turf
grass
icon = 'grass.dmi'
Entered()
usr.hp -= 2
sleep(20)
Exited()
usr.hp == usr.hp

something like that... but you have to get it to repeat somehow.

~Aleis~
In response to Aleis
that doesn't help me much
In response to midevilOz
mob/var/onturf = 0

turf/onetileawayturf
Entered(O)
usr.onturf = 1
usr.str += 2
usr.srgiven()
Exited(O)
usr.onturf = 0

mob/proc/strgiven()
if(usr.onturf == 1)
sleep(20)//2 seconds.:/
usr.str += 2
usr.strgiven()
else
..()
In response to Aleis
Aleis wrote:
for grass you could do someting like this

turf
grass
icon = 'grass.dmi'
Entered()
usr.hp -= 2
sleep(20)
Exited()
usr.hp == usr.hp

This is really horrific, for two reasons:

  • NEVER use usr in Entered() or Exited().
  • usr.hp == usr.hp does absolutely nothing because == is a comparison operator. If it was just =, it would still do nothing, because you're only setting the value to itself.

    Lummox JR
In response to ShadowSiientx
ShadowSiientx wrote:
mob/var/onturf = 0

turf/onetileawayturf
Entered(O)
usr.onturf = 1
usr.str += 2
usr.srgiven()
Exited(O)
usr.onturf = 0

Egads, SS, how many times do I have to tell you this? DO NOT use usr in Entered(). In this case, the correct var would be O. You'd have to cast it to a mob first, though, like this:
turf/onetileawayturf
Entered(atom/movable/A)
if(ismob(A))
var/mob/M=A
M.onturf=1
...

mob/proc/strgiven()
if(usr.onturf == 1)
sleep(20)//2 seconds.:/
usr.str += 2
usr.strgiven()
else
..()

This should be src, not usr, because the proc belongs to the mob it's happening to. During the sleep period, usr could change to something else.
Also, you have to use spawn() to call strgiven() again, or else you'll eventually overflow the stack because the same proc keeps calling itself recursively.

Lummox JR
obj/Thingy
proc
Weaken()
for(var/mob/M in oview(1))
M.str -= 2
spawn(20) Weaken()
New()
spawn() Weaken()

I have no idea why everyone else was using Entered and Exited...