Ejemplo n.º 1
0
// Define the game WAP and cache flags/values
gameSettings.passwordUnlocked = 0;
gameSettings.pointsUnlocked = <?= !empty($_SESSION['GAME']['counters']['battle_points']) ? $_SESSION['GAME']['counters']['battle_points'] : 0 ?>;
gameSettings.fadeIn = true;
gameSettings.demo = <?= $_SESSION['GAME']['DEMO'] ?>;
gameSettings.wapFlag = <?= $flag_wap ? 'true' : 'false' ?>;
gameSettings.cacheTime = '<?= MMRPG_CONFIG_CACHE_DATE?>';
gameSettings.startLink = '<?= $prototype_start_link ?>';
gameSettings.windowEventsCanvas = [];
gameSettings.windowEventsMessages = [];
gameSettings.totalPlayerOptions = <?= $unlock_count_players ?>;
gameSettings.prototypeBannerKey = 0;
gameSettings.prototypeBanners = ['prototype-banners_title-screen_01.gif'];
// Define any preset menu selections
battleOptions['this_player_id'] = <?= $this_userid ?>;
<?php if(rpg_game::is_demo()): ?>
  battleOptions['this_player_token'] = 'dr-light';
  <?php if(rpg_game::robots_unlocked('dr-light') == 3): ?>
    battleOptions['this_player_robots'] = '103_mega-man,104_bass,105_proto-man';
  <?endif;?>
<?php else: ?>
  <?php if(!empty($_SESSION['GAME']['battle_settings']['this_player_token'])): ?>
    battleOptions['this_player_token'] = '<?= $_SESSION['GAME']['battle_settings']['this_player_token']?>';
  <?php elseif($unlock_count_players < 2): ?>
    battleOptions['this_player_token'] = 'dr-light';
  <?php endif; ?>
