1- #include < map >
2- #include " Log .h"
1+ #include " utils/Utils.h "
2+ #include " Chat .h"
33#include " Config.h"
4- #include " ScriptMgr.h"
5- #include " Unit.h"
6- #include " Player.h"
7- #include " Pet.h"
8- #include " Map.h"
94#include " Group.h"
105#include " InstanceScript.h"
11- #include " Chat.h"
12- #include < math.h>
13- #include < unordered_map>
6+ #include " Log.h"
7+ #include " Map.h"
148#include " ObjectGuid.h"
15- #include " utils/Utils.h"
9+ #include " Pet.h"
10+ #include " Player.h"
11+ #include " ScriptMgr.h"
12+ #include " Unit.h"
13+ #include < cstdint>
1614#include < iostream>
17- #include < vector>
15+ #include < map>
16+ #include < math.h>
1817#include < string>
19- #include < cstdint>
18+ #include < unordered_map>
19+ #include < vector>
2020
2121bool SoloCraftEnable = 1 ;
2222bool SoloCraftAnnounceModule = 1 ;
@@ -45,7 +45,9 @@ float D649H25 = 1.0;
4545class SolocraftConfig : public WorldScript
4646{
4747public:
48- SolocraftConfig () : WorldScript(" SolocraftConfig" ) {}
48+ SolocraftConfig () : WorldScript(" SolocraftConfig" , {
49+ WORLDHOOK_ON_BEFORE_CONFIG_LOAD
50+ }) {}
4951
5052 void OnBeforeConfigLoad (bool /* reload*/ ) override
5153 {
@@ -323,14 +325,17 @@ class SolocraftAnnounce : public PlayerScript
323325 std::map<ObjectGuid, bool > playerInInstanceMap;
324326
325327public:
326- SolocraftAnnounce () : PlayerScript(" SolocraftAnnounce" ) {}
328+ SolocraftAnnounce () : PlayerScript(" SolocraftAnnounce" , {
329+ PLAYERHOOK_ON_LOGIN,
330+ PLAYERHOOK_ON_LOGOUT,
331+ PLAYERHOOK_ON_MAP_CHANGED,
332+ PLAYERHOOK_ON_GIVE_EXP
333+ }) {}
327334
328335 void OnPlayerLogin (Player* player) override
329336 {
330337 if (SoloCraftEnable && SoloCraftAnnounceModule)
331- {
332338 ChatHandler (player->GetSession ()).SendSysMessage (" This server is running the |cff4CFF00SoloCraft |rmodule." );
333- }
334339 }
335340
336341 void OnPlayerLogout (Player* player) override
@@ -347,13 +352,9 @@ class SolocraftAnnounce : public PlayerScript
347352 void OnPlayerMapChanged (Player* player) override
348353 {
349354 if (player->GetMap ()->IsDungeon () || player->GetMap ()->IsRaid ())
350- {
351355 playerInInstanceMap[player->GetGUID ()] = true ;
352- }
353356 else
354- {
355357 playerInInstanceMap[player->GetGUID ()] = false ;
356- }
357358 }
358359
359360 void OnPlayerGiveXP (Player* player, uint32& amount, Unit* /* victim*/ , uint8 /* xpSource*/ ) override
@@ -369,7 +370,9 @@ class SolocraftAnnounce : public PlayerScript
369370class SolocraftPlayerInstanceHandler : public PlayerScript
370371{
371372public:
372- SolocraftPlayerInstanceHandler () : PlayerScript(" SolocraftPlayerInstanceHandler" ) {}
373+ SolocraftPlayerInstanceHandler () : PlayerScript(" SolocraftPlayerInstanceHandler" , {
374+ PLAYERHOOK_ON_MAP_CHANGED
375+ }) {}
373376
374377 bool IsInSolocraftInstanceExcludedList (uint32 id)
375378 {
@@ -395,48 +398,34 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
395398 if (map)
396399 {
397400 if (IsInSolocraftInstanceExcludedList (map->GetId ()))
398- {
399401 return 0 ;
400- }
401402
402403 if (map->Is25ManRaid ())
403404 {
404405 if (map->IsHeroic () && map->GetId () == 649 )
405- {
406406 return D649H25;
407- }
408407 else if (diff_Multiplier_Heroics.find (map->GetId ()) == diff_Multiplier_Heroics.end ())
409- {
410408 return D25;
411- }
412409 else
413410 return diff_Multiplier_Heroics[map->GetId ()];
414411 }
415412
416413 if (map->IsHeroic ())
417414 {
418415 if (map->GetId () == 649 )
419- {
420416 return D649H10;
421- }
422417 else if (diff_Multiplier_Heroics.find (map->GetId ()) == diff_Multiplier_Heroics.end ())
423- {
424418 return D10;
425- }
426419 else
427420 return diff_Multiplier_Heroics[map->GetId ()];
428421 }
429422
430423 if (diff_Multiplier.find (map->GetId ()) == diff_Multiplier.end ())
431424 {
432425 if (map->IsDungeon ())
433- {
434426 return D5;
435- }
436427 else if (map->IsRaid ())
437- {
438428 return D40;
439- }
440429 }
441430 else
442431 return diff_Multiplier[map->GetId ()];
@@ -449,13 +438,9 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
449438 uint32 CalculateDungeonLevel (Map* map)
450439 {
451440 if (dungeons.find (map->GetId ()) == dungeons.end ())
452- {
453441 return SolocraftDungeonLevel;
454- }
455442 else
456- {
457443 return dungeons[map->GetId ()];
458- }
459444 }
460445
461446 // Get the group's size
@@ -479,13 +464,9 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
479464 uint32 classBalance = 100 ;
480465
481466 if (classes.find (player->getClass ()) == classes.end ())
482- {
483467 return classBalance;
484- }
485468 else if (classes[player->getClass ()] >= 0 && classes[player->getClass ()] <= 100 )
486- {
487469 return classes[player->getClass ()];
488- }
489470 else
490471 return classBalance;
491472 }
@@ -507,9 +488,7 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
507488 if (result)
508489 {
509490 if ((*result)[1 ].Get <float >() > 0 )
510- {
511491 GroupDifficulty = GroupDifficulty + (*result)[1 ].Get <float >();
512- }
513492 }
514493 }
515494 }
@@ -533,33 +512,25 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
533512 SoloCraftXPMod = 1.0 ;
534513
535514 for (uint32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
536- {
537515 player->HandleStatModifier (UnitMods (UNIT_MOD_STAT_START + i), TOTAL_PCT, difficulty * StatsMultPct, false );
538- }
539516
540517 if (player->HasFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN) && !SolocraftNoXPFlag)
541- {
542518 player->RemoveFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN);
543- }
544519
545520 SolocraftNoXPFlag = 0 ;
546521 CharacterDatabase.Execute (" DELETE FROM custom_solocraft_character_stats WHERE GUID = {}" , player->GetGUID ().GetCounter ());
547522 }
548523
549524 if (player->getPowerType () == POWER_MANA || player->getClass () == CLASS_DRUID)
550- {
551525 player->ApplySpellPowerBonus (SpellPowerBonus, false );
552- }
553526 }
554527
555528 // Apply the player buffs
556529 void ApplyBuffs (Player* player, Map* map, float difficulty, int dunLevel, int numInGroup, int classBalance)
557530 {
558531 // Check whether to debuff back to normal or check to buff the player
559532 if (difficulty == 0 || IsInSolocraftInstanceExcludedList (map->GetId ()))
560- {
561533 ClearBuffs (player); // Check to revert player back to normal - Moving this here fixed logout and login while in instance buff and debuff issues
562- }
563534 else
564535 {
565536 std::ostringstream ss;
@@ -568,9 +539,7 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
568539
569540 // Check for an existing No XP Gain flag - other mod compatibility
570541 if (player->HasFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN))
571- {
572542 SolocraftNoXPFlag = 1 ;
573- }
574543
575544 // If a player is too high level for dungeon don't buff but if in a group will count towards the group offset balancing.
576545 if (player->GetLevel () <= dunLevel + SolocraftLevelDiff)
@@ -589,9 +558,7 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
589558
590559 // Disable player XP gain if debuff applied
591560 if (!player->HasFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN) && SolocraftXPBalEnabled)
592- {
593561 player->SetFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN);
594- }
595562 }
596563 else
597564 {
@@ -610,16 +577,12 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
610577 {
611578 SoloCraftXPMod = 0 ;
612579 if (!player->HasFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN) && SolocraftXPBalEnabled)
613- {
614580 player->SetFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN);
615- }
616581 }
617582
618583 // Check XP modifier for over max limit and adjust
619584 if (SoloCraftXPMod > 1 )
620- {
621585 SoloCraftXPMod = 1.0 ;
622- }
623586 }
624587
625588 // Check Database for a current dungeon entry
@@ -631,9 +594,7 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
631594 {
632595 // Check for Dungeon to Dungeon Transfer and remove old buff
633596 if (result)
634- {
635597 player->HandleStatModifier (UnitMods (UNIT_MOD_STAT_START + i), TOTAL_PCT, (*result)[1 ].Get <float >() * (*result)[4 ].Get <float >(), false );
636- }
637598 // Buff the player
638599 // Unitmods enum UNIT_MOD_STAT_START defined in Unit.h line 391
639600 player->HandleStatModifier (UnitMods (UNIT_MOD_STAT_START + i), TOTAL_PCT, difficulty * SoloCraftStatsMult, true );
@@ -678,9 +639,7 @@ class SolocraftPlayerInstanceHandler : public PlayerScript
678639 {
679640 SoloCraftXPMod = 0 ;
680641 if (!player->HasFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN))
681- {
682642 player->SetFlag (PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN);
683- }
684643 }
685644
686645 // Announcements
0 commit comments