Skip to content

Commit

Permalink
Merge pull request #1 from FiendsOfTheElements/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
blocky-games-studio committed Dec 2, 2019
2 parents 328783b + dd71bea commit 0bcbc7f
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 26 deletions.
6 changes: 5 additions & 1 deletion FF1Blazorizer/Pages/Randomize.cshtml
Expand Up @@ -83,6 +83,7 @@
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Indent IsEnabled="@Flags.Shops" Id="randomWaresCheckBox" bind-Value="@Flags.RandomWares">Random Weapons and Armor</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Indent IsEnabled="@((Flags.Shops ?? true) && (Flags.RandomWares ?? true))" Id="randomWaresIncludesCheckBox" bind-Value="@Flags.RandomWaresIncludesSpecialGear">Include Caster &amp; Elite Gear</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Id="magicShopsCheckBox" bind-Value="@Flags.MagicShops">Magic Shops</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Id="magicShopLocsCheckBox" bind-Value="@Flags.MagicShopLocs">Magic Shop Locations</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Id="magicLevelsCheckBox" bind-Value="@Flags.MagicLevels">Magic Levels</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Indent IsEnabled="@Flags.MagicLevels" Id="magicPermissionsCheckBox" bind-Value="@Flags.MagicPermissions">Keep Permissions</TriStateCheckBox>
<TriStateCheckBox UpdateToolTip="@UpdateToolTipID" Id="itemMagicCheckBox" bind-Value="@Flags.ItemMagic">Item Magic</TriStateCheckBox>
Expand Down Expand Up @@ -436,10 +437,13 @@
</div>
<div class="col-md-6">
<h4>Balance</h4>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="doubleBBCritCheckBox" bind-Value="@Flags.BBCritRate">Double BB Crit Rate</CheckBox>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="doubleWeaponCritCheckBox" bind-Value="@Flags.WeaponCritRate">Double Weapon Crit Rate</CheckBox>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="increaseWepBonusesCheckBox" bind-Value="@Flags.WeaponBonuses">Increase Weapon Elemental and Type Bonuses</CheckBox>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="thiefHitCheckBox" bind-Value="@Flags.ThiefHitRate">Double Thief &amp; Ninja Hit% growth.</CheckBox>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="housesFillHpCheckBox" bind-Value="@Flags.HousesFillHP">House Full HP Restoration</CheckBox>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="rebalanceSpellsCheckBox" bind-Value="@Flags.RebalanceSpells">LOCK and LOK2 Always Hit</CheckBox>
<EnumDropDown UpdateToolTip="@UpdateToolTipID" Id="MDefModeDropDown" TItem="MDEFGrowthMode" bind-Value="@Flags.MDefMode">MDEF Growth:</EnumDropDown>
<CheckBox UpdateToolTip="@UpdateToolTipID" Id="thiefHitCheckBox" bind-Value="@Flags.ThiefHitRate">Double Thief &amp; Ninja Hit% growth.</CheckBox>
</div>

</div>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/beginner.json
Expand Up @@ -117,6 +117,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": false,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"RebalanceSpells": true,
Expand Down
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/chaos-rush.json
Expand Up @@ -117,6 +117,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": false,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"RebalanceSpells": true,
Expand Down
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/debug.json
Expand Up @@ -117,6 +117,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": true,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"RebalanceSpells": true,
Expand Down
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/default.json
Expand Up @@ -118,6 +118,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": false,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"BlackBeltAbsorb": true,
Expand Down
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/full-npc.json
Expand Up @@ -117,6 +117,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": false,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"RebalanceSpells": true,
Expand Down
3 changes: 3 additions & 0 deletions FF1Blazorizer/wwwroot/presets/improved-vanilla.json
Expand Up @@ -117,6 +117,9 @@

