mob
WILD_Pidgey
icon = 'Pidgey.dmi'
gold = 2
hp = 50
maxhp = 50
player = 0
strength = 5
Expg = 2
level = 2
monster = 1
Pokemon = 1
PK = 1
NPC = 0
New()
. = ..()
spawn()
Wander()
proc/Wander(var/mob/P)
while(src)
if(P in oview(5))
step_towards(src,P)
for(P in oview(1))
break
for(P in oview(2))
break
for(P in oview(3))
break
for(P in oview(4))
break
else
step_rand(src)
sleep(5)
for(P in oview(5))
break
sleep(5)
spawn(5)
Wander()
Bump(mob/M)
if(M.Pokemon == 1)
Fight(M)
else
return
proc/Fight()
for(var/mob/E in get_step(usr,usr.dir))
var/damage = src.strength
E.hp -= damage
E << "<font color = white><font face = 'Comic Sans MS'>[src] attacks you for [damage] damage!!"
src<<"<font color = white><font face = 'Comic Sans MS'>You attack [E] for [damage] damage!!"
UserDcheck(E)
if(src.hp <= 0)
del(src)
sleep(10)
New(src)
spawn()// Right here is the error.
Problem description: After hours of trying to fix my trainers freezing the game, I finally fixed it and thought that maybe npc's were having the same problem so I tried and I fixed them too, now my trainers are working and my npc's move and attack, but what I'm trying to fix now is that im trying to make it so when the npc gets killed it gets deleted from the world and after about 30 seconds it spawns again. Any tips on how to fix this, also I have 1 error that says invalid expression and it takes me to the spot showed above.
DAMNIT
WHY WON'T THIS DIE?!
WHERE DO YOU EVEN GET THIS?
This same goddamn broken piece of crap has been around for literally years, and KEEPS ON COMING BACK. Like a goddamn zombie, no matter how many times we try to kill it, somebody - somewhere - finds it and uses it. The only explanation I can think of is that it's being used in some crappy source code (redundancy all up ins) that people are ripping.
Delete that crappy Wander() proc. This is what it shoul dbe:
All that for(P in oview()) crap is pointless, broken, and error-prone. So get rid of it.
Next, you need to fix Bump(). Bump(mob/M) just says, "when we bump into something, pretend it's a mob". It does not filter out non-mobs, you need to do that yourself. So, you need to do this:
Next, you need to get rid of usr in all your procs. Somehow, you manage to half get it right with Fight(). You pass an argument, like you should, but then in the proc itself you totally ignore it and use usr, which is WRONG. And it's been WRONG for the past five years and yet people STILL KEEP ON USING IT. Remove the for() loop in Fight(), give it an argument (so, Fight(var/mob/M)), and replace E with M.
Also willing to bet good money that you're using usr in UserDcheck(), where it would be - once again - wrong. usr is only valid in verbs, and procs that are only used as verbs (such as Click()).
And, because I'm really tired of people ignoring this advice, show you've made these changes and I'll solve the problem you're describing.