ID:146537
 
Code:HUD ATTACK
mob
proc
Attack2(mob/M in oview(1))
if(istype(M,/mob/monster))
if(usr.attacking == 1)
else
if(M.pk == 0) usr << "There not in PK mode."
else
if(usr.stamina <= 1) usr << "You need to rest."
else
if(usr.flight == 1) usr << "Not while flying!"
else
if(usr.str - M.defense > 0)
var/hit = rand(1,5)
usr.attacking = 1
if(hit == 1)
view() << "<I><font color = blue>[usr] High-kicks [M]"
usr.icon_state = "sparkick"
M.PowerLevel -= usr.str - M.defense
if(hit == 2)
view() << "<I><font color = blue>[usr] Low-kicks [M]"
usr.icon_state = "sparkick"
M.PowerLevel -= usr.str - M.defense
if(hit == 3)
view() << "<I><font color = blue>[usr] High-punches [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 4)
view() << "<I><font color = blue>[usr] Low-punches [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 5)
view() << "<I><font color = blue>[usr] Right Hooks [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 6)
view() << "<I><font color = blue>[usr] Left Hooks [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
M.DeathCheck()
sleep(7)
usr.stamina-=2
usr.attacking = 0
usr.icon_state = ""
if(hit == 7)
view() << "<I><font color = blue>[usr] attacks [M], but failed."
else
view() << "<I><Font color = blue>[usr] bounces off [M]!"
usr.icon_state = "sparpunch"
sleep(7)
usr.icon_state = ""
M.PowerLevel-=1
M.DeathCheck()
if(istype(M,/mob/player))
if(usr.attacking == 1) usr << "<I><font color = blue>You cant attack while attacking, flying or meditating."
else
if(M.pk == 0) usr << "There not PK"
else
if(usr.stamina <= 1) usr << "You need to rest."
else
if(usr.flight == 1) usr << "Not while flying!"
else
if(usr.str - M.defense > 0)
var/hit = rand(1,5)
usr.attacking = 1
if(hit == 1)
view() << "<I><font color = blue>[usr] High-kicks [M]"
usr.icon_state = "sparkick"
M.PowerLevel -= usr.str - M.defense
if(hit == 2)
view() << "<I><font color = blue>[usr] Low-kicks [M]"
usr.icon_state = "sparkick"
M.PowerLevel -= usr.str - M.defense
if(hit == 3)
view() << "<I><font color = blue>[usr] High-punches [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 4)
view() << "<I><font color = blue>[usr] Low-punches [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 5)
view() << "<I><font color = blue>[usr] Right Hooks [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
if(hit == 6)
view() << "<I><font color = blue>[usr] Left Hooks [M]"
usr.icon_state = "sparpunch"
M.PowerLevel -= usr.str - M.defense
M.DeathCheck()
sleep(7)
usr.stamina-=2
usr.attacking = 0
usr.icon_state = ""
if(hit == 7)
view() << "<I><font color = blue>[usr] attacks [M], but fails"
else
view() << "<I><Font color = blue>[usr] doesn't do any damage to [M]!"
usr.icon_state = "sparpunch2"
sleep(7)
usr.icon_state = ""
M.PowerLevel-=1
M.DeathCheck()


Problem description:Im trying to make a hud attack code,when i try the hud the guy just stands there?..down below is the hud code for it.

obj
hud
HUD
layer = MOB_LAYER + 1
icon = 'HUD.dmi'

atk
icon_state = "atk"
Click()
if(usr.poduse == 1)
usr << "Not in spacepod"
if(usr.flight == 1)
usr << "Not while flying"
if(usr.resting == 1)
usr << "Not while resting"
if(usr.HTC == 1)
usr << "Not in the HTC chamber"
if(usr.sparring == 1)
usr << "Not while sparring"
if(usr.z == 9)
usr << "Can't fight here."
else
usr.Attack2()
New(client/C)
screen_loc = "9,1"
C.screen+=src


client/New()
..()
new/obj/hud/HUD/say(src)
new/obj/hud/HUD/worldsay(src)
new/obj/hud/HUD/afk(src)
new/obj/hud/HUD/save(src)
new/obj/hud/HUD/help(src)
new/obj/hud/HUD/rest(src)
new/obj/hud/HUD/med(src)
new/obj/hud/HUD/fly(src)
new/obj/hud/HUD/atk(src)
You aren't saying who to attack in your Click proc. Also, look up switch() in the helpfiles. It'll help you get rid of those if() chains.