1- using Darkages . Common ;
1+ using System . Security . Cryptography ;
2+
3+ using Darkages . Common ;
24using Darkages . Enums ;
35using Darkages . Network . Client ;
46using Darkages . Network . Server ;
57using Darkages . ScriptingBase ;
68using Darkages . Sprites ;
79using Darkages . Sprites . Entity ;
810using Darkages . Types ;
9- using System . Security . Cryptography ;
1011
1112namespace Darkages . GameScripts . Monsters ;
1213
@@ -662,9 +663,11 @@ private void UpdatePhases()
662663 if ( Monster . CurrentHp <= Monster . MaximumHp * 0.75 && ! _phaseOne )
663664 {
664665 Monster . SendTargetedClientMethod ( PlayerScope . NearbyAislings , c => c . SendPublicMessage ( Monster . Serial , PublicMessageType . Shout , $ "{ Monster . Name } : AHHHHH That Hurts! You made Yeti Mad!") ) ;
665- var foundA = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanA" , out var templateA ) ;
666- var foundB = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanB" , out var templateB ) ;
667- var foundC = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanC" , out var templateC ) ;
666+ // Per-map monster template cache
667+ if ( ! ServerSetup . Instance . MonsterTemplateByMapCache . TryGetValue ( Monster . Map . ID , out var templates ) || templates . Length == 0 ) return ;
668+ var foundA = templates . TryGetValue ( t => t . Name == "SnowmanA" , out var templateA ) ;
669+ var foundB = templates . TryGetValue ( t => t . Name == "SnowmanB" , out var templateB ) ;
670+ var foundC = templates . TryGetValue ( t => t . Name == "SnowmanC" , out var templateC ) ;
668671
669672 if ( foundA ) Monster . CreateFromTemplate ( templateA , Monster . Map ) ;
670673 if ( foundB ) Monster . CreateFromTemplate ( templateB , Monster . Map ) ;
@@ -676,11 +679,13 @@ private void UpdatePhases()
676679 if ( Monster . CurrentHp <= Monster . MaximumHp * 0.50 && ! _phaseTwo )
677680 {
678681 Monster . SendTargetedClientMethod ( PlayerScope . NearbyAislings , c => c . SendPublicMessage ( Monster . Serial , PublicMessageType . Shout , $ "{ Monster . Name } : AHHHHH That Hurts! You made Yeti Really Mad!") ) ;
679- var foundA = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanA" , out var templateA ) ;
680- var foundB = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanB" , out var templateB ) ;
681- var foundC = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanC" , out var templateC ) ;
682- var foundD = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanD" , out var templateD ) ;
683- var foundE = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanE" , out var templateE ) ;
682+ // Per-map monster template cache
683+ if ( ! ServerSetup . Instance . MonsterTemplateByMapCache . TryGetValue ( Monster . Map . ID , out var templates ) || templates . Length == 0 ) return ;
684+ var foundA = templates . TryGetValue ( t => t . Name == "SnowmanA" , out var templateA ) ;
685+ var foundB = templates . TryGetValue ( t => t . Name == "SnowmanB" , out var templateB ) ;
686+ var foundC = templates . TryGetValue ( t => t . Name == "SnowmanC" , out var templateC ) ;
687+ var foundD = templates . TryGetValue ( t => t . Name == "SnowmanD" , out var templateD ) ;
688+ var foundE = templates . TryGetValue ( t => t . Name == "SnowmanE" , out var templateE ) ;
684689
685690 if ( foundA ) Monster . CreateFromTemplate ( templateA , Monster . Map ) ;
686691 if ( foundB ) Monster . CreateFromTemplate ( templateB , Monster . Map ) ;
@@ -694,13 +699,15 @@ private void UpdatePhases()
694699 if ( Monster . CurrentHp <= Monster . MaximumHp * 0.25 && ! _phaseThree )
695700 {
696701 Monster . SendTargetedClientMethod ( PlayerScope . NearbyAislings , c => c . SendPublicMessage ( Monster . Serial , PublicMessageType . Shout , $ "{ Monster . Name } : AHHHHH That Hurts! Time to die!!") ) ;
697- var foundA = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanA" , out var templateA ) ;
698- var foundB = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanB" , out var templateB ) ;
699- var foundC = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanC" , out var templateC ) ;
700- var foundD = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanD" , out var templateD ) ;
701- var foundE = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanE" , out var templateE ) ;
702- var foundF = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanF" , out var templateF ) ;
703- var foundG = ServerSetup . Instance . GlobalMonsterTemplateCache . TryGetValue ( "SnowmanG" , out var templateG ) ;
702+ // Per-map monster template cache
703+ if ( ! ServerSetup . Instance . MonsterTemplateByMapCache . TryGetValue ( Monster . Map . ID , out var templates ) || templates . Length == 0 ) return ;
704+ var foundA = templates . TryGetValue ( t => t . Name == "SnowmanA" , out var templateA ) ;
705+ var foundB = templates . TryGetValue ( t => t . Name == "SnowmanB" , out var templateB ) ;
706+ var foundC = templates . TryGetValue ( t => t . Name == "SnowmanC" , out var templateC ) ;
707+ var foundD = templates . TryGetValue ( t => t . Name == "SnowmanD" , out var templateD ) ;
708+ var foundE = templates . TryGetValue ( t => t . Name == "SnowmanE" , out var templateE ) ;
709+ var foundF = templates . TryGetValue ( t => t . Name == "SnowmanF" , out var templateF ) ;
710+ var foundG = templates . TryGetValue ( t => t . Name == "SnowmanG" , out var templateG ) ;
704711
705712 if ( foundA ) Monster . CreateFromTemplate ( templateA , Monster . Map ) ;
706713 if ( foundB ) Monster . CreateFromTemplate ( templateB , Monster . Map ) ;
0 commit comments