Skip to content

Commit

Permalink
v0.9.1.5a
Browse files Browse the repository at this point in the history
* Added missing raccoon pets and other added ingame items from v0.9.1.4a. These has been added to the website as well.
* Added a new redeemable christmas item: Black Santa Hat for 50 Christmas Tokens.
* Added a game settings to allow streamer to disable raids and dungeons with toggle buttons under Settings > Game. This will stop random dungeon or raids to start as well as prevents players from starting these events using scrolls.
* Fixed an issue where players could still gain exp on an island they were not supposed to.
* Fixed a bug with resting where players would start training immediately after using !rest
* Fixed a bug causing players to get stuck at start of dungeon.
* Fixed a bug causing players to get stuck when joining raids.
* Updated the Tavern to instead of showing missing labels or incorrect redeemable pet, it now shows a text that christmas redeemable previews are unavailabe at this time and I will try to fix this in a future update.
  • Loading branch information
zerratar committed Dec 3, 2023
1 parent ffa8496 commit 43c240e
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 81 deletions.
16 changes: 14 additions & 2 deletions Assets/Scripts/Dungeon/DungeonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public Vector3 StartingPoint
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsAlive(EnemyController x)
public static bool IsAlive(EnemyController x)
{
return x != null && x.gameObject != null && !x.Stats.IsDead && x.Stats.Health.CurrentValue > 0;
return !x.Stats.IsDead && x.Stats.Health.CurrentValue > 0;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -118,6 +118,13 @@ public IReadOnlyList<EnemyController> GetAliveEnemies()
{
return dungeonEnemyPool.HasLeasedEnemies ? dungeonEnemyPool.GetLeasedEnemies().AsList(IsAlive) : new List<EnemyController>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IReadOnlyList<EnemyController> GetEnemies()
{
return dungeonEnemyPool.HasLeasedEnemies ? dungeonEnemyPool.GetLeasedEnemies() : new List<EnemyController>();
}

internal EnemyController GetNextEnemyTarget(PlayerController player)
{
var room = Dungeon.Room;
Expand Down Expand Up @@ -205,6 +212,11 @@ internal IReadOnlyList<PlayerController> GetAlivePlayers()
// Update is called once per frame
private void Update()
{
if (PlayerSettings.Instance.DisableDungeons.GetValueOrDefault())
{
return;
}

ProcessRewardQueue();
UpdateDungeonTimer();
UpdateDungeonStartTimer();
Expand Down
11 changes: 11 additions & 0 deletions Assets/Scripts/Editor/RavenfallObjectTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ public static void AdjustPlacementsOnAllOobjects()
PlacementUtility.PlaceOnGround<CraftingStation>();
PlacementUtility.PlaceOnGround<FarmController>();
PlacementUtility.PlaceOnGround<TownHouseSlot>();
AdjustPlacementsOnIslandSpawnpoints();
}

[MenuItem("Ravenfall/Objects/Adjust Placements/Spawnpoints", priority = 10)]
public static void AdjustPlacementsOnIslandSpawnpoints()
{
var islands = GameObject.FindObjectsByType<IslandController>(FindObjectsSortMode.None);
foreach (var island in islands)
{
PlacementUtility.PlaceOnGround(island.SpawnPositionTransform);
}
}

[MenuItem("Ravenfall/Objects/Adjust Placements/Trees", priority = 10)]
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Game/Combat/EnemyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ void LateUpdate()
public bool IsUnreachable { get; set; }

public EnemySpawnPoint SpawnPoint;
private Transform _transform;
[NonSerialized] public Transform _transform;

public void ClearAttackers()
{
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/Game/Combat/EnemyMovementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ private void PlayDeathAnimation()
deathAnimationLength = 0f;
}

StartCoroutine(Hide());
if (this.isActiveAndEnabled)
{
StartCoroutine(Hide());
}
}

private IEnumerator Hide()
Expand Down
63 changes: 47 additions & 16 deletions Assets/Scripts/Game/Controllers/DungeonRoomController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,54 @@ public static EnemyController GetNextEnemyTarget(this EnemyController[] enemies,
// since healers are now attacked by enemies in dungeons.
// We have to always focus on enemies that are attacking a healer.

return
enemies
.Where(x => !x.IsUnreachable && !x.Stats.IsDead && (filter == null || filter(x)))
.OrderBy(x =>
EnemyController target = null;
float smallestDistance = float.MaxValue;

for (var i = 0; i < enemies.Length; ++i)
{
var enemy = enemies[i];
if (enemy.IsUnreachable || enemy.Stats.IsDead)
{
continue;
}

if (filter != null && !filter(enemy))
{
continue;
}

var distance = Vector3.Distance(enemy.Position, player.Movement.Position);

// we gotta protect our healers first hand. so we add 20 distance to enemies not targeting healers
if (!enemy.HasValidTarget || !enemy.TargetPlayer.TrainingHealing)
{
distance += 20;
}
if (distance < smallestDistance)
{
var distance = Vector3.Distance(x.Position, player.Movement.Position);

// We want it to sort by distance still, but to ensure we can protect our players
// we will add distance+constant so that healers are always prioritized.
if (x.HasValidTarget && x.TargetPlayer.TrainingHealing)
{
return distance;
}

return distance + 100f;
})
.FirstOrDefault();
target = enemy;
smallestDistance = distance;
}
}

return target;

//enemies
//.Where(x => !x.IsUnreachable && !x.Stats.IsDead && (filter == null || filter(x)))
//.OrderBy(x =>
//{
// var distance = Vector3.Distance(x.Position, player.Movement.Position);

// // We want it to sort by distance still, but to ensure we can protect our players
// // we will add distance+constant so that healers are always prioritized.
// if (x.HasValidTarget && x.TargetPlayer.TrainingHealing)
// {
// return distance;
// }

// return distance + 100f;
//})
//.FirstOrDefault();
}
}

