public void RefreshCommands() { Canto_Records canto = Global.game_system.Menu_Canto; Global.game_system.Menu_Canto = Canto_Records.None; RefreshCommands(canto); }
public void UnitMenuTalk(Game_Unit unit, int targetId, Canto_Records canto) { Global.game_map.remove_updated_move_range(unit.id); Global.game_map.clear_move_range(); Global.game_map.range_start_timer = 0; Global.game_state.activate_talk(unit.id, targetId); Global.game_temp.menuing = false; close_unit_menu(true); unit.cantoing = false; // Lock in unit movement unit.moved(); bool cantoMovement = unit.has_canto() && !unit.full_move(); if (Constants.Gameplay.TALKING_IS_FREE_ACTION) { Global.game_system.Menu_Canto = canto | Canto_Records.Talk | (cantoMovement ? Canto_Records.Horse : Canto_Records.None); unit.cantoing = true; } else if (cantoMovement) { unit.cantoing = true; } Global.player.facing = 6; Global.player.frame = 1; }
public void RefreshCommands(Canto_Records canto) { List <string> commands = SetCommands(canto); var window = NewUnitWindow(commands, 56); Window = window; }
public UnitCommandMenu(int unitId) { UnitId = unitId; Canto = Canto_Records.None; RefreshCommands(); CreateCancelButton(); }
public void UnitMenuGive(Game_Unit unit, int targetId, Canto_Records canto) { Global.game_map.clear_move_range(); // Lock in unit movement unit.moved(); unit.give_ally(targetId); Global.game_system.Menu_Canto = canto | Canto_Records.Give; Global.game_temp.menuing = false; close_unit_menu(true); }
internal static bool canto_allows_normal_actions(Canto_Records canto) { if (continuous_move_canto(canto)) { return(false); } if (canto.HasEnumFlag(Canto_Records.Take)) { return(false); } return(true); }
private static bool CantoAllowsItem(Canto_Records canto) { if (!CantoAllowsNormalActions(canto)) { // This can only be allowed if post-dash you can only equip, not use //if (!canto.HasEnumFlag(Canto_Records.Horse) && canto.HasEnumFlag(Canto_Records.Dash)) //Debug // return true; return(false); } return(true); }
private static bool CantoAllowsNormalActions(Canto_Records canto) { if (ContinuousMoveCanto(canto)) { return(false); } if (canto.HasEnumFlag(Canto_Records.Take)) { return(false); } return(true); }
internal static bool canto_allows_item(Canto_Records canto) { if (!canto_allows_normal_actions(canto)) { // This can only be allowed if post-dash you can only equip, not use //if (!canto.HasEnumFlag(Canto_Records.Horse) && canto.HasEnumFlag(Canto_Records.Dash)) //Debug // return true; return(false); } return(true); }
internal static bool canto_allows_take_drop(Canto_Records canto) { // Skills: Dash if (canto.HasEnumFlag(Canto_Records.Dash)) { return(false); } if (canto.HasEnumFlag(Canto_Records.Take)) { return(true); } return(false); }
private static bool CantoAllowsTakeDrop(Canto_Records canto) { // Skills: Dash if (canto.HasEnumFlag(Canto_Records.Dash)) { return(false); } if (canto.HasEnumFlag(Canto_Records.Take)) { return(true); } return(false); }
private static bool ContinuousMoveCanto(Canto_Records canto) { if (canto == Canto_Records.Horse) { return(true); } // Skills: Dash if (canto.HasEnumFlag(Canto_Records.Dash)) { return(true); } return(false); }
internal static bool continuous_move_canto(Canto_Records canto) { if (canto == Canto_Records.Horse) { return(true); } // Skills: Dash if (canto.HasEnumFlag(Canto_Records.Dash)) { return(true); } return(false); }
private static bool CantoAllowsTrade(Canto_Records canto) { if (canto.HasEnumFlag(Canto_Records.Trade)) { return(false); } if (CantoAllowsItem(canto)) { if (canto.HasEnumFlag(Canto_Records.Dash)) { return(false); } } if (!CantoAllowsNormalActions(canto)) { return(false); } return(true); }
internal static bool canto_allows_trade(Canto_Records canto) { if (canto.HasEnumFlag(Canto_Records.Trade)) { return(false); } if (canto_allows_item(canto)) { if (canto.HasEnumFlag(Canto_Records.Dash)) { return(false); } } if (!canto_allows_normal_actions(canto)) { return(false); } return(true); }
public void reset() { Instant_Move = false; Selected_Unit_Id = -1; //Rng = new List<int>(); reset_rng(); Preset_Rng = new List <int>(); Saved_Rns = new List <int>(); Saving_Rns = false; Preparations = false; Home_Base = false; Menu_Canto = Canto_Records.None; Battler_1_Id = -1; Battler_2_Id = -1; Aoe_Targets = new List <int>(); Staff_User_Id = -1; Staff_Target_Id = -1; Staff_Target_Loc = new Vector2(-1, -1); Rescuer_Id = -1; Rescuee_Id = -1; Item_User = -1; Item_Used = -1; Item_Inventory_Target = -1; ItemPromotionId = -1; ItemTargetLoc = new Vector2(-1, -1); Visitor_Id = -1; Visit_Loc = new Vector2(-1, -1); Shopper_Id = -1; Shop_Loc = new Vector2(-1, -1); SecretShop = false; In_Arena = false; Wager = -1; Arena_Distance = -1; Arena_Round = -1; Arena_Retreat = false; Stolen_Item = -1; Discarder_Id = -1; SupportGainId = -1; SupportGainTargets = new List <int>(); Battle_Mode = Constants.Animation_Modes.Map; Status_Page = 0; Unit_Page = 0; Unit_Sort = 0; Unit_Sort_Up = true; DataPage = 0; Supply_Item_Type = 0; Objective_Text = ""; Victory_Text = ""; Loss_Text = ""; Objective_Mode = new int[] { 0, 0 }; Loss_On_Death = new HashSet <int>(); Ally_Loss_On_Death = new List <int>(); Difficulty_Mode = Difficulty_Modes.Normal; Style = Global.save_file == null ? Mode_Styles.Standard : Global.save_file.Style; Previous_Chapters = new List <string>(); Rankings = new PastRankings(); Total_Play_Time = 0; Chapter_Save_Progression_Keys = new string[0]; Victory = false; Failure = false; clear_events(); }
public void read(BinaryReader reader, Version loadedVersion) { Instant_Move = reader.ReadBoolean(); Character_Anim_Count = reader.ReadInt32(); Selected_Unit_Id = reader.ReadInt32(); if (loadedVersion.older_than(0, 4, 3, 2)) { List <int> rand = new List <int>(); rand.read(reader); reset_rng(); } else { Rand = Rng.read(reader, loadedVersion); } //reset_rng(); //Debug Preset_Rng.read(reader); Preparations = reader.ReadBoolean(); if (!loadedVersion.older_than(0, 4, 3, 6)) { Home_Base = reader.ReadBoolean(); } Menu_Canto = (Canto_Records)reader.ReadInt32(); Battler_1_Id = reader.ReadInt32(); Battler_2_Id = reader.ReadInt32(); Aoe_Targets.read(reader); Staff_User_Id = reader.ReadInt32(); Staff_Target_Id = reader.ReadInt32(); Staff_Target_Loc = Staff_Target_Loc.read(reader); Rescuer_Id = reader.ReadInt32(); Rescuee_Id = reader.ReadInt32(); Item_User = reader.ReadInt32(); Item_Used = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 6, 1)) { Item_Inventory_Target = reader.ReadInt32(); } if (!loadedVersion.older_than(0, 6, 6, 0)) { ItemPromotionId = reader.ReadInt32(); } if (!loadedVersion.older_than(0, 6, 4, 1)) { ItemTargetLoc = ItemTargetLoc.read(reader); } Shopper_Id = reader.ReadInt32(); Shop_Loc = Shop_Loc.read(reader); if (!loadedVersion.older_than(0, 5, 0, 5)) { SecretShop = reader.ReadBoolean(); } In_Arena = reader.ReadBoolean(); Wager = reader.ReadInt32(); Arena_Distance = reader.ReadInt32(); Arena_Round = reader.ReadInt32(); Stolen_Item = reader.ReadInt32(); Dance_Item = reader.ReadInt32(); Discarder_Id = reader.ReadInt32(); if (!loadedVersion.older_than(0, 5, 5, 4)) { SupportGainId = reader.ReadInt32(); SupportGainTargets.read(reader); } Battle_Mode = (Constants.Animation_Modes)reader.ReadInt32(); Objective_Text = reader.ReadString(); Victory_Text = reader.ReadString(); Loss_Text = reader.ReadString(); Objective_Mode = Objective_Mode.read(reader); Loss_On_Death.read(reader); Ally_Loss_On_Death.read(reader); if (loadedVersion.older_than(0, 4, 2, 0)) { Difficulty_Mode = reader.ReadBoolean() ? Difficulty_Modes.Hard: Difficulty_Modes.Normal; } else { Difficulty_Mode = (Difficulty_Modes)reader.ReadInt32(); } Style = (Mode_Styles)reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 0, 4)) { Previous_Chapters.read(reader); } if (!loadedVersion.older_than(0, 4, 4, 0)) { Chapter_Id = reader.ReadString(); if (!loadedVersion.older_than(0, 5, 6, 3)) { PreviousChapterIds.read(reader); } else { PreviousChapterIds.Clear(); string previous_chapter = reader.ReadString(); if (!string.IsNullOrEmpty(previous_chapter)) { if (!Global.data_chapters.ContainsKey(Chapter_Id)) { throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", Chapter_Id)); } else if (!Global.data_chapters.ContainsKey(previous_chapter)) { throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", previous_chapter)); } else { string progression_id; if (!Global.data_chapters[Chapter_Id].Prior_Chapters .Intersect(Global.data_chapters[previous_chapter].Progression_Ids) .Any()) { #if DEBUG //throw new KeyNotFoundException(string.Format( // "Chapter {0}'s prior chapters do not match chapter {1}'s progression ids", // Chapter_Id, previous_chapter)); #endif // Incorrect but eh @Debug progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters.First(); } else { progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters .Intersect(Global.data_chapters[previous_chapter].Progression_Ids) .First(); } PreviousChapterIds.Add(progression_id, previous_chapter); } } } } if (!loadedVersion.older_than(0, 6, 7, 0)) { Rankings = PastRankings.read(reader, Difficulty_Mode); } else { Rankings = new PastRankings(); } Total_Play_Time = reader.ReadInt32(); Chapter_Play_Time = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 6, 3)) { Chapter_Start_Time = DateTime.FromBinary(reader.ReadInt64()); if (!loadedVersion.older_than(0, 6, 3, 1)) { GameplayStartTime = DateTime.FromBinary(reader.ReadInt64()); } else { GameplayStartTime = Chapter_Start_Time; } Deployed_Unit_Count = reader.ReadInt32(); Deployed_Unit_Avg_Level = reader.ReadInt32(); } Chapter_Turn = reader.ReadInt32(); Chapter_Exp_Gain = reader.ReadInt32(); Chapter_Damage_Taken = reader.ReadInt32(); Chapter_Deaths = reader.ReadInt32(); Chapter_Completion = reader.ReadInt32(); if (!loadedVersion.older_than(0, 4, 4, 3)) { Home_Base_Background = reader.ReadString(); } SWITCHES = Event_Variable_Data <bool> .read(reader, Config.EVENT_DATA_LENGTH); VARIABLES = Event_Variable_Data <int> .read(reader, Config.EVENT_DATA_LENGTH); //Event_Processor.read_data(reader); //Debug }
private List <string> SetCommands(Canto_Records canto) { Disabled = new List <int>(); List <string> commands = new List <string>(); // Actions: // 0 = Attack // 1 = Staff // 2 = Drop/Rescue // 3 = Item // 4 = Trade // 5 = Wait // 6 = Give/Take // 7 = Visit // 8 = Talk // 9 = Shop/Armory // 10 = Arena // 11 = Chest // 12 = Door // 13 = Steal // 14 = Seize // 15 = Status // 16 = Dance // 17 = Support // 18 = Supply // 19 = Escape // 20 = Construct // 29 = Secret Shop/Armory // 30 = Arena IndexRedirect = new List <int>(); Game_Unit unit = Global.game_map.units[UnitId]; unit.actor.remove_broken_items(); Canto = Canto_Records.None; // If canto state is null but the unit is cantoing, set to horse canto if (canto == Canto_Records.None && Canto == Canto_Records.None) { //Canto = (unit.cantoing && unit.has_canto() ? Canto_Records.Horse : Canto_Records.None); //@Debug Canto = (unit.cantoing ? Canto_Records.Horse : Canto_Records.None); } else if (canto != Canto_Records.None) { Canto = canto; } if (CantoAllowsNormalActions(Canto)) { List <int>[] range_ary; // enemies: attack range_ary = unit.enemies_in_range(); List <int> enemy_range = range_ary[0]; UseableWeapons = range_ary[1]; // enemies: staves UseableStaves = new List <int>(); range_ary = unit.enemies_in_staff_range(); UseableStaves.AddRange(range_ary[1]); // allies: staves range_ary = unit.allies_in_staff_range(); UseableStaves.AddRange(range_ary[1]); // other: staves range_ary = unit.untargeted_staff_range(); List <int> other_staff_range = range_ary[0]; UseableStaves.AddRange(range_ary[1]); UseableStaves = UseableStaves.Distinct().ToList(); // allies List <int> ally_range = unit.allies_in_range(1); // Attack if (UseableWeapons.Count > 0) { List <int> item_indices = unit.weapon_indices(UseableWeapons); Global.game_temp.temp_attack_range = unit.get_weapon_range(item_indices, new HashSet <Vector2> { unit.loc }); //Global.game_temp.temp_attack_range = Global.game_map.get_unit_range(new List<Vector2> { unit.loc }, // unit.min_range_absolute(), unit.max_range_absolute()); // this should care about the exact weapons, I think //Yeti Global.game_map.range_start_timer = 0; commands.Add("Attack"); IndexRedirect.Add(0); } // Staff if (UseableStaves.Count > 0) { List <int> item_indices = unit.weapon_indices(UseableStaves); Global.game_temp.temp_staff_range = unit.get_weapon_range(item_indices, new HashSet <Vector2> { unit.loc }); //Global.game_temp.temp_staff_range = Global.game_map.get_unit_range(new List<Vector2> { unit.loc }, // unit.min_range_absolute(true), unit.max_range_absolute(true)); // this should care about the exact weapons, I think //Yeti Global.game_map.range_start_timer = 0; commands.Add("Staff"); IndexRedirect.Add(1); } // Seize if (Global.game_map.get_seize_points(unit.team, unit.group).Contains(unit.loc) && unit.can_seize) { commands.Add("Seize"); IndexRedirect.Add(14); } // Escape if (Global.game_map.escape_point_locations(unit.team, unit.group).Contains(unit.loc)) { var escapePoint = Global.game_map.escape_point_data(unit, unit.loc); if (!escapePoint.LordOnly || unit.can_seize) { commands.Add("Escape"); IndexRedirect.Add(19); } } // Dance if (unit.can_dance()) { if (unit.dance_targets().Count > 0) { commands.Add(unit.dance_name()); IndexRedirect.Add(16); } } // Construct bool can_construct = false; if (unit.can_assemble() && unit.assemble_targets().Count > 0) { can_construct = true; } if (unit.can_reload() && unit.reload_targets().Count > 0) { can_construct = true; } if (unit.can_reclaim() && unit.reclaim_targets().Count > 0) { can_construct = true; } if (can_construct) { commands.Add("Construct"); IndexRedirect.Add(20); } // Steal if (unit.can_steal()) { if (unit.steal_targets().Count > 0) { commands.Add("Steal"); IndexRedirect.Add(13); if (unit.actor.is_full_items) { Disabled.Add(13); } } } // Support if (unit.can_support()) { commands.Add("Support"); IndexRedirect.Add(17); } // Talk if (!Canto.HasEnumFlag(Canto_Records.Talk) && unit.can_talk()) { Global.game_temp.temp_talk_range.Clear(); foreach (int id in unit.talk_targets()) { Global.game_temp.temp_talk_range.Add(Global.game_map.units[id].loc); } Global.game_map.range_start_timer = 0; commands.Add("Talk"); IndexRedirect.Add(8); } // Visit if (unit.can_visit()) { string visit_name = Global.game_map.visit_locations[unit.loc].Name; commands.Add(!string.IsNullOrEmpty(visit_name) ? visit_name : "Visit"); IndexRedirect.Add(7); } // Chest if (unit.can_open_chest(true)) { if (Global.game_map.chest_locations.ContainsKey(unit.loc)) { commands.Add("Chest"); IndexRedirect.Add(11); } } // Door if (unit.can_open_door(true)) { if (unit.door_targets().Count > 0) { commands.Add("Door"); IndexRedirect.Add(12); } } // Shop/arena if (Global.game_map.shops.ContainsKey(unit.loc)) { // Shop if (!Global.game_map.shops[unit.loc].arena) { commands.Add(Global.game_map.shops[unit.loc].face.Split('-')[0]); IndexRedirect.Add(9); } // Arena else if (unit.actor.can_arena()) { commands.Add(Global.game_map.shops[unit.loc].face.Split('-')[0]); IndexRedirect.Add(10); } } // Secret shop/arena if (Global.game_map.secret_shops.ContainsKey(unit.loc) && unit.is_member()) { // Secret Shop if (!Global.game_map.secret_shops[unit.loc].arena) { commands.Add(Global.game_map.secret_shops[unit.loc].face.Split('-')[0]); IndexRedirect.Add(29); } // Secret Arena else if (unit.actor.can_arena()) { commands.Add(Global.game_map.secret_shops[unit.loc].face.Split('-')[0]); IndexRedirect.Add(30); } } // Rescue/Take/Give/Drop if (Canto == Canto_Records.None || (!Canto.HasEnumFlag(Canto_Records.Give) && !Canto.HasEnumFlag(Canto_Records.Take))) { if (unit.is_rescuing) { if (unit.can_drop()) { commands.Add("Drop"); IndexRedirect.Add(2); } // Give bool can_give = false; foreach (int id in ally_range) { if (Global.game_map.units[id].different_team(unit)) { continue; } if (Global.game_map.units[id].is_rescuing) { continue; } if (!Global.game_map.units[id].is_rescue_blocked() && Global.game_map.units[id].can_rescue(Global.game_map.units[unit.rescuing])) { can_give = true; } } if (can_give) { commands.Add("Give"); IndexRedirect.Add(6); } } else if (ally_range.Count > 0) { // Rescue/Take bool can_rescue = false, can_take = false; foreach (int id in ally_range) { if (unit.can_rescue(Global.game_map.units[id])) { can_rescue = true; } // Prevent taking from other teams if (Global.game_map.units[id].different_team(unit)) { continue; } if (Global.game_map.units[id].is_rescuing) { if (unit.can_rescue(Global.game_map.units[Global.game_map.units[id].rescuing])) { can_take = true; } } } if (can_rescue) { commands.Add("Rescue"); IndexRedirect.Add(2); if (unit.is_rescue_blocked()) { Disabled.Add(2); } } if (can_take) { commands.Add("Take"); IndexRedirect.Add(6); if (unit.is_rescue_blocked()) { Disabled.Add(6); } } } } } // Item if (CantoAllowsItem(Canto)) { if (unit.actor.has_items) { commands.Add("Item"); IndexRedirect.Add(3); } } // Trade if (CantoAllowsTrade(Canto)) { if (unit.can_trade) { commands.Add("Trade"); IndexRedirect.Add(4); } } else if (CantoAllowsTakeDrop(Canto)) { if (unit.can_drop()) { commands.Add("Drop"); IndexRedirect.Add(2); } } if (!ContinuousMoveCanto(Canto) && !Canto.HasEnumFlag(Canto_Records.Supply)) { if (unit.can_supply()) { // Supply commands.Add("Supply"); IndexRedirect.Add(18); } } if (commands.Count == 0 && unit.cantoing) { // Wait AddWaitCommand(commands); // Status commands.Add("Status"); IndexRedirect.Add(15); } else { // Status commands.Add("Status"); IndexRedirect.Add(15); // Wait AddWaitCommand(commands); } AddSkillCommands(ref commands, unit); //@Debug: why? Input.clear_locked_repeats(); return(commands); }