znmud-0.0.1/benchmark/
znmud-0.0.1/cmd/
znmud-0.0.1/cmd/emotes/
znmud-0.0.1/cmd/objects/
znmud-0.0.1/cmd/tiny/
znmud-0.0.1/doc/
znmud-0.0.1/farts/
znmud-0.0.1/lib/
znmud-0.0.1/lib/combat/
znmud-0.0.1/lib/core/bodytypes/
znmud-0.0.1/lib/engine/
znmud-0.0.1/lib/farts/
znmud-0.0.1/logs/
#
# file::    cmd_flee.rb

# 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.
#

module Cmd

  bindtextdomain("cmd")

  # The flee command
  def cmd_flee(args)
	if @position == :fighting
		room = get_object(location)
		# Chance to flee is 50 % + 10% for each exit minus 10% for
		# Each person you are fighting
		chance = 50 + (10 * room.exits.size)
		chance -= 10 * @combatants.size
		if rand(100) < chance
			sendroom _("%{name} tries to flee" % {:name => name})
			@position = :standing
			@combatants.each do |cid|
				delete_combatant(cid)
			end
			exid = room.exits[rand(room.exits.size)]
			add_event(location, id, :show, _("You barely escape"))
 			add_event(id,exid,:leave, get_object(exid).name)
		else
			sendroom _("%{name} tries to flee but can not escape!" % {:name => name})
			sendto _("You can not escape!")
		end
	else
		sendto _("You are not fighting anybody")
	end
  end

end