# 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
# Base chart for dealing standard damage
class Damage < AttackMsgs
include GetText
bindtextdomain("core")
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)
damage = 0
loc = get_object(@hitlocationid).name
leg = _("leg")
head = _("head")
torso = _("torso")
hand = _("hand")
foot = _("foot")
arm = _("arm")
case @damagetype
when :zombie
chanceofinfection = 0
damage = 2 + rand(6)
strBonus = @a.stats[:strength] - 15
damage += strBonus / 2 if strBonus
# Non-critical zombie attacks are scratches
case loc
when /#{arm}/,/#{leg}/
self.msg2a = _("You rake your nails across ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 rakes their nails across your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 rakes their nails across ^p2's %{loc}!" % {:loc => loc})
chanceofinfection = 10
when /#{torso}/
self.msg2a = _("You clamor on top of ^p2!")
self.msg2d = _("^p1 tries to crawl on top of you!")
self.msg2r = _("^p1 pulls and tugs on ^p2!")
when /#{head}/
self.msg2a = _("You grab ^p2 by the hair!")
self.msg2d = _("^p1 grabs your hair!")
self.msg2r = _("^p1 grabs ^p2 by the hair!")
else
self.msg2a = _("You scratch at ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 scratches at your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 scratches at ^p2's %{loc}!" % {:loc => loc})
damage -= 1
chanceofinfection = 5
end
sendmsgs
if rand(100) < chanceofinfection
@d.add_attribute :infected
end
when :biting
damage = 2 + rand(4)
strBonus = @a.stats[:strength] - 15
damage += strBonus / 2 if strBonus
case rand(1)
when 1
self.msg2a = _("You bite ^p2 in their %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 bites you in your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 bites ^p2 in their %{loc}!" % {:loc => loc})
else
self.msg2a = _("You sink your teeth into ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 sinks thier teeth directly into your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 sinks their teeth into ^p2's %{loc}!" % {:loc => loc})
end
sendmsgs
when :clawing
damage = 2 + rand(4)
strBonus = @a.stats[:strength] - 15
damage += strBonus / 2 if strBonus
case rand(1)
when 1
self.msg2a = _("Your claws rip at ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 claws rip at your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 claws rip at ^p2's %{loc}!" % {:loc => loc})
else
self.msg2a = _("You slash ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 slashes your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 slashes ^p2's %{loc}!" % {:loc => loc})
end
sendmsgs
when :melee
damage = 2 + rand(4)
strBonus = @a.stats[:strength] - 15
damage += strBonus / 2 if strBonus
case loc
when /#{leg}/
self.msg2a = _("You kick ^p2 in their %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 kicks you in your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 kicks ^p2 in their %{loc}!" % {:loc => loc})
when /#{foot}/
self.msg2a = _("You stomp on ^p2's %{loc}!" % {:loc => loc})
self.msg2d = _("^p1 stomps on your %{loc}!" % {:loc => loc})
self.msg2r = _("^p1 stomps on ^p2's %{loc}!" % {:loc => loc})
damage -= 1
when /#{head}/
self.msg2a = _("You punch ^p2 if the face!")
self.msg2d = _("^p1 punches you in your face!")
self.msg2r = _("^p1 punches ^p2 in the face!")
damage += 1
else
self.msg2a = _("You hit ^p2 in the %{loc}" % {:loc => loc})
self.msg2d = _("^p1 hits you in your %{loc}" % {:loc => loc})
self.msg2r = _("^p1 hits ^p2 in the %{loc}" % {:loc => loc})
end
sendmsgs
when :bludgeon
weapon = get_object(@weaponid)
self.msg2a = _("You hit ^p2 in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2d = _("^p1 hits you in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2r = _("^p1 hits ^p2 in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
sendmsgs
damage = rand((weapon.weight) * 2)+1 if weapon.weight > 0
when :piercing
weapon = get_object(@weaponid)
self.msg2a = _("You stab ^p2 in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2d = _("^p1 stabs you in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2r = _("^p1 stabs ^p2 in the %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
sendmsgs
damage = rand((weapon.weight) * 2)+2 if weapon.weight > 0
when :slashing
weapon = get_object(@weaponid)
self.msg2a = _("You slash ^p2's %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2d = _("^p1 slashes your %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
self.msg2r = _("^p1 slashes ^p2's %{loc} with %{weaponname}!" % {:loc => loc, :weaponname => weapon.shortname})
sendmsgs
damage = rand((weapon.weight) * 2)+2 if weapon.weight > 0
else
self.msg2a = _("You attack ^p2 and hit!")
self.msg2d = _("^p1 hits you!")
self.msg2r = _("^p1 hits ^p2!")
if weapon
damage = rand((weapon.weight) * 2)+1 if weapon.weight > 0
end
sendmsgs
end
damage += damage_mod if damage
if damage > 0
strBonus = @a.stats[:strength] - 15
damage += strBonus if strBonus
@d.body.damage(@hitlocationid, damage)
else
self.msg2a = _("Your attack had no effect!")
self.msg2d = _("^p1's attack had no effect!")
self.msg2r = nil
sendmsgs
end
end
end