Aokromes

Dynamic Resurrection

Jun 20th, 2017
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.57 KB | None | 0 0
  1. diff --git a/src/server/game/Custom/DynamicResurrection/DynamicResurrection.cpp b/src/server/game/Custom/DynamicResurrection/DynamicResurrection.cpp
  2. new file mode 100644
  3. index 0000000..f3ec129
  4. --- /dev/null
  5. +++ b/src/server/game/Custom/DynamicResurrection/DynamicResurrection.cpp
  6. @@ -0,0 +1,32 @@
  7. +/* Copyright
  8. +Author : Callmephil
  9. +Version : 3.3.5 / 4.3.4
  10. +Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
  11. +*/
  12. +
  13. +#include "DynamicResurrection.h"
  14. +
  15. +bool Dynamic_Resurrection::IsInDungeonOrRaid(Player* player)
  16. +{
  17. +    if (sMapStore.LookupEntry(player->GetMapId())->Instanceable())
  18. +        return true; // boolean need to return to a value
  19. +    return false;
  20. +}
  21. +
  22. +bool Dynamic_Resurrection::CheckForSpawnPoint(Player* player)
  23. +{
  24. +    // Find Nearest Creature And Teleport.
  25. +    if (Creature* creature = player->FindNearestCreature(C_Resurrection_ENTRY, C_DISTANCE_CHECK_RANGE))
  26. +        return true;
  27. +    return false;
  28. +}
  29. +
  30. +void Dynamic_Resurrection::DynamicResurrection(Player* player)
  31. +{
  32. +    // Find Nearest Creature And Teleport.
  33. +    if (Creature* creature = player->FindNearestCreature(C_Resurrection_ENTRY, C_DISTANCE_CHECK_RANGE))
  34. +        player->TeleportTo(player->GetMapId(), creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), 1);
  35. +    // Revive Player with 70 %
  36. +    player->ResurrectPlayer(0.7);
  37. +    player->SpawnCorpseBones();
  38. +}
  39. \ No newline at end of file
  40. diff --git a/src/server/game/Custom/DynamicResurrection/DynamicResurrection.h b/src/server/game/Custom/DynamicResurrection/DynamicResurrection.h
  41. new file mode 100644
  42. index 0000000..d945ad4
  43. --- /dev/null
  44. +++ b/src/server/game/Custom/DynamicResurrection/DynamicResurrection.h
  45. @@ -0,0 +1,37 @@
  46. +/* Copyright
  47. +Author : Callmephil
  48. +Version : 3.3.5 / 4.3.4
  49. +Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
  50. +*/
  51. +
  52. +#ifndef DYNAMIC_RESURRECTION
  53. +#define DYNAMIC_RESURRECTION
  54. +
  55. +#include "Player.h"
  56. +#include "DBCStores.h"
  57. +
  58. +class Player;
  59. +
  60. +enum WAYPOINT_CREATURE
  61. +{
  62. +    C_Resurrection_ENTRY = 1, // change this as you wishes
  63. +    C_DISTANCE_CHECK_RANGE = 1000, // change this (in yards)
  64. +    C_SPAWN_TIMER_TWO_HOURS = 1200000, // change this (in miliseconds)
  65. +};
  66. +
  67. +class TC_GAME_API Dynamic_Resurrection
  68. +{
  69. +public:
  70. +    static Dynamic_Resurrection* instance()
  71. +    {
  72. +        static Dynamic_Resurrection instance;
  73. +        return &instance;
  74. +    }
  75. +
  76. +    bool IsInDungeonOrRaid(Player* player);
  77. +    bool CheckForSpawnPoint(Player* player);
  78. +    void DynamicResurrection(Player* player);
  79. +};
  80. +#define sDynRes Dynamic_Resurrection::instance()
  81. +
  82. +#endif
  83. \ No newline at end of file
  84. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  85. index b618200..89c9975 100644
  86. --- a/src/server/game/Entities/Player/Player.cpp
  87. +++ b/src/server/game/Entities/Player/Player.cpp
  88. @@ -81,6 +81,7 @@
  89.  #include "WorldSession.h"
  90.  #include "GameObjectAI.h"
  91.  #include "Transmogrification.h"
  92. +#include "DynamicResurrection.h"
  93.  
  94.  #define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
  95.  
  96. @@ -5124,16 +5125,21 @@ void Player::RepopAtGraveyard()
  97.      // and don't show spirit healer location
  98.      if (ClosestGrave)
  99.      {
  100. -        TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
  101. -        if (isDead())                                        // not send if alive, because it used in TeleportTo()
  102. -        {
  103. -            WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4);  // show spirit healer position on minimap
  104. -            data << ClosestGrave->map_id;
  105. -            data << ClosestGrave->x;
  106. -            data << ClosestGrave->y;
  107. -            data << ClosestGrave->z;
  108. -            GetSession()->SendPacket(&data);
  109. -        }
  110. +        if (sDynRes->IsInDungeonOrRaid(this) && sDynRes->CheckForSpawnPoint(this))
  111. +            sDynRes->DynamicResurrection(this);
  112. +        else
  113. +        {
  114. +            TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
  115. +            if (isDead())                                        // not send if alive, because it used in TeleportTo()
  116. +                {
  117. +                        WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4);  // show spirit healer position on minimap
  118. +                        data << ClosestGrave->map_id;
  119. +                        data << ClosestGrave->x;
  120. +                        data << ClosestGrave->y;
  121. +                        data << ClosestGrave->z;
  122. +                        GetSession()->SendPacket(&data);
  123. +                }
  124. +            }
  125.      }
  126.      else if (GetPositionZ() < GetMap()->GetMinHeight(GetPositionX(), GetPositionY()))
  127.          TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation());
  128. diff --git a/src/server/scripts/Custom/DynamicRessurection/DynamicReurrections.cpp b/src/server/scripts/Custom/DynamicRessurection/DynamicReurrections.cpp
  129. new file mode 100644
  130. index 0000000..435de9e
  131. --- /dev/null
  132. +++ b/src/server/scripts/Custom/DynamicRessurection/DynamicReurrections.cpp
  133. @@ -0,0 +1,24 @@
  134. +/* Copyright
  135. +Author : Callmephil
  136. +Version : 3.3.5 / 4.3.4
  137. +Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
  138. +*/
  139. +
  140. +#include "DynamicResurrection.h"
  141. +
  142. +class Dynamic_Resurrections : public PlayerScript
  143. +{
  144. +public:
  145. +    Dynamic_Resurrections() : PlayerScript("Dynamic_Resurrections") {}
  146. +
  147. +    void OnCreatureKill(Player* player, Creature* boss) override
  148. +    {
  149. +        if (sDynRes->IsInDungeonOrRaid(player) && (boss->isWorldBoss() || boss->IsDungeonBoss()))
  150. +            player->SummonCreature(C_RESURECTION_ENTRY, boss->GetPositionX(), boss->GetPositionY(), boss->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, C_SPAWN_TIMER_TWO_HOURS);
  151. +    }
  152. +};
  153. +
  154. +void AddSC_Dynamic_Resurrections()
  155. +{
  156. +    new Dynamic_Resurrections();
  157. +}
  158. \ No newline at end of file
  159. diff --git a/src/server/scripts/Custom/custom_script_loader.cpp b/src/server/scripts/Custom/custom_script_loader.cpp
  160. index dd4b5e9..fa143d7 100644
  161. --- a/src/server/scripts/Custom/custom_script_loader.cpp
  162. +++ b/src/server/scripts/Custom/custom_script_loader.cpp
  163. @@ -17,6 +17,7 @@
  164.  // 13
  165.  // 14
  166.  // 15
  167. +void AddSC_Dynamic_Resurrections();
  168.  // 16
  169.  // 17
  170.  // 18
  171. @@ -47,6 +47,7 @@
  172.      // 15
  173.      // 16
  174.      // 17
  175. +    AddSC_Dynamic_Resurrections();
  176.      // 18
  177.      // 19
  178.      // 20
Advertisement
Add Comment
Please, Sign In to add comment