miss.rb
znmud-0.0.1/lib/combat/miss.rb · 3.7 KB
From the archive znmud-minimal-0.0.1.tar.gz
Download the archive « Back to the archive contents
# 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
# Simple chart to describe miss messages
class Miss < 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)
case @damagetype
when :zombie
case roll
when 0..33
self.msg2a = _("You widly swing at ^p2 but miss.")
self.msg2d = _("^p1 wildly swings at you but misses.")
self.msg2r = _("^p1 wildly swings at ^p2 but misses.")
when 34..66
self.msg2a = _("You try to bite ^p2 but they push you away.")
self.msg2d = _("^p2 tries to bite you but you shove them away.")
self.msg2r = _("^p2 shoves ^p1 off of them.")
else
self.msg2a = _("You let out a roar of frustation at ^p2.")
self.msg2d = _("^p1 lets out an angry zombie moan.")
self.msg2r = msg2d
@a.moan(:angry) if @a.respond_to? "moan"
end
sendmsgs
when :biting
case rand(1)
when 1
self.msg2a = _("You teeth snap wildly in the air!")
self.msg2d = _("^p1's teeth snap in the air")
self.msg2r = _("^p1's teeth snap at ^p2")
else
self.msg2a = _("You growl at ^p2")
self.msg2d = _("^p1 lets out a low growl and shows their fangs.")
self.msg2r = msg2d
end
sendmsgs
when :clawing
case rand(1)
when 1
self.msg2a = _("You slash wildly in the air!")
self.msg2d = _("^p1's slashes the air with their claws")
self.msg2r = _("^p1's slashes at ^p2 but misses")
else
self.msg2a = _("Your claws just miss ^p2")
self.msg2d = _("^p1's claws just miss you.")
self.msg2r = _("^p1's claws just miss ^p2.")
end
sendmsgs
when :melee
case roll
when 0..33
self.msg2a = _("Your punch just misses them.")
self.msg2d = _("^p1 widly punches at you but misses")
self.msg2r = _("^p1 punches wildly at ^p2 but misses")
when 34..66
self.msg2a = _("You swing at ^p2 but they dodge")
self.msg2d = _("You duck as ^p1 tries to punch you")
self.msg2r = _("^p2 dodges a punch from ^p1.")
else
self.msg2a = _("You try to kick ^p2 but miss")
self.msg2d = _("^p1 tries to kick you but misses")
self.msg2r = _("^p1 tries to kick ^p2 but misses.")
end
sendmsgs
when :bludgeon, :slashing, :piercing
weapon = get_object(@weaponid)
loc = get_object(@hitlocationid).name
case roll
when 0..24
self.msg2a = _("You swing %{weapon} at ^p2's %{loc} but miss!" % {:weapon => weapon.shortname, :loc => loc})
self.msg2d = _("^p1 tries to swing %{weapon} at your %{loc} but misses!" % {:weapon => weapon.shortname, :loc => loc})
self.msg2r = _("^p1 swings %{weapon} wildly at ^p2 but misses" % {:weapon => weapon.shortname, :loc => loc})
else
self.msg2a = _("^p2 moves out of the way before you hit thim with %{weapon}." % {:weapon => weapon.shortname})
self.msg2d = _("You dodge an attack from ^p1's %{weapon}" % {:weapon => weapon.shortname})
self.msg2r = _("^p1 swings %{weapon} wildly at ^p2 but misses" % {:weapon => weapon.shortname})
end
sendmsgs
else
self.msg2a = _("You attack ^p2 but miss!")
self.msg2d = _("^p1 attacks you but misses!")
self.msg2r = _("^p1 attacks ^p2 but misses!")
sendmsgs
end
end
end