Skip to content

Instantly share code, notes, and snippets.

@callmephil
Last active November 16, 2023 15:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save callmephil/6bb933fdf772119c164b6f05b6369287 to your computer and use it in GitHub Desktop.
Save callmephil/6bb933fdf772119c164b6f05b6369287 to your computer and use it in GitHub Desktop.
[C++] Dungeon And Raid Dynamic Resurrection
diff --git a/src/server/game/Custom/DynamicResurrection/DynamicRes.cpp b/src/server/game/Custom/DynamicResurrection/DynamicRes.cpp
new file mode 100644
index 0000000000..7c9b42ae53
--- /dev/null
+++ b/src/server/game/Custom/DynamicResurrection/DynamicRes.cpp
@@ -0,0 +1,32 @@
+/* Copyright
+Author : Callmephil
+Version : 3.3.5 / 4.3.4
+Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
+Updated : 9/9/2018
+*/
+
+#include "DynamicRes.h"
+
+bool DynamicRes::IsInDungeonOrRaid(Player* player)
+{
+ if (sMapStore.LookupEntry(player->GetMapId())->Instanceable())
+ return true; // boolean need to return to a value
+ return false;
+}
+
+bool DynamicRes::CheckForSpawnPoint(Player* player)
+{
+ // Find Nearest Creature And Teleport.
+ if (Creature* creature = player->FindNearestCreature(CREATURE_ENTRY, DISTANCE_CHECK_RANGE))
+ return true;
+ return false;
+}
+
+void DynamicRes::DynamicResurrection(Player* player)
+{
+ // Find Nearest Creature And Teleport.
+ if (Creature* creature = player->FindNearestCreature(CREATURE_ENTRY, DISTANCE_CHECK_RANGE))
+ player->TeleportTo(player->GetMapId(), creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), 1);
+ // Revive Player with 70 %
+ player->ResurrectPlayer(0.7f);
+}
diff --git a/src/server/game/Custom/DynamicResurrection/DynamicRes.h b/src/server/game/Custom/DynamicResurrection/DynamicRes.h
new file mode 100644
index 0000000000..d214004fd6
--- /dev/null
+++ b/src/server/game/Custom/DynamicResurrection/DynamicRes.h
@@ -0,0 +1,39 @@
+/* Copyright
+Author : Callmephil
+Version : 3.3.5 / 4.3.4
+Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
+UPDATE : 9/9/2018
+*/
+
+#ifndef H_DYNAMIC_RES_
+#define H_DYNAMIC_RES_
+
+#include "Player.h"
+#include "DBCStores.h"
+
+class Player;
+
+enum WAYPOINT_CREATURE
+{
+ CREATURE_ENTRY = 1, // change this as you wishes
+ DISTANCE_CHECK_RANGE = 1000, // change this (in yards)
+ SPAWN_TIMER_TWO_HOURS = 1200000, // change this (in miliseconds)
+};
+
+class TC_GAME_API DynamicRes
+{
+public:
+ static DynamicRes* instance()
+ {
+ static DynamicRes instance;
+ return &instance;
+ }
+
+ bool IsInDungeonOrRaid(Player* player);
+ bool CheckForSpawnPoint(Player* player);
+ void DynamicResurrection(Player* player);
+};
+
+#define sDynRes DynamicRes::instance()
+
+#endif
\ No newline at end of file
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index cbd361d2e0..90562715e5 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -95,6 +95,7 @@
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
+#include "DynamicRes.h"
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
@@ -4980,13 +4981,18 @@ void Player::RepopAtGraveyard()
// and don't show spirit healer location
if (ClosestGrave)
{
- TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
- if (isDead()) // not send if alive, because it used in TeleportTo()
+ if (sDynRes->IsInDungeonOrRaid(this) && sDynRes->CheckForSpawnPoint(this))
+ sDynRes->DynamicResurrection(this);
+ else
{
- WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
- data << ClosestGrave->map_id;
- data << TaggedPosition<Position::XYZ>(ClosestGrave->x, ClosestGrave->y, ClosestGrave->z);
- SendDirectMessage(&data);
+ TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
+ if (isDead()) // not send if alive, because it used in TeleportTo()
+ {
+ WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // show spirit healer position on minimap
+ data << ClosestGrave->map_id;
+ data << TaggedPosition<Position::XYZ>(ClosestGrave->x, ClosestGrave->y, ClosestGrave->z);
+ SendDirectMessage(&data);
+ }
}
}
else if (GetPositionZ() < GetMap()->GetMinHeight(GetPositionX(), GetPositionY()))
diff --git a/src/server/scripts/Custom/DR_Spawn.cpp b/src/server/scripts/Custom/DR_Spawn.cpp
new file mode 100644
index 0000000000..3f2ad61f67
--- /dev/null
+++ b/src/server/scripts/Custom/DR_Spawn.cpp
@@ -0,0 +1,25 @@
+/* Copyright
+Author : Callmephil
+Version : 3.3.5 / 4.3.4
+Dynamic Resurrection is a simple script that add a "Resurrection Waypoint" near the latest boss killed in dungeon or raid. for faster Resurrection.
+Update : 9/9/2018
+*/
+
+#include "DynamicRes.h"
+
+class Dynamic_Resurrections : public PlayerScript
+{
+public:
+ Dynamic_Resurrections() : PlayerScript("Dynamic_Resurrections") {}
+
+ void OnCreatureKill(Player* player, Creature* boss) override
+ {
+ if (sDynRes->IsInDungeonOrRaid(player) && (boss->isWorldBoss() || boss->IsDungeonBoss()))
+ player->SummonCreature(CREATURE_ENTRY, boss->GetPositionX(), boss->GetPositionY(), boss->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, SPAWN_TIMER_TWO_HOURS);
+ }
+};
+
+void AddSC_Dynamic_Resurrections()
+{
+ new Dynamic_Resurrections();
+}
\ No newline at end of file
diff --git a/src/server/scripts/Custom/custom_script_loader.cpp b/src/server/scripts/Custom/custom_script_loader.cpp
index 87e53ae554..79a4107c4d 100644
--- a/src/server/scripts/Custom/custom_script_loader.cpp
+++ b/src/server/scripts/Custom/custom_script_loader.cpp
@@ -17,9 +17,11 @@
// This is where scripts' loading functions should be declared:
+void AddSC_Dynamic_Resurrections();
// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
void AddCustomScripts()
{
+ AddSC_Dynamic_Resurrections();
}
@Aokromes
Copy link

hey @callmephil i must say i like this script a lot, i was thinking if you change it to conf and made it disabled by default it may be merged into trinitycore repository (3.3.5a branch).

@Aokromes
Copy link

Also, i wonder if you can disable release button on raids while you are on combat with boss to stop exploits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment