Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
greyivy committed Jan 6, 2023
1 parent bac9492 commit 224c8c1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion OrnithologistsGuild.CP/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "[CP] Ornithologist's Guild",
"Author": "Ivy",
"Version": "1.4.0",
"Version": "1.4.1",
"Description": "Bird houses, binoculars, and a new building to explore! Ornithologist's Guild brings a totally new birding experience to Stardew Valley, complete with updated bird mechanics, seasonal birds, a progression system, a new shop, an NPC with a tragic past, and much more!",
"UniqueID": "Ivy.OrnithologistsGuild.CP",
"MinimumApiVersion": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion OrnithologistsGuild.STF/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "[STF] Ornithologist's Guild",
"Author": "Ivy",
"Version": "1.4.0",
"Version": "1.4.1",
"Description": "Bird houses, binoculars, and a new building to explore! Ornithologist's Guild brings a totally new birding experience to Stardew Valley, complete with updated bird mechanics, seasonal birds, a progression system, a new shop, an NPC with a tragic past, and much more!",
"UniqueID": "Ivy.OrnithologistsGuild.STF",
"MinimumApiVersion": "3.0.0",
Expand Down
11 changes: 6 additions & 5 deletions OrnithologistsGuild/Game/Critters/BetterBirdie.StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void InitializeStateMachine()
})
.Update(a =>
{
if (Game1.random.NextDouble() < 0.008) StateMachine.Trigger(NextAction());
if (Game1.random.NextDouble() < 0.0075) StateMachine.Trigger(NextAction());
})
.State(BetterBirdieState.Hopping)
.TransitionTo(BetterBirdieState.Stopping).On(BetterBirdieTrigger.Stop)
Expand Down Expand Up @@ -226,8 +226,9 @@ private void InitializeStateMachine()
{
if (isEmoting) return;

if (Game1.random.NextDouble() < 0.002) doEmote(Character.sleepEmote);
else if (!IsRoosting && Game1.random.NextDouble() < 0.003) StateMachine.Trigger(BetterBirdieTrigger.Stop);
if (IsRoosting && Game1.random.NextDouble() < 0.00025) StateMachine.Trigger(BetterBirdieTrigger.Relocate);
else if (!IsRoosting && Game1.random.NextDouble() < 0.001) StateMachine.Trigger(BetterBirdieTrigger.Stop);
else if (Game1.random.NextDouble() < 0.0025) doEmote(Character.sleepEmote);
})
.State(BetterBirdieState.FlyingAway)
.OnEnter(e =>
Expand Down Expand Up @@ -380,8 +381,8 @@ private void InitializeStateMachine()
})
.Update(a =>
{
if (Game1.random.NextDouble() < 0.001) Flip();
if (Game1.random.NextDouble() < 0.003) StateMachine.Trigger(BetterBirdieTrigger.Relocate);
if (Game1.random.NextDouble() < 0.0025) Flip();
else if (Game1.random.NextDouble() < 0.005) StateMachine.Trigger(BetterBirdieTrigger.Relocate);
})
.GlobalTransitionTo(BetterBirdieState.FlyingAway).OnGlobal(BetterBirdieTrigger.FlyAway)
.GlobalTransitionTo(BetterBirdieState.Relocating).OnGlobal(BetterBirdieTrigger.Relocate)
Expand Down
15 changes: 8 additions & 7 deletions OrnithologistsGuild/Game/Critters/BetterBirdie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OrnithologistsGuild.Content;
using StardewModdingAPI.Utilities;
using StardewValley;
using StardewValley.TerrainFeatures;
using StateMachine;
Expand Down Expand Up @@ -159,14 +160,12 @@ public bool CheckRelocationDistance(Vector2 relocateTo)
return true;
}

public static bool CanSpawnAtOrRelocateTo(GameLocation location, Vector2 tileLocation, BirdieDef birdieDef, BetterBirdie birdie = null)
public static bool CanSpawnAtOrRelocateTo(GameLocation location, Vector2 tileLocation, BirdieDef birdieDef, BetterBirdie birdie = null, bool shouldBathe = false)
{
if (!location.isTileOnMap(tileLocation)) return false;
if (!location.isTileOnMap(tileLocation)) return false; // Tile not on map

var isOpenWater = location.isOpenWater((int)tileLocation.X, (int)tileLocation.Y);

var shouldBathe = birdieDef.CanBathe && Game1.random.NextDouble() < 0.2; // 20% chance to allow bathing
if (isOpenWater && !shouldBathe) return false;
if (isOpenWater && (!birdieDef.CanBathe || !shouldBathe)) return false; // Bird should not bathe

if (birdie != null && !birdie.CheckRelocationDistance(tileLocation)) return false; // Too close/straight

Expand All @@ -184,7 +183,7 @@ public static bool CanSpawnAtOrRelocateTo(GameLocation location, Vector2 tileLoc

public Tuple<Vector3, Perch> GetRandomRelocationTileOrPerch()
{
if (ModEntry.debug_PerchType.HasValue || Game1.random.NextDouble() < 0.4)
if (ModEntry.debug_PerchType.HasValue || Game1.random.NextDouble() < 0.25)
{
// Try to find an available perch to relocate to
var perch = Perch.GetRandomAvailablePerch(Game1.player.currentLocation, BirdieDef, this);
Expand All @@ -194,11 +193,13 @@ public Tuple<Vector3, Perch> GetRandomRelocationTileOrPerch()
}
}

var shouldBathe = Game1.random.NextDouble() < 0.25; // 25% chance to allow bathing

// Try to find clear tile to relocate to
for (int trial = 0; trial < 50; trial++)
{
var randomTile = Environment.getRandomTile();
if (!CanSpawnAtOrRelocateTo(Environment, randomTile, BirdieDef, this)) continue;
if (!CanSpawnAtOrRelocateTo(Environment, randomTile, BirdieDef, this, shouldBathe)) continue;

var relocateTo = randomTile * Game1.tileSize;

Expand Down
9 changes: 8 additions & 1 deletion OrnithologistsGuild/assets/content-pack/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
"birdie.SpottedTowhee.attribute.1": "black head",
"birdie.SpottedTowhee.attribute.2": "red eyes",
"birdie.SpottedTowhee.attribute.3": "rufous body",
"birdie.SpottedTowhee.funFact": "Spotted Towhees forage on the ground by kicking up dirt and debris, revealing food!"
"birdie.SpottedTowhee.funFact": "Spotted Towhees forage on the ground by kicking up dirt and debris, revealing food!",

"birdie.Verdin.commonName": "Verdin",
"birdie.Verdin.scientificName": "Auriparus Flaviceps",
"birdie.Verdin.attribute.1": "yellow head",
"birdie.Verdin.attribute.2": "chestnut patch",
"birdie.Verdin.attribute.3": "gray body",
"birdie.Verdin.funFact": "Verdins build unusual sphere-shaped nests, often roosting in them throughout the year!"
}
2 changes: 1 addition & 1 deletion OrnithologistsGuild/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Ornithologist's Guild",
"Author": "Ivy",
"Version": "1.4.0",
"Version": "1.4.1",
"Description": "Bird houses, binoculars, and a new building to explore! Ornithologist's Guild brings a totally new birding experience to Stardew Valley, complete with updated bird mechanics, seasonal birds, a progression system, a new shop, an NPC with a tragic past, and much more!",
"UniqueID": "Ivy.OrnithologistsGuild",
"MinimumApiVersion": "3.0.0",
Expand Down

0 comments on commit 224c8c1

Please sign in to comment.