mob/npc/attackers /*this will only effect the mobs defined as mob/npc/"name"*/
var
think_delay = 10 /*this is a default think delay*/
New()
..()
spawn(rand(1,think_delay)) AILoop()
proc/AILoop()
var/mob/M /*this monster attacks mobs only*/
for(M as mob in oview(src)) break /*this is done to the mob closest*/
if(!M)
spawn(think_delay) AILoop()
return
if(get_dist(src,M) > 1)
step_towards(src,M)
spawn(think_delay) AILoop() /*this means, that if the opponent is more then a block away, the mob will walk toward him*/
else
if(M.monster==0)
M.PlayerDeath()
M.Health -= 3*Attack /*again, this just takes hp from the opponent*/
s_damage(M,3*Attack,"white")
Exp+=M.expvalue
spawn() DeathCheck() /*again this insures that the deathcheck proc is in effect*/
spawn(think_delay) AILoop() /*this means that the mob will wait its think_delay until attacking again*/
spawn() DeathCheck()
else
this is the code I have. They won't attack anything, unfortunantly
ID:149252
Jun 9 2002, 9:50 am (Edited on Jun 9 2002, 5:08 pm)
|
|
In response to ShadowWolf
|
|
That code didn't work :(
|
In response to Buzzyboy
|
|
Then edit your code yourself. He said he wouldn't do it for you.
|
In response to Buzzyboy
|
|
Dude, I just copied your code and added my world statements.
If you're having compiler errors, post them up here WITHOUT my edits. |
Here's what you're going to do:
Add world outputs so that you can see exactly what it's thinking, and make sure vars are the same. Do things like this:
..
var/mob/M
world << "I am running the AILoop() proc!"
for(M as mob in oview(src)) break /
world << "I got [M] as a target"
What that will do is allow you to put the monster in different situations and see how it reacts. Things like objects and even turfs ( i found ) can interfere with advanced AI's! This will allow you to compinsate and know how it will react.
..
if(!M)
world << "Target is gone, trying to find another."
spawn(think_delay) AILoop()
˙˙return
˙if(get_dist(src,M) > 1)
world << "I am moving towards my target [M]."
step_towards(src,M)
˙˙spawn(think_delay) AILoop()
else
world << "Target [M] is close enough!"
˙if(M.monster==0)
world << "M.Moster value: [M.moster]"
world << "I am going to annihilate this guy!"
˙˙M.PlayerDeath()
˙˙M.Health -= 3*Attack ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ ˙˙s_damage(M,3*Attack,"white")
˙˙˙˙˙Exp+=M.expvalue
˙˙˙˙˙spawn() DeathCheck()
˙˙˙˙˙spawn(think_delay) AILoop()
˙˙˙˙˙spawn() DeathCheck()
else
world << "Not a valid or verifiable target!"
Now create you and 1 enemy and see what it does. You may also want to echo things like think_delay to yourself to make sure the values are right, and make echoes for other procs that you may not have fully tested.
By the way, this is the best way to debug anything in BYOND because you can see exactly where things are going wrong and echo anything you want back.
For my game, I actually am making a debugging statpanel where I can see the outside variable values :-)
this will allow you to see how it's reacting to the target.