Could someone tell me how to make monsters attack you when you get within a certain distance (depending on the monster)
I've sort of got an idea...
Mob
Monsters
var/sight
var/atk
var/def
var/gold
Zombie
sight = 2
atk = 3
def = 2
gold = 200 //So much cause my code drops half your money ;)
Could someone please help?
ID:177133
Oct 27 2002, 1:22 am
|
|
Try experimenting with a procedure that is periodically called through looping that uses the sight variable you declared to find mobs. You probably would like to look up Range() and View() by pressing in F1 and doing a topic search. If you still can't figure it out, Im sure someone (including me) will be glad to help you further.
-Koshigia |
Monster/New()
spawn()
Check()
..()
proc/Check()
for(var/mob/m in oview(src.sight))
if(m.client)
walk_to(src,m,0)
if(get_dist(src,m) <= 1)
Attack(src,m)
spawn(src.sight*10) Check()
proc/Attack(var/mob/attacker,var/mob/defender)
var/dmg = attacker.str - defender.def
if(dmg <= 0)
defender << "[attacker] can not hurt you."
return
else
dmg = rand(1, dmg)
defender << "[attacker] hit you for [dmg]"
defender.hp -= dmg
Death(attacker, defender)
proc/Death(var/mob/attacker, var/mob/defender)
if(defender.hp <= 0)
oview(defender) << "[attacker] killed [defender]"
defender.loc = locate(1,1,1)
defender.gold = defender.gold/2
return
else return
I gave you a basic AI system with attack.