"HouseMPRestoration": true,
"WeaponStats": true,
"BBCritRate": false,
"WeaponCritRate": true,
"WeaponBonuses": true,
"ChanceToRun": true,
"SpellBugs": true,
"RebalanceSpells": true,
Expand Down
23 changes: 20 additions & 3 deletions FF1Blazorizer/wwwroot/tooltips/tooltips.json
Expand Up @@ -84,7 +84,7 @@
{
"Id": "enemySkillsSpellsCheckBox",
"title": "Enemy Skills/Spells",
"screenshot": "allowUnsafePiratesCheckBox.png",
"screenshot": "enemySkillsSpellsCheckBox.png",
"description": "Enemy Skills/Spells: Shuffles enemy skills and spells so they can appear in any script. There are three groups of enemies:\nAll random encounters,\nthe first fiend fights,\nand the second fiend fights with WarMech."
},
{
Expand Down Expand Up @@ -124,6 +124,7 @@
{
"Id": "treasuresCheckBox",
"title": "Treasures",
"screenshot": "TreasureHuntCheckBox.png",
"description": "Treasures: Shuffle all treasures normally available to a random chest in the game. All items are assured to be in a chest somewhere in the game."
},
{
Expand All @@ -134,7 +135,7 @@
{
"Id": "worldWealthDropDown",
"title": "Random Wealth",
"screenshot": "worldWealthDropDow.gif",
"screenshot": "worldWealthDropDown.gif",
"description": "Random Wealth: Alters the distribution of items; Normal is the same number of each tier of item as in the vanilla item pool. High removes gold chests for more legendary and rare equipment, while more common items shows up in lower and lower tiers. Melmond has the lowest chance of top tier gear."
},
{
Expand Down Expand Up @@ -309,6 +310,7 @@
{
"Id": "spoilersCheckBox",
"title": "Generate Spoiler Log!",
"screenshot": "spoilerCheckBox.png",
"description": "Creates a spoiler log for the seed into the console window of the browser. The resulting ROM's randomization will be different than if the log had not been generated, in order to prevent cheating in races."
},
{
Expand Down Expand Up @@ -524,7 +526,22 @@
{
"Id": "weaponStatsCheckBox",
"title": "Weapon Stats",
"description": "Fixes various bugs about how weapon stats, including elemental bonuses and critical hit rate."
"description": "Fixes applying elemental and type bonuses to weapons"
},
{
"Id": "doubleBBCritCheckBox",
"title": "Double BB Crit Rate",
"description": "Doubles the BB crit rate"
},
{
"Id": "doubleWeaponCritCheckBox",
"title": "Double Weapon Crit Rates",
"description": "Doubles the crit rate of all weapons"
},
{
"Id": "increaseWepBonusesCheckBox",
"title": "Weapon Attack Bonuses",
"description": "Increases elemental and type bonuses to weapons"
},
{
"Id": "chanceToRunCheckBox",
Expand Down
21 changes: 15 additions & 6 deletions FF1Lib/BugFixes.cs
Expand Up @@ -43,25 +43,34 @@ public void FixWeaponStats()
// Move and rewrite function
Put(0x032CE1, Blob.FromHex("B18248C8B182488AA86891808868918060A9002006ADA9012006ADA9022006ADA9034C06AD8DB3682045A1A000B182A8B93CA0ACB36899A86BADB368A0009180A20220E1ACA00AA20420E1ACA021A20620E1ACA025A20720E1ACA023A20820E1ACA022A20920E1ACA020A20A20E1ACA024A20B20E1ACA901A00B9180A021B1824A4A4A4A4A186901A00C9180A900A00D9180C89180C89180A018B1823007C8C01CD0F7A900297FF02DE9002005AC85888689A002B188A00F9180A005B188A00D9180A004B188A00E9180"));

// Fix player elemental and category defense
Put(0x325B0, Blob.FromHex("A9008D6D68A00E"));
Put(0x325E8, Blob.FromHex("A9008D7668A00EA900"));
Put(0x33618, Blob.FromHex("A900"));
Put(0x33655, Blob.FromHex("A900"));
}

public void DontDoubleBBCritRates()
{
// Don't double BB crit
Put(0x32DDD, new byte[] { 0xEA });
}

public void DoubleWeaponCritRates()
{
// Increase crit rate of all weapons
var weapons = Get(WeaponOffset, WeaponSize * WeaponCount).Chunk(WeaponSize);
foreach (var weapon in weapons)
{
weapon[2] *= 2;
}
Put(WeaponOffset, weapons.SelectMany(weapon => weapon.ToBytes()).ToArray());
}

public void IncreaseWeaponBonus()
{
// Change damage bonus from +4 to +10
Put(0x326F5, Blob.FromHex("0A"));

// Fix player elemental and category defense
Put(0x325B0, Blob.FromHex("A9008D6D68A00E"));
Put(0x325E8, Blob.FromHex("A9008D7668A00EA900"));
Put(0x33618, Blob.FromHex("A900"));
Put(0x33655, Blob.FromHex("A900"));
}

public void FixChanceToRun()
Expand Down
21 changes: 17 additions & 4 deletions FF1Lib/Enemies.cs
Expand Up @@ -357,15 +357,16 @@ public void RandomEnemyStatusAttacks(MT19337 rng, bool AllowUnsafePirates)

List<(byte touch, byte element)> statusElements = new List<(byte touch, byte element)>()
{
(0x01, 0x08), //Death Touch = Death Element
(0x02, 0x02), //Stone Touch = Poison
(0x04, 0x02), //Poison Touch = Poison
(0x08, 0x01), //Dark Touch = Status
(0x10, 0x01), //Stun Touch = Status
(0x20, 0x01), //Sleep Touch = Status
(0x40, 0x01), //Mute Touch = Status
};

(byte touch, byte element) deathElement = (0x01, 0x08); //Death Touch = Death Element
(byte touch, byte element) stoneElement = (0x02, 0x02); //Stone Touch = Poison

for (int i = 0; i < EnemyCount; i++)
{
if (!AllowUnsafePirates)
Expand All @@ -375,8 +376,20 @@ public void RandomEnemyStatusAttacks(MT19337 rng, bool AllowUnsafePirates)
continue;
}
}
//Vanilla ratio is 37/128, hence the magic numbers
if (rng.Between(0, 128) < 37)

int roll = rng.Between(0, 128);
if (roll < 1) //1 vanilla death toucher
{
//Death Touch
var (touch, element) = deathElement;

}
else if (roll < 2) //1 vanilla stone toucher
{
//Stone Touch
var (touch, element) = stoneElement;
}
else if (roll < 37) //35 enemies with other assorted status touches
{
var (touch, element) = statusElements.PickRandom(rng);
enemies[i][15] = touch;
Expand Down
44 changes: 36 additions & 8 deletions FF1Lib/FF1Rom.cs
@@ -1,4 +1,4 @@
using FF1Lib.Procgen;
using FF1Lib.Procgen;
using RomUtilities;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -210,9 +210,9 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
{
KnightNinjaChargesForAllLevels();
}

if ((bool)flags.GenerateNewSpellbook)
{
{
CraftNewSpellbook(rng, (bool)flags.SpellcrafterMixSpells, flags.RebalanceSpells, (bool)flags.MagicLevels, (bool)flags.SpellcrafterRetainPermissions);
}

Expand Down Expand Up @@ -285,6 +285,11 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
}
}

if ((bool)flags.MagicShopLocs)
{
ShuffleMagicLocations(rng);
}

if (((bool)flags.MagicShops))
{
ShuffleMagicShops(rng);
Expand Down Expand Up @@ -515,6 +520,21 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
FixHouse(flags.HouseMPRestoration, flags.HousesFillHp);
}

if (!flags.BBCritRate)
{
DontDoubleBBCritRates();
}

if (flags.WeaponCritRate)
{
DoubleWeaponCritRates();
}

if (flags.WeaponBonuses)
{
IncreaseWeaponBonus();
}

if (flags.WeaponStats)
{
FixWeaponStats();
Expand Down Expand Up @@ -604,7 +624,7 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
NoDanMode();
}

SetProgressiveScaleMode(flags.ProgressiveScaleMode);
SetProgressiveScaleMode(flags);

if (flags.DisableTentSaving)
{
Expand Down Expand Up @@ -645,7 +665,7 @@ public void Randomize(Blob seed, Flags flags, Preferences preferences)
}

WriteSeedAndFlags(Version, seed.ToHex(), Flags.EncodeFlagsText(flags));
ExtraTrackingAndInitCode();
ExtraTrackingAndInitCode(flags);
}

private void EnableNPCSwatter()
Expand Down Expand Up @@ -681,7 +701,7 @@ private static string ByteArrayToString(byte[] ba)
return hex.ToString();
}

private void ExtraTrackingAndInitCode()
private void ExtraTrackingAndInitCode(Flags flags)
{
// Expanded game init code, does several things:
// - Encounter table emu/hardware fix
Expand Down Expand Up @@ -777,8 +797,16 @@ private void ExtraTrackingAndInitCode()
Put(0x388F5, Blob.FromHex("968D8E8F"));
Data[0x38DED] = 0x25;

//Key Items + Progressive Scaling
PutInBank(0x0F, 0x9000, Blob.FromHex("A200AD2160F001E8AD2260F001E8AD2560F001E8AD2A60F001E8AD2B60F001E8AD2C60F001E8AD2E60F001E8AD3060F001E8AD0060F001E8AD1260F001E8AD0460F001E8AD0860F001E8AD0C60D001E8AD2360D007AD0A622902F001E8AD2460D007AD05622902F001E8AD2660D007AD08622902F001E8AD2760D007AD09622902F001E8AD2860D007AD0B622902F001E8AD2960D007AD14622901D001E8AD2D60D007AD0E622902F001E8AD2F60D007AD13622903F001E88EB86060"));
//Key Items + Progressive Scaling
if (flags.ProgressiveScaleMode == ProgressiveScaleMode.OrbProgressiveSlow || flags.ProgressiveScaleMode == ProgressiveScaleMode.OrbProgressiveMedium || flags.ProgressiveScaleMode == ProgressiveScaleMode.OrbProgressiveFast || flags.ProgressiveScaleMode == ProgressiveScaleMode.OrbProgressiveVFast) {
if (flags.ShardHunt) {
PutInBank(0x0F, 0x9000, Blob.FromHex("AD35608DB86060"));
} else {
PutInBank(0x0F, 0x9000, Blob.FromHex("A200AD3160F001E8AD3260F001E8AD3360F001E8AD3460F001E88EB86060"));
}
} else {
PutInBank(0x0F, 0x9000, Blob.FromHex("A200AD2160F001E8AD2260F001E8AD2560F001E8AD2A60F001E8AD2B60F001E8AD2C60F001E8AD2E60F001E8AD3060F001E8AD0060F001E8AD1260F001E8AD0460F001E8AD0860F001E8AD0C60D001E8AD2360D007AD0A622902F001E8AD2460D007AD05622902F001E8AD2660D007AD08622902F001E8AD2760D007AD09622902F001E8AD2860D007AD0B622902F001E8AD2960D007AD14622901D001E8AD2D60D007AD0E622902F001E8AD2F60D007AD13622903F001E88EB86060"));
}
PutInBank(0x1F, 0xCFCB, CreateLongJumpTableEntry(0x0F, 0x9100));
//Division routine
PutInBank(0x0F, 0x90C0, Blob.FromHex("8A48A9008513A210261026112613A513C5129004E512851326102611CAD0EDA513851268AA60"));
Expand Down
12 changes: 12 additions & 0 deletions FF1Lib/Flags.cs
Expand Up @@ -29,6 +29,7 @@ public class Flags : IIncentiveFlags, IMapEditFlags, IScaleFlags, IFloorShuffleF
public bool? PreserveFiendRefights { get; set; } = false;

public bool? MagicShops { get; set; } = false;
public bool? MagicShopLocs { get; set; } = false;
public bool? MagicLevels { get; set; } = false;
public bool? MagicPermissions { get; set; } = false;
public bool? ItemMagic { get; set; } = false;
Expand Down Expand Up @@ -131,6 +132,9 @@ public class Flags : IIncentiveFlags, IMapEditFlags, IScaleFlags, IFloorShuffleF

public bool HouseMPRestoration { get; set; } = false;
public bool WeaponStats { get; set; } = false;
public bool BBCritRate { get; set; } = false;
public bool WeaponCritRate { get; set; } = false;
public bool WeaponBonuses { get; set; } = false;
public bool ChanceToRun { get; set; } = false;
public bool SpellBugs { get; set; } = false;
public bool BlackBeltAbsorb { get; set; } = false;
Expand Down Expand Up @@ -486,6 +490,7 @@ public static string EncodeFlagsText(Flags flags)
sum = AddTriState(sum, flags.ShortToFR);
sum = AddTriState(sum, flags.PreserveFiendRefights);
sum = AddTriState(sum, flags.MagicShops);
sum = AddTriState(sum, flags.MagicShopLocs);
sum = AddTriState(sum, flags.MagicLevels);
sum = AddTriState(sum, flags.MagicPermissions);
sum = AddTriState(sum, flags.ItemMagic);
Expand Down Expand Up @@ -568,6 +573,9 @@ public static string EncodeFlagsText(Flags flags)
sum = AddBoolean(sum, flags.WaitWhenUnrunnable);
sum = AddBoolean(sum, flags.HouseMPRestoration);
sum = AddBoolean(sum, flags.WeaponStats);
sum = AddBoolean(sum, flags.BBCritRate);
sum = AddBoolean(sum, flags.WeaponCritRate);
sum = AddBoolean(sum, flags.WeaponBonuses);
sum = AddBoolean(sum, flags.ChanceToRun);
sum = AddBoolean(sum, flags.SpellBugs);
sum = AddBoolean(sum, flags.BlackBeltAbsorb);
Expand Down Expand Up @@ -756,6 +764,9 @@ public static Flags DecodeFlagsText(string text)
BlackBeltAbsorb = GetBoolean(ref sum),
SpellBugs = GetBoolean(ref sum),
ChanceToRun = GetBoolean(ref sum),
WeaponBonuses = GetBoolean(ref sum),
WeaponCritRate = GetBoolean(ref sum),
BBCritRate = GetBoolean(ref sum),
WeaponStats = GetBoolean(ref sum),
HouseMPRestoration = GetBoolean(ref sum),
WaitWhenUnrunnable = GetBoolean(ref sum),
Expand Down Expand Up @@ -838,6 +849,7 @@ public static Flags DecodeFlagsText(string text)
ItemMagic = GetTriState(ref sum),
MagicPermissions = GetTriState(ref sum),
MagicLevels = GetTriState(ref sum),
MagicShopLocs = GetTriState(ref sum),
MagicShops = GetTriState(ref sum),
PreserveFiendRefights = GetTriState(ref sum),
ShortToFR = GetTriState(ref sum),
Expand Down

0 comments on commit 0bcbc7f

Please sign in to comment.