示例#1
0
        public string[] ReadText(int pointerOffset, int pointerBase, int count)
        {
            var pointers = Get(pointerOffset, 2 * count).ToUShorts().ToList();

            var texts = new string[count];

            for (int i = 0; i < pointers.Count; i++)
            {
                texts[i] = FF1Text.BytesToText(ReadUntil(pointerBase + pointers[i], 0x00));
            }

            return(texts);
        }
示例#2
0
        public string TranslateItem(Item item)
        {
            switch (item)
            {
            case Item.Ship: return(FF1Text.BytesToText(rom.Get(0x2B5D0, 4)));

            case Item.Bridge: return(FF1Text.BytesToText(rom.Get(0x2B5D0 + 16, 6)));

            case Item.Canal: return(FF1Text.BytesToText(rom.Get(0x2B5D0 + 24, 5)));

            case Item.Canoe: return(FF1Text.BytesToText(rom.Get(0x2B5D0 + 36, 5)));

            default: return(itemnames[(int)item].Replace(" ", ""));
            }
        }
示例#3
0
        };                                                                                          // Warp, Soft, Exit, Life, Life 2

        public void ShuffleItemMagic(MT19337 rng)
        {
            CastableItemTargeting();             // make items able to target a single enemy or party member

            List <Blob> spellNames = Get(SpellNamesOffset, SpellNamesSize * SpellNamesCount).Chunk(SpellNamesSize);
            var         Spells     = spellNames.Select((blob, i) => new MagicSpell // creat a list of all spells
            {
                Data  = null,
                Index = (byte)i,
                Name  = FF1Text.TextToBytes(FF1Text.BytesToText(blob).PadRight(6), false, FF1Text.Delimiter.Empty),
            }).ToList();

            Spells.RemoveAll(spell => SpellsToRemove.Contains(spell.Index)); // Remove the spells specified in SpellsToRemove
            Spells.Shuffle(rng);                                             // Shuffle all spells remaining, then assign to each item that can cast a spell
            foreach (var item in Spells.Zip(ItemLists.AllMagicItem, (s, i) => new { Spell = s, Item = i }))
            {
                WriteItemSpellData(item.Spell, item.Item);
            }
        }
示例#4
0
        private void WriteItemSpellData(MagicSpell Spell, Item item)
        {
            // Set the spell an item casts
            var offset = WeaponOffset + 0x8 * Math.Min((byte)item - WeaponStart, ArmorStart - WeaponStart) + 0x4 * Math.Max(0, (byte)item - ArmorStart) + MagicBitOffset;

            Data[offset] = (byte)(Spell.Index + 1);

            // Setup the text of the item's name to include the spell name.
            offset = GearTextOffset + ((byte)item > (byte)Item.Ribbon ? 1 : 0) + GearTextSize * ((byte)item - WeaponStart);
            if (Get(offset, 1)[0] > 200)
            {
                offset++;                 // If the first byte is in the icon range, bump the pointer to overwrite after it.
            }
            else if (Get(offset + 6, 1)[0] <= 200)
            {
                Data[offset + 6] = 0xFF;                 // Erase final non-icon characters from name.
            }

            // Fix up the name of the spell so it works as part of an item name.
            var fixedSpellName = FF1Text.TextToBytes(FF1Text.BytesToText(Spell.Name).PadRight(6), false, FF1Text.Delimiter.Empty);

            Debug.Assert(fixedSpellName.Length == 6);
            Put(offset, fixedSpellName);
        }