# Author: Craig Smith # # This source code copyright (C) 2009 Craig Smith # All rights reserved. # # Released under the terms of the TeensyMUD Public License # See LICENSE file for additional information. # require 'gettext' require 'combat/attackmsgs' # These are the damage tables. Once it has been determined that damage # has been done. The type of damage of the details are determined by # these charts. Initialize the appropriate chart and use deal() with a # random number from 1-100 # Critical Damage chart class CriticalDamage < AttackMsgs include GetText bindtextdomain("core") logger 'DEBUG' def initialize(attacker, defender, damagetype, hitlocationid, weaponid) @a = attacker @d = defender @damagetype = damagetype @hitlocationid = hitlocationid @weaponid = weaponid super(@a, @d, damagetype, hitlocationid, weaponid) end def deal(roll) roll2 = rand(100)+1 loc = get_object(@hitlocationid).name leg = _("leg") arm = _("arm") head = _("head") hand = _("hand") foot = _("foot") torso = _("torso") case @damagetype when :zombie chanceofinfection = 0 # Zombies use biting for critical attacks case loc when /#{leg}/,/#{arm}/,/#{hand}/ self.msg2a = _("You bite down hard on ^p2's %{loc}!!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 bites down hard on your %{loc}!![/color]" % {:loc => loc}) self.msg2r = _("^p1 bites down hard on ^p2's %{loc}!!" % {:loc => loc}) chanceofinfection = 50 when /#{head}/ self.msg2a = _("You clamp your jaws down on ^p2's neck!!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 bites down your your neck!!![/color]") self.msg2r = _("^p1 bites down on ^p2's neck!!!") chanceofinfection = 100 when /#{torso}/ # TODO: Stunned self.msg2a = _("You ram your head into ^p2's chest!") self.msg2d = _("^p1 rams their head into your chest and knocks the wind out of you!") self.msg2r = _("^p1 rams their head into ^p2's chest!") else self.msg2a = _("You tear at ^p2 causing blood to spray everywhere!") self.msg2d = _("[color Red]^p1 tears at you and blood squirts out across the room![/color]") self.msg2r = _("^p1 tears at ^p2 as blood sprays across the room!") chanceofinfection = 15 end sendmsgs if rand(100) < chanceofinfection @d.add_attribute :infected # Criticals also make the infection spread faster @d.stats[:infection] += (chanceofinfection / 2).to_i end when :biting part = get_object(@hitlocationid) case rand(1) when 1 self.msg2a = _("You rip the skin off of ^p2's %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1's teeth rip the skin and muscle from your %{loc}![/color]" % {:loc => loc}) self.msg2r = _("^p1's teeth take a huge chunk of of ^p2's %{loc}!" % {:loc => loc}) else self.msg2a = _("Blood spews from the newly torn hole in ^p2's %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]Blood squirts from the hole left by ^p1's bite to your %{loc}[/color]" % {:loc => loc}) self.msg2r = _("Blood squirts all over the room from the chewed hole left in ^p2's %{loc}!" % {:loc => loc}) end sendmsgs @d.body.damage(part.id, 5+rand(5)) part.crippled = true when :clawing part = get_object(@hitlocationid) case rand(1) when 1 self.msg2a = _("Your claws almost sever ^p2's %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1's claws almost sever your %{loc}![/color]" % {:loc => loc}) self.msg2r = _("^p1's claws almost sever ^p2's %{loc}!" % {:loc => loc}) else self.msg2a = _("Blood gushes from the huge cut left in ^p2's %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]Blood gushes from the huge cut from ^p1's claws in your %{loc}[/color]" % {:loc => loc}) self.msg2r = _("Blood gushes from the cut left in ^p2's %{loc}!" % {:loc => loc}) end sendmsgs @d.body.damage(part.id, 5+rand(5)) part.crippled = true when :melee case loc when /#{leg}/ leg = get_object(@hitlocationid) if leg.crippled self.msg2a = _("You kick ^p2's crippled %{loc}" % {:loc => loc}) self.msg2d = _("[color Red]^p1 kicks your criplled %{loc} HARD![/color]" % {:loc => loc}) self.msg2r = _("^p1 kicks ^p2 in their already crippled leg.") else self.msg2a = _("You slam down on ^p2's knee with a POP!") self.msg2d = _("[color Red]^p1 crashes down on your knee, shattering it![/color]") self.msg2r = _("^p1 breaks ^p2's knee!") end sendmsgs @d.body.damage(leg.id, 5+rand(5)) leg.crippled = true when /#{head}/ head = get_object(@hitlocationid) if head.crippled self.msg2a = _("You elbow crashes into ^p2's bloody face!") self.msg2d = _("[color Red]^p1 elbows you hard in the face![/color]") self.msg2r = _("^p1 smashes ^p2's face with their elbow") else self.msg2a = _("You beat ^p2's eye closed!") self.msg2d = _("[color Red]^p1 beats your eye closed![/color]") self.msg2a = _("^p1 beats ^p2's eye closed!") end sendmsgs if @d.has_attribute? :zombie or @d.is_a? Zombie @d.body.damage(head.id, 40+rand(5)) else @d.body.damage(head.id, 8+rand(5)) end head.crippled = true when /#{torso}/ torso = get_object(@hitlocationid) self.msg2a = _("You punch them hard in the solar plexes and they crumple to the floor.") self.msg2d = _("[color Red]^p1 punches hard in the solar plexes. You drop to your knees.[/color]") self.msg2r = _("^p1 punches ^p2 in the solar plexes knocking them off their feet.") sendmsgs @d.body.damage(torso.id, 4+rand(4)) @d.add_attribute :stunned when /#{hand}/ hand = get_object(@hitlocationid) if hand.wield weapon = get_object(hand.wield) self.msg2a = _("You knock %{weapon} out of ^p2's %{loc}!" % {:weapon => weapon.name, :loc => loc}) self.msg2d = _("[color Red]^p1 knocks %{weapon} out of your %{loc}!![/color]" % {:weapon => weapon.name, :loc => loc}) self.msg2r = _("^p1 knocks ^p2's %{weapon} out of their %{loc}" % {:weapon => weapon.name, :loc => loc}) sendmsgs room = get_object(@d.location) room.add_contents(hand.wield) hand.wield = nil @d.body.damage(hand.id, 3+rand(3)) else if hand.crippled self.msg2a = _("You knock ^p2's bloody hand to the side.") self.msg2d = _("[color Red]^p1 hits your already bloody %{loc}[/color]" % {:loc => loc}) self.msg2r = _("^p1 hits ^p2's %{loc} HARD" % {:loc => loc}) else self.msg2a = _("When you block ^p2's attack you could hear their %{loc} crack!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 hit your %{loc} so hard it broke![/color]" % {:loc => loc}) self.msg2r = _("^p1 broke ^p2's %{loc}!" % {:loc => loc}) end sendmsgs @d.body.damage(hand.id, 5+rand(5)) hand.crippled = true end else part = get_object(@hitlocationid) if part.crippled self.msg2a = _("You beat on ^p2's crippled %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 crushes your %{loc}![/color]" % {:loc => loc}) self.msg2r = _("^p1 gives ^p2's crippled %{loc} a beat down!" % {:loc => loc}) else self.msg2a = _("You break ^p2's %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 breaks your %{loc}!![/color]" % {:loc => loc}) self.msg2r = _("^p1 breaks ^p2's %{loc}!!" % {:loc => loc}) end sendmsgs @d.body.damage(part.id,5+rand(5)) part.crippled = true end when :piercing weapon = get_object(@weaponid) part = get_object(@hitlocationid) dmg = 5 dmg += 5 if part.crippled dmg += damage_mod case loc when /#{head}/ if @d.has_attribute? :zombie or @d.is_a? Zombie self.msg2a = _("You shove your %{weapon} through ^p2's skull!!" % {:weapon => weapon.name}) self.msg2d = _("[color Red]^p1 shoves %{weapon} through your skull!!![/color]" % {:weapon => weapon.shortname}) self.msg2r = _("^p1 shoves %{weapon} through ^p2's skull!!!" %{:weapon => weapon.shortname}) dmg = @d.get_stat(:maxhp) # Dead else self.msg2a = _("You brutally stab ^p2 in the face with the %{weapon}!!" % {:weapon => weapon.name}) self.msg2d = _("[color Red]^p1 brutally stabs you in the face with %{weapon}!!![/color]" % {:weapon => weapon.shortname}) self.msg2r = _("^p1 brutally stabs ^p2 in the face with %{weapon}!!" % {:weapon => weapon.shortname}) dmg += 2 end when /#{torso}/ self.msg2a = _("You stab ^p2 repeatedly in the chest with the %{weapon}!!" % {:weapon => weapon.name}) self.msg2d = _("[color Red]^p1 stabs you in the chest repeatedly with %{weapon}!!![/color]" % {:weapon => weapon.shortname}) self.msg2r = _("^p1 stabs ^p2 repeated in the chest with %{weapon}!!" % {:weapon => weapon.shortname}) when /#{hand}/, /#{foot}/ dmg -= 3 if part.wield vweapon = get_object(part.wield) self.msg2a = _("You stab ^p2's %{loc} knocking their %{weapon} to the ground." % {:weapon => vweapon.name, :loc => loc}) self.msg2d = _("[color Red]^p1 stabs your %{loc} and knocks your %{weapon} to the ground!!![/color]" % {:weapon => vweapon.name, :loc => loc}) self.msg2r = _("^p1 stabs ^p2's %{loc} and their %{weapon} falls to the ground!" % {:weapon => vweapon.name, :loc => loc}) room = get_object(@d.location) room.add_contents(part.wield) part.wield = nil else self.msg2a = _("You stab ^p2 in their %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 stabs you in your %{loc}!![/color]" % {:loc => loc}) self.msg2r = _("^p1 stabs ^p2 in their %{loc}!!" % {:loc => loc}) end else self.msg2a = _("You stab ^p2 in their %{loc}!" % {:loc => loc}) self.msg2d = _("[color Red]^p1 stabs you in your %{loc}!![/color]" % {:loc => loc}) self.msg2r = _("^p1 stabs ^p2 in their %{loc}!!" % {:loc => loc}) end sendmsgs @d.body.damage(part.id, dmg+rand(6)) part.crippled = true when :slashing weapon = get_object(@weaponid) part = get_object(@hitlocationid) dmg = 5 dmg += 5 if part.crippled dmg += damage_mod case loc when /#{head}/ case rand(2) when 1 # Beheading self.msg2a = _("[color Red]Your %{weapon} slices the head off of ^p2!!![/color]" % {:weapon => weapon.name}) self.msg2d = _("[color Red]^p1 cuts off your head with %{weapon}!!![/color]" % {:weapon => weapon.shortname}) self.msg2r = _("^p1 cuts off ^p2's head with %{weapon}!!!" % {:weapon => weapon.shortname}) @d.body.sever(part.id) part.location = @d.location get_object(@d.location).add_contents(part.id) dmg = @d.get_stat(:maxhp) else self.msg2a = _("Your %{weapon} gets stuck in ^p2's skull!!" % {:weapon => weapon.name}) self.msg2d = _("[color Red]^p1's %{weapon} gets stuck in your skull!![/color]" % {:weapon => weapon.name }) self.msg2r = _("^p1's %{weapon} gets stuck in ^p2's skull!!" % {:weapon => weapon.name}) dmg += 15 + rand(10) dmg += 20 if @d.has_attribute? :zombie part.crippled = true end when /#{torso}/ self.msg2a = _("You pratically disembowel ^p2 with your %{weapon}!" % {:weapon => weapon.shortname}) self.msg2d = _("[color Red]^p1 pratically disembowels you with %{weapon}![/color]" % {:weapon => weapon.shortname}) self.msg2r = _("^p1 pratically disembowels ^p2!") part.crippled = true else # Loose a limb self.msg2a = _("You hack off ^p2's %{limb}!!" % {:limb => part.name}) self.msg2d = _("[color Red]^p1 hacks off your %{limb}!![/color]" % {:limb => part.name}) self.msg2r = _("^p1 hacks off ^p2 %{limb}!!" % {:limb => part.name}) @d.body.sever(part.id) part.location = @d.location get_object(@d.location).add_contents(part.id) end sendmsgs @d.body.damage(part.id, dmg+rand(6)) else log.warn "No critical damage type set for #{@damagetype}" end end end