<?php endif; ?>
// Create the document ready events
$(document).ready(function(){

  <?php if($prototype_start_link == 'home' && empty($_SESSION['GAME']['battle_settings']['this_player_token'])): ?>
Ejemplo n.º 2
0
// Include the TOP file
require_once '_top.php';
// Define the default SEO and MARKUP variables
$this_seo_title = 'Game | Mega Man RPG World | Last Updated ' . preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})#', '$1/$2/$3', MMRPG_CONFIG_CACHE_DATE);
$this_seo_keywords = 'megaman,mega man,protoman,proto man,bass,rpg,prototype,dr.light,dr.wily,dr.cossack,battle,browser,pbbg,ipad,firefox,chrome,safari';
$this_seo_description = 'Battle through more than thirty robot masters in classic RPG style with either Dr. Light and Mega Man, Dr. Wily and Bass, or Dr. Cossack and Proto Man! Mega Man RPG World is a browser-based fangame that combines the mechanics of both the Pokémon and Mega Man series of video games into one strange and wonderful little time waster.';
// Define the default Open Graph tag variables
$this_graph_data = array('title' => 'Mega Man RPG World', 'type' => 'website', 'url' => $this_current_url, 'image' => MMRPG_CONFIG_ROOTURL . 'images/assets/mmrpg-prototype-logo.png?' . MMRPG_CONFIG_CACHE_DATE, 'site_name' => 'Mega Man RPG World', 'description' => $this_seo_description);
// If a reset was intentionally called
if (!empty($_GET['reset']) || rpg_game::is_demo() && !empty($_SESSION['GAME']['CACHE_DATE']) && $_SESSION['GAME']['CACHE_DATE'] != MMRPG_CONFIG_CACHE_DATE) {
    // Reset the game session
    rpg_game::reset_session();
} elseif (rpg_game::is_demo() && !empty($_SESSION['GAME']['CACHE_DATE']) && $_SESSION['GAME']['CACHE_DATE'] != MMRPG_CONFIG_CACHE_DATE) {
    // Reset the game session
    rpg_game::reset_session();
} elseif (!empty($_GET['reload']) || !isset($_SESSION['GAME']['CACHE_DATE']) || rpg_game::is_demo() && $_SESSION['GAME']['CACHE_DATE'] != MMRPG_CONFIG_CACHE_DATE) {
    // Ensure there is a save file to load
    if (rpg_user::is_member()) {
        // Load the save file into memory and overwrite the session
        rpg_game::load_session();
    } else {
        // Reset the game session
        rpg_game::reset_session();
    }
    // Update the cache date to reflect the reload
    $_SESSION['GAME']['CACHE_DATE'] = MMRPG_CONFIG_CACHE_DATE;
    // Save the updated file back to the system
    rpg_game::save_session();
}
// Automatically empty all temporary battle variables
$_SESSION['BATTLES'] = array();
Ejemplo n.º 3
0
 public function trigger_disabled($target_robot, $this_ability, $trigger_options = array())
 {
     // Pull in the global variable
     global $mmrpg_index;
     // Import global variables
     $db = cms_database::get_database();
     $this_battle = rpg_battle::get_battle();
     $this_field = rpg_field::get_field();
     // Generate default trigger options if not set
     if (!isset($trigger_options['item_multiplier'])) {
         $trigger_options['item_multiplier'] = 1.0;
     }
     // If the battle has already ended, return false
     if (!empty($this_battle->flags['battle_complete_message_created'])) {
         return false;
     }
     // Create references to save time 'cause I'm tired
     // (rather than replace all target references to this references)
     $this_battle =& $this_battle;
     $this_player =& $this->player;
     // the player of the robot being disabled
     $this_robot =& $this;
     // the robot being disabled
     $target_player =& $target_robot->player;
     // the player of the other robot
     $target_robot =& $target_robot;
     // the other robot that isn't this one
     // If the target player is the same as the current or the target is dead
     if ($this_player->player_id == $target_player->player_id) {
         // Collect the actual target player from the battle values
         if (!empty($this_battle->values['players'])) {
             foreach ($this_battle->values['players'] as $id => $info) {
                 if ($this_player->player_id != $id) {
                     unset($target_player);
                     $target_player = new rpg_player($info);
                 }
             }
         }
         // Collect the actual target robot from the battle values
         if (!empty($target_player->values['robots_active'])) {
             foreach ($target_player->values['robots_active'] as $key => $info) {
                 if ($info['robot_position'] == 'active') {
                     $target_robot->robot_load($info);
                 }
             }
         }
     }
     // Update the target player's session
     $this_player->update_session();
     // Create the robot disabled event
     $disabled_text = in_array($this_robot->robot_token, array('dark-frag', 'dark-spire', 'dark-tower')) || $this_robot->robot_core == 'empty' ? 'destroyed' : 'disabled';
     $event_header = ($this_player->player_token != 'player' ? $this_player->player_name . '&#39;s ' : '') . $this_robot->robot_name;
     $event_body = ($this_player->player_token != 'player' ? $this_player->print_name() . '&#39;s ' : 'The target ') . ' ' . $this_robot->print_name() . ' was ' . $disabled_text . '!<br />';
     //'.($this_robot->robot_position == 'bench' ? ' and removed from battle' : '').'
     if (isset($this_robot->robot_quotes['battle_defeat'])) {
         $this_find = array('{target_player}', '{target_robot}', '{this_player}', '{this_robot}');
         $this_replace = array($target_player->player_name, $target_robot->robot_name, $this_player->player_name, $this_robot->robot_name);
         $event_body .= $this_robot->print_quote('battle_defeat', $this_find, $this_replace);
     }
     if ($target_robot->robot_status != 'disabled') {
         $target_robot->robot_frame = 'base';
     }
     $this_robot->robot_frame = 'defeat';
     $target_robot->update_session();
     $this_robot->update_session();
     $this_battle->events_create($this_robot, $target_robot, $event_header, $event_body, array('console_show_target' => false, 'canvas_show_disabled_bench' => $this_robot->robot_id . '_' . $this_robot->robot_token));
     /*
      * EFFORT VALUES / STAT BOOST BONUSES
      */
     // Define the event options array
     $event_options = array();
     $event_options['this_ability_results']['total_actions'] = 0;
     // Calculate the bonus boosts from defeating the target robot (if NOT player battle)
     if ($target_player->player_side == 'left' && $this_player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID && $target_robot->robot_status != 'disabled') {
         // Boost this robot's attack if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_attack'])) {
             $this_attack_boost = $this_robot->robot_base_attack / 100;
             //ceil($this_robot->robot_base_attack / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_attack_boost = $this_attack_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_attack_boost = $this_attack_boost * 2;
             }
             if ($target_robot->robot_attack + $this_attack_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_attack_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_attack) * -1;
                 $this_attack_boost = $this_attack_boost - $this_attack_overboost;
             }
             $this_attack_boost = round($this_attack_boost);
         } else {
             $this_attack_boost = 0;
         }
         // Boost this robot's defense if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_defense'])) {
             $this_defense_boost = $this_robot->robot_base_defense / 100;
             //ceil($this_robot->robot_base_defense / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_defense_boost = $this_defense_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_defense_boost = $this_defense_boost * 2;
             }
             if ($target_robot->robot_defense + $this_defense_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_defense_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_defense) * -1;
                 $this_defense_boost = $this_defense_boost - $this_defense_overboost;
             }
             $this_defense_boost = round($this_defense_boost);
         } else {
             $this_defense_boost = 0;
         }
         // Boost this robot's speed if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_speed'])) {
             $this_speed_boost = $this_robot->robot_base_speed / 100;
             //ceil($this_robot->robot_base_speed / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_speed_boost = $this_speed_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_speed_boost = $this_speed_boost * 2;
             }
             if ($target_robot->robot_speed + $this_speed_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_speed_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_speed) * -1;
                 $this_speed_boost = $this_speed_boost - $this_speed_overboost;
             }
             $this_speed_boost = round($this_speed_boost);
         } else {
             $this_speed_boost = 0;
         }
         // If the target robot is holding a Growth Module, double the stat bonuses
         if ($target_robot->robot_item == 'growth-module') {
             if (!$this_attack_boost) {
                 $this_attack_boost = $this_attack_boost * 2;
             }
             if (!$this_defense_boost) {
                 $this_defense_boost = $this_defense_boost * 2;
             }
             if (!$this_speed_boost) {
                 $this_speed_boost = $this_speed_boost * 2;
             }
         }
         // Define the temporary boost actions counter
         $temp_boost_actions = 1;
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_attack < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'])) {
                 $this_attack_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] = 0;
             }
         }
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_defense < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'])) {
                 $this_defense_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] = 0;
             }
         }
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_speed < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'])) {
                 $this_speed_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] = 0;
             }
         }
         // If the attack boost was not empty, process it
         if ($this_attack_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] += $this_attack_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_attack < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base attack boost based on robot base stats
                 $temp_attack_boost = ceil($this_attack_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_attack_boost + $target_robot->robot_attack > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_attack_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_attack;
                 }
                 // Increment this robot's attack by the calculated amount and display an event
                 $target_robot->robot_attack = ceil($target_robot->robot_attack + $temp_attack_boost);
                 $target_robot->robot_base_attack = ceil($target_robot->robot_base_attack + $temp_attack_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'attack';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_attack_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads weapons data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s attack grew by <span class="recovery_amount">' . $temp_attack_boost . '</span>! ';
                 $target_robot->robot_frame = 'shoot';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack']);
                     $temp_attack_session_boost = round($this_attack_boost);
                     if ($temp_attack_session_boost < 1) {
                         $temp_attack_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] += $temp_attack_session_boost;
                 }
             }
         }
         // If the defense boost was not empty, process it
         if ($this_defense_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] += $this_defense_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_defense < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base defense boost based on robot base stats
                 $temp_defense_boost = ceil($this_defense_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_defense_boost + $target_robot->robot_defense > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_defense_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_defense;
                 }
                 // Increment this robot's defense by the calculated amount and display an event
                 $target_robot->robot_defense = ceil($target_robot->robot_defense + $temp_defense_boost);
                 $target_robot->robot_base_defense = ceil($target_robot->robot_base_defense + $temp_defense_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'defense';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_defense_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads shield data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s defense grew by <span class="recovery_amount">' . $temp_defense_boost . '</span>! ';
                 $target_robot->robot_frame = 'defend';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense']);
                     $temp_defense_session_boost = round($this_defense_boost);
                     if ($temp_defense_session_boost < 1) {
                         $temp_defense_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] += $temp_defense_session_boost;
                 }
             }
         }
         // If the speed boost was not empty, process it
         if ($this_speed_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] += $this_speed_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_speed < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base speed boost based on robot base stats
                 $temp_speed_boost = ceil($this_speed_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_speed_boost + $target_robot->robot_speed > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_speed_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_speed;
                 }
                 // Increment this robot's speed by the calculated amount and display an event
                 $target_robot->robot_speed = ceil($target_robot->robot_speed + $temp_speed_boost);
                 $target_robot->robot_base_speed = ceil($target_robot->robot_base_speed + $temp_speed_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'speed';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_speed_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads mobility data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s speed grew by <span class="recovery_amount">' . $temp_speed_boost . '</span>! ';
                 $target_robot->robot_frame = 'slide';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed']);
                     $temp_speed_session_boost = round($this_speed_boost);
                     if ($temp_speed_session_boost < 1) {
                         $temp_speed_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] += $temp_speed_session_boost;
                 }
             }
         }
         // Update the target robot frame
         $target_robot->robot_frame = 'base';
         $target_robot->update_session();
     }
     // Ensure player and robot variables are updated
     $target_robot->update_session();
     $target_player->update_session();
     $this_robot->update_session();
     $this_player->update_session();
     /*
     // DEBUG
     $this_battle->events_create(false, false, 'DEBUG', 'we made it past the stat boosts... <br />'.
         '$this_robot->robot_token='.$this_robot->robot_token.'; $target_robot->robot_token='.$target_robot->robot_token.';<br />'.
         '$target_player->player_token='.$target_player->player_token.'; $target_player->player_side='.$target_player->player_side.';<br />'
         );
     */
     /*
      * ITEM REWARDS / EXPERIENCE POINTS / LEVEL UP
      * Reward the player and robots with items and experience if not in demo mode
      */
     if ($target_player->player_side == 'left' && $this_player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID && rpg_game::is_user()) {
         // -- EXPERIENCE POINTS / LEVEL UP -- //
         // Filter out robots who were active in this battle in at least some way
         $temp_robots_active = $target_player->values['robots_active'];
         usort($temp_robots_active, array('rpg_functions', 'robot_sort_by_active'));
         // Define the boost multiplier and start out at zero
         $temp_boost_multiplier = 0;
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $this_robot->counters = <pre>'.print_r($this_robot->counters, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         // If the target has had any damage flags triggered, update the multiplier
         //if ($this_robot->flags['triggered_immunity']){ $temp_boost_multiplier += 0; }
         //if (!empty($this_robot->flags['triggered_resistance'])){ $temp_boost_multiplier -= $this_robot->counters['triggered_resistance'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_affinity'])){ $temp_boost_multiplier -= $this_robot->counters['triggered_affinity'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_weakness'])){ $temp_boost_multiplier += $this_robot->counters['triggered_weakness'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_critical'])){ $temp_boost_multiplier += $this_robot->counters['triggered_critical'] * 0.10; }
         // If we're in DEMO mode, give a 100% experience boost
         //if (rpg_game::is_demo()){ $temp_boost_multiplier += 1; }
         // Ensure the multiplier has not gone below 100%
         if ($temp_boost_multiplier < -0.99) {
             $temp_boost_multiplier = -0.99;
         } elseif ($temp_boost_multiplier > 0.99) {
             $temp_boost_multiplier = 0.99;
         }
         // Define the boost text to match the multiplier
         $temp_boost_text = '';
         if ($temp_boost_multiplier < 0) {
             $temp_boost_text = 'a lowered ';
         } elseif ($temp_boost_multiplier > 0) {
             $temp_boost_text = 'a boosted ';
         }
         /*
         $event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.'<pre>'.print_r($this_robot->flags, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         
         $event_body = preg_replace('/\s+/', ' ', $target_robot->robot_token.'<pre>'.print_r($target_robot->flags, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         */
         // Define the base experience for the target robot
         $temp_experience = $this_robot->robot_base_energy + $this_robot->robot_base_attack + $this_robot->robot_base_defense + $this_robot->robot_base_speed;
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_boost_multiplier = '.$temp_boost_multiplier.'; $temp_experience = '.$temp_experience.'; ');
         //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $event_body);
         // Apply any boost multipliers to the experience earned
         if ($temp_boost_multiplier > 0 || $temp_boost_multiplier < 0) {
             $temp_experience += $temp_experience * $temp_boost_multiplier;
         }
         if ($temp_experience <= 0) {
             $temp_experience = 1;
         }
         $temp_experience = round($temp_experience);
         $temp_target_experience = array('level' => $this_robot->robot_level, 'experience' => $temp_experience);
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_target_experience = <pre>'.print_r($temp_target_experience, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         // Define the robot experience level and start at zero
         $target_robot_experience = 0;
         // Sort the active robots based on active or not
         /*
         function mmrpg_sort_temp_active_robots($info1, $info2){
             if ($info1['robot_position'] == 'active'){ return -1; }
             else { return 1; }
         }
         usort($temp_robots_active, 'mmrpg_sort_temp_active_robots');
         */
         // If the target was defeated with overkill, add it to the battle var
         if (!empty($this_robot->counters['defeat_overkill'])) {
             $overkill_bonus = $this_robot->counters['defeat_overkill'];
             //$overkill_bonus = $overkill_bonus - ceil($overkill_bonus * 0.90);
             //$overkill_divider = $target_robot->robot_level >= 100 ? 0.01 : (100 - $target_robot->robot_level) / 100;
             //$overkill_bonus = floor($overkill_bonus * $overkill_divider);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_battle->battle_overkill' => $this_battle->battle_overkill, '$this_battle->battle_rewards_zenny' => $this_battle->battle_rewards_zenny), true)).'</pre>', $event_options);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$overkill_bonus' => $overkill_bonus), true)).'</pre>', $event_options);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_robot->robot_base_total' => $this_robot->robot_base_total, '$target_robot->robot_base_total' => $target_robot->robot_base_total), true)).'</pre>', $event_options);
             //if ($target_robot->robot_base_total > $this_robot->robot_base_total){ $overkill_bonus = floor($overkill_bonus * ($this_robot->robot_base_total / $target_robot->robot_base_total));   }
             //elseif ($target_robot->robot_base_total < $this_robot->robot_base_total){ $overkill_bonus = floor($overkill_bonus * ($target_robot->robot_base_total / $this_robot->robot_base_total));   }
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$overkill_bonus' => $overkill_bonus), true)).'</pre>', $event_options);
             $this_battle->battle_overkill += $this_robot->counters['defeat_overkill'];
             if (empty($this_battle->flags['starter_battle'])) {
                 $this_battle->battle_rewards_zenny += $overkill_bonus;
             }
             $this_battle->update_session();
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_battle->battle_overkill' => $this_battle->battle_overkill, '$this_battle->battle_rewards_zenny' => $this_battle->battle_rewards_zenny), true)).'</pre>', $event_options);
         }
         // Increment each of this player's robots
         $temp_robots_active_num = count($temp_robots_active);
         $temp_robots_active_num2 = $temp_robots_active_num;
         // This will be decremented for each non-experience gaining level 100 robots
         $temp_robots_active = array_reverse($temp_robots_active, true);
         usort($temp_robots_active, array('rpg_functions', 'robot_sort_by_active'));
         $temp_robot_active_position = false;
         foreach ($temp_robots_active as $temp_id => $temp_info) {
             $temp_robot = $target_robot->robot_id == $temp_info['robot_id'] ? $target_robot : new rpg_robot($target_player, $temp_info);
             if ($temp_robot->robot_level >= 100 || $temp_robot->robot_class != 'master') {
                 $temp_robots_active_num2--;
             }
             if ($temp_robot->robot_position == 'active') {
                 $temp_robot_active_position = $temp_robots_active[$temp_id];
                 unset($temp_robots_active[$temp_id]);
             }
         }
         $temp_unshift = array_unshift($temp_robots_active, $temp_robot_active_position);
         foreach ($temp_robots_active as $temp_id => $temp_info) {
             // Collect or define the robot points and robot rewards variables
             $temp_robot = $target_robot->robot_id == $temp_info['robot_id'] ? $target_robot : new rpg_robot($target_player, $temp_info);
             //if ($temp_robot->robot_class == 'mecha'){ continue; }
             $temp_robot_token = $temp_info['robot_token'];
             if ($temp_robot_token == 'robot') {
                 continue;
             }
             $temp_robot_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
             $temp_robot_rewards = !empty($temp_info['robot_rewards']) ? $temp_info['robot_rewards'] : array();
             if (empty($temp_robots_active_num2)) {
                 break;
             }
             // Continue if over already at level 100
             //if ($temp_robot->robot_level >= 100){ continue; }
             // Reset the robot experience points to zero
             $target_robot_experience = 0;
             // Continue with experience mods only if under level 100
             if ($temp_robot->robot_level < 100 && $temp_robot->robot_class == 'master') {
                 // Give a proportionate amount of experience based on this and the target robot's levels
                 if ($temp_robot->robot_level == $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'];
                 } elseif ($temp_robot->robot_level < $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'] + round(($temp_target_experience['level'] - $temp_robot->robot_level) / 100 * $temp_target_experience['experience']);
                     //$temp_experience_boost = $temp_target_experience['experience'] + ((($temp_target_experience['level']) / $temp_robot->robot_level) * $temp_target_experience['experience']);
                 } elseif ($temp_robot->robot_level > $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'] - round(($temp_robot->robot_level - $temp_target_experience['level']) / 100 * $temp_target_experience['experience']);
                     //$temp_experience_boost = $temp_target_experience['experience'] - ((($temp_robot->robot_level - $temp_target_experience['level']) / 100) * $temp_target_experience['experience']);
                 }
                 // DEBUG
                 //$event_body = 'START EXPERIENCE | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 //$temp_experience_boost = ceil($temp_experience_boost / 10);
                 $temp_experience_boost = ceil($temp_experience_boost / $temp_robots_active_num);
                 //$temp_experience_boost = ceil($temp_experience_boost / ($temp_robots_active_num * 2));
                 //$temp_experience_boost = ceil($temp_experience_boost / ($temp_robots_active_num2 * 2));
                 //$temp_experience_boost = ceil(($temp_experience_boost / $temp_robots_active_num2) * 1.00);
                 if ($temp_experience_boost > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_experience_boost = MMRPG_SETTINGS_STATS_MAX;
                 }
                 $target_robot_experience += $temp_experience_boost;
                 // DEBUG
                 //$event_body = 'ACTIVE ROBOT DIVISION | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robots_active_num = '.$temp_robots_active_num.'; $temp_robots_active_num2 = '.$temp_robots_active_num2.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 // If this robot has been traded, give it an additional experience boost
                 $temp_experience_boost = 0;
                 $temp_robot_boost_text = $temp_boost_text;
                 $temp_player_boosted = false;
                 if ($temp_robot->player_token != $temp_robot->robot_original_player) {
                     $temp_player_boosted = true;
                     $temp_robot_boost_text = 'a player boosted ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = $target_robot_experience * 2;
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     // DEBUG
                     //$event_body = 'PLAYER BOOSTED | ';
                     //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robot->player_token('.$temp_robot->player_token.') != $temp_robot->robot_original_player('.$temp_robot->robot_original_player.'); ');
                     //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 }
                 // If the target robot is holding a Growth Module, double the experience bonus
                 if ($temp_robot->robot_item == 'growth-module') {
                     $temp_robot_boost_text = $temp_player_boosted ? 'a player and module boosted ' : 'a module boosted ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = $target_robot_experience * 2;
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     // DEBUG
                     //$event_body = 'MODULE BOOSTED | ';
                     //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robot->robot_item = '.$temp_robot->robot_item.'; ');
                     //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 }
                 // If there are field multipliers in place, apply them now
                 $temp_experience_boost = 0;
                 if (isset($this->field->field_multipliers['experience'])) {
                     //$temp_robot_boost_text = '(and '.$target_robot_experience.' multiplied by '.number_format($this->field->field_multipliers['experience'], 1).') ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = ceil($target_robot_experience * $this->field->field_multipliers['experience']);
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                 }
                 // DEBUG
                 //$event_body = 'FIELD MULTIPLIERS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 /*
                 // If this robot has any overkill, add that to the temp experience modifier
                 $temp_experience_boost = 0;
                 if (!empty($this_robot->counters['defeat_overkill'])){
                     if (empty($temp_robot_boost_text)){ $temp_robot_boost_text = 'an overkill boosted '; }
                     else { $temp_robot_boost_text = 'a player and overkill boosted '; }
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience += ceil($this_robot->counters['defeat_overkill'] / $temp_robots_active_num2);
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     //$this_battle->battle_overkill += $this_robot->counters['defeat_overkill'];
                     //$this_battle->update_session();
                     //$temp_robot_boost_text .= 'umm '.$this_battle->battle_overkill;
                 }
                 */
                 // DEBUG
                 //$event_body = 'OVERKILL BONUS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 /*
                 // If the target robot's core type has been boosted by starforce
                 if (!empty($temp_robot->robot_core) && !empty($_SESSION['GAME']['values']['star_force'][$temp_robot->robot_core])){
                     if (empty($temp_robot_boost_text)){ $temp_robot_boost_text = 'a starforce boosted '; }
                     elseif ($temp_robot_boost_text == 'an overkill boosted '){ $temp_robot_boost_text = 'an overkill and starforce boosted '; }
                     elseif ($temp_robot_boost_text == 'a player boosted '){ $temp_robot_boost_text = 'a player and starforce boosted '; }
                     else { $temp_robot_boost_text = 'a player, overkill, and starforce boosted '; }
                     $temp_starforce = $_SESSION['GAME']['values']['star_force'][$temp_robot->robot_core];
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience += ceil($target_robot_experience * ($temp_starforce / 10));
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                 }
                 */
                 // DEBUG
                 //$event_body = 'STARFORCE BONUS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $temp_robot->robot_token.' : '.$temp_robot->robot_core.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 // If the experience is greater then the max, level it off at the max (sorry guys!)
                 if ($target_robot_experience > MMRPG_SETTINGS_STATS_MAX) {
                     $target_robot_experience = MMRPG_SETTINGS_STATS_MAX;
                 }
                 if ($target_robot_experience < MMRPG_SETTINGS_STATS_MIN) {
                     $target_robot_experience = MMRPG_SETTINGS_STATS_MIN;
                 }
                 // Collect the robot's current experience and level for reference later
                 $temp_start_experience = rpg_game::robot_experience($target_player->player_token, $temp_robot_token);
                 $temp_start_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
                 // Increment this robots's points total with the battle points
                 if (!isset($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] = 1;
                 }
                 if (!isset($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] += $target_robot_experience;
                 // Define the new experience for this robot
                 $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 $temp_new_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
                 // If the new experience is over the required, level up the robot
                 $level_boost = 0;
                 if ($temp_new_experience > $temp_required_experience) {
                     //$level_boost = floor($temp_new_experience / $temp_required_experience);
                     while ($temp_new_experience > $temp_required_experience) {
                         $level_boost += 1;
                         $temp_new_experience -= $temp_required_experience;
                         $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level + $level_boost);
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] += $level_boost;
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] = $temp_new_experience;
                     //$level_boost * $temp_required_experience;
                     if ($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] > 100) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] = 100;
                     }
                     $temp_new_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
                 }
                 // Define the new level for this robot
                 $temp_new_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
             } else {
                 // Collect the robot's current experience and level for reference later
                 $temp_start_experience = rpg_game::robot_experience($target_player->player_token, $temp_robot_token);
                 $temp_start_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
                 // Define the new experience for this robot
                 $temp_new_experience = $temp_start_experience;
                 $temp_new_level = $temp_start_level;
             }
             // Define the event options
             $event_options = array();
             $event_options['this_ability_results']['trigger_kind'] = 'recovery';
             $event_options['this_ability_results']['recovery_kind'] = 'experience';
             $event_options['this_ability_results']['recovery_type'] = '';
             $event_options['this_ability_results']['this_amount'] = $target_robot_experience;
             $event_options['this_ability_results']['this_result'] = 'success';
             $event_options['this_ability_results']['flag_affinity'] = true;
             $event_options['this_ability_results']['total_actions'] = 1;
             $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
             $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
             // Update player/robot frames and points for the victory
             $temp_robot->robot_frame = 'victory';
             $temp_robot->robot_level = $temp_new_level;
             $temp_robot->robot_experience = $temp_new_experience;
             $target_player->set_frame('victory');
             $temp_robot->update_session();
             // Only display the event if the player is under level 100
             if ($temp_robot->robot_level < 100 && $temp_robot->robot_class == 'master') {
                 // Display the win message for this robot with battle points
                 $temp_robot->robot_frame = 'taunt';
                 $temp_robot->robot_level = $temp_new_level;
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 }
                 $target_player->set_frame('victory');
                 $event_header = $temp_robot->robot_name . '&#39;s Rewards';
                 $event_multiplier_text = $temp_robot_boost_text;
                 $event_body = $temp_robot->print_name() . ' collects ' . $event_multiplier_text . '<span class="recovery_amount ability_type ability_type_cutter">' . $target_robot_experience . '</span> experience points! ';
                 $event_body .= '<br />';
                 if (isset($temp_robot->robot_quotes['battle_victory'])) {
                     $this_find = array('{target_player}', '{target_robot}', '{this_player}', '{this_robot}');
                     $this_replace = array($this_player->player_name, $this_robot->robot_name, $target_player->player_name, $temp_robot->robot_name);
                     $event_body .= $temp_robot->print_quote('battle_victory', $this_find, $this_replace);
                 }
                 //$event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $event_options['this_body_float'] = $target_player->player_side;
                 $temp_robot->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = $temp_new_experience;
                 }
                 if ($temp_robot->robot_core == 'copy') {
                     $temp_robot->robot_image = $temp_robot->robot_base_image;
                     $temp_robot->robot_image_overlay = array();
                 }
                 $temp_robot->update_session();
                 $target_player->update_session();
             }
             // Floor the robot's experience with or without the event
             $target_player->set_frame('victory');
             $temp_robot->robot_frame = 'base';
             if ($temp_start_level != $temp_new_level) {
                 $temp_robot->robot_experience = 0;
             }
             $temp_robot->update_session();
             // If the level has been boosted, display the stat increases
             if ($temp_start_level != $temp_new_level) {
                 // Define the event options
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'level';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_new_level - $temp_start_level;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = 2;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                 // Display the win message for this robot with battle points
                 $temp_robot->robot_frame = 'taunt';
                 $temp_robot->robot_level = $temp_new_level;
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 } else {
                     $temp_robot->robot_experience = $temp_new_experience;
                 }
                 $target_player->set_frame('victory');
                 $event_header = $temp_robot->robot_name . '&#39;s Rewards';
                 //$event_body = $temp_robot->print_name().' grew to <span class="recovery_amount'.($temp_new_level >= 100 ? ' ability_type ability_type_electric' : '').'">Level '.$temp_new_level.'</span>!<br /> ';
                 $event_body = $temp_robot->print_name() . ' grew to <span class="recovery_amount ability_type ability_type_level">Level ' . $temp_new_level . ($temp_new_level >= 100 ? ' &#9733;' : '') . '</span>!<br /> ';
                 $event_body .= $temp_robot->robot_name . '&#39;s energy, weapons, shields, and mobility were upgraded!';
                 //$event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $event_options['this_body_float'] = $target_player->player_side;
                 $temp_robot->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 $temp_robot->robot_experience = 0;
                 $temp_robot->update_session();
                 // Collect the base robot template from the index for calculations
                 $temp_index_robot = rpg_robot::get_index_info($temp_robot->robot_token);
                 // Define the event options
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['this_amount'] = $this_defense_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = 0;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                 // Update the robot rewards array with any recent info
                 $temp_robot_rewards = rpg_game::robot_rewards($target_player->player_token, $temp_robot->robot_token);
                 //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r($temp_robot_rewards, true)).'</pre>', $event_options);
                 // Define the base energy boost based on robot base stats
                 $temp_energy_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_energy']));
                 // If this robot has reached level 100, the max level, create the flag in their session
                 if ($temp_new_level >= 100) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['flags']['reached_max_level'] = true;
                 }
                 // Check if there are eny pending energy stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_energy_pending'])) {
                     $temp_robot_rewards['robot_energy_pending'] = round($temp_robot_rewards['robot_energy_pending']);
                     $temp_energy_boost += $temp_robot_rewards['robot_energy_pending'];
                     if (!empty($temp_robot_rewards['robot_energy'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy'] += $temp_robot_rewards['robot_energy_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy'] = $temp_robot_rewards['robot_energy_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy_pending'] = 0;
                 }
                 // Increment this robot's energy by the calculated amount and display an event
                 $temp_robot->robot_energy += $temp_energy_boost;
                 $temp_base_energy_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_energy']));
                 $temp_robot->robot_base_energy += $temp_base_energy_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'energy';
                 $event_options['this_ability_results']['this_amount'] = $temp_energy_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s health improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s energy grew by <span class="recovery_amount">' . $temp_energy_boost . '</span>! ';
                 $temp_robot->robot_frame = 'summon';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base attack boost based on robot base stats
                 $temp_attack_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_attack']));
                 // Check if there are eny pending attack stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_attack_pending'])) {
                     $temp_robot_rewards['robot_attack_pending'] = round($temp_robot_rewards['robot_attack_pending']);
                     $temp_attack_boost += $temp_robot_rewards['robot_attack_pending'];
                     if (!empty($temp_robot_rewards['robot_attack'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack'] += $temp_robot_rewards['robot_attack_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack'] = $temp_robot_rewards['robot_attack_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack_pending'] = 0;
                 }
                 // Increment this robot's attack by the calculated amount and display an event
                 $temp_robot->robot_attack += $temp_attack_boost;
                 $temp_base_attack_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_attack']));
                 $temp_robot->robot_base_attack += $temp_base_attack_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'attack';
                 $event_options['this_ability_results']['this_amount'] = $temp_attack_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s weapons improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s attack grew by <span class="recovery_amount">' . $temp_attack_boost . '</span>! ';
                 $temp_robot->robot_frame = 'shoot';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base defense boost based on robot base stats
                 $temp_defense_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_defense']));
                 // Check if there are eny pending defense stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_defense_pending'])) {
                     $temp_robot_rewards['robot_defense_pending'] = round($temp_robot_rewards['robot_defense_pending']);
                     $temp_defense_boost += $temp_robot_rewards['robot_defense_pending'];
                     if (!empty($temp_robot_rewards['robot_defense'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense'] += $temp_robot_rewards['robot_defense_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense'] = $temp_robot_rewards['robot_defense_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense_pending'] = 0;
                 }
                 // Increment this robot's defense by the calculated amount and display an event
                 $temp_robot->robot_defense += $temp_defense_boost;
                 $temp_base_defense_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_defense']));
                 $temp_robot->robot_base_defense += $temp_base_defense_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'defense';
                 $event_options['this_ability_results']['this_amount'] = $temp_defense_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s shields improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s defense grew by <span class="recovery_amount">' . $temp_defense_boost . '</span>! ';
                 $temp_robot->robot_frame = 'defend';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base speed boost based on robot base stats
                 $temp_speed_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_speed']));
                 // Check if there are eny pending speed stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_speed_pending'])) {
                     $temp_robot_rewards['robot_speed_pending'] = round($temp_robot_rewards['robot_speed_pending']);
                     $temp_speed_boost += $temp_robot_rewards['robot_speed_pending'];
                     if (!empty($temp_robot_rewards['robot_speed'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_speed'] += $temp_robot_rewards['robot_speed_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_speed'] = $temp_robot_rewards['robot_speed_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_speed_pending'] = 0;
                 }
                 // Increment this robot's speed by the calculated amount and display an event
                 $temp_robot->robot_speed += $temp_speed_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'speed';
                 $event_options['this_ability_results']['this_amount'] = $temp_speed_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $temp_base_speed_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_speed']));
                 $temp_robot->robot_base_speed += $temp_base_speed_boost;
                 $event_body = $temp_robot->print_name() . '&#39;s mobility improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s speed grew by <span class="recovery_amount">' . $temp_speed_boost . '</span>! ';
                 $temp_robot->robot_frame = 'slide';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the robot frame
                 $temp_robot->robot_frame = 'base';
                 $temp_robot->update_session();
             }
             // Update the experience level for real this time
             $temp_robot->robot_experience = $temp_new_experience;
             $temp_robot->update_session();
             // Collect the robot info array
             $temp_robot_info = $temp_robot->export_array();
             // Collect the indexed robot rewards for new abilities
             $index_robot_rewards = $temp_robot_info['robot_rewards'];
             //$event_body = preg_replace('/\s+/', ' ', '<pre>'.print_r($index_robot_rewards, true).'</pre>');
             //$this_battle->events_create(false, false, 'DEBUG', $event_body);
             // Loop through the ability rewards for this robot if set
             if ($temp_robot->robot_class != 'mecha' && ($temp_start_level == 100 || $temp_start_level != $temp_new_level && !empty($index_robot_rewards['abilities']))) {
                 $temp_abilities_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
                 foreach ($index_robot_rewards['abilities'] as $ability_reward_key => $ability_reward_info) {
                     // If the ability does not exist or is otherwise incomplete, continue
                     if (!isset($temp_abilities_index[$ability_reward_info['token']])) {
                         continue;
                     }
                     // If this ability is already unlocked, continue
                     if (rpg_game::ability_unlocked($target_player->player_token, $temp_robot_token, $ability_reward_info['token'])) {
                         continue;
                     }
                     // If we're in DEMO mode, continue
                     if (rpg_game::is_demo()) {
                         continue;
                     }
                     // Check if the required level has been met by this robot
                     if ($temp_new_level >= $ability_reward_info['level']) {
                         // Create the temporary ability object for event creation
                         $temp_ability_info = array('ability_id' => MMRPG_SETTINGS_BATTLEABILITIES_PERROBOT_MAX + $ability_reward_key, 'ability_token' => $ability_reward_info['token']);
                         $temp_ability = new rpg_ability($target_player, $temp_robot, $temp_ability_info);
                         // Collect or define the ability variables
                         $temp_ability_token = $ability_reward_info['token'];
                         // Display the robot reward message markup
                         $event_header = $temp_ability->ability_name . ' Unlocked';
                         $event_body = '<span class="robot_name">' . $temp_info['robot_name'] . '</span> unlocked new ability data!<br />';
                         $event_body .= $temp_ability->print_name() . ' can now be used in battle!';
                         $event_options = array();
                         $event_options['console_show_target'] = false;
                         $event_options['this_header_float'] = $target_player->player_side;
                         $event_options['this_body_float'] = $target_player->player_side;
                         $event_options['this_ability'] = $temp_ability;
                         $event_options['this_ability_image'] = 'icon';
                         $event_options['console_show_this_player'] = false;
                         $event_options['console_show_this_robot'] = false;
                         $event_options['console_show_this_ability'] = true;
                         $event_options['canvas_show_this_ability'] = false;
                         $temp_robot->robot_frame = $ability_reward_key % 2 == 2 ? 'taunt' : 'victory';
                         $temp_robot->update_session();
                         $temp_ability->ability_frame = 'base';
                         $temp_ability->update_session();
                         $this_battle->events_create($temp_robot, false, $event_header, $event_body, $event_options);
                         $temp_robot->robot_frame = 'base';
                         $temp_robot->update_session();
                         // Automatically unlock this ability for use in battle
                         $this_reward = rpg_ability::get_index_info($temp_ability_token);
                         //array('ability_token' => $temp_ability_token);
                         $temp_player_info = $target_player->export_array();
                         $show_event = !rpg_game::ability_unlocked('', '', $temp_ability_token) ? true : false;
                         rpg_game::unlock_ability($temp_player_info, $temp_robot_info, $this_reward, $show_event);
                         if ($temp_robot_info['robot_original_player'] == $temp_player_info['player_token']) {
                             rpg_game::unlock_ability($temp_player_info, false, $this_reward);
                         } else {
                             rpg_game::unlock_ability(array('player_token' => $temp_robot_info['robot_original_player']), false, $this_reward);
                         }
                         //$_SESSION['GAME']['values']['battle_rewards'][$target_player_token]['player_robots'][$temp_robot_token]['robot_abilities'][$temp_ability_token] = $this_reward;
                     }
                 }
             }
         }
         // -- ITEM REWARDS -- //
         // Define the temp player rewards array
         $target_player_rewards = array();
         // Define the chance multiplier and start at one
         $temp_chance_multiplier = $trigger_options['item_multiplier'];
         // Increase the item chance multiplier if one is set for the stage
         if (isset($this_battle->field->field_multipliers['items'])) {
             $temp_chance_multiplier = $temp_chance_multiplier * $this_battle->field->field_multipliers['items'];
         }
         // Define the available item drops for this battle
         $target_player_rewards['items'] = $this_battle->get_item_rewards();
         // Increase the multipliers if starter battle
         if (!empty($this_battle->flags['starter_battle'])) {
             $temp_chance_multiplier = 4;
         } else {
             // If the target holds a Fortune Module, increase the chance of dropps
             $temp_fortune_module = false;
             if ($target_robot->robot_item == 'fortune-module') {
                 $temp_fortune_module = true;
             }
             // If this robot was a MECHA class, it may drop SMALL SCREWS
             if ($this_robot->robot_class == 'mecha') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'small-screw', 'quantity' => mt_rand(1, $temp_fortune_module ? 9 : 6));
                 // If this robot was an empty core, it drops other items too
                 if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                     $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'super-pellet');
                 }
             }
             // If this robot was a MASTER class, it may drop LARGE SCREWS
             if ($this_robot->robot_class == 'master') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'large-screw', 'quantity' => mt_rand(1, $temp_fortune_module ? 6 : 3));
                 // If this robot was an empty core, it drops other items too
                 if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                     $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'super-capsule');
                 }
             }
             // If this robot was a BOSS class, it may drop EXTRA LIFE
             if ($this_robot->robot_class == 'boss') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'extra-life', 'quantity' => mt_rand(1, $temp_fortune_module ? 3 : 1));
             }
             // If this robot was holding an ITEM, it should also drop that at a high rate
             if (!empty($this_robot->robot_item)) {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => $this_robot->robot_item);
             }
         }
         // Precount the item values for later use
         $temp_value_total = 0;
         $temp_count_total = 0;
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $temp_value_total += $item_reward_info['chance'];
             $temp_count_total += 1;
         }
         //$this_battle->events_create(false, false, 'DEBUG', '$temp_count_total = '.$temp_count_total.';<br /> $temp_value_total = '.$temp_value_total.'; ');
         // If this robot was a MECHA class and destroyed by WEAKNESS, it may drop a SHARD
         if ($this_robot->robot_class == 'mecha' && !empty($this_robot->flags['triggered_weakness'])) {
             $temp_shard_type = !empty($this->robot_core) ? $this->robot_core : 'none';
             $target_player_rewards['items'] = array();
             $target_player_rewards['items'][] = array('chance' => 100, 'token' => $temp_shard_type . '-shard');
         } elseif (in_array($this_robot->robot_class, array('master', 'boss')) && !empty($this_robot->flags['triggered_weakness'])) {
             $temp_core_type = !empty($this->robot_core) ? $this->robot_core : 'none';
             $target_player_rewards['items'] = array();
             $target_player_rewards['items'][] = array('chance' => 100, 'token' => $temp_core_type . '-core');
         }
         // Recount the item values for later use
         $temp_value_total = 0;
         $temp_count_total = 0;
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $temp_value_total += $item_reward_info['chance'];
             $temp_count_total += 1;
         }
         // Adjust item values for easier to understand percentages
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $target_player_rewards['items'][$item_reward_key]['chance'] = ceil($item_reward_info['chance'] / $temp_value_total * 100);
         }
         // Shuffle the rewards so it doesn't look to formulaic
         shuffle($target_player_rewards['items']);
         // DEBUG
         //$temp_string = '';
         //foreach ($target_player_rewards['items'] AS $info){ $temp_string .= $info['token'].' = '.$info['chance'].'%, '; }
         //$this_battle->events_create(false, false, 'DEBUG', '$target_player_rewards[\'items\'] = '.count($target_player_rewards['items']).'<br /> '.$temp_string);
         // Define a function for dealing with item drops
         if (!function_exists('temp_player_rewards_items')) {
             function temp_player_rewards_items($this_battle, $target_player, $target_robot, $this_robot, $item_reward_key, $item_reward_info, $item_drop_count = 1)
             {
                 global $mmrpg_index;
                 // Create the temporary ability object for event creation
                 $temp_info = array('ability_id' => MMRPG_SETTINGS_BATTLEABILITIES_PERROBOT_MAX + $item_reward_key + 300, 'ability_token' => $item_reward_info['ability_token']);
                 $temp_ability = new rpg_ability($target_player, $target_robot, $item_reward_info);
                 $temp_ability->ability_name = $item_reward_info['ability_name'];
                 $temp_ability->ability_image = $item_reward_info['ability_token'];
                 $temp_ability->update_session();
                 // Collect or define the ability variables
                 $temp_item_token = $item_reward_info['ability_token'];
                 $temp_item_name = $item_reward_info['ability_name'];
                 $temp_item_colour = !empty($item_reward_info['ability_type']) ? $item_reward_info['ability_type'] : 'none';
                 if (!empty($item_reward_info['ability_type2'])) {
                     $temp_item_colour .= '_' . $item_reward_info['ability_type2'];
                 }
                 $temp_type_name = !empty($item_reward_info['ability_type']) ? ucfirst($item_reward_info['ability_type']) : 'Neutral';
                 $allow_over_max = false;
                 $temp_is_shard = preg_match('/-shard$/i', $temp_item_token) ? true : false;
                 $temp_is_core = preg_match('/-core$/i', $temp_item_token) ? true : false;
                 // Define the max quantity limit for this particular item
                 if ($temp_is_shard) {
                     $temp_item_quantity_max = MMRPG_SETTINGS_SHARDS_MAXQUANTITY;
                     $allow_over_max = true;
                 } elseif ($temp_is_core) {
                     $temp_item_quantity_max = MMRPG_SETTINGS_CORES_MAXQUANTITY;
                 } else {
                     $temp_item_quantity_max = MMRPG_SETTINGS_ITEMS_MAXQUANTITY;
                 }
                 // Create the session variable for this item if it does not exist and collect its value
                 if (empty($_SESSION['GAME']['values']['battle_items'][$temp_item_token])) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                 }
                 $temp_item_quantity = $_SESSION['GAME']['values']['battle_items'][$temp_item_token];
                 // If this item is already at the quantity limit, skip it entirely
                 if ($temp_item_quantity >= $temp_item_quantity_max) {
                     //$this_battle->events_create(false, false, 'DEBUG', 'max count for '.$temp_item_token.' of '.$temp_item_quantity_max.' has been reached ('.($allow_over_max ? 'allow' : 'disallow').')');
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = $temp_item_quantity_max;
                     $temp_item_quantity = $temp_item_quantity_max;
                     if (!$allow_over_max) {
                         return true;
                     }
                 }
                 // Define the new item quantity after increment
                 $temp_item_quantity_new = $temp_item_quantity + $item_drop_count;
                 $shards_remaining = false;
                 // If this is a shard piece
                 if ($temp_is_shard) {
                     // Define the number of shards remaining for a new core
                     $temp_item_quantity_max = MMRPG_SETTINGS_SHARDS_MAXQUANTITY;
                     $shards_remaining = $temp_item_quantity_max - $temp_item_quantity_new;
                     // If this player has collected enough shards to create a new core
                     if ($shards_remaining == 0) {
                         $temp_body_addon = 'The other ' . $temp_type_name . ' Shards from the inventory started glowing&hellip;';
                     } else {
                         $temp_body_addon = 'Collect ' . $shards_remaining . ' more shard' . ($shards_remaining > 1 ? 's' : '') . ' to create a new ' . $temp_type_name . ' Core!';
                     }
                 } elseif (preg_match('/-core$/i', $temp_item_token)) {
                     // Define the robot core drop text for displau
                     $temp_body_addon = $target_player->print_name() . ' added the new core to the inventory.';
                 } else {
                     // Define the normal item drop text for display
                     $temp_body_addon = $target_player->print_name() . ' added the dropped item' . ($item_drop_count > 1 ? 's' : '') . ' to the inventory.';
                 }
                 // Display the robot reward message markup
                 $event_header = $temp_item_name . ' Item Drop';
                 $event_body = rpg_functions::get_random_positive_word();
                 $event_body .= ' The disabled ' . $this_robot->print_name() . ' dropped ';
                 if ($item_drop_count == 1) {
                     $event_body .= (preg_match('/^(a|e|i|o|u)/i', $temp_item_name) ? 'an' : 'a') . ' <span class="ability_name ability_type ability_type_' . $temp_item_colour . '">' . $temp_item_name . '</span>!<br />';
                 } else {
                     $event_body .= 'x' . $item_drop_count . ' <span class="ability_name ability_type ability_type_' . $temp_item_colour . '">' . ($temp_item_name == 'Extra Life' ? 'Extra Lives' : $temp_item_name . 's') . '</span>!<br />';
                 }
                 $event_body .= $temp_body_addon;
                 $event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $target_player->player_side;
                 $event_options['this_body_float'] = $target_player->player_side;
                 $event_options['this_ability'] = $temp_ability;
                 $event_options['this_ability_image'] = 'icon';
                 $event_options['event_flag_victory'] = true;
                 $event_options['console_show_this_player'] = false;
                 $event_options['console_show_this_robot'] = false;
                 $event_options['console_show_this_ability'] = true;
                 $event_options['canvas_show_this_ability'] = true;
                 $target_player->set_frame($item_reward_key % 3 == 0 ? 'victory' : 'taunt');
                 $target_robot->robot_frame = $item_reward_key % 2 == 0 ? 'taunt' : 'base';
                 $target_robot->update_session();
                 $temp_ability->ability_frame = 'base';
                 $temp_ability->ability_frame_offset = array('x' => 220, 'y' => 0, 'z' => 10);
                 $temp_ability->update_session();
                 $this_battle->events_create($target_robot, $target_robot, $event_header, $event_body, $event_options);
                 // Create and/or increment the session variable for this item increasing its quantity
                 if (empty($_SESSION['GAME']['values']['battle_items'][$temp_item_token])) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                 }
                 if ($temp_item_quantity < $temp_item_quantity_max) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] += $item_drop_count;
                 }
                 // If this was a shard, and it was the LAST shard
                 if ($shards_remaining !== false && $shards_remaining < 1) {
                     // Define the new core token and increment value in session
                     $temp_core_token = str_replace('shard', 'core', $temp_item_token);
                     $temp_core_name = str_replace('Shard', 'Core', $temp_item_name);
                     $item_core_info = array('ability_token' => $temp_core_token, 'ability_name' => $temp_core_name, 'ability_type' => $item_reward_info['ability_type']);
                     // Create the temporary ability object for event creation
                     $temp_info['ability_id'] += 1;
                     $temp_info['ability_token'] = $temp_core_token;
                     $temp_core = new rpg_ability($target_player, $target_robot, $temp_info);
                     $temp_core->ability_name = $item_core_info['ability_name'];
                     $temp_core->ability_image = $item_core_info['ability_token'];
                     $temp_core->update_session();
                     // Collect or define the ability variables
                     //$temp_core_token = $item_core_info['ability_token'];
                     //$temp_core_name = $item_core_info['ability_name'];
                     $temp_type_name = !empty($temp_core->ability_type) ? ucfirst($temp_core->ability_type) : 'Neutral';
                     $temp_core_colour = !empty($temp_core->ability_type) ? $temp_core->ability_type : 'none';
                     // Define the max quantity limit for this particular item
                     $temp_core_quantity_max = MMRPG_SETTINGS_ITEMS_MAXQUANTITY;
                     // Create the session variable for this item if it does not exist and collect its value
                     if (empty($_SESSION['GAME']['values']['battle_items'][$temp_core_token])) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = 0;
                     }
                     $temp_core_quantity = $_SESSION['GAME']['values']['battle_items'][$temp_core_token];
                     // If this item is already at the quantity limit, skip it entirely
                     if ($temp_core_quantity >= $temp_core_quantity_max) {
                         //$this_battle->events_create(false, false, 'DEBUG', 'max count for '.$temp_core_token.' of '.$temp_core_quantity_max.' has been reached');
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = $temp_core_quantity_max;
                         $temp_core_quantity = $temp_core_quantity_max;
                         return true;
                     }
                     // Display the robot reward message markup
                     $event_header = $temp_core_name . ' Item Fusion';
                     $event_body = rpg_functions::get_random_positive_word() . ' The glowing shards fused to create a new ' . $temp_core->print_name() . '!<br />';
                     $event_body .= $target_player->print_name() . ' added the new core to the inventory.';
                     $event_options = array();
                     $event_options['console_show_target'] = false;
                     $event_options['this_header_float'] = $target_player->player_side;
                     $event_options['this_body_float'] = $target_player->player_side;
                     $event_options['this_ability'] = $temp_core;
                     $event_options['this_ability_image'] = 'icon';
                     $event_options['event_flag_victory'] = true;
                     $event_options['console_show_this_player'] = false;
                     $event_options['console_show_this_robot'] = false;
                     $event_options['console_show_this_ability'] = true;
                     $event_options['canvas_show_this_ability'] = true;
                     $target_player->set_frame($item_reward_key + 1 % 3 == 0 ? 'taunt' : 'victory');
                     $target_robot->robot_frame = $item_reward_key % 2 == 0 ? 'base' : 'taunt';
                     $target_robot->update_session();
                     $temp_core->ability_frame = 'base';
                     $temp_core->ability_frame_offset = array('x' => 220, 'y' => 0, 'z' => 10);
                     $temp_core->update_session();
                     $this_battle->events_create($target_robot, $target_robot, $event_header, $event_body, $event_options);
                     // Create and/or increment the session variable for this item increasing its quantity
                     if (empty($_SESSION['GAME']['values']['battle_items'][$temp_core_token])) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = 0;
                     }
                     if ($temp_core_quantity < $temp_core_quantity_max) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] += 1;
                     }
                     // Set the old shard counter back to zero now that they've fused
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                     $temp_item_quantity = 0;
                 }
                 // Return true on success
                 return true;
             }
         }
         // Loop through the ability rewards for this robot if set and NOT demo mode
         if (rpg_game::is_user() && !empty($target_player_rewards['items']) && $this->player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID) {
             $temp_items_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
             // Define the default success rate and multiply by the modifier
             $temp_success_value = $this_robot->robot_class == 'master' ? 50 : 25;
             $temp_success_value = ceil($temp_success_value * $temp_chance_multiplier);
             // Empty cores always have item drops
             if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                 $temp_success_value = 100;
             }
             // If the target holds a Fortune Module, increase the chance of dropps
             if ($target_robot->robot_item == 'fortune-module') {
                 $temp_success_value = $temp_success_value * 2;
             }
             // Fix success values over 100
             if ($temp_success_value > 100) {
                 $temp_success_value = 100;
             }
             // Define the failure based on success rate
             $temp_failure_value = 100 - $temp_success_value;
             // Define the dropping result based on rates
             $temp_dropping_result = $temp_success_value == 100 ? 'success' : rpg_functions::weighted_chance(array('success', 'failure'), array($temp_success_value, $temp_failure_value));
             //$this_battle->events_create(false, false, 'DEBUG', '..and the result of the drop ('.$temp_success_value.' / '.$temp_failure_value.') is '.$temp_dropping_result);
             if ($temp_dropping_result == 'success') {
                 $temp_value_total = 0;
                 $temp_count_total = 0;
                 foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
                     $temp_value_total += $item_reward_info['chance'];
                     $temp_count_total += 1;
                 }
                 $temp_item_counts = array();
                 $temp_item_tokens = array();
                 $temp_item_weights = array();
                 if ($temp_value_total > 0) {
                     foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
                         $temp_item_tokens[] = $item_reward_info['token'];
                         $temp_item_weights[] = ceil($item_reward_info['chance'] / $temp_value_total * 100);
                         $temp_item_counts[$item_reward_info['token']] = isset($item_reward_info['quantity']) ? $item_reward_info['quantity'] : 1;
                     }
                 }
                 $temp_random_item = rpg_functions::weighted_chance($temp_item_tokens, $temp_item_weights);
                 $item_index_info = rpg_ability::parse_index_info($temp_items_index[$temp_random_item]);
                 $item_drop_count = $temp_item_counts[$temp_random_item];
                 temp_player_rewards_items($this_battle, $target_player, $target_robot, $this, $item_reward_key, $item_index_info, $item_drop_count);
             }
         }
     }
     // DEBUG
     //$this_battle->events_create(false, false, 'DEBUG', 'we made it past the experience boosts');
     // If the player has replacement robots and the knocked-out one was active
     if ($this_player->counters['robots_active'] > 0) {
         // Try to find at least one active POSITION robot before requiring a switch
         $has_active_positon_robot = false;
         foreach ($this_player->values['robots_active'] as $key => $robot) {
             //if ($robot['robot_position'] == 'active'){ $has_active_positon_robot = true; }
         }
         // If the player does NOT have an active position robot, trigger a switch
         if (!$has_active_positon_robot) {
             // If the target player is not on autopilot, require input
             if ($this_player->player_autopilot == false) {
                 // Empty the action queue to allow the player switch time
                 $this_battle->actions = array();
             } elseif ($this_player->player_autopilot == true) {
                 // && $this_player->player_next_action != 'switch'
                 // Empty the action queue to allow the player switch time
                 $this_battle->actions = array();
                 // Remove any previous switch actions for this player
                 $backup_switch_actions = $this_battle->actions_extract(array('this_player_id' => $this_player->player_id, 'this_action' => 'switch'));
                 //$this_battle->events_create(false, false, 'DEBUG DEBUG', 'This is a test from inside the dead trigger ['.count($backup_switch_actions).'].');
                 // If there were any previous switches removed
                 if (!empty($backup_switch_actions)) {
                     // If the target robot was faster, it should attack first
                     if ($this_robot->robot_speed > $target_robot->robot_speed) {
                         // Prepend an ability action for this robot
                         $this_battle->actions_prepend($this_player, $this_robot, $target_player, $target_robot, 'ability', '');
                     } else {
                         // Prepend an ability action for this robot
                         $this_battle->actions_append($this_player, $this_robot, $target_player, $target_robot, 'ability', '');
                     }
                 }
                 // Prepend a switch action for the target robot
                 $this_battle->actions_prepend($this_player, $this_robot, $target_player, $target_robot, 'switch', '');
             }
         }
     } else {
         // Trigger a battle complete action
         $this_battle->trigger_complete($target_player, $target_robot, $this_player, $this_robot);
     }
     // Either way, set the hidden flag on the robot
     //if (($this_robot->robot_status == 'disabled' || $this_robot->robot_energy < 1) && $this_robot->robot_position == 'bench'){
     if ($this_robot->robot_status == 'disabled' || $this_robot->robot_energy < 1) {
         //$this_robot->robot_status == 'disabled';
         $this_robot->flags['apply_disabled_state'] = true;
         if ($this_robot->robot_position == 'bench') {
             $this_robot->flags['hidden'] = true;
         }
         $this_robot->update_session();
     }
     // -- ROBOT UNLOCKING STUFF!!! -- //
     // Check if this target winner was a HUMAN player and update the robot database counter for defeats
     if ($target_player->player_side == 'left') {
         // Add this robot to the global robot database array
         if (!isset($_SESSION['GAME']['values']['robot_database'][$this->robot_token])) {
             $_SESSION['GAME']['values']['robot_database'][$this->robot_token] = array('robot_token' => $this->robot_token);
         }
         if (!isset($_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated'])) {
             $_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated'] = 0;
         }
         $_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated']++;
     }
     // Check if this battle has any robot rewards to unlock and the winner was a HUMAN player
     $temp_robot_rewards = $this_battle->get_robot_rewards();
     if ($target_player->player_side == 'left' && !empty($temp_robot_rewards)) {
         // DEBUG
         //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | battle_rewards_robots = '.count($temp_robot_rewards).'');
         foreach ($temp_robot_rewards as $temp_reward_key => $temp_reward_info) {
             // DEBUG
             //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | checking '.$this->robot_token.' == '.preg_replace('/\s+/', ' ', print_r($temp_reward_info, true)).'...');
             // Check if this robot was part of the rewards for this battle
             if (!rpg_game::robot_unlocked(false, $temp_reward_info['token']) && $this->robot_token == $temp_reward_info['token']) {
                 // DEBUG
                 //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | '.$this->robot_token.' == '.$temp_reward_info['token'].' is a match!');
                 // Check if this robot has been attacked with any elemental moves
                 if (!empty($this->history['triggered_damage_types'])) {
                     // Loop through all the damage types and check if they're not empty
                     foreach ($this->history['triggered_damage_types'] as $key => $types) {
                         if (!empty($types)) {
                             // DEBUG
                             //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | '.$this->robot_token.' was attacked with a '.implode(', ', $types).' type ability!<br />Removing from the battle rewards!');
                             // Generate the robot removed event showing the destruction
                             /*
                             $event_header = $this->robot_name.'&#39;s Data Destroyed';
                             $event_body = $this->print_name().'&#39;s battle data was damaged beyond repair!<br />';
                             $event_body .= $this->print_name().' could not be unlocked for use in battle&hellip;';
                             $event_options = array();
                             $event_options['console_show_target'] = false;
                             $event_options['this_header_float'] = $this_player->player_side;
                             $event_options['this_body_float'] = $this_player->player_side;
                             $event_options['console_show_this_player'] = false;
                             $event_options['console_show_this_robot'] = true;
                             $this_robot->robot_frame = 'defeat';
                             $this_robot->update_session();
                             $this_battle->events_create($this, false, $event_header, $event_body, $event_options);
                             */
                             // Remove this robot from the battle rewards array
                             unset($temp_robot_rewards[$temp_reward_key]);
                             // Break, we know all we need to
                             break;
                         }
                     }
                 }
                 // If this robot is somehow still a reward, print a message showing a good job
                 if (!empty($temp_robot_rewards[$temp_reward_key])) {
                     // Collect this reward's information
                     $robot_reward_info = $temp_robot_rewards[$temp_reward_key];
                     // Collect or define the robot points and robot rewards variables
                     //$this_robot_token = $robot_reward_info['token'];
                     $this_robot_level = !empty($robot_reward_info['level']) ? $robot_reward_info['level'] : 1;
                     $this_robot_experience = !empty($robot_reward_info['experience']) ? $robot_reward_info['experience'] : 0;
                     $this_robot_rewards = !empty($robot_info['robot_rewards']) ? $robot_info['robot_rewards'] : array();
                     // Create the temp new robot for the player
                     //$temp_index_robot = rpg_robot::get_index_info($this_robot_token);
                     $temp_index_robot['robot_id'] = MMRPG_SETTINGS_TARGET_PLAYERID * 2;
                     $temp_index_robot['robot_level'] = $this_robot_level;
                     $temp_index_robot['robot_experience'] = $this_robot_experience;
                     $temp_unlocked_robot = new rpg_robot($target_player, $temp_index_robot);
                     // Automatically unlock this robot for use in battle
                     //$temp_unlocked_player = $mmrpg_index['players'][$target_player->player_token];
                     rpg_game::unlock_robot($temp_unlocked_player, $temp_index_robot, true, true);
                     // Display the robot reward message markup
                     //$event_header = $temp_unlocked_robot->robot_name.' Unlocked';
                     $event_body = rpg_functions::get_random_positive_word() . ' ' . $target_player->print_name() . ' unlocked new robot data!<br />';
                     $event_body .= $temp_unlocked_robot->print_name() . ' can now be used in battle!';
                     $event_options = array();
                     $event_options['console_show_target'] = false;
                     $event_options['this_header_float'] = $target_player->player_side;
                     $event_options['this_body_float'] = $target_player->player_side;
                     $event_options['this_robot_image'] = 'mug';
                     $temp_unlocked_robot->robot_frame = 'base';
                     $temp_unlocked_robot->update_session();
                     $this_battle->events_create($temp_unlocked_robot, false, $event_header, $event_body, $event_options);
                 }
                 // Update the battle with robot reward changes
                 $temp_robot_rewards = array_values($temp_robot_rewards);
                 $this_battle->set_robot_rewards($temp_robot_rewards);
             }
         }
     }
     // Return true on success
     return true;
 }
