mob/Monster
Class="Monster" //placing a variable here will effect all types of mobs created under it
var/mob/Target //this variable will only exist for Monsters, and is by default typed as a mob
Red_Nocturne
icon='Heartless.dmi'
icon_state="2"
Munny=5
Exp=5
Level=3
MaxHP=50
MaxMP=75
Str=100 //Str=0, but Mgc=100
Mgc=100
Def=75
New() //this is what happens when a new monster is created
src.HP=src.MaxHP //sets the monsters HP and MP to max
src.MP=src.MaxMP
spawn()
src.Wander() //when calling a proc that loops inside another proc you should ALWAYS spawn it
return ..() //this allows multiple New() procs to be ran on this mob, but make sure its at the end!
proc/Wander() //creates a new proc for Monster type mobs named Wander
while(src) //will loop as long as this mob exists
if(src.Target) //if the monster found a target do this
if(get_dist(src,src.Target)>1 && !step_to(src,src.Target,1)) //if they cant reach their target
src.Target=null;continue //then restart the loop without a target
src.dir=get_dir(src,src.Target) //make them face the target
src.Fight() //makes the monster attack!(coding shown below)
if(!ListCheck(src.Target,oview(5))) //ListCheck is a proc i created! you can find it in the Procedures.dm file
//note: placing a ! before an if means you want the oposite result, in this case if src.Target isnt in oview
src.Target=null //if their target wandered away, then null it out, which sets it to nothing basicaly
sleep(rand(10,15))
else
step_rand(src) //will make the monster randomly walk around
sleep(rand(15,25)) //then wait a random amount of time before taking another action
if(!src.Target) //if this mob doesnt already have a target
for(var/mob/M in oview(5)) //check for any targets within 5 blocks
if(M.key) //if any of the mobs around u are a player, then we'll target them
if(step_to(src,M,1)) //will make sure they can actualy reach the target
//(note: the step_to proc only knows how to check around dense turfs/areas)
src.Target=M //this sets the monsters target to the player it found
sleep(5)
break //as soon as it finds a target it can stop looking
proc/Fight()
for(var/mob/M in get_step(src,src.dir)) //finds any mobs directly in front of the monster
if(M.key)
flick("Attack[src.icon_state]",src)
var/damage=src.Str-M.Def //a simple damage calculation
damage=max(0,damage+rand(-1,1)) //make sure damage isnt negative and varry it a little
M.HP -= damage //subtract the damage off the victim's HP
M.DamageShow(damage,200,0,0) //flashes the damage on the screen
M.DeathCheck(src) //runs the DeathCheck proc on the victim of the attack
//(The DeathCheck proc can be found in the Procedures.dm file)
Problem description:
This is the code I have to get monsters to attack. It's taken directly from RPGStarter, yet for some reason the mobs refuse to attack. It is NOT this code, because this code is the EXACT same as it was before give or take a few variables. What I'd like to know is what the problem could possibly be concerning the rest of the code so I can take a look, go back, and fix it. If you'd like to request any other part of the code to see if that is the problem, I'd be more than happy to oblige.
EDIT: It's not this specific piece of code that's wrong. This code is perfect, flawless. I've checked. So the problem is that either I changed some other part of the code, not this part, so that they don't work well together, or I added code that somehow negates this code. I just need someone to troubleshoot for me, what MIGHT the problems be, so I can go around and check them all.
Also, you are using oview(5) when it should be oview(src,5). Otherwise, it defaults to oview(usr,5), and usr is invalid in procs.