attackmsgs.rb
znmud-0.0.1/lib/combat/attackmsgs.rb · 1.5 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.
#
# 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
class AttackMsgs
attr_accessor :msg2a, :msg2d, :msg2r
def initialize(attacker, defender, damagetype, hitlocationid, weaponid)
@a = attacker
@d = defender
@damagetype = damagetype
@hitlocationid = hitlocationid
@weaponid = weaponid
msg2a = nil # Msg to Attacker
msg2d = nil # Msg to Defender
msg2r = nil # Msg to the Rest (Observers)
end
# get_object taken from Root.rb
def get_object(oid)
Engine.instance.db.get(oid)
end
def sendmsgs
if msg2a # Send a message to the attacker
msg = Msg.new(msg2a)
msg.ch1 = @a
msg.ch2 = @d
@a.sendto(msg)
end
if msg2d # Send a message to the defender
msg = Msg.new(msg2d)
msg.ch1 = @a
msg.ch2 = @d
@d.sendto(msg)
end
if msg2r # Send a message to the rest of the ppl in the room
msg = Msg.new(msg2r)
msg.ch1 = @a
msg.ch2 = @d
@a.sendrest(msg, @d.id)
end
end
# [+return+] the damage modifier if any
def damage_mod
return 0 if not @weaponid
weapon = get_object(@weaponid)
return 0 if not weapon.has_val? :damage
return weapon.has_val?("damage")
end
end