Skip to content

Commit

Permalink
* Downgrade to Unity 2023.2.20f1 as Unity 6 would cause too many cras…
Browse files Browse the repository at this point in the history
…hes.

* Add in additional logging and continuesly delete the player.log and instead use the new Ravenfall.log
  • Loading branch information
zerratar committed Aug 28, 2024
1 parent 584acad commit a33dd33
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 2,565 deletions.
14 changes: 14 additions & 0 deletions Assets/Scripts/Dungeon/DungeonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private void HideDungeonUI()
{
Notifications.HideInformation();
}

private void UpdateDungeonUI()
{
if (this.Dungeon && Started)
Expand All @@ -372,6 +373,7 @@ public async Task<bool> ActivateDungeon(PlayerController initiator = null, Actio
{
if (gameManager.Events.TryStart(this))
{

HasBeenAnnounced = false;

await Notifications.OnDungeonActivated();
Expand All @@ -380,6 +382,7 @@ public async Task<bool> ActivateDungeon(PlayerController initiator = null, Actio

if (SpawnDungeonBoss())
{
Shinobytes.Debug.Log($"Dungeon #{(dungeonIndex + 1)} has been activated: " + Dungeon.Name);
Initiator = initiator;
state = DungeonManagerState.Active;
dungeonStartTimer = timeForDungeonStart;
Expand Down Expand Up @@ -521,6 +524,7 @@ public void PlayerDied(PlayerController player)

public void EndDungeonSuccess()
{
Shinobytes.Debug.Log("Dungeon ended in a success.");
var players = GetPlayers();
foreach (var player in players)
{
Expand All @@ -541,6 +545,15 @@ public void EndDungeonSuccess()

public void EndDungeonFailed(bool notifyChat = true)
{
if (notifyChat)
{
Shinobytes.Debug.Log("The dungeon has ended without any surviving players.");
}
else
{
Shinobytes.Debug.Log("The dungeon was stopped by a user.");
}

var players = GetPlayers();
foreach (var player in players)
{
Expand Down Expand Up @@ -875,6 +888,7 @@ private void UpdateTimer(ref float timer, Action action)

private void StartDungeon()
{
Shinobytes.Debug.Log("Starting dungeon: " + currentDungeon.Name);
SpawnEnemies();

Notifications.Hide();
Expand Down
16 changes: 9 additions & 7 deletions Assets/Scripts/Game/Controllers/DungeonRoomController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DungeonRoomController : MonoBehaviour
private int stuckCheckAliveCount;
private int stuckCheckAlivePlayerCount;
private long stuckCheckEnemyHealth;
private long stuckCheckPlayerHealth;

public DungeonBossController Boss { get; set; }
public bool InProgress => state == DungeonRoomState.InProgress;
Expand Down Expand Up @@ -129,33 +130,34 @@ private void Update()
}

var alivePlayerCount = dungeon.DungeonManager.GetAlivePlayerCount();
var ignore = false;
var healCount = 0;
var totalPlayerHealth = 0L;
// if the alive player count is the same, check if those players are training healing or not
if (alivePlayerCount == stuckCheckAlivePlayerCount)
{
var healCount = 0;
foreach (var plr in dungeon.DungeonManager.GetAlivePlayers())
{
if (plr.TrainingHealing)
{
healCount++;
}
}

ignore = healCount == alivePlayerCount;
totalPlayerHealth += plr.Stats.Health.CurrentValue;
}
}

if (ignore || (stuckCheckAliveCount != aliveEnemyCount || stuckCheckEnemyHealth != totalEnemyHealth) || stuckCheckAlivePlayerCount != alivePlayerCount)
if (totalPlayerHealth != stuckCheckPlayerHealth || healCount == alivePlayerCount || stuckCheckAliveCount != aliveEnemyCount || stuckCheckEnemyHealth != totalEnemyHealth || stuckCheckAlivePlayerCount != alivePlayerCount)
{
stuckCheckTime = GameTime.time;
stuckCheckAliveCount = aliveEnemyCount;
stuckCheckAlivePlayerCount = alivePlayerCount;
stuckCheckEnemyHealth = totalEnemyHealth;
stuckCheckPlayerHealth = totalPlayerHealth;
}
else if (GameTime.time - stuckCheckTime > 30f)
else if (GameTime.time - stuckCheckTime > 10f)
{
// forcibly kill all enemies.
Shinobytes.Debug.LogWarning("Dungeon room " + name + " is stuck. Forcibly killing all enemies to proceed to the next room.");
Shinobytes.Debug.LogWarning("[" + dungeon.Name + "] Dungeon room " + name + " is stuck. Forcibly killing all enemies to proceed to the next room.");

var players = dungeon.DungeonManager.GetPlayers();
foreach (var enemy in Enemies)
Expand Down
65 changes: 30 additions & 35 deletions Assets/Scripts/Game/Player/BotPlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,30 @@ public void Poll()
return;
}

var player = playerController;
// if we are stuck, try and resolve the issue
if (playerController.IsStuck)
if (player.IsStuck)
{
Shinobytes.Debug.LogWarning(playerController.Name + " is stuck. Trying to unstuck.");
// make sure we only call this once every 5 seconds.
if (playerController.Unstuck(true, 5f))
if (player.Unstuck(true, 5f))
{
playerController.Movement.AdjustPlayerPositionToNavmesh();
playerController.IsStuck = false;
Shinobytes.Debug.LogWarning("Unstuck attempt for " + player.Name + ".");
player.Movement.AdjustPlayerPositionToNavmesh();
player.IsStuck = false;
}

return;
}

if (gameManager.Raid.Started && gameManager.Raid.CanJoin(playerController) == RaidJoinResult.CanJoin)
if (gameManager.Raid.Started && gameManager.Raid.CanJoin(player) == RaidJoinResult.CanJoin)
{
joiningEvent = true;
StartCoroutine(JoinRaid());
}

if (gameManager.Dungeons.Active)
{
var result = gameManager.Dungeons.CanJoin(playerController);
var result = gameManager.Dungeons.CanJoin(player);
if (result == DungeonJoinResult.CanJoin)
{
joiningEvent = true;
Expand All @@ -75,83 +76,77 @@ public void Poll()
// first off here we want to check if our currently trained skill can be trained properly.
// if not, we have to log it and report so that I can fix it.
// since we are not in a raid nor a dungeon, unless we are on the ferry we must be on an island.
if (playerController.ferryHandler.OnFerry)
if (player.ferryHandler.OnFerry)
{
return;
}

if (!playerController.Island)
if (!player.Island)
{
Shinobytes.Debug.LogWarning(playerController.Name + " is not on an island! Please check scene view to see where this poor guy is.");
playerController.IsStuck = true;
Shinobytes.Debug.LogWarning(player.Name + " is not on an island! Please check scene view to see where this poor guy is.");
player.IsStuck = true;
// record position, target, island, any details here, record the amount of bots effected, include current task and target
return;
}

var now = Time.time;
if (now - LastTeleport < 3)
if (now - LastTeleport < 5)
{
// dont report if we just got teleported here since current paths does not get flushed out upon teleport.
return;
}

// TODO: if we have a task, and we are on an island that will let us gain exp
// check if we gained any exp the past 30s, if not then report!

if (playerController.ActiveSkill != RavenNest.Models.Skill.None)
{
// ...
}

var movement = playerController.Movement;
var movement = player.Movement;
if (movement.HasIncompletePath)
{
// if the path is partial, can we check if last point is close enough to do the task or not.
var distanceToTarget = 9999f;
if (movement.PathStatus == UnityEngine.AI.NavMeshPathStatus.PathPartial && playerController.Target && movement.CurrentPath != null)
if (movement.PathStatus == UnityEngine.AI.NavMeshPathStatus.PathPartial && player.Target && movement.CurrentPath != null)
{
var targetPos = playerController.Target.position;
var targetPos = player.Target.position;
var lastCorner = movement.CurrentPath.corners[^1];

distanceToTarget = Vector3.Distance(lastCorner, targetPos);
}

if (distanceToTarget > 2) // distance to target needs to be based on actual target.
{
Shinobytes.Debug.LogWarning(playerController.Name + ", island: " + playerController.Island.Identifier + ", has incomplete path: " + movement.PathStatus + ", current task: " + playerController.ActiveSkill);// + ", distance: " + distanceToTarget);
playerController.IsStuck = true;
Shinobytes.Debug.LogWarning(player.Name + ", island: " + player.Island.Identifier +
", has incomplete path: " + movement.PathStatus + ", current task: " + player.ActiveSkill);// + ", distance: " + distanceToTarget);
player.IsStuck = true;
// record position, target, island, any details here, only one record per target is necessary.
return;
}
}

// alright, we are on an island, lets check if we are stuck or not.
// of course, if we are resting this should be ignored.
if (playerController.TimeSinceLastTaskChange > 1f // if we recently changed task, this will spam, so make sure its been more than a second since we changed task.
&& playerController.ferryHandler.State != PlayerFerryState.Embarking
&& !playerController.onsenHandler.InOnsen
&& (movement.IdleTime >= ExpectedMaxIdleTime(playerController.ActiveSkill) || (movement.IdleTime >= 15 && (GameTime.time - playerController.LastExecutedTaskTime) >= 15))
&& playerController.Target)
if (player.TimeSinceLastTaskChange > 1f // if we recently changed task, this will spam, so make sure its been more than a second since we changed task.
&& player.ferryHandler.State != PlayerFerryState.Embarking
&& !player.onsenHandler.InOnsen
&& (movement.IdleTime >= ExpectedMaxIdleTime(player.ActiveSkill) || (movement.IdleTime >= 30 && (GameTime.time - player.LastExecutedTaskTime) >= 30))
&& player.Target)
{

// if we are training Ranged or Magic, we could potentially be standing for a long time
// so we also have to check "last activation" time of either magic or ranged skill
var ignored = false;
if (playerController.ActiveSkill == RavenNest.Models.Skill.Magic || playerController.ActiveSkill == RavenNest.Models.Skill.Ranged)
if (player.ActiveSkill == RavenNest.Models.Skill.Magic || player.ActiveSkill == RavenNest.Models.Skill.Ranged)
{
ignored = now - playerController.Animations.LastTrigger < 3;
ignored = now - player.Animations.LastTrigger < 10;
}

if (!ignored)
{
Shinobytes.Debug.LogWarning(playerController.Name + ", island: " + playerController.Island.Identifier + ", has been idling for much longer than expected for current task: " + playerController.ActiveSkill); //+ ", idleTime: " + movement.IdleTime);
playerController.IsStuck = true;
Shinobytes.Debug.LogWarning(player.Name + ", island: " + player.Island.Identifier +
", has been idling for much longer than expected for current task: " + player.ActiveSkill);
player.IsStuck = true;
// record position, target, island, any details here, only one record per target is necessary, but we can update amount of unique bots triggered out of bots using same skill.
return;
}
}

playerController.IsStuck = false;
player.IsStuck = false;
// after recording details, store it for later, let bots run wild for 5-10 minutes then teleport them to next island, and continue recording issues until all islands been tested.
// then generate a report
}
Expand Down
18 changes: 18 additions & 0 deletions Assets/Scripts/Game/Player/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,7 @@ public void ClearTask()

public bool Fish(FishingController fishingSpot)
{
LastExecutedTaskTime = Time.time;
actionTimer = fishingAnimationTime;
InCombat = false;
Movement.Lock();
Expand Down Expand Up @@ -2167,6 +2168,7 @@ public bool Fish(FishingController fishingSpot)

public bool Cook(CraftingStation craftingStation)
{
LastExecutedTaskTime = Time.time;
actionTimer = cookingAnimationTime;
Movement.Lock();
InCombat = false;
Expand Down Expand Up @@ -2200,6 +2202,7 @@ public bool Cook(CraftingStation craftingStation)

public bool Brew(CraftingStation craftingStation)
{
LastExecutedTaskTime = Time.time;
actionTimer = craftingAnimationTime;
Movement.Lock();
InCombat = false;
Expand Down Expand Up @@ -2235,6 +2238,7 @@ public bool Brew(CraftingStation craftingStation)

public bool Craft(CraftingStation craftingStation)
{
LastExecutedTaskTime = Time.time;
actionTimer = craftingAnimationTime;
Movement.Lock();
InCombat = false;
Expand Down Expand Up @@ -2265,6 +2269,7 @@ public bool Craft(CraftingStation craftingStation)

public bool Mine(RockController rock)
{
LastExecutedTaskTime = Time.time;
actionTimer = mineRockAnimationTime;
InCombat = false;
Movement.Lock();
Expand Down Expand Up @@ -2299,6 +2304,7 @@ public bool Mine(RockController rock)
}
public bool Farm(FarmController farm)
{
LastExecutedTaskTime = Time.time;
actionTimer = rakeAnimationTime;
InCombat = false;
Movement.Lock();
Expand Down Expand Up @@ -2333,6 +2339,7 @@ public bool Farm(FarmController farm)

public bool Cut(TreeController tree)
{
LastExecutedTaskTime = Time.time;
actionTimer = chompTreeAnimationTime;
InCombat = false;
Movement.Lock();
Expand All @@ -2359,6 +2366,7 @@ public bool Cut(TreeController tree)

public bool Gather(GatherController gather)
{
LastExecutedTaskTime = Time.time;
actionTimer = rakeAnimationTime;
InCombat = false;
Movement.Lock();
Expand Down Expand Up @@ -2404,6 +2412,7 @@ public bool Heal(PlayerController target)

private bool AttackEntity(IAttackable target, bool damageOnDraw = false)
{
LastExecutedTaskTime = Time.time;
if (target == null)
{
return false;
Expand Down Expand Up @@ -2500,6 +2509,7 @@ public AttackType GetAttackType()

public bool HealTarget(IAttackable target, float hitTime, float startTime)
{
LastExecutedTaskTime = Time.time;
var delta = Time.time - startTime;
if (delta < hitTime) return false;
try
Expand Down Expand Up @@ -2537,6 +2547,7 @@ public bool HealTarget(IAttackable target, float hitTime, float startTime)

public bool DamageEnemy(IAttackable enemy, float hitTime, float startTime)
{
LastExecutedTaskTime = Time.time;
var delta = Time.time - startTime;
if (delta < hitTime) return false;
if (enemy == null) return true;
Expand Down Expand Up @@ -2603,6 +2614,7 @@ public bool DamageEnemy(IAttackable enemy, float hitTime, float startTime)

private bool Gather(GatherController gather, float startTime)
{
LastExecutedTaskTime = Time.time;
var delta = Time.time - startTime;
var actionTime = chompTreeAnimationTime / 2f;
if (delta < actionTime)
Expand Down Expand Up @@ -2636,6 +2648,7 @@ private bool Gather(GatherController gather, float startTime)

public bool DamageTree(TreeController tree, float startTime)
{
LastExecutedTaskTime = Time.time;
var delta = Time.time - startTime;
var actionTime = chompTreeAnimationTime / 2f;
if (delta < actionTime)
Expand Down Expand Up @@ -2924,6 +2937,7 @@ private void DoTask()
var taskCompleted = Chunk.IsTaskCompleted(this, taskTarget);
if (taskCompleted)
{
LastExecutedTaskTime = GameTime.time;
Movement.Unlock();
}
else
Expand Down Expand Up @@ -2956,6 +2970,10 @@ private void DoTask()

return;
}
else
{
LastExecutedTaskTime = GameTime.time;
}

if (Chunk.ExecuteTask(this, taskTarget))
{
Expand Down
Loading

0 comments on commit a33dd33

Please sign in to comment.