Expand Down
43 changes: 32 additions & 11 deletions Assets/Scripts/Game/Handlers/DungeonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public void OnEnter()
player.Island.RemovePlayer(player);
}

//player.Movement.DisableLocalAvoidance();

waitForDungeon = 0;
InDungeon = true;

Expand Down Expand Up @@ -235,10 +237,15 @@ public void OnEnter()

this.player.Island = null;
this.player.taskTarget = null;

player.Movement.AdjustPlayerPositionToNavmesh();
}

public void OnExit()
{
player.Movement.EnableLocalAvoidance();


if (!InDungeon)
return;

Expand All @@ -253,6 +260,7 @@ public void OnExit()
else
{
player.teleportHandler.Teleport(previousPosition);
player.Movement.AdjustPlayerPositionToNavmesh();
}

if (previousTask != TaskType.None)
Expand Down Expand Up @@ -333,7 +341,11 @@ private void HealTarget()
}
else
{
player.SetDestination(healTarget.Position);
if (!player.SetDestination(healTarget.Position))
{
player.Movement.DisableLocalAvoidance();
}

healTarget = null;
}
}
Expand All @@ -347,7 +359,9 @@ private void AttackTarget()
return;
}

var distance = Vector3.Distance(player.transform.position, enemyTarget.transform.position);
var targetEnemyPosition = enemyTarget._transform.position;

var distance = Vector3.Distance(player._transform.position, targetEnemyPosition);
if (distance <= range)
{
if (!player.IsReadyForAction)
Expand All @@ -357,26 +371,33 @@ private void AttackTarget()
}

// Aggro more enemies that are close to the one being attacked if it doesnt have an attacker.
var enemies = dungeon.GetEnemiesNear(enemyTarget.transform.position);
if (enemies != null)

var enemies = dungeon.GetEnemies();
for (var i = 0; i < enemies.Count; ++i)
{
foreach (var enemy in enemies)
var enemy = enemies[i];
if (enemy.Stats.IsDead || enemy.Attackers.Count > 0 || enemy == enemyTarget)
{
if (enemy.Attackers.Count > 0)
{
continue;
}
continue;
}

enemy.Attack(this.player);
if (Vector3.Distance(targetEnemyPosition, enemy._transform.position) > enemy.AggroRange)
{
continue;
}

enemy.Attack(this.player);
}