Ejemplo n.º 4
0
 public static function reset_session()
 {
     // Reference global variables
     global $mmrpg_index, $db;
     //$GAME_SESSION = &$_SESSION[self::session_token()];
     $session_token = self::session_token();
     // Collect the user ID from the session
     $user_id = !empty($_SESSION[$session_token]['USER']['userid']) ? $_SESSION[$session_token]['USER']['userid'] : 0;
     // Back up the user and file info from the session
     $this_demo = $_SESSION[$session_token]['DEMO'];
     $this_user = $_SESSION[$session_token]['USER'];
     $this_file = $_SESSION[$session_token]['FILE'];
     $this_level_bonus = self::robot_level('dr-light', 'mega-man');
     $this_battle_points = !empty($_SESSION[$session_token]['counters']['battle_points']) ? $_SESSION[$session_token]['counters']['battle_points'] : 0;
     $this_battle_zenny = !empty($_SESSION[$session_token]['counters']['battle_zenny']) ? $_SESSION[$session_token]['counters']['battle_zenny'] : 0;
     $this_battle_items = !empty($_SESSION[$session_token]['counters']['battle_items']) ? $_SESSION[$session_token]['counters']['battle_items'] : array();
     $this_battle_stars = !empty($_SESSION[$session_token]['counters']['battle_stars']) ? $_SESSION[$session_token]['counters']['battle_stars'] : array();
     $this_battle_abilities = !empty($_SESSION[$session_token]['counters']['battle_abilities']) ? $_SESSION[$session_token]['counters']['battle_abilities'] : array();
     $this_battle_complete = !empty($_SESSION[$session_token]['values']['battle_complete']) ? $_SESSION[$session_token]['values']['battle_complete'] : array();
     $this_battle_failure = !empty($_SESSION[$session_token]['values']['battle_failure']) ? $_SESSION[$session_token]['values']['battle_failure'] : array();
     $this_robot_database = !empty($_SESSION[$session_token]['values']['robot_database']) ? $_SESSION[$session_token]['values']['robot_database'] : array();
     $this_battle_rewards = !empty($_SESSION[$session_token]['values']['battle_rewards']) ? $_SESSION[$session_token]['values']['battle_rewards'] : array();
     $this_battle_items = !empty($_SESSION[$session_token]['values']['battle_items']) ? $_SESSION[$session_token]['values']['battle_items'] : array();
     $this_index_settings = !empty($_SESSION[$session_token]['index_settings']) ? $_SESSION[$session_token]['index_settings'] : array();
     // Automatically unset the session variable entirely
     session_unset();
     // Automatically create the cache date
     $_SESSION[$session_token] = array();
     $_SESSION[$session_token]['CACHE_DATE'] = MMRPG_CONFIG_CACHE_DATE;
     // Redefine the user and file variables in the new session
     $_SESSION[$session_token]['DEMO'] = $this_demo;
     $_SESSION[$session_token]['USER'] = $this_user;
     // Automatically create the battle points counter and start at zero
     $_SESSION[$session_token]['counters']['battle_points'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? 0 : $this_battle_points;
     // Automatically create the battle points counter and start at zero
     $_SESSION[$session_token]['counters']['battle_zenny'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? 0 : $this_battle_zenny;
     // Automatically create the battle complete array and start at empty
     $_SESSION[$session_token]['values']['battle_complete'] = array();
     // Automatically create the battle failure array and start at empty
     $_SESSION[$session_token]['values']['battle_failure'] = array();
     // Automatically create the battle index array and start at empty
     $_SESSION[$session_token]['values']['battle_index'] = array();
     // Automatically create the battle items array and start at empty
     $_SESSION[$session_token]['values']['battle_items'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_items;
     // Automatically create the battle stars array and start at empty
     $_SESSION[$session_token]['values']['battle_stars'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_stars;
     // Automatically create the battle abilities array and start at empty
     $_SESSION[$session_token]['values']['battle_abilities'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_abilities;
     // Automatically create the robot database array and start at empty
     $_SESSION[$session_token]['values']['robot_database'] = array();
     // Automatically create the index settings array and start at what was before
     $_SESSION[$session_token]['index_settings'] = $this_index_settings;
     // Automatically create the last load and save variable and set to now
     $_SESSION[$session_token]['values']['last_load'] = time();
     $_SESSION[$session_token]['values']['last_save'] = time();
     // -- DEMO MODE UNLOCKS -- //
     if (rpg_game::is_demo()) {
         // Reset the demo flag and user id to defaul
         $_SESSION[$session_token]['USER']['userid'] = MMRPG_SETTINGS_GUEST_ID;
         $_SESSION[$session_token]['DEMO'] = 1;
         // Only unlock Dr. Light as a playable character
         $unlock_player_info = $mmrpg_index['players']['dr-light'];
         self::unlock_player($unlock_player_info, false, true);
         $_SESSION[$session_token]['values']['battle_rewards']['dr-light']['player_points'] = 0;
         $_SESSION[$session_token]['values']['battle_items'] = array('item-energy-pellet' => 3, 'item-energy-capsule' => 2, 'item-weapon-pellet' => 3, 'item-weapon-capsule' => 2);
         // Auto-select Dr. Light as the current playable character
         $_SESSION[$session_token]['battle_settings']['this_player_token'] = 'dr-light';
         // Collect the robot index for calculation purposes
         $this_robot_index = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token');
         // Unlock Mega Man as a playable character
         $unlock_robot_info = $this_robot_index['mega-man'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'super-throw'), array('level' => 0, 'token' => 'fire-storm'), array('level' => 0, 'token' => 'hyper-bomb'), array('level' => 0, 'token' => 'ice-breath'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'mega-buster'), array('level' => 0, 'token' => 'mega-ball'), array('level' => 0, 'token' => 'mega-slide'));
         //$unlock_robot_info['robot_level'] = 5;
         //echo __LINE__.print_r($_SESSION[$session_token]['values']['battle_rewards']['dr-light'], true);
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
         // Unlock Bass as a playable character
         $unlock_robot_info = $this_robot_index['bass'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'air-shooter'), array('level' => 0, 'token' => 'leaf-shield'), array('level' => 0, 'token' => 'bubble-spray'), array('level' => 0, 'token' => 'quick-boomerang'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'bass-buster'), array('level' => 0, 'token' => 'bass-crush'), array('level' => 0, 'token' => 'bass-baroque'));
         //$unlock_robot_info['robot_level'] = 99;
         //$unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
         // Unlock Proto Man as a playable character
         $unlock_robot_info = $this_robot_index['proto-man'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'drill-blitz'), array('level' => 0, 'token' => 'bright-burst'), array('level' => 0, 'token' => 'dive-missile'), array('level' => 0, 'token' => 'skull-barrier'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'proto-buster'), array('level' => 0, 'token' => 'proto-shield'), array('level' => 0, 'token' => 'proto-strike'));
         //$unlock_robot_info['robot_level'] = 99;
         //$unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
     } else {
         // Unlock Dr. Light as a playable character
         $unlock_player_info = $mmrpg_index['players']['dr-light'];
         self::unlock_player($unlock_player_info, true, true);
         $_SESSION[$session_token]['values']['battle_rewards']['dr-light']['player_points'] = 0;
         $_SESSION[$session_token]['values']['battle_items'] = array();
         // Auto-select Dr. Light as the current playable character
         $_SESSION[$session_token]['battle_settings']['this_player_token'] = 'dr-light';
         // Unlock Mega Man as a playable character
         $unlock_robot_info = rpg_robot::get_index_info('mega-man');
         $unlock_robot_info['robot_level'] = 1;
         //!empty($this_level_bonus) ? $this_level_bonus : 1;
         $unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
     }
     // Return true on success
     return true;
 }
Ejemplo n.º 5
0
<?php

/*
 * DEMO PLAYER SELECT
 */
if (rpg_game::is_demo()) {
    // Define the button size based on player count
    $this_button_size = '1x4';
    // Print out the normal mode's player select screen for Dr. Light
    if ($unlock_flag_light) {
        echo rpg_prototype::player_select_markup($prototype_data['demo'], 'dr-light', $this_button_size);
    }
} else {
    // Define the button size based on player count
    $this_button_size = '1x4';
    // Print out the normal mode's player select screen for Dr. Light
    if ($unlock_flag_light) {
        echo rpg_prototype::player_select_markup($prototype_data['dr-light'], 'dr-light', $this_button_size);
    }
    // Print out the normal mode's player select screen for Dr. Wily
    if ($unlock_flag_wily) {
        echo rpg_prototype::player_select_markup($prototype_data['dr-wily'], 'dr-wily', $this_button_size);
    }
    // Print out the normal mode's player select screen for Dr. Cossack
    if ($unlock_flag_cossack) {
        echo rpg_prototype::player_select_markup($prototype_data['dr-cossack'], 'dr-cossack', $this_button_size);
    }
}
Ejemplo n.º 6
0
 /**
  * Generate the canvas scene markup for this frame of battle including players, robots, abilities etc.
  * @param array $eventinfo
  * @param array $options (optional)
  * @return string
  */
 public function get_canvas_markup($eventinfo, $options = array())
 {
     // Collect references to global objects
     $db = cms_database::get_database();
     $this_battle = self::get_battle();
     $this_field = rpg_field::get_field();
     // Default the return markup to empty
     $this_markup = '';
     // If this robot was not provided or allowed by the function
     if (empty($eventinfo['this_player']) || empty($eventinfo['this_robot']) || $options['canvas_show_this'] == false) {
         // Set both this player and robot to false
         $eventinfo['this_player'] = false;
         $eventinfo['this_robot'] = false;
         // Collect possible player IDs and figure out which is which
         $all_player_ids = $this_battle->get_player_ids();
         $target_player_id = !empty($eventinfo['target_player']) ? $eventinfo['target_player']->get_id() : 0;
         if (!empty($target_player_id)) {
             $temp_player_id = array_shift($all_player_ids);
             $this_player_id = $temp_player_id == $target_player_id ? array_shift($all_player_ids) : $temp_player_id;
         } else {
             $target_player_id = array_shift($all_player_ids);
             $this_player_id = array_shift($all_player_ids);
         }
         // Recollect this player and robot info based on above
         if (!empty($this_player_id)) {
             $eventinfo['this_player'] = $this_battle->get_player($this_player_id);
             $eventinfo['this_robot'] = $this_battle->find_robot(array('player_id' => $this_player_id, 'robot_position' => 'active', 'robot_status' => 'active'));
         }
     }
     // If this robot was targetting itself, set the target to false
     if (!empty($eventinfo['this_robot']) && !empty($eventinfo['target_robot'])) {
         // If this and the target robot are the same, set target to false
         if ($eventinfo['this_robot']->robot_id == $eventinfo['target_robot']->robot_id) {
             $eventinfo['target_robot'] = false;
         }
         // If this and the target robot's ID is less than the prefedined computer target ID (same team), set target to false
         if ($eventinfo['this_robot']->robot_id < MMRPG_SETTINGS_TARGET_PLAYERID && $eventinfo['target_robot']->robot_id < MMRPG_SETTINGS_TARGET_PLAYERID) {
             $eventinfo['target_robot'] = false;
         }
         // If this and the target robot's ID is greater than the prefedined computer target ID (same team), set target to false
         if ($eventinfo['this_robot']->robot_id >= MMRPG_SETTINGS_TARGET_PLAYERID && $eventinfo['target_robot']->robot_id >= MMRPG_SETTINGS_TARGET_PLAYERID) {
             $eventinfo['target_robot'] = false;
         }
     }
     // If the target robot was not provided or allowed by the function
     if (empty($eventinfo['target_player']) || empty($eventinfo['target_robot']) || $options['canvas_show_target'] == false) {
         // Set both this player and robot to false
         $eventinfo['target_player'] = false;
         $eventinfo['target_robot'] = false;
         // Collect possible player IDs and figure out which is which
         $all_player_ids = $this_battle->get_player_ids();
         $this_player_id = !empty($eventinfo['this_player']) ? $eventinfo['this_player']->get_id() : 0;
         if (!empty($this_player_id)) {
             $temp_player_id = array_shift($all_player_ids);
             $target_player_id = $temp_player_id == $this_player_id ? array_shift($all_player_ids) : $temp_player_id;
         } else {
             $this_player_id = array_shift($all_player_ids);
             $target_player_id = array_shift($all_player_ids);
         }
         // Recollect the target player and robot info based on above
         if (!empty($target_player_id)) {
             $eventinfo['target_player'] = $this_battle->get_player($target_player_id);
             $eventinfo['target_robot'] = $this_battle->find_robot(array('player_id' => $target_player_id, 'robot_position' => 'active', 'robot_status' => 'active'));
         }
     }
     // Collect this player's markup data
     $this_player_data = $eventinfo['this_player']->get_canvas_markup($options);
     // Append this player's markup to the main markup array
     $this_markup .= $this_player_data['player_markup'];
     // Loop through and display this player's robots
     if ($options['canvas_show_this_robots'] && !empty($eventinfo['this_player']->player_robots)) {
         $num_player_robots = count($eventinfo['this_player']->player_robots);
         foreach ($eventinfo['this_player']->player_robots as $this_key => $this_robotinfo) {
             $this_robot = new rpg_robot($eventinfo['this_player'], $this_robotinfo);
             $this_options = $options;
             //if ($this_robot->robot_status == 'disabled' && $this_robot->robot_position == 'bench'){ continue; }
             if (!empty($this_robot->flags['hidden'])) {
                 continue;
             } elseif (!empty($eventinfo['this_robot']->robot_id) && $eventinfo['this_robot']->robot_id != $this_robot->robot_id) {
                 $this_options['this_ability'] = false;
             } elseif (!empty($eventinfo['this_robot']->robot_id) && $eventinfo['this_robot']->robot_id == $this_robot->robot_id && $options['canvas_show_this'] != false) {
                 $this_robot->robot_frame = $eventinfo['this_robot']->robot_frame;
             }
             $this_robot->robot_key = $this_robot->robot_key !== false ? $this_robot->robot_key : ($this_key > 0 ? $this_key : $num_player_robots);
             $this_robot_data = $this_robot->get_canvas_markup($this_options, $this_player_data);
             $this_robot_id_token = $this_robot_data['robot_id'] . '_' . $this_robot_data['robot_token'];
             // ABILITY OVERLAY STUFF
             if (!empty($this_options['this_ability_results']) && $this_options['this_ability_target'] == $this_robot_id_token) {
                 $this_markup .= '<div class="ability_overlay overlay1" data-target="' . $this_options['this_ability_target'] . '" data-key="' . $this_robot_data['robot_key'] . '" style="z-index: ' . ($this_robot_data['robot_position'] == 'active' ? 5052 : 4900 - $this_robot_data['robot_key'] * 100) . ';">&nbsp;</div>';
             } elseif ($this_robot_data['robot_position'] != 'bench' && !empty($this_options['this_ability']) && !empty($options['canvas_show_this_ability'])) {
                 $this_markup .= '<div class="ability_overlay overlay2" data-target="' . $this_options['this_ability_target'] . '" data-key="' . $this_robot_data['robot_key'] . '" style="z-index: ' . ($this_options['this_ability_target_position'] == 'active' ? 5051 : 4900 - $this_options['this_ability_target_key'] * 100) . ';">&nbsp;</div>';
             } elseif ($this_robot_data['robot_position'] != 'bench' && !empty($options['canvas_show_this_ability_overlay'])) {
                 $this_markup .= '<div class="ability_overlay overlay3" style="z-index: 100;">&nbsp;</div>';
             }
             // RESULTS ANIMATION STUFF
             if (!empty($this_options['this_ability_results']) && $this_options['this_ability_target'] == $this_robot_id_token) {
                 /*
                  * ABILITY EFFECT OFFSETS
                  * Frame 01 : Energy +
                  * Frame 02 : Energy -
                  * Frame 03 : Attack +
                  * Frame 04 : Attack -
                  * Frame 05 : Defense +
                  * Frame 06 : Defense -
                  * Frame 07 : Speed +
                  * Frame 08 : Speed -
                  */
                 // Define the results data array and populate with basic fields
                 $this_results_data = array();
                 $this_results_data['results_amount_markup'] = '';
                 $this_results_data['results_effect_markup'] = '';
                 // Calculate the results effect canvas offsets
                 $this_results_data['canvas_offset_x'] = ceil($this_robot_data['canvas_offset_x'] - 4 * $this_options['this_ability_results']['total_actions']);
                 $this_results_data['canvas_offset_y'] = ceil($this_robot_data['canvas_offset_y'] + 0);
                 $this_results_data['canvas_offset_z'] = ceil($this_robot_data['canvas_offset_z'] - 20);
                 $temp_size_diff = $this_robot_data['robot_size'] > 80 ? ceil(($this_robot_data['robot_size'] - 80) * 0.5) : 0;
                 $this_results_data['canvas_offset_x'] += $temp_size_diff;
                 if ($this_robot_data['robot_position'] == 'bench' && $this_robot_data['robot_size'] >= 80) {
                     $this_results_data['canvas_offset_x'] += ceil($this_robot_data['robot_size'] / 2);
                 }
                 // Define the style and class variables for these results
                 $base_image_size = 40;
                 $this_results_data['ability_size'] = $this_robot_data['robot_position'] == 'active' ? $base_image_size * 2 : $base_image_size;
                 $this_results_data['ability_scale'] = isset($this_robot_data['robot_scale']) ? $this_robot_data['robot_scale'] : ($this_robot_data['robot_position'] == 'active' ? 1 : 0.5 + (8 - $this_robot_data['robot_key']) / 8 * 0.5);
                 $zoom_size = $base_image_size * 2;
                 $this_results_data['ability_sprite_size'] = ceil($this_results_data['ability_scale'] * $zoom_size);
                 $this_results_data['ability_sprite_width'] = ceil($this_results_data['ability_scale'] * $zoom_size);
                 $this_results_data['ability_sprite_height'] = ceil($this_results_data['ability_scale'] * $zoom_size);
                 $this_results_data['ability_image_width'] = ceil($this_results_data['ability_scale'] * $zoom_size * 10);
                 $this_results_data['ability_image_height'] = ceil($this_results_data['ability_scale'] * $zoom_size);
                 $this_results_data['results_amount_class'] = 'sprite ';
                 $this_results_data['results_amount_canvas_offset_y'] = $this_robot_data['canvas_offset_y'] + 50;
                 $this_results_data['results_amount_canvas_offset_x'] = $this_robot_data['canvas_offset_x'] - 40;
                 $this_results_data['results_amount_canvas_offset_z'] = $this_robot_data['canvas_offset_z'] + 100;
                 if (!empty($this_options['this_ability_results']['total_actions'])) {
                     $total_actions = $this_options['this_ability_results']['total_actions'];
                     if ($this_options['this_ability_results']['trigger_kind'] == 'damage') {
                         $this_results_data['results_amount_canvas_offset_y'] -= ceil(1.5 * $total_actions * $total_actions);
                         $this_results_data['results_amount_canvas_offset_x'] -= $total_actions * 4;
                     } elseif ($this_options['this_ability_results']['trigger_kind'] == 'recovery') {
                         $this_results_data['results_amount_canvas_offset_y'] = $this_robot_data['canvas_offset_y'] + 20;
                         $this_results_data['results_amount_canvas_offset_x'] = $this_robot_data['canvas_offset_x'] - 40;
                         $this_results_data['results_amount_canvas_offset_y'] += ceil(1.5 * $total_actions * $total_actions);
                         $this_results_data['results_amount_canvas_offset_x'] -= $total_actions * 4;
                     }
                 }
                 $this_results_data['results_amount_canvas_opacity'] = 1.0;
                 if ($this_robot_data['robot_position'] == 'bench') {
                     $this_results_data['results_amount_canvas_offset_x'] += 105;
                     //$this_results_data['results_amount_canvas_offset_x'] * -1;
                     $this_results_data['results_amount_canvas_offset_y'] += 5;
                     //10;
                     $this_results_data['results_amount_canvas_offset_z'] = $this_robot_data['canvas_offset_z'] + 1000;
                     $this_results_data['results_amount_canvas_opacity'] -= 0.1;
                 } else {
                     $this_results_data['canvas_offset_x'] += mt_rand(0, 10);
                     //jitter
                     $this_results_data['canvas_offset_y'] += mt_rand(0, 10);
                     //jitter
                 }
                 $this_results_data['results_amount_style'] = 'bottom: ' . $this_results_data['results_amount_canvas_offset_y'] . 'px; ' . $this_robot_data['robot_float'] . ': ' . $this_results_data['results_amount_canvas_offset_x'] . 'px; z-index: ' . $this_results_data['results_amount_canvas_offset_z'] . '; opacity: ' . $this_results_data['results_amount_canvas_opacity'] . '; ';
                 $this_results_data['results_effect_class'] = 'sprite sprite_' . $this_results_data['ability_sprite_size'] . 'x' . $this_results_data['ability_sprite_size'] . ' ability_status_active ability_position_active ';
                 //sprite_'.$this_robot_data['robot_size'].'x'.$this_robot_data['robot_size'].'
                 $this_results_data['results_effect_style'] = 'z-index: ' . $this_results_data['canvas_offset_z'] . '; ' . $this_robot_data['robot_float'] . ': ' . $this_results_data['canvas_offset_x'] . 'px; bottom: ' . $this_results_data['canvas_offset_y'] . 'px; background-image: url(images/sprites/abilities/ability-results/sprite_' . $this_robot_data['robot_direction'] . '_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '); ';
                 // Ensure a damage/recovery trigger has been sent and actual damage/recovery was done
                 if (!empty($this_options['this_ability_results']['this_amount']) && in_array($this_options['this_ability_results']['trigger_kind'], array('damage', 'recovery'))) {
                     // Define the results effect index
                     $this_results_data['results_effect_index'] = array();
                     // Check if the results effect index was already generated
                     if (!empty($this_battle->index['results_effects'])) {
                         // Collect the results effect index from the battle index
                         $this_results_data['results_effect_index'] = $this_battle->index['results_effects'];
                     } else {
                         // Define the results effect index for quick programatic lookups
                         $this_results_data['results_effect_index']['recovery']['energy'] = '00';
                         $this_results_data['results_effect_index']['damage']['energy'] = '01';
                         $this_results_data['results_effect_index']['recovery']['attack'] = '02';
                         $this_results_data['results_effect_index']['damage']['attack'] = '03';
                         $this_results_data['results_effect_index']['recovery']['defense'] = '04';
                         $this_results_data['results_effect_index']['damage']['defense'] = '05';
                         $this_results_data['results_effect_index']['recovery']['speed'] = '06';
                         $this_results_data['results_effect_index']['damage']['speed'] = '07';
                         $this_results_data['results_effect_index']['recovery']['weapons'] = '04';
                         $this_results_data['results_effect_index']['damage']['weapons'] = '05';
                         $this_results_data['results_effect_index']['recovery']['experience'] = '10';
                         $this_results_data['results_effect_index']['damage']['experience'] = '10';
                         $this_results_data['results_effect_index']['recovery']['level'] = '10';
                         $this_results_data['results_effect_index']['damage']['level'] = '10';
                         $this_battle->index['results_effects'] = $this_results_data['results_effect_index'];
                     }
                     // Check if a damage trigger was sent with the ability results
                     if ($this_options['this_ability_results']['trigger_kind'] == 'damage') {
                         // Append the ability damage kind to the class
                         $temp_smalltext_class = strlen($this_options['this_ability_results']['this_amount']) > 4 ? 'ability_damage_smalltext' : '';
                         $this_results_data['results_amount_class'] .= 'ability_damage ' . $temp_smalltext_class . ' ability_damage_' . $this_options['this_ability_results']['damage_kind'] . ' ';
                         if (!empty($this_options['this_ability_results']['flag_resistance'])) {
                             $this_results_data['results_amount_class'] .= 'ability_damage_' . $this_options['this_ability_results']['damage_kind'] . '_low ';
                         } elseif (!empty($this_options['this_ability_results']['flag_weakness']) || !empty($this_options['this_ability_results']['flag_critical'])) {
                             $this_results_data['results_amount_class'] .= 'ability_damage_' . $this_options['this_ability_results']['damage_kind'] . '_high ';
                         } else {
                             $this_results_data['results_amount_class'] .= 'ability_damage_' . $this_options['this_ability_results']['damage_kind'] . '_base ';
                         }
                         $frame_number = $this_results_data['results_effect_index']['damage'][$this_options['this_ability_results']['damage_kind']];
                         $frame_int = (int) $frame_number;
                         $frame_offset = $frame_int > 0 ? '-' . $frame_int * $this_results_data['ability_sprite_size'] : 0;
                         $frame_position = $frame_int;
                         if ($frame_position === false) {
                             $frame_position = 0;
                         }
                         $frame_background_offset = -1 * ceil($this_results_data['ability_sprite_size'] * $frame_position);
                         $this_results_data['results_effect_class'] .= 'sprite_' . $this_results_data['ability_sprite_size'] . 'x' . $this_results_data['ability_sprite_size'] . '_' . $frame_number . ' ';
                         $this_results_data['results_effect_style'] .= 'width: ' . $this_results_data['ability_sprite_size'] . 'px; height: ' . $this_results_data['ability_sprite_size'] . 'px; background-size: ' . $this_results_data['ability_image_width'] . 'px ' . $this_results_data['ability_image_height'] . 'px; background-position: ' . $frame_background_offset . 'px 0; ';
                         // Append the final damage results markup to the markup array
                         $this_results_data['results_amount_markup'] .= '<div class="' . $this_results_data['results_amount_class'] . '" style="' . $this_results_data['results_amount_style'] . '">-' . $this_options['this_ability_results']['this_amount'] . '</div>';
                         $this_results_data['results_effect_markup'] .= '<div class="' . $this_results_data['results_effect_class'] . '" style="' . $this_results_data['results_effect_style'] . '">-' . $this_options['this_ability_results']['damage_kind'] . '</div>';
                     } elseif ($this_options['this_ability_results']['trigger_kind'] == 'recovery') {
                         // Append the ability recovery kind to the class
                         $temp_smalltext_class = strlen($this_options['this_ability_results']['this_amount']) > 4 ? 'ability_recovery_smalltext' : '';
                         $this_results_data['results_amount_class'] .= 'ability_recovery ' . $temp_smalltext_class . ' ability_recovery_' . $this_options['this_ability_results']['recovery_kind'] . ' ';
                         if (!empty($this_options['this_ability_results']['flag_resistance'])) {
                             $this_results_data['results_amount_class'] .= 'ability_recovery_' . $this_options['this_ability_results']['recovery_kind'] . '_low ';
                         } elseif (!empty($this_options['this_ability_results']['flag_affinity']) || !empty($this_options['this_ability_results']['flag_critical'])) {
                             $this_results_data['results_amount_class'] .= 'ability_recovery_' . $this_options['this_ability_results']['recovery_kind'] . '_high ';
                         } else {
                             $this_results_data['results_amount_class'] .= 'ability_recovery_' . $this_options['this_ability_results']['recovery_kind'] . '_base ';
                         }
                         $frame_number = $this_results_data['results_effect_index']['recovery'][$this_options['this_ability_results']['recovery_kind']];
                         $frame_int = (int) $frame_number;
                         $frame_offset = $frame_int > 0 ? '-' . $frame_int * $this_results_data['ability_size'] : 0;
                         $frame_position = $frame_int;
                         if ($frame_position === false) {
                             $frame_position = 0;
                         }
                         $frame_background_offset = -1 * ceil($this_results_data['ability_sprite_size'] * $frame_position);
                         $this_results_data['results_effect_class'] .= 'sprite_' . $this_results_data['ability_sprite_size'] . 'x' . $this_results_data['ability_sprite_size'] . '_' . $frame_number . ' ';
                         $this_results_data['results_effect_style'] .= 'width: ' . $this_results_data['ability_sprite_size'] . 'px; height: ' . $this_results_data['ability_sprite_size'] . 'px; background-size: ' . $this_results_data['ability_image_width'] . 'px ' . $this_results_data['ability_image_height'] . 'px; background-position: ' . $frame_background_offset . 'px 0; ';
                         // Append the final recovery results markup to the markup array
                         $this_results_data['results_amount_markup'] .= '<div class="' . $this_results_data['results_amount_class'] . '" style="' . $this_results_data['results_amount_style'] . '">+' . $this_options['this_ability_results']['this_amount'] . '</div>';
                         $this_results_data['results_effect_markup'] .= '<div class="' . $this_results_data['results_effect_class'] . '" style="' . $this_results_data['results_effect_style'] . '">+' . $this_options['this_ability_results']['recovery_kind'] . '</div>';
                     }
                 }
                 // Append this result's markup to the main markup array
                 $this_markup .= $this_results_data['results_amount_markup'];
                 $this_markup .= $this_results_data['results_effect_markup'];
             }
             // ATTACHMENT ANIMATION STUFF
             if (empty($this_robot->flags['apply_disabled_state']) && !empty($this_robot->robot_attachments)) {
                 // Loop through each attachment and process it
                 foreach ($this_robot->robot_attachments as $attachment_token => $attachment_info) {
                     // If this is an ability attachment
                     if ($attachment_info['class'] == 'ability') {
                         // Create the temporary ability object using the provided data and generate its markup data
                         $this_ability = new rpg_ability($eventinfo['this_player'], $this_robot, $attachment_info);
                         // Define this ability data array and generate the markup data
                         $this_attachment_options = $this_options;
                         $this_attachment_options['sticky'] = isset($attachment_info['sticky']) ? $attachment_info['sticky'] : false;
                         $this_attachment_options['data_sticky'] = $this_attachment_options['sticky'];
                         $this_attachment_options['data_type'] = 'attachment';
                         $this_attachment_options['data_debug'] = '';
                         //$attachment_token;
                         $this_attachment_options['ability_image'] = isset($attachment_info['ability_image']) ? $attachment_info['ability_image'] : $this_ability->ability_image;
                         $this_attachment_options['ability_frame'] = isset($attachment_info['ability_frame']) ? $attachment_info['ability_frame'] : $this_ability->ability_frame;
                         $this_attachment_options['ability_frame_span'] = isset($attachment_info['ability_frame_span']) ? $attachment_info['ability_frame_span'] : $this_ability->ability_frame_span;
                         $this_attachment_options['ability_frame_animate'] = isset($attachment_info['ability_frame_animate']) ? $attachment_info['ability_frame_animate'] : $this_ability->ability_frame_animate;
                         $attachment_frame_count = !empty($this_attachment_options['ability_frame_animate']) ? sizeof($this_attachment_options['ability_frame_animate']) : sizeof($this_attachment_options['ability_frame']);
                         $temp_event_frame = $this_battle->counters['event_frames'];
                         if ($temp_event_frame == 1 || $attachment_frame_count == 1) {
                             $attachment_frame_key = 0;
                         } elseif ($temp_event_frame < $attachment_frame_count) {
                             $attachment_frame_key = $temp_event_frame;
                         } elseif ($temp_event_frame >= $attachment_frame_count) {
                             $attachment_frame_key = $temp_event_frame % $attachment_frame_count;
                         }
                         if (isset($this_attachment_options['ability_frame_animate'][$attachment_frame_key])) {
                             $this_attachment_options['ability_frame'] = $this_attachment_options['ability_frame_animate'][$attachment_frame_key];
                         }
                         $this_attachment_options['ability_frame_offset'] = isset($attachment_info['ability_frame_offset']) ? $attachment_info['ability_frame_offset'] : $this_ability->ability_frame_offset;
                         $this_attachment_options['ability_frame_styles'] = isset($attachment_info['ability_frame_styles']) ? $attachment_info['ability_frame_styles'] : $this_ability->ability_frame_styles;
                         $this_attachment_options['ability_frame_classes'] = isset($attachment_info['ability_frame_classes']) ? $attachment_info['ability_frame_classes'] : $this_ability->ability_frame_classes;
                         $this_ability_data = $this_ability->get_canvas_markup($this_attachment_options, $this_player_data, $this_robot_data);
                         // Append this ability's markup to the main markup array
                         if (!preg_match('/display:\\s?none;/i', $this_robot->robot_frame_styles)) {
                             $this_markup .= $this_ability_data['ability_markup'];
                         }
                     }
                 }
             }
             // ABILITY ANIMATION STUFF
             if (!empty($this_options['this_ability']) && !empty($options['canvas_show_this_ability'])) {
                 // Define the ability data array and generate markup data
                 $attachment_options['data_type'] = 'ability';
                 $this_ability_data = $this_options['this_ability']->get_canvas_markup($this_options, $this_player_data, $this_robot_data);
                 // Display the ability's mugshot sprite
                 if (empty($this_options['this_ability_results']['total_actions'])) {
                     $this_mugshot_markup_left = '<div class="sprite ability_icon ability_icon_left" style="background-image: url(images/sprites/abilities/' . (!empty($this_options['this_ability']->ability_image) ? $this_options['this_ability']->ability_image : $this_options['this_ability']->ability_token) . '/icon_' . $this_robot_data['robot_direction'] . '_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . ');"></div>';
                     $this_mugshot_markup_right = '<div class="sprite ability_icon ability_icon_right" style="background-image: url(images/sprites/abilities/' . (!empty($this_options['this_ability']->ability_image) ? $this_options['this_ability']->ability_image : $this_options['this_ability']->ability_token) . '/icon_' . $this_robot_data['robot_direction'] . '_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . ');"></div>';
                     if (!empty($eventinfo['this_robot']) && !empty($eventinfo['target_robot']) && $eventinfo['this_robot']->robot_id != $eventinfo['target_robot']->robot_id) {
                         // Check to make sure starforce is enabled right now
                         $temp_starforce_enabled = true;
                         if (!empty($eventinfo['this_player']->counters['dark_elements'])) {
                             $temp_starforce_enabled = false;
                         }
                         if (!empty($eventinfo['target_player']->counters['dark_elements'])) {
                             $temp_starforce_enabled = false;
                         }
                         // Collect the attack value from this robot
                         $temp_attack_value = $eventinfo['this_robot']->robot_attack;
                         $temp_attack_markup = $temp_attack_value . ' AT';
                         // If this player has starforce, increase the attack amount appropriately
                         if ($temp_starforce_enabled && !empty($eventinfo['this_player']->player_starforce)) {
                             // Check to ensure this ability actually has a type before proceeding
                             if (!empty($this_options['this_ability']->ability_type)) {
                                 // Define the boost value and start at zero
                                 $temp_boost_value = 0;
                                 // If the player has a matching starforce amount, add the value
                                 if (!empty($eventinfo['this_player']->player_starforce[$this_options['this_ability']->ability_type])) {
                                     // Collect the force value for the first ability type
                                     $temp_force_value = $eventinfo['this_player']->player_starforce[$this_options['this_ability']->ability_type];
                                     // Increase the attack with the value times the boost constant
                                     $temp_boost_value = $temp_force_value * MMRPG_SETTINGS_STARS_ATTACKBOOST;
                                     $temp_attack_value += $temp_boost_value;
                                 }
                                 // And if the ability has a second type, process that too
                                 if (!empty($this_options['this_ability']->ability_type2)) {
                                     // If the player has a matching starforce amount, add the value
                                     if (!empty($eventinfo['this_player']->player_starforce[$this_options['this_ability']->ability_type2])) {
                                         // Collect the force value for the second ability type
                                         $temp_force_value = $eventinfo['this_player']->player_starforce[$this_options['this_ability']->ability_type2];
                                         // Increase the attack with the value times the boost constant
                                         $temp_boost_value = $temp_force_value * MMRPG_SETTINGS_STARS_ATTACKBOOST;
                                         $temp_attack_value += $temp_boost_value;
                                     }
                                 }
                                 // If there was a starforce boost, display it
                                 if ($temp_boost_value > 0) {
                                     // Append a star to the markup so people know it's boosted
                                     $temp_attack_markup .= ' +' . $temp_boost_value . '<span class="star">&#9733;</span>';
                                 }
                             }
                         }
                         // Collect the defense value for the target robot
                         $temp_defense_value = $eventinfo['target_robot']->robot_defense;
                         $temp_defense_markup = $temp_defense_value . ' DF';
                         // If the target player has starforce, increase the defense amount appropriately
                         if ($temp_starforce_enabled && !empty($eventinfo['target_player']->player_starforce)) {
                             // Check to ensure this ability actually has a type before proceeding
                             if (!empty($this_options['this_ability']->ability_type)) {
                                 // Define the boost value and start at zero
                                 $temp_boost_value = 0;
                                 // If the player has a matching starforce amount, add the value
                                 if (!empty($eventinfo['target_player']->player_starforce[$this_options['this_ability']->ability_type])) {
                                     // Collect the force value for the first ability type
                                     $temp_force_value = $eventinfo['target_player']->player_starforce[$this_options['this_ability']->ability_type];
                                     // Increase the defense with the value times the boost constant
                                     $temp_boost_value = $temp_force_value * MMRPG_SETTINGS_STARS_DEFENSEBOOST;
                                     $temp_defense_value += $temp_boost_value;
                                 }
                                 // And if the ability has a second type, process that too
                                 if (!empty($this_options['this_ability']->ability_type2)) {
                                     // If the player has a matching starforce amount, add the value
                                     if (!empty($eventinfo['target_player']->player_starforce[$this_options['this_ability']->ability_type2])) {
                                         // Collect the force value for the second ability type
                                         $temp_force_value = $eventinfo['target_player']->player_starforce[$this_options['this_ability']->ability_type2];
                                         // Increase the defense with the value times the boost constant
                                         $temp_boost_value = $temp_force_value * MMRPG_SETTINGS_STARS_DEFENSEBOOST;
                                         $temp_defense_value += $temp_boost_value;
                                     }
                                 }
                                 // If there was a starforce boost, display it
                                 if ($temp_boost_value > 0) {
                                     // Append a star to the markup so people know it's boosted
                                     $temp_defense_markup .= ' +' . $temp_boost_value . '<span class="star">&#9733;</span>';
                                 }
                             }
                         }
                         // Position the attack and defense values to right/left depending on player side
                         if ($eventinfo['this_player']->player_side == 'left') {
                             $this_stat_markup_left = '<span class="robot_stat robot_stat_left type_attack">' . $temp_attack_markup . '</span>';
                             $this_stat_markup_right = '<span class="robot_stat robot_stat_right type_defense">' . $temp_defense_markup . '</span>';
                         } elseif ($eventinfo['this_player']->player_side == 'right') {
                             $this_stat_markup_left = '<span class="robot_stat robot_stat_left type_defense">' . $temp_defense_markup . '</span>';
                             $this_stat_markup_right = '<span class="robot_stat robot_stat_right type_attack">' . $temp_attack_markup . '</span>';
                         }
                         // Always show the attack name and type at this point
                         $this_markup .= '<div class="' . $this_ability_data['ability_markup_class'] . ' canvas_ability_details ability_type ability_type_' . (!empty($this_options['this_ability']->ability_type) ? $this_options['this_ability']->ability_type : 'none') . (!empty($this_options['this_ability']->ability_type2) ? '_' . $this_options['this_ability']->ability_type2 : '') . '">' . $this_mugshot_markup_left . '<div class="ability_name" style="">' . $this_ability_data['ability_title'] . '</div>' . $this_mugshot_markup_right . '</div>';
                         // Only show stat amounts if we're not targetting ourselves
                         if ($this_options['canvas_show_ability_stats'] && $eventinfo['this_robot']->robot_id != $this_options['this_ability_results']['trigger_target_id']) {
                             $this_markup .= '<div class="' . $this_ability_data['ability_markup_class'] . ' canvas_ability_stats"><div class="wrap">' . $this_stat_markup_left . '<span class="vs">vs</span>' . $this_stat_markup_right . '</div></div>';
                         }
                     }
                 }
                 // Append this ability's markup to the main markup array
                 $this_markup .= $this_ability_data['ability_markup'];
             }
             // Append this robot's markup to the main markup array
             $this_markup .= $this_robot_data['robot_markup'];
         }
     }
     // Collect the target player's markup data
     $target_player_data = $eventinfo['target_player']->get_canvas_markup($options);
     // Append the target player's markup to the main markup array
     $this_markup .= $target_player_data['player_markup'];
     // Loop through and display the target player's robots
     if ($options['canvas_show_target_robots'] && !empty($eventinfo['target_player']->player_robots)) {
         // Count the number of robots on the target's side of the field
         $num_player_robots = count($eventinfo['target_player']->player_robots);
         // Loop through each target robot and generate it's markup
         foreach ($eventinfo['target_player']->player_robots as $target_key => $target_robotinfo) {
             // Create the temporary target robot ovject
             $target_robot = new rpg_robot($eventinfo['target_player'], $target_robotinfo);
             $target_options = $options;
             //if ($target_robot->robot_status == 'disabled' && $target_robot->robot_position == 'bench'){ continue; }
             if (!empty($target_robot->flags['hidden'])) {
                 continue;
             } elseif (!empty($eventinfo['target_robot']->robot_id) && $eventinfo['target_robot']->robot_id != $target_robot->robot_id) {
                 $target_options['this_ability'] = false;
             } elseif (!empty($eventinfo['target_robot']->robot_id) && $eventinfo['target_robot']->robot_id == $target_robot->robot_id && $options['canvas_show_target'] != false) {
                 $target_robot->robot_frame = $eventinfo['target_robot']->robot_frame;
             }
             $target_robot->robot_key = $target_robot->robot_key !== false ? $target_robot->robot_key : ($target_key > 0 ? $target_key : $num_player_robots);
             $target_robot_data = $target_robot->get_canvas_markup($target_options, $target_player_data);
             // ATTACHMENT ANIMATION STUFF
             if (empty($target_robot->flags['apply_disabled_state']) && !empty($target_robot->robot_attachments)) {
                 // Loop through each attachment and process it
                 foreach ($target_robot->robot_attachments as $attachment_token => $attachment_info) {
                     // If this is an ability attachment
                     if ($attachment_info['class'] == 'ability') {
                         // Create the target's temporary ability object using the provided data
                         $target_ability = new rpg_ability($eventinfo['target_player'], $target_robot, $attachment_info);
                         // Define this ability data array and generate the markup data
                         $target_attachment_options = $target_options;
                         $target_attachment_options['sticky'] = isset($attachment_info['sticky']) ? $attachment_info['sticky'] : false;
                         $target_attachment_options['data_sticky'] = $target_attachment_options['sticky'];
                         $target_attachment_options['data_type'] = 'attachment';
                         $target_attachment_options['data_debug'] = '';
                         //$attachment_token;
                         $target_attachment_options['ability_image'] = isset($attachment_info['ability_image']) ? $attachment_info['ability_image'] : $target_ability->ability_image;
                         $target_attachment_options['ability_frame'] = isset($attachment_info['ability_frame']) ? $attachment_info['ability_frame'] : $target_ability->ability_frame;
                         $target_attachment_options['ability_frame_span'] = isset($attachment_info['ability_frame_span']) ? $attachment_info['ability_frame_span'] : $target_ability->ability_frame_span;
                         $target_attachment_options['ability_frame_animate'] = isset($attachment_info['ability_frame_animate']) ? $attachment_info['ability_frame_animate'] : $target_ability->ability_frame_animate;
                         $attachment_frame_key = 0;
                         $attachment_frame_count = sizeof($target_attachment_options['ability_frame_animate']);
                         $temp_event_frame = $this_battle->counters['event_frames'];
                         if ($temp_event_frame == 1 || $attachment_frame_count == 1) {
                             $attachment_frame_key = 0;
                         } elseif ($temp_event_frame < $attachment_frame_count) {
                             $attachment_frame_key = $temp_event_frame;
                         } elseif ($attachment_frame_count > 0 && $temp_event_frame >= $attachment_frame_count) {
                             $attachment_frame_key = $temp_event_frame % $attachment_frame_count;
                         }
                         if (isset($target_attachment_options['ability_frame_animate'][$attachment_frame_key])) {
                             $target_attachment_options['ability_frame'] = $target_attachment_options['ability_frame_animate'][$attachment_frame_key];
                         } else {
                             $target_attachment_options['ability_frame'] = 0;
                         }
                         $target_attachment_options['ability_frame_offset'] = isset($attachment_info['ability_frame_offset']) ? $attachment_info['ability_frame_offset'] : $target_ability->ability_frame_offset;
                         $target_attachment_options['ability_frame_styles'] = isset($attachment_info['ability_frame_styles']) ? $attachment_info['ability_frame_styles'] : $target_ability->ability_frame_styles;
                         $target_attachment_options['ability_frame_classes'] = isset($attachment_info['ability_frame_classes']) ? $attachment_info['ability_frame_classes'] : $target_ability->ability_frame_classes;
                         $target_ability_data = $target_ability->get_canvas_markup($target_attachment_options, $target_player_data, $target_robot_data);
                         // Append this target's ability's markup to the main markup array
                         if (!preg_match('/display:\\s?none;/i', $target_robot->robot_frame_styles)) {
                             $this_markup .= $target_ability_data['ability_markup'];
                         }
                     }
                 }
             }
             $this_markup .= $target_robot_data['robot_markup'];
         }
     }
     // Append the field multipliers to the canvas markup
     if (!empty($this_battle->battle_field->field_multipliers)) {
         $temp_multipliers = $this_battle->battle_field->field_multipliers;
         asort($temp_multipliers);
         $temp_multipliers = array_reverse($temp_multipliers, true);
         $temp_multipliers_count = count($temp_multipliers);
         $this_special_types = array('experience', 'damage', 'recovery', 'items');
         $multiplier_markup_left = '';
         $multiplier_markup_right = '';
         foreach ($temp_multipliers as $this_type => $this_multiplier) {
             if ($this_type == 'experience' && rpg_game::is_demo()) {
                 continue;
             }
             if ($this_multiplier == 1) {
                 continue;
             }
             if ($this_multiplier < MMRPG_SETTINGS_MULTIPLIER_MIN) {
                 $this_multiplier = MMRPG_SETTINGS_MULTIPLIER_MIN;
             } elseif ($this_multiplier > MMRPG_SETTINGS_MULTIPLIER_MAX) {
                 $this_multiplier = MMRPG_SETTINGS_MULTIPLIER_MAX;
             }
             $temp_name = $this_type != 'none' ? ucfirst($this_type) : 'Neutral';
             $temp_number = number_format($this_multiplier, 1);
             $temp_title = $temp_name . ' x ' . $temp_number;
             if ($temp_multipliers_count >= 8) {
                 $temp_name = substr($temp_name, 0, 2);
             }
             $temp_markup = '<span title="' . $temp_title . '" data-tooltip-align="center" class="field_multiplier field_multiplier_' . $this_type . ' field_multiplier_count_' . $temp_multipliers_count . ' field_type field_type_' . $this_type . '"><span class="text"><span class="name">' . $temp_name . ' </span><span class="cross">x</span><span class="number"> ' . $temp_number . '</span></span></span>';
             if (in_array($this_type, $this_special_types)) {
                 $multiplier_markup_left .= $temp_markup;
             } else {
                 $multiplier_markup_right .= $temp_markup;
             }
         }
         if (!empty($multiplier_markup_left) || !empty($multiplier_markup_right)) {
             $this_markup .= '<div class="canvas_overlay_footer"><strong class="overlay_label">Field Multipliers</strong><span class="overlay_multiplier_count_' . $temp_multipliers_count . '">' . $multiplier_markup_left . $multiplier_markup_right . '</div></div>';
         }
     }
     // If this battle is over, display the mission complete/failed result
     if ($this_battle->battle_status == 'complete') {
         if ($this_battle->battle_result == 'victory') {
             $result_text = 'Mission Complete!';
             $result_class = 'nature';
         } elseif ($this_battle->battle_result == 'defeat') {
             $result_text = 'Mission Failure&hellip;';
             $result_class = 'flame';
         }
         if (!empty($this_markup) && $this_battle->battle_status == 'complete' || $this_battle->battle_result == 'defeat') {
             $this_mugshot_markup_left = '<div class="sprite ability_icon ability_icon_left">&nbsp;</div>';
             $this_mugshot_markup_right = '<div class="sprite ability_icon ability_icon_right">&nbsp;</div>';
             $this_markup = '<div class="sprite canvas_ability_details ability_type ability_type_' . $result_class . '">' . $this_mugshot_markup_left . '<div class="ability_name">' . $result_text . '</div>' . $this_mugshot_markup_right . '</div>' . $this_markup;
         }
     }
     // Return the generated markup and robot data
     return $this_markup;
 }