internal bool activate_event_by_name(string name, bool insert) { //foreach (int i in Event_Handler.events) //Debug if (Event_Handler.events.Any(x => map_event_data.Events[x].name == name)) { int i = Event_Handler.events.First(x => map_event_data.Events[x].name == name); Event_Data event_data = map_event_data.Events[i]; //if (event_data.name == name) //{ if (Global.game_system.add_event(i, true, insert)) { if (Global.game_system.is_interpreter_running) { wait_time = 2; Global.game_map.clear_move_range(); } return(true); } // break; //Debug //} } #if DEBUG else if (!Event_Handler.event_data.Events.Any(x => x.name == name)) { Print.message(string.Format("Failed to find and run event named\n\"{0}\"", name)); } #endif return(false); }
public bool is_blocked(Vector2 loc, int id, bool fow) { if (is_off_map(loc)) { #if DEBUG Print.message("immoissubke location[" + loc.X.ToString() + ", " + loc.Y.ToString() + "]"); #endif return(true); } Game_Unit unit = get_unit(loc); // Falsely returns that no unit is at this tile if the unit can't see it if (unit != null) { if (fow && !unit.visible_by(this.units[id].team)) { unit = null; } } // If there is a unit here and it's not the tested one if (unit != null && unit.id != id) { return(true); } // Block moving onto light runes if (get_light_rune(loc) != null) { return(true); } return(false); }
public Game_Actor this[int index] { get { index = Math.Max(index, 0); int data_count = max_actor_id(); // Temp Actor if (index > data_count) { if (index > data_count + temp_actors.Count + 1) { #if DEBUG Print.message("what are you doing"); #endif } // If a new temp actor if (index == data_count + temp_actors.Count + 1) { temp_actors.Add(new Game_Actor(index)); } // If temp actor was nulled before if (temp_actors[index - (data_count + 1)] == null) { temp_actors[index - (data_count + 1)] = new Game_Actor(index); } // Return the temp_actors actor return(temp_actors[index - (data_count + 1)]); } // Normal Actor if (!actors.ContainsKey(index)) { if (!Global.data_actors.Keys.Contains(index)) { throw new IndexOutOfRangeException("Actor data with id " + index.ToString() + " does not exist"); } actors[index] = new Game_Actor(Global.data_actors[index]); } return(actors[index]); } }
public bool add_actor_unit(int team, Vector2 loc, int actor_id, string identifier) { #if DEBUG if (Global.scene.is_map_scene && Global.scene.scene_type != "Scene_Map_Unit_Editor" && !Global.data_actors.ContainsKey(actor_id)) { Print.message("Adding an actor unit with actor id " + actor_id.ToString() + "\nThis actor id has no data defined.\nAre you sure this id is correct?"); } #endif new_unit_id(); var new_unit = Objects.add_unit( new Game_Unit(Last_Added_Unit_Id, loc, team, 0, actor_id), identifier); // If a dead actor, give them 1 hp so they can limp around unless they're a dead PC if (new_unit.actor.is_out_of_lives() && new_unit.is_player_team) { new_unit.hp = 0; } else { new_unit.actor.hp = Math.Max(1, new_unit.actor.hp); } return(true); }
private void ChangeScene(string newScene) { Global.return_to_title = false; if (Global.map_exists && MoveRangeUpdateThread == null) { StartMoveRangeThread(); } bool sceneChanged = true; string text = Global.game_temp.message_text; Global.game_temp.message_text = null; switch (newScene) { case "Scene_Splash": Global.scene = new Scene_Splash(); break; case "Scene_Soft_Reset": EndMoveRangeThread(); MoveRangeUpdateThread = null; Global.scene = new Scene_Soft_Reset(); break; #if DEBUG case "Debug_Start": #endif case "Start_Game": case "Scene_Worldmap": IOHandler.RefreshSaveId(); #if DEBUG IOHandler.RefreshDebugFileId(newScene == "Debug_Start"); if (newScene == "Start_Game" || newScene == "Debug_Start") { newScene = "Start_Game"; #else if (newScene == "Start_Game") { #endif IOHandler.LoadFile(true); Global.game_options.post_read(); Global.game_temp = new Game_Temp(); } Global.change_to_new_scene(newScene); break; case "Scene_Save": Global.change_to_new_scene("Scene_Save"); break; case "Start_Chapter": EndMoveRangeThread(); Global.start_chapter(); StartMoveRangeThread(); break; #if !MONOGAME && DEBUG case "Scene_Map_Unit_Editor": EndMoveRangeThread(); Global.start_unit_editor( MapEditorUnits, MapEditorMap, MapEditorUnitsSource); StartMoveRangeThread(); break; case "Scene_Map_Playtest": if (!Global.scene.is_unit_editor) { Print.message("Failed to start playtest, not currently in unit editor"); sceneChanged = false; } else { IOHandler.RefreshFileId(); IOHandler.LoadFile(true); Global.game_options.post_read(); Global.game_temp = new Game_Temp(); EndMoveRangeThread(); Global.start_unit_editor_playtest(); StartMoveRangeThread(); } break; #endif case "Load_Suspend": IOHandler.RefreshSaveId(); // Resume Arena if (Global.in_arena()) { ChangeScene("Scene_Arena"); StartMoveRangeThread(); return; } else { Global.suspend_finish_load(true); StartMoveRangeThread(); } break; case "Scene_Map": Global.change_to_new_scene("Scene_Map"); Global.init_map(); break; case "Scene_Dance": case "Scene_Staff": case "Scene_Arena": case "Scene_Battle": case "Scene_Promotion": #if DEBUG case "Scene_Test_Battle": if (newScene == "Scene_Test_Battle") { Global.change_to_new_scene("Scene_Test_Battle"); } else { #endif Global.change_to_new_scene(newScene); Global.initialize_action_scene(newScene == "Scene_Arena", newScene == "Scene_Promotion"); #if DEBUG } #endif break; case "Scene_Title_Load": Global.reset_system(); Global.change_to_new_scene("Scene_Title_Load"); break; case "Scene_Title": Global.reset_system(); Global.clear_events(); Global.change_to_new_scene("Scene_Title"); break; case "Scene_Class_Reel": Global.game_temp = new Game_Temp(); Global.new_game_actors(); Global.change_to_new_scene("Scene_Class_Reel"); break; default: sceneChanged = false; #if DEBUG Print.message("Non-existant scene type called: " + Global.new_scene); #endif break; } if (sceneChanged) { Global.dispose_battle_textures(); Global.dispose_face_textures(); Global.Audio.stop_bgs(); //@Debug Global.Audio.stop_me(); //@Debug } else { Global.game_temp.message_text = text; } Global.scene_change(""); }
public bool check_talk(Game_Unit battler_1, Game_Unit battler_2, bool reverse, bool test) { if (battler_2 == null) { return(false); } // Specific for two people for (int i = 0; i < Global.game_state.battle_convos.Count; i++) { Battle_Convo convo = Global.game_state.battle_convos[i]; if ((convo.Id1 == battler_1.id && convo.Id2 == battler_2.id) || (convo.Id1 == battler_2.id && convo.Id2 == battler_1.id)) { if (convo.Activated) { return(false); } if (!string.IsNullOrEmpty(convo.Value)) { if (!Global.battle_text.ContainsKey(convo.Value)) { #if DEBUG Print.message(string.Format( "Boss quote \"{0}\" does not exist", convo.Value)); #endif return(false); } if (test) { return(true); } new_message_window(); if (convo.Id1 == battler_1.id ^ !reverse) { message_reverse(); } Global.game_temp.message_text = Global.battle_text[convo.Value]; Global.game_state.clear_battle_convo(i); } return(false); } } // Specific for one person for (int i = 0; i < Global.game_state.battle_convos.Count; i++) { Battle_Convo convo = Global.game_state.battle_convos[i]; if (!convo.Activated && ((convo.Id1 == battler_1.id || convo.Id1 == battler_2.id) && convo.Id2 == -1 && battler_1.is_attackable_team(battler_2))) { if (!string.IsNullOrEmpty(convo.Value)) { if (!Global.battle_text.ContainsKey(convo.Value)) { #if DEBUG Print.message(string.Format( "Boss quote \"{0}\" does not exist", convo.Value)); #endif return(false); } if (test) { return(true); } Global.game_temp.message_text = Global.battle_text[convo.Value]; //Debug Global.game_state.clear_battle_convo(i); new_message_window(); if (convo.Id1 == battler_1.id ^ !reverse) { message_reverse(); } //Global.game_temp.message_text = Global.battle_text[convo.Value]; //Debug //Global.game_map.clear_battle_convo(i); } return(false); } } return(false); }
private bool process_command() { if (event_data == null || Index >= event_data.data.Count) { if (!Global.map_exists || !Global.game_map.units_dying) { Finished = true; } return(false); } if (!NO_ACTION_COMMANDS.Contains(command.Key) && Global.scene.is_map_scene) { if (try_cancel_ai_skip()) { return(false); } } switch (command.Key) { // Prep Message case 1: return(command_prepmessage()); // Run Message case 2: return(command_runmessage()); // Wait case 3: return(command_wait()); // Change Chapter case 4: return(command_chapter()); // Change screen tone case 5: return(command_tone()); // Warp Player case 6: return(command_player_warp()); // Close Message case 7: throw new NotImplementedException(); Index++; return(true); // Follow Moving Unit case 8: return(command_follow_unit()); // Warp Unit case 10: return(command_unit_warp()); // Move Unit case 11: return(command_unit_move()); // Wait for Move case 12: return(command_wait_for_move()); // Chapter Change Effect case 13: return(command_chapter_change()); // Add Battle Convo case 14: return(command_battle_convo()); // Temp Death Quote case 15: return(command_death_quote()); // Change Gold case 16: return(command_change_gold()); // Set Screen Color case 17: return(command_screen_color()); // Show Popup case 18: return(command_popup()); // Show Gold Gain Popup case 19: return(command_gold_gain_popup()); // Unit Battle Theme case 20: return(command_unit_theme()); // Add Unit case 21: return(command_add_unit()); // Change Mission case 22: return(command_change_mission()); // Change Team case 23: return(command_change_team()); // Change Group case 24: return(command_change_group()); // Change Team Name case 25: return(command_change_team_name()); // Set Boss case 26: return(command_set_boss()); // Set Drops case 27: return(command_set_drops()); // Add Talk Event case 28: return(command_add_talk()); // Add Deployment Point case 29: return(command_add_deployment()); // Add to Battalion case 30: return(command_add_to_battalion()); // Target Tile case 31: return(command_target_tile()); // Force Deployment case 32: return(command_force_deployment()); // Set Convoy case 33: return(command_set_convoy()); // Convoy Item Gain case 34: return(command_convoy_item_gain()); // Remove Unit case 35: return(command_remove_unit()); // Remove Talk Event case 36: return(command_remove_talk()); // Set FoW case 37: return(command_set_fow()); // Set FoW Vision case 38: return(command_fow_vision()); // Set Weather case 39: return(command_set_weather()); // FoW Light Source case 40: return(command_fow_light_source()); // Change Tile Id case 41: return(command_change_tile()); // Pillage Tile case 42: return(command_pillage_tile()); // Add Area Background case 43: return(command_area_background()); // Add Destroyable Object case 44: return(command_add_destroyable()); // Import Map Area case 45: return(command_import_map_area()); // Add Siege Engine case 46: return(command_add_siege()); // Edit Tile Outlines case 47: return(command_edit_tile_outlines()); // AI Target Map Object case 48: return(command_ai_target_map_object()); // Change class case 51: return(command_class_change()); // Exp Gain case 52: return(command_exp()); // Item Gain case 53: return(command_item_gain()); // Discard Item case 54: return(command_item_discard()); // WExp Gain case 55: return(command_wexp()); // Support case 56: return(command_support()); // Boss Hard Mode Stats case 57: return(command_boss_hard_mode()); // Block Support case 58: return(command_block_support()); // Change Status case 59: return(command_change_status()); // Heal Actors case 61: return(command_heal_actors()); // Set Unit Ready case 62: return(command_unit_ready()); // Set Map Edge Offsets case 63: return(command_map_edge()); // Unload Actor case 64: return(command_unload_actor()); // Rescue case 65: return(command_rescue()); // Change Actor Name case 66: return(command_change_name()); // Set Min Alpha case 71: return(command_min_alpha()); // Refresh Alpha case 72: return(command_refresh_alpha()); // Add Alpha Source case 73: return(command_add_alpha()); // Clear Alpha Sources case 74: return(command_clear_alpha()); // Set Ally Alpha case 75: return(command_ally_alpha()); // Blacken Screen case 76: return(command_blacken_screen()); // Add Visit Location case 81: return(command_add_visit()); // Remove Visit Location case 82: return(command_remove_visit()); // Add Shop Location case 83: return(command_add_shop()); // Add Arena Location case 86: return(command_add_arena()); // Add Escape Point case 91: return(command_add_escape()); // Add Seize Point case 92: return(command_add_seize()); // Add Defend Area case 93: return(command_add_defend()); // Add Unit Seek Location case 94: return(command_add_unit_seek()); // Add Team Seek Location case 95: return(command_add_team_seek()); // Change Objective case 96: return(command_change_objective()); // Set Team Leader case 97: return(command_set_leader()); // Loss On Death case 98: return(command_loss_on_death()); // Debug print case 101: #if DEBUG Print.message(string.Join("\n", command.Value), "Event Debug"); #endif Index++; return(true); // ASMC case 103: return(command_custom()); // Set Switch case 111: return(command_set_switch()); // Set Variable case 112: return(command_set_variable()); // Return to Title case 121: return(command_title()); // Game Over case 122: return(command_gameover()); // Return to World Map case 123: return(command_worldmap()); // Preparations case 124: return(command_preparations()); // Map Save case 125: return(command_map_save()); // End Chapter case 126: return(command_end_chapter()); // Home Base case 127: return(command_home_base()); // Wait for Preparations case 128: return(command_wait_for_prep()); // Add Base Event case 129: return(command_add_base_event()); // Gain Completion Points case 130: return(command_gain_completion_points()); // Play BGM case 131: return(command_play_bgm()); // Fade BGM case 132: return(command_fade_bgm()); // Play SFX case 133: return(command_play_sfx()); // Play BGS case 134: return(command_play_bgs()); // Stop BGS case 135: return(command_stop_bgs()); // Fade SFX case 136: return(command_fade_sfx()); // Stop SFX case 137: return(command_stop_sfx()); // Duck BGM case 138: return(command_duck_bgm()); // Center Worldmap Camera case 141: return(command_center_worldmap()); // Worldmap Dot case 142: return(command_worldmap_dot()); // Worldmap Arrow case 143: return(command_worldmap_arrow()); // Worldmap Remove Dot case 144: return(command_worldmap_remove_dot()); // Worldmap Beacon case 145: return(command_worldmap_beacon()); // Worldmap Remove Beacon case 146: return(command_worldmap_remove_beacon()); // Worldmap Zoomed Out case 147: return(command_worldmap_zoomed_out()); // Worldmap Unit case 151: return(command_worldmap_unit()); // Wmap Queue Unit Move case 152: return(command_worldmap_queue_unit_move()); // Wmap Queue Unit Idle case 153: return(command_worldmap_queue_unit_idle()); // Wmap Queue Unit Pose case 154: return(command_worldmap_queue_unit_pose()); // Wmap Queue Unit Remove case 155: return(command_worldmap_queue_unit_remove()); // Wmap Clear Removing case 156: return(command_worldmap_clear_removing()); // Wmap Queue Track Unit case 157: return(command_worldmap_queue_unit_tracking()); // Wmap Wait for Units case 158: return(command_worldmap_wait_for_unit_move()); // Preset RNs case 171: return(command_preset_rns()); // Scripted Battle case 172: return(command_scripted_battle()); // Scripted Battle Params case 173: return(command_scripted_battle_params()); // If statement case 201: return(command_if()); // If statement (or) // This should never come up on its own case 202: Index++; return(true); // Else statement, ElseIf statement case 203: case 205: return(command_else()); // EndIf statement // This does nothing on its own case 204: Index++; return(true); // Skip block start case 211: if (SkipOverride) { throw new InvalidOperationException(string.Format( "Encountered a Skip Block Start while already in a Skip Override block, at line {1} of event {0}", event_data.name, Index)); } if (SkipElseBlock >= Skip_Block) { throw new InvalidOperationException(string.Format( "Starting a skip block within a skip else is not allowed, at line {1} of event {0}", event_data.name, Index)); } return(command_skip()); // Skip block if skipped case 212: if (SkipOverride) { throw new InvalidOperationException(string.Format( "Encountered a Skip Block Else while already in a Skip Override block, at line {1} of event {0}", event_data.name, Index)); } return(command_skip_else()); // Skip block end case 213: if (SkipOverride) { throw new InvalidOperationException(string.Format( "Encountered a Skip Block End while already in a Skip Override block, at line {1} of event {0}", event_data.name, Index)); } // This command should only be hit at the end of a skip else, when the else should end // Or at the end of an unskipped block that has no else decrement_skip_block(); Skipping = false; Index++; return(true); // Skip override start // This does nothing on its own case 214: if (SkipOverride) { throw new InvalidOperationException(string.Format( "Encountered a Skip Override Start while already in a Skip Override block, at line {1} of event {0}", event_data.name, Index)); } Index++; return(true); // Skip override end case 215: return(command_skip_override_end()); // Delete Event case 250: return(command_delete()); // Cancel Other Events case 251: return(command_cancel_events()); // Call Event case 252: return(command_call_event()); default: Index++; return(true); } }
public static void start_unit_editor_playtest() { var old_scene = Global.scene; if (!(old_scene is Scene_Map_Unit_Editor)) { return; } Difficulty_Modes difficulty = Global.game_system.Difficulty_Mode; var chapter = Global.data_chapters[Global.game_system.New_Chapter_Id]; var previous_chapters = Global.save_file.valid_previous_chapters(chapter.Id); var previous_chapter_ids = previous_chapters .ToDictionary(p => p.Key, p => p.Value.Count == 0 ? "" : p.Value.Last()); if (previous_chapters.Count == 0 || previous_chapters.Any(x => x.Value.Count == 0)) { if (previous_chapters.Count > 0) { Print.message(string.Format( "Could not load any save data\nfor \"{0}\", tried to use save file {1}", Global.game_system.New_Chapter_Id, Global.current_save_id)); } previous_chapter_ids = previous_chapter_ids .ToDictionary(p => p.Key, p => ""); Global.game_system.reset(); Global.game_system.reset_event_variables(); int battalion_index = chapter.Battalion; Global.game_battalions.add_battalion(battalion_index); Global.game_battalions.current_battalion = battalion_index; } else { Global.save_file.load_data(chapter.Id, previous_chapter_ids, ""); Global.game_actors.heal_battalion(); Global.battalion.refresh_deployed(); } Global.game_system.Difficulty_Mode = difficulty; if (Global.game_system.Style != Mode_Styles.Classic) { Global.save_file.Difficulty = Global.game_system.Difficulty_Mode; } Global.game_system.new_chapter(chapter.Prior_Chapters, chapter.Id, previous_chapter_ids); // these weren't copied in like the rest of the Scene_Worldmap.start_chapter() stuff? //Debug Global.game_temp = new Game_Temp(); Global.save_file = null; Global.change_to_new_scene("Scene_Map"); Global.reset_game_state(); var old_map = Global.game_map; Global.game_map = new Game_Map(); Global.player = new Player(); // Trying to start this after everything else, instead of in the middle //move_range_update_thread(); //Debug Global.clear_events(); //Global.Audio.clear_map_theme(); //@Debug (Scene as Scene_Map).set_map(old_scene as Scene_Map_Unit_Editor); Global.game_state.reset_support_data(); Global.change_game_state_turn(); if (old_map != null) { Global.game_map.set_scroll_loc(old_map.display_loc, true, true); Global.player.center_cursor(true); } }