def pbStartBattle(troopID, canEscape, canLose, &block)
return if $game_temp.in_battle
if $game_temp.respond_to?("next_scene")
# For RPGVX style
$game_troop.setup(troopID)
$game_troop.can_escape = canEscape
$game_troop.can_lose = canLose
$game_temp.next_scene = "battle"
else
# For RPGXP style
$game_temp.battle_abort = true
# Set battle calling flag
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troopID
$game_temp.battle_can_escape = canEscape
$game_temp.battle_can_lose = canLose
end
if block_given?
# The block given takes a single parameter, n, which contains the result of the battle.
# Example:
# pbStartBattle(20, true, true) {|n|
# case n
# when 0;print "Player won"
# when 1;print "Player escaped"
# when 2;print "Player lost"
# end
# }
$game_temp.battle_proc = block
else
$game_temp.battle_proc = nil
end
end