ID:1344103
 
(See the best response by Rushnut.)
Basically, I've successfully created an AI system where a Zombie mob chases and attacks players, but I need help going more indepth. I created a door obj that players can open and close to get into a house where they can hide, Although, I need an AI function where the Zombies break down the door, but only if someone is hiding behind it. I've already tried making something like this but it failed do to my inexperience. Can someone please help? It would be much appreciated.

PS, you can't see through the door so it would make sense that the zombie would only break down the door if it knows that a player is hiding behind it.
Using step() to move the zombie towards its target, you can make it so that if it Bump()s into a obj/door, it sets the door to its new target. Then once the door is destroyed it'll look inside for a new target to chase and if they're long gone, give up and go eat a duck or something i dunno.
Hmmm, could you possibly write some example code for me please?
Sure give me two minutes to help someone else with something.
Okay no problem, thank you.
100% untested but the logic is there. Also not commented nearly enough but if you have questions on anything I'm here to halp.

world
mob = /mob/player
atom
var
attackable = 0 //This will decide whether or not I can attack this thing
health = 0 //Defining health here just to make things easier, you can define it on your objs and whatnot
proc
deathCheck()
if(health <= 0)
del(src)
obj
door
attackable = 1 //Doors can be attacked
health = 15
mob
player
attackable = 1
health = 10
chompy
health = 50
var
atom
target = null //This will refrence whatever the chompy wants to chompychomp chomp
proc
getTarget()
for(var/mob/player/M in view(src,5)) //Because getTarget only loops mob/players, it won't randomly aggro a door
if(M)
target = M
return 1
return 0
ai()
set background = 1
while(src)
if(target || getTarget())
step(src,get_dir(src,target)) //This will walk the zombie towards whatever target it has
sleep(5)
continue
step_rand(src)
sleep(10)
continue
Bump(atom/A) //When we boop something
..()
if(A.attackable) //If what we booped was attackable (I.e a door or a player)
if(A != target) //If it wasn't what we targetted (we can only target players, so if we boop something that is attackable, but not a player, it's most likely a door, or another player)
target = A //Our new target should be the boop-ee
if(target)
A.health -= 1
A.deathCheck()
New()
..()
spawn ai()
Awesome, I'm on my phone right now. When I get home I'll attempt to adapt that with my code. Thanks again.
Works great! Just tested it, ran behind a door and it worked. Thank you very much.
Best response
No problem it's what I'm here for, although getting a vote would be nice (Right hand side of the screen on my post)