ID:151111
 
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()

On 4/15/01 3:35 am Haroki wrote:
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()

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)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;w orld << "Didn't see anything." // DEBUG
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s pawn(think_delay) AILoop()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r eturn
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;if(M.dead)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world << "Saw [M] but it's dead." // DEBUG
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spawn(think _delay) AILoop()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r eturn
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;if(get_dist(src,M) > 1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp; world << "Stepping toward [M]." // DEBUG
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s tep_towards(src,M)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp; &nbsp;world << "Attacking [M]." // DEBUG
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f lick("attack",src)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;M .Damage(5)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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.
In response to Deadron
On 4/15/01 9:20 am Deadron wrote:
On 4/15/01 3:35 am Haroki wrote:
could someone tell me whats wrong with this?the animal wont move or attack when a mob comes into view.mob/wolf

i found the problem. It was trying to attack other wolves,so i changed this part

proc/AILoop()
var/mob/M
for(M in view(src)) break

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:
On 4/15/01 3:35 am Haroki wrote:
could someone tell me whats wrong with this?the animal wont move or attack when a mob comes into view.mob/wolf

i found the problem. It was trying to attack other wolves,so i changed this part

proc/AILoop()
var/mob/M
for(M in view(src)) break

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


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.