module Cmd def cmd_attack(args) args = args.split(" ") args.each do |x| x.downcase end place = get_object(location) if place.characters.size < 2 sendto("They are not here.") else place.characters(id).each do |x| case x.name when args[0].proper_name atk_r = rand(20)+1 def_r = rand(20)+1 dam_r = rand(6)+1 case args[1] when 'head' atk_r -= 4 dam_r += 2 target = 'head' when 'body' atk_r += 0 dam_r -= 0 target = 'body' when 'legs' atk_r -= 2 dam_r += 1 rand(100)>49? target='left leg' : target='right leg' when 'arms' atk_r += 2 dam_r -= 1 rand(100)>49? target='left arm' : target='right arm' else atk_r += 0 dam_r -= 0 target = 'body' end case self.attributes['stance'] when 'relaxed' atk_r += 0 dam_r += 0 when 'defensive' atk_r -= 2 dam_r -= 0 when 'evasive' atk_r -= 0 dam_r -= 2 when 'offensive' atk_r += 2 dam_r += 2 else sendto("There has been a serious bug, please report it.") end case x.attributes['stance'] when 'relaxed' def_r += 0 when 'defensive' def_r += 2 when 'evasive' def_r += 2 when 'offensive' def_r -= 2 else add_event(id,x.id,:show,"There has been a serious bug, please report it.") end dam_r<=0? dam_r=1 : dam_r+=0 # A little ugly. If dam_r is equal or less than 0 set it to 1 else do nothing. if atk_r > def_r add_event(id,x.id,:show,"#{name} hits you in the #{target} for #{dam_r} damage.") sendto("You hit #{x.name} in the #{target} for #{dam_r} damage.") x.damage('health',dam_r,x.id) else add_event(id,x.id,:show,"#{name} takes a swing at your #{target} and misses you.") sendto("You take a swing at #{x.name}'s #{target} and miss.") end else sendto("They are not here.") end end end end end