# Zombie class
# Author: Craig Smith
# The ZOMBIE class!!!
# 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.
#
$:.unshift "lib" if !$:.include? "lib"
require 'gettext'
require 'core/gameobject'
require 'core/body'
require 'storage/properties'
class Zombie < Mobile
include GetText
bindtextdomain("core")
logger 'DEBUG'
def initialize(name, owner, location=nil)
super(name, owner, location)
add_attribute :aggressive
add_attribute :infected
add_attribute :zombie
add_skill :bash
end
def idle(e)
recoverHP
recoverMP
recoverStunned
manage_hunger
if @position == :fighting
moan(:angry) if rand(3) == 0
return
end
# Look for people in room
found = find_zombie_victim
if found
kill_id(found)
else
room = get_object(location)
if hungry?
room.contents.each do |oid|
o = get_object(oid)
if o.is_a? Corpse
add_event(id,oid,:eat)
return
end
end
# No corpse found, still hungry
case rand(10)
when 0..2
move
when 3..4
moan
end
else # Not hungry
case rand(20)
when 0..2
move
when 3..4
parse(_("say %{moan}" % {:moan => "Grh"}))
end
end
end
end
# Lets out a zombie moan and you can hear it in adjacent rooms
def moan(type=:hungry)
case type
when :angry
m = "Graaaagh!"
when :hungry
case rand(3)
when 0
m = "Grrh"
when 1
m = "Graagh."
else
m = "Hangrah!!"
end
else
m = "Grh"
end
room = get_object(location)
room.exits.each do |exid|
ex = get_object(exid)
if type == :angry
get_object(ex.to_room).contents.each do |pid|
person = get_object(pid)
if person.is_a? Character
if person.is_a? Zombie or person.has_attribute? :zombie
oexit = get_object(ex.linked_exit)
if oexit
msg = _("You hear, %{moan} coming from the %{dir}." % {:moan => m, :dir => oexit.name})
person.dirhint = oexit.id
else
msg = _("You hear, %{moan}" % {:moan => m})
end
else
msg = _("You hear, %{moan}" % {:moan => m})
end
add_event(id, person.id, :show, msg)
end
end
end
end
parse(_("say %{moan}" % {:moan => m}))
end
# Tries to kill the target id
# [+tid+] Target ID to attack
def kill_id(tid)
target = get_object(tid)
msg = Msg.new _("^p1 snarls and lunges at ^p2!")
msg.p1 = name
msg.p2 = target.name
sendroom(msg)
parse(_("kill %{name}" % {:name => target.name}))
end
# Simplied zombie description, since they don't really have health
def describe_health(detailed=nil)
_("%{name} looks like a walking corpse!" % {:name => name})
end
# Move in a random direction, bash if necessary
def move
room = get_object(location)
if room.exits.size > 0
if dirhint
dir = dirhint
self.dirhint = nil
else
dir = room.exits[rand(room.exits.size)]
end
ex = get_object(dir)
if ex.door_state == Exit::DOOR_CLOSED or ex.door_state == Exit::DOOR_LOCKED and has_skill? :bash
parse(_("bash %{door}" % {:door => ex.door_name}))
else
parse(ex.name)
end
end
end
end