Skip to content

Commit

Permalink
tweaked nature generation and load to hopefully fix an issue affectin…
Browse files Browse the repository at this point in the history
…g users with huge modlist (see github issues)
  • Loading branch information
Gargamiel committed Jan 17, 2022
1 parent 8b43f4a commit 4eca48a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
Binary file modified Assemblies/PokeWorld.dll
Binary file not shown.
Binary file modified Source/PokeWorld/.vs/PokeWorld/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/PokeWorld/PokeWorld/CompPokemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override void CompTickRare()

public override IEnumerable<StatDrawEntry> SpecialDisplayStats()
{
if (parent.Faction != null && parent.Faction == Faction.OfPlayer)
if (parent.Faction != null && parent.Faction == Faction.OfPlayer && statTracker.nature != null)
{
NatureDef nature = statTracker.nature;
string natureLabel = nature.label;
Expand Down
4 changes: 2 additions & 2 deletions Source/PokeWorld/PokeWorld/Stats/StatWorker_PokemonStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public override void FinalizeValue(StatRequest req, ref float val, bool applyPos

public float GetNatureMultiplier(CompPokemon comp, StatDef stat)
{
try //Huge modelist sometimes cause unknown issue with nature save, see github issue
if(comp.statTracker.nature != null) //Huge modelist sometimes cause unknown issue with nature save, see github issue
{
return comp.statTracker.nature.GetMultiplier(stat);
}
catch
else
{
return 1;
}
Expand Down
9 changes: 8 additions & 1 deletion Source/PokeWorld/PokeWorld/Trackers/StatTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public StatTracker(CompPokemon comp)
{
this.comp = comp;
pokemonHolder = comp.Pokemon;
nature = DefDatabase<NatureDef>.GetRandom();
nature = DefDatabase<NatureDef>.AllDefs.RandomElement();
RandomizeIV();
SetAllEVZero();
}
Expand Down Expand Up @@ -247,6 +247,13 @@ public void ExposeData()

Scribe_Values.Look(ref healthScaleMult, "PW_healthScaleMult", 1);
Scribe_Defs.Look(ref nature, "PW_nature");
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (nature == null)
{
nature = DefDatabase<NatureDef>.AllDefs.RandomElement();
}
}
}
}
}
Binary file not shown.
Binary file modified Source/PokeWorld/PokeWorld/obj/Debug/PokeWorld.dll
Binary file not shown.

0 comments on commit 4eca48a

Please sign in to comment.