Code:
attack(mob/enemy/M as mob in oview(1))
var/tmp
damage
if(!M) return
if(atk < M.def) damage = 0
else
damage = ((atk + rand(0,luck)) - M.def)
src << "You did [damage] damage to [M]!"
M.hp -= damage
M.DeathCheck()
ID:145434
Mar 21 2006, 2:40 pm
|
|
Okay, I have a very simple attacking code here, but when I use it a box pops up asking which enemy I want to attack. I want it to attack all the enemies within 1 square. How do I do this?
Code: attack(mob/enemy/M as mob in oview(1)) |
mob |
In response to Sniper Joe
|
|
Alright! Everything's perfect. Thank you.
|
In response to Hovercraft
|
|
Or ofcourse, you can just use get_step(usr, usr.dir) in a for() loop. This'll attack all mobs you're facing.
|
The way you HAD it, it asked you which mob you want to attack. When you use for(), it loops through all of the specified types and performs the following functions accordingly.
I only fixed what you said because I am in a hurry so I am not sure if anything else is wrong.