Skip to content

Commit

Permalink
Adjustments to timing
Browse files Browse the repository at this point in the history
  • Loading branch information
FallenDev committed Jan 25, 2025
1 parent c137702 commit 15393e4
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 151 deletions.
Binary file modified Server.Configurations/ZolianDB/ZolianMundanes.sql
Binary file not shown.
102 changes: 56 additions & 46 deletions Zolian.Server.Base/GameScripts/Monsters/AdvancedMonsterAI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Chaos.Geometry;
using System.Diagnostics;
using Chaos.Geometry;
using Chaos.Geometry.Abstractions.Definitions;

using Darkages.Common;
Expand Down Expand Up @@ -181,10 +182,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -268,6 +269,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -295,8 +297,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -313,7 +314,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -776,10 +777,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -834,6 +835,7 @@ private string LevelColor(IWorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -861,8 +863,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -875,7 +876,7 @@ private void SummonMonsterNearby()
if (Monster.CantCast) return;
if (Monster.Target is null) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;

var monstersNearby = Monster.MonstersOnMap();

Expand Down Expand Up @@ -1120,7 +1121,7 @@ private void CastSpell()
if (Monster.Target is null) return;
if (!Monster.Target.WithinMonsterSpellRangeOf(Monster)) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -1303,10 +1304,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -1363,6 +1364,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -1390,8 +1392,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -1410,7 +1411,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -1593,10 +1594,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -1653,6 +1654,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -1689,8 +1691,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -1709,7 +1710,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -1902,10 +1903,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -1962,6 +1963,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -1989,8 +1991,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -2009,7 +2010,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand All @@ -2029,6 +2030,7 @@ public class AosdaHero : MonsterScript
private int Count => GhostChat.Length;
private int RunCount => GhostChase.Length;
private bool _deathCry;
private readonly Stopwatch _vulnerabilityWatch = new();

public AosdaHero(Monster monster, Area map) : base(monster, map)
{
Expand Down Expand Up @@ -2056,11 +2058,19 @@ public override void Update(TimeSpan elapsedTime)

if (Monster.IsVulnerable || Monster.IsPoisoned)
{
var pos = Monster.Pos;
Monster.SendAnimationNearby(75, new Position(pos));
if (!_vulnerabilityWatch.IsRunning)
_vulnerabilityWatch.Start();

foreach (var debuff in Monster.Debuffs.Values)
debuff?.OnEnded(Monster, debuff);
if (_vulnerabilityWatch.Elapsed.TotalMilliseconds > 1000)
{
var pos = Monster.Pos;
Monster.SendAnimationNearby(75, new Position(pos));

foreach (var debuff in Monster.Debuffs.Values)
debuff?.OnEnded(Monster, debuff);

_vulnerabilityWatch.Restart();
}
}

MonsterState(elapsedTime);
Expand Down Expand Up @@ -2199,10 +2209,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -2259,6 +2269,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -2286,8 +2297,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 30) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -2306,7 +2316,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.50)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -2496,10 +2506,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -2556,6 +2566,7 @@ private string LevelColor(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -2583,8 +2594,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -2603,7 +2613,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down Expand Up @@ -2778,10 +2788,10 @@ public override void MonsterState(TimeSpan elapsedTime)
return;
}

if (Monster.BashEnabled)
if (Monster.BashEnabled || Monster.NextToTargetFirstAttack)
{
if (!Monster.CantAttack)
if (assail) Bash();
if (assail || Monster.NextToTargetFirstAttack) Bash();
}

if (Monster.AbilityEnabled)
Expand Down Expand Up @@ -2851,6 +2861,7 @@ public override void OnApproach(WorldClient client)

private void Bash()
{
Monster.NextToTargetFirstAttack = false;
if (Monster.CantAttack) return;
// Training Dummy or other enemies who can't attack
if (Monster.SkillScripts.Count == 0) return;
Expand Down Expand Up @@ -2878,8 +2889,7 @@ private void Ability()
// Training Dummy or other enemies who can't attack
if (Monster.AbilityScripts.Count == 0) return;

var abilityAttempt = Generator.RandNumGen100();
if (abilityAttempt <= 60) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var abilityIdx = RandomNumberGenerator.GetInt32(Monster.AbilityScripts.Count);

if (Monster.AbilityScripts[abilityIdx] is null) return;
Expand All @@ -2896,7 +2906,7 @@ private void CastSpell()
// Training Dummy or other enemies who can't attack
if (Monster.SpellScripts.Count == 0) return;

if (!(Generator.RandomPercentPrecise() >= 0.70)) return;
if (Generator.RandomPercentPrecise() <= 0.70) return;
var spellIdx = RandomNumberGenerator.GetInt32(Monster.SpellScripts.Count);

if (Monster.SpellScripts[spellIdx] is null) return;
Expand Down
Loading

0 comments on commit 15393e4

Please sign in to comment.