ID:179659
 
How would i make it so the monster has to be next to the usr for it to attack
mob/Monsters
typechar = "monster"
var
walkspeed
warspeed
New()
checkarea()
proc
checkarea()
monsterattack(mob/M in oview(1))
var/damage=5for(var/mob/M in oview(6))
if(M.typechar == "normal")
walk_to(src,M,0,warspeed)
monsterattack(M)
spawn(5)
checkarea()

M.Health -= damage
if(M.Health<=0)
M.loc=locate("Bob")
it is this part that confuses me
for(var/mob/M in oview(6))
if(M.typechar == "normal")
walk_to(src,M,0,warspeed)
monsterattack(M)
spawn(5)
checkarea()
when i put oview(1)the wlk around aimlesly and until they get to me by luck they attack and i want them to walk towards me directly then get to attack when they are next to me
So can someone please help
Thanks
instead of oview, try view. I dont know why this might help but i usally do view.


-Rcet
I just spotted the problem (i think)

I think i fixed it:

mob/monsters
typechar = "monster"
var
walkspeed
warspeed
New()
checkarea()
proc
wander()
walk_rand(src,walkspeed)
checkarea()
for(var/mob/M in oview(4))
if(M == null)
return 0
if(M.typechar == "normal")
walk_to(src,M,0,warspeed)
monsterattack()
spawn(30)
checkarea()
monsterattack(mob/M in oview(1))
if(M == null)
return 0
if(src.attack - M.defense > 0)
M.hp -= src.attack - M.defense
M.DeathCheck()
else
M << "[src.name] cannot hurt you, dont be alarmed!!"


you had it all mixed around 8) try that and see if it works.


-Rcet
In response to Rcet
It works but they sort of dont attack and i took out the if(null) stuff and i got a very big runtime error
here it is
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
runtime error: Cannot read null.Health.
proc name: monsterattack (/mob/Monsters/proc/monsterattack)
In response to Greg
thats what if null is there for DOH!