|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Text; |
5 | | -using System.Threading.Tasks; |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
6 | 6 | using RomUtilities; |
7 | | -using System.Diagnostics; |
8 | | - |
9 | | -namespace FF1Lib |
10 | | -{ |
11 | | - public partial class FF1Rom : NesRom |
12 | | - { |
13 | | - public const int GearTextOffset = 0x2B9BD; |
14 | | - public const int GearTextSize = 8; |
15 | | - private const int MagicBitOffset = 0x3; |
16 | | - private int WeaponStart = (byte)ItemLists.AllWeapons.ElementAt(0); |
| 7 | +using System.Diagnostics; |
| 8 | + |
| 9 | +namespace FF1Lib |
| 10 | +{ |
| 11 | + public partial class FF1Rom : NesRom |
| 12 | + { |
| 13 | + public const int GearTextOffset = 0x2B9BD; |
| 14 | + public const int GearTextSize = 8; |
| 15 | + private const int MagicBitOffset = 0x3; |
| 16 | + private int WeaponStart = (byte)ItemLists.AllWeapons.ElementAt(0); |
17 | 17 | private int ArmourStart = (byte)ItemLists.AllArmor.ElementAt(0); |
18 | | - |
19 | | - private List<String> SpellNames = new List<String> { // must be 7 characters long each, add spaces if needed, can rename items with each spell by changing this |
20 | | - "CURE ", "HARM ", "FOG ", "RUSE ", "FIRE ", "SLEP ", "LOCK ", "LIT ", "LAMP ", "MUTE ", "ALIT ", |
21 | | - "INVS ", "ICE ", "DARK ", "TMPR ", "SLOW ", "CUR2 ", "HRM2 ", "AFIR ", "HEAL ", "FIR2 ", "HOLD ", |
22 | | - "LIT2 ", "LOK2 ", "PURE ", "FEAR ", "AICE ", "AMUT ", "SLP2 ", "FAST ", "CONF ", "ICE2 ", "CUR3 ", |
23 | | - "LIFE ", "HRM3 ", "HEL2 ", "FIR3 ", "BANE ", "WARP ", "SLO2 ", "SOFT ", "EXIT ", "FOG2 ", "INV2 ", |
24 | | - "LIT3 ", "RUB ", "QAKE ", "STUN ", "CUR4 ", "HRM4 ", "ARUB ", "HEL3 ", "ICE3 ", "BRAK ", "SABR ", |
| 18 | + |
| 19 | + private List<String> SpellNames = new List<String> { // must be 7 characters long each, add spaces if needed, can rename items with each spell by changing this |
| 20 | + "CURE ", "HARM ", "FOG ", "RUSE ", "FIRE ", "SLEP ", "LOCK ", "LIT ", "LAMP ", "MUTE ", "ALIT ", |
| 21 | + "INVS ", "ICE ", "DARK ", "TMPR ", "SLOW ", "CUR2 ", "HRM2 ", "AFIR ", "HEAL ", "FIR2 ", "HOLD ", |
| 22 | + "LIT2 ", "LOK2 ", "PURE ", "FEAR ", "AICE ", "AMUT ", "SLP2 ", "FAST ", "CONF ", "ICE2 ", "CUR3 ", |
| 23 | + "LIFE ", "HRM3 ", "HEL2 ", "FIR3 ", "BANE ", "WARP ", "SLO2 ", "SOFT ", "EXIT ", "FOG2 ", "INV2 ", |
| 24 | + "LIT3 ", "RUB ", "QAKE ", "STUN ", "CUR4 ", "HRM4 ", "ARUB ", "HEL3 ", "ICE3 ", "BRAK ", "SABR ", |
25 | 25 | "BLND ", "LIF2 ", "FADE ", "WALL ", "XFER ", "NUKE ", "STOP ", "ZAP ", "XXXX "}; |
26 | 26 |
|
27 | 27 | // Remove all out of battle only spells |
28 | | - private readonly List<byte> SpellsToRemove = new List<byte> {38, 40, 41, 33, 56 }; // Warp, Soft, Exit, Life, Life 2 |
| 28 | + private readonly List<byte> SpellsToRemove = new List<byte> {38, 40, 41, 33, 56 }; // Warp, Soft, Exit, Life, Life 2 |
29 | 29 |
|
30 | | - private void WriteItemSpellData(MagicSpell Spell, Item item) |
| 30 | + private void WriteItemSpellData(MagicSpell Spell, Item item) |
31 | 31 | { |
32 | 32 | // Set the spell an item casts |
33 | | - var output = Spell.Data.ToHex().Remove(2); |
34 | | - var offset = WeaponOffset + 0x8 * Math.Min((byte)item - WeaponStart,ArmourStart - WeaponStart) + 0x4 * Math.Max(0, (byte)item - ArmourStart) + MagicBitOffset; |
| 33 | + var output = Spell.Data.ToHex().Remove(2); |
| 34 | + var offset = WeaponOffset + 0x8 * Math.Min((byte)item - WeaponStart,ArmourStart - WeaponStart) + 0x4 * Math.Max(0, (byte)item - ArmourStart) + MagicBitOffset; |
35 | 35 | Put(offset, Blob.FromHex(output)); |
36 | 36 |
|
37 | 37 | // if the item is the Defense, overwrite the last character in the name, otherwise, keep the icon there. |
38 | 38 | output = Spell.Name.ToHex().Remove(12) + (item == Item.Defense ? "FF" : ""); |
39 | 39 | offset = GearTextOffset + ((byte)item > (byte)Item.Ribbon ? 1 : 0) + GearTextSize * ((byte)item - WeaponStart); |
40 | | - Put(offset, Blob.FromHex(output)); |
41 | | - } |
| 40 | + Put(offset, Blob.FromHex(output)); |
| 41 | + } |
42 | 42 |
|
43 | 43 | public void CastableItemTargeting() |
44 | 44 | { |
@@ -73,28 +73,28 @@ public void CastableItemTargeting() |
73 | 73 | PutInBank(0x1F, 0xC265, CreateLongJumpTableEntry(0x0F, 0x8AD0)); |
74 | 74 | PutInBank(0x0F, 0x8AD0, Blob.FromHex("85808681C0FFD008A9D68580A9968581A91060")); |
75 | 75 | } |
76 | | - |
77 | | - public void ShuffleItemMagic(MT19337 rng) |
78 | | - { |
| 76 | + |
| 77 | + public void ShuffleItemMagic(MT19337 rng) |
| 78 | + { |
79 | 79 | CastableItemTargeting(); // make items able to target a single enemy or party member |
80 | 80 |
|
81 | | - // Reusing MagicSpell from Magic.cs |
82 | | - List<byte> SpellIndex = new List<byte>(); |
83 | | - var Spells = SpellNames.Select((text, i) => new MagicSpell // creat a list of all spells |
84 | | - { |
85 | | - Data = Blob.FromInts(new int[1] { i+1 }), // spells are 1 based |
86 | | - Index = (byte)i, |
87 | | - Name = FF1Text.TextToBytes(text), |
88 | | - }).ToList(); |
89 | | - |
| 81 | + // Reusing MagicSpell from Magic.cs |
| 82 | + List<byte> SpellIndex = new List<byte>(); |
| 83 | + var Spells = SpellNames.Select((text, i) => new MagicSpell // creat a list of all spells |
| 84 | + { |
| 85 | + Data = Blob.FromInts(new int[1] { i+1 }), // spells are 1 based |
| 86 | + Index = (byte)i, |
| 87 | + Name = FF1Text.TextToBytes(text), |
| 88 | + }).ToList(); |
| 89 | + |
90 | 90 | Spells.RemoveAll(spell => SpellsToRemove.Contains(spell.Index)); // Remove the spells specified in SpellsToRemove |
91 | 91 | Spells.Shuffle(rng); // Shuffle all spells remaining, then assign to each item that can cast a spell |
92 | 92 |
|
93 | 93 | foreach (var item in Spells.Zip(ItemLists.AllMagicItem, (s, i) => new { Spell = s, Item = i })) |
94 | 94 | { |
95 | 95 | WriteItemSpellData(item.Spell, item.Item); |
96 | | - } |
| 96 | + } |
97 | 97 |
|
98 | | - } |
99 | | - } |
100 | | -} |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments