1- using Chaos . Geometry ;
1+ using System . Diagnostics ;
2+ using Chaos . Geometry ;
23using Chaos . Geometry . Abstractions . Definitions ;
34
45using Darkages . Common ;
@@ -181,10 +182,10 @@ public override void MonsterState(TimeSpan elapsedTime)
181182 return ;
182183 }
183184
184- if ( Monster . BashEnabled )
185+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
185186 {
186187 if ( ! Monster . CantAttack )
187- if ( assail ) Bash ( ) ;
188+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
188189 }
189190
190191 if ( Monster . AbilityEnabled )
@@ -268,6 +269,7 @@ private string LevelColor(WorldClient client)
268269
269270 private void Bash ( )
270271 {
272+ Monster . NextToTargetFirstAttack = false ;
271273 if ( Monster . CantAttack ) return ;
272274 // Training Dummy or other enemies who can't attack
273275 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -295,8 +297,7 @@ private void Ability()
295297 // Training Dummy or other enemies who can't attack
296298 if ( Monster . AbilityScripts . Count == 0 ) return ;
297299
298- var abilityAttempt = Generator . RandNumGen100 ( ) ;
299- if ( abilityAttempt <= 60 ) return ;
300+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
300301 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
301302
302303 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -313,7 +314,7 @@ private void CastSpell()
313314 // Training Dummy or other enemies who can't attack
314315 if ( Monster . SpellScripts . Count == 0 ) return ;
315316
316- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
317+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
317318 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
318319
319320 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -776,10 +777,10 @@ public override void MonsterState(TimeSpan elapsedTime)
776777 return ;
777778 }
778779
779- if ( Monster . BashEnabled )
780+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
780781 {
781782 if ( ! Monster . CantAttack )
782- if ( assail ) Bash ( ) ;
783+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
783784 }
784785
785786 if ( Monster . AbilityEnabled )
@@ -834,6 +835,7 @@ private string LevelColor(IWorldClient client)
834835
835836 private void Bash ( )
836837 {
838+ Monster . NextToTargetFirstAttack = false ;
837839 if ( Monster . CantAttack ) return ;
838840 // Training Dummy or other enemies who can't attack
839841 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -861,8 +863,7 @@ private void Ability()
861863 // Training Dummy or other enemies who can't attack
862864 if ( Monster . AbilityScripts . Count == 0 ) return ;
863865
864- var abilityAttempt = Generator . RandNumGen100 ( ) ;
865- if ( abilityAttempt <= 60 ) return ;
866+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
866867 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
867868
868869 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -875,7 +876,7 @@ private void SummonMonsterNearby()
875876 if ( Monster . CantCast ) return ;
876877 if ( Monster . Target is null ) return ;
877878
878- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
879+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
879880
880881 var monstersNearby = Monster . MonstersOnMap ( ) ;
881882
@@ -1120,7 +1121,7 @@ private void CastSpell()
11201121 if ( Monster . Target is null ) return ;
11211122 if ( ! Monster . Target . WithinMonsterSpellRangeOf ( Monster ) ) return ;
11221123
1123- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
1124+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
11241125 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
11251126
11261127 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -1303,10 +1304,10 @@ public override void MonsterState(TimeSpan elapsedTime)
13031304 return ;
13041305 }
13051306
1306- if ( Monster . BashEnabled )
1307+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
13071308 {
13081309 if ( ! Monster . CantAttack )
1309- if ( assail ) Bash ( ) ;
1310+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
13101311 }
13111312
13121313 if ( Monster . AbilityEnabled )
@@ -1363,6 +1364,7 @@ private string LevelColor(WorldClient client)
13631364
13641365 private void Bash ( )
13651366 {
1367+ Monster . NextToTargetFirstAttack = false ;
13661368 if ( Monster . CantAttack ) return ;
13671369 // Training Dummy or other enemies who can't attack
13681370 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -1390,8 +1392,7 @@ private void Ability()
13901392 // Training Dummy or other enemies who can't attack
13911393 if ( Monster . AbilityScripts . Count == 0 ) return ;
13921394
1393- var abilityAttempt = Generator . RandNumGen100 ( ) ;
1394- if ( abilityAttempt <= 60 ) return ;
1395+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
13951396 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
13961397
13971398 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -1410,7 +1411,7 @@ private void CastSpell()
14101411 // Training Dummy or other enemies who can't attack
14111412 if ( Monster . SpellScripts . Count == 0 ) return ;
14121413
1413- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
1414+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
14141415 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
14151416
14161417 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -1593,10 +1594,10 @@ public override void MonsterState(TimeSpan elapsedTime)
15931594 return ;
15941595 }
15951596
1596- if ( Monster . BashEnabled )
1597+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
15971598 {
15981599 if ( ! Monster . CantAttack )
1599- if ( assail ) Bash ( ) ;
1600+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
16001601 }
16011602
16021603 if ( Monster . AbilityEnabled )
@@ -1653,6 +1654,7 @@ private string LevelColor(WorldClient client)
16531654
16541655 private void Bash ( )
16551656 {
1657+ Monster . NextToTargetFirstAttack = false ;
16561658 if ( Monster . CantAttack ) return ;
16571659 // Training Dummy or other enemies who can't attack
16581660 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -1689,8 +1691,7 @@ private void Ability()
16891691 // Training Dummy or other enemies who can't attack
16901692 if ( Monster . AbilityScripts . Count == 0 ) return ;
16911693
1692- var abilityAttempt = Generator . RandNumGen100 ( ) ;
1693- if ( abilityAttempt <= 60 ) return ;
1694+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
16941695 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
16951696
16961697 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -1709,7 +1710,7 @@ private void CastSpell()
17091710 // Training Dummy or other enemies who can't attack
17101711 if ( Monster . SpellScripts . Count == 0 ) return ;
17111712
1712- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
1713+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
17131714 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
17141715
17151716 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -1902,10 +1903,10 @@ public override void MonsterState(TimeSpan elapsedTime)
19021903 return ;
19031904 }
19041905
1905- if ( Monster . BashEnabled )
1906+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
19061907 {
19071908 if ( ! Monster . CantAttack )
1908- if ( assail ) Bash ( ) ;
1909+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
19091910 }
19101911
19111912 if ( Monster . AbilityEnabled )
@@ -1962,6 +1963,7 @@ private string LevelColor(WorldClient client)
19621963
19631964 private void Bash ( )
19641965 {
1966+ Monster . NextToTargetFirstAttack = false ;
19651967 if ( Monster . CantAttack ) return ;
19661968 // Training Dummy or other enemies who can't attack
19671969 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -1989,8 +1991,7 @@ private void Ability()
19891991 // Training Dummy or other enemies who can't attack
19901992 if ( Monster . AbilityScripts . Count == 0 ) return ;
19911993
1992- var abilityAttempt = Generator . RandNumGen100 ( ) ;
1993- if ( abilityAttempt <= 60 ) return ;
1994+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
19941995 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
19951996
19961997 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -2009,7 +2010,7 @@ private void CastSpell()
20092010 // Training Dummy or other enemies who can't attack
20102011 if ( Monster . SpellScripts . Count == 0 ) return ;
20112012
2012- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
2013+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
20132014 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
20142015
20152016 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -2029,6 +2030,7 @@ public class AosdaHero : MonsterScript
20292030 private int Count => GhostChat . Length ;
20302031 private int RunCount => GhostChase . Length ;
20312032 private bool _deathCry ;
2033+ private readonly Stopwatch _vulnerabilityWatch = new ( ) ;
20322034
20332035 public AosdaHero ( Monster monster , Area map ) : base ( monster , map )
20342036 {
@@ -2056,11 +2058,19 @@ public override void Update(TimeSpan elapsedTime)
20562058
20572059 if ( Monster . IsVulnerable || Monster . IsPoisoned )
20582060 {
2059- var pos = Monster . Pos ;
2060- Monster . SendAnimationNearby ( 75 , new Position ( pos ) ) ;
2061+ if ( ! _vulnerabilityWatch . IsRunning )
2062+ _vulnerabilityWatch . Start ( ) ;
20612063
2062- foreach ( var debuff in Monster . Debuffs . Values )
2063- debuff ? . OnEnded ( Monster , debuff ) ;
2064+ if ( _vulnerabilityWatch . Elapsed . TotalMilliseconds > 1000 )
2065+ {
2066+ var pos = Monster . Pos ;
2067+ Monster . SendAnimationNearby ( 75 , new Position ( pos ) ) ;
2068+
2069+ foreach ( var debuff in Monster . Debuffs . Values )
2070+ debuff ? . OnEnded ( Monster , debuff ) ;
2071+
2072+ _vulnerabilityWatch . Restart ( ) ;
2073+ }
20642074 }
20652075
20662076 MonsterState ( elapsedTime ) ;
@@ -2199,10 +2209,10 @@ public override void MonsterState(TimeSpan elapsedTime)
21992209 return ;
22002210 }
22012211
2202- if ( Monster . BashEnabled )
2212+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
22032213 {
22042214 if ( ! Monster . CantAttack )
2205- if ( assail ) Bash ( ) ;
2215+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
22062216 }
22072217
22082218 if ( Monster . AbilityEnabled )
@@ -2259,6 +2269,7 @@ private string LevelColor(WorldClient client)
22592269
22602270 private void Bash ( )
22612271 {
2272+ Monster . NextToTargetFirstAttack = false ;
22622273 if ( Monster . CantAttack ) return ;
22632274 // Training Dummy or other enemies who can't attack
22642275 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -2286,8 +2297,7 @@ private void Ability()
22862297 // Training Dummy or other enemies who can't attack
22872298 if ( Monster . AbilityScripts . Count == 0 ) return ;
22882299
2289- var abilityAttempt = Generator . RandNumGen100 ( ) ;
2290- if ( abilityAttempt <= 30 ) return ;
2300+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
22912301 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
22922302
22932303 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -2306,7 +2316,7 @@ private void CastSpell()
23062316 // Training Dummy or other enemies who can't attack
23072317 if ( Monster . SpellScripts . Count == 0 ) return ;
23082318
2309- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.50 ) ) return ;
2319+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
23102320 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
23112321
23122322 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -2496,10 +2506,10 @@ public override void MonsterState(TimeSpan elapsedTime)
24962506 return ;
24972507 }
24982508
2499- if ( Monster . BashEnabled )
2509+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
25002510 {
25012511 if ( ! Monster . CantAttack )
2502- if ( assail ) Bash ( ) ;
2512+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
25032513 }
25042514
25052515 if ( Monster . AbilityEnabled )
@@ -2556,6 +2566,7 @@ private string LevelColor(WorldClient client)
25562566
25572567 private void Bash ( )
25582568 {
2569+ Monster . NextToTargetFirstAttack = false ;
25592570 if ( Monster . CantAttack ) return ;
25602571 // Training Dummy or other enemies who can't attack
25612572 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -2583,8 +2594,7 @@ private void Ability()
25832594 // Training Dummy or other enemies who can't attack
25842595 if ( Monster . AbilityScripts . Count == 0 ) return ;
25852596
2586- var abilityAttempt = Generator . RandNumGen100 ( ) ;
2587- if ( abilityAttempt <= 60 ) return ;
2597+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
25882598 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
25892599
25902600 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -2603,7 +2613,7 @@ private void CastSpell()
26032613 // Training Dummy or other enemies who can't attack
26042614 if ( Monster . SpellScripts . Count == 0 ) return ;
26052615
2606- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
2616+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
26072617 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
26082618
26092619 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
@@ -2778,10 +2788,10 @@ public override void MonsterState(TimeSpan elapsedTime)
27782788 return ;
27792789 }
27802790
2781- if ( Monster . BashEnabled )
2791+ if ( Monster . BashEnabled || Monster . NextToTargetFirstAttack )
27822792 {
27832793 if ( ! Monster . CantAttack )
2784- if ( assail ) Bash ( ) ;
2794+ if ( assail || Monster . NextToTargetFirstAttack ) Bash ( ) ;
27852795 }
27862796
27872797 if ( Monster . AbilityEnabled )
@@ -2851,6 +2861,7 @@ public override void OnApproach(WorldClient client)
28512861
28522862 private void Bash ( )
28532863 {
2864+ Monster . NextToTargetFirstAttack = false ;
28542865 if ( Monster . CantAttack ) return ;
28552866 // Training Dummy or other enemies who can't attack
28562867 if ( Monster . SkillScripts . Count == 0 ) return ;
@@ -2878,8 +2889,7 @@ private void Ability()
28782889 // Training Dummy or other enemies who can't attack
28792890 if ( Monster . AbilityScripts . Count == 0 ) return ;
28802891
2881- var abilityAttempt = Generator . RandNumGen100 ( ) ;
2882- if ( abilityAttempt <= 60 ) return ;
2892+ if ( Generator . RandomPercentPrecise ( ) <= 0.70 ) return ;
28832893 var abilityIdx = RandomNumberGenerator . GetInt32 ( Monster . AbilityScripts . Count ) ;
28842894
28852895 if ( Monster . AbilityScripts [ abilityIdx ] is null ) return ;
@@ -2896,7 +2906,7 @@ private void CastSpell()
28962906 // Training Dummy or other enemies who can't attack
28972907 if ( Monster . SpellScripts . Count == 0 ) return ;
28982908
2899- if ( ! ( Generator . RandomPercentPrecise ( ) > = 0.70 ) ) return ;
2909+ if ( Generator . RandomPercentPrecise ( ) < = 0.70 ) return ;
29002910 var spellIdx = RandomNumberGenerator . GetInt32 ( Monster . SpellScripts . Count ) ;
29012911
29022912 if ( Monster . SpellScripts [ spellIdx ] is null ) return ;
0 commit comments