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 . ''s ' : '') . $this_robot->robot_name; $event_body = ($this_player->player_token != 'player' ? $this_player->print_name() . ''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() . ''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() . ''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() . ''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 . ''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 . ''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 ? ' ★' : '') . '</span>!<br /> '; $event_body .= $temp_robot->robot_name . ''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() . ''s health improved! '; $event_body .= '<br />'; $event_body .= $temp_robot->print_name() . ''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() . ''s weapons improved! '; $event_body .= '<br />'; $event_body .= $temp_robot->print_name() . ''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() . ''s shields improved! '; $event_body .= '<br />'; $event_body .= $temp_robot->print_name() . ''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() . ''s mobility improved! '; $event_body .= '<br />'; $event_body .= $temp_robot->print_name() . ''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…'; } 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.''s Data Destroyed'; $event_body = $this->print_name().''s battle data was damaged beyond repair!<br />'; $event_body .= $this->print_name().' could not be unlocked for use in battle…'; $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; }
<?php /* * DEMO ROBOT SELECT */ if (!empty($_SESSION[$session_token]['DEMO'])) { // Only show robot select if the player has more than two robots if (rpg_game::robots_unlocked('dr-light') > 3) { // Print out the demo mode's robot select screen for Dr. Light echo '<div class="option_wrapper option_wrapper_hidden" data-condition="this_player_token=dr-light">' . "\n"; if (defined('MMRPG_SCRIPT_REQUEST')) { echo $prototype_data['demo']['robots_markup'] . "\n"; } else { echo '<a class="option option_sticky option_1x4 option_this-team-select option_disabled block_9" data-parent="true" data-token="" style=""><div class="platform"><div class="chrome"><div class="inset"><label class="has_image" style="width: 100px; margin-left: 70%; padding-left: 0;"><span class="single"><span class="count">0/8 Select</span><span class="arrow"> </span></span></label></div></div></div></a>' . "\n"; } echo '</div>' . "\n"; } } else { // Only print out Light's data if conditions allow or do not exist if (empty($this_data_condition) || in_array('this_player_token=dr-light', $this_data_condition)) { // Print out the normal mode's robot select screen for Dr. Light if ($unlock_flag_light) { echo '<div class="option_wrapper option_wrapper_hidden" data-condition="this_player_token=dr-light">' . "\n"; if (defined('MMRPG_SCRIPT_REQUEST')) { echo $prototype_data['dr-light']['robots_markup'] . "\n"; } else { echo '<a class="option option_sticky option_1x4 option_this-team-select option_disabled block_9" data-parent="true" data-token="" style=""><div class="platform"><div class="chrome"><div class="inset"><label class="has_image" style=""><span class="single"><span class="count">0/8 Select</span><span class="arrow"> </span></span></label></div></div></div></a>' . "\n"; } echo '</div>' . "\n"; } }
define('MMRPG_REMOTE_SKIP_STARS', true); require(MMRPG_CONFIG_ROOTDIR.'frames/remote_top.php'); // Collect the session token $session_token = rpg_game::session_token(); // Collect the editor flag if set $global_allow_editing = isset($_GET['edit']) && $_GET['edit'] == 'false' ? false : true; // Collect the number of completed battles for each player $unlock_flag_light = rpg_game::player_unlocked('dr-light'); $battles_complete_light = $unlock_flag_light ? rpg_prototype::battles_complete('dr-light') : 0; $unlock_flag_wily = rpg_game::player_unlocked('dr-wily'); $battles_complete_wily = $unlock_flag_wily ? rpg_prototype::battles_complete('dr-wily') : 0; $unlock_flag_cossack = rpg_game::player_unlocked('dr-cossack'); $battles_complete_cossack = $unlock_flag_cossack ? rpg_prototype::battles_complete('dr-cossack') : 0; $prototype_complete_flag = rpg_prototype::campaign_complete(); // Count the number of players unlocked $unlock_count_players = 0; if ($unlock_flag_light){ $unlock_count_players++; } if ($unlock_flag_wily){ $unlock_count_players++; } if ($unlock_flag_cossack){ $unlock_count_players++; } // Define a reference to the game's session flag variable if (empty($_SESSION[$session_token]['flags']['events'])){ $_SESSION[$session_token]['flags']['events'] = array(); } $temp_game_flags = &$_SESSION[$session_token]['flags']['events']; // Require the appropriate database files define('DATA_DATABASE_SHOW_CACHE', true);
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'])): ?> // Start playing the title screen music parent.mmrpg_music_load('misc/player-select', true, false);
//$this_graph_data['image'] = MMRPG_CONFIG_ROOTURL.'images/assets/mmrpg-prototype-logo.png'; //$this_graph_data['type'] = 'website'; // Define the MARKUP variables for this page $this_markup_header = 'Mega Man RPG World Community'; // Generate field lists for the relevant community database tables $db_category_fields = rpg_website::get_category_fields(true, 'categories'); $db_thread_fields = rpg_website::get_thread_fields(true, 'threads'); $db_post_fields = rpg_website::get_post_fields(true, 'posts'); $db_role_fields = rpg_user_role::get_fields(true, 'roles'); $db_user_fields = rpg_user::get_fields(true, 'users'); /* * COLLECT FORMACTIONS */ // Collect this player's battle point total if (empty($_SESSION[rpg_game::session_token()]['DEMO'])) { $community_battle_points = rpg_game::battle_points(); } else { $community_battle_points = 0; } // Collect all the categories from the index $this_categories_index = rpg_website::community_index(); $this_categories_index_tokens = array(); foreach ($this_categories_index as $token => $info) { $this_categories_index_tokens[$info['category_id']] = $token; } // Include the community form actions require_once 'pages/community_actions.php'; /* * COLLECT INDEXES */ // Define the view based on available data
} ?> </div> </form> </div> <?php } elseif ($this_action == 'game') { ?> <?php // Define the temp game flags $this_playerinfo = $this_userinfo; $temp_show_players = rpg_game::players_unlocked() > 1 ? true : false; $temp_show_starforce = rpg_prototype::campaign_complete() ? true : false; $temp_colour_token = !empty($this_playerinfo['user_colour_token']) ? $this_playerinfo['user_colour_token'] : 'none'; ?> <h2 class="subheader field_type_<?php echo MMRPG_SETTINGS_CURRENT_FIELDTYPE; ?> ">My Account » <?php echo $html_header_title; ?> </h2> <div class="subbody" style="padding-left: 15px; margin-bottom: 2px; "> <?php echo !strstr($html_header_text, '</p>') ? '<p class="text">' . $html_header_text . '</p>' : $html_header_text;
public static function print_editor_select_markup($ability_rewards_options, $player_info, $robot_info, $ability_info, $ability_key = 0) { // Define the global variables global $mmrpg_index, $this_current_uri, $this_current_url, $db; global $allowed_edit_players, $allowed_edit_robots, $allowed_edit_abilities; global $allowed_edit_data_count, $allowed_edit_player_count, $allowed_edit_robot_count, $first_robot_token, $global_allow_editing; global $key_counter, $player_rewards, $player_ability_rewards, $player_robot_favourites, $player_robot_database, $temp_robot_totals, $player_options_markup, $item_options_markup; global $mmrpg_database_abilities; $session_token = rpg_game::session_token(); if (empty($robot_info)) { return false; } if (empty($ability_info)) { return false; } // Define the select markup variable $this_select_markup = ''; $ability_info_id = $ability_info['ability_id']; $ability_info_token = $ability_info['ability_token']; $ability_info_name = $ability_info['ability_name']; $ability_info_energy = isset($ability_info['ability_energy']) ? $ability_info['ability_energy'] : 4; $ability_info_damage = !empty($ability_info['ability_damage']) ? $ability_info['ability_damage'] : 0; $ability_info_damage2 = !empty($ability_info['ability_damage2']) ? $ability_info['ability_damage2'] : 0; $ability_info_damage_percent = !empty($ability_info['ability_damage_percent']) ? true : false; $ability_info_damage2_percent = !empty($ability_info['ability_damage2_percent']) ? true : false; if ($ability_info_damage_percent && $ability_info_damage > 100) { $ability_info_damage = 100; } if ($ability_info_damage2_percent && $ability_info_damage2 > 100) { $ability_info_damage2 = 100; } $ability_info_recovery = !empty($ability_info['ability_recovery']) ? $ability_info['ability_recovery'] : 0; $ability_info_recovery2 = !empty($ability_info['ability_recovery2']) ? $ability_info['ability_recovery2'] : 0; $ability_info_recovery_percent = !empty($ability_info['ability_recovery_percent']) ? true : false; $ability_info_recovery2_percent = !empty($ability_info['ability_recovery2_percent']) ? true : false; if ($ability_info_recovery_percent && $ability_info_recovery > 100) { $ability_info_recovery = 100; } if ($ability_info_recovery2_percent && $ability_info_recovery2 > 100) { $ability_info_recovery2 = 100; } $ability_info_accuracy = !empty($ability_info['ability_accuracy']) ? $ability_info['ability_accuracy'] : 0; $ability_info_description = !empty($ability_info['ability_description']) ? $ability_info['ability_description'] : ''; $ability_info_description = str_replace('{DAMAGE}', $ability_info_damage, $ability_info_description); $ability_info_description = str_replace('{RECOVERY}', $ability_info_recovery, $ability_info_description); $ability_info_description = str_replace('{DAMAGE2}', $ability_info_damage2, $ability_info_description); $ability_info_description = str_replace('{RECOVERY2}', $ability_info_recovery2, $ability_info_description); $ability_info_title = rpg_ability::print_editor_title_markup($robot_info, $ability_info); $ability_info_title_plain = strip_tags(str_replace('<br />', '//', $ability_info_title)); $ability_info_title_tooltip = htmlentities($ability_info_title, ENT_QUOTES, 'UTF-8'); $ability_info_title_html = str_replace(' ', ' ', $ability_info_name); $temp_select_options = str_replace('value="' . $ability_info_token . '"', 'value="' . $ability_info_token . '" selected="selected" disabled="disabled"', $ability_rewards_options); $ability_info_title_html = '<label style="background-image: url(i/a/' . $ability_info_token . '/il40.png?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $ability_info_title_html . '<span class="arrow">∇</span></label>'; //if ($global_allow_editing){ $ability_info_title_html .= '<select class="ability_name" data-key="'.$ability_key.'" data-player="'.$player_info['player_token'].'" data-robot="'.$robot_info['robot_token'].'">'.$temp_select_options.'</select>'; } $this_select_markup = '<a class="ability_name ability_type ability_type_' . (!empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none') . (!empty($ability_info['ability_type2']) ? '_' . $ability_info['ability_type2'] : '') . '" style="' . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-id="' . $ability_info_id . '" data-key="' . $ability_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-ability="' . $ability_info_token . '" data-type="' . (!empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none') . '" data-type2="' . (!empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : '') . '" title="' . $ability_info_title_plain . '" data-tooltip="' . $ability_info_title_tooltip . '">' . $ability_info_title_html . '</a>'; // Return the generated select markup return $this_select_markup; }
$('.form .buttons').append('<input class="button button_submit" type="submit" value="Submit" />'); <? endif; ?> <? if(false && MMRPG_CONFIG_IS_LIVE): ?> // Add the Facebook like and page buttons to the predefined areas $('#header_social_facebook').append('<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmegamanpoweredup.net%2Frpg2k11%2F&send=false&layout=button_count&width=100&show_faces=false&font&colorscheme=light&action=like&height=21&appId=409819409099131" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>'); $('#header_social_google').append('<div class="g-plusone" data-annotation="none" data-href="<?= MMRPG_CONFIG_ROOTURL ?>"></div>'); // Initiate the +1 button (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); <? endif; ?> <? if(!empty($this_markup_jsready)): ?> <?= $this_markup_jsready."\n" ?> <? endif; ?> }); </script> <?php // Require the remote bottom in case we're in viewer mode require(MMRPG_CONFIG_ROOTDIR.'includes/analytics.php'); ?> </body> </html> <?php // If we're NOT in demo mode, automatically update the date-accessed for their database entry if (rpg_game::is_user()){ $temp_query = 'UPDATE mmrpg_users SET user_date_accessed = '.time().' WHERE user_id = '.$_SESSION['GAME']['USER']['userid']; $temp_result = $db->query($temp_query); } ?>
public static function robot_select_markup($this_prototype_data) { // Refence the global config and index objects for easy access global $db; // Define the temporary robot markup string $this_robots_markup = ''; // 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'); // Collect the ability index for calculation purposes $this_ability_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token'); // Loop through and display the available robot options for this player $temp_robot_option_count = count($this_prototype_data['robot_options']); $temp_player_favourites = rpg_game::robot_favourites(); foreach ($this_prototype_data['robot_options'] as $key => $info) { $info = array_merge($this_robot_index[$info['robot_token']], $info); if (!isset($info['original_player'])) { $info['original_player'] = $this_prototype_data['this_player_token']; } $this_option_class = 'option option_this-robot-select option_this-' . $info['original_player'] . '-robot-select option_' . ($temp_robot_option_count == 1 ? '1x4' : ($this_prototype_data['robots_unlocked'] <= 2 ? '1x2' : '1x1')) . ' option_' . $info['robot_token'] . ' block_' . ($key + 1); $this_option_style = ''; $this_option_token = $info['robot_id'] . '_' . $info['robot_token']; $this_option_image = !empty($info['robot_image']) ? $info['robot_image'] : $info['robot_token']; $this_option_size = !empty($info['robot_image_size']) ? $info['robot_image_size'] : 40; $temp_size = $this_option_size; $temp_size_text = $temp_size . 'x' . $temp_size; $temp_top = -2 + (40 - $temp_size); $temp_right_inc = $temp_size > 40 ? ceil($temp_size * 0.5 - 60) : 0; $temp_right = 15 + $temp_right_inc; $this_robot_name = $info['robot_name']; $this_robot_rewards = rpg_game::robot_rewards($this_prototype_data['this_player_token'], $info['robot_token']); $this_robot_settings = rpg_game::robot_settings($this_prototype_data['this_player_token'], $info['robot_token']); $this_robot_experience = rpg_game::robot_experience($this_prototype_data['this_player_token'], $info['robot_token']); $this_robot_level = rpg_game::robot_level($this_prototype_data['this_player_token'], $info['robot_token']); $this_experience_required = rpg_prototype::calculate_experience_required($this_robot_level); $this_robot_abilities = rpg_game::abilities_unlocked($this_prototype_data['this_player_token'], $info['robot_token']); $text_robot_special = $this_robot_level >= 100 || !empty($this_robot_rewards['flags']['reached_max_level']) ? true : false; $this_robot_experience = $this_robot_level >= 100 ? '<span style="position: relative; bottom: 0; font-size: 120%;">∞</span>' : $this_robot_experience; $this_robot_experience_title = $this_robot_level >= 100 ? '∞' : $this_robot_experience; $this_robot_favourite = in_array($info['robot_token'], $temp_player_favourites) ? true : false; $this_robot_name .= $this_robot_favourite ? ' <span style="position: relative; bottom: 2px; font-size: 11px;">♥</span>' : ''; $this_robot_name .= $text_robot_special ? ' <span style="position: relative; bottom: 2px; font-size: 9px;" title="Congratulations!!! :D">★</span>' : ''; $this_robot_item = !empty($info['robot_item']) ? $info['robot_item'] : ''; $this_robot_energy = $info['robot_energy']; $this_robot_attack = $info['robot_attack']; $this_robot_defense = $info['robot_defense']; $this_robot_speed = $info['robot_speed']; $this_robot_core = !empty($info['robot_core']) ? $info['robot_core'] : ''; $this_robot_core2 = !empty($info['robot_core2']) ? $info['robot_core2'] : ''; $temp_level = $this_robot_level - 1; $this_robot_energy += ceil($temp_level * (0.05 * $this_robot_energy)); $this_robot_attack += ceil($temp_level * (0.05 * $this_robot_attack)); $this_robot_defense += ceil($temp_level * (0.05 * $this_robot_defense)); $this_robot_speed += ceil($temp_level * (0.05 * $this_robot_speed)); if (!empty($this_robot_settings['robot_item'])) { $this_robot_item = $this_robot_settings['robot_item']; } if (!empty($this_robot_rewards['robot_energy'])) { $this_robot_energy += $this_robot_rewards['robot_energy']; } if (!empty($this_robot_rewards['robot_attack'])) { $this_robot_attack += $this_robot_rewards['robot_attack']; } if (!empty($this_robot_rewards['robot_defense'])) { $this_robot_defense += $this_robot_rewards['robot_defense']; } if (!empty($this_robot_rewards['robot_speed'])) { $this_robot_speed += $this_robot_rewards['robot_speed']; } if ($this_prototype_data['this_player_token'] == 'dr-light') { $this_robot_defense += ceil(0.25 * $this_robot_defense); } if ($this_prototype_data['this_player_token'] == 'dr-wily') { $this_robot_attack += ceil(0.25 * $this_robot_attack); } if ($this_prototype_data['this_player_token'] == 'dr-cossack') { $this_robot_speed += ceil(0.25 * $this_robot_speed); } $this_robot_energy = $this_robot_energy > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_energy; $this_robot_attack = $this_robot_attack > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_attack; $this_robot_defense = $this_robot_defense > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_defense; $this_robot_speed = $this_robot_speed > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_speed; if (!empty($this_robot_settings['robot_image'])) { $this_option_image = $this_robot_settings['robot_image']; } if (!empty($this_robot_item) && preg_match('/^item-core-/i', $this_robot_item)) { $item_core_type = preg_replace('/^item-core-/i', '', $this_robot_item); if (empty($this_robot_core2)) { //$this_robot_core != 'copy' && $this_robot_core2 = $item_core_type; } } $this_robot_abilities_current = !empty($info['robot_abilities']) ? array_keys($info['robot_abilities']) : array('buster-shot'); $this_option_title = ''; //-- Basics ------------------------------- <br />'; $this_option_title .= $info['robot_name']; //''.$info['robot_number'].' '.$info['robot_name']; $this_option_title .= ' (' . (!empty($this_robot_core) ? ucfirst($this_robot_core) . ' Core' : 'Neutral Core') . ')'; $this_option_title .= ' <br />Level ' . $this_robot_level . ' | ' . $this_robot_experience_title . ' / ' . $this_experience_required . ' Exp' . (!empty($this_robot_favourite_title) ? ' ' . $this_robot_favourite_title : ''); if (!empty($this_robot_item) && isset($this_ability_index[$this_robot_item])) { $this_option_title .= ' | + ' . $this_ability_index[$this_robot_item]['ability_name'] . ' '; } $this_option_title .= ' <br />E : ' . $this_robot_energy . ' | A : ' . $this_robot_attack . ' | D : ' . $this_robot_defense . ' | S: ' . $this_robot_speed; if (!empty($this_robot_abilities_current)) { $this_option_title .= ' <hr />'; // <hr />-- Abilities ------------------------------- <br />'; $temp_counter = 1; foreach ($this_robot_abilities_current as $token) { if (empty($token) || !isset($this_ability_index[$token])) { continue; } $temp_info = rpg_ability::parse_index_info($this_ability_index[$token]); $this_option_title .= $temp_info['ability_name']; if ($temp_counter % 4 == 0) { $this_option_title .= ' <br />'; } elseif ($temp_counter < count($this_robot_abilities_current)) { $this_option_title .= ' | '; } $temp_counter++; } } $this_option_title_plain = strip_tags(str_replace('<br />', ' ', $this_option_title)); $this_option_title_tooltip = htmlentities($this_option_title, ENT_QUOTES, 'UTF-8'); $this_option_label = '<span class="sprite sprite_' . $temp_size_text . ' sprite_' . $temp_size_text . '_base" style="background-image: url(i/r/' . $this_option_image . '/sr' . $temp_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '); top: ' . $temp_top . 'px; right: ' . $temp_right . 'px;">' . $info['robot_name'] . '</span>'; $this_option_label .= '<span class="multi">'; $this_option_label .= '<span class="maintext">' . $this_robot_name . '</span>'; $this_option_label .= '<span class="subtext">Level ' . $this_robot_level . '</span>'; $this_option_label .= '<span class="subtext2">' . $this_robot_experience . '/' . $this_experience_required . ' Exp</span>'; $this_option_label .= '</span>'; $this_option_label .= '<span class="arrow">►</span>'; //$this_robots_markup .= '<a class="'.$this_option_class.'" data-child="true" data-token="'.$this_option_token.'" title="'.$this_option_title_plain.'" data-tooltip="'.$this_option_title_tooltip.'" style="'.$this_option_style.'">'; $this_robots_markup .= '<a class="' . $this_option_class . '" data-child="true" data-token="' . $this_option_token . '" style="' . $this_option_style . '">'; $this_robots_markup .= '<div class="chrome chrome_type robot_type_' . (!empty($this_robot_core) ? $this_robot_core : 'none') . (!empty($this_robot_core2) ? '_' . $this_robot_core2 : '') . '" data-tooltip="' . $this_option_title_tooltip . '"><div class="inset"><label class="has_image">' . $this_option_label . '</label></div></div>'; $this_robots_markup .= '</a>' . "\r\n"; } // Loop through and display any option padding cells //if ($this_prototype_data['robots_unlocked'] >= 3){ if ($temp_robot_option_count >= 3) { //$this_prototype_data['padding_num'] = $this_prototype_data['robots_unlocked'] <= 8 ? 4 : 2; $this_prototype_data['padding_num'] = 4; $this_prototype_data['robots_padding'] = $temp_robot_option_count % $this_prototype_data['padding_num']; if (!empty($this_prototype_data['robots_padding'])) { $counter = $temp_robot_option_count % $this_prototype_data['padding_num'] + 1; for ($counter; $counter <= $this_prototype_data['padding_num']; $counter++) { $this_option_class = 'option option_this-robot-select option_this-' . $this_prototype_data['this_player_token'] . '-robot-select option_1x1 option_disabled block_' . $counter; $this_option_style = ''; $this_robots_markup .= '<a class="' . $this_option_class . '" style="' . $this_option_style . '">'; $this_robots_markup .= '<div class="platform"><div class="chrome"><div class="inset"><label> </label></div></div></div>'; $this_robots_markup .= '</a>' . "\r\n"; } } } // Return the generated markup return $this_robots_markup; }
// Collect this player's index data if available if (!empty($this_player_token) && isset($mmrpg_index['players'][$this_player_token])) { $this_player_data = $mmrpg_index['players'][$this_player_token]; if (empty($this_player_data['user_id'])) { $this_player_data['user_id'] = $this_userid; } if (empty($this_player_data['player_id'])) { $this_player_id = !empty($this_player_id) ? $this_player_id : $this_userid; $this_player_data['player_id'] = $this_player_id; } if (!empty($this_player_robots)) { $allowed_robots = strstr($this_player_robots, ',') ? explode(',', $this_player_robots) : array($this_player_robots); foreach ($this_player_data['player_robots'] as $key => $data) { if (!in_array($data['robot_id'] . '_' . $data['robot_token'], $allowed_robots)) { unset($this_player_data['player_robots'][$key]); } elseif (!rpg_game::robot_unlocked($this_player_token, $data['robot_token'])) { unset($allowed_robots[array_search($data['robot_id'] . '_' . $data['robot_token'], $allowed_robots)]); unset($this_player_data['player_robots'][$key]); } } $this_player_robots = implode(',', $allowed_robots); $this_player_data['player_robots'] = array_values($this_player_data['player_robots']); } } else { $this_player_data = false; } // Collect the target player's index data if available if (!empty($target_player_token) && isset($mmrpg_index['players'][$target_player_token])) { $target_player_data = $mmrpg_index['players'][$target_player_token]; if (empty($target_player_data['user_id'])) { $target_player_data['user_id'] = MMRPG_SETTINGS_TARGET_PLAYERID;
} // -- COLLECT ENVIRONMENT VARIABLES -- // // Collect the field stars from the session variable if (!isset($_SESSION[$session_token]['values']['battle_shops'])) { $_SESSION[$session_token]['values']['battle_shops'] = array(); } $this_battle_shops = !empty($_SESSION[$session_token]['values']['battle_shops']) ? $_SESSION[$session_token]['values']['battle_shops'] : array(); $this_battle_shops_count = !empty($this_battle_shops) ? count($this_battle_shops) : 0; // Define the array to hold all the item quantities $global_item_quantities = array(); $global_item_prices = array(); $global_zenny_counter = !empty($_SESSION[$session_token]['counters']['battle_zenny']) ? $_SESSION[$session_token]['counters']['battle_zenny'] : 0; $global_points_counter = !empty($_SESSION[$session_token]['counters']['battle_points']) ? $_SESSION[$session_token]['counters']['battle_points'] : 0; // Define the global counters for unlocked robot cores and ability types $global_unlocked_robots = rpg_game::robot_tokens_unlocked(); $global_unlocked_abilities = rpg_game::ability_tokens_unlocked(); $global_unlocked_items = !empty($_SESSION[$session_token]['values']['battle_items']) ? $_SESSION[$session_token]['values']['battle_items'] : array(); $global_unlocked_robots_cores = array(); $global_unlocked_abilities_types = array(); $global_unlocked_items_tokens = !empty($global_unlocked_items) ? array_keys($global_unlocked_items) : 0; // Create type counters for each element if (!empty($mmrpg_database_types)) { foreach ($mmrpg_database_types as $type => $info) { $global_unlocked_robots_cores[$type] = 0; $global_unlocked_abilities_types[$type] = 0; } } // Loop through robots and count the number of cores represented if (!empty($global_unlocked_robots)) { foreach ($global_unlocked_robots as $token) { if (!isset($mmrpg_database_robots[$token])) {
function refresh_editor_arrays() { global $allowed_edit_players, $allowed_edit_robots, $allowed_edit_data; global $allowed_edit_data_count, $allowed_edit_player_count, $allowed_edit_robot_count; // Collect the current session token $session_token = rpg_game::session_token(); // Collect the player array and merge in session details $temp_player_array = array(); if (!empty($_SESSION[$session_token]['values']['battle_rewards'])) { $temp_player_rewards = $_SESSION[$session_token]['values']['battle_rewards']; $temp_player_array = array_merge($temp_player_array, $temp_player_rewards); } if (!empty($_SESSION[$session_token]['values']['battle_settings'])) { $temp_player_settings = $_SESSION[$session_token]['values']['battle_settings']; $temp_player_array = array_merge($temp_player_array, $temp_player_settings); } // Define the editor indexes and count variables $allowed_edit_players = array(); $allowed_edit_robots = array(); $allowed_edit_data = array(); $allowed_edit_data_count = 0; $allowed_edit_player_count = 0; $allowed_edit_robot_count = 0; // Collect a temporary player index $temp_player_tokens = array_keys($temp_player_array); $temp_player_index = rpg_player::get_index_custom($temp_player_tokens); // Now to actually loop through and update the allowed players, robots, and abilities arrays foreach ($temp_player_array as $player_token => $player_info) { if (empty($player_token) || !isset($temp_player_index[$player_token])) { continue; } $player_index_info = $temp_player_index[$player_token]; // If this player has not yet completed chapter one, no robot editor $intro_complete = rpg_prototype::event_complete('completed-chapter_' . $player_token . '_one'); $prototype_complete = rpg_prototype::campaign_complete($player_token); if (!$intro_complete && !$prototype_complete) { continue; } // Merge the player and index info then append the token and info $player_info = array_merge($player_index_info, $player_info); $allowed_edit_players[] = $player_token; $allowed_edit_data[$player_token] = $player_info; // Collect a temporary robot index $temp_robot_tokens = array_keys($player_info['player_robots']); $temp_robot_index = rpg_robot::get_index_custom($temp_robot_tokens); foreach ($player_info['player_robots'] as $robot_token => $robot_info) { if (empty($robot_token) || !isset($temp_robot_index[$robot_token])) { continue; } $robot_index_info = $temp_robot_index[$robot_token]; // Merge the robot and index info then append the token and info $robot_info = array_merge($robot_index_info, $robot_info); $allowed_edit_robots[] = $robot_token; $allowed_edit_data[$player_token]['player_robots'][$robot_token] = $robot_info; // Collect a temporary ability index $temp_ability_tokens = array_keys($robot_info['robot_abilities']); $temp_ability_index = rpg_ability::get_index_custom($temp_ability_tokens); foreach ($robot_info['robot_abilities'] as $ability_token => $ability_info) { if (empty($ability_token) || !isset($temp_ability_index[$ability_token])) { continue; } $ability_index_info = $temp_ability_index[$ability_token]; // Merge the ability and index info then append the token and info $ability_info = array_merge($ability_index_info, $ability_info); $allowed_edit_data[$player_token]['player_robots'][$robot_token]['robot_abilities'][$ability_token] = $ability_info; } } } //$allowed_edit_data = array_reverse($allowed_edit_data, true); $allowed_edit_player_count = !empty($allowed_edit_players) ? count($allowed_edit_players) : 0; $allowed_edit_robot_count = !empty($allowed_edit_robots) ? count($allowed_edit_robots) : 0; $allowed_edit_data_count = 0; foreach ($allowed_edit_data as $pinfo) { $pcount = !empty($pinfo['player_robots']) ? count($pinfo['player_robots']) : 0; $allowed_edit_data_count += $pcount; } }
$html_form_verified = false; $html_form_show_coppa = true; } // The password was correct! Update the session with these credentials $_SESSION['GAME']['DEMO'] = 0; $_SESSION['GAME']['USER'] = $this_user; // Load the save file into memory and overwrite the session rpg_game::load_session($temp_database_user['user_id']); // If this is an old, unused save file, reset the game automatically if (empty($_SESSION['GAME']['counters']['battle_points']) || empty($_SESSION['GAME']['values']['battle_rewards'])) { rpg_game::reset_session(); } // Update the file with the coppa approval flag and birthdate $_SESSION['GAME']['USER']['dateofbirth'] = strtotime($_REQUEST['dateofbirth']); $_SESSION['GAME']['USER']['approved'] = 1; rpg_game::save_session($temp_database_user['user_id']); // Update the form markup, then break from the loop $file_has_updated = true; break; } } // Break from the POST loop break; } // Update the header markup title $html_header_title .= 'Load Existing Game File'; // Update the header markup text $html_header_text .= 'Please enter the username and password of your save file below. '; $html_header_text .= 'Passwords are case-sensitive, though usernames are not.'; if ($html_form_show_coppa) { $html_header_text .= '<br /> Your date of birth must now be confirmed in accordance with <a href="http://www.coppa.org/" target="_blank">COPPA</a> guidelines.';
$prototype_tooltip_index[] = 'If a robot has a weakness to either of a recovery ability\'s types, that robot will receive damage from that ability in battle instead.'; $prototype_tooltip_index[] = 'If a robot has an affinity to either of a damaging ability\'s types, that robot will receive recovery from that ability in battle instead.'; $prototype_tooltip_index[] = 'The Buster Shot is unique in that it requires zero Weapon Energy to use in battle. Very useful when you\'re out of ammo and need to recharge!'; $prototype_tooltip_index[] = 'Elemental abilities are powerful but can damage the target robot\'s data. Defeat key robots using only neutral abilities to unlock them for battle!'; //$prototype_tooltip_index[] = ''; //$prototype_tooltip_index[] = ''; //$prototype_tooltip_index[] = ''; //$prototype_tooltip_index[] = ''; //$prototype_tooltip_index[] = ''; //$prototype_tooltip_index[] = ''; if (!empty($_SESSION[rpg_game::session_token()]['DEMO'])) { // Define the demo-mode specific player tooltips $prototype_tooltip_index[] = 'Progress cannot be saved in the demo mode, but creating a new save file will let you start your adventure with any points earned thus far.'; } else { // Define the normal mode tooltips $unlock_count_players = rpg_game::players_unlocked(); $prototype_tooltip_index[] = 'Benched robots take reduced damage based on their distance from the attacker. Use this to your advantage and put your weakest in the back!'; $prototype_tooltip_index[] = 'Equip as many abilities as you can - there is no penalty for having multiple weapons and it\'s always better to be prepared for battle.'; $prototype_tooltip_index[] = 'The enemy robots that appear in battle grow in level as you progress through the game, so replay old missions if you\'re having a hard time.'; $prototype_tooltip_index[] = 'Most missions can be replayed any number of times and the robots that appear in them will grow by one level with each victory.'; $prototype_tooltip_index[] = 'Revived robot masters can be unlocked for use in battle if defeated using only Neutral type abilities like the Buster Shot or Mega Buster.'; if ($unlock_count_players >= 2) { $prototype_tooltip_index[] = 'Robots can be tranferred between players by clicking the player name in the robot editor and selecting the new owner from the dropdown.'; $prototype_tooltip_index[] = 'Transferred robots receive twice the experience points in battle, but do not benefit from player-based stat bonuses to attack, defense, or speed.'; } } // Count the number of battle tips generated $this_tooltip_count = !empty($prototype_tooltip_index) ? count($prototype_tooltip_index) : 0; ?> <!DOCTYPE html> <html>
// Only process if the Mega Buster has not yet been unlocked if ($_SESSION['GAME']['values']['battle_rewards']['dr-light']['player_points'] <= 0) { // Increase this player's score by 10,000 points $temp_bonus_points = 10000; $_SESSION['GAME']['counters']['battle_points'] += $temp_bonus_points; $_SESSION['GAME']['values']['battle_rewards']['dr-light']['player_points'] += $temp_bonus_points; // Unlock the Copy Shot for use in battle early rpg_game::unlock_ability($mmrpg_index['players']['dr-light'], false, array('ability_token' => 'copy-shot'), true); // Reset and return to the main menu header('Location: prototype.php'); exit; } } // If the UNLOCK BUBBLE BOMB password was created if (!empty($temp_flags['drlight_password_abilitygetbubblebombsaway'])) { if (!rpg_game::ability_unlocked('dr-light', false, 'bubble-bomb')) { // Unlock Bubble Bomb as an equippable ability rpg_game::unlock_ability($mmrpg_index['players']['dr-light'], false, array('ability_token' => 'bubble-bomb'), true); header('Location: prototype.php'); exit; } } // If the UNLOCK SHADOW BLADE password was created if (!empty($temp_flags['drlight_password_abilitygetcutterofdarkness'])) { if (!rpg_game::ability_unlocked('dr-light', false, 'shadow-blade')) { // Unlock Shadow Blade as an equippable ability rpg_game::unlock_ability($mmrpg_index['players']['dr-light'], false, array('ability_token' => 'shadow-blade'), true); header('Location: prototype.php'); exit; } }
$player_ability_rewards = $_SESSION[$session_token]['values']['battle_abilities']; } elseif (!empty($player_rewards['player_abilities'])) { $player_ability_rewards = array('buster-shot' => array('ability_token' => 'buster-shot')); } // Create a fake player and robot to pass the info check $player_info = $mmrpg_index['players']['player']; //rpg_player::get_index_info('player'); //array('player_token' => 'player', 'player_name' => 'Player'); $robot_info = rpg_robot::get_index_info('robot'); //array('robot_token' => 'robot', 'robot_name' => 'Robot'); // Sort the ability rewards based on ability number and such uasort($player_ability_rewards, array('rpg_functions', 'abilities_sort_for_editor')); $robot_ability_rewards = array(); // Collect the ability reward options to be used on all selects $ability_rewards_options = $global_allow_editing ? rpg_ability::print_editor_options_list_markup($player_ability_rewards, $robot_ability_rewards, $player_info, $robot_info) : ''; foreach ($mmrpg_database_abilities as $ability_token => $ability_info) { if (!rpg_game::ability_unlocked('', '', $ability_token)) { continue; } //if ($key_counter > 0 && $key_counter % 5 == 0){ echo '</tr><tr>'; } //echo '<td>'; $temp_select_markup = rpg_ability::print_editor_select_markup($ability_rewards_options, $player_info, $robot_info, $ability_info, $key_counter); //echo $ability_token.'<br />'; echo $temp_select_markup . ' '; //echo '</td>'; $key_counter++; } } //echo '</tr></table>'; echo '</div>'; if ($global_allow_editing) { ?>
if (!empty($_SESSION[$session_token]['DEMO'])) { // Include the demo mode options and markup require MMRPG_CONFIG_ROOTDIR . 'prototype/demo_menu.php'; } else { // Require the omega factors require MMRPG_CONFIG_ROOTDIR . 'prototype/omega.php'; // Do not process any events while we're in javascript mode if (!defined('MMRPG_SCRIPT_REQUEST')) { // Include the demo mode options and markup require MMRPG_CONFIG_ROOTDIR . 'prototype/unlocks.php'; } /* * MENU MARKUP */ // DEMO MENU OPTIONS if (!empty($_SESSION[rpg_game::session_token()]['DEMO'])) { // Only print out Light's data if conditions allow or do not exist if (empty($this_data_condition) || in_array('this_player_token=dr-light', $this_data_condition)) { // Include the light mode options and markup if ($unlock_flag_light) { require MMRPG_CONFIG_ROOTDIR . 'prototype/dr-light_menu.php'; } } } else { // Only print out Light's data if conditions allow or do not exist if (empty($this_data_condition) || $this_data_select == 'this_player_token' || in_array('this_player_token=dr-light', $this_data_condition)) { // Include the light mode options and markup if ($unlock_flag_light) { require MMRPG_CONFIG_ROOTDIR . 'prototype/dr-light_menu.php'; } }
exit; } // Require the PASSWORDS file for this player if (!defined('MMRPG_SCRIPT_REQUEST')) { require 'prototype_dr-xxx_passwords.php'; } // Require the MISSIONS file for this player require 'prototype_dr-xxx_missions.php'; // Define the robot options and counter for this mode if (empty($_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options'])) { $this_prototype_data['robot_options'] = !empty($mmrpg_index['players'][$this_prototype_data['this_player_token']]['player_robots']) ? $mmrpg_index['players'][$this_prototype_data['this_player_token']]['player_robots'] : array(); foreach ($this_prototype_data['robot_options'] as $key => $info) { if (!rpg_game::robot_unlocked($this_prototype_data['this_player_token'], $info['robot_token'])) { unset($this_prototype_data['robot_options'][$key]); } else { $temp_settings = rpg_game::robot_settings($this_prototype_data['this_player_token'], $info['robot_token']); $this_prototype_data['robot_options'][$key]['original_player'] = !empty($temp_settings['original_player']) ? $temp_settings['original_player'] : $this_prototype_data['this_player_token']; $this_prototype_data['robot_options'][$key]['robot_abilities'] = !empty($temp_settings['robot_abilities']) ? $temp_settings['robot_abilities'] : array(); $this_prototype_data['robot_options'][$key]['robot_item'] = !empty($temp_settings['robot_item']) ? $temp_settings['robot_item'] : ''; } } $this_prototype_data['robot_options'] = array_values($this_prototype_data['robot_options']); usort($this_prototype_data['robot_options'], array('rpg_prototype', 'sort_robots_position')); $_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options'] = $this_prototype_data['robot_options']; } else { $this_prototype_data['robot_options'] = $_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options']; } // Generate the markup for this player's robot select screen $this_prototype_data['robots_markup'] = rpg_prototype::robot_select_markup($this_prototype_data); // Generate the markup for any leftover player missions $this_prototype_data['missions_markup'] .= rpg_prototype::options_markup($this_prototype_data['battle_options'], $this_prototype_data['this_player_token']);
<?php // Require the application top file require_once '../_top.php'; // Require the leaderboard data file require_once '../data/leaderboard.php'; // Collect the session token $session_token = rpg_game::session_token(); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title><?php echo !MMRPG_CONFIG_IS_LIVE ? '@ ' : ''; ?> View Leaderboard | Mega Man RPG World Last Updated <?php echo preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})#', '$1/$2/$3', MMRPG_CONFIG_CACHE_DATE); ?> </title> <base href="<?php echo MMRPG_CONFIG_ROOTURL; ?> " /> <meta name="robots" content="noindex,nofollow" /> <meta name="format-detection" content="telephone=no" /> <link type="text/css" href="styles/master.css?<?php echo MMRPG_CONFIG_CACHE_DATE; ?> " rel="stylesheet" /> <link type="text/css" href="styles/prototype.css?<?php
public static function print_editor_select_markup($item_rewards_options, $player_info, $robot_info, $item_info, $item_key = 0) { // Define the global variables global $mmrpg_index, $this_current_uri, $this_current_url, $db; global $allowed_edit_players, $allowed_edit_robots, $allowed_edit_items; global $allowed_edit_data_count, $allowed_edit_player_count, $allowed_edit_robot_count, $first_robot_token, $global_allow_editing; global $key_counter, $player_rewards, $player_item_rewards, $player_robot_database, $temp_robot_totals, $player_options_markup, $item_options_markup; global $mmrpg_database_items; global $session_token; // Require the function file $this_select_markup = ''; // Collect values for potentially missing global variables if (!isset($session_token)) { $session_token = rpg_game::session_token(); } if (empty($robot_info)) { return false; } if (empty($item_info)) { return false; } $item_info_token = $item_info['item_token']; $item_info_count = !empty($_SESSION[$session_token]['values']['battle_items'][$item_info_token]) ? $_SESSION[$session_token]['values']['battle_items'][$item_info_token] : 0; $item_info_name = $item_info['item_name']; $item_info_type = !empty($item_info['item_type']) ? $item_info['item_type'] : false; $item_info_type2 = !empty($item_info['item_type2']) ? $item_info['item_type2'] : false; if (!empty($item_info_type) && !empty($mmrpg_index['types'][$item_info_type])) { $item_info_type = $mmrpg_index['types'][$item_info_type]['type_name'] . ' Type'; if (!empty($item_info_type2) && !empty($mmrpg_index['types'][$item_info_type2])) { $item_info_type = str_replace(' Type', ' / ' . $mmrpg_index['types'][$item_info_type2]['type_name'] . ' Type', $item_info_type); } } else { $item_info_type = ''; } $item_info_energy = isset($item_info['item_energy']) ? $item_info['item_energy'] : 4; $item_info_damage = !empty($item_info['item_damage']) ? $item_info['item_damage'] : 0; $item_info_damage2 = !empty($item_info['item_damage2']) ? $item_info['item_damage2'] : 0; $item_info_damage_percent = !empty($item_info['item_damage_percent']) ? true : false; $item_info_damage2_percent = !empty($item_info['item_damage2_percent']) ? true : false; if ($item_info_damage_percent && $item_info_damage > 100) { $item_info_damage = 100; } if ($item_info_damage2_percent && $item_info_damage2 > 100) { $item_info_damage2 = 100; } $item_info_recovery = !empty($item_info['item_recovery']) ? $item_info['item_recovery'] : 0; $item_info_recovery2 = !empty($item_info['item_recovery2']) ? $item_info['item_recovery2'] : 0; $item_info_recovery_percent = !empty($item_info['item_recovery_percent']) ? true : false; $item_info_recovery2_percent = !empty($item_info['item_recovery2_percent']) ? true : false; if ($item_info_recovery_percent && $item_info_recovery > 100) { $item_info_recovery = 100; } if ($item_info_recovery2_percent && $item_info_recovery2 > 100) { $item_info_recovery2 = 100; } $item_info_accuracy = !empty($item_info['item_accuracy']) ? $item_info['item_accuracy'] : 0; $item_info_description = !empty($item_info['item_description']) ? $item_info['item_description'] : ''; $item_info_description = str_replace('{DAMAGE}', $item_info_damage, $item_info_description); $item_info_description = str_replace('{RECOVERY}', $item_info_recovery, $item_info_description); $item_info_description = str_replace('{DAMAGE2}', $item_info_damage2, $item_info_description); $item_info_description = str_replace('{RECOVERY2}', $item_info_recovery2, $item_info_description); $item_info_class_type = !empty($item_info['item_type']) ? $item_info['item_type'] : 'none'; if (!empty($item_info['item_type2'])) { $item_info_class_type = $item_info_class_type != 'none' ? $item_info_class_type . '_' . $item_info['item_type2'] : $item_info['item_type2']; } $item_info_title = rpg_item::print_editor_title_markup($robot_info, $item_info); $item_info_title_plain = strip_tags(str_replace('<br />', '//', $item_info_title)); $item_info_title_tooltip = htmlentities($item_info_title, ENT_QUOTES, 'UTF-8'); $item_info_title_html = str_replace(' ', ' ', $item_info_name); $item_info_title_html .= '<span class="count">x ' . $item_info_count . '</span>'; $temp_select_options = str_replace('value="' . $item_info_token . '"', 'value="' . $item_info_token . '" selected="selected" disabled="disabled"', $item_rewards_options); $item_info_title_html = '<label style="background-image: url(i/i/' . $item_info_token . '/il40.png?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $item_info_title_html . '</label>'; //if ($global_allow_editing){ $item_info_title_html .= '<select class="item_name" data-key="'.$item_key.'" data-player="'.$player_info['player_token'].'" data-robot="'.$robot_info['robot_token'].'">'.$temp_select_options.'</select>'; } $this_select_markup = '<a class="item_name type type_' . $item_info_class_type . '" style="' . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-item="' . $item_info_token . '" data-count="' . $item_info_count . '" title="' . $item_info_title_plain . '" data-tooltip="' . $item_info_title_tooltip . '">' . $item_info_title_html . '</a>'; // Return the generated select markup return $this_select_markup; }
// Display the prototype complete message, showing Dr. Cossack and Proto Man $temp_event_flag = 'dr-cossack_event-99_prototype-complete-new'; if (empty($temp_game_flags['events'][$temp_event_flag])) { $temp_game_flags['events'][$temp_event_flag] = true; // Define the player's battle points total, battles complete, and other details $player_token = 'dr-cossack'; $player_info = $mmrpg_index['players'][$player_token]; $player_info['player_points'] = rpg_game::player_points($player_token); $player_info['player_battles_complete'] = rpg_prototype::battles_complete($player_token); $player_info['player_battles_complete_total'] = rpg_prototype::battles_complete($player_token, false); $player_info['player_battles_failure'] = rpg_prototype::battles_failure($player_token); $player_info['player_battles_failure_total'] = rpg_prototype::battles_failure($player_token, false); $player_info['player_robots_count'] = 0; $player_info['player_abilities_count'] = rpg_game::abilities_unlocked($player_token); $player_info['player_field_stars'] = rpg_game::stars_unlocked($player_token, 'field'); $player_info['player_fusion_stars'] = rpg_game::stars_unlocked($player_token, 'fusion'); $player_info['player_screw_counter'] = 0; $player_info['player_heart_counter'] = 0; // Define the player's experience points total $player_info['player_experience'] = 0; if (!empty($_SESSION[$session_token]['values']['battle_rewards'])) { foreach ($_SESSION[$session_token]['values']['battle_rewards'] as $temp_player => $temp_player_info) { if (!empty($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'])) { $temp_player_robot_rewards = $_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots']; $temp_player_robot_settings = $_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots']; if (empty($temp_player_robot_rewards) || empty($temp_player_robot_settings)) { unset($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots']); unset($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots']); continue; } foreach ($temp_player_robot_rewards as $temp_key => $temp_robot_info) {
*/ // -- COLLECT SETTINGS DATA -- // // Define the editor indexes and count variables $allowed_edit_players = array(); $allowed_edit_robots = array(); $allowed_edit_data = array(); $allowed_edit_data_count = 0; $allowed_edit_player_count = 0; $allowed_edit_robot_count = 0; // Collect the player's robot favourites $player_robot_favourites = rpg_game::robot_favourites(); if (empty($player_robot_favourites)) { $player_robot_favourites = array(); } // Collect the player's robot database $player_robot_database = rpg_game::robot_database(); if (empty($player_robot_database)) { $player_robot_database = array(); } // Include the functions file for the editor require 'robots_functions.php'; // Manually refresh all the editor arrays refresh_editor_arrays(); // -- PROCESS PLAYER ACTION -- // // Check if an action request has been sent with an player type if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'player') { require 'robots_action-player.php'; } // -- PROCESS ABILITY ACTION -- // // Check if an action request has been sent with an ability type if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'ability') {
$battle_complete_counter_wily = $unlock_flag_wily ? rpg_prototype::battles_complete('dr-wily') : 0; $battle_failure_counter_wily = $unlock_flag_wily ? rpg_prototype::battles_failure('dr-wily') : 0; //$battle_complete_counter_wily_total = $unlock_flag_light ? rpg_prototype::battles_complete('dr-wily', false) : 0; //$battle_failure_counter_wily_total = $unlock_flag_light ? rpg_prototype::battles_failure('dr-wily', false) : 0; $prototype_complete_flag_wily = $unlock_flag_wily ? rpg_prototype::campaign_complete('dr-wily') : false; if ($unlock_flag_wily && !$prototype_complete_flag_wily && $battle_complete_counter_wily >= 17) { $_SESSION[$session_token]['flags']['prototype_events']['dr-wily']['prototype_complete'] = $prototype_complete_flag_wily = true; } // Collect the counters and flags for Dr. Cossack $unlock_flag_cossack = rpg_game::player_unlocked('dr-cossack'); $point_counter_cossack = $unlock_flag_cossack ? rpg_game::player_points('dr-cossack') : 0; $robot_counter_cossack = $unlock_flag_cossack ? rpg_game::robots_unlocked('dr-cossack') : 0; if (empty($this_data_condition) || $this_data_select == 'this_player_token' || in_array('this_player_token=dr-cossack', $this_data_condition)) { $ability_counter_cossack = $unlock_flag_cossack ? rpg_game::abilities_unlocked('dr-cossack') : 0; $star_counter_cossack = $unlock_flag_cossack ? rpg_game::stars_unlocked('dr-cossack') : 0; $core_counter_cossack = $unlock_flag_cossack ? rpg_game::cores_unlocked('dr-cossack') : 0; } $battle_complete_counter_cossack = $unlock_flag_cossack ? rpg_prototype::battles_complete('dr-cossack') : 0; $battle_failure_counter_cossack = $unlock_flag_cossack ? rpg_prototype::battles_failure('dr-cossack') : 0; //$battle_complete_counter_cossack_total = $unlock_flag_light ? rpg_prototype::battles_complete('dr-cossack', false) : 0; //$battle_failure_counter_cossack_total = $unlock_flag_light ? rpg_prototype::battles_failure('dr-cossack', false) : 0; $prototype_complete_flag_cossack = $unlock_flag_cossack ? rpg_prototype::campaign_complete('dr-cossack') : false; if ($unlock_flag_cossack && !$prototype_complete_flag_cossack && $battle_complete_counter_cossack >= 17) { $_SESSION[$session_token]['flags']['prototype_events']['dr-cossack']['prototype_complete'] = $prototype_complete_flag_cossack = true; } // -- Mission Counts -- // // Define the missions counts for each chapter $chapter_mission_counts = array(); $chapter_mission_counts['zero'] = 0; $chapter_mission_counts['one'] = 3; // 3 x Starter
} if (!empty($temp_robot_info['robot_abilities'])) { foreach ($temp_robot_info['robot_abilities'] as $temp_ability_token => $temp_ability_info) { if (EDIT_ROBOT_UPDATES_DEBUG) { echo '---- ' . $temp_ability_token; } if (rpg_game::ability_unlocked($temp_robot_info['original_player'], false, $temp_ability_token)) { if (EDIT_ROBOT_UPDATES_DEBUG) { echo ' (unlocked!)'; } } else { if (EDIT_ROBOT_UPDATES_DEBUG) { echo ' (not unlocked!)'; } $temp_original_player_info = array('player_token' => $temp_robot_info['original_player']); rpg_game::unlock_ability($temp_original_player_info, false, $temp_ability_info); if (EDIT_ROBOT_UPDATES_DEBUG) { echo ' (but unlocked now!)'; } } if (EDIT_ROBOT_UPDATES_DEBUG) { echo '<br />'; } } } if (EDIT_ROBOT_UPDATES_DEBUG) { echo '<br /><hr /><br />'; } } } if (EDIT_ROBOT_UPDATES_DEBUG) {
public static function generate_bonus($this_prototype_data, $this_robot_count = 8, $this_robot_class = 'master') { // Pull in global variables for this function global $mmrpg_index, $db; // 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'); // Populate the battle options with the starter battle option $temp_rand_num = $this_robot_count; $temp_battle_token = $this_prototype_data['phase_battle_token'] . '-prototype-bonus-' . $this_robot_class; if ($this_robot_class == 'mecha') { $temp_battle_omega = rpg_battle::get_index_info('bonus-prototype-complete'); $temp_battle_omega['battle_field_info']['field_name'] = 'Bonus Field'; } elseif ($this_robot_class == 'master') { $temp_battle_omega = rpg_battle::get_index_info('bonus-prototype-complete-2'); $temp_battle_omega['battle_field_info']['field_name'] = 'Bonus Field II'; } // Populate the player's target robots with compatible class matches $temp_battle_omega['battle_target_player']['player_robots'] = array(); $temp_counter = 0; foreach ($this_robot_index as $token => $info) { if (empty($info['robot_flag_complete']) || $info['robot_class'] != $this_robot_class) { continue; } $temp_counter++; $temp_robot_info = array(); $temp_robot_info['robot_id'] = MMRPG_SETTINGS_TARGET_PLAYERID + $temp_counter; $temp_robot_info['robot_token'] = $info['robot_token']; $temp_robot_info['robot_core'] = $info['robot_core']; $temp_robot_info['robot_core2'] = $info['robot_core2']; $temp_battle_omega['battle_target_player']['player_robots'][] = $temp_robot_info; } //die('<pre>player_robots '.print_r($temp_battle_omega['battle_target_player']['player_robots'], true).'</pre>'); // Continue defining battle variables for this mission $temp_battle_omega['flags']['bonus_battle'] = true; $temp_battle_omega['battle_token'] = $temp_battle_token; $temp_battle_omega['battle_size'] = '1x4'; $temp_battle_omega['battle_phase'] = $this_prototype_data['battle_phase']; //if ($this_robot_class == 'mecha'){ $temp_battle_omega['battle_turns_limit'] = MMRPG_SETTINGS_BATTLETURNS_PERMECHA * $this_robot_count; } //elseif ($this_robot_class == 'master'){ $temp_battle_omega['battle_turns_limit'] = MMRPG_SETTINGS_BATTLETURNS_PERROBOT * $this_robot_count; } //$temp_battle_omega['battle_points'] = ceil(($this_prototype_data['battles_complete'] > 1 ? 100 : 1000) * $temp_rand_num); //shuffle($temp_battle_omega['battle_target_player']['player_robots']); // Create the randomized field multupliers $temp_types = $mmrpg_index['types']; $temp_allow_special = array(); //, 'damage', 'recovery', 'experience' foreach ($temp_types as $key => $temp_type) { if (!empty($temp_type['type_class']) && $temp_type['type_class'] == 'special' && !in_array($temp_type['type_token'], $temp_allow_special)) { unset($temp_types[$key]); } } //$temp_battle_omega['battle_field_info']['field_multipliers']['experience'] = round((mt_rand(200, 300) / 100), 1); //$temp_battle_omega['battle_field_info']['field_type'] = $temp_types[array_rand($temp_types)]['type_token']; //do { $temp_battle_omega['battle_field_info']['field_type2'] = $temp_types[array_rand($temp_types)]['type_token']; //} while($temp_battle_omega['battle_field_info']['field_type2'] == $temp_battle_omega['battle_field_info']['field_type']); $temp_battle_omega['battle_field_info']['field_multipliers'] = array(); while (count($temp_battle_omega['battle_field_info']['field_multipliers']) < 6) { $temp_type = $temp_types[array_rand($temp_types)]; $temp_multiplier = 1; while ($temp_multiplier == 1) { $temp_multiplier = round(mt_rand(10, 990) / 100, 1); } $temp_battle_omega['battle_field_info']['field_multipliers'][$temp_type['type_token']] = $temp_multiplier; //if (count($temp_battle_omega['battle_field_info']['field_multipliers']) >= 6){ break; } } // Update the field type based on multipliers $temp_multipliers = $temp_battle_omega['battle_field_info']['field_multipliers']; asort($temp_multipliers); $temp_multipliers = array_keys($temp_multipliers); $temp_battle_omega['battle_field_info']['field_type'] = array_pop($temp_multipliers); $temp_battle_omega['battle_field_info']['field_type2'] = array_pop($temp_multipliers); // Collect the field types into a simple array $temp_field_types = array($temp_battle_omega['battle_field_info']['field_type'], $temp_battle_omega['battle_field_info']['field_type2']); // Give the robots a quick shuffle before sorting by core shuffle($temp_battle_omega['battle_target_player']['player_robots']); //die('<pre>player_robots '.print_r($temp_battle_omega['battle_target_player']['player_robots'], true).'</pre>'); // Sort the robots by their relevance to the field type usort($temp_battle_omega['battle_target_player']['player_robots'], function ($r1, $r2) use($temp_field_types, $this_robot_index) { //global $temp_field_types, $this_robot_index; $r1_core = !empty($r1['robot_core']) ? $r1['robot_core'] : ''; $r2_core = !empty($r2['robot_core']) ? $r2['robot_core'] : ''; if (in_array($r1_core, $temp_field_types) && !in_array($r2_core, $temp_field_types)) { return -1; } elseif (!in_array($r1_core, $temp_field_types) && in_array($r2_core, $temp_field_types)) { return 1; } else { return 0; } }); //die('<pre>field_types = '.implode(', ', $temp_field_types).' | player_robots '.print_r($temp_battle_omega['battle_target_player']['player_robots'], true).'</pre>'); $temp_battle_omega['battle_target_player']['player_robots'] = array_slice($temp_battle_omega['battle_target_player']['player_robots'], 0, $this_robot_count); // Calculate what level these bonus robots should be in the range of $temp_player_rewards = rpg_game::player_rewards($this_prototype_data['this_player_token']); $temp_total_level = 0; $temp_total_robots = 0; $temp_bonus_level_min = 100; $temp_bonus_level_max = 1; if (!empty($temp_player_rewards['player_robots'])) { foreach ($temp_player_rewards['player_robots'] as $token => $info) { $temp_level = !empty($info['robot_level']) ? $info['robot_level'] : 1; if ($temp_level > $temp_bonus_level_max) { $temp_bonus_level_max = $temp_level; } if ($temp_level < $temp_bonus_level_min) { $temp_bonus_level_min = $temp_level; } $temp_total_robots++; } //$temp_bonus_level_max = ceil($temp_total_level / $temp_total_robots); //$temp_bonus_level_min = ceil($temp_bonus_level_max / 3); } // Start all the point-based battle vars at zero $temp_battle_omega['battle_points'] = 0; $temp_battle_omega['battle_zenny'] = 0; $temp_battle_omega['battle_turns_limit'] = 0; $temp_battle_omega['battle_robots_limit'] = 0; // Define the possible items for bonus mission robot masters $possible_master_items = array('item-energy-upgrade', 'item-weapon-upgrade', 'item-target-module', 'item-charge-module', 'item-fortune-module', 'item-field-booster', 'item-attack-booster', 'item-defense-booster', 'item-speed-booster'); foreach ($mmrpg_index['types'] as $token => $info) { if (!empty($info['type_class']) && $info['type_class'] == 'special') { continue; } elseif (in_array($token, array('copy', 'empty'))) { continue; } $possible_master_items[] = 'item-core-' . $token; } $possible_master_items_last_key = count($possible_master_items) - 1; // Loop through each of the bonus robots and update their levels foreach ($temp_battle_omega['battle_target_player']['player_robots'] as $key => $robot) { $robot['robot_level'] = mt_rand($temp_bonus_level_min, $temp_bonus_level_max); $index = rpg_robot::parse_index_info($this_robot_index[$robot['robot_token']]); if ($this_robot_class != 'mecha') { $robot['robot_item'] = $possible_master_items[mt_rand(0, $possible_master_items_last_key)]; } else { $robot['robot_item'] = ''; } $robot['robot_abilities'] = rpg_prototype::generate_abilities($index, $robot['robot_level'], 8, $robot['robot_item']); // Increment the battle's turn limit based on the class of target robot if ($index['robot_class'] == 'master') { $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERROBOT; } elseif ($index['robot_class'] == 'mecha') { $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERMECHA; } elseif ($index['robot_class'] == 'boss') { $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERBOSS; } // Increment the battle's point reward based on the class of target robot if ($index['robot_class'] == 'master') { $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERROBOT; } elseif ($index['robot_class'] == 'mecha') { $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERMECHA; } elseif ($index['robot_class'] == 'boss') { $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERBOSS; } // Increment the battle's zenny reward based on the class of target robot if ($index['robot_class'] == 'master') { $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERROBOT; } elseif ($index['robot_class'] == 'mecha') { $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERMECHA; } elseif ($index['robot_class'] == 'boss') { $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERBOSS; } // Increment the battle's robot limit based on the class of target robot if ($index['robot_class'] == 'master') { $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERROBOT; } elseif ($index['robot_class'] == 'mecha') { $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERMECHA; } elseif ($index['robot_class'] == 'boss') { $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERBOSS; } $temp_battle_omega['battle_target_player']['player_robots'][$key] = $robot; } // Fix any zero or invalid battle values if ($temp_battle_omega['battle_points'] < 1) { $temp_battle_omega['battle_points'] = 1; } else { $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points']); } if ($temp_battle_omega['battle_turns_limit'] < 1) { $temp_battle_omega['battle_turns_limit'] = 1; } else { $temp_battle_omega['battle_turns_limit'] = ceil($temp_battle_omega['battle_turns_limit']); } if ($temp_battle_omega['battle_robots_limit'] < 1) { $temp_battle_omega['battle_robots_limit'] = 1; } else { $temp_battle_omega['battle_robots_limit'] = ceil($temp_battle_omega['battle_robots_limit']); } // Multiply battle points and zenny by ten for bonus amount (basically a cheating stage) $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 10); $temp_battle_omega['battle_zenny'] = ceil($temp_battle_omega['battle_zenny'] / 10); //if ($this_robot_class == 'mecha'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 100); } //elseif ($this_robot_class == 'master'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 10); } //elseif ($this_robot_class == 'master'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 10); } //if ($this_robot_class == 'mecha'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 100); } //elseif ($this_robot_class == 'master'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 10); } //elseif ($this_robot_class == 'master'){ $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points'] / 10); } // types used to be here // Update the field music to a random boss theme from MM1-10 + MM&B $temp_music_number = mt_rand(1, 11); $temp_music_name = 'boss-theme-mm' . str_pad($temp_music_number, 2, '0', STR_PAD_LEFT); $temp_battle_omega['battle_field_info']['field_music'] = $temp_music_name; // Add some random item drops to the starter battle $temp_battle_omega['battle_rewards_items'] = array(array('chance' => 2, 'token' => 'item-energy-tank'), array('chance' => 2, 'token' => 'item-weapon-tank'), array('chance' => 1, 'token' => 'item-yashichi'), array('chance' => 1, 'token' => 'item-extra-life')); // Return the generated battle data return $temp_battle_omega; }
public static function print_editor_markup($player_info) { // Define the global variables global $mmrpg_index, $this_current_uri, $this_current_url, $db; global $allowed_edit_players, $allowed_edit_fields, $global_allow_editing; global $allowed_edit_data_count, $allowed_edit_player_count, $first_player_token; global $key_counter, $player_key, $player_counter, $player_rewards, $player_field_rewards, $player_item_rewards, $temp_player_totals, $player_options_markup; global $mmrpg_database_robots, $mmrpg_database_items; $session_token = rpg_game::session_token(); // If either fo empty, return error if (empty($player_info)) { return 'error:player-empty'; } // Collect the approriate database indexes if (empty($mmrpg_database_robots)) { $mmrpg_database_robots = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token'); } if (empty($mmrpg_database_items)) { $mmrpg_database_items = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_class = 'item' AND ability_flag_complete = 1;", 'ability_token'); } // Define the quick-access variables for later use $player_token = $player_info['player_token']; if (!isset($first_player_token)) { $first_player_token = $player_token; } // Define the player's image and size if not defined $player_info['player_image'] = !empty($player_info['player_image']) ? $player_info['player_image'] : $player_info['player_token']; $player_info['player_image_size'] = !empty($player_info['player_image_size']) ? $player_info['player_image_size'] : 40; // Define the player's battle points total, battles complete, and other details $player_info['player_points'] = rpg_game::player_points($player_token); $player_info['player_battles_complete'] = rpg_prototype::battles_complete($player_token); $player_info['player_battles_complete_total'] = rpg_prototype::battles_complete($player_token, false); $player_info['player_battles_failure'] = rpg_prototype::battles_failure($player_token); $player_info['player_battles_failure_total'] = rpg_prototype::battles_failure($player_token, false); $player_info['player_robots_count'] = 0; $player_info['player_abilities_count'] = rpg_game::abilities_unlocked($player_token); $player_info['player_field_stars'] = rpg_game::stars_unlocked($player_token, 'field'); $player_info['player_fusion_stars'] = rpg_game::stars_unlocked($player_token, 'fusion'); $player_info['player_screw_counter'] = 0; $player_info['player_heart_counter'] = 0; // Define the player's experience points total $player_info['player_experience'] = 0; // Collect this player's current defined omega item list if (!empty($_SESSION[$session_token]['values']['battle_rewards'])) { //$debug_experience_sum = $player_token.' : '; foreach ($_SESSION[$session_token]['values']['battle_rewards'] as $temp_player => $temp_player_info) { if (!empty($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'])) { $temp_player_robot_rewards = $_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots']; $temp_player_robot_settings = $_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots']; if (empty($temp_player_robot_rewards) || empty($temp_player_robot_settings)) { unset($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots']); unset($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots']); continue; } foreach ($temp_player_robot_rewards as $temp_key => $temp_robot_info) { if (empty($temp_robot_info['robot_token'])) { unset($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'][$temp_key]); unset($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_key]); continue; } $temp_robot_settings = $temp_player_robot_settings[$temp_robot_info['robot_token']]; $temp_robot_rewards = $temp_player_robot_settings[$temp_robot_info['robot_token']]; // If this robot is not owned by the player, skip it as it doesn't count towards their totals if (empty($temp_robot_settings['original_player']) && $temp_player != $player_token) { continue; } elseif (empty($temp_robot_settings['original_player'])) { $temp_robot_settings['original_player'] = $temp_player; } if ($temp_robot_settings['original_player'] != $player_token) { continue; } //$debug_experience_sum .= $temp_robot_info['robot_token'].', '; $player_info['player_robots_count']++; if (!empty($temp_robot_info['robot_level'])) { $player_info['player_experience'] += $temp_robot_info['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERROBOT; } if (!empty($temp_robot_info['robot_experience'])) { $player_info['player_experience'] += $temp_robot_info['robot_experience']; } } } } //die($debug_experience_sum); } // Collect this player's current field selection from the omega session $temp_session_key = $player_info['player_token'] . '_target-robot-omega_prototype'; $player_info['target_robot_omega'] = !empty($_SESSION[$session_token]['values'][$temp_session_key]) ? $_SESSION[$session_token]['values'][$temp_session_key] : array(); $player_info['player_fields_current'] = array(); //die('<pre>$player_info[\'target_robot_omega\'] = '.print_r($player_info['target_robot_omega'], true).'</pre>'); if (count($player_info['target_robot_omega']) == 2) { $player_info['target_robot_omega'] = array_shift($player_info['target_robot_omega']); } foreach ($player_info['target_robot_omega'] as $key => $info) { $field = rpg_field::get_index_info($info['field']); if (empty($field)) { continue; } $player_info['player_fields_current'][] = $field; } // Define this player's stat type boost for display purposes $player_info['player_stat_type'] = ''; if (!empty($player_info['player_energy'])) { $player_info['player_stat_type'] = 'energy'; } elseif (!empty($player_info['player_attack'])) { $player_info['player_stat_type'] = 'attack'; } elseif (!empty($player_info['player_defense'])) { $player_info['player_stat_type'] = 'defense'; } elseif (!empty($player_info['player_speed'])) { $player_info['player_stat_type'] = 'speed'; } // Define whether or not field switching is enabled $temp_allow_field_switch = rpg_prototype::campaign_complete($player_info['player_token']) || rpg_prototype::campaign_complete(); // Collect a temp robot object for printing items if ($player_info['player_token'] == 'dr-light') { $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['mega-man']); } elseif ($player_info['player_token'] == 'dr-wily') { $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['bass']); } elseif ($player_info['player_token'] == 'dr-cossack') { $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['proto-man']); } // Define the markup variable $this_markup = ''; // Start the output buffer ob_start(); // DEBUG //die(print_r($player_field_rewards, true)); ?> <div class="event event_double event_<?php echo $player_key == $first_player_token ? 'visible' : 'hidden'; ?> " data-token="<?php echo $player_info['player_token'] . '_' . $player_info['player_token']; ?> "> <div class="this_sprite sprite_left" style="height: 40px;"> <?php $temp_margin = -1 * ceil(($player_info['player_image_size'] - 40) * 0.5); ?> <div style="margin-top: <?php echo $temp_margin; ?> px; margin-bottom: <?php echo $temp_margin * 3; ?> px; background-image: url(i/p/<?php echo !empty($player_info['player_image']) ? $player_info['player_image'] : $player_info['player_token']; ?> /mr<?php echo $player_info['player_image_size']; ?> .png?<?php echo MMRPG_CONFIG_CACHE_DATE; ?> ); " class="sprite sprite_player sprite_player_sprite sprite_<?php echo $player_info['player_image_size'] . 'x' . $player_info['player_image_size']; ?> sprite_<?php echo $player_info['player_image_size'] . 'x' . $player_info['player_image_size']; ?> _mug player_status_active player_position_active"><?php echo $player_info['player_name']; ?> </div> </div> <div class="header header_left player_type player_type_<?php echo !empty($player_info['player_stat_type']) ? $player_info['player_stat_type'] : 'none'; ?> " style="margin-right: 0;"><?php echo $player_info['player_name']; ?> 's Data <span class="player_type"><?php echo !empty($player_info['player_stat_type']) ? ucfirst($player_info['player_stat_type']) : 'Neutral'; ?> Type</span></div> <div class="body body_left" style="margin-right: 0; padding: 2px 3px; height: auto;"> <table class="full" style="margin-bottom: 5px;"> <colgroup> <col width="48.5%" /> <col width="1%" /> <col width="48.5%" /> </colgroup> <tbody> <tr> <td class="right"> <label style="display: block; float: left;">Name :</label> <span class="player_name player_type player_type_none"><?php echo $player_info['player_name']; ?> </span> </td> <td class="center"> </td> <td class="right"> <label style="display: block; float: left;">Bonus :</label> <?php // Display any special boosts this player has if (!empty($player_info['player_stat_type'])) { echo '<span class="player_name player_type player_type_' . $player_info['player_stat_type'] . '">Robot ' . ucfirst($player_info['player_stat_type']) . ' +' . $player_info['player_' . $player_info['player_stat_type']] . '%</span>'; } else { echo '<span class="player_name player_type player_type_none">None</span>'; } ?> </td> </tr> <tr> <td class="right"> <label style="display: block; float: left;">Exp Points :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_experience']) ? 'cutter' : 'none'; ?> "><?php echo number_format($player_info['player_experience'], 0, '.', ','); ?> EXP</span> </td> <td class="center"> </td> <td class="right"> <label style="display: block; float: left;">Unlocked Robots :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_robots_count']) ? 'cutter' : 'none'; ?> "><?php echo $player_info['player_robots_count'] . ' ' . ($player_info['player_robots_count'] == 1 ? 'Robot' : 'Robots'); ?> </span> </td> </tr> <tr> <td class="right"> <label style="display: block; float: left;">Battle Points :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_points']) ? 'cutter' : 'none'; ?> "><?php echo number_format($player_info['player_points'], 0, '.', ','); ?> BP</span> </td> <td class="center"> </td> <td class="right"> <label style="display: block; float: left;">Unlocked Abilities :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_abilities_count']) ? 'cutter' : 'none'; ?> "><?php echo $player_info['player_abilities_count'] . ' ' . ($player_info['player_abilities_count'] == 1 ? 'Ability' : 'Abilities'); ?> </span> </td> </tr> <tr> <td class="right"> <label style="display: block; float: left;">Missions Completed :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_battles_complete']) ? 'energy' : 'none'; ?> "><?php echo $player_info['player_battles_complete']; ?> Missions</span> </td> <td class="center"> </td> <td class="right"> <label style="display: block; float: left;">Total Victories :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_battles_complete_total']) ? 'energy' : 'none'; ?> "><?php echo $player_info['player_battles_complete_total']; ?> Victories</span> </td> </tr> <tr> <td class="right"> <label style="display: block; float: left;">Missions Failed :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_battles_failure']) ? 'attack' : 'none'; ?> "><?php echo $player_info['player_battles_failure']; ?> Missions</span> </td> <td class="center"> </td> <td class="right"> <label style="display: block; float: left;">Total Defeats :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_battles_failure_total']) ? 'attack' : 'none'; ?> "><?php echo $player_info['player_battles_failure_total']; ?> Defeats</span> </td> </tr> <tr> <td class="right"> <?php if (!empty($player_info['player_field_stars'])) { ?> <label style="display: block; float: left;">Field Stars :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_field_stars']) ? 'electric' : 'empty'; ?> "><?php echo $player_info['player_field_stars'] . ' ' . ($player_info['player_field_stars'] == 1 ? 'Star' : 'Stars'); ?> </span> <?php } else { ?> <label style="display: block; float: left; opacity: 0.5; filter: alpha(opacity=50); ">??? :</label> <span class="player_stat player_type player_type_empty" style=" opacity: 0.5; filter: alpha(opacity=50); ">0</span> <?php } ?> </td> <td class="center"> </td> <td class="right"> <?php if (!empty($player_info['player_fusion_stars'])) { ?> <label style="display: block; float: left;">Fusion Stars :</label> <span class="player_stat player_type player_type_<?php echo !empty($player_info['player_fusion_stars']) ? 'time' : 'empty'; ?> "><?php echo $player_info['player_fusion_stars'] . ' ' . ($player_info['player_fusion_stars'] == 1 ? 'Star' : 'Stars'); ?> </span> <?php } else { ?> <label style="display: block; float: left; opacity: 0.5; filter: alpha(opacity=50); ">??? :</label> <span class="player_stat player_type player_type_empty" style=" opacity: 0.5; filter: alpha(opacity=50); ">0</span> <?php } ?> </td> </tr> </tbody> </table> <?php if (false && !empty($player_item_rewards)) { ?> <table class="full"> <colgroup> <col width="100%" /> </colgroup> <tbody> <tr> <td class="right" style="padding-top: 4px;"> <label class="item_header">Player Items :</label> <div class="item_container" style="height: auto;"> <?php // Define the array to hold ALL the reward option markup $item_rewards_options = ''; // Collect this player's item rewards and add them to the dropdown //$player_item_rewards = !empty($player_rewards['player_items']) ? $player_rewards['player_items'] : array(); //if (!empty($player_item_rewards)){ sort($player_item_rewards); } // DEBUG //$debug_tokens = array(); //foreach ($player_item_rewards AS $info){ $debug_tokens[] = $info['ability_token']; } //echo 'before:'.implode(',', array_keys($debug_tokens)).'<br />'; // Sort the item index based on item group uasort($player_item_rewards, array('rpg_functions', 'items_sort_for_editor')); // DEBUG //echo 'after:'.implode(',', array_keys($player_item_rewards)).'<br />'; // DEBUG //$debug_tokens = array(); //foreach ($player_item_rewards AS $info){ $debug_tokens[] = $info['ability_token']; } //echo 'after:'.implode(',', $debug_tokens).'<br />'; // Dont' bother generating option dropdowns if editing is disabled if ($global_allow_editing) { $player_item_rewards_options = array(); foreach ($player_item_rewards as $temp_item_key => $temp_item_info) { if (empty($temp_item_info['ability_token'])) { continue; } $temp_token = $temp_item_info['ability_token']; $temp_item_info = rpg_ability::parse_index_info($mmrpg_database_items[$temp_token]); $temp_option_markup = rpg_ability::print_editor_option_markup($robot_info, $temp_item_info); if (!empty($temp_option_markup)) { $player_item_rewards_options[] = $temp_option_markup; } } $player_item_rewards_options = '<optgroup label="Player Items">' . implode('', $player_item_rewards_options) . '</optgroup>'; $item_rewards_options .= $player_item_rewards_options; /* // Collect this robot's item rewards and add them to the dropdown $player_item_rewards = !empty($player_rewards['player_items']) ? $player_rewards['player_items'] : array(); $player_item_settings = !empty($player_settings['player_items']) ? $player_settings['player_items'] : array(); foreach ($player_item_settings AS $token => $info){ if (empty($player_item_rewards[$token])){ $player_item_rewards[$token] = $info; } } if (!empty($player_item_rewards)){ sort($player_item_rewards); } $player_item_rewards_options = array(); foreach ($player_item_rewards AS $temp_item_info){ if (empty($temp_item_info['ability_token'])){ continue; } $temp_token = $temp_item_info['ability_token']; $temp_item_info = rpg_ability::parse_index_info($mmrpg_database_items[$temp_token]); $temp_option_markup = rpg_ability::print_editor_option_markup($robot_info, $temp_item_info); if (!empty($temp_option_markup)){ $player_item_rewards_options[] = $temp_option_markup; } } $player_item_rewards_options = '<optgroup label="Player Items">'.implode('', $player_item_rewards_options).'</optgroup>'; $item_rewards_options .= $player_item_rewards_options; */ // Add an option at the bottom to remove the ability $item_rewards_options .= '<optgroup label="Item Actions">'; $item_rewards_options .= '<option value="" title="">- Remove Item -</option>'; $item_rewards_options .= '</optgroup>'; } // Loop through the robot's current items and list them one by one $empty_item_counter = 0; $temp_string = array(); $temp_inputs = array(); $item_key = 0; if (!empty($player_info['player_items_current'])) { // DEBUG //echo 'robot-ability:'; foreach ($player_info['player_items_current'] as $key => $player_item) { if (empty($player_item['ability_token'])) { continue; } elseif ($player_item['ability_token'] == '*') { continue; } elseif ($player_item['ability_token'] == 'ability') { continue; } elseif ($item_key > 7) { continue; } $this_item = rpg_ability::parse_index_info($mmrpg_database_items[$player_item['ability_token']]); if (empty($this_item)) { continue; } $this_item_token = $this_item['ability_token']; $this_item_name = $this_item['ability_name']; $this_item_type = !empty($this_item['ability_type']) ? $this_item['ability_type'] : false; $this_item_type2 = !empty($this_item['ability_type2']) ? $this_item['ability_type2'] : false; if (!empty($this_item_type) && !empty($mmrpg_index['types'][$this_item_type])) { $this_item_type = $mmrpg_index['types'][$this_item_type]['type_name'] . ' Type'; if (!empty($this_item_type2) && !empty($mmrpg_index['types'][$this_item_type2])) { $this_item_type = str_replace(' Type', ' / ' . $mmrpg_index['types'][$this_item_type2]['type_name'] . ' Type', $this_item_type); } } else { $this_item_type = ''; } $this_item_energy = isset($this_item['ability_energy']) ? $this_item['ability_energy'] : 4; $this_item_damage = !empty($this_item['ability_damage']) ? $this_item['ability_damage'] : 0; $this_item_damage2 = !empty($this_item['ability_damage2']) ? $this_item['ability_damage2'] : 0; $this_item_damage_percent = !empty($this_item['ability_damage_percent']) ? true : false; $this_item_damage2_percent = !empty($this_item['ability_damage2_percent']) ? true : false; if ($this_item_damage_percent && $this_item_damage > 100) { $this_item_damage = 100; } if ($this_item_damage2_percent && $this_item_damage2 > 100) { $this_item_damage2 = 100; } $this_item_recovery = !empty($this_item['ability_recovery']) ? $this_item['ability_recovery'] : 0; $this_item_recovery2 = !empty($this_item['ability_recovery2']) ? $this_item['ability_recovery2'] : 0; $this_item_recovery_percent = !empty($this_item['ability_recovery_percent']) ? true : false; $this_item_recovery2_percent = !empty($this_item['ability_recovery2_percent']) ? true : false; if ($this_item_recovery_percent && $this_item_recovery > 100) { $this_item_recovery = 100; } if ($this_item_recovery2_percent && $this_item_recovery2 > 100) { $this_item_recovery2 = 100; } $this_item_accuracy = !empty($this_item['ability_accuracy']) ? $this_item['ability_accuracy'] : 0; $this_item_description = !empty($this_item['ability_description']) ? $this_item['ability_description'] : ''; $this_item_description = str_replace('{DAMAGE}', $this_item_damage, $this_item_description); $this_item_description = str_replace('{RECOVERY}', $this_item_recovery, $this_item_description); $this_item_description = str_replace('{DAMAGE2}', $this_item_damage2, $this_item_description); $this_item_description = str_replace('{RECOVERY2}', $this_item_recovery2, $this_item_description); $this_item_title = rpg_ability::print_editor_title_markup($robot_info, $this_item); $this_item_title_plain = strip_tags(str_replace('<br />', ' ', $this_item_title)); $this_item_title_tooltip = htmlentities($this_item_title, ENT_QUOTES, 'UTF-8'); $this_item_title_html = str_replace(' ', ' ', $this_item_name); $temp_select_options = str_replace('value="' . $this_item_token . '"', 'value="' . $this_item_token . '" selected="selected" disabled="disabled"', $item_rewards_options); $this_item_title_html = '<label style="background-image: url(i/a/' . $this_item_token . '/il40.png?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $this_item_title_html . '</label>'; if ($global_allow_editing) { $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '">' . $temp_select_options . '</select>'; } $temp_string[] = '<a class="ability_name ability_type ability_type_' . (!empty($this_item['ability_type']) ? $this_item['ability_type'] : 'none') . (!empty($this_item['ability_type2']) ? '_' . $this_item['ability_type2'] : '') . '" style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-item="' . $this_item_token . '" title="' . $this_item_title_plain . '" data-tooltip="' . $this_item_title_tooltip . '">' . $this_item_title_html . '</a>'; $item_key++; } if ($item_key <= 7) { for ($item_key; $item_key <= 7; $item_key++) { $empty_item_counter++; if ($empty_item_counter >= 2) { $empty_item_disable = true; } else { $empty_item_disable = false; } $temp_select_options = str_replace('value=""', 'value="" selected="selected" disabled="disabled"', $item_rewards_options); $this_item_title_html = '<label>-</label>'; if ($global_allow_editing) { $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_item_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>'; } $temp_string[] = '<a class="ability_name " style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_item_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-item="" title="" data-tooltip="">' . $this_item_title_html . '</a>'; } } } else { for ($item_key = 0; $item_key <= 7; $item_key++) { $empty_item_counter++; if ($empty_item_counter >= 2) { $empty_item_disable = true; } else { $empty_item_disable = false; } $temp_select_options = str_replace('value=""', 'value="" selected="selected"', $item_rewards_options); $this_item_title_html = '<label>-</label>'; if ($global_allow_editing) { $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" ' . ($empty_item_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>'; } $temp_string[] = '<a class="ability_name " style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_item_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-ability="">' . $this_item_title_html . '</a>'; } } // DEBUG //echo 'temp-string:'; echo !empty($temp_string) ? implode(' ', $temp_string) : ''; // DEBUG //echo '<br />temp-inputs:'; echo !empty($temp_inputs) ? implode(' ', $temp_inputs) : ''; // DEBUG //echo '<br />'; ?> </div> </td> </tr> </tbody> </table> <?php } ?> <?php if (!empty($player_field_rewards) && rpg_prototype::campaign_complete($player_info['player_token'])) { ?> <table class="full"> <colgroup> <col width="100%" /> </colgroup> <tbody> <tr> <td class="right" style="padding-top: 4px;"> <label class="field_header"><?php echo $global_allow_editing ? 'Edit ' : ''; ?> Player Fields :</label> <div class="field_container" style="height: auto;"> <?php // Define the array to hold ALL the reward option markup $field_rewards_options = ''; // Collect this player's field rewards and add them to the dropdown //$player_field_rewards = !empty($player_rewards['player_fields']) ? $player_rewards['player_fields'] : array(); //if (!empty($player_field_rewards)){ sort($player_field_rewards); } // DEBUG //echo 'start:player_field_rewards:<pre style="font-size: 80%;">'.print_r($player_field_rewards, true).'</pre><br />'; // DEBUG //echo 'before:player_field_rewards(keys):'.implode(',', array_keys($player_field_rewards)).'<br />'; // DEBUG //$debug_tokens = array(); //foreach ($player_field_rewards AS $info){ $debug_tokens[] = $info['field_token']; } //echo 'before:player_field_rewards(field_tokens):'.implode(',', array_values($debug_tokens)).'<br />'; // Sort the field index based on field number uasort($player_field_rewards, array('rpg_functions', 'fields_sort_for_editor')); // DEBUG //echo 'after:player_field_rewards(keys):'.implode(',', array_keys($player_field_rewards)).'<br />'; // DEBUG //$debug_tokens = array(); //foreach ($player_field_rewards AS $info){ $debug_tokens[] = $info['field_token']; } //echo 'after:player_field_rewards(field_tokens):'.implode(',', array_values($debug_tokens)).'<br />'; // Don't bother generating the option markup if disabled editing if ($global_allow_editing) { // Define the field group index for displau $temp_group_index = array('MMRPG' => 'Mega Man RPG Fields', 'MM00' => 'Mega Man Bonus Fields', 'MM01' => 'Mega Man 1 Fields', 'MM02' => 'Mega Man 2 Fields', 'MM03' => 'Mega Man 3 Fields', 'MM04' => 'Mega Man 4 Fields', 'MM05' => 'Mega Man 5 Fields', 'MM06' => 'Mega Man 6 Fields', 'MM07' => 'Mega Man 7 Fields', 'MM08' => 'Mega Man 8 Fields', 'MM09' => 'Mega Man 9 Fields', 'MM10' => 'Mega Man 10 Fields'); // Loop through the group index and display any fields that match $player_field_rewards_backup = $player_field_rewards; foreach ($temp_group_index as $group_key => $group_name) { $player_field_rewards_options = array(); foreach ($player_field_rewards_backup as $temp_field_key => $temp_field_info) { if (empty($temp_field_info['field_game']) || $temp_field_info['field_game'] != $group_key) { continue; } $temp_option_markup = rpg_field::print_editor_option_markup($temp_field_info); if (!empty($temp_option_markup)) { $player_field_rewards_options[] = $temp_option_markup; } unset($player_field_rewards_backup[$temp_field_key]); } if (empty($player_field_rewards_options)) { continue; } $player_field_rewards_options = '<optgroup label="' . $group_name . '">' . implode('', $player_field_rewards_options) . '</optgroup>'; $field_rewards_options .= $player_field_rewards_options; } } // Add an option at the bottom to remove the field //$field_rewards_options .= '<optgroup label="Field Actions">'; //$field_rewards_options .= '<option value="" title="">- Remove Field -</option>'; //$field_rewards_options .= '</optgroup>'; // Loop through the player's current fields and list them one by one $empty_field_counter = 0; $temp_string = array(); $temp_inputs = array(); $field_key = 0; if (!empty($player_info['player_fields_current'])) { // DEBUG //echo 'player-field:'; $rpg_field_index = rpg_field::get_index(); $player_info['player_fields_current'] = $player_info['player_fields_current']; //array_reverse($player_info['player_fields_current']); foreach ($player_info['player_fields_current'] as $player_field) { if ($player_field['field_token'] == '*') { continue; } elseif (!isset($rpg_field_index[$player_field['field_token']])) { continue; } elseif ($field_key > 7) { continue; } $this_field = rpg_field::parse_index_info($rpg_field_index[$player_field['field_token']]); $this_field_token = $this_field['field_token']; $this_robot_token = $this_field['field_master']; $this_robot = rpg_robot::parse_index_info($mmrpg_database_robots[$this_robot_token]); $this_field_name = $this_field['field_name']; $this_field_type = !empty($this_field['field_type']) ? $this_field['field_type'] : false; $this_field_type2 = !empty($this_field['field_type2']) ? $this_field['field_type2'] : false; if (!empty($this_field_type) && !empty($mmrpg_index['types'][$this_field_type])) { $this_field_type = $mmrpg_index['types'][$this_field_type]['type_name'] . ' Type'; if (!empty($this_field_type2) && !empty($mmrpg_index['types'][$this_field_type2])) { $this_field_type = str_replace(' Type', ' / ' . $mmrpg_index['types'][$this_field_type2]['type_name'] . ' Type', $this_field_type); } } else { $this_field_type = ''; } $this_field_description = !empty($this_field['field_description']) ? $this_field['field_description'] : ''; $this_field_title = rpg_field::print_editor_title_markup($this_field); $this_field_title_plain = strip_tags(str_replace('<br />', ' ', $this_field_title)); $this_field_title_tooltip = htmlentities($this_field_title, ENT_QUOTES, 'UTF-8'); $this_field_title_html = str_replace(' ', ' ', $this_field_name); $temp_select_options = str_replace('value="' . $this_field_token . '"', 'value="' . $this_field_token . '" selected="selected" disabled="disabled"', $field_rewards_options); $temp_field_type_class = 'field_type_' . (!empty($this_field['field_type']) ? $this_field['field_type'] : 'none') . (!empty($this_field['field_type2']) ? '_' . $this_field['field_type2'] : ''); if ($global_allow_editing && $temp_allow_field_switch) { $this_field_title_html = '<label class="field_type ' . $temp_field_type_class . '" style="">' . $this_field_title_html . '</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '">' . $temp_select_options . '</select>'; } elseif (!$global_allow_editing && $temp_allow_field_switch) { $this_field_title_html = '<label class="field_type ' . $temp_field_type_class . '" style="cursor: default !important;">' . $this_field_title_html . '</label>'; } else { $this_field_title_html = '<label class="field_type ' . $temp_field_type_class . '" style="cursor: default !important;">' . $this_field_title_html . '</label>'; } $temp_string[] = '<a class="field_name field_type ' . $temp_field_type_class . '" style="background-image: url(i/f/' . $this_field_token . '/bfp.png?' . MMRPG_CONFIG_CACHE_DATE . '); ' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . (!$temp_allow_field_switch || !$global_allow_editing ? 'cursor: default !important; ' : '') . (!$temp_allow_field_switch ? 'opacity: 0.50; filter: alpha(opacity=50); ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="' . $this_field_token . '" data-tooltip="' . $this_field_title_tooltip . '">' . $this_field_title_html . '</a>'; $field_key++; } if ($field_key <= 7) { for ($field_key; $field_key <= 7; $field_key++) { $empty_field_counter++; if ($empty_field_counter >= 2) { $empty_field_disable = true; } else { $empty_field_disable = false; } $temp_select_options = str_replace('value=""', 'value="" selected="selected" disabled="disabled"', $field_rewards_options); $this_field_title_html = '<label>-</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_field_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>'; $temp_string[] = '<a class="field_name " style="' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_field_disable ? 'opacity:0.25; ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="" title="">' . $this_field_title_html . '</a>'; } } } else { for ($field_key = 0; $field_key <= 7; $field_key++) { $empty_field_counter++; if ($empty_field_counter >= 2) { $empty_field_disable = true; } else { $empty_field_disable = false; } $temp_select_options = str_replace('value=""', 'value="" selected="selected"', $field_rewards_options); $this_field_title_html = '<label>-</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_field_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>'; $temp_string[] = '<a class="field_name " style="' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_field_disable ? 'opacity:0.25; ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="" title="">' . $this_field_title_html . '</a>'; } } // DEBUG //echo 'temp-string:'; echo !empty($temp_string) ? implode(' ', $temp_string) : ''; // DEBUG //echo '<br />temp-inputs:'; echo !empty($temp_inputs) ? implode(' ', $temp_inputs) : ''; // DEBUG //echo '<br />'; // Collect the available star counts for this player $temp_star_counts = rpg_game::stars_available($player_token); ?> <div class="field_stars"> <label class="label">stars</label> <span class="star star_field" data-star="field"><?php echo $temp_star_counts['field']; ?> field</span> <span class="star star_fusion" data-star="fusion"><?php echo $temp_star_counts['fusion']; ?> fusion</span> </div> <?php // Print the sort wrapper and options if allowed if ($global_allow_editing) { ?> <div class="field_tools"> <label class="label">tools</label> <a class="tool tool_shuffle" data-tool="shuffle" data-player="<?php echo $player_token; ?> ">shuffle</a> <a class="tool tool_randomize" data-tool="randomize" data-player="<?php echo $player_token; ?> ">randomize</a> </div> <?php } ?> </div> </td> </tr> </tbody> </table> <?php } ?> </div> </div> <?php $key_counter++; // Collect the outbut buffer contents $this_markup = trim(ob_get_clean()); // Return the generated markup return $this_markup; }
$temp_player_battles = rpg_prototype::battles_complete($player_token); $temp_player_transfer = $temp_player_battles >= 1 ? true : false; $item_options_markup .= '<option value="'.$player_info['player_token'].'" data-label="'.$player_info['player_token'].'" title="'.$player_info['player_name'].'" '.(!$temp_player_transfer ? 'disabled="disabled"' : '').'>'.$player_info['player_name'].'</option>'; } */ // Loop through the allowed edit data for all players $key_counter = 0; // Loop through and count each player's robot totals $temp_robot_totals = array(); foreach ($allowed_edit_data as $player_token => $player_info) { $temp_robot_totals[$player_token] = !empty($player_info['player_robots']) ? count($player_info['player_robots']) : 0; } // Loop through the players in the ability edit data foreach ($allowed_edit_data as $player_token => $player_info) { // Collect the rewards for this player $player_rewards = rpg_game::player_rewards($player_token); // Check how many robots this player has and see if they should be able to transfer $counter_player_robots = !empty($player_info['player_robots']) ? count($player_info['player_robots']) : false; $counter_player_missions = rpg_prototype::battles_complete($player_info['player_token']); $allow_player_selector = $allowed_edit_player_count > 1 && $counter_player_missions > 0 ? true : false; // Loop through the player robots and display their edit boxes foreach ($player_info['player_robots'] as $robot_token => $robot_info) { // Update the robot key to the current counter $robot_key = $key_counter; // Make a backup of the player selector $allow_player_selector_backup = $allow_player_selector; // Collect this player's ability rewards and add them to the dropdown if (!empty($_SESSION[$session_token]['values']['battle_abilities'])) { $player_ability_rewards = $_SESSION[$session_token]['values']['battle_abilities']; } elseif (!empty($player_rewards['player_abilities'])) { $player_ability_rewards = $player_rewards['player_abilities'];
$ability_counter = 0; if (!empty($ability_list_array)) { foreach ($ability_list_array as $token => $price) { $ability_info = $mmrpg_database_abilities[$token]; $ability_info_token = $token; $ability_info_price = $price; $ability_info_name = $ability_info['ability_name']; $ability_info_type = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none'; if ($ability_info_type != 'none' && !empty($ability_info['ability_type2'])) { $ability_info_type .= '_' . $ability_info['ability_type2']; } elseif ($ability_info_type == 'none' && !empty($ability_info['ability_type2'])) { $ability_info_type = $ability_info['ability_type2']; } $ability_info_quantity = 0; $ability_info_unlocked = array(); if (rpg_game::ability_unlocked('', '', $token)) { $ability_info_quantity = 3; $ability_info_unlocked = array('dr-light', 'dr-wily', 'dr-cossack'); $ability_info_price = 0; } if (empty($ability_info['ability_flag_complete'])) { //$ability_info_name = '<del>'.$ability_info_name.'</del> '; $ability_info_quantity = -1; $ability_info_unlocked = array('coming-soon'); $ability_info_name = preg_replace('/[a-z0-9]/i', '?', $ability_info_name); $ability_info_price = 0; } $global_item_quantities[$ability_info_token] = $ability_info_quantity; $global_item_prices['buy'][$ability_info_token] = $ability_info_price; $temp_info_tooltip = !empty($ability_info['ability_flag_complete']) ? rpg_ability::print_editor_title_markup($robot_info, $ability_info) : 'Coming Soon! <br /> <span style="font-size:80%;">This ability is still in development and cannot be purchased yet. <br /> Apologies for the inconveinece, and please check back later!</span>'; $temp_info_tooltip = htmlentities($temp_info_tooltip, ENT_QUOTES, 'UTF-8', true);
<?php // Collect the ability variables from the request header, if they exist $temp_player = !empty($_REQUEST['player']) ? $_REQUEST['player'] : ''; $temp_robot = !empty($_REQUEST['robot']) ? $_REQUEST['robot'] : ''; $temp_image = !empty($_REQUEST['image']) ? $_REQUEST['image'] : ''; // If key variables are not provided, kill the script in error if (empty($temp_player) || empty($temp_robot) || empty($temp_image)) { die('error|request-error|' . preg_replace('/\\s+/', ' ', print_r($_REQUEST, true))); } // Collect the current robot favourites for this user $temp_player_info = $allowed_edit_data[$temp_player]; $temp_robot_info = $allowed_edit_data[$temp_player]['player_robots'][$temp_robot]; // If player or robot info was not found, kill the script in error if (empty($temp_player_info) || empty($temp_robot_info)) { die('error|request-notfound|' . preg_replace('/\\s+/', ' ', print_r($_REQUEST, true))); } // Regardless of what happened before, update this robot's image in the session and save $temp_image_full = $temp_robot . ($temp_image != 'base' ? '_' . $temp_image : ''); $_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_robot]['robot_image'] = $temp_image_full; rpg_game::save_session(); exit('success|image-updated|' . $temp_image_full);
public static function load_session($user_id = 0) { // Reference global variables global $db; //$GAME_SESSION = &$_SESSION[self::session_token()]; $session_token = self::session_token(); // Do NOT load, save, or otherwise alter the game file while viewing remote if (defined('MMRPG_REMOTE_GAME')) { return true; } // Collect or update the user ID in the session if (empty($user_id) && isset($_SESSION[$session_token]['USER']['userid'])) { $user_id = $_SESSION[$session_token]['USER']['userid']; } else { $_SESSION[$session_token]['USER']['userid'] = $user_id; } // Clear the community thread tracker $_SESSION['COMMUNITY']['threads_viewed'] = array(); // If this is NOT demo mode, load from database if (!empty($user_id) && $user_id != MMRPG_SETTINGS_GUEST_ID) { // LOAD DATABASE USER & SAVE INFO // Collect the user and save info from the database $db_save = $db->get_array("SELECT * FROM mmrpg_saves WHERE user_id = {$user_id} LIMIT 1"); $db_user = $db->get_array("SELECT * FROM mmrpg_users WHERE user_id = '{$user_id}' LIMIT 1"); // Update the game session with database extracted variables $new_game_data = array(); $new_game_data['CACHE_DATE'] = $db_save['save_cache_date']; $new_game_data['USER']['userid'] = $db_user['user_id']; $new_game_data['USER']['roleid'] = $db_user['role_id']; $new_game_data['USER']['username'] = $db_user['user_name']; $new_game_data['USER']['username_clean'] = $db_user['user_name_clean']; $new_game_data['USER']['password'] = $db_user['user_password']; $new_game_data['USER']['password_encoded'] = $db_user['user_password_encoded']; $new_game_data['USER']['profiletext'] = $db_user['user_profile_text']; $new_game_data['USER']['creditstext'] = $db_user['user_credit_text']; $new_game_data['USER']['creditsline'] = $db_user['user_credit_line']; $new_game_data['USER']['imagepath'] = $db_user['user_image_path']; $new_game_data['USER']['backgroundpath'] = $db_user['user_background_path']; $new_game_data['USER']['colourtoken'] = $db_user['user_colour_token']; $new_game_data['USER']['gender'] = $db_user['user_gender']; $new_game_data['USER']['displayname'] = $db_user['user_name_public']; $new_game_data['USER']['emailaddress'] = $db_user['user_email_address']; $new_game_data['USER']['websiteaddress'] = $db_user['user_website_address']; $new_game_data['USER']['dateofbirth'] = $db_user['user_date_birth']; $new_game_data['USER']['approved'] = $db_user['user_flag_approved']; $new_game_data['counters'] = !empty($db_save['save_counters']) ? json_decode($db_save['save_counters'], true) : array(); $new_game_data['values'] = !empty($db_save['save_values']) ? json_decode($db_save['save_values'], true) : array(); if (!empty($db_save['save_values_battle_index'])) { //$new_game_data['values']['battle_index'] = json_decode($db_save['save_values_battle_index'], true); //foreach ($new_game_data['values']['battle_index'] AS $token => $array){ $new_game_data['values']['battle_index'][$token] = json_encode($array); } //$new_game_data['values']['battle_index_hash'] = md5($db_save['save_values_battle_index']); $new_game_data['values']['battle_index'] = array(); } if (!empty($db_save['save_values_battle_complete'])) { $new_game_data['values']['battle_complete'] = json_decode($db_save['save_values_battle_complete'], true); $new_game_data['values']['battle_complete_hash'] = md5($db_save['save_values_battle_complete']); } if (!empty($db_save['save_values_battle_failure'])) { $new_game_data['values']['battle_failure'] = json_decode($db_save['save_values_battle_failure'], true); $new_game_data['values']['battle_failure_hash'] = md5($db_save['save_values_battle_failure']); } if (!empty($db_save['save_values_battle_rewards'])) { $new_game_data['values']['battle_rewards'] = json_decode($db_save['save_values_battle_rewards'], true); $new_game_data['values']['battle_rewards_hash'] = md5($db_save['save_values_battle_rewards']); } if (!empty($db_save['save_values_battle_settings'])) { $new_game_data['values']['battle_settings'] = json_decode($db_save['save_values_battle_settings'], true); $new_game_data['values']['battle_settings_hash'] = md5($db_save['save_values_battle_settings']); } if (!empty($db_save['save_values_battle_items'])) { $new_game_data['values']['battle_items'] = json_decode($db_save['save_values_battle_items'], true); $new_game_data['values']['battle_items_hash'] = md5($db_save['save_values_battle_items']); } if (!empty($db_save['save_values_battle_stars'])) { $new_game_data['values']['battle_stars'] = json_decode($db_save['save_values_battle_stars'], true); $new_game_data['values']['battle_stars_hash'] = md5($db_save['save_values_battle_stars']); } if (!empty($db_save['save_values_robot_database'])) { $new_game_data['values']['robot_database'] = json_decode($db_save['save_values_robot_database'], true); $new_game_data['values']['robot_database_hash'] = md5($db_save['save_values_robot_database']); } $new_game_data['flags'] = !empty($db_save['save_flags']) ? json_decode($db_save['save_flags'], true) : array(); $new_game_data['battle_settings'] = !empty($db_save['save_settings']) ? json_decode($db_save['save_settings'], true) : array(); // Update the session with the new save info $_SESSION[$session_token] = array_merge($_SESSION[$session_token], $new_game_data); unset($new_game_data); // Unset the player selection to restart at the player select screen if (rpg_game::players_unlocked() > 1) { $_SESSION[$session_token]['battle_settings']['this_player_token'] = false; } } else { // LOAD DEMO USER AND SAVE INFO // return false for now... return false; } // Update the last saved value $_SESSION[$session_token]['values']['last_load'] = time(); // Update the user table in the database if not done already if (empty($_SESSION[$session_token]['DEMO'])) { $db->update('mmrpg_users', array('user_last_login' => time(), 'user_backup_login' => $db_user['user_last_login']), "user_id = {$db_user['user_id']}"); } //exit(); // Return true on success return true; }