ID:148042
 
In My Game, When You Attack And There Are Two Or More Kinds Of Different Enemys, A List Pops Up Asking Which One To Attack! And By The Time You've Chosen, Your Already Half Dead. I Was Wondering If Instead Of It Asking The User Which One To Attack, If It Could Instead Randomly Choose One To Attack, Or Attack The Strongest One. Can Someone Please Help Me, The List Is So Annoying!

Heres My Attack Code:
mob/PC 
HP = 50
Max_HP = 50
strength = 5
exp = 0
gold = 100
weapon
exp_give = 0
house = null
verb
Attack(mob/NPC/M in AtomTypeInRange(src, 1, /mob/NPC)
if(istype(M,/mob/NPC))
var/damage = rand(1,strength)
usr << "You attack [M]!"
usr << "You Do [damage] damage!"
M << "[usr] attacks you!"
M << "[usr] Does [damage] damage!"
M.HP -= damage
M.Death()
That happens because you have to choose inbetween them. Just because I'm in a good mood today, I'm going to post you a better attack verb. =P

obj/sword
icon = 'sword.dmi'


mob/PC/verb/Attack()
var/obj/sword/S = new /obj/sword (get_step(src,src.dir), src)
S.dir = src.dir
for(var/mob/M in S.loc) // for all the mobs in the sword's location...
var/damage = rand(1,src.strength)
src << "You attack [M] for [damage] HP"
M << "[src] attacks you for [damage] HP"
view() << "[src] attacks [M] for [damage] HP"
M.HP -= damage
M.Death()
sleep(3)
del(S)

~~Dragon Lord~~

PS: Please Do Not Capitalize Every Word In Every Sentence You Write. It Is Annoying Like This. ~_~

PPS: If you dont like this, here is a randomly attacking thing that doesnt pop up a list.

Attack()
for(var/NPC/N in AtomTypeInRange(src, 1, /mob/NPC))
N = pick(N)
var/damage = rand(1,strength)
usr << "You attack [M]!"
usr << "You Do [damage] damage!"
M << "[usr] attacks you!"
M << "[usr] Does [damage] damage!"
M.HP -= damage
M.Death()

PPPS: Just tell me if it doesnt work, anybody, because I'm not sure. =/


PPPPS: Sorry for the PS's. =/
In response to Unknown Person
Annoying Like What?
In response to DarkCampainger
Like how you capitalize every word in a sentence. Meh, nevermind that. ~_~
mob
verb
Attack()
var/mob/NPC/M=locate() in get_step(usr,usr.dir)
if(M)
//attack stuff here
The only solution is to use something other than a verb. Either use a macro that run an attack proc on the NPC in the step in the direction you're facing:

<code>client/Center() var/mob/target = get_step(mob, mob.dir) mob.Attack(target)</code>

Or make it so when you bump a mob, you attack it.

<code>mob/Bump(mob/M) if(istype(M, /mob/NPC)) src.Attack(M)</code>

In response to Foomer
The Second One Doesn't Work :(
In response to DarkCampainger
Are you sure the mobs you're attacking are /mob/NPC mobs? If not, adjust that code to suit.