player.Attack(enemyTarget);
}
else
{
if (!player.SetDestination(enemyTarget.transform.position))
if (!player.SetDestination(targetEnemyPosition))
{
player.Movement.DisableLocalAvoidance();

// unreachable enemy in dungeon
enemyTarget.IsUnreachable = true;
enemyTarget.TakeDamage(player, enemyTarget.Stats.Health.Level);
Expand Down
15 changes: 8 additions & 7 deletions Assets/Scripts/Game/Handlers/OnsenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public void Enter(OnsenController onsen)
player.GameManager.RavenBot.SendReply(player, Localization.MSG_ONSEN_FULL);
return;
}

var target = spot.Target;

player.Movement.Lock();
player.teleportHandler.Teleport(target.position, false);
player._transform.SetParent(target);
player._transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);

// used for determing which animation to use
this.positionType = spot.Type;
Expand All @@ -92,15 +99,9 @@ public void Enter(OnsenController onsen)
break;
}

player.Movement.Lock();
InOnsen = true;

var target = spot.Target;
player.teleportHandler.Teleport(target.position, false);
player.transform.SetParent(target);
player.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
this.onsenParentID = target.GetInstanceID();

InOnsen = true;
onsen.UpdateDetailsLabel();
}

Expand Down
7 changes: 6 additions & 1 deletion Assets/Scripts/Game/Handlers/RaidHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ void Update()
}
else
{
player.SetDestination(target.position);
if (!player.SetDestination(target.position))
{
player.Movement.DisableLocalAvoidance();
}
}
}

Expand Down Expand Up @@ -166,6 +169,8 @@ public void OnEnter()
previousIsland = player.Island;
player.teleportHandler.Teleport(boss.Island.SpawnPosition);
}

player.Movement.AdjustPlayerPositionToNavmesh();
}

private IEnumerator WaitForStart()
Expand Down
6 changes: 5 additions & 1 deletion Assets/Scripts/Game/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,11 @@ private void OnGUI()
void TeleportBot(PlayerController player, IslandController island)
{
player.teleportHandler.Teleport(island.SpawnPosition);
player.Bot.LastTeleport = Time.time;
if (player.IsBot)
{
player.Bot.LastTeleport = Time.time;
}

player.ClearTarget();
if (!string.IsNullOrEmpty(player.CurrentTaskName))
player.SetTask(player.CurrentTaskName, player.taskArgument, true);
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/Game/Managers/RaidManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ public float GetParticipationPercentage(DateTime enterTime)
// Update is called once per frame
private void Update()
{
if (PlayerSettings.Instance.DisableRaids.GetValueOrDefault())
{
return;
}

ProcessRewardQueue();

var playerCount = playerManager.GetPlayerCount(true);
Expand Down
10 changes: 7 additions & 3 deletions Assets/Scripts/Game/Player/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class PlayerController : MonoBehaviour, IAttackable

[SerializeField] private GameObject[] availableMonsterMeshes;

private Transform _transform;
[NonSerialized] public Transform _transform;
private StatsModifiers playerStatsModifiers = new StatsModifiers();
private ConcurrentDictionary<StatusEffectType, StatusEffect> statusEffects = new ConcurrentDictionary<StatusEffectType, StatusEffect>();

Expand Down Expand Up @@ -2632,6 +2632,10 @@ private void DoTask()
{
// path is invalid, this target is therefor invalid.
Chunk.SetTargetInvalid(taskTarget);

// turn off local avoidance as well.
Movement.DisableLocalAvoidance();

taskTarget = null;
}
}
Expand Down Expand Up @@ -2701,10 +2705,10 @@ private void LookAt(Transform targetTransform)
transform.rotation = Quaternion.Euler(rotAfter.x, rotBefore.y, rotAfter.z);
}

public bool SetDestination(Vector3 position)
public bool SetDestination(Vector3 position, bool adjustToNavmesh = false)
{
InCombat = duelHandler.InDuel || attackTarget;
return Movement.SetDestination(position);
return Movement.SetDestination(position, adjustToNavmesh);
}

public void SetPosition(Vector3 position, bool adjustToNavmesh = true)
Expand Down
Loading

0 comments on commit 43c240e

Please sign in to comment.