public UnitMoveProps(Unit u) { is_trans_available_on_ground = u.IsTransAvailable("陸") && u.get_Adaption(2) != 0; is_trans_available_in_water = u.IsTransAvailable("水") && u.get_Adaption(3) != 0; is_trans_available_in_sky = u.IsTransAvailable("空") && u.get_Adaption(1) != 0; is_trans_available_in_moon_sky = is_trans_available_in_sky || u.IsTransAvailable("宇宙") && u.get_Adaption(4) != 0; is_adaptable_in_water = Strings.Mid(u.Data.Adaption, 3, 1) != "-" || u.IsFeatureAvailable("水中移動"); is_adaptable_in_space = Strings.Mid(u.Data.Adaption, 4, 1) != "-" || u.IsFeatureAvailable("宇宙移動"); is_trans_available_on_water = u.IsFeatureAvailable("水上移動") || u.IsFeatureAvailable("ホバー移動"); adopted_terrain = GeneralLib.ToL(u.FeatureData("地形適応")).Skip(1).ToList(); allowed_terrains = new List <string>(); if (u.IsFeatureAvailable("移動制限")) { if (u.Area != "空中" && u.Area != "地中") { allowed_terrains = u.Feature("移動制限").DataL.Skip(1).ToList(); } } prohibited_terrains = new List <string>(); if (u.IsFeatureAvailable("進入不可")) { if (u.Area != "空中" && u.Area != "地中") { prohibited_terrains = u.Feature("進入不可").DataL.Skip(1).ToList(); } } is_swimable = u.IsFeatureAvailable("水泳"); is_able_to_penetrate = u.IsFeatureAvailable("透過移動") || u.IsUnderSpecialPowerEffect("透過移動"); }
public CombineFeature(FeatureData fd) { FeatureData = fd; var opts = GeneralLib.ToL(fd.StrData); CombineName = opts.First(); var unitnames = opts.Skip(1).ToList(); ConbineUnitName = unitnames.First(); PartUnitNames = unitnames.Skip(1).ToList(); }
// ユニット u に乗ることができるかどうか public bool IsAbleToRide(Unit u) { // 汎用ユニットは必要技能を満たせばOK if (u.Class == "汎用") { goto CheckNecessarySkill; } // 人間ユニット指定を除いて判定 string uclass; if (Strings.Left(u.Class, 1) == "(" && Strings.Right(u.Class, 1) == ")") { uclass = Strings.Mid(u.Class, 2, Strings.Len(u.Class) - 2); } else { uclass = u.Class; } // サポートかどうかをまず判定しておく if (IsSupport(u)) { // 必要技能をチェックする goto CheckNecessarySkill; } // ユニットクラスは複数設定可能 foreach (var pclass in GeneralLib.ToL(Class)) { if (uclass == pclass || uclass == (pclass + "(" + get_Nickname(false) + "専用)") || uclass == (pclass + "(" + Name + "専用)") || uclass == (pclass + "(" + Sex + "専用)")) { // 必要技能をチェックする goto CheckNecessarySkill; } } // クラスが合わない return(false); CheckNecessarySkill: ; // 必要技能&不必要技能をチェック // 両能力を持っていない場合はチェック不要 if (!u.IsFeatureAvailable("必要技能") && !u.IsFeatureAvailable("不必要技能")) { return(true); } foreach (var fd in u.Features.Where(fd => fd.Name == "必要技能")) { if (!u.IsNecessarySkillSatisfied(fd.Data, this)) { return(false); } } foreach (var fd in u.Features.Where(fd => fd.Name == "不必要技能")) { if (u.IsNecessarySkillSatisfied(fd.Data, this)) { return(false); } } return(true); }
// パイロットがユニット u のサポートかどうか public bool IsSupport(Unit u) { if (u.IsFeatureAvailable("ダミーユニット")) { // ダミーユニットの場合はサポートパイロットも通常のパイロットとして扱う return(false); } // サポート指定が存在する? if (GeneralLib.InStrNotNest(Class, "サポート)") == 0) { return(false); } if (u.CountPilot() == 0) { // パイロットが乗っていないユニットの場合は通常パイロットを優先 foreach (var pclass in GeneralLib.ToL(Class)) { var uclass = u.Class; if (uclass == pclass || uclass == (pclass + "(" + get_Nickname(false) + "専用)") || uclass == (pclass + "(" + Name + "専用)") || uclass == (pclass + "(" + Sex + "専用)")) { // 通常のパイロットとして搭乗可能であればサポートでないとみなす return(false); } } } else { // 通常のパイロットとして搭乗している? if (u.Pilots.Contains(this)) { return(false); } } { var uclass = u.Class0; // 通常のサポート? foreach (var pclass in GeneralLib.ToL(Class)) { if ((uclass + "(サポート)" ?? "") == pclass) { return(true); } } // パイロットが乗っていないユニットの場合はここで終了 if (u.CountPilot() == 0) { return(false); } // 専属サポート? var p = u.MainPilot(); foreach (var pclass in GeneralLib.ToL(Class)) { if (pclass == (uclass + "(" + p.Name + "専属サポート)") || pclass == (uclass + "(" + p.get_Nickname(false) + "専属サポート)") || pclass == (uclass + "(" + p.Sex + "専属サポート)")) { return(true); } foreach (var sname in p.Skills.Select(skill => skill.Name)) { if (pclass == (uclass + "(" + sname + "専属サポート)" ?? "")) { return(true); } } } } return(false); }
protected override int ExecInternal() { // short unum; // short ux, uy; // var uclass = default(string); // string buf, opt = default; // short j, i, num; // int tmp; // int min_value; // short max_item; // int max_value; // int[] lv_list; // string[] list; // short ret; // bool without_refresh; // bool without_animation; var opt = ""; var num = ArgNum; for (var i = 5; i <= num; i++) { switch (GetArgAsString(i) ?? "") { case "密集": opt = opt + " 出撃"; break; case "非同期": opt = opt + " 非同期"; break; case "アニメ非表示": opt = opt + " アニメ非表示"; break; } } if (Strings.InStr(opt, "出撃") <= 0) { opt = opt + " 部隊配置"; } if (num < 4) { throw new EventErrorException(this, "Organizeコマンドの引数の数が違います"); } var unum = GetArgAsLong(2); if (unum < 1) { throw new EventErrorException(this, "ユニット数が不正です"); } var ux = GetArgAsLong(3); if (ux < 1) { ux = 1; } else if (ux > Map.MapWidth) { ux = Map.MapWidth; } var uy = GetArgAsLong(4); if (uy < 1) { uy = 1; } else if (uy > Map.MapHeight) { uy = Map.MapHeight; } var uclass = ""; if (num < 5) { uclass = "全て"; } else { var loopTo1 = num; for (var i = 5; i <= num; i++) { uclass = uclass + " " + GetArgAsString(i); } uclass = Strings.Trim(uclass); } Beginning: ; var units = SRC.UList.Items .Where(u => !(u.Party0 != "味方" || u.Status != "待機" || u.CountPilot() == 0)) // パイロット数のチェック .Where(u => !((u.Data.PilotNum == 1 || Math.Abs(u.Data.PilotNum) == 2) && u.CountPilot() < Math.Abs(u.Data.PilotNum) && !u.IsFeatureAvailable("1人乗り可能"))) .Where(u => { var td = Map.Terrain(1, 1); switch (td.Class) { case "宇宙": case "月面": if (u.get_Adaption(4) == 0) { return(false); } break; default: // 宇宙専用ユニットは宇宙でしか活動できない if (u.Transportation == "宇宙") { return(false); } // 空中マップか? if (td.Name == "空" && Map.Terrain((Map.MapWidth / 2), (Map.MapHeight / 2)).Name == "空" && Map.Terrain(Map.MapWidth, Map.MapHeight).Name == "空") { if (!u.IsTransAvailable("空")) { return(false); } } break; } return(true); }) .Where(u => { switch (uclass) { case "全て": case "": break; // 全てのユニット case "通常ユニット": if (u.IsFeatureAvailable("母艦")) { return(false); } break; case "母艦ユニット": if (!u.IsFeatureAvailable("母艦")) { return(false); } break; case "LL": if (u.Size == "XL") { return(false); } break; case "L": if (u.Size == "XL" || u.Size == "LL") { return(false); } break; case "M": if (u.Size == "XL" || u.Size == "LL" || u.Size == "L") { return(false); } break; case "S": if (u.Size == "XL" || u.Size == "LL" || u.Size == "L" || u.Size == "M") { return(false); } break; case "SS": if (u.Size == "XL" || u.Size == "LL" || u.Size == "L" || u.Size == "M" || u.Size == "S") { return(false); } break; default: // ユニットクラス指定した場合 // 指定されたクラスに該当するか return(GeneralLib.ToL(uclass).Any(x => x == u.Class0)); } return(true); }) .ToList(); if (!units.Any()) { return(EventData.NextID); } // レベルの一覧と最大値・最小値を求める var min_value = units.Min(u => u.MainPilot().Level + u.MainPilot().Exp); var max_value = units.Max(u => u.MainPilot().Level + u.MainPilot().Exp); // レベルにばらつきがある時にのみレベルでソート if (min_value != max_value) { units = units.OrderByDescending(u => u.MainPilot().Level + u.MainPilot().Exp).ToList(); } var list = units .Select(u => { var msg = ""; if (Expression.IsOptionDefined("等身大基準")) { msg = u.Nickname0 + Strings.Space(GeneralLib.MaxLng(52 - Strings.LenB(u.Nickname0), 1)) + GeneralLib.LeftPaddedString("" + u.MainPilot().Level, 2); } else { msg = u.Nickname0 + Strings.Space(GeneralLib.MaxLng(36 - Strings.LenB(u.Nickname0), 1)) + u.MainPilot().get_Nickname(false) + Strings.Space(GeneralLib.MaxLng(17 - Strings.LenB(u.MainPilot().get_Nickname(false)), 1)) + GeneralLib.LeftPaddedString("" + u.MainPilot().Level, 2); } return(new ListBoxItem(msg, u.ID)); }).ToList(); int ret; do { string info; if (Expression.IsOptionDefined("等身大基準")) { info = "ユニット Lv"; } else { info = "ユニット パイロット Lv"; } ret = GUI.MultiSelectListBox(new ListBoxArgs { lb_caption = "出撃ユニット選択", lb_info = info, Items = list, }, unum); if (ret == 0) { Commands.CommandState = "ユニット選択"; GUI.UnlockGUI(); Commands.ViewMode = true; while (Commands.ViewMode) { GUI.Sleep(50); } GUI.LockGUI(); goto Beginning; } }while (ret == 0); if (Strings.InStr(opt, "非同期") > 0) { GUI.Center(ux, uy); GUI.RefreshScreen(); } foreach (var u in list.Where(x => x.ListItemFlag) .Select(x => SRC.UList.Item(x.ListItemID))) { u.UsedAction = 0; u.UsedSupportAttack = 0; u.UsedSupportGuard = 0; u.UsedSyncAttack = 0; u.UsedCounterAttack = 0; u.StandBy(ux, uy, opt); } SRC.UList.CheckAutoHyperMode(); return(EventData.NextID); }
protected override int ExecInternal() { if (ArgNum != 4 && ArgNum != 5) { throw new EventErrorException(this, "SetSkillコマンドの引数の数が違います"); } var pname = GetArgAsString(2); if (SRC.PList.IsDefined(pname)) { pname = SRC.PList.Item(pname).ID; } else if (SRC.PDList.IsDefined(pname)) { pname = SRC.PDList.Item(pname).Name; } else { throw new EventErrorException(this, "「" + pname + "」というパイロットが見つかりません"); } var sname = GetArgAsString(3); var slevel = GetArgAsDouble(4); var sdata = ""; if (ArgNum == 5) { sdata = GetArgAsString(5); } // エリアスが定義されている? var sList = new List <SkillData>(); if (SRC.ALDList.IsDefined(sname)) { { var alias = SRC.ALDList.Item(sname); foreach (var elm in alias.Elements) { var sd = new SkillData(); sList.Add(sd); if (GeneralLib.LIndex(elm.strAliasData, 1) == "解説") { if (string.IsNullOrEmpty(sdata)) { sd.Name = elm.strAliasType; } else { sd.Name = GeneralLib.LIndex(sdata, 1); } if (slevel == 0d) { sd.Level = 0d; } else { sd.Level = Constants.DEFAULT_LEVEL; } sd.StrData = elm.strAliasData; } else { sd.Name = elm.strAliasType; if (slevel == -1) { sd.Level = elm.dblAliasLevel; } else if (elm.blnAliasLevelIsPlusMod) { sd.Level = slevel + elm.dblAliasLevel; } else if (elm.blnAliasLevelIsMultMod) { sd.Level = slevel * elm.dblAliasLevel; } else { sd.Level = slevel; } if (string.IsNullOrEmpty(sdata)) { sd.StrData = elm.strAliasData; } else { sd.StrData = Strings.Trim(sdata + " " + GeneralLib.ListTail(elm.strAliasData, 2)); } if (elm.blnAliasLevelIsPlusMod || elm.blnAliasLevelIsPlusMod) { sd.StrData = Strings.Trim(GeneralLib.LIndex(sd.StrData, 1) + "Lv" + SrcFormatter.Format(slevel) + " " + GeneralLib.ListTail(sd.StrData, 2)); } } } } } else { sList.Add(new SkillData { Name = sname, Level = slevel, StrData = sdata, }); } foreach (var sd in sList) { sname = sd.Name; slevel = sd.Level; sdata = sd.StrData; if (string.IsNullOrEmpty(sname)) { continue; } string slist; // アビリティ一覧表示用にSetSkillが適用された能力の一覧用変数を作成 if (!Expression.IsGlobalVariableDefined("Ability(" + pname + ")")) { Expression.DefineGlobalVariable("Ability(" + pname + ")"); slist = sname; } else { slist = Conversions.ToString(Event.GlobalVariableList["Ability(" + pname + ")"].StringValue); if (!GeneralLib.ToL(slist).Contains(sname)) { slist = slist + " " + sname; } } Expression.SetVariableAsString("Ability(" + pname + ")", slist); // 今回SetSkillが適用された能力sname用変数を作成 var vname = "Ability(" + pname + "," + sname + ")"; if (!Expression.IsGlobalVariableDefined(vname)) { Expression.DefineGlobalVariable(vname); } if (!string.IsNullOrEmpty(sdata)) { // 別名指定があった場合 Expression.SetVariableAsString(vname, SrcFormatter.Format(slevel) + " " + sdata); // 必要技能用 if (sdata != "非表示" && GeneralLib.LIndex(sdata, 1) != "解説") { vname = "Ability(" + pname + "," + GeneralLib.LIndex(sdata, 1) + ")"; if (!Expression.IsGlobalVariableDefined(vname)) { Expression.DefineGlobalVariable(vname); } Expression.SetVariableAsString(vname, SrcFormatter.Format(slevel)); } } else { Expression.SetVariableAsString(vname, SrcFormatter.Format(slevel)); } } // パイロットやユニットのステータスをアップデート if (SRC.PList.IsDefined(pname)) { { var withBlock1 = SRC.PList.Item(pname); withBlock1.Update(); if (withBlock1.Unit is object) { withBlock1.Unit.Update(); if (withBlock1.Unit.Status == "出撃") { SRC.PList.UpdateSupportMod(withBlock1.Unit); } } } } return(EventData.NextID); }
// 「変形」コマンド private void TransformCommand() { // MOD START MARGE //// If MainWidth <> 15 Then //if (GUI.NewGUIMode) //{ // // MOD END MARGE // Status.ClearUnitStatus(); //} GUI.LockGUI(); var fdata = SelectedUnit.FeatureData("変形"); if (Map.IsStatusView) { // ユニットステータスコマンドの場合 var forms = GeneralLib.ToL(fdata).Skip(1) .Select(x => SelectedUnit.OtherForm(x)) .Where(x => x.IsAvailable()) .Select(x => new ListBoxItem { ListItemID = x.Name, Text = x.Nickname0, }).ToList(); var ret = 1; if (forms.Count > 1) { GUI.TopItem = 1; ret = GUI.ListBox(new ListBoxArgs { lb_caption = SelectedUnit.IsHero() ? "変身先" : "変形先", lb_info = "名前", lb_mode = "カーソル移動", Items = forms, }); if (ret == 0) { CancelCommand(); GUI.UnlockGUI(); return; } } var uname = forms[ret - 1].ListItemID; var targetUnit = SRC.UDList.Item(uname); // 変形を実施 var u = SelectedUnit; u.Transform(uname); // ユニットリストの表示を更新 Event.MakeUnitList(smode: ""); // ステータスウィンドウの表示を更新 Status.DisplayUnitStatus(u.CurrentForm()); // コマンドを終了 // XXX RedrawScreen 元はしてなかった気がする GUI.RedrawScreen(); GUI.UnlockGUI(); CommandState = "ユニット選択"; return; } { // 変形可能な形態の一覧を作成 var forms = GeneralLib.ToL(fdata).Skip(1) .Select(x => SelectedUnit.OtherForm(x)) .Where(x => x.IsAvailable()) .Select(x => new ListBoxItem { ListItemID = x.Name, Text = x.Nickname0, ListItemFlag = !(x.IsAbleToEnter(SelectedUnit.x, SelectedUnit.y) || Map.IsStatusView) }).ToList(); // 変形先の形態を選択 int ret; if (forms.Count() == 1) { if (forms.First().ListItemFlag) { GUI.Confirm("この地形では" + GeneralLib.LIndex(fdata, 1) + "できません", "", GuiConfirmOption.Ok); CancelCommand(); GUI.UnlockGUI(); return; } ret = 1; } else { GUI.TopItem = 1; ret = GUI.ListBox(new ListBoxArgs { lb_caption = SelectedUnit.IsHero() ? "変身先" : "変形先", lb_info = "名前", lb_mode = "カーソル移動", HasFlag = true, Items = forms, }); if (ret == 0) { CancelCommand(); GUI.UnlockGUI(); return; } } var uname = forms[ret - 1].ListItemID; var targetUnit = SRC.UDList.Item(uname); string BGM; { var u = SelectedUnit; // ダイアログでメッセージを表示させるため追加パイロットをあらかじめ作成 AddAdditionalPilotIfNotExist(uname, u); // BGMの変更 if (u.IsFeatureAvailable("変形BGM")) { foreach (var fd in u.Features.Where(x => x.Name == "変形BGM") .Where(x => GeneralLib.LIndex(x.Data, 1) == uname)) { BGM = Sound.SearchMidiFile(Strings.Mid(fd.Data, Strings.InStr(fd.Data, " ") + 1)); if (Strings.Len(BGM) > 0) { Sound.ChangeBGM(BGM); GUI.Sleep(500); } break; } } // メッセージを表示 SelectedUnit.PilotMassageIfDefined(new string[] { "変形(" + u.Name + "=>" + uname + ")", "変形(" + uname + ")", "変形(" + u.FeatureName("変形") + ")", }); // アニメ表示 SelectedUnit.PlayAnimationIfDefined(new string[] { "変形(" + u.Name + "=>" + uname + ")", "変形(" + uname + ")", "変形(" + u.FeatureName("変形") + ")", }); } // 変形 var prev_uname = SelectedUnit.Name; SelectedUnit.Transform(uname); SelectedUnit = Map.MapDataForUnit[SelectedUnit.x, SelectedUnit.y]; // 変形をキャンセルする? if (SelectedUnit.Action == 0) { var confirmRet = GUI.Confirm( "この形態ではこれ以上の行動が出来ません。" + Constants.vbCr + Constants.vbLf + "それでも変形しますか?", "変形", GuiConfirmOption.OkCancel | GuiConfirmOption.Question); if (confirmRet == GuiDialogResult.Cancel) { SelectedUnit.Transform(prev_uname); SelectedUnit = Map.MapDataForUnit[SelectedUnit.x, SelectedUnit.y]; if (SelectedUnit.IsConditionSatisfied("消耗")) { SelectedUnit.DeleteCondition("消耗"); } } GUI.RedrawScreen(); } // 変形イベント { Event.HandleEvent("変形", SelectedUnit.CurrentForm().MainPilot().ID, SelectedUnit.CurrentForm().Name); } if (SRC.IsScenarioFinished) { SRC.IsScenarioFinished = false; Status.ClearUnitStatus(); GUI.RedrawScreen(); CommandState = "ユニット選択"; GUI.UnlockGUI(); return; } SRC.IsCanceled = false; // ハイパーモード・ノーマルモードの自動発動をチェック SelectedUnit.CurrentForm().CheckAutoHyperMode(); SelectedUnit.CurrentForm().CheckAutoNormalMode(); // カーソル自動移動 if (SelectedUnit.Status == "出撃") { if (SRC.AutoMoveCursor) { GUI.MoveCursorPos("ユニット選択", SelectedUnit); } Status.DisplayUnitStatus(SelectedUnit); } // XXX RedrawScreen 元はしてなかった気がする GUI.RedrawScreen(); CommandState = "ユニット選択"; GUI.UnlockGUI(); } }