public static void SetOverdriveCounter(int charIndex, int odIndex, int odCount) { var odOffset = StructHelper.GetFieldOffset <PartyMember>("OverdriveWarrior", _offsetParty + Marshal.SizeOf <PartyMember>() * charIndex + OverdriveModes[odIndex].BitIndex * 2); GameMemory.Write(odOffset, BitConverter.GetBytes((ushort)odCount), false); }
public static void MaxSphereLevels() { var partyOffset = OffsetScanner.GetOffset(GameOffset.FFX_PartyStatBase); for (var i = 0; i < 8; i++) { int characterOffset = partyOffset + 0x94 * i; LegacyMemoryReader.WriteByte(StructHelper.GetFieldOffset <PartyMember>("SphereLevelCurrent", characterOffset), 255); } }
public static void ToggleOverdriveMode(int charIndex, int overdriveId) { var odOffset = StructHelper.GetFieldOffset <PartyMember>("OverdriveModes", _offsetParty + Marshal.SizeOf <PartyMember>() * charIndex); var odBytes = GameMemory.Read <byte>(odOffset, 3, false); var odMode = OverdriveModes.First(od => od.ID == overdriveId); var bitIndex = odMode.BitIndex % 8; var byteIndex = odMode.BitIndex / 8; odBytes[byteIndex] = BitHelper.ToggleBit(odBytes[byteIndex], bitIndex); GameMemory.Write(odOffset, odBytes, false); }
public static void LearnAllAbilities() { var partyOffset = OffsetScanner.GetOffset(GameOffset.FFX_PartyStatBase); for (var i = 0; i < 18; i++) { int characterAbilityOffset = partyOffset + Marshal.SizeOf <PartyMember>() * i + StructHelper.GetFieldOffset <PartyMember>("SkillFlags");; var currentAbilities = LegacyMemoryReader.ReadBytes(characterAbilityOffset, 13); // Flip all normal ability bits currentAbilities[1] |= 0xF0; for (int b = 2; b < 11; b++) { currentAbilities[b] |= 0xFF; } currentAbilities[11] |= 0x0F; currentAbilities[12] |= 0xFF; LegacyMemoryReader.WriteBytes(characterAbilityOffset, currentAbilities); } }
public void Update() { if (!_modActive) { return; } // Read battle pointer from memory var battlePointer = GameMemory.Read <IntPtr>(_offsetEnemyPointer); // Check if we need to reset battle if (battlePointer == IntPtr.Zero && changedCreature != null) { changedThisBattle = false; changedCreature = null; } if (battlePointer != IntPtr.Zero && !changedThisBattle) { ModLogger.WriteLine("Battle detected, modifying enemies"); changedCreature = new bool[8]; // Loop until all creatures are modified or limit is hit var loopLimit = 2000; // maximum times to attempt modification before giving up while (changedCreature.Contains(false) && loopLimit > 0) { loopLimit--; for (int i = 0; i < 8; i++) { if (changedCreature[i]) { continue; // Enemy already modified } var entityData = Battle.GetEnemyEntity(i); var entityName = StringConverter.ToString(entityData.text_name); int entityOffset = (int)battlePointer + _sizeBattleEntity * i; if (entityData.guid == 0) // No enemy in this slot { continue; } ModLogger.WriteLine("Modifying creature: {0}", entityName); var newHP = entityData.hp_max * m_HpMpMultiplier; newHP = newHP > int.MaxValue ? int.MaxValue : newHP; var newMP = entityData.mp_max * m_HpMpMultiplier; newMP = newMP > int.MaxValue ? int.MaxValue : newMP; var newStrength = entityData.strength * m_StatMultiplier; newStrength = newStrength > byte.MaxValue ? byte.MaxValue : newStrength; var newDefense = entityData.defense * m_StatMultiplier; newDefense = newDefense > byte.MaxValue ? byte.MaxValue : newDefense; var newMagic = entityData.magic * m_StatMultiplier; newMagic = newMagic > byte.MaxValue ? byte.MaxValue : newMagic; var newMagicDef = entityData.magic_defense * m_StatMultiplier; newMagicDef = newMagicDef > byte.MaxValue ? byte.MaxValue : newMagicDef; var newAgility = entityData.agility * m_StatMultiplier; newAgility = newAgility > byte.MaxValue ? byte.MaxValue : newAgility; var newLuck = entityData.luck * m_StatMultiplier; newLuck = newLuck > byte.MaxValue ? byte.MaxValue : newLuck; var newAccuracy = entityData.accuracy * m_StatMultiplier; newAccuracy = newAccuracy > byte.MaxValue ? byte.MaxValue : newAccuracy; var newEvasion = entityData.evasion * m_StatMultiplier; newEvasion = newEvasion > byte.MaxValue ? byte.MaxValue : newEvasion; // update entity values GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_current"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max2"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_current"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max2"), newMP, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("strength"), (byte)newStrength, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("defense"), (byte)newDefense, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic"), (byte)newMagic, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic_defense"), (byte)newMagicDef, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("agility"), (byte)newAgility, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("luck"), (byte)newLuck, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("accuracy"), (byte)newAccuracy, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("evasion"), (byte)newEvasion, false); changedCreature[i] = true; } } changedThisBattle = true; } }