private sbyte AddItem(ref byte pos, ref short skip, Saves.Item item, ItemInMenu itemdata) { if ((pos >= Rows)) //reached max rows. { return(0); } if ((item.ID == 0 || item.QTY == 0) || // skip empty values. (Battle && itemdata.Battle == null) || // if battle mode skip nonbattle items. (itemdata.ID == 0) || // skip empty values. (skip-- > 0)) //skip items that are on prev pages. { return(-1); } Enemy e = null; if ((Damageable?.GetEnemy(out e) ?? false)) { } var color = Font.ColorID.White; var palette = itemdata.Palette; if (!itemdata.ValidTarget(Battle)) { color = Font.ColorID.Grey; BLANKS[pos] = true; palette = itemdata.FadedPalette; } else { BLANKS[pos] = false; } ((IGMDataItem.Text)(ITEM[pos, 0])).Data = itemdata.Name; ((IGMDataItem.Text)(ITEM[pos, 0])).Icon = itemdata.Icon; ((IGMDataItem.Text)(ITEM[pos, 0])).Palette = palette; ((IGMDataItem.Text)(ITEM[pos, 0])).FontColor = color; ((IGMDataItem.Integer)(ITEM[pos, 1])).Data = item.QTY; if (e != null) { ITEM[pos, 1].Hide(); } else { ITEM[pos, 1].Show(); } ((IGMDataItem.Integer)(ITEM[pos, 1])).FontColor = color; _helpStr[pos] = itemdata.Description; Contents[pos] = itemdata; ITEM[pos, 0].Show(); pos++; return(1); }
public override void Refresh() { if (!Battle && !eventSet && Menu.IGMItems != null) { Menu.IGMItems.ModeChangeHandler += ModeChangeEvent; Menu.IGMItems.RefreshCompletedHandler += RefreshCompletedEvent; eventSet = true; } base.Refresh(); Source = Memory.State; if (Source != null && Source.Items != null) { ((IGMDataItem.Box)CONTAINER).Title = Pages <= 1 ? (Icons.ID?)Icons.ID.ITEM : (Icons.ID?)(Icons.ID.ITEM_PG1 + (byte)Page); byte pos = 0; var skip = checked ((short)(Page * Rows)); Enemy e = null; if (Damageable?.GetEnemy(out e) ?? false) { sbyte addEnemyItem(ItemInMenu itemdata) { var item = new Saves.Item(itemdata.ID, byte.MaxValue); return(AddItem(ref pos, ref skip, item, itemdata)); } var items = new HashSet <ItemInMenu>(); foreach (var a in e.Abilities.Where(x => x.Item != null)) { items.Add(a.Item.Value); } foreach (var a in e.DropList.Where(x => x.ID != 0 && x.Data != null)) { items.Add(a.Data.Value); } foreach (var a in e.MugList.Where(x => x.ID != 0 && x.Data != null)) { items.Add(a.Data.Value); } foreach (var i in items) { if (addEnemyItem(i) == 0) { break; } } NUM_.Hide(); DefaultPages = items.Count / Rows; } else { for (byte i = 0; pos < Rows && i < Source.Items.Count; i++) { var item = Source.Items[i]; var itemdata = item.Data ?? new ItemInMenu(); if (AddItem(ref pos, ref skip, item, itemdata) == 0) { break; } } } for (; pos < Rows; pos++) { ((IGMDataItem.Integer)(ITEM[pos, 1])).Hide(); if (pos == 0) { return; // if page turning. this till be enough to trigger a try next page. } ((IGMDataItem.Text)(ITEM[pos, 0])).Data = null; ((IGMDataItem.Integer)(ITEM[pos, 1])).Data = 0; ((IGMDataItem.Text)(ITEM[pos, 0])).Icon = Icons.ID.None; BLANKS[pos] = true; ITEM[pos, 1].Hide(); ITEM[pos, 0].Hide(); } } }
public override void Refresh() { if (!Battle && !eventSet && Menu.IGM_Items != null) { Menu.IGM_Items.ModeChangeHandler += ModeChangeEvent; Menu.IGM_Items.ReInitCompletedHandler += ReInitCompletedEvent; eventSet = true; } base.Refresh(); Source = Memory.State; if (Source != null && Source.Items != null) { ((IGMDataItem.Box)CONTAINER).Title = Pages <= 1 ? (Icons.ID?)Icons.ID.ITEM : (Icons.ID?)(Icons.ID.ITEM_PG1 + (byte)Page); byte pos = 0; int skip = Page * Rows; for (byte i = 0; pos < Rows && i < Source.Items.Count; i++) { Saves.Item item = Source.Items[i]; if (item.ID == 0 || item.QTY == 0) { continue; // skip empty values. } if (skip-- > 0) { continue; //skip items that are on prev pages. } Item_In_Menu itemdata = item.DATA ?? new Item_In_Menu(); if (Battle && itemdata.Battle == null) { continue; } if (itemdata.ID == 0) { continue; // skip empty values. } Font.ColorID color = Font.ColorID.White; byte palette = itemdata.Palette; if (!itemdata.ValidTarget(Battle)) { color = Font.ColorID.Grey; BLANKS[pos] = true; palette = itemdata.Faded_Palette; } else { BLANKS[pos] = false; } ((IGMDataItem.Text)(ITEM[pos, 0])).Data = itemdata.Name; ((IGMDataItem.Text)(ITEM[pos, 0])).Icon = itemdata.Icon; ((IGMDataItem.Text)(ITEM[pos, 0])).Palette = palette; ((IGMDataItem.Text)(ITEM[pos, 0])).FontColor = color; ((IGMDataItem.Integer)(ITEM[pos, 1])).Data = item.QTY; ((IGMDataItem.Integer)(ITEM[pos, 1])).Show(); ((IGMDataItem.Integer)(ITEM[pos, 1])).FontColor = color; _helpStr[pos] = itemdata.Description; Contents[pos] = itemdata; pos++; } for (; pos < Rows; pos++) { ((IGMDataItem.Integer)(ITEM[pos, 1])).Hide(); if (pos == 0) { return; // if page turning. this till be enough to trigger a try next page. } ((IGMDataItem.Text)(ITEM[pos, 0])).Data = null; ((IGMDataItem.Integer)(ITEM[pos, 1])).Data = 0; ((IGMDataItem.Text)(ITEM[pos, 0])).Icon = Icons.ID.None; BLANKS[pos] = true; } } }
public ItemInMenu this[Saves.Item item] => Items[item.ID];
protected override void Init() { base.Init(); if (CommandFunc == null) { CommandFunc = new Dictionary <int, Func <bool> > { //{0,Command00 }, { 1, Command01_ATTACK }, { 2, Command02_MAGIC }, //{3,Command03_GF }, { 4, Command04_ITEM }, { 5, Command05_RENZOKUKEN }, { 6, Command06_DRAW }, { 7, Command07_DEVOUR }, //{8,Command08_UNNAMED }, //{9,Command09_CAST }, //{10,Command10_STOCK }, { 11, Command11_DUEL }, { 12, Command12_MUG }, //{13,Command13_NOMSG }, { 14, Command14_SHOT }, { 15, Command15_BLUE_MAGIC }, //{16,Command16_SLOT }, { 17, Command17_FIRE_CROSS_NO_MERCY }, { 18, Command18_SORCERY_ICE_STRIKE }, { 19, Command19_COMBINE }, { 20, Command20_DESPERADO }, { 21, Command21_BLOOD_PAIN }, { 22, Command22_MASSIVE_ANCHOR }, //{23,Command23_DEFEND }, { 24, Command24_MADRUSH }, { 25, Command25_TREATMENT }, { 26, Command26_RECOVERY }, { 27, Command27_REVIVE }, { 28, Command28_DARKSIDE }, { 29, Command29_CARD }, { 30, Command30_DOOM }, { 31, Command31_KAMIKAZI }, { 32, Command32_ABSORB }, { 33, Command33_LVL_DOWN }, { 34, Command34_LVL_UP }, { 35, Command35_SINGLE }, { 36, Command36_DOUBLE }, { 37, Command37_TRIPLE }, { 38, Command38_MINIMOG }, } } ; //bool Command00() => throw new NotImplementedException(); bool Command01_ATTACK() { Neededvaribles(out Damageable[] d); if (EnemyAttack != null && Damageable.GetEnemy(out Enemy e)) { Debug.WriteLine($"{Damageable.Name} uses {EnemyAttack.Name}({EnemyAttack.MagicID}) enemy attack on { DebugMessageSuffix(d) }"); } EndTurn(); return(true); } bool Command02_MAGIC() { Neededvaribles(out Damageable[] d, Magic.PositiveMagic); Debug.WriteLine($"{Damageable.Name} casts {Magic.Name}({Magic.ID}) spell on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } //bool Command03_GF() => throw new NotImplementedException(); bool Command04_ITEM() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} uses {Item.Name}({Item.ID}) item on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command05_RENZOKUKEN() { Neededvaribles(out Damageable[] d); if (d.First().GetType() == typeof(Enemy) && Damageable.GetCharacterData(out Saves.CharacterData c)) { Saves.CharacterData squall = Memory.State[Characters.Squall_Leonhart]; //Renzokuken byte weaponid = squall.WeaponID; int hits = 0; if (c.CurrentCrisisLevel > 0) { hits = c.CurrentCrisisLevel < Renzokuken_hits.Length ? Renzokuken_hits[c.CurrentCrisisLevel] : Renzokuken_hits.Last(); } //else return false; else { hits = Renzokuken_hits.First(); } int finisherchance = (c.CurrentCrisisLevel + 1) * 60; bool willfinish = Memory.Random.Next(byte.MaxValue + 1) <= finisherchance; int choosefinish = Memory.Random.Next(3 + 1); Kernel_bin.Weapons_Data weapondata = Kernel_bin.WeaponsData[weaponid]; Kernel_bin.Renzokeken_Finisher renzokekenfinisher = weapondata.Renzokuken; if (renzokekenfinisher == 0) { willfinish = false; } //per wiki the chance of which finisher is 25% each and the highest value finisher get the remaining of 100 percent. //so rough divide is 100% when you only only have that //when you unlock 2 one is 75% chance //when you onlock 3 last one is 50% //when you unlock all 4 it's 25% each. //finishers each have their own target Menu.BattleMenus.GetCurrentBattleMenu().Renzokeken.Reset(hits); Menu.BattleMenus.GetCurrentBattleMenu().Renzokeken.Show(); if (willfinish) { List <Kernel_bin.Renzokeken_Finisher> flags = Enum.GetValues(typeof(Kernel_bin.Renzokeken_Finisher)) .Cast <Kernel_bin.Renzokeken_Finisher>() .Where(f => (f & renzokekenfinisher) != 0) .ToList(); Kernel_bin.Renzokeken_Finisher finisher = choosefinish >= flags.Count ? flags.Last() : flags[choosefinish]; Debug.WriteLine($"{Damageable.Name} hits {hits} times with {Command.Name}({Command.ID}) then uses {Kernel_bin.RenzokukenFinishersData[finisher].Name}."); } else { Debug.WriteLine($"{Damageable.Name} hits {hits} times with {Command.Name}({Command.ID}) then fails to use a finisher."); } } return(true); } bool Command06_DRAW() { Neededvaribles(out Damageable[] d); //draw //spawn a 1 page 4 row pool of the magic/gfs that the selected enemy has. if (d.First().GetType() == typeof(Enemy)) { Enemy e = (Enemy)d.First(); DrawMagic(e.DrawList); Draw_Pool.Refresh(e.DrawList); Draw_Pool.Show(); } return(true); } bool Command07_DEVOUR() { Neededvaribles(out Damageable[] d); //TODO add devour commands Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } //bool Command08_UNNAMED() => throw new NotImplementedException(); //bool Command09_CAST() => throw new NotImplementedException(); //bool Command10_STOCK() => throw new NotImplementedException(); bool Command11_DUEL() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command12_MUG() { Neededvaribles(out Damageable[] d); if (d.First().GetType() == typeof(Enemy)) { Enemy e = (Enemy)d.First(); //unsure if party member being ejected or if they need to be in the party for rare item to work Saves.Item i = e.Mug(Damageable.SPD, Memory.State.PartyHasAbility(Kernel_bin.Abilities.RareItem)); Debug.WriteLine($"{Damageable.Name} stole {i.DATA?.Name}({i.ID}) x {i.QTY} from { DebugMessageSuffix(d) }"); } EndTurn(); return(true); } //bool Command13_NOMSG() => throw new NotImplementedException(); bool Command14_SHOT() { Neededvaribles(out Damageable[] d); Menu.BattleMenus.GetCurrentBattleMenu().Shot.Refresh(Item, d); Menu.BattleMenus.GetCurrentBattleMenu().Shot.Show(); Debug.WriteLine($"{Damageable.Name} uses {Item.Name}({Item.ID}) item on { DebugMessageSuffix(d) }"); return(true); } bool Command15_BLUE_MAGIC() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} casts {BlueMagic.Name}({BlueMagic.ID}) spell on { DebugMessageSuffix(d) }"); EndTurn(); return(false); } //bool Command16_SLOT() => throw new NotImplementedException(); bool Command17_FIRE_CROSS_NO_MERCY() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command18_SORCERY_ICE_STRIKE() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command19_COMBINE() { //perform angelo attack unless angel wing is unlocked and chosen in menu. Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {CombineKernelItem.Name}({CombineKernelItem.ID}) - Combine Limit Break on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command20_DESPERADO() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command21_BLOOD_PAIN() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command22_MASSIVE_ANCHOR() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } //bool Command23_DEFEND() => throw new NotImplementedException(); bool Command24_MADRUSH() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command25_TREATMENT() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command26_RECOVERY() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command27_REVIVE() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command28_DARKSIDE() { Neededvaribles(out Damageable[] d); EndTurn(); return(true); } bool Command29_CARD() { Neededvaribles(out Damageable[] d); if (d.First().GetType() == typeof(Enemy)) { Enemy e = (Enemy)d.First(); Cards.ID c = e.Card(); if (c == Cards.ID.Fail) { Debug.WriteLine($"{Damageable.Name} Failed to use {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); } else if (c == Cards.ID.Immune) { Debug.WriteLine($"{Damageable.Name} Failed to use {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) } because they are immune!"); } else { Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) } and got a {c} card"); } EndTurn(); } return(true); } bool Command30_DOOM() { Neededvaribles(out Damageable[] d); EndTurn(); return(true); } bool Command31_KAMIKAZI() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command32_ABSORB() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command33_LVL_DOWN() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command34_LVL_UP() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } bool Command35_SINGLE() => Command02_MAGIC(); bool Command36_DOUBLE() { // CHOOSE 2X TARGETS throw new NotImplementedException(); } bool Command37_TRIPLE() { // CHOOSE 3X TARGETS throw new NotImplementedException(); } bool Command38_MINIMOG() { Neededvaribles(out Damageable[] d); Debug.WriteLine($"{Damageable.Name} used {Command.Name}({Command.ID}) on { DebugMessageSuffix(d) }"); EndTurn(); return(true); } }