mob/Monster/butterfly
icon = 'hellbutterfly.dmi'
icon_state = ""
health = 25
atk = 7
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
var/Found = 0
for(client in oview(5,src))
step_towards(src,client)
Found = 1
break
if(Found != 1)
step_rand(src)
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(client))
Attack(client)
proc/Attack(mob/M)
flick("attack",src)
sleep(2)
var/damage = rand(1,atk)
M.health -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"
Problem description:
So I took this from a library thing I found and it didn't quite work so I started tweaking it a bit and apparently I jacked up the code. Problem is, I'm not quite sure where I screwed it up. It's probably where I replaced his "player" variable with "client", but the player thing wasn't working. Anyway, here's the original code, which works on his game but not mine >_>
mob/var
Found = FALSE
//now its time to make monsters :(....
mob/Monster/Goblin
icon = 'Monsters.dmi'
icon_state = ""
HP = 25
Power = 7// its power
expplus = 7//ow much exp it gives
var/mob/player/P // it is way easyer it type P then to type mob/player all the time :)
New()
. = ..()
spawn()//starts to do the next command
Wander()
proc/Wander()
while(src)//makes sure it is doing it
var/Found = FALSE// flase is the same as 0 and ture means 1, just did diferent for a while XD
for(P in oview(5,src))//if the player is within 5 steps.
step_towards(src,P)//steps towards the player
Found = TRUE
break // makes it so it wont just leave the person it is chasing and go after something else
if(Found != TRUE)
step_rand(src)//steps randomly for a while
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(M,/mob/player))
Attack(M)
proc/Attack(mob/M)
flick("attack",src)//shows the mnster attacking. OPTION :)
sleep(2)
var/damage = rand(1,Power)
M.HP -= damage
view(src) << "[src] attacks [M]!"//tell people who and what got attacked
view(src) << "[damage] damage!"// says how much damage
M.Death()
world
mob = /mob/player
I'm such a failure at AI -_-
This way, all you need to do to add enemies is set their icon, icon state, health, and attack, instead of re-doing the AI procs for every single monster.