Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From ce524527ff819739112cfca7ed5334fc2a0d25dc Mon Sep 17 00:00:00 2001
- From: Dany <Kaiosown@gmail.com>
- Date: Wed, 27 Jun 2012 00:09:13 +0200
- Subject: [PATCH] Script/Command: Implement Warp
- based on @LilleCarl
- ---
- src/server/game/Scripting/ScriptLoader.cpp | 2 +
- src/server/scripts/Commands/CMakeLists.txt | 1 +
- src/server/scripts/Commands/cs_warp.cpp | 98 ++++++++++++++++++++++++++++
- src/server/shared/Common.h | 4 ++
- 4 files changed, 105 insertions(+)
- create mode 100644 src/server/scripts/Commands/cs_warp.cpp
- diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
- index 3ca7539..1263371 100755
- --- a/src/server/game/Scripting/ScriptLoader.cpp
- +++ b/src/server/game/Scripting/ScriptLoader.cpp
- @@ -65,6 +65,7 @@
- void AddSC_server_commandscript();
- void AddSC_titles_commandscript();
- void AddSC_wp_commandscript();
- +void AddSC_warp_commandscript();
- void AddSC_character_commandscript();
- #ifdef SCRIPTS
- @@ -679,6 +680,7 @@ void AddCommandScripts()
- AddSC_tele_commandscript();
- AddSC_server_commandscript();
- AddSC_titles_commandscript();
- + AddSC_warp_commandscript();
- AddSC_wp_commandscript();
- AddSC_character_commandscript();
- }
- diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
- index 268d71a..cb222ba 100644
- --- a/src/server/scripts/Commands/CMakeLists.txt
- +++ b/src/server/scripts/Commands/CMakeLists.txt
- @@ -33,6 +33,7 @@ set(scripts_STAT_SRCS
- Commands/cs_vip.cpp
- Commands/cs_titles.cpp
- Commands/cs_wp.cpp
- + Commands/cs_warp.cpp
- # Commands/cs_lookup.cpp
- # Commands/cs_pdump.cpp
- # Commands/cs_guild.cpp
- diff --git a/src/server/scripts/Commands/cs_warp.cpp b/src/server/scripts/Commands/cs_warp.cpp
- new file mode 100644
- index 0000000..62c425e
- --- /dev/null
- +++ b/src/server/scripts/Commands/cs_warp.cpp
- @@ -0,0 +1,98 @@
- +#include "ScriptMgr.h"
- +#include "Chat.h"
- +#include "MapManager.h"
- +
- +class warp_commandscript : public CommandScript
- +{
- +public:
- + warp_commandscript() : CommandScript("warp_commandscript") { }
- +
- + ChatCommand* GetCommands() const
- + {
- + static ChatCommand warpCommandTable[] =
- + {
- + { "warp", SEC_ADMINISTRATOR, true, &HandleWarpCommand, "", NULL },
- + { NULL, 0, false, NULL, "", NULL }
- + };
- + static ChatCommand commandTable[] =
- + {
- + { "ashen", SEC_ADMINISTRATOR, true, NULL, "", warpCommandTable },
- + { NULL, 0, false, NULL, "", NULL }
- + };
- + return commandTable;
- + }
- +
- + static bool HandleWarpCommand(ChatHandler* handler, char const* args)
- + {
- + if (!*args)
- + return false;
- +
- + Player* player = handler->GetSession()->GetPlayer();
- +
- + char* arg1 = strtok((char*)args, " ");
- + char* arg2 = strtok(NULL, " ");
- +
- + if (!arg1 || !arg2)
- + return false;
- +
- + char dir = arg1[0];
- + float value = float(atof(arg2));
- + float x = player->GetPositionX();
- + float y = player->GetPositionY();
- + float z = player->GetPositionZ();
- + float o = player->GetOrientation();
- + uint32 mapid = player->GetMapId();
- + Map const* map = sMapMgr->CreateBaseMap(mapid);
- + z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
- +
- + switch (dir)
- + {
- + case 'l': // left
- + {
- + x = x + cos(o+(M_PI/2))*value;
- + y = y + sin(o+(M_PI/2))*value;
- +
- + player->TeleportTo(mapid, x, y, z, o);
- + }
- + break;
- + case 'r': // right
- + {
- + x = x + cos(o-(M_PI/2))*value;
- + y = y + sin(o-(M_PI/2))*value;
- +
- + player->TeleportTo(mapid, x, y, z, o);
- + }
- + break;
- + case 'f': // forward
- + {
- + x = x + cosf(o)*value;
- + y = y + sinf(o)*value;
- +
- + player->TeleportTo(mapid, x, y, z, o);
- + }
- + break;
- + case 'u': // up
- + {
- + player->TeleportTo(mapid, x, y, z + value, o);
- + }
- + break;
- + case 'd': // down
- + {
- + player->TeleportTo(mapid, x, y, z - value, o);
- + }
- + break;
- + case 'o': //orientation
- + {
- + o = MapManager::NormalizeOrientation((value * M_PI_F/180.0f)+ o);
- +
- + player->TeleportTo(mapid, x, y, z, o);
- + }
- + break;
- + }
- + return true;
- + };
- +};
- +void AddSC_warp_commandscript()
- +{
- + new warp_commandscript();
- +}
- \ No newline at end of file
- diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
- index 259c60a..a54f7b0 100755
- --- a/src/server/shared/Common.h
- +++ b/src/server/shared/Common.h
- @@ -202,6 +202,10 @@ enum LocaleConstant
- #define M_PI 3.14159265358979323846f
- #endif
- +#ifndef M_PI_F
- +# define M_PI_F float(M_PI)
- +#endif
- +
- #define MAX_QUERY_LEN 32*1024
- #define TRINITY_GUARD(MUTEX, LOCK) \
- --
- 1.7.10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement