could someone tell me whats wrong with this?the animal wont move or attack when a mob comes into view.mob/wolf
icon = 'wolf.dmi'
health = 40
corpse = /obj/item/corpse/wolf
respawn = /area/wolf
expadd = 10
enemy = 1
var/think_delay = 10
New()
..()
spawn(rand(1,think_delay)) AILoop()
proc/AILoop()
var/mob/M
for(M in view(src)) break
if(!M)
spawn(think_delay) AILoop()
return
if(M.dead)
spawn(think_delay) AILoop()
return
if(get_dist(src,M) > 1)
step_towards(src,M)
else
flick("attack",src)
M.Damage(5)
spawn(think_delay) AILoop()
ID:151111
Apr 15 2001, 12:35 am
|
|
In response to Deadron
|
|
On 4/15/01 9:20 am Deadron wrote:
On 4/15/01 3:35 am Haroki wrote: i found the problem. It was trying to attack other wolves,so i changed this part proc/AILoop() proc/AILoop() var/mob/player/M for(M in view(src)) break and made this the default mob world mob = /mob/player yet it still does't see the mob/player when it comes into view |
In response to Haroki
|
|
On 4/15/01 4:55 pm Haroki wrote:
On 4/15/01 9:20 am Deadron wrote: I'd need to see the game to debug it. If you want to zip it up and send it to me at [email protected], I'll take a look. |
In response to Deadron
|
|
I'd need to see the game to debug it. If you want to zip it up and send it to me at [email protected], I'll take a look. ok i just sent it. I hope you got it. |
I don't see anything directly wrong with the code...so what I would do is put in some debugging statements to see what's happening, like this:
& amp;nbsp; New()
& amp;nbsp; & amp;nbsp; ..()
& amp;nbsp; & amp;nbsp; spawn(rand(1,think_de lay)) AILoop()
proc/ AILoop()
&;nbsp; var/ mob/M
& amp;nbsp; & amp;nbsp; for(M in view(src)) break
& amp;nbsp; & amp;nbsp; if(!M)
& amp;nbsp; & amp;nbsp; & amp;nbsp; w orld << "Didn't see anything." // DEBUG
& amp;nbsp; & amp;nbsp; & amp;nbsp; s pawn(think_delay) AILoop()
& amp;nbsp; & amp;nbsp; & amp;nbsp; r eturn
& amp;nbsp; & amp;nbsp; if(M.dead)
& amp;nbsp; & amp;nbsp; & amp;nbsp; world << "Saw [M] but it's dead." // DEBUG
& amp;nbsp; & amp;nbsp; & amp;nbsp; spawn(think _delay) AILoop()
& amp;nbsp; & amp;nbsp; & amp;nbsp; r eturn
& amp;nbsp; & amp;nbsp; if(get_dist(src,M) > 1)
& amp;nbsp; & amp;nbsp; & amp;nbsp; world << "Stepping toward [M]." // DEBUG
& amp;nbsp; & amp;nbsp; & amp;nbsp; s tep_towards(src,M)
& amp;nbsp; & amp;nbsp; else
& amp;nbsp; & amp;nbsp; & amp;nbsp; world << "Attacking [M]." // DEBUG
& amp;nbsp; & amp;nbsp; & amp;nbsp; f lick("attack",src)
& amp;nbsp; & amp;nbsp; & amp;nbsp; M .Damage(5)
& amp;nbsp; & amp;nbsp; & amp;nbsp; s pawn(think_delay) AILoop()
This kind of debugging is a major way to deal with code that isn't working. You'll find yourself doing it a lot.