diff --git a/.hgsub b/.hgsub deleted file mode 100644 index d28397639..000000000 --- a/.hgsub +++ /dev/null @@ -1 +0,0 @@ -database = https://bitbucket.org/_hellground/database diff --git a/.hgsubstate b/.hgsubstate deleted file mode 100644 index f4e23870a..000000000 --- a/.hgsubstate +++ /dev/null @@ -1 +0,0 @@ -dcd9aae66de38167c3939b22a35953dad8979d60 database diff --git a/CMakeLists.txt b/CMakeLists.txt index 248438821..26aedaa0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,13 @@ endif() # ) # endif() +if(NOT WIN32) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (GCC_VERSION VERSION_LESS 4.7) + message(FATAL_ERROR "Your GCC have to be >= 4.7") + endif() +endif() + # Output description of this script message( "\nThis script builds the HellGround project server. @@ -64,12 +71,14 @@ message( PREFIX: Path where the server should be installed to PCH : Use precompiled headers DEBUG : Debug mode + NOT_USE_ELUNA_HOOKS: Do not use Elunas HookMgr CLI : Build with CLI (default) TBB_USE_EXTERNAL: Use external TBB library instead of built in (default) ACE_USE_EXTERNAL: Use external ACE library instead of built in (default) USE_STD_MALLOC : Use standard malloc instead of TBB LARGE_CELL : Use large cell size ADD_COMPILE_F : Add additional compile flags (default) + ADD_OPTI_F : Add additional compile optimization flags ADD_MATH_F : Add additional compile math flags ADD_GPROF_F : Add additional compile gprof flag MAP_UPDATE_DIFF_INFO: Used for gathering info about execution time for specific parts of Map::Update @@ -115,6 +124,7 @@ option(TBB_USE_EXTERNAL "Use external TBB" 1) option(USE_STD_MALLOC "Use standard malloc instead of TBB" 0) option(ACE_USE_EXTERNAL "Use external ACE" 1) option(LARGE_CELL "Use large cell size" 0) +option(NOT_USE_ELUNA_HOOKS "Do not use Elunas HookMgr" 1) option(ADD_COMPILE_F "Add additional compile flags" 1) option(ADD_MATH_F "Add additional compile math flags" 0) option(ADD_GPROF_F "Add additional compile gprof flag" 0) @@ -219,8 +229,6 @@ if(UNIX) find_package(Readline REQUIRED) find_package(MySQL REQUIRED) find_package(ZLIB REQUIRED) - set(Boost_USE_MULTITHREADED ON) - find_package(Boost 1.34.0 COMPONENTS regex REQUIRED) endif() # Add uninstall script and target @@ -293,10 +301,11 @@ endif(LARGE_CELL) message("") if(PLATFORM MATCHES X86) -set(ADDITIONAL_COMPILE_FLAGS "-std=c++0x -ggdb -O2 -msse3 -fomit-frame-pointer -fno-delete-null-pointer-checks -ftracer -fno-strict-aliasing -funroll-loops -m32 -pipe -DFD_SETSIZE=4096 -frename-registers") + set(ADDITIONAL_COMPILE_FLAGS "-std=c++0x -ggdb -O2 -msse3 -fno-delete-null-pointer-checks -ftracer -fno-strict-aliasing -funroll-loops -m32 -pipe -DFD_SETSIZE=4096") else() -set(ADDITIONAL_COMPILE_FLAGS "-std=c++0x -ggdb -O2 -msse3 -fomit-frame-pointer -fno-delete-null-pointer-checks -ftracer -fno-strict-aliasing -funroll-loops -m64 -pipe -DFD_SETSIZE=4096 -frename-registers") + set(ADDITIONAL_COMPILE_FLAGS "-std=c++0x -ggdb -O2 -msse3 -fno-delete-null-pointer-checks -ftracer -fno-strict-aliasing -funroll-loops -m64 -pipe -DFD_SETSIZE=4096") endif() +set(ADDITIONAL_OPTIMIZE_FLAGS "-fomit-frame-pointer -frename-registers") set(ADDITIONAL_MATH_FLAGS " -ffast-math -fno-math-errno -funsafe-math-optimizations") set(ADDITIONAL_GPROF_FLAGS " -pg") @@ -408,6 +417,10 @@ if(ADD_COMPILE_F) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDITIONAL_COMPILE_FLAGS}") endif() +if(ADD_OPTI_F) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDITIONAL_OPTIMIZE_FLAGS}") +endif() + if(ADD_MATH_F) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDITIONAL_MATH_FLAGS}") endif() @@ -442,7 +455,11 @@ if(WIN32) set(DEFINITIONS_RELEASE ${DEFINITIONS_RELEASE} _CRT_SECURE_NO_WARNINGS) endif() if(USE_STD_MALLOC) - set(DEFINITIONS ${DEFINITIONS} USE_STANDARD_MALLOC) + set(DEFINITIONS ${DEFINITIONS} USE_STANDARD_MALLOC) +endif() + +if(NOT_USE_ELUNA_HOOKS) + set(DEFINITIONS ${DEFINITIONS} NOT_USE_ELUNA_HOOKS) endif() set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DEFINITIONS}") diff --git a/README b/README deleted file mode 100644 index e1d1345bc..000000000 --- a/README +++ /dev/null @@ -1,5 +0,0 @@ -################################################# -# # -# HellGound.pl - World of Warcraft TBC server # -# It is over 7000 ! # -################################################# \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 000000000..b5fca1245 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +![logox.png](https://bitbucket.org/repo/7EMrE/images/632678489-logox.png) + +###################### +# HellGroundCore # +###################### + +World of Warcraft TBC server + +* Repository: http://tbc-core.hellground.net +* Wiki: http://tbc-wiki.hellground.net +* Site: https://hellground.net + +Welcome! diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index ec7aa94c2..9b532af17 100755 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -16,10 +16,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -if(NOT TBB_USE_EXTERNAL) +if(NOT TBB_USE_EXTERNAL AND NOT USE_STD_MALLOC) add_subdirectory(tbb) endif() +add_subdirectory(lualib) add_subdirectory(g3dlite) add_subdirectory(recastnavigation) add_subdirectory(src) diff --git a/dep/lualib/CMakeLists.txt b/dep/lualib/CMakeLists.txt new file mode 100644 index 000000000..6b0e8b9cc --- /dev/null +++ b/dep/lualib/CMakeLists.txt @@ -0,0 +1,63 @@ +# +# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +set(LIBRARY_NAME lualib) + +set(LIBRARY_SRCS + lapi.c + lauxlib.c + lbaselib.c + lbitlib.c + lcode.c + lcorolib.c + lctype.c + ldblib.c + ldebug.c + ldo.c + ldump.c + lfunc.c + lgc.c + linit.c + liolib.c + llex.c + lmathlib.c + lmem.c + loadlib.c + lobject.c + lopcodes.c + loslib.c + lparser.c + lstate.c + lstring.c + lstrlib.c + ltable.c + ltablib.c + ltm.c + lua.c + lundump.c + lvm.c + lzio.c +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_library(${LIBRARY_NAME} STATIC + ${LIBRARY_SRCS} +) \ No newline at end of file diff --git a/dep/lualib/lapi.c b/dep/lualib/lapi.c new file mode 100644 index 000000000..59b91c082 --- /dev/null +++ b/dep/lualib/lapi.c @@ -0,0 +1,1281 @@ +/* +** $Id: lapi.c,v 2.164 2012/06/08 15:14:04 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$LuaVersion: " LUA_COPYRIGHT " $" + "$LuaAuthors: " LUA_AUTHORS " $"; + + +/* value at a non-valid index */ +#define NONVALIDVALUE cast(TValue *, luaO_nilobject) + +/* corresponding test */ +#define isvalid(o) ((o) != luaO_nilobject) + +#define api_checkvalidindex(L, i) api_check(L, isvalid(i), "invalid index") + + +static TValue *index2addr (lua_State *L, int idx) { + CallInfo *ci = L->ci; + if (idx > 0) { + TValue *o = ci->func + idx; + api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index"); + if (o >= L->top) return NONVALIDVALUE; + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); + return L->top + idx; + } + else if (idx == LUA_REGISTRYINDEX) + return &G(L)->l_registry; + else { /* upvalues */ + idx = LUA_REGISTRYINDEX - idx; + api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); + if (ttislcf(ci->func)) /* light C function? */ + return NONVALIDVALUE; /* it has no upvalues */ + else { + CClosure *func = clCvalue(ci->func); + return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE; + } + } +} + + +/* +** to be called by 'lua_checkstack' in protected mode, to grow stack +** capturing memory errors +*/ +static void growstack (lua_State *L, void *ud) { + int size = *(int *)ud; + luaD_growstack(L, size); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res; + CallInfo *ci = L->ci; + lua_lock(L); + if (L->stack_last - L->top > size) /* stack large enough? */ + res = 1; /* yes; check is OK */ + else { /* no; need to grow stack */ + int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; + if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */ + res = 0; /* no */ + else /* try to grow stack */ + res = (luaD_rawrunprotected(L, &growstack, &size) == LUA_OK); + } + if (res && ci->top < L->top + size) + ci->top = L->top + size; /* adjust frame top */ + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to), "moving among independent states"); + api_check(from, to->ci->top - to->top >= n, "not enough elements to move"); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API const lua_Number *lua_version (lua_State *L) { + static const lua_Number version = LUA_VERSION_NUM; + if (L == NULL) return &version; + else return G(L)->version; +} + + + +/* +** basic stack manipulation +*/ + + +/* +** convert an acceptable stack index into an absolute index +*/ +LUA_API int lua_absindex (lua_State *L, int idx) { + return (idx > 0 || idx <= LUA_REGISTRYINDEX) + ? idx + : cast_int(L->top - L->ci->func + idx); +} + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - (L->ci->func + 1)); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + StkId func = L->ci->func; + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); + while (L->top < (func + 1) + idx) + setnilvalue(L->top++); + L->top = (func + 1) + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2addr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2addr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +static void moveto (lua_State *L, TValue *fr, int idx) { + TValue *to = index2addr(L, idx); + api_checkvalidindex(L, to); + setobj(L, to, fr); + if (idx < LUA_REGISTRYINDEX) /* function upvalue? */ + luaC_barrier(L, clCvalue(L->ci->func), fr); + /* LUA_REGISTRYINDEX does not need gc barrier + (collector revisits it before finishing collection) */ +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + lua_lock(L); + api_checknelems(L, 1); + moveto(L, L->top - 1, idx); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { + TValue *fr; + lua_lock(L); + fr = index2addr(L, fromidx); + api_checkvalidindex(L, fr); + moveto(L, fr, toidx); + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2addr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (isvalid(o) ? ttypenv(o) : LUA_TNONE); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return ttypename(t); +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (ttislcf(o) || (ttisCclosure(o))); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2addr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2addr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2addr(L, index1); + StkId o2 = index2addr(L, index2); + return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0; +} + + +LUA_API void lua_arith (lua_State *L, int op) { + StkId o1; /* 1st operand */ + StkId o2; /* 2nd operand */ + lua_lock(L); + if (op != LUA_OPUNM) /* all other operations expect two operands */ + api_checknelems(L, 2); + else { /* for unary minus, add fake 2nd operand */ + api_checknelems(L, 1); + setobjs2s(L, L->top, L->top - 1); + L->top++; + } + o1 = L->top - 2; + o2 = L->top - 1; + if (ttisnumber(o1) && ttisnumber(o2)) { + changenvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2))); + } + else + luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD)); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { + StkId o1, o2; + int i = 0; + lua_lock(L); /* may call tag method */ + o1 = index2addr(L, index1); + o2 = index2addr(L, index2); + if (isvalid(o1) && isvalid(o2)) { + switch (op) { + case LUA_OPEQ: i = equalobj(L, o1, o2); break; + case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; + case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; + default: api_check(L, 0, "invalid option"); + } + } + lua_unlock(L); + return i; +} + + +LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum) { + TValue n; + const TValue *o = index2addr(L, idx); + if (tonumber(o, &n)) { + if (isnum) *isnum = 1; + return nvalue(o); + } + else { + if (isnum) *isnum = 0; + return 0; + } +} + + +LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) { + TValue n; + const TValue *o = index2addr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + if (isnum) *isnum = 1; + return res; + } + else { + if (isnum) *isnum = 0; + return 0; + } +} + + +LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *isnum) { + TValue n; + const TValue *o = index2addr(L, idx); + if (tonumber(o, &n)) { + lua_Unsigned res; + lua_Number num = nvalue(o); + lua_number2unsigned(res, num); + if (isnum) *isnum = 1; + return res; + } + else { + if (isnum) *isnum = 0; + return 0; + } +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2addr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2addr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2addr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_rawlen (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttypenv(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + if (ttislcf(o)) return fvalue(o); + else if (ttisCclosure(o)) + return clCvalue(o)->f; + else return NULL; /* not a C function */ +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttypenv(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TLCL: return clLvalue(o); + case LUA_TCCL: return clCvalue(o); + case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + luai_checknum(L, L->top, + luaG_runerror(L, "C API - attempt to push a signaling NaN")); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushunsigned (lua_State *L, lua_Unsigned u) { + lua_Number n; + lua_lock(L); + n = lua_unsigned2number(u); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { + TString *ts; + lua_lock(L); + luaC_checkGC(L); + ts = luaS_newlstr(L, s, len); + setsvalue2s(L, L->top, ts); + api_incr_top(L); + lua_unlock(L); + return getstr(ts); +} + + +LUA_API const char *lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) { + lua_pushnil(L); + return NULL; + } + else { + TString *ts; + lua_lock(L); + luaC_checkGC(L); + ts = luaS_new(L, s); + setsvalue2s(L, L->top, ts); + api_incr_top(L); + lua_unlock(L); + return getstr(ts); + } +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + lua_lock(L); + if (n == 0) { + setfvalue(L->top, fn); + } + else { + Closure *cl; + api_checknelems(L, n); + api_check(L, n <= MAXUPVAL, "upvalue index too large"); + luaC_checkGC(L); + cl = luaF_newCclosure(L, n); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top + n); + setclCvalue(L, L->top, cl); + } + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_getglobal (lua_State *L, const char *var) { + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt; /* global table */ + lua_lock(L); + gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + setsvalue2s(L, L->top++, luaS_new(L, var)); + luaV_gettable(L, gt, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_checkvalidindex(L, t); + setsvalue2s(L, L->top, luaS_new(L, k)); + api_incr_top(L); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2s(L, L->top, luaH_getint(hvalue(t), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawgetp (lua_State *L, int idx, const void *p) { + StkId t; + TValue k; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setpvalue(&k, cast(void *, p)); + setobj2s(L, L->top, luaH_get(hvalue(t), &k)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + Table *t; + lua_lock(L); + luaC_checkGC(L); + t = luaH_new(L); + sethvalue(L, L->top, t); + api_incr_top(L); + if (narray > 0 || nrec > 0) + luaH_resize(L, t, narray, nrec); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2addr(L, objindex); + switch (ttypenv(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttypenv(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getuservalue (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2addr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttisuserdata(o), "userdata expected"); + if (uvalue(o)->env) { + sethvalue(L, L->top, uvalue(o)->env); + } else + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_setglobal (lua_State *L, const char *var) { + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt; /* global table */ + lua_lock(L); + api_checknelems(L, 1); + gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + setsvalue2s(L, L->top++, luaS_new(L, var)); + luaV_settable(L, gt, L->top - 1, L->top - 2); + L->top -= 2; /* pop value and key */ + lua_unlock(L); +} + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2addr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + lua_lock(L); + api_checknelems(L, 1); + t = index2addr(L, idx); + api_checkvalidindex(L, t); + setsvalue2s(L, L->top++, luaS_new(L, k)); + luaV_settable(L, t, L->top - 1, L->top - 2); + L->top -= 2; /* pop value and key */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + invalidateTMcache(hvalue(t)); + luaC_barrierback(L, gcvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId t; + lua_lock(L); + api_checknelems(L, 1); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + luaH_setint(L, hvalue(t), n, L->top - 1); + luaC_barrierback(L, gcvalue(t), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { + StkId t; + TValue k; + lua_lock(L); + api_checknelems(L, 1); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setpvalue(&k, cast(void *, p)); + setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1); + luaC_barrierback(L, gcvalue(t), L->top - 1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2addr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1), "table expected"); + mt = hvalue(L->top - 1); + } + switch (ttypenv(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrierback(L, gcvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) { + luaC_objbarrier(L, rawuvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + } + break; + } + default: { + G(L)->mt[ttypenv(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API void lua_setuservalue (lua_State *L, int idx) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2addr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttisuserdata(o), "userdata expected"); + if (ttisnil(L->top - 1)) + uvalue(o)->env = NULL; + else { + api_check(L, ttistable(L->top - 1), "table expected"); + uvalue(o)->env = hvalue(L->top - 1); + luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + } + L->top--; + lua_unlock(L); +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ + "results from function overflow current stack size") + + +LUA_API int lua_getctx (lua_State *L, int *ctx) { + if (L->ci->callstatus & CIST_YIELDED) { + if (ctx) *ctx = L->ci->u.c.ctx; + return L->ci->u.c.status; + } + else return LUA_OK; +} + + +LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k) { + StkId func; + lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); + api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ + L->ci->u.c.k = k; /* save continuation */ + L->ci->u.c.ctx = ctx; /* save context */ + luaD_call(L, func, nresults, 1); /* do the call */ + } + else /* no continuation or no yieldable */ + luaD_call(L, func, nresults, 0); /* just do the call */ + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults, 0); +} + + + +LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, + int ctx, lua_CFunction k) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); + api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2addr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */ + c.nresults = nresults; /* do a 'conventional' protected call */ + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + } + else { /* prepare continuation (call is already protected by 'resume') */ + CallInfo *ci = L->ci; + ci->u.c.k = k; /* save continuation */ + ci->u.c.ctx = ctx; /* save context */ + /* save information for error recovery */ + ci->extra = savestack(L, c.func); + ci->u.c.old_allowhook = L->allowhook; + ci->u.c.old_errfunc = L->errfunc; + L->errfunc = func; + /* mark that function may do error recovery */ + ci->callstatus |= CIST_YPCALL; + luaD_call(L, c.func, nresults, 1); /* do the call */ + ci->callstatus &= ~CIST_YPCALL; + L->errfunc = ci->u.c.old_errfunc; + status = LUA_OK; /* if it is here, there were no errors */ + } + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname, const char *mode) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname, mode); + if (status == LUA_OK) { /* no errors? */ + LClosure *f = clLvalue(L->top - 1); /* get newly created function */ + if (f->nupvalues == 1) { /* does it have one upvalue? */ + /* get global table from registry */ + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ + setobj(L, f->upvals[0]->v, gt); + luaC_barrier(L, f->upvals[0], gt); + } + } + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, getproto(o), writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->gcrunning = 0; + break; + } + case LUA_GCRESTART: { + luaE_setdebt(g, 0); + g->gcrunning = 1; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L, 0); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(gettotalbytes(g) >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(gettotalbytes(g) & 0x3ff); + break; + } + case LUA_GCSTEP: { + if (g->gckind == KGC_GEN) { /* generational mode? */ + res = (g->GCestimate == 0); /* true if it will do major collection */ + luaC_forcestep(L); /* do a single step */ + } + else { + lu_mem debt = cast(lu_mem, data) * 1024 - GCSTEPSIZE; + if (g->gcrunning) + debt += g->GCdebt; /* include current debt */ + luaE_setdebt(g, debt); + luaC_forcestep(L); + if (g->gcstate == GCSpause) /* end of cycle? */ + res = 1; /* signal it */ + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETMAJORINC: { + res = g->gcmajorinc; + g->gcmajorinc = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + case LUA_GCISRUNNING: { + res = g->gcrunning; + break; + } + case LUA_GCGEN: { /* change collector to generational mode */ + luaC_changemode(L, KGC_GEN); + break; + } + case LUA_GCINC: { /* change collector to incremental mode */ + luaC_changemode(L, KGC_NORMAL); + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API void lua_len (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + luaV_objlen(L, L->top, t); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, NULL); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val, + GCObject **owner) { + switch (ttype(fi)) { + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + if (!(1 <= n && n <= f->nupvalues)) return NULL; + *val = &f->upvalue[n-1]; + if (owner) *owner = obj2gco(f); + return ""; + } + case LUA_TLCL: { /* Lua closure */ + LClosure *f = clLvalue(fi); + TString *name; + Proto *p = f->p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->upvals[n-1]->v; + if (owner) *owner = obj2gco(f->upvals[n - 1]); + name = p->upvalues[n-1].name; + return (name == NULL) ? "" : getstr(name); + } + default: return NULL; /* not a closure */ + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val = NULL; /* to avoid warnings */ + lua_lock(L); + name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val = NULL; /* to avoid warnings */ + GCObject *owner = NULL; /* to avoid warnings */ + StkId fi; + lua_lock(L); + fi = index2addr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val, &owner); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, owner, L->top); + } + lua_unlock(L); + return name; +} + + +static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { + LClosure *f; + StkId fi = index2addr(L, fidx); + api_check(L, ttisLclosure(fi), "Lua function expected"); + f = clLvalue(fi); + api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); + if (pf) *pf = f; + return &f->upvals[n - 1]; /* get its upvalue pointer */ +} + + +LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { + StkId fi = index2addr(L, fidx); + switch (ttype(fi)) { + case LUA_TLCL: { /* lua closure */ + return *getupvalref(L, fidx, n, NULL); + } + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index"); + return &f->upvalue[n - 1]; + } + default: { + api_check(L, 0, "closure expected"); + return NULL; + } + } +} + + +LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, + int fidx2, int n2) { + LClosure *f1; + UpVal **up1 = getupvalref(L, fidx1, n1, &f1); + UpVal **up2 = getupvalref(L, fidx2, n2, NULL); + *up1 = *up2; + luaC_objbarrier(L, f1, *up2); +} + diff --git a/dep/lualib/lapi.h b/dep/lualib/lapi.h new file mode 100644 index 000000000..aa806c367 --- /dev/null +++ b/dep/lualib/lapi.h @@ -0,0 +1,24 @@ +/* +** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "llimits.h" +#include "lstate.h" + +#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ + "stack overflow");} + +#define adjustresults(L,nres) \ + { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + +#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ + "not enough elements in the stack") + + +#endif diff --git a/dep/lualib/lauxlib.c b/dep/lualib/lauxlib.c new file mode 100644 index 000000000..fdf2da870 --- /dev/null +++ b/dep/lualib/lauxlib.c @@ -0,0 +1,958 @@ +/* +** $Id: lauxlib.c,v 1.244 2012/05/31 20:28:45 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +/* +** {====================================================== +** Traceback +** ======================================================= +*/ + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + + + +/* +** search for 'objidx' in table at index -1. +** return 1 + string at top if find a good name. +*/ +static int findfield (lua_State *L, int objidx, int level) { + if (level == 0 || !lua_istable(L, -1)) + return 0; /* not found */ + lua_pushnil(L); /* start 'next' loop */ + while (lua_next(L, -2)) { /* for each pair in table */ + if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */ + if (lua_rawequal(L, objidx, -1)) { /* found object? */ + lua_pop(L, 1); /* remove value (but keep name) */ + return 1; + } + else if (findfield(L, objidx, level - 1)) { /* try recursively */ + lua_remove(L, -2); /* remove table (but keep name) */ + lua_pushliteral(L, "."); + lua_insert(L, -2); /* place '.' between the two names */ + lua_concat(L, 3); + return 1; + } + } + lua_pop(L, 1); /* remove value */ + } + return 0; /* not found */ +} + + +static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { + int top = lua_gettop(L); + lua_getinfo(L, "f", ar); /* push function */ + lua_pushglobaltable(L); + if (findfield(L, top + 1, 2)) { + lua_copy(L, -1, top + 1); /* move name to proper place */ + lua_pop(L, 2); /* remove pushed values */ + return 1; + } + else { + lua_settop(L, top); /* remove function and global table */ + return 0; + } +} + + +static void pushfuncname (lua_State *L, lua_Debug *ar) { + if (*ar->namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, "function " LUA_QS, ar->name); + else if (*ar->what == 'm') /* main? */ + lua_pushfstring(L, "main chunk"); + else if (*ar->what == 'C') { + if (pushglobalfuncname(L, ar)) { + lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1)); + lua_remove(L, -2); /* remove name */ + } + else + lua_pushliteral(L, "?"); + } + else + lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); +} + + +static int countlevels (lua_State *L) { + lua_Debug ar; + int li = 1, le = 1; + /* find an upper bound */ + while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } + /* do a binary search */ + while (li < le) { + int m = (li + le)/2; + if (lua_getstack(L, m, &ar)) li = m + 1; + else le = m; + } + return le - 1; +} + + +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, + const char *msg, int level) { + lua_Debug ar; + int top = lua_gettop(L); + int numlevels = countlevels(L1); + int mark = (numlevels > LEVELS1 + LEVELS2) ? LEVELS1 : 0; + if (msg) lua_pushfstring(L, "%s\n", msg); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level == mark) { /* too many levels? */ + lua_pushliteral(L, "\n\t..."); /* add a '...' */ + level = numlevels - LEVELS2; /* and skip to last ones */ + } + else { + lua_getinfo(L1, "Slnt", &ar); + lua_pushfstring(L, "\n\t%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + lua_pushliteral(L, " in "); + pushfuncname(L, &ar); + if (ar.istailcall) + lua_pushliteral(L, "\n\t(...tail calls...)"); + lua_concat(L, lua_gettop(L) - top); + } + } + lua_concat(L, lua_gettop(L) - top); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self", ar.name); + } + if (ar.name == NULL) + ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +static int typeerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + typeerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + + +LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { + int en = errno; /* calls to Lua API may change this value */ + if (stat) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (fname) + lua_pushfstring(L, "%s: %s", fname, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +#if !defined(inspectstat) /* { */ + +#if defined(LUA_USE_POSIX) + +#include + +/* +** use appropriate macros to interpret 'pclose' return status +*/ +#define inspectstat(stat,what) \ + if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ + else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } + +#else + +#define inspectstat(stat,what) /* no op */ + +#endif + +#endif /* } */ + + +LUALIB_API int luaL_execresult (lua_State *L, int stat) { + const char *what = "exit"; /* type of termination */ + if (stat == -1) /* error? */ + return luaL_fileresult(L, 0, NULL); + else { + inspectstat(stat, what); /* interpret result */ + if (*what == 'e' && stat == 0) /* successful termination? */ + lua_pushboolean(L, 1); + else + lua_pushnil(L); + lua_pushstring(L, what); + lua_pushinteger(L, stat); + return 3; /* return true/nil,what,code */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Userdata's metatable manipulation +** ======================================================= +*/ + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); /* try to get metatable */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} + + +LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + luaL_getmetatable(L, tname); /* get correct metatable */ + if (!lua_rawequal(L, -1, -2)) /* not the same? */ + p = NULL; /* value is a userdata with wrong metatable */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + return NULL; /* value is not a userdata with a metatable */ +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = luaL_testudata(L, ud, tname); + if (p == NULL) typeerror(L, ud, tname); + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Argument check functions +** ======================================================= +*/ + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { + /* keep some extra space to run error routines, if needed */ + const int extra = LUA_MINSTACK; + if (!lua_checkstack(L, space + extra)) { + if (msg) + luaL_error(L, "stack overflow (%s)", msg); + else + luaL_error(L, "stack overflow"); + } +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + int isnum; + lua_Number d = lua_tonumberx(L, narg, &isnum); + if (!isnum) + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + int isnum; + lua_Integer d = lua_tointegerx(L, narg, &isnum); + if (!isnum) + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg) { + int isnum; + lua_Unsigned d = lua_tounsignedx(L, narg, &isnum); + if (!isnum) + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int narg, + lua_Unsigned def) { + return luaL_opt(L, luaL_checkunsigned, narg, def); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +/* +** check whether buffer is using a userdata on the stack as a temporary +** buffer +*/ +#define buffonstack(B) ((B)->b != (B)->initb) + + +/* +** returns a pointer to a free area with at least 'sz' bytes +*/ +LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { + lua_State *L = B->L; + if (B->size - B->n < sz) { /* not enough space? */ + char *newbuff; + size_t newsize = B->size * 2; /* double buffer size */ + if (newsize - B->n < sz) /* not bit enough? */ + newsize = B->n + sz; + if (newsize < B->n || newsize - B->n < sz) + luaL_error(L, "buffer too large"); + /* create larger buffer */ + newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char)); + /* move content to new buffer */ + memcpy(newbuff, B->b, B->n * sizeof(char)); + if (buffonstack(B)) + lua_remove(L, -2); /* remove old buffer */ + B->b = newbuff; + B->size = newsize; + } + return &B->b[B->n]; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + char *b = luaL_prepbuffsize(B, l); + memcpy(b, s, l * sizeof(char)); + luaL_addsize(B, l); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + lua_State *L = B->L; + lua_pushlstring(L, B->b, B->n); + if (buffonstack(B)) + lua_remove(L, -2); /* remove old buffer */ +} + + +LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) { + luaL_addsize(B, sz); + luaL_pushresult(B); +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t l; + const char *s = lua_tolstring(L, -1, &l); + if (buffonstack(B)) + lua_insert(L, -2); /* put value below buffer */ + luaL_addlstring(B, s, l); + lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */ +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->b = B->initb; + B->n = 0; + B->size = LUAL_BUFFERSIZE; +} + + +LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { + luaL_buffinit(L, B); + return luaL_prepbuffsize(B, sz); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Reference system +** ======================================================= +*/ + +/* index of free-list header */ +#define freelist 0 + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */ + } + else /* no free elements */ + ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */ + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); + lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, freelist); /* t[freelist] = ref */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int n; /* number of pre-read characters */ + FILE *f; /* file being read */ + char buff[LUAL_BUFFERSIZE]; /* area for reading file */ +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; /* not used */ + if (lf->n > 0) { /* are there pre-read characters to be read? */ + *size = lf->n; /* return them (chars already in buffer) */ + lf->n = 0; /* no more pre-read characters */ + } + else { /* read a block from file */ + /* 'fread' can return > 0 *and* set the EOF flag. If next call to + 'getF' called 'fread', it might still wait for user input. + The next check avoids this problem. */ + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ + } + return lf->buff; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +static int skipBOM (LoadF *lf) { + const char *p = "\xEF\xBB\xBF"; /* Utf8 BOM mark */ + int c; + lf->n = 0; + do { + c = getc(lf->f); + if (c == EOF || c != *(unsigned char *)p++) return c; + lf->buff[lf->n++] = c; /* to be read by the parser */ + } while (*p != '\0'); + lf->n = 0; /* prefix matched; discard it */ + return getc(lf->f); /* return next character */ +} + + +/* +** reads the first character of file 'f' and skips an optional BOM mark +** in its beginning plus its first line if it starts with '#'. Returns +** true if it skipped the first line. In any case, '*cp' has the +** first "valid" character of the file (after the optional BOM and +** a first-line comment). +*/ +static int skipcomment (LoadF *lf, int *cp) { + int c = *cp = skipBOM(lf); + if (c == '#') { /* first line is a comment (Unix exec. file)? */ + do { /* skip first line */ + c = getc(lf->f); + } while (c != EOF && c != '\n') ; + *cp = getc(lf->f); /* skip end-of-line, if present */ + return 1; /* there was a comment */ + } + else return 0; /* no comment */ +} + + +LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, + const char *mode) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + if (skipcomment(&lf, &c)) /* read initial portion */ + lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + skipcomment(&lf, &c); /* re-read initial portion */ + } + if (c != EOF) + lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ + status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; /* not used */ + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size, + const char *name, const char *mode) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name, mode); +} + + +LUALIB_API int luaL_loadstring (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + +/* }====================================================== */ + + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = lua_absindex(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API int luaL_len (lua_State *L, int idx) { + int l; + int isnum; + lua_len(L, idx); + l = (int)lua_tointegerx(L, -1, &isnum); + if (!isnum) + luaL_error(L, "object length is not a number"); + lua_pop(L, 1); /* remove object */ + return l; +} + + +LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { + if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */ + switch (lua_type(L, idx)) { + case LUA_TNUMBER: + case LUA_TSTRING: + lua_pushvalue(L, idx); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, idx), + lua_topointer(L, idx)); + break; + } + } + return lua_tolstring(L, -1, len); +} + + +/* +** {====================================================== +** Compatibility with 5.1 module functions +** ======================================================= +*/ +#if defined(LUA_COMPAT_MODULE) + +static const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + if (idx) lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + +/* +** Count number of elements in a luaL_Reg list. +*/ +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l && l->name; l++) size++; + return size; +} + + +/* +** Find or create a module table with a given name. The function +** first looks at the _LOADED table and, if that fails, try a +** global variable with that name. In any case, leaves on the stack +** the module table. +*/ +LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, + int sizehint) { + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */ + lua_getfield(L, -1, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + lua_pushglobaltable(L); + if (luaL_findtable(L, 0, modname, sizehint) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ +} + + +LUALIB_API void luaL_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + luaL_checkversion(L); + if (libname) { + luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ + lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ + } + if (l) + luaL_setfuncs(L, l, nup); + else + lua_pop(L, nup); /* remove upvalues */ +} + +#endif +/* }====================================================== */ + +/* +** set functions from list 'l' into table at top - 'nup'; each +** function gets the 'nup' elements at the top as upvalues. +** Returns with only the table at the stack. +*/ +LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { + luaL_checkversion(L); + luaL_checkstack(L, nup, "too many upvalues"); + for (; l->name != NULL; l++) { /* fill the table with given functions */ + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ + lua_setfield(L, -(nup + 2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + +/* +** ensure that stack[idx][fname] has a table and push that table +** into the stack +*/ +LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { + lua_getfield(L, idx, fname); + if (lua_istable(L, -1)) return 1; /* table already there */ + else { + lua_pop(L, 1); /* remove previous result */ + idx = lua_absindex(L, idx); + lua_newtable(L); + lua_pushvalue(L, -1); /* copy to be left at top */ + lua_setfield(L, idx, fname); /* assign new table to field */ + return 0; /* false, because did not find table there */ + } +} + + +/* +** stripped-down 'require'. Calls 'openf' to open a module, +** registers the result in 'package.loaded' table and, if 'glb' +** is true, also registers the result in the global table. +** Leaves resulting module on the top. +*/ +LUALIB_API void luaL_requiref (lua_State *L, const char *modname, + lua_CFunction openf, int glb) { + lua_pushcfunction(L, openf); + lua_pushstring(L, modname); /* argument to open function */ + lua_call(L, 1, 1); /* open module */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_pushvalue(L, -2); /* make copy of module (call result) */ + lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ + lua_pop(L, 1); /* remove _LOADED table */ + if (glb) { + lua_pushvalue(L, -1); /* copy of 'mod' */ + lua_setglobal(L, modname); /* _G[modname] = module */ + } +} + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; (void)osize; /* not used */ + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; /* return to Lua to abort */ +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + + +LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver) { + const lua_Number *v = lua_version(L); + if (v != lua_version(NULL)) + luaL_error(L, "multiple Lua VMs detected"); + else if (*v != ver) + luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", + ver, *v); + /* check conversions number -> integer types */ + lua_pushnumber(L, -(lua_Number)0x1234); + if (lua_tointeger(L, -1) != -0x1234 || + lua_tounsigned(L, -1) != (lua_Unsigned)-0x1234) + luaL_error(L, "bad conversion number->int;" + " must recompile Lua with proper settings"); + lua_pop(L, 1); +} + diff --git a/dep/lualib/lauxlib.h b/dep/lualib/lauxlib.h new file mode 100644 index 000000000..a08c01a03 --- /dev/null +++ b/dep/lualib/lauxlib.h @@ -0,0 +1,213 @@ +/* +** $Id: lauxlib.h,v 1.120 2011/11/29 15:55:08 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); +#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) + +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); +LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); +LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, + lua_Unsigned def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + +LUALIB_API int (luaL_len) (lua_State *L, int idx); + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); + +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); + +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); + +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) +#define luaL_checkbool(L, n) ( lua_isboolean( L, n ) ? lua_toboolean( L, n ) : (bool)luaL_optint( L, n, false) ) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_ppcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_ppcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +typedef struct luaL_Buffer { + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ + lua_State *L; + char initb[LUAL_BUFFERSIZE]; /* initial buffer */ +} luaL_Buffer; + + +#define luaL_addchar(B,c) \ + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) + +#define luaL_addsize(B,s) ((B)->n += (s)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); + +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + +/* }====================================================== */ + + + +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ + +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ + +#define LUA_FILEHANDLE "FILE*" + + +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + + + +/* compatibility with old module system */ +#if defined(LUA_COMPAT_MODULE) + +LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, + int sizehint); +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); + +#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) + +#endif + + +#endif + + diff --git a/dep/lualib/lbaselib.c b/dep/lualib/lbaselib.c new file mode 100644 index 000000000..b4fc2e2b2 --- /dev/null +++ b/dep/lualib/lbaselib.c @@ -0,0 +1,459 @@ +/* +** $Id: lbaselib.c,v 1.274 2012/04/27 14:13:19 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + size_t l; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tolstring(L, -1, &l); /* get result */ + if (s == NULL) + return luaL_error(L, + LUA_QL("tostring") " must return a string to " LUA_QL("print")); + if (i>1) luai_writestring("\t", 1); + luai_writestring(s, l); + lua_pop(L, 1); /* pop result */ + } + luai_writeline(); + return 0; +} + + +#define SPACECHARS " \f\n\r\t\v" + +static int luaB_tonumber (lua_State *L) { + if (lua_isnoneornil(L, 2)) { /* standard conversion */ + int isnum; + lua_Number n = lua_tonumberx(L, 1, &isnum); + if (isnum) { + lua_pushnumber(L, n); + return 1; + } /* else not a number; must be something */ + luaL_checkany(L, 1); + } + else { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *e = s + l; /* end point for 's' */ + int base = luaL_checkint(L, 2); + int neg = 0; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + s += strspn(s, SPACECHARS); /* skip initial spaces */ + if (*s == '-') { s++; neg = 1; } /* handle signal */ + else if (*s == '+') s++; + if (isalnum((unsigned char)*s)) { + lua_Number n = 0; + do { + int digit = (isdigit((unsigned char)*s)) ? *s - '0' + : toupper((unsigned char)*s) - 'A' + 10; + if (digit >= base) break; /* invalid numeral; force a fail */ + n = n * (lua_Number)base + (lua_Number)digit; + s++; + } while (isalnum((unsigned char)*s)); + s += strspn(s, SPACECHARS); /* skip trailing spaces */ + if (s == e) { /* no invalid trailing characters? */ + lua_pushnumber(L, (neg) ? -n : n); + return 1; + } /* else not a number */ + } /* else not a number */ + } + lua_pushnil(L); /* not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + return luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawlen (lua_State *L) { + int t = lua_type(L, 1); + luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, + "table or string expected"); + lua_pushinteger(L, lua_rawlen(L, 1)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", + "setmajorinc", "isrunning", "generational", "incremental", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, + LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; + int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, o, ex); + switch (o) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + lua_pushinteger(L, b); + return 2; + } + case LUA_GCSTEP: case LUA_GCISRUNNING: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushinteger(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int pairsmeta (lua_State *L, const char *method, int iszero, + lua_CFunction iter) { + if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */ + luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ + lua_pushcfunction(L, iter); /* will return generator, */ + lua_pushvalue(L, 1); /* state, */ + if (iszero) lua_pushinteger(L, 0); /* and initial value */ + else lua_pushnil(L); + } + else { + lua_pushvalue(L, 1); /* argument 'self' to metamethod */ + lua_call(L, 1, 3); /* get 3 values from metamethod */ + } + return 3; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + return pairsmeta(L, "__pairs", 0, luaB_next); +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 1 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + return pairsmeta(L, "__ipairs", 1, ipairsaux); +} + + +static int load_aux (lua_State *L, int status) { + if (status == LUA_OK) + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + const char *mode = luaL_optstring(L, 2, NULL); + int env = !lua_isnone(L, 3); /* 'env' parameter? */ + int status = luaL_loadfilex(L, fname, mode); + if (status == LUA_OK && env) { /* 'env' parameter? */ + lua_pushvalue(L, 3); + lua_setupvalue(L, -2, 1); /* set it as 1st upvalue of loaded chunk */ + } + return load_aux(L, status); +} + + +/* +** {====================================================== +** Generic Read function +** ======================================================= +*/ + + +/* +** reserved slot, above all arguments, to hold a copy of the returned +** string to avoid it being collected while parsed. 'load' has four +** optional arguments (chunk, source name, mode, and environment). +*/ +#define RESERVEDSLOT 5 + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)(ud); /* not used */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* pop result */ + *size = 0; + return NULL; + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "reader function must return a string"); + lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ + return lua_tolstring(L, RESERVEDSLOT, size); +} + + +static int luaB_load (lua_State *L) { + int status; + size_t l; + int top = lua_gettop(L); + const char *s = lua_tolstring(L, 1, &l); + const char *mode = luaL_optstring(L, 3, "bt"); + if (s != NULL) { /* loading a string? */ + const char *chunkname = luaL_optstring(L, 2, s); + status = luaL_loadbufferx(L, s, l, chunkname, mode); + } + else { /* loading from a reader function */ + const char *chunkname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, RESERVEDSLOT); /* create reserved slot */ + status = lua_load(L, generic_reader, NULL, chunkname, mode); + } + if (status == LUA_OK && top >= 4) { /* is there an 'env' argument */ + lua_pushvalue(L, 4); /* environment for loaded function */ + lua_setupvalue(L, -2, 1); /* set it as 1st upvalue */ + } + return load_aux(L, status); +} + +/* }====================================================== */ + + +static int dofilecont (lua_State *L) { + return lua_gettop(L) - 1; +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + lua_settop(L, 1); + if (luaL_loadfile(L, fname) != LUA_OK) lua_error(L); + lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); + return dofilecont(L); +} + + +static int luaB_assert (lua_State *L) { + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int finishpcall (lua_State *L, int status) { + if (!lua_checkstack(L, 1)) { /* no space for extra boolean? */ + lua_settop(L, 0); /* create space for return values */ + lua_pushboolean(L, 0); + lua_pushstring(L, "stack overflow"); + return 2; /* return false, msg */ + } + lua_pushboolean(L, status); /* first result (status) */ + lua_replace(L, 1); /* put first result in first slot */ + return lua_gettop(L); +} + + +static int pcallcont (lua_State *L) { + int status = lua_getctx(L, NULL); + return finishpcall(L, (status == LUA_YIELD)); +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + lua_pushnil(L); + lua_insert(L, 1); /* create space for status result */ + status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, pcallcont); + return finishpcall(L, (status == LUA_OK)); +} + + +static int luaB_xpcall (lua_State *L) { + int status; + int n = lua_gettop(L); + luaL_argcheck(L, n >= 2, 2, "value expected"); + lua_pushvalue(L, 1); /* exchange function... */ + lua_copy(L, 2, 1); /* ...and error handler */ + lua_replace(L, 2); + status = lua_pcallk(L, n - 2, LUA_MULTRET, 1, 0, pcallcont); + return finishpcall(L, (status == LUA_OK)); +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + luaL_tolstring(L, 1, NULL); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"getmetatable", luaB_getmetatable}, + {"ipairs", luaB_ipairs}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, +#if defined(LUA_COMPAT_LOADSTRING) + {"loadstring", luaB_load}, +#endif + {"next", luaB_next}, + {"pairs", luaB_pairs}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawlen", luaB_rawlen}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_base (lua_State *L) { + /* set global _G */ + lua_pushglobaltable(L); + lua_pushglobaltable(L); + lua_setfield(L, -2, "_G"); + /* open lib into global table */ + luaL_setfuncs(L, base_funcs, 0); + lua_pushliteral(L, LUA_VERSION); + lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */ + return 1; +} + diff --git a/dep/lualib/lbitlib.c b/dep/lualib/lbitlib.c new file mode 100644 index 000000000..7fad1f7fa --- /dev/null +++ b/dep/lualib/lbitlib.c @@ -0,0 +1,209 @@ +/* +** $Id: lbitlib.c,v 1.16 2011/06/20 16:35:23 roberto Exp $ +** Standard library for bitwise operations +** See Copyright Notice in lua.h +*/ + +#define lbitlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* number of bits to consider in a number */ +#if !defined(LUA_NBITS) +#define LUA_NBITS 32 +#endif + + +#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) + +/* macro to trim extra bits */ +#define trim(x) ((x) & ALLONES) + + +/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ +#define mask(n) (~((ALLONES << 1) << ((n) - 1))) + + +typedef lua_Unsigned b_uint; + + + +static b_uint andaux (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = ~(b_uint)0; + for (i = 1; i <= n; i++) + r &= luaL_checkunsigned(L, i); + return trim(r); +} + + +static int b_and (lua_State *L) { + b_uint r = andaux(L); + lua_pushunsigned(L, r); + return 1; +} + + +static int b_test (lua_State *L) { + b_uint r = andaux(L); + lua_pushboolean(L, r != 0); + return 1; +} + + +static int b_or (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r |= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_xor (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r ^= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_not (lua_State *L) { + b_uint r = ~luaL_checkunsigned(L, 1); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_shift (lua_State *L, b_uint r, int i) { + if (i < 0) { /* shift right? */ + i = -i; + r = trim(r); + if (i >= LUA_NBITS) r = 0; + else r >>= i; + } + else { /* shift left */ + if (i >= LUA_NBITS) r = 0; + else r <<= i; + r = trim(r); + } + lua_pushunsigned(L, r); + return 1; +} + + +static int b_lshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2)); +} + + +static int b_rshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2)); +} + + +static int b_arshift (lua_State *L) { + b_uint r = luaL_checkunsigned(L, 1); + int i = luaL_checkint(L, 2); + if (i < 0 || !(r & ((b_uint)1 << (LUA_NBITS - 1)))) + return b_shift(L, r, -i); + else { /* arithmetic shift for 'negative' number */ + if (i >= LUA_NBITS) r = ALLONES; + else + r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ + lua_pushunsigned(L, r); + return 1; + } +} + + +static int b_rot (lua_State *L, int i) { + b_uint r = luaL_checkunsigned(L, 1); + i &= (LUA_NBITS - 1); /* i = i % NBITS */ + r = trim(r); + r = (r << i) | (r >> (LUA_NBITS - i)); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_lrot (lua_State *L) { + return b_rot(L, luaL_checkint(L, 2)); +} + + +static int b_rrot (lua_State *L) { + return b_rot(L, -luaL_checkint(L, 2)); +} + + +/* +** get field and width arguments for field-manipulation functions, +** checking whether they are valid +*/ +static int fieldargs (lua_State *L, int farg, int *width) { + int f = luaL_checkint(L, farg); + int w = luaL_optint(L, farg + 1, 1); + luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); + luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); + if (f + w > LUA_NBITS) + luaL_error(L, "trying to access non-existent bits"); + *width = w; + return f; +} + + +static int b_extract (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + int f = fieldargs(L, 2, &w); + r = (r >> f) & mask(w); + lua_pushunsigned(L, r); + return 1; +} + + +static int b_replace (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + b_uint v = luaL_checkunsigned(L, 2); + int f = fieldargs(L, 3, &w); + int m = mask(w); + v &= m; /* erase bits outside given width */ + r = (r & ~(m << f)) | (v << f); + lua_pushunsigned(L, r); + return 1; +} + + +static const luaL_Reg bitlib[] = { + {"arshift", b_arshift}, + {"band", b_and}, + {"bnot", b_not}, + {"bor", b_or}, + {"bxor", b_xor}, + {"btest", b_test}, + {"extract", b_extract}, + {"lrotate", b_lrot}, + {"lshift", b_lshift}, + {"replace", b_replace}, + {"rrotate", b_rrot}, + {"rshift", b_rshift}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_bit32 (lua_State *L) { + luaL_newlib(L, bitlib); + return 1; +} + diff --git a/dep/lualib/lcode.c b/dep/lualib/lcode.c new file mode 100644 index 000000000..0e2a15725 --- /dev/null +++ b/dep/lualib/lcode.c @@ -0,0 +1,882 @@ +/* +** $Id: lcode.c,v 2.60 2011/08/30 16:26:41 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstring.h" +#include "ltable.h" +#include "lvm.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + int l = from + n - 1; /* last register to set nil */ + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pl = pfrom + GETARG_B(*previous); + if ((pfrom <= from && from <= pl + 1) || + (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ + if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ + if (pl > l) l = pl; /* l = max(l, pl) */ + SETARG_A(*previous, from); + SETARG_B(*previous, l - from); + return; + } + } /* else go through */ + } + luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) { + level++; /* argument is +1 to reserve 0 as non-op */ + while (list != NO_JUMP) { + int next = getjump(fs, list); + lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && + (GETARG_A(fs->f->code[list]) == 0 || + GETARG_A(fs->f->code[list]) >= level)); + SETARG_A(fs->f->code[list], level); + list = next; + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +static int luaK_code (FuncState *fs, Instruction i) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "opcodes"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "opcodes"); + f->lineinfo[fs->pc] = fs->ls->lastline; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); + return luaK_code(fs, CREATE_ABC(o, a, b, c)); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, bc)); +} + + +static int codeextraarg (FuncState *fs, int a) { + lua_assert(a <= MAXARG_Ax); + return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); +} + + +int luaK_codek (FuncState *fs, int reg, int k) { + if (k <= MAXARG_Bx) + return luaK_codeABx(fs, OP_LOADK, reg, k); + else { + int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); + codeextraarg(fs, k); + return p; + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.info); +} + + +static int addk (FuncState *fs, TValue *key, TValue *v) { + lua_State *L = fs->ls->L; + TValue *idx = luaH_set(L, fs->h, key); + Proto *f = fs->f; + int k, oldsize; + if (ttisnumber(idx)) { + lua_Number n = nvalue(idx); + lua_number2int(k, n); + if (luaV_rawequalobj(&f->k[k], v)) + return k; + /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0"); + go through and create a new entry for this value */ + } + /* constant not found; create a new entry */ + oldsize = f->sizek; + k = fs->nk; + /* numerical value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setnvalue(idx, cast_num(k)); + luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[k], v); + fs->nk++; + luaC_barrier(L, f, v); + return k; +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->ls->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + int n; + lua_State *L = fs->ls->L; + TValue o; + setnvalue(&o, r); + if (r == 0 || luai_numisnan(NULL, r)) { /* handle -0 and NaN */ + /* use raw representation as key to avoid numeric problems */ + setsvalue(L, L->top, luaS_newlstr(L, (char *)&r, sizeof(r))); + incr_top(L); + n = addk(fs, L->top - 1, &o); + L->top--; + } + else + n = addk(fs, &o, &o); /* regular case */ + return n; +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->ls->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */ + freereg(fs, e->u.ind.idx); + if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */ + freereg(fs, e->u.ind.t); + op = OP_GETTABLE; + } + e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codek(fs, reg, e->u.info); + break; + } + case VKNUM: { + luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.info; /* exp is already in a register */ + if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.info); /* put value on it */ + return e->u.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.info; +} + + +void luaK_exp2anyregup (FuncState *fs, expdesc *e) { + if (e->k != VUPVAL || hasjumps(e)) + luaK_exp2anyreg(fs, e); +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */ + e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.info); + } + else break; + } + case VKNUM: { + e->u.info = luaK_numberK(fs, e->u.nval); + e->k = VK; + /* go through */ + } + case VK: { + if (e->u.info <= MAXINDEXRK) /* constant fits in argC? */ + return RKASK(e->u.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); + break; + } + case VINDEXED: { + OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int ereg; + luaK_exp2anyreg(fs, e); + ereg = e->u.info; /* register where 'e' was placed */ + freeexp(fs, e); + e->u.info = fs->freereg; /* base register for op_self */ + e->k = VNONRELOC; + luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ + luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key)); + freeexp(fs, key); +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VJMP: { + invertjump(fs, e); + pc = e->u.info; + break; + } + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VJMP: { + pc = e->u.info; + break; + } + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + lua_assert(!hasjumps(t)); + t->u.ind.t = t->u.info; + t->u.ind.idx = luaK_exp2RK(fs, k); + t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL + : check_exp(vkisinreg(t->k), VLOCAL); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0) + return 0; /* do not attempt to divide by 0 */ + r = luaO_arith(op - OP_ADD + LUA_OPADD, e1->u.nval, e2->u.nval); + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, + expdesc *e1, expdesc *e2, int line) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + luaK_fixline(fs, line); + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (isnumeral(e)) /* minus constant? */ + e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */ + else { + luaK_exp2anyreg(fs, e); + codearith(fs, OP_UNM, e, &e2, line); + } + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2, line); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, + expdesc *e1, expdesc *e2, int line) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.info); + e1->k = VRELOCABLE; e1->u.info = e2->u.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2, line); + } + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line); + break; + } + case OPR_EQ: case OPR_LT: case OPR_LE: { + codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2); + break; + } + case OPR_NE: case OPR_GT: case OPR_GE: { + codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else if (c <= MAXARG_Ax) { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + codeextraarg(fs, c); + } + else + luaX_syntaxerror(fs->ls, "constructor too long"); + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/dep/lualib/lcode.h b/dep/lualib/lcode.h new file mode 100644 index 000000000..2ce00d2ae --- /dev/null +++ b/dep/lualib/lcode.h @@ -0,0 +1,83 @@ +/* +** $Id: lcode.h,v 1.58 2011/08/30 16:26:41 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums (ORDER OP) +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_EQ, OPR_LT, OPR_LE, + OPR_NE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, + expdesc *v2, int line); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/dep/lualib/lcorolib.c b/dep/lualib/lcorolib.c new file mode 100644 index 000000000..d972a1675 --- /dev/null +++ b/dep/lualib/lcorolib.c @@ -0,0 +1,155 @@ +/* +** $Id: lcorolib.c,v 1.4 2012/04/27 18:59:04 roberto Exp $ +** Coroutine Library +** See Copyright Notice in lua.h +*/ + + +#include + + +#define lcorolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status; + if (!lua_checkstack(co, narg)) { + lua_pushliteral(L, "too many arguments to resume"); + return -1; /* error flag */ + } + if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { + lua_pushliteral(L, "cannot resume dead coroutine"); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + status = lua_resume(co, L, narg); + if (status == LUA_OK || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) { + lua_pop(co, nres); /* remove results anyway */ + lua_pushliteral(L, "too many results to resume"); + return -1; /* error flag */ + } + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL; + luaL_checktype(L, 1, LUA_TFUNCTION); + NL = lua_newthread(L); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + if (L == co) lua_pushliteral(L, "running"); + else { + switch (lua_status(co)) { + case LUA_YIELD: + lua_pushliteral(L, "suspended"); + break; + case LUA_OK: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + lua_pushliteral(L, "normal"); /* it is running */ + else if (lua_gettop(co) == 0) + lua_pushliteral(L, "dead"); + else + lua_pushliteral(L, "suspended"); /* initial state */ + break; + } + default: /* some error occurred */ + lua_pushliteral(L, "dead"); + break; + } + } + return 1; +} + + +static int luaB_corunning (lua_State *L) { + int ismain = lua_pushthread(L); + lua_pushboolean(L, ismain); + return 2; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_coroutine (lua_State *L) { + luaL_newlib(L, co_funcs); + return 1; +} + diff --git a/dep/lualib/lctype.c b/dep/lualib/lctype.c new file mode 100644 index 000000000..f4f4fbd59 --- /dev/null +++ b/dep/lualib/lctype.c @@ -0,0 +1,52 @@ +/* +** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#define lctype_c +#define LUA_CORE + +#include "lctype.h" + +#if !LUA_USE_CTYPE /* { */ + +#include + +LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { + 0x00, /* EOZ */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ + 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +#endif /* } */ diff --git a/dep/lualib/lctype.h b/dep/lualib/lctype.h new file mode 100644 index 000000000..6afeb798b --- /dev/null +++ b/dep/lualib/lctype.h @@ -0,0 +1,95 @@ +/* +** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lctype_h +#define lctype_h + +#include "lua.h" + + +/* +** WARNING: the functions defined here do not necessarily correspond +** to the similar functions in the standard C ctype.h. They are +** optimized for the specific needs of Lua +*/ + +#if !defined(LUA_USE_CTYPE) + +#if 'A' == 65 && '0' == 48 +/* ASCII case: can use its own tables; faster and fixed */ +#define LUA_USE_CTYPE 0 +#else +/* must use standard C ctype */ +#define LUA_USE_CTYPE 1 +#endif + +#endif + + +#if !LUA_USE_CTYPE /* { */ + +#include + +#include "llimits.h" + + +#define ALPHABIT 0 +#define DIGITBIT 1 +#define PRINTBIT 2 +#define SPACEBIT 3 +#define XDIGITBIT 4 + + +#define MASK(B) (1 << (B)) + + +/* +** add 1 to char to allow index -1 (EOZ) +*/ +#define testprop(c,p) (luai_ctype_[(c)+1] & (p)) + +/* +** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' +*/ +#define lislalpha(c) testprop(c, MASK(ALPHABIT)) +#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) +#define lisdigit(c) testprop(c, MASK(DIGITBIT)) +#define lisspace(c) testprop(c, MASK(SPACEBIT)) +#define lisprint(c) testprop(c, MASK(PRINTBIT)) +#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) + +/* +** this 'ltolower' only works for alphabetic characters +*/ +#define ltolower(c) ((c) | ('A' ^ 'a')) + + +/* two more entries for 0 and -1 (EOZ) */ +LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; + + +#else /* }{ */ + +/* +** use standard C ctypes +*/ + +#include + + +#define lislalpha(c) (isalpha(c) || (c) == '_') +#define lislalnum(c) (isalnum(c) || (c) == '_') +#define lisdigit(c) (isdigit(c)) +#define lisspace(c) (isspace(c)) +#define lisprint(c) (isprint(c)) +#define lisxdigit(c) (isxdigit(c)) + +#define ltolower(c) (tolower(c)) + +#endif /* } */ + +#endif + diff --git a/dep/lualib/ldblib.c b/dep/lualib/ldblib.c new file mode 100644 index 000000000..845f3b62f --- /dev/null +++ b/dep/lualib/ldblib.c @@ -0,0 +1,398 @@ +/* +** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define HOOKKEY "_HKEY" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; /* return 1st argument */ +} + + +static int db_getuservalue (lua_State *L) { + if (lua_type(L, 1) != LUA_TUSERDATA) + lua_pushnil(L); + else + lua_getuservalue(L, 1); + return 1; +} + + +static int db_setuservalue (lua_State *L) { + if (lua_type(L, 1) == LUA_TLIGHTUSERDATA) + luaL_argerror(L, 1, "full userdata expected, got light userdata"); + luaL_checktype(L, 1, LUA_TUSERDATA); + if (!lua_isnoneornil(L, 2)) + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + lua_setuservalue(L, 1); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsb (lua_State *L, const char *i, int v) { + lua_pushboolean(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnStu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) { + settabsi(L, "nups", ar.nups); + settabsi(L, "nparams", ar.nparams); + settabsb(L, "isvararg", ar.isvararg); + } + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 't')) + settabsb(L, "istailcall", ar.istailcall); + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + int nvar = luaL_checkint(L, arg+2); /* local-variable index */ + if (lua_isfunction(L, arg + 1)) { /* function argument? */ + lua_pushvalue(L, arg + 1); /* push function */ + lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ + return 1; + } + else { /* stack-level argument */ + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, nvar); + if (name) { + lua_xmove(L1, L, 1); /* push local value */ + lua_pushstring(L, name); /* push name */ + lua_pushvalue(L, -2); /* re-order */ + return 2; + } + else { + lua_pushnil(L); /* no name (nor value) */ + return 1; + } + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + +static int checkupval (lua_State *L, int argf, int argnup) { + lua_Debug ar; + int nup = luaL_checkint(L, argnup); + luaL_checktype(L, argf, LUA_TFUNCTION); + lua_pushvalue(L, argf); + lua_getinfo(L, ">u", &ar); + luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index"); + return nup; +} + + +static int db_upvalueid (lua_State *L) { + int n = checkupval(L, 1, 2); + lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); + return 1; +} + + +static int db_upvaluejoin (lua_State *L) { + int n1 = checkupval(L, 1, 2); + int n2 = checkupval(L, 3, 4); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); + lua_upvaluejoin(L, 1, n1, 3, n2); + return 0; +} + + +#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY) + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail call"}; + gethooktable(L); + lua_pushthread(L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + if (gethooktable(L) == 0) { /* creating hook table? */ + lua_pushstring(L, "k"); + lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ + lua_pushvalue(L, -1); + lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ + } + lua_pushthread(L1); lua_xmove(L1, L, 1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushthread(L1); lua_xmove(L1, L, 1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + luai_writestringerror("%s", "lua_debug> "); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_ppcall(L, 0, 0, 0)) + luai_writestringerror("%s\n", lua_tostring(L, -1)); + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +static int db_traceback (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + const char *msg = lua_tostring(L, arg + 1); + if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ + lua_pushvalue(L, arg + 1); /* return it untouched */ + else { + int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0); + luaL_traceback(L, L1, msg, level); + } + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getuservalue", db_getuservalue}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"upvaluejoin", db_upvaluejoin}, + {"upvalueid", db_upvalueid}, + {"setuservalue", db_setuservalue}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_traceback}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_debug (lua_State *L) { + luaL_newlib(L, dblib); + return 1; +} + diff --git a/dep/lualib/ldebug.c b/dep/lualib/ldebug.c new file mode 100644 index 000000000..d6008c74f --- /dev/null +++ b/dep/lualib/ldebug.c @@ -0,0 +1,580 @@ +/* +** $Id: ldebug.c,v 2.89 2012/01/20 22:05:50 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (CallInfo *ci) { + lua_assert(isLua(ci)); + return pcRel(ci->u.l.savedpc, ci_func(ci)->p); +} + + +static int currentline (CallInfo *ci) { + return getfuncline(ci_func(ci)->p, currentpc(ci)); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + if (isLua(L->ci)) + L->oldpc = L->ci->u.l.savedpc; + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + if (level < 0) return 0; /* invalid (negative) level */ + lua_lock(L); + for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous) + level--; + if (level == 0 && ci != &L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = ci; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static const char *upvalname (Proto *p, int uv) { + TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); + if (s == NULL) return "?"; + else return getstr(s); +} + + +static const char *findvararg (CallInfo *ci, int n, StkId *pos) { + int nparams = clLvalue(ci->func)->p->numparams; + if (n >= ci->u.l.base - ci->func - nparams) + return NULL; /* no such vararg */ + else { + *pos = ci->func + nparams + n; + return "(*vararg)"; /* generic name for any vararg */ + } +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n, + StkId *pos) { + const char *name = NULL; + StkId base; + if (isLua(ci)) { + if (n < 0) /* access to vararg values? */ + return findvararg(ci, -n, pos); + else { + base = ci->u.l.base; + name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); + } + } + else + base = ci->func + 1; + if (name == NULL) { /* no 'standard' name? */ + StkId limit = (ci == L->ci) ? L->top : ci->next->func; + if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + name = "(*temporary)"; /* generic name for any valid slot */ + else + return NULL; /* no name */ + } + *pos = base + (n - 1); + return name; +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + const char *name; + lua_lock(L); + if (ar == NULL) { /* information about non-active function? */ + if (!isLfunction(L->top - 1)) /* not a Lua function? */ + name = NULL; + else /* consider live variables at function start (parameters) */ + name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); + } + else { /* active function; get information through 'ar' */ + StkId pos = 0; /* to avoid warnings */ + name = findlocal(L, ar->i_ci, n, &pos); + if (name) { + setobj2s(L, L->top, pos); + api_incr_top(L); + } + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + StkId pos = 0; /* to avoid warnings */ + const char *name = findlocal(L, ar->i_ci, n, &pos); + lua_lock(L); + if (name) + setobjs2s(L, pos, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (noLuaClosure(cl)) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + Proto *p = cl->l.p; + ar->source = p->source ? getstr(p->source) : "=?"; + ar->linedefined = p->linedefined; + ar->lastlinedefined = p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (noLuaClosure(f)) { + setnilvalue(L->top); + incr_top(L); + } + else { + int i; + TValue v; + int *lineinfo = f->l.p->lineinfo; + Table *t = luaH_new(L); /* new table to store active lines */ + sethvalue(L, L->top, t); /* push it on stack */ + incr_top(L); + setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ + for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ + luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ + } +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; + break; + } + case 'u': { + ar->nups = (f == NULL) ? 0 : f->c.nupvalues; + if (noLuaClosure(f)) { + ar->isvararg = 1; + ar->nparams = 0; + } + else { + ar->isvararg = f->l.p->is_vararg; + ar->nparams = f->l.p->numparams; + } + break; + } + case 't': { + ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0; + break; + } + case 'n': { + /* calling function is a known Lua function? */ + if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) + ar->namewhat = getfuncname(L, ci->previous, &ar->name); + else + ar->namewhat = NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *cl; + CallInfo *ci; + StkId func; + lua_lock(L); + if (*what == '>') { + ci = NULL; + func = L->top - 1; + api_check(L, ttisfunction(func), "function expected"); + what++; /* skip the '>' */ + L->top--; /* pop function */ + } + else { + ci = ar->i_ci; + func = ci->func; + lua_assert(ttisfunction(ci->func)); + } + cl = ttisclosure(func) ? clvalue(func) : NULL; + status = auxgetinfo(L, what, ar, cl, ci); + if (strchr(what, 'f')) { + setobjs2s(L, L->top, func); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, cl); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution +** ======================================================= +*/ + +static const char *getobjname (Proto *p, int lastpc, int reg, + const char **name); + + +/* +** find a "name" for the RK value 'c' +*/ +static void kname (Proto *p, int pc, int c, const char **name) { + if (ISK(c)) { /* is 'c' a constant? */ + TValue *kvalue = &p->k[INDEXK(c)]; + if (ttisstring(kvalue)) { /* literal constant? */ + *name = svalue(kvalue); /* it is its own name */ + return; + } + /* else no reasonable name found */ + } + else { /* 'c' is a register */ + const char *what = getobjname(p, pc, c, name); /* search for 'c' */ + if (what && *what == 'c') { /* found a constant name? */ + return; /* 'name' already filled */ + } + /* else no reasonable name found */ + } + *name = "?"; /* no reasonable name found */ +} + + +/* +** try to find last instruction before 'lastpc' that modified register 'reg' +*/ +static int findsetreg (Proto *p, int lastpc, int reg) { + int pc; + int setreg = -1; /* keep last instruction that changed 'reg' */ + for (pc = 0; pc < lastpc; pc++) { + Instruction i = p->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + switch (op) { + case OP_LOADNIL: { + int b = GETARG_B(i); + if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ + setreg = pc; + break; + } + case OP_TFORCALL: { + if (reg >= a + 2) setreg = pc; /* affect all regs above its base */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (reg >= a) setreg = pc; /* affect all registers above base */ + break; + } + case OP_JMP: { + int b = GETARG_sBx(i); + int dest = pc + 1 + b; + /* jump is forward and do not skip `lastpc'? */ + if (pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_TEST: { + if (reg == a) setreg = pc; /* jumped code can change 'a' */ + break; + } + default: + if (testAMode(op) && reg == a) /* any instruction that set A */ + setreg = pc; + break; + } + } + return setreg; +} + + +static const char *getobjname (Proto *p, int lastpc, int reg, + const char **name) { + int pc; + *name = luaF_getlocalname(p, reg + 1, lastpc); + if (*name) /* is a local? */ + return "local"; + /* else try symbolic execution */ + pc = findsetreg(p, lastpc, reg); + if (pc != -1) { /* could find instruction? */ + Instruction i = p->code[pc]; + OpCode op = GET_OPCODE(i); + switch (op) { + case OP_MOVE: { + int b = GETARG_B(i); /* move from 'b' to 'a' */ + if (b < GETARG_A(i)) + return getobjname(p, pc, b, name); /* get name for 'b' */ + break; + } + case OP_GETTABUP: + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + int t = GETARG_B(i); /* table index */ + const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ + ? luaF_getlocalname(p, t + 1, pc) + : upvalname(p, t); + kname(p, pc, k, name); + return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; + } + case OP_GETUPVAL: { + *name = upvalname(p, GETARG_B(i)); + return "upvalue"; + } + case OP_LOADK: + case OP_LOADKX: { + int b = (op == OP_LOADK) ? GETARG_Bx(i) + : GETARG_Ax(p->code[pc + 1]); + if (ttisstring(&p->k[b])) { + *name = svalue(&p->k[b]); + return "constant"; + } + break; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + kname(p, pc, k, name); + return "method"; + } + default: break; /* go through to return NULL */ + } + } + return NULL; /* could not find reasonable name */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + TMS tm; + Proto *p = ci_func(ci)->p; /* calling function */ + int pc = currentpc(ci); /* calling instruction index */ + Instruction i = p->code[pc]; /* calling instruction */ + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: /* get function name */ + return getobjname(p, pc, GETARG_A(i), name); + case OP_TFORCALL: { /* for iterator */ + *name = "for iterator"; + return "for iterator"; + } + /* all other instructions can call only through metamethods */ + case OP_SELF: + case OP_GETTABUP: + case OP_GETTABLE: tm = TM_INDEX; break; + case OP_SETTABUP: + case OP_SETTABLE: tm = TM_NEWINDEX; break; + case OP_EQ: tm = TM_EQ; break; + case OP_ADD: tm = TM_ADD; break; + case OP_SUB: tm = TM_SUB; break; + case OP_MUL: tm = TM_MUL; break; + case OP_DIV: tm = TM_DIV; break; + case OP_MOD: tm = TM_MOD; break; + case OP_POW: tm = TM_POW; break; + case OP_UNM: tm = TM_UNM; break; + case OP_LEN: tm = TM_LEN; break; + case OP_LT: tm = TM_LT; break; + case OP_LE: tm = TM_LE; break; + case OP_CONCAT: tm = TM_CONCAT; break; + default: + return NULL; /* else no useful name can be found */ + } + *name = getstr(G(L)->tmname[tm]); + return "metamethod"; +} + +/* }====================================================== */ + + + +/* +** only ANSI way to check whether a pointer points to an array +** (used only for error messages, so efficiency is not a big concern) +*/ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->u.l.base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +static const char *getupvalname (CallInfo *ci, const TValue *o, + const char **name) { + LClosure *c = ci_func(ci); + int i; + for (i = 0; i < c->nupvalues; i++) { + if (c->upvals[i]->v == o) { + *name = upvalname(c->p, i); + return "upvalue"; + } + } + return NULL; +} + + +l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + CallInfo *ci = L->ci; + const char *name = NULL; + const char *t = objtypename(o); + const char *kind = NULL; + if (isLua(ci)) { + kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ + if (!kind && isinstack(ci, o)) /* no? try a register */ + kind = getobjname(ci_func(ci)->p, currentpc(ci), + cast_int(o - ci->u.l.base), &name); + } + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p2)); + luaG_typeerror(L, p1, "concatenate"); +} + + +l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = objtypename(p1); + const char *t2 = objtypename(p2); + if (t1 == t2) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(ci); + TString *src = ci_func(ci)->p->source; + if (src) + luaO_chunkid(buff, getstr(src), LUA_IDSIZE); + else { /* no source available; use "?" instead */ + buff[0] = '?'; buff[1] = '\0'; + } + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +l_noret luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1, 0); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff --git a/dep/lualib/ldebug.h b/dep/lualib/ldebug.h new file mode 100644 index 000000000..9835fefcc --- /dev/null +++ b/dep/lualib/ldebug.h @@ -0,0 +1,34 @@ +/* +** $Id: ldebug.h,v 2.7 2011/10/07 20:45:19 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + +/* Active Lua function (given call info) */ +#define ci_func(ci) (clLvalue((ci)->func)) + + +LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC l_noret luaG_errormsg (lua_State *L); + +#endif diff --git a/dep/lualib/ldo.c b/dep/lualib/ldo.c new file mode 100644 index 000000000..707c8e832 --- /dev/null +++ b/dep/lualib/ldo.c @@ -0,0 +1,668 @@ +/* +** $Id: ldo.c,v 2.105 2012/06/08 15:14:04 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + +/* +** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By +** default, Lua handles errors with exceptions when compiling as +** C++ code, with _longjmp/_setjmp when asked to use them, and with +** longjmp/setjmp otherwise. +*/ +#if !defined(LUAI_THROW) + +#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) \ + try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + +#endif + + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { /* memory error? */ + setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + default: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +l_noret luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { /* thread has an error handler? */ + L->errorJmp->status = errcode; /* set status */ + LUAI_THROW(L, L->errorJmp); /* jump to it */ + } + else { /* thread has no error handler */ + L->status = cast_byte(errcode); /* mark it as dead */ + if (G(L)->mainthread->errorJmp) { /* main thread has a handler? */ + setobjs2s(L, G(L)->mainthread->top++, L->top - 1); /* copy error obj. */ + luaD_throw(G(L)->mainthread, errcode); /* re-throw in main thread */ + } + else { /* no handler at all; abort */ + if (G(L)->panic) { /* panic function? */ + lua_unlock(L); + G(L)->panic(L); /* call it (last chance to jump out) */ + } + abort(); + } + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + unsigned short oldnCcalls = L->nCcalls; + struct lua_longjmp lj; + lj.status = LUA_OK; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + L->nCcalls = oldnCcalls; + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->ci; ci != NULL; ci = ci->previous) { + ci->top = (ci->top - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + if (isLua(ci)) + ci->u.l.base = (ci->u.l.base - oldstack) + L->stack; + } +} + + +/* some space for error handling */ +#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int lim = L->stacksize; + lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); + luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue); + for (; lim < newsize; lim++) + setnilvalue(L->stack + lim); /* erase new segment */ + L->stacksize = newsize; + L->stack_last = L->stack + newsize - EXTRA_STACK; + correctstack(L, oldstack); +} + + +void luaD_growstack (lua_State *L, int n) { + int size = L->stacksize; + if (size > LUAI_MAXSTACK) /* error after extra size? */ + luaD_throw(L, LUA_ERRERR); + else { + int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; + int newsize = 2 * size; + if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; + if (newsize < needed) newsize = needed; + if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ + luaD_reallocstack(L, ERRORSTACKSIZE); + luaG_runerror(L, "stack overflow"); + } + else + luaD_reallocstack(L, newsize); + } +} + + +static int stackinuse (lua_State *L) { + CallInfo *ci; + StkId lim = L->top; + for (ci = L->ci; ci != NULL; ci = ci->previous) { + lua_assert(ci->top <= L->stack_last); + if (lim < ci->top) lim = ci->top; + } + return cast_int(lim - L->stack) + 1; /* part of stack in use */ +} + + +void luaD_shrinkstack (lua_State *L) { + int inuse = stackinuse(L); + int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; + if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK; + if (inuse > LUAI_MAXSTACK || /* handling stack overflow? */ + goodsize >= L->stacksize) /* would grow instead of shrink? */ + condmovestack(L); /* don't change stack (change only for debugging) */ + else + luaD_reallocstack(L, goodsize); /* shrink it */ +} + + +void luaD_hook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + CallInfo *ci = L->ci; + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + ar.i_ci = ci; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + ci->callstatus |= CIST_HOOKED; + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + ci->callstatus &= ~CIST_HOOKED; + } +} + + +static void callhook (lua_State *L, CallInfo *ci) { + int hook = LUA_HOOKCALL; + ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ + if (isLua(ci->previous) && + GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) { + ci->callstatus |= CIST_TAIL; + hook = LUA_HOOKTAILCALL; + } + luaD_hook(L, hook, -1); + ci->u.l.savedpc--; /* correct 'pc' */ +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + StkId base, fixed; + lua_assert(actual >= nfixargs); + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed + i); + setnilvalue(fixed + i); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) + + +/* +** returns true if function has been executed (C function) +*/ +int luaD_precall (lua_State *L, StkId func, int nresults) { + lua_CFunction f; + CallInfo *ci; + int n; /* number of arguments (Lua) or returns (C) */ + ptrdiff_t funcr = savestack(L, func); + switch (ttype(func)) { + case LUA_TLCF: /* light C function */ + f = fvalue(func); + goto Cfunc; + case LUA_TCCL: { /* C closure */ + f = clCvalue(func)->f; + Cfunc: + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = restorestack(L, funcr); + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->callstatus = 0; + if (L->hookmask & LUA_MASKCALL) + luaD_hook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*f)(L); /* do the actual call */ + lua_lock(L); + api_checknelems(L, n); + luaD_poscall(L, L->top - n); + return 1; + } + case LUA_TLCL: { /* Lua function: prepare its call */ + StkId base; + Proto *p = clLvalue(func)->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + n = cast_int(L->top - func) - 1; /* number of real arguments */ + for (; n < p->numparams; n++) + setnilvalue(L->top++); /* complete missing arguments */ + base = (!p->is_vararg) ? func + 1 : adjust_varargs(L, p, n); + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = func; + ci->u.l.base = base; + ci->top = base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + ci->u.l.savedpc = p->code; /* starting point */ + ci->callstatus = CIST_LUA; + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) + callhook(L, ci); + return 0; + } + default: { /* not a function */ + func = tryfuncTM(L, func); /* retry with 'function' tag method */ + return luaD_precall(L, func, nresults); /* now it must be a function */ + } + } +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci = L->ci; + if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) { + if (L->hookmask & LUA_MASKRET) { + ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */ + luaD_hook(L, LUA_HOOKRET, -1); + firstResult = restorestack(L, fr); + } + L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ + } + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->ci = ci = ci->previous; /* back to caller */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (!allowyield) L->nny++; + if (!luaD_precall(L, func, nResults)) /* is a Lua function? */ + luaV_execute(L); /* call it */ + if (!allowyield) L->nny--; + L->nCcalls--; + luaC_checkGC(L); +} + + +static void finishCcall (lua_State *L) { + CallInfo *ci = L->ci; + int n; + lua_assert(ci->u.c.k != NULL); /* must have a continuation */ + lua_assert(L->nny == 0); + /* finish 'lua_callk' */ + adjustresults(L, ci->nresults); + /* call continuation function */ + if (!(ci->callstatus & CIST_STAT)) /* no call status? */ + ci->u.c.status = LUA_YIELD; /* 'default' status */ + lua_assert(ci->u.c.status != LUA_OK); + ci->callstatus = (ci->callstatus & ~(CIST_YPCALL | CIST_STAT)) | CIST_YIELDED; + lua_unlock(L); + n = (*ci->u.c.k)(L); + lua_lock(L); + api_checknelems(L, n); + /* finish 'luaD_precall' */ + luaD_poscall(L, L->top - n); +} + + +static void unroll (lua_State *L, void *ud) { + UNUSED(ud); + for (;;) { + if (L->ci == &L->base_ci) /* stack is empty? */ + return; /* coroutine finished normally */ + if (!isLua(L->ci)) /* C function? */ + finishCcall(L); + else { /* Lua function */ + luaV_finishOp(L); /* finish interrupted instruction */ + luaV_execute(L); /* execute down to higher C 'boundary' */ + } + } +} + + +/* +** check whether thread has a suspended protected call +*/ +static CallInfo *findpcall (lua_State *L) { + CallInfo *ci; + for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */ + if (ci->callstatus & CIST_YPCALL) + return ci; + } + return NULL; /* no pending pcall */ +} + + +static int recover (lua_State *L, int status) { + StkId oldtop; + CallInfo *ci = findpcall(L); + if (ci == NULL) return 0; /* no recovery point */ + /* "finish" luaD_pcall */ + oldtop = restorestack(L, ci->extra); + luaF_close(L, oldtop); + seterrorobj(L, status, oldtop); + L->ci = ci; + L->allowhook = ci->u.c.old_allowhook; + L->nny = 0; /* should be zero to be yieldable */ + luaD_shrinkstack(L); + L->errfunc = ci->u.c.old_errfunc; + ci->callstatus |= CIST_STAT; /* call has error status */ + ci->u.c.status = status; /* (here it is) */ + return 1; /* continue running the coroutine */ +} + + +/* +** signal an error in the call to 'resume', not in the execution of the +** coroutine itself. (Such errors should not be handled by any coroutine +** error handler and should not kill the coroutine.) +*/ +static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { + L->top = firstArg; /* remove args from the stack */ + setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ + incr_top(L); + luaD_throw(L, -1); /* jump back to 'lua_resume' */ +} + + +/* +** do the work for 'lua_resume' in protected mode +*/ +static void resume (lua_State *L, void *ud) { + int nCcalls = L->nCcalls; + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (nCcalls >= LUAI_MAXCCALLS) + resume_error(L, "C stack overflow", firstArg); + if (L->status == LUA_OK) { /* may be starting a coroutine */ + if (ci != &L->base_ci) /* not in base level? */ + resume_error(L, "cannot resume non-suspended coroutine", firstArg); + /* coroutine is in base level; start running it */ + if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ + luaV_execute(L); /* call it */ + } + else if (L->status != LUA_YIELD) + resume_error(L, "cannot resume dead coroutine", firstArg); + else { /* resuming from previous yield */ + L->status = LUA_OK; + ci->func = restorestack(L, ci->extra); + if (isLua(ci)) /* yielded inside a hook? */ + luaV_execute(L); /* just continue running Lua code */ + else { /* 'common' yield */ + if (ci->u.c.k != NULL) { /* does it have a continuation? */ + int n; + ci->u.c.status = LUA_YIELD; /* 'default' status */ + ci->callstatus |= CIST_YIELDED; + lua_unlock(L); + n = (*ci->u.c.k)(L); /* call continuation */ + lua_lock(L); + api_checknelems(L, n); + firstArg = L->top - n; /* yield results come from continuation */ + } + luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ + } + unroll(L, NULL); + } + lua_assert(nCcalls == L->nCcalls); +} + + +LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { + int status; + lua_lock(L); + luai_userstateresume(L, nargs); + L->nCcalls = (from) ? from->nCcalls + 1 : 1; + L->nny = 0; /* allow yields */ + api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status == -1) /* error calling 'lua_resume'? */ + status = LUA_ERRRUN; + else { /* yield or regular error */ + while (status != LUA_OK && status != LUA_YIELD) { /* error? */ + if (recover(L, status)) /* recover point? */ + status = luaD_rawrunprotected(L, unroll, NULL); /* run continuation */ + else { /* unrecoverable error */ + L->status = cast_byte(status); /* mark thread as `dead' */ + seterrorobj(L, status, L->top); + L->ci->top = L->top; + break; + } + } + lua_assert(status == L->status); + } + L->nny = 1; /* do not allow yields */ + L->nCcalls--; + lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); + lua_unlock(L); + return status; +} + + +LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { + CallInfo *ci = L->ci; + luai_userstateyield(L, nresults); + lua_lock(L); + api_checknelems(L, nresults); + if (L->nny > 0) { + if (L != G(L)->mainthread) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + else + luaG_runerror(L, "attempt to yield from outside a coroutine"); + } + L->status = LUA_YIELD; + ci->extra = savestack(L, ci->func); /* save current 'func' */ + if (isLua(ci)) { /* inside a hook? */ + api_check(L, k == NULL, "hooks cannot continue after yielding"); + } + else { + if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ + ci->u.c.ctx = ctx; /* save context */ + ci->func = L->top - nresults - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); + } + lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ + lua_unlock(L); + return 0; /* return to 'luaD_hook' */ +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + CallInfo *old_ci = L->ci; + lu_byte old_allowhooks = L->allowhook; + unsigned short old_nny = L->nny; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != LUA_OK) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close possible pending closures */ + seterrorobj(L, status, oldtop); + L->ci = old_ci; + L->allowhook = old_allowhooks; + L->nny = old_nny; + luaD_shrinkstack(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* dynamic structure used by the scanner */ + Dyndata dyd; /* dynamic structures used by the parser */ + const char *mode; + const char *name; +}; + + +static void checkmode (lua_State *L, const char *mode, const char *x) { + if (mode && strchr(mode, x[0]) == NULL) { + luaO_pushfstring(L, + "attempt to load a %s chunk (mode is " LUA_QS ")", x, mode); + luaD_throw(L, LUA_ERRSYNTAX); + } +} + + +static void f_parser (lua_State *L, void *ud) { + int i; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = zgetc(p->z); /* read first character */ + if (c == LUA_SIGNATURE[0]) { + checkmode(L, p->mode, "binary"); + cl = luaU_undump(L, p->z, &p->buff, p->name); + } + else { + checkmode(L, p->mode, "text"); + cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); + } + lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); + for (i = 0; i < cl->l.nupvalues; i++) { /* initialize upvalues */ + UpVal *up = luaF_newupval(L); + cl->l.upvals[i] = up; + luaC_objbarrier(L, cl, up); + } +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode) { + struct SParser p; + int status; + L->nny++; /* cannot yield during parsing */ + p.z = z; p.name = name; p.mode = mode; + p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; + p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; + p.dyd.label.arr = NULL; p.dyd.label.size = 0; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); + luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); + luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); + L->nny--; + return status; +} + + diff --git a/dep/lualib/ldo.h b/dep/lualib/ldo.h new file mode 100644 index 000000000..1f27b0f72 --- /dev/null +++ b/dep/lualib/ldo.h @@ -0,0 +1,46 @@ +/* +** $Id: ldo.h,v 2.20 2011/11/29 15:55:08 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ + luaD_growstack(L, n); else condmovestack(L); + + +#define incr_top(L) {L->top++; luaD_checkstack(L,0);} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode); +LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, + int allowyield); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); +LUAI_FUNC void luaD_shrinkstack (lua_State *L); + +LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +#endif + diff --git a/dep/lualib/ldump.c b/dep/lualib/ldump.c new file mode 100644 index 000000000..0f1d00d55 --- /dev/null +++ b/dep/lualib/ldump.c @@ -0,0 +1,173 @@ +/* +** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size*sizeof(char),D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttypenv(o),D); + switch (ttypenv(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: lua_assert(0); + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],D); +} + +static void DumpUpvalues(const Proto* f, DumpState* D) +{ + int i,n=f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i].instack,D); + DumpChar(f->upvalues[i].idx,D); + } +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + DumpString((D->strip) ? NULL : f->source,D); + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i].name,D); +} + +static void DumpFunction(const Proto* f, DumpState* D) +{ + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpUpvalues(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + lu_byte h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,&D); + return D.status; +} diff --git a/dep/lualib/lfunc.c b/dep/lualib/lfunc.c new file mode 100644 index 000000000..1a781f2c9 --- /dev/null +++ b/dep/lualib/lfunc.c @@ -0,0 +1,161 @@ +/* +** $Id: lfunc.c,v 2.29 2012/05/08 13:53:33 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int n) { + Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl; + c->c.nupvalues = cast_byte(n); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int n) { + Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl; + c->l.p = NULL; + c->l.nupvalues = cast_byte(n); + while (n--) c->l.upvals[n] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), NULL, 0)->uv; + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = gco2uv(*pp))->v >= level) { + GCObject *o = obj2gco(p); + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, o)) /* is it dead? */ + changewhite(o); /* resurrect it */ + return p; + } + resetoldbit(o); /* may create a newer upval after this one */ + pp = &p->next; + } + /* not found: create a new one */ + uv = &luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal), pp, 0)->uv; + uv->v = level; /* current value lives in the stack */ + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = gco2uv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); /* remove upvalue from 'uvhead' list */ + setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ + uv->v = &uv->u.value; /* now current value lives here */ + gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */ + g->allgc = o; + luaC_checkupvalcolor(g, uv); + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = &luaC_newobj(L, LUA_TPROTO, sizeof(Proto), NULL, 0)->p; + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->cache = NULL; + f->sizecode = 0; + f->lineinfo = NULL; + f->sizelineinfo = 0; + f->upvalues = NULL; + f->sizeupvalues = 0; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->locvars = NULL; + f->sizelocvars = 0; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode); + luaM_freearray(L, f->p, f->sizep); + luaM_freearray(L, f->k, f->sizek); + luaM_freearray(L, f->lineinfo, f->sizelineinfo); + luaM_freearray(L, f->locvars, f->sizelocvars); + luaM_freearray(L, f->upvalues, f->sizeupvalues); + luaM_free(L, f); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/dep/lualib/lfunc.h b/dep/lualib/lfunc.h new file mode 100644 index 000000000..b6c04b453 --- /dev/null +++ b/dep/lualib/lfunc.h @@ -0,0 +1,33 @@ +/* +** $Id: lfunc.h,v 2.8 2012/05/08 13:53:33 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/dep/lualib/lgc.c b/dep/lualib/lgc.c new file mode 100644 index 000000000..9e5dee6ce --- /dev/null +++ b/dep/lualib/lgc.c @@ -0,0 +1,1205 @@ +/* +** $Id: lgc.c,v 2.133 2012/05/31 21:28:59 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +/* +** cost of sweeping one element (the size of a small object divided +** by some adjust for the sweep speed) +*/ +#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) + +/* maximum number of elements to sweep in each single step */ +#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) + +/* maximum number of finalizers to call in each GC step */ +#define GCFINALIZENUM 4 + + +/* +** macro to adjust 'stepmul': 'stepmul' is actually used like +** 'stepmul / STEPMULADJ' (value chosen by tests) +*/ +#define STEPMULADJ 200 + +/* +** macro to adjust 'pause': 'pause' is actually used like +** 'pause / PAUSEADJ' (value chosen by tests) +*/ +#define PAUSEADJ 200 + + + + +/* +** standard negative debt for GC; a reasonable "time" to wait before +** starting a new cycle +*/ +#define stddebtest(g,e) (-cast(l_mem, (e)/PAUSEADJ) * g->gcpause) +#define stddebt(g) stddebtest(g, gettotalbytes(g)) + + +/* +** 'makewhite' erases all color bits plus the old bit and then +** sets only the current white bit +*/ +#define maskcolors (~(bit2mask(BLACKBIT, OLDBIT) | WHITEBITS)) +#define makewhite(g,x) \ + (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g))) + +#define white2gray(x) resetbits(gch(x)->marked, WHITEBITS) +#define black2gray(x) resetbit(gch(x)->marked, BLACKBIT) + + +#define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT) + +#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) + + +#define checkconsistency(obj) \ + lua_longassert(!iscollectable(obj) || righttt(obj)) + + +#define markvalue(g,o) { checkconsistency(o); \ + if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if ((t) && iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + +static void reallymarkobject (global_State *g, GCObject *o); + + +/* +** {====================================================== +** Generic functions +** ======================================================= +*/ + + +/* +** one after last element in a hash array +*/ +#define gnodelast(h) gnode(h, cast(size_t, sizenode(h))) + + +/* +** link table 'h' into list pointed by 'p' +*/ +#define linktable(h,p) ((h)->gclist = *(p), *(p) = obj2gco(h)) + + +/* +** if key is not marked, mark its entry as dead (therefore removing it +** from the table) +*/ +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (valiswhite(gkey(n))) + setdeadvalue(gkey(n)); /* unused and unmarked key; remove it */ +} + + +/* +** tells whether a key or value can be cleared from a weak +** table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for objects +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (global_State *g, const TValue *o) { + if (!iscollectable(o)) return 0; + else if (ttisstring(o)) { + markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + else return iswhite(gcvalue(o)); +} + + +/* +** barrier that moves collector forward, that is, mark the white object +** being pointed by a black object. +*/ +void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(isgenerational(g) || g->gcstate != GCSpause); + lua_assert(gch(o)->tt != LUA_TTABLE); + if (keepinvariant(g)) /* must keep invariant? */ + reallymarkobject(g, v); /* restore invariant */ + else { /* sweep phase */ + lua_assert(issweepphase(g)); + makewhite(g, o); /* mark main obj. as white to avoid other barriers */ + } +} + + +/* +** barrier that moves collector backward, that is, mark the black object +** pointing to a white object as gray again. (Current implementation +** only works for tables; access to 'gclist' is not uniform across +** different types.) +*/ +void luaC_barrierback_ (lua_State *L, GCObject *o) { + global_State *g = G(L); + lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE); + black2gray(o); /* make object gray (again) */ + gco2t(o)->gclist = g->grayagain; + g->grayagain = o; +} + + +/* +** barrier for prototypes. When creating first closure (cache is +** NULL), use a forward barrier; this may be the only closure of the +** prototype (if it is a "regular" function, with a single instance) +** and the prototype may be big, so it is better to avoid traversing +** it again. Otherwise, use a backward barrier, to avoid marking all +** possible instances. +*/ +LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) { + global_State *g = G(L); + lua_assert(isblack(obj2gco(p))); + if (p->cache == NULL) { /* first time? */ + luaC_objbarrier(L, p, c); + } + else { /* use a backward barrier */ + black2gray(obj2gco(p)); /* make prototype gray (again) */ + p->gclist = g->grayagain; + g->grayagain = obj2gco(p); + } +} + + +/* +** check color (and invariants) for an upvalue that was closed, +** i.e., moved into the 'allgc' list +*/ +void luaC_checkupvalcolor (global_State *g, UpVal *uv) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o)); /* open upvalues are never black */ + if (isgray(o)) { + if (keepinvariant(g)) { + resetoldbit(o); /* see MOVE OLD rule */ + gray2black(o); /* it is being visited now */ + markvalue(g, uv->v); + } + else { + lua_assert(issweepphase(g)); + makewhite(g, o); + } + } +} + + +/* +** create a new collectable object (with given type and size) and link +** it to '*list'. 'offset' tells how many bytes to allocate before the +** object itself (used only by states). +*/ +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, + int offset) { + global_State *g = G(L); + char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); + GCObject *o = obj2gco(raw + offset); + if (list == NULL) + list = &g->allgc; /* standard list for collectable objects */ + gch(o)->marked = luaC_white(g); + gch(o)->tt = tt; + gch(o)->next = *list; + *list = o; + return o; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Mark functions +** ======================================================= +*/ + + +/* +** mark an object. Userdata, strings, and closed upvalues are visited +** and turned black here. Other objects are marked gray and added +** to appropriate list to be visited (and turned black) later. (Open +** upvalues are already linked in 'headuv' list.) +*/ +static void reallymarkobject (global_State *g, GCObject *o) { + lu_mem size; + white2gray(o); + switch (gch(o)->tt) { + case LUA_TSHRSTR: + case LUA_TLNGSTR: { + size = sizestring(gco2ts(o)); + break; /* nothing else to mark; make it black */ + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + markobject(g, mt); + markobject(g, gco2u(o)->env); + size = sizeudata(gco2u(o)); + break; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v != &uv->u.value) /* open? */ + return; /* open upvalues remain gray */ + size = sizeof(UpVal); + break; + } + case LUA_TLCL: { + gco2lcl(o)->gclist = g->gray; + g->gray = o; + return; + } + case LUA_TCCL: { + gco2ccl(o)->gclist = g->gray; + g->gray = o; + return; + } + case LUA_TTABLE: { + linktable(gco2t(o), &g->gray); + return; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + return; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + return; + } + default: lua_assert(0); return; + } + gray2black(o); + g->GCmemtrav += size; +} + + +/* +** mark metamethods for basic types +*/ +static void markmt (global_State *g) { + int i; + for (i=0; i < LUA_NUMTAGS; i++) + markobject(g, g->mt[i]); +} + + +/* +** mark all objects in list of being-finalized +*/ +static void markbeingfnz (global_State *g) { + GCObject *o; + for (o = g->tobefnz; o != NULL; o = gch(o)->next) { + makewhite(g, o); + reallymarkobject(g, o); + } +} + + +/* +** mark all values stored in marked open upvalues. (See comment in +** 'lstate.h'.) +*/ +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +/* +** mark root set and reset all gray lists, to start a new +** incremental (or full) collection +*/ +static void markroot (global_State *g) { + g->gray = g->grayagain = NULL; + g->weak = g->allweak = g->ephemeron = NULL; + markobject(g, g->mainthread); + markvalue(g, &g->l_registry); + markmt(g); + markbeingfnz(g); /* mark any finalizing object left from previous cycle */ +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Traverse functions +** ======================================================= +*/ + +static void traverseweakvalue (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + /* if there is array part, assume it may have white values (do not + traverse it just to check) */ + int hasclears = (h->sizearray > 0); + for (n = gnode(h, 0); n < limit; n++) { + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ + hasclears = 1; /* table will have to be cleared */ + } + } + if (hasclears) + linktable(h, &g->weak); /* has to be cleared later */ + else /* no white values */ + linktable(h, &g->grayagain); /* no need to clean */ +} + + +static int traverseephemeron (global_State *g, Table *h) { + int marked = 0; /* true if an object is marked in this traversal */ + int hasclears = 0; /* true if table has white keys */ + int prop = 0; /* true if table has entry "white-key -> white-value" */ + Node *n, *limit = gnodelast(h); + int i; + /* traverse array part (numeric keys are 'strong') */ + for (i = 0; i < h->sizearray; i++) { + if (valiswhite(&h->array[i])) { + marked = 1; + reallymarkobject(g, gcvalue(&h->array[i])); + } + } + /* traverse hash part */ + for (n = gnode(h, 0); n < limit; n++) { + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ + hasclears = 1; /* table must be cleared */ + if (valiswhite(gval(n))) /* value not marked yet? */ + prop = 1; /* must propagate again */ + } + else if (valiswhite(gval(n))) { /* value not marked yet? */ + marked = 1; + reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ + } + } + if (prop) + linktable(h, &g->ephemeron); /* have to propagate again */ + else if (hasclears) /* does table have white keys? */ + linktable(h, &g->allweak); /* may have to clean white keys */ + else /* no white keys */ + linktable(h, &g->grayagain); /* no need to clean */ + return marked; +} + + +static void traversestrongtable (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + int i; + for (i = 0; i < h->sizearray; i++) /* traverse array part */ + markvalue(g, &h->array[i]); + for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + markvalue(g, gval(n)); /* mark value */ + } + } +} + + +static lu_mem traversetable (global_State *g, Table *h) { + const char *weakkey, *weakvalue; + const TValue *mode = gfasttm(g, h->metatable, TM_MODE); + markobject(g, h->metatable); + if (mode && ttisstring(mode) && /* is there a weak mode? */ + ((weakkey = strchr(svalue(mode), 'k')), + (weakvalue = strchr(svalue(mode), 'v')), + (weakkey || weakvalue))) { /* is really weak? */ + black2gray(obj2gco(h)); /* keep table gray */ + if (!weakkey) /* strong keys? */ + traverseweakvalue(g, h); + else if (!weakvalue) /* strong values? */ + traverseephemeron(g, h); + else /* all weak */ + linktable(h, &g->allweak); /* nothing to traverse now */ + } + else /* not weak */ + traversestrongtable(g, h); + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); +} + + +static int traverseproto (global_State *g, Proto *f) { + int i; + if (f->cache && iswhite(obj2gco(f->cache))) + f->cache = NULL; /* allow cache to be collected */ + markobject(g, f->source); + for (i = 0; i < f->sizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ + markobject(g, f->upvalues[i].name); + for (i = 0; i < f->sizep; i++) /* mark nested protos */ + markobject(g, f->p[i]); + for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ + markobject(g, f->locvars[i].varname); + return sizeof(Proto) + sizeof(Instruction) * f->sizecode + + sizeof(Proto *) * f->sizep + + sizeof(TValue) * f->sizek + + sizeof(int) * f->sizelineinfo + + sizeof(LocVar) * f->sizelocvars + + sizeof(Upvaldesc) * f->sizeupvalues; +} + + +static lu_mem traverseCclosure (global_State *g, CClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->upvalue[i]); + return sizeCclosure(cl->nupvalues); +} + +static lu_mem traverseLclosure (global_State *g, LClosure *cl) { + int i; + markobject(g, cl->p); /* mark its prototype */ + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->upvals[i]); + return sizeLclosure(cl->nupvalues); +} + + +static lu_mem traversestack (global_State *g, lua_State *th) { + StkId o = th->stack; + if (o == NULL) + return 1; /* stack not completely built yet */ + for (; o < th->top; o++) + markvalue(g, o); + if (g->gcstate == GCSatomic) { /* final traversal? */ + StkId lim = th->stack + th->stacksize; /* real end of stack */ + for (; o < lim; o++) /* clear not-marked stack slice */ + setnilvalue(o); + } + return sizeof(lua_State) + sizeof(TValue) * th->stacksize; +} + + +/* +** traverse one gray object, turning it to black (except for threads, +** which are always gray). +*/ +static void propagatemark (global_State *g) { + lu_mem size; + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (gch(o)->tt) { + case LUA_TTABLE: { + Table *h = gco2t(o); + g->gray = h->gclist; /* remove from 'gray' list */ + size = traversetable(g, h); + break; + } + case LUA_TLCL: { + LClosure *cl = gco2lcl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseLclosure(g, cl); + break; + } + case LUA_TCCL: { + CClosure *cl = gco2ccl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseCclosure(g, cl); + break; + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; /* remove from 'gray' list */ + th->gclist = g->grayagain; + g->grayagain = o; /* insert into 'grayagain' list */ + black2gray(o); + size = traversestack(g, th); + break; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; /* remove from 'gray' list */ + size = traverseproto(g, p); + break; + } + default: lua_assert(0); return; + } + g->GCmemtrav += size; +} + + +static void propagateall (global_State *g) { + while (g->gray) propagatemark(g); +} + + +static void propagatelist (global_State *g, GCObject *l) { + lua_assert(g->gray == NULL); /* no grays left */ + g->gray = l; + propagateall(g); /* traverse all elements from 'l' */ +} + +/* +** retraverse all gray lists. Because tables may be reinserted in other +** lists when traversed, traverse the original lists to avoid traversing +** twice the same table (which is not wrong, but inefficient) +*/ +static void retraversegrays (global_State *g) { + GCObject *weak = g->weak; /* save original lists */ + GCObject *grayagain = g->grayagain; + GCObject *ephemeron = g->ephemeron; + g->weak = g->grayagain = g->ephemeron = NULL; + propagateall(g); /* traverse main gray list */ + propagatelist(g, grayagain); + propagatelist(g, weak); + propagatelist(g, ephemeron); +} + + +static void convergeephemerons (global_State *g) { + int changed; + do { + GCObject *w; + GCObject *next = g->ephemeron; /* get ephemeron list */ + g->ephemeron = NULL; /* tables will return to this list when traversed */ + changed = 0; + while ((w = next) != NULL) { + next = gco2t(w)->gclist; + if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ + propagateall(g); /* propagate changes */ + changed = 1; /* will have to revisit all ephemeron tables */ + } + } + } while (changed); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Sweep Functions +** ======================================================= +*/ + + +/* +** clear entries with unmarked keys from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearkeys (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +/* +** clear entries with unmarked values from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearvalues (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + int i; + for (i = 0; i < h->sizearray; i++) { + TValue *o = &h->array[i]; + if (iscleared(g, o)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (gch(o)->tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TLCL: { + luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues)); + break; + } + case LUA_TCCL: { + luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); + break; + } + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2t(o)); break; + case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; + case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; + case LUA_TSHRSTR: + G(L)->strt.nuse--; + /* go through */ + case LUA_TLNGSTR: { + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + default: lua_assert(0); + } +} + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count); + + +/* +** sweep the (open) upvalues of a thread and resize its stack and +** list of call-info structures. +*/ +static void sweepthread (lua_State *L, lua_State *L1) { + if (L1->stack == NULL) return; /* stack not completely built yet */ + sweepwholelist(L, &L1->openupval); /* sweep open upvalues */ + luaE_freeCI(L1); /* free extra CallInfo slots */ + /* should not change the stack during an emergency gc cycle */ + if (G(L)->gckind != KGC_EMERGENCY) + luaD_shrinkstack(L1); +} + + +/* +** sweep at most 'count' elements from a list of GCObjects erasing dead +** objects, where a dead (not alive) object is one marked with the "old" +** (non current) white and not fixed. +** In non-generational mode, change all non-dead objects back to white, +** preparing for next collection cycle. +** In generational mode, keep black objects black, and also mark them as +** old; stop when hitting an old object, as all objects after that +** one will be old too. +** When object is a thread, sweep its list of open upvalues too. +*/ +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + global_State *g = G(L); + int ow = otherwhite(g); + int toclear, toset; /* bits to clear and to set in all live objects */ + int tostop; /* stop sweep when this is true */ + if (isgenerational(g)) { /* generational mode? */ + toclear = ~0; /* clear nothing */ + toset = bitmask(OLDBIT); /* set the old bit of all surviving objects */ + tostop = bitmask(OLDBIT); /* do not sweep old generation */ + } + else { /* normal mode */ + toclear = maskcolors; /* clear all color bits + old bit */ + toset = luaC_white(g); /* make object white */ + tostop = 0; /* do not stop */ + } + while (*p != NULL && count-- > 0) { + GCObject *curr = *p; + int marked = gch(curr)->marked; + if (isdeadm(ow, marked)) { /* is 'curr' dead? */ + *p = gch(curr)->next; /* remove 'curr' from list */ + freeobj(L, curr); /* erase 'curr' */ + } + else { + if (testbits(marked, tostop)) + return NULL; /* stop sweeping this list */ + if (gch(curr)->tt == LUA_TTHREAD) + sweepthread(L, gco2th(curr)); /* sweep thread's upvalues */ + /* update marks */ + gch(curr)->marked = cast_byte((marked & toclear) | toset); + p = &gch(curr)->next; /* go to next element */ + } + } + return (*p == NULL) ? NULL : p; +} + + +/* +** sweep a list until a live object (or end of list) +*/ +static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { + GCObject ** old = p; + int i = 0; + do { + i++; + p = sweeplist(L, p, 1); + } while (p == old); + if (n) *n += i; + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Finalization +** ======================================================= +*/ + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + if (g->gckind != KGC_EMERGENCY) { /* do not change sizes in emergency */ + int hs = g->strt.size / 2; /* half the size of the string table */ + if (g->strt.nuse < cast(lu_int32, hs)) /* using less than that half? */ + luaS_resize(L, hs); /* halve its size */ + luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */ + } +} + + +static GCObject *udata2finalize (global_State *g) { + GCObject *o = g->tobefnz; /* get first element */ + lua_assert(isfinalized(o)); + g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */ + gch(o)->next = g->allgc; /* return it to 'allgc' list */ + g->allgc = o; + resetbit(gch(o)->marked, SEPARATED); /* mark that it is not in 'tobefnz' */ + lua_assert(!isold(o)); /* see MOVE OLD rule */ + if (!keepinvariant(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + return o; +} + + +static void dothecall (lua_State *L, void *ud) { + UNUSED(ud); + luaD_call(L, L->top - 2, 0, 0); +} + + +static void GCTM (lua_State *L, int propagateerrors) { + global_State *g = G(L); + const TValue *tm; + TValue v; + setgcovalue(L, &v, udata2finalize(g)); + tm = luaT_gettmbyobj(L, &v, TM_GC); + if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */ + int status; + lu_byte oldah = L->allowhook; + int running = g->gcrunning; + L->allowhook = 0; /* stop debug hooks during GC metamethod */ + g->gcrunning = 0; /* avoid GC steps */ + setobj2s(L, L->top, tm); /* push finalizer... */ + setobj2s(L, L->top + 1, &v); /* ... and its argument */ + L->top += 2; /* and (next line) call the finalizer */ + status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); + L->allowhook = oldah; /* restore hooks */ + g->gcrunning = running; /* restore state */ + if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ + if (status == LUA_ERRRUN) { /* is there an error object? */ + const char *msg = (ttisstring(L->top - 1)) + ? svalue(L->top - 1) + : "no message"; + luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); + status = LUA_ERRGCMM; /* error in __gc metamethod */ + } + luaD_throw(L, status); /* re-throw error */ + } + } +} + + +/* +** move all unreachable objects (or 'all' objects) that need +** finalization from list 'finobj' to list 'tobefnz' (to be finalized) +*/ +static void separatetobefnz (lua_State *L, int all) { + global_State *g = G(L); + GCObject **p = &g->finobj; + GCObject *curr; + GCObject **lastnext = &g->tobefnz; + /* find last 'next' field in 'tobefnz' list (to add elements in its end) */ + while (*lastnext != NULL) + lastnext = &gch(*lastnext)->next; + while ((curr = *p) != NULL) { /* traverse all finalizable objects */ + lua_assert(!isfinalized(curr)); + lua_assert(testbit(gch(curr)->marked, SEPARATED)); + if (!(all || iswhite(curr))) /* not being collected? */ + p = &gch(curr)->next; /* don't bother with it */ + else { + l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ + *p = gch(curr)->next; /* remove 'curr' from 'finobj' list */ + gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ + *lastnext = curr; + lastnext = &gch(curr)->next; + } + } +} + + +/* +** if object 'o' has a finalizer, remove it from 'allgc' list (must +** search the list to find it) and link it in 'finobj' list. +*/ +void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { + global_State *g = G(L); + if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */ + isfinalized(o) || /* ... or is finalized... */ + gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ + return; /* nothing to be done */ + else { /* move 'o' to 'finobj' list */ + GCObject **p; + GCheader *ho = gch(o); + if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */ + lua_assert(issweepphase(g)); + g->sweepgc = sweeptolive(L, g->sweepgc, NULL); + } + /* search for pointer pointing to 'o' */ + for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } + *p = ho->next; /* remove 'o' from root list */ + ho->next = g->finobj; /* link it in list 'finobj' */ + g->finobj = o; + l_setbit(ho->marked, SEPARATED); /* mark it as such */ + if (!keepinvariant(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + else + resetoldbit(o); /* see MOVE OLD rule */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** GC control +** ======================================================= +*/ + + +#define sweepphases \ + (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep)) + + +/* +** enter first sweep phase (strings) and prepare pointers for other +** sweep phases. The calls to 'sweeptolive' make pointers point to an +** object inside the list (instead of to the header), so that the real +** sweep do not need to skip objects created between "now" and the start +** of the real sweep. +** Returns how many objects it sweeped. +*/ +static int entersweep (lua_State *L) { + global_State *g = G(L); + int n = 0; + g->gcstate = GCSsweepstring; + lua_assert(g->sweepgc == NULL && g->sweepfin == NULL); + /* prepare to sweep strings, finalizable objects, and regular objects */ + g->sweepstrgc = 0; + g->sweepfin = sweeptolive(L, &g->finobj, &n); + g->sweepgc = sweeptolive(L, &g->allgc, &n); + return n; +} + + +/* +** change GC mode +*/ +void luaC_changemode (lua_State *L, int mode) { + global_State *g = G(L); + if (mode == g->gckind) return; /* nothing to change */ + if (mode == KGC_GEN) { /* change to generational mode */ + /* make sure gray lists are consistent */ + luaC_runtilstate(L, bitmask(GCSpropagate)); + g->GCestimate = gettotalbytes(g); + g->gckind = KGC_GEN; + } + else { /* change to incremental mode */ + /* sweep all objects to turn them back to white + (as white has not changed, nothing extra will be collected) */ + g->gckind = KGC_NORMAL; + entersweep(L); + luaC_runtilstate(L, ~sweepphases); + } +} + + +/* +** call all pending finalizers +*/ +static void callallpendingfinalizers (lua_State *L, int propagateerrors) { + global_State *g = G(L); + while (g->tobefnz) { + resetoldbit(g->tobefnz); + GCTM(L, propagateerrors); + } +} + + +void luaC_freeallobjects (lua_State *L) { + global_State *g = G(L); + int i; + separatetobefnz(L, 1); /* separate all objects with finalizers */ + lua_assert(g->finobj == NULL); + callallpendingfinalizers(L, 0); + g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ + g->gckind = KGC_NORMAL; + sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */ + sweepwholelist(L, &g->allgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); + lua_assert(g->strt.nuse == 0); +} + + +static l_mem atomic (lua_State *L) { + global_State *g = G(L); + l_mem work = -g->GCmemtrav; /* start counting work */ + GCObject *origweak, *origall; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + /* registry and global metatables may be changed by API */ + markvalue(g, &g->l_registry); + markmt(g); /* mark basic metatables */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + propagateall(g); /* propagate changes */ + work += g->GCmemtrav; /* stop counting (do not (re)count grays) */ + /* traverse objects caught by write barrier and by 'remarkupvals' */ + retraversegrays(g); + work -= g->GCmemtrav; /* restart counting */ + convergeephemerons(g); + /* at this point, all strongly accessible objects are marked. */ + /* clear values from weak tables, before checking finalizers */ + clearvalues(g, g->weak, NULL); + clearvalues(g, g->allweak, NULL); + origweak = g->weak; origall = g->allweak; + work += g->GCmemtrav; /* stop counting (objects being finalized) */ + separatetobefnz(L, 0); /* separate objects to be finalized */ + markbeingfnz(g); /* mark objects that will be finalized */ + propagateall(g); /* remark, to propagate `preserveness' */ + work -= g->GCmemtrav; /* restart counting */ + convergeephemerons(g); + /* at this point, all resurrected objects are marked. */ + /* remove dead objects from weak tables */ + clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ + clearkeys(g, g->allweak, NULL); /* clear keys from all allweak tables */ + /* clear values from resurrected weak tables */ + clearvalues(g, g->weak, origweak); + clearvalues(g, g->allweak, origall); + g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ + work += g->GCmemtrav; /* complete counting */ + return work; /* estimate of memory marked by 'atomic' */ +} + + +static lu_mem singlestep (lua_State *L) { + global_State *g = G(L); + switch (g->gcstate) { + case GCSpause: { + g->GCmemtrav = 0; /* start to count memory traversed */ + if (!isgenerational(g)) + markroot(g); /* start a new collection */ + /* in any case, root must be marked at this point */ + lua_assert(!iswhite(obj2gco(g->mainthread)) + && !iswhite(gcvalue(&g->l_registry))); + g->gcstate = GCSpropagate; + return g->GCmemtrav; + } + case GCSpropagate: { + if (g->gray) { + lu_mem oldtrav = g->GCmemtrav; + propagatemark(g); + return g->GCmemtrav - oldtrav; /* memory traversed in this step */ + } + else { /* no more `gray' objects */ + lu_mem work; + int sw; + g->gcstate = GCSatomic; /* finish mark phase */ + g->GCestimate = g->GCmemtrav; /* save what was counted */; + work = atomic(L); /* add what was traversed by 'atomic' */ + g->GCestimate += work; /* estimate of total memory traversed */ + sw = entersweep(L); + return work + sw * GCSWEEPCOST; + } + } + case GCSsweepstring: { + int i; + for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++) + sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]); + g->sweepstrgc += i; + if (g->sweepstrgc >= g->strt.size) /* no more strings to sweep? */ + g->gcstate = GCSsweepudata; + return i * GCSWEEPCOST; + } + case GCSsweepudata: { + if (g->sweepfin) { + g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX); + return GCSWEEPMAX*GCSWEEPCOST; + } + else { + g->gcstate = GCSsweep; + return 0; + } + } + case GCSsweep: { + if (g->sweepgc) { + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + return GCSWEEPMAX*GCSWEEPCOST; + } + else { + /* sweep main thread */ + GCObject *mt = obj2gco(g->mainthread); + sweeplist(L, &mt, 1); + checkSizes(L); + g->gcstate = GCSpause; /* finish collection */ + return GCSWEEPCOST; + } + } + default: lua_assert(0); return 0; + } +} + + +/* +** advances the garbage collector until it reaches a state allowed +** by 'statemask' +*/ +void luaC_runtilstate (lua_State *L, int statesmask) { + global_State *g = G(L); + while (!testbit(statesmask, g->gcstate)) + singlestep(L); +} + + +static void generationalcollection (lua_State *L) { + global_State *g = G(L); + if (g->GCestimate == 0) { /* signal for another major collection? */ + luaC_fullgc(L, 0); /* perform a full regular collection */ + g->GCestimate = gettotalbytes(g); /* update control */ + } + else { + lu_mem estimate = g->GCestimate; + luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ + luaC_runtilstate(L, bitmask(GCSpause)); + if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) + g->GCestimate = 0; /* signal for a major collection */ + } + luaE_setdebt(g, stddebt(g)); +} + + +static void incstep (lua_State *L) { + global_State *g = G(L); + l_mem debt = g->GCdebt; + int stepmul = g->gcstepmul; + if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values */ + /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */ + debt = (debt / STEPMULADJ) + 1; + debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; + do { /* always perform at least one single step */ + lu_mem work = singlestep(L); /* do some work */ + debt -= work; + } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); + if (g->gcstate == GCSpause) + debt = stddebtest(g, g->GCestimate); /* pause until next cycle */ + else + debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */ + luaE_setdebt(g, debt); +} + + +/* +** performs a basic GC step +*/ +void luaC_forcestep (lua_State *L) { + global_State *g = G(L); + int i; + if (isgenerational(g)) generationalcollection(L); + else incstep(L); + /* run a few finalizers (or all of them at the end of a collect cycle) */ + for (i = 0; g->tobefnz && (i < GCFINALIZENUM || g->gcstate == GCSpause); i++) + GCTM(L, 1); /* call one finalizer */ +} + + +/* +** performs a basic GC step only if collector is running +*/ +void luaC_step (lua_State *L) { + global_State *g = G(L); + if (g->gcrunning) luaC_forcestep(L); + else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */ +} + + + +/* +** performs a full GC cycle; if "isemergency", does not call +** finalizers (which could change stack positions) +*/ +void luaC_fullgc (lua_State *L, int isemergency) { + global_State *g = G(L); + int origkind = g->gckind; + int someblack = keepinvariant(g); + lua_assert(origkind != KGC_EMERGENCY); + if (isemergency) /* do not run finalizers during emergency GC */ + g->gckind = KGC_EMERGENCY; + else { + g->gckind = KGC_NORMAL; + callallpendingfinalizers(L, 1); + } + if (someblack) { /* may there be some black objects? */ + /* must sweep all objects to turn them back to white + (as white has not changed, nothing will be collected) */ + entersweep(L); + } + /* finish any pending sweep phase to start a new cycle */ + luaC_runtilstate(L, bitmask(GCSpause)); + /* run entire collector */ + luaC_runtilstate(L, ~bitmask(GCSpause)); + luaC_runtilstate(L, bitmask(GCSpause)); + if (origkind == KGC_GEN) { /* generational mode? */ + /* generational mode must always start in propagate phase */ + luaC_runtilstate(L, bitmask(GCSpropagate)); + } + g->gckind = origkind; + luaE_setdebt(g, stddebt(g)); + if (!isemergency) /* do not run finalizers during emergency GC */ + callallpendingfinalizers(L, 1); +} + +/* }====================================================== */ + + diff --git a/dep/lualib/lgc.h b/dep/lualib/lgc.h new file mode 100644 index 000000000..48547a932 --- /dev/null +++ b/dep/lualib/lgc.h @@ -0,0 +1,147 @@ +/* +** $Id: lgc.h,v 2.56 2012/05/23 15:43:14 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" +#include "lstate.h" + +/* +** Collectable objects may have one of three colors: white, which +** means the object is not marked; gray, which means the +** object is marked, but its references may be not marked; and +** black, which means that the object and all its references are marked. +** The main invariant of the garbage collector, while marking objects, +** is that a black object can never point to a white one. Moreover, +** any gray object must be in a "gray list" (gray, grayagain, weak, +** allweak, ephemeron) so that it can be visited again before finishing +** the collection cycle. These lists have no meaning when the invariant +** is not being enforced (e.g., sweep phase). +*/ + + + +/* how much to allocate before next GC step */ +#if !defined(GCSTEPSIZE) +/* ~100 small strings */ +#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) +#endif + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpropagate 0 +#define GCSatomic 1 +#define GCSsweepstring 2 +#define GCSsweepudata 3 +#define GCSsweep 4 +#define GCSpause 5 + + +#define issweepphase(g) \ + (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep) + +#define isgenerational(g) ((g)->gckind == KGC_GEN) + +/* +** macro to tell when main invariant (white objects cannot point to black +** ones) must be kept. During a non-generational collection, the sweep +** phase may break the invariant, as objects turned white may point to +** still-black objects. The invariant is restored when sweep ends and +** all objects are white again. During a generational collection, the +** invariant must be kept all times. +*/ +#define keepinvariant(g) (isgenerational(g) || g->gcstate <= GCSatomic) + + +/* +** some useful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) + + +/* Layout for bit use in `marked' field: */ +#define WHITE0BIT 0 /* object is white (type 0) */ +#define WHITE1BIT 1 /* object is white (type 1) */ +#define BLACKBIT 2 /* object is black */ +#define FINALIZEDBIT 3 /* object has been separated for finalization */ +#define SEPARATED 4 /* object is in 'finobj' list or in 'tobefnz' */ +#define FIXEDBIT 5 /* object is fixed (should not be collected) */ +#define OLDBIT 6 /* object is old (only in generational mode) */ +/* bit 7 is currently used by tests (luaL_checkmemory) */ + +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) testbits((x)->gch.marked, WHITEBITS) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) /* neither white nor black */ \ + (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) + +#define isold(x) testbit((x)->gch.marked, OLDBIT) + +/* MOVE OLD rule: whenever an object is moved to the beginning of + a GC list, its old bit must be cleared */ +#define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) +#define isdead(g,v) isdeadm(otherwhite(g), (v)->gch.marked) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_condGC(L,c) \ + {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);} +#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);) + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrier_(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barrierback(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierback_(L,p); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrier_(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarrierback(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); } + +#define luaC_barrierproto(L,p,c) \ + { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } + +LUAI_FUNC void luaC_freeallobjects (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_forcestep (lua_State *L); +LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); +LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); +LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, + GCObject **list, int offset); +LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); +LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c); +LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); +LUAI_FUNC void luaC_checkupvalcolor (global_State *g, UpVal *uv); +LUAI_FUNC void luaC_changemode (lua_State *L, int mode); + +#endif diff --git a/dep/lualib/linit.c b/dep/lualib/linit.c new file mode 100644 index 000000000..6fe9bd34c --- /dev/null +++ b/dep/lualib/linit.c @@ -0,0 +1,67 @@ +/* +** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $ +** Initialization of libraries for lua.c and other clients +** See Copyright Notice in lua.h +*/ + + +/* +** If you embed Lua in your program and need to open the standard +** libraries, call luaL_openlibs in your program. If you need a +** different set of libraries, copy this file to your project and edit +** it to suit your needs. +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +/* +** these libs are loaded by lua.c and are readily available to any Lua +** program +*/ +static const luaL_Reg loadedlibs[] = { + {"_G", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_COLIBNAME, luaopen_coroutine}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_BITLIBNAME, luaopen_bit32}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +/* +** these libs are preloaded and must be required before used +*/ +static const luaL_Reg preloadedlibs[] = { + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib; + /* call open functions from 'loadedlibs' and set results to global table */ + for (lib = loadedlibs; lib->func; lib++) { + luaL_requiref(L, lib->name, lib->func, 1); + lua_pop(L, 1); /* remove lib */ + } + /* add open functions from 'preloadedlibs' into 'package.preload' table */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); + for (lib = preloadedlibs; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_setfield(L, -2, lib->name); + } + lua_pop(L, 1); /* remove _PRELOAD table */ +} + diff --git a/dep/lualib/liolib.c b/dep/lualib/liolib.c new file mode 100644 index 000000000..95c9d4476 --- /dev/null +++ b/dep/lualib/liolib.c @@ -0,0 +1,657 @@ +/* +** $Id: liolib.c,v 2.108 2011/11/25 12:50:03 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +/* +** POSIX idiosyncrasy! +** This definition must come before the inclusion of 'stdio.h'; it +** should not affect non-POSIX systems +*/ +#if !defined(_FILE_OFFSET_BITS) +#define _FILE_OFFSET_BITS 64 +#endif + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +/* +** {====================================================== +** lua_popen spawns a new process connected to the current +** one through the file streams. +** ======================================================= +*/ + +#if !defined(lua_popen) /* { */ + +#if defined(LUA_USE_POPEN) /* { */ + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, pclose(file)) + +#elif defined(LUA_WIN) /* }{ */ + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, _pclose(file)) + + +#else /* }{ */ + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), -1) + + +#endif /* } */ + +#endif /* } */ + +/* }====================================================== */ + + +/* +** {====================================================== +** lua_fseek/lua_ftell: configuration for longer offsets +** ======================================================= +*/ + +#if !defined(lua_fseek) /* { */ + +#if defined(LUA_USE_POSIX) + +#define l_fseek(f,o,w) fseeko(f,o,w) +#define l_ftell(f) ftello(f) +#define l_seeknum off_t + +#elif defined(LUA_WIN) && !defined(_CRTIMP_TYPEINFO) \ + && defined(_MSC_VER) && (_MSC_VER >= 1400) +/* Windows (but not DDK) and Visual C++ 2005 or higher */ + +#define l_fseek(f,o,w) _fseeki64(f,o,w) +#define l_ftell(f) _ftelli64(f) +#define l_seeknum __int64 + +#else + +#define l_fseek(f,o,w) fseek(f,o,w) +#define l_ftell(f) ftell(f) +#define l_seeknum long + +#endif + +#endif /* } */ + +/* }====================================================== */ + + +#define IO_PREFIX "_IO_" +#define IO_INPUT (IO_PREFIX "input") +#define IO_OUTPUT (IO_PREFIX "output") + + +typedef luaL_Stream LStream; + + +#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + +#define isclosed(p) ((p)->closef == NULL) + + +static int io_type (lua_State *L) { + LStream *p; + luaL_checkany(L, 1); + p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE); + if (p == NULL) + lua_pushnil(L); /* not a file */ + else if (isclosed(p)) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static int f_tostring (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", p->f); + return 1; +} + + +static FILE *tofile (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + luaL_error(L, "attempt to use a closed file"); + lua_assert(p->f); + return p->f; +} + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static LStream *newprefile (lua_State *L) { + LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); + p->closef = NULL; /* mark file handle as 'closed' */ + luaL_setmetatable(L, LUA_FILEHANDLE); + return p; +} + + +static int aux_close (lua_State *L) { + LStream *p = tolstream(L); + lua_CFunction cf = p->closef; + p->closef = NULL; /* mark stream as closed */ + return (*cf)(L); /* close it */ +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) /* no argument? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ + tofile(L); /* make sure argument is an open stream */ + return aux_close(L); +} + + +static int f_gc (lua_State *L) { + LStream *p = tolstream(L); + if (!isclosed(p) && p->f != NULL) + aux_close(L); /* ignore closed and incompletely open files */ + return 0; +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + LStream *p = tolstream(L); + int res = fclose(p->f); + return luaL_fileresult(L, (res == 0), NULL); +} + + +static LStream *newfile (lua_State *L) { + LStream *p = newprefile(L); + p->f = NULL; + p->closef = &io_fclose; + return p; +} + + +static void opencheck (lua_State *L, const char *fname, const char *mode) { + LStream *p = newfile(L); + p->f = fopen(fname, mode); + if (p->f == NULL) + luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno)); +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + LStream *p = newfile(L); + int i = 0; + /* check whether 'mode' matches '[rwa]%+?b?' */ + if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL && + (mode[i] != '+' || ++i) && /* skip if char is '+' */ + (mode[i] != 'b' || ++i) && /* skip if char is 'b' */ + (mode[i] == '\0'))) + return luaL_error(L, "invalid mode " LUA_QS + " (should match " LUA_QL("[rwa]%%+?b?") ")", mode); + p->f = fopen(filename, mode); + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + LStream *p = tolstream(L); + return luaL_execresult(L, lua_pclose(L, p->f)); +} + + +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + LStream *p = newprefile(L); + p->f = lua_popen(L, filename, mode); + p->closef = &io_pclose; + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + LStream *p = newfile(L); + p->f = tmpfile(); + return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, const char *findex) { + LStream *p; + lua_getfield(L, LUA_REGISTRYINDEX, findex); + p = (LStream *)lua_touserdata(L, -1); + if (isclosed(p)) + luaL_error(L, "standard %s file is closed", findex + strlen(IO_PREFIX)); + return p->f; +} + + +static int g_iofile (lua_State *L, const char *f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) + opencheck(L, filename, mode); + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_setfield(L, LUA_REGISTRYINDEX, f); + } + /* return current value */ + lua_getfield(L, LUA_REGISTRYINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int toclose) { + int i; + int n = lua_gettop(L) - 1; /* number of arguments to read */ + /* ensure that arguments will fit here and into 'io_readline' stack */ + luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options"); + lua_pushvalue(L, 1); /* file handle */ + lua_pushinteger(L, n); /* number of arguments to read */ + lua_pushboolean(L, toclose); /* close/not close file when finished */ + for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */ + lua_pushcclosure(L, io_readline, 3 + n); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + int toclose; + if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ + if (lua_isnil(L, 1)) { /* no file name? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */ + lua_replace(L, 1); /* put it at index 1 */ + tofile(L); /* check that it's a valid file handle */ + toclose = 0; /* do not close it after iteration */ + } + else { /* open a new file */ + const char *filename = luaL_checkstring(L, 1); + opencheck(L, filename, "r"); + lua_replace(L, 1); /* put file at index 1 */ + toclose = 1; /* close it after iteration */ + } + aux_lines(L, toclose); + return 1; +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else { + lua_pushnil(L); /* "result" to be removed */ + return 0; /* read fails */ + } +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f, int chop) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_rawlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - chop); /* chop 'eol' if needed */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +#define MAX_SIZE_T (~(size_t)0) + +static void read_all (lua_State *L, FILE *f) { + size_t rlen = LUAL_BUFFERSIZE; /* how much to read in each cycle */ + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + char *p = luaL_prepbuffsize(&b, rlen); + size_t nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + if (nr < rlen) break; /* eof? */ + else if (rlen <= (MAX_SIZE_T / 4)) /* avoid buffers too large */ + rlen *= 2; /* double buffer size at each iteration */ + } + luaL_pushresult(&b); /* close buffer */ +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t nr; /* number of chars actually read */ + char *p; + luaL_Buffer b; + luaL_buffinit(L, &b); + p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ + nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ + luaL_addsize(&b, nr); + luaL_pushresult(&b); /* close buffer */ + return (nr > 0); /* true iff read something */ +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f, 1); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f, 1); + break; + case 'L': /* line with end-of-line */ + success = read_line(L, f, 0); + break; + case 'a': /* file */ + read_all(L, f); /* read entire file */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return luaL_fileresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); + int i; + int n = (int)lua_tointeger(L, lua_upvalueindex(2)); + if (isclosed(p)) /* file is already closed? */ + return luaL_error(L, "file is already closed"); + lua_settop(L , 1); + for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ + lua_pushvalue(L, lua_upvalueindex(3 + i)); + n = g_read(L, p->f, 2); /* 'n' is number of results */ + lua_assert(n > 0); /* should return at least a nil */ + if (!lua_isnil(L, -n)) /* read at least one value? */ + return n; /* return them */ + else { /* first result is nil: EOF or error */ + if (n > 1) { /* is there error information? */ + /* 2nd result is error message */ + return luaL_error(L, "%s", lua_tostring(L, -n + 1)); + } + if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - arg; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + if (status) return 1; /* file handle already on stack top */ + else return luaL_fileresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + FILE *f = tofile(L); + lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ + return g_write(L, f, 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + lua_Number p3 = luaL_optnumber(L, 3, 0); + l_seeknum offset = (l_seeknum)p3; + luaL_argcheck(L, (lua_Number)offset == p3, 3, + "not an integer in proper range"); + op = l_fseek(f, offset, mode[op]); + if (op) + return luaL_fileresult(L, 0, NULL); /* error */ + else { + lua_pushnumber(L, (lua_Number)l_ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return luaL_fileresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); +} + + +/* +** functions for 'io' library +*/ +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +/* +** methods for file handles +*/ +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", f_gc}, + {"__tostring", f_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ + lua_pop(L, 1); /* pop new metatable */ +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + LStream *p = tolstream(L); + p->closef = &io_noclose; /* keep file opened */ + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +static void createstdfile (lua_State *L, FILE *f, const char *k, + const char *fname) { + LStream *p = newprefile(L); + p->f = f; + p->closef = &io_noclose; + if (k != NULL) { + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */ + } + lua_setfield(L, -2, fname); /* add file to module */ +} + + +LUAMOD_API int luaopen_io (lua_State *L) { + luaL_newlib(L, iolib); /* new module */ + createmeta(L); + /* create (and set) default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, NULL, "stderr"); + return 1; +} + diff --git a/dep/lualib/llex.c b/dep/lualib/llex.c new file mode 100644 index 000000000..f997d7a85 --- /dev/null +++ b/dep/lualib/llex.c @@ -0,0 +1,527 @@ +/* +** $Id: llex.c,v 2.61 2012/01/23 23:05:51 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "lctype.h" +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +static const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "goto", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", "::", "", + "", "", "" +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static l_noret lexerror (LexState *ls, const char *msg, int token); + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) { + size_t newsize; + if (luaZ_sizebuffer(b) >= MAX_SIZET/2) + lexerror(ls, "lexical element too long", 0); + newsize = luaZ_sizebuffer(b) * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[luaZ_bufflen(b)++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.extra = cast_byte(i+1); /* reserved word */ + } +} + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) : + luaO_pushfstring(ls->L, "char(%d)", token); + } + else { + const char *s = luaX_tokens[token - FIRST_RESERVED]; + if (token < TK_EOS) + return luaO_pushfstring(ls->L, LUA_QS, s); + else + return s; + } +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaO_pushfstring(ls->L, LUA_QS, luaZ_buffer(ls->buff)); + default: + return luaX_token2str(ls, token); + } +} + + +static l_noret lexerror (LexState *ls, const char *msg, int token) { + char buff[LUA_IDSIZE]; + luaO_chunkid(buff, getstr(ls->source), LUA_IDSIZE); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near %s", msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +l_noret luaX_syntaxerror (LexState *ls, const char *msg) { + lexerror(ls, msg, ls->t.token); +} + + +/* +** creates a new string and anchors it in function's table so that +** it will not be collected until the end of the function's compilation +** (by that time it should be anchored in function's prototype) +*/ +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TValue *o; /* entry for `str' */ + TString *ts = luaS_newlstr(L, str, l); /* create new string */ + setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */ + o = luaH_set(L, ls->fs->h, L->top - 1); + if (ttisnil(o)) { /* not in use yet? (see 'addK') */ + /* boolean value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setbvalue(o, 1); /* t[string] = true */ + luaC_checkGC(L); + } + L->top--; /* remove string from stack */ + return ts; +} + + +/* +** increment line number and skips newline sequence (any of +** \n, \r, \n\r, or \r\n) +*/ +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, + int firstchar) { + ls->decpoint = '.'; + ls->L = L; + ls->current = firstchar; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + ls->envn = luaS_new(L, LUA_ENV); /* create env name */ + luaS_fix(ls->envn); /* never collect this name */ + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (ls->current == '\0' || !strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +/* +** change all characters 'from' in buffer to 'to' +*/ +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +#if !defined(getlocaledecpoint) +#define getlocaledecpoint() (localeconv()->decimal_point[0]) +#endif + + +#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e) + +/* +** in case of format error, try to change decimal point separator to +** the one defined in the current locale and check again +*/ +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + char old = ls->decpoint; + ls->decpoint = getlocaledecpoint(); + buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ + if (!buff2d(ls->buff, &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +/* +** this function is quite liberal in what it accepts, as 'luaO_str2d' +** will reject ill-formed numerals. +*/ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + const char *expo = "Ee"; + int first = ls->current; + lua_assert(lisdigit(ls->current)); + save_and_next(ls); + if (first == '0' && check_next(ls, "Xx")) /* hexadecimal? */ + expo = "Pp"; + for (;;) { + if (check_next(ls, expo)) /* exponent part? */ + check_next(ls, "+-"); /* optional exponent sign */ + if (lisxdigit(ls->current) || ls->current == '.') + save_and_next(ls); + else break; + } + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!buff2d(ls->buff, &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +/* +** skip a sequence '[=*[' or ']=*]' and return its number of '='s or +** -1 if sequence is malformed +*/ +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ + goto endloop; + } + break; + } + case '\n': case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void escerror (LexState *ls, int *c, int n, const char *msg) { + int i; + luaZ_resetbuffer(ls->buff); /* prepare error message */ + save(ls, '\\'); + for (i = 0; i < n && c[i] != EOZ; i++) + save(ls, c[i]); + lexerror(ls, msg, TK_STRING); +} + + +static int readhexaesc (LexState *ls) { + int c[3], i; /* keep input for error message */ + int r = 0; /* result accumulator */ + c[0] = 'x'; /* for error message */ + for (i = 1; i < 3; i++) { /* read two hexa digits */ + c[i] = next(ls); + if (!lisxdigit(c[i])) + escerror(ls, c, i + 1, "hexadecimal digit expected"); + r = (r << 4) + luaO_hexavalue(c[i]); + } + return r; +} + + +static int readdecesc (LexState *ls) { + int c[3], i; + int r = 0; /* result accumulator */ + for (i = 0; i < 3 && lisdigit(ls->current); i++) { /* read up to 3 digits */ + c[i] = ls->current; + r = 10*r + c[i] - '0'; + next(ls); + } + if (r > UCHAR_MAX) + escerror(ls, c, i, "decimal escape too large"); + return r; +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); /* keep delimiter (for error messages) */ + while (ls->current != del) { + switch (ls->current) { + case EOZ: + lexerror(ls, "unfinished string", TK_EOS); + break; /* to avoid warnings */ + case '\n': + case '\r': + lexerror(ls, "unfinished string", TK_STRING); + break; /* to avoid warnings */ + case '\\': { /* escape sequences */ + int c; /* final character to be saved */ + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; goto read_save; + case 'b': c = '\b'; goto read_save; + case 'f': c = '\f'; goto read_save; + case 'n': c = '\n'; goto read_save; + case 'r': c = '\r'; goto read_save; + case 't': c = '\t'; goto read_save; + case 'v': c = '\v'; goto read_save; + case 'x': c = readhexaesc(ls); goto read_save; + case '\n': case '\r': + inclinenumber(ls); c = '\n'; goto only_save; + case '\\': case '\"': case '\'': + c = ls->current; goto read_save; + case EOZ: goto no_save; /* will raise an error next loop */ + case 'z': { /* zap following span of spaces */ + next(ls); /* skip the 'z' */ + while (lisspace(ls->current)) { + if (currIsNewline(ls)) inclinenumber(ls); + else next(ls); + } + goto no_save; + } + default: { + if (!lisdigit(ls->current)) + escerror(ls, &ls->current, 1, "invalid escape sequence"); + /* digital escape \ddd */ + c = readdecesc(ls); + goto only_save; + } + } + read_save: next(ls); /* read next character */ + only_save: save(ls, c); /* save 'c' */ + no_save: break; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': case '\r': { /* line breaks */ + inclinenumber(ls); + break; + } + case ' ': case '\f': case '\t': case '\v': { /* spaces */ + next(ls); + break; + } + case '-': { /* '-' or '--' (comment) */ + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { /* long comment? */ + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* skip long comment */ + luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ + break; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); /* skip until end of line (or end of file) */ + break; + } + case '[': { /* long string or simply '[' */ + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case ':': { + next(ls); + if (ls->current != ':') return ':'; + else { next(ls); return TK_DBCOLON; } + } + case '"': case '\'': { /* short literal strings */ + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { /* '.', '..', '...', or number */ + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* '...' */ + else return TK_CONCAT; /* '..' */ + } + else if (!lisdigit(ls->current)) return '.'; + /* else go through */ + } + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + case EOZ: { + return TK_EOS; + } + default: { + if (lislalpha(ls->current)) { /* identifier or reserved word? */ + TString *ts; + do { + save_and_next(ls); + } while (lislalnum(ls->current)); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + seminfo->ts = ts; + if (isreserved(ts)) /* reserved word? */ + return ts->tsv.extra - 1 + FIRST_RESERVED; + else { + return TK_NAME; + } + } + else { /* single-char tokens (+ - / ...) */ + int c = ls->current; + next(ls); + return c; + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +int luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); + return ls->lookahead.token; +} + diff --git a/dep/lualib/llex.h b/dep/lualib/llex.h new file mode 100644 index 000000000..532a07bbf --- /dev/null +++ b/dep/lualib/llex.h @@ -0,0 +1,78 @@ +/* +** $Id: llex.h,v 1.72 2011/11/30 12:43:51 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, + TK_NUMBER, TK_NAME, TK_STRING +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +/* state of the lexer plus state of the parser when shared by all + functions */ +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* current function (parser) */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + struct Dyndata *dyd; /* dynamic structures used by the parser */ + TString *source; /* current source name */ + TString *envn; /* environment variable name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source, int firstchar); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC int luaX_lookahead (LexState *ls); +LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/dep/lualib/llimits.h b/dep/lualib/llimits.h new file mode 100644 index 000000000..9db3b99c1 --- /dev/null +++ b/dep/lualib/llimits.h @@ -0,0 +1,309 @@ +/* +** $Id: llimits.h,v 1.99 2012/05/28 20:32:28 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef unsigned LUA_INT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + +#define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2)) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +#if !defined(LUAI_USER_ALIGNMENT_T) +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } +#endif + +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#if defined(lua_assert) +#define check_exp(c,e) (lua_assert(c), (e)) +/* to avoid problems with conditions too long */ +#define lua_longassert(c) { if (!(c)) lua_assert(0); } +#else +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define lua_longassert(c) ((void)0) +#endif + +/* +** assertion for checking API calls +*/ +#if !defined(luai_apicheck) + +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,e) assert(e) +#else +#define luai_apicheck(L,e) lua_assert(e) +#endif + +#endif + +#define api_check(l,e,msg) luai_apicheck(l,(e) && msg) + + +#if !defined(UNUSED) +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#define cast(t, exp) ((t)(exp)) + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) +#define cast_uchar(i) cast(unsigned char, (i)) + + +/* +** non-return type +*/ +#if defined(__GNUC__) +#define l_noret void __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define l_noret void __declspec(noreturn) +#else +#define l_noret void +#endif + + + +/* +** maximum depth for nested C calls and syntactical nested non-terminals +** in a program. (Value must fit in an unsigned short int.) +*/ +#if !defined(LUAI_MAXCCALLS) +#define LUAI_MAXCCALLS 200 +#endif + +/* +** maximum number of upvalues in a closure (both C and Lua). (Value +** must fit in an unsigned char.) +*/ +#define MAXUPVAL UCHAR_MAX + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#if !defined(MINSTRTABSIZE) +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#if !defined(LUA_MINBUFFER) +#define LUA_MINBUFFER 32 +#endif + + +#if !defined(lua_lock) +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#if !defined(luai_threadyield) +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** these macros allow user-specific actions on threads when you defined +** LUAI_EXTRASPACE and need to do something extra when a thread is +** created/deleted/resumed/yielded. +*/ +#if !defined(luai_userstateopen) +#define luai_userstateopen(L) ((void)L) +#endif + +#if !defined(luai_userstateclose) +#define luai_userstateclose(L) ((void)L) +#endif + +#if !defined(luai_userstatethread) +#define luai_userstatethread(L,L1) ((void)L) +#endif + +#if !defined(luai_userstatefree) +#define luai_userstatefree(L,L1) ((void)L) +#endif + +#if !defined(luai_userstateresume) +#define luai_userstateresume(L,n) ((void)L) +#endif + +#if !defined(luai_userstateyield) +#define luai_userstateyield(L,n) ((void)L) +#endif + +/* +** lua_number2int is a macro to convert lua_Number to int. +** lua_number2integer is a macro to convert lua_Number to lua_Integer. +** lua_number2unsigned is a macro to convert a lua_Number to a lua_Unsigned. +** lua_unsigned2number is a macro to convert a lua_Unsigned to a lua_Number. +** luai_hashnum is a macro to hash a lua_Number value into an integer. +** The hash must be deterministic and give reasonable values for +** both small and large values (outside the range of integers). +*/ + +#if defined(MS_ASMTRICK) /* { */ +/* trick with Microsoft assembler for X86 */ + +#define lua_number2int(i,n) __asm {__asm fld n __asm fistp i} +#define lua_number2integer(i,n) lua_number2int(i, n) +#define lua_number2unsigned(i,n) \ + {__int64 l; __asm {__asm fld n __asm fistp l} i = (unsigned int)l;} + + +#elif defined(LUA_IEEE754TRICK) /* }{ */ +/* the next trick should work on any machine using IEEE754 with + a 32-bit int type */ + +union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; + +#if !defined(LUA_IEEEENDIAN) /* { */ +#define LUAI_EXTRAIEEE \ + static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)}; +#define LUA_IEEEENDIANLOC (ieeeendian.l_p[1] == 33) +#else +#define LUA_IEEEENDIANLOC LUA_IEEEENDIAN +#define LUAI_EXTRAIEEE /* empty */ +#endif /* } */ + +#define lua_number2int32(i,n,t) \ + { LUAI_EXTRAIEEE \ + volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \ + (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; } + +#define luai_hashnum(i,n) \ + { volatile union luai_Cast u; u.l_d = (n) + 1.0; /* avoid -0 */ \ + (i) = u.l_p[0]; (i) += u.l_p[1]; } /* add double bits for his hash */ + +#define lua_number2int(i,n) lua_number2int32(i, n, int) +#define lua_number2unsigned(i,n) lua_number2int32(i, n, lua_Unsigned) + +/* the trick can be expanded to lua_Integer when it is a 32-bit value */ +#if defined(LUA_IEEELL) +#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer) +#endif + +#endif /* } */ + + +/* the following definitions always work, but may be slow */ + +#if !defined(lua_number2int) +#define lua_number2int(i,n) ((i)=(int)(n)) +#endif + +#if !defined(lua_number2integer) +#define lua_number2integer(i,n) ((i)=(lua_Integer)(n)) +#endif + +#if !defined(lua_number2unsigned) /* { */ +/* the following definition assures proper modulo behavior */ +#if defined(LUA_NUMBER_DOUBLE) +#include +#define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1) +#define lua_number2unsigned(i,n) \ + ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED)) +#else +#define lua_number2unsigned(i,n) ((i)=(lua_Unsigned)(n)) +#endif +#endif /* } */ + + +#if !defined(lua_unsigned2number) +/* on several machines, coercion from unsigned to double is slow, + so it may be worth to avoid */ +#define lua_unsigned2number(u) \ + (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u)) +#endif + + + +#if defined(ltable_c) && !defined(luai_hashnum) + +#include +#include + +#define luai_hashnum(i,n) { int e; \ + n = frexp(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ + lua_number2int(i, n); i += e; } + +#endif + + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#if !defined(HARDSTACKTESTS) +#define condmovestack(L) ((void)0) +#else +/* realloc stack keeping its size */ +#define condmovestack(L) luaD_reallocstack((L), (L)->stacksize) +#endif + +#if !defined(HARDMEMTESTS) +#define condchangemem(L) condmovestack(L) +#else +#define condchangemem(L) \ + ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1))) +#endif + +#endif diff --git a/dep/lualib/lmathlib.c b/dep/lualib/lmathlib.c new file mode 100644 index 000000000..9bafb5d16 --- /dev/null +++ b/dep/lualib/lmathlib.c @@ -0,0 +1,283 @@ +/* +** $Id: lmathlib.c,v 1.81 2012/05/18 17:47:53 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro 'l_tg' allows the addition of an 'l' or 'f' to all math operations */ +#if !defined(l_tg) +#define l_tg(x) (x) +#endif + + +#undef PI +#define PI (l_tg(3.1415926535897932384626433832795)) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, l_tg(sin)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, l_tg(sinh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, l_tg(cos)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, l_tg(cosh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, l_tg(tan)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, l_tg(tanh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, l_tg(asin)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, l_tg(acos)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, l_tg(atan)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, l_tg(atan2)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, l_tg(ceil)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, l_tg(floor)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, l_tg(fmod)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + lua_Number ip; + lua_Number fp = l_tg(modf)(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, l_tg(sqrt)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, l_tg(pow)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_Number x = luaL_checknumber(L, 1); + lua_Number res; + if (lua_isnoneornil(L, 2)) + res = l_tg(log)(x); + else { + lua_Number base = luaL_checknumber(L, 2); + if (base == 10.0) res = l_tg(log10)(x); + else res = l_tg(log)(x)/l_tg(log)(base); + } + lua_pushnumber(L, res); + return 1; +} + +#if defined(LUA_COMPAT_LOG10) +static int math_log10 (lua_State *L) { + lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1))); + return 1; +} +#endif + +static int math_exp (lua_State *L) { + lua_pushnumber(L, l_tg(exp)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, l_tg(frexp)(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, l_tg(ldexp)(luaL_checknumber(L, 1), + luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + lua_Number u = luaL_checknumber(L, 1); + luaL_argcheck(L, 1.0 <= u, 1, "interval is empty"); + lua_pushnumber(L, l_tg(floor)(r*u) + 1.0); /* int in [1, u] */ + break; + } + case 2: { /* lower and upper limits */ + lua_Number l = luaL_checknumber(L, 1); + lua_Number u = luaL_checknumber(L, 2); + luaL_argcheck(L, l <= u, 2, "interval is empty"); + lua_pushnumber(L, l_tg(floor)(r*(u-l+1)) + l); /* int in [l, u] */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkunsigned(L, 1)); + (void)rand(); /* discard first value to avoid undesirable correlations */ + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, +#if defined(LUA_COMPAT_LOG10) + {"log10", math_log10}, +#endif + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUAMOD_API int luaopen_math (lua_State *L) { + luaL_newlib(L, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); + return 1; +} + diff --git a/dep/lualib/lmem.c b/dep/lualib/lmem.c new file mode 100644 index 000000000..a20f68b1d --- /dev/null +++ b/dep/lualib/lmem.c @@ -0,0 +1,99 @@ +/* +** $Id: lmem.c,v 1.84 2012/05/23 15:41:53 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** * frealloc(ud, NULL, x, s) creates a new block of size `s' (no +** matter 'x'). +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL); +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *what) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, "too many %s (limit is %d)", what, limit); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +l_noret luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + void *newblock; + global_State *g = G(L); + size_t realosize = (block) ? osize : 0; + lua_assert((realosize == 0) == (block == NULL)); +#if defined(HARDMEMTESTS) + if (nsize > realosize && g->gcrunning) + luaC_fullgc(L, 1); /* force a GC whenever possible */ +#endif + newblock = (*g->frealloc)(g->ud, block, osize, nsize); + if (newblock == NULL && nsize > 0) { + api_check(L, nsize > realosize, + "realloc cannot fail when shrinking a block"); + if (g->gcrunning) { + luaC_fullgc(L, 1); /* try to free some memory... */ + newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ + } + if (newblock == NULL) + luaD_throw(L, LUA_ERRMEM); + } + lua_assert((nsize == 0) == (newblock == NULL)); + g->GCdebt = (g->GCdebt + nsize) - realosize; + return newblock; +} + diff --git a/dep/lualib/lmem.h b/dep/lualib/lmem.h new file mode 100644 index 000000000..31f78cc9c --- /dev/null +++ b/dep/lualib/lmem.h @@ -0,0 +1,50 @@ +/* +** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + (luaM_toobig(L), (void *)0) : \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e))) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) + +#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + +LUAI_FUNC l_noret luaM_toobig (lua_State *L); + +/* not to be called directly */ +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *what); + +#endif + diff --git a/dep/lualib/loadlib.c b/dep/lualib/loadlib.c new file mode 100644 index 000000000..c83961b6f --- /dev/null +++ b/dep/lualib/loadlib.c @@ -0,0 +1,725 @@ +/* +** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Windows, and a stub for other +** systems. +*/ + + +/* +** if needed, includes windows header before everything else +*/ +#if defined(_WIN32) +#include +#endif + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** LUA_PATH and LUA_CPATH are the names of the environment +** variables that Lua check to set its paths. +*/ +#if !defined(LUA_PATH) +#define LUA_PATH "LUA_PATH" +#endif + +#if !defined(LUA_CPATH) +#define LUA_CPATH "LUA_CPATH" +#endif + +#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + +#define LUA_PATHVERSION LUA_PATH LUA_PATHSUFFIX +#define LUA_CPATHVERSION LUA_CPATH LUA_PATHSUFFIX + +/* +** LUA_PATH_SEP is the character that separates templates in a path. +** LUA_PATH_MARK is the string that marks the substitution points in a +** template. +** LUA_EXEC_DIR in a Windows path is replaced by the executable's +** directory. +** LUA_IGMARK is a mark to ignore all before it when building the +** luaopen_ function name. +*/ +#if !defined (LUA_PATH_SEP) +#define LUA_PATH_SEP ";" +#endif +#if !defined (LUA_PATH_MARK) +#define LUA_PATH_MARK "?" +#endif +#if !defined (LUA_EXEC_DIR) +#define LUA_EXEC_DIR "!" +#endif +#if !defined (LUA_IGMARK) +#define LUA_IGMARK "-" +#endif + + +/* +** LUA_CSUBSEP is the character that replaces dots in submodule names +** when searching for a C loader. +** LUA_LSUBSEP is the character that replaces dots in submodule names +** when searching for a Lua loader. +*/ +#if !defined(LUA_CSUBSEP) +#define LUA_CSUBSEP LUA_DIRSEP +#endif + +#if !defined(LUA_LSUBSEP) +#define LUA_LSUBSEP LUA_DIRSEP +#endif + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +/* table (in the registry) that keeps handles for all loaded C libraries */ +#define CLIBS "_CLIBS" + +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +/* +** system-dependent functions +*/ +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path, int seeglb); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_USE_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path, int seeglb) { + void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL)); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#undef setprogdir + +/* +** optional flags for LoadLibraryEx +*/ +#if !defined(LUA_LLE_FLAGS) +#define LUA_LLE_FLAGS 0 +#endif + + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HMODULE)lib); +} + + +static void *ll_load (lua_State *L, const char *path, int seeglb) { + HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS); + (void)(seeglb); /* not used: symbols are 'global' by default */ + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)(lib); /* not used */ +} + + +static void *ll_load (lua_State *L, const char *path, int seeglb) { + (void)(path); (void)(seeglb); /* not used */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)(lib); (void)(sym); /* not used */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + +static void *ll_checkclib (lua_State *L, const char *path) { + void *plib; + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_getfield(L, -1, path); + plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ + lua_pop(L, 2); /* pop CLIBS table and 'plib' */ + return plib; +} + + +static void ll_addtoclib (lua_State *L, const char *path, void *plib) { + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_pushlightuserdata(L, plib); + lua_pushvalue(L, -1); + lua_setfield(L, -3, path); /* CLIBS[path] = plib */ + lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ + lua_pop(L, 1); /* pop CLIBS table */ +} + + +/* +** __gc tag method for CLIBS table: calls 'll_unloadlib' for all lib +** handles in list CLIBS +*/ +static int gctm (lua_State *L) { + int n = luaL_len(L, 1); + for (; n >= 1; n--) { /* for each handle, in reverse order */ + lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ + ll_unloadlib(lua_touserdata(L, -1)); + lua_pop(L, 1); /* pop handle */ + } + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void *reg = ll_checkclib(L, path); /* check loaded C libraries */ + if (reg == NULL) { /* must load library? */ + reg = ll_load(L, path, *sym == '*'); + if (reg == NULL) return ERRLIB; /* unable to load library */ + ll_addtoclib(L, path, reg); + } + if (*sym == '*') { /* loading only library (no function)? */ + lua_pushboolean(L, 1); /* return 'true' */ + return 0; /* no errors */ + } + else { + lua_CFunction f = ll_sym(L, reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); /* else create new function */ + return 0; /* no errors */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATH_SEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATH_SEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *searchpath (lua_State *L, const char *name, + const char *path, + const char *sep, + const char *dirsep) { + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + if (*sep != '\0') /* non-empty separator? */ + name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename = luaL_gsub(L, lua_tostring(L, -1), + LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + luaL_addvalue(&msg); /* concatenate error msg. entry */ + } + luaL_pushresult(&msg); /* create error message */ + return NULL; /* not found */ +} + + +static int ll_searchpath (lua_State *L) { + const char *f = searchpath(L, luaL_checkstring(L, 1), + luaL_checkstring(L, 2), + luaL_optstring(L, 3, "."), + luaL_optstring(L, 4, LUA_DIRSEP)); + if (f != NULL) return 1; + else { /* error message is on top of the stack */ + lua_pushnil(L); + lua_insert(L, -2); + return 2; /* return nil + error message */ + } +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname, + const char *dirsep) { + const char *path; + lua_getfield(L, lua_upvalueindex(1), pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + return searchpath(L, name, path, ".", dirsep); +} + + +static int checkload (lua_State *L, int stat, const char *filename) { + if (stat) { /* module loaded successfully? */ + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; /* return open function and file name */ + } + else + return luaL_error(L, "error loading module " LUA_QS + " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int searcher_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path", LUA_LSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename); +} + + +static int loadfunc (lua_State *L, const char *filename, const char *modname) { + const char *funcname; + const char *mark; + modname = luaL_gsub(L, modname, ".", LUA_OFSEP); + mark = strchr(modname, *LUA_IGMARK); + if (mark) { + int stat; + funcname = lua_pushlstring(L, modname, mark - modname); + funcname = lua_pushfstring(L, LUA_POF"%s", funcname); + stat = ll_loadfunc(L, filename, funcname); + if (stat != ERRFUNC) return stat; + modname = mark + 1; /* else go ahead and try old-style name */ + } + funcname = lua_pushfstring(L, LUA_POF"%s", modname); + return ll_loadfunc(L, filename, funcname); +} + + +static int searcher_C (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath", LUA_CSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (loadfunc(L, filename, name) == 0), filename); +} + + +static int searcher_Croot (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); + if (filename == NULL) return 1; /* root not found */ + if ((stat = loadfunc(L, filename, name)) != 0) { + if (stat != ERRFUNC) + return checkload(L, 0, filename); /* real error */ + else { /* open function not found */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; + } + } + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; +} + + +static int searcher_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static void findloader (lua_State *L, const char *name) { + int i; + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ + if (!lua_istable(L, 3)) + luaL_error(L, LUA_QL("package.searchers") " must be a table"); + /* iterate over available searchers to find a loader */ + for (i = 1; ; i++) { + lua_rawgeti(L, 3, i); /* get a searcher */ + if (lua_isnil(L, -1)) { /* no more searchers? */ + lua_pop(L, 1); /* remove nil */ + luaL_pushresult(&msg); /* create error message */ + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -1)); + } + lua_pushstring(L, name); + lua_call(L, 1, 2); /* call it */ + if (lua_isfunction(L, -2)) /* did it find a loader? */ + return; /* module loader found */ + else if (lua_isstring(L, -2)) { /* searcher returned error message? */ + lua_pop(L, 1); /* remove extra return */ + luaL_addvalue(&msg); /* concatenate error message */ + } + else + lua_pop(L, 2); /* remove both returns */ + } +} + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); /* _LOADED[name] */ + if (lua_toboolean(L, -1)) /* is it there? */ + return 1; /* package is already loaded */ + /* else must load package */ + lua_pop(L, 1); /* remove 'getfield' result */ + findloader(L, name); + lua_pushstring(L, name); /* pass name as argument to module loader */ + lua_insert(L, -2); /* name is 1st argument (before search data) */ + lua_call(L, 2, 1); /* run loader to load module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_isnil(L, -1)) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ +#if defined(LUA_COMPAT_MODULE) + +/* +** changes the environment variable of calling function +*/ +static void set_env (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); /* copy new environment table to top */ + lua_setupvalue(L, -2, 1); + lua_pop(L, 1); /* remove function */ +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int lastarg = lua_gettop(L); /* last parameter */ + luaL_pushmodule(L, modname, 1); /* get/create module table */ + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + set_env(L); + dooptions(L, lastarg); + return 1; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushglobaltable(L); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + +#endif +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + + +/* +** return registry.LUA_NOENV as a boolean +*/ +static int noenv (lua_State *L) { + int b; + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + b = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + return b; +} + + +static void setpath (lua_State *L, const char *fieldname, const char *envname1, + const char *envname2, const char *def) { + const char *path = getenv(envname1); + if (path == NULL) /* no environment variable? */ + path = getenv(envname2); /* try alternative name */ + if (path == NULL || noenv(L)) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, + LUA_PATH_SEP AUXMARK LUA_PATH_SEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"searchpath", ll_searchpath}, +#if defined(LUA_COMPAT_MODULE) + {"seeall", ll_seeall}, +#endif + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { +#if defined(LUA_COMPAT_MODULE) + {"module", ll_module}, +#endif + {"require", ll_require}, + {NULL, NULL} +}; + + +static void createsearcherstable (lua_State *L) { + static const lua_CFunction searchers[] = + {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; + int i; + /* create 'searchers' table */ + lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); + /* fill it with pre-defined searchers */ + for (i=0; searchers[i] != NULL; i++) { + lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ + lua_pushcclosure(L, searchers[i], 1); + lua_rawseti(L, -2, i+1); + } +} + + +LUAMOD_API int luaopen_package (lua_State *L) { + /* create table CLIBS to keep track of loaded C libraries */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); + lua_createtable(L, 0, 1); /* metatable for CLIBS */ + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ + lua_setmetatable(L, -2); + /* create `package' table */ + luaL_newlib(L, pk_funcs); + createsearcherstable(L); +#if defined(LUA_COMPAT_LOADERS) + lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ + lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */ +#endif + lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ + /* set field 'path' */ + setpath(L, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT); + /* set field 'cpath' */ + setpath(L, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT); + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" + LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); + lua_setfield(L, -2, "preload"); + lua_pushglobaltable(L); + lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ + luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ + lua_pop(L, 1); /* pop global table */ + return 1; /* return 'package' table */ +} + diff --git a/dep/lualib/lobject.c b/dep/lualib/lobject.c new file mode 100644 index 000000000..c32d7b6a6 --- /dev/null +++ b/dep/lualib/lobject.c @@ -0,0 +1,289 @@ +/* +** $Id: lobject.c,v 2.55 2011/11/30 19:30:16 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "lctype.h" +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* exponent */ + if (x < 8) return x; + while (x >= 0x10) { + x = (x+1) >> 1; + e++; + } + return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 0x1f; + if (e == 0) return x; + else return ((x & 7) + 8) << (e - 1); +} + + +int luaO_ceillog2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = 0; + x--; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; +} + + +lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) { + switch (op) { + case LUA_OPADD: return luai_numadd(NULL, v1, v2); + case LUA_OPSUB: return luai_numsub(NULL, v1, v2); + case LUA_OPMUL: return luai_nummul(NULL, v1, v2); + case LUA_OPDIV: return luai_numdiv(NULL, v1, v2); + case LUA_OPMOD: return luai_nummod(NULL, v1, v2); + case LUA_OPPOW: return luai_numpow(NULL, v1, v2); + case LUA_OPUNM: return luai_numunm(NULL, v1); + default: lua_assert(0); return 0; + } +} + + +int luaO_hexavalue (int c) { + if (lisdigit(c)) return c - '0'; + else return ltolower(c) - 'a' + 10; +} + + +#if !defined(lua_strx2number) + +#include + + +static int isneg (const char **s) { + if (**s == '-') { (*s)++; return 1; } + else if (**s == '+') (*s)++; + return 0; +} + + +static lua_Number readhexa (const char **s, lua_Number r, int *count) { + for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */ + r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s))); + (*count)++; + } + return r; +} + + +/* +** convert an hexadecimal numeric string to a number, following +** C99 specification for 'strtod' +*/ +static lua_Number lua_strx2number (const char *s, char **endptr) { + lua_Number r = 0.0; + int e = 0, i = 0; + int neg = 0; /* 1 if number is negative */ + *endptr = cast(char *, s); /* nothing is valid yet */ + while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ + neg = isneg(&s); /* check signal */ + if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ + return 0.0; /* invalid format (no '0x') */ + s += 2; /* skip '0x' */ + r = readhexa(&s, r, &i); /* read integer part */ + if (*s == '.') { + s++; /* skip dot */ + r = readhexa(&s, r, &e); /* read fractional part */ + } + if (i == 0 && e == 0) + return 0.0; /* invalid format (no digit) */ + e *= -4; /* each fractional digit divides value by 2^-4 */ + *endptr = cast(char *, s); /* valid up to here */ + if (*s == 'p' || *s == 'P') { /* exponent part? */ + int exp1 = 0; + int neg1; + s++; /* skip 'p' */ + neg1 = isneg(&s); /* signal */ + if (!lisdigit(cast_uchar(*s))) + goto ret; /* must have at least one digit */ + while (lisdigit(cast_uchar(*s))) /* read exponent */ + exp1 = exp1 * 10 + *(s++) - '0'; + if (neg1) exp1 = -exp1; + e += exp1; + } + *endptr = cast(char *, s); /* valid up to here */ + ret: + if (neg) r = -r; + return ldexp(r, e); +} + +#endif + + +int luaO_str2d (const char *s, size_t len, lua_Number *result) { + char *endptr; + if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */ + return 0; + else if (strpbrk(s, "xX")) /* hexa? */ + *result = lua_strx2number(s, &endptr); + else + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* nothing recognized */ + while (lisspace(cast_uchar(*endptr))) endptr++; + return (endptr == s + len); /* OK if no trailing characters */ +} + + + +static void pushstr (lua_State *L, const char *str, size_t l) { + setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 0; + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s, strlen(s)); + break; + } + case 'c': { + char buff; + buff = cast(char, va_arg(argp, int)); + pushstr(L, &buff, 1); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + int l = sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff, l); + break; + } + case '%': { + pushstr(L, "%", 1); + break; + } + default: { + luaG_runerror(L, + "invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"), + *(e + 1)); + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt, strlen(fmt)); + if (n > 0) luaV_concat(L, n + 1); + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +/* number of chars of a literal string without the ending \0 */ +#define LL(x) (sizeof(x)/sizeof(char) - 1) + +#define RETS "..." +#define PRE "[string \"" +#define POS "\"]" + +#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + size_t l = strlen(source); + if (*source == '=') { /* 'literal' source */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* truncate it */ + addstr(out, source + 1, bufflen - 1); + *out = '\0'; + } + } + else if (*source == '@') { /* file name */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* add '...' before rest of name */ + addstr(out, RETS, LL(RETS)); + bufflen -= LL(RETS); + memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char)); + } + } + else { /* string; format as [string "source"] */ + const char *nl = strchr(source, '\n'); /* find first new line (if any) */ + addstr(out, PRE, LL(PRE)); /* add prefix */ + bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */ + if (l < bufflen && nl == NULL) { /* small one-line source? */ + addstr(out, source, l); /* keep it */ + } + else { + if (nl != NULL) l = nl - source; /* stop at first newline */ + if (l > bufflen) l = bufflen; + addstr(out, source, l); + addstr(out, RETS, LL(RETS)); + } + memcpy(out, POS, (LL(POS) + 1) * sizeof(char)); + } +} + diff --git a/dep/lualib/lobject.h b/dep/lualib/lobject.h new file mode 100644 index 000000000..a593a9be1 --- /dev/null +++ b/dep/lualib/lobject.h @@ -0,0 +1,610 @@ +/* +** $Id: lobject.h,v 2.70 2012/05/11 14:10:50 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO LUA_NUMTAGS +#define LUA_TUPVAL (LUA_NUMTAGS+1) +#define LUA_TDEADKEY (LUA_NUMTAGS+2) + +/* +** number of all possible tags (including LUA_TNONE but excluding DEADKEY) +*/ +#define LUA_TOTALTAGS (LUA_TUPVAL+2) + + +/* +** tags for Tagged Values have the following use of bits: +** bits 0-3: actual tag (a LUA_T* value) +** bits 4-5: variant bits +** bit 6: whether value is collectable +*/ + +#define VARBITS (3 << 4) + + +/* +** LUA_TFUNCTION variants: +** 0 - Lua function +** 1 - light C function +** 2 - regular C function (closure) +*/ + +/* Variant tags for functions */ +#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ +#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ +#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ + + +/* +** LUA_TSTRING variants */ +#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ +#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ + + +/* Bit mark for collectable types */ +#define BIT_ISCOLLECTABLE (1 << 6) + +/* mark a tag as collectable */ +#define ctb(t) ((t) | BIT_ISCOLLECTABLE) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + +/* +** Union of all Lua values +*/ +typedef union Value Value; + + +#define numfield lua_Number n; /* numbers */ + + + +/* +** Tagged Values. This is the basic representation of values in Lua, +** an actual value plus a tag with its type. +*/ + +#define TValuefields Value value_; int tt_ + +typedef struct lua_TValue TValue; + + +/* macro defining a nil value */ +#define NILCONSTANT {NULL}, LUA_TNIL + + +#define val_(o) ((o)->value_) +#define num_(o) (val_(o).n) + + +/* raw type tag of a TValue */ +#define rttype(o) ((o)->tt_) + +/* tag with no variants (bits 0-3) */ +#define novariant(x) ((x) & 0x0F) + +/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ +#define ttype(o) (rttype(o) & 0x3F) + +/* type tag of a TValue with no variants (bits 0-3) */ +#define ttypenv(o) (novariant(rttype(o))) + + +/* Macros to test type */ +#define checktag(o,t) (rttype(o) == (t)) +#define checktype(o,t) (ttypenv(o) == (t)) +#define ttisnumber(o) checktag((o), LUA_TNUMBER) +#define ttisnil(o) checktag((o), LUA_TNIL) +#define ttisboolean(o) checktag((o), LUA_TBOOLEAN) +#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) +#define ttisstring(o) checktype((o), LUA_TSTRING) +#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) +#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) +#define ttistable(o) checktag((o), ctb(LUA_TTABLE)) +#define ttisfunction(o) checktype(o, LUA_TFUNCTION) +#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) +#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) +#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) +#define ttislcf(o) checktag((o), LUA_TLCF) +#define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA)) +#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) +#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) + +#define ttisequal(o1,o2) (rttype(o1) == rttype(o2)) + +/* Macros to access values */ +#define nvalue(o) check_exp(ttisnumber(o), num_(o)) +#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) +#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) +#define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl) +#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l) +#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c) +#define fvalue(o) check_exp(ttislcf(o), val_(o).f) +#define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h) +#define bvalue(o) check_exp(ttisboolean(o), val_(o).b) +#define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th) +/* a dead value may get the 'gc' field, but cannot access its contents */ +#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + + +#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) + + +/* Macros for internal tests */ +#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) + +#define checkliveness(g,obj) \ + lua_longassert(!iscollectable(obj) || \ + (righttt(obj) && !isdead(g,gcvalue(obj)))) + + +/* Macros to set values */ +#define settt_(o,t) ((o)->tt_=(t)) + +#define setnvalue(obj,x) \ + { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); } + +#define changenvalue(o,x) check_exp(ttisnumber(o), num_(o)=(x)) + +#define setnilvalue(obj) settt_(obj, LUA_TNIL) + +#define setfvalue(obj,x) \ + { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } + +#define setpvalue(obj,x) \ + { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } + +#define setbvalue(obj,x) \ + { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } + +#define setgcovalue(L,obj,x) \ + { TValue *io=(obj); GCObject *i_g=(x); \ + val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); } + +#define setsvalue(L,obj,x) \ + { TValue *io=(obj); \ + TString *x_ = (x); \ + val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \ + checkliveness(G(L),io); } + +#define setuvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \ + checkliveness(G(L),io); } + +#define setthvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \ + checkliveness(G(L),io); } + +#define setclLvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \ + checkliveness(G(L),io); } + +#define setclCvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \ + checkliveness(G(L),io); } + +#define sethvalue(L,obj,x) \ + { TValue *io=(obj); \ + val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \ + checkliveness(G(L),io); } + +#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) + + + +#define setobj(L,obj1,obj2) \ + { const TValue *io2=(obj2); TValue *io1=(obj1); \ + io1->value_ = io2->value_; io1->tt_ = io2->tt_; \ + checkliveness(G(L),io1); } + + +/* +** different types of assignments, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + + +/* check whether a number is valid (useful only for NaN trick) */ +#define luai_checknum(L,o,c) { /* empty */ } + + +/* +** {====================================================== +** NaN Trick +** ======================================================= +*/ +#if defined(LUA_NANTRICK) + +/* +** numbers are represented in the 'd_' field. All other values have the +** value (NNMARK | tag) in 'tt__'. A number with such pattern would be +** a "signaled NaN", which is never generated by regular operations by +** the CPU (nor by 'strtod') +*/ + +/* allows for external implementation for part of the trick */ +#if !defined(NNMARK) /* { */ + + +#if !defined(LUA_IEEEENDIAN) +#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN' +#endif + + +#define NNMARK 0x7FF7A500 +#define NNMASK 0x7FFFFF00 + +#undef TValuefields +#undef NILCONSTANT + +#if (LUA_IEEEENDIAN == 0) /* { */ + +/* little endian */ +#define TValuefields \ + union { struct { Value v__; int tt__; } i; double d__; } u +#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}} +/* field-access macros */ +#define v_(o) ((o)->u.i.v__) +#define d_(o) ((o)->u.d__) +#define tt_(o) ((o)->u.i.tt__) + +#else /* }{ */ + +/* big endian */ +#define TValuefields \ + union { struct { int tt__; Value v__; } i; double d__; } u +#define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}} +/* field-access macros */ +#define v_(o) ((o)->u.i.v__) +#define d_(o) ((o)->u.d__) +#define tt_(o) ((o)->u.i.tt__) + +#endif /* } */ + +#endif /* } */ + + +/* correspondence with standard representation */ +#undef val_ +#define val_(o) v_(o) +#undef num_ +#define num_(o) d_(o) + + +#undef numfield +#define numfield /* no such field; numbers are the entire struct */ + +/* basic check to distinguish numbers from non-numbers */ +#undef ttisnumber +#define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK) + +#define tag2tt(t) (NNMARK | (t)) + +#undef rttype +#define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff) + +#undef settt_ +#define settt_(o,t) (tt_(o) = tag2tt(t)) + +#undef setnvalue +#define setnvalue(obj,x) \ + { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); } + +#undef setobj +#define setobj(L,obj1,obj2) \ + { const TValue *o2_=(obj2); TValue *o1_=(obj1); \ + o1_->u = o2_->u; \ + checkliveness(G(L),o1_); } + + +/* +** these redefinitions are not mandatory, but these forms are more efficient +*/ + +#undef checktag +#undef checktype +#define checktag(o,t) (tt_(o) == tag2tt(t)) +#define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS)) + +#undef ttisequal +#define ttisequal(o1,o2) \ + (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2))) + + +#undef luai_checknum +#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } + +#endif +/* }====================================================== */ + + + +/* +** {====================================================== +** types and prototypes +** ======================================================= +*/ + + +union Value { + GCObject *gc; /* collectable objects */ + void *p; /* light userdata */ + int b; /* booleans */ + lua_CFunction f; /* light C functions */ + numfield /* numbers */ +}; + + +struct lua_TValue { + TValuefields; +}; + + +typedef TValue *StkId; /* index to stack elements */ + + + + +/* +** Header for string value; string bytes follow the end of this structure +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte extra; /* reserved words for short strings; "has hash" for longs */ + unsigned int hash; + size_t len; /* number of characters in string */ + } tsv; +} TString; + + +/* get the actual string (array of bytes) from a TString */ +#define getstr(ts) cast(const char *, (ts) + 1) + +/* get the actual string (array of bytes) from a Lua value */ +#define svalue(o) getstr(rawtsvalue(o)) + + +/* +** Header for userdata; memory area follows the end of this structure +*/ +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; /* number of bytes */ + } uv; +} Udata; + + + +/* +** Description of an upvalue for function prototypes +*/ +typedef struct Upvaldesc { + TString *name; /* upvalue name (for debug information) */ + lu_byte instack; /* whether it is in stack */ + lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ +} Upvaldesc; + + +/* +** Description of a local variable for function prototypes +** (used for debug information) +*/ +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines (debug information) */ + LocVar *locvars; /* information about local variables (debug information) */ + Upvaldesc *upvalues; /* upvalue information */ + union Closure *cache; /* last created closure with this prototype */ + TString *source; /* used for debug information */ + int sizeupvalues; /* size of 'upvalues' */ + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte numparams; /* number of fixed parameters */ + lu_byte is_vararg; + lu_byte maxstacksize; /* maximum stack used by this function */ +} Proto; + + + +/* +** Lua Upvalues +*/ +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte nupvalues; GCObject *gclist + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; /* list of upvalues */ +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; /* list of upvalues */ +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define isLfunction(o) ttisLclosure(o) + +#define getproto(o) (clLvalue(o)->p) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +/* +** (address of) a fixed nil value +*/ +#define luaO_nilobject (&luaO_nilobject_) + + +LUAI_DDEC const TValue luaO_nilobject_; + + +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_ceillog2 (unsigned int x); +LUAI_FUNC lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2); +LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result); +LUAI_FUNC int luaO_hexavalue (int c); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/dep/lualib/lopcodes.c b/dep/lualib/lopcodes.c new file mode 100644 index 000000000..97ff168ad --- /dev/null +++ b/dep/lualib/lopcodes.c @@ -0,0 +1,107 @@ +/* +** $Id: lopcodes.c,v 1.49 2012/05/14 13:34:18 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADKX", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETTABUP", + "GETTABLE", + "SETTABUP", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORCALL", + "TFORLOOP", + "SETLIST", + "CLOSURE", + "VARARG", + "EXTRAARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ + ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ +}; + diff --git a/dep/lualib/lopcodes.h b/dep/lualib/lopcodes.h new file mode 100644 index 000000000..045db3ce1 --- /dev/null +++ b/dep/lualib/lopcodes.h @@ -0,0 +1,288 @@ +/* +** $Id: lopcodes.h,v 1.142 2011/07/15 12:50:29 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + 'Ax' : 26 bits ('A', 'B', and 'C' together) + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 +#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A) + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C +#define POS_Ax POS_A + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + +#if SIZE_Ax < LUAI_BITSINT-1 +#define MAXARG_Ax ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>pos) & MASK1(size,0))) +#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ + ((cast(Instruction, v)<= R(A) + 1 */ +OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ +OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ +OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ + +OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) > 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/dep/lualib/loslib.c b/dep/lualib/loslib.c new file mode 100644 index 000000000..912da9b93 --- /dev/null +++ b/dep/lualib/loslib.c @@ -0,0 +1,323 @@ +/* +** $Id: loslib.c,v 1.39 2012/05/23 15:37:09 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** list of valid conversion specifiers for the 'strftime' function +*/ +#if !defined(LUA_STRFTIMEOPTIONS) + +#if !defined(LUA_USE_POSIX) +#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" } +#else +#define LUA_STRFTIMEOPTIONS \ + { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \ + "", "E", "cCxXyY", \ + "O", "deHImMSuUVwWy" } +#endif + +#endif + + + +/* +** By default, Lua uses tmpnam except when POSIX is available, where it +** uses mkstemp. +*/ +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#elif !defined(lua_tmpnam) + +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } + +#endif + + +/* +** By default, Lua uses gmtime/localtime, except when POSIX is available, +** where it uses gmtime_r/localtime_r +*/ +#if defined(LUA_USE_GMTIME_R) + +#define l_gmtime(t,r) gmtime_r(t,r) +#define l_localtime(t,r) localtime_r(t,r) + +#elif !defined(l_gmtime) + +#define l_gmtime(t,r) ((void)r, gmtime(t)) +#define l_localtime(t,r) ((void)r, localtime(t)) + +#endif + + + +static int os_execute (lua_State *L) { + const char *cmd = luaL_optstring(L, 1, NULL); + int stat = system(cmd); + if (cmd != NULL) + return luaL_execresult(L, stat); + else { + lua_pushboolean(L, stat); /* true if there is a shell */ + return 1; + } +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return luaL_fileresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res, isnum; + lua_getfield(L, -1, key); + res = (int)lua_tointegerx(L, -1, &isnum); + if (!isnum) { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static const char *checkoption (lua_State *L, const char *conv, char *buff) { + static const char *const options[] = LUA_STRFTIMEOPTIONS; + unsigned int i; + for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) { + if (*conv != '\0' && strchr(options[i], *conv) != NULL) { + buff[1] = *conv; + if (*options[i + 1] == '\0') { /* one-char conversion specifier? */ + buff[2] = '\0'; /* end buffer */ + return conv + 1; + } + else if (*(conv + 1) != '\0' && + strchr(options[i + 1], *(conv + 1)) != NULL) { + buff[2] = *(conv + 1); /* valid two-char conversion specifier */ + buff[3] = '\0'; /* end buffer */ + return conv + 2; + } + } + } + luaL_argerror(L, 1, + lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); + return conv; /* to avoid warnings */ +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm tmr, *stm; + if (*s == '!') { /* UTC? */ + stm = l_gmtime(&t, &tmr); + s++; /* skip `!' */ + } + else + stm = l_localtime(&t, &tmr); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[4]; + luaL_Buffer b; + cc[0] = '%'; + luaL_buffinit(L, &b); + while (*s) { + if (*s != '%') /* no conversion specifier? */ + luaL_addchar(&b, *s++); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + s = checkoption(L, s + 1, cc); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + int status; + if (lua_isboolean(L, 1)) + status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE); + else + status = luaL_optint(L, 1, EXIT_SUCCESS); + if (lua_toboolean(L, 2)) + lua_close(L); + if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */ + return 0; +} + + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUAMOD_API int luaopen_os (lua_State *L) { + luaL_newlib(L, syslib); + return 1; +} + diff --git a/dep/lualib/lparser.c b/dep/lualib/lparser.c new file mode 100644 index 000000000..b0b8e6afb --- /dev/null +++ b/dep/lualib/lparser.c @@ -0,0 +1,1635 @@ +/* +** $Id: lparser.c,v 2.128 2012/05/20 14:51:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +/* maximum number of local variables per function (must be smaller + than 250, due to the bytecode format) */ +#define MAXVARS 200 + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + short firstlabel; /* index of first label in this block */ + short firstgoto; /* index of first pending goto in this block */ + lu_byte nactvar; /* # active locals outside the block */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isloop; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void statement (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + /* last token from outer function must be EOS */ + lua_assert(ls->fs != NULL || ls->t.token == TK_EOS); + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +/* semantic error */ +static l_noret semerror (LexState *ls, const char *msg) { + ls->t.token = 0; /* remove 'near to' from final message */ + luaX_syntaxerror(ls, msg); +} + + +static l_noret error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); +} + + +static l_noret errorlimit (FuncState *fs, int limit, const char *what) { + lua_State *L = fs->ls->L; + const char *msg; + int line = fs->f->linedefined; + const char *where = (line == 0) + ? "main function" + : luaO_pushfstring(L, "function at line %d", line); + msg = luaO_pushfstring(L, "too many %s (limit is %d) in %s", + what, limit, where); + luaX_syntaxerror(fs->ls, msg); +} + + +static void checklimit (FuncState *fs, int v, int l, const char *what) { + if (v > l) errorlimit(fs, l, what); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + "%s expected (to close %s at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname (LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +static void new_localvar (LexState *ls, TString *name) { + FuncState *fs = ls->fs; + Dyndata *dyd = ls->dyd; + int reg = registerlocalvar(ls, name); + checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, + MAXVARS, "local variables"); + luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, + dyd->actvar.size, Vardesc, MAX_INT, "local variables"); + dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg); +} + + +static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { + new_localvar(ls, luaX_newstring(ls, name, sz)); +} + +#define new_localvarliteral(ls,v) \ + new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1) + + +static LocVar *getlocvar (FuncState *fs, int i) { + int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; + lua_assert(idx < fs->nlocvars); + return &fs->f->locvars[idx]; +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc; + } +} + + +static void removevars (FuncState *fs, int tolevel) { + fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar)->endpc = fs->pc; +} + + +static int searchupvalue (FuncState *fs, TString *name) { + int i; + Upvaldesc *up = fs->f->upvalues; + for (i = 0; i < fs->nups; i++) { + if (luaS_eqstr(up[i].name, name)) return i; + } + return -1; /* not found */ +} + + +static int newupvalue (FuncState *fs, TString *name, expdesc *v) { + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); + luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, + Upvaldesc, MAXUPVAL, "upvalues"); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; + f->upvalues[fs->nups].instack = (v->k == VLOCAL); + f->upvalues[fs->nups].idx = cast_byte(v->u.info); + f->upvalues[fs->nups].name = name; + luaC_objbarrier(fs->ls->L, f, name); + return fs->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (luaS_eqstr(n, getlocvar(fs, i)->varname)) + return i; + } + return -1; /* not found */ +} + + +/* + Mark block where variable at given level was defined + (to emit close instructions later). +*/ +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl->nactvar > level) bl = bl->previous; + bl->upval = 1; +} + + +/* + Find variable with given name 'n'. If it is an upvalue, add this + upvalue into all intermediate functions. +*/ +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) /* no more levels? */ + return VVOID; /* default is global */ + else { + int v = searchvar(fs, n); /* look up locals at current level */ + if (v >= 0) { /* found? */ + init_exp(var, VLOCAL, v); /* variable is local */ + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found as local at current level; try upvalues */ + int idx = searchupvalue(fs, n); /* try existing upvalues */ + if (idx < 0) { /* not found? */ + if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */ + return VVOID; /* not found; is a global */ + /* else was LOCAL or UPVAL */ + idx = newupvalue(fs, n, var); /* will be a new upvalue */ + } + init_exp(var, VUPVAL, idx); + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ + expdesc key; + singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ + lua_assert(var->k == VLOCAL || var->k == VUPVAL); + codestring(ls, &key, varname); /* key is variable name */ + luaK_indexed(fs, var, &key); /* env[varname] */ + } +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + lua_State *L = ls->L; + ++L->nCcalls; + checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void closegoto (LexState *ls, int g, Labeldesc *label) { + int i; + FuncState *fs = ls->fs; + Labellist *gl = &ls->dyd->gt; + Labeldesc *gt = &gl->arr[g]; + lua_assert(luaS_eqstr(gt->name, label->name)); + if (gt->nactvar < label->nactvar) { + TString *vname = getlocvar(fs, gt->nactvar)->varname; + const char *msg = luaO_pushfstring(ls->L, + " at line %d jumps into the scope of local " LUA_QS, + getstr(gt->name), gt->line, getstr(vname)); + semerror(ls, msg); + } + luaK_patchlist(fs, gt->pc, label->pc); + /* remove goto from pending list */ + for (i = g; i < gl->n - 1; i++) + gl->arr[i] = gl->arr[i + 1]; + gl->n--; +} + + +/* +** try to close a goto with existing labels; this solves backward jumps +*/ +static int findlabel (LexState *ls, int g) { + int i; + BlockCnt *bl = ls->fs->bl; + Dyndata *dyd = ls->dyd; + Labeldesc *gt = &dyd->gt.arr[g]; + /* check labels in current block for a match */ + for (i = bl->firstlabel; i < dyd->label.n; i++) { + Labeldesc *lb = &dyd->label.arr[i]; + if (luaS_eqstr(lb->name, gt->name)) { /* correct label? */ + if (gt->nactvar > lb->nactvar && + (bl->upval || dyd->label.n > bl->firstlabel)) + luaK_patchclose(ls->fs, gt->pc, lb->nactvar); + closegoto(ls, g, lb); /* close it */ + return 1; + } + } + return 0; /* label not found; cannot close goto */ +} + + +static int newlabelentry (LexState *ls, Labellist *l, TString *name, + int line, int pc) { + int n = l->n; + luaM_growvector(ls->L, l->arr, n, l->size, + Labeldesc, SHRT_MAX, "labels/gotos"); + l->arr[n].name = name; + l->arr[n].line = line; + l->arr[n].nactvar = ls->fs->nactvar; + l->arr[n].pc = pc; + l->n++; + return n; +} + + +/* +** check whether new label 'lb' matches any pending gotos in current +** block; solves forward jumps +*/ +static void findgotos (LexState *ls, Labeldesc *lb) { + Labellist *gl = &ls->dyd->gt; + int i = ls->fs->bl->firstgoto; + while (i < gl->n) { + if (luaS_eqstr(gl->arr[i].name, lb->name)) + closegoto(ls, i, lb); + else + i++; + } +} + + +/* +** "export" pending gotos to outer level, to check them against +** outer labels; if the block being exited has upvalues, and +** the goto exits the scope of any variable (which can be the +** upvalue), close those variables being exited. +*/ +static void movegotosout (FuncState *fs, BlockCnt *bl) { + int i = bl->firstgoto; + Labellist *gl = &fs->ls->dyd->gt; + /* correct pending gotos to current block and try to close it + with visible labels */ + while (i < gl->n) { + Labeldesc *gt = &gl->arr[i]; + if (gt->nactvar > bl->nactvar) { + if (bl->upval) + luaK_patchclose(fs, gt->pc, bl->nactvar); + gt->nactvar = bl->nactvar; + } + if (!findlabel(fs->ls, i)) + i++; /* move to next one */ + } +} + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { + bl->isloop = isloop; + bl->nactvar = fs->nactvar; + bl->firstlabel = fs->ls->dyd->label.n; + bl->firstgoto = fs->ls->dyd->gt.n; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +/* +** create a label named "break" to resolve break statements +*/ +static void breaklabel (LexState *ls) { + TString *n = luaS_new(ls->L, "break"); + int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); + findgotos(ls, &ls->dyd->label.arr[l]); +} + +/* +** generates an error for an undefined 'goto'; choose appropriate +** message when label name is a reserved word (which can only be 'break') +*/ +static l_noret undefgoto (LexState *ls, Labeldesc *gt) { + const char *msg = isreserved(gt->name) + ? "<%s> at line %d not inside a loop" + : "no visible label " LUA_QS " for at line %d"; + msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); + semerror(ls, msg); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + LexState *ls = fs->ls; + if (bl->previous && bl->upval) { + /* create a 'jump to here' to close upvalues */ + int j = luaK_jump(fs); + luaK_patchclose(fs, j, bl->nactvar); + luaK_patchtohere(fs, j); + } + if (bl->isloop) + breaklabel(ls); /* close pending breaks */ + fs->bl = bl->previous; + removevars(fs, bl->nactvar); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + ls->dyd->label.n = bl->firstlabel; /* remove local labels */ + if (bl->previous) /* inner block? */ + movegotosout(fs, bl); /* update pending gotos to outer block */ + else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ + undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ +} + + +/* +** adds a new prototype into list of prototypes +*/ +static Proto *addprototype (LexState *ls) { + Proto *clp; + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; /* prototype of current function */ + if (fs->np >= f->sizep) { + int oldsize = f->sizep; + luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + } + f->p[fs->np++] = clp = luaF_newproto(L); + luaC_objbarrier(L, f, clp); + return clp; +} + + +/* +** codes instruction to create new closure in parent function +*/ +static void codeclosure (LexState *ls, expdesc *v) { + FuncState *fs = ls->fs->prev; + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); + luaK_exp2nextreg(fs, v); /* fix it at stack top (for GC) */ +} + + +static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { + lua_State *L = ls->L; + Proto *f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = 0; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nups = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->firstlocal = ls->dyd->actvar.n; + fs->bl = NULL; + f = fs->f; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L); + /* anchor table of constants (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + enterblock(fs, bl, 0); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + luaK_ret(fs, 0, 0); /* final return */ + leaveblock(fs); + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); + f->sizeupvalues = fs->nups; + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + /* last token read was anchored in defunct function; must re-anchor it */ + anchor_token(ls); + L->top--; /* pop table of constants */ + luaC_checkGC(L); +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +/* +** check whether current token is in the follow set of a block. +** 'until' closes syntactical blocks, but do not close scope, +** so it handled in separate. +*/ +static int block_follow (LexState *ls, int withuntil) { + switch (ls->t.token) { + case TK_ELSE: case TK_ELSEIF: + case TK_END: case TK_EOS: + return 1; + case TK_UNTIL: return withuntil; + default: return 0; + } +} + + +static void statlist (LexState *ls) { + /* statlist -> { stat [`;'] } */ + while (!block_follow(ls, 1)) { + if (ls->t.token == TK_RETURN) { + statement(ls); + return; /* 'return' must be last statement */ + } + statement(ls); + } +} + + +static void fieldsel (LexState *ls, expdesc *v) { + /* fieldsel -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyregup(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + /* listfield -> exp */ + expr(ls, &cc->v); + checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void field (LexState *ls, struct ConsControl *cc) { + /* field -> listfield | recfield */ + switch(ls->t.token) { + case TK_NAME: { /* may be 'listfield' or 'recfield' */ + if (luaX_lookahead(ls) != '=') /* expression? */ + listfield(ls, cc); + else + recfield(ls, cc); + break; + } + case '[': { + recfield(ls, cc); + break; + } + default: { + listfield(ls, cc); + break; + } + } +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> '{' [ field { sep field } [sep] ] '}' + sep -> ',' | ';' */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + field(ls, &cc); + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls)); + nparams++; + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); + f->is_vararg = 1; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int ismethod, int line) { + /* body -> `(' parlist `)' block END */ + FuncState new_fs; + BlockCnt bl; + new_fs.f = addprototype(ls); + new_fs.f->linedefined = line; + open_func(ls, &new_fs, &bl); + checknext(ls, '('); + if (ismethod) { + new_localvarliteral(ls, "self"); /* create 'self' parameter */ + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + statlist(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + codeclosure(ls, e); + close_func(ls); +} + + +static int explist (LexState *ls, expdesc *v) { + /* explist -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f, int line) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist ] `)' */ + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + } + } +} + + +static void suffixedexp (LexState *ls, expdesc *v) { + /* suffixedexp -> + primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + primaryexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* fieldsel */ + fieldsel(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyregup(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v, line); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v, line); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... | + constructor | FUNCTION body | suffixedexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + suffixedexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `*' `/' `%' */ + {10, 9}, {5, 4}, /* ^, .. (right associative) */ + {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ + {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ + {2, 2}, {1, 1} /* and, or */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + int line = ls->linenumber; + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v, line); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + int line = ls->linenumber; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2, line); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static void block (LexState *ls) { + /* block -> statlist */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + statlist(ls); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to an upvalue/local variable, the +** upvalue/local variable is begin used in a previous assignment to a +** table. If so, save original upvalue/local value in a safe place and +** use this safe copy in the previous assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { /* check all previous assignments */ + if (lh->v.k == VINDEXED) { /* assigning to a table? */ + /* table is the upvalue/local being assigned now? */ + if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) { + conflict = 1; + lh->v.u.ind.vt = VLOCAL; + lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ + } + /* index is the local being assigned? (index cannot be upvalue) */ + if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { + conflict = 1; + lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + /* copy upvalue/local value to a temporary (in position 'extra') */ + OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, op, extra, v->u.info, 0); + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, vkisvar(lh->v.k), "syntax error"); + if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + suffixedexp(ls, &nv.v); + if (nv.v.k != VINDEXED) + check_conflict(ls, lh, &nv.v); + checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, + "C levels"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist */ + int nexps; + checknext(ls, '='); + nexps = explist(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void gotostat (LexState *ls, int pc) { + int line = ls->linenumber; + TString *label; + int g; + if (testnext(ls, TK_GOTO)) + label = str_checkname(ls); + else { + luaX_next(ls); /* skip break */ + label = luaS_new(ls->L, "break"); + } + g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); + findlabel(ls, g); /* close it if label already defined */ +} + + +/* check for repeated labels on the same block */ +static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { + int i; + for (i = fs->bl->firstlabel; i < ll->n; i++) { + if (luaS_eqstr(label, ll->arr[i].name)) { + const char *msg = luaO_pushfstring(fs->ls->L, + "label " LUA_QS " already defined on line %d", + getstr(label), ll->arr[i].line); + semerror(fs->ls, msg); + } + } +} + + +/* skip no-op statements */ +static void skipnoopstat (LexState *ls) { + while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) + statement(ls); +} + + +static void labelstat (LexState *ls, TString *label, int line) { + /* label -> '::' NAME '::' */ + FuncState *fs = ls->fs; + Labellist *ll = &ls->dyd->label; + int l; /* index of new label being created */ + checkrepeated(fs, ll, label); /* check for repeated labels */ + checknext(ls, TK_DBCOLON); /* skip double colon */ + /* create new entry for this label */ + l = newlabelentry(ls, ll, label, line, fs->pc); + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ + /* assume that locals are already out of scope */ + ll->arr[l].nactvar = fs->bl->nactvar; + } + findgotos(ls, &ll->arr[l]); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_jumpto(fs, whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + statlist(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (bl2.upval) /* upvalues? */ + luaK_patchclose(fs, condexit, bl2.nactvar); + leaveblock(fs); /* finish scope */ + luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int reg; + expr(ls, &e); + luaK_exp2nextreg(ls->fs, &e); + lua_assert(e.k == VNONRELOC); + reg = e.u.info; + return reg; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + if (isnum) /* numeric for? */ + endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); + else { /* generic for */ + luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); + luaK_fixline(fs, line); + endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); + } + luaK_patchlist(fs, endfor, prep + 1); + luaK_fixline(fs, line); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)"); + new_localvarliteral(ls, "(for limit)"); + new_localvarliteral(ls, "(for step)"); + new_localvar(ls, varname); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codek(fs, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 4; /* gen, state, control, plus at least one declared var */ + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for control)"); + /* create declared variables */ + new_localvar(ls, indexname); + while (testnext(ls, ',')) { + new_localvar(ls, str_checkname(ls)); + nvars++; + } + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static void test_then_block (LexState *ls, int *escapelist) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + BlockCnt bl; + FuncState *fs = ls->fs; + expdesc v; + int jf; /* instruction to skip 'then' code (if condition is false) */ + luaX_next(ls); /* skip IF or ELSEIF */ + expr(ls, &v); /* read condition */ + checknext(ls, TK_THEN); + if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { + luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ + enterblock(fs, &bl, 0); /* must enter block before 'goto' */ + gotostat(ls, v.t); /* handle goto/break */ + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ + leaveblock(fs); + return; /* and that is it */ + } + else /* must skip over 'then' part if condition is false */ + jf = luaK_jump(fs); + } + else { /* regular case (not goto/break) */ + luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ + enterblock(fs, &bl, 0); + jf = v.f; + } + statlist(ls); /* `then' part */ + leaveblock(fs); + if (ls->t.token == TK_ELSE || + ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */ + luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */ + luaK_patchtohere(fs, jf); +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int escapelist = NO_JUMP; /* exit list for finished parts */ + test_then_block(ls, &escapelist); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) + test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */ + if (testnext(ls, TK_ELSE)) + block(ls); /* `else' part */ + check_match(ls, TK_END, TK_IF, line); + luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ +} + + +static void localfunc (LexState *ls) { + expdesc b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls)); /* new local variable */ + adjustlocalvars(ls, 1); /* enter its scope */ + body(ls, &b, 0, ls->linenumber); /* function created in next register */ + /* debug information will only see the variable after this point! */ + getlocvar(fs, b.u.info)->startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls)); + nvars++; + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {fieldsel} [`:' NAME] */ + int ismethod = 0; + singlevar(ls, v); + while (ls->t.token == '.') + fieldsel(ls, v); + if (ls->t.token == ':') { + ismethod = 1; + fieldsel(ls, v); + } + return ismethod; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int ismethod; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + ismethod = funcname(ls, &v); + body(ls, &b, ismethod, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + suffixedexp(ls, &v.v); + if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ + v.prev = NULL; + assignment(ls, &v, 1); + } + else { /* stat -> func */ + check_condition(ls, v.v.k == VCALL, "syntax error"); + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN [explist] [';'] */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + if (block_follow(ls, 1) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); + testnext(ls, ';'); /* skip optional semicolon */ +} + + +static void statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + enterlevel(ls); + switch (ls->t.token) { + case ';': { /* stat -> ';' (empty statement) */ + luaX_next(ls); /* skip ';' */ + break; + } + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + break; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + break; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + break; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + break; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + break; + } + case TK_FUNCTION: { /* stat -> funcstat */ + funcstat(ls, line); + break; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + break; + } + case TK_DBCOLON: { /* stat -> label */ + luaX_next(ls); /* skip double colon */ + labelstat(ls, str_checkname(ls), line); + break; + } + case TK_RETURN: { /* stat -> retstat */ + luaX_next(ls); /* skip RETURN */ + retstat(ls); + break; + } + case TK_BREAK: /* stat -> breakstat */ + case TK_GOTO: { /* stat -> 'goto' NAME */ + gotostat(ls, luaK_jump(ls->fs)); + break; + } + default: { /* stat -> func | assignment */ + exprstat(ls); + break; + } + } + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + leavelevel(ls); +} + +/* }====================================================================== */ + + +/* +** compiles the main function, which is a regular vararg function with an +** upvalue named LUA_ENV +*/ +static void mainfunc (LexState *ls, FuncState *fs) { + BlockCnt bl; + expdesc v; + open_func(ls, fs, &bl); + fs->f->is_vararg = 1; /* main function is always vararg */ + init_exp(&v, VLOCAL, 0); /* create and... */ + newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ + luaX_next(ls); /* read first token */ + statlist(ls); /* parse main body */ + check(ls, TK_EOS); + close_func(ls); +} + + +Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar) { + LexState lexstate; + FuncState funcstate; + Closure *cl = luaF_newLclosure(L, 1); /* create main closure */ + /* anchor closure (to avoid being collected) */ + setclLvalue(L, L->top, cl); + incr_top(L); + funcstate.f = cl->l.p = luaF_newproto(L); + funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ + lexstate.buff = buff; + lexstate.dyd = dyd; + dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; + luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); + mainfunc(&lexstate, &funcstate); + lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); + /* all scopes should be correctly finished */ + lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); + return cl; /* it's on the stack too */ +} + diff --git a/dep/lualib/lparser.h b/dep/lualib/lparser.h new file mode 100644 index 000000000..cdb44c5bb --- /dev/null +++ b/dep/lualib/lparser.h @@ -0,0 +1,119 @@ +/* +** $Id: lparser.h,v 1.70 2012/05/08 13:53:33 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VNONRELOC, /* info = result register */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in 'upvalues' */ + VINDEXED, /* t = table register/upvalue; idx = index R/K */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + + +#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) +#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) + +typedef struct expdesc { + expkind k; + union { + struct { /* for indexed variables (VINDEXED) */ + short idx; /* index (R/K) */ + lu_byte t; /* table (register or upvalue) */ + lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ + } ind; + int info; /* for generic use */ + lua_Number nval; /* for VKNUM */ + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +/* description of active local variable */ +typedef struct Vardesc { + short idx; /* variable index in stack */ +} Vardesc; + + +/* description of pending goto statements and label statements */ +typedef struct Labeldesc { + TString *name; /* label identifier */ + int pc; /* position in code */ + int line; /* line where it appeared */ + lu_byte nactvar; /* local level where it appears in current block */ +} Labeldesc; + + +/* list of labels or gotos */ +typedef struct Labellist { + Labeldesc *arr; /* array */ + int n; /* number of entries in use */ + int size; /* array size */ +} Labellist; + + +/* dynamic structures used by the parser */ +typedef struct Dyndata { + struct { /* list of active local variables */ + Vardesc *arr; + int n; + int size; + } actvar; + Labellist gt; /* list of pending gotos */ + Labellist label; /* list of active labels */ +} Dyndata; + + +/* control of blocks */ +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* 'label' of last 'jump label' */ + int jpc; /* list of pending jumps to `pc' */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + int firstlocal; /* index of first local var (in Dyndata array) */ + short nlocvars; /* number of elements in 'f->locvars' */ + lu_byte nactvar; /* number of active local variables */ + lu_byte nups; /* number of upvalues */ + lu_byte freereg; /* first free register */ +} FuncState; + + +LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar); + + +#endif diff --git a/dep/lualib/lstate.c b/dep/lualib/lstate.c new file mode 100644 index 000000000..209691eb3 --- /dev/null +++ b/dep/lualib/lstate.c @@ -0,0 +1,322 @@ +/* +** $Id: lstate.c,v 2.98 2012/05/30 12:33:44 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#if !defined(LUAI_GCPAUSE) +#define LUAI_GCPAUSE 200 /* 200% */ +#endif + +#if !defined(LUAI_GCMAJOR) +#define LUAI_GCMAJOR 200 /* 200% */ +#endif + +#if !defined(LUAI_GCMUL) +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ +#endif + + +#define MEMERRMSG "not enough memory" + + +/* +** a macro to help the creation of a unique random seed when a state is +** created; the seed is used to randomize hashes. +*/ +#if !defined(luai_makeseed) +#include +#define luai_makeseed() cast(size_t, time(NULL)) +#endif + + + +/* +** thread state + extra space +*/ +typedef struct LX { +#if defined(LUAI_EXTRASPACE) + char buff[LUAI_EXTRASPACE]; +#endif + lua_State l; +} LX; + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + LX l; + global_State g; +} LG; + + + +#define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) + + +/* +** Compute an initial seed as random as possible. In ANSI, rely on +** Address Space Layout Randomization (if present) to increase +** randomness.. +*/ +#define addbuff(b,p,e) \ + { size_t t = cast(size_t, e); \ + memcpy(buff + p, &t, sizeof(t)); p += sizeof(t); } + +static unsigned int makeseed (lua_State *L) { + char buff[4 * sizeof(size_t)]; + unsigned int h = luai_makeseed(); + int p = 0; + addbuff(buff, p, L); /* heap variable */ + addbuff(buff, p, &h); /* local variable */ + addbuff(buff, p, luaO_nilobject); /* global variable */ + addbuff(buff, p, &lua_newstate); /* public function */ + lua_assert(p == sizeof(buff)); + return luaS_hash(buff, p, h); +} + + +/* +** set GCdebt to a new value keeping the value (totalbytes + GCdebt) +** invariant +*/ +void luaE_setdebt (global_State *g, l_mem debt) { + g->totalbytes -= (debt - g->GCdebt); + g->GCdebt = debt; +} + + +CallInfo *luaE_extendCI (lua_State *L) { + CallInfo *ci = luaM_new(L, CallInfo); + lua_assert(L->ci->next == NULL); + L->ci->next = ci; + ci->previous = L->ci; + ci->next = NULL; + return ci; +} + + +void luaE_freeCI (lua_State *L) { + CallInfo *ci = L->ci; + CallInfo *next = ci->next; + ci->next = NULL; + while ((ci = next) != NULL) { + next = ci->next; + luaM_free(L, ci); + } +} + + +static void stack_init (lua_State *L1, lua_State *L) { + int i; CallInfo *ci; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); + L1->stacksize = BASIC_STACK_SIZE; + for (i = 0; i < BASIC_STACK_SIZE; i++) + setnilvalue(L1->stack + i); /* erase new stack */ + L1->top = L1->stack; + L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; + /* initialize first ci */ + ci = &L1->base_ci; + ci->next = ci->previous = NULL; + ci->callstatus = 0; + ci->func = L1->top; + setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ + ci->top = L1->top + LUA_MINSTACK; + L1->ci = ci; +} + + +static void freestack (lua_State *L) { + if (L->stack == NULL) + return; /* stack not completely built yet */ + L->ci = &L->base_ci; /* free the entire 'ci' list */ + luaE_freeCI(L); + luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ +} + + +/* +** Create registry table and its predefined values +*/ +static void init_registry (lua_State *L, global_State *g) { + TValue mt; + /* create registry */ + Table *registry = luaH_new(L); + sethvalue(L, &g->l_registry, registry); + luaH_resize(L, registry, LUA_RIDX_LAST, 0); + /* registry[LUA_RIDX_MAINTHREAD] = L */ + setthvalue(L, &mt, L); + luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt); + /* registry[LUA_RIDX_GLOBALS] = table of globals */ + sethvalue(L, &mt, luaH_new(L)); + luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt); +} + + +/* +** open parts of the state that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + init_registry(L, g); + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + /* pre-create memory-error message */ + g->memerrmsg = luaS_newliteral(L, MEMERRMSG); + luaS_fix(g->memerrmsg); /* it should never be collected */ + g->gcrunning = 1; /* allow gc */ +} + + +/* +** preinitialize a state with consistent values without allocating +** any memory (to avoid errors) +*/ +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->ci = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->nCcalls = 0; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->nny = 1; + L->status = LUA_OK; + L->errfunc = 0; +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeallobjects(L); /* collect all objects */ + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); + luaZ_freebuffer(L, &g->buff); + freestack(L); + lua_assert(gettotalbytes(g) == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th; + setthvalue(L, L->top, L1); + api_incr_top(L); + preinit_state(L1, G(L)); + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + luai_userstatethread(L, L1); + stack_init(L1, L); /* init stack */ + lua_unlock(L); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + LX *l = fromstate(L1); + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L, L1); + freestack(L1); + luaM_free(L, l); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); + if (l == NULL) return NULL; + L = &l->l.l; + g = &l->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + g->gckind = KGC_NORMAL; + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->seed = makeseed(L); + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->gcrunning = 0; /* no GC while building state */ + g->GCestimate = 0; + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(&g->l_registry); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->version = lua_version(NULL); + g->gcstate = GCSpause; + g->allgc = NULL; + g->finobj = NULL; + g->tobefnz = NULL; + g->sweepgc = g->sweepfin = NULL; + g->gray = g->grayagain = NULL; + g->weak = g->ephemeron = g->allweak = NULL; + g->totalbytes = sizeof(LG); + g->GCdebt = 0; + g->gcpause = LUAI_GCPAUSE; + g->gcmajorinc = LUAI_GCMAJOR; + g->gcstepmul = LUAI_GCMUL; + for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luai_userstateclose(L); + close_state(L); +} + + diff --git a/dep/lualib/lstate.h b/dep/lualib/lstate.h new file mode 100644 index 000000000..a7b04a669 --- /dev/null +++ b/dep/lualib/lstate.h @@ -0,0 +1,228 @@ +/* +** $Id: lstate.h,v 2.81 2012/06/08 15:14:04 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + +/* + +** Some notes about garbage-collected objects: All objects in Lua must +** be kept somehow accessible until being freed. +** +** Lua keeps most objects linked in list g->allgc. The link uses field +** 'next' of the CommonHeader. +** +** Strings are kept in several lists headed by the array g->strt.hash. +** +** Open upvalues are not subject to independent garbage collection. They +** are collected together with their respective threads. Lua keeps a +** double-linked list with all open upvalues (g->uvhead) so that it can +** mark objects referred by them. (They are always gray, so they must +** be remarked in the atomic step. Usually their contents would be marked +** when traversing the respective threads, but the thread may already be +** dead, while the upvalue is still accessible through closures.) +** +** Objects with finalizers are kept in the list g->finobj. +** +** The list g->tobefnz links all objects being finalized. + +*/ + + +struct lua_longjmp; /* defined in ldo.c */ + + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + +/* kinds of Garbage Collection */ +#define KGC_NORMAL 0 +#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */ +#define KGC_GEN 2 /* generational collection */ + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** information about a call +*/ +typedef struct CallInfo { + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + struct CallInfo *previous, *next; /* dynamic call link */ + short nresults; /* expected number of results from this function */ + lu_byte callstatus; + ptrdiff_t extra; + union { + struct { /* only for Lua functions */ + StkId base; /* base for this function */ + const Instruction *savedpc; + } l; + struct { /* only for C functions */ + int ctx; /* context info. in case of yields */ + lua_CFunction k; /* continuation in case of yields */ + ptrdiff_t old_errfunc; + lu_byte old_allowhook; + lu_byte status; + } c; + } u; +} CallInfo; + + +/* +** Bits in CallInfo status +*/ +#define CIST_LUA (1<<0) /* call is running a Lua function */ +#define CIST_HOOKED (1<<1) /* call is running a debug hook */ +#define CIST_REENTRY (1<<2) /* call is running on same invocation of + luaV_execute of previous call */ +#define CIST_YIELDED (1<<3) /* call reentered after suspension */ +#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ +#define CIST_STAT (1<<5) /* call has an error status (pcall) */ +#define CIST_TAIL (1<<6) /* call was tail called */ +#define CIST_HOOKYIELD (1<<7) /* last hook called yielded */ + + +#define isLua(ci) ((ci)->callstatus & CIST_LUA) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */ + l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ + lu_mem GCmemtrav; /* memory traversed by the GC */ + lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ + stringtable strt; /* hash table for strings */ + TValue l_registry; + unsigned int seed; /* randomized seed for hashes */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + lu_byte gckind; /* kind of GC running */ + lu_byte gcrunning; /* true if GC is running */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *allgc; /* list of all collectable objects */ + GCObject *finobj; /* list of collectable objects with finalizers */ + GCObject **sweepgc; /* current position of sweep in list 'allgc' */ + GCObject **sweepfin; /* current position of sweep in list 'finobj' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of tables with weak values */ + GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ + GCObject *allweak; /* list of all-weak tables */ + GCObject *tobefnz; /* list of userdata to be GC */ + UpVal uvhead; /* head of double-linked list of all open upvalues */ + Mbuffer buff; /* temporary buffer for string concatenation */ + int gcpause; /* size of pause between successive GCs */ + int gcmajorinc; /* how much to wait for a major GC (only in gen. mode) */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + struct lua_State *mainthread; + const lua_Number *version; /* pointer to version number */ + TString *memerrmsg; /* memory-error message */ + TString *tmname[TM_N]; /* array with tag-method names */ + struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *oldpc; /* last pc traced */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + int stacksize; + unsigned short nny; /* number of non-yieldable calls in stack */ + unsigned short nCcalls; /* number of nested C calls */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ + CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; /* common header */ + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +#define gch(o) (&(o)->gch) + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l)) +#define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c)) +#define gco2cl(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl)) +#define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +/* actual number of total bytes allocated */ +#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt) + +LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); +LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); +LUAI_FUNC void luaE_freeCI (lua_State *L); + + +#endif + diff --git a/dep/lualib/lstring.c b/dep/lualib/lstring.c new file mode 100644 index 000000000..117b0e9ea --- /dev/null +++ b/dep/lualib/lstring.c @@ -0,0 +1,185 @@ +/* +** $Id: lstring.c,v 2.24 2012/05/11 14:14:42 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + +/* +** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to +** compute its hash +*/ +#if !defined(LUAI_HASHLIMIT) +#define LUAI_HASHLIMIT 5 +#endif + + +/* +** equality for long strings +*/ +int luaS_eqlngstr (TString *a, TString *b) { + size_t len = a->tsv.len; + lua_assert(a->tsv.tt == LUA_TLNGSTR && b->tsv.tt == LUA_TLNGSTR); + return (a == b) || /* same instance or... */ + ((len == b->tsv.len) && /* equal length and ... */ + (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ +} + + +/* +** equality for strings +*/ +int luaS_eqstr (TString *a, TString *b) { + return (a->tsv.tt == b->tsv.tt) && + (a->tsv.tt == LUA_TSHRSTR ? eqshrstr(a, b) : luaS_eqlngstr(a, b)); +} + + +unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { + unsigned int h = seed ^ l; + size_t l1; + size_t step = (l >> LUAI_HASHLIMIT) + 1; + for (l1 = l; l1 >= step; l1 -= step) + h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1])); + return h; +} + + +/* +** resizes the string table +*/ +void luaS_resize (lua_State *L, int newsize) { + int i; + stringtable *tb = &G(L)->strt; + /* cannot resize while GC is traversing strings */ + luaC_runtilstate(L, ~bitmask(GCSsweepstring)); + if (newsize > tb->size) { + luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *); + for (i = tb->size; i < newsize; i++) tb->hash[i] = NULL; + } + /* rehash */ + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + tb->hash[i] = NULL; + while (p) { /* for each node in the list */ + GCObject *next = gch(p)->next; /* save next */ + unsigned int h = lmod(gco2ts(p)->hash, newsize); /* new position */ + gch(p)->next = tb->hash[h]; /* chain it */ + tb->hash[h] = p; + resetoldbit(p); /* see MOVE OLD rule */ + p = next; + } + } + if (newsize < tb->size) { + /* shrinking slice must be empty */ + lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL); + luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *); + } + tb->size = newsize; +} + + +/* +** creates a new string object +*/ +static TString *createstrobj (lua_State *L, const char *str, size_t l, + int tag, unsigned int h, GCObject **list) { + TString *ts; + size_t totalsize; /* total size of TString object */ + totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); + ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts; + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.extra = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + return ts; +} + + +/* +** creates a new short string, inserting it into string table +*/ +static TString *newshrstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + GCObject **list; /* (pointer to) list where it will be inserted */ + stringtable *tb = &G(L)->strt; + TString *s; + if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + list = &tb->hash[lmod(h, tb->size)]; + s = createstrobj(L, str, l, LUA_TSHRSTR, h, list); + tb->nuse++; + return s; +} + + +/* +** checks whether short string exists and reuses it or creates a new one +*/ +static TString *internshrstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + global_State *g = G(L); + unsigned int h = luaS_hash(str, l, g->seed); + for (o = g->strt.hash[lmod(h, g->strt.size)]; + o != NULL; + o = gch(o)->next) { + TString *ts = rawgco2ts(o); + if (h == ts->tsv.hash && + ts->tsv.len == l && + (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { + if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */ + changewhite(o); /* resurrect it */ + return ts; + } + } + return newshrstr(L, str, l, h); /* not found; create a new string */ +} + + +/* +** new string (with explicit length) +*/ +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + if (l <= LUAI_MAXSHORTLEN) /* short string? */ + return internshrstr(L, str, l); + else { + if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL); + } +} + + +/* +** new zero-terminated string +*/ +TString *luaS_new (lua_State *L, const char *str) { + return luaS_newlstr(L, str, strlen(str)); +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + return u; +} + diff --git a/dep/lualib/lstring.h b/dep/lualib/lstring.h new file mode 100644 index 000000000..afa5342c1 --- /dev/null +++ b/dep/lualib/lstring.h @@ -0,0 +1,46 @@ +/* +** $Id: lstring.h,v 1.49 2012/02/01 21:57:15 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + + +/* +** test whether a string is a reserved word +*/ +#define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) + + +/* +** equality for short strings, which are always internalized +*/ +#define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) + + +LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); +LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); +LUAI_FUNC int luaS_eqstr (TString *a, TString *b); +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); +LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); + + +#endif diff --git a/dep/lualib/lstrlib.c b/dep/lualib/lstrlib.c new file mode 100644 index 000000000..7abe737dc --- /dev/null +++ b/dep/lualib/lstrlib.c @@ -0,0 +1,972 @@ +/* +** $Id: lstrlib.c,v 1.176 2012/05/23 15:37:09 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** maximum number of captures that a pattern can do during +** pattern-matching. This limit is arbitrary. +*/ +#if !defined(LUA_MAXCAPTURES) +#define LUA_MAXCAPTURES 32 +#endif + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, (lua_Integer)l); + return 1; +} + + +/* translate a relative string position: negative means back from end */ +static size_t posrelat (ptrdiff_t pos, size_t len) { + if (pos >= 0) return (size_t)pos; + else if (0u - (size_t)pos > len) return 0; + else return len - ((size_t)-pos) + 1; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + size_t start = posrelat(luaL_checkinteger(L, 2), l); + size_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > l) end = l; + if (start <= end) + lua_pushlstring(L, s + start - 1, end - start + 1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l, i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + char *p = luaL_buffinitsize(L, &b, l); + for (i = 0; i < l; i++) + p[i] = s[l - i - 1]; + luaL_pushresultsize(&b, l); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + char *p = luaL_buffinitsize(L, &b, l); + for (i=0; i> 1) + +static int str_rep (lua_State *L) { + size_t l, lsep; + const char *s = luaL_checklstring(L, 1, &l); + int n = luaL_checkint(L, 2); + const char *sep = luaL_optlstring(L, 3, "", &lsep); + if (n <= 0) lua_pushliteral(L, ""); + else if (l + lsep < l || l + lsep >= MAXSIZE / n) /* may overflow? */ + return luaL_error(L, "resulting string too large"); + else { + size_t totallen = n * l + (n - 1) * lsep; + luaL_Buffer b; + char *p = luaL_buffinitsize(L, &b, totallen); + while (n-- > 1) { /* first n-1 copies (followed by separator) */ + memcpy(p, s, l * sizeof(char)); p += l; + if (lsep > 0) { /* avoid empty 'memcpy' (may be expensive) */ + memcpy(p, sep, lsep * sizeof(char)); p += lsep; + } + } + memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */ + luaL_pushresultsize(&b, totallen); + } + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + size_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + size_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi < 1) posi = 1; + if (pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* (size_t -> int) overflow? */ + return luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index %%%d", l + 1); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (p == ms->p_end) + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (p == ms->p_end) + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && p < ms->p_end) + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'g' : res = isgraph(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; /* deprecated option */ + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (p >= ms->p_end - 1) + luaL_error(ms->L, "malformed pattern " + "(missing arguments to " LUA_QL("%%b") ")"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + if (p == ms->p_end) /* end of pattern? */ + return s; /* match succeeded */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case '$': { + if ((p+1) == ms->p_end) /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + default: goto dflt; + } + } + default: dflt: { /* pattern class plus optional suffix */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = s < ms->src_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +/* check whether pattern has no special characters */ +static int nospecials (const char *p, size_t l) { + size_t upto = 0; + do { + if (strpbrk(p + upto, SPECIALS)) + return 0; /* pattern has a special character */ + upto += strlen(p + upto) + 1; /* may have more after \0 */ + } while (upto <= l); + return 1; /* no special chars found */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t ls, lp; + const char *s = luaL_checklstring(L, 1, &ls); + const char *p = luaL_checklstring(L, 2, &lp); + size_t init = posrelat(luaL_optinteger(L, 3, 1), ls); + if (init < 1) init = 1; + else if (init > ls + 1) { /* start after string's end? */ + lua_pushnil(L); /* cannot find anything */ + return 1; + } + /* explicit request or no special characters? */ + if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { + /* do a plain search */ + const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp); + if (s2) { + lua_pushinteger(L, s2 - s + 1); + lua_pushinteger(L, s2 - s + lp); + return 2; + } + } + else { + MatchState ms; + const char *s1 = s + init - 1; + int anchor = (*p == '^'); + if (anchor) { + p++; lp--; /* skip anchor character */ + } + ms.L = L; + ms.src_init = s; + ms.src_end = s + ls; + ms.p_end = p + lp; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1 - s + 1); /* start */ + lua_pushinteger(L, res - s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls, lp; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + ms.p_end = p + lp; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) { + if (news[i] != L_ESC) + luaL_error(ms->L, "invalid use of " LUA_QL("%c") + " in replacement string", L_ESC); + luaL_addchar(b, news[i]); + } + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e, int tr) { + lua_State *L = ms->L; + switch (tr) { + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + default: { /* LUA_TNUMBER or LUA_TSTRING */ + add_s(ms, b, s, e); + return; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl, lp; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checklstring(L, 2, &lp); + int tr = lua_type(L, 3); + size_t max_s = luaL_optinteger(L, 4, srcl+1); + int anchor = (*p == '^'); + size_t n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + if (anchor) { + p++; lp--; /* skip anchor character */ + } + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + ms.p_end = p + lp; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e, tr); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** STRING FORMAT +** ======================================================= +*/ + +/* +** LUA_INTFRMLEN is the length modifier for integer conversions in +** 'string.format'; LUA_INTFRM_T is the integer type corresponding to +** the previous length +*/ +#if !defined(LUA_INTFRMLEN) /* { */ +#if defined(LUA_USE_LONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif +#endif /* } */ + + +/* +** LUA_FLTFRMLEN is the length modifier for float conversions in +** 'string.format'; LUA_FLTFRM_T is the float type corresponding to +** the previous length +*/ +#if !defined(LUA_FLTFRMLEN) + +#define LUA_FLTFRMLEN "" +#define LUA_FLTFRM_T double + +#endif + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + if (*s == '"' || *s == '\\' || *s == '\n') { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + } + else if (*s == '\0' || iscntrl(uchar(*s))) { + char buff[10]; + if (!isdigit(uchar(*(s+1)))) + sprintf(buff, "\\%d", (int)uchar(*s)); + else + sprintf(buff, "\\%03d", (int)uchar(*s)); + luaL_addstring(b, buff); + } + else + luaL_addchar(b, *s); + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char)); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +/* +** add length modifier into formats +*/ +static void addlenmod (char *form, const char *lenmod) { + size_t l = strlen(form); + size_t lm = strlen(lenmod); + char spec = form[l - 1]; + strcpy(form + l - 1, lenmod); + form[l + lm - 1] = spec; + form[l + lm] = '\0'; +} + + +static int str_format (lua_State *L) { + int top = lua_gettop(L); + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ + int nb = 0; /* number of bytes in added item */ + if (++arg > top) + luaL_argerror(L, arg, "no value"); + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + nb = sprintf(buff, form, luaL_checkint(L, arg)); + break; + } + case 'd': case 'i': { + lua_Number n = luaL_checknumber(L, arg); + LUA_INTFRM_T ni = (LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, + "not a number in proper range"); + addlenmod(form, LUA_INTFRMLEN); + nb = sprintf(buff, form, ni); + break; + } + case 'o': case 'u': case 'x': case 'X': { + lua_Number n = luaL_checknumber(L, arg); + unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, + "not a non-negative number in proper range"); + addlenmod(form, LUA_INTFRMLEN); + nb = sprintf(buff, form, ni); + break; + } + case 'e': case 'E': case 'f': +#if defined(LUA_USE_AFORMAT) + case 'a': case 'A': +#endif + case 'g': case 'G': { + addlenmod(form, LUA_FLTFRMLEN); + nb = sprintf(buff, form, (LUA_FLTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + break; + } + case 's': { + size_t l; + const char *s = luaL_tolstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + luaL_addvalue(&b); + break; + } + else { + nb = sprintf(buff, form, s); + lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addsize(&b, nb); + } + } + luaL_pushresult(&b); + return 1; +} + +/* }====================================================== */ + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* table to be metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); /* copy table */ + lua_setmetatable(L, -2); /* set table as metatable for strings */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* get string library */ + lua_setfield(L, -2, "__index"); /* metatable.__index = string */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUAMOD_API int luaopen_string (lua_State *L) { + luaL_newlib(L, strlib); + createmetatable(L); + return 1; +} + diff --git a/dep/lualib/ltable.c b/dep/lualib/ltable.c new file mode 100644 index 000000000..1001d3b52 --- /dev/null +++ b/dep/lualib/ltable.c @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.71 2012/05/23 15:37:09 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lvm.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT >= 32 +#define MAXBITS 30 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +#define dummynode (&dummynode_) + +#define isdummy(n) ((n) == dummynode) + +static const Node dummynode_ = { + {NILCONSTANT}, /* value */ + {{NILCONSTANT, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + int i; + luai_hashnum(i, n); + if (i < 0) { + if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */ + i = 0; /* handle INT_MIN */ + i = -i; /* must be a positive value */ + } + return hashmod(t, i); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TLNGSTR: { + TString *s = rawtsvalue(key); + if (s->tsv.extra == 0) { /* no hash? */ + s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash); + s->tsv.extra = 1; /* now it has its hash */ + } + return hashstr(t, rawtsvalue(key)); + } + case LUA_TSHRSTR: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + case LUA_TLCF: + return hashpointer(t, fvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signaled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + for (;;) { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaV_rawequalobj(gkey(n), key) || + (ttisdeadkey(gkey(n)) && iscollectable(key) && + deadvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + if (n == NULL) + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + } + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, gkey(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[luaO_ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(gkey(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = luaO_ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + luaH_setint(L, t, i + 1, &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) { + /* doesn't need barrier/invalidate cache, as entry was + already present in the table */ + setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); + } + } + if (!isdummy(nold)) + luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = isdummy(t->node) ? 0 : sizenode(t); + luaH_resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys with 2^(i-1) < k <= 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + luaH_resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L) { + Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h; + t->metatable = NULL; + t->flags = cast_byte(~0); + t->array = NULL; + t->sizearray = 0; + setnodevector(L, t, 0); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (!isdummy(t->node)) + luaM_freearray(L, t->node, cast(size_t, sizenode(t))); + luaM_freearray(L, t->array, t->sizearray); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree > t->node) { + t->lastfree--; + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp; + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(L, nvalue(key))) + luaG_runerror(L, "table index is NaN"); + mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + /* whatever called 'newkey' take care of TM cache and GC barrier */ + return luaH_set(L, t, key); /* insert key into grown table */ + } + lua_assert(!isdummy(n)); + othern = mainposition(t, gkey(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + setobj2t(L, gkey(mp), key); + luaC_barrierback(L, obj2gco(t), key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getint (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for short strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + lua_assert(key->tsv.tt == LUA_TSHRSTR); + do { /* check whether `key' is somewhere in the chain */ + if (ttisshrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getint(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaV_rawequalobj(gkey(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +/* +** beware: when using this function you probably need to check a GC +** barrier and invalidate the TM cache. +*/ +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else return luaH_newkey(L, t, key); +} + + +void luaH_setint (lua_State *L, Table *t, int key, TValue *value) { + const TValue *p = luaH_getint(t, key); + TValue *cell; + if (p != luaO_nilobject) + cell = cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + cell = luaH_newkey(L, t, &k); + } + setobj2t(L, cell, value); +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getint(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getint(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getint(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (isdummy(t->node)) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return isdummy(n); } + +#endif diff --git a/dep/lualib/ltable.h b/dep/lualib/ltable.h new file mode 100644 index 000000000..214c01d98 --- /dev/null +++ b/dep/lualib/ltable.h @@ -0,0 +1,41 @@ +/* +** $Id: ltable.h,v 2.16 2011/08/17 20:26:47 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.tvk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define invalidateTMcache(t) ((t)->flags = 0) + + +LUAI_FUNC const TValue *luaH_getint (Table *t, int key); +LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L); +LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff --git a/dep/lualib/ltablib.c b/dep/lualib/ltablib.c new file mode 100644 index 000000000..dc27e6ce8 --- /dev/null +++ b/dep/lualib/ltablib.c @@ -0,0 +1,283 @@ +/* +** $Id: ltablib.c,v 1.63 2011/11/28 17:26:30 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) \ + (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n)) + + +#if defined(LUA_COMPAT_MAXN) +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} +#endif + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos 0) { /* at least one element? */ + int i; + lua_pushvalue(L, 1); + lua_rawseti(L, -2, 1); /* insert first element */ + lua_replace(L, 1); /* move table into index 1 */ + for (i = n; i >= 2; i--) /* assign other elements */ + lua_rawseti(L, 1, i); + } + return 1; /* return table */ +} + + +static int unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Quicksort +** (based on `Algorithms in MODULA-3', Robert Sedgewick; +** Addison-Wesley, 1993.) +** ======================================================= +*/ + + +static void set2 (lua_State *L, int i, int j) { + lua_rawseti(L, 1, i); + lua_rawseti(L, 1, j); +} + +static int sort_comp (lua_State *L, int a, int b) { + if (!lua_isnil(L, 2)) { /* function? */ + int res; + lua_pushvalue(L, 2); + lua_pushvalue(L, a-1); /* -1 to compensate function */ + lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ + lua_call(L, 2, 1); + res = lua_toboolean(L, -1); + lua_pop(L, 1); + return res; + } + else /* a < b? */ + return lua_compare(L, a, b, LUA_OPLT); +} + +static void auxsort (lua_State *L, int l, int u) { + while (l < u) { /* for tail recursion */ + int i, j; + /* sort elements a[l], a[(l+u)/2] and a[u] */ + lua_rawgeti(L, 1, l); + lua_rawgeti(L, 1, u); + if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ + set2(L, l, u); /* swap a[l] - a[u] */ + else + lua_pop(L, 2); + if (u-l == 1) break; /* only 2 elements */ + i = (l+u)/2; + lua_rawgeti(L, 1, i); + lua_rawgeti(L, 1, l); + if (sort_comp(L, -2, -1)) /* a[i]= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>=u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j<=l) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[j] */ + } + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +static const char udatatypename[] = "userdata"; + +LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { + "no value", + "nil", "boolean", udatatypename, "number", + "string", "table", "function", udatatypename, "thread", + "proto", "upval" /* these last two cases are used for tests only */ +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__len", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttypenv(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff --git a/dep/lualib/ltm.h b/dep/lualib/ltm.h new file mode 100644 index 000000000..09e342e4d --- /dev/null +++ b/dep/lualib/ltm.h @@ -0,0 +1,57 @@ +/* +** $Id: ltm.h,v 2.11 2011/02/28 17:32:10 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_LEN, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +#define ttypename(x) luaT_typenames_[(x) + 1] +#define objtypename(x) ttypename(ttypenv(x)) + +LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff --git a/dep/lualib/lua.c b/dep/lualib/lua.c new file mode 100644 index 000000000..a2f401a99 --- /dev/null +++ b/dep/lualib/lua.c @@ -0,0 +1,496 @@ +/* +** $Id: lua.c,v 1.205 2012/05/23 15:37:09 roberto Exp $ +** Lua stand-alone interpreter +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lua_c + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#if !defined(LUA_PROMPT) +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " +#endif + +#if !defined(LUA_PROGNAME) +#define LUA_PROGNAME "lua" +#endif + +#if !defined(LUA_MAXINPUT) +#define LUA_MAXINPUT 512 +#endif + +#if !defined(LUA_INIT) +#define LUA_INIT "LUA_INIT" +#endif + +#define LUA_INITVERSION \ + LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + + +/* +** lua_stdin_is_tty detects whether the standard input is a 'tty' (that +** is, whether we're running lua interactively). +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +** lua_readline defines how to show a prompt and then read a line from +** the standard input. +** lua_saveline defines how to "save" a read line in a "history". +** lua_freeline defines how to free a line read by lua_readline. +*/ +#if defined(LUA_USE_READLINE) + +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) + +#elif !defined(lua_readline) + +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } + +#endif + + + + +static lua_State *globalL = NULL; + +static const char *progname = LUA_PROGNAME; + + + +static void lstop (lua_State *L, lua_Debug *ar) { + (void)ar; /* unused arg. */ + lua_sethook(L, NULL, 0, 0); + luaL_error(L, "interrupted!"); +} + + +static void laction (int i) { + signal(i, SIG_DFL); /* if another SIGINT happens before lstop, + terminate process (default action) */ + lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); +} + + +static void print_usage (const char *badoption) { + luai_writestringerror("%s: ", progname); + if (badoption[1] == 'e' || badoption[1] == 'l') + luai_writestringerror("'%s' needs argument\n", badoption); + else + luai_writestringerror("unrecognized option '%s'\n", badoption); + luai_writestringerror( + "usage: %s [options] [script [args]]\n" + "Available options are:\n" + " -e stat execute string " LUA_QL("stat") "\n" + " -i enter interactive mode after executing " LUA_QL("script") "\n" + " -l name require library " LUA_QL("name") "\n" + " -v show version information\n" + " -E ignore environment variables\n" + " -- stop handling options\n" + " - stop handling options and execute stdin\n" + , + progname); +} + + +static void l_message (const char *pname, const char *msg) { + if (pname) luai_writestringerror("%s: ", pname); + luai_writestringerror("%s\n", msg); +} + + +static int report (lua_State *L, int status) { + if (status != LUA_OK && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1); + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + /* force a complete garbage collection in case of errors */ + lua_gc(L, LUA_GCCOLLECT, 0); + } + return status; +} + + +/* the next function is called unprotected, so it must avoid errors */ +static void finalreport (lua_State *L, int status) { + if (status != LUA_OK) { + const char *msg = (lua_type(L, -1) == LUA_TSTRING) ? lua_tostring(L, -1) + : NULL; + if (msg == NULL) msg = "(error object is not a string)"; + l_message(progname, msg); + lua_pop(L, 1); + } +} + + +static int traceback (lua_State *L) { + const char *msg = lua_tostring(L, 1); + if (msg) + luaL_traceback(L, L, msg, 1); + else if (!lua_isnoneornil(L, 1)) { /* is there an error object? */ + if (!luaL_callmeta(L, 1, "__tostring")) /* try its 'tostring' metamethod */ + lua_pushliteral(L, "(no error message)"); + } + return 1; +} + + +static int docall (lua_State *L, int narg, int nres) { + int status; + int base = lua_gettop(L) - narg; /* function index */ + lua_pushcfunction(L, traceback); /* push traceback function */ + lua_insert(L, base); /* put it under chunk and args */ + globalL = L; /* to be available to 'laction' */ + signal(SIGINT, laction); + status = lua_ppcall(L, narg, nres, base); + signal(SIGINT, SIG_DFL); + lua_remove(L, base); /* remove traceback function */ + return status; +} + + +static void print_version (void) { + luai_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT)); + luai_writeline(); +} + + +static int getargs (lua_State *L, char **argv, int n) { + int narg; + int i; + int argc = 0; + while (argv[argc]) argc++; /* count total number of arguments */ + narg = argc - (n + 1); /* number of arguments to the script */ + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i=n+1; i < argc; i++) + lua_pushstring(L, argv[i]); + lua_createtable(L, narg, n + 1); + for (i=0; i < argc; i++) { + lua_pushstring(L, argv[i]); + lua_rawseti(L, -2, i - n); + } + return narg; +} + + +static int dofile (lua_State *L, const char *name) { + int status = luaL_loadfile(L, name); + if (status == LUA_OK) status = docall(L, 0, 0); + return report(L, status); +} + + +static int dostring (lua_State *L, const char *s, const char *name) { + int status = luaL_loadbuffer(L, s, strlen(s), name); + if (status == LUA_OK) status = docall(L, 0, 0); + return report(L, status); +} + + +static int dolibrary (lua_State *L, const char *name) { + int status; + lua_getglobal(L, "require"); + lua_pushstring(L, name); + status = docall(L, 1, 1); /* call 'require(name)' */ + if (status == LUA_OK) + lua_setglobal(L, name); /* global[name] = require return */ + return report(L, status); +} + + +static const char *get_prompt (lua_State *L, int firstline) { + const char *p; + lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); + p = lua_tostring(L, -1); + if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); + lua_pop(L, 1); /* remove global */ + return p; +} + +/* mark in error messages for incomplete statements */ +#define EOFMARK "" +#define marklen (sizeof(EOFMARK)/sizeof(char) - 1) + +static int incomplete (lua_State *L, int status) { + if (status == LUA_ERRSYNTAX) { + size_t lmsg; + const char *msg = lua_tolstring(L, -1, &lmsg); + if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) { + lua_pop(L, 1); + return 1; + } + } + return 0; /* else... */ +} + + +static int pushline (lua_State *L, int firstline) { + char buffer[LUA_MAXINPUT]; + char *b = buffer; + size_t l; + const char *prmt = get_prompt(L, firstline); + if (lua_readline(L, b, prmt) == 0) + return 0; /* no input */ + l = strlen(b); + if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ + b[l-1] = '\0'; /* remove it */ + if (firstline && b[0] == '=') /* first line starts with `=' ? */ + lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ + else + lua_pushstring(L, b); + lua_freeline(L, b); + return 1; +} + + +static int loadline (lua_State *L) { + int status; + lua_settop(L, 0); + if (!pushline(L, 1)) + return -1; /* no input */ + for (;;) { /* repeat until gets a complete line */ + size_t l; + const char *line = lua_tolstring(L, 1, &l); + status = luaL_loadbuffer(L, line, l, "=stdin"); + if (!incomplete(L, status)) break; /* cannot try to add lines? */ + if (!pushline(L, 0)) /* no more input? */ + return -1; + lua_pushliteral(L, "\n"); /* add a new line... */ + lua_insert(L, -2); /* ...between the two lines */ + lua_concat(L, 3); /* join them */ + } + lua_saveline(L, 1); + lua_remove(L, 1); /* remove line */ + return status; +} + + +static void dotty (lua_State *L) { + int status; + const char *oldprogname = progname; + progname = NULL; + while ((status = loadline(L)) != -1) { + if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET); + report(L, status); + if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */ + luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); + lua_getglobal(L, "print"); + lua_insert(L, 1); + if (lua_ppcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK) + l_message(progname, lua_pushfstring(L, + "error calling " LUA_QL("print") " (%s)", + lua_tostring(L, -1))); + } + } + lua_settop(L, 0); /* clear stack */ + luai_writeline(); + progname = oldprogname; +} + + +static int handle_script (lua_State *L, char **argv, int n) { + int status; + const char *fname; + int narg = getargs(L, argv, n); /* collect arguments */ + lua_setglobal(L, "arg"); + fname = argv[n]; + if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + lua_insert(L, -(narg+1)); + if (status == LUA_OK) + status = docall(L, narg, LUA_MULTRET); + else + lua_pop(L, narg); + return report(L, status); +} + + +/* check that argument has no extra characters at the end */ +#define noextrachars(x) {if ((x)[2] != '\0') return -1;} + + +/* indices of various argument indicators in array args */ +#define has_i 0 /* -i */ +#define has_v 1 /* -v */ +#define has_e 2 /* -e */ +#define has_E 3 /* -E */ + +#define num_has 4 /* number of 'has_*' */ + + +static int collectargs (char **argv, int *args) { + int i; + for (i = 1; argv[i] != NULL; i++) { + if (argv[i][0] != '-') /* not an option? */ + return i; + switch (argv[i][1]) { /* option */ + case '-': + noextrachars(argv[i]); + return (argv[i+1] != NULL ? i+1 : 0); + case '\0': + return i; + case 'E': + args[has_E] = 1; + break; + case 'i': + noextrachars(argv[i]); + args[has_i] = 1; /* go through */ + case 'v': + noextrachars(argv[i]); + args[has_v] = 1; + break; + case 'e': + args[has_e] = 1; /* go through */ + case 'l': /* both options need an argument */ + if (argv[i][2] == '\0') { /* no concatenated argument? */ + i++; /* try next 'argv' */ + if (argv[i] == NULL || argv[i][0] == '-') + return -(i - 1); /* no next argument or it is another option */ + } + break; + default: /* invalid option; return its index... */ + return -i; /* ...as a negative value */ + } + } + return 0; +} + + +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + lua_assert(argv[i][0] == '-'); + switch (argv[i][1]) { /* option */ + case 'e': { + const char *chunk = argv[i] + 2; + if (*chunk == '\0') chunk = argv[++i]; + lua_assert(chunk != NULL); + if (dostring(L, chunk, "=(command line)") != LUA_OK) + return 0; + break; + } + case 'l': { + const char *filename = argv[i] + 2; + if (*filename == '\0') filename = argv[++i]; + lua_assert(filename != NULL); + if (dolibrary(L, filename) != LUA_OK) + return 0; /* stop if file fails */ + break; + } + default: break; + } + } + return 1; +} + + +static int handle_luainit (lua_State *L) { + const char *name = "=" LUA_INITVERSION; + const char *init = getenv(name + 1); + if (init == NULL) { + name = "=" LUA_INIT; + init = getenv(name + 1); /* try alternative name */ + } + if (init == NULL) return LUA_OK; + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, name); +} + + +static int pmain (lua_State *L) { + int argc = (int)lua_tointeger(L, 1); + char **argv = (char **)lua_touserdata(L, 2); + int script; + int args[num_has]; + args[has_i] = args[has_v] = args[has_e] = args[has_E] = 0; + if (argv[0] && argv[0][0]) progname = argv[0]; + script = collectargs(argv, args); + if (script < 0) { /* invalid arg? */ + print_usage(argv[-script]); + return 0; + } + if (args[has_v]) print_version(); + if (args[has_E]) { /* option '-E'? */ + lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */ + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + } + /* open standard libraries */ + luaL_checkversion(L); + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + if (!args[has_E] && handle_luainit(L) != LUA_OK) + return 0; /* error running LUA_INIT */ + /* execute arguments -e and -l */ + if (!runargs(L, argv, (script > 0) ? script : argc)) return 0; + /* execute main script (if there is one) */ + if (script && handle_script(L, argv, script) != LUA_OK) return 0; + if (args[has_i]) /* -i option? */ + dotty(L); + else if (script == 0 && !args[has_e] && !args[has_v]) { /* no arguments? */ + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + lua_pushboolean(L, 1); /* signal no errors */ + return 1; +} + + +int main (int argc, char **argv) { + int status, result; + lua_State *L = luaL_newstate(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + /* call 'pmain' in protected mode */ + lua_pushcfunction(L, &pmain); + lua_pushinteger(L, argc); /* 1st argument */ + lua_pushlightuserdata(L, argv); /* 2nd argument */ + status = lua_ppcall(L, 2, 1, 0); + result = lua_toboolean(L, -1); /* get result */ + finalreport(L, status); + lua_close(L); + return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/dep/lualib/lua.h b/dep/lualib/lua.h new file mode 100644 index 000000000..5d046633a --- /dev/null +++ b/dep/lualib/lua.h @@ -0,0 +1,443 @@ +/* +** $Id: lua.h,v 1.283 2012/04/20 13:18:26 roberto Exp $ +** Lua - A Scripting Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "2" +#define LUA_VERSION_NUM 502 +#define LUA_VERSION_RELEASE "1" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2012 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in 'lua_ppcall' and 'lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) + + +/* thread status */ +#define LUA_OK 0 +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRGCMM 5 +#define LUA_ERRERR 6 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + +#define LUA_NUMTAGS 9 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +LUA_API const lua_Number *(lua_version) (lua_State *L); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_absindex) (lua_State *L, int idx); +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Unsigned (lua_tounsignedx) (lua_State *L, int idx, int *isnum); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPDIV 3 +#define LUA_OPMOD 4 +#define LUA_OPPOW 5 +#define LUA_OPUNM 6 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushunsigned) (lua_State *L, lua_Unsigned n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_getglobal) (lua_State *L, const char *var); +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawgetp) (lua_State *L, int idx, const void *p); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getuservalue) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_setglobal) (lua_State *L, const char *var); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); + + +/* +** 'load' and 'call' functions (load and run Lua code) +*/ +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_getctx) (lua_State *L, int *ctx); + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + int ctx, lua_CFunction k); + +#define lua_ppcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, + const char *mode); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yieldk) (lua_State *L, int nresults, int ctx, + lua_CFunction k); +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 +#define LUA_GCSETMAJORINC 8 +#define LUA_GCISRUNNING 9 +#define LUA_GCGEN 10 +#define LUA_GCINC 11 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_tonumber(L,i) lua_tonumberx(L,i,NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,i,NULL) +#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL) + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_ref(L, lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_pushglobaltable(L) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILCALL 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debugger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); + +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + struct CallInfo *i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2012 Lua.org, PUC-Rio. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/dep/lualib/lua.hpp b/dep/lualib/lua.hpp new file mode 100644 index 000000000..6c10bc055 --- /dev/null +++ b/dep/lualib/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/dep/lualib/luaconf.h b/dep/lualib/luaconf.h new file mode 100644 index 000000000..b86c7ad73 --- /dev/null +++ b/dep/lualib/luaconf.h @@ -0,0 +1,548 @@ +/* +** $Id: luaconf.h,v 1.172 2012/05/11 14:14:42 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + +#if COMPILER == COMPILER_MICROSOFT +# pragma warning ( disable : 4996) +#endif +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_WIN /* enable goodies for regular Windows platforms */ +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#endif + + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionality listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#define LUA_USE_GMTIME_R +#endif + + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" + +#else /* }{ */ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_ENV is the name of the variable that holds the current +@@ environment, used to access global names. +** CHANGE it if you do not like this name. +*/ +#define LUA_ENV "_ENV" + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +@* that are not to be exported to outside modules (LUAI_DDEF for +@* definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ + +#else /* }{ */ +#define LUAI_FUNC extern +#define LUAI_DDEC extern +#define LUAI_DDEF /* empty */ +#endif /* } */ + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ luai_writestring/luai_writeline define how 'print' prints its results. +** They are only used in libraries and the stand-alone program. (The #if +** avoids including 'stdio.h' everywhere.) +*/ +#if defined(LUA_LIB) || defined(lua_c) +#include +#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout)) +#endif + +/* +@@ luai_writestringerror defines how to print error messages. +** (A format string with one argument is enough for Lua...) +*/ +#define luai_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) + + +/* +@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, +** strings that are internalized. (Cannot be smaller than reserved words +** or tags for metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#define LUAI_MAXSHORTLEN 40 + + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_ALL controls all compatibility options. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_ALL) /* { */ + +/* +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. +*/ +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_ppcall(L,1,0,0)) + + +/* +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. +*/ +#define LUA_COMPAT_LOG10 + +/* +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. +*/ +#define LUA_COMPAT_LOADSTRING + +/* +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. +*/ +#define LUA_COMPAT_MAXN + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ + +/* }================================================================== */ + + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 /* { */ +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L /* }{ */ +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else /* }{ */ +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif /* } */ + + +/* +@@ LUA_INT32 is an signed integer with exactly 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. Probably you do not need to change +** this. +*/ +#if LUAI_BITSINT >= 32 /* { */ +#define LUA_INT32 int +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else /* }{ */ +/* 16-bit ints */ +#define LUA_INT32 long +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif /* } */ + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua to consume unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + +/* reserve some space for error handling */ +#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) + + + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ + + +/* +@@ lua_str2number converts a decimal numeric string to a number. +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' do both conversions. C89, however, has no function +** to convert floating hexadecimal strings to numbers. For these +** systems, you can leave 'lua_strx2number' undefined and Lua will +** provide its own implementation. +*/ +#define lua_str2number(s,p) strtod((s), (p)) + +#if defined(LUA_USE_STRTODHEX) +#define lua_strx2number(s,p) strtod((s), (p)) +#endif + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ + +/* the following operations need the math library */ +#if defined(lobject_c) || defined(lvm_c) +#include +#define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(L,a,b) (pow(a,b)) +#endif + +/* these are quite standard operations */ +#if defined(LUA_CORE) +#define luai_numadd(L,a,b) ((a)+(b)) +#define luai_numsub(L,a,b) ((a)-(b)) +#define luai_nummul(L,a,b) ((a)*(b)) +#define luai_numdiv(L,a,b) ((a)/(b)) +#define luai_numunm(L,a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(L,a,b) ((a)<(b)) +#define luai_numle(L,a,b) ((a)<=(b)) +#define luai_numisnan(L,a) (!luai_numeq((a), (a))) +#endif + + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + +/* +@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned. +** It must have at least 32 bits. +*/ +#define LUA_UNSIGNED unsigned LUA_INT32 + + + +/* +** Some tricks with doubles +*/ + +#if defined(LUA_CORE) && \ + defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** The next definitions activate some tricks to speed up the +** conversion from doubles to integer types, mainly to LUA_UNSIGNED. +** +@@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a +** DirectX idiosyncrasy. +** +@@ LUA_IEEE754TRICK uses a trick that should work on any machine +** using IEEE754 with a 32-bit integer type. +** +@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be +** defined when LUA_INTEGER is a 32-bit integer. +** +@@ LUA_IEEEENDIAN is the endianness of doubles in your machine +** (0 for little endian, 1 for big endian); if not defined, Lua will +** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). +** +@@ LUA_NANTRICK controls the use of a trick to pack all types into +** a single double value, using NaN values to represent non-number +** values. The trick only works on 32-bit machines (ints and pointers +** are 32-bit values) with numbers represented as IEEE 754-2008 doubles +** with conventional endianess (12345678 or 87654321), in CPUs that do +** not produce signaling NaN values (all NaNs are quiet). +*/ + +/* Microsoft compiler on a Pentium (32 bit) ? */ +#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ + +#define MS_ASMTRICK +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + + +/* pentium 32 bits? */ +#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEELL +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + +/* pentium 64 bits? */ +#elif defined(__x86_64) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 0 + +#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 1 + +#else /* }{ */ + +/* assume IEEE754 and a 32-bit integer type */ +#define LUA_IEEE754TRICK + +#endif /* } */ + +#endif /* } */ + +/* }================================================================== */ + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/dep/lualib/lualib.h b/dep/lualib/lualib.h new file mode 100644 index 000000000..ae63a1ca2 --- /dev/null +++ b/dep/lualib/lualib.h @@ -0,0 +1,55 @@ +/* +** $Id: lualib.h,v 1.43 2011/12/08 12:11:37 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + + +LUAMOD_API int (luaopen_base) (lua_State *L); + +#define LUA_COLIBNAME "coroutine" +LUAMOD_API int (luaopen_coroutine) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUAMOD_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUAMOD_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUAMOD_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_BITLIBNAME "bit32" +LUAMOD_API int (luaopen_bit32) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUAMOD_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUAMOD_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUAMOD_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#if !defined(lua_assert) +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/dep/lualib/lundump.c b/dep/lualib/lundump.c new file mode 100644 index 000000000..a47c5bc0f --- /dev/null +++ b/dep/lualib/lundump.c @@ -0,0 +1,258 @@ +/* +** $Id: lundump.c,v 2.22 2012/05/08 13:53:33 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +static l_noret error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +#if !defined(luai_verifycode) +#define luai_verifycode(L,b,f) /* empty */ +#endif + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + if (luaZ_read(S->Z,b,size)!=0) error(S,"truncated"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + if (x<0) error(S,"corrupted"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size*sizeof(char)); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static void LoadFunction(LoadState* S, Proto* f); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: lua_assert(0); + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=luaF_newproto(S->L); + LoadFunction(S,f->p[i]); + } +} + +static void LoadUpvalues(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,Upvaldesc); + f->sizeupvalues=n; + for (i=0; iupvalues[i].name=NULL; + for (i=0; iupvalues[i].instack=LoadByte(S); + f->upvalues[i].idx=LoadByte(S); + } +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + f->source=LoadString(S); + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + for (i=0; iupvalues[i].name=LoadString(S); +} + +static void LoadFunction(LoadState* S, Proto* f) +{ + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadUpvalues(S,f); + LoadDebug(S,f); +} + +/* the code below must be consistent with the code in luaU_header */ +#define N0 LUAC_HEADERSIZE +#define N1 (sizeof(LUA_SIGNATURE)-sizeof(char)) +#define N2 N1+2 +#define N3 N2+6 + +static void LoadHeader(LoadState* S) +{ + lu_byte h[LUAC_HEADERSIZE]; + lu_byte s[LUAC_HEADERSIZE]; + luaU_header(h); + memcpy(s,h,sizeof(char)); /* first char already read */ + LoadBlock(S,s+sizeof(char),LUAC_HEADERSIZE-sizeof(char)); + if (memcmp(h,s,N0)==0) return; + if (memcmp(h,s,N1)!=0) error(S,"not a"); + if (memcmp(h,s,N2)!=0) error(S,"version mismatch in"); + if (memcmp(h,s,N3)!=0) error(S,"incompatible"); else error(S,"corrupted"); +} + +/* +** load precompiled chunk +*/ +Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + Closure* cl; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + cl=luaF_newLclosure(L,1); + setclLvalue(L,L->top,cl); incr_top(L); + cl->l.p=luaF_newproto(L); + LoadFunction(&S,cl->l.p); + if (cl->l.p->sizeupvalues != 1) + { + Proto* p=cl->l.p; + cl=luaF_newLclosure(L,cl->l.p->sizeupvalues); + cl->l.p=p; + setclLvalue(L,L->top-1,cl); + } + luai_verifycode(L,buff,cl->l.p); + return cl; +} + +#define MYINT(s) (s[0]-'0') +#define VERSION MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR) +#define FORMAT 0 /* this is the official format */ + +/* +* make header for precompiled chunks +* if you change the code below be sure to update LoadHeader and FORMAT above +* and LUAC_HEADERSIZE in lundump.h +*/ +void luaU_header (lu_byte* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-sizeof(char)); + h+=sizeof(LUA_SIGNATURE)-sizeof(char); + *h++=cast_byte(VERSION); + *h++=cast_byte(FORMAT); + *h++=cast_byte(*(char*)&x); /* endianness */ + *h++=cast_byte(sizeof(int)); + *h++=cast_byte(sizeof(size_t)); + *h++=cast_byte(sizeof(Instruction)); + *h++=cast_byte(sizeof(lua_Number)); + *h++=cast_byte(((lua_Number)0.5)==0); /* is lua_Number integral? */ + memcpy(h,LUAC_TAIL,sizeof(LUAC_TAIL)-sizeof(char)); +} diff --git a/dep/lualib/lundump.h b/dep/lualib/lundump.h new file mode 100644 index 000000000..d2f820f08 --- /dev/null +++ b/dep/lualib/lundump.h @@ -0,0 +1,28 @@ +/* +** $Id: lundump.h,v 1.39 2012/05/08 13:53:33 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (lu_byte* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +/* data to catch conversion errors */ +#define LUAC_TAIL "\x19\x93\r\n\x1a\n" + +/* size in bytes of header of binary files */ +#define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) + +#endif diff --git a/dep/lualib/lvm.c b/dep/lualib/lvm.c new file mode 100644 index 000000000..fe9ecd9a9 --- /dev/null +++ b/dep/lualib/lvm.c @@ -0,0 +1,868 @@ +/* +** $Id: lvm.c,v 2.152 2012/06/08 15:14:04 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), tsvalue(obj)->len, &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + int l = lua_number2str(s, n); + setsvalue2s(L, obj, luaS_newlstr(L, s, l)); + return 1; + } +} + + +static void traceexec (lua_State *L) { + CallInfo *ci = L->ci; + lu_byte mask = L->hookmask; + int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); + if (counthook) + resethookcount(L); /* reset count */ + if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ + return; /* do not call hook again (VM yielded, so it did not move) */ + } + if (counthook) + luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(ci)->p; + int npc = pcRel(ci->u.l.savedpc, p); + int newline = getfuncline(p, npc); + if (npc == 0 || /* call linehook when enter a new function, */ + ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ + newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ + luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ + } + L->oldpc = ci->u.l.savedpc; + if (L->status == LUA_YIELD) { /* did hook yield? */ + if (counthook) + L->hookcount = 1; /* undo decrement to zero */ + ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yieled */ + ci->func = L->top - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); + } +} + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, TValue *p3, int hasres) { + ptrdiff_t result = savestack(L, p3); + setobj2s(L, L->top++, f); /* push function */ + setobj2s(L, L->top++, p1); /* 1st argument */ + setobj2s(L, L->top++, p2); /* 2nd argument */ + if (!hasres) /* no result? 'p3' is third argument */ + setobj2s(L, L->top++, p3); /* 3rd argument */ + luaD_checkstack(L, 0); + /* metamethod may yield only when called from Lua code */ + luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); + if (hasres) { /* if has result, move it to its place */ + p3 = restorestack(L, result); + setobjs2s(L, p3, --L->top); + } +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is not nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val, 1); + return; + } + t = tm; /* else repeat with 'tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = cast(TValue *, luaH_get(h, key)); + /* if previous value is not nil, there must be a previous entry + in the table; moreover, a metamethod has no relevance */ + if (!ttisnil(oldval) || + /* previous value is nil; must check the metamethod */ + ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL && + /* no metamethod; is there a previous entry in the table? */ + (oldval != luaO_nilobject || + /* no previous entry; must create one. (The next test is + always true; we only need the assignment.) */ + (oldval = luaH_newkey(L, h, key), 1)))) { + /* no metamethod and (now) there is an entry with given key */ + setobj2t(L, oldval, val); /* assign new value to that entry */ + invalidateTMcache(h); + luaC_barrierback(L, obj2gco(h), val); + return; + } + /* else will try the metamethod */ + } + else /* not a table; check metamethod */ + if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + /* there is a metamethod */ + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val, 0); + return; + } + t = tm; /* else repeat with 'tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTM(L, tm, p1, p2, res, 1); + return 1; +} + + +static const TValue *get_equalTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaV_rawequalobj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + if (!call_binTM(L, p1, p2, L->top, event)) + return -1; /* no metamethod */ + else + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttisnumber(l) && ttisnumber(r)) + return luai_numlt(L, nvalue(l), nvalue(r)); + else if (ttisstring(l) && ttisstring(r)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) < 0) + luaG_ordererror(L, l, r); + return res; +} + + +int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttisnumber(l) && ttisnumber(r)) + return luai_numle(L, nvalue(l), nvalue(r)); + else if (ttisstring(l) && ttisstring(r)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */ + luaG_ordererror(L, l, r); + return !res; +} + + +/* +** equality of Lua values. L == NULL means raw equality (no metamethods) +*/ +int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttisequal(t1, t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TLCF: return fvalue(t1) == fvalue(t2); + case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2)); + case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2)); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + else if (L == NULL) return 0; + tm = get_equalTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + else if (L == NULL) return 0; + tm = get_equalTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTM(L, tm, t1, t2, L->top, 1); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total) { + lua_assert(total >= 2); + do { + StkId top = L->top; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } + else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ + (void)tostring(L, top - 2); /* result is first operand */ + else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { + setobjs2s(L, top - 2, top - 1); /* result is second op. */ + } + else { + /* at least two non-empty string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (i = 1; i < total && tostring(L, top-i-1); i++) { + size_t l = tsvalue(top-i-1)->len; + if (l >= (MAX_SIZET/sizeof(char)) - tl) + luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + n = i; + do { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l * sizeof(char)); + tl += l; + } while (--i > 0); + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got 'n' strings to create 1 new */ + L->top -= n-1; /* popped 'n' strings and pushed one */ + } while (total > 1); /* repeat until only 1 result left */ +} + + +void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { + const TValue *tm; + switch (ttypenv(rb)) { + case LUA_TTABLE: { + Table *h = hvalue(rb); + tm = fasttm(L, h->metatable, TM_LEN); + if (tm) break; /* metamethod? break switch to call it */ + setnvalue(ra, cast_num(luaH_getn(h))); /* else primitive len */ + return; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + return; + } + default: { /* try metamethod */ + tm = luaT_gettmbyobj(L, rb, TM_LEN); + if (ttisnil(tm)) /* no metamethod? */ + luaG_typeerror(L, rb, "get length of"); + break; + } + } + callTM(L, tm, rb, rb, ra, 1); +} + + +void luaV_arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number res = luaO_arith(op - TM_ADD + LUA_OPADD, nvalue(b), nvalue(c)); + setnvalue(ra, res); + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + +/* +** check whether cached closure in prototype 'p' may be reused, that is, +** whether there is a cached closure with the same upvalues needed by +** new closure to be created. +*/ +static Closure *getcached (Proto *p, UpVal **encup, StkId base) { + Closure *c = p->cache; + if (c != NULL) { /* is there a cached closure? */ + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ + TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; + if (c->l.upvals[i]->v != v) + return NULL; /* wrong upvalue; cannot reuse closure */ + } + } + return c; /* return cached closure (or NULL if no cached closure) */ +} + + +/* +** create a new Lua closure, push it in the stack, and initialize +** its upvalues. Note that the call to 'luaC_barrierproto' must come +** before the assignment to 'p->cache', as the function needs the +** original value of that field. +*/ +static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, + StkId ra) { + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + Closure *ncl = luaF_newLclosure(L, nup); + ncl->l.p = p; + setclLvalue(L, ra, ncl); /* anchor new closure in stack */ + for (i = 0; i < nup; i++) { /* fill in its upvalues */ + if (uv[i].instack) /* upvalue refers to local variable? */ + ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); + else /* get upvalue from enclosing function */ + ncl->l.upvals[i] = encup[uv[i].idx]; + } + luaC_barrierproto(L, p, ncl); + p->cache = ncl; /* save it on cache for reuse */ +} + + +/* +** finish execution of an opcode interrupted by an yield +*/ +void luaV_finishOp (lua_State *L) { + CallInfo *ci = L->ci; + StkId base = ci->u.l.base; + Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ + OpCode op = GET_OPCODE(inst); + switch (op) { /* finish its execution */ + case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: + case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN: + case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { + setobjs2s(L, base + GETARG_A(inst), --L->top); + break; + } + case OP_LE: case OP_LT: case OP_EQ: { + int res = !l_isfalse(L->top - 1); + L->top--; + /* metamethod should not be called when operand is K */ + lua_assert(!ISK(GETARG_B(inst))); + if (op == OP_LE && /* "<=" using "<" instead? */ + ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) + res = !res; /* invert result */ + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); + if (res != GETARG_A(inst)) /* condition failed? */ + ci->u.l.savedpc++; /* skip jump instruction */ + break; + } + case OP_CONCAT: { + StkId top = L->top - 1; /* top when 'call_binTM' was called */ + int b = GETARG_B(inst); /* first element to concatenate */ + int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ + setobj2s(L, top - 2, top); /* put TM result in proper position */ + if (total > 1) { /* are there elements to concat? */ + L->top = top - 1; /* top is one after last element (at top-2) */ + luaV_concat(L, total); /* concat them (may yield again) */ + } + /* move final result to final position */ + setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); + L->top = ci->top; /* restore top */ + break; + } + case OP_TFORCALL: { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP); + L->top = ci->top; /* correct top */ + break; + } + case OP_CALL: { + if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */ + L->top = ci->top; /* adjust results */ + break; + } + case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: + break; + default: lua_assert(0); + } +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#if !defined luai_runtimecheck +#define luai_runtimecheck(L, c) /* void */ +#endif + + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) \ + (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++))) + + +/* execute a jump instruction */ +#define dojump(ci,i,e) \ + { int a = GETARG_A(i); \ + if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \ + ci->u.l.savedpc += GETARG_sBx(i) + e; } + +/* for test instructions, execute the jump instruction that follows it */ +#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } + + +#define Protect(x) { {x;}; base = ci->u.l.base; } + +#define checkGC(L,c) \ + Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \ + luaC_step(L); \ + L->top = ci->top;}) /* restore top */ \ + luai_threadyield(L); ) + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(L, nb, nc)); \ + } \ + else { Protect(luaV_arith(L, ra, rb, rc, tm)); } } + + +#define vmdispatch(o) switch(o) +#define vmcase(l,b) case l: {b} break; +#define vmcasenb(l,b) case l: {b} /* nb = no break */ + +void luaV_execute (lua_State *L) { + CallInfo *ci = L->ci; + LClosure *cl; + TValue *k; + StkId base; + newframe: /* reentry point when frame changes (call/return) */ + lua_assert(ci == L->ci); + cl = clLvalue(ci->func); + k = cl->p->k; + base = ci->u.l.base; + /* main loop of interpreter */ + for (;;) { + Instruction i = *(ci->u.l.savedpc++); + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + Protect(traceexec(L)); + } + /* WARNING: several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == ci->u.l.base); + lua_assert(base <= L->top && L->top < L->stack + L->stacksize); + vmdispatch (GET_OPCODE(i)) { + vmcase(OP_MOVE, + setobjs2s(L, ra, RB(i)); + ) + vmcase(OP_LOADK, + TValue *rb = k + GETARG_Bx(i); + setobj2s(L, ra, rb); + ) + vmcase(OP_LOADKX, + TValue *rb; + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + rb = k + GETARG_Ax(*ci->u.l.savedpc++); + setobj2s(L, ra, rb); + ) + vmcase(OP_LOADBOOL, + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ + ) + vmcase(OP_LOADNIL, + int b = GETARG_B(i); + do { + setnilvalue(ra++); + } while (b--); + ) + vmcase(OP_GETUPVAL, + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + ) + vmcase(OP_GETTABUP, + int b = GETARG_B(i); + Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); + ) + vmcase(OP_GETTABLE, + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + ) + vmcase(OP_SETTABUP, + int a = GETARG_A(i); + Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); + ) + vmcase(OP_SETUPVAL, + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + ) + vmcase(OP_SETTABLE, + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + ) + vmcase(OP_NEWTABLE, + int b = GETARG_B(i); + int c = GETARG_C(i); + Table *t = luaH_new(L); + sethvalue(L, ra, t); + if (b != 0 || c != 0) + luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); + checkGC(L, ra + 1); + ) + vmcase(OP_SELF, + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + ) + vmcase(OP_ADD, + arith_op(luai_numadd, TM_ADD); + ) + vmcase(OP_SUB, + arith_op(luai_numsub, TM_SUB); + ) + vmcase(OP_MUL, + arith_op(luai_nummul, TM_MUL); + ) + vmcase(OP_DIV, + arith_op(luai_numdiv, TM_DIV); + ) + vmcase(OP_MOD, + arith_op(luai_nummod, TM_MOD); + ) + vmcase(OP_POW, + arith_op(luai_numpow, TM_POW); + ) + vmcase(OP_UNM, + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(L, nb)); + } + else { + Protect(luaV_arith(L, ra, rb, rb, TM_UNM)); + } + ) + vmcase(OP_NOT, + TValue *rb = RB(i); + int res = l_isfalse(rb); /* next assignment may change this value */ + setbvalue(ra, res); + ) + vmcase(OP_LEN, + Protect(luaV_objlen(L, ra, RB(i))); + ) + vmcase(OP_CONCAT, + int b = GETARG_B(i); + int c = GETARG_C(i); + StkId rb; + L->top = base + c + 1; /* mark the end of concat operands */ + Protect(luaV_concat(L, c - b + 1)); + ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ + rb = b + base; + setobjs2s(L, ra, rb); + checkGC(L, (ra >= rb ? ra + 1 : rb)); + L->top = ci->top; /* restore top */ + ) + vmcase(OP_JMP, + dojump(ci, i, 0); + ) + vmcase(OP_EQ, + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (cast_int(equalobj(L, rb, rc)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + ) + vmcase(OP_LT, + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + ) + vmcase(OP_LE, + Protect( + if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + ) + vmcase(OP_TEST, + if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + vmcase(OP_TESTSET, + TValue *rb = RB(i); + if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) + ci->u.l.savedpc++; + else { + setobjs2s(L, ra, rb); + donextjump(ci); + } + ) + vmcase(OP_CALL, + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + if (luaD_precall(L, ra, nresults)) { /* C function? */ + if (nresults >= 0) L->top = ci->top; /* adjust results */ + base = ci->u.l.base; + } + else { /* Lua function */ + ci = L->ci; + ci->callstatus |= CIST_REENTRY; + goto newframe; /* restart luaV_execute over new Lua function */ + } + ) + vmcase(OP_TAILCALL, + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ + base = ci->u.l.base; + else { + /* tail call: put called frame (n) in place of caller one (o) */ + CallInfo *nci = L->ci; /* called frame */ + CallInfo *oci = nci->previous; /* caller frame */ + StkId nfunc = nci->func; /* called function */ + StkId ofunc = oci->func; /* caller function */ + /* last stack slot filled by 'precall' */ + StkId lim = nci->u.l.base + getproto(nfunc)->numparams; + int aux; + /* close all upvalues from previous call */ + if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); + /* move new frame into old one */ + for (aux = 0; nfunc + aux < lim; aux++) + setobjs2s(L, ofunc + aux, nfunc + aux); + oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ + oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ + oci->u.l.savedpc = nci->u.l.savedpc; + oci->callstatus |= CIST_TAIL; /* function was tail called */ + ci = L->ci = oci; /* remove new frame */ + lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); + goto newframe; /* restart luaV_execute over new Lua function */ + } + ) + vmcasenb(OP_RETURN, + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (cl->p->sizep > 0) luaF_close(L, base); + b = luaD_poscall(L, ra); + if (!(ci->callstatus & CIST_REENTRY)) /* 'ci' still the called one */ + return; /* external invocation: return */ + else { /* invocation via reentry: continue execution */ + ci = L->ci; + if (b) L->top = ci->top; + lua_assert(isLua(ci)); + lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); + goto newframe; /* restart luaV_execute over new Lua function */ + } + ) + vmcase(OP_FORLOOP, + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(L, 0, step) ? luai_numle(L, idx, limit) + : luai_numle(L, limit, idx)) { + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + ) + vmcase(OP_FORPREP, + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); + ci->u.l.savedpc += GETARG_sBx(i); + ) + vmcasenb(OP_TFORCALL, + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb + 3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i), 1)); + L->top = ci->top; + i = *(ci->u.l.savedpc++); /* go to next instruction */ + ra = RA(i); + lua_assert(GET_OPCODE(i) == OP_TFORLOOP); + goto l_tforloop; + ) + vmcase(OP_TFORLOOP, + l_tforloop: + if (!ttisnil(ra + 1)) { /* continue loop? */ + setobjs2s(L, ra, ra + 1); /* save control variable */ + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + } + ) + vmcase(OP_SETLIST, + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) n = cast_int(L->top - ra) - 1; + if (c == 0) { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + c = GETARG_Ax(*ci->u.l.savedpc++); + } + luai_runtimecheck(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-allocate it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + luaH_setint(L, h, last--, val); + luaC_barrierback(L, obj2gco(h), val); + } + L->top = ci->top; /* correct top (in case of previous open call) */ + ) + vmcase(OP_CLOSURE, + Proto *p = cl->p->p[GETARG_Bx(i)]; + Closure *ncl = getcached(p, cl->upvals, base); /* cached closure */ + if (ncl == NULL) /* no match? */ + pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ + else + setclLvalue(L, ra, ncl); /* push cashed closure */ + checkGC(L, ra + 1); + ) + vmcase(OP_VARARG, + int b = GETARG_B(i) - 1; + int j; + int n = cast_int(base - ci->func) - cl->p->numparams - 1; + if (b < 0) { /* B == 0? */ + b = n; /* get all var. arguments */ + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, base - n + j); + } + else { + setnilvalue(ra + j); + } + } + ) + vmcase(OP_EXTRAARG, + lua_assert(0); + ) + } + } +} + diff --git a/dep/lualib/lvm.h b/dep/lualib/lvm.h new file mode 100644 index 000000000..8d27c4427 --- /dev/null +++ b/dep/lualib/lvm.h @@ -0,0 +1,45 @@ +/* +** $Id: lvm.h,v 2.17 2011/05/31 18:27:56 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) + +#define luaV_rawequalobj(t1,t2) \ + (ttisequal(t1,t2) && luaV_equalobj_(NULL,t1,t2)) + + +/* not to called directly */ +LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_finishOp (lua_State *L); +LUAI_FUNC void luaV_execute (lua_State *L); +LUAI_FUNC void luaV_concat (lua_State *L, int total); +LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op); +LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); + +#endif diff --git a/dep/lualib/lzio.c b/dep/lualib/lzio.c new file mode 100644 index 000000000..292a41a7e --- /dev/null +++ b/dep/lualib/lzio.c @@ -0,0 +1,76 @@ +/* +** $Id: lzio.c,v 1.35 2012/05/14 13:34:18 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) + return EOZ; + z->n = size - 1; /* discount char being returned */ + z->p = buff; + return cast_uchar(*(z->p++)); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (z->n == 0) { /* no bytes in buffer? */ + if (luaZ_fill(z) == EOZ) /* try to read more */ + return n; /* no more input; return number of missing bytes */ + else { + z->n++; /* luaZ_fill consumed first byte; put it back */ + z->p--; + } + } + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff --git a/dep/lualib/lzio.h b/dep/lualib/lzio.h new file mode 100644 index 000000000..aa4fa2fdc --- /dev/null +++ b/dep/lualib/lzio.h @@ -0,0 +1,65 @@ +/* +** $Id: lzio.h,v 1.26 2011/07/15 12:48:03 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) + + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; /* reader function */ + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/dep/recastnavigation/Detour/win/VC100/Detour.vcxproj b/dep/recastnavigation/Detour/win/VC100/Detour.vcxproj index cb12cebb3..4aa322a60 100644 --- a/dep/recastnavigation/Detour/win/VC100/Detour.vcxproj +++ b/dep/recastnavigation/Detour/win/VC100/Detour.vcxproj @@ -1,162 +1,166 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6} - Detour - - - - StaticLibrary - true - MultiByte - - - StaticLibrary - true - MultiByte - - - StaticLibrary - false - false - MultiByte - - - StaticLibrary - false - false - MultiByte - - - - - - - - - - - - - - - - - - - $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ - - - $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ - - - .\$(ProjectName)__$(Platform)_$(Configuration)\ - - - .\$(ProjectName)__$(Platform)_$(Configuration)\ - - - $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ - - - $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ - - - .\$(ProjectName)__$(Platform)_$(Configuration)\ - - - .\$(ProjectName)__$(Platform)_$(Configuration)\ - - - - Level3 - Disabled - ..\..\include - WIN32;DEBUG;_MBCS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - Disabled - ..\..\include - WIN32;DEBUG;_MBCS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - MaxSpeed - true - true - ..\..\include - WIN32;NDEBUG;_MBCS;%(PreprocessorDefinitions) - Speed - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - ..\..\include - WIN32;NDEBUG;_MBCS;%(PreprocessorDefinitions) - Speed - - - true - true - true - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6} + Detour + + + + StaticLibrary + true + MultiByte + v120 + + + StaticLibrary + true + MultiByte + v120 + + + StaticLibrary + false + false + MultiByte + v120 + + + StaticLibrary + false + false + MultiByte + v120 + + + + + + + + + + + + + + + + + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + $(ProjectDir)\..\..\..\..\lib\$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + .\$(ProjectName)__$(Platform)_$(Configuration)\ + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;%(PreprocessorDefinitions) + + + true + + + + + Level3 + Disabled + ..\..\include + WIN32;DEBUG;_MBCS;%(PreprocessorDefinitions) + + + true + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;%(PreprocessorDefinitions) + Speed + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + ..\..\include + WIN32;NDEBUG;_MBCS;%(PreprocessorDefinitions) + Speed + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/recastnavigation/RecastDemo/Bin/DroidSans.ttf b/dep/recastnavigation/RecastDemo/Bin/DroidSans.ttf new file mode 100644 index 000000000..767c63ad0 Binary files /dev/null and b/dep/recastnavigation/RecastDemo/Bin/DroidSans.ttf differ diff --git a/dep/recastnavigation/RecastDemo/Bin/Tests/nav_mesh_test.txt b/dep/recastnavigation/RecastDemo/Bin/Tests/nav_mesh_test.txt index aca6e1285..e69de29bb 100644 --- a/dep/recastnavigation/RecastDemo/Bin/Tests/nav_mesh_test.txt +++ b/dep/recastnavigation/RecastDemo/Bin/Tests/nav_mesh_test.txt @@ -1,23 +0,0 @@ -s Solo Mesh Simple -f nav_test.obj -pf 18.138550 -2.370003 -21.319118 -19.206181 -2.369133 24.802742 0x3 0x0 -pf 18.252758 -2.368240 -7.000238 -19.206181 -2.369133 24.802742 0x3 0x0 -pf 18.252758 -2.368240 -7.000238 -22.759071 -2.369453 2.003946 0x3 0x0 -pf 18.252758 -2.368240 -7.000238 -24.483898 -2.369728 -6.778278 0x3 0x0 -pf 18.252758 -2.368240 -7.000238 -24.068850 -2.370285 -18.879251 0x3 0x0 -pf 18.252758 -2.368240 -7.000238 12.124170 -2.369637 -21.222471 0x3 0x0 -pf 10.830146 -2.366791 19.002508 12.124170 -2.369637 -21.222471 0x3 0x0 -pf 10.830146 -2.366791 19.002508 -7.146484 -2.368736 -16.031403 0x3 0x0 -pf 10.830146 -2.366791 19.002508 -21.615391 -2.368706 -3.264029 0x3 0x0 -pf 10.830146 -2.366791 19.002508 -22.651268 -2.369354 1.053217 0x3 0x0 -pf 10.830146 -2.366791 19.002508 19.181122 -2.368134 3.011776 0x3 0x0 -pf 10.830146 -2.366791 19.002508 19.041592 -2.368713 -7.404587 0x3 0x0 -pf 6.054083 -2.365402 3.330421 19.041592 -2.368713 -7.404587 0x3 0x0 -pf 6.054083 -2.365402 3.330421 21.846087 -2.368568 17.918859 0x3 0x0 -pf 6.054083 -2.365402 3.330421 0.967449 -2.368439 25.767756 0x3 0x0 -pf 6.054083 -2.365402 3.330421 -17.518076 -2.368477 26.569633 0x3 0x0 -pf 6.054083 -2.365402 3.330421 -22.141787 -2.369209 2.440046 0x3 0x0 -pf 6.054083 -2.365402 3.330421 -23.296972 -2.369797 -17.411043 0x3 0x0 -pf 6.054083 -2.365402 3.330421 -1.564062 -2.369926 -20.452827 0x3 0x0 -pf 6.054083 -2.365402 3.330421 16.905643 -2.370193 -21.811655 0x3 0x0 -pf 6.054083 -2.365402 3.330421 19.289761 -2.368813 -6.954918 0x3 0x0 diff --git a/dep/recastnavigation/RecastDemo/Build/VC10/Recast.vcxproj b/dep/recastnavigation/RecastDemo/Build/VC10/Recast.vcxproj index 2ed44c3cd..31a4c13d6 100644 --- a/dep/recastnavigation/RecastDemo/Build/VC10/Recast.vcxproj +++ b/dep/recastnavigation/RecastDemo/Build/VC10/Recast.vcxproj @@ -1,180 +1,186 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {CEF242C5-E9A3-403B-BAFF-99397BDA5730} - Recast - Win32Proj - - - - Application - Unicode - true - - - Application - Unicode - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\Bin\ - $(Configuration)\ - false - ..\..\Bin\ - $(Configuration)\ - false - - - - Disabled - ..\..\Contrib\SDL\include;..\..\Include;..\..\..\Detour\Include;..\..\..\DebugUtils\Include;..\..\..\Recast\Include;..\..\Contrib - WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - opengl32.lib;glu32.lib;sdlmain.lib;sdl.lib;%(AdditionalDependencies) - ..\..\Contrib\SDL\lib;%(AdditionalLibraryDirectories) - true - Windows - MachineX86 - - - - - MaxSpeed - true - ..\..\..\DebugUtils\Include;..\..\Contrib\SDL\include;..\..\Include;..\..\..\Detour\Include;..\..\..\Recast\Include;..\..\Contrib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level4 - ProgramDatabase - - - opengl32.lib;glu32.lib;sdlmain.lib;sdl.lib;%(AdditionalDependencies) - ..\..\Contrib\SDL\lib;%(AdditionalLibraryDirectories) - true - Windows - true - true - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {CEF242C5-E9A3-403B-BAFF-99397BDA5730} + Recast + Win32Proj + + + + Application + Unicode + true + + + Application + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\Bin\ + $(Configuration)\ + false + ..\..\Bin\ + $(Configuration)\ + false + + + + Disabled + ..\..\Contrib\SDL\include;..\..\Include;..\..\..\Detour\Include;..\..\..\DebugUtils\Include;..\..\..\Recast\Include;..\..\Contrib + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + + + opengl32.lib;glu32.lib;sdlmain.lib;sdl.lib;%(AdditionalDependencies) + ..\..\Contrib\SDL\lib;%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + copy /Y "$(ProjectDir)..\..\Contrib\SDL\lib\SDL.dll" "$(ProjectDir)..\..\Bin\SDL.dll" + + + + + MaxSpeed + true + ..\..\..\DebugUtils\Include;..\..\Contrib\SDL\include;..\..\Include;..\..\..\Detour\Include;..\..\..\Recast\Include;..\..\Contrib;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + ProgramDatabase + + + opengl32.lib;glu32.lib;sdlmain.lib;sdl.lib;%(AdditionalDependencies) + ..\..\Contrib\SDL\lib;%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX86 + + + copy /Y "$(ProjectDir)/../../Contrib/SDL/lib/SDL.dll" "$(ProjectDir)/../../Bin/SDL.dll" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.dll b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.dll new file mode 100644 index 000000000..628cdfcf0 Binary files /dev/null and b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.dll differ diff --git a/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.lib b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.lib new file mode 100644 index 000000000..5b3f17c58 Binary files /dev/null and b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDL.lib differ diff --git a/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDLmain.lib b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDLmain.lib new file mode 100644 index 000000000..945b9ad8e Binary files /dev/null and b/dep/recastnavigation/RecastDemo/Contrib/SDL/lib/SDLmain.lib differ diff --git a/dep/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp b/dep/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp index ec192a603..d2ecac68b 100644 --- a/dep/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp +++ b/dep/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp @@ -127,6 +127,10 @@ void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool const unsigned short flags = SAMPLE_POLYFLAGS_JUMP; geom->addOffMeshConnection(m_hitPos, p, m_sample->getAgentRadius(), m_bidir ? 1 : 0, area, flags); m_hitPosSet = false; + float* v = new float[6]; + rcVcopy(&v[0], m_hitPos); + rcVcopy(&v[3], p); + printf("572 29,29 (%.3f %.3f %.3f) (%.3f %.3f %.3f) 5.0f", v[0],v[1], v[2],v[3],v[4],v[5]); } } diff --git a/dep/recastnavigation/RecastDemo/Source/Sample.cpp b/dep/recastnavigation/RecastDemo/Source/Sample.cpp index c437bffa0..70b908dc2 100644 --- a/dep/recastnavigation/RecastDemo/Source/Sample.cpp +++ b/dep/recastnavigation/RecastDemo/Source/Sample.cpp @@ -112,19 +112,19 @@ const float* Sample::getBoundsMax() void Sample::resetCommonSettings() { - m_cellSize = 0.3f; - m_cellHeight = 0.2f; + m_cellSize = 0.26f; + m_cellHeight = 0.26f; m_agentHeight = 2.0f; - m_agentRadius = 0.6f; - m_agentMaxClimb = 0.9f; - m_agentMaxSlope = 45.0f; - m_regionMinSize = 8; - m_regionMergeSize = 20; - m_edgeMaxLen = 12.0f; - m_edgeMaxError = 1.3f; - m_vertsPerPoly = 6.0f; - m_detailSampleDist = 6.0f; - m_detailSampleMaxError = 1.0f; + m_agentRadius = 2.f; + m_agentMaxClimb = 4.0f; + m_agentMaxSlope = 60.0f; + m_regionMinSize = 7.74f; + m_regionMergeSize = 7.07f; + m_edgeMaxLen = 81.0f; + m_edgeMaxError = 2.0f; + m_vertsPerPoly = 80.0f; + m_detailSampleDist = m_cellSize* 64; + m_detailSampleMaxError =m_cellSize*2; } void Sample::handleCommonSettings() @@ -146,9 +146,9 @@ void Sample::handleCommonSettings() imguiSeparator(); imguiLabel("Agent"); - imguiSlider("Height", &m_agentHeight, 0.1f, 5.0f, 0.1f); + imguiSlider("Height", &m_agentHeight, 0.1f, 10.0f, 0.1f); imguiSlider("Radius", &m_agentRadius, 0.0f, 5.0f, 0.1f); - imguiSlider("Max Climb", &m_agentMaxClimb, 0.1f, 5.0f, 0.1f); + imguiSlider("Max Climb", &m_agentMaxClimb, 0.1f, 10.0f, 0.1f); imguiSlider("Max Slope", &m_agentMaxSlope, 0.0f, 90.0f, 1.0f); imguiSeparator(); diff --git a/dep/recastnavigation/RecastDemo/Source/main.cpp b/dep/recastnavigation/RecastDemo/Source/main.cpp index ba12e9e51..0805330f7 100644 --- a/dep/recastnavigation/RecastDemo/Source/main.cpp +++ b/dep/recastnavigation/RecastDemo/Source/main.cpp @@ -299,14 +299,14 @@ int main(int /*argc*/, char** /*argv*/) if (mouseOverMenu) mscroll--; else - scrollZoom -= 1.0f; + scrollZoom -= 5.0f; } else if (event.button.button == SDL_BUTTON_WHEELDOWN) { if (mouseOverMenu) mscroll++; else - scrollZoom += 1.0f; + scrollZoom += 5.0f; } break; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be1392b45..e5835dc1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,16 +1,16 @@ -# Needs to link against mangos_worldd.lib -if(WIN32) - link_directories( - ${CMAKE_BINARY_DIR}/src/trinitycore/${CMAKE_CFG_INTDIR} - ) - include_directories( - ${CMAKE_SOURCE_DIR}/dep/include # For Win32 - ) -endif() - -add_subdirectory(framework) -add_subdirectory(shared) -add_subdirectory(trinityrealm) -add_subdirectory(game) -add_subdirectory(scripts) -add_subdirectory(trinitycore) +# Needs to link against mangos_worldd.lib +if(WIN32) + link_directories( + ${CMAKE_BINARY_DIR}/src/hellgroundcore/${CMAKE_CFG_INTDIR} + ) + include_directories( + ${CMAKE_SOURCE_DIR}/dep/include # For Win32 + ) +endif() + +add_subdirectory(framework) +add_subdirectory(shared) +add_subdirectory(hellgroundrealm) +add_subdirectory(game) +add_subdirectory(scripts) +add_subdirectory(hellgroundcore) diff --git a/src/framework/Dynamic/FactoryHolder.h b/src/framework/Dynamic/FactoryHolder.h index 1fc901c5d..488a07fb5 100755 --- a/src/framework/Dynamic/FactoryHolder.h +++ b/src/framework/Dynamic/FactoryHolder.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h index 4d77f71cb..ac32354af 100755 --- a/src/framework/Dynamic/ObjectRegistry.h +++ b/src/framework/Dynamic/ObjectRegistry.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index 8915e7cc4..fc5111591 100755 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h index 25bd89fc5..14e237233 100755 --- a/src/framework/GameSystem/GridLoader.h +++ b/src/framework/GameSystem/GridLoader.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/GameSystem/GridRefManager.h b/src/framework/GameSystem/GridRefManager.h index 4858a829f..3fc01c2b8 100755 --- a/src/framework/GameSystem/GridRefManager.h +++ b/src/framework/GameSystem/GridRefManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _GRIDREFMANAGER -#define _GRIDREFMANAGER +#ifndef HELLGROUND_GRIDREFMANAGER +#define HELLGROUND_GRIDREFMANAGER #include "Utilities/LinkedReference/RefManager.h" diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h index c93730950..7675dd978 100755 --- a/src/framework/GameSystem/GridReference.h +++ b/src/framework/GameSystem/GridReference.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _GRIDREFERENCE_H -#define _GRIDREFERENCE_H +#ifndef HELLGROUND_GRIDREFERENCE_H +#define HELLGROUND_GRIDREFERENCE_H #include "Utilities/LinkedReference/Reference.h" diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h index ba26f2bea..5840cf82b 100755 --- a/src/framework/GameSystem/NGrid.h +++ b/src/framework/GameSystem/NGrid.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index d58805eb4..296f1fdef 100755 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index ed7719bdb..e24706a1e 100755 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TYPECONTAINER_FUNCTIONS_H -#define TYPECONTAINER_FUNCTIONS_H +#ifndef HELLGROUND_TYPECONTAINER_FUNCTIONS_H +#define HELLGROUND_TYPECONTAINER_FUNCTIONS_H /* * Here you'll find a list of helper functions to make diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h index 9e43665a9..a53fbfa74 100755 --- a/src/framework/GameSystem/TypeContainerVisitor.h +++ b/src/framework/GameSystem/TypeContainerVisitor.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/Platform/CompilerDefs.h b/src/framework/Platform/CompilerDefs.h index f7497d78d..2e16d3358 100755 --- a/src/framework/Platform/CompilerDefs.h +++ b/src/framework/Platform/CompilerDefs.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index deaf7c9d2..9c58d0d15 100755 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2012 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_DEFINE_H @@ -43,7 +43,7 @@ typedef ACE_SHLIB_HANDLE HELLGROUND_LIBRARY_HANDLE; -#define HELLGROUND_SCRIPT_NAME "trinityscript" +#define HELLGROUND_SCRIPT_NAME "hellgroundscript" #define HELLGROUND_SCRIPT_SUFFIX ACE_DLL_SUFFIX #define HELLGROUND_SCRIPT_PREFIX ACE_DLL_PREFIX #define HELLGROUND_LOAD_LIBRARY(libname) ACE_OS::dlopen(libname) diff --git a/src/framework/Policies/MemoryManagement.cpp b/src/framework/Policies/MemoryManagement.cpp index 776372e03..96b982b51 100644 --- a/src/framework/Policies/MemoryManagement.cpp +++ b/src/framework/Policies/MemoryManagement.cpp @@ -1,21 +1,21 @@ - /* -* Copyright (C) 2009-2010 MaNGOS -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Copyright (C) 2009-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ //lets use Intel scalable_allocator by default and //switch to OS specific allocator only when _STANDARD_MALLOC is defined diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h index 9be985e35..2a0751dfe 100755 --- a/src/framework/Utilities/ByteConverter.h +++ b/src/framework/Utilities/ByteConverter.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_BYTECONVERTER_H diff --git a/src/framework/Utilities/Callback.h b/src/framework/Utilities/Callback.h index d1f7601d1..5c9ab6d5a 100755 --- a/src/framework/Utilities/Callback.h +++ b/src/framework/Utilities/Callback.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_CALLBACK_H diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp index b54739206..2074540d2 100755 --- a/src/framework/Utilities/EventProcessor.cpp +++ b/src/framework/Utilities/EventProcessor.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/Utilities/EventProcessor.h b/src/framework/Utilities/EventProcessor.h index 3048ae0a0..61de1c6fb 100755 --- a/src/framework/Utilities/EventProcessor.h +++ b/src/framework/Utilities/EventProcessor.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,13 +18,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __EVENTPROCESSOR_H -#define __EVENTPROCESSOR_H +#ifndef HELLGROUND_EVENTPROCESSOR_H +#define HELLGROUND_EVENTPROCESSOR_H #include "Platform/Define.h" -#include - +#include +#include +#include // Note. All times are in milliseconds here. class HELLGROUND_IMPORT_EXPORT BasicEvent @@ -63,6 +64,12 @@ class HELLGROUND_IMPORT_EXPORT EventProcessor void Update(uint32 p_time); void KillAllEvents(bool force); void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); + + bool HasEventOfType(BasicEvent* type) + { + return std::any_of(m_events.begin(), m_events.end(), [&type](std::pair i) { return typeid(*i.second) == typeid(*type); }); + }; + uint64 CalculateTime(uint64 t_offset); protected: uint64 m_time; diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h index f312dfaea..849a8fd7d 100755 --- a/src/framework/Utilities/LinkedList.h +++ b/src/framework/Utilities/LinkedList.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _LINKEDLIST -#define _LINKEDLIST +#ifndef HELLGROUND_LINKEDLIST +#define HELLGROUND_LINKEDLIST #include "Common.h" diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h index 5f0e3a9e1..5fff40356 100755 --- a/src/framework/Utilities/LinkedReference/RefManager.h +++ b/src/framework/Utilities/LinkedReference/RefManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _REFMANAGER_H -#define _REFMANAGER_H +#ifndef HELLGROUND_REFMANAGER_H +#define HELLGROUND_REFMANAGER_H //===================================================== #include "Utilities/LinkedList.h" diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index 926317c9f..548ca5f64 100755 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _REFERENCE_H -#define _REFERENCE_H +#ifndef HELLGROUND_REFERENCE_H +#define HELLGROUND_REFERENCE_H #include "Utilities/LinkedList.h" #include "Log.h" diff --git a/src/framework/Utilities/TypeList.h b/src/framework/Utilities/TypeList.h index 6a63b3dca..bc815c661 100755 --- a/src/framework/Utilities/TypeList.h +++ b/src/framework/Utilities/TypeList.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/framework/Utilities/UnorderedMap.h b/src/framework/Utilities/UnorderedMap.h index c462ca35e..c72328e82 100755 --- a/src/framework/Utilities/UnorderedMap.h +++ b/src/framework/Utilities/UnorderedMap.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index 29c0b9e5c..42f90ef53 100755 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,8 +32,8 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass if (utf8length(username) > MAX_ACCOUNT_STR) return AOR_NAME_TOO_LONG; // username's too long - normilizeString(username); - normilizeString(password); + normalizeString(username); + normalizeString(password); AccountsDatabase.escape_string(username); AccountsDatabase.escape_string(password); @@ -98,8 +98,8 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, if (utf8length(new_passwd) > MAX_ACCOUNT_STR) return AOR_PASS_TOO_LONG; - normilizeString(new_uname); - normilizeString(new_passwd); + normalizeString(new_uname); + normalizeString(new_passwd); AccountsDatabase.escape_string(new_uname); AccountsDatabase.escape_string(new_passwd); @@ -119,10 +119,10 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) if (utf8length(new_passwd) > MAX_ACCOUNT_STR) return AOR_PASS_TOO_LONG; - normilizeString(new_passwd); + normalizeString(new_passwd); AccountsDatabase.escape_string(new_passwd); - if (!AccountsDatabase.PExecute("UPDATE account SET sha_pass_hash = SHA1(CONCAT(username, ':', '%s')) WHERE account_id = '%u'", new_passwd.c_str(), accid)) + if (!AccountsDatabase.PExecute("UPDATE account SET pass_hash = SHA1(CONCAT(username, ':', '%s')) WHERE account_id = '%u'", new_passwd.c_str(), accid)) return AOR_DB_INTERNAL_ERROR; // unexpected error return AOR_OK; @@ -147,6 +147,11 @@ uint64 AccountMgr::GetPermissions(uint32 acc_id) return 0; } +bool AccountMgr::HasPermissions(uint32 accId, uint64 perms) +{ + return GetPermissions(accId) & perms; +} + bool AccountMgr::GetName(uint32 acc_id, std::string &name) { QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT username FROM account WHERE account_id = '%u'", acc_id); @@ -161,17 +166,17 @@ bool AccountMgr::GetName(uint32 acc_id, std::string &name) bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) { - normilizeString(passwd); + normalizeString(passwd); AccountsDatabase.escape_string(passwd); - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT 1 FROM account WHERE account_id ='%u' AND sha_pass_hash=SHA1(CONCAT(username, ':', '%s'))", accid, passwd.c_str()); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT 1 FROM account WHERE account_id ='%u' AND pass_hash=SHA1(CONCAT(username, ':', '%s'))", accid, passwd.c_str()); if (result) return true; return false; } -bool AccountMgr::normilizeString(std::string& utf8str) +bool AccountMgr::normalizeString(std::string& utf8str) { wchar_t wstr_buf[MAX_ACCOUNT_STR+1]; @@ -183,3 +188,45 @@ bool AccountMgr::normilizeString(std::string& utf8str) return WStrToUtf8(wstr_buf,wstr_len,utf8str); } + +std::vector AccountMgr::GetRAFAccounts(uint32 accid, bool referred) +{ + + QueryResultAutoPtr result; + + if (referred) + result = AccountsDatabase.PQuery("SELECT `friend_id` FROM `account_friends` WHERE `id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERERS)); + else + result = AccountsDatabase.PQuery("SELECT `id` FROM `account_friends` WHERE `friend_id` = %u AND `expire_date` > NOW() LIMIT %u", accid, sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERALS)); + + std::vector acclist; + + if (result) + { + do + { + Field* fields = result->Fetch(); + uint32 refaccid = fields[0].GetUInt32(); + acclist.push_back(refaccid); + } + while (result->NextRow()); + } + + return acclist; +} + +AccountOpResult AccountMgr::AddRAFLink(uint32 accid, uint32 friendid) +{ + if (!AccountsDatabase.PExecute("INSERT INTO `account_friends` (`id`, `friend_id`, `expire_date`) VALUES (%u,%u,NOW() + INTERVAL 3 MONTH)", accid, friendid)) + return AOR_DB_INTERNAL_ERROR; + + return AOR_OK; +} + +AccountOpResult AccountMgr::DeleteRAFLink(uint32 accid, uint32 friendid) +{ + if (!AccountsDatabase.PExecute("DELETE FROM `account_friends` WHERE `id` = %u AND `friend_id` = %u", accid, friendid)) + return AOR_DB_INTERNAL_ERROR; + + return AOR_OK; +} diff --git a/src/game/AccountMgr.h b/src/game/AccountMgr.h index 95129b8a8..56a4dfc19 100755 --- a/src/game/AccountMgr.h +++ b/src/game/AccountMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _sAccountMgr_H -#define _sAccountMgr_H +#ifndef HELLGROUND_ACCOUNTMGR_H +#define HELLGROUND_ACCOUNTMGR_H #include "Common.h" #include @@ -46,9 +46,14 @@ namespace AccountMgr uint32 GetId(std::string username); uint64 GetPermissions(uint32 acc_id); + bool HasPermissions(uint32 accId, uint64 perms); bool GetName(uint32 acc_id, std::string &name); - bool normilizeString(std::string& utf8str); + bool normalizeString(std::string& utf8str); + + std::vector GetRAFAccounts(uint32 accid, bool referred = true); + AccountOpResult AddRAFLink(uint32 accid, uint32 friendid); + AccountOpResult DeleteRAFLink(uint32 accid, uint32 friendid); }; #endif diff --git a/src/game/AddonHandler.cpp b/src/game/AddonHandler.cpp index 43d347a84..a02f1574d 100755 --- a/src/game/AddonHandler.cpp +++ b/src/game/AddonHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/AddonHandler.h b/src/game/AddonHandler.h index c80f9b021..e87e136be 100755 --- a/src/game/AddonHandler.h +++ b/src/game/AddonHandler.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ADDONHANDLER_H -#define __ADDONHANDLER_H +#ifndef HELLGROUND_ADDONHANDLER_H +#define HELLGROUND_ADDONHANDLER_H #include "Common.h" #include "WorldPacket.h" diff --git a/src/game/AntiCheat.cpp b/src/game/AntiCheat.cpp index d55b59c0d..41b2194f3 100644 --- a/src/game/AntiCheat.cpp +++ b/src/game/AntiCheat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2012 HellGround + * Copyright (C) 2008-2014 HellGround * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +8,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "AntiCheat.h" @@ -35,29 +35,34 @@ int ACRequest::call() if (pPlayer->hasUnitState(UNIT_STAT_CHARGING)) return -1; - if (DetectTeleportToPlane(pPlayer)) - return -1; - uint32 latency = pPlayer->GetSession()->GetLatency(); - if (DetectWaterWalkHack(pPlayer)) + if (DetectFlyHack(pPlayer)) { - sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) - possible water walk Cheat. MapId: %u, coords: %f %f %f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s", + sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) - possible Fly Cheat. MapId: %u, coords: x: %f, y: %f, z: %f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s", pPlayer->GetName(), pPlayer->GetGUIDLow(), pPlayer->GetSession()->GetAccountId(), pPlayer->GetMapId(), GetNewMovementInfo().pos.x, GetNewMovementInfo().pos.y, GetNewMovementInfo().pos.z, GetNewMovementInfo().GetMovementFlags(), latency, pPlayer->GetMap() ? (pPlayer->GetMap()->IsBattleGroundOrArena() ? "Yes" : "No") : "No"); - - sWorld.SendGMText(LANG_ANTICHEAT_WATERWALK, pPlayer->GetName(), pPlayer->GetName()); + + pPlayer->CumulativeACReport(ANTICHEAT_CHECK_FLYHACK); + pPlayer->SetFlying(false); return -1; } - - if (DetectFlyHack(pPlayer)) + + if (DetectSpeedHack(pPlayer)) + return -1; + + if (DetectWaterWalkHack(pPlayer)) { - sWorld.SendGMText(LANG_ANTICHEAT_FLY, pPlayer->GetName(), pPlayer->GetName()); - sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) - possible Fly Cheat. MapId: %u, coords: x: %f, y: %f, z: %f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s", + sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) - possible water walk Cheat. MapId: %u, coords: %f %f %f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s", pPlayer->GetName(), pPlayer->GetGUIDLow(), pPlayer->GetSession()->GetAccountId(), pPlayer->GetMapId(), GetNewMovementInfo().pos.x, GetNewMovementInfo().pos.y, GetNewMovementInfo().pos.z, GetNewMovementInfo().GetMovementFlags(), latency, pPlayer->GetMap() ? (pPlayer->GetMap()->IsBattleGroundOrArena() ? "Yes" : "No") : "No"); + pPlayer->CumulativeACReport(ANTICHEAT_CHECK_WATERWALKHACK); + pPlayer->SetMovement(MOVE_LAND_WALK); return -1; } + if (DetectTeleportToPlane(pPlayer)) + return -1; + return 0; } @@ -139,26 +144,30 @@ bool ACRequest::DetectSpeedHack(Player *pPlayer) n.x = n.x - o.x; n.y = n.y - o.y; - uint32 exact2dDist = sqrt(n.x*n.x + n.y*n.y); + float exact2dDist = sqrt(n.x*n.x + n.y*n.y); - // how many yards the player can do in one sec. - uint32 speedRate = uint32(pPlayer->GetSpeed(UnitMoveType(moveType)) + GetNewMovementInfo().j_xyspeed); + // how many yards the player should do in one sec. (server-side speed) + float speedRate = pPlayer->GetSpeed(UnitMoveType(moveType)) + GetNewMovementInfo().j_xyspeed; // how long the player took to move to here. uint32 timeDiff = WorldTimer::getMSTimeDiff(GetLastMovementInfo().time, GetNewMovementInfo().time); if (!timeDiff) timeDiff = 1; - // this is the distance doable by the player in 1 sec, using the time done to move to this point. - uint32 clientSpeedRate = exact2dDist * 1000 / timeDiff; + //client-side speed, traveled distance div by movement time. + float clientSpeedRate = exact2dDist * 1000 / timeDiff; - // we did the (uint32) cast to accept a margin of tolerance - if (clientSpeedRate > speedRate) - return true; + if (clientSpeedRate <= speedRate * sWorld.getConfig(CONFIG_ANTICHEAT_SPEEDHACK_TOLERANCE)) + return false; pPlayer->m_AC_timer = IN_MILISECONDS; // 1 sek - sWorld.SendGMText(LANG_ANTICHEAT, pPlayer->GetName(), pPlayer->GetName(), 0, speedRate, clientSpeedRate); - sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) moved for distance %f with server speed : %f (client speed: %f). MapID: %u, player's coord before X:%f Y:%f Z:%f. Player's coord now X:%f Y:%f Z:%f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s", pPlayer->GetName(), pPlayer->GetGUIDLow(), pPlayer->GetSession()->GetAccountId(), exact2dDist, speedRate, clientSpeedRate, pPlayer->GetMapId(), GetLastMovementInfo().pos.x, GetLastMovementInfo().pos.y, GetLastMovementInfo().pos.z, GetNewMovementInfo().pos.x, GetNewMovementInfo().pos.y, GetNewMovementInfo().pos.z, GetNewMovementInfo().GetMovementFlags(), pPlayer->GetSession()->GetLatency(), pPlayer->GetMap() ? (pPlayer->GetMap()->IsBattleGroundOrArena() ? "Yes" : "No") : "No"); - return false; + sWorld.SendGMText(LANG_ANTICHEAT_SPEEDHACK, pPlayer->GetName(), pPlayer->GetName(), 0, speedRate, clientSpeedRate); + sLog.outLog(LOG_CHEAT, "Player %s (GUID: %u / ACCOUNT_ID: %u) moved for distance %f with server speed : %f (client speed: %f). MapID: %u, player's coord before X:%f Y:%f Z:%f. Player's coord now X:%f Y:%f Z:%f. MOVEMENTFLAGS: %u LATENCY: %u. BG/Arena: %s\n", + pPlayer->GetName(), pPlayer->GetGUIDLow(), pPlayer->GetSession()->GetAccountId(), exact2dDist, speedRate, + clientSpeedRate, pPlayer->GetMapId(), GetLastMovementInfo().pos.x, GetLastMovementInfo().pos.y, GetLastMovementInfo().pos.z, + GetNewMovementInfo().pos.x, GetNewMovementInfo().pos.y, GetNewMovementInfo().pos.z, + GetNewMovementInfo().GetMovementFlags(), pPlayer->GetSession()->GetLatency(), + pPlayer->GetMap() ? (pPlayer->GetMap()->IsBattleGroundOrArena() ? "Yes" : "No") : "No"); + return true; } diff --git a/src/game/AntiCheat.h b/src/game/AntiCheat.h index f9bbf7091..823495c5b 100644 --- a/src/game/AntiCheat.h +++ b/src/game/AntiCheat.h @@ -1,5 +1,23 @@ -#ifndef _ANTICHEAT_H -#define _ANTICHEAT_H +/* + * Copyright (C) 2008-2014 HellGround + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_ANTICHEAT_H +#define HELLGROUND_ANTICHEAT_H #include diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 9195274a1..fe635f7cb 100755 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,18 +9,19 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldPacket.h" #include "ObjectMgr.h" #include "ArenaTeam.h" #include "World.h" +#include "BattleGroundMgr.h" ArenaTeam::ArenaTeam() { @@ -551,7 +553,7 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating) //'chance' calculation - to beat the opponent float chance = GetChanceAgainst(stats.rating, againstRating); // calculate the rating modification (ELO system with k=32) - int32 mod = (int32)floor(32.0f * (1.0f - chance)); + int32 mod = (int32)floor((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT) * (1.0f - chance)); // modify the team stats accordingly stats.rating += mod; stats.games_week += 1; @@ -577,7 +579,7 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating) //'chance' calculation - to loose to the opponent float chance = GetChanceAgainst(stats.rating, againstRating); // calculate the rating modification (ELO system with k=32) - int32 mod = (int32)ceil(32.0f * (0.0f - chance)); + int32 mod = (int32)ceil((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT) * (0.0f - chance)); // modify the team stats accordingly stats.rating += mod; stats.games_week += 1; @@ -605,7 +607,7 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating, uint32 againstHid { // update personal rating float chance = GetChanceAgainst(itr->personal_rating, againstRating); - int32 mod = (int32)ceil(32.0f * (0.0f - chance)); + int32 mod = (int32)ceil((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT)* (0.0f - chance)); // NEED to check hiddenRatingbeforePenalty if (sWorld.getConfig(CONFIG_ENABLE_HIDDEN_RATING) && sWorld.getConfig(CONFIG_ENABLE_HIDDEN_RATING_LOWER_LOSS)) @@ -618,7 +620,7 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating, uint32 againstHid // update matchmaker rating chance = GetChanceAgainst(itr->matchmaker_rating, againstHiddenRating); - mod = (int32)ceil(32.0f * (0.0f - chance)); + mod = (int32)ceil((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT) * (0.0f - chance)); itr->ModifyMatchmakerRating(mod, GetType()); // update personal played stats @@ -628,7 +630,7 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating, uint32 againstHid // update the unit fields plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week); plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season); - return; + } } } @@ -642,12 +644,12 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating, uint32 againstHidd { // update personal rating float chance = GetChanceAgainst(itr->personal_rating, againstRating); - int32 mod = (int32)floor(32.0f * (1.0f - chance)); + int32 mod = (int32)floor((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT) * (1.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update matchmaker rating chance = GetChanceAgainst(itr->matchmaker_rating, againstHiddenRating); - mod = (int32)ceil(32.0f * (1.0f - chance)); + mod = (int32)ceil((float)sWorld.getConfig(CONFIG_ARENA_ELO_COEFFICIENT) * (1.0f - chance)); itr->ModifyMatchmakerRating(mod, GetType()); // update personal stats @@ -658,7 +660,16 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating, uint32 againstHidd // update unit fields plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week); plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season); - return; + + if(uint16 requirement = sWorld.getConfig(CONFIG_ARENA_DAILY_REQUIREMENT)) + { + plr->m_DailyArenasWon++; + if(plr->m_DailyArenasWon == requirement) + { + plr->ModifyArenaPoints(sWorld.getConfig(CONFIG_ARENA_DAILY_AP_REWARD)); + sLog.outLog(LOG_ARENA,"Player %s (%u) awarded from daily arena",plr->GetName(),plr->GetGUIDLow()); + } + } } } } diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 832562c31..2bbd8786a 100755 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_ARENATEAM_H -#define TRINITYCORE_ARENATEAM_H +#ifndef HELLGROUND_ARENATEAM_H +#define HELLGROUND_ARENATEAM_H enum ArenaTeamCommandTypes { diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index c5aabfeff..c36fe1127 100755 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldSession.h" diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 4d7e8be7c..87a942b7b 100755 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2011 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldPacket.h" @@ -31,6 +31,7 @@ #include "Mail.h" #include "Util.h" #include "Chat.h" +#include "luaengine/HookMgr.h" //please DO NOT use iterator++, because it is slower than ++iterator!!! //post-incrementation is always slower than pre-incrementation ! @@ -322,7 +323,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) return; } - if (GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount()); @@ -344,6 +345,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, it, etime, bid, buyout, deposit, pl); + // used by eluna + sHookMgr->OnAdd(auctionHouse); + SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK); } @@ -496,6 +500,10 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) RealmDataDatabase.CommitTransaction(); sAuctionMgr.RemoveAItem(auction->itemGuidLow); auctionHouse->RemoveAuction(auction->Id); + + // used by eluna + sHookMgr->OnRemove(auctionHouse); + delete auction; } diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index f5602fd10..6f5e040fd 100755 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "AuctionHouseMgr.h" @@ -69,7 +70,7 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 if (deposit < min_deposit) deposit = min_deposit; - return uint32(deposit * sWorld.getRate(RATE_AUCTION_DEPOSIT)); + return uint32(deposit * sWorld.getConfig(RATE_AUCTION_DEPOSIT)); } // does not clear ram void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) @@ -97,12 +98,12 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) bidderAccId = sObjectMgr.GetPlayerAccountIdByGUID(bidderGuid); bidderPermissions = bidderAccId ? AccountMgr::GetPermissions(bidderAccId) : PERM_PLAYER; if (!sObjectMgr.GetPlayerNameByGUID(bidderGuid, bidderName)) - bidderName = sObjectMgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); + bidderName = sObjectMgr.GetHellgroundStringForDBCLocale(LANG_UNKNOWN); } std::string ownerName; if (!sObjectMgr.GetPlayerNameByGUID(ownerGuid, ownerName)) - ownerName = sObjectMgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); + ownerName = sObjectMgr.GetHellgroundStringForDBCLocale(LANG_UNKNOWN); uint32 ownerAccId = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid); @@ -383,7 +384,7 @@ void AuctionHouseMgr::LoadAuctions() { std::string plName; if (!sObjectMgr.GetPlayerNameByGUID(ObjectGuid(HIGHGUID_PLAYER, auction->owner), plName)) - plName = sObjectMgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); + plName = sObjectMgr.GetHellgroundStringForDBCLocale(LANG_UNKNOWN); Utf8toWStr(plName, plWName); } @@ -894,7 +895,7 @@ void WorldSession::BuildListAuctionItems(AuctionHouseObject::AuctionEntryMap con AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* it, uint32 etime, uint32 bid, uint32 buyout, uint32 deposit, Player * pl /*= NULL*/) { - uint32 auction_time = uint32(etime * sWorld.getRate(RATE_AUCTION_TIME)); + uint32 auction_time = uint32(etime * sWorld.getConfig(RATE_AUCTION_TIME)); AuctionEntry *AH = new AuctionEntry; AH->Id = sObjectMgr.GenerateAuctionID(); @@ -974,7 +975,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const uint32 AuctionEntry::GetAuctionCut() const { - return uint32(auctionHouseEntry->cutPercent * bid * sWorld.getRate(RATE_AUCTION_CUT) / 100.f); + return uint32(auctionHouseEntry->cutPercent * bid * sWorld.getConfig(RATE_AUCTION_CUT) / 100.f); } /// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h index cadbe79a1..080b18c5d 100755 --- a/src/game/AuctionHouseMgr.h +++ b/src/game/AuctionHouseMgr.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUCTION_HOUSE_MGR_H -#define _AUCTION_HOUSE_MGR_H +#ifndef HELLGROUND_AUCTION_HOUSE_MGR_H +#define HELLGROUND_AUCTION_HOUSE_MGR_H #include "ace/Singleton.h" diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index ce3b86530..ca8ef5c5b 100755 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -166,7 +166,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/) void Bag::StoreItem(uint8 slot, Item *pItem, bool /*update*/) { - if (slot > MAX_BAG_SIZE) + if (slot >= MAX_BAG_SIZE) { sLog.outLog(LOG_DEFAULT, "ERROR: Player GUID " UI64FMTD " tried to manipulate packets and crash the server.", GetOwnerGUID()); return; diff --git a/src/game/Bag.h b/src/game/Bag.h index e0b6b15cf..282cd68fd 100755 --- a/src/game/Bag.h +++ b/src/game/Bag.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index c5a115f13..9f074b2bc 100755 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Object.h" @@ -93,6 +93,7 @@ BattleGround::BattleGround() m_PrematureCountDown = false; m_PrematureCountDown = 0; + m_TimeElapsedSinceBeggining = 0; m_HonorMode = BG_NORMAL; @@ -140,6 +141,7 @@ void BattleGround::Update(uint32 diff) return; m_StartTime += diff; + m_TimeElapsedSinceBeggining += diff; if (GetRemovedPlayersSize()) { @@ -261,7 +263,10 @@ void BattleGround::Update(uint32 diff) { m_PrematureCountDown = true; m_PrematureCountDownTimer = sBattleGroundMgr.GetPrematureFinishTime(); - SendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING); + if( sBattleGroundMgr.IsPrematureFinishTimerEnabled()) + PrepareMessageToAll("Not enough players. This battleground will close in %u min.",m_PrematureCountDownTimer / 60000); + else + SendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING); } else if (m_PrematureCountDownTimer < diff) { @@ -274,7 +279,10 @@ void BattleGround::Update(uint32 diff) uint32 newtime = m_PrematureCountDownTimer - diff; // announce every minute if (m_PrematureCountDownTimer != sBattleGroundMgr.GetPrematureFinishTime() && newtime / 60000 != m_PrematureCountDownTimer / 60000) - SendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING); + if( sBattleGroundMgr.IsPrematureFinishTimerEnabled()) + PrepareMessageToAll("Not enough players. This battleground will close in %u min.",m_PrematureCountDownTimer / 60000); + else + SendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING); m_PrematureCountDownTimer = newtime; } } @@ -297,12 +305,31 @@ void BattleGround::Update(uint32 diff) if (isArena() && GetStatus() == STATUS_IN_PROGRESS) { - uint8 dct = 5; - if (GetMapId() == 559 && dct && dct < (time(NULL) - m_progressStart)) + if (GetMapId() == 559 && BG_NA_DOOR_DESPAWN_TIMER < (time(NULL) - m_progressStart)) { for (uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_2; i++) - DelObject(i); + DelObject(i, false); + } + } + + if (isArena() && sBattleGroundMgr.GetArenaEndAfterTime() && m_TimeElapsedSinceBeggining > sBattleGroundMgr.GetArenaEndAfterTime() && GetStatus() == STATUS_IN_PROGRESS) + { + if (!sBattleGroundMgr.IsArenaEndAfterAlwaysDraw()) + { + if(GetAlivePlayersCountByTeam(HORDE) > GetAlivePlayersCountByTeam(ALLIANCE)) + { + EndBattleGround(HORDE); + return; + } + else if (GetAlivePlayersCountByTeam(HORDE) < GetAlivePlayersCountByTeam(ALLIANCE)) + { + EndBattleGround(ALLIANCE); + return; + } } + + EndBattleGround(0); + return; } } @@ -423,7 +450,6 @@ void BattleGround::YellToAll(Creature* creature, const char* text, uint32 langua } } - void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID) { for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) @@ -506,9 +532,9 @@ void BattleGround::EndBattleGround(uint32 winner) if (winner == ALLIANCE) { if (isBattleGround()) - winmsg = GetTrinityString(LANG_BG_A_WINS); + winmsg = GetHellgroundString(LANG_BG_A_WINS); else - winmsg = GetTrinityString(LANG_ARENA_GOLD_WINS); + winmsg = GetHellgroundString(LANG_ARENA_GOLD_WINS); PlaySoundToAll(SOUND_ALLIANCE_WINS); // alliance wins sound @@ -517,9 +543,9 @@ void BattleGround::EndBattleGround(uint32 winner) else if (winner == HORDE) { if (isBattleGround()) - winmsg = GetTrinityString(LANG_BG_H_WINS); + winmsg = GetHellgroundString(LANG_BG_H_WINS); else - winmsg = GetTrinityString(LANG_ARENA_GREEN_WINS); + winmsg = GetHellgroundString(LANG_ARENA_GREEN_WINS); PlaySoundToAll(SOUND_HORDE_WINS); // horde wins sound @@ -775,7 +801,7 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) sObjectMgr.GetItemLocaleStrings(markProto->ItemId, loc_idx, &subject); // text - std::string textFormat = plr->GetSession()->GetTrinityString(LANG_BG_MARK_BY_MAIL); + std::string textFormat = plr->GetSession()->GetHellgroundString(LANG_BG_MARK_BY_MAIL); char textBuf[300]; snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName()); uint32 itemTextId = sObjectMgr.CreateItemText(textBuf); @@ -831,6 +857,19 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac m_Players.erase(itr); // check if the player was a participant of the match, or only entered through gm command (goname) participant = true; + + if (isArena()) + { + switch (GetArenaType()) + { + case ARENA_TYPE_2v2: + sBattleGroundMgr.inArenasCount[0]--; break; + case ARENA_TYPE_3v3: + sBattleGroundMgr.inArenasCount[1]--; break; + case ARENA_TYPE_5v5: + sBattleGroundMgr.inArenasCount[2]--; break; + } + } } std::map::iterator itr2 = m_PlayerScores.find(guid); @@ -849,6 +888,10 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac if (plr && plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); + // should remove SPELL_AURA_MOD_STUN + if (plr && plr->isAlive() && plr->HasAuraType(SPELL_AURA_MOD_STUN)) + plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_STUN); //testfixbg + if (plr && !plr->isAlive()) // resurrect on exit { plr->ResurrectPlayer(1.0f); @@ -872,7 +915,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac if (isArena()) { plr->RemoveArenaAuras(true); // removes debuffs / dots etc., we don't want the player to die after porting out - plr->GetMotionMaster()->MoveIdle(); + plr->GetMotionMaster()->MovementExpired(); bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing) @@ -906,9 +949,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac } if (winner_arena_team && loser_arena_team) - { loser_arena_team->MemberLost(plr, winner_arena_team->GetRating(), winner_arena_team->GetAverageMMR(GetBgRaid(win))); - } } } @@ -1023,7 +1064,7 @@ void BattleGround::AnnounceBGStart() case BATTLEGROUND_EY: ss << "Eye of the Storm "; break; case BATTLEGROUND_AB: - ss << "Arathi Bathin "; break; + ss << "Arathi Basin "; break; default: return; } @@ -1061,6 +1102,9 @@ void BattleGround::AddPlayer(Player *plr) plr->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); plr->CombatStop(); + // should remove SPELL_AURA_MOD_STUN + if (plr && plr->isAlive() && plr->HasAuraType(SPELL_AURA_MOD_STUN)) + plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_STUN); //testfixbg // add arena specific auras if (isArena()) @@ -1095,10 +1139,17 @@ void BattleGround::AddPlayer(Player *plr) (plr)->SetTemporaryUnsummonedPetNumber(pet->GetCharmInfo()->GetPetNumber()); (plr)->SetOldPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL)); } + pet->RemoveArenaAuras(); plr->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT); } else + { + // Remove auras off unsummoned pet + if (plr->GetTemporaryUnsummonedPetNumber()) + RealmDataDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", plr->GetTemporaryUnsummonedPetNumber()); + plr->SetTemporaryUnsummonedPetNumber(0); + } if (GetStatus() == STATUS_WAIT_JOIN) // not started yet { @@ -1110,6 +1161,18 @@ void BattleGround::AddPlayer(Player *plr) if (plr->GetPower(POWER_RAGE)) plr->SetPower(POWER_RAGE, 0); } + + switch (GetArenaType()) + { + case ARENA_TYPE_2v2: + sBattleGroundMgr.inArenasCount[0]++; break; + case ARENA_TYPE_3v3: + sBattleGroundMgr.inArenasCount[1]++; break; + case ARENA_TYPE_5v5: + sBattleGroundMgr.inArenasCount[2]++; break; + } + + ChatHandler(plr).SendSysMessage("NOTICE: If you are ready, write: .arena ready. So, when everyone are ready arena preparation can end earlier."); } else { @@ -1208,6 +1271,8 @@ void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) break; case SCORE_DEATHS: // Deaths itr->second->Deaths += value; + if (itr->second->Deaths >= 50) + Source->ToUnit()->WorthHonor = true; break; case SCORE_HONORABLE_KILLS: // Honorable kills itr->second->HonorableKills += value; @@ -1500,7 +1565,7 @@ bool BattleGround::DelCreature(uint32 type) return true; } -bool BattleGround::DelObject(uint32 type) +bool BattleGround::DelObject(uint32 type, bool setGoState) { Map * map = GetMap(); if (!map) @@ -1516,7 +1581,7 @@ bool BattleGround::DelObject(uint32 type) return false; } obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); + obj->Delete(setGoState); m_BgObjects[type] = 0; return true; } @@ -1574,9 +1639,35 @@ void BattleGround::SendMessageToAll(char const* text) SendPacketToAll(&data); } +void BattleGround::SendMessageToTeam(uint32 team, char const* text) +{ + WorldPacket data; + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, text, NULL); + SendPacketToTeam(team, &data); +} + +void BattleGround::SendMessageToTeam(uint32 team, int32 entry) +{ + char const* text = GetHellgroundString(entry); + + WorldPacket data; + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, text, NULL); + SendPacketToTeam(team, &data); +} + +void BattleGround::PrepareMessageToAll(char const *format, ...) +{ + va_list ap; + char str [1024]; + va_start(ap, format); + vsnprintf(str,1024,format, ap); + va_end(ap); + SendMessageToAll(str); +} + void BattleGround::SendMessageToAll(int32 entry) { - char const* text = GetTrinityString(entry); + char const* text = GetHellgroundString(entry); WorldPacket data; ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, text, NULL); SendPacketToAll(&data); @@ -1592,10 +1683,10 @@ void BattleGround::EndNow() } // Battleground messages are localized using the dbc lang, they are not client language dependent -const char *BattleGround::GetTrinityString(int32 entry) +const char *BattleGround::GetHellgroundString(int32 entry) { // FIXME: now we have different DBC locales and need localized message for each target client - return sObjectMgr.GetTrinityStringForDBCLocale(entry); + return sObjectMgr.GetHellgroundStringForDBCLocale(entry); } bool BattleGround::HandlePlayerUnderMap(Player * plr, float z) @@ -1677,7 +1768,9 @@ void BattleGround::HandleKillPlayer(Player *player, Player *killer) // add +1 kills to group and +1 killing_blows to killer if (killer) { - UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1); + if (!player->ToUnit()->WorthHonor) + UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1); + UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1); for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) @@ -1687,7 +1780,7 @@ void BattleGround::HandleKillPlayer(Player *player, Player *killer) if (!plr || plr == killer) continue; - if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player)) + if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player) && !player->ToUnit()->WorthHonor) UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1); } } @@ -1805,5 +1898,69 @@ void BattleGround::SetStatus(uint32 Status) { m_Status = Status; if (Status == STATUS_IN_PROGRESS) + { m_progressStart = time(NULL); + m_TimeElapsedSinceBeggining = 0; + } +} + +void BattleGround::SendObjectiveComplete(uint32 id, uint32 TeamID, float x, float y) +{ + float distance =45.0f; + distance= distance*distance; + for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + { + Player *plr = sObjectMgr.GetPlayer(itr->first); + + if (!plr) + { + sLog.outDebug("BattleGround: Player " UI64FMTD " not found!", itr->first); + continue; + } + + uint32 team = itr->second.Team;//GetPlayerTeam(plr->GetGUID()); + if (!team) team = plr->GetTeam(); + + if (team == TeamID && plr->IsInWorld()) + { + float dist = (plr->GetPositionX() - x)*(plr->GetPositionX() - x)+(plr->GetPositionY() - y)*(plr->GetPositionY() - y); + if (dist < distance) + plr->KilledMonster(id, 0); + } + } +} + +bool BattleGround::SetPlayerReady(uint64 playerGUID) +{ + if ( !isArena() ) + return false; + + uint32 readyCount = m_guidsReady[ 0 ].size() + m_guidsReady[ 1 ].size(); + if ( readyCount == GetMaxPlayers() ) + return false; + + uint32 team = GetPlayerTeam( playerGUID ); + if ( team == TEAM_NONE ) + return false; + + if ( GetStatus() != STATUS_WAIT_JOIN ) + return false; + + if ( GetStartDelayTime() <= sWorld.getConfig(CONFIG_ARENA_READY_START_TIMER) ) + return false; + + uint8 idx = team == ALLIANCE ? 0 : 1; + m_guidsReady[ idx ].insert( playerGUID ); + + readyCount = m_guidsReady[ 0 ].size() + m_guidsReady[ 1 ].size(); + if ( readyCount == GetMaxPlayers() ) + { + SendMessageToAll( "Everyone are ready. Let's rumble!"); + SetStartDelayTime(sWorld.getConfig(CONFIG_ARENA_READY_START_TIMER)); + } + else if ( m_guidsReady[ idx ].size() == GetMaxPlayersPerTeam() ) + { + SendMessageToTeam(team == ALLIANCE ? HORDE : ALLIANCE, "Opponents are ready to start earlier, what about you?"); + } + return true; } diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 154a0ea97..6cce6d946 100755 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUND_H -#define __BATTLEGROUND_H +#ifndef HELLGROUND_BATTLEGROUND_H +#define HELLGROUND_BATTLEGROUND_H #include "Common.h" #include "SharedDefines.h" @@ -411,8 +411,12 @@ class HELLGROUND_IMPORT_EXPORT BattleGround void EndBattleGround(uint32 winner); void BlockMovement(Player *plr); + void PrepareMessageToAll(char const *format,...); void SendMessageToAll(char const* text); void SendMessageToAll(int32 entry); + void SendMessageToTeam(uint32 team, char const* text); + void SendMessageToTeam(uint32 team, int32 entry); + void SendObjectiveComplete(uint32 id, uint32 TeamID, float x, float y); /* Raid Group */ Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } @@ -474,14 +478,14 @@ class HELLGROUND_IMPORT_EXPORT BattleGround // void SpawnBGCreature(uint32 type, uint32 respawntime); Creature* AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime = 0); bool DelCreature(uint32 type); - bool DelObject(uint32 type); + bool DelObject(uint32 type, bool setGoState = true); bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team); void AddSpectatorNPC(float x, float y, float z, float o); int32 GetObjectType(uint64 guid); void DoorOpen(uint32 type); void DoorClose(uint32 type); - const char *GetTrinityString(int32 entry); + const char *GetHellgroundString(int32 entry); virtual bool HandlePlayerUnderMap(Player * plr, float z); void AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 guid, uint32 team); @@ -493,10 +497,15 @@ class HELLGROUND_IMPORT_EXPORT BattleGround void SetDeleteThis(){ m_SetDeleteThis = true; } + bool SetPlayerReady(uint64 guid); + protected: //this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends BattleGround void EndNow(); + std::set m_guidsReady[2]; + + /* Scorekeeping */ // Player scores std::map m_PlayerScores; @@ -514,6 +523,7 @@ class HELLGROUND_IMPORT_EXPORT BattleGround uint8 m_Events; bool m_BuffChange; + uint32 m_TimeElapsedSinceBeggining; uint32 m_score[2]; //array that keeps general team scores, used to determine who gets most marks when bg ends prematurely BGHonorMode m_HonorMode; diff --git a/src/game/BattleGroundAA.cpp b/src/game/BattleGroundAA.cpp index f9f76e5b6..f092b4084 100755 --- a/src/game/BattleGroundAA.cpp +++ b/src/game/BattleGroundAA.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/BattleGroundAA.h b/src/game/BattleGroundAA.h index 16ad2e5c5..81768dc58 100755 --- a/src/game/BattleGroundAA.h +++ b/src/game/BattleGroundAA.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDAA_H -#define __BATTLEGROUNDAA_H + +#ifndef HELLGROUND_BATTLEGROUNDAA_H +#define HELLGROUND_BATTLEGROUNDAA_H class BattleGround; diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 7928218d2..bcf73c428 100755 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,19 +96,19 @@ void BattleGroundAB::Update(uint32 diff) else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; - SendMessageToAll(GetTrinityString(LANG_BG_AB_ONEMINTOSTART)); + SendMessageToAll(GetHellgroundString(LANG_BG_AB_ONEMINTOSTART)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; - SendMessageToAll(GetTrinityString(LANG_BG_AB_HALFMINTOSTART)); + SendMessageToAll(GetHellgroundString(LANG_BG_AB_HALFMINTOSTART)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; - SendMessageToAll(GetTrinityString(LANG_BG_AB_STARTED)); + SendMessageToAll(GetHellgroundString(LANG_BG_AB_STARTED)); // spawn neutral banners for (int banner = BG_AB_OBJECT_BANNER_NEUTRAL, i = 0; i < 5; banner += 8, ++i) @@ -172,7 +172,7 @@ void BattleGroundAB::Update(uint32 diff) // Message to chatlog char buf[256]; uint8 type = (teamIndex == 0) ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE; - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_TAKEN), (teamIndex == 0) ? GetTrinityString(LANG_BG_AB_ALLY) : GetTrinityString(LANG_BG_AB_HORDE), _GetNodeName(node)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_TAKEN), (teamIndex == 0) ? GetHellgroundString(LANG_BG_AB_ALLY) : GetHellgroundString(LANG_BG_AB_HORDE), _GetNodeName(node)); WorldPacket data; ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, buf, NULL); SendPacketToAll(&data); @@ -212,9 +212,9 @@ void BattleGroundAB::Update(uint32 diff) if (!m_IsInformedNearVictory && m_TeamScores[team] > 1800) { if (team == BG_TEAM_ALLIANCE) - SendMessageToAll(GetTrinityString(LANG_BG_AB_A_NEAR_VICTORY)); + SendMessageToAll(GetHellgroundString(LANG_BG_AB_A_NEAR_VICTORY)); else - SendMessageToAll(GetTrinityString(LANG_BG_AB_H_NEAR_VICTORY)); + SendMessageToAll(GetHellgroundString(LANG_BG_AB_H_NEAR_VICTORY)); PlaySoundToAll(SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } @@ -325,15 +325,15 @@ const char* BattleGroundAB::_GetNodeName(uint8 node) switch (node) { case BG_AB_NODE_STABLES: - return GetTrinityString(LANG_BG_AB_NODE_STABLES); + return GetHellgroundString(LANG_BG_AB_NODE_STABLES); case BG_AB_NODE_BLACKSMITH: - return GetTrinityString(LANG_BG_AB_NODE_BLACKSMITH); + return GetHellgroundString(LANG_BG_AB_NODE_BLACKSMITH); case BG_AB_NODE_FARM: - return GetTrinityString(LANG_BG_AB_NODE_FARM); + return GetHellgroundString(LANG_BG_AB_NODE_FARM); case BG_AB_NODE_LUMBER_MILL: - return GetTrinityString(LANG_BG_AB_NODE_LUMBER_MILL); + return GetHellgroundString(LANG_BG_AB_NODE_LUMBER_MILL); case BG_AB_NODE_GOLD_MINE: - return GetTrinityString(LANG_BG_AB_NODE_GOLD_MINE); + return GetHellgroundString(LANG_BG_AB_NODE_GOLD_MINE); default: ASSERT(0); } @@ -490,8 +490,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_CLAIMED), _GetNodeName(node), (teamIndex == 0) ? GetTrinityString(LANG_BG_AB_ALLY) : GetTrinityString(LANG_BG_AB_HORDE)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_CLAIMED), _GetNodeName(node), (teamIndex == 0) ? GetHellgroundString(LANG_BG_AB_ALLY) : GetHellgroundString(LANG_BG_AB_HORDE)); sound = SOUND_NODE_CLAIMED; + SendObjectiveComplete(BG_AB_CREDITMARKER[node], teamIndex,BG_AB_NodePositions[node][1],BG_AB_NodePositions[node][2]); } // If node is contested else if ((m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_CONTESTED) || (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_CONTESTED)) @@ -508,7 +509,8 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ _CreateBanner(node, BG_AB_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_ASSAULTED), _GetNodeName(node)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_ASSAULTED), _GetNodeName(node)); + SendObjectiveComplete(BG_AB_CREDITMARKER[node], teamIndex,BG_AB_NodePositions[node][1],BG_AB_NodePositions[node][2]); } // If contested, change back to occupied else @@ -523,7 +525,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ _SendNodeUpdate(node); m_NodeTimers[node] = 0; _NodeOccupied(node,(teamIndex == 0) ? ALLIANCE:HORDE); - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_DEFENDED), _GetNodeName(node)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_DEFENDED), _GetNodeName(node)); } sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; } @@ -540,8 +542,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ _SendNodeUpdate(node); _NodeDeOccupied(node); m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_ASSAULTED), _GetNodeName(node)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_ASSAULTED), _GetNodeName(node)); sound = (teamIndex == 0) ? SOUND_NODE_ASSAULTED_ALLIANCE : SOUND_NODE_ASSAULTED_HORDE; + SendObjectiveComplete(BG_AB_CREDITMARKER[node], teamIndex,BG_AB_NodePositions[node][1],BG_AB_NodePositions[node][2]); } WorldPacket data; ChatHandler::FillMessageData(&data, source->GetSession(), type, LANG_UNIVERSAL, NULL, source->GetGUID(), buf, NULL); @@ -549,7 +552,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ // If node is occupied again, send "X has taken the Y" msg. if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED) { - sprintf(buf, GetTrinityString(LANG_BG_AB_NODE_TAKEN), (teamIndex == 0) ? GetTrinityString(LANG_BG_AB_ALLY) : GetTrinityString(LANG_BG_AB_HORDE), _GetNodeName(node)); + sprintf(buf, GetHellgroundString(LANG_BG_AB_NODE_TAKEN), (teamIndex == 0) ? GetHellgroundString(LANG_BG_AB_ALLY) : GetHellgroundString(LANG_BG_AB_HORDE), _GetNodeName(node)); ChatHandler::FillMessageData(&data, NULL, type, LANG_UNIVERSAL, NULL, 0, buf, NULL); SendPacketToAll(&data); } diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index 7ecc6989b..8f5e60eef 100755 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDAB_H -#define __BATTLEGROUNDAB_H + +#ifndef HELLGROUND_BATTLEGROUNDAB_H +#define HELLGROUND_BATTLEGROUNDAB_H class BattleGround; @@ -63,7 +64,7 @@ enum BG_AB_WorldStates const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787}; const uint32 BG_AB_OP_NODEICONS[5] = {1842, 1846, 1845, 1844, 1843}; - +const uint32 BG_AB_CREDITMARKER[5] = {15001, 15002, 15003, 15004, 15005}; /* Note: code uses that these IDs follow each other */ enum BG_AB_NodeObjectId { diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 5444bb105..487feace0 100755 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,7 +93,7 @@ void BattleGroundAV::HandleKillUnit(Creature *unit, Player *killer) SpawnBGObject(BG_AV_OBJECT_BURN_BUILDING_ALLIANCE+i,RESPAWN_IMMEDIATELY); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) - YellToAll(creature,GetTrinityString(LANG_BG_AV_A_CAPTAIN_DEAD),LANG_UNIVERSAL); + YellToAll(creature,GetHellgroundString(LANG_BG_AV_A_CAPTAIN_DEAD),LANG_UNIVERSAL); } else if (entry == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0]) @@ -112,12 +112,18 @@ void BattleGroundAV::HandleKillUnit(Creature *unit, Player *killer) SpawnBGObject(BG_AV_OBJECT_BURN_BUILDING_HORDE+i,RESPAWN_IMMEDIATELY); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) - YellToAll(creature,GetTrinityString(LANG_BG_AV_H_CAPTAIN_DEAD),LANG_UNIVERSAL); + YellToAll(creature,GetHellgroundString(LANG_BG_AV_H_CAPTAIN_DEAD),LANG_UNIVERSAL); } else if (entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_N_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_A_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_N_MINE_H_4][0]) + { ChangeMineOwner(AV_NORTH_MINE,killer->GetTeam()); + SendObjectiveComplete(BG_AV_MINE_CREDITMARKER, killer->GetTeam(),BG_AV_CreaturePos[AV_CPLACE_MINE_N_3][1],BG_AV_ObjectPos[AV_CPLACE_MINE_N_3][2]); + } else if (entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_N_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_A_4][0] || entry == BG_AV_CreatureInfo[AV_NPC_S_MINE_H_4][0]) + { ChangeMineOwner(AV_SOUTH_MINE,killer->GetTeam()); + SendObjectiveComplete(BG_AV_MINE_CREDITMARKER, killer->GetTeam(),BG_AV_CreaturePos[AV_CPLACE_MINE_S_3][1],BG_AV_ObjectPos[AV_CPLACE_MINE_S_3][2]); + } } void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player) @@ -242,7 +248,7 @@ void BattleGroundAV::UpdateScore(uint16 team, int16 points) } else if (!m_IsInformedNearVictory[teamindex] && m_Team_Scores[teamindex] < SEND_MSG_NEAR_LOSE) { - SendMessageToAll(GetTrinityString((teamindex==BG_TEAM_HORDE)?LANG_BG_AV_H_NEAR_LOSE:LANG_BG_AV_A_NEAR_LOSE)); + SendMessageToAll(GetHellgroundString((teamindex==BG_TEAM_HORDE)?LANG_BG_AV_H_NEAR_LOSE:LANG_BG_AV_A_NEAR_LOSE)); PlaySoundToAll(AV_SOUND_NEAR_VICTORY); m_IsInformedNearVictory[teamindex] = true; } @@ -381,13 +387,13 @@ void BattleGroundAV::Update(uint32 diff) else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; - SendMessageToAll(GetTrinityString(LANG_BG_AV_ONEMINTOSTART)); + SendMessageToAll(GetHellgroundString(LANG_BG_AV_ONEMINTOSTART)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; - SendMessageToAll(GetTrinityString(LANG_BG_AV_HALFMINTOSTART)); + SendMessageToAll(GetHellgroundString(LANG_BG_AV_HALFMINTOSTART)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10)) @@ -396,7 +402,7 @@ void BattleGroundAV::Update(uint32 diff) UpdateWorldState(AV_SHOW_A_SCORE, 1); m_Events |= 0x10; - SendMessageToAll(GetTrinityString(LANG_BG_AV_STARTED)); + SendMessageToAll(GetHellgroundString(LANG_BG_AV_STARTED)); PlaySoundToAll(SOUND_BG_START); SetStatus(STATUS_IN_PROGRESS); @@ -670,9 +676,9 @@ void BattleGroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) //send a nice message to all :) char buf[256]; if (IsTower(node)) - sprintf(buf, GetTrinityString(LANG_BG_AV_TOWER_TAKEN) , GetNodeName(node),(owner == ALLIANCE) ? GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE) ); + sprintf(buf, GetHellgroundString(LANG_BG_AV_TOWER_TAKEN) , GetNodeName(node),(owner == ALLIANCE) ? GetHellgroundString(LANG_BG_AV_ALLY) : GetHellgroundString(LANG_BG_AV_HORDE) ); else - sprintf(buf, GetTrinityString(LANG_BG_AV_GRAVE_TAKEN) , GetNodeName(node),(owner == ALLIANCE) ? GetTrinityString(LANG_BG_AV_ALLY) :GetTrinityString(LANG_BG_AV_HORDE) ); + sprintf(buf, GetHellgroundString(LANG_BG_AV_GRAVE_TAKEN) , GetNodeName(node),(owner == ALLIANCE) ? GetHellgroundString(LANG_BG_AV_ALLY) :GetHellgroundString(LANG_BG_AV_HORDE) ); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) @@ -753,7 +759,7 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, uint32 team, bool initial) { m_Mine_Reclaim_Timer[mine]=AV_MINE_RECLAIM_TIMER; char buf[256]; - sprintf(buf, GetTrinityString(LANG_BG_AV_MINE_TAKEN), GetTrinityString((mine == AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH), (team == ALLIANCE) ? GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE)); + sprintf(buf, GetHellgroundString(LANG_BG_AV_MINE_TAKEN), GetHellgroundString((mine == AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH), (team == ALLIANCE) ? GetHellgroundString(LANG_BG_AV_ALLY) : GetHellgroundString(LANG_BG_AV_HORDE)); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) YellToAll(creature,buf,LANG_UNIVERSAL); @@ -971,7 +977,7 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, uint32 object) } //send a nice message to all :) char buf[256]; - sprintf(buf, GetTrinityString((IsTower(node)) ? LANG_BG_AV_TOWER_DEFENDED : LANG_BG_AV_GRAVE_DEFENDED), GetNodeName(node),(team == ALLIANCE) ? GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE)); + sprintf(buf, GetHellgroundString((IsTower(node)) ? LANG_BG_AV_TOWER_DEFENDED : LANG_BG_AV_GRAVE_DEFENDED), GetNodeName(node),(team == ALLIANCE) ? GetHellgroundString(LANG_BG_AV_ALLY) : GetHellgroundString(LANG_BG_AV_HORDE)); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) YellToAll(creature,buf,LANG_UNIVERSAL); @@ -1005,6 +1011,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) else SpawnBGObject(BG_AV_OBJECT_FLAG_C_H_SNOWFALL_GRAVE, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_AV_OBJECT_AURA_N_FIRSTAID_STATION+3*node,RESPAWN_IMMEDIATELY); //neutral aura spawn + SendObjectiveComplete(BG_AV_GY_CREDITMARKER, team,BG_AV_ObjectPos[node][1],BG_AV_ObjectPos[node][2]); } else if (m_Nodes[node].TotalOwner == AV_NEUTRAL_TEAM) //recapping, when no team owns this node realy { @@ -1047,6 +1054,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) SpawnBGObject(BG_AV_OBJECT_TAURA_H_DUNBALDAR_SOUTH+(2*(node-BG_AV_NODES_DUNBALDAR_SOUTH)),(team==HORDE)? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY); SpawnBGObject(BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH+(2*(node-BG_AV_NODES_DUNBALDAR_SOUTH)),(team==ALLIANCE)? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY); SpawnBGObject(BG_AV_OBJECT_TFLAG_H_DUNBALDAR_SOUTH+(2*(node-BG_AV_NODES_DUNBALDAR_SOUTH)),(team==HORDE)? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY); + SendObjectiveComplete(BG_AV_TOWER_CREDITMARKER, team,BG_AV_ObjectPos[node][1],BG_AV_ObjectPos[node][2]); } else { @@ -1065,7 +1073,11 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) if (!plr) continue; if (!ClosestGrave) + { + m_Nodes[node].Owner=536-m_Nodes[node].Owner; // Ally <-> Horde swap, prevents from selecting this grave as closest one ClosestGrave = GetClosestGraveYard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetTeam()); + m_Nodes[node].Owner=536-m_Nodes[node].Owner; // return + } plr->NearTeleportTo(ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation()); } @@ -1081,7 +1093,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) //send a nice message to all :) char buf[256]; - sprintf(buf, (IsTower(node)) ? GetTrinityString(LANG_BG_AV_TOWER_ASSAULTED) : GetTrinityString(LANG_BG_AV_GRAVE_ASSAULTED), GetNodeName(node), (team == ALLIANCE) ? GetTrinityString(LANG_BG_AV_ALLY) : GetTrinityString(LANG_BG_AV_HORDE)); + sprintf(buf, (IsTower(node)) ? GetHellgroundString(LANG_BG_AV_TOWER_ASSAULTED) : GetHellgroundString(LANG_BG_AV_GRAVE_ASSAULTED), GetNodeName(node), (team == ALLIANCE) ? GetHellgroundString(LANG_BG_AV_ALLY) : GetHellgroundString(LANG_BG_AV_HORDE)); Creature* creature = GetBGCreature(AV_CPLACE_HERALD); if (creature) YellToAll(creature,buf,LANG_UNIVERSAL); @@ -1352,21 +1364,21 @@ const char* BattleGroundAV::GetNodeName(BG_AV_Nodes node) { switch (node) { - case BG_AV_NODES_FIRSTAID_STATION: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_STORM_AID); - case BG_AV_NODES_DUNBALDAR_SOUTH: return GetTrinityString(LANG_BG_AV_NODE_TOWER_DUN_S); - case BG_AV_NODES_DUNBALDAR_NORTH: return GetTrinityString(LANG_BG_AV_NODE_TOWER_DUN_N); - case BG_AV_NODES_STORMPIKE_GRAVE: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_STORMPIKE); - case BG_AV_NODES_ICEWING_BUNKER: return GetTrinityString(LANG_BG_AV_NODE_TOWER_ICEWING); - case BG_AV_NODES_STONEHEART_GRAVE: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_STONE); - case BG_AV_NODES_STONEHEART_BUNKER: return GetTrinityString(LANG_BG_AV_NODE_TOWER_STONE); - case BG_AV_NODES_SNOWFALL_GRAVE: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_SNOW); - case BG_AV_NODES_ICEBLOOD_TOWER: return GetTrinityString(LANG_BG_AV_NODE_TOWER_ICE); - case BG_AV_NODES_ICEBLOOD_GRAVE: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_ICE); - case BG_AV_NODES_TOWER_POINT: return GetTrinityString(LANG_BG_AV_NODE_TOWER_POINT); - case BG_AV_NODES_FROSTWOLF_GRAVE: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_FROST); - case BG_AV_NODES_FROSTWOLF_ETOWER: return GetTrinityString(LANG_BG_AV_NODE_TOWER_FROST_E); - case BG_AV_NODES_FROSTWOLF_WTOWER: return GetTrinityString(LANG_BG_AV_NODE_TOWER_FROST_W); - case BG_AV_NODES_FROSTWOLF_HUT: return GetTrinityString(LANG_BG_AV_NODE_GRAVE_FROST_HUT); + case BG_AV_NODES_FIRSTAID_STATION: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_STORM_AID); + case BG_AV_NODES_DUNBALDAR_SOUTH: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_DUN_S); + case BG_AV_NODES_DUNBALDAR_NORTH: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_DUN_N); + case BG_AV_NODES_STORMPIKE_GRAVE: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_STORMPIKE); + case BG_AV_NODES_ICEWING_BUNKER: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_ICEWING); + case BG_AV_NODES_STONEHEART_GRAVE: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_STONE); + case BG_AV_NODES_STONEHEART_BUNKER: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_STONE); + case BG_AV_NODES_SNOWFALL_GRAVE: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_SNOW); + case BG_AV_NODES_ICEBLOOD_TOWER: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_ICE); + case BG_AV_NODES_ICEBLOOD_GRAVE: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_ICE); + case BG_AV_NODES_TOWER_POINT: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_POINT); + case BG_AV_NODES_FROSTWOLF_GRAVE: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_FROST); + case BG_AV_NODES_FROSTWOLF_ETOWER: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_FROST_E); + case BG_AV_NODES_FROSTWOLF_WTOWER: return GetHellgroundString(LANG_BG_AV_NODE_TOWER_FROST_W); + case BG_AV_NODES_FROSTWOLF_HUT: return GetHellgroundString(LANG_BG_AV_NODE_GRAVE_FROST_HUT); default: { sLog.outLog(LOG_DEFAULT, "ERROR: tried to get name for node %u%",node); diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index a2b37bcbe..4e4ac1a30 100755 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDAV_H -#define __BATTLEGROUNDAV_H +#ifndef HELLGROUND_BATTLEGROUNDAV_H +#define HELLGROUND_BATTLEGROUNDAV_H class BattleGround; @@ -109,6 +109,14 @@ enum BG_AV_OTHER_VALUES AV_MINE_RECLAIM_TIMER = 1200000, //TODO: get the right value.. this is currently 20 minutes AV_NEUTRAL_TEAM = 0 //this is the neutral owner of snowfall }; + +enum BG_AV_CREDITMARKERS +{ + BG_AV_GY_CREDITMARKER =13756, + BG_AV_TOWER_CREDITMARKER =13778, + BG_AV_MINE_CREDITMARKER =13796 +}; + enum BG_AV_ObjectIds { //cause the mangos-system is a bit different, we don't use the right go-ids for every node.. if we want to be 100% like another big server, we must take one object for every node diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp index cc77b26a1..8e6c0380f 100755 --- a/src/game/BattleGroundBE.cpp +++ b/src/game/BattleGroundBE.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/BattleGroundBE.h b/src/game/BattleGroundBE.h index 33393e640..b64773beb 100755 --- a/src/game/BattleGroundBE.h +++ b/src/game/BattleGroundBE.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDBE_H -#define __BATTLEGROUNDBE_H + +#ifndef HELLGROUND_BATTLEGROUNDBE_H +#define HELLGROUND_BATTLEGROUNDBE_H class BattleGround; diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index c3d319994..5c85cdff7 100755 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,13 +88,13 @@ void BattleGroundEY::Update(uint32 diff) else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; - SendMessageToAll(GetTrinityString(LANG_BG_EY_ONE_MINUTE)); + SendMessageToAll(GetHellgroundString(LANG_BG_EY_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; - SendMessageToAll(GetTrinityString(LANG_BG_EY_HALF_MINUTE)); + SendMessageToAll(GetHellgroundString(LANG_BG_EY_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) @@ -115,7 +115,7 @@ void BattleGroundEY::Update(uint32 diff) SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REALVER + buff + i * 3, RESPAWN_IMMEDIATELY); } - SendMessageToAll(GetTrinityString(LANG_BG_EY_BEGIN)); + SendMessageToAll(GetHellgroundString(LANG_BG_EY_BEGIN)); PlaySoundToAll(SOUND_BG_START); if (sWorld.getConfig(CONFIG_BG_START_MUSIC)) @@ -581,7 +581,7 @@ void BattleGroundEY::RespawnFlag(bool send_message) if (send_message) { - SendMessageToAll(GetTrinityString(LANG_BG_EY_RESETED_FLAG)); + SendMessageToAll(GetHellgroundString(LANG_BG_EY_RESETED_FLAG)); PlaySoundToAll(BG_EY_SOUND_FLAG_RESET); // flags respawned sound... } @@ -646,12 +646,12 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player *Source) Source->CastSpell(Source, BG_EY_PLAYER_DROPPED_FLAG_SPELL, true); if (Source->GetTeam() == ALLIANCE) { - message = GetTrinityString(LANG_BG_EY_DROPPED_FLAG); + message = GetHellgroundString(LANG_BG_EY_DROPPED_FLAG); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; } else { - message = GetTrinityString(LANG_BG_EY_DROPPED_FLAG); + message = GetHellgroundString(LANG_BG_EY_DROPPED_FLAG); type = CHAT_MSG_BG_SYSTEM_HORDE; } //this does not work correctly :((it should remove flag carrier name) @@ -670,7 +670,7 @@ void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target const char *message; uint8 type = 0; - message = GetTrinityString(LANG_BG_EY_HAS_TAKEN_FLAG); + message = GetHellgroundString(LANG_BG_EY_HAS_TAKEN_FLAG); if (Source->GetTeam() == ALLIANCE) { @@ -717,7 +717,7 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point) { m_TeamPointsCount[BG_TEAM_ALLIANCE]--; message_type = CHAT_MSG_BG_SYSTEM_ALLIANCE; - message = GetTrinityString(m_LoosingPointTypes[Point].MessageIdAlliance); + message = GetHellgroundString(m_LoosingPointTypes[Point].MessageIdAlliance); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeAlliance, RESPAWN_ONE_DAY); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeAlliance + 1, RESPAWN_ONE_DAY); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeAlliance + 2, RESPAWN_ONE_DAY); @@ -726,7 +726,7 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point) { m_TeamPointsCount[BG_TEAM_HORDE]--; message_type = CHAT_MSG_BG_SYSTEM_HORDE; - message = GetTrinityString(m_LoosingPointTypes[Point].MessageIdHorde); + message = GetHellgroundString(m_LoosingPointTypes[Point].MessageIdHorde); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeHorde, RESPAWN_ONE_DAY); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeHorde + 1, RESPAWN_ONE_DAY); SpawnBGObject(m_LoosingPointTypes[Point].DespawnObjectTypeHorde + 2, RESPAWN_ONE_DAY); @@ -766,7 +766,7 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) { m_TeamPointsCount[BG_TEAM_ALLIANCE]++; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; - message = GetTrinityString(m_CapturingPointTypes[Point].MessageIdAlliance); + message = GetHellgroundString(m_CapturingPointTypes[Point].MessageIdAlliance); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY); @@ -775,7 +775,7 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) { m_TeamPointsCount[BG_TEAM_HORDE]++; type = CHAT_MSG_BG_SYSTEM_HORDE; - message = GetTrinityString(m_CapturingPointTypes[Point].MessageIdHorde); + message = GetHellgroundString(m_CapturingPointTypes[Point].MessageIdHorde); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY); SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY); @@ -823,14 +823,14 @@ void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType { PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_ALLIANCE); team_id = BG_TEAM_ALLIANCE; - message = GetTrinityString(LANG_BG_EY_CAPTURED_FLAG_A); + message = GetHellgroundString(LANG_BG_EY_CAPTURED_FLAG_A); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; } else { PlaySoundToAll(BG_EY_SOUND_FLAG_CAPTURED_HORDE); team_id = BG_TEAM_HORDE; - message = GetTrinityString(LANG_BG_EY_CAPTURED_FLAG_H); + message = GetHellgroundString(LANG_BG_EY_CAPTURED_FLAG_H); type = CHAT_MSG_BG_SYSTEM_HORDE; } @@ -919,50 +919,29 @@ void BattleGroundEY::FillInitialWorldStates(WorldPacket& data) WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(float x, float y, float z, uint32 team) { - uint32 g_id = 0; - - if (team == ALLIANCE) - g_id = EY_GRAVEYARD_MAIN_ALLIANCE; - else if (team == HORDE) - g_id = EY_GRAVEYARD_MAIN_HORDE; - else - return NULL; - - float distance, nearestDistance; - - WorldSafeLocsEntry const* entry = NULL; - WorldSafeLocsEntry const* nearestEntry = NULL; - entry = sWorldSafeLocsStore.LookupEntry(g_id); - nearestEntry = entry; - - if (!entry) - { - sLog.outLog(LOG_DEFAULT, "ERROR: BattleGroundEY: Not found the main team graveyard. Graveyard system isn't working!"); - return NULL; - } - - distance = (entry->x - x)*(entry->x - x) + (entry->y - y)*(entry->y - y) + (entry->z - z)*(entry->z - z); - nearestDistance = distance; - + WorldSafeLocsEntry const* good_entry = NULL; + float mindist = 999999.0f; for (uint8 i = 0; i < EY_POINTS_MAX; ++i) { - if (m_PointOwnedByTeam[i]==team && m_PointState[i]==EY_POINT_UNDER_CONTROL) + WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry(i+EY_GRAVEYARD_FEL_REALVER); + if (!entry || !(m_PointOwnedByTeam[i]==team) || !(m_PointState[i]==EY_POINT_UNDER_CONTROL)) + continue; + float dist = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z); + if (mindist > dist) { - entry = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[i].GraveYardId); - if (!entry) - sLog.outLog(LOG_DEFAULT, "ERROR: BattleGroundEY: Not found graveyard: %u",m_CapturingPointTypes[i].GraveYardId); - else - { - distance = (entry->x - x)*(entry->x - x) + (entry->y - y)*(entry->y - y) + (entry->z - z)*(entry->z - z); - if (distance < nearestDistance) - { - nearestDistance = distance; - nearestEntry = entry; - } - } + mindist = dist; + good_entry = entry; } } + // If not, place ghost on starting location + if (!good_entry) + { + if (team== ALLIANCE) + good_entry = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE); + else + good_entry = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_HORDE); + } - return nearestEntry; + return good_entry; } diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index eddf7c7d0..17cdd7a02 100755 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDEY_H -#define __BATTLEGROUNDEY_H +#ifndef HELLGROUND_BATTLEGROUNDEY_H +#define HELLGROUND_BATTLEGROUNDEY_H #include "Language.h" diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 526b6df7d..d3cec7ed5 100755 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -206,7 +206,7 @@ void WorldSession::HandleBattleGroundJoinOpcode(WorldPacket & recv_data ) if (sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_INFO)) { - uint32 queuedHorde = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetQueuedPlayersCount(BG_TEAM_ALLIANCE, bgBracketId); + uint32 queuedHorde = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetQueuedPlayersCount(BG_TEAM_HORDE, bgBracketId); uint32 queuedAlliance = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetQueuedPlayersCount(BG_TEAM_ALLIANCE, bgBracketId); uint32 minPlayers = bg->GetMinPlayersPerTeam(); ChatHandler(_player).PSendSysMessage("Horde queued: %u, Alliance queued: %u. Minimum per team: %u", queuedHorde, queuedAlliance, minPlayers); @@ -244,15 +244,43 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket & /*recv_ data << count2; // horde flag holders count if (ap) { - data << (uint64)ap->GetGUID(); - data << (float)ap->GetPositionX(); - data << (float)ap->GetPositionY(); + // Horde team can always track alliance flag picker + if (_player->GetTeam() == HORDE) + { + data << (uint64)ap->GetGUID(); + data << (float)ap->GetPositionX(); + data << (float)ap->GetPositionY(); + } + + if (_player->GetTeam() == ALLIANCE) + { + if (BG_WS_FLAG_UPDATE_TIME < (time(NULL) - ((BattleGroundWS*)bg)->m_AllianceFlagUpdate)) + { + data << (uint64)ap->GetGUID(); + data << (float)ap->GetPositionX(); + data << (float)ap->GetPositionY(); + } + } } if (hp) { - data << (uint64)hp->GetGUID(); - data << (float)hp->GetPositionX(); - data << (float)hp->GetPositionY(); + // Alliance team can always track horde flag picker + if (_player->GetTeam() == ALLIANCE) + { + data << (uint64)hp->GetGUID(); + data << (float)hp->GetPositionX(); + data << (float)hp->GetPositionY(); + } + + if (_player->GetTeam() == HORDE) + { + if (BG_WS_FLAG_UPDATE_TIME < (time(NULL) - ((BattleGroundWS*)bg)->m_HordeFlagUpdate)) + { + data << (uint64)hp->GetGUID(); + data << (float)hp->GetPositionX(); + data << (float)hp->GetPositionY(); + } + } } SendPacket(&data); @@ -264,10 +292,7 @@ void WorldSession::HandleBattleGroundPVPlogdataOpcode(WorldPacket & /*recv_data* sLog.outDebug("WORLD: Recvd MSG_PVP_LOG_DATA Message"); BattleGround *bg = _player->GetBattleGround(); - if (!bg) - return; - - if (bg->isArena()) + if (!bg || bg->isArena()) return; WorldPacket data; @@ -869,7 +894,7 @@ void WorldSession::SendBattleGroundOrArenaJoinError(uint8 err) return; break; } - ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, GetTrinityString(msg), NULL); + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, NULL, 0, GetHellgroundString(msg), NULL); SendPacket(&data); return; } diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp old mode 100755 new mode 100644 index 45bbedfe6..c279a27ca --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -759,7 +759,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI else if (bg_template->isArena()) { bool hiddenEnabled = sWorld.getConfig(CONFIG_ENABLE_HIDDEN_RATING); - + bool stepbystepEnabled = sWorld.getConfig(CONFIG_ENABLE_ARENA_STEP_BY_STEP_MATCHING); + uint32 stepbystepTime = sWorld.getConfig(CONFIG_ARENA_STEP_BY_STEP_TIME); + uint32 stepbystepValue = sWorld.getConfig(CONFIG_ARENA_STEP_BY_STEP_VALUE); // found out the minimum and maximum ratings the newly added team should battle against // arenaRating is the rating of the latest joined team, or 0 // 0 is on (automatic update call) and we must set it to team's with longest wait time @@ -793,7 +795,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI // (after what time the ratings aren't taken into account when making teams) then // the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account // else leave the discard time on 0, this way all ratings will be discarded - uint32 discardTime = WorldTimer::getMSTime() - sBattleGroundMgr.GetRatingDiscardTimer(); + uint32 discardTime = stepbystepEnabled ? WorldTimer::getMSTime() : (WorldTimer::getMSTime() - sBattleGroundMgr.GetRatingDiscardTimer()); // we need to find 2 teams which will play next game @@ -809,13 +811,28 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { uint32 arenaTeamRating = hiddenEnabled ? (*itr_team[i])->HiddenRating : (*itr_team[i])->ArenaTeamRating; // if group match conditions, then add it to pool - if( !(*itr_team[i])->IsInvitedToBGInstanceGUID - && ((arenaTeamRating >= arenaMinRating && arenaTeamRating <= arenaMaxRating) - || (*itr_team[i])->JoinTime < discardTime) ) + if (stepbystepEnabled) { - m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); - // break for cycle to be able to start selecting another group from same faction queue - break; + uint32 stepbystepChange = stepbystepValue * (uint8)((discardTime - (*itr_team[i])->JoinTime)/stepbystepTime); + if( !(*itr_team[i])->IsInvitedToBGInstanceGUID + && (arenaTeamRating + stepbystepChange >= arenaMinRating + && arenaTeamRating - stepbystepChange <= arenaMaxRating)) + { + m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } + } + else + { + if( !(*itr_team[i])->IsInvitedToBGInstanceGUID + && ((arenaTeamRating >= arenaMinRating && arenaTeamRating <= arenaMaxRating) + || (*itr_team[i])->JoinTime < discardTime) ) + { + m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } } } } @@ -831,12 +848,28 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { uint32 arenaTeamRatingA = hiddenEnabled ? (*itr_team[BG_TEAM_ALLIANCE])->HiddenRating : (*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating; - if( !(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID - && ((arenaTeamRatingA >= arenaMinRating && arenaTeamRatingA <= arenaMaxRating) - || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime) ) + if (stepbystepEnabled) { - m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); - break; + uint32 stepbystepChange = stepbystepValue * (uint8)((discardTime - (*itr_team[BG_TEAM_ALLIANCE])->JoinTime)/stepbystepTime); + if( !(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID + && (arenaTeamRatingA + stepbystepChange >= arenaMinRating + && arenaTeamRatingA - stepbystepChange <= arenaMaxRating)) + { + m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } + } + else + { + if( !(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID + && ((arenaTeamRatingA >= arenaMinRating && arenaTeamRatingA <= arenaMaxRating) + || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime) ) + { + m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } } } } @@ -849,12 +882,28 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { uint32 arenaTeamRatingH = hiddenEnabled ? (*itr_team[BG_TEAM_HORDE])->HiddenRating : (*itr_team[BG_TEAM_HORDE])->ArenaTeamRating; - if( !(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID - && ((arenaTeamRatingH >= arenaMinRating && arenaTeamRatingH <= arenaMaxRating) - || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime) ) + if (stepbystepEnabled) { - m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); - break; + uint32 stepbystepChange = stepbystepValue * (uint8)((discardTime - (*itr_team[BG_TEAM_HORDE])->JoinTime)/stepbystepTime); + if( !(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID + && (arenaTeamRatingH + stepbystepChange >= arenaMinRating + && arenaTeamRatingH - stepbystepChange <= arenaMaxRating)) + { + m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } + } + else + { + if( !(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID + && ((arenaTeamRatingH >= arenaMinRating && arenaTeamRatingH <= arenaMaxRating) + || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime) ) + { + m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); + // break for cycle to be able to start selecting another group from same faction queue + break; + } } } } @@ -1018,6 +1067,10 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER); m_Testing=false; + + inArenasCount[0] = 0; + inArenasCount[1] = 0; + inArenasCount[2] = 0; } BattleGroundMgr::~BattleGroundMgr() @@ -1111,7 +1164,7 @@ void BattleGroundMgr::Update(uint32 diff) { if (!m_ApAnnounce) { - sWorld.SendWorldText(LANG_SYSTEMMESSAGE, "Distributing arena points to players will be performed in 2 minutes."); + sWorld.SendWorldText(LANG_SYSTEMMESSAGE, 0, "Distributing arena points to players will be performed in 2 minutes."); m_AutoDistributionTimeChecker = 120000; m_ApAnnounce = true; return; @@ -1891,6 +1944,36 @@ uint32 BattleGroundMgr::GetPrematureFinishTime() const return sWorld.getConfig(CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER); } +bool BattleGroundMgr::IsPrematureFinishTimerEnabled() const +{ + return sWorld.getConfig(CONFIG_BATTLEGROUND_TIMER_INFO); +} + +bool BattleGroundMgr::IsWSGEndAfterEnabled() const +{ + return sWorld.getConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_ENABLED); +} + +bool BattleGroundMgr::IsWSGEndAfterAlwaysDraw() const +{ + return sWorld.getConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_ALWAYS_DRAW); +} + +uint32 BattleGroundMgr::GetWSGEndAfterTime() const +{ + return sWorld.getConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_TIME); +} + +uint32 BattleGroundMgr::GetArenaEndAfterTime() const +{ + return sWorld.getConfig(CONFIG_ARENA_END_AFTER_TIME); +} + +bool BattleGroundMgr::IsArenaEndAfterAlwaysDraw() const +{ + return sWorld.getConfig(CONFIG_ARENA_END_AFTER_ALWAYS_DRAW); +} + bool BattleGroundMgr::IsBGWeekend(BattleGroundTypeId bgTypeId) { uint32 eventId = 0; diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index 4f1a23e08..9cc43bf54 100755 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDMGR_H -#define __BATTLEGROUNDMGR_H +#ifndef HELLGROUND_BATTLEGROUNDMGR_H +#define HELLGROUND_BATTLEGROUNDMGR_H #include "ace/Singleton.h" @@ -234,6 +234,13 @@ class BattleGroundMgr uint32 GetRatingDiscardTimer() const; uint32 GetPrematureFinishTime() const; + bool IsPrematureFinishTimerEnabled() const; + bool IsWSGEndAfterEnabled() const; + bool IsWSGEndAfterAlwaysDraw() const; + uint32 GetWSGEndAfterTime() const; + uint32 GetArenaEndAfterTime() const; + bool IsArenaEndAfterAlwaysDraw() const; + void InitAutomaticArenaPointDistribution(); void DistributeArenaPoints(); void ToggleArenaTesting(); @@ -259,6 +266,7 @@ class BattleGroundMgr static bool IsBGWeekend(BattleGroundTypeId bgTypeId); + int32 inArenasCount[3]; private: BattleMastersMap mBattleMastersMap; std::vector m_QueueUpdateScheduler; diff --git a/src/game/BattleGroundNA.cpp b/src/game/BattleGroundNA.cpp index 9d9c36bdd..95cc8b6dc 100755 --- a/src/game/BattleGroundNA.cpp +++ b/src/game/BattleGroundNA.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/BattleGroundNA.h b/src/game/BattleGroundNA.h index 0d8d57a9f..3c6d6f9af 100755 --- a/src/game/BattleGroundNA.h +++ b/src/game/BattleGroundNA.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDNA_H -#define __BATTLEGROUNDNA_H + +#ifndef HELLGROUND_BATTLEGROUNDNA_H +#define HELLGROUND_BATTLEGROUNDNA_H class BattleGround; @@ -49,6 +50,11 @@ enum BattleGroundNACreatures BG_NA_CREATURE_MAX = 1 }; +enum BattleGroundNATimers +{ + BG_NA_DOOR_DESPAWN_TIMER = 5 +}; + class BattleGroundNAScore : public BattleGroundScore { public: diff --git a/src/game/BattleGroundRL.cpp b/src/game/BattleGroundRL.cpp index bcdad8820..7741d4a63 100755 --- a/src/game/BattleGroundRL.cpp +++ b/src/game/BattleGroundRL.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,7 +84,7 @@ void BattleGroundRL::Update(uint32 diff) else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10)) { m_Events |= 0x10; - + for (uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; i++) DoorOpen(i); diff --git a/src/game/BattleGroundRL.h b/src/game/BattleGroundRL.h index a8a65a124..7410db5bf 100755 --- a/src/game/BattleGroundRL.h +++ b/src/game/BattleGroundRL.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDRL_H -#define __BATTLEGROUNDRL_H + +#ifndef HELLGROUND_BATTLEGROUNDRL_H +#define HELLGROUND_BATTLEGROUNDRL_H class BattleGround; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index f0a78fa5d..7742ada6e 100755 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "Player.h" #include "BattleGround.h" #include "BattleGroundWS.h" +#include "BattleGroundMgr.h" #include "Creature.h" #include "GameObject.h" #include "Chat.h" @@ -55,6 +56,8 @@ BattleGroundWS::BattleGroundWS() m_BothFlagsKept = false; m_BgObjects.resize(BG_WS_OBJECT_MAX); m_BgCreatures.resize(BG_CREATURES_MAX_WS); + m_AllianceFlagUpdate = 0; + m_HordeFlagUpdate = 0; } BattleGroundWS::~BattleGroundWS() @@ -65,6 +68,35 @@ void BattleGroundWS::Update(uint32 diff) { BattleGround::Update(diff); + if (sBattleGroundMgr.IsWSGEndAfterEnabled()) + { + if (m_TimeElapsedSinceBeggining > sBattleGroundMgr.GetWSGEndAfterTime() && GetStatus() == STATUS_IN_PROGRESS) + { + if (!sBattleGroundMgr.IsWSGEndAfterAlwaysDraw()) + { + if(GetTeamScore(HORDE) > GetTeamScore(ALLIANCE)) + { + EndBattleGround(HORDE); + return; + } + else if (GetTeamScore(HORDE) < GetTeamScore(ALLIANCE)) + { + EndBattleGround(ALLIANCE); + return; + } + } + + EndBattleGround(0); + return; + } + + if(m_TimeElapsedSinceBeggining> sBattleGroundMgr.GetWSGEndAfterTime()/2 && + m_TimeElapsedSinceBeggining/180000 > (m_TimeElapsedSinceBeggining - diff)/180000) //warning every 3 mins + PrepareMessageToAll("This battleground will end in %u min.", + (sBattleGroundMgr.GetWSGEndAfterTime() - m_TimeElapsedSinceBeggining) /60000); + + } + // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { @@ -98,18 +130,19 @@ void BattleGroundWS::Update(uint32 diff) else if (GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; - SendMessageToAll(GetTrinityString(LANG_BG_WS_ONE_MINUTE)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; - SendMessageToAll(GetTrinityString(LANG_BG_WS_HALF_MINUTE)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if (GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; + for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_A_4; i++) DoorOpen(i); for (uint32 i = BG_WS_OBJECT_DOOR_H_1; i <= BG_WS_OBJECT_DOOR_H_2; i++) @@ -123,7 +156,7 @@ void BattleGroundWS::Update(uint32 diff) for (uint32 i = BG_WS_OBJECT_A_FLAG; i <= BG_WS_OBJECT_BERSERKBUFF_2; i++) SpawnBGObject(i, RESPAWN_IMMEDIATELY); - SendMessageToAll(GetTrinityString(LANG_BG_WS_BEGIN)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_BEGIN)); PlaySoundToAll(SOUND_BG_START); if (sWorld.getConfig(CONFIG_BG_START_MUSIC)) @@ -228,11 +261,13 @@ void BattleGroundWS::RespawnFlag(uint32 Team, bool captured) { sLog.outDebug("Respawn Alliance flag"); m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE; + m_AllianceFlagUpdate = 0; } else { sLog.outDebug("Respawn Horde flag"); m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE; + m_HordeFlagUpdate = 0; } if (captured) @@ -240,7 +275,7 @@ void BattleGroundWS::RespawnFlag(uint32 Team, bool captured) //when map_update will be allowed for battlegrounds this code will be useless SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_IMMEDIATELY); - SendMessageToAll(GetTrinityString(LANG_BG_WS_F_PLACED)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_F_PLACED)); PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED); // flag respawned sound... } m_BothFlagsKept = false; @@ -255,12 +290,12 @@ void BattleGroundWS::RespawnFlagAfterDrop(uint32 team) if (team == ALLIANCE) { SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_IMMEDIATELY); - SendMessageToAll(GetTrinityString(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED)); } else { SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_IMMEDIATELY); - SendMessageToAll(GetTrinityString(LANG_BG_WS_HORDE_FLAG_RESPAWNED)); + SendMessageToAll(GetHellgroundString(LANG_BG_WS_HORDE_FLAG_RESPAWNED)); } PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED); @@ -305,7 +340,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (m_FlagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); - message = GetTrinityString(LANG_BG_WS_CAPTURED_HF); + message = GetHellgroundString(LANG_BG_WS_CAPTURED_HF); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; if (GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE) AddPoint(ALLIANCE, 1); @@ -326,7 +361,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT); if (m_FlagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); - message = GetTrinityString(LANG_BG_WS_CAPTURED_AF); + message = GetHellgroundString(LANG_BG_WS_CAPTURED_AF); type = CHAT_MSG_BG_SYSTEM_HORDE; if (GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE) AddPoint(HORDE, 1); @@ -415,7 +450,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source) if (m_FlagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND; - message = GetTrinityString(LANG_BG_WS_DROPPED_HF); + message = GetHellgroundString(LANG_BG_WS_DROPPED_HF); type = CHAT_MSG_BG_SYSTEM_HORDE; Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true); set = true; @@ -434,7 +469,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source) if (m_FlagDebuffState == 2) Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT); m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND; - message = GetTrinityString(LANG_BG_WS_DROPPED_AF); + message = GetHellgroundString(LANG_BG_WS_DROPPED_AF); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true); set = true; @@ -466,12 +501,13 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target const char *message; uint8 type = 0; - + //alliance flag picked up from base if (Source->GetTeam() == HORDE && this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE && this->m_BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) { - message = GetTrinityString(LANG_BG_WS_PICKEDUP_AF); + m_AllianceFlagUpdate = time(NULL); // Set the time + message = GetHellgroundString(LANG_BG_WS_PICKEDUP_AF); type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); @@ -482,14 +518,15 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1); Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); if (m_FlagState[1] == BG_WS_FLAG_STATE_ON_PLAYER) - m_BothFlagsKept = true; + m_BothFlagsKept = true; } //horde flag picked up from base if (Source->GetTeam() == ALLIANCE && this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE && this->m_BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) { - message = GetTrinityString(LANG_BG_WS_PICKEDUP_HF); + m_HordeFlagUpdate = time(NULL); // Set the time + message = GetHellgroundString(LANG_BG_WS_PICKEDUP_HF); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); @@ -500,7 +537,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1); Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); if (m_FlagState[0] == BG_WS_FLAG_STATE_ON_PLAYER) - m_BothFlagsKept = true; + m_BothFlagsKept = true; } //Alliance flag on ground(not in base) (returned or picked up again from ground!) @@ -508,7 +545,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target { if (Source->GetTeam() == ALLIANCE) { - message = GetTrinityString(LANG_BG_WS_RETURNED_AF); + message = GetHellgroundString(LANG_BG_WS_RETURNED_AF); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(ALLIANCE, false); @@ -519,7 +556,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target } else { - message = GetTrinityString(LANG_BG_WS_PICKEDUP_AF); + message = GetHellgroundString(LANG_BG_WS_PICKEDUP_AF); type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY); @@ -542,7 +579,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target { if (Source->GetTeam() == HORDE) { - message = GetTrinityString(LANG_BG_WS_RETURNED_HF); + message = GetHellgroundString(LANG_BG_WS_RETURNED_HF); type = CHAT_MSG_BG_SYSTEM_HORDE; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_WAIT_RESPAWN); RespawnFlag(HORDE, false); @@ -553,7 +590,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target } else { - message = GetTrinityString(LANG_BG_WS_PICKEDUP_HF); + message = GetHellgroundString(LANG_BG_WS_PICKEDUP_HF); type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY); diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 251b01905..dca2823e3 100755 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __BATTLEGROUNDWS_H -#define __BATTLEGROUNDWS_H +#ifndef HELLGROUND_BATTLEGROUNDWS_H +#define HELLGROUND_BATTLEGROUNDWS_H #include "BattleGround.h" @@ -29,7 +29,8 @@ enum BG_WS_TimerOrScore BG_WS_FLAG_RESPAWN_TIME = 23000, BG_WS_FLAG_DROP_TIME = 10000, BG_WS_SPELL_FORCE_TIME = 600000, - BG_WS_SPELL_BRUTAL_TIME = 900000 + BG_WS_SPELL_BRUTAL_TIME = 900000, + BG_WS_FLAG_UPDATE_TIME = 45 }; enum BG_WS_Sound @@ -198,6 +199,8 @@ class BattleGroundWS : public BattleGround void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; m_score[GetTeamIndexByTeamId(TeamID)] = m_TeamScores[GetTeamIndexByTeamId(TeamID)];} void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; m_score[GetTeamIndexByTeamId(TeamID)] = m_TeamScores[GetTeamIndexByTeamId(TeamID)]; } + uint64 m_AllianceFlagUpdate; + uint64 m_HordeFlagUpdate; private: uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde uint64 m_DroppedFlagGUID[2]; @@ -205,7 +208,7 @@ class BattleGroundWS : public BattleGround uint32 m_TeamScores[2]; int32 m_FlagsTimer[2]; int32 m_FlagsDropTimer[2]; - + int32 m_FlagSpellForceTimer; int32 m_FlagSpellBrutalTimer; bool m_BothFlagsKept; diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index e34deb7f3..7a6ed1ebf 100755 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -5,6 +5,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/dep/g3dlite/include ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour ${CMAKE_SOURCE_DIR}/dep/recastnavigation/ + ${CMAKE_SOURCE_DIR}/dep/lualib ${CMAKE_CURRENT_SOURCE_DIR}/vmap ${CMAKE_CURRENT_SOURCE_DIR}/movemap ${CMAKE_SOURCE_DIR}/dep/include @@ -53,6 +54,12 @@ source_group("Tool" REGULAR_EXPRESSION Language ) +source_group("Lua Engine" + REGULAR_EXPRESSION Methods|Lua|Hook + FILES + luaengine/Includes.h +) + source_group("References" REGULAR_EXPRESSION Reference|RefManager|ThreatManager ) @@ -65,6 +72,7 @@ target_link_libraries(game shared g3dlib detour + lualib ) if(UNIX) diff --git a/src/game/Camera.cpp b/src/game/Camera.cpp index 1fd13943e..2d61b47b3 100644 --- a/src/game/Camera.cpp +++ b/src/game/Camera.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Camera.h" @@ -21,10 +22,10 @@ #include "CellImpl.h" #include "Log.h" #include "Player.h" +#include "ObjectAccessor.h" Camera::Camera(Player* pl) : _owner(*pl), _source(pl) { - _source->GetViewPoint().Attach(this); } Camera::~Camera() @@ -36,6 +37,11 @@ Camera::~Camera() _source->GetViewPoint().Detach(this); } +void Camera::Init() +{ + _source->GetViewPoint().Attach(this); +} + void Camera::ReceivePacket(WorldPacket *data) { _owner.SendPacketToSelf(data); @@ -130,6 +136,11 @@ void Camera::UpdateVisibilityOf(WorldObject* target) _owner.UpdateVisibilityOf(_source, target); } +const uint64& Camera::getOwnerGuid() +{ + return _owner.GetGUID(); +} + template void Camera::UpdateVisibilityOf(T * target, UpdateData &data, std::set& vis) { @@ -159,3 +170,17 @@ ViewPoint::~ViewPoint() _cameras.clear(); } } + +void ViewPoint::CameraCall(void (Camera::*handler)()) +{ + if (!_cameras.empty()) + { + CameraList tempCameras = _cameras; + for(CameraList::iterator itr = tempCameras.begin(); itr != tempCameras.end(); ++itr) + { + Player* owner = sObjectAccessor.GetPlayer(*itr); + if (owner) + (owner->GetCamera().*handler)(); + } + } +} \ No newline at end of file diff --git a/src/game/Camera.h b/src/game/Camera.h index 064b9cc51..debfcae84 100644 --- a/src/game/Camera.h +++ b/src/game/Camera.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CAMERA_H -#define CAMERA_H +#ifndef HELLGROUND_CAMERA_H +#define HELLGROUND_CAMERA_H #include "Common.h" #include "GridDefines.h" @@ -40,6 +41,7 @@ class HELLGROUND_IMPORT_EXPORT Camera WorldObject* GetBody() { return _source;} Player* GetOwner() { return &_owner;} + void Init(); // set camera's view to any worldobject // Note: this worldobject must be in same map, in same phase with camera's owner(player) // client supports only unit and dynamic objects as farsight objects @@ -57,6 +59,7 @@ class HELLGROUND_IMPORT_EXPORT Camera // updates visibility of worldobjects around viewpoint for camera's owner void UpdateVisibilityForOwner(); + const uint64& getOwnerGuid(); private: // called when viewpoint changes visibility state void Event_AddedToWorld(); @@ -81,25 +84,17 @@ class HELLGROUND_IMPORT_EXPORT ViewPoint { friend class Camera; - typedef std::list CameraList; + typedef std::list CameraList; CameraList _cameras; GridType * _grid; - void Attach(Camera* c) { _cameras.push_back(c); } - void Detach(Camera* c) { _cameras.remove(c); } + void Attach(Camera* c) {ACE_GUARD(ACE_Thread_Mutex,guard,m_mutex); _cameras.push_back(c->getOwnerGuid()); } + void Detach(Camera* c) {ACE_GUARD(ACE_Thread_Mutex,guard,m_mutex); _cameras.remove(c->getOwnerGuid()); } - void CameraCall(void (Camera::*handler)()) - { - if (!_cameras.empty()) - { - for(CameraList::iterator itr = _cameras.begin(); itr != _cameras.end();) - { - if (Camera *c = *(itr++)) - (c->*handler)(); - } - } - } + void CameraCall(void (Camera::*handler)()); +private: + ACE_Thread_Mutex m_mutex; public: diff --git a/src/game/Cell.h b/src/game/Cell.h index 4c3cc108a..b3df85004 100755 --- a/src/game/Cell.h +++ b/src/game/Cell.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_CELL_H diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h index f10e8beb1..88596771e 100755 --- a/src/game/CellImpl.h +++ b/src/game/CellImpl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_CELLIMPL_H diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index bf6119fda..17ef58d8f 100755 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Channel.h" @@ -80,6 +80,13 @@ void Channel::Join(uint64 p, const char *pass) } } + if (!m_ownerGUID && (!plr || !plr->CanSpeak())) // muted players can't create new channels + { + MakeBanned(&data);//no idea what to send + SendToOne(&data, p); + return; + } + if (IsBanned(p) && (!plr || !plr->isGameMaster())) { MakeBanned(&data); @@ -96,8 +103,8 @@ void Channel::Join(uint64 p, const char *pass) if (plr) { - if (HasFlag(CHANNEL_FLAG_LFG) && - sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !(plr->GetSession()->GetPermissions() & PERM_GMT) && + if (IsLFG() && + sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !plr->GetSession()->HasPermissions(PERM_GMT) && plr->m_lookingForGroup.Empty()) { MakeNotInLfg(&data); @@ -111,7 +118,7 @@ void Channel::Join(uint64 p, const char *pass) plr->JoinedChannel(this); } - if (m_announce && (!plr || !(plr->GetSession()->GetPermissions() & PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!plr || !plr->GetSession()->HasPermissions(PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); @@ -165,7 +172,7 @@ void Channel::Leave(uint64 p, bool send) bool changeowner = players[p].IsOwner(); players.erase(p); - if (m_announce && (!plr || !(plr->GetSession()->GetPermissions() & PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!plr || !plr->GetSession()->HasPermissions(PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, p); @@ -350,7 +357,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team - if ((!(plr->GetSession()->GetPermissions() & PERM_GMT) || !(newp->GetSession()->GetPermissions() & PERM_GMT)) && + if ((!plr->GetSession()->HasPermissions(PERM_GMT) || !newp->GetSession()->HasPermissions(PERM_GMT)) && plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; @@ -460,7 +467,7 @@ void Channel::List(Player* player) size_t pos = data.wpos(); data << uint32(0); // size of list, placeholder - bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || player->GetSession()->GetPermissions() & PERM_GMT; + bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || player->GetSession()->HasPermissions(PERM_GMT_HDEV); uint32 count = 0; for (PlayerList::iterator i = players.begin(); i != players.end(); ++i) @@ -471,7 +478,7 @@ void Channel::List(Player* player) // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (!(user->GetSession()->GetPermissions() & PERM_GMT) || gmInWhoList) + if (!user->GetSession()->HasPermissions(PERM_GMT) || gmInWhoList) { data << uint64(i->first); data << uint8(i->second.flags); // flags seems to be changed... @@ -594,7 +601,27 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) data << what; data << uint8(plr ? plr->chatTag() : 0); - SendToAll(&data, !players[p].IsModerator() ? p : false); + if (!plr || !plr->IsTrollmuted()) + { + // exclude LFG from two-side channels + if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) && IsLFG() && plr) + { + uint32 fromteam = plr->GetTeam(); + for (PlayerList::iterator i = players.begin(); i != players.end(); ++i) + { + Player *to = sObjectMgr.GetPlayer(i->first); + if (!to || to->GetTeam() != fromteam) + continue; + + if (!p || !to->GetSocial()->HasIgnore(GUID_LOPART(p))) + to->SendPacketToSelf(&data); + } + } + else + SendToAll(&data, !players[p].IsModerator() ? p : false); + } + else + plr->SendPacketToSelf(&data); } } @@ -1024,7 +1051,7 @@ void Channel::ChangeOwner() for (PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { Player * tmpPlr = ObjectAccessor::GetPlayer(itr->second.player); - if (tmpPlr && !(tmpPlr->GetSession()->GetPermissions() & PERM_GMT)) + if (tmpPlr && !tmpPlr->GetSession()->HasPermissions(PERM_GMT)) { newOwner = itr->second.player; break; diff --git a/src/game/Channel.h b/src/game/Channel.h index 4bd8d9bf5..1805e749b 100755 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _CHANNEL_H -#define _CHANNEL_H +#ifndef HELLGROUND_CHANNEL_H +#define HELLGROUND_CHANNEL_H #include "Common.h" #include "WorldPacket.h" @@ -31,6 +31,38 @@ #include #include +enum ChannelDBCFlags + { + CHANNEL_DBC_FLAG_NONE = 0x00000, + CHANNEL_DBC_FLAG_INITIAL = 0x00001, // General, Trade, LocalDefense, LFG + CHANNEL_DBC_FLAG_ZONE_DEP = 0x00002, // General, Trade, LocalDefense, GuildRecruitment + CHANNEL_DBC_FLAG_GLOBAL = 0x00004, // WorldDefense + CHANNEL_DBC_FLAG_TRADE = 0x00008, // Trade + CHANNEL_DBC_FLAG_CITY_ONLY = 0x00010, // Trade, GuildRecruitment + CHANNEL_DBC_FLAG_CITY_ONLY2 = 0x00020, // Trade, GuildRecruitment + CHANNEL_DBC_FLAG_DEFENSE = 0x10000, // LocalDefense, WorldDefense + CHANNEL_DBC_FLAG_GUILD_REQ = 0x20000, // GuildRecruitment + CHANNEL_DBC_FLAG_LFG = 0x40000 // LookingForGroup + }; + +enum ChannelFlags + { + CHANNEL_FLAG_NONE = 0x00, + CHANNEL_FLAG_CUSTOM = 0x01, + // 0x02 + CHANNEL_FLAG_TRADE = 0x04, + CHANNEL_FLAG_NOT_LFG = 0x08, + CHANNEL_FLAG_GENERAL = 0x10, + CHANNEL_FLAG_CITY = 0x20, + CHANNEL_FLAG_LFG = 0x40, + CHANNEL_FLAG_VOICE = 0x80 + // General 0x18 = 0x10 | 0x08 + // Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04 + // LocalDefence 0x18 = 0x10 | 0x08 + // GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08 + // LookingForGroup 0x50 = 0x40 | 0x10 + }; + class Channel { enum ChatNotify @@ -75,38 +107,6 @@ class Channel CHAT_VOICE_OFF_NOTICE = 0x23, //+ "[%s] Channel voice disabled by %s."; }; - enum ChannelFlags - { - CHANNEL_FLAG_NONE = 0x00, - CHANNEL_FLAG_CUSTOM = 0x01, - // 0x02 - CHANNEL_FLAG_TRADE = 0x04, - CHANNEL_FLAG_NOT_LFG = 0x08, - CHANNEL_FLAG_GENERAL = 0x10, - CHANNEL_FLAG_CITY = 0x20, - CHANNEL_FLAG_LFG = 0x40, - CHANNEL_FLAG_VOICE = 0x80 - // General 0x18 = 0x10 | 0x08 - // Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04 - // LocalDefence 0x18 = 0x10 | 0x08 - // GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08 - // LookingForGroup 0x50 = 0x40 | 0x10 - }; - - enum ChannelDBCFlags - { - CHANNEL_DBC_FLAG_NONE = 0x00000, - CHANNEL_DBC_FLAG_INITIAL = 0x00001, // General, Trade, LocalDefense, LFG - CHANNEL_DBC_FLAG_ZONE_DEP = 0x00002, // General, Trade, LocalDefense, GuildRecruitment - CHANNEL_DBC_FLAG_GLOBAL = 0x00004, // WorldDefense - CHANNEL_DBC_FLAG_TRADE = 0x00008, // Trade - CHANNEL_DBC_FLAG_CITY_ONLY = 0x00010, // Trade, GuildRecruitment - CHANNEL_DBC_FLAG_CITY_ONLY2 = 0x00020, // Trade, GuildRecruitment - CHANNEL_DBC_FLAG_DEFENSE = 0x10000, // LocalDefense, WorldDefense - CHANNEL_DBC_FLAG_GUILD_REQ = 0x20000, // GuildRecruitment - CHANNEL_DBC_FLAG_LFG = 0x40000 // LookingForGroup - }; - enum ChannelMemberFlags { MEMBER_FLAG_NONE = 0x00, @@ -249,7 +249,7 @@ class Channel uint32 GetChannelId() const { return m_channelId; } bool IsConstant() const { return m_channelId != 0; } bool IsAnnounce() const { return m_announce; } - bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } + bool IsLFG() const { return m_flags & CHANNEL_FLAG_LFG; } std::string GetPassword() const { return m_password; } void SetPassword(const std::string& npassword) { m_password = npassword; } void SetAnnounce(bool nannounce) { m_announce = nannounce; } diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp index dd88cf5db..574c6ab27 100755 --- a/src/game/ChannelHandler.cpp +++ b/src/game/ChannelHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ObjectMgr.h" // for normalizePlayerName @@ -41,6 +41,9 @@ void WorldSession::HandleChannelJoin(WorldPacket& recvPacket) CHECK_PACKET_SIZE(recvPacket, 4+1+1+(channelname.size()+1)+1); recvPacket >> pass; + if(channel_id == 2 && sWorld.getConfig(CONFIG_GLOBAL_TRADE_CHANNEL)) //magic number - trade channel id from DBC + channelname = "Trade"; + if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel *chn = cMgr->GetJoinChannel(channelname, channel_id)) chn->Join(_player->GetGUID(), pass.c_str()); @@ -52,9 +55,9 @@ void WorldSession::HandleChannelLeave(WorldPacket& recvPacket) //recvPacket.hexlike(); CHECK_PACKET_SIZE(recvPacket, 4+1); - uint32 unk; + uint32 channel_id; std::string channelname; - recvPacket >> unk; // channel id? + recvPacket >> channel_id; recvPacket >> channelname; if (channelname.empty()) @@ -240,10 +243,22 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - + if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel *chn = cMgr->GetChannel(channelname, _player)) + { + if (!sObjectAccessor.GetPlayerByName(otp) || !sObjectAccessor.GetPlayerByName(otp)->isAcceptWhispers()) // player not found + { + WorldPacket data; + data.Initialize(SMSG_CHANNEL_NOTIFY, 1+channelname.size()+1); + data << uint8(0x09); //CHAT_PLAYER_NOT_FOUND_NOTICE + data << channelname; + data << otp; + SendPacket(&data); + return; + } chn->Invite(_player->GetGUID(), otp.c_str()); + } } void WorldSession::HandleChannelKick(WorldPacket& recvPacket) diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h index aa2d9f274..dd46ec4f6 100755 --- a/src/game/ChannelMgr.h +++ b/src/game/ChannelMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,15 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_CHANNELMGR_H -#define TRINITYCORE_CHANNELMGR_H + +#ifndef HELLGROUND_CHANNELMGR_H +#define HELLGROUND_CHANNELMGR_H #include "ace/Singleton.h" @@ -86,7 +87,7 @@ class ChannelMgr { std::list tmpList; for (ChannelMap::const_iterator itr = channels.begin();itr!=channels.end(); ++itr) - if (!itr->second->GetFlags() || itr->second->HasFlag(1)) + if (!itr->second->GetFlags() || itr->second->HasFlag(CHANNEL_FLAG_CUSTOM)) tmpList.push_back(itr->first); return tmpList; diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 61862855e..410ebdfaa 100755 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -42,6 +42,8 @@ #include "Chat.h" #include "SystemConfig.h" #include "GameEvent.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" class GameEvent; @@ -66,7 +68,7 @@ bool LoginQueryHolder::Initialize() // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure. // !!! NOTE: including unused `zone`,`online` - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,instance_id,title FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,instance_id,title,grantableLevels,changeRaceTo FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); @@ -88,6 +90,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGCOORD, "SELECT bgid, bgteam, bgmap, bgx, bgy, bgz, bgo FROM character_bgcoord WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS, "SELECT id,messageType,sender,receiver,subject,itemTextId,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS, "SELECT data, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYARENA, "SELECT dailyarenawins FROM character_stats_ro WHERE guid = '%u'", GUID_LOPART(m_guid)); return res; } @@ -196,7 +199,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases - if (!(GetPermissions() & PERM_GMT)) + if (!HasPermissions(PERM_GMT)) { if (uint32 mask = sWorld.getConfig(CONFIG_CHARACTERS_CREATING_DISABLED)) { @@ -265,7 +268,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) return; } - if (!(GetPermissions() & PERM_GMT) && sObjectMgr.IsReservedName(name)) + if (!HasPermissions(PERM_GMT) && sObjectMgr.IsReservedName(name)) { data << uint8(CHAR_NAME_RESERVED); SendPacket(&data); @@ -308,7 +311,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) } } - bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS) || GetPermissions() & PERM_GMT; + bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS) || HasPermissions(PERM_GMT_DEV); uint32 skipCinematics = sWorld.getConfig(CONFIG_SKIP_CINEMATICS); bool have_same_race = false; @@ -371,6 +374,8 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) if ((have_same_race && skipCinematics == 1) || skipCinematics == 2) pNewChar->setCinematic(true); // not show intro + pNewChar->SetAtLoginFlag(AT_LOGIN_FIRST); // First login + // Player created, save it now pNewChar->SaveToDB(); charcount += 1; @@ -391,6 +396,9 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) std::string IP_str = GetRemoteAddress(); sLog.outDetail("Account: %d (IP: %s) Create Character:[%s]",GetAccountId(),IP_str.c_str(),name.c_str()); sLog.outLog(LOG_CHAR, "Account: %d (IP: %s) Create Character:[%s]",GetAccountId(),IP_str.c_str(),name.c_str()); + + // used by eluna + sHookMgr->OnCreate(pNewChar); } void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) @@ -408,7 +416,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) std::string name; // is guild leader - if (sObjectMgr.GetGuildByLeader(guid)) + if (sGuildMgr.GetGuildByLeader(guid)) { WorldPacket data(SMSG_CHAR_DELETE, 1); data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER; @@ -446,6 +454,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) WorldPacket data(SMSG_CHAR_DELETE, 1); data << (uint8)CHAR_DELETE_SUCCESS; SendPacket(&data); + + // used by eluna + sHookMgr->OnDelete(GUID_LOPART(guid)); } void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recv_data) @@ -493,7 +504,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) m_playerLoading = false; return; } - + pCurrChar->GetCamera().Init(); pCurrChar->GetMotionMaster()->Initialize(); SetPlayer(pCurrChar); @@ -577,7 +588,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) if (pCurrChar->GetGuildId() != 0) { - Guild* guild = sObjectMgr.GetGuildById(pCurrChar->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId()); if (guild) { data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1)); @@ -626,6 +637,8 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } } + sObjectAccessor.AddPlayer(pCurrChar); + if (!pCurrChar->GetMap()->Add(pCurrChar)) { // normal delayed teleport protection not applied (and this correct) for this case (Player object just created) @@ -636,7 +649,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) pCurrChar->TeleportToHomebind(); } - sObjectAccessor.AddPlayer(pCurrChar); //sLog.outDebug("Player %s added to Map.",pCurrChar->GetName()); pCurrChar->GetSocial()->SendSocialList(); @@ -746,6 +758,13 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) SendNotification(LANG_RESET_SPELLS); } + // used by eluna + if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) + sHookMgr->OnFirstLogin(pCurrChar); + + if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) + pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST); + if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { pCurrChar->resetTalents(true); @@ -756,7 +775,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) if (sWorld.IsShutdowning()) sWorld.ShutdownMsg(true,pCurrChar); - if (sWorld.getConfig(CONFIG_ALL_TAXI_PATHS)) + if (sWorld.getConfig(CONFIG_START_ALL_TAXI_PATHS)) pCurrChar->SetTaxiCheater(true); if (pCurrChar->isGameMaster()) @@ -772,6 +791,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) sWorld.ModifyLoggedInCharsCount(_player->GetTeamId(), 1); + // used by eluna + sHookMgr->OnLogin(pCurrChar); + delete holder; } @@ -895,7 +917,7 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data) } // check name limitations - if (!(GetPermissions() & PERM_GMT) && sObjectMgr.IsReservedName(newname)) + if (!HasPermissions(PERM_GMT) && sObjectMgr.IsReservedName(newname)) { WorldPacket data(SMSG_CHAR_RENAME, 1); data << uint8(CHAR_NAME_RESERVED); diff --git a/src/game/CharmInfo.cpp b/src/game/CharmInfo.cpp index 57f8bb3da..67c30c2dd 100644 --- a/src/game/CharmInfo.cpp +++ b/src/game/CharmInfo.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "CharmInfo.h" #include "WorldPacket.h" @@ -11,26 +29,58 @@ //////////////////////////////////////////////////////////// // Methods of class GlobalCooldownMgr -bool GlobalCooldownMgr::HasGlobalCooldown(SpellEntry const* spellInfo) const +bool CooldownMgr::HasGlobalCooldown(SpellEntry const* spellInfo) const { - GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory); + CooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory); return itr != m_GlobalCooldowns.end() && itr->second.duration && WorldTimer::getMSTimeDiff(itr->second.cast_time, WorldTimer::getMSTime()) < itr->second.duration; } -void GlobalCooldownMgr::AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd) +void CooldownMgr::AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd) { // HACKFIX: find bugged mechanic if (spellInfo->Id == 15473) return; - m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, WorldTimer::getMSTime()); + m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = Cooldown(gcd, WorldTimer::getMSTime()); } -void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo) +void CooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo) { m_GlobalCooldowns[spellInfo->StartRecoveryCategory].duration = 0; } +bool CooldownMgr::HasSpellCategoryCooldown(SpellEntry const* spellInfo) const +{ + CooldownList::const_iterator itr = m_CategoryCooldowns.find(spellInfo->Category); + return itr != m_CategoryCooldowns.end() && itr->second.duration && WorldTimer::getMSTimeDiff(itr->second.cast_time, WorldTimer::getMSTime()) < itr->second.duration; +} + +void CooldownMgr::AddSpellCategoryCooldown(SpellEntry const* spellInfo, uint32 gcd) +{ + m_CategoryCooldowns[spellInfo->Category] = Cooldown(gcd, WorldTimer::getMSTime()); +} + +void CooldownMgr::CancelSpellCategoryCooldown(SpellEntry const* spellInfo) +{ + m_CategoryCooldowns[spellInfo->Category].duration = 0; +} + +bool CooldownMgr::HasSpellIdCooldown(SpellEntry const* spellInfo) const +{ + CooldownList::const_iterator itr = m_SpellCooldowns.find(spellInfo->Id); + return itr != m_SpellCooldowns.end() && itr->second.duration && WorldTimer::getMSTimeDiff(itr->second.cast_time, WorldTimer::getMSTime()) < itr->second.duration; +} + +void CooldownMgr::AddSpellIdCooldown(SpellEntry const* spellInfo, uint32 gcd) +{ + m_SpellCooldowns[spellInfo->Id] = Cooldown(gcd, WorldTimer::getMSTime()); +} + +void CooldownMgr::CancelSpellIdCooldown(SpellEntry const* spellInfo) +{ + m_SpellCooldowns[spellInfo->Id].duration = 0; +} + CharmInfo::CharmInfo(Unit* unit) : m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_petnumber(0), m_barInit(false) { @@ -108,6 +158,15 @@ void CharmInfo::InitPossessCreateSpells() 40322 }; + uint32 BlueDrakeID[5] = //Power of the Blue Flight spells (Kij'jaeden fight) + { + 45862, + 45856, + 45860, + 60000, //to make empty slot + 45848 + }; + if (m_unit->GetEntry() == 23109) //HACK to allow proper spells for Vengeful Spirit { InitEmptyActionBar(false); @@ -120,6 +179,18 @@ void CharmInfo::InitPossessCreateSpells() return; } + if (m_unit->GetEntry() == 25653) //HACK to allow proper spells for the Power of the Blue Flight + { + InitEmptyActionBar(false); + + for (uint32 i = 0; i < 5; ++i) + { + uint32 spellid = BlueDrakeID[i]; + AddSpellToActionBar(0, spellid, ACT_CAST); + } + return; + } + InitEmptyActionBar(); if (m_unit->GetTypeId() == TYPEID_UNIT) @@ -251,6 +322,9 @@ void CharmInfo::HandleStayCommand() void CharmInfo::HandleFollowCommand() { + if (m_unit->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE) + return; + SetCommandState(COMMAND_FOLLOW); m_unit->AttackStop(); @@ -309,7 +383,7 @@ void CharmInfo::HandleSpellActCommand(uint64 targetGUID, uint32 spellId) return; // Global Cooldown, stop cast - if (spellInfo->StartRecoveryCategory > 0 && GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) + if (spellInfo->StartRecoveryCategory > 0 && GetCooldownMgr().HasGlobalCooldown(spellInfo)) return; for (uint32 i = 0; i < 3;i++) diff --git a/src/game/CharmInfo.h b/src/game/CharmInfo.h index fe26f6e0e..50f1d6574 100644 --- a/src/game/CharmInfo.h +++ b/src/game/CharmInfo.h @@ -1,5 +1,23 @@ -#ifndef __CHARMINFO_H -#define __CHARMINFO_H +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_CHARMINFO_H +#define HELLGROUND_CHARMINFO_H #include "Common.h" #include "Unit.h" @@ -44,28 +62,38 @@ struct UnitActionBarEntry uint32 SpellOrAction; }; -struct GlobalCooldown +struct Cooldown { - explicit GlobalCooldown(uint32 _dur = 0, uint32 _time = 0) : duration(_dur), cast_time(_time) {} + explicit Cooldown(uint32 _dur = 0, uint32 _time = 0) : duration(_dur), cast_time(_time) {} uint32 duration; uint32 cast_time; }; -typedef UNORDERED_MAP GlobalCooldownList; +typedef UNORDERED_MAP CooldownList; -class GlobalCooldownMgr +class HELLGROUND_IMPORT_EXPORT CooldownMgr { public: - GlobalCooldownMgr() {} + CooldownMgr() {} public: bool HasGlobalCooldown(SpellEntry const* spellInfo) const; void AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd); void CancelGlobalCooldown(SpellEntry const* spellInfo); + bool HasSpellCategoryCooldown(SpellEntry const* spellInfo) const; + void AddSpellCategoryCooldown(SpellEntry const* spellInfo, uint32 cd); + void CancelSpellCategoryCooldown(SpellEntry const* spellInfo); + + bool HasSpellIdCooldown(SpellEntry const* spellInfo) const; + void AddSpellIdCooldown(SpellEntry const* spellInfo, uint32 cd); + void CancelSpellIdCooldown(SpellEntry const* spellInfo); + private: - GlobalCooldownList m_GlobalCooldowns; + CooldownList m_GlobalCooldowns; + CooldownList m_CategoryCooldowns; + CooldownList m_SpellCooldowns; }; struct HELLGROUND_IMPORT_EXPORT CharmInfo @@ -91,7 +119,7 @@ struct HELLGROUND_IMPORT_EXPORT CharmInfo UnitActionBarEntry* GetActionBarEntry(uint8 index) { return &(PetActionBar[index]); } CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); } - GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; } + CooldownMgr& GetCooldownMgr() { return m_CooldownMgr; } void HandleStayCommand(); void HandleFollowCommand(); @@ -111,7 +139,7 @@ struct HELLGROUND_IMPORT_EXPORT CharmInfo //for restoration after charmed ReactStates m_oldReactState; - GlobalCooldownMgr m_GlobalCooldownMgr; + CooldownMgr m_CooldownMgr; }; #endif diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp old mode 100755 new mode 100644 index c7803c102..681b66d58 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -39,711 +39,752 @@ bool ChatHandler::load_command_table = true; ChatCommand * ChatHandler::getCommandTable() { + static ChatCommand arenaCommandTable[] = + { + { "ready", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleArenaReadyCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } + }; + static ChatCommand accountSetCommandTable[] = { - { "addon", PERM_ADM, true, &ChatHandler::HandleAccountSetAddonCommand, "", NULL }, - { "gmlevel", PERM_CONSOLE, true, &ChatHandler::HandleAccountSetGmLevelCommand, "", NULL }, - { "password", PERM_CONSOLE, true, &ChatHandler::HandleAccountSetPasswordCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "addon", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleAccountSetAddonCommand, "", NULL }, + { "permissions", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleAccountSetPermissionsCommand,"", NULL }, + { "password", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleAccountSetPasswordCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } + }; + + static ChatCommand accountAnnounceCommandTable[] = + { + { "battleground", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountBattleGroundAnnCommand, "", NULL }, + { "bg", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountBattleGroundAnnCommand, "", NULL }, + { "broadcast", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountAnnounceBroadcastCommand, "", NULL }, + { "guild", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountGuildAnnToggleCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } + }; + + static ChatCommand accountFriendCommandTable[] = + { + { "add", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleAccountFriendAddCommand, "", NULL }, + { "delete", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleAccountFriendDeleteCommand, "", NULL }, + { "list", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleAccountFriendListCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand accountCommandTable[] = { - { "create", PERM_CONSOLE, true, &ChatHandler::HandleAccountCreateCommand, "", NULL }, - { "bgann", PERM_PLAYER, false, &ChatHandler::HandleAccountBattleGroundAnnCommand, "", NULL }, - { "delete", PERM_CONSOLE, true, &ChatHandler::HandleAccountDeleteCommand, "", NULL }, - { "gann", PERM_PLAYER, false, &ChatHandler::HandleAccountGuildAnnToggleCommand, "", NULL }, - { "bones", PERM_PLAYER, false, &ChatHandler::HandleAccountBonesHideCommand, "", NULL }, - { "log", PERM_ADM, true, &ChatHandler::HandleAccountSpecialLogCommand, "", NULL }, - { "onlinelist", PERM_CONSOLE, true, &ChatHandler::HandleAccountOnlineListCommand, "", NULL }, - { "set", PERM_ADM, true, NULL, "", accountSetCommandTable }, - { "xp", PERM_PLAYER, false, &ChatHandler::HandleAccountXPToggleCommand, "", NULL }, - { "whisp", PERM_ADM, true, &ChatHandler::HandleAccountWhispLogCommand, "", NULL }, - { "", PERM_PLAYER, false, &ChatHandler::HandleAccountCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "announce", PERM_PLAYER, PERM_CONSOLE, false, NULL, "", accountAnnounceCommandTable }, + { "create", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleAccountCreateCommand, "", NULL }, + { "bgann", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountBattleGroundAnnCommand, "", NULL }, + { "delete", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleAccountDeleteCommand, "", NULL }, + { "friend", PERM_ADM, PERM_CONSOLE, true, NULL, "", accountFriendCommandTable }, + { "gann", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountGuildAnnToggleCommand, "", NULL }, + { "bones", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountBonesHideCommand, "", NULL }, + { "log", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleAccountSpecialLogCommand, "", NULL }, + { "onlinelist", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleAccountOnlineListCommand, "", NULL }, + { "set", PERM_ADM, PERM_CONSOLE, true, NULL, "", accountSetCommandTable }, + { "xp", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountXPToggleCommand, "", NULL }, + { "whisp", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleAccountWhispLogCommand, "", NULL }, + { "", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleAccountCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverSetCommandTable[] = { - { "difftime", PERM_CONSOLE, true, &ChatHandler::HandleServerSetDiffTimeCommand, "", NULL }, - { "loglevel", PERM_CONSOLE, true, &ChatHandler::HandleServerSetLogLevelCommand, "", NULL }, - { "motd", PERM_ADM, true, &ChatHandler::HandleServerSetMotdCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "difftime", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleServerSetDiffTimeCommand, "", NULL }, + { "motd", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerSetMotdCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand sendCommandTable[] = { - { "items", PERM_ADM, true, &ChatHandler::HandleSendItemsCommand, "", NULL }, - { "mail", PERM_GMT, true, &ChatHandler::HandleSendMailCommand, "", NULL }, - { "message", PERM_ADM, true, &ChatHandler::HandleSendMessageCommand, "", NULL }, - { "money", PERM_ADM, true, &ChatHandler::HandleSendMoneyCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "items", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleSendItemsCommand, "", NULL }, + { "mail", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleSendMailCommand, "", NULL }, + { "message", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleSendMessageCommand, "", NULL }, + { "money", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleSendMoneyCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverIdleRestartCommandTable[] = { - { "cancel", PERM_ADM, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, - { "" , PERM_ADM, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverIdleShutdownCommandTable[] = { - { "cancel", PERM_ADM, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, - { "" , PERM_ADM, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverRestartCommandTable[] = { - { "cancel", PERM_ADM, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, - { "" , PERM_ADM, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverShutdownCommandTable[] = { - { "cancel", PERM_ADM, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, - { "" , PERM_ADM, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand serverCommandTable[] = { - { "corpses", PERM_HIGH_GMT, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, - { "exit", PERM_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, - { "idlerestart", PERM_ADM, true, NULL, "", serverIdleRestartCommandTable }, - { "idleshutdown", PERM_ADM, true, NULL, "", serverShutdownCommandTable }, - { "info", PERM_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, - { "events", PERM_PLAYER, true, &ChatHandler::HandleServerEventsCommand, "", NULL }, - { "motd", PERM_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, - { "mute", PERM_ADM, true, &ChatHandler::HandleServerMuteCommand, "", NULL }, - { "restart", PERM_ADM, true, NULL, "", serverRestartCommandTable }, - { "rollshutdown", PERM_ADM, true, &ChatHandler::HandleServerRollShutDownCommand, "", NULL}, - { "set", PERM_ADM, true, NULL, "", serverSetCommandTable }, - { "shutdown", PERM_ADM, true, NULL, "", serverShutdownCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { "corpses", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, + { "exit", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, + { "idlerestart", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverIdleRestartCommandTable }, + { "idleshutdown", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverShutdownCommandTable }, + { "info", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, + { "events", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleServerEventsCommand, "", NULL }, + { "motd", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, + { "mute", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerMuteCommand, "", NULL }, + { "pvp", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleServerPVPCommand, "", NULL }, + { "restart", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverRestartCommandTable }, + { "rollshutdown", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleServerRollShutDownCommand, "", NULL}, + { "set", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverSetCommandTable }, + { "shutdown", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverShutdownCommandTable }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand mmapCommandTable[] = { - { "path", PERM_GMT, false, &ChatHandler::HandleMmapPathCommand, "", NULL }, - { "loc", PERM_GMT, false, &ChatHandler::HandleMmapLocCommand, "", NULL }, - { "loadedtiles", PERM_GMT, false, &ChatHandler::HandleMmapLoadedTilesCommand, "", NULL }, - { "stats", PERM_GMT, false, &ChatHandler::HandleMmapStatsCommand, "", NULL }, - { "testarea", PERM_GMT, false, &ChatHandler::HandleMmapTestArea, "", NULL }, - { "offmesh", PERM_GMT, false, &ChatHandler::HandleMmapOffsetCreateCommand, "", NULL }, - { "", PERM_ADM, false, &ChatHandler::HandleMmap, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "path", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapPathCommand, "", NULL }, + { "loc", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapLocCommand, "", NULL }, + { "loadedtiles", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapLoadedTilesCommand, "", NULL }, + { "stats", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapStatsCommand, "", NULL }, + { "testarea", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapTestArea, "", NULL }, + { "offmesh", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMmapOffsetCreateCommand, "", NULL }, + { "", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleMmap, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand modifyCommandTable[] = { - { "arena", PERM_ADM, false, &ChatHandler::HandleModifyArenaCommand, "", NULL }, - { "aspeed", PERM_GMT, false, &ChatHandler::HandleModifyASpeedCommand, "", NULL }, - { "bit", PERM_GMT, false, &ChatHandler::HandleModifyBitCommand, "", NULL }, - { "bwalk", PERM_GMT, false, &ChatHandler::HandleModifyBWalkCommand, "", NULL }, - { "drunk", PERM_GMT, false, &ChatHandler::HandleModifyDrunkCommand, "", NULL }, - { "energy", PERM_GMT, false, &ChatHandler::HandleModifyEnergyCommand, "", NULL }, - { "faction", PERM_GMT, false, &ChatHandler::HandleModifyFactionCommand, "", NULL }, - { "fly", PERM_GMT, false, &ChatHandler::HandleModifyFlyCommand, "", NULL }, - { "gender", PERM_ADM, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, - { "honor", PERM_ADM, false, &ChatHandler::HandleModifyHonorCommand, "", NULL }, - { "hp", PERM_GMT, false, &ChatHandler::HandleModifyHPCommand, "", NULL }, - { "mana", PERM_GMT, false, &ChatHandler::HandleModifyManaCommand, "", NULL }, - { "money", PERM_ADM, false, &ChatHandler::HandleModifyMoneyCommand, "", NULL }, - { "morph", PERM_GMT, false, &ChatHandler::HandleModifyMorphCommand, "", NULL }, - { "mount", PERM_GMT, false, &ChatHandler::HandleModifyMountCommand, "", NULL }, - { "rage", PERM_GMT, false, &ChatHandler::HandleModifyRageCommand, "", NULL }, - { "rep", PERM_ADM, false, &ChatHandler::HandleModifyRepCommand, "", NULL }, - { "scale", PERM_GMT, false, &ChatHandler::HandleModifyScaleCommand, "", NULL }, - { "speed", PERM_GMT, false, &ChatHandler::HandleModifySpeedCommand, "", NULL }, - { "spell", PERM_GMT, false, &ChatHandler::HandleModifySpellCommand, "", NULL }, - { "standstate", PERM_GMT, false, &ChatHandler::HandleModifyStandStateCommand, "", NULL }, - { "swim", PERM_GMT, false, &ChatHandler::HandleModifySwimCommand, "", NULL }, - { "titles", PERM_ADM, false, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, - { "tp", PERM_ADM, false, &ChatHandler::HandleModifyTalentCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "arena", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyArenaCommand, "", NULL }, + { "aspeed", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyASpeedCommand, "", NULL }, + { "bit", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyBitCommand, "", NULL }, + { "bwalk", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyBWalkCommand, "", NULL }, + { "drunk", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyDrunkCommand, "", NULL }, + { "energy", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyEnergyCommand, "", NULL }, + { "faction", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyFactionCommand, "", NULL }, + { "fly", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyFlyCommand, "", NULL }, + { "gender", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, + { "honor", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyHonorCommand, "", NULL }, + { "hp", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyHPCommand, "", NULL }, + { "mana", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyManaCommand, "", NULL }, + { "money", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyMoneyCommand, "", NULL }, + { "morph", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyMorphCommand, "", NULL }, + { "mount", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyMountCommand, "", NULL }, + { "rage", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyRageCommand, "", NULL }, + { "rep", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyRepCommand, "", NULL }, + { "scale", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyScaleCommand, "", NULL }, + { "speed", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifySpeedCommand, "", NULL }, + { "spell", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifySpellCommand, "", NULL }, + { "standstate", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifyStandStateCommand, "", NULL }, + { "swim", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleModifySwimCommand, "", NULL }, + { "titles", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, + { "tp", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleModifyTalentCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand wpCommandTable[] = { - { "add", PERM_DEVELOPER, false, &ChatHandler::HandleWpAddCommand, "", NULL }, - { "event", PERM_DEVELOPER, false, &ChatHandler::HandleWpEventCommand, "", NULL }, - { "load", PERM_DEVELOPER, false, &ChatHandler::HandleWpLoadPathCommand, "", NULL }, - { "modify", PERM_DEVELOPER, false, &ChatHandler::HandleWpModifyCommand, "", NULL }, - { "reloadpath", PERM_ADM, false, &ChatHandler::HandleWpReloadPath, "", NULL }, - { "show", PERM_DEVELOPER, false, &ChatHandler::HandleWpShowCommand, "", NULL }, - { "tofile", PERM_ADM, false, &ChatHandler::HandleWPToFileCommand, "", NULL }, - { "unload", PERM_DEVELOPER, false, &ChatHandler::HandleWpUnLoadPathCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpAddCommand, "", NULL }, + { "event", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpEventCommand, "", NULL }, + { "load", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpLoadPathCommand, "", NULL }, + { "modify", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpModifyCommand, "", NULL }, + { "reloadpath", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleWpReloadPath, "", NULL }, + { "show", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpShowCommand, "", NULL }, + { "tofile", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleWPToFileCommand, "", NULL }, + { "unload", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleWpUnLoadPathCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand banCommandTable[] = { - { "account", PERM_GMT, true, &ChatHandler::HandleBanAccountCommand, "", NULL }, - { "character", PERM_GMT, true, &ChatHandler::HandleBanCharacterCommand, "", NULL }, - { "email", PERM_ADM, true, &ChatHandler::HandleBanEmailCommand, "", NULL }, - { "ip", PERM_GMT, true, &ChatHandler::HandleBanIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanAccountCommand, "", NULL }, + { "character", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanCharacterCommand, "", NULL }, + { "email", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleBanEmailCommand, "", NULL }, + { "ip", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanIPCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand baninfoCommandTable[] = { - { "account", PERM_GMT, true, &ChatHandler::HandleBanInfoAccountCommand, "", NULL }, - { "character", PERM_GMT, true, &ChatHandler::HandleBanInfoCharacterCommand, "", NULL }, - { "email", PERM_ADM, true, &ChatHandler::HandleBanInfoEmailCommand, "", NULL }, - { "ip", PERM_GMT, true, &ChatHandler::HandleBanInfoIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanInfoAccountCommand, "", NULL }, + { "character", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanInfoCharacterCommand, "", NULL }, + { "email", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleBanInfoEmailCommand, "", NULL }, + { "ip", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanInfoIPCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand banlistCommandTable[] = { - { "account", PERM_GMT, true, &ChatHandler::HandleBanListAccountCommand, "", NULL }, - { "character", PERM_GMT, true, &ChatHandler::HandleBanListCharacterCommand, "", NULL }, - { "email", PERM_ADM, true, &ChatHandler::HandleBanListEmailCommand, "", NULL }, - { "ip", PERM_GMT, true, &ChatHandler::HandleBanListIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanListAccountCommand, "", NULL }, + { "character", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanListCharacterCommand, "", NULL }, + { "email", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleBanListEmailCommand, "", NULL }, + { "ip", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleBanListIPCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand unbanCommandTable[] = { - { "account", PERM_GMT, true, &ChatHandler::HandleUnBanAccountCommand, "", NULL }, - { "character", PERM_GMT, true, &ChatHandler::HandleUnBanCharacterCommand, "", NULL }, - { "email", PERM_ADM, true, &ChatHandler::HandleUnBanEmailCommand, "", NULL }, - { "ip", PERM_GMT, true, &ChatHandler::HandleUnBanIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleUnBanAccountCommand, "", NULL }, + { "character", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleUnBanCharacterCommand, "", NULL }, + { "email", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleUnBanEmailCommand, "", NULL }, + { "ip", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleUnBanIPCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand debugPlayCommandTable[] = { - { "cinematic", PERM_DEVELOPER, false, &ChatHandler::HandleDebugPlayCinematicCommand, "", NULL }, - { "sound", PERM_DEVELOPER, false, &ChatHandler::HandleDebugPlaySoundCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cinematic", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleDebugPlayCinematicCommand, "", NULL }, + { "sound", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleDebugPlaySoundCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand debugSendCommandTable[] = { - { "buyerror", PERM_ADM, false, &ChatHandler::HandleDebugSendBuyErrorCommand, "", NULL }, - { "channelnotify", PERM_ADM, false, &ChatHandler::HandleDebugSendChannelNotifyCommand, "", NULL }, - { "chatmessage", PERM_ADM, false, &ChatHandler::HandleDebugSendChatMsgCommand, "", NULL }, - { "equiperror", PERM_ADM, false, &ChatHandler::HandleDebugSendEquipErrorCommand, "", NULL }, - { "opcode", PERM_ADM, false, &ChatHandler::HandleDebugSendOpcodeCommand, "", NULL }, - { "poi", PERM_ADM, false, &ChatHandler::HandleDebugSendPoiCommand, "", NULL }, - { "qpartymsg", PERM_ADM, false, &ChatHandler::HandleDebugSendQuestPartyMsgCommand, "", NULL }, - { "qinvalidmsg", PERM_ADM, false, &ChatHandler::HandleDebugSendQuestInvalidMsgCommand, "", NULL }, - { "sellerror", PERM_ADM, false, &ChatHandler::HandleDebugSendSellErrorCommand, "", NULL }, - { "spellfail", PERM_ADM, false, &ChatHandler::HandleDebugSendSpellFailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "buyerror", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendBuyErrorCommand, "", NULL }, + { "channelnotify", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendChannelNotifyCommand, "", NULL }, + { "chatmessage", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendChatMsgCommand, "", NULL }, + { "equiperror", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendEquipErrorCommand, "", NULL }, + { "opcode", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendOpcodeCommand, "", NULL }, + { "poi", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendPoiCommand, "", NULL }, + { "qpartymsg", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendQuestPartyMsgCommand, "", NULL }, + { "qinvalidmsg", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendQuestInvalidMsgCommand, "", NULL }, + { "sellerror", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendSellErrorCommand, "", NULL }, + { "spellfail", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSendSpellFailCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand debugCommandTable[] = { - { "addformation", PERM_DEVELOPER, false, &ChatHandler::HandleDebugAddFormationToFileCommand, "", NULL }, - { "anim", PERM_GMT_DEV, false, &ChatHandler::HandleDebugAnimCommand, "", NULL }, - { "arena", PERM_ADM, false, &ChatHandler::HandleDebugArenaCommand, "", NULL }, - { "bg", PERM_ADM, false, &ChatHandler::HandleDebugBattleGroundCommand, "", NULL }, - { "getitemstate", PERM_ADM, false, &ChatHandler::HandleDebugGetItemState, "", NULL }, - { "getinstdata", PERM_ADM, false, &ChatHandler::HandleDebugGetInstanceDataCommand, "", NULL }, - { "getinstdata64", PERM_ADM, false, &ChatHandler::HandleDebugGetInstanceData64Command, "", NULL }, - { "getvalue", PERM_ADM, false, &ChatHandler::HandleDebugGetValue, "", NULL }, - { "hostilelist", PERM_GMT_DEV, false, &ChatHandler::HandleDebugHostilRefList, "", NULL }, - { "lootrecipient", PERM_GMT_DEV, false, &ChatHandler::HandleDebugGetLootRecipient, "", NULL }, - { "Mod32Value", PERM_ADM, false, &ChatHandler::HandleDebugMod32Value, "", NULL }, - { "play", PERM_DEVELOPER, false, NULL, "", debugPlayCommandTable }, - { "poolstats", PERM_GMT_DEV, false, &ChatHandler::HandleGetPoolObjectStatsCommand, "", NULL }, - { "rel", PERM_ADM, false, &ChatHandler::HandleRelocateCreatureCommand, "", NULL }, - { "send", PERM_ADM, false, NULL, "", debugSendCommandTable }, - { "setinstdata", PERM_ADM, false, &ChatHandler::HandleDebugSetInstanceDataCommand, "", NULL }, - { "setinstdata64", PERM_ADM, false, &ChatHandler::HandleDebugSetInstanceData64Command, "", NULL }, - { "setitemflag", PERM_ADM, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL }, - { "setvalue", PERM_ADM, false, &ChatHandler::HandleDebugSetValue, "", NULL }, - { "showcombatstats",PERM_ADM, false, &ChatHandler::HandleDebugShowCombatStats, "", NULL }, - { "threatlist", PERM_GMT_DEV, false, &ChatHandler::HandleDebugThreatList, "", NULL }, - { "printstate", PERM_PLAYER, false, &ChatHandler::HandleDebugUnitState, "", NULL }, - { "update", PERM_ADM, false, &ChatHandler::HandleDebugUpdate, "", NULL }, - { "uws", PERM_ADM, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "addformation", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleDebugAddFormationToFileCommand, "", NULL }, + { "anim", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleDebugAnimCommand, "", NULL }, + { "arena", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugArenaCommand, "", NULL }, + { "bg", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugBattleGroundCommand, "", NULL }, + { "getitemstate", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugGetItemState, "", NULL }, + { "getinstdata", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugGetInstanceDataCommand, "", NULL }, + { "getinstdata64", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugGetInstanceData64Command, "", NULL }, + { "getvalue", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugGetValue, "", NULL }, + { "hostilelist", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleDebugHostileRefList, "", NULL }, + { "lootrecipient", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleDebugGetLootRecipient, "", NULL }, + { "Mod32Value", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugMod32Value, "", NULL }, + { "play", PERM_DEVELOPER, PERM_CONSOLE, false, NULL, "", debugPlayCommandTable }, + { "poolstats", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGetPoolObjectStatsCommand, "", NULL }, + { "rel", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleRelocateCreatureCommand, "", NULL }, + { "send", PERM_ADM, PERM_CONSOLE, false, NULL, "", debugSendCommandTable }, + { "setinstdata", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSetInstanceDataCommand, "", NULL }, + { "setinstdata64", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSetInstanceData64Command, "", NULL }, + { "setitemflag", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL }, + { "setvalue", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugSetValue, "", NULL }, + { "showcombatstats",PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugShowCombatStats, "", NULL }, + { "threatlist", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleDebugThreatList, "", NULL }, + { "printstate", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleDebugUnitState, "", NULL }, + { "update", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugUpdate, "", NULL }, + { "uws", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand eventCommandTable[] = { - { "activelist", PERM_GMT_DEV, true, &ChatHandler::HandleEventActiveListCommand, "", NULL }, - { "start", PERM_HIGH_GMT, true, &ChatHandler::HandleEventStartCommand, "", NULL }, - { "stop", PERM_HIGH_GMT, true, &ChatHandler::HandleEventStopCommand, "", NULL }, - { "", PERM_GMT_DEV, true, &ChatHandler::HandleEventInfoCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "activelist", PERM_GMT_DEV, PERM_CONSOLE, true, &ChatHandler::HandleEventActiveListCommand, "", NULL }, + { "start", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleEventStartCommand, "", NULL }, + { "stop", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleEventStopCommand, "", NULL }, + { "", PERM_GMT_DEV, PERM_CONSOLE, true, &ChatHandler::HandleEventInfoCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand learnCommandTable[] = { - { "all", PERM_ADM, false, &ChatHandler::HandleLearnAllCommand, "", NULL }, - { "all_crafts", PERM_GMT, false, &ChatHandler::HandleLearnAllCraftsCommand, "", NULL }, - { "all_default", PERM_GMT, false, &ChatHandler::HandleLearnAllDefaultCommand, "", NULL }, - { "all_gm", PERM_GMT, false, &ChatHandler::HandleLearnAllGMCommand, "", NULL }, - { "all_lang", PERM_GMT, false, &ChatHandler::HandleLearnAllLangCommand, "", NULL }, - { "all_myclass", PERM_ADM, false, &ChatHandler::HandleLearnAllMyClassCommand, "", NULL }, - { "all_myspells", PERM_ADM, false, &ChatHandler::HandleLearnAllMySpellsCommand, "", NULL }, - { "all_mytalents", PERM_ADM, false, &ChatHandler::HandleLearnAllMyTalentsCommand, "", NULL }, - { "all_recipes", PERM_GMT, false, &ChatHandler::HandleLearnAllRecipesCommand, "", NULL }, - { "", PERM_ADM, false, &ChatHandler::HandleLearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "all", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllCommand, "", NULL }, + { "all_crafts", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllCraftsCommand, "", NULL }, + { "all_default", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllDefaultCommand, "", NULL }, + { "all_gm", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllGMCommand, "", NULL }, + { "all_lang", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllLangCommand, "", NULL }, + { "all_myclass", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllMyClassCommand, "", NULL }, + { "all_myspells", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllMySpellsCommand, "", NULL }, + { "all_mytalents", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllMyTalentsCommand, "", NULL }, + { "all_recipes", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLearnAllRecipesCommand, "", NULL }, + { "", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleLearnCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand reloadCommandTable[] = { - { "all", PERM_ADM, true, &ChatHandler::HandleReloadAllCommand, "", NULL }, - { "all_item", PERM_ADM, true, &ChatHandler::HandleReloadAllItemCommand, "", NULL }, - { "all_locales", PERM_ADM, true, &ChatHandler::HandleReloadAllLocalesCommand, "", NULL }, - { "all_loot", PERM_ADM, true, &ChatHandler::HandleReloadAllLootCommand, "", NULL }, - { "all_npc", PERM_ADM, true, &ChatHandler::HandleReloadAllNpcCommand, "", NULL }, - { "all_quest", PERM_ADM, true, &ChatHandler::HandleReloadAllQuestCommand, "", NULL }, - { "all_scripts", PERM_ADM, true, &ChatHandler::HandleReloadAllScriptsCommand, "", NULL }, - { "all_spell", PERM_ADM, true, &ChatHandler::HandleReloadAllSpellCommand, "", NULL }, - - { "config", PERM_ADM, true, &ChatHandler::HandleReloadConfigCommand, "", NULL }, - - { "areatrigger_tavern", PERM_ADM, true, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, - { "areatrigger_teleport", PERM_ADM, true, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, - { "access_requirement", PERM_ADM, true, &ChatHandler::HandleReloadAccessRequirementCommand, "", NULL }, - { "areatrigger_involvedrelation",PERM_ADM, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, - { "auctions", PERM_ADM, true, &ChatHandler::HandleReloadAuctionsCommand, "", NULL }, - { "autobroadcast", PERM_ADM, true, &ChatHandler::HandleReloadAutobroadcastCommand, "", NULL }, - { "command", PERM_ADM, true, &ChatHandler::HandleReloadCommandCommand, "", NULL }, - { "creature_involvedrelation", PERM_ADM, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand, "", NULL }, - { "creature_linked_respawn", PERM_ADM, true, &ChatHandler::HandleReloadCreatureLinkedRespawnCommand, "", NULL }, - { "creature_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL }, - { "creature_questrelation", PERM_ADM, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL }, - { "creature_ai_scripts", PERM_ADM, true, &ChatHandler::HandleReloadEventAIScriptsCommand, "", NULL }, - { "disenchant_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesDisenchantCommand, "", NULL }, - { "eventai", PERM_ADM, true, &ChatHandler::HandleReloadEventAICommand, "", NULL }, - { "event_scripts", PERM_ADM, true, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL }, - { "fishing_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesFishingCommand, "", NULL }, - { "game_graveyard_zone", PERM_ADM, true, &ChatHandler::HandleReloadGameGraveyardZoneCommand, "", NULL }, - { "game_tele", PERM_ADM, true, &ChatHandler::HandleReloadGameTeleCommand, "", NULL }, - { "gameobject_involvedrelation", PERM_ADM, true, &ChatHandler::HandleReloadGOQuestInvRelationsCommand, "", NULL }, - { "gameobject_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesGameobjectCommand, "", NULL }, - { "gameobject_questrelation", PERM_ADM, true, &ChatHandler::HandleReloadGOQuestRelationsCommand, "", NULL }, - { "gameobject_scripts", PERM_ADM, true, &ChatHandler::HandleReloadGameObjectScriptsCommand, "", NULL }, - { "gm_tickets", PERM_ADM, true, &ChatHandler::HandleReloadGMTicketCommand, "", NULL }, - { "item_enchantment_template", PERM_ADM, true, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL }, - { "item_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL }, - { "locales_creature", PERM_ADM, true, &ChatHandler::HandleReloadLocalesCreatureCommand, "", NULL }, - { "locales_gameobject", PERM_ADM, true, &ChatHandler::HandleReloadLocalesGameobjectCommand, "", NULL }, - { "locales_item", PERM_ADM, true, &ChatHandler::HandleReloadLocalesItemCommand, "", NULL }, - { "locales_npc_text", PERM_ADM, true, &ChatHandler::HandleReloadLocalesNpcTextCommand, "", NULL }, - { "locales_page_text", PERM_ADM, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL }, - { "locales_quest", PERM_ADM, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL }, - { "npc_gossip", PERM_ADM, true, &ChatHandler::HandleReloadNpcGossipCommand, "", NULL }, - { "npc_option", PERM_ADM, true, &ChatHandler::HandleReloadNpcOptionCommand, "", NULL }, - { "npc_trainer", PERM_ADM, true, &ChatHandler::HandleReloadNpcTrainerCommand, "", NULL }, - { "npc_vendor", PERM_ADM, true, &ChatHandler::HandleReloadNpcVendorCommand, "", NULL }, - { "page_text", PERM_ADM, true, &ChatHandler::HandleReloadPageTextsCommand, "", NULL }, - { "pickpocketing_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand,"", NULL}, - { "prospecting_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand, "", NULL }, - { "quest_mail_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesQuestMailCommand, "", NULL }, - { "quest_end_scripts", PERM_ADM, true, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, - { "quest_start_scripts", PERM_ADM, true, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, - { "quest_template", PERM_ADM, true, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL }, - { "reference_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, - { "reserved_name", PERM_ADM, true, &ChatHandler::HandleReloadReservedNameCommand, "", NULL }, - { "reputation_reward_rate", PERM_ADM, true, &ChatHandler::HandleReloadReputationRewardRateCommand, "", NULL }, - { "reputation_spillover_template", PERM_ADM, true, &ChatHandler::HandleReloadReputationSpilloverTemplateCommand, "", NULL }, - { "skill_discovery_template", PERM_ADM, true, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, - { "skill_extra_item_template", PERM_ADM, true, &ChatHandler::HandleReloadSkillExtraItemTemplateCommand, "", NULL }, - { "skill_fishing_base_level", PERM_ADM, true, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL }, - { "skinning_loot_template", PERM_ADM, true, &ChatHandler::HandleReloadLootTemplatesSkinningCommand, "", NULL }, - { "spell_affect", PERM_ADM, true, &ChatHandler::HandleReloadSpellAffectCommand, "", NULL }, - { "spell_required", PERM_ADM, true, &ChatHandler::HandleReloadSpellRequiredCommand, "", NULL }, - { "spell_elixir", PERM_ADM, true, &ChatHandler::HandleReloadSpellElixirCommand, "", NULL }, - { "spell_learn_spell", PERM_ADM, true, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", NULL }, - { "spell_linked_spell", PERM_ADM, true, &ChatHandler::HandleReloadSpellLinkedSpellCommand, "", NULL }, - { "spell_pet_auras", PERM_ADM, true, &ChatHandler::HandleReloadSpellPetAurasCommand, "", NULL }, - { "spell_proc_event", PERM_ADM, true, &ChatHandler::HandleReloadSpellProcEventCommand, "", NULL }, - { "spell_enchant_proc_data", PERM_ADM, true, &ChatHandler::HandleReloadSpellEnchantDataCommand, "", NULL }, - { "spell_script_target", PERM_ADM, true, &ChatHandler::HandleReloadSpellScriptTargetCommand, "", NULL }, - { "spell_scripts", PERM_ADM, true, &ChatHandler::HandleReloadSpellScriptsCommand, "", NULL }, - { "spell_target_position", PERM_ADM, true, &ChatHandler::HandleReloadSpellTargetPositionCommand, "", NULL }, - { "spell_threats", PERM_ADM, true, &ChatHandler::HandleReloadSpellThreatsCommand, "", NULL }, - { "spell_disabled", PERM_ADM, true, &ChatHandler::HandleReloadSpellDisabledCommand, "", NULL }, - { "hellground_string", PERM_ADM, true, &ChatHandler::HandleReloadHellgroundStringCommand, "", NULL }, - { "unqueue_account", PERM_ADM, true, &ChatHandler::HandleReloadUnqueuedAccountListCommand, "", NULL }, - { "waypoint_scripts", PERM_ADM, true, &ChatHandler::HandleReloadWpScriptsCommand, "", NULL }, - - { "", PERM_ADM, true, &ChatHandler::HandleReloadCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "all", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllCommand, "", NULL }, + { "all_item", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllItemCommand, "", NULL }, + { "all_locales", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllLocalesCommand, "", NULL }, + { "all_loot", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllLootCommand, "", NULL }, + { "all_npc", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllNpcCommand, "", NULL }, + { "all_quest", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllQuestCommand, "", NULL }, + { "all_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllScriptsCommand, "", NULL }, + { "all_spell", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAllSpellCommand, "", NULL }, + + { "config", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadConfigCommand, "", NULL }, + { "eluna", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadElunaCommand, "", NULL }, + + { "areatrigger_tavern", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, + { "areatrigger_teleport", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, + { "access_requirement", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAccessRequirementCommand, "", NULL }, + { "areatrigger_involvedrelation",PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, + { "auctions", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAuctionsCommand, "", NULL }, + { "autobroadcast", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadAutobroadcastCommand, "", NULL }, + { "command", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadCommandCommand, "", NULL }, + { "creature_involvedrelation", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand, "", NULL }, + { "creature_linked_respawn", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadCreatureLinkedRespawnCommand, "", NULL }, + { "creature_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL }, + { "creature_questrelation", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL }, + { "creature_ai_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadEventAIScriptsCommand, "", NULL }, + { "disenchant_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesDisenchantCommand, "", NULL }, + { "eventai", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadEventAICommand, "", NULL }, + { "event_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL }, + { "fishing_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesFishingCommand, "", NULL }, + { "game_graveyard_zone", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGameGraveyardZoneCommand, "", NULL }, + { "game_tele", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGameTeleCommand, "", NULL }, + { "gameobject_involvedrelation", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGOQuestInvRelationsCommand, "", NULL }, + { "gameobject_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesGameobjectCommand, "", NULL }, + { "gameobject_questrelation", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGOQuestRelationsCommand, "", NULL }, + { "gameobject_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGameObjectScriptsCommand, "", NULL }, + { "gm_tickets", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadGMTicketCommand, "", NULL }, + { "item_enchantment_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL }, + { "item_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL }, + { "locales_creature", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesCreatureCommand, "", NULL }, + { "locales_gameobject", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesGameobjectCommand, "", NULL }, + { "locales_item", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesItemCommand, "", NULL }, + { "locales_npc_text", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesNpcTextCommand, "", NULL }, + { "locales_page_text", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL }, + { "locales_quest", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL }, + { "npc_gossip", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadNpcGossipCommand, "", NULL }, + { "npc_option", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadNpcOptionCommand, "", NULL }, + { "npc_trainer", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadNpcTrainerCommand, "", NULL }, + { "npc_vendor", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadNpcVendorCommand, "", NULL }, + { "page_text", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadPageTextsCommand, "", NULL }, + { "pickpocketing_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand,"", NULL}, + { "prospecting_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand, "", NULL }, + { "quest_mail_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesQuestMailCommand, "", NULL }, + { "quest_end_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, + { "quest_start_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, + { "quest_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL }, + { "reference_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, + { "reserved_name", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadReservedNameCommand, "", NULL }, + { "reputation_reward_rate", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadReputationRewardRateCommand, "", NULL }, + { "reputation_spillover_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadReputationSpilloverTemplateCommand, "", NULL }, + { "skill_discovery_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, + { "skill_extra_item_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSkillExtraItemPrototypeCommand, "", NULL }, + { "skill_fishing_base_level", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL }, + { "skinning_loot_template", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadLootTemplatesSkinningCommand, "", NULL }, + { "spell_affect", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellAffectCommand, "", NULL }, + { "spell_required", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellRequiredCommand, "", NULL }, + { "spell_elixir", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellElixirCommand, "", NULL }, + { "spell_learn_spell", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", NULL }, + { "spell_linked_spell", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellLinkedSpellCommand, "", NULL }, + { "spell_pet_auras", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellPetAurasCommand, "", NULL }, + { "spell_proc_event", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellProcEventCommand, "", NULL }, + { "spell_enchant_proc_data", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellEnchantDataCommand, "", NULL }, + { "spell_script_target", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellScriptTargetCommand, "", NULL }, + { "spell_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellScriptsCommand, "", NULL }, + { "spell_target_position", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellTargetPositionCommand, "", NULL }, + { "spell_threats", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellThreatsCommand, "", NULL }, + { "spell_disabled", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadSpellDisabledCommand, "", NULL }, + { "hellground_string", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadHellgroundStringCommand, "", NULL }, + { "unqueue_account", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadUnqueuedAccountListCommand, "", NULL }, + { "waypoint_scripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadWpScriptsCommand, "", NULL }, + + { "", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleReloadCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand honorCommandTable[] = { - { "add", PERM_HIGH_GMT, false, &ChatHandler::HandleHonorAddCommand, "", NULL }, - { "addkill", PERM_HIGH_GMT, false, &ChatHandler::HandleHonorAddKillCommand, "", NULL }, - { "update", PERM_HIGH_GMT, false, &ChatHandler::HandleHonorUpdateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleHonorAddCommand, "", NULL }, + { "addkill", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleHonorAddKillCommand, "", NULL }, + { "update", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleHonorUpdateCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand guildDisableCommandTable[] = { - { "announce", PERM_GMT, true, &ChatHandler::HandleGuildDisableAnnounceCommand, "", NULL}, - { NULL, 0, false, NULL, "", NULL} + { "announce", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildDisableAnnounceCommand, "", NULL}, + { NULL, 0, 0, false, NULL, "", NULL} }; static ChatCommand guildEnableCommandTable[] = { - { "announce", PERM_GMT, true, &ChatHandler::HandleGuildEnableAnnounceCommand, "", NULL}, - { NULL, 0, false, NULL, "", NULL} + { "announce", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildEnableAnnounceCommand, "", NULL}, + { NULL, 0, 0, false, NULL, "", NULL} }; static ChatCommand guildCommandTable[] = { - { "ann", PERM_PLAYER, false, &ChatHandler::HandleGuildAnnounceCommand, "", NULL }, - { "create", PERM_HIGH_GMT, true, &ChatHandler::HandleGuildCreateCommand, "", NULL }, - { "delete", PERM_HIGH_GMT, true, &ChatHandler::HandleGuildDeleteCommand, "", NULL }, - { "disable", PERM_GMT, true, NULL, "", guildDisableCommandTable }, - { "enable", PERM_GMT, true, NULL, "", guildEnableCommandTable }, - { "invite", PERM_HIGH_GMT, true, &ChatHandler::HandleGuildInviteCommand, "", NULL }, - { "rank", PERM_HIGH_GMT, true, &ChatHandler::HandleGuildRankCommand, "", NULL }, - { "uninvite", PERM_HIGH_GMT, true, &ChatHandler::HandleGuildUninviteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "ann", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleGuildAnnounceCommand, "", NULL }, + { "create", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildCreateCommand, "", NULL }, + { "delete", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildDeleteCommand, "", NULL }, + { "disable", PERM_GMT, PERM_CONSOLE, true, NULL, "", guildDisableCommandTable }, + { "enable", PERM_GMT, PERM_CONSOLE, true, NULL, "", guildEnableCommandTable }, + { "invite", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildInviteCommand, "", NULL }, + { "rank", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildRankCommand, "", NULL }, + { "uninvite", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGuildUninviteCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand petCommandTable[] = { - { "create", PERM_GMT, false, &ChatHandler::HandleCreatePetCommand, "", NULL }, - { "learn", PERM_GMT, false, &ChatHandler::HandlePetLearnCommand, "", NULL }, - { "tp", PERM_GMT, false, &ChatHandler::HandlePetTpCommand, "", NULL }, - { "unlearn", PERM_GMT, false, &ChatHandler::HandlePetUnlearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "create", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCreatePetCommand, "", NULL }, + { "learn", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandlePetLearnCommand, "", NULL }, + { "tp", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandlePetTpCommand, "", NULL }, + { "unlearn", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandlePetUnlearnCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand groupCommandTable[] = { - { "disband", PERM_ADM, false, &ChatHandler::HandleGroupDisbandCommand, "", NULL }, - { "leader", PERM_ADM, false, &ChatHandler::HandleGroupLeaderCommand, "", NULL }, - { "remove", PERM_ADM, false, &ChatHandler::HandleGroupRemoveCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "disband", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleGroupDisbandCommand, "", NULL }, + { "leader", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleGroupLeaderCommand, "", NULL }, + { "remove", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleGroupRemoveCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand lookupPlayerCommandTable[] = { - { "account", PERM_GMT, true, &ChatHandler::HandleLookupPlayerAccountCommand, "", NULL }, - { "email", PERM_HIGH_GMT, true, &ChatHandler::HandleLookupPlayerEmailCommand, "", NULL }, - { "ip", PERM_GMT, true, &ChatHandler::HandleLookupPlayerIpCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupPlayerAccountCommand, "", NULL }, + { "email", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupPlayerEmailCommand, "", NULL }, + { "ip", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupPlayerIpCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand lookupCommandTable[] = { - { "area", PERM_GMT, true, &ChatHandler::HandleLookupAreaCommand, "", NULL }, - { "creature", PERM_ADM, true, &ChatHandler::HandleLookupCreatureCommand, "", NULL }, - { "event", PERM_GMT, true, &ChatHandler::HandleLookupEventCommand, "", NULL }, - { "faction", PERM_ADM, true, &ChatHandler::HandleLookupFactionCommand, "", NULL }, - { "item", PERM_ADM, true, &ChatHandler::HandleLookupItemCommand, "", NULL }, - { "itemset", PERM_ADM, true, &ChatHandler::HandleLookupItemSetCommand, "", NULL }, - { "object", PERM_ADM, true, &ChatHandler::HandleLookupObjectCommand, "", NULL }, - { "player", PERM_HIGH_GMT, true, NULL, "", lookupPlayerCommandTable }, - { "quest", PERM_ADM, true, &ChatHandler::HandleLookupQuestCommand, "", NULL }, - { "skill", PERM_ADM, true, &ChatHandler::HandleLookupSkillCommand, "", NULL }, - { "spell", PERM_ADM, true, &ChatHandler::HandleLookupSpellCommand, "", NULL }, - { "tele", PERM_GMT, true, &ChatHandler::HandleLookupTeleCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "area", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupAreaCommand, "", NULL }, + { "creature", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupCreatureCommand, "", NULL }, + { "event", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupEventCommand, "", NULL }, + { "faction", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupFactionCommand, "", NULL }, + { "item", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupItemCommand, "", NULL }, + { "itemset", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupItemSetCommand, "", NULL }, + { "object", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupObjectCommand, "", NULL }, + { "player", PERM_HIGH_GMT, PERM_CONSOLE, true, NULL, "", lookupPlayerCommandTable }, + { "quest", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupQuestCommand, "", NULL }, + { "skill", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupSkillCommand, "", NULL }, + { "spell", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLookupSpellCommand, "", NULL }, + { "tele", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleLookupTeleCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand resetCommandTable[] = { - { "all", PERM_ADM, false, &ChatHandler::HandleResetAllCommand, "", NULL }, - { "honor", PERM_ADM, false, &ChatHandler::HandleResetHonorCommand, "", NULL }, - { "level", PERM_ADM, false, &ChatHandler::HandleResetLevelCommand, "", NULL }, - { "spells", PERM_ADM, false, &ChatHandler::HandleResetSpellsCommand, "", NULL }, - { "stats", PERM_ADM, false, &ChatHandler::HandleResetStatsCommand, "", NULL }, - { "talents", PERM_ADM, false, &ChatHandler::HandleResetTalentsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "all", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetAllCommand, "", NULL }, + { "honor", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetHonorCommand, "", NULL }, + { "level", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetLevelCommand, "", NULL }, + { "spells", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetSpellsCommand, "", NULL }, + { "stats", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetStatsCommand, "", NULL }, + { "talents", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleResetTalentsCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand castCommandTable[] = { - { "back", PERM_ADM, false, &ChatHandler::HandleCastBackCommand, "", NULL }, - { "dist", PERM_ADM, false, &ChatHandler::HandleCastDistCommand, "", NULL }, - { "null", PERM_ADM, false, &ChatHandler::HandleCastNullCommand, "", NULL }, - { "self", PERM_ADM, false, &ChatHandler::HandleCastSelfCommand, "", NULL }, - { "target", PERM_ADM, false, &ChatHandler::HandleCastTargetCommand, "", NULL }, - { "", PERM_ADM, false, &ChatHandler::HandleCastCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "back", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastBackCommand, "", NULL }, + { "dist", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastDistCommand, "", NULL }, + { "null", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastNullCommand, "", NULL }, + { "self", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastSelfCommand, "", NULL }, + { "target", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastTargetCommand, "", NULL }, + { "", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCastCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand listCommandTable[] = { - { "auras", PERM_ADM, false, &ChatHandler::HandleListAurasCommand, "", NULL }, - { "creature", PERM_ADM, true, &ChatHandler::HandleListCreatureCommand, "", NULL }, - { "item", PERM_ADM, true, &ChatHandler::HandleListItemCommand, "", NULL }, - { "object", PERM_ADM, true, &ChatHandler::HandleListObjectCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "auras", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleListAurasCommand, "", NULL }, + { "creature", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleListCreatureCommand, "", NULL }, + { "item", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleListItemCommand, "", NULL }, + { "object", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleListObjectCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand teleCommandTable[] = { - { "add", PERM_ADM, false, &ChatHandler::HandleTeleAddCommand, "", NULL }, - { "del", PERM_ADM, true, &ChatHandler::HandleTeleDelCommand, "", NULL }, - { "group", PERM_GMT, false, &ChatHandler::HandleTeleGroupCommand, "", NULL }, - { "name", PERM_GMT, true, &ChatHandler::HandleTeleNameCommand, "", NULL }, - { "", PERM_GMT, false, &ChatHandler::HandleTeleCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleTeleAddCommand, "", NULL }, + { "del", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleTeleDelCommand, "", NULL }, + { "group", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleTeleGroupCommand, "", NULL }, + { "name", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleTeleNameCommand, "", NULL }, + { "", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleTeleCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand npcCommandTable[] = { - { "add", PERM_HIGH_GMT, false, &ChatHandler::HandleNpcAddCommand, "", NULL }, - { "addformation", PERM_DEVELOPER, false, &ChatHandler::HandleNpcAddFormationCommand, "", NULL }, - { "additem", PERM_HIGH_GMT, false, &ChatHandler::HandleNpcAddItemCommand, "", NULL }, - { "addmove", PERM_DEVELOPER, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL }, - { "addtemp", PERM_HIGH_GMT, false, &ChatHandler::HandleNpcAddTempCommand, "", NULL }, - { "changeentry", PERM_ADM, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL }, - { "changelevel", PERM_HIGH_GMT, false, &ChatHandler::HandleNpcChangeLevelCommand, "", NULL }, - { "delete", PERM_HIGH_GMT, false, &ChatHandler::HandleNpcDeleteCommand, "", NULL }, - { "deleteformation",PERM_DEVELOPER, false, &ChatHandler::HandleNpcDeleteFormationCommand, "", NULL }, - { "delitem", PERM_GMT_DEV, false, &ChatHandler::HandleNpcDelItemCommand, "", NULL }, - { "doaction", PERM_GMT_DEV, false, &ChatHandler::HandleNpcDoActionCommand, "", NULL }, - { "enterevademode", PERM_GMT_DEV, false, &ChatHandler::HandleNpcEnterEvadeModeCommand, "", NULL }, - { "factionid", PERM_GMT_DEV, false, &ChatHandler::HandleNpcFactionIdCommand, "", NULL }, - { "flag", PERM_GMT_DEV, false, &ChatHandler::HandleNpcFlagCommand, "", NULL }, - { "follow", PERM_GMT_DEV, false, &ChatHandler::HandleNpcFollowCommand, "", NULL }, - { "info", PERM_PLAYER, false, &ChatHandler::HandleNpcInfoCommand, "", NULL }, - { "move", PERM_GMT_DEV, false, &ChatHandler::HandleNpcMoveCommand, "", NULL }, - { "playemote", PERM_GMT_DEV, false, &ChatHandler::HandleNpcPlayEmoteCommand, "", NULL }, - { "resetai", PERM_GMT_DEV, false, &ChatHandler::HandleNpcResetAICommand, "", NULL }, - { "say", PERM_GMT, false, &ChatHandler::HandleNpcSayCommand, "", NULL }, - { "setlink", PERM_GMT_DEV, false, &ChatHandler::HandleNpcSetLinkCommand, "", NULL }, - { "setmodel", PERM_GMT_DEV, false, &ChatHandler::HandleNpcSetModelCommand, "", NULL }, - { "setmovetype", PERM_GMT_DEV, false, &ChatHandler::HandleNpcSetMoveTypeCommand, "", NULL }, - { "spawndist", PERM_GMT_DEV, false, &ChatHandler::HandleNpcSpawnDistCommand, "", NULL }, - { "spawntime", PERM_GMT_DEV, false, &ChatHandler::HandleNpcSpawnTimeCommand, "", NULL }, - { "textemote", PERM_GMT, false, &ChatHandler::HandleNpcTextEmoteCommand, "", NULL }, - { "unfollow", PERM_GMT_DEV, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL }, - { "whisper", PERM_GMT, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL }, - { "yell", PERM_GMT, false, &ChatHandler::HandleNpcYellCommand, "", NULL }, + { "add", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcAddCommand, "", NULL }, + { "addformation", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleNpcAddFormationCommand, "", NULL }, + { "additem", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcAddItemCommand, "", NULL }, + { "addmove", PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL }, + { "addtemp", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcAddTempCommand, "", NULL }, + { "changeentry", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL }, + { "changelevel", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcChangeLevelCommand, "", NULL }, + { "delete", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcDeleteCommand, "", NULL }, + { "deleteformation",PERM_DEVELOPER, PERM_CONSOLE, false, &ChatHandler::HandleNpcDeleteFormationCommand, "", NULL }, + { "delitem", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcDelItemCommand, "", NULL }, + { "doaction", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcDoActionCommand, "", NULL }, + { "enterevademode", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcEnterEvadeModeCommand, "", NULL }, + { "extraflag", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcExtraFlagCommand, "", NULL }, + { "factionid", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcFactionIdCommand, "", NULL }, + { "fieldflag", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcFieldFlagCommand, "", NULL }, + { "flag", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcFlagCommand, "", NULL }, + { "follow", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcFollowCommand, "", NULL }, + { "info", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleNpcInfoCommand, "", NULL }, + { "move", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcMoveCommand, "", NULL }, + { "playemote", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcPlayEmoteCommand, "", NULL }, + { "resetai", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcResetAICommand, "", NULL }, + { "say", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcSayCommand, "", NULL }, + { "setlink", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcSetLinkCommand, "", NULL }, + { "setmodel", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcSetModelCommand, "", NULL }, + { "setmovetype", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcSetMoveTypeCommand, "", NULL }, + { "spawndist", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcSpawnDistCommand, "", NULL }, + { "spawntime", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcSpawnTimeCommand, "", NULL }, + { "standstate", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcStandState, "", NULL }, + { "textemote", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcTextEmoteCommand, "", NULL }, + { "unfollow", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL }, + { "whisper", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL }, + { "yell", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNpcYellCommand, "", NULL }, //{ TODO: fix or remove this commands - { "name", PERM_GMT, false, &ChatHandler::HandleNameCommand, "", NULL }, - { "subname", PERM_GMT, false, &ChatHandler::HandleSubNameCommand, "", NULL }, - { "addweapon", PERM_ADM, false, &ChatHandler::HandleAddWeaponCommand, "", NULL }, + { "name", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNameCommand, "", NULL }, + { "subname", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleSubNameCommand, "", NULL }, + { "addweapon", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleAddWeaponCommand, "", NULL }, //} - - { NULL, 0, false, NULL, "", NULL } + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand goCommandTable[] = { - { "creature", PERM_GMT_DEV, false, &ChatHandler::HandleGoCreatureCommand, "", NULL }, - { "graveyard", PERM_GMT_DEV, false, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, - { "grid", PERM_GMT_DEV, false, &ChatHandler::HandleGoGridCommand, "", NULL }, - { "object", PERM_GMT_DEV, false, &ChatHandler::HandleGoObjectCommand, "", NULL }, - { "ticket", PERM_GMT, false, &ChatHandler::HandleGoTicketCommand, "", NULL }, - { "trigger", PERM_GMT_DEV, false, &ChatHandler::HandleGoTriggerCommand, "", NULL }, - { "zonexy", PERM_GMT_DEV, false, &ChatHandler::HandleGoZoneXYCommand, "", NULL }, - { "xy", PERM_GMT_DEV, false, &ChatHandler::HandleGoXYCommand, "", NULL }, - { "xyz", PERM_GMT_DEV, false, &ChatHandler::HandleGoXYZCommand, "", NULL }, - { "", PERM_GMT_DEV, false, &ChatHandler::HandleGoXYZCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "creature", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoCreatureCommand, "", NULL }, + { "direct", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoCreatureDirectCommand, "", NULL }, + { "graveyard", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, + { "grid", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoGridCommand, "", NULL }, + { "object", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoObjectCommand, "", NULL }, + { "ticket", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGoTicketCommand, "", NULL }, + { "trigger", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoTriggerCommand, "", NULL }, + { "zonexy", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoZoneXYCommand, "", NULL }, + { "xy", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoXYCommand, "", NULL }, + { "xyz", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoXYZCommand, "", NULL }, + { "", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGoXYZCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand gobjectCommandTable[] = { - { "activate", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectActivateCommand, "", NULL }, - { "add", PERM_HIGH_GMT, false, &ChatHandler::HandleGameObjectAddCommand, "", NULL }, - { "addtemp", PERM_HIGH_GMT, false, &ChatHandler::HandleGameObjectAddTempCommand, "", NULL }, - { "delete", PERM_HIGH_GMT, false, &ChatHandler::HandleGameObjectDeleteCommand, "", NULL }, - { "grid", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectGridCommand, "", NULL }, - { "move", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectMoveCommand, "", NULL }, - { "near", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectNearCommand, "", NULL }, - { "target", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectTargetCommand, "", NULL }, - { "turn", PERM_GMT_DEV, false, &ChatHandler::HandleGameObjectTurnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "activate", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectActivateCommand, "", NULL }, + { "add", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectAddCommand, "", NULL }, + { "addtemp", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectAddTempCommand, "", NULL }, + { "delete", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectDeleteCommand, "", NULL }, + { "grid", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectGridCommand, "", NULL }, + { "move", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectMoveCommand, "", NULL }, + { "near", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectNearCommand, "", NULL }, + { "reset", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectResetCommand, "", NULL }, + { "target", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectTargetCommand, "", NULL }, + { "turn", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGameObjectTurnCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand questCommandTable[] = { - { "add", PERM_HIGH_GMT, false, &ChatHandler::HandleQuestAdd, "", NULL }, - { "complete", PERM_HIGH_GMT, false, &ChatHandler::HandleQuestComplete, "", NULL }, - { "remove", PERM_HIGH_GMT, false, &ChatHandler::HandleQuestRemove, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleQuestAdd, "", NULL }, + { "complete", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleQuestComplete, "", NULL }, + { "remove", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleQuestRemove, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand gmCommandTable[] = { - { "announce", PERM_HIGH_GMT, true, &ChatHandler::HandleGMAnnounceCommand, "", NULL }, - { "chat", PERM_GMT, false, &ChatHandler::HandleGMChatCommand, "", NULL }, - { "fly", PERM_HIGH_GMT, false, &ChatHandler::HandleGMFlyCommand, "", NULL }, - { "list", PERM_ADM, true, &ChatHandler::HandleGMListFullCommand, "", NULL }, - { "nameannounce", PERM_GMT, false, &ChatHandler::HandleGMNameAnnounceCommand, "", NULL }, - { "notify", PERM_HIGH_GMT, true, &ChatHandler::HandleGMNotifyCommand, "", NULL }, - { "visible", PERM_GMT, false, &ChatHandler::HandleGMVisibleCommand, "", NULL }, - { "", PERM_GMT, false, &ChatHandler::HandleGMCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "announce", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGMAnnounceCommand, "", NULL }, + { "chat", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMChatCommand, "", NULL }, + { "fly", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMFlyCommand, "", NULL }, + { "list", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleGMListFullCommand, "", NULL }, + { "nameannounce", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMNameAnnounceCommand, "", NULL }, + { "notify", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleGMNotifyCommand, "", NULL }, + { "visible", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMVisibleCommand, "", NULL }, + { "", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand instanceCommandTable[] = { - { "listbinds", PERM_GMT_DEV, false, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, - { "savedata", PERM_GMT, false, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, - { "selfunbind", PERM_GMT, false, &ChatHandler::HandleInstanceSelfUnbindCommand, "", NULL }, - { "stats", PERM_GMT_DEV, true, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, - { "unbind", PERM_HIGH_GMT, false, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, - { "bind", PERM_GMT, false, &ChatHandler::HandleInstanceBindCommand, "", NULL }, - { "resetencounters", PERM_GMT, false, &ChatHandler::HandleInstanceResetEncountersCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "listbinds", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, + { "savedata", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, + { "selfunbind", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInstanceSelfUnbindCommand, "", NULL }, + { "stats", PERM_GMT_DEV, PERM_CONSOLE, true, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, + { "unbind", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, + { "bind", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInstanceBindCommand, "", NULL }, + { "resetencounters", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInstanceResetEncountersCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand ticketCommandTable[] = { - { "assign", PERM_GMT, false, &ChatHandler::HandleGMTicketAssignToCommand, "", NULL }, - { "close", PERM_GMT, false, &ChatHandler::HandleGMTicketCloseByIdCommand, "", NULL }, - { "closedlist", PERM_GMT, false, &ChatHandler::HandleGMTicketListClosedCommand, "", NULL }, - { "comment", PERM_GMT, false, &ChatHandler::HandleGMTicketCommentCommand, "", NULL }, - { "delete", PERM_ADM, false, &ChatHandler::HandleGMTicketDeleteByIdCommand, "", NULL }, - { "history", PERM_GMT, false, &ChatHandler::HandleGMTicketHistoryCommand, "", NULL }, - { "list", PERM_GMT, false, &ChatHandler::HandleGMTicketListCommand, "", NULL }, - { "onlinelist", PERM_GMT, false, &ChatHandler::HandleGMTicketListOnlineCommand, "", NULL }, - { "response", PERM_GMT, false, &ChatHandler::HandleGMTicketResponseCommand, "", NULL }, - { "unassign", PERM_GMT, false, &ChatHandler::HandleGMTicketUnAssignCommand, "", NULL }, - { "viewid", PERM_GMT, false, &ChatHandler::HandleGMTicketGetByIdCommand, "", NULL }, - { "viewname", PERM_GMT, false, &ChatHandler::HandleGMTicketGetByNameCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "assign", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketAssignToCommand, "", NULL }, + { "close", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketCloseByIdCommand, "", NULL }, + { "closedlist", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketListClosedCommand, "", NULL }, + { "comment", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketCommentCommand, "", NULL }, + { "delete", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketDeleteByIdCommand, "", NULL }, + { "history", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketHistoryCommand, "", NULL }, + { "list", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketListCommand, "", NULL }, + { "onlinelist", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketListOnlineCommand, "", NULL }, + { "response", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketResponseCommand, "", NULL }, + { "unassign", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketUnAssignCommand, "", NULL }, + { "viewid", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketGetByIdCommand, "", NULL }, + { "viewname", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGMTicketGetByNameCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand channelCommandTable[] = { - { "kick", PERM_ADM, false, &ChatHandler::HandleChannelKickCommand, "", NULL }, - { "list", PERM_GMT, false, &ChatHandler::HandleChannelListCommand, "", NULL }, - { "masskick", PERM_ADM, false, &ChatHandler::HandleChannelMassKickCommand, "", NULL }, - { "pass", PERM_ADM, false, &ChatHandler::HandleChannelPassCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "kick", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleChannelKickCommand, "", NULL }, + { "list", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleChannelListCommand, "", NULL }, + { "masskick", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleChannelMassKickCommand, "", NULL }, + { "pass", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleChannelPassCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } }; static ChatCommand crashCommandTable[] = { - { "map", PERM_HIGH_GMT, false, &ChatHandler::HandleCrashMapCommand, "", NULL }, - { "server", PERM_ADM, true, &ChatHandler::HandleCrashServerCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "map", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCrashMapCommand, "", NULL }, + { "server", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleCrashServerCommand, "", NULL }, + { NULL, 0, 0, false, NULL, "", NULL } + }; + + static ChatCommand cheatCommandTable[] = + { + { "explore", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleExploreCheatCommand, "", NULL }, + { "godmode", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCheatGodmodeCommand, "", NULL }, + { "maxskill", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleMaxSkillCommand, "", NULL }, + { "possess", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandlePossessCommand, "", NULL }, + { "power", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCheatPowerCommand, "", NULL }, + { "repairitems", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleRepairitemsCommand, "", NULL }, + { "taxi", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleTaxiCheatCommand, "", NULL }, + { "unpossess", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnPossessCommand, "", NULL }, + { "waterwalk", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, }; static ChatCommand commandTable[] = { - { "account", PERM_PLAYER, true, NULL, "", accountCommandTable }, - { "ban", PERM_GMT, true, NULL, "", banCommandTable }, - { "baninfo", PERM_GMT, false, NULL, "", baninfoCommandTable }, - { "banlist", PERM_GMT, true, NULL, "", banlistCommandTable }, - { "cast", PERM_GMT, false, NULL, "", castCommandTable }, - { "channel", PERM_GMT, false, NULL, "", channelCommandTable}, - { "crash", PERM_HIGH_GMT, false, NULL, "", crashCommandTable }, - { "debug", PERM_GMT, false, NULL, "", debugCommandTable }, - { "event", PERM_GMT, false, NULL, "", eventCommandTable }, - { "gm", PERM_GMT, true, NULL, "", gmCommandTable }, - { "go", PERM_GMT_DEV, false, NULL, "", goCommandTable }, - { "gobject", PERM_GMT_DEV, false, NULL, "", gobjectCommandTable }, - { "guild", PERM_HIGH_GMT, true, NULL, "", guildCommandTable }, - { "honor", PERM_HIGH_GMT, false, NULL, "", honorCommandTable }, - { "instance", PERM_GMT_DEV, true, NULL, "", instanceCommandTable }, - { "learn", PERM_GMT, false, NULL, "", learnCommandTable }, - { "list", PERM_ADM, true, NULL, "", listCommandTable }, - { "lookup", PERM_GMT, true, NULL, "", lookupCommandTable }, - { "modify", PERM_GMT, false, NULL, "", modifyCommandTable }, - { "mmap", PERM_GMT_DEV, false, NULL, "", mmapCommandTable }, - { "npc", PERM_GMT_DEV, false, NULL, "", npcCommandTable }, - { "path", PERM_GMT_DEV, false, NULL, "", wpCommandTable }, - { "pet", PERM_GMT, false, NULL, "", petCommandTable }, - { "quest", PERM_HIGH_GMT, false, NULL, "", questCommandTable }, - { "reload", PERM_ADM, true, NULL, "", reloadCommandTable }, - { "reset", PERM_ADM, false, NULL, "", resetCommandTable }, - { "send", PERM_GMT, true, NULL, "", sendCommandTable }, - { "server", PERM_ADM, true, NULL, "", serverCommandTable }, - { "tele", PERM_GMT_DEV, true, NULL, "", teleCommandTable }, - { "ticket", PERM_GMT, false, NULL, "", ticketCommandTable }, - { "unban", PERM_GMT, true, NULL, "", unbanCommandTable }, - { "wp", PERM_GMT_DEV, false, NULL, "", wpCommandTable }, - - { "additem", PERM_ADM, false, &ChatHandler::HandleAddItemCommand, "", NULL }, - { "additemset", PERM_ADM, false, &ChatHandler::HandleAddItemSetCommand, "", NULL }, - { "allowmove", PERM_ADM, false, &ChatHandler::HandleAllowMovementCommand, "", NULL }, - { "announce", PERM_GMT, true, &ChatHandler::HandleAnnounceCommand, "", NULL }, - { "aura", PERM_ADM, false, &ChatHandler::HandleAuraCommand, "", NULL }, - { "bank", PERM_ADM, false, &ChatHandler::HandleBankCommand, "", NULL }, - { "bindfollow", PERM_ADM, false, &ChatHandler::HandleBindFollowCommand, "", NULL }, - { "bindsight", PERM_ADM, false, &ChatHandler::HandleBindSightCommand, "", NULL }, - { "cd", PERM_ADM, false, &ChatHandler::HandleCooldownCommand, "", NULL }, - { "chardelete", PERM_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, - { "combatstop", PERM_GMT, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, - { "cometome", PERM_GMT, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, - { "commands", PERM_PLAYER, true, &ChatHandler::HandleCommandsCommand, "", NULL }, - { "cooldown", PERM_HIGH_GMT, false, &ChatHandler::HandleCooldownCommand, "", NULL }, - { "damage", PERM_ADM, false, &ChatHandler::HandleDamageCommand, "", NULL }, - { "demorph", PERM_GMT, false, &ChatHandler::HandleDeMorphCommand, "", NULL }, - { "die", PERM_ADM, false, &ChatHandler::HandleDieCommand, "", NULL }, - { "dismount", PERM_PLAYER, false, &ChatHandler::HandleDismountCommand, "", NULL }, - { "distance", PERM_GMT_DEV, false, &ChatHandler::HandleGetDistanceCommand, "", NULL }, - { "explorecheat", PERM_ADM, false, &ChatHandler::HandleExploreCheatCommand, "", NULL }, - //{ "flusharenapoints",PERM_CONSOLE, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, - { "freeze", PERM_GMT, false, &ChatHandler::HandleFreezeCommand, "", NULL }, - { "goname", PERM_GMT, false, &ChatHandler::HandleGonameCommand, "", NULL }, - { "gps", PERM_GMT_DEV, false, &ChatHandler::HandleGPSCommand, "", NULL }, - { "info", PERM_GMT, false, &ChatHandler::HandleInfoCommand, "", NULL }, - { "groupgo", PERM_GMT, false, &ChatHandler::HandleGroupgoCommand, "", NULL }, - { "guid", PERM_GMT_DEV, false, &ChatHandler::HandleGUIDCommand, "", NULL }, - { "help", PERM_PLAYER, true, &ChatHandler::HandleHelpCommand, "", NULL }, - { "hidearea", PERM_ADM, false, &ChatHandler::HandleHideAreaCommand, "", NULL }, - { "hover", PERM_ADM, false, &ChatHandler::HandleHoverCommand, "", NULL }, - { "itemmove", PERM_ADM, false, &ChatHandler::HandleItemMoveCommand, "", NULL }, - { "kick", PERM_GMT, true, &ChatHandler::HandleKickPlayerCommand, "", NULL }, - { "levelup", PERM_HIGH_GMT, false, &ChatHandler::HandleLevelUpCommand, "", NULL }, - { "linkgrave", PERM_GMT_DEV, false, &ChatHandler::HandleLinkGraveCommand, "", NULL }, - { "listfreeze", PERM_GMT, false, &ChatHandler::HandleListFreezeCommand, "", NULL }, - { "loadscripts", PERM_ADM, true, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, - { "lockaccount", PERM_PLAYER, false, &ChatHandler::HandleLockAccountCommand, "", NULL }, - { "maxskill", PERM_HIGH_GMT, false, &ChatHandler::HandleMaxSkillCommand, "", NULL }, - { "movegens", PERM_GMT_DEV, false, &ChatHandler::HandleMovegensCommand, "", NULL }, - { "mute", PERM_GMT, true, &ChatHandler::HandleMuteCommand, "", NULL }, - { "muteinfo", PERM_GMT, true, &ChatHandler::HandleMuteInfoCommand, "", NULL }, - { "nameannounce", PERM_GMT, false, &ChatHandler::HandleNameAnnounceCommand, "", NULL }, - { "namego", PERM_GMT, false, &ChatHandler::HandleNamegoCommand, "", NULL }, - { "neargrave", PERM_GMT_DEV, false, &ChatHandler::HandleNearGraveCommand, "", NULL }, - { "notify", PERM_HIGH_GMT, true, &ChatHandler::HandleNotifyCommand, "", NULL }, - { "password", PERM_PLAYER, false, &ChatHandler::HandlePasswordCommand, "", NULL }, - { "pinfo", PERM_GMT, true, &ChatHandler::HandlePInfoCommand, "", NULL }, - { "playall", PERM_ADM, false, &ChatHandler::HandlePlayAllCommand, "", NULL }, - { "plimit", PERM_ADM, true, &ChatHandler::HandlePLimitCommand, "", NULL }, - { "possess", PERM_ADM, false, &ChatHandler::HandlePossessCommand, "", NULL }, - { "recall", PERM_GMT, false, &ChatHandler::HandleRecallCommand, "", NULL }, - { "rename", PERM_HIGH_GMT, true, &ChatHandler::HandleRenameCommand, "", NULL }, - { "repairitems", PERM_GMT, false, &ChatHandler::HandleRepairitemsCommand, "", NULL }, - { "respawn", PERM_ADM, false, &ChatHandler::HandleRespawnCommand, "", NULL }, - { "revive", PERM_ADM, false, &ChatHandler::HandleReviveCommand, "", NULL }, - { "revivegroup", PERM_ADM, false, &ChatHandler::HandleReviveGroupCommand, "", NULL }, - { "save", PERM_PLAYER, false, &ChatHandler::HandleSaveCommand, "", NULL }, - { "setskill", PERM_ADM, false, &ChatHandler::HandleSetSkillCommand, "", NULL }, - { "showarea", PERM_ADM, false, &ChatHandler::HandleShowAreaCommand, "", NULL }, - { "start", PERM_PLAYER, false, &ChatHandler::HandleStartCommand, "", NULL }, - { "taxicheat", PERM_HIGH_GMT, false, &ChatHandler::HandleTaxiCheatCommand, "", NULL }, - { "unaura", PERM_ADM, false, &ChatHandler::HandleUnAuraCommand, "", NULL }, - { "unbindfollow", PERM_ADM, false, &ChatHandler::HandleUnbindFollowCommand, "", NULL }, - { "unbindsight", PERM_ADM, false, &ChatHandler::HandleUnbindSightCommand, "", NULL }, - { "unfreeze", PERM_ADM, false, &ChatHandler::HandleUnFreezeCommand, "", NULL }, - { "unlearn", PERM_ADM, false, &ChatHandler::HandleUnLearnCommand, "", NULL }, - { "unmute", PERM_GMT, true, &ChatHandler::HandleUnmuteCommand, "", NULL }, - { "unpossess", PERM_ADM, false, &ChatHandler::HandleUnPossessCommand, "", NULL }, - { "waterwalk", PERM_ADM, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, - { "wchange", PERM_ADM, false, &ChatHandler::HandleChangeWeather, "", NULL }, - { "weather", PERM_PLAYER, true, &ChatHandler::HandleAccountWeatherCommand, "", NULL }, - { "whispers", PERM_GMT, false, &ChatHandler::HandleWhispersCommand, "", NULL }, - - { NULL, 0, false, NULL, "", NULL } + { "account", PERM_PLAYER, PERM_CONSOLE, true, NULL, "", accountCommandTable }, + { "arena", PERM_PLAYER, PERM_CONSOLE, false, NULL, "", arenaCommandTable }, + { "ban", PERM_GMT, PERM_CONSOLE, true, NULL, "", banCommandTable }, + { "baninfo", PERM_GMT, PERM_CONSOLE, false, NULL, "", baninfoCommandTable }, + { "banlist", PERM_GMT, PERM_CONSOLE, true, NULL, "", banlistCommandTable }, + { "cast", PERM_GMT, PERM_CONSOLE, false, NULL, "", castCommandTable }, + { "channel", PERM_GMT, PERM_CONSOLE, false, NULL, "", channelCommandTable}, + { "crash", PERM_HIGH_GMT, PERM_CONSOLE, false, NULL, "", crashCommandTable }, + { "debug", PERM_GMT, PERM_CONSOLE, false, NULL, "", debugCommandTable }, + { "event", PERM_GMT, PERM_CONSOLE, false, NULL, "", eventCommandTable }, + { "gm", PERM_GMT, PERM_CONSOLE, true, NULL, "", gmCommandTable }, + { "go", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", goCommandTable }, + { "gobject", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", gobjectCommandTable }, + { "guild", PERM_HIGH_GMT, PERM_CONSOLE, true, NULL, "", guildCommandTable }, + { "honor", PERM_HIGH_GMT, PERM_CONSOLE, false, NULL, "", honorCommandTable }, + { "instance", PERM_GMT_DEV, PERM_CONSOLE, true, NULL, "", instanceCommandTable }, + { "learn", PERM_GMT, PERM_CONSOLE, false, NULL, "", learnCommandTable }, + { "list", PERM_ADM, PERM_CONSOLE, true, NULL, "", listCommandTable }, + { "lookup", PERM_GMT, PERM_CONSOLE, true, NULL, "", lookupCommandTable }, + { "modify", PERM_GMT, PERM_CONSOLE, false, NULL, "", modifyCommandTable }, + { "mmap", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", mmapCommandTable }, + { "npc", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", npcCommandTable }, + { "path", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", wpCommandTable }, + { "pet", PERM_GMT, PERM_CONSOLE, false, NULL, "", petCommandTable }, + { "quest", PERM_HIGH_GMT, PERM_CONSOLE, false, NULL, "", questCommandTable }, + { "reload", PERM_ADM, PERM_CONSOLE, true, NULL, "", reloadCommandTable }, + { "reset", PERM_ADM, PERM_CONSOLE, false, NULL, "", resetCommandTable }, + { "send", PERM_GMT, PERM_CONSOLE, true, NULL, "", sendCommandTable }, + { "server", PERM_ADM, PERM_CONSOLE, true, NULL, "", serverCommandTable }, + { "tele", PERM_GMT_DEV, PERM_CONSOLE, true, NULL, "", teleCommandTable }, + { "ticket", PERM_GMT, PERM_CONSOLE, false, NULL, "", ticketCommandTable }, + { "unban", PERM_GMT, PERM_CONSOLE, true, NULL, "", unbanCommandTable }, + { "wp", PERM_GMT_DEV, PERM_CONSOLE, false, NULL, "", wpCommandTable }, + { "cheat", PERM_GMT, PERM_CONSOLE, false, NULL, "", cheatCommandTable }, + + { "additem", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleAddItemCommand, "", NULL }, + { "additemset", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleAddItemSetCommand, "", NULL }, + { "allowmove", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleAllowMovementCommand, "", NULL }, + { "announce", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleAnnounceCommand, "", NULL }, + { "aura", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleAuraCommand, "", NULL }, + { "bank", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleBankCommand, "", NULL }, + { "bindfollow", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleBindFollowCommand, "", NULL }, + { "bindsight", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleBindSightCommand, "", NULL }, + { "cd", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleCooldownCommand, "", NULL }, + { "chardelete", PERM_CONSOLE, PERM_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, + { "combatstop", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, + { "cometome", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, + { "commands", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleCommandsCommand, "", NULL }, + { "cooldown", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleCooldownCommand, "", NULL }, + { "damage", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDamageCommand, "", NULL }, + { "demorph", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleDeMorphCommand, "", NULL }, + { "die", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleDieCommand, "", NULL }, + { "dismount", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleDismountCommand, "", NULL }, + { "distance", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGetDistanceCommand, "", NULL }, + //{ "flusharenapoints",PERM_CONSOLE, PERM_CONSOLE, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, + { "freeze", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleFreezeCommand, "", NULL }, + { "goname", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGonameCommand, "", NULL }, + { "gps", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGPSCommand, "", NULL }, + { "info", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleInfoCommand, "", NULL }, + { "groupgo", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleGroupgoCommand, "", NULL }, + { "guid", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleGUIDCommand, "", NULL }, + { "hdevannounce", PERM_HEAD_DEVELOPER,PERM_CONSOLE, false,&ChatHandler::HandleHDevAnnounceCommand, "", NULL }, + { "help", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleHelpCommand, "", NULL }, + { "hidearea", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleHideAreaCommand, "", NULL }, + { "hover", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleHoverCommand, "", NULL }, + { "itemmove", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleItemMoveCommand, "", NULL }, + { "kick", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleKickPlayerCommand, "", NULL }, + { "levelup", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleLevelUpCommand, "", NULL }, + { "linkgrave", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleLinkGraveCommand, "", NULL }, + { "listfreeze", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleListFreezeCommand, "", NULL }, + { "loadscripts", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, + { "lockaccount", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleLockAccountCommand, "", NULL }, + { "movegens", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleMovegensCommand, "", NULL }, + { "mute", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleMuteCommand, "", NULL }, + { "muteinfo", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleMuteInfoCommand, "", NULL }, + { "nameannounce", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNameAnnounceCommand, "", NULL }, + { "namego", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleNamegoCommand, "", NULL }, + { "neargrave", PERM_GMT_DEV, PERM_CONSOLE, false, &ChatHandler::HandleNearGraveCommand, "", NULL }, + { "notify", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleNotifyCommand, "", NULL }, + { "password", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandlePasswordCommand, "", NULL }, + { "pinfo", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandlePInfoCommand, "", NULL }, + { "playall", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandlePlayAllCommand, "", NULL }, + { "plimit", PERM_ADM, PERM_CONSOLE, true, &ChatHandler::HandlePLimitCommand, "", NULL }, + { "recall", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleRecallCommand, "", NULL }, + { "rename", PERM_HIGH_GMT, PERM_CONSOLE, true, &ChatHandler::HandleRenameCommand, "", NULL }, + { "respawn", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleRespawnCommand, "", NULL }, + { "revive", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleReviveCommand, "", NULL }, + { "revivegroup", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleReviveGroupCommand, "", NULL }, + { "save", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleSaveCommand, "", NULL }, + { "setskill", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleSetSkillCommand, "", NULL }, + { "showarea", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleShowAreaCommand, "", NULL }, + { "start", PERM_PLAYER, PERM_CONSOLE, false, &ChatHandler::HandleStartCommand, "", NULL }, + { "trollmute", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleTrollmuteCommand, "", NULL }, + { "trollmuteinfo", PERM_HIGH_GMT, PERM_CONSOLE, false, &ChatHandler::HandleTrollmuteInfoCommand, "", NULL }, + { "unaura", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnAuraCommand, "", NULL }, + { "unbindfollow", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnbindFollowCommand, "", NULL }, + { "unbindsight", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnbindSightCommand, "", NULL }, + { "unfreeze", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnFreezeCommand, "", NULL }, + { "unlearn", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleUnLearnCommand, "", NULL }, + { "unmute", PERM_GMT, PERM_CONSOLE, true, &ChatHandler::HandleUnmuteCommand, "", NULL }, + { "wchange", PERM_ADM, PERM_CONSOLE, false, &ChatHandler::HandleChangeWeather, "", NULL }, + { "weather", PERM_PLAYER, PERM_CONSOLE, true, &ChatHandler::HandleAccountWeatherCommand, "", NULL }, + { "whispers", PERM_GMT, PERM_CONSOLE, false, &ChatHandler::HandleWhispersCommand, "", NULL }, + + { NULL, 0, 0, false, NULL, "", NULL } }; if (load_command_table) { load_command_table = false; - QueryResultAutoPtr result = GameDataDatabase.Query("SELECT name, permission_mask, help FROM command"); + QueryResultAutoPtr result = GameDataDatabase.Query("SELECT name, permission_mask, self_mask, help FROM command"); if (result) { do @@ -755,7 +796,8 @@ ChatCommand * ChatHandler::getCommandTable() if (name == commandTable[i].Name) { commandTable[i].RequiredPermissions = fields[1].GetUInt64(); - commandTable[i].Help = fields[2].GetCppString(); + commandTable[i].SelfPermissions = fields[2].GetUInt64(); + commandTable[i].Help = fields[3].GetCppString(); } if (commandTable[i].ChildCommands != NULL) { @@ -767,7 +809,8 @@ ChatCommand * ChatHandler::getCommandTable() name == fmtstring("%s %s", commandTable[i].Name, ptable[j].Name)) { ptable[j].RequiredPermissions = fields[1].GetUInt64(); - ptable[j].Help = fields[2].GetCppString(); + ptable[j].SelfPermissions = fields[2].GetUInt64(); + ptable[j].Help = fields[3].GetCppString(); } } } @@ -780,15 +823,15 @@ ChatCommand * ChatHandler::getCommandTable() return commandTable; } -const char *ChatHandler::GetTrinityString(int32 entry) const +const char *ChatHandler::GetHellgroundString(int32 entry) const { - return m_session->GetTrinityString(entry); + return m_session->GetHellgroundString(entry); } -bool ChatHandler::isAvailable(ChatCommand const& cmd) const +bool ChatHandler::isAvailable(ChatCommand const& cmd, bool self) const { // check security level only for simple command (without child commands) - return m_session->GetPermissions() & cmd.RequiredPermissions; + return m_session->HasPermissions(self ? cmd.SelfPermissions : cmd.RequiredPermissions); } bool ChatHandler::hasStringAbbr(const char* name, const char* part) @@ -853,7 +896,7 @@ void ChatHandler::SendGlobalSysMessage(const char *str) void ChatHandler::SendGlobalGMSysMessage(int32 entry, ...) { - const char *format = GetTrinityString(entry); + const char *format = GetHellgroundString(entry); va_list ap; char str [1024]; va_start(ap, entry); @@ -881,12 +924,12 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str) void ChatHandler::SendSysMessage(int32 entry) { - SendSysMessage(GetTrinityString(entry)); + SendSysMessage(GetHellgroundString(entry)); } void ChatHandler::PSendSysMessage(int32 entry, ...) { - const char *format = GetTrinityString(entry); + const char *format = GetHellgroundString(entry); va_list ap; char str [1024]; va_start(ap, entry); @@ -905,7 +948,7 @@ void ChatHandler::PSendSysMessage(const char *format, ...) SendSysMessage(str); } -bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcmd) +bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, std::string& fullcmd) { char const* oldtext = text; std::string cmd = ""; @@ -922,10 +965,11 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co { if (!hasStringAbbr(table[i].Name, cmd.c_str())) continue; - + fullcmd += table[i].Name; // select subcommand from child commands list if (table[i].ChildCommands != NULL) { + fullcmd += " "; if (!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd)) { if (text && text[0] != '\0') @@ -940,25 +984,38 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co } // must be available and have handler - if (!table[i].Handler || !isAvailable(table[i])) + if (!isAvailable(table[i],false)) + { + if(isAvailable(table[i],true)) + m_session->GetPlayer()->SetSelection(m_session->GetPlayer()->GetGUID()); + else + continue; + } + if (!table[i].Handler) continue; SetSentErrorMessage(false); // table[i].Name == "" is special case: send original command to handler + std::string args = strlen(table[i].Name )!=0 ? std::string(" ") + text : oldtext; if ((this->*(table[i].Handler))(strlen(table[i].Name)!=0 ? text : oldtext)) { - if (table[i].RequiredPermissions & sWorld.getConfig(CONFIG_MIN_GM_COMMAND_LOG_LEVEL)) + if (m_session && (m_session->GetPermissions() & sWorld.getConfig(CONFIG_COMMAND_LOG_PERMISSION)) && table[i].Name != "password") { - // chat case - if (m_session) - { - Player* p = m_session->GetPlayer(); - uint64 sel_guid = p->GetSelection(); - if (table[i].Name != "password") - sLog.outCommand(m_session->GetAccountId(),"Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: (GUID: %u)]", - fullcmd.c_str(),p->GetName(),m_session->GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(), - GUID_LOPART(sel_guid)); - } + Player* p = m_session->GetPlayer(); + uint64 sel_guid = p->GetSelection(); + Unit* unit = p->GetUnit(sel_guid); + char sel_string[100]; + if(sel_guid && unit) + sprintf(sel_string,"%s (GUID:%u)",unit->GetName(), GUID_LOPART(sel_guid)); + else if (sel_guid) + sprintf(sel_string,"(GUID:%u)", GUID_LOPART(sel_guid)); + else + sprintf(sel_string,"NONE"); + + sLog.outCommand(m_session->GetAccountId(),"Command: %s%s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s]", + fullcmd.c_str(),args .c_str(), + p->GetName(),m_session->GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(), + sel_string); } } // some commands have custom error messages. Don't send the default one in these cases. @@ -991,8 +1048,7 @@ int ChatHandler::ParseCommands(const char* text) ASSERT(text); ASSERT(*text); - std::string fullcmd = text; - + std::string fullcmd = ""; /// chat case (.command format) if (m_session) { @@ -1015,7 +1071,7 @@ int ChatHandler::ParseCommands(const char* text) if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { - if (m_session && !(m_session->GetPermissions() & PERM_GMT)) + if (m_session && !m_session->HasPermissions(PERM_GMT)) return 0; SendSysMessage(LANG_NO_CMD); } @@ -1028,7 +1084,7 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, ch for (uint32 i = 0; table[i].Name != NULL; ++i) { // must be available (ignore handler existence for show command with possibe avalable subcomands - if (!isAvailable(table[i])) + if (!isAvailable(table[i],false) && !isAvailable(table[i],true)) continue; /// for empty subcmd show all available @@ -1067,7 +1123,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd) for (uint32 i = 0; table[i].Name != NULL; ++i) { // must be available (ignore handler existence for show command with possibe avalable subcomands - if (!isAvailable(table[i])) + if (!isAvailable(table[i],false) && !isAvailable(table[i],true)) continue; if (!hasStringAbbr(table[i].Name, cmd)) @@ -1097,7 +1153,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd) for (uint32 i = 0; table[i].Name != NULL; ++i) { // must be available (ignore handler existence for show command with possibe avalable subcomands - if (!isAvailable(table[i])) + if (!isAvailable(table[i],false) && !isAvailable(table[i],true)) continue; if (strlen(table[i].Name)) @@ -1428,7 +1484,7 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text) // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r char* cId = extractKeyFromLink(text,"Htele"); if (!cId) - return false; + return NULL; // id case (explicit or from shift link) if (cId[0] >= '0' || cId[0] >= '9') @@ -1449,12 +1505,12 @@ bool ChatHandler::needReportToTarget(Player* chr) const return pl != chr && pl->IsVisibleGloballyfor (chr); } -const char *CliHandler::GetTrinityString(int32 entry) const +const char *CliHandler::GetHellgroundString(int32 entry) const { - return sObjectMgr.GetTrinityStringForDBCLocale(entry); + return sObjectMgr.GetHellgroundStringForDBCLocale(entry); } -bool CliHandler::isAvailable(ChatCommand const& cmd) const +bool CliHandler::isAvailable(ChatCommand const& cmd, bool) const { // skip non-console commands in console case return cmd.AllowConsole; @@ -1468,7 +1524,7 @@ void CliHandler::SendSysMessage(const char *str) const char *CliHandler::GetName() const { - return GetTrinityString(LANG_CONSOLE_COMMAND); + return GetHellgroundString(LANG_CONSOLE_COMMAND); } bool CliHandler::needReportToTarget(Player* /*chr*/) const @@ -1520,7 +1576,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G return true; } -std::string ChatHandler::GetNameLink(std::string & name) +std::string ChatHandler::GetNameLink(const std::string & name) { return "|Hplayer:" + name + "|h[" + name + "]|h"; } diff --git a/src/game/Chat.h b/src/game/Chat.h old mode 100755 new mode 100644 index ecbe5a910..bae990993 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_CHAT_H -#define TRINITYCORE_CHAT_H +#ifndef HELLGROUND_CHAT_H +#define HELLGROUND_CHAT_H #include "SharedDefines.h" @@ -35,6 +35,7 @@ class ChatCommand public: const char * Name; uint64 RequiredPermissions; // function pointer required correct align (use uint32) + uint64 SelfPermissions; bool AllowConsole; bool (ChatHandler::*Handler)(const char* args); std::string Help; @@ -61,9 +62,9 @@ class ChatHandler } static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } - static std::string GetNameLink(std::string & name); + static std::string GetNameLink(const std::string & name); - virtual const char *GetTrinityString(int32 entry) const; + virtual const char *GetHellgroundString(int32 entry) const; virtual void SendSysMessage( const char *str); void SendSysMessage( int32 entry); @@ -82,7 +83,7 @@ class ChatHandler bool hasStringAbbr(const char* name, const char* part); - virtual bool isAvailable(ChatCommand const& cmd) const; + virtual bool isAvailable(ChatCommand const& cmd, bool self) const; virtual bool needReportToTarget(Player* chr) const; void SendGlobalSysMessage(const char *str); @@ -91,7 +92,7 @@ class ChatHandler bool SendGMMail(const char* pName, const char* msgSubject, const char* msgText); - bool ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcommand); + bool ExecuteCommandInTable(ChatCommand *table, const char* text, std::string& fullcommand); bool ShowHelpForCommand(ChatCommand *table, const char* cmd); bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); @@ -100,7 +101,7 @@ class ChatHandler bool HandleAccountDeleteCommand(const char* args); bool HandleAccountOnlineListCommand(const char* args); bool HandleAccountSetAddonCommand(const char* args); - bool HandleAccountSetGmLevelCommand(const char* args); + bool HandleAccountSetPermissionsCommand(const char* args); bool HandleAccountSetPasswordCommand(const char* args); bool HandleAccountWeatherCommand(const char*args); bool HandleAccountSpecialLogCommand(const char* args); @@ -109,6 +110,9 @@ class ChatHandler bool HandleAccountBonesHideCommand(const char* args); bool HandleAccountXPToggleCommand(const char* args); bool HandleAccountBattleGroundAnnCommand(const char* args); + bool HandleAccountAnnounceBroadcastCommand(const char* args); + + bool HandleArenaReadyCommand(const char* args); bool HandleBanAccountCommand(const char* args); bool HandleBanCharacterCommand(const char* args); @@ -181,10 +185,15 @@ class ChatHandler bool HandleGameObjectGridCommand(const char* args); bool HandleGameObjectMoveCommand(const char* args); bool HandleGameObjectNearCommand(const char* args); + bool HandleGameObjectResetCommand(const char* args); bool HandleGameObjectStateCommand(const char* args); bool HandleGameObjectTargetCommand(const char* args); bool HandleGameObjectTurnCommand(const char* args); + bool HandleAccountFriendAddCommand(const char* args); + bool HandleAccountFriendDeleteCommand(const char* args); + bool HandleAccountFriendListCommand(const char* args); + bool HandleGMAnnounceCommand(const char* args); bool HandleGMCommand(const char* args); bool HandleGMChatCommand(const char* args); @@ -281,7 +290,9 @@ class ChatHandler bool HandleNpcAddMoveCommand(const char* args); bool HandleNpcChangeEntryCommand(const char *args); bool HandleNpcDeleteCommand(const char* args); + bool HandleNpcExtraFlagCommand(const char* args); bool HandleNpcFactionIdCommand(const char* args); + bool HandleNpcFieldFlagCommand(const char* args); bool HandleNpcFlagCommand(const char* args); bool HandleNpcFollowCommand(const char* args); bool HandleNpcInfoCommand(const char* args); @@ -292,6 +303,7 @@ class ChatHandler bool HandleNpcSetMoveTypeCommand(const char* args); bool HandleNpcSpawnDistCommand(const char* args); bool HandleNpcSpawnTimeCommand(const char* args); + bool HandleNpcStandState(const char* args); bool HandleNpcTameCommand(const char* args); bool HandleNpcTextEmoteCommand(const char* args); bool HandleNpcUnFollowCommand(const char* args); @@ -308,6 +320,7 @@ class ChatHandler bool HandleQuestRemove(const char * args); bool HandleQuestComplete(const char * args); + bool HandleReloadElunaCommand(const char* args); bool HandleReloadCommand(const char* args); bool HandleReloadAllCommand(const char* args); bool HandleReloadAllAreaCommand(const char* args); @@ -362,7 +375,7 @@ class ChatHandler bool HandleReloadReputationRewardRateCommand(const char* args); bool HandleReloadReputationSpilloverTemplateCommand(const char* args); bool HandleReloadSkillDiscoveryTemplateCommand(const char* args); - bool HandleReloadSkillExtraItemTemplateCommand(const char* args); + bool HandleReloadSkillExtraItemPrototypeCommand(const char* args); bool HandleReloadSkillFishingBaseLevelCommand(const char* args); bool HandleReloadSpellAffectCommand(const char* args); bool HandleReloadSpellRequiredCommand(const char* args); @@ -411,11 +424,11 @@ class ChatHandler bool HandleServerMuteCommand(const char* args); bool HandleServerRestartCommand(const char* args); bool HandleServerSetMotdCommand(const char* args); - bool HandleServerSetLogLevelCommand(const char* args); bool HandleServerSetDiffTimeCommand(const char* args); bool HandleServerShutDownCommand(const char* args); bool HandleServerRollShutDownCommand(const char* args); bool HandleServerShutDownCancelCommand(const char* args); + bool HandleServerPVPCommand(const char* args); bool HandleTeleCommand(const char * args); bool HandleTeleAddCommand(const char * args); @@ -455,6 +468,7 @@ class ChatHandler bool HandleTaxiCheatCommand(const char* args); bool HandleWhispersCommand(const char* args); bool HandleModifyDrunkCommand(const char* args); + bool HandleHDevAnnounceCommand(const char* args); bool HandleLoadScriptsCommand(const char* args); @@ -470,6 +484,7 @@ class ChatHandler bool HandleNpcDelItemCommand(const char* args); bool HandleNpcChangeLevelCommand(const char* args); bool HandleGoCreatureCommand(const char* args); + bool HandleGoCreatureDirectCommand(const char* args); bool HandleGoObjectCommand(const char* args); bool HandleGoTicketCommand(const char* args); bool HandleGoTriggerCommand(const char* args); @@ -477,6 +492,8 @@ class ChatHandler bool HandlePInfoCommand(const char* args); bool HandlePLimitCommand(const char* args); bool HandleMuteCommand(const char* args); + bool HandleTrollmuteCommand(const char* args); + bool HandleTrollmuteInfoCommand(const char* args); bool HandleUnmuteCommand(const char* args); bool HandleMuteInfoCommand(const char* args); bool HandleMovegensCommand(const char* args); @@ -528,6 +545,9 @@ class ChatHandler bool HandleChangeWeather(const char* args); bool HandleKickPlayerCommand(const char * args); + bool HandleCheatGodmodeCommand(const char* args); + bool HandleCheatPowerCommand(const char* args); + // GM ticket command handlers bool HandleGMTicketListCommand(const char* args); bool HandleGMTicketListOnlineCommand(const char* args); @@ -560,7 +580,7 @@ class ChatHandler //! Development Commands bool HandleSet32Bit(const char* args); - bool HandleDebugHostilRefList(const char * args); + bool HandleDebugHostileRefList(const char * args); bool HandlePossessCommand(const char* args); bool HandleUnPossessCommand(const char* args); bool HandleBindSightCommand(const char* args); @@ -611,8 +631,8 @@ class CliHandler : public ChatHandler explicit CliHandler(Print* zprint) : m_print(zprint) {} // overwrite functions - const char *GetTrinityString(int32 entry) const; - bool isAvailable(ChatCommand const& cmd) const; + const char *GetHellgroundString(int32 entry) const; + bool isAvailable(ChatCommand const& cmd, bool) const; void SendSysMessage(const char *str); char const* GetName() const; bool needReportToTarget(Player* chr) const; diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 2db42099e..baf158114 100755 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -39,6 +39,8 @@ #include "Util.h" #include "GridNotifiersImpl.h" #include "CellImpl.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" enum ChatDenyMask { @@ -129,7 +131,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } // mass mute for players check - if (!(GetPermissions() & PERM_GMT) && sWorld.GetMassMuteTime() && sWorld.GetMassMuteTime() > time(NULL)) + if (!HasPermissions(PERM_GMT) && sWorld.GetMassMuteTime() && sWorld.GetMassMuteTime() > time(NULL)) { if (sWorld.GetMassMuteReason()) ChatHandler(_player).PSendSysMessage("Mass mute reason: %s", sWorld.GetMassMuteReason()); @@ -184,7 +186,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (lang != LANG_ADDON) { std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); - SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); + SendNotification(GetHellgroundString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); ChatHandler(_player).PSendSysMessage(LANG_YOUR_CHAT_IS_DISABLED, timeStr.c_str(), m_muteReason.c_str()); } @@ -245,12 +247,19 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } } + // used by eluna + if (!sHookMgr->OnChat(GetPlayer(), type, lang, msg)) + return; + switch (type) { case CHAT_MSG_SAY: case CHAT_MSG_EMOTE: case CHAT_MSG_YELL: { + if (!_player->isAlive()) + return; + // strip invisible characters for non-addon messages if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) stripLineInvisibleChars(msg); @@ -261,13 +270,22 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (ChatHandler(this).ContainsNotAllowedSigns(msg)) return; - if (type == CHAT_MSG_SAY) - GetPlayer()->Say(msg, lang); - else if (type == CHAT_MSG_EMOTE) - GetPlayer()->TextEmote(msg); - else if (type == CHAT_MSG_YELL) - GetPlayer()->Yell(msg, lang); - } break; + switch (type) + { + case CHAT_MSG_SAY: + GetPlayer()->Say(msg, lang); + break; + case CHAT_MSG_EMOTE: + GetPlayer()->TextEmote(msg); + break; + case CHAT_MSG_YELL: + GetPlayer()->Yell(msg, lang); + break; + default: + break; + } + } + break; case CHAT_MSG_WHISPER: { @@ -290,9 +308,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } Player *player = sObjectMgr.GetPlayer(to.c_str()); - uint64 tPermissions = GetPermissions(); - uint64 pPermissions = player ? player->GetSession()->GetPermissions() : 0; - if (!player || (!(tPermissions & PERM_GMT) && !(pPermissions & PERM_GMT) && !player->isAcceptWhispers())) + if (!player || + ( player->GetSession()->HasPermissions(PERM_GMT) && !HasPermissions(PERM_GMT_HDEV) && + !player->isAcceptWhispers() && !GetPlayer()->canWhisperToGM()) + ) { WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, (to.size()+1)); data<GetSession()->HasPermissions(PERM_GMT_HDEV)) { uint32 sidea = GetPlayer()->GetTeam(); uint32 sideb = player->GetTeam(); @@ -314,7 +333,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } GetPlayer()->Whisper(msg, lang,player->GetGUID()); - } break; + } + break; case CHAT_MSG_PARTY: { @@ -351,7 +371,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (GetPlayer()->GetGuildId()) { - Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (guild) guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); } @@ -373,7 +393,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (GetPlayer()->GetGuildId()) { - Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (guild) guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); } @@ -499,7 +519,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (!_player->isAFK()) { if (msg.empty()) - msg = GetTrinityString(LANG_PLAYER_AFK_DEFAULT); + msg = GetHellgroundString(LANG_PLAYER_AFK_DEFAULT); _player->afkMsg = msg; } _player->ToggleAFK(); @@ -515,7 +535,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (!_player->isDND()) { if (msg.empty()) - msg = GetTrinityString(LANG_PLAYER_DND_DEFAULT); + msg = GetHellgroundString(LANG_PLAYER_DND_DEFAULT); _player->dndMsg = msg; } _player->ToggleDND(); @@ -538,6 +558,10 @@ void WorldSession::HandleEmoteOpcode(WorldPacket & recv_data) uint32 emote; recv_data >> emote; + + // used by eluna + sHookMgr->OnEmote(GetPlayer(), emote); + GetPlayer()->HandleEmoteCommand(emote); } @@ -582,7 +606,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) if (!player->CanSpeak()) { std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); - SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); + SendNotification(GetHellgroundString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str()); ChatHandler(player).PSendSysMessage(LANG_YOUR_CHAT_IS_DISABLED, timeStr.c_str(), m_muteReason.c_str()); return; } @@ -633,6 +657,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) sScriptMgr.OnReceiveEmote(GetPlayer(), (Creature*)unit, text_emote); } + + // used by eluna + sHookMgr->OnTextEmote(GetPlayer(), text_emote, emoteNum, guid); } void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data) diff --git a/src/game/CombatAI.cpp b/src/game/CombatAI.cpp index 222de5c60..7c11f03c7 100644 --- a/src/game/CombatAI.cpp +++ b/src/game/CombatAI.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,7 +61,7 @@ void CombatAI::Reset() void CombatAI::JustDied(Unit *killer) { for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i) - if (AISpellInfo[*i].condition == AICOND_DIE) + if (AISpellEntry[*i].condition == AICOND_DIE) me->CastSpell(killer, *i, true); } @@ -69,10 +69,10 @@ void CombatAI::EnterCombat(Unit *who) { for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i) { - if (AISpellInfo[*i].condition == AICOND_AGGRO) + if (AISpellEntry[*i].condition == AICOND_AGGRO) me->CastSpell(who, *i, false); - else if (AISpellInfo[*i].condition == AICOND_COMBAT) - events.ScheduleEvent(*i, AISpellInfo[*i].cooldown + rand()%AISpellInfo[*i].cooldown); + else if (AISpellEntry[*i].condition == AICOND_COMBAT) + events.ScheduleEvent(*i, AISpellEntry[*i].cooldown + rand()%AISpellEntry[*i].cooldown); } } @@ -89,7 +89,7 @@ void CombatAI::UpdateAI(const uint32 diff) if (uint32 spellId = events.ExecuteEvent()) { DoCast(spellId); - events.ScheduleEvent(spellId, AISpellInfo[spellId].cooldown + rand()%AISpellInfo[spellId].cooldown); + events.ScheduleEvent(spellId, AISpellEntry[spellId].cooldown + rand()%AISpellEntry[spellId].cooldown); } else DoMeleeAttackIfReady(); @@ -106,8 +106,8 @@ void CasterAI::InitializeAI() float m_attackDist = 30.0f; for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr) - if (AISpellInfo[*itr].condition == AICOND_COMBAT && m_attackDist > GetAISpellInfo(*itr)->maxRange) - m_attackDist = GetAISpellInfo(*itr)->maxRange; + if (AISpellEntry[*itr].condition == AICOND_COMBAT && m_attackDist > GetAISpellEntry(*itr)->maxRange) + m_attackDist = GetAISpellEntry(*itr)->maxRange; if (m_attackDist == 30.0f) m_attackDist = MELEE_RANGE; } @@ -121,11 +121,11 @@ void CasterAI::EnterCombat(Unit *who) uint32 count = 0; for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count) { - if (AISpellInfo[*itr].condition == AICOND_AGGRO) + if (AISpellEntry[*itr].condition == AICOND_AGGRO) me->CastSpell(who, *itr, false); - else if (AISpellInfo[*itr].condition == AICOND_COMBAT) + else if (AISpellEntry[*itr].condition == AICOND_COMBAT) { - uint32 cooldown = GetAISpellInfo(*itr)->realCooldown; + uint32 cooldown = GetAISpellEntry(*itr)->realCooldown; if (count == spell) { DoCast(spells[spell]); @@ -150,6 +150,6 @@ void CasterAI::UpdateAI(const uint32 diff) { DoCast(spellId); uint32 casttime = me->GetCurrentSpellCastTime(spellId); - events.ScheduleEvent(spellId, (casttime ? casttime : 500) + GetAISpellInfo(spellId)->realCooldown); + events.ScheduleEvent(spellId, (casttime ? casttime : 500) + GetAISpellEntry(spellId)->realCooldown); } } \ No newline at end of file diff --git a/src/game/CombatAI.h b/src/game/CombatAI.h index 8a7166ca0..f9cfeddc0 100644 --- a/src/game/CombatAI.h +++ b/src/game/CombatAI.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp index eab93c3e8..6b26e2cc6 100755 --- a/src/game/CombatHandler.cpp +++ b/src/game/CombatHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 50f3e2de9..96016eb02 100755 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,7 +69,15 @@ bool ConfusedMovementGenerator::Update(UNIT &unit, const uint32 &diff) uint32 nextMove = urand(0, MAX_RANDOM_POINTS-1); Movement::MoveSplineInit init(unit); - init.MoveTo(_randomPosition[nextMove].x, _randomPosition[nextMove].y, _randomPosition[nextMove].z); + + PathFinder path(&unit); + path.setPathLengthLimit(30.0f); + bool result = path.calculate(_randomPosition[nextMove].x, _randomPosition[nextMove].y, _randomPosition[nextMove].z); + if (!result || path.getPathType() & PATHFIND_NOPATH) + init.MoveTo(_randomPosition[nextMove].x, _randomPosition[nextMove].y, _randomPosition[nextMove].z); + else + init.MovebyPath(path.getPath()); + init.SetWalk(true); init.Launch(); diff --git a/src/game/ConfusedMovementGenerator.h b/src/game/ConfusedMovementGenerator.h index 276407a5b..22bd26b72 100755 --- a/src/game/ConfusedMovementGenerator.h +++ b/src/game/ConfusedMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef HELLGROUND_CONFUSEDGENERATOR_H -#define HELLGROUND_CONFUSEDGENERATOR_H +#ifndef HELLGROUND_CONFUSEDMOVEMENTGENERATOR_H +#define HELLGROUND_CONFUSEDMOVEMENTGENERATOR_H #include "MovementGenerator.h" @@ -48,6 +48,7 @@ class HELLGROUND_EXPORT ConfusedMovementGenerator : public MovementGeneratorMedi void _generateMovement(UNIT &unit); TimeTrackerSmall _nextMoveTime; + Position _randomPosition[MAX_RANDOM_POINTS+1]; }; diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 5c157ca3c..cd81d1fb2 100755 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Corpse.h b/src/game/Corpse.h index e5641ee9d..3c3906340 100755 --- a/src/game/Corpse.h +++ b/src/game/Corpse.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_CORPSE_H -#define TRINITYCORE_CORPSE_H +#ifndef HELLGROUND_CORPSE_H +#define HELLGROUND_CORPSE_H #include "Object.h" #include "Database/DatabaseEnv.h" diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index bf483ab0d..d247c6737 100755 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -148,7 +148,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } Creature::Creature() : -Unit(), m_aggroRange(0.0), +Unit(), m_aggroRange(0.0), m_ignoreSelection (false), lootForPickPocketed(false), lootForBody(false), m_lootMoney(0), m_lootRecipient(0), m_deathTimer(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_gossipOptionLoaded(false), m_isPet(false), m_isTotem(false), m_reactState(REACT_AGGRESSIVE), @@ -159,6 +159,7 @@ m_tempSummon(false) { m_regenTimer = 2000; m_valuesCount = UNIT_END; + m_xpMod = 0; for (int i =0; i < CREATURE_MAX_SPELLS; ++i) m_spells[i] = 0; @@ -572,6 +573,15 @@ void Creature::Update(uint32 update_diff, uint32 diff) IsAIEnabled = true; } + if (!(isTotem() || isPet() || IsTemporarySummon() || IS_CREATURE_GUID(GetOwnerGUID()) && GetOwner()->ToCreature()->isTotem()) && GetMap() && !GetMap()->IsDungeon() && !AI()->IsEscorted() && + GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE && + GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) + { + uint32 distToHome = sWorld.getConfig(CONFIG_EVADE_HOMEDIST) * 3; + if (!IsWithinDistInMap(&homeLocation, distToHome)) + AI()->EnterEvadeMode(); + } + if (!IsInEvadeMode() && IsAIEnabled) { // do not allow the AI to be changed during update @@ -643,7 +653,7 @@ void Creature::RegenerateMana() { if (!IsUnderLastManaUseEffect()) { - float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); + float ManaIncreaseRate = sWorld.getConfig(RATE_POWER_MANA); float Spirit = GetStat(STAT_SPIRIT); addvalue = uint32((Spirit/5.0f + 17.0f) * ManaIncreaseRate); @@ -674,7 +684,7 @@ void Creature::RegenerateHealth() // Not only pet, but any controlled creature if (GetCharmerOrOwnerGUID()) { - float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); + float HealthIncreaseRate = sWorld.getConfig(RATE_HEALTH); float Spirit = GetStat(STAT_SPIRIT); if (GetPower(POWER_MANA) > 0) @@ -1237,6 +1247,8 @@ void Creature::SetLootRecipient(Unit *unit) if (!unit) { + loot.RemoveSavedLootFromDB(); + m_lootRecipient = 0; m_playersAllowedToLoot.clear(); @@ -1378,7 +1390,9 @@ void Creature::SelectLevel(const CreatureInfo *cinfo) uint32 minhealth = std::min(cinfo->maxhealth, cinfo->minhealth); uint32 maxhealth = std::max(cinfo->maxhealth, cinfo->minhealth); - uint32 health = uint32(healthmod * (minhealth + uint32(rellevel*(maxhealth - minhealth)))); + uint32 health = (rellevel == 0 ? uint32(healthmod * urand(minhealth, maxhealth)) : uint32(healthmod * (minhealth + uint32(rellevel*(maxhealth - minhealth))))); + if (health < 1) + health = 1; SetCreateHealth(health); SetMaxHealth(health); @@ -1419,17 +1433,17 @@ float Creature::_GetHealthMod(int32 Rank) switch (Rank) // define rates for each elite rank { case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_HP); + return sWorld.getConfig(RATE_CREATURE_NORMAL_HP); case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_HP); case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_HP); + return sWorld.getConfig(RATE_CREATURE_ELITE_RAREELITE_HP); case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_HP); + return sWorld.getConfig(RATE_CREATURE_ELITE_WORLDBOSS_HP); case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_HP); + return sWorld.getConfig(RATE_CREATURE_ELITE_RARE_HP); default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_HP); } } @@ -1438,17 +1452,17 @@ float Creature::_GetDamageMod(int32 Rank) switch (Rank) // define rates for each elite rank { case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_NORMAL_DAMAGE); case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_DAMAGE); case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_RAREELITE_DAMAGE); case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE); case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_RARE_DAMAGE); default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_DAMAGE); } } @@ -1457,17 +1471,17 @@ float Creature::GetSpellDamageMod(int32 Rank) switch (Rank) // define rates for each elite rank { case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_NORMAL_SPELLDAMAGE); case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE); case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE); case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_RARE_SPELLDAMAGE); default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); + return sWorld.getConfig(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); } } @@ -1552,8 +1566,26 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) // checked at creature_template loading m_defaultMovementType = MovementGeneratorType(data->movementType); + + + if (CreatureInfo const* info = sObjectMgr.GetCreatureTemplate(data->id)) + m_xpMod = info->xpMod; + else + m_xpMod = 0.0f; m_creatureData = data; + + // check if it is rabbit day + if (isAlive() && sWorld.getConfig(CONFIG_RABBIT_DAY)) + { + time_t rabbit_day = time_t(sWorld.getConfig(CONFIG_RABBIT_DAY)); + tm rabbit_day_tm = *localtime(&rabbit_day); + tm now_tm = *localtime(&sWorld.GetGameTime()); + + if (now_tm.tm_mon == rabbit_day_tm.tm_mon && now_tm.tm_mday == rabbit_day_tm.tm_mday) + CastSpell(this, 10710 + urand(0, 2), true); + } + return true; } @@ -1696,6 +1728,7 @@ bool Creature::IsWithinSightDist(Unit const* u) const bool Creature::canStartAttack(Unit const* who) const { if (isCivilian() + || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE) || !who->isInAccessiblePlacefor (this) || (!CanFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) || !IsWithinDistInMap(who, GetAttackDistance(who))) @@ -1712,7 +1745,7 @@ bool Creature::canStartAttack(Unit const* who) const float Creature::GetAttackDistance(Unit const* pl) const { - float aggroRate = sWorld.getRate(isGuard() ? RATE_CREATURE_GUARD_AGGRO : RATE_CREATURE_AGGRO); + float aggroRate = sWorld.getConfig(isGuard() ? RATE_CREATURE_GUARD_AGGRO : RATE_CREATURE_AGGRO); if (aggroRate==0) return 0.0f; @@ -1779,6 +1812,9 @@ void Creature::setDeathState(DeathState s) //Dismiss group if is leader if (m_formation && m_formation->getLeader() == this) m_formation->FormationReset(true); + + if (m_zoneScript) + m_zoneScript->OnCreatureDeath(this); } Unit::setDeathState(s); @@ -1829,6 +1865,9 @@ void Creature::setDeathState(DeathState s) SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); LoadCreaturesAddon(true); + + //reset map changes + GetMap()->CreatureRespawnRelocation(this); } } @@ -2032,7 +2071,7 @@ bool Creature::IsVisibleInGridForPlayer(Player const* pl) const if (corpse) { // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level - if (corpse->IsWithinDistInMap(this, (20 + 25) * sWorld.getRate(RATE_CREATURE_AGGRO))) + if (corpse->IsWithinDistInMap(this, (20 + 25) * sWorld.getConfig(RATE_CREATURE_AGGRO))) return true; } @@ -2056,7 +2095,7 @@ void Creature::DoFleeToGetAssistance() if (HasAuraType(SPELL_AURA_PREVENTS_FLEEING) || hasUnitState(UNIT_STAT_NOT_MOVE)) return; - float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS); + float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_RADIUS); if (radius > 0) { Creature* pCreature = NULL; @@ -2207,12 +2246,21 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const if (sMapStore.LookupEntry(GetMapId())->IsDungeon()) return false; - float AttackDist = GetAttackDistance(pVictim); - uint32 ThreatRadius = sWorld.getConfig(CONFIG_THREAT_RADIUS); + uint32 AttackDist = GetAttackDistance(pVictim); + + uint32 distToHome = std::max(AttackDist, sWorld.getConfig(CONFIG_EVADE_HOMEDIST)); + uint32 distToTarget = std::max(AttackDist, sWorld.getConfig(CONFIG_EVADE_TARGETDIST)); + + if (!IsWithinDistInMap(&homeLocation, distToHome)) + return true; - float dist = (ThreatRadius > AttackDist ? ThreatRadius : AttackDist); - //Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick. - return !IsWithinDistInMap(&homeLocation, dist) || !pVictim->IsWithinDistInMap(&homeLocation, 1.5f*dist); + if (!IsWithinDistInMap(pVictim, distToTarget)) + return true; + + if (!pVictim->IsWithinDistInMap(&homeLocation, distToHome)) + return true; + + return false; } CreatureDataAddon const* Creature::GetCreatureAddon() const @@ -2260,8 +2308,8 @@ bool Creature::LoadCreaturesAddon(bool reload) { for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura) { - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura->spell_id); - if (!AdditionalSpellInfo) + SpellEntry const *AdditionalSpellEntry = sSpellStore.LookupEntry(cAura->spell_id); + if (!AdditionalSpellEntry) { sLog.outLog(LOG_DB_ERR, "Creature (GUIDLow: %u Entry: %u) has wrong spell %u defined in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id); continue; @@ -2276,9 +2324,9 @@ bool Creature::LoadCreaturesAddon(bool reload) continue; } - Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, this, this, 0); + Aura* AdditionalAura = CreateAura(AdditionalSpellEntry, cAura->effect_idx, NULL, this, this, 0); AddAura(AdditionalAura); - sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u)", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[0],GetGUIDLow(),GetEntry()); + sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u)", cAura->spell_id, AdditionalSpellEntry->EffectApplyAuraName[0],GetGUIDLow(),GetEntry()); } } return true; @@ -2336,9 +2384,9 @@ void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time) m_CreatureSpellCooldowns[spell_id] = end_time; } -void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time) +void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t end_time) { - m_CreatureCategoryCooldowns[category] = apply_time; + m_CreatureCategoryCooldowns[category] = end_time; } void Creature::AddCreatureSpellCooldown(uint32 spellid) @@ -2348,11 +2396,23 @@ void Creature::AddCreatureSpellCooldown(uint32 spellid) return; uint32 cooldown = SpellMgr::GetSpellRecoveryTime(spellInfo); - if (cooldown) - _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/1000); + uint32 CategoryCooldown = spellInfo->CategoryRecoveryTime; + + if (isPet()) + if (Unit* Owner = GetOwner()) + if (Owner->GetTypeId() == TYPEID_PLAYER) + { + Owner->ToPlayer()->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, CategoryCooldown); + if (CategoryCooldown < 0) + CategoryCooldown = 0; + cooldown = CategoryCooldown; + } + + if (cooldown) + _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/1000); - if (spellInfo->Category) - _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL)); + if (spellInfo->Category && CategoryCooldown) + _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL) + CategoryCooldown/1000); } bool Creature::HasCategoryCooldown(uint32 spell_id) const @@ -2362,7 +2422,7 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const return false; CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category); - return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / 1000)) > time(NULL)); + return(itr != m_CreatureCategoryCooldowns.end() && itr->second > time(NULL)); } bool Creature::HasSpellCooldown(uint32 spell_id) const @@ -2460,7 +2520,7 @@ void Creature::AllLootRemovedFromCorpse() // corpse was not skinnable -> apply corpse looted timer if (!cinfo || !cinfo->SkinLootId) - nDeathTimer = (uint32)((m_corpseDelay * 1000) * sWorld.getRate(RATE_CORPSE_DECAY_LOOTED)); + nDeathTimer = (uint32)((m_corpseDelay * 1000) * sWorld.getConfig(RATE_CORPSE_DECAY_LOOTED)); // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update else nDeathTimer = 0; diff --git a/src/game/Creature.h b/src/game/Creature.h index 4ccc6179f..9c37e723d 100755 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_CREATURE_H -#define TRINITYCORE_CREATURE_H +#ifndef HELLGROUND_CREATURE_H +#define HELLGROUND_CREATURE_H #include "Common.h" #include "Unit.h" @@ -145,7 +145,9 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_HASTE_IMMUNE = 0x00400000, // 4194304 CREATURE_FLAG_EXTRA_CANT_MISS = 0x00800000, // 8388608 creature melee attacks cant miss CREATURE_FLAG_EXTRA_NOT_REGEN_MANA = 0x01000000, // 16777216 creature has mana pool, but do not regenerates it when OOC - CREATURE_FLAG_EXTRA_NOT_REGEN_HEALTH = 0x02000000 // 33554432 rare case that creature should not regen health when OOC + CREATURE_FLAG_EXTRA_NOT_REGEN_HEALTH = 0x02000000, // 33554432 rare case that creature should not regen health when OOC + CREATURE_FLAG_EXTRA_1PCT_TAUNT_RESIST = 0x04000000, // 67108864 creature have only 1% chance to resist taunt like spell + CREATURE_FLAG_EXTRA_NO_HEALING_TAKEN = 0x08000000, // 134217728 }; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform @@ -175,6 +177,7 @@ struct CreatureInfo uint32 minmana; uint32 maxmana; uint32 armor; + float xpMod; uint32 faction_A; uint32 faction_H; uint32 npcflag; @@ -521,7 +524,7 @@ class HELLGROUND_IMPORT_EXPORT Creature : public Unit void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); } void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); - void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time); + void _AddCreatureCategoryCooldown(uint32 category, time_t end_time); void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; @@ -701,6 +704,16 @@ class HELLGROUND_IMPORT_EXPORT Creature : public Unit Unit *SelectVictim(); + void SetIngoreVictimSelection(bool ignoreSelection) + { + if (ignoreSelection) + SetSelection(0); + else if (getVictim()) + SetSelection(getVictimGUID()); + m_ignoreSelection = ignoreSelection; + } + bool hasIgnoreVictimSelection() { return m_ignoreSelection; } + void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; } bool IsReputationGainDisabled() { return DisableReputationGain; } bool IsDamageEnoughForLootingAndReward() { return m_PlayerDamageReq == 0; } @@ -718,10 +731,12 @@ class HELLGROUND_IMPORT_EXPORT Creature : public Unit bool CanReactToPlayerOnTaxi(); - bool IsTempSummon() { return m_tempSummon; } + bool IsTemporarySummon() { return m_tempSummon; } void UpdateDeathTimer(uint32 timer) { if(m_deathTimer < timer) m_deathTimer = timer; } + virtual float GetXPMod() const override { return m_xpMod; } + protected: bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); @@ -753,6 +768,7 @@ class HELLGROUND_IMPORT_EXPORT Creature : public Unit ReactStates m_reactState; // for AI, not charmInfo void RegenerateMana(); void RegenerateHealth(); + MovementGeneratorType m_defaultMovementType; Cell m_currentCell; // store current cell where creature listed uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid @@ -784,7 +800,10 @@ class HELLGROUND_IMPORT_EXPORT Creature : public Unit uint32 m_aiReinitializeCheckTimer; float m_aggroRange; - + bool m_ignoreSelection; + public: + float m_xpMod; + private: //Formation var CreatureGroup *m_formation; diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 8e613d02d..05dec21be 100755 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "CreatureAI.h" @@ -33,8 +33,8 @@ void CreatureAI::OnCharmed(bool apply) } } -AISpellInfoType * UnitAI::AISpellInfo; -HELLGROUND_EXPORT AISpellInfoType * GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } +AISpellEntryType * UnitAI::AISpellEntry; +HELLGROUND_EXPORT AISpellEntryType * GetAISpellEntry(uint32 i) { return &CreatureAI::AISpellEntry[i]; } void CreatureAI::DoZoneInCombat(float max_dist) { diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 020c0dd5d..6ead2cd55 100755 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,9 +80,9 @@ class HELLGROUND_IMPORT_EXPORT CreatureAI : public UnitAI void SetGazeOn(Unit *target); - Creature *DoSummon(uint32 uiEntry, const WorldLocation &pos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); - Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); - Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + Creature *DoSummon(uint32 uiEntry, const WorldLocation &pos, uint32 uiDespawntime = 30000, TemporarySummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TemporarySummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); + Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TemporarySummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); public: explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c), m_MoveInLineOfSight_locked(false) {} @@ -130,7 +130,7 @@ class HELLGROUND_IMPORT_EXPORT CreatureAI : public UnitAI virtual void SpellHitTarget(Unit* target, const SpellEntry*) {} //Called when creature deals damage to player - virtual void DamageMade(Unit* target, uint32 & , bool direct_damage) {} + virtual void DamageMade(Unit* target, uint32 & , bool direct_damage, uint8 school_mask) {} // Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc) //virtual void AttackedBy(Unit* attacker); @@ -142,7 +142,7 @@ class HELLGROUND_IMPORT_EXPORT CreatureAI : public UnitAI // Called at waypoint reached or point movement finished virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {} - void OnCharmed(bool apply); + virtual void OnCharmed(bool apply); //virtual void SpellClick(Player *player) {} @@ -183,10 +183,11 @@ class HELLGROUND_IMPORT_EXPORT CreatureAI : public UnitAI virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; } virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {} + bool _EnterEvadeMode(); protected: virtual void MoveInLineOfSight(Unit *); - bool _EnterEvadeMode(); + private: bool m_MoveInLineOfSight_locked; diff --git a/src/game/CreatureAIFactory.h b/src/game/CreatureAIFactory.h index c772287b5..86068f9a4 100644 --- a/src/game/CreatureAIFactory.h +++ b/src/game/CreatureAIFactory.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,13 +10,14 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef HELLGROUND_CREATUREAIFACTORY_H #define HELLGROUND_CREATUREAIFACTORY_H diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index 4f6299c6b..ac14c5ab5 100755 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,15 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CREATUREAIIMPL_H -#define CREATUREAIIMPL_H + +#ifndef HELLGROUND_CREATUREAIIMPL_H +#define HELLGROUND_CREATUREAIIMPL_H #include "Common.h" #include "Platform/Define.h" @@ -472,9 +473,9 @@ enum AICondition #define AI_DEFAULT_COOLDOWN 5000 -struct AISpellInfoType +struct AISpellEntryType { - AISpellInfoType() : target(AITARGET_SELF), condition(AICOND_COMBAT) + AISpellEntryType() : target(AITARGET_SELF), condition(AICOND_COMBAT) , cooldown(AI_DEFAULT_COOLDOWN), realCooldown(0), maxRange(0.0f){} AITarget target; AICondition condition; @@ -483,7 +484,7 @@ struct AISpellInfoType float maxRange; }; -HELLGROUND_IMPORT_EXPORT AISpellInfoType * GetAISpellInfo(uint32 i); +HELLGROUND_IMPORT_EXPORT AISpellEntryType * GetAISpellEntry(uint32 i); inline void CreatureAI::SetGazeOn(Unit *target) @@ -539,16 +540,20 @@ inline bool CreatureAI::UpdateVictim() if (!me->isInCombat() || !me->isAlive()) return false; - if (me->hasUnitState(UNIT_STAT_LOST_CONTROL)) + bool outofthreat = me->IsOutOfThreatArea(me->getVictim()); + if (me->hasUnitState(UNIT_STAT_LOST_CONTROL) && !outofthreat) + { + me->SetSelection(0); return me->getVictim(); + } - if (me->getVictim()) + if (me->getVictim() && !outofthreat) { - if (me->IsNonMeleeSpellCasted(false)) + if (me->IsNonMeleeSpellCast(false)) return true; else { - if (!me->HasReactState(REACT_PASSIVE) && me->GetSelection() != me->getVictimGUID()) + if (!me->hasUnitState(UNIT_STAT_CANNOT_TURN) && !me->HasReactState(REACT_PASSIVE) && me->GetSelection() != me->getVictimGUID() && !me->hasIgnoreVictimSelection()) me->SetSelection(me->getVictimGUID()); } } @@ -558,7 +563,7 @@ inline bool CreatureAI::UpdateVictim() if (Unit *pVictim = me->SelectVictim()) AttackStart(pVictim); } - else if (me->getThreatManager().isThreatListEmpty()) + else if (me->getThreatManager().isThreatListEmpty() || outofthreat) { EnterEvadeMode(); me->SetReactState(REACT_PASSIVE); @@ -623,22 +628,22 @@ inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered) me->CastSpell((Unit*)NULL, spellId, triggered); } -inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const WorldLocation &pos, uint32 uiDespawntime, TempSummonType uiType) +inline Creature *CreatureAI::DoSummon(uint32 uiEntry, const WorldLocation &pos, uint32 uiDespawntime, TemporarySummonType uiType) { return me->SummonCreature(uiEntry, pos.coord_x, pos.coord_y, pos.coord_z, pos.orientation, uiType, uiDespawntime); } -inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* obj, float fRadius, uint32 uiDespawntime, TempSummonType uiType) +inline Creature *CreatureAI::DoSummon(uint32 uiEntry, WorldObject* obj, float fRadius, uint32 uiDespawntime, TemporarySummonType uiType) { WorldLocation pos; - obj->GetClosePoint(pos.coord_x,pos.coord_y,pos.coord_z,obj->GetObjectSize(), fRadius); + obj->GetNearPoint(pos.coord_x,pos.coord_y,pos.coord_z,obj->GetObjectSize(), fRadius); return me->SummonCreature(uiEntry, pos.coord_x, pos.coord_y, pos.coord_z, pos.orientation, uiType, uiDespawntime); } -inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TempSummonType uiType) +inline Creature *CreatureAI::DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float _fZ, float fRadius, uint32 uiDespawntime, TemporarySummonType uiType) { WorldLocation pos; - obj->GetClosePoint(pos.coord_x,pos.coord_y,pos.coord_z,obj->GetObjectSize(), fRadius); + obj->GetNearPoint(pos.coord_x,pos.coord_y,pos.coord_z,obj->GetObjectSize(), fRadius); pos.coord_z += _fZ; return me->SummonCreature(uiEntry, pos.coord_x, pos.coord_y, pos.coord_z, pos.orientation, uiType, uiDespawntime); } diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp index 6bbef2ee8..f970633a6 100755 --- a/src/game/CreatureAIRegistry.cpp +++ b/src/game/CreatureAIRegistry.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "PassiveAI.h" diff --git a/src/game/CreatureAIRegistry.h b/src/game/CreatureAIRegistry.h index 517716f72..2c7138353 100755 --- a/src/game/CreatureAIRegistry.h +++ b/src/game/CreatureAIRegistry.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index b15de5e0f..7e8cc8ca9 100755 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Creature.h" diff --git a/src/game/CreatureAISelector.h b/src/game/CreatureAISelector.h index 8fae15778..bcde474b3 100755 --- a/src/game/CreatureAISelector.h +++ b/src/game/CreatureAISelector.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 1ad0bdd22..9217f3981 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -246,7 +246,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction break; } case EVENT_T_TARGET_CASTING: - if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) + if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCast(false, false, true)) return false; //Repeat Timers @@ -496,7 +496,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 caster = target; //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered - bool canCast = !caster->IsNonMeleeSpellCasted(false) || (action.cast.castFlags & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); + bool canCast = !caster->hasUnitState(UNIT_STAT_LOST_CONTROL) && (!caster->IsNonMeleeSpellCast(false) || (action.cast.castFlags & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS))); // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if (action.cast.castFlags & CAST_AURA_NOT_PRESENT) @@ -532,7 +532,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 else { //Interrupt any previous spell - if (action.cast.castFlags & CAST_INTURRUPT_PREVIOUS && caster->IsNonMeleeSpellCasted(false)) + if (action.cast.castFlags & CAST_INTURRUPT_PREVIOUS && caster->IsNonMeleeSpellCast(false)) caster->InterruptNonMeleeSpells(false); caster->CastSpell(target, action.cast.spellId, (action.cast.castFlags & CAST_TRIGGERED)); @@ -558,7 +558,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered - bool canCast = !caster->IsNonMeleeSpellCasted(false) || (action.castguid.castFlags & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); + bool canCast = !caster->IsNonMeleeSpellCast(false) || (action.castguid.castFlags & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if (action.castguid.castFlags & CAST_AURA_NOT_PRESENT) @@ -594,7 +594,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 else { //Interrupt any previous spell - if (caster->IsNonMeleeSpellCasted(false) && action.castguid.castFlags & CAST_INTURRUPT_PREVIOUS) + if (caster->IsNonMeleeSpellCast(false) && action.castguid.castFlags & CAST_INTURRUPT_PREVIOUS) caster->InterruptNonMeleeSpells(false); caster->CastSpell(target, action.castguid.spellId, (action.castguid.castFlags & CAST_TRIGGERED)); @@ -607,9 +607,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_SUMMON: { - if (HasEventAISummonedUnits()) - break; - Unit* target = GetTargetByType(action.summon.target, pActionInvoker); Creature* pCreature = NULL; @@ -631,8 +628,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_THREAT_ALL_PCT: { - std::list& threatList = m_creature->getThreatManager().getThreatList(); - for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) + std::list& threatList = m_creature->getThreatManager().getThreatList(); + for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid())) m_creature->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); break; @@ -645,7 +642,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_CAST_EVENT: if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) - ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId); + ((Player*)target)->CastCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { @@ -683,7 +680,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { if (action.combat_movement.melee && m_creature->isInCombat()) if (Unit* victim = m_creature->getVictim()) - m_creature->SendMeleeAttackStart(victim); + m_creature->SendMeleeAttackStart(victim->GetGUID()); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); } @@ -691,9 +688,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { if (action.combat_movement.melee && m_creature->isInCombat()) if (Unit* victim = m_creature->getVictim()) - m_creature->SendMeleeAttackStop(victim); + m_creature->SendMeleeAttackStop(victim->GetGUID()); - m_creature->GetMotionMaster()->MoveIdle(); + if (!m_creature->hasUnitState(UNIT_STAT_LOST_CONTROL)) + m_creature->GetMotionMaster()->MoveIdle(); } break; case ACTION_T_COMBAT_STOP: @@ -741,11 +739,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_CAST_EVENT_ALL: { - std::list& threatList = m_creature->getThreatManager().getThreatList(); - for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) + std::list& threatList = m_creature->getThreatManager().getThreatList(); + for (std::list::iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid())) if (Temp->GetTypeId() == TYPEID_PLAYER) - ((Player*)Temp)->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetGUID(), action.cast_event_all.spellId); + ((Player*)Temp)->CastCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetGUID(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: @@ -771,9 +769,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_SUMMON_ID: { - if (HasEventAISummonedUnits()) - break; - Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker); CreatureEventAI_Summon_Map::const_iterator i = sCreatureEAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId); @@ -874,7 +869,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_MOVE_RANDOM_POINT: //dosen't work in combat { float x,y,z; - me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, action.raw.param1); + me->GetNearPoint(x, y, z, me->GetObjectSize() / 3, action.raw.param1); me->GetMotionMaster()->MovePoint(0,x,y,z); break; } @@ -1129,8 +1124,6 @@ void CreatureEventAI::AttackStart(Unit *who) { if (CombatMovementEnabled) m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle); - else - m_creature->GetMotionMaster()->MoveIdle(); } } diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 5e8d67183..baa679c60 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_CREATURE_EAI_H diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 0dac510eb..5a2a7210a 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -64,7 +65,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use) } // range negative (don't must be happen, loaded from same table) - if (!sObjectMgr.GetTrinityStringLocale(i)) + if (!sObjectMgr.GetHellgroundStringLocale(i)) { sLog.outLog(LOG_DB_ERR, "CreatureEventAI: Entry %i in table `creature_ai_texts` not found",i); continue; diff --git a/src/game/CreatureEventAIMgr.h b/src/game/CreatureEventAIMgr.h index de51b4f56..5eeb34b1f 100644 --- a/src/game/CreatureEventAIMgr.h +++ b/src/game/CreatureEventAIMgr.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_CREATURE_EAI_MGR_H diff --git a/src/game/CreatureGroups.cpp b/src/game/CreatureGroups.cpp index cf94b7258..eecafaad3 100755 --- a/src/game/CreatureGroups.cpp +++ b/src/game/CreatureGroups.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Creature.h" @@ -303,7 +303,6 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) Hellground::NormalizeMapCoord(dy); member->UpdateGroundPositionZ(dx, dy, dz); - if (member->IsWithinDistInMap(m_leader, dist + MAX_DESYNC)) { uint32 moveFlags = m_leader->GetUnitMovementFlags(); @@ -321,7 +320,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z) member->SetWalk(false); } - member->GetMotionMaster()->MovePoint(0, dx, dy, dz, true, UNIT_ACTION_HOME); + member->GetMotionMaster()->MovePoint(0, dx, dy, dz, true, true, UNIT_ACTION_HOME); member->SetHomePosition(m_leader->GetPositionX(), m_leader->GetPositionY(), m_leader->GetPositionZ(), pathangle); m_movingUnits++; } @@ -348,4 +347,27 @@ Creature* CreatureGroup::GetNextRandomCreatureGroupMember(Creature* member, floa uint32 randTarget = urand(0,nearMembers.size()-1); return nearMembers[randTarget]; +} + +bool CreatureGroup::AllUnitsReachedWaypoint() const +{ + auto numStillMovingUnits = m_movingUnits; + + for (auto& member : m_members) + { + Creature* creature = m_leader->GetMap()->GetCreature(member.first); + if (!creature || creature == m_leader) + continue; + + //Don't wait for dead units + if (creature->isDead()) + --numStillMovingUnits; + } + + std::count_if(std::begin(m_members), std::end(m_members), [](std::pair& member) + { + + }); + + return numStillMovingUnits == 0; } diff --git a/src/game/CreatureGroups.h b/src/game/CreatureGroups.h index 2dca33d28..71521a771 100755 --- a/src/game/CreatureGroups.h +++ b/src/game/CreatureGroups.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _FORMATIONS_H -#define _FORMATIONS_H +#ifndef HELLGROUND_CREATUREGROUPS_H +#define HELLGROUND_CREATUREGROUPS_H #include "Common.h" @@ -82,7 +82,7 @@ class CreatureGroup void ReachedWaypoint() { if( m_movingUnits > 0 ) m_movingUnits--; } void ClearMovingUnits() { m_movingUnits = 0; } - bool AllUnitsReachedWaypoint() const { return m_movingUnits == 0; } + bool AllUnitsReachedWaypoint() const; }; #endif diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 5d6e92ba2..dadb28ff1 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -1,23 +1,24 @@ /* -* Copyright (C) 2005-2008 MaNGOS -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef DBCENUMS_H -#define DBCENUMS_H + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_DBCENUMS_H +#define HELLGROUND_DBCENUMS_H // client supported max level for player/pets/etc. Avoid overflow or client stability affected. // also see GT_MAX_LEVEL define diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 4e736d998..dd35cdef5 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DBCStores.h" @@ -354,6 +354,20 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc"); + {//HACK for +12spirit +12hit rating gems, those have wrong values in dbc + SpellItemEnchantmentEntry* entry; + for(uint32 i = 0; i < sSpellItemEnchantmentStore.GetNumRows(); ++i) + { + entry = (SpellItemEnchantmentEntry*)sSpellItemEnchantmentStore.LookupEntry(i); + if(!entry) + continue; + + if (entry->GemID == 33137) + entry->amount[0] = 12; + else if (entry->GemID == 33142) + entry->amount[1] = 12; + }} + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore, dbcPath,"SpellRadius.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRangeStore, dbcPath,"SpellRange.dbc"); @@ -524,7 +538,7 @@ void LoadDBCStores(const std::string& dataPath) // error checks if(bad_dbc_files.size() >= DBCFilesCount ) { - sLog.outLog(LOG_DEFAULT, "ERROR: \nIncorrect DataDir value in Trinityd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str()); + sLog.outLog(LOG_DEFAULT, "ERROR: \nIncorrect DataDir value in .conf file or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str()); exit(1); } else if(!bad_dbc_files.empty() ) diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h index a9d022044..0d3af5e78 100644 --- a/src/game/DBCStores.h +++ b/src/game/DBCStores.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCSTORES_H -#define DBCSTORES_H +#ifndef HELLGROUND_DBCSTORES_H +#define HELLGROUND_DBCSTORES_H #include "Common.h" #include "Database/DBCStore.h" diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 5f19d37aa..539bc23f1 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCSTRUCTURE_H -#define DBCSTRUCTURE_H +#ifndef HELLGROUND_DBCSTRUCTURE_H +#define HELLGROUND_DBCSTRUCTURE_H #include "DBCEnums.h" #include "Platform/Define.h" @@ -792,6 +792,61 @@ struct SpellEntry return false; } + bool IsDestTargetEffect(uint8 eff) const + { + switch (EffectImplicitTargetA[eff]) + { + case TARGET_DST_HOME: + case TARGET_DST_DB: + case TARGET_DST_CASTER: + case TARGET_DEST_DYNOBJ_ENEMY: + case TARGET_DEST_DYNOBJ_ALLY: + case TARGET_UNIT_AREA_ALLY_DST: + case TARGET_UNIT_AREA_PARTY_DST: + case TARGET_DEST_CASTER_RANDOM_UNKNOWN: + case TARGET_DEST_CASTER_FRONT_LEFT: + case TARGET_DEST_CASTER_BACK_LEFT: + case TARGET_DEST_CASTER_BACK_RIGHT: + case TARGET_DEST_CASTER_FRONT_RIGHT: + case TARGET_DST_NEARBY_ENTRY: + case TARGET_DEST_CASTER_FRONT: + case TARGET_DEST_CASTER_BACK: + case TARGET_DEST_CASTER_RIGHT: + case TARGET_DEST_CASTER_LEFT: + case TARGET_DST_TARGET_ENEMY: + case TARGET_DEST_CASTER_FRONT_LEAP: + case TARGET_DEST_TARGET_ANY: + case TARGET_DEST_TARGET_FRONT: + case TARGET_DEST_TARGET_BACK: + case TARGET_DEST_TARGET_RIGHT: + case TARGET_DEST_TARGET_LEFT: + case TARGET_DEST_TARGET_FRONT_LEFT: + case TARGET_DEST_TARGET_BACK_LEFT: + case TARGET_DEST_TARGET_BACK_RIGHT: + case TARGET_DEST_TARGET_FRONT_RIGHT: + case TARGET_DEST_CASTER_RANDOM: + case TARGET_DEST_CASTER_RADIUS: + case TARGET_DEST_TARGET_RANDOM: + case TARGET_DEST_TARGET_RADIUS: + case TARGET_DEST_CHANNEL: + case TARGET_DEST_DEST_FRONT: + case TARGET_DEST_DEST_BACK: + case TARGET_DEST_DEST_RIGHT: + case TARGET_DEST_DEST_LEFT: + case TARGET_DEST_DEST_FRONT_LEFT: + case TARGET_DEST_DEST_BACK_LEFT: + case TARGET_DEST_DEST_BACK_RIGHT: + case TARGET_DEST_DEST_FRONT_RIGHT: + case TARGET_DEST_DEST_RANDOM: + case TARGET_DEST_DEST: + case TARGET_DEST_DYNOBJ_NONE: + case TARGET_DEST_TRAJ: + return true; + } + + return false; + } + bool NeedFillTargetMapForTargets(uint8 eff) const { // check combinations A <> B of implicit targets diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index b10065ec3..0c058398e 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef HELLGROUND_DBCFMT_H +#define HELLGROUND_DBCFMT_H + const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxx"; const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx"; const char AreaTriggerEntryfmt[]="niffffffff"; @@ -93,3 +96,4 @@ const char WorldMapAreaEntryfmt[]="xinxffffi"; const char WMOAreaTableEntryfmt[]="niiixxxxxiixxxxxxxxxxxxxxxxx"; const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx"; +#endif diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp index d4c61534c..98799a085 100755 --- a/src/game/Debugcmds.cpp +++ b/src/game/Debugcmds.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -672,6 +672,8 @@ bool ChatHandler::HandleDebugUnitState(const char * /*args*/) { Player* player = m_session->GetPlayer(); PSendSysMessage("You have state: %u", player->m_state); + if (player->IsBeingTeleported()) + PSendSysMessage("If You see this line and cannot move please report it"); return true; } @@ -686,14 +688,14 @@ bool ChatHandler::HandleDebugThreatList(const char * /*args*/) return false; uint32 max_count = 0; - if (!(m_session->GetPermissions() & (PERM_GMT | PERM_DEVELOPER))) + if (!m_session->HasPermissions(PERM_GMT_DEV)) { pOwner->AddSpellCooldown(COMMAND_COOLDOWN, 0, time(NULL) +10); max_count = 3; } - std::list& tlist = target->getThreatManager().getThreatList(); - std::list::iterator itr; + std::list& tlist = target->getThreatManager().getThreatList(); + std::list::iterator itr; uint32 cnt = 0; PSendSysMessage("Threat list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); @@ -713,12 +715,12 @@ bool ChatHandler::HandleDebugThreatList(const char * /*args*/) return true; } -bool ChatHandler::HandleDebugHostilRefList(const char * /*args*/) +bool ChatHandler::HandleDebugHostileRefList(const char * /*args*/) { Unit* target = getSelectedUnit(); if (!target) target = m_session->GetPlayer(); - HostilReference* ref = target->getHostilRefManager().getFirst(); + HostileReference* ref = target->getHostileRefManager().getFirst(); uint32 cnt = 0; PSendSysMessage("Hostile reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); while (ref) diff --git a/src/game/DuelHandler.cpp b/src/game/DuelHandler.cpp index 22c256fe3..8d1c4d68d 100755 --- a/src/game/DuelHandler.cpp +++ b/src/game/DuelHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 8577671b3..c9cb8e964 100755 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index ed4ac9fd3..d59ff5010 100755 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_DYNAMICOBJECT_H -#define TRINITYCORE_DYNAMICOBJECT_H +#ifndef HELLGROUND_DYNAMICOBJECT_H +#define HELLGROUND_DYNAMICOBJECT_H #include "Object.h" diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index cec1d4792..b8644c333 100755 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,8 +33,19 @@ void FleeingMovementGenerator::_moveToNextLocation(UNIT &unit) if (!_getPoint(unit, dest)) return; + PathFinder path(&unit); + path.setPathLengthLimit(30.0f); + bool result = path.calculate(dest.x, dest.y, dest.z); + + if (!result || path.getPathType() & PATHFIND_NOPATH) + unit.GetPosition(dest); + Movement::MoveSplineInit init(unit); - init.MoveTo(dest.x, dest.y, dest.z); + if (path.getPathType() & PATHFIND_NOPATH) + init.MoveTo(dest.x, dest.y, dest.z); + else + init.MovebyPath(path.getPath()); + init.SetWalk(false); init.Launch(); diff --git a/src/game/FleeingMovementGenerator.h b/src/game/FleeingMovementGenerator.h index 46bc71c15..dff53257a 100755 --- a/src/game/FleeingMovementGenerator.h +++ b/src/game/FleeingMovementGenerator.h @@ -1,22 +1,22 @@ /* -* Copyright (C) 2005-2008 MaNGOS -* -* Copyright (C) 2008 Trinity -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef HELLGROUND_FLEEINGMOVEMENTGENERATOR_H #define HELLGROUND_FLEEINGMOVEMENTGENERATOR_H diff --git a/src/game/FollowerRefManager.h b/src/game/FollowerRefManager.h index 136fdbfea..a1c1a90fd 100755 --- a/src/game/FollowerRefManager.h +++ b/src/game/FollowerRefManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _FOLLOWERREFMANAGER -#define _FOLLOWERREFMANAGER +#ifndef HELLGROUND_FOLLOWERREFMANAGER_H +#define HELLGROUND_FOLLOWERREFMANAGER_H #include "Utilities/LinkedReference/RefManager.h" diff --git a/src/game/FollowerReference.cpp b/src/game/FollowerReference.cpp index 44c8e8d55..cfc7a7a6d 100755 --- a/src/game/FollowerReference.cpp +++ b/src/game/FollowerReference.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/FollowerReference.h b/src/game/FollowerReference.h index ff2c92efb..4c010556a 100755 --- a/src/game/FollowerReference.h +++ b/src/game/FollowerReference.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _FOLLOWERREFERENCE_H -#define _FOLLOWERREFERENCE_H +#ifndef HELLGROUND_FOLLOWERREFERENCE_H +#define HELLGROUND_FOLLOWERREFERENCE_H #include "Utilities/LinkedReference/Reference.h" diff --git a/src/game/Formulas.h b/src/game/Formulas.h index 2832fae3e..52e4f20d2 100755 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_FORMULAS_H @@ -114,14 +114,24 @@ namespace Hellground (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL))) return 0; - uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId())); + uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId())); if (xp_gain == 0) return 0; if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isElite()) xp_gain *= 2; - return (uint32)(xp_gain*pl->GetXPRate(RATE_XP_KILL)); + float expCalc = xp_gain * pl->GetXPRate(RATE_XP_KILL) * u->GetXPMod(); + uint32 exp = (uint32)(expCalc); + + if (sLog.IsLogEnabled(LOG_EXP)) + { + CreatureInfo const * tmpInfo = ObjectMgr::GetCreatureTemplate(u->GetEntry()); + sLog.outLog(LOG_EXP, "Exp calculation for Player %u and Unit %u (id: %u): xp_gain: %u, plLvl: %u, uLvl: %u, XPRate: %f, XPMod: %f (template: %f), exp calculated: %f, exp after cast: %u", + pl->GetGUIDLow(), u->GetGUIDLow(), xp_gain, pl->getLevel(), u->getLevel(), u->GetEntry(), pl->GetXPRate(RATE_XP_KILL), u->GetXPMod(), tmpInfo ? tmpInfo->xpMod : -1.0f, expCalc, exp); + } + + return exp; } inline uint32 xp_Diff(uint32 lvl) @@ -167,7 +177,7 @@ namespace Hellground }else { // level higher than 70 is not supported - xp = (uint32)(779700 * (pow(sWorld.getRate(RATE_XP_PAST_70), (int32)lvl - 69))); + xp = (uint32)(779700 * (pow(sWorld.getConfig(RATE_XP_PAST_70), (int32)lvl - 69))); return ((xp < 0x7fffffff) ? xp : 0x7fffffff); } diff --git a/src/game/GameEvent.cpp b/src/game/GameEvent.cpp old mode 100755 new mode 100644 index f03c2e966..cdf59ad55 --- a/src/game/GameEvent.cpp +++ b/src/game/GameEvent.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "GameEvent.h" @@ -193,7 +193,7 @@ void GameEventMgr::LoadFromDB() mGameEvent.resize(max_event_id+1); } - QueryResultAutoPtr result = GameDataDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,description,world_event FROM game_event"); + QueryResultAutoPtr result = GameDataDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,description,world_event,flags FROM game_event"); if (!result) { mGameEvent.clear(); @@ -229,6 +229,7 @@ void GameEventMgr::LoadFromDB() pGameEvent.description = fields[5].GetCppString(); pGameEvent.state = (GameEventState)(fields[6].GetUInt8()); pGameEvent.nextstart = 0; + pGameEvent.flags = (GameEventFlag)(fields[7].GetUInt8()); if (pGameEvent.length==0 && pGameEvent.state == GAMEEVENT_NORMAL) // length>0 is validity check { @@ -1098,7 +1099,7 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id) case 0: // disable break; case 1: // announce events - sWorld.SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str()); + sWorld.SendWorldText(LANG_EVENTMESSAGE, 0, mGameEvent[event_id].description.c_str()); break; } @@ -1451,6 +1452,15 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool Activate) { if (!hasCreatureQuestActiveEventExcept(itr->second,event_id)) { + if (mGameEvent[event_id].flags & GAMEEVENT_FLAG_REMOVE_QUESTS_AT_END) + { + //remove quest from both online and offline players + RealmDataDatabase.PExecute("DELETE FROM character_queststatus WHERE quest = %u",itr->second); + HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); + for (HashMapHolder::MapType::iterator pitr = m.begin(); pitr != m.end(); ++pitr) + if (pitr->second->GetQuestStatus(itr->second) != QUEST_STATUS_NONE) + pitr->second->SetQuestStatus(itr->second,QUEST_STATUS_NONE); + } // Remove the pair(id,quest) from the multimap QuestRelations::iterator qitr = CreatureQuestMap.find(itr->first); if (qitr == CreatureQuestMap.end()) @@ -1476,6 +1486,15 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool Activate) { if (!hasGameObjectQuestActiveEventExcept(itr->second,event_id)) { + if (mGameEvent[event_id].flags & GAMEEVENT_FLAG_REMOVE_QUESTS_AT_END) + { + //remove quest from both online and offline players + RealmDataDatabase.PExecute("DELETE FROM character_queststatus WHERE quest = %u",itr->second); + HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); + for (HashMapHolder::MapType::iterator pitr = m.begin(); pitr != m.end(); ++pitr) + if (pitr->second->GetQuestStatus(itr->second) != QUEST_STATUS_NONE) + pitr->second->SetQuestStatus(itr->second,QUEST_STATUS_NONE); + } // Remove the pair(id,quest) from the multimap QuestRelations::iterator qitr = GameObjectQuestMap.find(itr->first); if (qitr == GameObjectQuestMap.end()) diff --git a/src/game/GameEvent.h b/src/game/GameEvent.h index ba0fb29ad..da0b99388 100755 --- a/src/game/GameEvent.h +++ b/src/game/GameEvent.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,12 @@ enum GameEventState GAMEEVENT_WORLD_FINISHED // next events are started, unapply this one }; +enum GameEventFlag +{ + GAMEEVENT_FLAG_NONE = 0x00, + GAMEEVENT_FLAG_REMOVE_QUESTS_AT_END = 0x01 +}; + struct GameEventFinishCondition { float reqNum; // required number // use float, since some events use percent @@ -55,7 +61,7 @@ struct GameEventQuestToEventConditionNum struct GameEventData { - GameEventData() : start(1),end(0),nextstart(0),occurence(0),length(0),state(GAMEEVENT_NORMAL) {} + GameEventData() : start(1),end(0),nextstart(0),occurence(0),length(0),state(GAMEEVENT_NORMAL),flags(GAMEEVENT_FLAG_NONE) {} time_t start; // occurs after this time time_t end; // occurs before this time time_t nextstart; // after this time the follow-up events count this phase completed @@ -65,6 +71,7 @@ struct GameEventData std::map conditions; // conditions to finish std::set prerequisite_events; // events that must be completed before starting this event std::string description; + GameEventFlag flags; bool isValid() const { return ((length > 0) || (state > GAMEEVENT_NORMAL)); } }; diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 1a9b3660a..88a9a7816 100755 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -332,7 +332,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) if (!ok) Cell::VisitWorldObjects(this, checker, radius); } - else // environmental trap + else if (isSpawnedByDefault()) // environmental trap { // affect only players Player* p_ok = NULL; @@ -343,11 +343,16 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) ok = p_ok; } + else // creature spawned traps + { + CastSpell((Unit*)NULL, goInfo->trap.spellId); + m_cooldownTime = time(NULL) + goInfo->trap.cooldown; + } if (ok) { CastSpell(ok, goInfo->trap.spellId); - m_cooldownTime = time(NULL) + 4; // 4 seconds + m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : 4); // default 4 sec cooldown?? SendCustomAnimation(); if (NeedDespawn) @@ -438,6 +443,11 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) m_lootState = GO_JUST_DEACTIVATED; break; } + default: + { + m_lootState = GO_JUST_DEACTIVATED; + break; + } } break; } @@ -464,10 +474,10 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) { if (Unit* caster = Unit::GetUnit(*this, uint64(*i))) { - if (caster->m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (Spell* spell = caster->m_currentSpells[CURRENT_CHANNELED_SPELL]) { - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); - caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); + spell->SendChannelUpdate(0); + spell->finish(); } } } @@ -485,7 +495,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) void GameObject::Refresh() { - // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway) + // not refresh despawned not cast GO (despawned cast GO destroyed in all cases anyway) if (m_respawnTime > 0 && m_spawnedByDefault) return; @@ -501,11 +511,13 @@ void GameObject::AddUniqueUse(Player* player) m_unique_users.insert(player->GetGUIDLow()); } -void GameObject::Delete() +void GameObject::Delete(bool setGoState) { SendObjectDeSpawnAnim(GetGUID()); - SetGoState(GO_STATE_READY); + if (setGoState) + SetGoState(GO_STATE_READY); + SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); uint16 poolid = sPoolMgr.IsPartOfAPool(GetGUIDLow()); @@ -835,7 +847,11 @@ void GameObject::Reset() m_usetimes = 0; loot.clear(); SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); + SetGoState(GetGOData() ? GetGOData()->go_state : GO_STATE_READY); SetLootState(GO_READY); + if (!GetDespawnPossibility()) + SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);// this flag is set in LoadFromDB() for some objects + } void GameObject::Despawn() @@ -846,8 +862,24 @@ void GameObject::Despawn() if (GetOwnerGUID()) { if (Unit* owner = GetOwner()) + { owner->RemoveGameObject(this, false); + if (this->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE && owner->GetTypeId() == TYPEID_PLAYER) + { + Player *player = (Player *)owner; + + if (player && player->m_currentSpells[CURRENT_CHANNELED_SPELL]) + { + player->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); + player->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); + + WorldPacket data(SMSG_FISH_NOT_HOOKED, 0); + player->SendPacketToSelf(&data); + } + } + } + m_respawnTime = 0; Delete(); } @@ -1099,6 +1131,8 @@ void GameObject::Use(Unit* user) // triggering linked GO if (uint32 trapEntry = GetGOInfo()->spellFocus.linkedTrapId) TriggeringLinkedGameObject(trapEntry, user); + Activate(); + SetGoState(GO_STATE_ACTIVE); return; case GAMEOBJECT_TYPE_GOOBER: //10 { @@ -1121,7 +1155,7 @@ void GameObject::Use(Unit* user) break; } - pPlayer->CastedCreatureOrGO(GetEntry(), GetGUID(), 0); + pPlayer->CastCreatureOrGO(GetEntry(), GetGUID(), 0); if (info->goober.eventId) { @@ -1265,10 +1299,15 @@ void GameObject::Use(Unit* user) m_lootState = GO_ACTIVATED; AddUniqueUse(pPlayer); - if(info->summoningRitual.animSpell) + if (info->summoningRitual.animSpell) pPlayer->CastSpell(pPlayer, info->summoningRitual.animSpell, false); else - pPlayer->CastSpell(pPlayer, 32783, false); + { + if (m_spellId == 29893) + pPlayer->CastSpell(pPlayer, 43897, false); + else + pPlayer->CastSpell(pPlayer, 32783, false); + } if(m_unique_users.size() == GetGOInfo()->summoningRitual.reqParticipants) { @@ -1446,6 +1485,13 @@ void GameObject::CastSpell(Unit* target, uint32 spell) return; } + if (target) + { + const SpellEntry* spellInfo = sSpellStore.LookupEntry(spell); + if (SpellMgr::isSpellBreakStealth(spellInfo)) + target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); + } + if (Unit *owner = GetOwner()) { trigger->setFaction(owner->getFaction()); @@ -1454,7 +1500,7 @@ void GameObject::CastSpell(Unit* target, uint32 spell) else { trigger->setFaction(14); - trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID()); + trigger->CastSpell(target, spell, true, 0, 0, target != nullptr ? target->GetGUID() : NULL); } //trigger->setDeathState(JUST_DIED); //trigger->RemoveCorpse(); @@ -1475,7 +1521,7 @@ void GameObject::CastSpell(GameObject* target, uint32 spell) else { trigger->setFaction(14); - trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID()); + trigger->CastSpell(target, spell, true, 0, 0, target != nullptr ? target->GetGUID() : 0); } } @@ -1530,7 +1576,7 @@ void GameObject::HandleNonDbcSpell(uint32 spellId, Player* pUser) uint32 entry = spellId == 37639 ? 20021 : 21729; float x, y, z; - pUser->GetClosePoint(x, y, z, 0.0f, 3.0f, frand(0, 2*M_PI)); + pUser->GetNearPoint(x, y, z, 0.0f, 3.0f, frand(0, 2*M_PI)); if (Creature *pSummon = pUser->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000)) pSummon->AI()->AttackStart(pUser); @@ -1538,7 +1584,7 @@ void GameObject::HandleNonDbcSpell(uint32 spellId, Player* pUser) } default: - sLog.outDebug("Gameobject: %s, %u type: %u. casted non-handled and non-existing spell: %u", GetName(), GetEntry(), GetGoType(), spellId); + sLog.outDebug("Gameobject: %s, %u type: %u. cast non-handled and non-existing spell: %u", GetName(), GetEntry(), GetGoType(), spellId); break; } } diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 6d5c3b89c..5f8bdc246 100755 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_GAMEOBJECT_H -#define TRINITYCORE_GAMEOBJECT_H +#ifndef HELLGROUND_GAMEOBJECT_H +#define HELLGROUND_GAMEOBJECT_H #include "Common.h" #include "SharedDefines.h" @@ -548,7 +548,7 @@ class HELLGROUND_IMPORT_EXPORT GameObject : public WorldObject void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; } uint32 GetRespawnDelay() const { return m_respawnDelayTime; } void Refresh(); - void Delete(); + void Delete(bool setGoState = true); void SetSpellId(uint32 id) { m_spellId = id;} uint32 GetSpellId() const { return m_spellId;} void getFishLoot(Loot *loot, Player* loot_owner); diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index f226ce978..3c5b7d424 100755 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "QuestDef.h" @@ -436,8 +436,8 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, uint64 npcGUID, // rewarded honor points. Multiply with 10 to satisfy client data << uint32(10*Hellground::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // cast spell data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) data << uint32(QUEST_EMOTE_COUNT); @@ -507,8 +507,8 @@ void PlayerMenu::SendQuestQueryResponse(Quest const *pQuest) data << uint32(pQuest->GetRewOrReqMoney()); data << uint32(pQuest->GetRewMoneyMaxLevel()); // used in XP calculation at client - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // cast spell // rewarded honor points data << uint32(Hellground::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); @@ -649,8 +649,8 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, uint64 npcGUID, // rewarded honor points. Multiply with 10 to satisfy client data << uint32(10*Hellground::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); data << uint32(0x08); // unused by client? - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // cast spell data << uint32(0x00); // unk, NOT honor pSession->SendPacket(&data); sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId()); diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index 6b82864c7..7b35fc899 100755 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_GOSSIP_H -#define TRINITYCORE_GOSSIP_H +#ifndef HELLGROUND_GOSSIP_H +#define HELLGROUND_GOSSIP_H #include "Common.h" #include "QuestDef.h" diff --git a/src/game/GridDefines.h b/src/game/GridDefines.h index 27781214c..564c9ffb3 100755 --- a/src/game/GridDefines.h +++ b/src/game/GridDefines.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/GridMap.cpp b/src/game/GridMap.cpp index 805530108..0e9393aee 100644 --- a/src/game/GridMap.cpp +++ b/src/game/GridMap.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapManager.h" @@ -610,7 +611,7 @@ bool GridMap::ExistVMap(uint32 mapid,int gx,int gy) } ////////////////////////////////////////////////////////////////////////// -TerrainInfo::TerrainInfo(uint32 mapid, TerrainSpecifics terrainspecifics) : m_mapId(mapid), specifics(terrainspecifics) +TerrainInfo::TerrainInfo(uint32 mapid, TerrainSpecifics terrainspecifics) : m_mapId(mapid) { for (int k = 0; k < MAX_NUMBER_OF_GRIDS; ++k) { @@ -628,6 +629,8 @@ TerrainInfo::TerrainInfo(uint32 mapid, TerrainSpecifics terrainspecifics) : m_ma i_timer.SetInterval(iCleanUpInterval * 1000); i_timer.SetCurrent(iRandomStart * 1000); + + m_specifics = new MapTemplate(terrainspecifics); } TerrainInfo::~TerrainInfo() @@ -638,6 +641,9 @@ TerrainInfo::~TerrainInfo() VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(m_mapId); MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_mapId); + + delete m_specifics; + m_specifics = nullptr; } GridMap * TerrainInfo::Load(const uint32 x, const uint32 y) @@ -1031,7 +1037,6 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) } delete [] tmp; - m_GridMaps[x][y] = map; //load VMAPs for current map/grid... const MapEntry * i_mapEntry = sMapStore.LookupEntry(m_mapId); @@ -1051,6 +1056,8 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) } MMAP::MMapFactory::createOrGetMMapManager()->loadMap(m_mapId, x, y); + + m_GridMaps[x][y] = map; } } @@ -1080,32 +1087,40 @@ float TerrainInfo::GetWaterLevel(float x, float y, float z, float* pGround /*= N bool TerrainInfo::IsLineOfSightEnabled() const { - if (GetSpecifics()->lineofsight == F_ALWAYS_DISABLED) + const TerrainSpecifics* specifics = GetSpecifics(); + if (specifics == nullptr) + return true; + + if (specifics->lineofsight == F_ALWAYS_DISABLED) return false; - if (GetSpecifics()->lineofsight == F_ALWAYS_ENABLED) + if (specifics->lineofsight == F_ALWAYS_ENABLED) return sWorld.getConfig(CONFIG_VMAP_LOS_ENABLED); if (sWorld.getConfig(CONFIG_COREBALANCER_ENABLED)) { - if (GetSpecifics()->lineofsight <= sWorld.GetCoreBalancerTreshold()) + if (specifics->lineofsight <= sWorld.GetCoreBalancerTreshold()) return false; } - return GetSpecifics()->lineofsight != F_ALWAYS_DISABLED && sWorld.getConfig(CONFIG_VMAP_LOS_ENABLED); + return specifics->lineofsight != F_ALWAYS_DISABLED && sWorld.getConfig(CONFIG_VMAP_LOS_ENABLED); } bool TerrainInfo::IsPathFindingEnabled() const { - if (GetSpecifics()->pathfinding == F_ALWAYS_DISABLED) + const TerrainSpecifics* specifics = GetSpecifics(); + if (specifics == nullptr) return false; - if (GetSpecifics()->pathfinding == F_ALWAYS_ENABLED) + if (specifics->pathfinding == F_ALWAYS_DISABLED) + return false; + + if (specifics->pathfinding == F_ALWAYS_ENABLED) return sWorld.getConfig(CONFIG_MMAP_ENABLED); if (sWorld.getConfig(CONFIG_COREBALANCER_ENABLED)) { - if (GetSpecifics()->pathfinding <= sWorld.GetCoreBalancerTreshold()) + if (specifics->pathfinding <= sWorld.GetCoreBalancerTreshold()) return false; } @@ -1114,10 +1129,15 @@ bool TerrainInfo::IsPathFindingEnabled() const float TerrainInfo::GetVisibilityDistance() { + const TerrainSpecifics* specifics = GetSpecifics(); + if (specifics == nullptr) + return DEFAULT_VISIBILITY_DISTANCE; + + float visibility = specifics->visibility; if (sWorld.GetCoreBalancerTreshold() >= CB_VISIBILITY_PENALTY) - return GetSpecifics()->visibility - sWorld.getConfig(CONFIG_COREBALANCER_VISIBILITY_PENALTY); + visibility -= sWorld.getConfig(CONFIG_COREBALANCER_VISIBILITY_PENALTY); - return GetSpecifics()->visibility; + return visibility; } ////////////////////////////////////////////////////////////////////////// diff --git a/src/game/GridMap.h b/src/game/GridMap.h index 80dc093b8..2498151a8 100644 --- a/src/game/GridMap.h +++ b/src/game/GridMap.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_GRIDMAP_H @@ -256,7 +257,7 @@ class HELLGROUND_IMPORT_EXPORT TerrainInfo : public Referencable bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const; bool IsOutdoors(float x, float y, float z) const; - TerrainSpecifics const* GetSpecifics() const { return &specifics; } + TerrainSpecifics const* GetSpecifics() const { return m_specifics; } //this method should be used only by TerrainManager //to cleanup unreferenced GridMap objects - they are too heavy @@ -287,7 +288,7 @@ class HELLGROUND_IMPORT_EXPORT TerrainInfo : public Referencable const uint32 m_mapId; - TerrainSpecifics specifics; + TerrainSpecifics* m_specifics; GridMap *m_GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; int16 m_GridRef[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 6017f502b..a62f08f41 100755 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "GridNotifiers.h" diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 40d87c533..6097627a6 100755 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_GRIDNOTIFIERS_H @@ -33,6 +33,7 @@ #include "Player.h" #include "Unit.h" #include "CreatureAI.h" +#include "SpellAuras.h" class Player; //class Map; @@ -373,7 +374,7 @@ namespace Hellground NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj,uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {} bool operator()(GameObject* go) { - if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range)) + if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range) && go->getLootState() == GO_READY) { i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check return true; @@ -650,7 +651,7 @@ namespace Hellground public: explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0, bool force = false) : m_creature(creature), m_force(force) { - m_range = (dist == 0 ? 9999 : dist); + m_range = (dist == 0 ? 80.0f : dist); } bool operator()(Unit* u) { @@ -767,10 +768,10 @@ namespace Hellground class AnyPlayerInObjectRangeCheck { public: - AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range, bool alive = true) : i_obj(obj), i_range(range), i_alive(alive) {} bool operator()(Player* u) { - if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) + if ((i_alive && u->isAlive() || !i_alive && !u->isAlive()) && i_obj->IsWithinDistInMap(u, i_range)) return true; return false; @@ -778,9 +779,10 @@ namespace Hellground private: WorldObject const* i_obj; float i_range; + bool i_alive; }; - // Searchers used by ScriptedAI + // Searchers used by CreatureAI class MostHPMissingInRange { public: diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 2bfa4926f..94615b04a 100755 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +54,7 @@ inline void PlayerCreatureRelocationWorker(Player* p, Creature* c) return; // Creature AI reaction - if (c->HasReactState(REACT_AGGRESSIVE) && !c->IsInEvadeMode() && c->IsAIEnabled) + if ((c->HasReactState(REACT_AGGRESSIVE) || c->isTrigger()) && !c->IsInEvadeMode() && c->IsAIEnabled) c->AI()->MoveInLineOfSight_Safe(p); } @@ -67,7 +67,7 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) return; // Creature AI reaction - if (c1->HasReactState(REACT_AGGRESSIVE) && !c1->IsInEvadeMode() && c1->IsAIEnabled) + if ((c1->HasReactState(REACT_AGGRESSIVE) || c1->isTrigger()) && !c1->IsInEvadeMode() && c1->IsAIEnabled) c1->AI()->MoveInLineOfSight_Safe(c2); } /* diff --git a/src/game/GridStates.cpp b/src/game/GridStates.cpp index f78e3e625..459f4288e 100755 --- a/src/game/GridStates.cpp +++ b/src/game/GridStates.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "GridStates.h" diff --git a/src/game/GridStates.h b/src/game/GridStates.h index cadcc31be..809919889 100755 --- a/src/game/GridStates.h +++ b/src/game/GridStates.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 9fd81c649..1ce511937 100755 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -32,6 +32,7 @@ #include "MapManager.h" #include "InstanceSaveMgr.h" #include "Util.h" +#include "luaengine/HookMgr.h" Group::Group() { @@ -150,6 +151,9 @@ bool Group::Create(const uint64 &guid, const char * name, bool lfg) if (!isBGGroup()) RealmDataDatabase.CommitTransaction(); + // used by eluna + sHookMgr->OnCreate(this, m_leaderGuid, m_groupType); + return true; } @@ -265,6 +269,9 @@ bool Group::AddInvite(Player *player) player->SetGroupInvite(this); + // used by eluna + sHookMgr->OnInviteMember(this, player->GetGUID()); + return true; } @@ -289,7 +296,10 @@ uint32 Group::RemoveInvite(Player *player) void Group::RemoveAllInvites() { for (InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr) - (*itr)->SetGroupInvite(NULL); + { + if ((*itr)->GetTypeId() == TYPEID_PLAYER) + (*itr)->SetGroupInvite(NULL); + } m_invitees.clear(); } @@ -349,6 +359,9 @@ bool Group::AddMember(const uint64 &guid, const char* name, bool lfg) player->ClearLFG(); player->ClearLFM(); } + + // used by eluna + sHookMgr->OnAddMember(this, player->GetGUID()); } return true; @@ -402,6 +415,9 @@ uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method) else Disband(true); + // used by eluna + sHookMgr->OnRemoveMember(this, guid, method); + return m_memberSlots.size(); } @@ -422,6 +438,9 @@ void Group::ChangeLeader(const uint64 &guid) _setLeader(guid); + // used by eluna + sHookMgr->OnChangeLeader(this, guid, GetLeaderGUID()); + WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size()+1); data << slot->name; BroadcastPacket(&data, false); @@ -485,6 +504,9 @@ bool Group::ChangeLeaderToFirstOnlineMember() void Group::Disband(bool hideDestroy) { + // used by eluna + sHookMgr->OnDisband(this); + Player *player; for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) @@ -858,7 +880,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); if (msg == EQUIP_ERR_OK) { - roll->getLoot()->setItemLooted(item); + roll->getLoot()->setItemLooted(item,player); roll->getLoot()->NotifyItemRemoved(roll->itemSlot); --roll->getLoot()->unlootedCount; @@ -906,7 +928,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, roll->itemid, item->count); if (msg == EQUIP_ERR_OK) { - roll->getLoot()->setItemLooted(item); + roll->getLoot()->setItemLooted(item,player); roll->getLoot()->NotifyItemRemoved(roll->itemSlot); --roll->getLoot()->unlootedCount; @@ -998,6 +1020,19 @@ void Group::SendTargetIconList(WorldSession *session) session->SendPacket(&data); } +uint8 Group::GetMemberFlags(member_citerator &citr) const +{ + uint8 flags = citr->assistant ? MEMBER_FLAG_ASSISTANT : MEMBER_FLAG_NONE; + + if (this->m_mainTank == citr->guid) + flags |= MEMBER_FLAG_MAINTANK; + + if (this->m_mainAssistant == citr->guid) + flags |= MEMBER_FLAG_MAINASSIST; + + return flags; +} + void Group::SendUpdate() { Player *player; @@ -1013,7 +1048,7 @@ void Group::SendUpdate() data << (uint8)m_groupType; // group type data << (uint8)(isBGGroup() ? 1 : 0); // 2.0.x, isBattleGroundGroup? data << (uint8)(citr->group); // groupid - data << (uint8)(citr->assistant?0x01:0); // 0x2 main assist, 0x4 main tank + data << (uint8)GetMemberFlags(citr); // flags data << uint64(0x50000000FFFFFFFELL); // related to voice chat? data << uint32(GetMembersCount()-1); for (member_citerator citr2 = m_memberSlots.begin(); citr2 != m_memberSlots.end(); ++citr2) @@ -1029,7 +1064,7 @@ void Group::SendUpdate() data << (uint64)citr2->guid; data << (uint8)(onlineState); // online-state data << (uint8)(citr2->group); // groupid - data << (uint8)(citr2->assistant?0x01:0); // 0x2 main assist, 0x4 main tank + data << (uint8)GetMemberFlags(citr2); // flags } data << uint64(m_leaderGuid); // leader guid @@ -1399,18 +1434,22 @@ bool Group::_setAssistantFlag(const uint64 &guid, const bool &state) bool Group::_setMainTank(const uint64 &guid) { - member_citerator slot = _getMemberCSlot(guid); - if (slot==m_memberSlots.end()) - return false; + if (guid) + { + member_citerator slot = _getMemberCSlot(guid); + + if (slot == m_memberSlots.end()) + return false; - static SqlStatementID updateMainTank; + if (m_mainAssistant == guid) + _setMainAssistant(0); + } - if (m_mainAssistant == guid) - _setMainAssistant(0); m_mainTank = guid; if (!isBGGroup()) { + static SqlStatementID updateMainTank; SqlStatement stmt = RealmDataDatabase.CreateStatement(updateMainTank, "UPDATE groups SET mainTank = ? WHERE leaderGuid = ?"); stmt.PExecute(GUID_LOPART(m_mainTank), GUID_LOPART(m_leaderGuid)); } @@ -1420,21 +1459,26 @@ bool Group::_setMainTank(const uint64 &guid) bool Group::_setMainAssistant(const uint64 &guid) { - member_witerator slot = _getMemberWSlot(guid); - if (slot==m_memberSlots.end()) - return false; + if (guid) + { + member_witerator slot = _getMemberWSlot(guid); - static SqlStatementID updateMainAssist; + if (slot == m_memberSlots.end()) + return false; + + if (m_mainTank == guid) + _setMainTank(0); + } - if (m_mainTank == guid) - _setMainTank(0); m_mainAssistant = guid; if (!isBGGroup()) { + static SqlStatementID updateMainAssist; SqlStatement stmt = RealmDataDatabase.CreateStatement(updateMainAssist, "UPDATE groups SET mainAssistant = ? WHERE leaderGuid = ?"); stmt.PExecute(GUID_LOPART(m_mainAssistant), GUID_LOPART(m_leaderGuid)); } + return true; } @@ -1552,6 +1596,7 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGround { // check for min / max count uint32 memberscount = GetMembersCount(); + uint32 onlinememberscount = 0; if (memberscount < MinPlayerCount) return BG_JOIN_ERR_GROUP_NOT_ENOUGH; if (memberscount > MaxPlayerCount) @@ -1574,11 +1619,12 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGround // offline member? don't let join if (!member) return BG_JOIN_ERR_OFFLINE_MEMBER; + onlinememberscount++; // don't allow cross-faction join as group if (member->GetTeam() != team) return BG_JOIN_ERR_MIXED_FACTION; // not in the same battleground level bracket, don't let join - if (member->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracket_id) + if (member->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracket_id || member->getLevel() < 10) return BG_JOIN_ERR_MIXED_LEVELS; // don't let join rated matches if the arena team id doesn't match if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId) @@ -1593,6 +1639,8 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGround if (!member->HasFreeBattleGroundQueueId()) return BG_JOIN_ERR_ALL_QUEUES_USED; } + if (memberscount != onlinememberscount) + return BG_JOIN_ERR_OFFLINE_MEMBER; return BG_JOIN_ERR_OK; } diff --git a/src/game/Group.h b/src/game/Group.h index 7afbd1d44..15130a812 100755 --- a/src/game/Group.h +++ b/src/game/Group.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_GROUP_H -#define TRINITYCORE_GROUP_H +#ifndef HELLGROUND_GROUP_H +#define HELLGROUND_GROUP_H #include "GroupReference.h" #include "GroupRefManager.h" @@ -43,6 +43,14 @@ enum RollVote NOT_VALID = 4 }; +enum GroupMemberFlags +{ + MEMBER_FLAG_NONE = 0x00, + MEMBER_FLAG_ASSISTANT = 0x01, + MEMBER_FLAG_MAINTANK = 0x02, + MEMBER_FLAG_MAINASSIST = 0x04 +}; + enum GroupMemberOnlineStatus { MEMBER_STATUS_OFFLINE = 0x0000, @@ -54,6 +62,7 @@ enum GroupMemberOnlineStatus MEMBER_STATUS_UNK3 = 0x0020, // never seen MEMBER_STATUS_UNK4 = 0x0040, // appears with dead and ghost flags MEMBER_STATUS_UNK5 = 0x0080, // never seen + MEMBER_STATUS_RAF = 0x0100, // RAF status in party/raid }; enum GroupType @@ -243,7 +252,8 @@ class HELLGROUND_IMPORT_EXPORT Group GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); } uint32 GetMembersCount() const { return m_memberSlots.size(); } void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level); - uint8 GetMemberGroup(uint64 guid) const + uint8 GetMemberFlags(member_citerator &citr) const; + uint8 GetMemberGroup(uint64 guid) const { member_citerator mslot = _getMemberCSlot(guid); if (mslot==m_memberSlots.end()) diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 8f377a5a6..9a2341027 100755 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,6 +94,10 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data) SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_NOT_IN_YOUR_INSTANCE); return; } + if (sWorld.getConfig(CONFIG_FFA_DISALLOWGROUP) && (player->IsFFAPvP() || GetPlayer()->IsFFAPvP())){ + SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU); + return; + } // just ignore us if (player->GetInstanceId() != 0 && player->GetDifficulty() != GetPlayer()->GetDifficulty()) { @@ -435,7 +439,7 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) data << GetPlayer()->GetGUID(); data << x; data << y; - GetPlayer()->GetGroup()->BroadcastPacket(&data, -1, GetPlayer()->GetGUID()); + GetPlayer()->GetGroup()->BroadcastPacket(&data, false, -1, GetPlayer()->GetGUID()); } void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) @@ -575,7 +579,7 @@ void WorldSession::HandleGroupAssistantOpcode(WorldPacket & recv_data) /********************/ // everything's fine, do it - group->SetAssistant(guid, (flag==0?false:true)); + group->SetAssistant(guid, flag == 0 ? false : true); } void WorldSession::HandleGroupPromoteOpcode(WorldPacket & recv_data) @@ -586,24 +590,20 @@ void WorldSession::HandleGroupPromoteOpcode(WorldPacket & recv_data) if (!group) return; - uint8 flag1, flag2; + uint8 mainAssistant, mainTank; uint64 guid; - recv_data >> flag1 >> flag2; + recv_data >> mainAssistant >> mainTank; recv_data >> guid; - // if (flag1) Main Assist - // 0x4 - // if (flag2) Main Tank - // 0x2 /** error handling **/ - if (!group->IsLeader(GetPlayer()->GetGUID())) + if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) return; /********************/ // everything's fine, do it - if (flag1 == 1) + if (mainAssistant) group->SetMainAssistant(guid); - if (flag2 == 1) + else group->SetMainTank(guid); } @@ -839,9 +839,11 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recv_data) if (pet) mask1 = 0x7FFFFFFF; // for hunters and other classes with pets + uint16 online_status = GetPlayer()->IsReferAFriendLinked(player) ? (MEMBER_STATUS_ONLINE | MEMBER_STATUS_RAF) : MEMBER_STATUS_ONLINE; + Powers powerType = player->getPowerType(); data << (uint32) mask1; // group update mask - data << (uint16) MEMBER_STATUS_ONLINE; // member's online status + data << (uint16) online_status; // member's online status data << (uint16) player->GetHealth(); // GROUP_UPDATE_FLAG_CUR_HP data << (uint16) player->GetMaxHealth(); // GROUP_UPDATE_FLAG_MAX_HP data << (uint8) powerType; // GROUP_UPDATE_FLAG_POWER_TYPE diff --git a/src/game/GroupRefManager.h b/src/game/GroupRefManager.h index ce8b3b595..622f21afe 100755 --- a/src/game/GroupRefManager.h +++ b/src/game/GroupRefManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _GROUPREFMANAGER -#define _GROUPREFMANAGER +#ifndef HELLGROUND_GROUPREFMANAGER_H +#define HELLGROUND_GROUPREFMANAGER_H #include "Utilities/LinkedReference/RefManager.h" diff --git a/src/game/GroupReference.cpp b/src/game/GroupReference.cpp index 24646e305..4a88e7c9d 100755 --- a/src/game/GroupReference.cpp +++ b/src/game/GroupReference.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/GroupReference.h b/src/game/GroupReference.h index 838f8405d..7f990d55f 100755 --- a/src/game/GroupReference.h +++ b/src/game/GroupReference.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _GROUPREFERENCE_H -#define _GROUPREFERENCE_H +#ifndef HELLGROUND_GROUPREFERENCE_H +#define HELLGROUND_GROUPREFERENCE_H #include "Utilities/LinkedReference/Reference.h" diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index a54288cd9..af3bba28e 100755 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,7 +121,7 @@ void GuardAI::UpdateAI(const uint32 /*diff*/) bool GuardAI::IsVisible(Unit *pl) const { - return m_creature->IsWithinDistInMap(pl,sWorld.getConfig(CONFIG_SIGHT_GUARDER)) && + return m_creature->IsWithinDistInMap(pl,sWorld.getConfig(CONFIG_SIGHT_GUARD)) && pl->isVisibleForOrDetect(m_creature, m_creature, true); } diff --git a/src/game/GuardAI.h b/src/game/GuardAI.h index fab3fa4ab..99ef18b46 100755 --- a/src/game/GuardAI.h +++ b/src/game/GuardAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 7bc9e4857..c50529238 100755 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Database/DatabaseEnv.h" @@ -29,6 +29,8 @@ #include "Chat.h" #include "SocialMgr.h" #include "Util.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" Guild::Guild() { @@ -46,6 +48,7 @@ Guild::Guild() CreatedYear = 0; CreatedMonth = 0; CreatedDay = 0; + m_guildFlags = 0; } Guild::~Guild() @@ -60,7 +63,7 @@ bool Guild::create(uint64 lGuid, std::string gname) if (!sObjectMgr.GetPlayerNameByGUID(lGuid, lName)) return false; - if (sObjectMgr.GetGuildByName(gname)) + if (sGuildMgr.GetGuildByName(gname)) return false; sLog.outLog(LOG_SPECIAL, "GUILD: creating guild %s to leader: %u", gname.c_str(), GUID_LOPART(lGuid)); @@ -72,7 +75,7 @@ bool Guild::create(uint64 lGuid, std::string gname) guildbank_money = 0; purchased_tabs = 0; - Id = sObjectMgr.GenerateGuildId(); + Id = sGuildMgr.GenerateGuildId(); // gname already assigned to Guild::name, use it to encode string for DB RealmDataDatabase.escape_string(gname); @@ -102,6 +105,11 @@ bool Guild::create(uint64 lGuid, std::string gname) rname = "Initiate"; CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + Player* leader = sObjectMgr.GetPlayer(leaderGuid); + + // used by eluna + sHookMgr->OnCreate(this, leader, gname.c_str()); + return AddMember(lGuid, (uint32)GR_GUILDMASTER); } @@ -159,6 +167,9 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank) UpdateAccountsCount(); + // used by eluna + sHookMgr->OnAddMember(this, pl, newmember.RankId); + return true; } @@ -169,6 +180,9 @@ void Guild::SetMOTD(std::string motd) // motd now can be used for encoding to DB RealmDataDatabase.escape_string(motd); RealmDataDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), Id); + + // used by eluna + sHookMgr->OnMOTDChanged(this, motd); } void Guild::SetGINFO(std::string ginfo) @@ -178,6 +192,9 @@ void Guild::SetGINFO(std::string ginfo) // ginfo now can be used for encoding to DB RealmDataDatabase.escape_string(ginfo); RealmDataDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), Id); + + // used by eluna + sHookMgr->OnInfoChanged(this, ginfo); } bool Guild::LoadGuildFromDB(uint32 GuildId) @@ -523,6 +540,9 @@ void Guild::DelMember(uint64 guid, bool isDisbanding) RealmDataDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid)); UpdateAccountsCount(); + + // used by eluna + sHookMgr->OnRemoveMember(this, player, isDisbanding); } void Guild::ChangeRank(uint64 guid, uint32 newRank) @@ -565,7 +585,7 @@ void Guild::SetOFFNOTE(uint64 guid,std::string offnote) void Guild::BroadcastToGuild(WorldSession *session, const std::string& msg, uint32 language) { - if (session && (session->GetPermissions() & PERM_GMT || (session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)))) + if (session && (session->HasPermissions(PERM_GMT) || (session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK)))) { WorldPacket data; ChatHandler(session).FillMessageData(&data, CHAT_MSG_GUILD, language, 0, msg.c_str()); @@ -724,7 +744,11 @@ void Guild::Disband() RealmDataDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'",Id); RealmDataDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'",Id); RealmDataDatabase.CommitTransaction(); - sObjectMgr.RemoveGuild(Id); + + // used by eluna + sHookMgr->OnDisband(this); + + sGuildMgr.RemoveGuild(Id); } void Guild::WriteMemberRosterPacket(Player *sessionPlayer, const MemberSlot &member, Player *pl, WorldPacket &data) @@ -750,7 +774,7 @@ void Guild::WriteMemberRosterPacket(Player *sessionPlayer, const MemberSlot &mem data << pZoneId; data << member.Pnote; - data << member.OFFnote; + data << (HasRankRight(sessionPlayer->GetRank(), GR_RIGHT_VIEWOFFNOTE) ? member.OFFnote : ""); }else{ data << uint64(MAKE_NEW_GUID(member.guid, 0, HIGHGUID_PLAYER)); data << uint8(0); @@ -762,11 +786,10 @@ void Guild::WriteMemberRosterPacket(Player *sessionPlayer, const MemberSlot &mem data << uint32(member.zoneId); data << float((time(NULL)-member.logout_time)) / DAY; data << member.Pnote; - data << member.OFFnote; + data << (HasRankRight(sessionPlayer->GetRank(), GR_RIGHT_VIEWOFFNOTE) ? member.OFFnote : ""); } } - void Guild::Roster(WorldSession *session) { // Blizz proof: While approximately 500 members were visible in the UI, there was no real need to limit guild size. That is no longer the case. Guild leveling in Cataclysm features ... @@ -1388,6 +1411,13 @@ bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid) RealmDataDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", itr->second.BankRemMoney, Id, LowGuid); } + + // Trigger OnMemberWitdrawMoney event + Player* player = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, LowGuid)); + + // used by eluna + sHookMgr->OnMemberWitdrawMoney(this, player, amount, false); // IsRepair not a part of Mangos, implement? + return true; } @@ -1736,6 +1766,10 @@ void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint } m_GuildBankEventLog_Item[TabId].push_back(NewEvent); } + + // used by eluna + sHookMgr->OnBankEvent(this, LogEntry, TabId, PlayerGuidLow, ItemOrMoney, ItemStackCount, DestTabId); + RealmDataDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "')", Id, NewEvent->LogGuid, uint32(NewEvent->LogEntry), uint32(TabId), NewEvent->PlayerGuid, NewEvent->ItemOrMoney, uint32(NewEvent->ItemStackCount), uint32(NewEvent->DestTabId), NewEvent->TimeStamp); } @@ -1779,7 +1813,7 @@ void Guild::AppendDisplayGuildBankSlot(WorldPacket& data, GuildBankTab const *ta // +12 // ITEM_FIELD_STACK_COUNT data << uint8(pItem->GetCount()); data << uint32(0); // +16 // Unknown value - data << uint8(0); // unknown 2.4.2 + data << uint8(abs(pItem->GetSpellCharges())); // charges if (uint32 Enchant0 = pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)) { data << uint8(1); // number of enchantments (max 3) why max 3? @@ -1916,7 +1950,7 @@ uint8 Guild::_CanStoreItem_InSpecificSlot(uint8 tab, uint8 slot, GuildItemPosCou uint8 Guild::_CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot) const { - for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; j++) + for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; ++j) { // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot if (j==skip_slot) diff --git a/src/game/Guild.h b/src/game/Guild.h index b4ad9bef6..bd1ec9c17 100755 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,14 +18,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_GUILD_H -#define TRINITYCORE_GUILD_H +#ifndef HELLGROUND_GUILD_H +#define HELLGROUND_GUILD_H #define WITHDRAW_MONEY_UNLIMITED 0xFFFFFFFF #define WITHDRAW_SLOT_UNLIMITED 0xFFFFFFFF #define MAX_ROSTER_MEMBERS 499 #include "Item.h" +#include "ObjectAccessor.h" class Item; diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 0eaef3996..b3ba8bd2b 100755 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,8 @@ #include "MapManager.h" #include "GossipDef.h" #include "SocialMgr.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) { @@ -41,7 +43,7 @@ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) recvPacket >> guildId; - guild = sObjectMgr.GetGuildById(guildId); + guild = sGuildMgr.GetGuildById(guildId); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -51,29 +53,6 @@ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) guild->Query(this); } -void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) -{ - CHECK_PACKET_SIZE(recvPacket, 1); - - std::string gname; - - //sLog.outDebug("WORLD: Received CMSG_GUILD_CREATE"); - - recvPacket >> gname; - - if (GetPlayer()->GetGuildId()) - return; - - Guild *guild = new Guild; - if (!guild->create(GetPlayer()->GetGUID(),gname)) - { - delete guild; - return; - } - - sObjectMgr.AddGuild(guild); -} - void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) { CHECK_PACKET_SIZE(recvPacket, 1); @@ -95,7 +74,7 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) return; } - Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -160,7 +139,7 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(plName)) return; - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -206,7 +185,7 @@ void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/) //sLog.outDebug("WORLD: Received CMSG_GUILD_ACCEPT"); - guild = sObjectMgr.GetGuildById(player->GetGuildIdInvited()); + guild = sGuildMgr.GetGuildById(player->GetGuildIdInvited()); if (!guild || player->GetGuildId()) return; @@ -241,7 +220,7 @@ void WorldSession::HandleGuildInfoOpcode(WorldPacket& /*recvPacket*/) Guild *guild; //sLog.outDebug("WORLD: Received CMSG_GUILD_INFO"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -263,7 +242,7 @@ void WorldSession::HandleGuildRosterOpcode(WorldPacket& /*recvPacket*/) { //sLog.outDebug("WORLD: Received CMSG_GUILD_ROSTER"); - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) return; @@ -283,7 +262,7 @@ void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(plName)) return; - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -341,7 +320,7 @@ void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(plName)) return; - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { @@ -393,7 +372,7 @@ void WorldSession::HandleGuildLeaveOpcode(WorldPacket& /*recvPacket*/) //sLog.outDebug("WORLD: Received CMSG_GUILD_LEAVE"); - guild = sObjectMgr.GetGuildById(_player->GetGuildId()); + guild = sGuildMgr.GetGuildById(_player->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -435,7 +414,7 @@ void WorldSession::HandleGuildDisbandOpcode(WorldPacket& /*recvPacket*/) //sLog.outDebug("WORLD: Received CMSG_GUILD_DISBAND"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -467,7 +446,7 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(name)) return; - guild = sObjectMgr.GetGuildById(oldLeader->GetGuildId()); + guild = sGuildMgr.GetGuildById(oldLeader->GetGuildId()); if (!guild) { @@ -510,7 +489,7 @@ void WorldSession::HandleGuildMOTDOpcode(WorldPacket& recvPacket) //sLog.outDebug("WORLD: Received CMSG_GUILD_MOTD"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -551,7 +530,7 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(name)) return; - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -592,7 +571,7 @@ void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket) if (!normalizePlayerName(plName)) return; - Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -633,7 +612,7 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) //sLog.outDebug("WORLD: Received CMSG_GUILD_RANK"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -680,7 +659,7 @@ void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket) //sLog.outDebug("WORLD: Received CMSG_GUILD_ADD_RANK"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -711,7 +690,7 @@ void WorldSession::HandleGuildDelRankOpcode(WorldPacket& /*recvPacket*/) //sLog.outDebug("WORLD: Received CMSG_GUILD_DEL_RANK"); - guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -751,7 +730,7 @@ void WorldSession::HandleGuildChangeInfoOpcode(WorldPacket& recvPacket) recvPacket >> GINFO; - Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); @@ -802,7 +781,7 @@ void WorldSession::HandleGuildSaveEmblemOpcode(WorldPacket& recvPacket) recvPacket >> BorderColor; recvPacket >> BackgroundColor; - Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); if (!guild) { //"You are not part of a guild!"; @@ -843,7 +822,7 @@ void WorldSession::HandleGuildEventLogOpcode(WorldPacket& /* recvPacket */) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -861,7 +840,7 @@ void WorldSession::HandleGuildBankGetMoneyAmount(WorldPacket & /* recv_data */) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -876,7 +855,7 @@ void WorldSession::HandleGuildBankGetRights(WorldPacket& /* recv_data */) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -911,7 +890,7 @@ void WorldSession::HandleGuildBankQuery(WorldPacket & recv_data) if (uint32 GuildId = GetPlayer()->GetGuildId()) { - if (Guild *pGuild = sObjectMgr.GetGuildById(GuildId)) + if (Guild *pGuild = sGuildMgr.GetGuildById(GuildId)) { pGuild->DisplayGuildBankTabsInfo(this); return; @@ -937,7 +916,7 @@ void WorldSession::HandleGuildBankTabColon(WorldPacket & recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -966,7 +945,7 @@ void WorldSession::HandleGuildBankDeposit(WorldPacket & recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -988,12 +967,15 @@ void WorldSession::HandleGuildBankDeposit(WorldPacket & recv_data) } // logging money - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", _player->GetName(),_player->GetSession()->GetAccountId(),money,GuildId); } + // used by eluna + sHookMgr->OnMemberDepositMoney(pGuild, GetPlayer(), money); + // log pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money); @@ -1020,7 +1002,7 @@ void WorldSession::HandleGuildBankWithdraw(WorldPacket & recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -1127,7 +1109,7 @@ void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -1392,7 +1374,7 @@ void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data) if (pItemChar) { // logging item move to bank - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), @@ -1469,7 +1451,7 @@ void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data) } // logging item move to bank (before items merge - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), @@ -1502,7 +1484,7 @@ void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data) if (msg == EQUIP_ERR_OK) // merge { // logging item move to bank - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), @@ -1560,7 +1542,7 @@ void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data) } // logging item move to bank - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), @@ -1617,11 +1599,11 @@ void WorldSession::HandleGuildBankBuyTab(WorldPacket & recv_data) if (GuildId==0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; - uint32 TabCost = sObjectMgr.GetGuildBankTabPrice(TabId) * GOLD; + uint32 TabCost = sGuildMgr.GetGuildBankTabPrice(TabId) * GOLD; if (!TabCost) return; @@ -1676,7 +1658,7 @@ void WorldSession::HandleGuildBankModifyTab(WorldPacket & recv_data) if (GuildId==0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -1694,7 +1676,7 @@ void WorldSession::HandleGuildBankLog(WorldPacket & recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -1713,7 +1695,7 @@ void WorldSession::HandleGuildBankTabText(WorldPacket &recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; @@ -1732,7 +1714,7 @@ void WorldSession::HandleGuildBankSetTabText(WorldPacket &recv_data) if (GuildId == 0) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; diff --git a/src/game/GuildMgr.cpp b/src/game/GuildMgr.cpp new file mode 100644 index 000000000..c922d2ada --- /dev/null +++ b/src/game/GuildMgr.cpp @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "GuildMgr.h" + +#include "Database/DatabaseEnv.h" +#include "Database/SQLStorage.h" +#include "Database/SQLStorageImpl.h" + +#include "Common.h" +#include "SharedDefines.h" +#include "Guild.h" +#include "ProgressBar.h" +#include "World.h" +#include "Log.h" + +GuildMgr::GuildMgr() +{ + m_guildId = 1; + + m_guildBankTabPrices.resize( GUILD_BANK_MAX_TABS ); + m_guildBankTabPrices[0] = 100; + m_guildBankTabPrices[1] = 250; + m_guildBankTabPrices[2] = 500; + m_guildBankTabPrices[3] = 1000; + m_guildBankTabPrices[4] = 2500; + m_guildBankTabPrices[5] = 5000; +} + +GuildMgr::~GuildMgr() +{ + for (GuildMap::iterator itr = m_guildsMap.begin(); itr != m_guildsMap.end(); ++itr) + delete itr->second; + + m_guildsMap.clear(); +} + + +Guild * GuildMgr::GetGuildById(const uint32 & GuildId) const +{ + GuildMap::const_iterator itr = m_guildsMap.find(GuildId); + if (itr != m_guildsMap.end()) + return itr->second; + + return nullptr; +} + +Guild * GuildMgr::GetGuildByName(const std::string& guildname) const +{ + std::string search = guildname; + std::transform(search.begin(), search.end(), search.begin(), toupper); + for (GuildMap::const_iterator itr = m_guildsMap.begin(); itr != m_guildsMap.end(); ++itr) + { + std::string gname = itr->second->GetName(); + std::transform(gname.begin(), gname.end(), gname.begin(), toupper); + if (search == gname) + return itr->second; + } + return nullptr; +} + +std::string GuildMgr::GetGuildNameById(const uint32 & GuildId) const +{ + GuildMap::const_iterator itr = m_guildsMap.find(GuildId); + if (itr != m_guildsMap.end()) + return itr->second->GetName(); + + return ""; +} + +Guild* GuildMgr::GetGuildByLeader(const uint64 &guid) const +{ + for (GuildMap::const_iterator itr = m_guildsMap.begin(); itr != m_guildsMap.end(); ++itr) + if (itr->second->GetLeader() == guid) + return itr->second; + + return nullptr; +} + +void GuildMgr::AddGuild(Guild* guild) +{ + m_guildsMap[guild->GetId()] = guild; +} + +void GuildMgr::RemoveGuild(const uint32 & Id) +{ + m_guildsMap.erase(Id); +} + +uint32 GuildMgr::GetGuildBankTabPrice( const uint8 & Index ) const +{ + return Index < GUILD_BANK_MAX_TABS ? m_guildBankTabPrices[Index] : 0; +} + +void GuildMgr::LoadGuildAnnCooldowns() +{ + uint32 count = 0; + + QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guild_id, cooldown_end FROM guild_announce_cooldown"); + + if (!result) + { + BarGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outString(">> Loaded 0 guildann_cooldowns."); + return; + } + + BarGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 guild_id = fields[0].GetUInt32(); + uint64 respawn_time = fields[1].GetUInt64(); + + m_guildCooldownTimes[guild_id] = time_t(respawn_time); + + ++count; + } while (result->NextRow()); + + sLog.outString(">> Loaded %u guild ann cooldowns.", m_guildCooldownTimes.size()); + sLog.outString(); +} + + +void GuildMgr::LoadGuilds() +{ + Guild *newguild; + uint32 count = 0; + + QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guildid FROM guild"); + + if (!result) + { + + BarGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outString(">> Loaded %u guild definitions", count); + return; + } + + BarGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + ++count; + + newguild = new Guild; + if ( !newguild->LoadGuildFromDB( fields[0].GetUInt32() ) ) + { + newguild->Disband(); + delete newguild; + continue; + } + AddGuild(newguild); + + } + while ( result->NextRow( )); + + + result = RealmDataDatabase.Query("SELECT MAX(guildid) FROM guild"); + if (result) + m_guildId = (*result)[0].GetUInt32()+1; + + sLog.outString(); + sLog.outString(">> Loaded %u guild definitions, next guild ID: %u", count, m_guildId); +} + + +uint32 GuildMgr::GenerateGuildId() +{ + if (m_guildId >= 0xFFFFFFFE) + { + sLog.outLog(LOG_DEFAULT, "ERROR: Guild ids overflow!! Can't continue, shutting down server. "); + World::StopNow(ERROR_EXIT_CODE); + } + return m_guildId++; +} + +void GuildMgr::SaveGuildAnnCooldown(uint32 guild_id) +{ + time_t tmpTime = time_t(time(NULL) + sWorld.getConfig(CONFIG_GUILD_ANN_COOLDOWN)); + m_guildCooldownTimes[guild_id] = tmpTime; + RealmDataDatabase.PExecute("REPLACE INTO guild_announce_cooldown VALUES ('%u', '" UI64FMTD "')", guild_id, uint64(tmpTime)); +} diff --git a/src/game/GuildMgr.h b/src/game/GuildMgr.h new file mode 100644 index 000000000..59bcc18ca --- /dev/null +++ b/src/game/GuildMgr.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_GUILDMGR_H +#define HELLGROUND_GUILDMGR_H + +#include "ace/Singleton.h" +#include "Utilities/UnorderedMap.h" + +class Guild; + +typedef UNORDERED_MAP< uint32, Guild * > GuildMap; +typedef std::vector< uint32 > GuildBankTabPriceMap; +typedef UNORDERED_MAP GuildCooldowns; + +class GuildMgr +{ + friend class ACE_Singleton; + GuildMgr(); + + public: + ~GuildMgr(); + + uint32 GenerateGuildId(); + + Guild* GetGuildByLeader( const uint64 & guid ) const; + Guild* GetGuildById( const uint32 & GuildId ) const; + Guild* GetGuildByName( const std::string & guildname ) const; + + std::string GetGuildNameById( const uint32 & GuildId ) const; + + void AddGuild( Guild* guild) ; + void RemoveGuild( const uint32 & Id ); + + void LoadGuilds(); + void LoadGuildAnnCooldowns(); + + time_t GetGuildAnnCooldown(uint32 guild_id) { return m_guildCooldownTimes[guild_id]; } + void SaveGuildAnnCooldown(uint32 guild_id); + + // guild bank tabs + uint32 GetGuildBankTabPrice( const uint8 & Index ) const; + + protected: + uint32 m_guildId; + GuildMap m_guildsMap; + GuildCooldowns m_guildCooldownTimes; + GuildBankTabPriceMap m_guildBankTabPrices; + +}; + +#define sGuildMgr (*ACE_Singleton::instance()) + +#endif diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp index 5e13ddc59..514570401 100755 --- a/src/game/HomeMovementGenerator.cpp +++ b/src/game/HomeMovementGenerator.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,6 +77,13 @@ void HomeMovementGenerator::Finalize(Creature& owner) owner.AI()->JustReachedHome(); - owner.AddEvent(new RestoreReactState(owner), sWorld.getConfig(CONFIG_CREATURE_RESTORE_STATE)); + BasicEvent* event = new RestoreReactState(owner); + if (owner.GetEvents()->HasEventOfType(event)) + { + delete event; + return; + } + + owner.AddEvent(event, sWorld.getConfig(CONFIG_CREATURE_RESTORE_STATE)); } } diff --git a/src/game/HomeMovementGenerator.h b/src/game/HomeMovementGenerator.h index 1f66d3a67..3ba6dc89c 100755 --- a/src/game/HomeMovementGenerator.h +++ b/src/game/HomeMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/HostilRefManager.cpp b/src/game/HostileRefManager.cpp old mode 100755 new mode 100644 similarity index 71% rename from src/game/HostilRefManager.cpp rename to src/game/HostileRefManager.cpp index 8a1074437..3883fa88e --- a/src/game/HostilRefManager.cpp +++ b/src/game/HostileRefManager.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "HostilRefManager.h" +#include "HostileRefManager.h" #include "ThreatManager.h" #include "Unit.h" #include "DBCStructure.h" #include "SpellMgr.h" -HostilRefManager::~HostilRefManager() +HostileRefManager::~HostileRefManager() { deleteReferences(); } @@ -34,12 +34,12 @@ HostilRefManager::~HostilRefManager() // The pVictim is hated than by them as well // use for buffs and healing threat functionality -void HostilRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) +void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { if (iOwner->hasUnitState(UNIT_STAT_IGNORE_ATTACKERS)) return; - HostilReference* ref; + HostileReference* ref; uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not divide threat ref = getFirst(); @@ -56,56 +56,40 @@ void HostilRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry con //================================================= -void HostilRefManager::addThreatPercent(int32 pValue) +void HostileRefManager::addThreatPercent(int32 pValue) { - HostilReference* ref; - - ref = getFirst(); - while (ref != NULL) - { + for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->addThreatPercent(pValue); - ref = ref->next(); - } } //================================================= // The online / offline status is given to the method. The calculation has to be done before -void HostilRefManager::setOnlineOfflineState(bool pIsOnline) +void HostileRefManager::setOnlineOfflineState(bool pIsOnline) { - HostilReference* ref; - - ref = getFirst(); - while (ref != NULL) - { + for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->setOnlineOfflineState(pIsOnline); - ref = ref->next(); - } } //================================================= // The online / offline status is calculated and set -void HostilRefManager::updateThreatTables() +void HostileRefManager::updateThreatTables() { - HostilReference* ref = getFirst(); - while (ref) - { + for (HostileReference* ref = getFirst(); ref != NULL; ref = ref->next()) ref->updateOnlineStatus(); - ref = ref->next(); - } } //================================================= // The references are not needed anymore // tell the source to remove them from the list and free the mem -void HostilRefManager::deleteReferences() +void HostileRefManager::deleteReferences() { - HostilReference* ref = getFirst(); + HostileReference* ref = getFirst(); while (ref) { - HostilReference* nextRef = ref->next(); + HostileReference* nextRef = ref->next(); ref->removeReference(); delete ref; ref = nextRef; @@ -115,12 +99,12 @@ void HostilRefManager::deleteReferences() //================================================= // delete one reference, defined by Unit -void HostilRefManager::deleteReference(Unit *pCreature) +void HostileRefManager::deleteReference(Unit *pCreature) { - HostilReference* ref = getFirst(); + HostileReference* ref = getFirst(); while (ref) { - HostilReference* nextRef = ref->next(); + HostileReference* nextRef = ref->next(); if (ref->getSource()->getOwner() == pCreature) { ref->removeReference(); @@ -134,12 +118,12 @@ void HostilRefManager::deleteReference(Unit *pCreature) //================================================= // set state for one reference, defined by Unit -void HostilRefManager::setOnlineOfflineState(Unit *pCreature,bool pIsOnline) +void HostileRefManager::setOnlineOfflineState(Unit *pCreature,bool pIsOnline) { - HostilReference* ref = getFirst(); + HostileReference* ref = getFirst(); while (ref) { - HostilReference* nextRef = ref->next(); + HostileReference* nextRef = ref->next(); if (ref->getSource()->getOwner() == pCreature) { ref->setOnlineOfflineState(pIsOnline); diff --git a/src/game/HostilRefManager.h b/src/game/HostileRefManager.h old mode 100755 new mode 100644 similarity index 76% rename from src/game/HostilRefManager.h rename to src/game/HostileRefManager.h index fa99c8691..9b9b0bcce --- a/src/game/HostilRefManager.h +++ b/src/game/HostileRefManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,26 +18,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _HOSTILEREFMANAGER -#define _HOSTILEREFMANAGER +#ifndef HELLGROUND_HOSTILEREFMANAGER_H +#define HELLGROUND_HOSTILEREFMANAGER_H #include "Common.h" #include "Utilities/LinkedReference/RefManager.h" class Unit; class ThreatManager; -class HostilReference; +class HostileReference; struct SpellEntry; //================================================= -class HostilRefManager : public RefManager +class HostileRefManager : public RefManager { private: Unit *iOwner; public: - explicit HostilRefManager(Unit *pOwner) { iOwner = pOwner; } - ~HostilRefManager(); + explicit HostileRefManager(Unit *pOwner) { iOwner = pOwner; } + ~HostileRefManager(); Unit* getOwner() { return iOwner; } @@ -52,7 +52,7 @@ class HostilRefManager : public RefManager // tell the source to remove them from the list and free the mem void deleteReferences(); - HostilReference* getFirst() { return ((HostilReference*) RefManager::getFirst()); } + HostileReference* getFirst() { return ((HostileReference*) RefManager::getFirst()); } void updateThreatTables(); diff --git a/src/game/IdleMovementGenerator.cpp b/src/game/IdleMovementGenerator.cpp index 02b2340ec..5ff2d7966 100755 --- a/src/game/IdleMovementGenerator.cpp +++ b/src/game/IdleMovementGenerator.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/IdleMovementGenerator.h b/src/game/IdleMovementGenerator.h index 45efe7073..2e1b86e38 100755 --- a/src/game/IdleMovementGenerator.h +++ b/src/game/IdleMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index 7dc79b6c9..d3182f39a 100755 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "InstanceData.h" #include "Database/DatabaseEnv.h" #include "Map.h" #include "GameObject.h" #include "Creature.h" +#include "MapRefManager.h" +#include "MapReference.h" +#include "Language.h" +#include "Player.h" void InstanceData::SaveToDB() { @@ -181,3 +187,66 @@ void InstanceData::ResetEncounterInProgress() // this will only reset encounter state to NOT_STARTED, it won't evade creatures inside of map, better option is to override it in instance script Load(GetSaveData().c_str()); } + +void InstanceData::HandleInitCreatureState(Creature * mob) +{ + if (mob == nullptr) + return; + + const CreatureData *tmp = mob->GetLinkedRespawnCreatureData(); + if (!tmp) + return; + + uint32 encounter = GetEncounterForEntry(tmp->id); + + if (encounter && mob->isAlive() && GetData(encounter) == DONE) + { + mob->setDeathState(JUST_DIED); + mob->RemoveCorpse(); + return; + } + + encounter = GetRequiredEncounterForEntry(tmp->id); + + if (encounter && mob->isAlive() && GetData(encounter) != DONE) + { + mob->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + requiredEncounterToMobs[encounter].push_back(mob->GetGUID()); + } +} + +void InstanceData::HandleRequiredEncounter(uint32 encounter) +{ + if (GetData(encounter) != DONE) + return; + + auto itr = requiredEncounterToMobs.find(encounter); + if (itr != requiredEncounterToMobs.end()) + { + std::vector & tmpVec = itr->second; + + std::for_each(tmpVec.begin(), tmpVec.end(), [this] (uint64& var) + { + Creature * tmp = GetCreature(var); + if (tmp != nullptr) + tmp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + }); + } +} + +void InstanceData::LogPossibleCheaters(const char* cheatName) +{ + std::string playerlist=""; + Map::PlayerList players = instance->GetPlayers(); + if (Player* pPlayer = players.getFirst()->getSource()) + { + for (MapRefManager::iterator itr = players.begin(); itr != players.end(); ++itr) + { + playerlist += itr->getSource()->GetName(); + playerlist += " "; + } + sLog.outLog(LOG_CHEAT,"Possible cheaters(%s): %s",cheatName,playerlist.c_str()); + + sWorld.SendGMText(LANG_POSSIBLE_CHEAT, cheatName, pPlayer->GetName(),playerlist.c_str()); + } +} diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index d56382e39..693d39530 100755 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,10 +21,13 @@ #ifndef HELLGROUND_INSTANCE_DATA_H #define HELLGROUND_INSTANCE_DATA_H +#include + #include "ZoneScript.h" //#include "GameObject.h" #include "Map.h" + class Map; class Unit; class Player; @@ -125,7 +128,12 @@ class HELLGROUND_IMPORT_EXPORT InstanceData : public ZoneScript Creature *GetCreature(uint64 guid){ return instance->GetCreature(guid); } virtual uint32 GetEncounterForEntry(uint32 entry) { return 0; } + virtual uint32 GetRequiredEncounterForEntry(uint32 entry) { return 0; } + + virtual void HandleInitCreatureState(Creature * mob); + virtual void HandleRequiredEncounter(uint32 encounter); + void LogPossibleCheaters(const char* cheatName); protected: void SetBossNumber(uint32 number) { bosses.resize(number); } void LoadDoorData(const DoorData *data); @@ -135,10 +143,14 @@ class HELLGROUND_IMPORT_EXPORT InstanceData : public ZoneScript std::string LoadBossState(const char * data); std::string GetBossSaveData(); + + UNORDERED_MAP > requiredEncounterToMobs; + private: std::vector bosses; DoorInfoMap doors; + virtual void OnObjectCreate(GameObject *) {} virtual void OnCreatureCreate(Creature *, uint32 entry) {} }; diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index af4eee7f1..d83e010f9 100755 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -1,8 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity - * + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,8 +58,14 @@ void InstanceSaveManager::UnbindBeforeDelete() for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end(); ++itr) { InstanceSave *save = itr->second; + if (save == nullptr) + continue; + for (InstanceSave::PlayerListType::iterator itr2 = save->m_playerList.begin(); itr2 != save->m_playerList.end(); ++itr2) - (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); + { + if (Player* player = sObjectMgr.GetPlayer(*itr2)) + player->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); + } save->m_playerList.clear(); @@ -68,7 +73,9 @@ void InstanceSaveManager::UnbindBeforeDelete() (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); save->m_groupList.clear(); + delete save; + itr->second = nullptr; } m_instanceSaveById.clear(); @@ -200,6 +207,11 @@ time_t InstanceSave::GetResetTimeForDB() return GetResetTime(); } +bool InstanceSave::HasPlayer(uint64 guid) +{ + return std::any_of(m_playerList.begin(), m_playerList.end(), [guid](uint64 p) { return p == guid; }); +} + // to cache or not to cache, that is the question InstanceTemplate const* InstanceSave::GetTemplate() { @@ -512,6 +524,9 @@ void InstanceSaveManager::Update() static int tim[4] = {3600, 900, 300, 60}; ScheduleReset(true, resetTime - tim[event.type-1], event); } + else + sMapMgr.InitMaxInstanceId(); // recalculate max instance id + m_resetTimeQueue.erase(m_resetTimeQueue.begin()); } } @@ -525,9 +540,10 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr) InstanceSave::PlayerListType &pList = itr->second->m_playerList; while (!pList.empty()) { - Player *player = *(pList.begin()); + Player *player = sObjectMgr.GetPlayer(*pList.begin()); player->UnbindInstance(itr->second->GetMapId(), itr->second->GetDifficulty(), true); } + InstanceSave::GroupListType &gList = itr->second->m_groupList; while (!gList.empty()) { @@ -538,6 +554,8 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr) RealmDataDatabase.PExecute("DELETE FROM group_saved_loot WHERE instanceid = '%u'", itr->second->GetInstanceId()); delete itr->second; + itr->second = nullptr; + m_instanceSaveById.erase(itr++); lock_instLists = false; diff --git a/src/game/InstanceSaveMgr.h b/src/game/InstanceSaveMgr.h index 418be8eb6..2a61512b1 100755 --- a/src/game/InstanceSaveMgr.h +++ b/src/game/InstanceSaveMgr.h @@ -1,8 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity - * + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __InstanceSaveMgr_H -#define __InstanceSaveMgr_H +#ifndef HELLGROUND_INSTANCESAVEMGR_H +#define HELLGROUND_INSTANCESAVEMGR_H #include "Platform/Define.h" #include "ace/Singleton.h" @@ -79,10 +78,12 @@ class InstanceSave InstanceTemplate const* GetTemplate(); MapEntry const* GetMapEntry(); + bool HasPlayer(uint64 guid); + /* online players bound to the instance (perm/solo) does not include the members of the group unless they have permanent saves */ - void AddPlayer(Player *player) { m_playerList.push_back(player); } - bool RemovePlayer(Player *player) { m_playerList.remove(player); return UnloadIfEmpty(); } + void AddPlayer(uint64 guid) { m_playerList.push_back(guid); } + bool RemovePlayer(uint64 guid) { m_playerList.remove(guid); return UnloadIfEmpty(); } /* all groups bound to the instance */ void AddGroup(Group *group) { m_groupList.push_back(group); } bool RemoveGroup(Group *group) { m_groupList.remove(group); return UnloadIfEmpty(); } @@ -97,7 +98,7 @@ class InstanceSave but that would depend on a lot of things that can easily change in future */ uint8 GetDifficulty() { return m_difficulty; } - typedef std::list PlayerListType; + typedef std::list PlayerListType; typedef std::list GroupListType; private: bool UnloadIfEmpty(); diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 9388cd48a..5b8619800 100755 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -24,6 +24,7 @@ #include "WorldPacket.h" #include "Database/DatabaseEnv.h" #include "ItemEnchantmentMgr.h" +#include "luaengine/HookMgr.h" void AddItemsSetItem(Player*player,Item *item) { @@ -99,7 +100,7 @@ void AddItemsSetItem(Player*player,Item *item) break; } - // spell casted only if fit form requirement, in other case will casted at form change + // spell cast only if fit form requirement, in other case will cast at form change player->ApplyEquipSpell(spellInfo,NULL,true); eff->spells[y] = spellInfo; break; @@ -300,6 +301,9 @@ void Item::UpdateDuration(Player* owner, uint32 diff) if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff) { + // used by eluna + sHookMgr->OnExpire(owner, GetProto()); + owner->DestroyItem(GetBagSlot(), GetSlot(), true); return; } diff --git a/src/game/Item.h b/src/game/Item.h index 488e5acf0..f4bae7c0b 100755 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_ITEM_H -#define TRINITYCORE_ITEM_H +#ifndef HELLGROUND_ITEM_H +#define HELLGROUND_ITEM_H #include "Common.h" #include "Object.h" diff --git a/src/game/ItemEnchantmentMgr.cpp b/src/game/ItemEnchantmentMgr.cpp index 7925a0761..8f479e160 100755 --- a/src/game/ItemEnchantmentMgr.cpp +++ b/src/game/ItemEnchantmentMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include diff --git a/src/game/ItemEnchantmentMgr.h b/src/game/ItemEnchantmentMgr.h index 17cf63486..b0f00e363 100755 --- a/src/game/ItemEnchantmentMgr.h +++ b/src/game/ItemEnchantmentMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _ITEM_ENCHANTMENT_MGR_H -#define _ITEM_ENCHANTMENT_MGR_H +#ifndef HELLGROUND_ITEM_ENCHANTMENT_MGR_H +#define HELLGROUND_ITEM_ENCHANTMENT_MGR_H #include "Common.h" diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index b7654ab2c..1c7b168f6 100755 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -809,7 +809,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data) } // no-op: placed in same slot - if (dest.size()==1 && dest[0].pos==src) + if (dest.size()==1 && (dest[0].pos==src || (dest[0].pos >> 8) == srcslot)) { // just remove grey item state _player->SendEquipError(EQUIP_ERR_NONE, pItem, NULL); diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index caaca5d80..1606cdfe6 100755 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _ITEMPROTOTYPE_H -#define _ITEMPROTOTYPE_H +#ifndef HELLGROUND_ITEMPROTOTYPE_H +#define HELLGROUND_ITEMPROTOTYPE_H #include "Common.h" @@ -57,10 +57,11 @@ enum ItemModType ITEM_MOD_CRIT_TAKEN_RATING = 34, ITEM_MOD_RESILIENCE_RATING = 35, ITEM_MOD_HASTE_RATING = 36, - ITEM_MOD_EXPERTISE_RATING = 37 + ITEM_MOD_EXPERTISE_RATING = 37, + ITEM_MOD_SPELL_PENETRATION = 38 }; -#define MAX_ITEM_MOD 38 +#define MAX_ITEM_MOD 39 enum ItemSpelltriggerType { diff --git a/src/game/LFGHandler.cpp b/src/game/LFGHandler.cpp index 2ad17d8b9..85a7932c2 100755 --- a/src/game/LFGHandler.cpp +++ b/src/game/LFGHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Language.h b/src/game/Language.h index b7d6f603a..9c37ebc45 100755 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,18 +10,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __HELLGROUND_LANGUAGE_H -#define __HELLGROUND_LANGUAGE_H +#ifndef HELLGROUND_LANGUAGE_H +#define HELLGROUND_LANGUAGE_H -enum TrinityStrings +enum HellgroundStrings { // for chat commands LANG_SELECT_CHAR_OR_CREATURE = 1, @@ -266,9 +266,11 @@ enum TrinityStrings LANG_COMMAND_KICKMESSAGE = 282, LANG_COMMAND_KICKNOTFOUNDPLAYER = 283, LANG_COMMAND_WHISPERACCEPTING = 284, - LANG_COMMAND_WHISPERON = 285, - LANG_COMMAND_WHISPEROFF = 286, + LANG_YOU_CAN_WHISPER_TO_GM_ON = 285, + LANG_YOU_CAN_WHISPER_TO_GM_OFF = 286, LANG_COMMAND_CREATGUIDNOTFOUND = 287, + LANG_COMMAND_CAN_WHISPER_GM_ON = 288, + LANG_COMMAND_CAN_WHISPER_GM_OFF = 289, // TICKET STRINGS NEED REWRITE // 288-296 FREE // END @@ -330,6 +332,9 @@ enum TrinityStrings LANG_MUTEINFO_HISTORYENTRY = 349, LANG_MUTEINFO_YES = 350, LANG_MUTEINFO_NO = 351, + LANG_MUTEINFO_TROLLMUTE_HISTORY = 352, + LANG_MUTEINFO_NOACCOUNT_TROLLMUTE = 353, + LANG_GM_TROLLMUTED_PLAYER = 354, // Room for more level 2 346-399 not used @@ -702,6 +707,7 @@ enum TrinityStrings LANG_MOVEGENS_FOLLOW_CREATURE = 790, LANG_MOVEGENS_FOLLOW_NULL = 791, LANG_MOVEGENS_EFFECT = 792, + LANG_HDEV_ANNOUNCE_COLOR = 793, LANG_BG_GROUP_TOO_LARGE = 1122, // "Your group is too large for this battleground. Please regroup to join." LANG_ARENA_GROUP_TOO_LARGE = 1123, // "Your group is too large for this arena. Please regroup to join." @@ -778,6 +784,9 @@ enum TrinityStrings LANG_CINEMATIC_NOT_EXIST = 1200, // Room for more debug 1201-1299 not used + LANG_COMMAND_FRIEND = 1700, + LANG_COMMAND_FRIEND_ERROR = 1701, + // Ticket Strings 2000-2029 LANG_COMMAND_TICKETNEW = 2000, LANG_COMMAND_TICKETUPDATED = 2001, @@ -892,7 +901,7 @@ enum TrinityStrings // Use for custom patches 11000-11999 LANG_BG_START_ANNOUNCE = 11000, - LANG_ANTICHEAT = 11001, + LANG_ANTICHEAT_SPEEDHACK = 11001, LANG_SET_WEATHER = 11002, LANG_BANINFO_NOEMAIL = 11003, LANG_BANINFO_EMAILENTRY = 11004, @@ -907,6 +916,8 @@ enum TrinityStrings LANG_ANTICHEAT_WATERWALK = 11013, LANG_ANTICHEAT_NOFALLDMG = 11014, LANG_GM_BANNED_PLAYER = 11015, + LANG_POSSIBLE_CHEAT = 11016, + LANG_INSTA_KILL_GUARDIAN = 11017 // NOT RESERVED IDS 12000-1999999999 // `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp old mode 100755 new mode 100644 index 010f2b0fd..553640041 --- a/src/game/Level0.cpp +++ b/src/game/Level0.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ #include "revision.h" #include "Util.h" #include "GameEvent.h" +#include "BattleGroundMgr.h" bool ChatHandler::HandleAccountXPToggleCommand(const char* args) { @@ -128,15 +129,11 @@ bool ChatHandler::HandleAccountBattleGroundAnnCommand(const char* args) if (session->IsAccountFlagged(ACC_DISABLED_BGANN)) { session->RemoveAccountFlag(ACC_DISABLED_BGANN); - - AccountsDatabase.PExecute("UPDATE account SET account_flags = account_flags & '%u' WHERE account_id = '%u'", ~ACC_DISABLED_GANN, account_id); PSendSysMessage("BattleGround announces have been enabled for this account."); } else { session->AddAccountFlag(ACC_DISABLED_BGANN); - - AccountsDatabase.PExecute("UPDATE account SET account_flags = account_flags | '%u' WHERE account_id = '%u'", ACC_DISABLED_GANN, account_id); PSendSysMessage("BattleGround announces have been disabled for this account."); } } @@ -151,6 +148,22 @@ bool ChatHandler::HandleAccountBattleGroundAnnCommand(const char* args) return true; } +bool ChatHandler::HandleAccountAnnounceBroadcastCommand(const char* args) +{ + if (m_session->IsAccountFlagged(ACC_DISABLED_BROADCAST)) + { + m_session->RemoveAccountFlag(ACC_DISABLED_BROADCAST); + PSendSysMessage("AutoBroadcast announces have been enabled for this account."); + } + else + { + m_session->AddAccountFlag(ACC_DISABLED_BROADCAST); + PSendSysMessage("AutoBroadcast announces have been disabled for this account."); + } + + return true; +} + bool ChatHandler::HandleHelpCommand(const char* args) { char* cmd = strtok((char*)args, " "); @@ -227,6 +240,30 @@ bool ChatHandler::HandleAccountWeatherCommand(const char* args) return true; } +bool ChatHandler::HandleArenaReadyCommand(const char* args) +{ + Player* player = m_session->GetPlayer(); + if ( !player->InArena() ) + { + PSendSysMessage("You can use this command only in arena."); + return false; + } + + BattleGround* bg = player->GetBattleGround(); + if ( bg == nullptr ) + return false; + + bool result = bg->SetPlayerReady(player->GetGUID()); + if (result) + { + PSendSysMessage("You have been NOT marked as ready due to some problems."); + return false; + } + + PSendSysMessage("You have been marked as ready."); + return true; +} + bool ChatHandler::HandleServerInfoCommand(const char* /*args*/) { uint32 activeClientsNum = sWorld.GetActiveSessionCount(); @@ -235,10 +272,12 @@ bool ChatHandler::HandleServerInfoCommand(const char* /*args*/) uint32 maxQueuedClientsNum = sWorld.GetMaxQueuedSessionCount(); std::string str = secsToTimeString(sWorld.GetUptime()); uint32 updateTime = sWorld.GetUpdateTime(); + std::string str2 = TimeToTimestampStr(sWorld.GetGameTime()); - PSendSysMessage("Hellground.pl - rev: " _REVISION); + PSendSysMessage("HellGround.net - rev: %s",_REVISION); PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum); PSendSysMessage(LANG_UPTIME, str.c_str()); + PSendSysMessage("Current time: %s", str2.c_str()); PSendSysMessage("Update time diff: %u.", updateTime); if (sWorld.IsShutdowning()) @@ -255,6 +294,11 @@ bool ChatHandler::HandleServerEventsCommand(const char*) { std::string active_events = sGameEventMgr.getActiveEventsString(); PSendSysMessage(active_events.c_str());//ChatHandler::FillMessageData(&data, this, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), active_events, NULL); + if(sWorld.getConfig(CONFIG_ARENA_DAILY_REQUIREMENT)) + { + PSendSysMessage("Daily Arenas! Get %u AP for winning %u rated arenas", + sWorld.getConfig(CONFIG_ARENA_DAILY_AP_REWARD),sWorld.getConfig(CONFIG_ARENA_DAILY_REQUIREMENT)); + } return true; } @@ -285,7 +329,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/) Player *player=m_session->GetPlayer(); // save GM account without delay and output message (testing, etc) - if (m_session->GetPermissions() & PERM_GMT) + if (m_session->HasPermissions(PERM_GMT)) { player->SaveToDB(); SendSysMessage(LANG_PLAYER_SAVED); @@ -385,3 +429,79 @@ bool ChatHandler::HandleServerMotdCommand(const char* /*args*/) return true; } +bool ChatHandler::HandleServerPVPCommand(const char* /*args*/) +{ + Player *player = m_session->GetPlayer(); + + if (!sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_INFO)) + PSendSysMessage("Battleground queue info is disabled"); + else + { + if (!(player->InBattleGroundQueue())) + PSendSysMessage("You aren't in any battleground queue"); + else + { + BattleGroundQueueTypeId qtype; + BattleGroundTypeId bgtype; + bool isbg; + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + { + qtype = player->GetBattleGroundQueueTypeId(i); + isbg = false; + switch (qtype) + { + case BATTLEGROUND_QUEUE_AB: + { + PSendSysMessage("You are queued for Arathi Basin"); + isbg = true; + bgtype = BATTLEGROUND_AB; + break; + } + case BATTLEGROUND_QUEUE_AV: + { + PSendSysMessage("You are queued for Alterac Valley"); + isbg = true; + bgtype = BATTLEGROUND_AV; + break; + } + case BATTLEGROUND_QUEUE_WS: + { + PSendSysMessage("You are queued for Warsong Gulch"); + isbg = true; + bgtype = BATTLEGROUND_WS; + break; + } + case BATTLEGROUND_QUEUE_EY: + { + PSendSysMessage("You are queued for Eye of the storm"); + isbg = true; + bgtype = BATTLEGROUND_EY; + break; + } + default: + break; + } + + if (isbg) + { + uint32 minPlayers = sBattleGroundMgr.GetBattleGroundTemplate(bgtype)->GetMinPlayersPerTeam(); + uint32 queuedHorde = sBattleGroundMgr.m_BattleGroundQueues[qtype].GetQueuedPlayersCount(BG_TEAM_HORDE, player->GetBattleGroundBracketIdFromLevel(bgtype)); + uint32 queuedAlliance = sBattleGroundMgr.m_BattleGroundQueues[qtype].GetQueuedPlayersCount(BG_TEAM_ALLIANCE, player->GetBattleGroundBracketIdFromLevel(bgtype)); + PSendSysMessage("Horde queued: %u, Alliance queued: %u. Minimum per team: %u", queuedHorde, queuedAlliance, minPlayers); + } + } + } + } + + if (sWorld.getConfig(CONFIG_ARENA_STATUS_INFO)) + PSendSysMessage("Arena status: %u players in 2v2, %u in 3v3, %u in 5v5", + sBattleGroundMgr.inArenasCount[0],sBattleGroundMgr.inArenasCount[1],sBattleGroundMgr.inArenasCount[2]); + else + PSendSysMessage("Arena status is disabled"); + + if(sWorld.getConfig(CONFIG_ARENA_DAILY_REQUIREMENT)) + PSendSysMessage("Today you won %u rated arenas (%u required for reward)", + player->m_DailyArenasWon,sWorld.getConfig(CONFIG_ARENA_DAILY_REQUIREMENT)); + + return true; +} diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp old mode 100755 new mode 100644 index cee5dd4e7..67c8691c1 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -38,6 +38,8 @@ #include "GridMap.h" #include "Guild.h" #include "AccountMgr.h" +#include "SocialMgr.h" +#include "GuildMgr.h" #ifdef _DEBUG_VMAPS #include "VMapFactory.h" @@ -145,7 +147,7 @@ bool ChatHandler::HandleGuildAnnounceCommand(const char *args) SetSentErrorMessage(true); if (uint32 gId = m_session->GetPlayer()->GetGuildId()) { - if (sObjectMgr.GetGuildAnnCooldown(gId) < time(NULL)) + if (sGuildMgr.GetGuildAnnCooldown(gId) < time(NULL)) { if (msg.size() > sWorld.getConfig(CONFIG_GUILD_ANN_LENGTH)) { @@ -153,7 +155,7 @@ bool ChatHandler::HandleGuildAnnounceCommand(const char *args) return false; } - Guild * pGuild = sObjectMgr.GetGuildById(gId); + Guild * pGuild = sGuildMgr.GetGuildById(gId); if (!pGuild) { PSendSysMessage("Error occured while sending guild announce."); @@ -174,20 +176,20 @@ bool ChatHandler::HandleGuildAnnounceCommand(const char *args) if (pGuild->GetMemberSize() < 10) { - PSendSysMessage("Your guild is to small, you need at least 10 members to append guild announce."); + PSendSysMessage("Your guild is too small, you need at least 10 members to send guild announce."); return false; } - PSendSysMessage("Your message has been queued and will be displayed soon, please wait: %u seconds before sending another one.", sWorld.getConfig(CONFIG_GUILD_ANN_COOLDOWN)); + PSendSysMessage("Your message has been queued and will be displayed soon. Please wait %s before sending another one.", secsToTimeString(sWorld.getConfig(CONFIG_GUILD_ANN_COOLDOWN)).c_str()); - sObjectMgr.SaveGuildAnnCooldown(gId); + sGuildMgr.SaveGuildAnnCooldown(gId); sLog.outLog(LOG_GUILD_ANN, "Player %s (" UI64FMTD ") - guild: %s (%u) append guild announce: %s", m_session->GetPlayer()->GetName(), m_session->GetPlayer()->GetGUID(), pGuild->GetName().c_str(), gId, msg.c_str()); sWorld.QueueGuildAnnounce(gId, m_session->GetPlayer()->GetTeam(), msg); return true; } else { - PSendSysMessage("Cooldown between messages didn't pass, come back later :]"); + PSendSysMessage("Please wait before guild announce cooldown expires in %s", secsToTimeString(uint32(sGuildMgr.GetGuildAnnCooldown(gId) - time(NULL))).c_str()); return false; } } @@ -202,8 +204,18 @@ bool ChatHandler::HandleNameAnnounceCommand(const char* args) if (!*args) return false; //char str[1024]; - //sprintf(str, GetTrinityString(LANG_ANNOUNCE_COLOR), m_session->GetPlayer()->GetName(), args); - sWorld.SendWorldText(LANG_ANNOUNCE_COLOR, m_session->GetPlayer()->GetName(), args); + //sprintf(str, GetHellgroundString(LANG_ANNOUNCE_COLOR), m_session->GetPlayer()->GetName(), args); + sWorld.SendWorldText(LANG_ANNOUNCE_COLOR, 0, m_session->GetPlayer()->GetName(), args); + return true; +} + +bool ChatHandler::HandleHDevAnnounceCommand(const char* args) +{ + WorldPacket data; + if (!*args) + return false; + + sWorld.SendWorldText(LANG_HDEV_ANNOUNCE_COLOR, 0, m_session->GetPlayer()->GetName(), args); return true; } @@ -223,7 +235,7 @@ bool ChatHandler::HandleAnnounceCommand(const char* args) if (!*args) return false; - sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); + sWorld.SendWorldText(LANG_SYSTEMMESSAGE, 0, args); return true; } @@ -243,7 +255,7 @@ bool ChatHandler::HandleNotifyCommand(const char* args) if (!*args) return false; - std::string str = GetTrinityString(LANG_GLOBAL_NOTIFY); + std::string str = GetHellgroundString(LANG_GLOBAL_NOTIFY); str += args; WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); @@ -259,7 +271,7 @@ bool ChatHandler::HandleGMNotifyCommand(const char* args) if (!*args) return false; - std::string str = GetTrinityString(LANG_GM_NOTIFY); + std::string str = GetHellgroundString(LANG_GM_NOTIFY); str += args; WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); @@ -345,7 +357,7 @@ bool ChatHandler::HandleGMChatCommand(const char* args) std::string ChatHandler::PGetParseString(int32 entry, ...) { - const char *format = GetTrinityString(entry); + const char *format = GetHellgroundString(entry); va_list ap; char str [1024]; va_start(ap, entry); @@ -665,9 +677,8 @@ bool ChatHandler::HandleGMTicketAssignToCommand(const char* args) } uint64 tarGUID = sObjectMgr.GetPlayerGUIDByName(targm.c_str()); uint64 accid = sObjectMgr.GetPlayerAccountIdByGUID(tarGUID); - uint64 targetPermissions = AccountMgr::GetPermissions(accid); - if (!tarGUID || !(targetPermissions & PERM_GMT)) + if (!tarGUID || !AccountMgr::HasPermissions(accid, PERM_GMT)) { SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; @@ -828,15 +839,20 @@ bool ChatHandler::HandleGMVisibleCommand(const char* args) { if (!*args) { - PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetTrinityString(LANG_VISIBLE) : GetTrinityString(LANG_INVISIBLE)); + PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetHellgroundString(LANG_VISIBLE) : GetHellgroundString(LANG_INVISIBLE)); return true; } + const uint32 VISUAL_AURA = 37800; std::string argstr = (char*)args; + Player* player = m_session->GetPlayer(); if (argstr == "on") { - m_session->GetPlayer()->SetGMVisible(true); + if (player->HasAura(VISUAL_AURA, 0)) + player->RemoveAurasDueToSpell(VISUAL_AURA); + + player->SetGMVisible(true); m_session->SendNotification(LANG_INVISIBLE_VISIBLE); return true; } @@ -845,6 +861,9 @@ bool ChatHandler::HandleGMVisibleCommand(const char* args) { m_session->SendNotification(LANG_INVISIBLE_INVISIBLE); m_session->GetPlayer()->SetGMVisible(false); + + player->AddAura(VISUAL_AURA, player); + return true; } @@ -938,7 +957,7 @@ bool ChatHandler::HandleGPSCommand(const char* args) GetName(), (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry())); - sLog.outDebug(GetTrinityString(LANG_MAP_POSITION), + sLog.outDebug(GetHellgroundString(LANG_MAP_POSITION), obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : ""), zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : ""), area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : ""), @@ -954,7 +973,7 @@ bool ChatHandler::HandleInfoCommand(const char* args) Player* _player = m_session->GetPlayer(); MapEntry const* mapEntry = sMapStore.LookupEntry(_player->GetMapId()); - PSendSysMessage("MapId: %u, Name: %s", _player->GetMapId(), mapEntry->name); + PSendSysMessage("MapId: %u, Name: /", _player->GetMapId() /*, mapEntry->name*/); PSendSysMessage("- cached data -"); const AreaTableEntry* zEntry = GetAreaEntryByAreaID(_player->GetCachedZone()); @@ -962,8 +981,8 @@ bool ChatHandler::HandleInfoCommand(const char* args) if (!aEntry || !zEntry) return false; - PSendSysMessage("*zone: %s [%u]", zEntry->area_name, _player->GetCachedZone()); - PSendSysMessage("*area: %s [%u]", aEntry->area_name, _player->GetCachedArea()); + PSendSysMessage("*zone: / [%u]",/* zEntry->area_name,*/ _player->GetCachedZone()); + PSendSysMessage("*area: / [%u]", /*aEntry->area_name,*/ _player->GetCachedArea()); const AreaTableEntry* zEntry2 = GetAreaEntryByAreaID(_player->GetZoneId()); const AreaTableEntry* aEntry2 = GetAreaEntryByAreaID(_player->GetAreaId()); @@ -971,14 +990,14 @@ bool ChatHandler::HandleInfoCommand(const char* args) return false; PSendSysMessage("- real data -"); - PSendSysMessage("*zone: %s [%u]", zEntry2->area_name, _player->GetZoneId()); - PSendSysMessage("*area: %s [%u]", aEntry2->area_name, _player->GetAreaId()); + PSendSysMessage("*zone: / [%u]", /*zEntry2->area_name,*/ _player->GetZoneId()); + PSendSysMessage("*area: / [%u]", /*aEntry2->area_name,*/ _player->GetAreaId()); TerrainInfo const *terrain = _player->GetTerrain(); PSendSysMessage("- terrain data -"); - PSendSysMessage("*ground Z: %u", terrain->GetHeight(_player->GetPositionX(), _player->GetPositionY(), MAX_HEIGHT)); - PSendSysMessage("*floor Z: %u", terrain->GetHeight(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ())); + PSendSysMessage("*ground Z: %f", terrain->GetHeight(_player->GetPositionX(), _player->GetPositionY(), MAX_HEIGHT)); + PSendSysMessage("*floor Z: %f", terrain->GetHeight(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ())); PSendSysMessage("*los: %s", terrain->IsLineOfSightEnabled() ? "enabled" : "disabled"); PSendSysMessage("*mmaps: %s", terrain->IsPathFindingEnabled() ? "enabled" : "disabled"); PSendSysMessage("*outdoors: %s", terrain->IsOutdoors(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ()) ? "yes" : "no"); @@ -1061,16 +1080,16 @@ bool ChatHandler::HandleNamegoCommand(const char* args) ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, GetName()); // stop flight if need - m_session->GetPlayer()->InterruptTaxiFlying(); + target->InterruptTaxiFlying(); // before GM float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,target->GetObjectSize()); + m_session->GetPlayer()->GetNearPoint(x,y,z,target->GetObjectSize()); target->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,target->GetOrientation()); } else if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name)) { - PSendSysMessage(LANG_SUMMONING, name.c_str(),GetTrinityString(LANG_OFFLINE)); + PSendSysMessage(LANG_SUMMONING, name.c_str(),GetHellgroundString(LANG_OFFLINE)); // in point where GM stay Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), @@ -1435,7 +1454,7 @@ bool ChatHandler::HandleModifyEnergyCommand(const char* args) chr->SetMaxPower(POWER_ENERGY,energym); chr->SetPower(POWER_ENERGY, energy); - sLog.outDetail(GetTrinityString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); + sLog.outDetail(GetHellgroundString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); return true; } @@ -1844,7 +1863,7 @@ bool ChatHandler::HandleModifyFlyCommand(const char* args) float FSpeed = (float)atof((char*)args); - if (FSpeed > 10.0f || FSpeed < 0.1f) + if (FSpeed > 30.0f || FSpeed < 0.1f) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -2178,7 +2197,7 @@ bool ChatHandler::HandleModifyMoneyCommand(const char* args) { int32 newmoney = moneyuser + addmoney; - sLog.outDetail(GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); + sLog.outDetail(GetHellgroundString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); if (newmoney <= 0) { PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName()); @@ -2203,7 +2222,7 @@ bool ChatHandler::HandleModifyMoneyCommand(const char* args) chr->ModifyMoney(addmoney); } - sLog.outDetail(GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney()); + sLog.outDetail(GetHellgroundString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney()); return true; } @@ -2426,29 +2445,97 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args) return true; } -//Enable\Dissable accept whispers (for GM) +//Enable\Disable GM accept whispers and players ability to whisper to gm bool ChatHandler::HandleWhispersCommand(const char* args) { if (!*args) { - PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); + PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetHellgroundString(LANG_ON) : GetHellgroundString(LANG_OFF)); return true; } - std::string argstr = (char*)args; + std::string firstpart = strtok((char*)args, " "); + if (firstpart.empty()) + return false; + // whisper on - if (argstr == "on") + if (firstpart == "on") { m_session->GetPlayer()->SetAcceptWhispers(true); - SendSysMessage(LANG_COMMAND_WHISPERON); + PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING,GetHellgroundString(LANG_ON)); return true; } // whisper off - if (argstr == "off") + if (firstpart == "off") { m_session->GetPlayer()->SetAcceptWhispers(false); - SendSysMessage(LANG_COMMAND_WHISPEROFF); + PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING,GetHellgroundString(LANG_OFF)); + return true; + } + + if (firstpart == "list") + { + SendSysMessage("Listing online players with GMWhisper enabled"); + std::for_each(sSocialMgr.canWhisperToGMList.begin(),sSocialMgr.canWhisperToGMList.end(), + [this](uint64 guid)-> void + {if(Player* plr = sObjectAccessor.GetPlayer(guid)) + PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, GetNameLink(plr->GetName()).c_str(), guid);} + ); + return true; + } + + std::string secondpart = strtok(NULL, " "); + if (secondpart.empty()) + return false; + + if (!normalizePlayerName(firstpart)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint32 targetguid; + Player* target = sObjectAccessor.GetPlayerByName(firstpart); + if (!target) + { + GameDataDatabase.escape_string(firstpart); + QueryResultAutoPtr result = RealmDataDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s' ",firstpart.c_str()); + if (!result) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + targetguid = result->Fetch()[0].GetUInt32(); + } + + if (secondpart == "on") + { + if (target) + { + target->SetCanWhisperToGM(true); + if (m_session->GetPlayer()->IsVisibleGloballyfor(target)) + ChatHandler(target).SendSysMessage(LANG_YOU_CAN_WHISPER_TO_GM_ON); + } + else + RealmDataDatabase.PExecute("UPDATE characters SET extra_flags = extra_flags | %u WHERE guid ='%u'", uint32(PLAYER_EXTRA_CAN_WHISP_TO_GM), targetguid); + SendGlobalGMSysMessage(LANG_COMMAND_CAN_WHISPER_GM_ON, firstpart.c_str()); + return true; + } + if (secondpart == "off") + { + if (target) + { + target->SetCanWhisperToGM(false); + if (m_session->GetPlayer()->IsVisibleGloballyfor(target)) + ChatHandler(target).SendSysMessage(LANG_YOU_CAN_WHISPER_TO_GM_OFF); + } + else + RealmDataDatabase.PExecute("UPDATE characters SET extra_flags = extra_flags & ~ %u WHERE guid ='%u'", uint32(PLAYER_EXTRA_CAN_WHISP_TO_GM), targetguid); + SendGlobalGMSysMessage(LANG_COMMAND_CAN_WHISPER_GM_OFF, firstpart.c_str()); return true; } @@ -2611,7 +2698,7 @@ bool ChatHandler::HandleTeleNameCommand(const char * args) } else if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name.c_str())) { - PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str()); + PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetHellgroundString(LANG_OFFLINE), tele->name.c_str()); Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),guid); } else @@ -2766,7 +2853,7 @@ bool ChatHandler::HandleGroupgoCommand(const char* args) // before GM float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize()); + m_session->GetPlayer()->GetNearPoint(x,y,z,pl->GetObjectSize()); pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); } @@ -2987,3 +3074,48 @@ bool ChatHandler::HandleModifyDrunkCommand(const char* args) return true; } +bool ChatHandler::HandleNpcStandState(const char* args) +{ + uint32 state = atoi((char*)args); + + Creature* target = getSelectedCreature(); + if (!target) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + target->SetStandState(state); + + return true; +} + +bool ChatHandler::HandleCheatGodmodeCommand(const char* args) +{ + if (!m_session) + return false; + + m_session->GetPlayer()->ToggleCheatState(PlayerCheatState::God); + + if (m_session->GetPlayer()->HasCheatState(PlayerCheatState::God)) + SendSysMessage("Godmode has been enabled!"); + else + SendSysMessage("Godmode has been disabled!"); + + return true; +} + +bool ChatHandler::HandleCheatPowerCommand(const char* args) +{ + if (!m_session) + return false; + + m_session->GetPlayer()->ToggleCheatState(PlayerCheatState::Power); + + if (m_session->GetPlayer()->HasCheatState(PlayerCheatState::Power)) + SendSysMessage("Power cheat has been enabled!"); + else + SendSysMessage("Power cheat has been disabled!"); + return true; +} diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp old mode 100755 new mode 100644 index bcdbc9669..f3766064f --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +46,7 @@ #include "TicketMgr.h" #include "CreatureAI.h" #include "ChannelMgr.h" +#include "GuildMgr.h" #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "MoveMap.h" // for mmap manager @@ -144,7 +145,7 @@ bool ChatHandler::HandleMuteCommand(const char* args) AccountsDatabase.escape_string(author); - AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), '%u', '%s', '%s')", + AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), '%u', '%s', '%s', '1')", account_id, PUNISHMENT_MUTE, uint64(mutetime), author.c_str(), mutereasonstr.c_str()); SendGlobalGMSysMessage(LANG_GM_DISABLE_CHAT, author.c_str(), cname.c_str(), notspeaktime, mutereasonstr.c_str()); @@ -205,6 +206,8 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) if (chr) { + chr->GetSession()->m_trollmuteTime = 0; + chr->GetSession()->m_trollmuteReason = ""; if (chr->CanSpeak()) { SendSysMessage(LANG_CHAT_ALREADY_ENABLED); @@ -217,7 +220,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); } - AccountsDatabase.PExecute("UPDATE account_punishment SET expiration_date = UNIX_TIMESTAMP() WHERE account_id = '%u' AND punishment_type_id = '%u'", account_id, PUNISHMENT_MUTE); + AccountsDatabase.PExecute("UPDATE account_punishment SET active ='0' WHERE account_id = '%u' AND punishment_type_id IN ('%u','%u')", account_id, PUNISHMENT_MUTE, PUNISHMENT_TROLLMUTE); std::string author; @@ -263,7 +266,7 @@ bool ChatHandler::HandleMuteInfoCommand(const char* args) return true; } - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT FROM_UNIXTIME(punishment_date), expiration_date-punishment_date, expiration_date, reason, punished_by " + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT FROM_UNIXTIME(punishment_date), expiration_date-punishment_date, expiration_date, reason, punished_by, active " "FROM account_punishment " "WHERE account_id = '%u' AND punishment_type_id = '%u' " "ORDER BY punishment_date ASC", accountid, PUNISHMENT_MUTE); @@ -283,12 +286,12 @@ bool ChatHandler::HandleMuteInfoCommand(const char* args) uint64 muteLength = fields[1].GetUInt64(); bool active = false; - if (muteLength == 0 || unmutedate >= time(NULL)) + if ((muteLength == 0 || unmutedate >= time(NULL)) && fields[5].GetBool()) active = true; std::string mutetime = secsToTimeString(muteLength, true); PSendSysMessage(LANG_MUTEINFO_HISTORYENTRY, - fields[0].GetString(), mutetime.c_str(), active ? GetTrinityString(LANG_MUTEINFO_YES):GetTrinityString(LANG_MUTEINFO_NO), fields[3].GetString(), fields[4].GetString()); + fields[0].GetString(), mutetime.c_str(), active ? GetHellgroundString(LANG_MUTEINFO_YES):GetHellgroundString(LANG_MUTEINFO_NO), fields[3].GetString(), fields[4].GetString()); } while (result->NextRow()); @@ -671,6 +674,57 @@ bool ChatHandler::HandleGoCreatureCommand(const char* args) return true; } +bool ChatHandler::HandleGoCreatureDirectCommand(const char* args) +{ + if (!*args || !m_session) + return false; + uint32 lowguid = atoi(args); + CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); + if (!data) + { + PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + QueryResultAutoPtr result = GameDataDatabase.PQuery("SELECT map FROM creature WHERE guid = '%u'",lowguid); + if (!result) + { + SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); + SetSentErrorMessage(true); + return false; + } + uint16 mapid = result->Fetch()[0].GetUInt16(); + Map* map; + + if (m_session->GetPlayer()->GetMap()->GetId() == mapid) + map = m_session->GetPlayer()->GetMap(); + else + map = sMapMgr.FindMap(mapid); + + if (!map) + { + SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); + SetSentErrorMessage(true); + return false; + } + + Creature* creature = map->GetCreature(MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); + if (!creature) + { + SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); + SetSentErrorMessage(true); + return false; + } + + m_session->GetPlayer()->InterruptTaxiFlying(); + + WorldLocation loc; + creature->GetPosition(loc); + m_session->GetPlayer()->TeleportTo(loc); + return true; +} + bool ChatHandler::HandleGUIDCommand(const char* /*args*/) { uint64 guid = m_session->GetPlayer()->GetSelection(); @@ -747,25 +801,25 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args) if (repState) // and then target!=NULL also { ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry); - std::string rankName = GetTrinityString(ReputationRankStrIndex[rank]); + std::string rankName = GetHellgroundString(ReputationRankStrIndex[rank]); ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")"; if (repState->Flags & FACTION_FLAG_VISIBLE) - ss << GetTrinityString(LANG_FACTION_VISIBLE); + ss << GetHellgroundString(LANG_FACTION_VISIBLE); if (repState->Flags & FACTION_FLAG_AT_WAR) - ss << GetTrinityString(LANG_FACTION_ATWAR); + ss << GetHellgroundString(LANG_FACTION_ATWAR); if (repState->Flags & FACTION_FLAG_PEACE_FORCED) - ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); + ss << GetHellgroundString(LANG_FACTION_PEACE_FORCED); if (repState->Flags & FACTION_FLAG_HIDDEN) - ss << GetTrinityString(LANG_FACTION_HIDDEN); + ss << GetHellgroundString(LANG_FACTION_HIDDEN); if (repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) - ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); + ss << GetHellgroundString(LANG_FACTION_INVISIBLE_FORCED); if (repState->Flags & FACTION_FLAG_INACTIVE) - ss << GetTrinityString(LANG_FACTION_INACTIVE); + ss << GetHellgroundString(LANG_FACTION_INACTIVE); } else - ss << GetTrinityString(LANG_FACTION_NOREPUTATION); + ss << GetHellgroundString(LANG_FACTION_NOREPUTATION); SendSysMessage(ss.str().c_str()); counter++; @@ -816,7 +870,7 @@ bool ChatHandler::HandleModifyRepCommand(const char * args) amount = -42000; for (; r < MAX_REPUTATION_RANK; ++r) { - std::string rank = GetTrinityString(ReputationRankStrIndex[r]); + std::string rank = GetHellgroundString(ReputationRankStrIndex[r]); if (rank.empty()) continue; @@ -1109,6 +1163,8 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args) Creature* pCreature = getSelectedCreature(); + float o = m_session->GetPlayer()->GetOrientation(); + if (!pCreature) { // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r @@ -1118,34 +1174,30 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args) lowguid = atoi(cId); - /* FIXME: impossibel without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - // Attempting creature load from DB data - if (!pCreature) + CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); + if (!data) { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } + PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } - uint32 map_id = data->mapid; + o = data->orientation;// .npc move guid should not change orientation - if (m_session->GetPlayer()->GetMapId()!=map_id) - { - PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); - SetSentErrorMessage(true); - return false; - } + uint32 map_id = data->mapid; + if (m_session->GetPlayer()->GetMapId()!=map_id) + { + PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); + SetSentErrorMessage(true); + return false; } else { - lowguid = pCreature->GetDBTableGUIDLow(); + Map* pMap = sMapMgr.FindMap(map_id,m_session->GetPlayer()->GetInstanceId()); + if (pMap) + pCreature = pMap->GetCreature(MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); + //not sure how MAKE_NEW_GUID does what it does, and FIXME: does not work in instances } } else @@ -1156,17 +1208,16 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args) float x = m_session->GetPlayer()->GetPositionX(); float y = m_session->GetPlayer()->GetPositionY(); float z = m_session->GetPlayer()->GetPositionZ(); - float o = m_session->GetPlayer()->GetOrientation(); + if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid)) + { + const_cast(data)->posX = x; + const_cast(data)->posY = y; + const_cast(data)->posZ = z; + const_cast(data)->orientation = o; + } if (pCreature) { - if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) - { - const_cast(data)->posX = x; - const_cast(data)->posY = y; - const_cast(data)->posZ = z; - const_cast(data)->orientation = o; - } Map *pMap = pCreature->GetMap(); pMap->CreatureRelocation(pCreature,x, y, z,o); pCreature->GetMotionMaster()->Initialize(); @@ -1620,6 +1671,60 @@ bool ChatHandler::HandleNpcFlagCommand(const char* args) return true; } +//set field flags of creature +bool ChatHandler::HandleNpcFieldFlagCommand(const char* args) +{ + if (!*args) + return false; + + uint32 Flags = (uint32) atoi((char*)args); + + Creature* pCreature = getSelectedCreature(); + + if (!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, Flags); + + GameDataDatabase.PExecuteLog("UPDATE creature_template SET unit_flags = '%u' WHERE entry = '%u'", Flags, pCreature->GetEntry()); + + SendSysMessage(LANG_VALUE_SAVED_REJOIN); + + return true; +} + +bool ChatHandler::HandleNpcExtraFlagCommand(const char* args) +{ + if (!*args) + return false; + + uint32 Flags = (uint32) atoi((char*)args); + + Creature* pCreature = getSelectedCreature(); + + if (!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if (CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) + { + const_cast(cinfo)->flags_extra = Flags; + } + + GameDataDatabase.PExecuteLog("UPDATE creature_template SET flags_extra = '%u' WHERE entry = '%u'", Flags, pCreature->GetEntry()); + + SendSysMessage(LANG_VALUE_SAVED_REJOIN); + + return true; +} + //set model of creature bool ChatHandler::HandleNpcSetModelCommand(const char* args) { @@ -1733,7 +1838,7 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) } if (sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD)) - sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, player->GetName(), kicker.c_str(), reason.c_str()); + sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, 0, player->GetName(), kicker.c_str(), reason.c_str()); else PSendSysMessage(LANG_COMMAND_KICKMESSAGE, player->GetName(), kicker.c_str(), reason.c_str()); @@ -1774,7 +1879,7 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) if (sWorld.KickPlayer(name.c_str())) { if (sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD)) - sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, name.c_str(), kicker.c_str(), reason.c_str()); + sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, 0, name.c_str(), kicker.c_str(), reason.c_str()); else PSendSysMessage(LANG_COMMAND_KICKMESSAGE, name.c_str(), kicker.c_str(), reason.c_str()); } @@ -1846,6 +1951,8 @@ bool ChatHandler::HandlePInfoCommand(const char* args) uint8 Class; // get additional information from Player object + if (target && target->GetSession()->HasPermissions(PERM_GMT) && !m_session->HasPermissions(sWorld.getConfig(CONFIG_GM_TRUSTED_LEVEL))) + return false; if (target) { targetGUID = target->GetGUID(); @@ -1873,47 +1980,47 @@ bool ChatHandler::HandlePInfoCommand(const char* args) level = fields[1].GetUInt32(); money = fields[2].GetUInt32(); accId = fields[3].GetUInt32(); + race = fields[4].GetUInt8(); + Class = fields[5].GetUInt8(); + + } - std::string username = GetTrinityString(LANG_ERROR); - std::string email = GetTrinityString(LANG_ERROR); - std::string last_ip = GetTrinityString(LANG_ERROR); + std::string username = GetHellgroundString(LANG_ERROR); + std::string email = GetHellgroundString(LANG_ERROR); + std::string last_ip = GetHellgroundString(LANG_ERROR); uint32 permissions = 0; - std::string last_login = GetTrinityString(LANG_ERROR); + std::string last_login = GetHellgroundString(LANG_ERROR); - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT username, permission_mask, email, ip, login_date" - "FROM account JOIN account_permissions ON account.account_id = account_permissions.account_id " - " JOIN account_login ON account.account_id = account_login.account_id " - "WHERE account.account_id = '%u' AND realmd_id = '%u'" - "ORDER BY login_date DESC " - "LIMIT 1", accId, realmID); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT a.username,ap.permission_mask,a.email,a.last_ip,a.last_login " + "FROM account a " + "LEFT JOIN account_permissions ap " + "ON (a.account_id = ap.account_id) " + "WHERE a.account_id = '%u'",accId); + if (result) { Field* fields = result->Fetch(); username = fields[0].GetCppString(); permissions = fields[1].GetUInt32(); + if ((permissions & PERM_GMT) && !m_session->HasPermissions(sWorld.getConfig(CONFIG_GM_TRUSTED_LEVEL))) + return false; if (email.empty()) email = "-"; - - if (!m_session || m_session->GetPermissions() >= permissions) - { - if (sWorld.getConfig(CONFIG_GM_TRUSTED_LEVEL) & m_session->GetPermissions()) - email = fields[2].GetCppString(); - - last_ip = fields[3].GetCppString(); - last_login = fields[4].GetCppString(); - } + + last_ip = fields[3].GetCppString(); + last_login = fields[4].GetCppString(); + + if (!m_session || m_session->HasPermissions(sWorld.getConfig(CONFIG_GM_TRUSTED_LEVEL))) + email = fields[2].GetCppString(); else - { - email = "-"; - last_ip = "-"; - last_login = "-"; - } + email = "NO_PERMISSION"; + } - PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : GetTrinityString(LANG_OFFLINE)), GetNameLink(name).c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, email.c_str(), permissions, last_ip.c_str(), last_login.c_str(), latency); + PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : GetHellgroundString(LANG_OFFLINE)), GetNameLink(name).c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, email.c_str(), permissions, last_ip.c_str(), last_login.c_str(), latency); std::string race_s, Class_s; switch(race) @@ -1965,23 +2072,23 @@ bool ChatHandler::HandlePInfoCommand(const char* args) FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); char const* factionName = factionEntry ? factionEntry->name[m_session->GetSessionDbcLocale()] : "#Not found#"; ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry); - std::string rankName = GetTrinityString(ReputationRankStrIndex[rank]); + std::string rankName = GetHellgroundString(ReputationRankStrIndex[rank]); std::ostringstream ss; ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << factionName << "]|h|r " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")"; if (itr->second.Flags & FACTION_FLAG_VISIBLE) - ss << GetTrinityString(LANG_FACTION_VISIBLE); + ss << GetHellgroundString(LANG_FACTION_VISIBLE); if (itr->second.Flags & FACTION_FLAG_AT_WAR) - ss << GetTrinityString(LANG_FACTION_ATWAR); + ss << GetHellgroundString(LANG_FACTION_ATWAR); if (itr->second.Flags & FACTION_FLAG_PEACE_FORCED) - ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); + ss << GetHellgroundString(LANG_FACTION_PEACE_FORCED); if (itr->second.Flags & FACTION_FLAG_HIDDEN) - ss << GetTrinityString(LANG_FACTION_HIDDEN); + ss << GetHellgroundString(LANG_FACTION_HIDDEN); if (itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) - ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); + ss << GetHellgroundString(LANG_FACTION_INVISIBLE_FORCED); if (itr->second.Flags & FACTION_FLAG_INACTIVE) - ss << GetTrinityString(LANG_FACTION_INACTIVE); + ss << GetHellgroundString(LANG_FACTION_INACTIVE); SendSysMessage(ss.str().c_str()); } @@ -2118,7 +2225,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args) Player* player = m_session->GetPlayer(); Map *map = player->GetMap(); - GameDataDatabase.PExecuteLog("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z, move_flag, delay) VALUES ('%u','%u','%f', '%f', '%f', '%u', '%u')", + GameDataDatabase.PExecuteLog("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z, move_type, delay) VALUES ('%u','%u','%f', '%f', '%f', '%u', '%u')", pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), moveflag, delay); PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point,"|r|cff00ff00 created. "); @@ -2474,7 +2581,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) // Check // Remember: "show" must also be the name of a column! if ((show != "delay") && (show != "action") && (show != "action_chance") - && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd") + && (show != "move_type") && (show != "del") && (show != "move") && (show != "wpadd") ) { return false; @@ -2644,6 +2751,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) bool ChatHandler::HandleWpShowCommand(const char* args) { + /* sLog.outDebug("DEBUG: HandleWpShowCommand"); if (!*args) @@ -2720,7 +2828,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) return false; } - QueryResultAutoPtr result = GameDataDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = '%u'", target->GetDBTableGUIDLow()); + QueryResultAutoPtr result = GameDataDatabase.PQuery("SELECT id, point, delay, move_type, action, action_chance FROM waypoint_data WHERE wpguid = '%u'", target->GetDBTableGUIDLow()); if (!result) @@ -2985,6 +3093,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); return true; + */ } //////////// WAYPOINT COMMANDS // @@ -3100,7 +3209,7 @@ bool ChatHandler::HandleGameObjectAddCommand(const char* args) return false; } - sLog.outDebug(GetTrinityString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o); + sLog.outDebug(GetHellgroundString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o); map->Add(pGameObj); @@ -3198,7 +3307,7 @@ bool ChatHandler::HandleLookupEventCommand(const char* args) if (Utf8FitTo(descr, wnamepart)) { - char const* active = activeEvents.find(id) != activeEvents.end() ? GetTrinityString(LANG_ACTIVE) : ""; + char const* active = activeEvents.find(id) != activeEvents.end() ? GetHellgroundString(LANG_ACTIVE) : ""; if (m_session) PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,id,id,eventData.description.c_str(),active); @@ -3222,7 +3331,7 @@ bool ChatHandler::HandleEventActiveListCommand(const char* args) GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); - char const* active = GetTrinityString(LANG_ACTIVE); + char const* active = GetHellgroundString(LANG_ACTIVE); for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr) { @@ -3274,7 +3383,7 @@ bool ChatHandler::HandleEventInfoCommand(const char* args) GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); bool active = activeEvents.find(event_id) != activeEvents.end(); - char const* activeStr = active ? GetTrinityString(LANG_ACTIVE) : ""; + char const* activeStr = active ? GetHellgroundString(LANG_ACTIVE) : ""; std::string startTimeStr = TimeToTimestampStr(eventData.start); std::string endTimeStr = TimeToTimestampStr(eventData.end); @@ -3408,7 +3517,7 @@ bool ChatHandler::HandleCombatStopCommand(const char* args) } player->CombatStop(); - player->getHostilRefManager().deleteReferences(); + player->getHostileRefManager().deleteReferences(); return true; } @@ -3541,9 +3650,17 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) int32 limit = limit_str ? atoi(limit_str) : -1; AccountsDatabase.escape_string(ip); - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT account_id, username FROM account WHERE last_ip = '%s'", ip.c_str()); + if (sWorld.getConfig(CONFIG_HIDE_GAMEMASTER_ACCOUNTS) && !m_session->HasPermissions(PERM_HIGH_GMT)) + { + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT account_id, username FROM account WHERE last_ip = '%s' AND account_id NOT IN (SELECT account_id FROM account_permissions WHERE account_id = account.account_id AND permission_mask >= '3' AND realm_id = '%i')", ip.c_str(), realmID); + return LookupPlayerSearchCommand(result, limit); + } + else + { + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT account_id, username FROM account WHERE last_ip = '%s'", ip.c_str()); + return LookupPlayerSearchCommand(result, limit); + } - return LookupPlayerSearchCommand(result, limit); } bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) @@ -3555,7 +3672,7 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) char* limit_str = strtok(NULL, " "); int32 limit = limit_str ? atoi(limit_str) : -1; - if (!AccountMgr::normilizeString(account)) + if (!AccountMgr::normalizeString(account)) return false; AccountsDatabase.escape_string(account); @@ -3914,6 +4031,40 @@ bool ChatHandler::HandleGameObjectActivateCommand(const char *args) return true; } +bool ChatHandler::HandleGameObjectResetCommand(const char *args) +{ + if (!*args) + return false; + + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + // Activate + obj->Reset(); + + PSendSysMessage("Object reset!"); + + return true; +} + // add creature, temp only bool ChatHandler::HandleNpcAddTempCommand(const char* args) { @@ -4403,7 +4554,7 @@ bool ChatHandler::HandleGuildDisableAnnounceCommand(const char *args) std::string guildName = args; - Guild* guild = sObjectMgr.GetGuildByName(guildName); + Guild* guild = sGuildMgr.GetGuildByName(guildName); if (!guild) return false; @@ -4421,7 +4572,7 @@ bool ChatHandler::HandleGuildEnableAnnounceCommand(const char *args) std::string guildName = args; - Guild* guild = sObjectMgr.GetGuildByName(guildName); + Guild* guild = sGuildMgr.GetGuildByName(guildName); if (!guild) return false; @@ -4431,3 +4582,160 @@ bool ChatHandler::HandleGuildEnableAnnounceCommand(const char *args) return true; } + +bool ChatHandler::HandleTrollmuteCommand(const char* args) +{ + if (!*args) + return false; + + char *charname = strtok((char*)args, " "); + if (!charname) + return false; + + std::string cname = charname; + + char *timetonotspeak = strtok(NULL, " "); + if (!timetonotspeak) + return false; + + char *mutereason = strtok(NULL, ""); + std::string mutereasonstr; + if (!mutereason) + mutereasonstr = "No reason."; + else + mutereasonstr = mutereason; + + uint32 notspeaktime = (uint32) atoi(timetonotspeak); + + if (notspeaktime == 0) + return false; + + if (!normalizePlayerName(cname)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = sObjectMgr.GetPlayerGUIDByName(cname.c_str()); + if (!guid) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = sObjectMgr.GetPlayer(guid); + + // check security + uint32 account_id = 0; + uint32 permissions = 0; + + if (chr) + { + account_id = chr->GetSession()->GetAccountId(); + permissions = chr->GetSession()->GetPermissions(); + } + else + { + account_id = sObjectMgr.GetPlayerAccountIdByGUID(guid); + permissions = AccountMgr::GetPermissions(account_id); + } + + if (m_session && permissions >= m_session->GetPermissions()) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + SetSentErrorMessage(true); + return false; + } + + time_t mutetime = time(NULL) + notspeaktime*60; + + AccountsDatabase.escape_string(mutereasonstr); + + if (chr) + { + chr->GetSession()->m_trollmuteTime = mutetime; + chr->GetSession()->m_trollmuteReason = mutereasonstr; + } + + std::string author; + + if (m_session) + author = m_session->GetPlayerName(); + else + author = "[CONSOLE]"; + + AccountsDatabase.escape_string(author); + + AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), '%u', '%s', '%s', '1')", + account_id, PUNISHMENT_TROLLMUTE, uint64(mutetime), author.c_str(), mutereasonstr.c_str()); + + SendGlobalGMSysMessage(LANG_GM_TROLLMUTED_PLAYER, author.c_str(), cname.c_str(), notspeaktime, mutereasonstr.c_str()); + + return true; +} + +bool ChatHandler::HandleTrollmuteInfoCommand(const char* args) +{ + if (!args) + return false; + + char* cname = strtok ((char*)args, ""); + if (!cname) + return false; + + std::string name = cname; + if (!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint32 accountid = sObjectMgr.GetPlayerAccountIdByPlayerName(name); + if (!accountid) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + std::string accountname; + if (!AccountMgr::GetName(accountid,accountname)) + { + PSendSysMessage(LANG_MUTEINFO_NOCHARACTER); + return true; + } + + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT FROM_UNIXTIME(punishment_date), expiration_date-punishment_date, expiration_date, reason, punished_by, active " + "FROM account_punishment " + "WHERE account_id = '%u' AND punishment_type_id = '%u' " + "ORDER BY punishment_date ASC", accountid, PUNISHMENT_TROLLMUTE); + + if (!result) + { + PSendSysMessage(LANG_MUTEINFO_NOACCOUNT_TROLLMUTE, accountname.c_str()); + return true; + } + + PSendSysMessage(LANG_MUTEINFO_TROLLMUTE_HISTORY, accountname.c_str()); + do + { + Field* fields = result->Fetch(); + + time_t unmutedate = time_t(fields[2].GetUInt64()); + uint64 muteLength = fields[1].GetUInt64(); + + bool active = false; + if ((muteLength == 0 || unmutedate >= time(NULL)) && fields[5].GetBool()) + active = true; + + std::string mutetime = secsToTimeString(muteLength, true); + PSendSysMessage(LANG_MUTEINFO_HISTORYENTRY, + fields[0].GetString(), mutetime.c_str(), active ? GetHellgroundString(LANG_MUTEINFO_YES):GetHellgroundString(LANG_MUTEINFO_NO), fields[3].GetString(), fields[4].GetString()); + } + while (result->NextRow()); + + return true; +} diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp old mode 100755 new mode 100644 index 2bfb58e56..fc070ea2a --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1,22 +1,22 @@ /* -* Copyright (C) 2005-2009 MaNGOS -* -* Copyright (C) 2008-2009 Trinity -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "Common.h" #include "Database/DatabaseEnv.h" @@ -47,7 +47,6 @@ #include "SkillDiscovery.h" #include "SkillExtraItems.h" #include "SystemConfig.h" -#include "Config/Config.h" #include "Util.h" #include "ItemEnchantmentMgr.h" #include "BattleGroundMgr.h" @@ -55,6 +54,8 @@ #include "InstanceData.h" #include "CreatureEventAIMgr.h" #include "ChannelMgr.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" bool ChatHandler::HandleReloadAutobroadcastCommand(const char*) { @@ -72,6 +73,18 @@ bool ChatHandler::HandleReloadCommand(const char* arg) return false; } +extern bool StartEluna(); +bool ChatHandler::HandleReloadElunaCommand(const char* /*args*/) +{ + sLog.outString("Re-Loading Eluna LuaEngine..."); + + if (StartEluna()) + SendGlobalGMSysMessage("Eluna LuaEngine reloaded."); + else + SendGlobalGMSysMessage("Eluna Lua Engine is disabled can't reload."); + return true; +} + bool ChatHandler::HandleReloadAllCommand(const char*) { HandleReloadAreaTriggerTeleportCommand(""); @@ -156,7 +169,7 @@ bool ChatHandler::HandleReloadAllScriptsCommand(const char*) bool ChatHandler::HandleReloadAllSpellCommand(const char*) { HandleReloadSkillDiscoveryTemplateCommand("a"); - HandleReloadSkillExtraItemTemplateCommand("a"); + HandleReloadSkillExtraItemPrototypeCommand("a"); HandleReloadSpellAffectCommand("a"); HandleReloadSpellRequiredCommand("a"); HandleReloadSpellElixirCommand("a"); @@ -434,7 +447,7 @@ bool ChatHandler::HandleReloadReputationRewardRateCommand(const char*) { sLog.outString("Re-Loading `reputation_reward_rate` Table!"); sObjectMgr.LoadReputationRewardRate(); - SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); + SendGlobalGMSysMessage("DB table `reputation_reward_rate` reloaded."); return true; } @@ -442,7 +455,7 @@ bool ChatHandler::HandleReloadReputationSpilloverTemplateCommand(const char*) { sLog.outString("Re-Loading `reputation_spillover_template` Table!"); sObjectMgr.LoadReputationSpilloverTemplate(); - SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); + SendGlobalGMSysMessage("DB table `reputation_spillover_template` reloaded."); return true; } @@ -454,7 +467,7 @@ bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/ return true; } -bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) +bool ChatHandler::HandleReloadSkillExtraItemPrototypeCommand(const char* /*args*/) { sLog.outString("Re-Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); @@ -810,7 +823,7 @@ bool ChatHandler::HandleReloadAuctionsCommand(const char* args) return true; } -bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) +bool ChatHandler::HandleAccountSetPermissionsCommand(const char* args) { if (!*args) return false; @@ -847,16 +860,15 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) } // Decide which string to show - if (m_session->GetPlayer()!=targetPlayer) - { + if (m_session->GetPlayer() != targetPlayer) PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - }else{ + else PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, m_session->GetPlayer()->GetName(), gm); - } - AccountsDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + AccountsDatabase.PExecute("UPDATE account_permissions SET permission_mask = '%u' WHERE account_id = '%u' AND realm_id = '%u'", gm, targetAccountId, realmID); return true; - }else + } + else { // Check for second parameter if (!arg2) @@ -864,9 +876,9 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) // Check for account targetAccountName = arg1; - if (!AccountMgr::normilizeString(targetAccountName)) + if (!AccountMgr::normalizeString(targetAccountName)) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str()); SetSentErrorMessage(true); return false; } @@ -915,7 +927,7 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) return false; std::string account_name = szAccount; - if (!AccountMgr::normilizeString(account_name)) + if (!AccountMgr::normalizeString(account_name)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); SetSentErrorMessage(true); @@ -1134,13 +1146,13 @@ bool ChatHandler::HandleCooldownCommand(const char* args) if (!sSpellStore.LookupEntry(spell_id)) { - PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); + PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetHellgroundString(LANG_YOU) : target->GetName()); SetSentErrorMessage(true); return false; } target->RemoveSpellCooldown(spell_id,true); - PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); + PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetHellgroundString(LANG_YOU) : target->GetName()); } return true; } @@ -2056,7 +2068,7 @@ bool ChatHandler::HandleAddItemCommand(const char* args) if (!plTarget) plTarget = pl; - sLog.outDetail(GetTrinityString(LANG_ADDITEM), itemId, count); + sLog.outDetail(GetHellgroundString(LANG_ADDITEM), itemId, count); ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemId); if (!pProto) @@ -2135,7 +2147,7 @@ bool ChatHandler::HandleAddItemSetCommand(const char* args) if (!plTarget) plTarget = pl; - sLog.outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); + sLog.outDetail(GetHellgroundString(LANG_ADDITEMSET), itemsetId); bool found = false; for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) @@ -2617,7 +2629,7 @@ void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx)//, Player* targ if (target) { if (target->CanUseItem(itemProto)) - usableStr = GetTrinityString(LANG_COMMAND_ITEM_USABLE); + usableStr = GetHellgroundString(LANG_COMMAND_ITEM_USABLE); }*/ if (m_session) @@ -2777,7 +2789,7 @@ bool ChatHandler::HandleLookupSkillCommand(const char* args) { char const* knownStr = ""; if (target && target->HasSkill(id)) - knownStr = GetTrinityString(LANG_KNOWN); + knownStr = GetHellgroundString(LANG_KNOWN); // send skill in "id - [namedlink locale]" format if (m_session) @@ -2865,7 +2877,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args) // include rank in link name if (rank) - ss << GetTrinityString(LANG_SPELL_RANK) << rank; + ss << GetHellgroundString(LANG_SPELL_RANK) << rank; if (m_session) ss << " " << localeNames[loc] << "]|h|r"; @@ -2873,15 +2885,15 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args) ss << " " << localeNames[loc]; if (talent) - ss << GetTrinityString(LANG_TALENT); + ss << GetHellgroundString(LANG_TALENT); if (passive) - ss << GetTrinityString(LANG_PASSIVE); + ss << GetHellgroundString(LANG_PASSIVE); if (learn) - ss << GetTrinityString(LANG_LEARN); + ss << GetHellgroundString(LANG_LEARN); if (known) - ss << GetTrinityString(LANG_KNOWN); + ss << GetHellgroundString(LANG_KNOWN); if (active) - ss << GetTrinityString(LANG_ACTIVE); + ss << GetHellgroundString(LANG_ACTIVE); SendSysMessage(ss.str().c_str()); @@ -2939,12 +2951,12 @@ bool ChatHandler::HandleLookupQuestCommand(const char* args) if (status == QUEST_STATUS_COMPLETE) { if (target->GetQuestRewardStatus(qinfo->GetQuestId())) - statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_REWARDED); else - statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_COMPLETE); } else if (status == QUEST_STATUS_INCOMPLETE) - statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_ACTIVE); } if (m_session) @@ -2973,12 +2985,12 @@ bool ChatHandler::HandleLookupQuestCommand(const char* args) if (status == QUEST_STATUS_COMPLETE) { if (target->GetQuestRewardStatus(qinfo->GetQuestId())) - statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_REWARDED); else - statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_COMPLETE); } else if (status == QUEST_STATUS_INCOMPLETE) - statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); + statusStr = GetHellgroundString(LANG_COMMAND_QUEST_ACTIVE); } if (m_session) @@ -3159,7 +3171,7 @@ bool ChatHandler::HandleGuildCreateCommand(const char* args) return false; } - sObjectMgr.AddGuild (guild); + sGuildMgr.AddGuild (guild); return true; } @@ -3174,7 +3186,7 @@ bool ChatHandler::HandleGuildInviteCommand(const char *args) return false; std::string glName = par2; - Guild* targetGuild = sObjectMgr.GetGuildByName (glName); + Guild* targetGuild = sGuildMgr.GetGuildByName (glName); if (!targetGuild) return false; @@ -3235,7 +3247,7 @@ bool ChatHandler::HandleGuildUninviteCommand(const char *args) if (!plGuid || !glId) return false; - Guild* targetGuild = sObjectMgr.GetGuildById (glId); + Guild* targetGuild = sGuildMgr.GetGuildById (glId); if (!targetGuild) return false; @@ -3277,7 +3289,7 @@ bool ChatHandler::HandleGuildRankCommand(const char *args) if (!plGuid || !glId) return false; - Guild* targetGuild = sObjectMgr.GetGuildById (glId); + Guild* targetGuild = sGuildMgr.GetGuildById (glId); if (!targetGuild) return false; @@ -3297,7 +3309,7 @@ bool ChatHandler::HandleGuildDeleteCommand(const char* args) std::string gld = args; - Guild* targetGuild = sObjectMgr.GetGuildByName(gld); + Guild* targetGuild = sGuildMgr.GetGuildByName(gld); if (!targetGuild) return false; @@ -3567,7 +3579,7 @@ bool ChatHandler::HandleReviveGroupCommand(const char* args) // before GM float x,y,z; - gm->GetClosePoint(x, y, z, pl->GetObjectSize()); + gm->GetNearPoint(x, y, z, pl->GetObjectSize()); pl->TeleportTo(gm->GetMapId(), x, y, z, pl->GetOrientation()); pl->ResurrectPlayer(0.5f); @@ -3724,14 +3736,14 @@ bool ChatHandler::HandleNearGraveCommand(const char* args) g_team = data->team; - std::string team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); + std::string team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_NOTEAM); if (g_team == 0) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_ANY); else if (g_team == HORDE) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_HORDE); else if (g_team == ALLIANCE) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_ALLIANCE); PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id,team_name.c_str(),player->GetCachedZone()); } @@ -3740,11 +3752,11 @@ bool ChatHandler::HandleNearGraveCommand(const char* args) std::string team_name; if (g_team == 0) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_ANY); else if (g_team == HORDE) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_HORDE); else if (g_team == ALLIANCE) - team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + team_name = GetHellgroundString(LANG_COMMAND_GRAVEYARD_ALLIANCE); if (g_team == ~uint32(0)) PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, player->GetCachedZone()); @@ -3816,6 +3828,8 @@ bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) if (npcflags & UNIT_NPC_FLAG_TRAINER) SendSysMessage(LANG_NPCINFO_TRAINER); + PSendSysMessage("XpMOD template: %f", cInfo->xpMod); + PSendSysMessage("XpMOD creature: %f", target->m_xpMod); PSendSysMessage("AIName: %s, ScriptName: %s", target->GetAIName().c_str(), target->GetScriptName().c_str()); PSendSysMessage("DeadByDefault: %i", (int)target->GetIsDeadByDefault()); @@ -3829,7 +3843,7 @@ bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) PSendSysMessage("Combat reach: %f, BoundingRadius: %f", target->GetFloatValue(UNIT_FIELD_COMBATREACH), target->GetFloatValue(UNIT_FIELD_BOUNDINGRADIUS)); PSendSysMessage("Determinative Size: %f, CollisionWidth: %f, Scale DB: %f, Scale DBC: %f", target->GetDeterminativeSize(), modelInfo->CollisionWidth, cInfo->scale, displayInfo->scale); - PSendSysMessage("Active flags: %x", target->isActiveObject()); + PSendSysMessage("Active flags: %x; Extra flags: 0x%08X", target->isActiveObject(),cInfo->flags_extra); return true; } @@ -4002,6 +4016,7 @@ bool ChatHandler::HandleLevelUpCommand(const char* args) if (chr) { + chr->SetDifficulty(DIFFICULTY_NORMAL); chr->GiveLevel(newlevel); chr->InitTalentForLevel(); chr->SetUInt32Value(PLAYER_XP,0); @@ -4226,14 +4241,14 @@ bool ChatHandler::HandleDebugSetValue(const char* args) if (isint32) { iValue = (uint32)atoi(py); - sLog.outDebug(GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); + sLog.outDebug(GetHellgroundString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); target->SetUInt32Value(Opcode , iValue); PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); } else { fValue = (float)atof(py); - sLog.outDebug(GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + sLog.outDebug(GetHellgroundString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); target->SetFloatValue(Opcode , fValue); PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); } @@ -4277,13 +4292,13 @@ bool ChatHandler::HandleDebugGetValue(const char* args) if (isint32) { iValue = target->GetUInt32Value(Opcode); - sLog.outDebug(GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); + sLog.outDebug(GetHellgroundString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); } else { fValue = target->GetFloatValue(Opcode); - sLog.outDebug(GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + sLog.outDebug(GetHellgroundString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); } @@ -4306,7 +4321,7 @@ bool ChatHandler::HandleSet32Bit(const char* args) if (Value > 32) //uint32 = 32 bits return false; - sLog.outDebug(GetTrinityString(LANG_SET_32BIT), Opcode, Value); + sLog.outDebug(GetHellgroundString(LANG_SET_32BIT), Opcode, Value); m_session->GetPlayer()->SetUInt32Value(Opcode , 2^Value); @@ -4334,7 +4349,7 @@ bool ChatHandler::HandleDebugMod32Value(const char* args) return false; } - sLog.outDebug(GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); + sLog.outDebug(GetHellgroundString(LANG_CHANGE_32BIT), Opcode, Value); int CurrentValue = (int)m_session->GetPlayer()->GetUInt32Value(Opcode); @@ -4414,8 +4429,8 @@ bool ChatHandler::HandleListAurasCommand (const char * /*args*/) return false; } - char const* talentStr = GetTrinityString(LANG_TALENT); - char const* passiveStr = GetTrinityString(LANG_PASSIVE); + char const* talentStr = GetHellgroundString(LANG_TALENT); + char const* passiveStr = GetHellgroundString(LANG_PASSIVE); Unit::AuraMap const& uAuras = unit->GetAuras(); PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size()); @@ -4770,16 +4785,16 @@ bool ChatHandler::HandleResetAllCommand(const char * args) if (casename=="spells") { atLogin = AT_LOGIN_RESET_SPELLS; - sWorld.SendWorldText(LANG_RESETALL_SPELLS); + sWorld.SendWorldText(LANG_RESETALL_SPELLS, 0); } else if (casename=="talents") { atLogin = AT_LOGIN_RESET_TALENTS; - sWorld.SendWorldText(LANG_RESETALL_TALENTS); + sWorld.SendWorldText(LANG_RESETALL_TALENTS, 0); } else { - PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE,args); + PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE, 0, args); SetSentErrorMessage(true); return false; } @@ -4866,7 +4881,7 @@ bool ChatHandler::HandleServerRollShutDownCommand(const char* args) time = urand(1, roll); - sWorld.SendWorldText(LANG_ROLLSHUTDOWN, roll, time, exitmsg); + sWorld.SendWorldText(LANG_ROLLSHUTDOWN, 0, roll, time, exitmsg); sWorld.ShutdownServ(time, 0, SHUTDOWN_EXIT_CODE, exitmsg); return true; @@ -5083,7 +5098,7 @@ bool ChatHandler::HandleQuestComplete(const char* args) } } - // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") + // All creature/GO slain/cast (not required, but otherwise it will display "Creature slain 0/10") for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { uint32 creature = pQuest->ReqCreatureOrGOId[i]; @@ -5092,7 +5107,7 @@ bool ChatHandler::HandleQuestComplete(const char* args) if (uint32 spell_id = pQuest->ReqSpell[i]) { for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); + player->CastCreatureOrGO(creature,0,spell_id); } else if (creature > 0) { @@ -5102,7 +5117,7 @@ bool ChatHandler::HandleQuestComplete(const char* args) else if (creature < 0) { for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,0); + player->CastCreatureOrGO(creature,0,0); } } @@ -5171,7 +5186,7 @@ bool ChatHandler::HandleBanHelper(BanMode mode, const char* args) switch (mode) { case BAN_ACCOUNT: - if (!AccountMgr::normilizeString(nameIPOrMail)) + if (!AccountMgr::normalizeString(nameIPOrMail)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameIPOrMail.c_str()); SetSentErrorMessage(true); @@ -5265,7 +5280,7 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, const char* args) switch (mode) { case BAN_ACCOUNT: - if (!AccountMgr::normilizeString(nameIPOrMail)) + if (!AccountMgr::normalizeString(nameIPOrMail)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameIPOrMail.c_str()); SetSentErrorMessage(true); @@ -5304,7 +5319,7 @@ bool ChatHandler::HandleBanInfoAccountCommand(const char* args) return false; std::string account_name = cname; - if (!AccountMgr::normilizeString(account_name)) + if (!AccountMgr::normalizeString(account_name)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); SetSentErrorMessage(true); @@ -5358,7 +5373,7 @@ bool ChatHandler::HandleBanInfoCharacterCommand(const char* args) bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) { - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT FROM_UNIXTIME(punishment_date), expiration_date-punishment_date, expiration_date, reason, punished_by " + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT FROM_UNIXTIME(punishment_date), expiration_date-punishment_date, expiration_date, reason, punished_by, active " "FROM account_punishment " "WHERE punishment_type_id = '%u' AND account_id = '%u' " "ORDER BY punishment_date ASC", PUNISHMENT_BAN, accountid); @@ -5379,13 +5394,13 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) bool active = false; bool permanent = (banLength == 0); - if (permanent || unbandate >= time(NULL)) + if ((permanent || unbandate >= time(NULL)) && fields[5].GetBool()) active = true; - std::string bantime = permanent ? GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(banLength, true); + std::string bantime = permanent ? GetHellgroundString(LANG_BANINFO_INFINITE) : secsToTimeString(banLength, true); PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[3].GetString(), fields[4].GetString()); + fields[0].GetString(), bantime.c_str(), active ? GetHellgroundString(LANG_BANINFO_YES):GetHellgroundString(LANG_BANINFO_NO), fields[3].GetString(), fields[4].GetString()); } while (result->NextRow()); @@ -5407,7 +5422,7 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args) std::string IP = cIP; AccountsDatabase.escape_string(IP); - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT ip, FROM_UNIXTIME(ban_date), FROM_UNIXTIME(unban_date), unban_date-UNIX_TIMESTAMP(), ban_reason, banned_by, unban_date-ban_date FROM ip_banned WHERE ip = '%s'", IP.c_str()); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT ip, FROM_UNIXTIME(punishment_date), FROM_UNIXTIME(expiration_date), expiration_date-UNIX_TIMESTAMP(), ban_reason, punished_by, expiration_date-punishment_date FROM ip_banned WHERE ip = '%s'", IP.c_str()); if (!result) { PSendSysMessage(LANG_BANINFO_NOIP); @@ -5417,8 +5432,8 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args) Field *fields = result->Fetch(); bool permanent = !fields[6].GetUInt64(); PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), - permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); + fields[0].GetString(), fields[1].GetString(), permanent ? GetHellgroundString(LANG_BANINFO_NEVER):fields[2].GetString(), + permanent ? GetHellgroundString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); return true; } @@ -5434,7 +5449,7 @@ bool ChatHandler::HandleBanInfoEmailCommand(const char* args) std::string email = cEmail; AccountsDatabase.escape_string(email); - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT email, FROM_UNIXTIME(ban_date), ban_reason, banned_by FROM email_banned WHERE email = '%s'", email.c_str()); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT email, FROM_UNIXTIME(punishment_date), ban_reason, punished_by FROM email_banned WHERE email = '%s'", email.c_str()); if (!result) { PSendSysMessage(LANG_BANINFO_NOEMAIL); @@ -5476,11 +5491,12 @@ bool ChatHandler::HandleBanListAccountCommand(const char* args) if (filter.empty()) result = AccountsDatabase.PQuery("SELECT account.account_id, username " "FROM account JOIN account_punishment ON account.account_id = account_punishment.account_id " - "WHERE punishment_type_id = '%u' AND expiration_date > UNIX_TIMESTAMP() GROUP BY account.account_id", PUNISHMENT_BAN); + "WHERE punishment_type_id = '%u' AND active = 1 GROUP BY account.account_id", PUNISHMENT_BAN); else result = AccountsDatabase.PQuery("SELECT account.account_id, username " "FROM account JOIN account_punishment ON account.account_id = account_punishment.account_id " - "WHERE punishment_type_id = '%u' AND username LIKE '%%%s%%' GROUP BY account.account_id", PUNISHMENT_BAN, filter.c_str()); + "WHERE punishment_type_id = '%u' AND active = 1 AND " + "username LIKE '%%%s%%' GROUP BY account.account_id", PUNISHMENT_BAN, filter.c_str()); if (!result) @@ -5585,13 +5601,13 @@ bool ChatHandler::HandleBanListIPCommand(const char* args) QueryResultAutoPtr result; if (filter.empty()) - result = AccountsDatabase.Query("SELECT ip, ban_date, unban_date, banned_by, ban_reason FROM ip_banned" - " WHERE (ban_date = unban_date OR unban_date > UNIX_TIMESTAMP())" - " ORDER BY unban_date"); + result = AccountsDatabase.Query("SELECT ip, punishment_date, expiration_date, punished_by, ban_reason FROM ip_banned" + " WHERE (punishment_date = expiration_date OR expiration_date > UNIX_TIMESTAMP())" + " ORDER BY expiration_date"); else - result = AccountsDatabase.PQuery("SELECT ip, ban_date, unban_date, banned_by, ban_reason FROM ip_banned" - " WHERE (ban_date = unban_date OR unban_date > UNIX_TIMESTAMP()) AND ip LIKE '%%%s%%'" - " ORDER BY unban_date", filter.c_str()); + result = AccountsDatabase.PQuery("SELECT ip, punishment_date, expiration_date, punished_by, ban_reason FROM ip_banned" + " WHERE (punishment_date = expiration_date OR expiration_date > UNIX_TIMESTAMP()) AND ip LIKE '%%%s%%'" + " ORDER BY expiration_date", filter.c_str()); if (!result) { @@ -5655,12 +5671,12 @@ bool ChatHandler::HandleBanListEmailCommand(const char* args) if (filter.empty()) { - result = AccountsDatabase.Query ("SELECT email, ban_date, banned_by, ban_reason FROM email_banned" + result = AccountsDatabase.Query ("SELECT email, punishment_date, punished_by, ban_reason FROM email_banned" " ORDER BY bandate ASC"); } else { - result = AccountsDatabase.PQuery("SELECT email, ban_date, banned_by, ban_reason FROM email_banned" + result = AccountsDatabase.PQuery("SELECT email, punishment_date, punished_by, ban_reason FROM email_banned" " WHERE email LIKE CONCAT('%', '%s', '%')" " ORDER BY bandate ASC" , filter.c_str()); } @@ -5862,18 +5878,8 @@ bool ChatHandler::HandlePLimitCommand(const char *args) if (!param) return false; - int l = strlen(param); - - if (strncmp(param,"reset",l) == 0) - sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); - else - { - int val = atoi(param); - if (val < 0) - sWorld.SetMinimumPermissionMask(-val); - else - sWorld.SetPlayerLimit(val); - } + int val = atoi(param); + sWorld.SetPlayerLimit(val); // kick all low security level players if (!sWorld.GetMinimumPermissionMask() & PERM_PLAYER) @@ -6007,7 +6013,7 @@ bool ChatHandler::HandleCastDistCommand(const char* args) bool triggered = (trig_str != NULL); float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,dist); + m_session->GetPlayer()->GetNearPoint(x,y,z,dist); m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); return true; @@ -6409,7 +6415,7 @@ bool ChatHandler::HandleInstanceResetEncountersCommand(const char* args) bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) { ///- Get the accounts with GM Level >0 - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT username, permission_mask FROM account JOIN account_permission WHERE permission_mask & '%u' AND realm_id = '%u'", PERM_GMT, realmID); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT username, permission_mask FROM account JOIN account_permission WHERE permission_mask & '%u' AND realm_id = '%u'", PERM_GMT_DEV, realmID); if (result) { SendSysMessage(LANG_GMLIST); @@ -6466,7 +6472,7 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args) { ///- Convert Account name to Upper Format account_name = szAcc; - if (!AccountMgr::normilizeString(account_name)) + if (!AccountMgr::normalizeString(account_name)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); SetSentErrorMessage(true); @@ -6902,7 +6908,7 @@ bool ChatHandler::HandleFreezeCommand(const char *args) //stop combat + make player unattackable + duel stop + stop some spells player->setFaction(35); player->CombatStop(); - if (player->IsNonMeleeSpellCasted(true)) + if (player->IsNonMeleeSpellCast(true)) player->InterruptNonMeleeSpells(true); player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); player->SetUInt32Value(PLAYER_DUEL_TEAM, 1); @@ -7396,3 +7402,78 @@ bool ChatHandler::HandleMmapTestArea(const char* args) return true; } + +// Set friends for account +bool ChatHandler::HandleAccountFriendAddCommand(const char* args) +{ + ///- Get the command line arguments + char* arg1 = strtok((char*) args, " "); + if (arg1 == nullptr || arg1 == "") + return false; + + uint32 targetAccountId = atoi(arg1); + if (!targetAccountId) + return false; + + uint32 friendAccountId = atoi(strtok(NULL, " ")); + + if (!friendAccountId) + return false; + + AccountOpResult result = AccountMgr::AddRAFLink(targetAccountId, friendAccountId); + + switch (result) + { + case AOR_OK: + SendSysMessage(LANG_COMMAND_FRIEND); + break; + default: + SendSysMessage(LANG_COMMAND_FRIEND_ERROR); + SetSentErrorMessage(true); + return false; + } + + return true; +} + +// Delete friends for account +bool ChatHandler::HandleAccountFriendDeleteCommand(const char* args) +{ + ///- Get the command line arguments + char* arg1 = strtok((char*) args, " "); + if (arg1 == nullptr || arg1 == "") + return false; + + uint32 targetAccountId = atoi(arg1); + if (!targetAccountId) + return false; + + char* arg2 = strtok(NULL, " "); + if (arg2 == nullptr || arg2 == "") + return false; + + uint32 friendAccountId = atoi(arg2); + if (!friendAccountId) + return false; + + AccountOpResult result = AccountMgr::DeleteRAFLink(targetAccountId, friendAccountId); + + switch (result) + { + case AOR_OK: + SendSysMessage(LANG_COMMAND_FRIEND); + break; + default: + SendSysMessage(LANG_COMMAND_FRIEND_ERROR); + SetSentErrorMessage(true); + return false; + } + + return true; +} + +// List friends for account +bool ChatHandler::HandleAccountFriendListCommand(const char* args) +{ + return false; +} diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index a3072fe54..a7bc2cd71 100755 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ #include "Group.h" #include "World.h" #include "Util.h" +#include "luaengine/HookMgr.h" void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data) { @@ -149,9 +150,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data) //if only one person is supposed to loot the item, then set it to looted if (!item->freeforall) - loot->setItemLooted(item); - else - loot->removeItemFromSavedLoot(item); + loot->setItemLooted(item,player); --loot->unlootedCount; player->SendNewItem(newitem, uint32(item->count), false, false, true); @@ -243,6 +242,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) else player->ModifyMoney(pLoot->gold); + // used by eluna + sHookMgr->OnLootMoney(player, pLoot->gold); + pLoot->gold = 0; pLoot->NotifyMoneyRemoved(); } @@ -315,8 +317,13 @@ void WorldSession::DoLootRelease(uint64 lguid) else go->SetLootState(GO_READY); } - else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) - go->SetLootState(GO_JUST_DEACTIVATED); + + loot->clear(); + } + + if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) + { + go->SetLootState(GO_JUST_DEACTIVATED); loot->clear(); } @@ -416,6 +423,9 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (_player->GetLootGUID() != lootguid) return; + if (_player->GetInstanceId() != target->GetInstanceId()) + return; + Loot *pLoot = NULL; if (IS_CREATURE_GUID(GetPlayer()->GetLootGUID())) @@ -461,10 +471,13 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) target->SaveToDB(); + // used by eluna + sHookMgr->OnLootItem(target, newitem, item.count, lootguid); + // mark as looted item.count=0; - pLoot->setItemLooted(&item); + pLoot->setItemLooted(&item,target); pLoot->NotifyItemRemoved(slotid); --pLoot->unlootedCount; } diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index d36508ca3..df1d22557 100755 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -235,11 +235,11 @@ bool LootStoreItem::Roll() const return true; if (mincountOrRef < 0) // reference case - return roll_chance_f(chance*sWorld.getRate(RATE_DROP_ITEM_REFERENCED)); + return roll_chance_f(chance*sWorld.getConfig(RATE_DROP_ITEM_REFERENCED)); ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); - float qualityModifier = pProto ? sWorld.getRate(qualityToRate[pProto->Quality]) : 1.0f; + float qualityModifier = pProto ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f; return roll_chance_f(chance*qualityModifier); } @@ -394,7 +394,7 @@ void Loot::AddItem(LootStoreItem const & item) bool Loot::IsPlayerAllowedToLoot(Player *player, WorldObject *object) { return players_allowed_to_loot.empty() ? - player->IsWithinDist(object, sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE), false) : + player->IsWithinDistInMap(object, sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE), false) : players_allowed_to_loot.find(player->GetGUID()) != players_allowed_to_loot.end(); } @@ -555,6 +555,36 @@ void Loot::removeItemFromSavedLoot(LootItem *item) //CharacterDatabase.CommitTransaction(); } +void Loot::RemoveSavedLootFromDB(Creature * pCreature) +{ + if (!pCreature) + return; + + static SqlStatementID deleteCreatureLoot; + + SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteCreatureLoot, "DELETE FROM group_saved_loot WHERE creatureId=? AND instanceId=?"); + stmt.PExecute(pCreature->GetEntry(), pCreature->GetInstanceId()); +} + +void Loot::RemoveSavedLootFromDB() +{ + if (!m_creatureGUID) + return; + + Map *pMap = sMapMgr.FindMap(m_mapID.nMapId, m_mapID.nInstanceId); + if (!pMap || !pMap->Instanceable()) + return; + + Creature *pCreature = pMap->GetCreatureOrPet(m_creatureGUID); + if (!pCreature) + { + //sLog.outLog(LOG_BOSS, "Loot::saveLootToDB: pCreature not found !!: player %s(%u)", owner->GetName(),owner->GetGUIDLow()); + return; + } + + RemoveSavedLootFromDB(pCreature); +} + void Loot::saveLootToDB(Player *owner) { if (!m_creatureGUID) @@ -574,16 +604,15 @@ void Loot::saveLootToDB(Player *owner) std::map item_count; RealmDataDatabase.BeginTransaction(); - static SqlStatementID deleteCreatureLoot; static SqlStatementID updateItemCount; static SqlStatementID insertItem; // delete old saved loot - SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteCreatureLoot, "DELETE FROM group_saved_loot WHERE creatureId=? AND instanceId=?"); - stmt.PExecute(pCreature->GetEntry(), pCreature->GetInstanceId()); + RemoveSavedLootFromDB(pCreature); std::stringstream ss; - ss << "Player's group: " << owner->GetName() << ":(" << owner->GetGUIDLow() << ") " << "LootedItems: "; + ss << "Player's group: " << owner->GetName() << ":(" << owner->GetGUIDLow() << ") Map: " << m_mapID.nMapId + << " Id: " << m_mapID.nInstanceId << " Generated loot: "; std::stringstream guids; @@ -618,7 +647,7 @@ void Loot::saveLootToDB(Player *owner) stmt.addUInt32(pCreature->GetInstanceId()); stmt.addUInt32(item->itemid); stmt.addUInt32(count); - stmt.addBool(pCreature->IsTempSummon()); + stmt.addBool(pCreature->IsTemporarySummon()); stmt.addFloat(pCreature->GetPositionX()); stmt.addFloat(pCreature->GetPositionY()); stmt.addFloat(pCreature->GetPositionZ()); @@ -843,18 +872,23 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount) if (maxAmount > 0) { if (maxAmount <= minAmount) - gold = uint32(maxAmount * sWorld.getRate(RATE_DROP_MONEY)); + gold = uint32(maxAmount * sWorld.getConfig(RATE_DROP_MONEY)); else if ((maxAmount - minAmount) < 32700) - gold = uint32(urand(minAmount, maxAmount) * sWorld.getRate(RATE_DROP_MONEY)); + gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(RATE_DROP_MONEY)); else - gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getRate(RATE_DROP_MONEY)) << 8; + gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getConfig(RATE_DROP_MONEY)) << 8; } } -void Loot::setItemLooted(LootItem *pLootItem) +void Loot::setItemLooted(LootItem *pLootItem, Player* looter) { pLootItem->is_looted = true; + if (pLootItem->freeforall || pLootItem->conditionId) // those are not saved, trying to remove them will cause log spam + return; removeItemFromSavedLoot(pLootItem); + if(looter && m_creatureGUID) + sLog.outLog(LOG_BOSS,"Map: %u ID: %u ; Item [%u] looted by %s (%u)", + m_mapID.nMapId,m_mapID.nInstanceId,pLootItem->itemid,looter->GetName(),looter->GetGUIDLow()); } LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qitem, QuestItem **ffaitem, QuestItem **conditem) diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index f33748099..0a27610da 100755 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -289,13 +289,14 @@ struct Loot void FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal); void saveLootToDB(Player *owner); + void RemoveSavedLootFromDB(); bool IsPlayerAllowedToLoot(Player *player, WorldObject *object); // Inserts the item into the loot (called by LootTemplate processors) void AddItem(LootStoreItem const & item); - void setItemLooted(LootItem *pLootItem); + void setItemLooted(LootItem *pLootItem, Player* looter); void removeItemFromSavedLoot(LootItem *pLootItem); void setCreatureGUID(Creature *pCreature); @@ -312,6 +313,8 @@ struct Loot void RemoveQuestLoot(Player* player); private: + void RemoveSavedLootFromDB(Creature *pCreature); + void FillNotNormalLootFor(Player* player); QuestItemList* FillFFALoot(Player* player); QuestItemList* FillQuestLoot(Player* player); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 2bc539e7f..dd73cf211 100755 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/src/game/Mail.h b/src/game/Mail.h index 421655476..ac4d33a7a 100755 --- a/src/game/Mail.h +++ b/src/game/Mail.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** @@ -31,8 +32,8 @@ * */ -#ifndef MANGOS_MAIL_H -#define MANGOS_MAIL_H +#ifndef HELLGROUND_MAIL_H +#define HELLGROUND_MAIL_H #include "Common.h" #include "ObjectGuid.h" diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp index 108224741..abd323e76 100644 --- a/src/game/MailHandler.cpp +++ b/src/game/MailHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** @@ -227,7 +227,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) } // test the receiver's Faction... - if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && !(GetPermissions() & PERM_GMT)) + if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && !HasPermissions(PERM_GMT)) { pl->SendMailResult(0, 0, MAIL_ERR_NOT_YOUR_TEAM); return; @@ -293,14 +293,14 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) MailDraft draft(subject, body); + uint32 rc_account = 0; + if (receive) + rc_account = receive->GetSession()->GetAccountId(); + else + rc_account = sObjectMgr.GetPlayerAccountIdByGUID(rc); + if (items_count > 0 || money > 0) { - uint32 rc_account = 0; - if (receive) - rc_account = receive->GetSession()->GetAccountId(); - else - rc_account = sObjectMgr.GetPlayerAccountIdByGUID(rc); - if (items_count > 0) { for(uint8 i = 0; i < items_count; ++i) @@ -309,13 +309,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) if (!item) continue; - if (GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); } - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); pl->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true); @@ -335,7 +335,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) if (money > 0) { - if (GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)", GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); @@ -347,16 +347,19 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); } - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) mail money: %u with subject: %s and body: %s to player: %s (Account: %u)", - GetPlayerName(), GetAccountId(), money, subject.c_str(), body.c_str(), receiver.c_str(), rc_account); + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) mail money: %u to player: %s (Account: %u)", + GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); } } + sLog.outLog(LOG_MAIL, "Player %s (Account: %u) sent mail to player: %s (Account: %u) with subject: %s and body: %s", + GetPlayerName(), GetAccountId(), receiver.c_str(), rc_account, subject.c_str(), body.c_str()); + // If theres is an item, there is a one hour delivery delay if sent to another account's character. uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0; // If GM sends mail to player - deliver_delay must be zero - if (deliver_delay && GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_MAIL)) + if (deliver_delay && HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_MAIL)) deliver_delay = 0; // will delete item or place to receiver mail list @@ -565,35 +568,29 @@ void WorldSession::HandleTakeItem(WorldPacket & recv_data) Player *sender = sObjectMgr.GetPlayer(sender_guid); uint32 sender_accId = 0; - - if (IsAccountFlagged(ACC_SPECIAL_LOG) || (GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE))) + std::string sender_name; + if (sender) { - std::string sender_name; - if (sender) - { - sender_accId = sender->GetSession()->GetAccountId(); - sender_name = sender->GetName(); - } - else if (sender_guid) - { - // can be calculated early - sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); - - if(!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name)) - sender_name = sObjectMgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN); - } + sender_accId = sender->GetSession()->GetAccountId(); + sender_name = sender->GetName(); + } + else if (sender_guid) + { + // can be calculated early + sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); - if (GetPermissions() & PERM_GMT) - { - sLog.outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", - GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); - } + if(!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name)) + sender_name = sObjectMgr.GetHellgroundStringForDBCLocale(LANG_UNKNOWN); + } - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", - GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); + if (HasPermissions(PERM_GMT)) + { + sLog.outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", + GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); } - else if (!sender) - sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); + + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", + GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId); // check player existence if (sender || sender_accId) diff --git a/src/game/Map.cpp b/src/game/Map.cpp old mode 100755 new mode 100644 index 4fb5aaa48..f505074f0 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapManager.h" @@ -46,7 +46,7 @@ #define DEFAULT_GRID_EXPIRY 300 #define MAX_GRID_LOAD_TIME 50 -#define MAX_CREATURE_ATTACK_RADIUS (45.0f * sWorld.getRate(RATE_CREATURE_AGGRO)) +#define MAX_CREATURE_ATTACK_RADIUS (45.0f * sWorld.getConfig(RATE_CREATURE_AGGRO)) struct ScriptAction { @@ -434,11 +434,17 @@ void Map::BroadcastPacketExcept(WorldObject* sender, WorldPacket* msg, Player* e bool Map::loaded(const GridPair &p) const { - return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); + if (NGridType* grid_type = getNGrid(p.x_coord, p.y_coord)) + { + return grid_type->isGridObjectDataLoaded(); + } + return false; } void Map::Update(const uint32 &t_diff) { + volatile uint32 debug_map_id = GetId(); + MAP_UPDATE_DIFF(DiffRecorder diff("", 0)) /// update worldsessions for existing players @@ -675,14 +681,7 @@ void Map::Remove(T *obj, bool remove) if (obj->isActiveObject()) RemoveFromActive(obj); - // workaround for crash caused by corpses on not loaded terrain /? - if (!obj->GetObjectGuid().IsCorpse()) - obj->UpdateObjectVisibility(); - else - { - if (grid->GetGridState() == GRID_STATE_ACTIVE) - obj->UpdateObjectVisibility(); - } + obj->UpdateObjectVisibility(); RemoveFromGrid(obj,grid,cell); @@ -1513,6 +1512,10 @@ void Map::ScriptsProcess() } source->SetFlag(step.script->datalong, step.script->datalong2); + + if (source->GetTypeId() == TYPEID_UNIT && step.script->datalong == UNIT_NPC_FLAGS) + ((Creature *)source)->ResetGossipOptions(); + break; case SCRIPT_COMMAND_FLAG_REMOVE: if (!source) @@ -1528,6 +1531,10 @@ void Map::ScriptsProcess() } source->RemoveFlag(step.script->datalong, step.script->datalong2); + + if (source->GetTypeId() == TYPEID_UNIT && step.script->datalong == UNIT_NPC_FLAGS) + ((Creature *)source)->ResetGossipOptions(); + break; case SCRIPT_COMMAND_TELEPORT_TO: @@ -2050,6 +2057,21 @@ void Map::ScriptsProcess() } break; } + case SCRIPT_COMMAND_SET_INST_DATA: + { + if (!source) + break; + + InstanceData* pInst = (InstanceData*)((WorldObject*)source)->GetInstanceData(); + if (!pInst) + { + sLog.outLog(LOG_DEFAULT, "ERROR: SCRIPT_COMMAND_SET_INST_DATA %d attempt to set instance data without instance script.", step.script->id); + return; + } + + pInst->SetData(step.script->datalong, step.script->datalong2); + break; + } default: sLog.outLog(LOG_DEFAULT, "ERROR: Unknown script command %u called.",step.script->command); @@ -2601,6 +2623,12 @@ Creature * Map::GetCreature(uint64 guid, float x, float y) return NULL; } + +Creature * Map::GetCreatureById(uint32 id, GetCreatureGuidType type) +{ + return GetCreature(GetCreatureGUID(id, type)); +} + Creature * Map::GetCreatureOrPet(uint64 guid) { if (IS_PLAYER_GUID(guid)) @@ -3043,8 +3071,11 @@ float Map::GetVisibilityDistance(WorldObject* obj, Player* invoker) const if (invoker && invoker->getWatchingCinematic() != 0) return MAX_VISIBILITY_DISTANCE; + if (m_TerrainData == nullptr) + return DEFAULT_VISIBILITY_DISTANCE; + float dist = m_TerrainData->GetVisibilityDistance(); - if (obj) + if (obj != nullptr) { if (obj->GetObjectGuid().IsGameObject()) return (dist + obj->ToGameObject()->GetDeterminativeSize()); // or maybe should be GetMaxVisibleDistanceForObject instead m_VisibleDistance ? diff --git a/src/game/Map.h b/src/game/Map.h old mode 100755 new mode 100644 index de8016521..35604652b --- a/src/game/Map.h +++ b/src/game/Map.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_MAP_H @@ -252,6 +252,7 @@ class HELLGROUND_IMPORT_EXPORT Map : public GridRefManager Creature* GetCreature(uint64 guid); Creature* GetCreature(uint64 guid, float x, float y); + Creature* GetCreatureById(uint32 id, GetCreatureGuidType type = GET_FIRST_CREATURE_GUID); Creature* GetCreatureOrPet(uint64 guid); GameObject* GetGameObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 5403660e9..b6031b8de 100755 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapManager.h" @@ -152,7 +152,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) { // probably there must be special opcode, because client has this string constant in GlobalStrings.lua // TODO: this is not a good place to send the message - player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(810), mapName); + player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetHellgroundString(810), mapName); sLog.outDebug("MAP: Player '%s' must be in a raid group to enter instance of '%s'", player->GetName(), mapName); return false; } @@ -185,7 +185,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) if (!instance_map) { - player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(811), mapName); + player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetHellgroundString(811), mapName); sLog.outDebug("MAP: Player '%s' doesn't has a corpse in instance '%s' and can't enter", player->GetName(), mapName); return false; } diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 365a7c9e8..8324709b3 100755 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_MAPMANAGER_H diff --git a/src/game/MapRefManager.h b/src/game/MapRefManager.h index cf8170a7b..5cb9c5f9c 100755 --- a/src/game/MapRefManager.h +++ b/src/game/MapRefManager.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MAPREFMANAGER -#define _MAPREFMANAGER +#ifndef HELLGROUND_MAPREFMANAGER_H +#define HELLGROUND_MAPREFMANAGER_H #include "Utilities/LinkedReference/RefManager.h" diff --git a/src/game/MapReference.h b/src/game/MapReference.h index 88f6b3367..f97f22540 100755 --- a/src/game/MapReference.h +++ b/src/game/MapReference.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MAPREFERENCE_H -#define _MAPREFERENCE_H +#ifndef HELLGROUND_MAPREFERENCE_H +#define HELLGROUND_MAPREFERENCE_H #include "Utilities/LinkedReference/Reference.h" #include "Map.h" diff --git a/src/game/MapUpdater.cpp b/src/game/MapUpdater.cpp index 8941f055a..d566bfdc0 100755 --- a/src/game/MapUpdater.cpp +++ b/src/game/MapUpdater.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "MapUpdater.h" #include "DelayExecutor.h" diff --git a/src/game/MapUpdater.h b/src/game/MapUpdater.h index 488d7d5c5..207bf4afe 100755 --- a/src/game/MapUpdater.h +++ b/src/game/MapUpdater.h @@ -1,6 +1,23 @@ -#ifndef _MAP_UPDATER_H_INCLUDED -#define _MAP_UPDATER_H_INCLUDED - +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_MAPUPDATER_H +#define HELLGROUND_MAPUPDATER_H #include #include diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 74573ffce..067240ffb 100755 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -49,6 +49,8 @@ #include "CellImpl.h" #include "AccountMgr.h" #include "Group.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" void WorldSession::HandleRepopRequestOpcode(WorldPacket & /*recv_data*/) { @@ -68,6 +70,9 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket & /*recv_data*/) GetPlayer()->KillPlayer(); } + // used by eluna + sHookMgr->OnRepop(GetPlayer()); + //this is spirit release confirm? GetPlayer()->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); GetPlayer()->BuildPlayerRepop(); @@ -137,6 +142,8 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) } else sScriptMgr.OnGossipSelect(_player, go, sender, action, code.empty() ? NULL : code.c_str()); + + sHookMgr->HandleGossipSelectOption(GetPlayer(), action, GetPlayer()->PlayerTalkClass->GossipOptionSender(option), GetPlayer()->PlayerTalkClass->GossipOptionAction(option), code); } void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) @@ -222,7 +229,6 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) level_max = STRONG_MAX_LEVEL; uint32 team = _player->GetTeam(); - uint32 security = GetPermissions(); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST); @@ -234,23 +240,23 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); for (HashMapHolder::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) { - if (!(security & PERM_GMT)) + if (!HasPermissions(PERM_GMT_HDEV)) { // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST if (itr->second->GetTeam() != team && !allowTwoSideWhoList) continue; // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST - if ((itr->second->GetSession()->GetPermissions() & PERM_GMT && !gmInWhoList)) + if (itr->second->GetSession()->HasPermissions(PERM_GMT) && !gmInWhoList) continue; } //do not process players which are not in world - if (!(itr->second->IsInWorld())) + if (!itr->second->IsInWorld()) continue; // check if target is globally visible for player - if (!(itr->second->IsVisibleGloballyfor (_player))) + if (!itr->second->IsVisibleGloballyfor(_player)) continue; // check if target's level is in level range @@ -303,7 +309,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos)) continue; - std::string gname = sObjectMgr.GetGuildNameById(itr->second->GetGuildId()); + std::string gname = sGuildMgr.GetGuildNameById(itr->second->GetGuildId()); std::wstring wgname; if (!Utf8toWStr(gname,wgname)) continue; @@ -380,7 +386,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->IsTaxiFlying() || - GetPermissions() & sWorld.getConfig(CONFIG_INSTANT_LOGOUT)) + HasPermissions(sWorld.getConfig(CONFIG_INSTANT_LOGOUT))) { LogoutPlayer(true); return; @@ -549,7 +555,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data) sLog.outDebug("WORLD: Received CMSG_ADD_FRIEND"); - std::string friendName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); + std::string friendName = GetHellgroundString(LANG_FRIEND_IGNORE_UNKNOWN); std::string friendNote; recv_data >> friendName; @@ -591,19 +597,19 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResultAutoPtr result, uint team = Player::TeamForRace((*result)[1].GetUInt8()); friendAcctid = (*result)[2].GetUInt32(); - if (session->GetPermissions() & PERM_GMT || sWorld.getConfig(CONFIG_ALLOW_GM_FRIEND) || !(AccountMgr::GetPermissions(friendAcctid) & PERM_GMT)) + if (session->HasPermissions(PERM_GMT_HDEV) || sWorld.getConfig(CONFIG_ALLOW_GM_FRIEND) || !AccountMgr::HasPermissions(friendAcctid, PERM_GMT)) if (friendGuid) { if (friendGuid==session->GetPlayer()->GetGUID()) friendResult = FRIEND_SELF; - else if (session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && !(session->GetPermissions() & PERM_GMT)) + else if (session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && !session->HasPermissions(PERM_GMT_HDEV)) friendResult = FRIEND_ENEMY; else if (session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) friendResult = FRIEND_ALREADY; else { Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); - if (pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyfor (session->GetPlayer())) + if (pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyfor(session->GetPlayer())) friendResult = FRIEND_ADDED_ONLINE; else friendResult = FRIEND_ADDED_OFFLINE; @@ -645,7 +651,7 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket & recv_data) sLog.outDebug("WORLD: Received CMSG_ADD_IGNORE"); - std::string IgnoreName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); + std::string IgnoreName = GetHellgroundString(LANG_FRIEND_IGNORE_UNKNOWN); recv_data >> IgnoreName; @@ -680,7 +686,7 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResultAutoPtr result, uint if (IgnoreGuid) { Player * tmp = ObjectAccessor::GetPlayer(IgnoreGuid); - if (!tmp || !(session->GetPermissions() & PERM_GMT)) // add only players + if (!tmp || !tmp->GetSession()->HasPermissions(PERM_GMT_HDEV)) // add only players { if (IgnoreGuid==session->GetPlayer()->GetGUID()) // not add yourself ignoreResult = FRIEND_IGNORE_SELF; @@ -1193,12 +1199,15 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) uint32 curtalent_maxrank = 0; for (uint32 k = 5; k > 0; --k) { - if (talentInfo->RankID[k-1] && SpellMgr::GetHighestSpellRankForPlayer(talentInfo->RankID[k-1], plr)) + if (talentInfo->RankID[k-1] && plr->HasSpell(talentInfo->RankID[k-1])) { curtalent_maxrank = k; break; } } + // now check for 1 rank talents but multiple spell ranks (like faerie fire feral) + if (!curtalent_maxrank && SpellMgr::GetHighestSpellRankForPlayer(talentInfo->RankID[0], plr)) + curtalent_maxrank = 1; // not learned talent if (!curtalent_maxrank) @@ -1289,7 +1298,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) recv_data >> Orientation; // o (3.141593 = 180 degrees) DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time/1000, mapid, PositionX, PositionY, PositionZ, Orientation); - if (GetPermissions() & PERM_ADM) + if (HasPermissions(PERM_ADM)) GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation); else SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); @@ -1304,7 +1313,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) std::string charname; recv_data >> charname; - if (!(GetPermissions() & PERM_ADM)) + if (!HasPermissions(PERM_ADM)) { SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); return; @@ -1668,3 +1677,58 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket & recv_data) sLog.outDebug("Client used \"/timetest %d\" command", mode); } +// Refer-A-Friend +void WorldSession::HandleGrantLevel(WorldPacket& recv_data) +{ + DEBUG_LOG("WORLD: CMSG_GRANT_LEVEL"); + + ObjectGuid guid; + recv_data >> guid.ReadAsPacked(); + + if (!guid.IsPlayer()) + return; + + Player * target = sObjectMgr.GetPlayer(guid); + + // cheating and other check + ReferAFriendError err = _player->GetReferFriendError(target, false); + + if (err) + { + _player->SendReferFriendError(err, target); + return; + } + + target->AccessGrantableLevel(_player->GetObjectGuid()); + + WorldPacket data(SMSG_PROPOSE_LEVEL_GRANT, 8); + data << _player->GetPackGUID(); + target->GetSession()->SendPacket(&data); +} + +void WorldSession::HandleAcceptGrantLevel(WorldPacket& recv_data) +{ + DEBUG_LOG("WORLD: CMSG_ACCEPT_LEVEL_GRANT"); + + ObjectGuid guid; + recv_data >> guid.ReadAsPacked(); + + if (!guid.IsPlayer()) + return; + + if (!_player->IsAccessGrantableLevel(guid)) + return; + + _player->AccessGrantableLevel(ObjectGuid()); + Player * grant_giver = sObjectMgr.GetPlayer(guid); + + if (!grant_giver) + return; + + if (grant_giver->GetGrantableLevels()) + grant_giver->ChangeGrantableLevels(0); + else + return; + + _player->GiveLevel(_player->getLevel() + 1); +} diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 399134ca7..c0b812ae9 100755 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MotionMaster.h" @@ -123,12 +124,12 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle) Mutate(new FollowMovementGenerator(*target,dist,angle), UNIT_ACTION_DOWAYPOINTS); } -void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath, UnitActionId actionId /*= UNIT_ACTION_ASSISTANCE*/) +void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath, bool callStop, UnitActionId actionId /*= UNIT_ACTION_ASSISTANCE*/) { if (m_owner->GetTypeId() == TYPEID_PLAYER) - Mutate(new PointMovementGenerator(id,x,y,z, generatePath), actionId); + Mutate(new PointMovementGenerator(id,x,y,z, generatePath, callStop), actionId); else - Mutate(new PointMovementGenerator(id,x,y,z, generatePath), actionId); + Mutate(new PointMovementGenerator(id,x,y,z, generatePath, callStop), actionId); } void MotionMaster::MoveSeekAssistance(float x, float y, float z) diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index d937ca640..c2b3309fc 100755 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,11 +14,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_MOTIONMASTER_H -#define MANGOS_MOTIONMASTER_H +#ifndef HELLGROUND_MOTIONMASTER_H +#define HELLGROUND_MOTIONMASTER_H #include "Common.h" #include "SharedDefines.h" @@ -60,7 +61,7 @@ class HELLGROUND_IMPORT_EXPORT MotionMaster void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f); void MoveConfused(); void MoveFleeing(Unit* enemy, uint32 timeLimit = 0); - void MovePoint(uint32 id, float x,float y,float z, bool generatePath = true, UnitActionId actionId = UNIT_ACTION_ASSISTANCE); + void MovePoint(uint32 id, float x,float y,float z, bool generatePath = true, bool callStop = true, UnitActionId actionId = UNIT_ACTION_ASSISTANCE); void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, bool generatePath = false); void MoveCharge(PathFinder path, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE); void MoveSeekAssistance(float x,float y,float z); diff --git a/src/game/MovementGenerator.cpp b/src/game/MovementGenerator.cpp index 66874340f..9df876cf6 100755 --- a/src/game/MovementGenerator.cpp +++ b/src/game/MovementGenerator.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MovementGenerator.h" diff --git a/src/game/MovementGenerator.h b/src/game/MovementGenerator.h index 91ddef06f..cd99e9c85 100755 --- a/src/game/MovementGenerator.h +++ b/src/game/MovementGenerator.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,11 +14,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_MOVEMENTGENERATOR_H -#define MANGOS_MOVEMENTGENERATOR_H +#ifndef HELLGROUND_MOVEMENTGENERATOR_H +#define HELLGROUND_MOVEMENTGENERATOR_H #include "ace/Singleton.h" diff --git a/src/game/MovementGeneratorImpl.h b/src/game/MovementGeneratorImpl.h index 40c7bb460..5479b8c0d 100755 --- a/src/game/MovementGeneratorImpl.h +++ b/src/game/MovementGeneratorImpl.h @@ -13,11 +13,11 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_MOVEMENTGENERATOR_IMPL_H -#define MANGOS_MOVEMENTGENERATOR_IMPL_H +#ifndef HELLGROUND_MOVEMENTGENERATOR_IMPL_H +#define HELLGROUND_MOVEMENTGENERATOR_IMPL_H #include "MovementGenerator.h" diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index f1773117d..e1f08b345 100755 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -114,7 +114,6 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (!GetPlayer()->GetMap()->Add(GetPlayer())) { // Teleport to previous place, if cannot be ported back TP to homebind place - GetPlayer()->SetDontMove(false); if (!GetPlayer()->TeleportTo(old_loc)) GetPlayer()->TeleportToHomebind(); @@ -150,7 +149,6 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (!_player->InBattleGround()) { // short preparations to continue flight - GetPlayer()->SetDontMove(false); FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); flight->Reset(*GetPlayer()); return; @@ -198,8 +196,6 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->m_temporaryUnsummonedPetNumber = 0; } - - GetPlayer()->SetDontMove(false); } void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) @@ -252,13 +248,17 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data) void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) { - movementInfo.UpdateTime(WorldTimer::getMSTime()); + uint32 mstime = WorldTimer::getMSTime(); + if ( m_clientTimeDelay == 0 ) + m_clientTimeDelay = mstime - movementInfo.time; + + movementInfo.UpdateTime( movementInfo.time + m_clientTimeDelay ); Unit *mover = _player->GetMover(); if (Player *plMover = mover->ToPlayer()) { - if (sWorld.getConfig(CONFIG_ENABLE_PASSIVE_ANTICHEAT) && !plMover->hasUnitState(UNIT_STAT_LOST_CONTROL | UNIT_STAT_NOT_MOVE) && !plMover->isGameMaster() && plMover->m_AC_timer == 0) + if (sWorld.getConfig(CONFIG_ENABLE_PASSIVE_ANTICHEAT) && !plMover->hasUnitState(UNIT_STAT_LOST_CONTROL | UNIT_STAT_NOT_MOVE) && !plMover->GetSession()->HasPermissions(PERM_GMT_DEV) && plMover->m_AC_timer == 0) sWorld.m_ac.execute(new ACRequest(plMover, plMover->m_movementInfo, movementInfo)); if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT)) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index ae0de7c39..6d9411aea 100755 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -39,6 +39,7 @@ #include "BattleGroundMgr.h" #include "BattleGround.h" #include "Guild.h" +#include "GuildMgr.h" void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket & recv_data) { @@ -111,7 +112,7 @@ void WorldSession::HandleTrainerListOpcode(WorldPacket & recv_data) void WorldSession::SendTrainerList(uint64 guid) { - std::string str = GetTrinityString(LANG_NPC_TAINER_HELLO); + std::string str = GetHellgroundString(LANG_NPC_TAINER_HELLO); SendTrainerList(guid, str); } @@ -822,7 +823,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket & recv_data) uint32 GuildId = _player->GetGuildId(); if (!GuildId) return; - Guild *pGuild = sObjectMgr.GetGuildById(GuildId); + Guild *pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) return; pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost); diff --git a/src/game/NPCHandler.h b/src/game/NPCHandler.h index 70b7e61aa..4c4c7464b 100755 --- a/src/game/NPCHandler.h +++ b/src/game/NPCHandler.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __NPCHANDLER_H -#define __NPCHANDLER_H +#ifndef HELLGROUND_NPCHANDLER_H +#define HELLGROUND_NPCHANDLER_H // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform #if defined(__GNUC__) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2db91fe0e..5e62bd188 100755 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +50,7 @@ #include "OutdoorPvPMgr.h" #include "movement/packet_builder.h" +#include "luaengine/HookMgr.h" uint32 GuidHigh2TypeId(uint32 guid_hi) { @@ -535,6 +536,14 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * else *data << uint32(0); // disable quest object } + // hide RAF flag if need + else if (index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_PLAYER) + { + if (!((Player*)this)->IsReferAFriendLinked(target)) + *data << (m_uint32Values[index] & ~UNIT_DYNFLAG_REFER_A_FRIEND); + else + *data << m_uint32Values[index]; + } else *data << m_uint32Values[ index ]; // other cases } @@ -1288,161 +1297,6 @@ bool WorldObject::HasInArc(const float arcangle, WorldObject const* obj) const return ((angle >= lborder) && (angle <= rborder)); } -void WorldObject::GetRandomPoint(float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const -{ - if (distance==0) - { - rand_x = x; - rand_y = y; - rand_z = z; - return; - } - - // angle to face `obj` to `this` - float angle = frand(0.0f, 2*M_PI); - // random dist in range 0 - distance; - float new_dist = frand(0.0f, distance); - - rand_x = x + new_dist * cos(angle); - rand_y = y + new_dist * sin(angle); - rand_z = z; - - Hellground::NormalizeMapCoord(rand_x); - Hellground::NormalizeMapCoord(rand_y); - UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available -} - -// this will find point in LOS before collision occur -void WorldObject::GetValidPointInAngle(Position &pos, float dist, float angle, bool meAsSourcePos, bool ignoreLOSOffset) -{ - angle += GetOrientation(); - - if (meAsSourcePos) - GetPosition(pos); - - Position dest; - dest.x = pos.x + dist * cos(angle); - dest.y = pos.y + dist * sin(angle); - - TerrainInfo const* _map = GetTerrain(); - float ground = _map->GetHeight(dest.x, dest.y, MAX_HEIGHT, true); - float floor = _map->GetHeight(dest.x, dest.y, pos.z, true); - - dest.z = 1.0f +fabs(ground - pos.z) <= fabs(floor - pos.z) ? ground : floor; - - // collision occured - bool result = false; - if (ignoreLOSOffset) - result = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.x, pos.y, pos.z +0.5f, dest.x, dest.y, dest.z +0.5f, dest.x, dest.y, dest.z, -1.5f); - else - result = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.x, pos.y, pos.z +3.0f, dest.x, dest.y, dest.z +7.0f, dest.x, dest.y, dest.z, -0.5f); - - if (result) - { - // move back a bit - dest.x -= 0.5f * cos(angle); - dest.y -= 0.5f * sin(angle); - dist = sqrt((pos.x - dest.x)*(pos.x - dest.x) + (pos.y - dest.y)*(pos.y - dest.y)); - } - - float step = dist / 10.0f; - for (int j = 0; j < 10; ++j) - { - // do not allow too big z changes - if (fabs(pos.z - dest.z) > 4.3f) - { - dest.x -= step * cos(angle); - dest.y -= step * sin(angle); - ground = _map->GetHeight(dest.x, dest.y, MAX_HEIGHT, true); - floor = _map->GetHeight(dest.x, dest.y, pos.z +2.0f, true); - dest.z = 1.0f +fabs(ground - pos.z) <= fabs(floor - pos.z) ? ground : floor; - } - // we have correct destz now - else - { - pos = dest; - break; - } - } - - Hellground::NormalizeMapCoord(pos.x); - Hellground::NormalizeMapCoord(pos.y); - ground = _map->GetHeight(pos.x, pos.y, MAX_HEIGHT, true); - floor = _map->GetHeight(pos.x, pos.y, pos.z +2.0f, true); - pos.z = 0.5f +fabs(ground - pos.z) <= fabs(floor - pos.z) ? ground : floor; -} - -void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const -{ - float new_z = GetTerrain()->GetHeight(x,y,z,true); - if (new_z > INVALID_HEIGHT) - z = new_z + 0.06f; // just to be sure that we are not a few pixel under the surface -} - -void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const -{ - switch (GetTypeId()) - { - case TYPEID_UNIT: - { - // non fly unit don't must be in air - // non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast - if (!((Creature const*)this)->CanFly()) - { - bool CanSwim = ((Creature const*)this)->CanSwim(); - float ground_z = z; - float max_z = CanSwim - ? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) - : ((ground_z = GetTerrain()->GetHeight(x, y, z, true))); - if (max_z > INVALID_HEIGHT) - { - if (z > max_z) - z = max_z; - else if (z < ground_z) - z = ground_z; - } - } - else - { - float ground_z = GetTerrain()->GetHeight(x, y, z, true); - if (z < ground_z) - z = ground_z; - } - break; - } - case TYPEID_PLAYER: - { - // for server controlled moves playr work same as creature (but it can always swim) - if (!((Player const*)this)->CanFly()) - { - float ground_z = z; - float max_z = GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)); - if (max_z > INVALID_HEIGHT) - { - if (z > max_z) - z = max_z; - else if (z < ground_z) - z = ground_z; - } - } - else - { - float ground_z = GetTerrain()->GetHeight(x, y, z, true); - if (z < ground_z) - z = ground_z; - } - break; - } - default: - { - float ground_z = GetTerrain()->GetHeight(x, y, z, true); - if (ground_z > INVALID_HEIGHT) - z = ground_z; - break; - } - } -} - bool WorldObject::IsPositionValid() const { return Hellground::IsValidMapCoord(m_positionX,m_positionY,m_positionZ,m_orientation); @@ -1513,7 +1367,7 @@ namespace Hellground : i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(language), i_targetGUID(targetGUID), i_withoutPrename(withoutPrename) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetTrinityString(i_textId, loc_idx); + char const* text = sObjectMgr.GetHellgroundString(i_textId, loc_idx); // TODO: i_object.GetName() also must be localized? i_object.BuildMonsterChat(&data, i_msgtype, text, i_language, i_object.GetNameForLocaleIdx(loc_idx), i_targetGUID, i_withoutPrename); } @@ -1590,7 +1444,7 @@ void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisp return; uint32 loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); - char const* text = sObjectMgr.GetTrinityString(textId, loc_idx); + char const* text = sObjectMgr.GetHellgroundString(textId, loc_idx); WorldPacket data(SMSG_MESSAGECHAT, 200); BuildMonsterChat(&data,IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetNameForLocaleIdx(loc_idx), receiver); @@ -1604,9 +1458,9 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, int32 iText if(GetTypeId() == TYPEID_PLAYER) { uint32 loc_idx = ((Player*)this)->GetSession()->GetSessionDbLocaleIndex(); - text = sObjectMgr.GetTrinityString(iTextEntry,loc_idx); + text = sObjectMgr.GetHellgroundString(iTextEntry,loc_idx); } else - text = sObjectMgr.GetTrinityStringForDBCLocale(iTextEntry); + text = sObjectMgr.GetHellgroundStringForDBCLocale(iTextEntry); BuildMonsterChat(data, msgtype, text, language, name, targetGuid, withoutPrename); if(GetTypeId() == TYPEID_PLAYER) data->put(5, (uint64)0); // BAD HACK @@ -1682,7 +1536,7 @@ void WorldObject::AddObjectToRemoveList() GetMap()->AddObjectToRemoveList(this); } -Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime) +Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TemporarySummonType spwtype,uint32 despwtime) { TemporarySummon* pCreature = new TemporarySummon(GetGUID()); @@ -1702,6 +1556,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->JustSummoned(pCreature); + if (Unit* summoner = ToUnit()) + sHookMgr->OnSummoned(pCreature, summoner); + if (pCreature->IsAIEnabled) { pCreature->AI()->JustRespawned(); @@ -1740,7 +1597,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry, 0, false, x, y, z, ang)) { // Remove Demonic Sacrifice auras (known pet) - Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) { if ((*itr)->GetModifier()->m_miscvalue==2228) @@ -1761,8 +1618,11 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->clearUnitState(UNIT_STAT_FOLLOW); pet->SendPetAIReaction(pet->GetGUID()); } - else if(entry == 510) + else if (entry == 510) + { pet->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + pet->ApplySpellImmune(0, IMMUNITY_DISPEL, DISPEL_POISON, true); + } return NULL; } @@ -1829,7 +1689,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy if (petType == SUMMON_PET) { // Remove Demonic Sacrifice auras (known pet) - Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& auraClassScripts = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) { if ((*itr)->GetModifier()->m_miscvalue==2228) @@ -1884,7 +1744,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, CreatureAI* (*GetAI)(Creature*)) { - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; + TemporarySummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration); if (!summon) return NULL; @@ -1901,25 +1761,15 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } -void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const +void WorldObject::GetNearPoint(float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const { - x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle); - y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle); + absAngle -= GetOrientation(); - Hellground::NormalizeMapCoord(x); - Hellground::NormalizeMapCoord(y); -} - -void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const -{ - GetNearPoint2D(x, y, distance2d+searcher_bounding_radius, absAngle); - const float init_z = z = GetPositionZ(); - - // if detection disabled, return first point - if (searcher) - searcher->UpdateAllowedPositionZ(x,y,z); // update to LOS height if available - else - UpdateGroundPositionZ(x,y,z); + Position pos; + GetValidPointInAngle(pos, distance2d+searcher_bounding_radius, absAngle, true); + x = pos.x; + y = pos.y; + z = pos.z; } void WorldObject::GetGroundPoint(float &x, float &y, float &z, float dist, float angle) @@ -1943,7 +1793,14 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/) { //updates object's visibility for nearby players Hellground::VisibleChangesNotifier notifier(*this); - Cell::VisitWorldObjects(this, notifier, GetMap()->GetVisibilityDistance() + World::GetVisibleObjectGreyDistance()); + float radius = World::GetVisibleObjectGreyDistance(); + + if ( ToCorpse() != nullptr || !IsInWorld() ) + radius = MAX_VISIBILITY_DISTANCE; + else if ( Map* map = GetMap() ) + radius += map->GetVisibilityDistance(); + + Cell::VisitWorldObjects(this, notifier, radius); } void WorldObject::AddToClientUpdateList() @@ -2057,3 +1914,156 @@ bool WorldObject::UpdateHelper::ProcessUpdate(WorldObject* obj) { return obj->IsInWorld(); } + +// + +void WorldObject::GetRandomPoint(float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const +{ + if (distance == 0) + { + rand_x = x; + rand_y = y; + rand_z = z; + return; + } + + Position pos; + pos.x = x; + pos.y = y; + pos.z = z; + + GetValidPointInAngle(pos, frand(0.0f, distance), frand(0.0f, 2*M_PI), false); + + rand_x = pos.x; + rand_y = pos.y; + rand_z = pos.z; +} + +// this will find point in LOS before collision occur +void WorldObject::GetValidPointInAngle(Position &pos, float dist, float angle, bool meAsSourcePos, bool ignoreLOSOffset, float allowHeightDifference) const +{ + angle += GetOrientation(); + + if (meAsSourcePos) + GetPosition(pos); + + pos.z += 2.0f; + + Position dest; + dest.x = pos.x + dist * cos(angle); + dest.y = pos.y + dist * sin(angle); + + TerrainInfo const* _map = GetTerrain(); + float ground = _map->GetHeight(dest.x, dest.y, MAX_HEIGHT, true); + float floor = _map->GetHeight(dest.x, dest.y, pos.z, true); + dest.z = fabs(ground - pos.z) <= fabs(floor - pos.z) ? ground : floor; + + // collision occurred + bool result = false; + if (ignoreLOSOffset) + result = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.x, pos.y, pos.z +0.5f, dest.x, dest.y, dest.z +1.0f, dest.x, dest.y, dest.z, -0.5f); + else + result = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.x, pos.y, pos.z +3.0f, dest.x, dest.y, dest.z +7.0f, dest.x, dest.y, dest.z, -0.5f); + + if (result) + { + // move back a bit + dest.x -= 0.25f * cos(angle); + dest.y -= 0.25f * sin(angle); + dist = sqrt((pos.x - dest.x)*(pos.x - dest.x) + (pos.y - dest.y)*(pos.y - dest.y)); + } + + float step = dist / 10.0f; + for (int j = 0; j < 10; ++j) + { + // do not allow too big z changes + if (fabs(pos.z - dest.z) > allowHeightDifference) + { + dest.x -= step * cos(angle); + dest.y -= step * sin(angle); + ground = _map->GetHeight(dest.x, dest.y, MAX_HEIGHT, true); + floor = _map->GetHeight(dest.x, dest.y, pos.z, true); + dest.z = fabs(ground - pos.z) <= fabs(floor - pos.z) ? ground : floor; + } + else + { + pos = dest; + break; + } + } + + Hellground::NormalizeMapCoord(pos.x); + Hellground::NormalizeMapCoord(pos.y); + UpdateAllowedPositionZ(pos.x, pos.y, pos.z); +} + +void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const +{ + float new_z = GetTerrain()->GetHeight(x,y,z,true); + if (new_z > INVALID_HEIGHT) + z = new_z + 0.06f; // just to be sure that we are not a few pixel under the surface +} + +void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const +{ + switch (GetTypeId()) + { + case TYPEID_UNIT: + { + // non fly unit don't must be in air + // non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast + if (!((Creature const*)this)->CanFly()) + { + bool CanSwim = ((Creature const*)this)->CanSwim(); + float ground_z = z; + float max_z = CanSwim + ? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) + : ((ground_z = GetTerrain()->GetHeight(x, y, z, true))); + if (max_z > INVALID_HEIGHT) + { + if (z > max_z) + z = max_z; + else if (z < ground_z) + z = ground_z; + } + } + else + { + float ground_z = GetTerrain()->GetHeight(x, y, z, true); + if (z < ground_z) + z = ground_z; + } + break; + } + case TYPEID_PLAYER: + { + // for server controlled moves playr work same as creature (but it can always swim) + if (!((Player const*)this)->CanFly()) + { + float ground_z = z; + float max_z = GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)); + if (max_z > INVALID_HEIGHT) + { + if (z > max_z) + z = max_z; + else if (z < ground_z) + z = ground_z; + } + } + else + { + float ground_z = GetTerrain()->GetHeight(x, y, z, true); + if (z < ground_z) + z = ground_z; + } + break; + } + default: + { + float ground_z = GetTerrain()->GetHeight(x, y, z, true); + if (ground_z > INVALID_HEIGHT) + z = ground_z; + break; + } + } +} diff --git a/src/game/Object.h b/src/game/Object.h index aa748c7b2..8b687da13 100755 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _OBJECT_H -#define _OBJECT_H +#ifndef HELLGROUND_OBJECT_H +#define HELLGROUND_OBJECT_H #include "Common.h" #include "ByteBuffer.h" @@ -40,10 +40,11 @@ #define MIN_MELEE_REACH 2.0f #define NOMINAL_MELEE_RANGE 5.0f #define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players +#define COMMON_ALLOW_HEIGHT_DIFF 4.3f uint32 GuidHigh2TypeId(uint32 guid_hi); -enum TempSummonType +enum TemporarySummonType { TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN = 2, // despawns after a specified time OR when the creature dies @@ -88,7 +89,7 @@ struct Position Position() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {} float x, y, z, o; - bool operator!=(Position &b) { return (x != b.x || y != b.y || z != b.z); } + bool operator!=(Position &b) { return (x != b.x || y != b.y || z != b.z/* || o != b.o*/); } }; struct WorldLocation @@ -416,25 +417,6 @@ class HELLGROUND_IMPORT_EXPORT WorldObject : public Object//, public WorldLocati void GetPosition(Position &pos) const { pos.x = m_positionX; pos.y = m_positionY; pos.z = m_positionZ; pos.o = m_orientation; } - void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; - void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const; - void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const - { - // angle calculated from current orientation - GetNearPoint(NULL,x,y,z,size,distance2d,GetOrientation() + angle); - } - void GetGroundPoint(float &x, float &y, float &z, float dist, float angle); - void GetGroundPointAroundUnit(float &x, float &y, float &z, float dist, float angle) - { - GetPosition(x, y, z); - GetGroundPoint(x, y, z, dist, angle); - } - void GetContactPoint(WorldObject const* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const - { - // angle to face `obj` to `this` using distance includes size of `obj` - GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle(obj)); - } - virtual float GetObjectBoundingRadius() const { return DEFAULT_WORLD_OBJECT_SIZE; } float GetObjectSize() const @@ -443,11 +425,23 @@ class HELLGROUND_IMPORT_EXPORT WorldObject : public Object//, public WorldLocati } bool IsPositionValid() const; +#pragma region Move all this shit to Position struct void UpdateGroundPositionZ(float x, float y, float &z) const; void UpdateAllowedPositionZ(float x, float y, float &z) const; + void GetNearPoint(float &x, float &y, float &z, float searcher_size, float distance2d = 0.0f,float absAngle = 0.0f) const; + + void GetGroundPoint(float &x, float &y, float &z, float dist, float angle); + void GetGroundPointAroundUnit(float &x, float &y, float &z, float dist, float angle) + { + GetPosition(x, y, z); + GetGroundPoint(x, y, z, dist, angle); + } + void GetRandomPoint(float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const; - void GetValidPointInAngle(Position &pos, float dist, float angle, bool meAsSourcePo, bool ignoreLOSOffset = false); + void GetValidPointInAngle(Position &pos, float dist, float angle, bool meAsSourcePo, bool ignoreLOSOffset = false, float allowHeightDifference = COMMON_ALLOW_HEIGHT_DIFF) const; + +#pragma endregion Move all this shit to Position struct void SetMapId(uint32 newMap) { m_mapId = newMap; m_map = NULL; } uint32 GetMapId() const { return m_mapId; } @@ -584,7 +578,7 @@ class HELLGROUND_IMPORT_EXPORT WorldObject : public Object//, public WorldLocati void AddToClientUpdateList(); void RemoveFromClientUpdateList(); - Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TemporarySummonType spwtype,uint32 despwtime); GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index c8a924d96..0e5cf1f38 100755 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ObjectAccessor.h" diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 03b272c71..eb8ad0b30 100755 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_OBJECTACCESSOR_H diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index 6683b32a3..6c308890a 100755 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ObjectGridLoader.h b/src/game/ObjectGridLoader.h index 38d87a54e..883cf0288 100755 --- a/src/game/ObjectGridLoader.h +++ b/src/game/ObjectGridLoader.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ObjectGuid.cpp b/src/game/ObjectGuid.cpp index e844eb204..7528d9903 100644 --- a/src/game/ObjectGuid.cpp +++ b/src/game/ObjectGuid.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ObjectGuid.h" diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index f8a9fbcf6..733711c35 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 86fd514fc..1387940ca 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -114,18 +114,9 @@ ObjectMgr::ObjectMgr() m_hiPetNumber = 1; m_ItemTextId = 1; m_mailid = 1; - m_guildId = 1; m_arenaTeamId = 1; m_auctionid = 1; - mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); - mGuildBankTabPrice[0] = 100; - mGuildBankTabPrice[1] = 250; - mGuildBankTabPrice[2] = 500; - mGuildBankTabPrice[3] = 1000; - mGuildBankTabPrice[4] = 2500; - mGuildBankTabPrice[5] = 5000; - // Only zero condition left, others will be added while loading DB tables mConditions.resize(1); } @@ -155,10 +146,6 @@ ObjectMgr::~ObjectMgr() for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr) delete (*itr); - for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr) - delete itr->second; - mGuildMap.clear(); - for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) itr->second.Clear(); @@ -175,51 +162,6 @@ Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const return NULL; } -Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const -{ - GuildMap::const_iterator itr = mGuildMap.find(GuildId); - if (itr != mGuildMap.end()) - return itr->second; - - return NULL; -} - -Guild * ObjectMgr::GetGuildByName(const std::string& guildname) const -{ - for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr) - if (itr->second->GetName() == guildname) - return itr->second; - - return NULL; -} - -std::string ObjectMgr::GetGuildNameById(const uint32 GuildId) const -{ - GuildMap::const_iterator itr = mGuildMap.find(GuildId); - if (itr != mGuildMap.end()) - return itr->second->GetName(); - - return ""; -} - -Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const -{ - for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr) - if (itr->second->GetLeader() == guid) - return itr->second; - - return NULL; -} - -void ObjectMgr::AddGuild(Guild* guild) -{ - mGuildMap[guild->GetId()] = guild; -} - -void ObjectMgr::RemoveGuild(uint32 Id) -{ - mGuildMap.erase(Id); -} ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 arenateamid) const { ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid); @@ -229,12 +171,18 @@ ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 arenateamid) const return NULL; } + ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const { + std::string search = arenateamname; + std::transform(search.begin(), search.end(), search.begin(), toupper); for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) - if (itr->second->GetName() == arenateamname) + { + std::string teamname = itr->second->GetName(); + std::transform(teamname.begin(), teamname.end(), teamname.begin(), toupper); + if (search == teamname) return itr->second; - + } return NULL; } @@ -557,6 +505,12 @@ void ObjectMgr::LoadCreatureTemplates() CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(modelid); const_cast(cInfo)->scale = ScaleEntry ? ScaleEntry->scale : 1.0f; } + + if (cInfo->xpMod < 0) + { + sLog.outLog(LOG_DB_ERR, "Table `creature_template` have creature (Entry: %u) with wrong xpMod: %u. Defaulting to 0.0f", cInfo->Entry, cInfo->equipmentId); + const_cast(cInfo)->xpMod = 0.0f; + } } } @@ -613,14 +567,14 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* sLog.outLog(LOG_DB_ERR, "Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); continue; } - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura.spell_id); - if (!AdditionalSpellInfo) + SpellEntry const *AdditionalSpellEntry = sSpellStore.LookupEntry(cAura.spell_id); + if (!AdditionalSpellEntry) { sLog.outLog(LOG_DB_ERR, "Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.spell_id,table); continue; } - if (!AdditionalSpellInfo->Effect[cAura.effect_idx] || !AdditionalSpellInfo->EffectApplyAuraName[cAura.effect_idx]) + if (!AdditionalSpellEntry->Effect[cAura.effect_idx] || !AdditionalSpellEntry->EffectApplyAuraName[cAura.effect_idx]) { sLog.outLog(LOG_DB_ERR, "Creature (%s: %u) has not aura effect %u of spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); continue; @@ -1297,41 +1251,6 @@ void ObjectMgr::LoadCreatureRespawnTimes() sLog.outString(); } -void ObjectMgr::LoadGuildAnnCooldowns() -{ - uint32 count = 0; - - QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guild_id, cooldown_end FROM guild_announce_cooldown"); - - if (!result) - { - BarGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outString(">> Loaded 0 guildann_cooldowns."); - return; - } - - BarGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 guild_id = fields[0].GetUInt32(); - uint64 respawn_time = fields[1].GetUInt64(); - - mGuildCooldownTimes[guild_id] = time_t(respawn_time); - - ++count; - } while (result->NextRow()); - - sLog.outString(">> Loaded %u guild ann cooldowns.", mGuildCooldownTimes.size()); - sLog.outString(); -} void ObjectMgr::LoadGameobjectRespawnTimes() { @@ -1777,6 +1696,10 @@ void ObjectMgr::LoadItemPrototypes() sLog.outLog(LOG_DB_ERR, "Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; } + else if (proto->Spells[j].SpellCategory) + { + sSpellCategoryStore[proto->Spells[j].SpellCategory].insert(proto->Spells[j].SpellId); + } } } } @@ -1902,7 +1825,7 @@ void ObjectMgr::LoadPetLevelInfo() if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum sLog.outLog(LOG_DB_ERR, "Wrong (> %u) level %u in `pet_levelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level); else - sLog.outDetail("Unused (> MaxPlayerLevel in Trinityd.conf) level %u in `pet_levelstats` table, ignoring.",current_level); + sLog.outDetail("Unused (> MaxPlayerLevel) level %u in `pet_levelstats` table, ignoring.",current_level); continue; } else if (current_level < 1) @@ -2278,7 +2201,7 @@ void ObjectMgr::LoadPlayerInfo() if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum sLog.outLog(LOG_DB_ERR, "Wrong (> %u) level %u in `player_classlevelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level); else - sLog.outDetail("Unused (> MaxPlayerLevel in Trinityd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level); + sLog.outDetail("Unused (> MaxPlayerLevel) level %u in `player_classlevelstats` table, ignoring.",current_level); continue; } @@ -2371,7 +2294,7 @@ void ObjectMgr::LoadPlayerInfo() if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum sLog.outLog(LOG_DB_ERR, "Wrong (> %u) level %u in `player_levelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level); else - sLog.outDetail("Unused (> MaxPlayerLevel in Trinityd.conf) level %u in `player_levelstats` table, ignoring.",current_level); + sLog.outDetail("Unused (> MaxPlayerLevel) level %u in `player_levelstats` table, ignoring.",current_level); continue; } @@ -2546,49 +2469,6 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play } } -void ObjectMgr::LoadGuilds() -{ - Guild *newguild; - uint32 count = 0; - - QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guildid FROM guild"); - - if (!result) - { - - BarGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outString(">> Loaded %u guild definitions", count); - return; - } - - BarGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - - bar.step(); - ++count; - - newguild = new Guild; - if (!newguild->LoadGuildFromDB(fields[0].GetUInt32())) - { - newguild->Disband(); - delete newguild; - continue; - } - AddGuild(newguild); - - }while (result->NextRow()); - - sLog.outString(); - sLog.outString(">> Loaded %u guild definitions", count); -} - void ObjectMgr::LoadArenaTeams() { uint32 count = 0; @@ -3221,13 +3101,13 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outLog(LOG_DB_ERR, "Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player + qinfo->RewSpellCast = 0; // no spell will be cast on player } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outLog(LOG_DB_ERR, "Quest %u has `RewSpellCast` = %u but spell %u is broken, quest can't be done.", qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player + qinfo->RewSpellCast = 0; // no spell will be cast on player } } @@ -3609,7 +3489,7 @@ void ObjectMgr::LoadInstanceTemplate() } // the reset_delay must be at least one day - temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME))); + temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getConfig(RATE_INSTANCE_RESET_TIME))); } sLog.outString(">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount); @@ -4318,7 +4198,6 @@ void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool return; } - void ObjectMgr::LoadAreaTriggerTeleports() { mAreaTriggers.clear(); // need for reload case @@ -4588,10 +4467,6 @@ void ObjectMgr::SetHighestGuids() result = RealmDataDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); if (result) m_arenaTeamId = (*result)[0].GetUInt32()+1; - - result = RealmDataDatabase.Query("SELECT MAX(guildid) FROM guild"); - if (result) - m_guildId = (*result)[0].GetUInt32()+1; } uint32 ObjectMgr::GenerateArenaTeamId() @@ -4604,16 +4479,6 @@ uint32 ObjectMgr::GenerateArenaTeamId() return m_arenaTeamId++; } -uint32 ObjectMgr::GenerateGuildId() -{ - if (m_guildId>=0xFFFFFFFE) - { - sLog.outLog(LOG_DEFAULT, "ERROR: Guild ids overflow!! Can't continue, shutting down server. "); - World::StopNow(ERROR_EXIT_CODE); - } - return m_guildId++; -} - uint32 ObjectMgr::GenerateAuctionID() { if (m_auctionid>=0xFFFFFFFE) @@ -5501,13 +5366,6 @@ void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t RealmDataDatabase.CommitTransaction(); } -void ObjectMgr::SaveGuildAnnCooldown(uint32 guild_id) -{ - time_t tmpTime = time_t(time(NULL) + sWorld.getConfig(CONFIG_GUILD_ANN_COOLDOWN)); - mGuildCooldownTimes[guild_id] = tmpTime; - RealmDataDatabase.PExecute("REPLACE INTO guild_announce_cooldown VALUES ('%u', '" UI64FMTD "')", guild_id, uint64(tmpTime)); -} - void ObjectMgr::DeleteCreatureData(uint32 guid) { // remove mapid*cellid -> guid_set map @@ -5911,7 +5769,7 @@ bool ObjectMgr::LoadHellgroundStrings(DatabaseType& db, char const* table, int32 sLog.outString(); if (min_value == MIN_HELLGROUND_STRING_ID) // error only in case internal strings - sLog.outLog(LOG_DB_ERR, ">> Loaded 0 trinity strings. DB table `%s` is empty. Cannot continue.",table); + sLog.outLog(LOG_DB_ERR, ">> Loaded 0 hellground strings. DB table `%s` is empty. Cannot continue.",table); else sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table); return false; @@ -5939,7 +5797,7 @@ bool ObjectMgr::LoadHellgroundStrings(DatabaseType& db, char const* table, int32 continue; } - TrinityStringLocale& data = mHellgroundStringLocaleMap[entry]; + HellgroundStringLocale& data = mHellgroundStringLocaleMap[entry]; if (data.Content.size() > 0) { @@ -5972,19 +5830,19 @@ bool ObjectMgr::LoadHellgroundStrings(DatabaseType& db, char const* table, int32 } while (result->NextRow()); sLog.outString(); - if (min_value == MIN_HELLGROUND_STRING_ID) // internal Trinity strings - sLog.outString(">> Loaded %u Trinity strings from table %s", count,table); + if (min_value == MIN_HELLGROUND_STRING_ID) // internal Hellground strings + sLog.outString(">> Loaded %u hellground strings from table %s", count,table); else sLog.outString(">> Loaded %u string templates from %s", count,table); return true; } -const char *ObjectMgr::GetTrinityString(int32 entry, int locale_idx) const +const char *ObjectMgr::GetHellgroundString(int32 entry, int locale_idx) const { // locale_idx==-1 -> default, locale_idx >= 0 in to idx+1 - // Content[0] always exist if exist TrinityStringLocale - if (TrinityStringLocale const *msl = GetTrinityStringLocale(entry)) + // Content[0] always exist if exist HellgroundStringLocale + if (HellgroundStringLocale const *msl = GetHellgroundStringLocale(entry)) { if (msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty()) return msl->Content[locale_idx+1].c_str(); @@ -5995,7 +5853,7 @@ const char *ObjectMgr::GetTrinityString(int32 entry, int locale_idx) const if (entry > 0) sLog.outLog(LOG_DB_ERR, "Entry %i not found in `HELLGROUND_string` table.",entry); else - sLog.outLog(LOG_DB_ERR, "Trinity string entry %i not found in DB.",entry); + sLog.outLog(LOG_DB_ERR, "hellground string entry %i not found in DB.",entry); return ""; } @@ -6156,8 +6014,13 @@ bool PlayerCondition::Meets(Player const * player) const return player->GetQuestRewardStatus(value1); case CONDITION_QUESTTAKEN: { - QuestStatus status = player->GetQuestStatus(value1); - return (status == QUEST_STATUS_INCOMPLETE); + QuestStatus status1 = player->GetQuestStatus(value1); + if (status1 == QUEST_STATUS_INCOMPLETE) + return true; + if (value2 == 0) + return false; + QuestStatus status2 = player->GetQuestStatus(value2); + return (status2 == QUEST_STATUS_INCOMPLETE); } case CONDITION_AD_COMMISSION_AURA: { @@ -6279,14 +6142,21 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val case CONDITION_QUESTREWARDED: case CONDITION_QUESTTAKEN: { - Quest const *Quest = sObjectMgr.GetQuestTemplate(value1); - if (!Quest) + Quest const *quest1 = sObjectMgr.GetQuestTemplate(value1); + if (!quest1) { sLog.outLog(LOG_DB_ERR, "Quest condition specifies non-existing quest (%u), skipped", value1); return false; } - if (value2) - sLog.outLog(LOG_DB_ERR, "Quest condition has useless data in value2 (%u)!", value2); + if (!value2) + return true; + + Quest const *quest2 = sObjectMgr.GetQuestTemplate(value1); + if (!quest2) + { + sLog.outLog(LOG_DB_ERR, "Quest condition specifies non-existing secondary quest (%u), skipped", value2); + return false; + } break; } case CONDITION_AD_COMMISSION_AURA: @@ -6426,7 +6296,7 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const // explicit name case std::wstring wname; if (!Utf8toWStr(name,wname)) - return false; + return NULL; // converting string that we try to find to lower case wstrToLower(wname); diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index c5c413252..e69c790f8 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -1,6 +1,7 @@ -/* Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity +/* + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -9,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _OBJECTMGR_H -#define _OBJECTMGR_H +#ifndef HELLGROUND_OBJECTMGR_H +#define HELLGROUND_OBJECTMGR_H #include "ace/Singleton.h" @@ -95,7 +96,6 @@ typedef UNORDERED_MAP CellObjectGuidsMap; typedef UNORDERED_MAP MapObjectGuids; typedef UNORDERED_MAP RespawnTimes; -typedef UNORDERED_MAP GuildCooldowns; // trinity string ranges #define MIN_HELLGROUND_STRING_ID 1 // 'HELLGROUND_string' @@ -104,7 +104,7 @@ typedef UNORDERED_MAP GuildCooldowns; #define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts' #define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000) -struct TrinityStringLocale +struct HellgroundStringLocale { std::vector Content; // 0 -> default, i -> i-1 locale index }; @@ -118,7 +118,7 @@ typedef UNORDERED_MAP ItemLocaleMap; typedef UNORDERED_MAP QuestLocaleMap; typedef UNORDERED_MAP NpcTextLocaleMap; typedef UNORDERED_MAP PageTextLocaleMap; -typedef UNORDERED_MAP HellgroundStringLocaleMap; +typedef UNORDERED_MAP HellgroundStringLocaleMap; typedef UNORDERED_MAP NpcOptionLocaleMap; typedef UNORDERED_MAP OpcodesCooldown; @@ -270,7 +270,6 @@ class ObjectMgr typedef std::set< Group * > GroupSet; - typedef UNORDERED_MAP GuildMap; typedef UNORDERED_MAP ArenaTeamMap; typedef UNORDERED_MAP QuestMap; typedef UNORDERED_MAP AreaTriggerMap; @@ -299,14 +298,6 @@ class ObjectMgr GroupSet::iterator GetGroupSetBegin() { return mGroupSet.begin(); } GroupSet::iterator GetGroupSetEnd() { return mGroupSet.end(); } - - Guild* GetGuildByLeader(uint64 const&guid) const; - Guild* GetGuildById(const uint32 GuildId) const; - Guild* GetGuildByName(const std::string& guildname) const; - std::string GetGuildNameById(const uint32 GuildId) const; - void AddGuild(Guild* guild); - void RemoveGuild(uint32 Id); - ArenaTeam* GetArenaTeamById(const uint32 arenateamid) const; ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const; ArenaTeam* GetArenaTeamByCaptain(uint64 const& guid) const; @@ -449,7 +440,6 @@ class ObjectMgr return NULL; } - void LoadGuilds(); void LoadArenaTeams(); void LoadGroups(); void LoadQuests(); @@ -483,7 +473,6 @@ class ObjectMgr bool CheckCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid) const; bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid); void LoadCreatureRespawnTimes(); - void LoadGuildAnnCooldowns(); void LoadUnqueuedAccountList(); bool IsUnqueuedAccount(uint64 accid); void LoadCreatureAddons(); @@ -552,7 +541,6 @@ class ObjectMgr uint32 GenerateItemTextID(); uint32 GeneratePetNumber(); uint32 GenerateArenaTeamId(); - uint32 GenerateGuildId(); uint32 CreateItemText(std::string text); std::string GetItemText(uint32 id) @@ -667,14 +655,14 @@ class ObjectMgr GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; } void DeleteGOData(uint32 guid); - TrinityStringLocale const* GetTrinityStringLocale(int32 entry) const + HellgroundStringLocale const* GetHellgroundStringLocale(int32 entry) const { HellgroundStringLocaleMap::const_iterator itr = mHellgroundStringLocaleMap.find(entry); if (itr==mHellgroundStringLocaleMap.end()) return NULL; return &itr->second; } - const char *GetTrinityString(int32 entry, int locale_idx) const; - const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } + const char *GetHellgroundString(int32 entry, int locale_idx) const; + const char *GetHellgroundStringForDBCLocale(int32 entry) const { return GetHellgroundString(entry,DBCLocaleIndex); } int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } @@ -687,9 +675,6 @@ class ObjectMgr void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t); void DeleteRespawnTimeForInstance(uint32 instance); - time_t GetGuildAnnCooldown(uint32 guild_id) { return mGuildCooldownTimes[guild_id]; } - void SaveGuildAnnCooldown(uint32 guild_id); - // grid objects void AddCreatureToGrid(uint32 guid, CreatureData const* data); void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); @@ -720,8 +705,6 @@ class ObjectMgr int GetIndexForLocale(LocaleConstant loc); LocaleConstant GetLocaleForIndex(int i); - // guild bank tabs - uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const @@ -782,7 +765,6 @@ class ObjectMgr uint32 m_mailid; uint32 m_ItemTextId; uint32 m_arenaTeamId; - uint32 m_guildId; uint32 m_hiPetNumber; // first free low guid for seelcted guid type @@ -802,41 +784,40 @@ class ObjectMgr typedef std::set TavernAreaTriggerSet; typedef std::set GameObjectForQuestSet; - GroupSet mGroupSet; - GuildMap mGuildMap; - ArenaTeamMap mArenaTeamMap; + GroupSet mGroupSet; + ArenaTeamMap mArenaTeamMap; - ItemTextMap mItemTexts; + ItemTextMap mItemTexts; - QuestAreaTriggerMap mQuestAreaTriggerMap; - TavernAreaTriggerSet mTavernAreaTriggerSet; - GossipTextMap mGossipText; - AreaTriggerMap mAreaTriggers; - AccessRequirementMap mAccessRequirements; + QuestAreaTriggerMap mQuestAreaTriggerMap; + TavernAreaTriggerSet mTavernAreaTriggerSet; + GossipTextMap mGossipText; + AreaTriggerMap mAreaTriggers; + AccessRequirementMap mAccessRequirements; - RepRewardRateMap m_RepRewardRateMap; - RepOnKillMap mRepOnKill; + RepRewardRateMap m_RepRewardRateMap; + RepOnKillMap mRepOnKill; RepSpilloverTemplateMap m_RepSpilloverTemplateMap; - WeatherZoneMap mWeatherZoneMap; + WeatherZoneMap mWeatherZoneMap; - PetCreateSpellMap mPetCreateSpell; + PetCreateSpellMap mPetCreateSpell; //character reserved names typedef std::set ReservedNamesMap; - ReservedNamesMap m_ReservedNames; + ReservedNamesMap m_ReservedNames; - std::set m_DisabledPlayerSpells; - std::set m_DisabledCreatureSpells; - std::set m_DisabledPetSpells; - std::set m_UnqueuedAccounts; + std::set m_DisabledPlayerSpells; + std::set m_DisabledCreatureSpells; + std::set m_DisabledPetSpells; + std::set m_UnqueuedAccounts; - GraveYardMap mGraveYardMap; + GraveYardMap mGraveYardMap; - GameTeleMap m_GameTeleMap; + GameTeleMap m_GameTeleMap; - typedef std::vector LocalForIndex; - LocalForIndex m_LocalForIndex; + typedef std::vector LocalForIndex; + LocalForIndex m_LocalForIndex; int GetOrNewIndexForLocale(LocaleConstant loc); int DBCLocaleIndex; @@ -879,12 +860,8 @@ class ObjectMgr RespawnTimes mCreatureRespawnTimes; RespawnTimes mGORespawnTimes; - GuildCooldowns mGuildCooldownTimes; OpcodesCooldown _opcodesCooldown; - typedef std::vector GuildBankTabPriceMap; - GuildBankTabPriceMap mGuildBankTabPrice; - // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required) typedef std::vector ConditionStore; ConditionStore mConditions; diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 18b6f6ace..d106a9531 100755 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -157,7 +157,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x07E*/ { "SMSG_PARTY_MEMBER_STATS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x07F*/ { "SMSG_PARTY_COMMAND_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x080*/ { "UMSG_UPDATE_GROUP_MEMBERS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x081*/ { "CMSG_GUILD_CREATE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildCreateOpcode }, + /*0x081*/ { "CMSG_GUILD_CREATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x082*/ { "CMSG_GUILD_INVITE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildInviteOpcode }, /*0x083*/ { "SMSG_GUILD_INVITE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x084*/ { "CMSG_GUILD_ACCEPT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildAcceptOpcode }, @@ -938,7 +938,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x38B*/ { "SMSG_REALM_SPLIT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x38C*/ { "CMSG_REALM_SPLIT", STATUS_AUTHED, PROCESS_INPLACE, &WorldSession::HandleRealmStateRequestOpcode }, /*0x38D*/ { "CMSG_MOVE_CHNG_TRANSPORT", STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleMovementOpcodes }, - /*0x38E*/ { "MSG_PARTY_ASSIGNMENT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupPromoteOpcode }, + /*0x38E*/ { "CMSG_PARTY_ASSIGNMENT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupPromoteOpcode }, /*0x38F*/ { "SMSG_OFFER_PETITION_ERROR", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x390*/ { "SMSG_TIME_SYNC_REQ", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x391*/ { "CMSG_TIME_SYNC_RESP", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleTimeSyncResp }, @@ -1052,8 +1052,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3FD*/ { "MSG_GUILD_BANK_MONEY_WITHDRAWN", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankGetMoneyAmount }, /*0x3FE*/ { "MSG_GUILD_EVENT_LOG_QUERY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildEventLogOpcode }, /*0x3FF*/ { "CMSG_MAELSTROM_RENAME_GUILD", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x400*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x401*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x400*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleGetMirrorimageData }, + /*0x401*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x402*/ { "SMSG_FORCE_DISPLAY_UPDATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x403*/ { "SMSG_SPELL_CHANCE_RESIST_PUSHBACK",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x404*/ { "CMSG_IGNORE_DIMINISHING_RETURNS_CHEAT",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, @@ -1064,12 +1064,12 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x409*/ { "MSG_QUERY_GUILD_BANK_TEXT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankTabText }, /*0x40A*/ { "CMSG_SET_GUILD_BANK_TEXT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankSetTabText }, /*0x40B*/ { "CMSG_SET_GRANTABLE_LEVELS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x40C*/ { "CMSG_GRANT_LEVEL", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x40C*/ {"CMSG_GRANT_LEVEL", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGrantLevel }, /*0x40D*/ { "CMSG_REFER_A_FRIEND", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x40E*/ { "MSG_GM_CHANGE_ARENA_RATING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x40F*/ { "CMSG_DECLINE_CHANNEL_INVITE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleChannelDeclineInvite }, /*0x410*/ { "CMSG_GROUPACTION_THROTTLED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x411*/ { "SMSG_OVERRIDE_LIGHT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x411*/ { "SMSG_override_LIGHT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x412*/ { "SMSG_TOTEM_CREATED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x413*/ { "CMSG_TOTEM_DESTROYED", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleTotemDestroy }, /*0x414*/ { "CMSG_EXPIRE_RAID_INSTANCE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, @@ -1083,8 +1083,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x41C*/ { "SMSG_SERVER_BUCK_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x41D*/ { "SMSG_SEND_UNLEARN_SPELLS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x41E*/ { "SMSG_PROPOSE_LEVEL_GRANT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x41F*/ { "CMSG_ACCEPT_LEVEL_GRANT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x420*/ { "SMSG_REFER_A_FRIEND_FAILURE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x41F*/ { "CMSG_ACCEPT_LEVEL_GRANT", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAcceptGrantLevel }, + /*0x420*/ { "SMSG_REFER_A_FRIEND_ERROR", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x421*/ { "SMSG_SPLINE_MOVE_SET_FLYING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x422*/ { "SMSG_SPLINE_MOVE_UNSET_FLYING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x423*/ { "SMSG_SUMMON_CANCEL", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h index 1064c6532..7f6aaf12d 100755 --- a/src/game/Opcodes.h +++ b/src/game/Opcodes.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef _OPCODES_H -#define _OPCODES_H +#ifndef HELLGROUND_OPCODES_H +#define HELLGROUND_OPCODES_H #include "Common.h" @@ -1077,7 +1077,7 @@ enum Opcodes MSG_GM_CHANGE_ARENA_RATING = 0x40E, CMSG_DECLINE_CHANNEL_INVITE = 0x40F, CMSG_GROUPACTION_THROTTLED = 0x410, - SMSG_OVERRIDE_LIGHT = 0x411, + SMSG_override_LIGHT = 0x411, SMSG_TOTEM_CREATED = 0x412, CMSG_TOTEM_DESTROYED = 0x413, CMSG_EXPIRE_RAID_INSTANCE = 0x414, @@ -1092,7 +1092,7 @@ enum Opcodes SMSG_SEND_UNLEARN_SPELLS = 0x41D, SMSG_PROPOSE_LEVEL_GRANT = 0x41E, CMSG_ACCEPT_LEVEL_GRANT = 0x41F, - SMSG_REFER_A_FRIEND_FAILURE = 0x420, + SMSG_REFER_A_FRIEND_ERROR = 0x420, SMSG_SPLINE_MOVE_SET_FLYING = 0x421, SMSG_SPLINE_MOVE_UNSET_FLYING = 0x422, SMSG_SUMMON_CANCEL = 0x423 diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp index 53fb30a1a..5e7ecd2eb 100755 --- a/src/game/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/OutdoorPvP.h b/src/game/OutdoorPvP.h index 3f9b43a97..c86a95d92 100755 --- a/src/game/OutdoorPvP.h +++ b/src/game/OutdoorPvP.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_H_ -#define OUTDOOR_PVP_H_ +#ifndef HELLGROUND_OUTDOOR_PVP_H +#define HELLGROUND_OUTDOOR_PVP_H #include "Util.h" #include "ZoneScript.h" diff --git a/src/game/OutdoorPvPEP.cpp b/src/game/OutdoorPvPEP.cpp index 352ebfe1e..d673700c6 100755 --- a/src/game/OutdoorPvPEP.cpp +++ b/src/game/OutdoorPvPEP.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -190,13 +191,13 @@ void OPvPCapturePointEP::ChangeState() field = EP_MAP_A[m_TowerType]; if (((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled) ((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled--; - sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(EP_LANG_LOOSE_A[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(EP_LANG_LOOSE_A[m_TowerType])); break; case OBJECTIVESTATE_HORDE: field = EP_MAP_H[m_TowerType]; if (((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled) ((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled--; - sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(EP_LANG_LOOSE_H[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(EP_LANG_LOOSE_H[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: case OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE: @@ -226,14 +227,14 @@ void OPvPCapturePointEP::ChangeState() artkit = 2; if (((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled<4) ((OutdoorPvPEP*)m_PvP)->m_AllianceTowersControlled++; - sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(EP_LANG_CAPTURE_A[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(EP_LANG_CAPTURE_A[m_TowerType])); break; case OBJECTIVESTATE_HORDE: field = EP_MAP_H[m_TowerType]; artkit = 1; if (((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled<4) ((OutdoorPvPEP*)m_PvP)->m_HordeTowersControlled++; - sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(EP_LANG_CAPTURE_H[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPEPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(EP_LANG_CAPTURE_H[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: case OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE: @@ -474,7 +475,7 @@ void OPvPCapturePointEP::SummonFlightMaster(uint32 team) { gso.Action = GOSSIP_OPTION_OUTDOORPVP; gso.GossipId = 0; - gso.OptionText.assign(sObjectMgr.GetTrinityStringForDBCLocale(EP_LANG_FLIGHT_GOSSIPS[i])); + gso.OptionText.assign(sObjectMgr.GetHellgroundStringForDBCLocale(EP_LANG_FLIGHT_GOSSIPS[i])); gso.Id = 50; gso.Icon = 0; gso.NpcFlag = 0; diff --git a/src/game/OutdoorPvPEP.h b/src/game/OutdoorPvPEP.h index f29001e55..dcc76042c 100755 --- a/src/game/OutdoorPvPEP.h +++ b/src/game/OutdoorPvPEP.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_EP_ -#define OUTDOOR_PVP_EP_ +#ifndef HELLGROUND_OUTDOOR_PVP_EP_H +#define HELLGROUND_OUTDOOR_PVP_EP_H #include "OutdoorPvPImpl.h" diff --git a/src/game/OutdoorPvPHP.cpp b/src/game/OutdoorPvPHP.cpp index 8ae6ec578..faf735cc8 100755 --- a/src/game/OutdoorPvPHP.cpp +++ b/src/game/OutdoorPvPHP.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -178,13 +179,13 @@ void OPvPCapturePointHP::ChangeState() field = HP_MAP_A[m_TowerType]; if (((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled) ((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled--; - sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(HP_LANG_LOOSE_A[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(HP_LANG_LOOSE_A[m_TowerType])); break; case OBJECTIVESTATE_HORDE: field = HP_MAP_H[m_TowerType]; if (((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled) ((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled--; - sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(HP_LANG_LOOSE_H[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(HP_LANG_LOOSE_H[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: field = HP_MAP_N[m_TowerType]; @@ -219,7 +220,7 @@ void OPvPCapturePointHP::ChangeState() artkit2 = HP_TowerArtKit_A[m_TowerType]; if (((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled<3) ((OutdoorPvPHP*)m_PvP)->m_AllianceTowersControlled++; - sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(HP_LANG_CAPTURE_A[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(HP_LANG_CAPTURE_A[m_TowerType])); break; case OBJECTIVESTATE_HORDE: field = HP_MAP_H[m_TowerType]; @@ -227,7 +228,7 @@ void OPvPCapturePointHP::ChangeState() artkit2 = HP_TowerArtKit_H[m_TowerType]; if (((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled<3) ((OutdoorPvPHP*)m_PvP)->m_HordeTowersControlled++; - sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(HP_LANG_CAPTURE_H[m_TowerType])); + sWorld.SendZoneText(OutdoorPvPHPBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(HP_LANG_CAPTURE_H[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: field = HP_MAP_N[m_TowerType]; diff --git a/src/game/OutdoorPvPHP.h b/src/game/OutdoorPvPHP.h index fdf24388c..15ee5255a 100755 --- a/src/game/OutdoorPvPHP.h +++ b/src/game/OutdoorPvPHP.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_HP_ -#define OUTDOOR_PVP_HP_ +#ifndef HELLGROUND_OUTDOOR_PVP_HP_H +#define HELLGROUND_OUTDOOR_PVP_HP_H #include "OutdoorPvPImpl.h" diff --git a/src/game/OutdoorPvPImpl.h b/src/game/OutdoorPvPImpl.h index 531732e65..8915d2a63 100644 --- a/src/game/OutdoorPvPImpl.h +++ b/src/game/OutdoorPvPImpl.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,15 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOORPVP_IMPL_H -#define OUTDOORPVP_IMPL_H + +#ifndef HELLGROUND_OUTDOORPVP_IMPL_H +#define HELLGROUND_OUTDOORPVP_IMPL_H #include "SharedDefines.h" #include "OutdoorPvP.h" diff --git a/src/game/OutdoorPvPMgr.cpp b/src/game/OutdoorPvPMgr.cpp index ca1cf9de4..9946bf828 100755 --- a/src/game/OutdoorPvPMgr.cpp +++ b/src/game/OutdoorPvPMgr.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/OutdoorPvPMgr.h b/src/game/OutdoorPvPMgr.h index d2985c701..4cb88f859 100755 --- a/src/game/OutdoorPvPMgr.h +++ b/src/game/OutdoorPvPMgr.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_MGR_H_ -#define OUTDOOR_PVP_MGR_H_ +#ifndef HELLGROUND_OUTDOOR_PVP_MGR_H +#define HELLGROUND_OUTDOOR_PVP_MGR_H #include "ace/Singleton.h" #include "OutdoorPvP.h" diff --git a/src/game/OutdoorPvPNA.cpp b/src/game/OutdoorPvPNA.cpp index 483c2e3ed..96d8427e2 100755 --- a/src/game/OutdoorPvPNA.cpp +++ b/src/game/OutdoorPvPNA.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,9 +145,9 @@ void OPvPCapturePointNA::FactionTakeOver(uint32 team) if (m_ControllingFaction) sObjectMgr.RemoveGraveYardLink(NA_HALAA_GRAVEYARD,NA_HALAA_GRAVEYARD_ZONE,m_ControllingFaction,false); if (m_ControllingFaction == ALLIANCE) - sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_NA_LOOSE_A)); + sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_NA_LOOSE_A)); else if (m_ControllingFaction == HORDE) - sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_NA_LOOSE_H)); + sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_NA_LOOSE_H)); m_ControllingFaction = team; if (m_ControllingFaction) @@ -168,7 +169,7 @@ void OPvPCapturePointNA::FactionTakeOver(uint32 team) m_PvP->SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 0); m_PvP->SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 1); m_PvP->SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive); - sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_NA_CAPTURE_A)); + sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_NA_CAPTURE_A)); } else { @@ -180,7 +181,7 @@ void OPvPCapturePointNA::FactionTakeOver(uint32 team) m_PvP->SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 1); m_PvP->SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 0); m_PvP->SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive); - sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_NA_CAPTURE_H)); + sWorld.SendZoneText(NA_HALAA_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_NA_CAPTURE_H)); } UpdateWyvernRoostWorldState(NA_ROOST_S); UpdateWyvernRoostWorldState(NA_ROOST_N); diff --git a/src/game/OutdoorPvPNA.h b/src/game/OutdoorPvPNA.h index 4bb129a43..2b9f99935 100755 --- a/src/game/OutdoorPvPNA.h +++ b/src/game/OutdoorPvPNA.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_NA_ -#define OUTDOOR_PVP_NA_ +#ifndef HELLGROUND_OUTDOOR_PVP_NA_H +#define HELLGROUND_OUTDOOR_PVP_NA_H // TODO: "sometimes" set to neutral diff --git a/src/game/OutdoorPvPSI.cpp b/src/game/OutdoorPvPSI.cpp index 5c3500ed1..cf0a48f43 100755 --- a/src/game/OutdoorPvPSI.cpp +++ b/src/game/OutdoorPvPSI.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,7 +95,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player *plr, uint32 trigger) if (m_Gathered_A >= SI_MAX_RESOURCES) { TeamApplyBuff(TEAM_ALLIANCE, SI_CENARION_FAVOR); - sWorld.SendZoneText(OutdoorPvPSIBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A)); + sWorld.SendZoneText(OutdoorPvPSIBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A)); m_LastController = ALLIANCE; m_Gathered_A = 0; m_Gathered_H = 0; @@ -119,7 +120,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player *plr, uint32 trigger) if (m_Gathered_H >= SI_MAX_RESOURCES) { TeamApplyBuff(TEAM_HORDE, SI_CENARION_FAVOR); - sWorld.SendZoneText(OutdoorPvPSIBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H)); + sWorld.SendZoneText(OutdoorPvPSIBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H)); m_LastController = HORDE; m_Gathered_A = 0; m_Gathered_H = 0; diff --git a/src/game/OutdoorPvPSI.h b/src/game/OutdoorPvPSI.h index 0142bcb0f..7951cc617 100755 --- a/src/game/OutdoorPvPSI.h +++ b/src/game/OutdoorPvPSI.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_SI_ -#define OUTDOOR_PVP_SI_ +#ifndef HELLGROUND_OUTDOOR_PVP_SI_H +#define HELLGROUND_OUTDOOR_PVP_SI_H #include "OutdoorPvPImpl.h" diff --git a/src/game/OutdoorPvPTF.cpp b/src/game/OutdoorPvPTF.cpp index 9fb0715c2..5cf832e7e 100755 --- a/src/game/OutdoorPvPTF.cpp +++ b/src/game/OutdoorPvPTF.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -251,14 +252,14 @@ void OPvPCapturePointTF::ChangeState() { if (((OutdoorPvPTF*)m_PvP)->m_AllianceTowersControlled) ((OutdoorPvPTF*)m_PvP)->m_AllianceTowersControlled--; - sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_TF_LOOSE_A)); + sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_TF_LOOSE_A)); } // if changing from controlling horde to alliance else if (m_OldState == OBJECTIVESTATE_HORDE) { if (((OutdoorPvPTF*)m_PvP)->m_HordeTowersControlled) ((OutdoorPvPTF*)m_PvP)->m_HordeTowersControlled--; - sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_TF_LOOSE_H)); + sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_TF_LOOSE_H)); } uint32 artkit = 21; @@ -270,8 +271,8 @@ void OPvPCapturePointTF::ChangeState() artkit = 2; if (((OutdoorPvPTF*)m_PvP)->m_AllianceTowersControlledm_AllianceTowersControlled++; - sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); - for (PlayerSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr) + sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); + for (PlayerSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr) (*itr)->AreaExploredOrEventHappens(TF_ALLY_QUEST); break; case OBJECTIVESTATE_HORDE: @@ -279,8 +280,8 @@ void OPvPCapturePointTF::ChangeState() artkit = 1; if (((OutdoorPvPTF*)m_PvP)->m_HordeTowersControlledm_HordeTowersControlled++; - sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); - for (PlayerSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr) + sWorld.SendZoneText(OutdoorPvPTFBuffZones[0],sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); + for (PlayerSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr) (*itr)->AreaExploredOrEventHappens(TF_HORDE_QUEST); break; case OBJECTIVESTATE_NEUTRAL: diff --git a/src/game/OutdoorPvPTF.h b/src/game/OutdoorPvPTF.h index 3a88b7fd3..0cb31f6ca 100755 --- a/src/game/OutdoorPvPTF.h +++ b/src/game/OutdoorPvPTF.h @@ -1,5 +1,24 @@ -#ifndef OUTDOOR_PVP_TF_ -#define OUTDOOR_PVP_TF_ +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_OUTDOOR_PVP_TF_H +#define HELLGROUND_OUTDOOR_PVP_TF_H #include "OutdoorPvPImpl.h" diff --git a/src/game/OutdoorPvPZM.cpp b/src/game/OutdoorPvPZM.cpp index e28716ee8..4205aa591 100755 --- a/src/game/OutdoorPvPZM.cpp +++ b/src/game/OutdoorPvPZM.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,14 +81,14 @@ void OPvPCapturePointZM_Beacon::ChangeState() { if (((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled) ((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlled--; - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(ZMBeaconLooseA[m_TowerType])); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(ZMBeaconLooseA[m_TowerType])); } // if changing from controlling horde to alliance else if (m_OldState == OBJECTIVESTATE_HORDE) { if (((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled) ((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlled--; - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(ZMBeaconLooseH[m_TowerType])); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(ZMBeaconLooseH[m_TowerType])); } switch (m_State) @@ -96,13 +97,13 @@ void OPvPCapturePointZM_Beacon::ChangeState() m_TowerState = ZM_TOWERSTATE_A; if (((OutdoorPvPZM*)m_PvP)->m_AllianceTowersControlledm_AllianceTowersControlled++; - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(ZMBeaconCaptureA[m_TowerType])); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(ZMBeaconCaptureA[m_TowerType])); break; case OBJECTIVESTATE_HORDE: m_TowerState = ZM_TOWERSTATE_H; if (((OutdoorPvPZM*)m_PvP)->m_HordeTowersControlledm_HordeTowersControlled++; - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(ZMBeaconCaptureH[m_TowerType])); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(ZMBeaconCaptureH[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL: case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: @@ -217,7 +218,7 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player *plr, uint64 guid) if (plr->HasAura(ZM_BATTLE_STANDARD_A,0) && m_GraveYardState != ZM_GRAVEYARD_A) { if (m_GraveYardState == ZM_GRAVEYARD_H) - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_H)); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_H)); m_GraveYardState = ZM_GRAVEYARD_A; DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant AddObject(0,ZM_Banner_A.entry,0,ZM_Banner_A.map,ZM_Banner_A.x,ZM_Banner_A.y,ZM_Banner_A.z,ZM_Banner_A.o,ZM_Banner_A.rot0,ZM_Banner_A.rot1,ZM_Banner_A.rot2,ZM_Banner_A.rot3); @@ -225,12 +226,12 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player *plr, uint64 guid) sObjectMgr.AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE, false); // add gy m_PvP->TeamApplyBuff(TEAM_ALLIANCE, ZM_CAPTURE_BUFF); plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A)); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A)); } else if (plr->HasAura(ZM_BATTLE_STANDARD_H,0) && m_GraveYardState != ZM_GRAVEYARD_H) { if (m_GraveYardState == ZM_GRAVEYARD_A) - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_A)); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_LOOSE_GY_A)); m_GraveYardState = ZM_GRAVEYARD_H; DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant AddObject(0,ZM_Banner_H.entry,0,ZM_Banner_H.map,ZM_Banner_H.x,ZM_Banner_H.y,ZM_Banner_H.z,ZM_Banner_H.o,ZM_Banner_H.rot0,ZM_Banner_H.rot1,ZM_Banner_H.rot2,ZM_Banner_H.rot3); @@ -238,7 +239,7 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player *plr, uint64 guid) sObjectMgr.AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE, false); // add gy m_PvP->TeamApplyBuff(TEAM_HORDE, ZM_CAPTURE_BUFF); plr->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); - sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H)); + sWorld.SendZoneText(ZM_GRAVEYARD_ZONE,sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H)); } UpdateTowerState(); } @@ -335,12 +336,12 @@ bool OPvPCapturePointZM_GraveYard::CanTalkTo(Player * plr, Creature * c, GossipO { if (itr->second == ZM_ALLIANCE_FIELD_SCOUT && plr->GetTeam() == ALLIANCE && m_BothControllingFaction == ALLIANCE && !m_FlagCarrierGUID && m_GraveYardState != ZM_GRAVEYARD_A) { - gso.OptionText.assign(sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_ALLIANCE)); + gso.OptionText.assign(sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_ALLIANCE)); return true; } else if (itr->second == ZM_HORDE_FIELD_SCOUT && plr->GetTeam() == HORDE && m_BothControllingFaction == HORDE && !m_FlagCarrierGUID && m_GraveYardState != ZM_GRAVEYARD_H) { - gso.OptionText.assign(sObjectMgr.GetTrinityStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_HORDE)); + gso.OptionText.assign(sObjectMgr.GetHellgroundStringForDBCLocale(LANG_OPVP_ZM_GOSSIP_HORDE)); return true; } } diff --git a/src/game/OutdoorPvPZM.h b/src/game/OutdoorPvPZM.h index 78f1cc8ab..f339f21e5 100755 --- a/src/game/OutdoorPvPZM.h +++ b/src/game/OutdoorPvPZM.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTDOOR_PVP_ZM_ -#define OUTDOOR_PVP_ZM_ +#ifndef HELLGROUND_OUTDOOR_PVP_ZM_H +#define HELLGROUND_OUTDOOR_PVP_ZM_H #include "OutdoorPvPImpl.h" #include "Language.h" diff --git a/src/game/PassiveAI.cpp b/src/game/PassiveAI.cpp index 71f21cc83..6565e7e94 100644 --- a/src/game/PassiveAI.cpp +++ b/src/game/PassiveAI.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/PassiveAI.h b/src/game/PassiveAI.h index f83dd6af6..05f5fda60 100644 --- a/src/game/PassiveAI.h +++ b/src/game/PassiveAI.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,5 +80,6 @@ class HELLGROUND_IMPORT_EXPORT TriggerAI : public NullCreatureAI public: explicit TriggerAI(Creature *c) : NullCreatureAI(c) {} void IsSummonedBy(Unit *summoner); + virtual void MoveInLineOfSight(Unit *) {}; }; #endif diff --git a/src/game/Path.h b/src/game/Path.h index 8afe38f75..f2abb533c 100755 --- a/src/game/Path.h +++ b/src/game/Path.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_PATH_H -#define TRINITYCORE_PATH_H +#ifndef HELLGROUND_PATH_H +#define HELLGROUND_PATH_H #include "Common.h" #include diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index af8724cd5..ba5fd8469 100755 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -172,7 +172,7 @@ bool Pet::LoadPetFromDB(Unit* owner, uint32 petentry, uint32 petnumber, bool cur if (!x || !y) { - owner->GetClosePoint(x, y, z, GetObjectSize(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + owner->GetNearPoint(x, y, z, GetObjectSize(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); ang = owner->GetOrientation(); } @@ -390,11 +390,8 @@ void Pet::SavePetToDB(PetSaveMode mode) case PET_SAVE_IN_STABLE_SLOT_2: case PET_SAVE_NOT_IN_SLOT: { - RemoveAllAuras(); - - //only alive hunter pets get auras saved, the others don't - if (!(getPetType() == HUNTER_PET && isAlive())) - m_Auras.clear(); + if (getPetType() != HUNTER_PET || !isAlive()) + RemoveAllAuras(); } default: break; @@ -633,7 +630,7 @@ void Pet::RegenerateFocus() if (curValue >= maxValue) return; - float addvalue = 24 * sWorld.getRate(RATE_POWER_FOCUS); + float addvalue = 24 * sWorld.getConfig(RATE_POWER_FOCUS); AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) @@ -659,7 +656,7 @@ void Pet::ModifyLoyalty(int32 addvalue) uint32 loyaltylevel = GetLoyaltyLevel(); if (addvalue > 0) //only gain influenced, not loss - addvalue = int32((float)addvalue * sWorld.getRate(RATE_LOYALTY)); + addvalue = int32((float)addvalue * sWorld.getConfig(RATE_LOYALTY)); if (loyaltylevel >= BEST_FRIEND && (addvalue + m_loyaltyPoints) > int32(GetMaxLoyaltyPoints(loyaltylevel))) return; @@ -1187,12 +1184,14 @@ bool Pet::InitStatsForLevel(uint32 petlevel) SetCreateHealth(100 + 120*petlevel); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); break; case 15438: //fire elemental SetCreateHealth(40*petlevel); SetCreateMana(28 + 10*petlevel); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); + ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); break; case 17503: //Woeful Healer SetCreateMana(100000); //arbitrary @@ -1461,6 +1460,7 @@ void Pet::_SaveAuras() RealmDataDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", m_charmInfo->GetPetNumber()); AuraMap const& auras = GetAuras(); + if (auras.empty()) return; @@ -1915,7 +1915,7 @@ void Pet::CastPetAura(PetAura const* aura) CastSpell(this, auraId, true); } -void Pet::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { Unit* unitOwner = GetOwner(); if (!unitOwner || unitOwner->GetTypeId() != TYPEID_PLAYER) diff --git a/src/game/Pet.h b/src/game/Pet.h index ee6ec7f8a..42f981589 100755 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_PET_H -#define TRINITYCORE_PET_H +#ifndef HELLGROUND_PET_H +#define HELLGROUND_PET_H #include "ObjectGuid.h" #include "Creature.h" @@ -163,7 +163,7 @@ class Pet : public Creature return m_autospells[pos]; } - void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); void RegenerateFocus(); void LooseHappiness(); diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 6cd169161..ce0fb949a 100755 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,7 +70,9 @@ bool PetAI::targetHasInterruptableAura(Unit *target) const bool PetAI::_needToStop() const { // This is needed for charmed creatures, as once their target was reset other effects can trigger threat - if (me->isCharmed() && me->getVictim() == me->GetCharmer()) + // also pet should stop attacking if his target of his owner is in sanctuary (applies only to player and player-pets targets) + if ((me->isCharmed() && me->getVictim() == me->GetCharmer()) || + (me->GetOwner() && me->GetOwner()->isInSanctuary() && me->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself())) return true; return targetHasInterruptableAura(me->getVictim()) || !me->canAttack(me->getVictim()); @@ -84,7 +86,7 @@ void PetAI::_stopAttack() me->GetMotionMaster()->MoveIdle(); me->CombatStop(); - me->getHostilRefManager().deleteReferences(); + me->getHostileRefManager().deleteReferences(); return; } @@ -201,10 +203,10 @@ void PetAI::AutocastPreparedSpells() me->SendCreateUpdateToPlayer((Player*)m_owner); } - me->AddCreatureSpellCooldown(spell->GetSpellInfo()->Id); + me->AddCreatureSpellCooldown(spell->GetSpellEntry()->Id); if (me->isPet()) - ((Pet*)me)->CheckLearning(spell->GetSpellInfo()->Id); + ((Pet*)me)->CheckLearning(spell->GetSpellEntry()->Id); spell->prepare(&targets); } @@ -217,11 +219,27 @@ void PetAI::AutocastPreparedSpells() } } +void PetAI::MovementInform(uint32 type, uint32 data) +{ + if (type != CHASE_MOTION_TYPE || data != 2) // target reached only + return; + + if (Unit *target = me->getVictim()) + if (target->getVictim() && target->getVictim() != me && target->isInFront(me, 7.0f, M_PI)) + { + float x, y, z; + target->GetGroundPointAroundUnit(x, y, z, target->GetObjectSize(), M_PI); + + if (abs(z - me->GetPositionZ()) <= NOMINAL_MELEE_RANGE) // height difference check + me->GetMotionMaster()->MovePoint(0, x, y, z); + } +} + void PetAI::UpdateAI(const uint32 diff) { m_owner = me->GetCharmerOrOwner(); - // quest support - Razorthorn Ravager, switch to ScriptedAI when charmed and not in combat + // quest support - Razorthorn Ravager, switch to CreatureAI when charmed and not in combat if (me->GetEntry() == 24922 && me->isCharmed() && !me->isInCombat()) me->NeedChangeAI = true; diff --git a/src/game/PetAI.h b/src/game/PetAI.h index 5cab5379f..183660809 100755 --- a/src/game/PetAI.h +++ b/src/game/PetAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ class PetAI : public CreatureAI void EnterEvadeMode(); void JustDied(Unit *who) { _stopAttack(); } + void MovementInform(uint32 type, uint32 data); void UpdateAI(const uint32); static int Permissible(const Creature *); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 37647e0ae..5208d1fb7 100755 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -502,7 +502,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) return; if (spellInfo->StartRecoveryCategory > 0) //Check if spell is affected by GCD - if (caster->GetTypeId() == TYPEID_UNIT && caster->GetCharmInfo() && caster->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) + if (caster->GetTypeId() == TYPEID_UNIT && caster->GetCharmInfo() && caster->GetCharmInfo()->GetCooldownMgr().HasGlobalCooldown(spellInfo)) { caster->SendPetCastFail(spellid, SPELL_FAILED_NOT_READY); return; diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index e1f8ad85a..0235b241e 100755 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ #include "MapManager.h" #include "GossipDef.h" #include "SocialMgr.h" +#include "GuildMgr.h" /*enum PetitionType // dbc data { @@ -148,7 +149,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) if (type == 9) { - if (sObjectMgr.GetGuildByName(name)) + if (sGuildMgr.GetGuildByName(name)) { SendGuildCommandResult(GUILD_CREATE_S, name, GUILD_NAME_EXISTS); return; @@ -400,7 +401,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) if (type == 9) { - if (sObjectMgr.GetGuildByName(newname)) + if (sGuildMgr.GetGuildByName(newname)) { SendGuildCommandResult(GUILD_CREATE_S, newname, GUILD_NAME_EXISTS); return; @@ -781,7 +782,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) if (type == 9) { - if (sObjectMgr.GetGuildByName(name)) + if (sGuildMgr.GetGuildByName(name)) { SendGuildCommandResult(GUILD_CREATE_S, name, GUILD_NAME_EXISTS); return; @@ -816,7 +817,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) } // register guild and add guildmaster - sObjectMgr.AddGuild(guild); + sGuildMgr.AddGuild(guild); // add members for (uint8 i = 0; i < signs; ++i) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 1eecaf29f..d846b9686 100755 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -65,11 +65,13 @@ #include "GameEvent.h" #include "GridMap.h" #include "WorldEventProcessor.h" - +#include "AccountMgr.h" #include "PlayerAI.h" +#include "GuildMgr.h" #include #include +#include "luaengine/HookMgr.h" #define ZONE_UPDATE_INTERVAL 1000 @@ -262,7 +264,10 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi) UpdateMask Player::updateVisualBits; -Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera(this) +Player::Player (WorldSession *session): Unit(), + m_reputationMgr(this), + m_camera(this), + m_cheatState(PlayerCheatState::None) { m_transport = 0; @@ -270,6 +275,11 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( m_AC_timer = 0; m_AC_NoFall_count = 0; + for (uint8 i = 0 ; i< ANTICHEAT_CHECK_MAX;i++) + { + m_AC_cumulative_count[i] = 0; + m_AC_cumulative_timer[i] = time(NULL); + } m_speakTime = 0; m_speakCount = 0; @@ -289,7 +299,7 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( m_ExtraFlags = 0; // players always accept - if (!(GetSession()->GetPermissions() & PERM_GMT)) + if (!GetSession()->HasPermissions(PERM_GMT_HDEV)) SetAcceptWhispers(true); m_curSelection = 0; @@ -334,8 +344,6 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( m_atLoginFlags = AT_LOGIN_NONE; - m_dontMove = false; - pTrader = 0; ClearTrade(); @@ -353,6 +361,7 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( m_DailyQuestChanged = false; m_lastDailyQuestTime = 0; + m_DailyArenasWon = 0; for (uint8 i=0; i< MAX_TIMERS; i++) m_MirrorTimer[i] = DISABLED_MIRROR_TIMER; @@ -433,6 +442,8 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( m_auraBaseMod[i][PCT_MOD] = 1.0f; } + m_spellPenetrationItemMod = 0; + // Honor System m_lastHonorUpdateTime = time(NULL); @@ -455,6 +466,13 @@ Player::Player (WorldSession *session): Unit(), m_reputationMgr(this), m_camera( _preventSave = false; _preventUpdate = false; + + positionStatus.Reset(0); + + m_GrantableLevelsCount = 0; + m_outdoors = GetTerrain()->IsOutdoors(GetPositionX(), GetPositionY(), GetPositionZ()); + + StartTeleportTimer(); } Player::~Player () @@ -492,14 +510,18 @@ Player::~Player () // clean up player-instance binds, may unload some instance saves for (uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - itr->second.save->RemovePlayer(this); + { + InstanceSave* save = itr->second.save; + if (save != nullptr && save->HasPlayer(GetGUID())) + save->RemovePlayer(GetGUID()); + } + } delete m_declinedname; - sWorldEventProcessor.DestroyEvents(GetGUID()); - - DeleteCharmAI(); + DeleteCharmAI(); } void Player::CleanupsBeforeDelete() @@ -522,6 +544,7 @@ void Player::CleanupsBeforeDelete() // just to be sure that we are removed from all outdoorpvp before we are deleted sOutdoorPvPMgr.HandlePlayerLeave(this); + sSocialMgr.canWhisperToGMList.remove(GetGUID()); } ClearLFG(); @@ -611,6 +634,14 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); SetUInt32Value(PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24))); + + LoadAccountLinkedState(); + + if (GetAccountLinkedState() != STATE_NOT_LINKED) + SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RAF); // rest state = refer-a-friend + else + SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_NORMAL); // rest state = normal + SetUInt32Value(PLAYER_BYTES_2, (facialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24))); SetByteValue(PLAYER_BYTES_3, 0, gender); @@ -626,7 +657,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); // set starting level - if (GetSession()->GetPermissions() & PERM_GMT) + if (GetSession()->HasPermissions(PERM_GMT_HDEV)) SetUInt32Value (UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_GM_LEVEL)); else SetUInt32Value (UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL)); @@ -916,18 +947,21 @@ int32 Player::getMaxTimer(MirrorTimerType timer) return MINUTE*IN_MILISECONDS; case BREATH_TIMER: { - if (!isAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetPermissions() & sWorld.getConfig(CONFIG_DISABLE_BREATHING)) + if (!isAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->HasPermissions(sWorld.getConfig(CONFIG_DISABLE_BREATHING))) return DISABLED_MIRROR_TIMER; + int32 UnderWaterTime = MINUTE*IN_MILISECONDS; AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); for (AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifierValue()) / 100.0f); + return UnderWaterTime; } case FIRE_TIMER: { if (!isAlive()) return DISABLED_MIRROR_TIMER; + return IN_MILISECONDS; } default: @@ -1170,6 +1204,8 @@ void Player::Update(uint32 update_diff, uint32 p_time) m_AC_timer -= update_diff; } + positionStatus.Update(update_diff); + // undelivered mail if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL)) { @@ -1301,7 +1337,7 @@ void Player::Update(uint32 update_diff, uint32 p_time) int time_inn = time(NULL)-GetTimeInnEnter(); if (time_inn >= 10) //freeze update { - float bubble = 0.125*sWorld.getRate(RATE_REST_INGAME); + float bubble = 0.125*sWorld.getConfig(RATE_REST_INGAME); //speed collect rest bonus (section/in hour) SetRestBonus(GetRestBonus()+ time_inn*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); UpdateInnerTime(time(NULL)); @@ -1365,6 +1401,9 @@ void Player::Update(uint32 update_diff, uint32 p_time) { if (update_diff >= m_nextSave) { + // used by eluna + sHookMgr->OnSave(this); + // m_nextSave reseted in SaveToDB call SaveToDB(); sLog.outDetail("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); @@ -1424,6 +1463,8 @@ void Player::Update(uint32 update_diff, uint32 p_time) // group update SendUpdateToOutOfRangeGroupMembers(); + UpdateConsecutiveKills(); + _preventUpdate = false; updateMutex.release(); } @@ -1453,7 +1494,7 @@ void Player::setDeathState(DeathState s) RemoveAurasDueToSpell(m_ShapeShiftFormSpellId); //FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD) - RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); + RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true, true); // remove uncontrolled pets RemoveMiniPet(); @@ -1540,7 +1581,8 @@ bool Player::BuildEnumData(QueryResultAutoPtr result, WorldPacket * p_data) *p_data << uint32(char_flags); // character flags - *p_data << uint8(1); // unknown + // First login + *p_data << uint8(1);//uint8(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0); // Pets info { @@ -1645,7 +1687,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return false; } - if (!(GetSession()->GetPermissions() & PERM_ADM) && !sWorld.IsAllowedMap(mapid)) + if (!GetSession()->HasPermissions(PERM_ADM) && !sWorld.IsAllowedMap(mapid)) { sLog.outLog(LOG_DEFAULT, "ERROR: Player %s tried to enter a forbidden map", GetName()); return false; @@ -1831,6 +1873,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati SetSelection(0); CombatStop(); ResetContestedPvP(); + StartTeleportTimer(); // remove player from battleground on far teleport (when changing maps) if (BattleGround const* bg = GetBattleGround()) @@ -1860,7 +1903,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // stop spellcasting // not attempt interrupt teleportation spell at caster teleport if (!(options & TELE_TO_SPELL)) - if (IsNonMeleeSpellCasted(true)) + if (IsNonMeleeSpellCast(true)) InterruptNonMeleeSpells(true); //remove auras before removing from map... @@ -1935,11 +1978,6 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati SetFallInformation(0, final_z); // if the player is saved before worldportack (at logout for example) // this will be used instead of the current location in SaveToDB - - // move packet sent by client always after far teleport - // SetPosition(final_x, final_y, final_z, final_o, true); - SetDontMove(true); - // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet } else return false; @@ -1948,11 +1986,6 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return true; } -void Player::SetDontMove(bool dontMove) -{ - m_dontMove = dontMove; -} - void Player::AddToWorld() { ///- Do not add/remove the player from the object storage @@ -2019,7 +2052,7 @@ void Player::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacke addRage *= 2.0f; } - addRage *= sWorld.getRate(RATE_POWER_RAGE_INCOME); + addRage *= sWorld.getConfig(RATE_POWER_RAGE_INCOME); ModifyPower(POWER_RAGE, uint32(addRage*10)); } @@ -2058,7 +2091,7 @@ void Player::Regenerate(Powers power) case POWER_MANA: { bool recentCast = IsUnderLastManaUseEffect(); - float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); + float ManaIncreaseRate = sWorld.getConfig(RATE_POWER_MANA); if (recentCast) { // Trinity Updates Mana in intervals of 2s, which is correct @@ -2071,7 +2104,7 @@ void Player::Regenerate(Powers power) } break; case POWER_RAGE: // Regenerate rage { - float RageDecreaseRate = sWorld.getRate(RATE_POWER_RAGE_LOSS); + float RageDecreaseRate = sWorld.getConfig(RATE_POWER_RAGE_LOSS); int mult = 30; const AuraList &auras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN); @@ -2126,7 +2159,7 @@ void Player::RegenerateHealth() if (curValue >= maxValue) return; - float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); + float HealthIncreaseRate = sWorld.getConfig(RATE_HEALTH); float addvalue = 0.0f; @@ -2276,7 +2309,7 @@ void Player::SetInWater(bool apply) // remove auras that need water/land RemoveAurasWithInterruptFlags(apply ? AURA_INTERRUPT_FLAG_NOT_ABOVEWATER : AURA_INTERRUPT_FLAG_NOT_UNDERWATER); - getHostilRefManager().updateThreatTables(); + getHostileRefManager().updateThreatTables(); } void Player::SetGameMaster(bool on) @@ -2306,7 +2339,7 @@ void Player::SetGameMaster(bool on) UpdateArea(m_areaUpdateId); } - getHostilRefManager().setOnlineOfflineState(!on); + getHostileRefManager().setOnlineOfflineState(!on); UpdateVisibilityAndView(); } @@ -2390,18 +2423,18 @@ void Player::RemoveFromGroup(Group* group, uint64 guid) } } -void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) +void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool ReferAFriend) { WorldPacket data(SMSG_LOG_XPGAIN, 21); data << uint64(victim ? victim->GetGUID() : 0); // guid - data << uint32(GivenXP+RestXP); // given experience + data << uint32(GivenXP + BonusXP); // given experience data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type if (victim) { data << uint32(GivenXP); // experience without rested bonus data << float(1); // 1 - none 0 - 100% group bonus output } - data << uint8(0); // new 2.4.0 + data << (ReferAFriend ? 1 : 0); // Refer-A-Friend State SendPacketToSelf(&data); } @@ -2415,6 +2448,9 @@ void Player::GiveXP(uint32 xp, Unit* victim) uint32 level = getLevel(); + // used by eluna + sHookMgr->OnGiveXP(this, xp, victim); + // XP to money conversion processed in Player::RewardQuest if (level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) return; @@ -2424,21 +2460,62 @@ void Player::GiveXP(uint32 xp, Unit* victim) for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin();i != ModXPPctAuras.end(); ++i) xp = uint32(xp*(1.0f + (*i)->GetModifierValue() / 100.0f)); + if (uint32 goodEntry = sWorld.getConfig(CONFIG_XP_RATE_MODIFY_ITEM_ENTRY)) + { + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + { + Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == goodEntry) + { + xp = uint32(xp*(1.0f + sWorld.getConfig(CONFIG_XP_RATE_MODIFY_ITEM_PCT) / 100.0f)); + break; + } + } + } + // XP resting bonus for kill - uint32 rested_bonus_xp = victim ? GetXPRestBonus(xp) : 0; + uint32 bonus_xp = 0; + bool ReferAFriend = false; + if (CheckRAFConditions()) + { + // RAF bonus exp don't decrease rest exp + bool ReferAFriend = true; + bonus_xp = xp * (sWorld.getConfig(CONFIG_FLOAT_RATE_RAF_XP) - 1); + } + else + // XP resting bonus for kill + bonus_xp = victim ? GetXPRestBonus(xp) : 0; - SendLogXPGain(xp,victim,rested_bonus_xp); + SendLogXPGain(xp, victim, bonus_xp, ReferAFriend); uint32 curXP = GetUInt32Value(PLAYER_XP); uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); - uint32 newXP = curXP + xp + rested_bonus_xp; + uint32 newXP = curXP + xp + bonus_xp; while (newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) { newXP -= nextLvlXP; if (level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + // set health/po{ GiveLevel(level + 1); + level = getLevel(); + // Refer-A-Friend + if (GetAccountLinkedState() == STATE_REFERRAL || GetAccountLinkedState() == STATE_DUAL) + { + if (level < sWorld.getConfig(CONFIG_UINT32_RAF_MAXGRANTLEVEL)) + { + if (sWorld.getConfig(CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL) < 1.0f) + { + if (level%uint8(1.0f / sWorld.getConfig(CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL)) == 0) + ChangeGrantableLevels(1); + } + else + ChangeGrantableLevels(uint8(sWorld.getConfig(CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL))); + } + } + } level = getLevel(); nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); @@ -2481,6 +2558,8 @@ void Player::GiveLevel(uint32 level) //update level, max level of skills if (getLevel()!= level) m_Played_time[1] = 0; // Level Played Time reset + + uint32 oldLevel = getLevel(); SetLevel(level); UpdateSkillsForLevel (); @@ -2512,6 +2591,17 @@ void Player::GiveLevel(uint32 level) Pet* pet = GetPet(); if (pet && pet->getPetType()==SUMMON_PET) pet->GivePetLevel(level); + + // used by eluna + sHookMgr->OnLevelChanged(this, oldLevel); +} + +void Player::SetFreeTalentPoints(uint32 points) +{ + // used by eluna + sHookMgr->OnFreeTalentPointsChanged(this, points); + + SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } void Player::UpdateFreeTalentPoints(bool resetIfNeed) @@ -2534,7 +2624,7 @@ void Player::UpdateFreeTalentPoints(bool resetIfNeed) // if used more that have then reset if (m_usedTalentCount > talentPointsForLevel) { - if (resetIfNeed && !(GetSession()->GetPermissions() & PERM_ADM)) + if (resetIfNeed && !GetSession()->HasPermissions(PERM_ADM)) resetTalents(true); else SetFreeTalentPoints(0); @@ -3205,6 +3295,14 @@ void Player::removeSpell(uint32 spell_id, bool disabled) for (uint32 i=reqMap.count(spell_id);i>0;i--,itr2++) removeSpell(itr2->second,disabled); + if (CanDualWield()) + { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + + if (spellInfo && spellInfo->HasEffect(SPELL_EFFECT_DUAL_WIELD)) + SetCanDualWield(false); + } + // removing WorldPacket data(SMSG_REMOVED_SPELL, 4); data << uint16(spell_id); @@ -3334,7 +3432,7 @@ void Player::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */) WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); data << uint32(spell_id); data << uint64(GetGUID()); - SendPacketToSelf(&data); + SendPacketToSelf(&data); } } @@ -3467,6 +3565,9 @@ uint32 Player::resetTalentsCost() const bool Player::resetTalents(bool no_cost) { + // used by eluna + sHookMgr->OnTalentsReset(this, no_cost); + // not need after this call if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { @@ -3535,6 +3636,14 @@ bool Player::resetTalents(bool no_cost) if (spellInfo->Effect[i] == SPELL_EFFECT_TRIGGER_SPELL && HasAura(spellInfo->EffectTriggerSpell[i])) RemoveAurasDueToSpell(spellInfo->EffectTriggerSpell[i]); } + // for dual wield + if (itrFirstId == 30798) + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) // off hand here needed + { + uint16 dest; + if (CanEquipItem(EQUIPMENT_SLOT_OFFHAND, dest, item, false, false) != EQUIP_ERR_OK) + _ApplyItemMods(item,EQUIPMENT_SLOT_OFFHAND, false); + } removeSpell(itr->first,!SpellMgr::IsPassiveSpell(itr->first)); itr = GetSpellMap().begin(); continue; @@ -3893,7 +4002,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC uint32 guildId = GetGuildIdFromDB(playerguid); if (guildId != 0) { - Guild* guild = sObjectMgr.GetGuildById(guildId); + Guild* guild = sGuildMgr.GetGuildById(guildId); if (guild) guild->DelMember(guid); } @@ -4144,6 +4253,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) m_deathTimer = 0; + // refer-a-friend flag - maybe wrong and hacky + if (GetAccountLinkedState() != STATE_NOT_LINKED) + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND); + // set health/powers (0- will be set in caller) if (restore_percent>0.0f) { @@ -4166,6 +4279,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) UpdateVisibilityAndView(); + // used by eluna + sHookMgr->OnResurrect(this); + if (!applySickness) return; @@ -4477,7 +4593,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g return TotalCost; } - Guild *pGuild = sObjectMgr.GetGuildById(GetGuildId()); + Guild *pGuild = sGuildMgr.GetGuildById(GetGuildId()); if (!pGuild) return TotalCost; @@ -4550,6 +4666,7 @@ void Player::TeleportToNearestGraveyard() case BATTLEGROUND_AB: case BATTLEGROUND_EY: case BATTLEGROUND_AV: + case BATTLEGROUND_WS: ClosestGrave = bg->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetTeam()); break; default: @@ -4632,7 +4749,10 @@ void Player::UpdateLocalChannels(uint32 newZone) if (!ch) continue; - if ((ch->flags & 4) == 4) // global channel without zone name in pattern + if (ch->flags & CHANNEL_DBC_FLAG_GLOBAL)//Global channels + continue; + + if ((ch->flags & CHANNEL_DBC_FLAG_TRADE) && sWorld.getConfig(CONFIG_GLOBAL_TRADE_CHANNEL))//trade channel continue; // new channel @@ -4656,7 +4776,7 @@ void Player::UpdateLocalChannels(uint32 newZone) void Player::LeaveLFGChannel() { - if (!sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) || GetSession()->GetPermissions() & PERM_GMT) + if (!sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) || GetSession()->HasPermissions(PERM_GMT)) return; // don't kick if on lfg or lfm @@ -5091,7 +5211,7 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) if ((!max) || (!value) || (value >= max)) return false; - if (value*512 < max*urand(0,512)) + //if (value*512 < max*urand(0,512)) { uint32 new_value = value+step; if (new_value > max) @@ -5232,10 +5352,6 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) void Player::UpdateWeaponSkill (WeaponAttackType attType) { - // no skill gain in pvp - Unit *pVictim = getVictim(); - if (pVictim && pVictim->isCharmedOwnedByPlayerOrPlayer()) - return; if (IsInFeralForm(true)) return; // always maximized SKILL_FERAL_COMBAT in fact @@ -5269,41 +5385,38 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType) UpdateAllCritPercentages(); } -void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence) +void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence) //if defense than pVictim == attacker { - uint32 plevel = getLevel(); // if defense than pVictim == attacker - //uint32 greylevel = Hellground::XP::GetGrayLevel(plevel); + if (pVictim->isCharmedOwnedByPlayerOrPlayer()) // no skill ups in pvp + return; + + uint32 plevel = getLevel(); uint32 moblevel = pVictim->getLevelForTarget(this); - //if (moblevel < greylevel) - // return; if (moblevel > plevel + 5) moblevel = plevel + 5; - uint32 lvldif = 0; + float lvldif = 1.5f; if (moblevel >= plevel) { lvldif = moblevel - plevel; if (lvldif < 3) lvldif = 3; } - else - { - lvldif = plevel - moblevel; - if (lvldif > 3) - lvldif = 3; - } uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType)); if (skilldif <= 0) return; - float chance = float(3 * lvldif * skilldif) / plevel; + float chance = (float(3 * lvldif * skilldif) / plevel) * 0.5f; if (!defence) - chance *= 0.1f * GetStat(STAT_INTELLECT); + chance += 0.02f * GetStat(STAT_INTELLECT); chance = chance < 1.0f ? 1.0f : chance; //minimum chance to increase skill is 1% + if (!defence) + SendCombatStats("Weapon skill update [ skill: %u, chance %f, skilldif: %u ]", pVictim, attType, chance, skilldif); + if (roll_chance_f(chance)) { if (defence) @@ -5311,8 +5424,6 @@ void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool de else UpdateWeaponSkill(attType); } - else - return; } void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) @@ -5337,8 +5448,6 @@ void Player::UpdateSkillsForLevel() uint16 maxconfskill = sWorld.GetConfigMaxSkillValue(); uint32 maxSkill = GetMaxSkillValueForLevel(); - bool alwaysMaxSkill = sWorld.getConfig(CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL); - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) { @@ -5356,15 +5465,8 @@ void Player::UpdateSkillsForLevel() uint32 val = SKILL_VALUE(data); /// update only level dependent max skill values - if (max!=1) - { - /// miximize skill always - if (alwaysMaxSkill) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(maxSkill,maxSkill)); - /// update max skill value if current max skill not maximized - else if (max != maxconfskill) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,maxSkill)); - } + if (max!=1 && max!=maxconfskill) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,maxSkill)); } } @@ -5661,20 +5763,26 @@ void Player::removeActionButton(uint8 button) bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) { + bool groupUpdate = (GetGroup() && (teleport || abs(GetPositionX() - x) > 1.0f || abs(GetPositionY() - y) > 1.0f)); if (!Unit::SetPosition(x, y, z, orientation, teleport)) return false; - // group update - if (GetGroup()) - SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); + if(GetTrader() && !IsWithinDistInMap(GetTrader(), 5.0f)) + GetSession()->SendCancelTrade(); + + if (!positionStatus.Passed()) + return true; + + positionStatus.Reset(100); // code block for underwater state update // Unit::SetPosition() checks for validity and updates our coordinates // so we re-fetch them instead of using "raw" coordinates from function params UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ()); - if(GetTrader() && !IsWithinDistInMap(GetTrader(), 5)) - GetSession()->SendCancelTrade(); + // group update + if (groupUpdate) + SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); CheckAreaExploreAndOutdoor(); return true; @@ -5720,6 +5828,15 @@ void Player::CheckAreaExploreAndOutdoor() bool isOutdoor; uint16 areaFlag = GetTerrain()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ(), &isOutdoor); + if (m_outdoors != isOutdoor) + { + UpdateSpeed(MOVE_RUN, true); + UpdateSpeed(MOVE_SWIM, true); + UpdateSpeed(MOVE_FLIGHT, true); + + m_outdoors = isOutdoor; + } + if (!isOutdoor && sWorld.getConfig(CONFIG_VMAP_INDOOR_CHECK) && !isGameMaster()) RemoveAurasWithAttribute(SPELL_ATTR_OUTDOORS_ONLY, true); @@ -5844,10 +5961,10 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 switch (source) { case REPUTATION_SOURCE_KILL: - rate = sWorld.getRate(RATE_REPUTATION_LOWLEVEL_KILL); + rate = sWorld.getConfig(RATE_REPUTATION_LOWLEVEL_KILL); break; case REPUTATION_SOURCE_QUEST: - rate = sWorld.getRate(RATE_REPUTATION_LOWLEVEL_QUEST); + rate = sWorld.getConfig(RATE_REPUTATION_LOWLEVEL_QUEST); break; } @@ -5884,7 +6001,7 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 percent *= repRate; } - return int32(sWorld.getRate(RATE_REPUTATION_GAIN)*rep*percent/100.0f); + return int32(0.01f + sWorld.getConfig(RATE_REPUTATION_GAIN)*rep*percent/100.0f); } //Calculates how many reputation points player gains in victim's enemy factions @@ -6048,6 +6165,50 @@ void Player::UpdateHonorFields() m_lastHonorUpdateTime = now; } +void Player::UpdateConsecutiveKills() +{ + if (sWorld.getConfig(CONFIG_ENABLE_GANKING_PENALTY) == false) + return; + + Map* map = GetMap(); + if (map == nullptr || map->IsBattleGroundOrArena()) + return; + + uint64 currentTime = sWorld.GetGameTime(); + uint64 expireTime = sWorld.getConfig(CONFIG_GANKING_PENALTY_EXPIRE); + + for (auto itr = m_consecutiveKills.begin(); itr != m_consecutiveKills.end();) + { + uint32 diff = currentTime - itr->second.second; + if (diff > expireTime) + m_consecutiveKills.erase(itr++); + else + ++itr; + } +} + +void Player::AddConsecutiveKill(uint64 victimGuid) +{ + if (sWorld.getConfig(CONFIG_ENABLE_GANKING_PENALTY) == false) + return; + + auto itr = m_consecutiveKills.find(victimGuid); + if (itr == m_consecutiveKills.end()) + return void(m_consecutiveKills.insert(std::make_pair(victimGuid, std::make_pair(1, sWorld.GetGameTime())))); + + ++itr->second.first; + itr->second.second = sWorld.GetGameTime(); +} + +uint32 Player::GetConsecutiveKillsCount(uint64 victimGuid) +{ + auto itr = m_consecutiveKills.find(victimGuid); + if (itr != m_consecutiveKills.end()) + return itr->second.first; + + return 0; +} + ///Calculate the amount of honor gained based on the victim ///and the size of the group for which the honor is divided ///An exact honor value can also be given (overriding the calcs) @@ -6082,7 +6243,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt if (honor <= 0) { - if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT) || uVictim->WorthHonor || uVictim->HasAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) return false; victim_guid = uVictim->GetGUID(); @@ -6094,6 +6255,10 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt if (GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm()) return false; + uint32 killsCount = GetConsecutiveKillsCount(victim_guid); + + AddConsecutiveKill(victim_guid); + float f = 1; //need for total kills (?? need more info) uint32 k_grey = 0; uint32 k_level = getLevel(); @@ -6145,6 +6310,25 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt honor = ((f * diff_level * (190 + v_rank*10))/6); honor *= ((float)k_level) / 70.0f; //factor of dependence on levels of the killer + Map* map = GetMap(); + if (map && !map->IsBattleGroundOrArena()) + { + if (sWorld.getConfig(CONFIG_ENABLE_GANKING_PENALTY)) + honor *= 1.0f - killsCount * sWorld.getConfig(CONFIG_GANKING_PENALTY_PER_KILL); + + if (killsCount >= sWorld.getConfig(CONFIG_GANKING_KILLS_ALERT)) + { + std::stringstream stream; + stream << "Possible HK / Honor farming exploit (killer: " << GetName() << ", victim: " << pVictim->GetName() << ") kills count: " << killsCount; + + sWorld.SendGMText(LANG_POSSIBLE_CHEAT, stream.str().c_str(), GetName(), GetName()); + sLog.outLog(LOG_CHEAT, "%s", stream.str().c_str()); + } + + if (honor <= 0.0f) + return false; + } + // count the number of playerkills in one day ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true); // and those in a lifetime @@ -6164,7 +6348,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt if (uVictim != NULL) { - honor *= sWorld.getRate(RATE_HONOR); + honor *= sWorld.getConfig(RATE_HONOR); if (groupsize > 1) honor /= groupsize; @@ -6191,7 +6375,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt if (sWorld.getConfig(CONFIG_PVP_TOKEN_ENABLE) && pvptoken) { - if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT) || uVictim->WorthHonor || uVictim->HasAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) return true; if (uVictim->GetTypeId() == TYPEID_PLAYER) @@ -6388,6 +6572,9 @@ void Player::UpdateZone(uint32 newZone) m_zoneUpdateId = newZone; m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; + // used by eluna + sHookMgr->OnUpdateZone(this, newZone, newZone); + // zone changed, so area changed as well, update it UpdateArea(GetAreaId()); @@ -6549,6 +6736,9 @@ void Player::DuelComplete(DuelCompleteType type) if (!duel) return; + // used by eluna + sHookMgr->OnDuelEnd(duel->opponent, this, type); + WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << (uint8)((type != DUEL_INTERUPTED) ? 1 : 0); SendPacketToSelf(&data); @@ -6642,16 +6832,20 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) if (slot >= INVENTORY_SLOT_BAG_END || !item) return; - // not apply/remove mods for broken item (_ApplyItemMods is used before setting durability to 0 when item - // loss durability so there is no need to check for 'apply' (prevent bug abuse by stats stacking)) - if (item->IsBroken()) - return; - ItemPrototype const *proto = item->GetProto(); if (!proto) return; + // not apply/remove mods for broken item (_ApplyItemMods is used before setting durability to 0 when item + // loss durability so there is no need to check for 'apply' (prevent bug abuse by stats stacking)) + if (item->IsBroken()) + { + if (proto->Socket[0].Color) + CorrectMetaGemEnchants(slot, apply); + return; + } + sLog.outDetail("applying mods for item %u ",item->GetGUIDLow()); uint32 attacktype = Player::GetAttackBySlot(slot); @@ -6802,6 +6996,10 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply) case ITEM_MOD_EXPERTISE_RATING: ApplyRatingMod(CR_EXPERTISE, int32(val), apply); break; + case ITEM_MOD_SPELL_PENETRATION: + ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, int32(-val), apply); + m_spellPenetrationItemMod += apply ? int32(val) : int32(-val); + break; } } @@ -7073,7 +7271,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 default: slot = EQUIPMENT_SLOT_END; break; } - if (attType == RANGED_ATTACK && slot == EQUIPMENT_SLOT_MAINHAND) + if (attType == RANGED_ATTACK && i == EQUIPMENT_SLOT_MAINHAND) { // exception for Righteous Weapon Coating, enchant on main hand should also proc from ranged attacks if(uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT))) @@ -7082,7 +7280,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 if(pEnchant && pEnchant->ID == 3266) // Blessed Weapon Coating { ((Player*)this)->CastItemCombatSpell(target, attType, procVictim, procEx, item, proto, spellInfo); - break; + continue; } } } @@ -7597,7 +7795,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) loot->FillLoot(1, LootTemplates_Creature, this, true); // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY)); + bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel)/5.76f, 2.5f) * sWorld.getConfig(RATE_DROP_MONEY)); } if (bones->lootRecipient != this) @@ -7635,7 +7833,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) // Generate extra money for pick pocket loot const uint32 a = urand(0, creature->getLevel()/2); const uint32 b = urand(0, getLevel()/2); - loot->gold = uint32(10 * (a + b) * sWorld.getRate(RATE_DROP_MONEY)); + loot->gold = uint32(10 * (a + b) * sWorld.getConfig(RATE_DROP_MONEY)); } } else @@ -8726,6 +8924,16 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const return NULL; } +uint32 Player::GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const +{ + const Item* pItem = GetItemByPos(bag, slot); + + if (!pItem) + return 0; + + return pItem->GetProto()->DisplayInfoID; +} + Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) const { uint16 slot; @@ -9923,13 +10131,13 @@ uint8 Player::CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, boo if (isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err - if (IsNonMeleeSpellCasted(false)) + if (IsNonMeleeSpellCast(false)) { // exclude spells with transform item effect if (!m_currentSpells[CURRENT_GENERIC_SPELL] || - (m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo()->Effect[0] != SPELL_EFFECT_SUMMON_CHANGE_ITEM && - m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo()->Effect[1] != SPELL_EFFECT_SUMMON_CHANGE_ITEM && - m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo()->Effect[2] != SPELL_EFFECT_SUMMON_CHANGE_ITEM)) + (m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry()->Effect[0] != SPELL_EFFECT_SUMMON_CHANGE_ITEM && + m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry()->Effect[1] != SPELL_EFFECT_SUMMON_CHANGE_ITEM && + m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry()->Effect[2] != SPELL_EFFECT_SUMMON_CHANGE_ITEM)) return EQUIP_ERR_CANT_DO_RIGHT_NOW; } @@ -10621,7 +10829,7 @@ Item* Player::EquipItem(uint16 pos, Item *pItem, bool update) m_weaponChangeTimer = spellProto->StartRecoveryTime; if (getClass() != CLASS_ROGUE) - GetGlobalCooldownMgr().AddGlobalCooldown(spellProto, m_weaponChangeTimer); + GetCooldownMgr().AddGlobalCooldown(spellProto, m_weaponChangeTimer); WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4); data << uint64(GetGUID()); @@ -10645,6 +10853,9 @@ Item* Player::EquipItem(uint16 pos, Item *pItem, bool update) UpdateExpertise(BASE_ATTACK); else if (slot == EQUIPMENT_SLOT_OFFHAND) UpdateExpertise(OFF_ATTACK); + + // used by eluna + sHookMgr->OnEquip(this, pItem2, bag, slot); } else { @@ -10669,6 +10880,9 @@ Item* Player::EquipItem(uint16 pos, Item *pItem, bool update) ApplyEquipCooldown(pItem2); + // used by eluna + sHookMgr->OnEquip(this, pItem2, bag, slot); + return pItem2; } @@ -11991,15 +12205,16 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) return; - if (!item->IsBroken()) - for (int s=0; s<3; s++) + if (!item->IsBroken() || !apply) { - uint32 enchant_display_type = pEnchant->type[s]; - uint32 enchant_amount = pEnchant->amount[s]; - uint32 enchant_spell_id = pEnchant->spellid[s]; - - switch (enchant_display_type) + for (int s=0; s<3; s++) { + uint32 enchant_display_type = pEnchant->type[s]; + uint32 enchant_amount = pEnchant->amount[s]; + uint32 enchant_spell_id = pEnchant->spellid[s]; + + switch (enchant_display_type) + { case ITEM_ENCHANTMENT_TYPE_NONE: break; case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: @@ -12017,8 +12232,47 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a if (enchant_spell_id) { SpellEntry const *temp = sSpellStore.LookupEntry(enchant_spell_id); - if (!temp) - break; + if (!temp) // unsupported enchant support + { + switch(enchant_spell_id) + { + case 22841: //arcanum of rapidity + { + enchant_spell_id=13928; + break; + } + case 22847: //arcanum of protection + { + enchant_spell_id=13669; + break; + } + case 22755: //elemental sharpening stone + { + enchant_spell_id=7598; + break; + } + case 22843: //arcanum of focus + { + enchant_spell_id=9398; + break; + } + case 28162: //savage guard + { + enchant_spell_id=14630; + break; + } + case 28164: //ice guard + { + enchant_spell_id=14550; + break; + } + case 28166: //shadow guard + { + enchant_spell_id=14673; + break; + } + } + } if (apply) { @@ -12070,26 +12324,26 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_STAT: - { - if (!enchant_amount) { - ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if (item_rand_suffix) + if (!enchant_amount) { - for (int k=0; k<3; k++) + ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand_suffix) { - if (item_rand_suffix->enchant_id[k] == enchant_id) + for (int k=0; k<3; k++) { - enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000); - break; + if (item_rand_suffix->enchant_id[k] == enchant_id) + { + enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000); + break; + } } } } - } - sLog.outDebug("Adding %u to stat nb %u",enchant_amount,enchant_spell_id); - switch (enchant_spell_id) - { + sLog.outDebug("Adding %u to stat nb %u",enchant_amount,enchant_spell_id); + switch (enchant_spell_id) + { case ITEM_MOD_AGILITY: sLog.outDebug("+ %u AGILITY",enchant_amount); HandleStatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); @@ -12155,32 +12409,32 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a ((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); sLog.outDebug("+ %u SPELL_CRIT", enchant_amount); break; -// Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used -// in Enchantments -// case ITEM_MOD_HIT_TAKEN_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_SPELL_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); -// break; + // Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used + // in Enchantments + // case ITEM_MOD_HIT_TAKEN_MELEE_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_HIT_TAKEN_RANGED_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); + // break; + // case ITEM_MOD_HIT_TAKEN_SPELL_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_HASTE_MELEE_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_HASTE_RANGED_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); + // break; case ITEM_MOD_HASTE_SPELL_RATING: ((Player*)this)->ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); break; @@ -12196,17 +12450,17 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a //((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); sLog.outDebug("+ %u CRITICAL", enchant_amount); break; -// Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment -// case ITEM_MOD_HIT_TAKEN_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; + // Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment + // case ITEM_MOD_HIT_TAKEN_RATING: + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); + // ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_RATING: + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + // ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + // break; case ITEM_MOD_RESILIENCE_RATING: ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); @@ -12225,32 +12479,33 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a break; default: break; + } + break; } - break; - } case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon - { - if (getClass() == CLASS_SHAMAN) { - float addValue = 0.0f; - if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) - { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); - HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); - } - else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) + if (getClass() == CLASS_SHAMAN) { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); - HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); + float addValue = 0.0f; + if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) + { + addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); + } + else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) + { + addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); + } } + break; } - break; - } default: sLog.outLog(LOG_DEFAULT, "ERROR: Unknown item enchantment display type: %d",enchant_display_type); break; - } /*switch (enchant_display_type)*/ - } /*for*/ + } /*switch (enchant_display_type)*/ + } /*for*/ + } // visualize enchantment at player and equipped items if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT) @@ -12847,7 +13102,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, if (getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) GiveXP(XP , NULL); else - ModifyMoney(int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY))); + ModifyMoney(int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getConfig(RATE_DROP_MONEY))); // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative ModifyMoney(pQuest->GetRewOrReqMoney()); @@ -12903,6 +13158,21 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver, CastSpell(this, pQuest->GetRewSpell(), true); } +void Player::ModifyMoney(int32 d) +{ + // used by eluna + sHookMgr->OnMoneyChanged(this, d); + + if (d < 0) + SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); + else + SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); + + // "At Gold Limit" + if (GetMoney() >= MAX_MONEY_AMOUNT) + SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); +} + void Player::RewardDNDQuest(uint32 questId) { const Quest * tmpQ = sObjectMgr.GetQuestTemplate(questId); @@ -12917,7 +13187,7 @@ void Player::RewardDNDQuest(uint32 questId) if (getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) GiveXP(XP , NULL); else - ModifyMoney(int32(tmpQ->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY))); + ModifyMoney(int32(tmpQ->GetRewMoneyMaxLevel() * sWorld.getConfig(RATE_DROP_MONEY))); RewardReputation(tmpQ); @@ -13207,6 +13477,9 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) if (qInfo->GetExclusiveGroup() <= 0) return true; + if (qInfo->IsDaily() && !sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return true; + ObjectMgr::ExclusiveQuestGroups::iterator iter = sObjectMgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator end = sObjectMgr.mExclusiveQuestGroups.upper_bound(qInfo->GetExclusiveGroup()); @@ -13304,7 +13577,7 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) return true; bool have_slot = false; - for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY); ++quest_daily_idx) { uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); if (qInfo->GetQuestId()==id) @@ -13659,7 +13932,7 @@ void Player::KilledMonster(uint32 entry, uint64 guid) } } -void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id) +void Player::CastCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id) { bool isCreature = IS_CREATURE_GUID(guid); @@ -13887,7 +14160,7 @@ bool Player::HasQuestForItem(uint32 itemid) const q_status.m_itemcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqItemCount[idx] * qinfo->ReqSourceCount[j]) return true; - // total count of casted ReqCreatureOrGOs and SourceItems is less than ReqCreatureOrGOCount + // total count of cast ReqCreatureOrGOs and SourceItems is less than ReqCreatureOrGOCount if (qinfo->ReqCreatureOrGOId[idx] != 0) { if (q_status.m_creatureOrGOcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqCreatureOrGOCount[idx] * qinfo->ReqSourceCount[j]) @@ -13896,7 +14169,7 @@ bool Player::HasQuestForItem(uint32 itemid) const // spell with SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT (with script) case else if (qinfo->ReqSpell[idx] != 0) { - // not casted and need more reagents/item for use. + // not cast and need more reagents/item for use. if (!q_status.m_explored && GetItemCount(itemid,true) < qinfo->ReqSourceCount[j]) return true; } @@ -13935,7 +14208,7 @@ void Player::SendQuestReward(Quest const *pQuest, uint32 XP, Object * questGiver else { data << uint32(0); - data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY))); + data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getConfig(RATE_DROP_MONEY))); } data << uint32(0); // new 2.3.0, HonorPoints? data << uint32(pQuest->GetRewItemsCount()); // max is 5 @@ -13948,6 +14221,14 @@ void Player::SendQuestReward(Quest const *pQuest, uint32 XP, Object * questGiver data << uint32(0) << uint32(0); } SendPacketToSelf(&data); + + // used by eluna + if (questGiver->GetTypeId() == TYPEID_UNIT) + sHookMgr->OnQuestComplete(this, (Creature*)questGiver, pQuest); + + // used by eluna + if (questGiver->GetTypeId() == TYPEID_GAMEOBJECT) + sHookMgr->OnQuestComplete(this, (GameObject*)questGiver, pQuest); } void Player::SendQuestFailed(uint32 quest_id) @@ -14224,7 +14505,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) // player should be able to load/delete character only with correct account! if (dbAccountId != GetSession()->GetAccountId()) { - sLog.outLog(LOG_DEFAULT, "ERROR: Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId); + sLog.outLog(LOG_DEFAULT, "ERROR: Player (GUID: %u) loading from wrong account (is: %u, should be: %u)", guid, GetSession()->GetAccountId(), dbAccountId); return false; } @@ -14233,7 +14514,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) m_name = fields[3].GetCppString(); // check name limitations - if (!ObjectMgr::IsValidName(m_name) || !(GetSession()->GetPermissions() & PERM_GMT) && sObjectMgr.IsReservedName(m_name)) + if (!ObjectMgr::IsValidName(m_name) || !GetSession()->HasPermissions(PERM_GMT) && sObjectMgr.IsReservedName(m_name)) { RealmDataDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid); return false; @@ -14421,6 +14702,11 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) SetMapId(GetBattleGroundEntryPointMap()); Relocate(GetBattleGroundEntryPointX(),GetBattleGroundEntryPointY(),GetBattleGroundEntryPointZ(),GetBattleGroundEntryPointO()); //RemoveArenaAuras(true); + if (!isAlive())// resurrect on bg exit + { + ResurrectPlayer(1.0f); + SpawnCorpseBones(); + } } } } @@ -14594,8 +14880,8 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) if ((int32)fields[23].GetUInt32() > 0) { float bubble = fields[24].GetUInt32() > 0 - ? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) - : bubble0*sWorld.getRate(RATE_REST_OFFLINE_IN_WILDERNESS); + ? bubble1*sWorld.getConfig(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) + : bubble0*sWorld.getConfig(RATE_REST_OFFLINE_IN_WILDERNESS); SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); } @@ -14615,6 +14901,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) m_taxi.LoadTaxiMask(fields[18].GetString()); // must be before InitTaxiNodesForLevel uint32 extraflags = fields[32].GetUInt32(); + SetCanWhisperToGM(extraflags & PLAYER_EXTRA_CAN_WHISP_TO_GM); m_stableSlots = fields[33].GetUInt32(); if (m_stableSlots > 2) @@ -14696,11 +14983,26 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff); + m_GrantableLevelsCount = fields[43].GetUInt32(); + + // refer-a-friend flag - maybe wrong and hacky + LoadAccountLinkedState(); + if (GetAccountLinkedState() != STATE_NOT_LINKED) + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND); + + // set grant flag + if (m_GrantableLevelsCount > 0) + SetByteValue(PLAYER_FIELD_BYTES, 1, 0x01); + // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) m_deathState = DEAD; _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS)); + + //Ugly hacky one - give summon friend spell to players created before RAF implement + if (GetAccountLinkedState() != STATE_NOT_LINKED) + learnSpell(45927); // after spell load InitTalentForLevel(); @@ -14798,7 +15100,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) outDebugValues(); // GM state - if (GetSession()->GetPermissions() & PERM_GMT) + if (GetSession()->HasPermissions(PERM_GMT_HDEV)) { switch (sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) { @@ -14810,7 +15112,21 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) SetGameMaster(true); break; } + + switch (sWorld.getConfig(CONFIG_GM_WISPERING_TO)) + { + default: + case 0: break; // disable + case 1: SetAcceptWhispers(true); break; // enable + case 2: // save state + if (extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) + SetAcceptWhispers(true); + break; + } + } + if (GetSession()->HasPermissions(PERM_GMT)) + { switch (sWorld.getConfig(CONFIG_GM_VISIBLE_STATE)) { default: @@ -14832,17 +15148,6 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) SetGMChat(true); break; } - - switch (sWorld.getConfig(CONFIG_GM_WISPERING_TO)) - { - default: - case 0: break; // disable - case 1: SetAcceptWhispers(true); break; // enable - case 2: // save state - if (extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) - SetAcceptWhispers(true); - break; - } } _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); @@ -14863,6 +15168,19 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder) if (!HasAura(28006) && (GetQuestRewardStatus(9121) || GetQuestRewardStatus(9122) || GetQuestRewardStatus(9123))) CastSpell(this, 28006, true); + uint8 changeRaceTo = fields[44].GetUInt8(); + if (changeRaceTo) + { + ChangeRace(changeRaceTo); + RealmDataDatabase.PExecute("UPDATE characters SET changeRaceTo = '0' WHERE guid ='%u'", GetGUIDLow()); + } + + result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYARENA); + if(result) + { + m_DailyArenasWon = result->Fetch()->GetUInt16(); + } + return true; } @@ -15191,7 +15509,7 @@ void Player::_LoadInventory(QueryResultAutoPtr result, uint32 timediff) // send by mail problematic items while (!problematicItems.empty()) { - std::string subject = GetSession()->GetTrinityString(LANG_NOT_EQUIPPED_ITEM); + std::string subject = GetSession()->GetHellgroundString(LANG_NOT_EQUIPPED_ITEM); // fill mail MailDraft draft(subject); @@ -15415,7 +15733,7 @@ void Player::_LoadQuestStatus(QueryResultAutoPtr result) void Player::_LoadDailyQuestStatus(QueryResultAutoPtr result) { - for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY); ++quest_daily_idx) SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); //QueryResultAutoPtr result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); @@ -15426,7 +15744,7 @@ void Player::_LoadDailyQuestStatus(QueryResultAutoPtr result) do { - if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query + if (quest_daily_idx >= sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY)) // max amount with exist data in query { sLog.outLog(LOG_DEFAULT, "ERROR: Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); break; @@ -15591,15 +15909,20 @@ void Player::UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, { if (itr != m_boundInstances[difficulty].end()) { - if (!unload) RealmDataDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), itr->second.save->GetInstanceId()); - itr->second.save->RemovePlayer(this); // save can become invalid + if (!unload) + RealmDataDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), itr->second.save->GetInstanceId()); + + InstanceSave* save = itr->second.save; + if (save != nullptr) + save->RemovePlayer(GetGUID()); + m_boundInstances[difficulty].erase(itr++); } } InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, bool load) { - if (save) + if (save != nullptr) { InstancePlayerBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; if (bind.save) @@ -15613,19 +15936,26 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, b if (bind.save != save) { - if (bind.save) bind.save->RemovePlayer(this); - save->AddPlayer(this); + if (bind.save != nullptr) + bind.save->RemovePlayer(GetGUID()); + + save->AddPlayer(GetGUID()); } if (permanent) save->SetCanReset(false); bind.save = save; bind.perm = permanent; - if (!load) sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + if (!load) + sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + + // used by eluna + sHookMgr->OnBindToInstance(this, DungeonDifficulties(save->GetDifficulty()), save->GetMapId(), permanent); + return &bind; } else - return NULL; + return nullptr; } void Player::SendRaidInfo() @@ -15788,7 +16118,7 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report if (report) { if (missingItem) - GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), ar->levelMin, ObjectMgr::GetItemPrototype(missingItem)->Name1); + GetSession()->SendAreaTriggerMessage(GetSession()->GetHellgroundString(LANG_LEVEL_MINREQUIRED_AND_ITEM), ar->levelMin, ObjectMgr::GetItemPrototype(missingItem)->Name1); else if (missingKey) SendTransferAborted(target_map, TRANSFER_ABORT_DIFFICULTY2); else if (missingHeroicQuest) @@ -15796,7 +16126,7 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report else if (missingQuest) GetSession()->SendAreaTriggerMessage(ar->questFailedText.c_str()); else if (LevelMin) - GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED), LevelMin); + GetSession()->SendAreaTriggerMessage(GetSession()->GetHellgroundString(LANG_LEVEL_MINREQUIRED), LevelMin); else if (missingAura) GetSession()->SendAreaTriggerMessage(ar->missingAuraText.c_str()); } @@ -15910,8 +16240,8 @@ void Player::SaveToDB() stmt.PExecute(GetGUIDLow()); static SqlStatementID updateStats; - stmt = RealmDataDatabase.CreateStatement(updateStats, "INSERT INTO character_stats_ro VALUES (?, ?, ?)"); - stmt.PExecute(GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY), GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); + stmt = RealmDataDatabase.CreateStatement(updateStats, "INSERT INTO character_stats_ro VALUES (?, ?, ?, ?)"); + stmt.PExecute(GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY), GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS),m_DailyArenasWon); static SqlStatementID deleteCharacter; static SqlStatementID insertCharacter; @@ -15924,13 +16254,13 @@ void Player::SaveToDB() "taximask, online, cinematic, " "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, " - "death_expire_time, taxi_path, arena_pending_points, latency, title) " + "death_expire_time, taxi_path, arena_pending_points, latency, title, grantableLevels) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " "?, ?, ?, ?, ?, ?, ?, ?, " "?, ?, ?, " "?, ?, ?, ?, ?, ?, ?, " "?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?)"); + "?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(GetSession()->GetAccountId()); @@ -16009,6 +16339,7 @@ void Player::SaveToDB() stmt.addUInt32(0); stmt.addUInt32(GetSession()->GetLatency()); stmt.addUInt64(GetUInt64Value(PLAYER__FIELD_KNOWN_TITLES)); + stmt.addUInt32(m_GrantableLevelsCount); stmt.Execute(); if (m_mailsUpdated) //save mails only when needed @@ -16276,7 +16607,7 @@ void Player::_SaveInventory() if (!GetSession()->IsAccountFlagged(ACC_SPECIAL_LOG)) GetSession()->AddAccountFlag(ACC_SPECIAL_LOG); - stmt = AccountsDatabase.CreateStatement(insertBan, "INSERT INTO account_punishment VALUES (?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '[CONSOLE]', 'With love: cheater -.-', 1)"); + stmt = AccountsDatabase.CreateStatement(insertBan, "INSERT INTO account_punishment VALUES (?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '[CONSOLE]', 'Cheat CON-01', 1)"); stmt.PExecute(GetSession()->GetAccountId(), uint32(PUNISHMENT_BAN)); AccountsDatabase.CommitTransaction(); @@ -16292,7 +16623,7 @@ void Player::_SaveInventory() AccountsDatabase.BeginTransaction(); - SqlStatement stmt = AccountsDatabase.CreateStatement(insertBan, "INSERT INTO account_panishment VALUES (?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '[CONSOLE]', 'With love: cheater -.-', 1)"); + SqlStatement stmt = AccountsDatabase.CreateStatement(insertBan, "INSERT INTO account_punishment VALUES (?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '[CONSOLE]', 'Cheat CON-02', 1)"); stmt.PExecute(GetSession()->GetAccountId(), uint32(PUNISHMENT_BAN)); if (!GetSession()->IsAccountFlagged(ACC_SPECIAL_LOG)) @@ -16498,7 +16829,7 @@ void Player::_SaveDailyQuestStatus() SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteDailies, "DELETE FROM character_queststatus_daily WHERE guid = ?"); stmt.PExecute(GetGUIDLow()); - for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY); ++quest_daily_idx) { if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) { @@ -16618,7 +16949,7 @@ void Player::outDebugValues() const void Player::UpdateSpeakTime() { // ignore chat spam protection for GMs in any mode - if (GetSession()->GetPermissions() & PERM_GMT) + if (GetSession()->HasPermissions(PERM_GMT)) return; time_t current = time (NULL); @@ -16653,6 +16984,11 @@ bool Player::CanSpeak() const return GetSession()->m_muteTime <= time (NULL); } +bool Player::IsTrollmuted() const +{ + return GetSession()->m_trollmuteTime >= time (NULL); +} + /*********************************************************/ /*** LOW LEVEL FUNCTIONS:Notifiers ***/ /*********************************************************/ @@ -16811,7 +17147,7 @@ void Player::ResetInstances(uint8 method) { InstanceSave *p = itr->second.save; const MapEntry *entry = sMapStore.LookupEntry(itr->first); - if (!entry || !p->CanReset()) + if (!entry || !p->CanReset() || p == nullptr) { ++itr; continue; @@ -16830,11 +17166,13 @@ void Player::ResetInstances(uint8 method) // if the map is loaded, reset it Map *map = sMapMgr.FindMap(p->GetMapId(), p->GetInstanceId()); if (map && map->IsDungeon()) + { if (!((InstanceMap*)map)->Reset(method)) { ++itr; continue; } + } // since this is a solo instance there should not be any players inside if (method == INSTANCE_RESET_ALL || method == INSTANCE_RESET_CHANGE_DIFFICULTY) @@ -16844,7 +17182,7 @@ void Player::ResetInstances(uint8 method) m_boundInstances[dif].erase(itr++); // the following should remove the instance save from the manager and delete it as well - p->RemovePlayer(this); + p->RemovePlayer(GetGUID()); } } @@ -16902,8 +17240,11 @@ void Player::UpdatePvPFlag(time_t currTime) void Player::SetFFAPvP(bool state) { - if (state) + if (state){ SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); + if (sWorld.getConfig(CONFIG_FFA_DISALLOWGROUP) && !GetMap()->IsBattleGroundOrArena()) + RemoveFromGroup(); + } else RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); } @@ -16913,6 +17254,9 @@ void Player::UpdateDuelFlag(time_t currTime) if (!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) return; + // used by eluna + sHookMgr->OnDuelStart(this, duel->opponent); + SetUInt32Value(PLAYER_DUEL_TEAM, 1); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 2); @@ -16922,11 +17266,15 @@ void Player::UpdateDuelFlag(time_t currTime) duel->opponent->duel->startTime = currTime; } -void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) +void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent, bool isDying) { if (!pet) pet = GetPet(); + // Remove auras off unsummoned pet when owner dies + if (isDying && !pet && GetTemporaryUnsummonedPetNumber()) + RealmDataDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", GetTemporaryUnsummonedPetNumber()); + if (returnreagent && (pet || m_temporaryUnsummonedPetNumber) && !InBattleGround()) { //returning of reagents only for players, so best done here @@ -16991,6 +17339,10 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) } } + // Clear auras when owner dies + if (isDying) + pet->RemoveAllAuras(); + pet->SavePetToDB(mode); pet->AddObjectToRemoveList(); @@ -17144,7 +17496,7 @@ void Player::Whisper(const std::string& text, uint32 language,uint64 receiver) if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster()) { SetAcceptWhispers(true); - ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON); + ChatHandler(this).PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING,ChatHandler(this).GetHellgroundString(LANG_ON)); } // announce to player that player he is whispering to is afk @@ -17404,7 +17756,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply) data << uint8(eff); data << uint8(mod->op); data << int32(val); - SendPacketToSelf(&data); + SendPacketToSelf(&data); } } @@ -17531,11 +17883,15 @@ void Player::SetRestBonus (float rest_bonus_new) else m_rest_bonus = rest_bonus_new; - // update data for client - if (m_rest_bonus>10) - SetByteValue(PLAYER_BYTES_2, 3, 0x01); // Set Reststate = Rested - else if (m_rest_bonus<=1) - SetByteValue(PLAYER_BYTES_2, 3, 0x02); // Set Reststate = Normal + if (GetAccountLinkedState() != STATE_NOT_LINKED) + SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RAF); // Set Reststate = Refer-A-Friend + else + { + if (m_rest_bonus > 10) + SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RESTED); // Set Reststate = Rested + else if (m_rest_bonus <= 1) + SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_NORMAL); // Set Reststate = Normal + } //RestTickUpdate SetUInt32Value(PLAYER_REST_STATE_EXPERIENCE, uint32(m_rest_bonus)); @@ -17616,8 +17972,8 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, uint32 mount_i // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi if (GetSession()->isLogingOut() || (!m_currentSpells[CURRENT_GENERIC_SPELL] || - m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo()->Effect[0] != SPELL_EFFECT_SEND_TAXI)&& - IsNonMeleeSpellCasted(false) || + m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry()->Effect[0] != SPELL_EFFECT_SEND_TAXI)&& + IsNonMeleeSpellCast(false) || isInCombat()) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); @@ -17739,10 +18095,10 @@ void Player::CleanupAfterTaxiFlight() m_taxi.ClearTaxiDestinations(); // not destinations, clear source node Unmount(); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - getHostilRefManager().setOnlineOfflineState(true); + getHostileRefManager().setOnlineOfflineState(true); } -void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { // last check 2.0.10 WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); @@ -18124,30 +18480,16 @@ void Player::UpdatePvP(bool state, bool ovrride) ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP, false); } - if (!state || ovrride) - { - SetPvP(state); - if (Pet* pet = GetPet()) - pet->SetPvP(state); - if (Unit* charmed = GetCharm()) - charmed->SetPvP(state); + SetPvP(state); + if (Pet* pet = GetPet()) + pet->SetPvP(state); + if (Unit* charmed = GetCharm()) + charmed->SetPvP(state); + if (!state || ovrride) pvpInfo.endTimer = 0; - } - else - { - if (pvpInfo.endTimer != 0) - pvpInfo.endTimer = time(NULL); - else - { - SetPvP(state); - - if (Pet* pet = GetPet()) - pet->SetPvP(state); - if (Unit* charmed = GetCharm()) - charmed->SetPvP(state); - } - } + else if (!pvpInfo.inHostileArea && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP)) + pvpInfo.endTimer = time(NULL); } void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) @@ -18341,9 +18683,6 @@ void Player::LeaveBattleground(bool teleportToEntryPoint) { if (BattleGround *bg = GetBattleGround()) { - if (InArena() && isInCombat() && bg->GetStatus() == STATUS_IN_PROGRESS) - return; - if (bg->isArena() && !isGameMaster()) { SetVisibility(VISIBILITY_ON); @@ -18559,7 +18898,7 @@ bool Player::IsVisibleInGridForPlayer(Player const * pl) const if (corpse) { // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level - if (corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO))) + if (corpse->IsWithinDistInMap(this,(20+25)*sWorld.getConfig(RATE_CREATURE_AGGRO))) return true; } } @@ -18582,7 +18921,7 @@ bool Player::IsVisibleGloballyfor (Player* u) const return true; // GMs are visible for higher gms (or players are visible for gms) - if (u->GetSession()->GetPermissions() & PERM_GMT) + if (u->GetSession()->HasPermissions(PERM_GMT_HDEV)) return GetSession()->GetPermissions() <= u->GetSession()->GetPermissions(); // non faction visibility non-breakable for non-GMs @@ -18641,6 +18980,12 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe if (Creature* c = target->ToCreature()) BeforeVisibilityDestroy(c, this); + UpdateData udata; + WorldPacket packet; + target->BuildValuesUpdateBlockForPlayer(&udata,this); + udata.BuildPacket(&packet); + SendPacketToSelf(&packet); + target->DestroyForPlayer(this); m_clientGUIDs.erase(target->GetGUID()); } @@ -18692,7 +19037,7 @@ void Player::SendInitialVisiblePackets(Unit* target) if (target->isAlive()) { if (target->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim()) - target->SendMeleeAttackStart(target->getVictim()); + target->SendMeleeAttackStart(target->getVictimGUID()); } } @@ -19154,7 +19499,7 @@ void Player::SendAuraDurationsForTarget(Unit* target) void Player::SetDailyQuestStatus(uint32 quest_id) { - for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY); ++quest_daily_idx) { if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) { @@ -19168,12 +19513,13 @@ void Player::SetDailyQuestStatus(uint32 quest_id) void Player::ResetDailyQuestStatus() { - for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + for (uint32 quest_daily_idx = 0; quest_daily_idx < sWorld.getConfig(CONFIG_DAILY_MAX_PER_DAY); ++quest_daily_idx) SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); // DB data deleted in caller m_DailyQuestChanged = false; m_lastDailyQuestTime = 0; + m_DailyArenasWon = 0; } BattleGround* Player::GetBattleGround() const @@ -19325,15 +19671,47 @@ void Player::UpdateForQuestsGO() SendPacketToSelf(&packet); } +bool Player::CanBeSummonedBy(const Unit * summoner) +{ + if (!summoner) + return false; + + // if summoning to instance + if (summoner->GetMap()->IsDungeon()) + { + // check for permbinded id's + InstanceSave * tmpInst = GetInstanceSave(summoner->GetMapId()); + if (tmpInst) + { + if (tmpInst->GetInstanceId() != summoner->GetInstanceId()) + return false; + } + // check for temp id's + else if (GetMap()->IsDungeon() && GetMapId() == summoner->GetMapId() && GetInstanceId() != summoner->GetInstanceId()) + return false; + } + + return true; +} + +bool Player::CanBeSummonedBy(uint64 summoner) +{ + return CanBeSummonedBy(GetUnit(summoner)); +} + void Player::SummonIfPossible(bool agree, uint64 summonerGUID) { - if(Unit* summoner = GetUnit(summonerGUID)) + Unit* summoner = GetUnit(summonerGUID); + if (summoner) { if (summoner->m_currentSpells[CURRENT_CHANNELED_SPELL]) { summoner->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0); summoner->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(); } + + if (!CanBeSummonedBy(summoner)) + return; } if (!agree) @@ -19490,11 +19868,11 @@ void Player::RemoveItemDependentAurasAndCasts(Item * pItem) itr = auras.begin(); } - // currently casted spells can be dependent from item + // currently cast spells can be dependent from item for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) { if (m_currentSpells[i] && m_currentSpells[i]->getState()!=SPELL_STATE_DELAYED && - !HasItemFitToSpellReqirements(m_currentSpells[i]->GetSpellInfo(),pItem)) + !HasItemFitToSpellReqirements(m_currentSpells[i]->GetSpellEntry(),pItem)) InterruptSpell(i); } } @@ -19783,6 +20161,7 @@ void Player::UpdateAreaDependentAuras(uint32 newArea) case 3966: case 3939: case 3965: + case 3967: if (GetDummyAura(40214)) { if (!HasAura(40216,0)) @@ -20080,7 +20459,7 @@ void Player::LFGSet(uint8 slot, uint32 entry, uint32 type) return; // don't add GM to lfg list - if (GetSession()->GetPermissions() & PERM_GMT) + if (GetSession()->HasPermissions(PERM_GMT)) return; LfgContainerType::accessor a; @@ -20139,7 +20518,7 @@ void Player::LFGSet(uint8 slot, uint32 entry, uint32 type) void Player::LFMSet(uint32 entry, uint32 type) { // don't add GM to lfm list - if (GetSession()->GetPermissions() & PERM_GMT) + if (GetSession()->HasPermissions(PERM_GMT)) return; // don't add to lfm list if still in lfg @@ -20419,7 +20798,7 @@ void Player::HandleFallDamage(MovementInfo& movementInfo) if (damageperc >0) { - uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL)); + uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getConfig(RATE_DAMAGE_FALL)); float height = movementInfo.GetPos()->z; UpdateAllowedPositionZ(movementInfo.GetPos()->x, movementInfo.GetPos()->y, height); @@ -20622,13 +21001,13 @@ float Player::GetXPRate(Rates rate) if (sWorld.getConfig(CONFIG_ENABLE_CUSTOM_XP_RATES) && GetSession()->IsAccountFlagged(ACC_BLIZZLIKE_RATES)) return 1.0f; else - return sWorld.getRate(Rates(rate)); + return sWorld.getConfig(Rates(rate)); } uint32 Player::CalculateTalentsPoints() const { uint32 talentPointsForLevel = getLevel() < 10 ? 0 : getLevel()-9; - return uint32(talentPointsForLevel * sWorld.getRate(RATE_TALENT)); + return uint32(talentPointsForLevel * sWorld.getConfig(RATE_TALENT)); } BattleGroundBracketId Player::GetBattleGroundBracketIdFromLevel(BattleGroundTypeId bgTypeId) const @@ -20658,3 +21037,391 @@ void Player::InterruptTaxiFlying() else SaveRecallPosition(); } + +// Refer-A-Friend +void Player::SendReferFriendError(ReferAFriendError err, Player * target) +{ + WorldPacket data(SMSG_REFER_A_FRIEND_ERROR, 24); + data << uint32(err); + if (target && (err == ERR_REFER_A_FRIEND_NOT_IN_GROUP || err == ERR_REFER_A_FRIEND_SUMMON_OFFLINE_S)) + data << target->GetName(); + + GetSession()->SendPacket(&data); +} + +ReferAFriendError Player::GetReferFriendError(Player * target, bool summon) +{ + if (!target || target->GetTypeId() != TYPEID_PLAYER) + return summon ? ERR_REFER_A_FRIEND_SUMMON_OFFLINE_S : ERR_REFER_A_FRIEND_NO_TARGET; + + if (!IsReferAFriendLinked(target)) + return ERR_REFER_A_FRIEND_NOT_REFERRED_BY; + + if (Group * gr1 = GetGroup()) + { + Group * gr2 = target->GetGroup(); + + if (!gr2 || gr1 != gr2) + return ERR_REFER_A_FRIEND_NOT_IN_GROUP; + } + + if (summon) + { + if (HasSpellCooldown(45927)) + return ERR_REFER_A_FRIEND_SUMMON_COOLDOWN; + if (target->getLevel() > sWorld.getConfig(CONFIG_UINT32_RAF_MAXGRANTLEVEL)) + return ERR_REFER_A_FRIEND_SUMMON_LEVEL_MAX_I; + + if (MapEntry const* mEntry = sMapStore.LookupEntry(GetMapId())) + if (mEntry->Expansion() > target->GetSession()->Expansion()) + return ERR_REFER_A_FRIEND_INSUF_EXPAN_LVL; + } + else + { + if (GetTeam() != target->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) + return ERR_REFER_A_FRIEND_DIFFERENT_FACTION; + if (getLevel() <= target->getLevel()) + return ERR_REFER_A_FRIEND_TARGET_TOO_HIGH; + if (!GetGrantableLevels()) + return ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS; + if (GetDistance(target) > DEFAULT_VISIBILITY_DISTANCE || !target->IsVisibleGloballyfor(this)) + return ERR_REFER_A_FRIEND_TOO_FAR; + if (target->getLevel() >= sWorld.getConfig(CONFIG_UINT32_RAF_MAXGRANTLEVEL)) + return ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I; + } + + return ERR_REFER_A_FRIEND_NONE; +} + +void Player::ChangeGrantableLevels(uint8 increase) +{ + if (increase) + { + if (m_GrantableLevelsCount <= uint32(sWorld.getConfig(CONFIG_UINT32_RAF_MAXGRANTLEVEL) * sWorld.getConfig(CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL))) + m_GrantableLevelsCount = increase; + } + else + { + m_GrantableLevelsCount -= 1; + + if (m_GrantableLevelsCount < 0) + m_GrantableLevelsCount = 0; + } + + // set/unset flag - granted levels + if (m_GrantableLevelsCount > 0) + { + if (!HasByteFlag(PLAYER_FIELD_BYTES, 1, 0x01)) + SetByteFlag(PLAYER_FIELD_BYTES, 1, 0x01); + } + else + { + if (HasByteFlag(PLAYER_FIELD_BYTES, 1, 0x01)) + RemoveByteFlag(PLAYER_FIELD_BYTES, 1, 0x01); + } + +} + +bool Player::CheckRAFConditions() +{ + if (Group * grp = GetGroup()) + { + if (GetAccountLinkedState() == STATE_NOT_LINKED) + return false; + + for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* member = itr->getSource(); + + if (!member || !member->isAlive()) + continue; + + if (GetObjectGuid() == member->GetObjectGuid()) + continue; + + if (!IsReferAFriendLinked(member)) + continue; + + if (GetDistance(member) < 100 && (getLevel() <= member->getLevel() + 4)) + return true; + } + } + + return false; +} + +AccountLinkedState Player::GetAccountLinkedState() +{ + + if (!m_referredAccounts.empty() && !m_referalAccounts.empty()) + return STATE_DUAL; + + if (!m_referredAccounts.empty()) + return STATE_REFER; + + if (!m_referalAccounts.empty()) + return STATE_REFERRAL; + + return STATE_NOT_LINKED; +} + +void Player::LoadAccountLinkedState() +{ + m_referredAccounts.clear(); + m_referredAccounts = AccountMgr::GetRAFAccounts(GetSession()->GetAccountId(), true); + + if (m_referredAccounts.size() > sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERERS)) + sLog.outLog(LOG_DEFAULT, "Player:RAF:Warning: loaded %u referred accounts instead of %u for player %u", m_referredAccounts.size(), sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERERS), GetObjectGuid().GetCounter()); + else + DEBUG_LOG("Player:RAF: loaded %u referred accounts for player %u", m_referredAccounts.size(), GetObjectGuid().GetCounter()); + + m_referalAccounts.clear(); + m_referalAccounts = AccountMgr::GetRAFAccounts(GetSession()->GetAccountId(), false); + + if (m_referalAccounts.size() > sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERALS)) + sLog.outLog(LOG_DEFAULT, "Player:RAF:Warning: loaded %u referal accounts instead of %u for player %u", m_referalAccounts.size(), sWorld.getConfig(CONFIG_UINT32_RAF_MAXREFERALS), GetObjectGuid().GetCounter()); + else + DEBUG_LOG("Player:RAF: loaded %u referal accounts for player %u", m_referalAccounts.size(), GetObjectGuid().GetCounter()); +} + +bool Player::IsReferAFriendLinked(Player* target) +{ + // check link this(refer) - target(referral) + for (std::vector::const_iterator itr = m_referalAccounts.begin(); itr != m_referalAccounts.end(); ++itr) + { + if ((*itr) == target->GetSession()->GetAccountId()) + return true; + } + + // check link target(refer) - this(referral) + for (std::vector::const_iterator itr = m_referredAccounts.begin(); itr != m_referredAccounts.end(); ++itr) + { + if ((*itr) == target->GetSession()->GetAccountId()) + return true; + } + + return false; +} + +void Player::ChangeRace(uint8 new_race) +{ + static uint16 CapitalForRace[12] = {0,72,76,47,69,68,81,54,530,0,911,930}; + + static uint16 MountsForRace[12][7] = { + {0,0,0,0,0,0,0}, + {2411,2414,5655,5656,18776,18777,18778}, + {1132,5665,5668,1132,18796,18797,18798}, + {5864,5872,5873,5864,18785,18786,18787}, + {8629,8631,8632,8629,18766,18767,18902}, + {13331,13332,13333,13331,13334,18791,13334}, + {15277,15290,15277,15290,18793,18794,18795}, + {8595,8563,13321,13322,18772,18773,18774}, + {8588,8591,8592,8588,18788,18789,18790}, + {0,0,0,0,0,0,0}, + {28927,29220,29221,29222,29223,29224,28936}, + {28481,29743,29744,28481,29745,29746,29747} + }; + + sLog.outLog(LOG_RACE_CHANGE,"[%u] Starting race change for player %s from %u to %u",GetGUIDLow(),GetName(),getRace(),new_race); + Races old_race = Races(getRace()); + + if (bool((1 << new_race) & 0x89A) != bool((1 << old_race) & 0x89A)) + { + sLog.outLog(LOG_RACE_CHANGE,"[%u] Invalid race change, trans-faction NYI",GetGUIDLow()); + return; + } + + const PlayerInfo* new_info = sObjectMgr.GetPlayerInfo(new_race,getClass()); + if (!new_info) + { + sLog.outLog(LOG_RACE_CHANGE,"[%u] Invalid race/class pair: %u / %u",GetGUIDLow(),new_race,getClass()); + return; + } + + QueryResultAutoPtr result = GameDataDatabase.PQuery( + "SELECT skin1,skin2,skin3 FROM race_change_skins WHERE race = %u AND gender = %u",new_race,getGender()); + + if (!result) + { + sLog.outLog(LOG_RACE_CHANGE,"[%u] skins not found (race %u gender %u)",GetGUIDLow(),new_race,getGender()); + return; + } + SetUInt32Value(PLAYER_BYTES,result->Fetch()[urand(0,2)].GetUInt32()); //face, hair, skin and hair color + SetByteValue(PLAYER_BYTES_2,0,0); //facial hair + + if (getGender() == GENDER_FEMALE) + { + SetDisplayId(new_info->displayId_f); + SetNativeDisplayId(new_info->displayId_f); + } + else + { + SetDisplayId(new_info->displayId_m); + SetNativeDisplayId(new_info->displayId_m); + } + uint32 unitbytes0 = GetUInt32Value(UNIT_FIELD_BYTES_0) & 0xFFFFFF00; + unitbytes0 |= new_race; + SetUInt32Value(UNIT_FIELD_BYTES_0, unitbytes0); + + //spells + result = GameDataDatabase.PQuery("SELECT spell FROM race_change_spells WHERE race = %u AND class = %u",old_race,getClass()); + Field* fields; + if (result) + { + do + { + fields = result->Fetch(); + removeSpell(fields[0].GetUInt32()); + } + while (result->NextRow()); + } + + if (getClass() == CLASS_PRIEST) + { + removeSpell(2651); + removeSpell(2652); + removeSpell(2944); + removeSpell(9035); + removeSpell(10797); + removeSpell(13896); + removeSpell(13908); + removeSpell(18137); + removeSpell(32548); + removeSpell(32676); + removeSpell(44041); + } + + result = GameDataDatabase.PQuery("SELECT spell FROM race_change_spells WHERE race = %u AND class = %u",new_race,getClass()); + if (result) + { + do + { + fields = result->Fetch(); + learnSpell(fields[0].GetUInt32()); + } + while (result->NextRow()); + } + + //reps + setFaction(Player::getFactionForRace(new_race)); + if (!GetReputationMgr().SwitchReputation(CapitalForRace[old_race],CapitalForRace[new_race])) + sLog.outLog(LOG_RACE_CHANGE,"[%u] Problem encountered while changing reputation",GetGUIDLow()); + + //Mounts + for (uint8 type = 0;type<7;type++){ + for (uint16 i = INVENTORY_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pItem && pItem->GetEntry() == MountsForRace[old_race][type]) + { + DestroyItem(INVENTORY_SLOT_BAG_0,i,true); + ItemPosCountVec vector; + vector.push_back(ItemPosCount((INVENTORY_SLOT_BAG_0 <<8) + i,1)); + StoreNewItem(vector,MountsForRace[new_race][type],true); + } + } + for (uint16 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pBag) + { + for (uint32 j = 0; j < pBag->GetBagSize(); j++) + { + Item* pItem = pBag->GetItemByPos(j); + if (pItem && pItem->GetEntry() == MountsForRace[old_race][type]) + { + DestroyItem(i,j,true); + ItemPosCountVec vector; + vector.push_back(ItemPosCount((i <<8) + j,1)); + StoreNewItem(vector,MountsForRace[new_race][type],true); + } + } + } + } + for (uint16 i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (pBag) + { + for (uint32 j = 0; j < pBag->GetBagSize(); j++) + { + Item* pItem = pBag->GetItemByPos(j); + if (pItem && pItem->GetEntry() == MountsForRace[old_race][type]) + { + DestroyItem(i,j,true); + ItemPosCountVec vector; + vector.push_back(ItemPosCount((i <<8) + j,1)); + StoreNewItem(vector,MountsForRace[new_race][type],true); + } + } + } + } + } + sLog.outLog(LOG_RACE_CHANGE,"[%u] Race change for player %s succesful",GetGUIDLow(),GetName()); +} + +void Player::SetCanWhisperToGM(bool on) +{ + if (on) + { + m_ExtraFlags |= PLAYER_EXTRA_CAN_WHISP_TO_GM; + sSocialMgr.canWhisperToGMList.push_back(GetGUID()); + } + else + { + m_ExtraFlags &= ~PLAYER_EXTRA_CAN_WHISP_TO_GM; + sSocialMgr.canWhisperToGMList.remove(GetGUID()); + } +} + +bool Player::isInSanctuary() +{ + return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_SANCTUARY); +} + +void Player::CumulativeACReport(AnticheatChecks check) +{ + if(check >= ANTICHEAT_CHECK_MAX) + return; + + ++m_AC_cumulative_count[check]; + if (m_AC_cumulative_timer[check] > time(NULL)) + { + m_AC_cumulative_timer[check] = time(NULL) + sWorld.getConfig(CONFIG_ANTICHEAT_CUMULATIVE_DELAY); + uint32 report = 0; + switch (check) + { + case ANTICHEAT_CHECK_FLYHACK: + report = LANG_ANTICHEAT_FLY; break; + case ANTICHEAT_CHECK_WATERWALKHACK: + report = LANG_ANTICHEAT_WATERWALK; break; + default: + break; + } + if (report) + sWorld.SendGMText(report,GetName(),GetName(),m_AC_cumulative_count[check]); + + m_AC_cumulative_count[check] = 0; + } + +} + +void Player::SetCheatState(PlayerCheatState newState) +{ + m_cheatState = m_cheatState | newState; +} + +PlayerCheatState Player::GetCheatState() const +{ + return m_cheatState; +} + +bool Player::HasCheatState(PlayerCheatState requestedState) const +{ + return (m_cheatState & requestedState) != PlayerCheatState::None; +} + +void Player::ToggleCheatState(PlayerCheatState newState) +{ + m_cheatState = m_cheatState ^ newState; +} diff --git a/src/game/Player.h b/src/game/Player.h index 22978e43a..70b47b3e4 100755 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _PLAYER_H -#define _PLAYER_H +#ifndef HELLGROUND_PLAYER_H +#define HELLGROUND_PLAYER_H #include "Common.h" @@ -61,7 +61,14 @@ struct PlayerAI; typedef std::deque PlayerMails; #define PLAYER_MAX_SKILLS 127 -#define PLAYER_MAX_DAILY_QUESTS 25 + +enum AnticheatChecks +{ + ANTICHEAT_CHECK_FLYHACK, + ANTICHEAT_CHECK_WATERWALKHACK, + + ANTICHEAT_CHECK_MAX +}; // Note: SPELLMOD_* values is aura types in fact enum SpellModType @@ -90,6 +97,37 @@ enum PlayerSpellState PLAYERSPELL_REMOVED = 3 }; +// A set of ".cheat"-command related states +enum class PlayerCheatState : uint32 +{ + // No state is set + None = 0x0, + // Can not take any damage + God = 0x1, + // Abilities do not cost any power + Power = 0x2 +}; + +inline PlayerCheatState operator|(PlayerCheatState lhs, PlayerCheatState rhs) +{ + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +inline PlayerCheatState operator&(PlayerCheatState lhs, PlayerCheatState rhs) +{ + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +inline PlayerCheatState operator^(PlayerCheatState lhs, PlayerCheatState rhs) +{ + return static_cast(static_cast(lhs) ^ static_cast(rhs)); +} + +inline PlayerCheatState operator~(PlayerCheatState rhs) +{ + return static_cast(~static_cast(rhs)); +} + struct PlayerSpell { uint16 slotId : 16; @@ -115,6 +153,8 @@ struct SpellModifier typedef UNORDERED_MAP PlayerSpellMap; typedef std::list SpellModList; +typedef UNORDERED_MAP> ConsecutiveKillsMap; + struct SpellCooldown { time_t end; @@ -157,6 +197,39 @@ enum ActionButtonType ACTION_BUTTON_ITEM = 128 }; +enum RestState +{ + REST_STATE_RESTED = 0x01, + REST_STATE_NORMAL = 0x02, + REST_STATE_RAF = 0x06 +}; + +enum ReferAFriendError +{ + ERR_REFER_A_FRIEND_NONE = 0x00, + ERR_REFER_A_FRIEND_NOT_REFERRED_BY = 0x01, + ERR_REFER_A_FRIEND_TARGET_TOO_HIGH = 0x02, + ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS = 0x03, + ERR_REFER_A_FRIEND_TOO_FAR = 0x04, + ERR_REFER_A_FRIEND_DIFFERENT_FACTION = 0x05, + ERR_REFER_A_FRIEND_NOT_NOW = 0x06, + ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I = 0x07, + ERR_REFER_A_FRIEND_NO_TARGET = 0x08, + ERR_REFER_A_FRIEND_NOT_IN_GROUP = 0x09, + ERR_REFER_A_FRIEND_SUMMON_LEVEL_MAX_I = 0x0A, + ERR_REFER_A_FRIEND_SUMMON_COOLDOWN = 0x0B, + ERR_REFER_A_FRIEND_INSUF_EXPAN_LVL = 0x0C, + ERR_REFER_A_FRIEND_SUMMON_OFFLINE_S = 0x0D +}; + +enum AccountLinkedState +{ + STATE_NOT_LINKED = 0x00, + STATE_REFER = 0x01, + STATE_REFERRAL = 0x02, + STATE_DUAL = 0x04, +}; + #define MAX_ACTION_BUTTONS 132 //checked in 2.3.0 typedef std::map ActionButtonList; @@ -528,6 +601,7 @@ enum PlayerExtraFlags { // gm abilities PLAYER_EXTRA_GM_ON = 0x0001, + PLAYER_EXTRA_CAN_WHISP_TO_GM = 0x0002, PLAYER_EXTRA_ACCEPT_WHISPERS = 0x0004, PLAYER_EXTRA_TAXICHEAT = 0x0008, PLAYER_EXTRA_GM_INVISIBLE = 0x0010, @@ -544,7 +618,8 @@ enum AtLoginFlags AT_LOGIN_RENAME = 0x1, AT_LOGIN_RESET_SPELLS = 0x2, AT_LOGIN_RESET_TALENTS = 0x4, - AT_LOGIN_DISPLAY_CHANGE = 0x8 + AT_LOGIN_DISPLAY_CHANGE = 0x8, + AT_LOGIN_FIRST = 0x20, }; typedef std::map QuestStatusMap; @@ -808,6 +883,7 @@ enum PlayerLoginQueryIndex PLAYER_LOGIN_QUERY_LOADBGCOORD = 17, PLAYER_LOGIN_QUERY_LOADMAILS = 18, PLAYER_LOGIN_QUERY_LOADMAILEDITEMS = 19, + PLAYER_LOGIN_QUERY_LOADDAILYARENA = 20, MAX_PLAYER_LOGIN_QUERY }; @@ -828,10 +904,11 @@ struct InstancePlayerBind { InstanceSave *save; bool perm; + /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players that aren't already permanently bound when they are inside when a boss is killed or when they enter an instance that the group leader is permanently bound to. */ - InstancePlayerBind() : save(NULL), perm(false) {} + InstancePlayerBind() : save(nullptr), perm(false) {} }; struct AccessRequirement @@ -957,6 +1034,8 @@ class HELLGROUND_EXPORT Player : public Unit m_summon_z = z; } void SummonIfPossible(bool agree, uint64 summonerGUID); + bool CanBeSummonedBy(uint64 summoner); + bool CanBeSummonedBy(const Unit * summoner); bool Create(uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId); @@ -999,9 +1078,11 @@ class HELLGROUND_EXPORT Player : public Unit bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; } void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } + bool canWhisperToGM() const { return m_ExtraFlags & PLAYER_EXTRA_CAN_WHISP_TO_GM; } + void SetCanWhisperToGM(bool on); bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; } void SetGameMaster(bool on); - bool isGMChat() const { return GetSession()->GetPermissions() & PERM_GMT && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); } + bool isGMChat() const { return GetSession()->HasPermissions(PERM_GMT) && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); } void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; } void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } @@ -1046,7 +1127,7 @@ class HELLGROUND_EXPORT Player : public Unit void UpdateInnerTime (int time) { time_inn_enter = time; }; Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime); - void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); + void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false, bool isDying = false); void RemoveMiniPet(); Pet* GetMiniPet(); void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); } @@ -1073,6 +1154,7 @@ class HELLGROUND_EXPORT Player : public Unit Item* GetItemByGuid(uint64 guid) const; Item* GetItemByPos(uint16 pos) const; Item* GetItemByPos(uint8 bag, uint8 slot) const; + uint32 GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const; Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; Item* GetShield(bool useable = false) const; static uint32 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot @@ -1275,7 +1357,7 @@ class HELLGROUND_EXPORT Player : public Unit void ItemAddedQuestCheck(uint32 entry, uint32 count); void ItemRemovedQuestCheck(uint32 entry, uint32 count); void KilledMonster(uint32 entry, uint64 guid); - void CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id); + void CastCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id); void TalkedToCreature(uint32 entry, uint64 guid); void MoneyChanged(uint32 value); void ReputationChanged(FactionEntry const* factionEntry); @@ -1347,17 +1429,7 @@ class HELLGROUND_EXPORT Player : public Unit void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); } - void ModifyMoney(int32 d) - { - if (d < 0) - SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); - else - SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); - - // "At Gold Limit" - if (GetMoney() >= MAX_MONEY_AMOUNT) - SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); - } + void ModifyMoney(int32 d); void SetMoney(uint32 value) { SetUInt32Value (PLAYER_FIELD_COINAGE, value); @@ -1454,6 +1526,7 @@ class HELLGROUND_EXPORT Player : public Unit bool HasSpell(uint32 spell) const; TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; bool IsSpellFitByClassAndRace(uint32 spell_id) const; + void ChangeRace(uint8 new_raceID); void SendProficiency(uint8 pr1, uint32 pr2); void SendInitialSpells(); @@ -1466,7 +1539,7 @@ class HELLGROUND_EXPORT Player : public Unit void learnQuestRewardedSpells(Quest const* quest); uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } - void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } + void SetFreeTalentPoints(uint32 points); bool resetTalents(bool no_cost = false); uint32 resetTalentsCost() const; void UpdateFreeTalentPoints(bool resetIfNeed = true); @@ -1489,7 +1562,7 @@ class HELLGROUND_EXPORT Player : public Unit void RemoveSpellMods(Spell const* spell); void RestoreSpellMods(Spell const* spell); - GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; } + CooldownMgr& GetCooldownMgr() { return m_CooldownMgr; } bool HasSpellCooldown(uint32 spell_id) const { @@ -1504,7 +1577,7 @@ class HELLGROUND_EXPORT Player : public Unit } void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); void SendCooldownEvent(SpellEntry const *spellInfo); - void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs); + void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); void RemoveSpellCooldown(uint32 spell_id, bool update = false); void RemoveArenaSpellCooldowns(); void RemoveAllSpellCooldown(); @@ -1650,6 +1723,7 @@ class HELLGROUND_EXPORT Player : public Unit uint32 GetRangedCritDamageReduction(uint32 damage) const; uint32 GetSpellCritDamageReduction(uint32 damage) const; uint32 GetDotDamageReduction(uint32 damage) const; + int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; } float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; void UpdateBlockPercentage(); @@ -1673,7 +1747,7 @@ class HELLGROUND_EXPORT Player : public Unit void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const; void DestroyForPlayer(Player *target) const; void SendDelayResponse(const uint32); - void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); + void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool ReferAFriend); //notifiers void SendAttackSwingCantAttack(); @@ -1756,9 +1830,6 @@ class HELLGROUND_EXPORT Player : public Unit void learnSkillRewardedSpells(uint32 id); void learnSkillRewardedSpells(); - void SetDontMove(bool dontMove); - bool GetDontMove() const { return m_dontMove; } - void CheckAreaExploreAndOutdoor(void); static uint32 TeamForRace(uint8 race); @@ -1783,9 +1854,40 @@ class HELLGROUND_EXPORT Player : public Unit void UpdateSkillsToMaxSkillsForLevel(); // for .levelup void ModifySkillBonus(uint32 skillid,int32 val, bool talent); + /*********************************************************/ + /*** REFER-A-FRIEND SYSTEM ***/ + /*********************************************************/ + void SendReferFriendError(ReferAFriendError err, Player * target = NULL); + ReferAFriendError GetReferFriendError(Player * target, bool summon); + void AccessGrantableLevel(ObjectGuid guid) + { + m_curGrantLevelGiverGuid = guid; + } + bool IsAccessGrantableLevel(ObjectGuid guid) + { + return m_curGrantLevelGiverGuid == guid; + } + uint32 GetGrantableLevels() + { + return m_GrantableLevelsCount; + } + void ChangeGrantableLevels(uint8 increase = 0); + bool CheckRAFConditions(); + AccountLinkedState GetAccountLinkedState(); + bool IsReferAFriendLinked(Player * target); + void LoadAccountLinkedState(); + std::vector m_referredAccounts; + std::vector m_referalAccounts; + + // Refer-A-Friend + ObjectGuid m_curGrantLevelGiverGuid; + + int32 m_GrantableLevelsCount; + /*********************************************************/ /*** ANTICHEAT SYSTEM ***/ /*********************************************************/ + void CumulativeACReport(AnticheatChecks check); uint32 m_AC_timer; uint32 m_AC_NoFall_count; @@ -1800,6 +1902,7 @@ class HELLGROUND_EXPORT Player : public Unit void ModifyHonorPoints(int32 value); void ModifyArenaPoints(int32 value); uint32 GetMaxPersonalArenaRatingRequirement(); + uint16 m_DailyArenasWon; //End of PvP System @@ -2024,6 +2127,7 @@ class HELLGROUND_EXPORT Player : public Unit void UpdateSpeakTime(); bool CanSpeak() const; void ChangeSpeakTime(int utime); + bool IsTrollmuted() const; /*********************************************************/ /*** VARIOUS SYSTEMS ***/ @@ -2039,6 +2143,7 @@ class HELLGROUND_EXPORT Player : public Unit void BuildTeleportAckMsg(WorldPacket & data, float x, float y, float z, float ang) const; + bool isInSanctuary(); bool isMoving() const { return HasUnitMovementFlag(MOVEFLAG_MOVING); } bool isTurning() const { return HasUnitMovementFlag(MOVEFLAG_TURNING); } bool isMovingOrTurning() const { return HasUnitMovementFlag(MOVEFLAG_TURNING | MOVEFLAG_MOVING); } @@ -2111,6 +2216,7 @@ class HELLGROUND_EXPORT Player : public Unit uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; } + void RemoveAtLoginFlag(AtLoginFlags f) { m_atLoginFlags &= ~f; } void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; } LookingForGroup m_lookingForGroup; @@ -2210,7 +2316,14 @@ class HELLGROUND_EXPORT Player : public Unit Camera& GetCamera() { return m_camera; } + // .cheat related + void SetCheatState(PlayerCheatState newState); + PlayerCheatState GetCheatState() const; + bool HasCheatState(PlayerCheatState requestedState) const; + void ToggleCheatState(PlayerCheatState newState); + protected: + TimeTrackerSmall positionStatus; /*********************************************************/ /*** BATTLEGROUND SYSTEM ***/ @@ -2343,6 +2456,8 @@ class HELLGROUND_EXPORT Player : public Unit EnchantDurationList m_enchantDuration; ItemDurationList m_itemDuration; + int32 m_spellPenetrationItemMod; + uint64 m_resurrectGUID; uint32 m_resurrectMap; float m_resurrectX, m_resurrectY, m_resurrectZ; @@ -2353,8 +2468,6 @@ class HELLGROUND_EXPORT Player : public Unit typedef std::list JoinedChannelsList; JoinedChannelsList m_channels; - bool m_dontMove; - bool m_cinematic; uint32 m_watchingCinematicId; @@ -2368,7 +2481,7 @@ class HELLGROUND_EXPORT Player : public Unit uint32 m_Tutorials[8]; bool m_TutorialsChanged; - bool m_DailyQuestChanged; + bool m_DailyQuestChanged; time_t m_lastDailyQuestTime; uint32 m_drunkTimer; @@ -2465,19 +2578,33 @@ class HELLGROUND_EXPORT Player : public Unit uint32 m_timeSyncTimer; uint32 m_timeSyncClient; uint32 m_timeSyncServer; + + void AddConsecutiveKill(uint64 guid); + uint32 GetConsecutiveKillsCount(uint64 guid); + void UpdateConsecutiveKills(); + ConsecutiveKillsMap m_consecutiveKills; + + time_t m_AC_cumulative_timer[ANTICHEAT_CHECK_MAX]; + uint32 m_AC_cumulative_count[ANTICHEAT_CHECK_MAX]; // Current teleport data WorldLocation m_teleport_dest; + void StartTeleportTimer() {m_teleportStartTime = time(NULL);} + bool HasTeleportTimerPassed(uint64 diff) {return m_teleportStartTime + diff < time(NULL);} + uint64 m_teleportStartTime; // Temporary removed pet cache uint32 m_temporaryUnsummonedPetNumber; uint32 m_oldpetspell; - GlobalCooldownMgr m_GlobalCooldownMgr; + CooldownMgr m_CooldownMgr; ReputationMgr m_reputationMgr; Camera m_camera; + bool m_outdoors; + + PlayerCheatState m_cheatState; }; typedef std::set PlayerSet; diff --git a/src/game/PlayerAI.cpp b/src/game/PlayerAI.cpp index 22650f5ff..c8a880fe6 100755 --- a/src/game/PlayerAI.cpp +++ b/src/game/PlayerAI.cpp @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "PlayerAI.h" #include "Player.h" #include "DBCStores.h" diff --git a/src/game/PlayerAI.h b/src/game/PlayerAI.h index ca4481bb8..d279a3167 100755 --- a/src/game/PlayerAI.h +++ b/src/game/PlayerAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index eafb43247..d80d83933 100755 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +33,8 @@ template void PointMovementGenerator::Initialize(UNIT &unit) { - unit.StopMoving(); + if ( m_callStopMove ) + unit.StopMoving(); unit.addUnitState(UNIT_STAT_ROAMING); diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index 32622c426..7a3d92943 100755 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ template class PointMovementGenerator : public MovementGeneratorMedium< UNIT, PointMovementGenerator > { public: - PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath = false) : _id(id), - _x(x), _y(y), _z(z), _generatePath(generatePath) {} + PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath = false, bool callStop = true) : _id(id), + _x(x), _y(y), _z(z), _generatePath(generatePath), m_callStopMove( callStop ) {} void Initialize(UNIT &); void Finalize(UNIT &); @@ -48,6 +48,7 @@ class PointMovementGenerator : public MovementGeneratorMedium< UNIT, PointMoveme uint32 _id; float _x, _y, _z; bool _generatePath; + bool m_callStopMove; }; class AssistanceMovementGenerator : public PointMovementGenerator diff --git a/src/game/PoolManager.cpp b/src/game/PoolManager.cpp index 3f51b715c..293cdcd60 100644 --- a/src/game/PoolManager.cpp +++ b/src/game/PoolManager.cpp @@ -1,5 +1,7 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "PoolManager.h" diff --git a/src/game/PoolManager.h b/src/game/PoolManager.h index ea842be3e..e0f2161d5 100644 --- a/src/game/PoolManager.h +++ b/src/game/PoolManager.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_POOLHANDLER_H -#define MANGOS_POOLHANDLER_H +#ifndef HELLGROUND_POOLMGR_H +#define HELLGROUND_POOLMGR_H #include "ace/Singleton.h" diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 0a44c41cc..dba9d7b2f 100755 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,7 +92,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResultAutoPtr result, std::string name = fields[1].GetCppString(); uint32 field = 0; if (name == "") - name = session->GetTrinityString(LANG_NON_EXIST_CHARACTER); + name = session->GetHellgroundString(LANG_NON_EXIST_CHARACTER); else field = fields[2].GetUInt32(); diff --git a/src/game/QuestDef.cpp b/src/game/QuestDef.cpp index e233fafbc..c71248cc7 100755 --- a/src/game/QuestDef.cpp +++ b/src/game/QuestDef.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -199,6 +199,6 @@ int32 Quest::GetRewOrReqMoney() const if (RewOrReqMoney <=0) return RewOrReqMoney; - return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY)); + return int32(RewOrReqMoney * sWorld.getConfig(RATE_DROP_MONEY)); } diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index a68371d67..c88d192f2 100755 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_QUEST_H -#define TRINITYCORE_QUEST_H +#ifndef HELLGROUND_QUESTDEF_H +#define HELLGROUND_QUESTDEF_H #include "Platform/Define.h" #include "Database/DatabaseEnv.h" @@ -109,7 +109,9 @@ enum __QuestGiverStatus DIALOG_STATUS_AVAILABLE_REP = 5, DIALOG_STATUS_AVAILABLE = 6, DIALOG_STATUS_REWARD2 = 7, // not yellow dot on minimap - DIALOG_STATUS_REWARD = 8 // yellow dot on minimap + DIALOG_STATUS_REWARD = 8, // yellow dot on minimap + + DIALOG_STATUS_SCRIPTED_NO_STATUS = 100 }; enum __QuestFlags diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 2b794db4b..71f4aaa14 100755 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ #include "Group.h" #include "BattleGround.h" #include "BattleGroundAV.h" +#include "luaengine/HookMgr.h" void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) { @@ -59,7 +60,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) if (!cr_questgiver->IsHostileTo(_player)) // not show quest status to enemies { questStatus = sScriptMgr.GetDialogStatus(_player, cr_questgiver); - if (questStatus > 6) + if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, cr_questgiver, defstatus); } break; @@ -69,7 +70,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u",uint32(GUID_LOPART(guid))); GameObject* go_questgiver=(GameObject*)questgiver; questStatus = sScriptMgr.GetDialogStatus(_player, go_questgiver); - if (questStatus > 6) + if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, go_questgiver, defstatus); break; } @@ -396,6 +397,9 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) if (!_player->TakeQuestSourceItem(quest, true)) return; // can't un-equip some items, reject quest cancel + // used by eluna + sHookMgr->OnQuestAbandon(_player, quest); + _player->SetQuestStatus(quest, QUEST_STATUS_NONE); } @@ -679,7 +683,7 @@ void WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(WorldPacket& /*recv if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = sScriptMgr.GetDialogStatus(_player, questgiver); - if (questStatus > 6) + if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); @@ -694,7 +698,7 @@ void WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(WorldPacket& /*recv if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = sScriptMgr.GetDialogStatus(_player, questgiver); - if (questStatus > 6) + if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index 55b107598..0e4d4fc40 100755 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Creature.h" diff --git a/src/game/RandomMovementGenerator.h b/src/game/RandomMovementGenerator.h index 96139fdb3..213022c05 100755 --- a/src/game/RandomMovementGenerator.h +++ b/src/game/RandomMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef HELLGROUND_RANDOMMOTIONGENERATOR_H -#define HELLGROUND_RANDOMMOTIONGENERATOR_H +#ifndef HELLGROUND_RANDOMMOVEMENTGENERATOR_H +#define HELLGROUND_RANDOMMOVEMENTGENERATOR_H #include "MovementGenerator.h" diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index 2b86b3e34..beb8abc8b 100755 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ReactorAI.h b/src/game/ReactorAI.h index a04c21d11..871166c18 100755 --- a/src/game/ReactorAI.h +++ b/src/game/ReactorAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp index c4623b3db..a9d0bb91e 100644 --- a/src/game/ReputationMgr.cpp +++ b/src/game/ReputationMgr.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ReputationMgr.h" @@ -21,6 +22,7 @@ #include "Player.h" #include "WorldPacket.h" #include "ObjectMgr.h" +#include "luaengine/HookMgr.h" const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; @@ -228,6 +230,9 @@ void ReputationMgr::Initialize() bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) { + // used by eluna + sHookMgr->OnReputationChange(m_player, factionEntry->ID, standing, incremental); + bool res = false; // if spillover definition exists in DB if (const RepSpilloverTemplate *repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) @@ -491,3 +496,38 @@ void ReputationMgr::SaveToDB(bool transaction) if (transaction) RealmDataDatabase.CommitTransaction(); } + +bool ReputationMgr::SwitchReputation(uint32 faction1Id, uint32 faction2Id) +{ + FactionEntry const *faction1Entry = sFactionStore.LookupEntry(faction1Id); + FactionEntry const *faction2Entry = sFactionStore.LookupEntry(faction2Id); + if (!faction1Entry || !faction2Entry) + return false; + + FactionStateList::iterator itr1 = m_factions.find(faction1Entry->reputationListID); + FactionStateList::iterator itr2 = m_factions.find(faction2Entry->reputationListID); + if (itr1 != m_factions.end() && itr2 != m_factions.end()) + { + int32 temp = itr1->second.Standing; + itr1->second.Standing = itr2->second.Standing; + itr2->second.Standing = temp; + + itr1->second.needSend = true; + itr1->second.needSave = true; + itr2->second.needSend = true; + itr2->second.needSave = true; + + SetVisible(&itr1->second); + SetVisible(&itr2->second); + + if (ReputationToRank(itr1->second.Standing) <= REP_HOSTILE) + SetAtWar(&itr1->second, true); + if (ReputationToRank(itr2->second.Standing) <= REP_HOSTILE) + SetAtWar(&itr2->second, true); + + m_player->ReputationChanged(faction1Entry); + m_player->ReputationChanged(faction2Entry); + return true; + } + return false; +} diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h index 74fed40a8..3011d4867 100644 --- a/src/game/ReputationMgr.h +++ b/src/game/ReputationMgr.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __MANGOS_REPUTATION_MGR_H -#define __MANGOS_REPUTATION_MGR_H +#ifndef HELLGROUND_REPUTATIONMGR_H +#define HELLGROUND_REPUTATIONMGR_H #include "Common.h" #include "SharedDefines.h" @@ -108,6 +109,7 @@ class HELLGROUND_EXPORT ReputationMgr { return SetReputation(factionEntry, standing, true); } + bool SwitchReputation(uint32 faction1Id, uint32 faction2Id); void SetVisible(FactionTemplateEntry const* factionTemplateEntry); void SetVisible(FactionEntry const* factionEntry); diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index f3b3a9490..13f8e4df8 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ScriptMgr.h" @@ -22,6 +23,7 @@ #include "ObjectMgr.h" #include "WaypointMgr.h" #include "World.h" +#include "luaengine/HookMgr.h" #include "../shared/Config/Config.h" @@ -289,6 +291,16 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) } break; } + case SCRIPT_COMMAND_SET_INST_DATA: + { + if (tmp.datalong2 < 0 || tmp.datalong2 > 5) + { + sLog.outLog(LOG_DB_ERR, "Table `%s` has wrong value (%u) for instance data in `datalong2` in SCRIPT_COMMAND_SET_INST_DATA in `datalong2` for script id %u", + tablename,tmp.datalong2,tmp.id); + continue; + } + break; + } } if (scripts.find(tmp.id) == scripts.end()) @@ -314,7 +326,7 @@ void ScriptMgr::CheckScripts(ScriptMapMap const& scripts,std::set& ids) { if (itrM->second.dataint) { - if (!sObjectMgr.GetTrinityStringLocale (itrM->second.dataint)) + if (!sObjectMgr.GetHellgroundStringLocale (itrM->second.dataint)) sLog.outLog(LOG_DB_ERR, "Table `db_script_string` has not existed string id %u", itrM->first); if (ids.count(itrM->second.dataint)) @@ -590,7 +602,7 @@ void ScriptMgr::LoadDbScriptStrings() std::set ids; for (int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) - if (sObjectMgr.GetTrinityStringLocale(i)) + if (sObjectMgr.GetHellgroundStringLocale(i)) ids.insert(i); CheckScripts(sQuestEndScripts,ids); @@ -722,6 +734,10 @@ void ScriptMgr::LoadCompletedCinematicScripts() CreatureAI* ScriptMgr::GetCreatureAI(Creature* pCreature) { + // used by eluna + if (CreatureAI* luaAI = sHookMgr->GetAI(pCreature)) + return luaAI; + if (!m_pGetCreatureAI) return NULL; @@ -738,11 +754,26 @@ InstanceData* ScriptMgr::CreateInstanceData(Map* pMap) bool ScriptMgr::OnGossipHello(Player* pPlayer, Creature* pCreature) { + // used by eluna + if (sHookMgr->OnGossipHello(pPlayer, pCreature)) + return true; + return m_pOnGossipHello != NULL && m_pOnGossipHello(pPlayer, pCreature); } bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code) { + if (code) + { + // used by eluna + if (sHookMgr->OnGossipSelectCode(pPlayer, pCreature, sender, action, code)) + return true; + } + else + // used by eluna + if (sHookMgr->OnGossipSelect(pPlayer, pCreature, sender, action)) + return true; + if (code) return m_pOnGossipSelectWithCode != NULL && m_pOnGossipSelectWithCode(pPlayer, pCreature, sender, action, code); else @@ -751,6 +782,17 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 send bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code) { + if (code) + { + // used by eluna + if (sHookMgr->OnGossipSelectCode(pPlayer, pGameObject, sender, action, code)) + return true; + } + else + // used by eluna + if (sHookMgr->OnGossipSelect(pPlayer, pGameObject, sender, action)) + return true; + if (code) return m_pOnGOGossipSelectWithCode != NULL && m_pOnGOGossipSelectWithCode(pPlayer, pGameObject, sender, action, code); else @@ -759,57 +801,96 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 bool ScriptMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest) { + // used by eluna + if (sHookMgr->OnQuestAccept(pPlayer, pCreature, pQuest)) + return true; + return m_pOnQuestAccept != NULL && m_pOnQuestAccept(pPlayer, pCreature, pQuest); } bool ScriptMgr::OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) { + if (sHookMgr->OnQuestAccept(pPlayer, pGameObject, pQuest)) + return true; + return m_pOnGOQuestAccept != NULL && m_pOnGOQuestAccept(pPlayer, pGameObject, pQuest); } bool ScriptMgr::OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest) { + // used by eluna + if(sHookMgr->OnQuestAccept(pPlayer, pItem, pQuest)) + return true; + return m_pOnItemQuestAccept != NULL && m_pOnItemQuestAccept(pPlayer, pItem, pQuest); } bool ScriptMgr::OnQuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest) { + // used by eluna + if (sHookMgr->OnQuestReward(pPlayer, pCreature, pQuest)) + return true; + return m_pOnQuestRewarded != NULL && m_pOnQuestRewarded(pPlayer, pCreature, pQuest); } bool ScriptMgr::OnQuestRewarded(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) { + // used by eluna + if (sHookMgr->OnQuestReward(pPlayer, pGameObject, pQuest)) + return true; + return m_pOnGOQuestRewarded != NULL && m_pOnGOQuestRewarded(pPlayer, pGameObject, pQuest); } uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, Creature* pCreature) { + // used by eluna + if (uint32 dialogId = sHookMgr->GetDialogStatus(pPlayer, pCreature)) + return dialogId; + if (!m_pGetNPCDialogStatus) - return 100; + return DIALOG_STATUS_SCRIPTED_NO_STATUS; return m_pGetNPCDialogStatus(pPlayer, pCreature); } uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, GameObject* pGameObject) { + // used by eluna + if (uint32 dialogId = sHookMgr->GetDialogStatus(pPlayer, pGameObject)) + return dialogId; + if (!m_pGetGODialogStatus) - return 100; + return DIALOG_STATUS_SCRIPTED_NO_STATUS; return m_pGetGODialogStatus(pPlayer, pGameObject); } bool ScriptMgr::OnGameObjectUse(Player* pPlayer, GameObject* pGameObject) { + // used by eluna + if (sHookMgr->OnGameObjectUse(pPlayer, pGameObject)) + return true; + return m_pOnGOUse != NULL && m_pOnGOUse(pPlayer, pGameObject); } bool ScriptMgr::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets) { + // used by eluna + if(sHookMgr->OnUse(pPlayer, pItem, targets)) + return true; + return m_pOnItemUse != NULL && m_pOnItemUse(pPlayer, pItem, targets); } bool ScriptMgr::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry) { + // used by eluna + if(sHookMgr->OnAreaTrigger(pPlayer, atEntry)) + return true; + return m_pOnAreaTrigger != NULL && m_pOnAreaTrigger(pPlayer, atEntry); } @@ -825,16 +906,28 @@ bool ScriptMgr::OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget, bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, uint32 effIndex, Creature* pTarget) { + // used by eluna + if(sHookMgr->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) + return true; + return m_pOnEffectDummyCreature != NULL && m_pOnEffectDummyCreature(pCaster, spellId, effIndex, pTarget); } bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, uint32 effIndex, GameObject* pTarget) { + // used by eluna + if(sHookMgr->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) + return true; + return m_pOnEffectDummyGO != NULL && m_pOnEffectDummyGO(pCaster, spellId, effIndex, pTarget); } bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, uint32 effIndex, Item* pTarget) { + // used by eluna + if(sHookMgr->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) + return true; + return m_pOnEffectDummyItem != NULL && m_pOnEffectDummyItem(pCaster, spellId, effIndex, pTarget); } diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h index 4e4f5e4dd..2a8507d1a 100644 --- a/src/game/ScriptMgr.h +++ b/src/game/ScriptMgr.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _SCRIPTMGR_H -#define _SCRIPTMGR_H +#ifndef HELLGROUND_SCRIPTMGR_H +#define HELLGROUND_SCRIPTMGR_H #include "ace/Singleton.h" diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 160ed3f8d..7c5a106d7 100755 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -309,7 +309,7 @@ enum SpellCategory #define SPELL_ATTR_EX2_UNK0 0x00000001 // 0 #define SPELL_ATTR_EX2_UNK1 0x00000002 // 1 ? many triggered spells have this flag #define SPELL_ATTR_EX2_IGNORE_LOS 0x00000004 // 2 used to detect when ever spell can ignore los check -#define SPELL_ATTR_EX2_UNK3 0x00000008 // 3 +#define SPELL_ATTR_EX2_UNK3 0x00000008 // 3 mostly used in shamans' elemental weapons & rogue poisons (sth like "my weapon enchant only") #define SPELL_ATTR_EX2_DISPLAY_IN_STANCE_BAR 0x00000010 // 4 client displays icon in stance bar when learned, even if not shapeshift #define SPELL_ATTR_EX2_AUTOREPEAT_FLAG 0x00000020 // 5 #define SPELL_ATTR_EX2_CANT_TARGET_TAPPED 0x00000040 // 6 target must be tapped by caster @@ -319,14 +319,14 @@ enum SpellCategory #define SPELL_ATTR_EX2_UNK10 0x00000400 // 10 #define SPELL_ATTR_EX2_HEALTH_FUNNEL 0x00000800 // 11 #define SPELL_ATTR_EX2_UNK12 0x00001000 // 12 -#define SPELL_ATTR_EX2_UNK13 0x00002000 // 13 +#define SPELL_ATTR_EX2_NOT_USABLE_VIA_TRADE 0x00002000 // 13 enchants that cannot be done via trade window (plus disenchanting and prospecting) #define SPELL_ATTR_EX2_UNK14 0x00004000 // 14 #define SPELL_ATTR_EX2_UNK15 0x00008000 // 15 not set in 2.4.2 #define SPELL_ATTR_EX2_TAME_BEAST 0x00010000 // 16 #define SPELL_ATTR_EX2_NOT_RESET_AUTOSHOT 0x00020000 // 17 Hunters Shot and Stings only have this flag #define SPELL_ATTR_EX2_UNK18 0x00040000 // 18 Only Revive pet - possible req dead pet #define SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT 0x00080000 // 19 does not necessarly need shapeshift -#define SPELL_ATTR_EX2_UNK20 0x00100000 // 20 +#define SPELL_ATTR_EX2_FROM_BEHIND 0x00100000 // 20 must be behind target #define SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD 0x00200000 // 21 for ice blocks, pala immunity buffs, priest absorb shields, but used also for other spells -> not sure! #define SPELL_ATTR_EX2_UNK22 0x00400000 // 22 #define SPELL_ATTR_EX2_UNK23 0x00800000 // 23 Only mage Arcane Concentration have this flag @@ -350,7 +350,7 @@ enum SpellCategory #define SPELL_ATTR_EX3_PLAYERS_ONLY 0x00000100 // 8 Player only? #define SPELL_ATTR_EX3_TRIGGERED_CAN_TRIGGER_2 0x00000200 // 9 triggered from effect? #define SPELL_ATTR_EX3_MAIN_HAND 0x00000400 // 10 Main hand weapon required -#define SPELL_ATTR_EX3_BATTLEGROUND 0x00000800 // 11 Can casted only on battleground +#define SPELL_ATTR_EX3_BATTLEGROUND 0x00000800 // 11 Can cast only on battleground #define SPELL_ATTR_EX3_CAST_ON_DEAD 0x00001000 // 12 target is a dead player (not every spell has this flag) #define SPELL_ATTR_EX3_UNK13 0x00002000 // 13 #define SPELL_ATTR_EX3_UNK14 0x00004000 // 14 "Honorless Target" only this spells have this flag @@ -664,7 +664,7 @@ enum SpellEffects SPELL_EFFECT_SUMMON_OBJECT_SLOT3 = 106, SPELL_EFFECT_SUMMON_OBJECT_SLOT4 = 107, SPELL_EFFECT_DISPEL_MECHANIC = 108, - SPELL_EFFECT_SUMMON_DEAD_PET = 109, + SPELL_EFFECT_RESURRECT_PET = 109, SPELL_EFFECT_DESTROY_ALL_TOTEMS = 110, SPELL_EFFECT_DURABILITY_DAMAGE = 111, SPELL_EFFECT_SUMMON_DEMON = 112, @@ -700,14 +700,14 @@ enum SpellEffects SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE = 142, SPELL_EFFECT_APPLY_AREA_AURA_OWNER = 143, SPELL_EFFECT_KNOCK_BACK_2 = 144, - SPELL_EFFECT_145 = 145, + SPELL_EFFECT_SUSPEND_GRAVITY = 145, SPELL_EFFECT_146 = 146, SPELL_EFFECT_QUEST_FAIL = 147, SPELL_EFFECT_148 = 148, SPELL_EFFECT_CHARGE2 = 149, SPELL_EFFECT_150 = 150, SPELL_EFFECT_TRIGGER_SPELL_2 = 151, - SPELL_EFFECT_152 = 152, + SPELL_EFFECT_FRIEND_SUMMON = 152, SPELL_EFFECT_153 = 153, TOTAL_SPELL_EFFECTS = 154 }; @@ -2185,12 +2185,14 @@ enum TotemCategory enum UnitDynFlags { + UNIT_DYNFLAG_NONE = 0x0000, UNIT_DYNFLAG_LOOTABLE = 0x0001, UNIT_DYNFLAG_TRACK_UNIT = 0x0002, UNIT_DYNFLAG_OTHER_TAGGER = 0x0004, UNIT_DYNFLAG_ROOTED = 0x0008, UNIT_DYNFLAG_SPECIALINFO = 0x0010, - UNIT_DYNFLAG_DEAD = 0x0020 + UNIT_DYNFLAG_DEAD = 0x0020, + UNIT_DYNFLAG_REFER_A_FRIEND = 0x0040, }; enum CorpseDynFlags @@ -2261,8 +2263,8 @@ enum ChatMsg CHAT_MSG_BG_SYSTEM_HORDE = 0x26, CHAT_MSG_RAID_LEADER = 0x27, CHAT_MSG_RAID_WARNING = 0x28, - CHAT_MSG_RAID_BOSS_WHISPER = 0x29, - CHAT_MSG_RAID_BOSS_EMOTE = 0x2A, + CHAT_MSG_RAID_BOSS_EMOTE = 0x29, + CHAT_MSG_RAID_BOSS_WHISPER = 0x2A, CHAT_MSG_FILTERED = 0x2B, CHAT_MSG_BATTLEGROUND = 0x2C, CHAT_MSG_BATTLEGROUND_LEADER = 0x2D, @@ -2322,7 +2324,7 @@ enum DiminishingGroup DIMINISHING_CONTROL_STUN, // Player Controlled stuns DIMINISHING_TRIGGER_STUN, // By aura proced stuns, usualy chance on hit talents DIMINISHING_SLEEP, - DIMINISHING_CONTROL_ROOT, // Immobilizing effects from casted spells + DIMINISHING_CONTROL_ROOT, // Immobilizing effects from cast spells DIMINISHING_TRIGGER_ROOT, // Immobilizing effects from triggered spells like Frostbite DIMINISHING_FEAR, // Non-warlock fears DIMINISHING_CHARM, diff --git a/src/game/SkillDiscovery.cpp b/src/game/SkillDiscovery.cpp index a19724668..a371094c9 100755 --- a/src/game/SkillDiscovery.cpp +++ b/src/game/SkillDiscovery.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -138,7 +138,7 @@ uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player) { for (SkillDiscoveryList::iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) { - if (roll_chance_f(item_iter->chance * sWorld.getRate(RATE_SKILL_DISCOVERY)) + if (roll_chance_f(item_iter->chance * sWorld.getConfig(RATE_SKILL_DISCOVERY)) && !player->HasSpell(item_iter->spellId)) return item_iter->spellId; } @@ -152,7 +152,7 @@ uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player) { for (SkillDiscoveryList::iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) { - if (roll_chance_f(item_iter->chance * sWorld.getRate(RATE_SKILL_DISCOVERY)) + if (roll_chance_f(item_iter->chance * sWorld.getConfig(RATE_SKILL_DISCOVERY)) && !player->HasSpell(item_iter->spellId)) return item_iter->spellId; } diff --git a/src/game/SkillDiscovery.h b/src/game/SkillDiscovery.h index 02d334e4a..b6f84886c 100755 --- a/src/game/SkillDiscovery.h +++ b/src/game/SkillDiscovery.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/SkillExtraItems.cpp b/src/game/SkillExtraItems.cpp index 81c4a481c..4d891535b 100755 --- a/src/game/SkillExtraItems.cpp +++ b/src/game/SkillExtraItems.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/SkillExtraItems.h b/src/game/SkillExtraItems.h index 358b1ad32..7cba2c492 100755 --- a/src/game/SkillExtraItems.h +++ b/src/game/SkillExtraItems.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 3b53c4e4b..c3492b43a 100755 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ #include "ObjectAccessor.h" #include "UpdateMask.h" #include "SpellAuras.h" +#include "luaengine/HookMgr.h" void WorldSession::HandleLearnTalentOpcode(WorldPacket & recv_data) { diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index bcf558175..1af5cd26d 100755 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -173,7 +173,7 @@ bool PlayerSocial::HasIgnore(uint32 ignore_guid) SocialMgr::SocialMgr() { - + canWhisperToGMList.clear(); } SocialMgr::~SocialMgr() @@ -203,9 +203,8 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &fri return; uint32 team = player->GetTeam(); - uint64 security = player->GetSession()->GetPermissions(); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); - bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || security & PERM_GMT; + bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || player->GetSession()->HasPermissions(PERM_GMT_HDEV); PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID); if (itr != player->GetSocial()->m_playerSocialMap.end()) @@ -214,17 +213,16 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &fri // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all if (pFriend && pFriend->GetName() && - (security & PERM_GMT || + (player->GetSession()->HasPermissions(PERM_GMT_HDEV) || (pFriend->GetTeam() == team || allowTwoSideWhoList) && - (!(pFriend->GetSession()->GetPermissions() & PERM_GMT) || gmInWhoList && pFriend->IsVisibleGloballyfor (player)))) + (!pFriend->GetSession()->HasPermissions(PERM_GMT) || gmInWhoList && pFriend->IsVisibleGloballyfor (player)))) { - friendInfo.Status = FRIEND_STATUS_ONLINE; + friendInfo.Status = FriendStatus(friendInfo.Status | FRIEND_STATUS_ONLINE); - if (pFriend->isAFK()) - friendInfo.Status = FRIEND_STATUS_AFK; + pFriend->isAFK() ? friendInfo.Status = FriendStatus(friendInfo.Status | FRIEND_STATUS_AFK) : friendInfo.Status = FriendStatus(friendInfo.Status & ~FRIEND_STATUS_AFK); + pFriend->isDND() ? friendInfo.Status = FriendStatus(friendInfo.Status | FRIEND_STATUS_DND) : friendInfo.Status = FriendStatus(friendInfo.Status & ~FRIEND_STATUS_DND); + pFriend->IsReferAFriendLinked(player) ? friendInfo.Status = FriendStatus(friendInfo.Status | FRIEND_STATUS_RAF) : friendInfo.Status = FriendStatus(friendInfo.Status & ~FRIEND_STATUS_RAF); - if (pFriend->isDND()) - friendInfo.Status = FRIEND_STATUS_DND; friendInfo.Area = pFriend->GetCachedZone(); @@ -282,7 +280,6 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet) return; uint32 team = player->GetTeam(); - uint64 security = player->GetSession()->GetPermissions(); uint32 guid = player->GetGUIDLow(); bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); @@ -297,9 +294,9 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet) // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all if (pFriend && pFriend->IsInWorld() && - (pFriend->GetSession()->GetPermissions() & PERM_GMT || + (pFriend->GetSession()->HasPermissions(PERM_GMT_HDEV) || (pFriend->GetTeam() == team || allowTwoSideWhoList) && - (!(security & PERM_GMT) || gmInWhoList && player->IsVisibleGloballyfor (pFriend)))) + (!player->GetSession()->HasPermissions(PERM_GMT) || gmInWhoList && player->IsVisibleGloballyfor (pFriend)))) { pFriend->SendPacketToSelf(packet); } diff --git a/src/game/SocialMgr.h b/src/game/SocialMgr.h index c9a498aed..4e5b8e7b6 100755 --- a/src/game/SocialMgr.h +++ b/src/game/SocialMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __HELLGROUND_SOCIALMGR_H -#define __HELLGROUND_SOCIALMGR_H +#ifndef HELLGROUND_SOCIALMGR_H +#define HELLGROUND_SOCIALMGR_H #include "ace/Singleton.h" @@ -33,11 +33,11 @@ class WorldPacket; enum FriendStatus { - FRIEND_STATUS_OFFLINE = 0, - FRIEND_STATUS_ONLINE = 1, - FRIEND_STATUS_AFK = 2, - FRIEND_STATUS_UNK3 = 3, - FRIEND_STATUS_DND = 4 + FRIEND_STATUS_OFFLINE = 0x00, + FRIEND_STATUS_ONLINE = 0x01, + FRIEND_STATUS_AFK = 0x02, + FRIEND_STATUS_DND = 0x04, + FRIEND_STATUS_RAF = 0x08, }; enum SocialFlag @@ -154,6 +154,8 @@ class SocialMgr void BroadcastToFriendListers(Player *player, WorldPacket *packet); // Loading PlayerSocial *LoadFromDB(QueryResultAutoPtr result, uint32 guid); + + std::list canWhisperToGMList; private: SocialMap m_socialMap; }; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 775bf30dd..11a16b265 100755 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -51,6 +51,7 @@ #include "TemporarySummon.h" #include "PetAI.h" #include "MovementGenerator.h" +#include "luaengine/HookMgr.h" #define SPELL_CHANNEL_UPDATE_INTERVAL 1000 @@ -156,6 +157,7 @@ void SpellCastTargets::setItemTarget(Item* item) void SpellCastTargets::setCorpseTarget(Corpse* corpse) { m_CorpseTargetGUID = corpse->GetGUID(); + m_corpseTarget = corpse; } void SpellCastTargets::Update(Unit* caster) @@ -284,14 +286,14 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin m_destroyed = false; m_applyMultiplierMask = 0; - + m_procCastEnd = 0; m_spellSchoolMask = SpellMgr::GetSpellSchoolMask(info); // Can be override for some spell (wand shoot for example) // Get data for type of attack - switch (GetSpellInfo()->DmgClass) + switch (GetSpellEntry()->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: - if (GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) + if (GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) m_attackType = OFF_ATTACK; else m_attackType = BASE_ATTACK; @@ -301,7 +303,7 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin break; default: // Wands - if (GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) + if (GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) { m_attackType = RANGED_ATTACK; if (m_caster->getClassMask() & CLASSMASK_WAND_USERS && m_caster->GetTypeId()==TYPEID_PLAYER) @@ -334,7 +336,7 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin m_currentBasePoints[i] = m_spellValue->EffectBasePoints[i]; m_TriggerSpells.clear(); - m_IsTriggeredSpell = GetSpellInfo()->AttributesEx4 & SPELL_ATTR_EX4_FORCE_TRIGGERED || triggered; + m_IsTriggeredSpell = GetSpellEntry()->AttributesEx4 & SPELL_ATTR_EX4_FORCE_TRIGGERED || triggered; //m_AreaAura = false; m_CastItem = NULL; m_castItemGUID = 0; @@ -347,7 +349,7 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin m_triggeredByAuraSpell = NULL; //Auto Shot & Shoot - if (GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG && !triggered) + if (GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG && !triggered) m_autoRepeat = true; else m_autoRepeat = false; @@ -359,9 +361,9 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin m_needAliveTargetMask = 0; // determine reflection - m_canReflect = GetSpellInfo()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(GetSpellInfo()->Attributes & SPELL_ATTR_ABILITY) - && !(GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_CANT_BE_REFLECTED) && !(GetSpellInfo()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) - && !SpellMgr::IsPassiveSpell(GetSpellInfo()) && !SpellMgr::IsPositiveSpell(GetSpellInfo()->Id); + m_canReflect = GetSpellEntry()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(GetSpellEntry()->Attributes & SPELL_ATTR_ABILITY) + && !(GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_CANT_BE_REFLECTED) && !(GetSpellEntry()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) + && !SpellMgr::IsPassiveSpell(GetSpellEntry()) && !SpellMgr::IsPositiveSpell(GetSpellEntry()->Id); CleanupTargetList(); } @@ -378,17 +380,17 @@ void Spell::FillTargetMap() { // not call for empty effect. // Also some spells use not used effect targets for store targets for dummy effect in triggered spells - if (!GetSpellInfo()->Effect[i]) + if (!GetSpellEntry()->Effect[i]) continue; - uint32 effectTargetType = sSpellMgr.EffectTargetType[GetSpellInfo()->Effect[i]]; + uint32 effectTargetType = sSpellMgr.EffectTargetType[GetSpellEntry()->Effect[i]]; // is it possible that areaaura is not applied to caster? if (effectTargetType == SPELL_REQUIRE_NONE) continue; - uint32 targetA = GetSpellInfo()->EffectImplicitTargetA[i]; - uint32 targetB = GetSpellInfo()->EffectImplicitTargetB[i]; + uint32 targetA = GetSpellEntry()->EffectImplicitTargetA[i]; + uint32 targetB = GetSpellEntry()->EffectImplicitTargetB[i]; if (targetA) SetTargetMap(i, targetA); @@ -412,16 +414,16 @@ void Spell::FillTargetMap() { // add here custom effects that need default target. // FOR EVERY TARGET TYPE THERE IS A DIFFERENT FILL!! - switch (GetSpellInfo()->Effect[i]) + switch (GetSpellEntry()->Effect[i]) { case SPELL_EFFECT_DUMMY: { - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 20577: // Cannibalize { // non-standard target selection - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex); + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex); float max_range = SpellMgr::GetSpellMaxRange(srange); WorldObject* result = NULL; @@ -465,7 +467,7 @@ void Spell::FillTargetMap() else { if (m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellCooldown(GetSpellInfo()->Id, true); + ((Player*)m_caster)->RemoveSpellCooldown(GetSpellEntry()->Id, true); SendCastResult(SPELL_FAILED_NO_EDIBLE_CORPSES); finish(false); @@ -479,7 +481,6 @@ void Spell::FillTargetMap() } break; } - case SPELL_EFFECT_RESURRECT: case SPELL_EFFECT_CREATE_ITEM: case SPELL_EFFECT_TRIGGER_SPELL: case SPELL_EFFECT_SKILL_STEP: @@ -496,24 +497,20 @@ void Spell::FillTargetMap() if (m_targets.getUnitTarget()) AddUnitTarget(m_targets.getUnitTarget(), i); break; + case SPELL_EFFECT_RESURRECT: case SPELL_EFFECT_RESURRECT_NEW: if (m_targets.getUnitTarget()) AddUnitTarget(m_targets.getUnitTarget(), i); if (m_targets.getCorpseTargetGUID()) - { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); - if (corpse) - { - Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); - if (owner) + if (Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID())) + if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID())) AddUnitTarget(owner, i); - } - } break; case SPELL_EFFECT_SUMMON_CHANGE_ITEM: case SPELL_EFFECT_ADD_FARSIGHT: case SPELL_EFFECT_STUCK: case SPELL_EFFECT_DESTROY_ALL_TOTEMS: + case SPELL_EFFECT_FRIEND_SUMMON: AddUnitTarget(m_caster, i); break; case SPELL_EFFECT_LEARN_PET_SPELL: @@ -529,7 +526,7 @@ void Spell::FillTargetMap() AddItemTarget(m_targets.getItemTarget(), i); break;*/ case SPELL_EFFECT_APPLY_AURA: - switch (GetSpellInfo()->EffectApplyAuraName[i]) + switch (GetSpellEntry()->EffectApplyAuraName[i]) { case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_UNIT_CASTER(1) (and present for other ranks for same spell for example) case SPELL_AURA_ADD_PCT_MODIFIER: @@ -541,31 +538,23 @@ void Spell::FillTargetMap() break; case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: // AreaAura - if (GetSpellInfo()->Attributes == 0x9050000 || GetSpellInfo()->Attributes == 0x10000) + if (GetSpellEntry()->Attributes == 0x9050000 || GetSpellEntry()->Attributes == 0x10000) SetTargetMap(i, TARGET_UNIT_PARTY_TARGET); break; case SPELL_EFFECT_SKIN_PLAYER_CORPSE: if (m_targets.getUnitTarget()) - { AddUnitTarget(m_targets.getUnitTarget(), i); - } else if (m_targets.getCorpseTargetGUID()) - { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); - if (corpse) - { - Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); - if (owner) + if (Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID())) + if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID())) AddUnitTarget(owner, i); - } - } break; default: break; } } - if (SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (SpellMgr::IsChanneledSpell(GetSpellEntry())) { uint8 mask = (1<::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) @@ -584,13 +573,13 @@ void Spell::FillTargetMap() if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { - if (GetSpellInfo()->speed > 0.0f && m_targets.HasDst()) + if (GetSpellEntry()->speed > 0.0f && m_targets.HasDst()) { float dist = m_caster->GetDistance(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ); if (dist < 5.0f) dist = 5.0f; - m_delayMoment = (uint64) floor(dist / GetSpellInfo()->speed * 1000.0f); + m_delayMoment = (uint64) floor(dist / GetSpellEntry()->speed * 1000.0f); } - else if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) + else if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) m_delayMoment = SPELL_FAKE_DELAY; } } @@ -604,22 +593,22 @@ void Spell::prepareDataForTriggerSystem() //========================================================================================== // Fill flag can spell trigger or not - if (!m_IsTriggeredSpell) + if (!IsTriggeredSpell()) m_canTrigger = true; // Normal cast - can trigger else if (!m_triggeredByAuraSpell) m_canTrigger = true; // Triggered from SPELL_EFFECT_TRIGGER_SPELL - can trigger else // Exceptions (some periodic triggers) { m_canTrigger = false; // Triggered spells can`t trigger another - switch (GetSpellInfo()->SpellFamilyName) + switch (GetSpellEntry()->SpellFamilyName) { case SPELLFAMILY_MAGE: // Arcane Missles / Blizzard triggers need do it / Molten Armor proc also - if (GetSpellInfo()->SpellFamilyFlags & 0x0000000000200080LL) m_canTrigger = true; - if (GetSpellInfo()->SpellFamilyFlags & 0x800000000LL) m_canTrigger = true; + if (GetSpellEntry()->SpellFamilyFlags & 0x0000000000200080LL) m_canTrigger = true; + if (GetSpellEntry()->SpellFamilyFlags & 0x800000000LL) m_canTrigger = true; break; case SPELLFAMILY_WARLOCK: // For Hellfire Effect / Rain of Fire / Seed of Corruption triggers need do it - if (GetSpellInfo()->SpellFamilyFlags & 0x0000800000000060LL) m_canTrigger = true; - if (GetSpellInfo()->SpellFamilyFlags & 0x0000008000000060LL) + if (GetSpellEntry()->SpellFamilyFlags & 0x0000800000000060LL) m_canTrigger = true; + if (GetSpellEntry()->SpellFamilyFlags & 0x0000008000000060LL) { m_procAttacker = PROC_FLAG_ON_DO_PERIODIC; m_procVictim = PROC_FLAG_ON_TAKE_PERIODIC; @@ -628,26 +617,26 @@ void Spell::prepareDataForTriggerSystem() } break; case SPELLFAMILY_SHAMAN: - if (GetSpellInfo()->SpellFamilyFlags & 0x800000LL) m_canTrigger = true; // Flurry etc. from WF ATTACK ! + if (GetSpellEntry()->SpellFamilyFlags & 0x800000LL) m_canTrigger = true; // Flurry etc. from WF ATTACK ! break; case SPELLFAMILY_HUNTER: // Hunter Explosive Trap Effect/Immolation Trap Effect/Frost Trap Aura/Snake Trap Effect - if (GetSpellInfo()->SpellFamilyFlags & 0x0000200000000014LL) m_canTrigger = true; + if (GetSpellEntry()->SpellFamilyFlags & 0x0000200000000014LL) m_canTrigger = true; break; case SPELLFAMILY_PALADIN: // For Holy Shock and Seals triggers need do it - if (GetSpellInfo()->SpellFamilyFlags & 0x0001000000200000LL) m_canTrigger = true; // Holy Shock - if (GetSpellInfo()->SpellFamilyFlags & 0x0000040002000000LL) m_canTrigger = true; // Seal of Command & Seal of Blood + if (GetSpellEntry()->SpellFamilyFlags & 0x0001000000200000LL) m_canTrigger = true; // Holy Shock + if (GetSpellEntry()->SpellFamilyFlags & 0x0000040002000000LL) m_canTrigger = true; // Seal of Command & Seal of Blood break; case SPELLFAMILY_ROGUE: // mutilate mainhand + offhand - if (GetSpellInfo()->SpellFamilyFlags & 0x600000000LL) m_canTrigger = true; + if (GetSpellEntry()->SpellFamilyFlags & 0x600000000LL) m_canTrigger = true; break; } } - if (m_CastItem && GetSpellInfo()->SpellFamilyName != SPELLFAMILY_POTION) + if (m_CastItem && GetSpellEntry()->SpellFamilyName != SPELLFAMILY_POTION) m_canTrigger = false; // Do not trigger from item cast spell(except potions) // Get data for type of attack and fill base info for trigger - switch (GetSpellInfo()->DmgClass) + switch (GetSpellEntry()->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: m_procAttacker = PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT; @@ -672,7 +661,7 @@ void Spell::prepareDataForTriggerSystem() m_procCastEnd = PROC_FLAG_DELAYED_RANGED_SPELL_CAST_END; break; default: - if (SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) // Check for positive spell + if (SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) // Check for positive spell { m_procAttacker = PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL; m_procVictim = PROC_FLAG_TAKEN_POSITIVE_SPELL; @@ -680,7 +669,7 @@ void Spell::prepareDataForTriggerSystem() if (IsDelayedSpell()) m_procCastEnd = PROC_FLAG_DELAYED_POSITIVE_SPELL_CAST_END; } - else if (GetSpellInfo()->Id == 5019) // Wands + else if (GetSpellEntry()->Id == 5019) // Wands { m_procAttacker = PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT; m_procVictim = PROC_FLAG_TAKEN_RANGED_SPELL_HIT; @@ -696,15 +685,15 @@ void Spell::prepareDataForTriggerSystem() break; } - if (m_IsTriggeredSpell && GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_TRIGGERED_CAN_TRIGGER) + if (IsTriggeredSpell() && GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_TRIGGERED_CAN_TRIGGER) m_canTrigger = true; - if (GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_CANT_TRIGGER_PROC) + if (GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_CANT_TRIGGER_PROC) m_canTrigger = false; // Hunter traps spells (for Entrapment trigger) // Gives your Immolation Trap, Frost Trap, Explosive Trap, and Snake Trap .... - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellInfo()->SpellFamilyFlags & 0x0000200000000014LL) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellEntry()->SpellFamilyFlags & 0x0000200000000014LL) m_procAttacker |= PROC_FLAG_ON_TRAP_ACTIVATION; } @@ -726,7 +715,7 @@ void Spell::CleanupTargetList() void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool redirected) { - if (GetSpellInfo()->Effect[effIndex]==0) + if (GetSpellEntry()->Effect[effIndex]==0) return; if (!redirected && !CheckTarget(pVictim, effIndex)) @@ -761,8 +750,8 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool redirected) // Calculate hit result if (m_originalCaster) { - bool canMiss = (m_triggeredByAuraSpell || !m_IsTriggeredSpell); - target.missCondition = m_originalCaster->SpellHitResult(pVictim, GetSpellInfo(), m_canReflect, canMiss); + bool canMiss = m_triggeredByAuraSpell || !IsTriggeredSpell() || IsAutoShootSpell(); + target.missCondition = m_originalCaster->SpellHitResult(pVictim, GetSpellEntry(), m_canReflect, canMiss); if (m_skipCheck && target.missCondition != SPELL_MISS_IMMUNE) target.missCondition = SPELL_MISS_NONE; } @@ -775,7 +764,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool redirected) ++m_countOfMiss; // Spell have speed - need calculate incoming time - if (GetSpellInfo()->speed > 0.0f) + if (GetSpellEntry()->speed > 0.0f) { // calculate spell incoming interval // TODO: this is a hack @@ -784,13 +773,13 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool redirected) if (dist < 5.0f) dist = 5.0f; - target.timeDelay = (uint64) floor(dist / GetSpellInfo()->speed * 1000.0f); + target.timeDelay = (uint64) floor(dist / GetSpellEntry()->speed * 1000.0f); // Calculate minimum incoming time if (m_delayMoment == 0 || m_delayMoment>target.timeDelay) m_delayMoment = target.timeDelay; } - else if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) + else if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) { target.timeDelay = SPELL_FAKE_DELAY; m_delayMoment = target.timeDelay; @@ -802,7 +791,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool redirected) if (target.missCondition == SPELL_MISS_REFLECT) { // Calculate reflected spell result on caster - target.reflectResult = m_caster->SpellHitResult(m_caster, GetSpellInfo(), m_canReflect); + target.reflectResult = m_caster->SpellHitResult(m_caster, GetSpellEntry(), m_canReflect); if (target.reflectResult == SPELL_MISS_REFLECT) // Impossible reflect again, so simply deflect spell target.reflectResult = SPELL_MISS_PARRY; @@ -826,7 +815,7 @@ void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) { - if (GetSpellInfo()->Effect[effIndex]==0) + if (GetSpellEntry()->Effect[effIndex]==0) return; uint64 targetGUID = pVictim->GetGUID(); @@ -852,16 +841,16 @@ void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) target.deleted = false; // Spell have speed - need calculate incoming time - if (GetSpellInfo()->speed > 0.0f) + if (GetSpellEntry()->speed > 0.0f) { // calculate spell incoming interval float dist = m_caster->GetDistance(pVictim->GetPositionX(), pVictim->GetPositionY(), pVictim->GetPositionZ()); if (dist < 5.0f) dist = 5.0f; - target.timeDelay = (uint64) floor(dist / GetSpellInfo()->speed * 1000.0f); + target.timeDelay = (uint64) floor(dist / GetSpellEntry()->speed * 1000.0f); if (m_delayMoment==0 || m_delayMoment>target.timeDelay) m_delayMoment = target.timeDelay; } - else if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) + else if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY) { target.timeDelay = SPELL_FAKE_DELAY; m_delayMoment = target.timeDelay; @@ -884,7 +873,7 @@ void Spell::AddGOTarget(uint64 goGUID, uint32 effIndex) void Spell::AddItemTarget(Item* pitem, uint32 effIndex) { - if (GetSpellInfo()->Effect[effIndex]==0) + if (GetSpellEntry()->Effect[effIndex]==0) return; // Lookup target in already in list @@ -908,7 +897,7 @@ void Spell::AddItemTarget(Item* pitem, uint32 effIndex) void Spell::DoAllEffectOnTarget(TargetInfo *target) { // useless? nie da rady wycastowac spella ktory nie jest w spell.dbc - if (GetSpellInfo()->Id > MAX_SPELL_ID) + if (GetSpellEntry()->Id > MAX_SPELL_ID) return; if (!target || target == (TargetInfo*)0x10 || target->processed) // Check target @@ -952,8 +941,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) else if (missInfo == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) { // drop reflect aura charges on spell_hit - caster->ProcDamageAndSpell(unit, PROC_FLAG_NONE, PROC_FLAG_TAKEN_NEGATIVE_SPELL_HIT, PROC_EX_REFLECT, 1, BASE_ATTACK,GetSpellInfo()); - if (target->reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him + caster->ProcDamageAndSpell(unit, PROC_FLAG_NONE, PROC_FLAG_TAKEN_NEGATIVE_SPELL_HIT, PROC_EX_REFLECT, 1, BASE_ATTACK,GetSpellEntry()); + if (target->reflectResult == SPELL_MISS_NONE && CheckTargetCreatureType(m_caster)) // If reflected spell hit caster -> do all effect on him, also check type again DoSpellHitOnUnit(m_caster, mask); } @@ -961,28 +950,28 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Do healing and triggers if (m_healing > 0) { - bool crit = caster->isSpellCrit(NULL, GetSpellInfo(), m_spellSchoolMask); + bool crit = caster->isSpellCrit(NULL, GetSpellEntry(), m_spellSchoolMask); uint32 addhealth = m_healing; if (crit) { procEx |= PROC_EX_CRITICAL_HIT; - addhealth = caster->SpellCriticalBonus(GetSpellInfo(), addhealth, NULL); + addhealth = caster->SpellCriticalBonus(GetSpellEntry(), addhealth, NULL); } else procEx |= PROC_EX_NORMAL_HIT; procEx |= PROC_EX_DAMAGE_OR_HEAL; - caster->SendHealSpellLog(unitTarget, GetSpellInfo()->Id, addhealth, crit); + caster->SendHealSpellLog(unitTarget, GetSpellEntry()->Id, addhealth, crit); // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) if (missInfo != SPELL_MISS_REFLECT) - caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, GetSpellInfo(), m_canTrigger); + caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, addhealth, m_attackType, GetSpellEntry(), m_canTrigger); int32 gain = unitTarget->ModifyHealth(int32(addhealth)); float threat = gain * 0.5f; - SpellMgr::ApplySpellThreatModifiers(GetSpellInfo(), threat); - unitTarget->getHostilRefManager().threatAssist(caster, threat, GetSpellInfo()); + SpellMgr::ApplySpellThreatModifiers(GetSpellEntry(), threat); + unitTarget->getHostileRefManager().threatAssist(caster, threat, GetSpellEntry()); if (caster->GetTypeId()==TYPEID_PLAYER) if (BattleGround *bg = ((Player*)caster)->GetBattleGround()) @@ -992,10 +981,10 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) else if (m_damage > 0) { // Fill base damage struct (unitTarget - is real spell target) - SpellDamageLog damageInfo(GetSpellInfo()->Id, caster, unitTarget, m_spellSchoolMask); + SpellDamageLog damageInfo(GetSpellEntry()->Id, caster, unitTarget, m_spellSchoolMask); // Add bonuses and fill damageInfo struct - caster->CalculateSpellDamageTaken(&damageInfo, m_damage, GetSpellInfo(), m_attackType, target->crit); + caster->CalculateSpellDamageTaken(&damageInfo, m_damage, GetSpellEntry(), m_attackType, target->crit); // Send log damage message to client // caster->SendSpellNonMeleeDamageLog(&damageInfo); @@ -1008,6 +997,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) if (damageInfo.absorb) procEx &= ~PROC_EX_DIRECT_DAMAGE; + else + procEx |= PROC_EX_DIRECT_DAMAGE; if (missInfo == SPELL_MISS_REFLECT) damageInfo.threatTarget = unit->GetGUID(); @@ -1017,29 +1008,29 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) if (missInfo != SPELL_MISS_REFLECT) { - caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, GetSpellInfo(), m_canTrigger); + caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, GetSpellEntry(), m_canTrigger); if (caster->GetTypeId() == TYPEID_PLAYER && !((Player *)caster)->IsInFeralForm(true)) - ((Player *)caster)->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx, GetSpellInfo()); + ((Player *)caster)->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx, GetSpellEntry()); } // Shadow Word: Death - deals damage equal to damage done to caster if victim is not killed - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST && GetSpellInfo()->SpellFamilyFlags&0x0000000200000000LL && + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_PRIEST && GetSpellEntry()->SpellFamilyFlags&0x0000000200000000LL && caster != unitTarget && unitTarget->isAlive()) { // Redirect damage to caster if victim alive m_caster->CastCustomSpell(m_caster, 32409, &m_damage, NULL, NULL, true); } // Judgement of Blood - else if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PALADIN && GetSpellInfo()->SpellFamilyFlags & 0x0000000800000000LL && GetSpellInfo()->SpellIconID==153) + else if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_PALADIN && GetSpellEntry()->SpellFamilyFlags & 0x0000000800000000LL && GetSpellEntry()->SpellIconID==153) { int32 damagePoint = damageInfo.damage * 33 / 100; m_caster->CastCustomSpell(m_caster, 32220, &damagePoint, NULL, NULL, true); } // Bloodthirst - else if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_WARRIOR && GetSpellInfo()->SpellFamilyFlags & 0x40000000000LL) + else if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_WARRIOR && GetSpellEntry()->SpellFamilyFlags & 0x40000000000LL) { uint32 BTAura = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 23881: BTAura = 23885; break; case 23892: BTAura = 23886; break; @@ -1048,7 +1039,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) case 25251: BTAura = 25252; break; case 30335: BTAura = 30339; break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectSchoolDMG: Spell %u not handled in BTAura",GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectSchoolDMG: Spell %u not handled in BTAura",GetSpellEntry()->Id); break; } if (BTAura) @@ -1059,11 +1050,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) else { // Fill base damage struct (unitTarget - is real spell target) - SpellDamageLog damageInfo(GetSpellInfo()->Id, caster, unitTarget, m_spellSchoolMask); + SpellDamageLog damageInfo(GetSpellEntry()->Id, caster, unitTarget, m_spellSchoolMask); procEx = createProcExtendMask(&damageInfo, missInfo); bool isDamageOrHealSpell = false; for(int i = 0; i < 3; i++) - switch(GetSpellInfo()->EffectApplyAuraName[i]) + switch(GetSpellEntry()->EffectApplyAuraName[i]) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_PERIODIC_LEECH: @@ -1075,24 +1066,25 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) if (missInfo != SPELL_MISS_REFLECT) - caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, GetSpellInfo(), m_canTrigger); + caster->ProcDamageAndSpell(unit, procAttacker, procVictim, procEx, 0, m_attackType, GetSpellEntry(), m_canTrigger); } - // Call scripted function for AI if this spell is casted upon a creature (except pets) + // Call scripted function for AI if this spell is cast upon a creature (except pets) if (unit->GetTypeId() == TYPEID_UNIT) { // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) // ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... ) if (!((Creature*)unit)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive()) if (Player* p = GetPlayerForCastQuestCond()) - p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), GetSpellInfo()->Id); + p->CastCreatureOrGO(unit->GetEntry(), unit->GetGUID(), GetSpellEntry()->Id); } - if (!m_caster->IsFriendlyTo(unit) && !SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + if (!m_caster->IsFriendlyTo(unit) && !SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) { - m_caster->CombatStart(unit, !(GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO)); + if(m_caster->GetTypeId() != TYPEID_PLAYER || !((Player const*)m_caster)->isGameMaster()) + m_caster->CombatStart(unit, !(GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO)); - if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_AURA_CC) + if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_AURA_CC) { if (!unit->IsStandState()) unit->SetStandState(PLAYER_STATE_NONE); @@ -1100,9 +1092,9 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) } // if target is flagged for pvp also flag caster if a player - if (unit->IsPvP()) + if (unit->IsPvP() && m_caster->GetTypeId() == TYPEID_PLAYER && m_caster != unit) { - if ((m_caster->GetTypeId() == TYPEID_PLAYER) && (m_caster != unit)) + if (!((Player*)m_caster)->duel || ((Player*)m_caster)->duel->opponent != unit->GetCharmerOrOwnerPlayerOrPlayerItself()) ((Player*)m_caster)->UpdatePvP(true); } } @@ -1112,23 +1104,20 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if (!unit || !effectMask) return; - for (int i = 0; i < 3; i++) + if (unit->IsImmunedToSpellEffect(SPELL_EFFECT_ATTACK_ME, MECHANIC_NONE) && SpellMgr::IsTauntSpell(GetSpellEntry())) { - if (unit->IsImmunedToSpellEffect(SPELL_EFFECT_ATTACK_ME, MECHANIC_NONE) && GetSpellInfo()->Effect[i] == SPELL_EFFECT_ATTACK_ME) - { - m_caster->SendSpellMiss(unit, GetSpellInfo()->Id, SPELL_MISS_IMMUNE); - return; - } + m_caster->SendSpellMiss(unit, GetSpellEntry()->Id, SPELL_MISS_IMMUNE); + return; } // Recheck immune (only for delayed spells) if (IsDelayedSpell() && - !(GetSpellInfo()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && - (unit->IsImmunedToDamage(SpellMgr::GetSpellSchoolMask(GetSpellInfo()),true) || - unit->IsImmunedToSpell(GetSpellInfo(),true)) + !(GetSpellEntry()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && + (unit->IsImmunedToDamage(SpellMgr::GetSpellSchoolMask(GetSpellEntry()),true) || + unit->IsImmunedToSpell(GetSpellEntry(),true)) ) { - m_caster->SendSpellMiss(unit, GetSpellInfo()->Id, SPELL_MISS_IMMUNE); + m_caster->SendSpellMiss(unit, GetSpellEntry()->Id, SPELL_MISS_IMMUNE); m_damage = 0; return; } @@ -1139,7 +1128,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) { if (unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) { - m_caster->SendSpellMiss(unit, GetSpellInfo()->Id, SPELL_MISS_EVADE); + m_caster->SendSpellMiss(unit, GetSpellEntry()->Id, SPELL_MISS_EVADE); m_damage = 0; return; } @@ -1153,21 +1142,21 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if (IsDelayedSpell() && unit == m_targets.getUnitTarget() && !isVisibleForHit) { // that was causing CombatLog errors - //m_caster->SendSpellMiss(unit, GetSpellInfo()->Id, SPELL_MISS_EVADE); + //m_caster->SendSpellMiss(unit, GetSpellEntry()->Id, SPELL_MISS_EVADE); m_damage = 0; return; } unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); - if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_AURA_CC) + if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_AURA_CC) unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); } else { // for delayed spells ignore negative spells (after duel end) for friendly targets // this cause soul transfer, and curse of boundless agony bugged, for a moment exception added - if (GetSpellInfo()->Id != 45034 && GetSpellInfo()->Id != 30531 && IsDelayedSpell() && unit->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + if (GetSpellEntry()->Id != 45034 && GetSpellEntry()->Id != 30531 && IsDelayedSpell() && unit->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) { - m_caster->SendSpellMiss(unit, GetSpellInfo()->Id, SPELL_MISS_EVADE); + m_caster->SendSpellMiss(unit, GetSpellEntry()->Id, SPELL_MISS_EVADE); m_damage = 0; return; } @@ -1179,23 +1168,23 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) //m_caster->UpdatePvP(true); } - if (unit->isInCombat() && !(GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO)) + if (unit->isInCombat() && !(GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO)) { m_caster->SetInCombatState(unit->GetCombatTimer() > 0, unit); - unit->getHostilRefManager().threatAssist(m_caster, 0.0f); + unit->getHostileRefManager().threatAssist(m_caster, 0.0f); } } } // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add - if (m_diminishGroup = SpellMgr::GetDiminishingReturnsGroupForSpell(GetSpellInfo(), m_triggeredByAuraSpell)) + if (m_diminishGroup = SpellMgr::GetDiminishingReturnsGroupForSpell(GetSpellEntry(), m_triggeredByAuraSpell)) { m_diminishLevel = unit->GetDiminishing(m_diminishGroup); // send immunity message if target is immune if (m_diminishLevel == DIMINISHING_LEVEL_IMMUNE) { - m_caster->SendSpellMiss(unitTarget, GetSpellInfo()->Id, SPELL_MISS_IMMUNE); - if(SpellMgr::IsChanneledSpell(GetSpellInfo())) + m_caster->SendSpellMiss(unitTarget, GetSpellEntry()->Id, SPELL_MISS_IMMUNE); + if(SpellMgr::IsChanneledSpell(GetSpellEntry())) SendChannelStart(0); return; } @@ -1203,15 +1192,15 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) DiminishingReturnsType type = SpellMgr::GetDiminishingReturnsGroupType(m_diminishGroup); // Increase Diminishing on unit, current informations for actually casts will use values above if ((type == DRTYPE_PLAYER && unit->isCharmedOwnedByPlayerOrPlayer()) || type == DRTYPE_ALL) - { // Freezing trap exception, since it is casted by GO ? - if (m_caster->isCharmedOwnedByPlayerOrPlayer() || (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellInfo()->SpellFamilyFlags & 0x00000000008LL)) + { // Freezing trap exception, since it is cast by GO ? + if (m_caster->isCharmedOwnedByPlayerOrPlayer() || (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellEntry()->SpellFamilyFlags & 0x00000000008LL)) unit->IncrDiminishing(m_diminishGroup); } } for (uint32 effectNumber=0;effectNumber<3;effectNumber++) { - if (unit->IsImmunedToSpellEffect(GetSpellInfo()->Effect[effectNumber],GetSpellInfo()->EffectMechanic[effectNumber])) + if (unit->IsImmunedToSpellEffect(GetSpellEntry()->Effect[effectNumber],GetSpellEntry()->EffectMechanic[effectNumber])) continue; if (effectMask & (1<GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->IsAIEnabled) - ((Creature*)unit)->AI()->SpellHit(m_caster, GetSpellInfo()); + ((Creature*)unit)->AI()->SpellHit(m_caster, GetSpellEntry()); if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsAIEnabled) - ((Creature*)m_caster)->AI()->SpellHitTarget(unit, GetSpellInfo()); + ((Creature*)m_caster)->AI()->SpellHitTarget(unit, GetSpellEntry()); // trigger only for first effect targets @@ -1242,7 +1231,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) // get duration from aura-only once if (!_duration) { - Aura * aur = unit->GetAuraByCasterSpell(GetSpellInfo()->Id, m_caster->GetGUID()); + Aura * aur = unit->GetAuraByCasterSpell(GetSpellEntry()->Id, m_caster->GetGUID()); _duration = aur ? aur->GetAuraDuration() : -1; } unit->SetAurasDurationByCasterSpell(i->first->Id, m_caster->GetGUID(), _duration); @@ -1251,9 +1240,9 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) } } - if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_LINK_HIT) + if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_LINK_HIT) { - if (const std::vector *spell_triggered = sSpellMgr.GetSpellLinked(GetSpellInfo()->Id + SPELL_LINK_HIT)) + if (const std::vector *spell_triggered = sSpellMgr.GetSpellLinked(GetSpellEntry()->Id + SPELL_LINK_HIT)) for (std::vector::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i) if (*i < 0) unit->RemoveAurasDueToSpell(-(*i)); @@ -1264,7 +1253,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) void Spell::DoAllEffectOnTarget(GOTargetInfo *target) { - if (this->GetSpellInfo()->Id <= 0 || this->GetSpellInfo()->Id > MAX_SPELL_ID || GetSpellInfo()->Id == 32 || GetSpellInfo()->Id == 80) + if (this->GetSpellEntry()->Id <= 0 || this->GetSpellEntry()->Id > MAX_SPELL_ID || GetSpellEntry()->Id == 32 || GetSpellEntry()->Id == 80) return; if (!target || target == (GOTargetInfo*)0x10 || target->processed) // Check target @@ -1288,7 +1277,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm...) if (!IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive()) if (Player* p = GetPlayerForCastQuestCond()) - p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), GetSpellInfo()->Id); + p->CastCreatureOrGO(go->GetEntry(), go->GetGUID(), GetSpellEntry()->Id); } void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) @@ -1319,7 +1308,7 @@ bool Spell::IsAliveUnitPresentInTargetList() { Unit *unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : m_caster->GetMap()->GetUnit(ihit->targetGUID); - if (unit && (unit->isAlive() != SpellMgr::IsDeathOnlySpell(GetSpellInfo()))) + if (unit && (unit->isAlive() != SpellMgr::IsDeathOnlySpell(GetSpellEntry()))) needAliveTargetMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target } } @@ -1366,7 +1355,7 @@ void Spell::SearchChainTarget(std::list &TagUnitMap, float max_range, uin return; //FIXME: This very like horrible hack and wrong for most spells - if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_MELEE) + if (GetSpellEntry()->DmgClass != SPELL_DAMAGE_CLASS_MELEE) max_range += num * CHAIN_SPELL_JUMP_RADIUS; std::list tempUnitMap; @@ -1391,7 +1380,7 @@ void Spell::SearchChainTarget(std::list &TagUnitMap, float max_range, uin std::list::iterator next; - bool ignoreLOS = SpellMgr::SpellIgnoreLOS(GetSpellInfo(), 0); + bool ignoreLOS = SpellMgr::SpellIgnoreLOS(GetSpellEntry(), 0); if (TargetType == SPELL_TARGETS_CHAINHEAL) { next = tempUnitMap.begin(); @@ -1411,10 +1400,10 @@ void Spell::SearchChainTarget(std::list &TagUnitMap, float max_range, uin if (cur->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) break; - while (GetSpellInfo()->DmgClass == SPELL_DAMAGE_CLASS_MELEE + while (GetSpellEntry()->DmgClass == SPELL_DAMAGE_CLASS_MELEE && !m_caster->isInFront(*next, max_range) || !m_caster->canSeeOrDetect(*next, m_caster, false) - || (GetSpellInfo()->AttributesEx6 & SPELL_ATTR_EX6_CANT_TARGET_CCD && ((*next)->hasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_CC) || (*next)->GetTypeId() == TYPEID_UNIT && ((Creature*)(*next))->GetCreatureType() == CREATURE_TYPE_CRITTER)) + || (GetSpellEntry()->AttributesEx6 & SPELL_ATTR_EX6_CANT_TARGET_CCD && ((*next)->hasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_CC) || (*next)->GetTypeId() == TYPEID_UNIT && ((Creature*)(*next))->GetCreatureType() == CREATURE_TYPE_CRITTER)) || !ignoreLOS && !cur->IsWithinLOSInMap(*next)) { ++next; @@ -1450,7 +1439,7 @@ void Spell::SearchAreaTarget(std::list &TagUnitMap, float radius, const u Unit *target = m_targets.getUnitTarget(); if (!target) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find unit target for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find unit target for spell ID %u\n", GetSpellEntry()->Id); return; } x = target->GetPositionX(); @@ -1471,7 +1460,7 @@ void Spell::SearchAreaTarget(std::list &TagUnitMap, float radius, const u { Hellground::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, type, TargetType, entry, x, y, z); Cell::VisitAllObjects(x, y, m_caster->GetMap(), notifier, radius); - if ((GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY)) + if ((GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY)) TagUnitMap.remove_if(Hellground::ObjectTypeIdCheck(TYPEID_PLAYER, false)); // above line will select also pets and totems, remove them break; } @@ -1522,7 +1511,7 @@ void Spell::SearchAreaTarget(std::list &goList, float radius, const GameObject *target = m_targets.getGOTarget(); if (!target) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find unit target for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find unit target for spell ID %u\n", GetSpellEntry()->Id); return; } x = target->GetPositionX(); @@ -1561,12 +1550,12 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargets TargetType) { case SPELL_TARGETS_ENTRY: { - SpellScriptTarget::const_iterator lower = sSpellMgr.GetBeginSpellScriptTarget(GetSpellInfo()->Id); - SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(GetSpellInfo()->Id); + SpellScriptTarget::const_iterator lower = sSpellMgr.GetBeginSpellScriptTarget(GetSpellEntry()->Id); + SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(GetSpellEntry()->Id); if (lower == upper) { - sLog.outLog(LOG_DB_ERR, "Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", GetSpellInfo()->Id, m_caster->GetEntry()); - if (SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + sLog.outLog(LOG_DB_ERR, "Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", GetSpellEntry()->Id, m_caster->GetEntry()); + if (SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) return SearchNearbyTarget(range, SPELL_TARGETS_ALLY); else return SearchNearbyTarget(range, SPELL_TARGETS_ENEMY); @@ -1677,12 +1666,20 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) case TARGET_UNIT_CASTER_FISHING: { //AddUnitTarget(m_caster, i); - float min_dis = SpellMgr::GetSpellMinRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); - float max_dis = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float min_dis = SpellMgr::GetSpellMinRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); + float max_dis = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); float dis = rand_norm() * (max_dis - min_dis) + min_dis; - float x, y, z; - m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis); - m_targets.setDestination(x, y, z); + Position pos; + m_caster->GetValidPointInAngle(pos, dis+DEFAULT_WORLD_OBJECT_SIZE, frand(-0.6, 0.6), true, false, max_dis); + float liquidLevel = m_caster->GetMap()->GetTerrain()->GetWaterOrGroundLevel(pos.x, pos.y, pos.z); + m_targets.setDestination(pos.x, pos.y, liquidLevel); + if (!m_caster->GetTerrain()->IsInWater(pos.x, pos.y, liquidLevel + 1.f)) + { + SendCastResult(SPELL_FAILED_NOT_HERE); + SendChannelUpdate(0); + finish(false); + return; + } break; } case TARGET_UNIT_MASTER: @@ -1706,7 +1703,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) Unit *target = m_targets.getUnitTarget(); if (!target) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no unit target for spell ID %u", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no unit target for spell ID %u", GetSpellEntry()->Id); break; } @@ -1734,14 +1731,14 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) case TARGET_TYPE_UNIT_NEARBY: { - float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); // limit check range for some spells if(range > 400) range = 400; if (modOwner) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RANGE, range, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RANGE, range, this); WorldObject *target = NULL; @@ -1756,6 +1753,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) target = SearchNearbyTarget(range, SPELL_TARGETS_ALLY); break; case TARGET_UNIT_NEARBY_ENTRY: + case TARGET_OBJECT_USE: target = SearchNearbyTarget(range, SPELL_TARGETS_ENTRY); break; } @@ -1783,9 +1781,9 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) break; case TARGET_TYPE_AREA_CONE: - if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_CONE_BACK) + if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_CONE_BACK) pushType = PUSH_IN_BACK; - else if (GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_CONE_LINE) + else if (GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_CONE_LINE) pushType = PUSH_IN_LINE; else pushType = PUSH_IN_FRONT; @@ -1808,7 +1806,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) float dist; float objSize = m_caster->GetObjectSize(); - dist = SpellMgr::GetSpellRadius(GetSpellInfo(),i,true); + dist = SpellMgr::GetSpellRadius(GetSpellEntry(),i,true); if (dist < objSize) dist = objSize; else if (cur == TARGET_DEST_CASTER_RANDOM) @@ -1839,7 +1837,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) Unit *target = m_targets.getUnitTarget(); if (!target) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no unit target for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no unit target for spell ID %u\n", GetSpellEntry()->Id); break; } @@ -1854,7 +1852,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) float dist; float objSize = target->GetObjectSize(); - dist = SpellMgr::GetSpellRadius(GetSpellInfo(),i,true); + dist = SpellMgr::GetSpellRadius(GetSpellEntry(),i,true); if (dist < objSize) dist = objSize; else if (cur == TARGET_DEST_CASTER_RANDOM) @@ -1882,7 +1880,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) { if (!m_targets.HasDst()) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no destination for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no destination for spell ID %u\n", GetSpellEntry()->Id); break; } @@ -1907,7 +1905,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) } float dist, x, y, z; - dist = SpellMgr::GetSpellRadius(GetSpellInfo(),i,true); + dist = SpellMgr::GetSpellRadius(GetSpellEntry(),i,true); if (cur == TARGET_DEST_DEST_RANDOM) dist *= rand_norm(); @@ -1923,18 +1921,18 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) switch (cur) { case TARGET_DST_DB: - if (SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(GetSpellInfo()->Id)) + if (SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(GetSpellEntry()->Id)) { //TODO: fix this check - if (GetSpellInfo()->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS - || GetSpellInfo()->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS - || GetSpellInfo()->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS) + if (GetSpellEntry()->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS + || GetSpellEntry()->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS + || GetSpellEntry()->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS) m_targets.setDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId); else if (st->target_mapId == m_caster->GetMapId()) m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); } else - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: unknown target coordinates for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: unknown target coordinates for spell ID %u\n", GetSpellEntry()->Id); break; case TARGET_DST_HOME: if (m_caster->GetTypeId() == TYPEID_PLAYER) @@ -1942,9 +1940,9 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) break; case TARGET_DST_NEARBY_ENTRY: { - float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); if (modOwner) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RANGE, range, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RANGE, range, this); WorldObject *target = SearchNearbyTarget(range, SPELL_TARGETS_ENTRY); if (target) @@ -1957,9 +1955,9 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) case TARGET_TYPE_CHANNEL: { - if (GetSpellInfo()->Id != 38700 && !m_originalCaster || !m_originalCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (GetSpellEntry()->Id != 38700 && !m_originalCaster || !m_originalCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]) { - sLog.outDebug("SPELL: no current channeled spell for spell ID %u", GetSpellInfo()->Id); + sLog.outDebug("SPELL: no current channeled spell for spell ID %u", GetSpellEntry()->Id); break; } @@ -1969,13 +1967,13 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) if (Unit* target = m_originalCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->m_targets.getUnitTarget()) AddUnitTarget(target, i); else - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find channel spell target for spell ID %u", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find channel spell target for spell ID %u", GetSpellEntry()->Id); break; case TARGET_DEST_CHANNEL: if (m_originalCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->m_targets.HasDst()) m_targets = m_originalCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->m_targets; else - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find channel spell destination for spell ID %u", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: cannot find channel spell destination for spell ID %u", GetSpellEntry()->Id); break; } break; @@ -1986,7 +1984,6 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) switch (cur) { case TARGET_GAMEOBJECT: - case TARGET_OBJECT_USE: if (m_targets.getGOTarget()) AddGOTarget(m_targets.getGOTarget(), i); break; @@ -2009,14 +2006,14 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) Unit *target = m_targets.getUnitTarget(); if (!target) { - sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no chain unit target for spell ID %u", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: SPELL: no chain unit target for spell ID %u", GetSpellEntry()->Id); return; } //Chain: 2, 6, 22, 25, 45, 77 - uint32 maxTargets = GetSpellInfo()->EffectChainTarget[i]; + uint32 maxTargets = GetSpellEntry()->EffectChainTarget[i]; if (modOwner) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this); if (maxTargets > 1) { @@ -2024,9 +2021,9 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) m_damageMultipliers[i] = 1.0f; m_applyMultiplierMask |= 1 << i; - float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); if (modOwner) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RANGE, range, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RANGE, range, this); std::list unitList; @@ -2054,12 +2051,12 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) else if (pushType) { // Dummy, just for client - if (sSpellMgr.EffectTargetType[GetSpellInfo()->Effect[i]] == SPELL_REQUIRE_DEST) + if (sSpellMgr.EffectTargetType[GetSpellEntry()->Effect[i]] == SPELL_REQUIRE_DEST) return; - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); if (modOwner) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RADIUS, radius, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RADIUS, radius, this); if (radius > MAX_VISIBILITY_DISTANCE) radius = MAX_VISIBILITY_DISTANCE; @@ -2074,7 +2071,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) case TARGET_UNIT_CONE_ENEMY: case TARGET_UNIT_CONE_ENEMY_UNKNOWN: SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENEMY); - radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); break; case TARGET_UNIT_AREA_ALLY_SRC: case TARGET_UNIT_AREA_ALLY_DST: @@ -2092,14 +2089,14 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) case TARGET_UNIT_AREA_ENTRY_DST: case TARGET_UNIT_CONE_ENTRY: // fix me { - SpellScriptTarget::const_iterator lower = sSpellMgr.GetBeginSpellScriptTarget(GetSpellInfo()->Id); - SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(GetSpellInfo()->Id); - radius = SpellMgr::GetSpellRadius(GetSpellInfo(), i, SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)); + SpellScriptTarget::const_iterator lower = sSpellMgr.GetBeginSpellScriptTarget(GetSpellEntry()->Id); + SpellScriptTarget::const_iterator upper = sSpellMgr.GetEndSpellScriptTarget(GetSpellEntry()->Id); + radius = SpellMgr::GetSpellRadius(GetSpellEntry(), i, SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)); if (lower == upper) { - sLog.outLog(LOG_DB_ERR, "Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", GetSpellInfo()->Id, m_caster->GetEntry()); + sLog.outLog(LOG_DB_ERR, "Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", GetSpellEntry()->Id, m_caster->GetEntry()); - if (SpellMgr::IsPositiveEffect(GetSpellInfo()->Id, i)) + if (SpellMgr::IsPositiveEffect(GetSpellEntry()->Id, i)) SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ALLY); else SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENEMY); @@ -2164,14 +2161,14 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) } } - sScriptMgr.OnSpellSetTargetMap(m_caster, unitList, m_targets, GetSpellInfo(), i); + sScriptMgr.OnSpellSetTargetMap(m_caster, unitList, m_targets, GetSpellEntry(), i); if (!unitList.empty()) { - if (GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF) + if (GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF) unitList.remove_if(Hellground::ObjectGUIDCheck(m_caster->GetGUID())); - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 40869: // Fatal Attraction unitList.remove_if(Hellground::UnitAuraCheck(true, 43690)); @@ -2200,8 +2197,12 @@ void Spell::SetTargetMap(uint32 i, uint32 cur) unitList.remove_if(Hellground::UnitAuraCheck(true, 45034)); break; case 41376: // Spite + case 46771: // Flame Sear unitList.remove_if(Hellground::ObjectGUIDCheck(m_caster->getVictimGUID())); break; + case 45248: // Shadow Blades + unitList.remove_if([=](Unit* unit)->bool {return abs(m_caster->GetPositionZ()-unit->GetPositionZ()) > 5.0;}); + break; default: break; } @@ -2245,7 +2246,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); //Prevent casting at cast another spell (ServerSide check) - if (m_caster->IsNonMeleeSpellCasted(false, true) && m_cast_count) + if (m_caster->IsNonMeleeSpellCast(false, true) && m_cast_count) { SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS); finish(false); @@ -2254,7 +2255,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) if (m_caster->GetTypeId() == TYPEID_PLAYER) { - if (sObjectMgr.IsPlayerSpellDisabled(GetSpellInfo()->Id)) + if (sObjectMgr.IsPlayerSpellDisabled(GetSpellEntry()->Id)) { SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE); finish(false); @@ -2263,7 +2264,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) } else if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isPet()) { - if (sObjectMgr.IsPetSpellDisabled(GetSpellInfo()->Id)) + if (sObjectMgr.IsPetSpellDisabled(GetSpellEntry()->Id)) { SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE); finish(false); @@ -2272,7 +2273,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) } else { - if (sObjectMgr.IsCreatureSpellDisabled(GetSpellInfo()->Id)) + if (sObjectMgr.IsCreatureSpellDisabled(GetSpellEntry()->Id)) { finish(false); return; @@ -2280,7 +2281,7 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) } // Fill cost data - m_powerCost = m_CastItem ? 0 : SpellMgr::CalculatePowerCost(GetSpellInfo(), m_caster, m_spellSchoolMask); + m_powerCost = m_CastItem ? 0 : SpellMgr::CalculatePowerCost(GetSpellEntry(), m_caster, m_spellSchoolMask); SpellCastResult result = CheckCast(true); if(result != SPELL_CAST_OK && !IsAutoRepeat()) //always cast autorepeat dummy for triggering @@ -2299,16 +2300,16 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) prepareDataForTriggerSystem(); // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail) - m_casttime = SpellMgr::GetSpellCastTime(GetSpellInfo(), this); + m_casttime = SpellMgr::GetSpellCastTime(GetSpellEntry(), this); // HACK for instant opening of Spectral Blast Portal - if (GetSpellInfo()->Id == 3365) + if (GetSpellEntry()->Id == 3365) { if(m_targets.getGOTarget()&& m_targets.getGOTarget()->GetEntry() == 187055) m_casttime = 0; } - if (GetCastTime() && !SpellMgr::IsChanneledSpell(GetSpellInfo()) ? GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT : GetSpellInfo()->ChannelInterruptFlags & CHANNEL_FLAG_MOVEMENT) + if (GetCastTime() && !SpellMgr::IsChanneledSpell(GetSpellEntry()) ? GetSpellEntry()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT : GetSpellEntry()->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_MOVEMENT) { // controlled state is delivered from idle movement so should be sufficient m_caster->addUnitState(UNIT_STAT_CASTING_NOT_MOVE); @@ -2318,28 +2319,28 @@ void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) // set timer base at cast time ReSetTimer(); - if (GetSpellInfo()->AttributesCu & SPELL_ATRR_CU_LINK_PRECAST) - if (const std::vector *spell_triggered = sSpellMgr.GetSpellLinked(GetSpellInfo()->Id + SPELL_LINK_PRECAST)) + if (GetSpellEntry()->AttributesCu & SPELL_ATRR_CU_LINK_PRECAST) + if (const std::vector *spell_triggered = sSpellMgr.GetSpellLinked(GetSpellEntry()->Id + SPELL_LINK_PRECAST)) for (std::vector::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i) m_caster->CastSpell(m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster, *i, true); - if (m_IsTriggeredSpell) + if (IsTriggeredSpell()) cast(true); else { // stealth must be removed at cast starting (at show channel bar) // skip triggered spell (item equip spell casting and other not explicit character casts/item uses) - if (SpellMgr::isSpellBreakStealth(GetSpellInfo())) + if (SpellMgr::isSpellBreakStealth(GetSpellEntry())) m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); - m_caster->SetCurrentCastedSpell(this); + m_caster->SetCurrentCastSpell(this); m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); SendSpellStart(); TriggerGlobalCooldown(); - if (!m_casttime /*&& !GetSpellInfo()->StartRecoveryTime*/ + if (!m_casttime /*&& !GetSpellEntry()->StartRecoveryTime*/ && !m_castItemGUID //item: first cast may destroy item and second cast causes crash && GetCurrentContainer() == CURRENT_GENERIC_SPELL) cast(true); @@ -2376,14 +2377,17 @@ void Spell::cancel() { Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : m_caster->GetMap()->GetUnit(ihit->targetGUID); if (unit && unit->isAlive()) - unit->RemoveAurasByCasterSpell(GetSpellInfo()->Id, m_caster->GetGUID()); + unit->RemoveAurasByCasterSpell(GetSpellEntry()->Id, m_caster->GetGUID()); } } - m_caster->RemoveAurasByCasterSpell(GetSpellInfo()->Id, m_caster->GetGUID()); + m_caster->RemoveAurasByCasterSpell(GetSpellEntry()->Id, m_caster->GetGUID()); SendChannelUpdate(0); - SendInterrupted(0); - SendCastResult(SPELL_FAILED_INTERRUPTED); + if (!SpellMgr::IsChanneledSpell(GetSpellEntry())) + { + SendInterrupted(0); + SendCastResult(SPELL_FAILED_INTERRUPTED); + } break; } default: @@ -2394,8 +2398,8 @@ void Spell::cancel() if (m_selfContainer && *m_selfContainer == this) *m_selfContainer = NULL; - m_caster->RemoveDynObject(GetSpellInfo()->Id); - m_caster->RemoveGameObject(GetSpellInfo()->Id,true); + m_caster->RemoveDynObject(GetSpellEntry()->Id); + m_caster->RemoveGameObject(GetSpellEntry()->Id,true); //set state back so finish will be processed m_spellState = oldState; @@ -2406,20 +2410,23 @@ void Spell::cancel() void Spell::cast(bool skipCheck) { // what the fuck is done here? o.O - SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellInfo()->Id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellEntry()->Id); if (!spellInfo) return; // update pointers base at GUIDs to prevent access to non-existed already object UpdatePointers(); - if (Unit *pTarget = m_targets.getUnitTarget()) + if (!IsTriggeredSpell()) // reflective shields, molten armor etc. are not checked for it. They should ignore stealth. (as of reflective shields ignore stealth 100% sure) { - if (pTarget->isAlive() && (pTarget->HasAuraType(SPELL_AURA_MOD_STEALTH) || pTarget->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) && !pTarget->IsFriendlyTo(m_caster) && !pTarget->isVisibleForOrDetect(m_caster, m_caster, true)) + if (Unit *pTarget = m_targets.getUnitTarget()) { - SendCastResult(SPELL_FAILED_BAD_TARGETS); - finish(false); - return; + if (pTarget->isAlive() && (pTarget->HasAuraType(SPELL_AURA_MOD_STEALTH) || pTarget->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) && !pTarget->IsFriendlyTo(m_caster) && !pTarget->isVisibleForOrDetect(m_caster, m_caster, true)) + { + SendCastResult(SPELL_FAILED_BAD_TARGETS); + finish(false); + return; + } } } @@ -2446,7 +2453,7 @@ void Spell::cast(bool skipCheck) if (m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) m_caster->SetInFront(m_targets.getUnitTarget()); - if (!m_IsTriggeredSpell) + if (!IsTriggeredSpell() || IsAutoShootSpell()) { castResult = CheckPower(); if (castResult != SPELL_CAST_OK) @@ -2494,7 +2501,13 @@ void Spell::cast(bool skipCheck) } } - FillTargetMap(); + // do NOT fill again spell target map if there are already some targets defined + if (m_UniqueTargetInfo.empty()) + FillTargetMap(); + + // used by eluna + if (m_caster->GetTypeId() == TYPEID_PLAYER) + sHookMgr->OnSpellCast(m_caster->ToPlayer(), this, skipCheck); if (m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in Take*/FillTargetMap { @@ -2506,7 +2519,7 @@ void Spell::cast(bool skipCheck) // set to real guid to be sent later to the client m_targets.updateTradeSlotItem(); - if (!m_IsTriggeredSpell) + if (!IsTriggeredSpell() || IsAutoShootSpell()) { //TakePower(); TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot @@ -2525,14 +2538,14 @@ void Spell::cast(bool skipCheck) Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); for (Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) { - SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); + SpellEntry const *auraSpellEntry = (*i)->GetSpellProto(); uint32 auraSpellIdx = (*i)->GetEffIndex(); - if (IsAffectedBy(auraSpellInfo, auraSpellIdx)) + if (IsAffectedBy(auraSpellEntry, auraSpellIdx)) { - if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(auraSpellInfo->EffectTriggerSpell[auraSpellIdx])) + if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(auraSpellEntry->EffectTriggerSpell[auraSpellIdx])) { // Calculate chance at that moment (can be depend for example from combo points) - int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(), NULL); + int32 chance = m_caster->CalculateSpellDamage(auraSpellEntry, auraSpellIdx, (*i)->GetBasePoints(), NULL); m_ChanceTriggerSpells.push_back(std::make_pair(spellInfo, chance * (*i)->GetStackAmount())); } } @@ -2547,7 +2560,7 @@ void Spell::cast(bool skipCheck) } // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells - if (IsDelayedSpell() && !SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (IsDelayedSpell() && !SpellMgr::IsChanneledSpell(GetSpellEntry())) { // Remove used for cast item if need (it can be already NULL after TakeReagents call // in case delayed spell remove item at cast delay start @@ -2558,14 +2571,14 @@ void Spell::cast(bool skipCheck) m_spellState = SPELL_STATE_DELAYED; SetDelayStart(0); - m_caster->ProcDamageAndSpell(m_targets.getUnitTarget(), m_procCastEnd, PROC_FLAG_NONE, PROC_EX_EX_TRIGGER_ALWAYS, 1, BASE_ATTACK, GetSpellInfo()); + m_caster->ProcDamageAndSpell(m_targets.getUnitTarget(), m_procCastEnd, PROC_FLAG_NONE, PROC_EX_EX_TRIGGER_ALWAYS, 1, BASE_ATTACK, GetSpellEntry()); } else // Immediate spell, no big deal handle_immediate(); // combo points should not be taken before SPELL_AURA_ADD_TARGET_TRIGGER auras are handled - if (!m_IsTriggeredSpell) + if (!IsTriggeredSpell() || IsAutoShootSpell()) TakePower(); if (spellInfo->AttributesCu & SPELL_ATTR_CU_LINK_CAST) @@ -2583,27 +2596,27 @@ void Spell::cast(bool skipCheck) void Spell::handle_immediate() { - if (GetSpellInfo()->Id <= 0 || GetSpellInfo()->Id > MAX_SPELL_ID || GetSpellInfo()->Id == 32 || GetSpellInfo()->Id == 48 || GetSpellInfo()->Id == 576 || GetSpellInfo()->Id == 80 || GetSpellInfo()->Id == 160) + if (GetSpellEntry()->Id <= 0 || GetSpellEntry()->Id > MAX_SPELL_ID || GetSpellEntry()->Id == 32 || GetSpellEntry()->Id == 48 || GetSpellEntry()->Id == 576 || GetSpellEntry()->Id == 80 || GetSpellEntry()->Id == 160) return; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellInfo()->Id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellEntry()->Id); if (!spellInfo) return; // start channeling if applicable - if (SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (SpellMgr::IsChanneledSpell(GetSpellEntry())) { - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); if (duration) { //apply haste mods - m_caster->ModSpellCastTime(GetSpellInfo(), duration, this); + m_caster->ModSpellCastTime(GetSpellEntry(), duration, this); // Apply duration mod if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_DURATION, duration); m_spellState = SPELL_STATE_CASTING; - m_caster->AddInterruptMask(GetSpellInfo()->ChannelInterruptFlags); + m_caster->AddInterruptMask(GetSpellEntry()->ChannelInterruptFlags); SendChannelStart(duration); } @@ -2709,23 +2722,23 @@ uint64 Spell::handle_delayed(uint64 t_offset) void Spell::_handle_immediate_phase() { // handle some immediate features of the spell here - HandleThreatSpells(GetSpellInfo()->Id); + HandleThreatSpells(GetSpellEntry()->Id); m_needSpellLog = IsNeedSendToClient(); for (uint32 j = 0;j<3;j++) { - if (GetSpellInfo()->Effect[j]==0) + if (GetSpellEntry()->Effect[j]==0) continue; // apply Send Event effect to ground in case empty target lists - if (GetSpellInfo()->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j)) + if (GetSpellEntry()->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j)) { HandleEffects(NULL,NULL,NULL, j); continue; } // Don't do spell log, if is school damage spell - if (GetSpellInfo()->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || GetSpellInfo()->Effect[j] == 0) + if (GetSpellEntry()->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || GetSpellEntry()->Effect[j] == 0) m_needSpellLog = false; } @@ -2737,19 +2750,19 @@ void Spell::_handle_immediate_phase() for (std::list::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) DoAllEffectOnTarget(&(*ihit)); - if (!m_originalCaster || GetSpellInfo()->Id == 43622) + if (!m_originalCaster || GetSpellEntry()->Id == 43622) return; // process ground for (uint32 j = 0; j < 3; ++j) { - if (sSpellMgr.EffectTargetType[GetSpellInfo()->Effect[j]] == SPELL_REQUIRE_DEST/* && GetSpellInfo()->Effect[j] != SPELL_EFFECT_TRIGGER_MISSILE*/) + if (sSpellMgr.EffectTargetType[GetSpellEntry()->Effect[j]] == SPELL_REQUIRE_DEST/* && GetSpellEntry()->Effect[j] != SPELL_EFFECT_TRIGGER_MISSILE*/) { if (!m_targets.HasDst()) // FIXME: this will ignore dest set in effect m_targets.setDestination(m_caster); HandleEffects(m_originalCaster, NULL, NULL, j); } - else if (sSpellMgr.EffectTargetType[GetSpellInfo()->Effect[j]] == SPELL_REQUIRE_NONE) + else if (sSpellMgr.EffectTargetType[GetSpellEntry()->Effect[j]] == SPELL_REQUIRE_NONE) HandleEffects(m_originalCaster, NULL, NULL, j); } } @@ -2757,7 +2770,7 @@ void Spell::_handle_immediate_phase() void Spell::_handle_finish_phase() { // spell log - if (m_needSpellLog && GetSpellInfo()) + if (m_needSpellLog && GetSpellEntry()) SendLogExecute(); } @@ -2769,9 +2782,9 @@ void Spell::SendSpellCooldown() Player* _player = (Player*)m_caster; // Add cooldown for max (disable spell) // Cooldown started on SendCooldownEvent call - if (GetSpellInfo()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) + if (GetSpellEntry()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) { - _player->AddSpellCooldown(GetSpellInfo()->Id, 0, time(NULL) - 1); + _player->AddSpellCooldown(GetSpellEntry()->Id, 0, time(NULL) - 1); return; } @@ -2780,7 +2793,7 @@ void Spell::SendSpellCooldown() int32 rec = -1; int32 catrec = -1; - // some special item spells without correct cooldown in SpellInfo + // some special item spells without correct cooldown in SpellEntry // cooldown information stored in item prototype // This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client. @@ -2791,7 +2804,7 @@ void Spell::SendSpellCooldown() { for (int idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx) { - if (proto->Spells[idx].SpellId == GetSpellInfo()->Id) + if (proto->Spells[idx].SpellId == GetSpellEntry()->Id) { cat = proto->Spells[idx].SpellCategory; rec = proto->Spells[idx].SpellCooldown; @@ -2805,9 +2818,9 @@ void Spell::SendSpellCooldown() // if no cooldown found above then base at DBC data if (rec < 0 && catrec < 0) { - cat = GetSpellInfo()->Category; - rec = GetSpellInfo()->RecoveryTime; - catrec = GetSpellInfo()->CategoryRecoveryTime; + cat = GetSpellEntry()->Category; + rec = GetSpellEntry()->RecoveryTime; + catrec = GetSpellEntry()->CategoryRecoveryTime; } // shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK) @@ -2817,10 +2830,10 @@ void Spell::SendSpellCooldown() // Now we have cooldown data (if found any), time to apply mods if (rec > 0) - _player->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_COOLDOWN, rec, this); + _player->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_COOLDOWN, rec, this); if (catrec > 0) - _player->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_COOLDOWN, catrec, this); + _player->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_COOLDOWN, catrec, this); // replace negative cooldowns by 0 if (rec < 0) rec = 0; @@ -2837,7 +2850,7 @@ void Spell::SendSpellCooldown() // self spell cooldown if (recTime > 0) - _player->AddSpellCooldown(GetSpellInfo()->Id, m_CastItem ? m_CastItem->GetEntry() : 0, recTime); + _player->AddSpellCooldown(GetSpellEntry()->Id, m_CastItem ? m_CastItem->GetEntry() : 0, recTime); // category spells if (catrec > 0) @@ -2847,7 +2860,7 @@ void Spell::SendSpellCooldown() { for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) { - if (*i_scset == GetSpellInfo()->Id) // skip main spell, already handled above + if (*i_scset == GetSpellEntry()->Id) // skip main spell, already handled above continue; _player->AddSpellCooldown(*i_scset, m_CastItem ? m_CastItem->GetEntry() : 0, catrecTime); @@ -2870,13 +2883,13 @@ void Spell::update(uint32 difftime) // check if caster has moved before the spell finished if (m_timer != 0 && m_caster->hasUnitState(UNIT_STAT_CASTING_NOT_MOVE) && !m_caster->HasUnitMovementFlag(MOVEFLAG_FALLINGFAR)) { - // Check for movin' by(rotation keys ft. mouse button) - if ((m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->isMoving() && m_casttime && !m_spellInfo->speed && - m_spellInfo->SpellFamilyFlags != SPELLFAMILY_GENERIC && !m_delayMoment)) - cancel(); + // Check for movin' by(rotation keys ft. mouse button) +// if ((m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->isMoving() && m_casttime && +// m_spellInfo->SpellFamilyFlags != SPELLFAMILY_GENERIC && !m_delayMoment)) +// cancel(); // add little offset for creature stop movement - if (!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_IsTriggeredSpell) + if (!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !IsTriggeredSpell()) { Position casterPos; m_caster->GetPosition(casterPos); @@ -2898,7 +2911,7 @@ void Spell::update(uint32 difftime) } if (m_timer == 0 && !IsNextMeleeSwingSpell() && !IsAutoRepeat()) - cast(GetSpellInfo()->CastingTimeIndex == 1); + cast(GetSpellEntry()->CastingTimeIndex == 1); } break; case SPELL_STATE_CASTING: { @@ -2918,9 +2931,9 @@ void Spell::update(uint32 difftime) finish(); } - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellInfo()->SpellFamilyFlags & 0x800) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellEntry()->SpellFamilyFlags & 0x800) { - float max_range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float max_range = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); if (!m_targets.getUnitTarget() || !m_caster->IsWithinDistInMap(m_targets.getUnitTarget(), max_range +3.0)) cancel(); @@ -2956,7 +2969,7 @@ void Spell::update(uint32 difftime) if (!unit) continue; - p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), GetSpellInfo()->Id); + p->CastCreatureOrGO(unit->GetEntry(), unit->GetGUID(), GetSpellEntry()->Id); } for (std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) @@ -2970,7 +2983,7 @@ void Spell::update(uint32 difftime) if (!go) continue; - p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), GetSpellInfo()->Id); + p->CastCreatureOrGO(go->GetEntry(), go->GetGUID(), GetSpellEntry()->Id); } } } @@ -2994,10 +3007,10 @@ void Spell::finish(bool ok) m_spellState = SPELL_STATE_FINISHED; - if (SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (SpellMgr::IsChanneledSpell(GetSpellEntry())) m_caster->UpdateInterruptMask(); - if (!m_caster->IsNonMeleeSpellCasted(false, false, true)) + if (!m_caster->IsNonMeleeSpellCast(false, false, true)) { if (m_caster->hasUnitState(UNIT_STAT_CASTING_NOT_MOVE)) m_caster->GetUnitStateMgr().DropAction(UNIT_ACTION_CONTROLLED); @@ -3008,25 +3021,25 @@ void Spell::finish(bool ok) if (!ok) { //restore spell mods - if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsChanneledSpell(GetSpellEntry())) ((Player*)m_caster)->RestoreSpellMods(this); return; } // other code related only to successfully finished spells //remove spell mods - if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsChanneledSpell(GetSpellEntry())) ((Player*)m_caster)->RemoveSpellMods(this); // Okay to remove extra attacks - if (GetSpellInfo()->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS)) + if (GetSpellEntry()->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS)) m_caster->m_extraAttacks = 0; // Heal caster for all health leech from all targets if (m_healthLeech) { m_caster->ModifyHealth(m_healthLeech); - m_caster->SendHealSpellLog(m_caster, GetSpellInfo()->Id, uint32(m_healthLeech)); + m_caster->SendHealSpellLog(m_caster, GetSpellEntry()->Id, uint32(m_healthLeech)); } if (IsMeleeAttackResetSpell()) @@ -3035,7 +3048,7 @@ void Spell::finish(bool ok) if (m_caster->haveOffhandWeapon()) m_caster->resetAttackTimer(OFF_ATTACK); - if (!(GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_NOT_RESET_AUTOSHOT)) + if (!(GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_NOT_RESET_AUTOSHOT)) m_caster->resetAttackTimer(RANGED_ATTACK); } @@ -3045,7 +3058,7 @@ void Spell::finish(bool ok) TriggerSpell(); // Stop Attack for some spells - if (GetSpellInfo()->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET) + if (GetSpellEntry()->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET) m_caster->AttackStop(); } @@ -3061,23 +3074,23 @@ void Spell::SendCastResult(SpellCastResult result) { WorldPacket data(SMSG_CLEAR_EXTRA_AURA_INFO, (8+4)); data << m_caster->GetPackGUID(); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); ((Player*)m_caster)->SendPacketToSelf(&data); return; } WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); data << uint8(result); // problem data << uint8(m_cast_count); // single cast or multi 2.3 (0/1) switch (result) { case SPELL_FAILED_REQUIRES_SPELL_FOCUS: - data << uint32(GetSpellInfo()->RequiresSpellFocus); + data << uint32(GetSpellEntry()->RequiresSpellFocus); break; case SPELL_FAILED_REQUIRES_AREA: // hardcode areas limitation case - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 41617: // Cenarion Mana Salve case 41619: // Cenarion Healing Salve @@ -3091,26 +3104,26 @@ void Spell::SendCastResult(SpellCastResult result) data << uint32(4075); break; default: // default case - data << uint32(GetSpellInfo()->AreaId); + data << uint32(GetSpellEntry()->AreaId); break; } break; case SPELL_FAILED_TOTEMS: - if (GetSpellInfo()->Totem[0]) - data << uint32(GetSpellInfo()->Totem[0]); - if (GetSpellInfo()->Totem[1]) - data << uint32(GetSpellInfo()->Totem[1]); + if (GetSpellEntry()->Totem[0]) + data << uint32(GetSpellEntry()->Totem[0]); + if (GetSpellEntry()->Totem[1]) + data << uint32(GetSpellEntry()->Totem[1]); break; case SPELL_FAILED_TOTEM_CATEGORY: - if (GetSpellInfo()->TotemCategory[0]) - data << uint32(GetSpellInfo()->TotemCategory[0]); - if (GetSpellInfo()->TotemCategory[1]) - data << uint32(GetSpellInfo()->TotemCategory[1]); + if (GetSpellEntry()->TotemCategory[0]) + data << uint32(GetSpellEntry()->TotemCategory[0]); + if (GetSpellEntry()->TotemCategory[1]) + data << uint32(GetSpellEntry()->TotemCategory[1]); break; case SPELL_FAILED_EQUIPPED_ITEM_CLASS: - data << uint32(GetSpellInfo()->EquippedItemClass); - data << uint32(GetSpellInfo()->EquippedItemSubClassMask); - data << uint32(GetSpellInfo()->EquippedItemInventoryTypeMask); + data << uint32(GetSpellEntry()->EquippedItemClass); + data << uint32(GetSpellEntry()->EquippedItemSubClassMask); + data << uint32(GetSpellEntry()->EquippedItemInventoryTypeMask); break; } ((Player*)m_caster)->SendPacketToSelf(&data); @@ -3121,7 +3134,7 @@ void Spell::SendSpellStart() if (!IsNeedSendToClient()) return; - sLog.outDebug("Sending SMSG_SPELL_START id=%u", GetSpellInfo()->Id); + sLog.outDebug("Sending SMSG_SPELL_START id=%u", GetSpellEntry()->Id); uint32 castFlags = CAST_FLAG_UNKNOWN2; if (IsRangedSpell()) @@ -3136,7 +3149,7 @@ void Spell::SendSpellStart() data << m_caster->GetPackGUID(); data << m_caster->GetPackGUID(); - data << uint32(GetSpellInfo()->Id);; // spellId + data << uint32(GetSpellEntry()->Id);; // spellId data << uint8(m_cast_count); // pending spell cast? data << uint16(castFlags); // cast flags data << uint32(m_timer); // delay? @@ -3154,14 +3167,14 @@ void Spell::SendSpellGo() if (!IsNeedSendToClient()) return; - sLog.outDebug("Sending SMSG_SPELL_GO id=%u", GetSpellInfo()->Id); + sLog.outDebug("Sending SMSG_SPELL_GO id=%u", GetSpellEntry()->Id); Unit *target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster; uint32 castFlags = CAST_FLAG_UNKNOWN9; // triggered spells with spell visual != 0 and not auto shot - if ((m_IsTriggeredSpell && (GetSpellInfo()->AttributesEx4 & SPELL_ATTR_EX4_AUTOSHOT) == 0) || m_triggeredByAuraSpell) + if ((IsTriggeredSpell() && (GetSpellEntry()->AttributesEx4 & SPELL_ATTR_EX4_AUTOSHOT) == 0) || m_triggeredByAuraSpell) castFlags |= CAST_FLAG_HIDDEN_COMBATLOG; if (IsRangedSpell()) @@ -3174,7 +3187,7 @@ void Spell::SendSpellGo() data << m_caster->GetPackGUID(); data << m_caster->GetPackGUID(); - data << uint32(GetSpellInfo()->Id); // spellId + data << uint32(GetSpellEntry()->Id); // spellId data << uint16(castFlags); // cast flags data << uint32(WorldTimer::getMSTime()); // timestamp @@ -3266,7 +3279,7 @@ void Spell::WriteSpellGoTargets(WorldPacket * data) } // Reset m_needAliveTargetMask for non channeled spell - if (!SpellMgr::IsChanneledSpell(GetSpellInfo())) + if (!SpellMgr::IsChanneledSpell(GetSpellEntry())) m_needAliveTargetMask = 0; } @@ -3284,17 +3297,17 @@ void Spell::SendLogExecute() else data << target->GetPackGUID(); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); uint32 count1 = 1; data << uint32(count1); // count1 (effect count?) for (uint32 i = 0; i < count1; ++i) { - data << uint32(GetSpellInfo()->Effect[0]); // spell effect + data << uint32(GetSpellEntry()->Effect[0]); // spell effect uint32 count2 = 1; data << uint32(count2); // count2 (target count?) for (uint32 j = 0; j < count2; ++j) { - switch (GetSpellInfo()->Effect[0]) + switch (GetSpellEntry()->Effect[0]) { case SPELL_EFFECT_POWER_DRAIN: if (Unit *unit = m_targets.getUnitTarget()) @@ -3312,13 +3325,6 @@ void Spell::SendLogExecute() data << uint8(0); data << uint32(m_caster->m_extraAttacks); break; - case SPELL_EFFECT_INTERRUPT_CAST: - if (Unit *unit = m_targets.getUnitTarget()) - data << unit->GetPackGUID(); - else - data << uint8(0); - data << uint32(0); // spellid - break; case SPELL_EFFECT_DURABILITY_DAMAGE: if (Unit *unit = m_targets.getUnitTarget()) data << unit->GetPackGUID(); @@ -3335,7 +3341,7 @@ void Spell::SendLogExecute() data << uint8(0); break; case SPELL_EFFECT_CREATE_ITEM: - data << uint32(GetSpellInfo()->EffectItemType[0]); + data << uint32(GetSpellEntry()->EffectItemType[0]); break; case SPELL_EFFECT_SUMMON: case SPELL_EFFECT_SUMMON_WILD: @@ -3390,13 +3396,13 @@ void Spell::SendInterrupted(uint8 result) { WorldPacket data(SMSG_SPELL_FAILURE, (8+4+1)); data << m_caster->GetPackGUID(); - data << GetSpellInfo()->Id; + data << GetSpellEntry()->Id; data << result; m_caster->BroadcastPacket(&data, true); data.Initialize(SMSG_SPELL_FAILED_OTHER, (8+4)); data << m_caster->GetPackGUID(); - data << GetSpellInfo()->Id; + data << GetSpellEntry()->Id; m_caster->BroadcastPacket(&data, true); } @@ -3451,7 +3457,7 @@ void Spell::SendChannelStart(uint32 duration) WorldPacket data(MSG_CHANNEL_START, (8+4+4)); data << m_caster->GetPackGUID(); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); data << uint32(duration); m_caster->BroadcastPacket(&data, true); @@ -3459,7 +3465,7 @@ void Spell::SendChannelStart(uint32 duration) m_timer = duration; if (target) m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID()); - m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, GetSpellInfo()->Id); + m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, GetSpellEntry()->Id); } void Spell::SendResurrectRequest(Player* target) @@ -3478,7 +3484,7 @@ void Spell::SendResurrectRequest(Player* target) data << uint8(m_caster->GetTypeId()==TYPEID_PLAYER ? 0 : 1); - if (GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_IGNORE_RESURRECTION_TIMER) + if (GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_IGNORE_RESURRECTION_TIMER) data << uint32(0); target->SendPacketToSelf(&data); @@ -3501,7 +3507,7 @@ void Spell::TakeCastItem() return; // not remove cast item at triggered spell (equipping, weapon damage, etc) - if (m_IsTriggeredSpell) + if (IsTriggeredSpell()) return; ItemPrototype const *proto = m_CastItem->GetProto(); @@ -3565,7 +3571,10 @@ void Spell::TakePower() bool hit = true; if (m_caster->GetTypeId() == TYPEID_PLAYER) { - if (GetSpellInfo()->powerType == POWER_RAGE || GetSpellInfo()->powerType == POWER_ENERGY) + if (m_caster->ToPlayer()->HasCheatState(PlayerCheatState::Power)) + return; + + if (GetSpellEntry()->powerType == POWER_RAGE || GetSpellEntry()->powerType == POWER_ENERGY) if (uint64 targetGUID = m_targets.getUnitTargetGUID()) for (std::list::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { @@ -3576,13 +3585,13 @@ void Spell::TakePower() { if (ihit->missCondition != SPELL_MISS_NONE && ihit->missCondition != SPELL_MISS_MISS/* && ihit->targetGUID!=m_caster->GetGUID()*/) hit = false; - else if (((Player*)m_caster)->getClass() == CLASS_DRUID && ihit->missCondition == SPELL_MISS_MISS && GetSpellInfo()->powerType == POWER_ENERGY) // not sure if it's limited only to druid/energy + else if (((Player*)m_caster)->getClass() == CLASS_DRUID && ihit->missCondition == SPELL_MISS_MISS && GetSpellEntry()->powerType == POWER_ENERGY) // not sure if it's limited only to druid/energy hit = false; break; } } - if (hit && SpellMgr::NeedsComboPoints(GetSpellInfo())) + if (hit && SpellMgr::NeedsComboPoints(GetSpellEntry())) ((Player*)m_caster)->ClearComboPoints(); } @@ -3590,21 +3599,21 @@ void Spell::TakePower() return; // health as power used - if (GetSpellInfo()->powerType == POWER_HEALTH) + if (GetSpellEntry()->powerType == POWER_HEALTH) { m_caster->ModifyHealth(-(int32)m_powerCost); return; } - if (GetSpellInfo()->powerType >= MAX_POWERS) + if (GetSpellEntry()->powerType >= MAX_POWERS) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::TakePower: Unknown power type '%d'", GetSpellInfo()->powerType); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::TakePower: Unknown power type '%d'", GetSpellEntry()->powerType); return; } - Powers powerType = Powers(GetSpellInfo()->powerType); + Powers powerType = Powers(GetSpellEntry()->powerType); - if (hit || (SpellMgr::NeedsComboPoints(GetSpellInfo()) && m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->getClass() == CLASS_DRUID) ) // not sure if it's limited only to druid + if (hit || (SpellMgr::NeedsComboPoints(GetSpellEntry()) && m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->getClass() == CLASS_DRUID) ) // not sure if it's limited only to druid m_caster->ModifyPower(powerType, -m_powerCost); else m_caster->ModifyPower(powerType, -irand(0, m_powerCost/4)); @@ -3616,23 +3625,23 @@ void Spell::TakePower() void Spell::TakeReagents() { - if (m_IsTriggeredSpell) // reagents used in triggered spell removed by original spell or don't must be removed. + if (IsTriggeredSpell()) // reagents used in triggered spell removed by original spell or don't must be removed. return; if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player* p_caster = (Player*)m_caster; - if (p_caster->CanNoReagentCast(GetSpellInfo())) + if (p_caster->CanNoReagentCast(GetSpellEntry())) return; for (uint32 x = 0; x < 8; ++x) { - if (GetSpellInfo()->Reagent[x] <= 0) + if (GetSpellEntry()->Reagent[x] <= 0) continue; - uint32 itemid = GetSpellInfo()->Reagent[x]; - uint32 itemcount = GetSpellInfo()->ReagentCount[x]; + uint32 itemid = GetSpellEntry()->Reagent[x]; + uint32 itemcount = GetSpellEntry()->ReagentCount[x]; // if CastItem is also spell reagent if (m_CastItem) @@ -3686,8 +3695,8 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar itemTarget = pItemTarget; gameObjTarget = pGOTarget; - uint8 eff = GetSpellInfo()->Effect[i]; - uint32 mechanic = GetSpellInfo()->EffectMechanic[i]; + uint8 eff = GetSpellEntry()->Effect[i]; + uint32 mechanic = GetSpellEntry()->EffectMechanic[i]; sLog.outDebug("Spell: Effect : %u", eff); @@ -3700,7 +3709,7 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar if (eff < TOTAL_SPELL_EFFECTS) { - if (!sScriptMgr.OnSpellHandleEffect(m_caster, unitTarget, itemTarget, gameObjTarget, GetSpellInfo(), i)) + if (!sScriptMgr.OnSpellHandleEffect(m_caster, unitTarget, itemTarget, gameObjTarget, GetSpellEntry(), i)) (*this.*SpellEffects[eff])(i); } } @@ -3717,58 +3726,58 @@ void Spell::TriggerSpell() SpellCastResult Spell::CheckCast(bool strict) { // check cooldowns to prevent cheating - if (!m_IsTriggeredSpell && m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->HasSpellCooldown(GetSpellInfo()->Id)) + if (!IsTriggeredSpell() && m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->HasSpellCooldown(GetSpellEntry()->Id)) { - //triggered spells shouldn't be casted (cooldown check in handleproctriggerspell) + //triggered spells shouldn't be cast (cooldown check in handleproctriggerspell) // if (m_triggeredByAuraSpell) // return SPELL_FAILED_DONT_REPORT; // else return SPELL_FAILED_NOT_READY; } - if (GetSpellInfo()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE && m_caster->HasAura(GetSpellInfo()->Id, 0)) + if (GetSpellEntry()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE && m_caster->HasAura(GetSpellEntry()->Id, 0)) return SPELL_FAILED_NOT_READY; // Check global cooldown - if (strict && !m_IsTriggeredSpell && HasGlobalCooldown()) + if (strict && !IsTriggeredSpell() && HasGlobalCooldown()) return SPELL_FAILED_NOT_READY; // only allow triggered spells if at an ended battleground - if (!m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER) + if (!IsTriggeredSpell() && m_caster->GetTypeId() == TYPEID_PLAYER) if (BattleGround * bg = ((Player*)m_caster)->GetBattleGround()) if (bg->GetStatus() == STATUS_WAIT_LEAVE) return SPELL_FAILED_DONT_REPORT; - if (!m_IsTriggeredSpell && SpellMgr::IsNonCombatSpell(GetSpellInfo()) && m_caster->isInCombat()) + if (!IsTriggeredSpell() && SpellMgr::IsNonCombatSpell(GetSpellEntry()) && m_caster->isInCombat()) return SPELL_FAILED_AFFECTING_COMBAT; // only check at first call, Stealth auras are already removed at second call // for now, ignore triggered spells - if (strict && !m_IsTriggeredSpell) + if (strict && !IsTriggeredSpell()) { // Cannot be used in this stance/form - SpellCastResult shapeError = SpellMgr::GetErrorAtShapeshiftedCast(GetSpellInfo(), m_caster->m_form); + SpellCastResult shapeError = SpellMgr::GetErrorAtShapeshiftedCast(GetSpellEntry(), m_caster->m_form); if(shapeError != SPELL_CAST_OK) return shapeError; - if ((GetSpellInfo()->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura())) + if ((GetSpellEntry()->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura())) return SPELL_FAILED_ONLY_STEALTHED; } // caster state requirements - if (GetSpellInfo()->CasterAuraState && !m_caster->HasAuraState(AuraState(GetSpellInfo()->CasterAuraState))) + if (GetSpellEntry()->CasterAuraState && !m_caster->HasAuraState(AuraState(GetSpellEntry()->CasterAuraState))) return SPELL_FAILED_CASTER_AURASTATE; - if (GetSpellInfo()->CasterAuraStateNot && m_caster->HasAuraState(AuraState(GetSpellInfo()->CasterAuraStateNot))) + if (GetSpellEntry()->CasterAuraStateNot && m_caster->HasAuraState(AuraState(GetSpellEntry()->CasterAuraStateNot))) return SPELL_FAILED_CASTER_AURASTATE; // cancel autorepeat spells if cast start when moving 'n' Check for movin' by(rotation keys ft. mouse button) // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code) if (m_caster->GetTypeId()==TYPEID_PLAYER && m_caster->ToPlayer()->isMoving()) { - uint32 ct = SpellMgr::GetSpellCastTime(GetSpellInfo(), this); - if (ct && m_spellInfo->SpellFamilyFlags != SPELLFAMILY_GENERIC) - return SPELL_FAILED_MOVING; +// uint32 ct = SpellMgr::GetSpellCastTime(GetSpellEntry(), this); +// if (ct && m_spellInfo->SpellFamilyFlags != SPELLFAMILY_GENERIC) +// return SPELL_FAILED_MOVING; if (!m_caster->HasUnitMovementFlag(MOVEFLAG_FALLINGFAR) && IsAutoRepeat()) return SPELL_FAILED_MOVING; @@ -3776,16 +3785,16 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->isGameMaster() && sWorld.getConfig(CONFIG_VMAP_INDOOR_CHECK)) { - if (GetSpellInfo()->Attributes & SPELL_ATTR_OUTDOORS_ONLY && + if (GetSpellEntry()->Attributes & SPELL_ATTR_OUTDOORS_ONLY && !m_caster->GetTerrain()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ())) return SPELL_FAILED_ONLY_OUTDOORS; - if(GetSpellInfo()->Attributes & SPELL_ATTR_INDOORS_ONLY && + if(GetSpellEntry()->Attributes & SPELL_ATTR_INDOORS_ONLY && m_caster->GetTerrain()->IsOutdoors(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ())) return SPELL_FAILED_ONLY_INDOORS; } - if (GetSpellInfo()->AttributesEx6 & SPELL_ATTR_EX6_NOT_IN_RAID_INSTANCE && m_caster->GetInstanceId()) + if (GetSpellEntry()->AttributesEx6 & SPELL_ATTR_EX6_NOT_IN_RAID_INSTANCE && m_caster->GetInstanceId()) { if (Map *PlrMap = m_caster->GetMap()) if (PlrMap->IsRaid()) @@ -3793,7 +3802,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // can't cast while seated - if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->IsSitState() && !m_IsTriggeredSpell && !(GetSpellInfo()->Attributes & SPELL_ATTR_CASTABLE_WHILE_SITTING)) + if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->IsSitState() && !(IsTriggeredSpell() || IsAutoShootSpell()) && !(GetSpellEntry()->Attributes & SPELL_ATTR_CASTABLE_WHILE_SITTING)) { ((Player*)m_caster)->SetStandState(UNIT_STAND_STATE_STAND); } @@ -3801,30 +3810,30 @@ SpellCastResult Spell::CheckCast(bool strict) if (Unit *target = m_targets.getUnitTarget()) { // target state requirements (not allowed state), apply to self also - if (GetSpellInfo()->TargetAuraStateNot && target->HasAuraState(AuraState(GetSpellInfo()->TargetAuraStateNot))) + if (GetSpellEntry()->TargetAuraStateNot && target->HasAuraState(AuraState(GetSpellEntry()->TargetAuraStateNot))) return SPELL_FAILED_TARGET_AURASTATE; if (target != m_caster) { // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds - if (GetSpellInfo()->TargetAuraState && !target->HasAuraState(AuraState(GetSpellInfo()->TargetAuraState))) + if (GetSpellEntry()->TargetAuraState && !target->HasAuraState(AuraState(GetSpellEntry()->TargetAuraState))) return SPELL_FAILED_TARGET_AURASTATE; // Not allow players casting on flying player - if (target->IsTaxiFlying() && m_caster->GetTypeId() == TYPEID_PLAYER) + if (target->IsTaxiFlying() && m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) return SPELL_FAILED_BAD_TARGETS; - if (!m_IsTriggeredSpell && !SpellMgr::SpellIgnoreLOS(GetSpellInfo(), 0) && VMAP::VMapFactory::checkSpellForLoS(GetSpellInfo()->Id) && !m_caster->IsWithinLOSInMap(target)) + if ((!IsTriggeredSpell() || IsAutoShootSpell()) && !SpellMgr::SpellIgnoreLOS(GetSpellEntry(), 0) && VMAP::VMapFactory::checkSpellForLoS(GetSpellEntry()->Id) && !m_caster->IsWithinLOSInMap(target)) return SPELL_FAILED_LINE_OF_SIGHT; // auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode // this case can be triggered if rank not found (too low-level target for first rank) - if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsPassiveSpell(GetSpellInfo()->Id) && !m_CastItem) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !SpellMgr::IsPassiveSpell(GetSpellEntry()->Id) && !m_CastItem) { for (int i=0;i<3;i++) { - if (SpellMgr::IsPositiveEffect(GetSpellInfo()->Id, i) && GetSpellInfo()->Effect[i] == SPELL_EFFECT_APPLY_AURA) - if (target->getLevel() + 10 < GetSpellInfo()->spellLevel) + if (SpellMgr::IsPositiveEffect(GetSpellEntry()->Id, i) && GetSpellEntry()->Effect[i] == SPELL_EFFECT_APPLY_AURA) + if (target->getLevel() + 10 < GetSpellEntry()->spellLevel) return SPELL_FAILED_LOWLEVEL; } } @@ -3833,7 +3842,7 @@ SpellCastResult Spell::CheckCast(bool strict) // check pet presents for (int j=0;j<3;j++) { - if (GetSpellInfo()->EffectImplicitTargetA[j] == TARGET_UNIT_PET) + if (GetSpellEntry()->EffectImplicitTargetA[j] == TARGET_UNIT_PET) { target = m_caster->GetPet(); if (!target) @@ -3863,7 +3872,7 @@ SpellCastResult Spell::CheckCast(bool strict) /*if (m_caster->GetTypeId() == TYPEID_PLAYER) { // Do not these spells to target creatures not tapped by us (Banish, Polymorph, many quest spells) - if (GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_CANT_TARGET_TAPPED) + if (GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_CANT_TARGET_TAPPED) { if (target->GetTypeId() == TYPEID_UNIT) { @@ -3880,10 +3889,10 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster != target && m_caster->GetTypeId()==TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) { // check correctness positive/negative cast target (pet cast real check and cheating check) - if (SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + if (SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) { //dispel positivity is dependant on target, don't check it - if (m_caster->IsHostileTo(target) && !SpellMgr::IsDispel(GetSpellInfo())) + if (m_caster->IsHostileTo(target) && !SpellMgr::IsDispel(GetSpellEntry())) return SPELL_FAILED_BAD_TARGETS; } else @@ -3894,44 +3903,50 @@ SpellCastResult Spell::CheckCast(bool strict) } /* This prevented to cast heal on players in cyclone, which should be possible - if (IsPositiveSpell(GetSpellInfo()->Id)) + if (IsPositiveSpell(GetSpellEntry()->Id)) { - if (target->IsImmunedToSpell(GetSpellInfo(),false)) + if (target->IsImmunedToSpell(GetSpellEntry(),false)) return SPELL_FAILED_TARGET_AURASTATE; } */ + if (SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) + { + if (m_spellInfo->Id == 3411 && !target->isAlive()) + return SPELL_FAILED_BAD_TARGETS; + } + //Must be behind the target. - if (GetSpellInfo()->AttributesEx2 == 0x100000 && (GetSpellInfo()->AttributesEx & 0x200) == 0x200 && target->HasInArc(M_PI, m_caster) - && (GetSpellInfo()->SpellFamilyName != SPELLFAMILY_DRUID || GetSpellInfo()->SpellFamilyFlags != 0x0000000000020000LL)) + if ((GetSpellEntry()->AttributesEx2 == SPELL_ATTR_EX2_FROM_BEHIND) && (GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_UNK9) && target->HasInArc(M_PI, m_caster) + && (GetSpellEntry()->SpellFamilyName != SPELLFAMILY_DRUID || GetSpellEntry()->SpellFamilyFlags != 0x0000000000020000LL)) { SendInterrupted(2); return SPELL_FAILED_NOT_BEHIND; } //Target must be facing you. - if ((GetSpellInfo()->Attributes == 0x150010) && !target->HasInArc(M_PI, m_caster)) + if ((GetSpellEntry()->Attributes == 0x150010) && !target->HasInArc(M_PI, m_caster)) { SendInterrupted(2); return SPELL_FAILED_NOT_INFRONT; } // check if target is in combat - if (target != m_caster && (GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat()) + if (target != m_caster && (GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat()) { return SPELL_FAILED_TARGET_AFFECTING_COMBAT; } } - else if (!m_IsTriggeredSpell) + else if (!IsTriggeredSpell()) { // check pet presents for (int j=0;j<3;j++) { - if (GetSpellInfo()->EffectImplicitTargetA[j] == TARGET_UNIT_PET) + if (GetSpellEntry()->EffectImplicitTargetA[j] == TARGET_UNIT_PET) { if (Pet *pPet = m_caster->GetPet()) { - if (!SpellMgr::SpellIgnoreLOS(GetSpellInfo(), j) && !pPet->IsWithinLOSInMap(m_caster)) + if (!SpellMgr::SpellIgnoreLOS(GetSpellEntry(), j) && !pPet->IsWithinLOSInMap(m_caster)) return SPELL_FAILED_LINE_OF_SIGHT; } break; @@ -3941,12 +3956,12 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_CastItem) { - if (GetSpellInfo()->NeedFillTargetMapForTargets(0) && m_targets.IsEmpty() && !m_targets.HasDst()) + if (GetSpellEntry()->NeedFillTargetMapForTargets(0) && m_targets.IsEmpty() && !m_targets.HasDst()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; } - // Spell casted only on battleground - if ((GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId()==TYPEID_PLAYER) + // Spell cast only on battleground + if ((GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId()==TYPEID_PLAYER) if (!((Player*)m_caster)->InBattleGround()) return SPELL_FAILED_ONLY_BATTLEGROUNDS; @@ -3954,9 +3969,9 @@ SpellCastResult Spell::CheckCast(bool strict) // - with greater than 15 min CD without SPELL_ATTR_EX4_USABLE_IN_ARENA flag // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag // - flying mounts/spells - if ((GetSpellInfo()->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || - GetSpellInfo()->HasApplyAura(SPELL_AURA_FLY) || GetSpellInfo()->HasApplyAura(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || GetSpellInfo()->HasApplyAura(SPELL_AURA_MOD_SPEED_FLIGHT) || - SpellMgr::GetSpellRecoveryTime(GetSpellInfo()) > 15 * MINUTE * 1000 && !(GetSpellInfo()->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA)) + if ((GetSpellEntry()->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || + GetSpellEntry()->HasApplyAura(SPELL_AURA_FLY) || GetSpellEntry()->HasApplyAura(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || GetSpellEntry()->HasApplyAura(SPELL_AURA_MOD_SPEED_FLIGHT) || + SpellMgr::GetSpellRecoveryTime(GetSpellEntry()) > 15 * MINUTE * 1000 && !(GetSpellEntry()->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA)) if (MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId())) if (mapEntry->IsBattleArena()) return SPELL_FAILED_NOT_IN_ARENA; @@ -3974,12 +3989,12 @@ SpellCastResult Spell::CheckCast(bool strict) areaid = m_caster->GetAreaId(); } - if (!SpellMgr::IsSpellAllowedInLocation(GetSpellInfo(), m_caster->GetMapId(), zoneid, areaid)) + if (!SpellMgr::IsSpellAllowedInLocation(GetSpellEntry(), m_caster->GetMapId(), zoneid, areaid)) return SPELL_FAILED_REQUIRES_AREA; // not let players cast spells at mount (and let do it to creatures) - if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && - !SpellMgr::IsPassiveSpell(GetSpellInfo()->Id) && !(GetSpellInfo()->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) + if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !IsTriggeredSpell() && + !SpellMgr::IsPassiveSpell(GetSpellEntry()->Id) && !(GetSpellEntry()->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) { if (m_caster->IsTaxiFlying()) return SPELL_FAILED_NOT_FLYING; @@ -3988,14 +4003,14 @@ SpellCastResult Spell::CheckCast(bool strict) } // always (except passive and triggered spells) check items (focus object can be required for any type casts) - if (!SpellMgr::IsPassiveSpell(GetSpellInfo()->Id) && !m_IsTriggeredSpell) + if (!SpellMgr::IsPassiveSpell(GetSpellEntry()->Id) && !IsTriggeredSpell()) { SpellCastResult castResult = CheckItems(); if (castResult != SPELL_CAST_OK) return castResult; } - if (!m_IsTriggeredSpell || GetSpellInfo()->Id == 33395) // hack for water elemental freeze since it is casted as triggered spell + if (!IsTriggeredSpell() || GetSpellEntry()->Id == 33395) // hack for water elemental freeze since it is cast as triggered spell { SpellCastResult castResult = CheckRange(strict); if (castResult != SPELL_CAST_OK) @@ -4013,28 +4028,28 @@ SpellCastResult Spell::CheckCast(bool strict) for (int i = 0; i < 3; i++) { // for effects of spells that have only one target - switch (GetSpellInfo()->Effect[i]) + switch (GetSpellEntry()->Effect[i]) { case SPELL_EFFECT_DUMMY: { - if (GetSpellInfo()->SpellIconID == 1648) // Execute + if (GetSpellEntry()->SpellIconID == 1648) // Execute { if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) return SPELL_FAILED_BAD_TARGETS; } - else if (GetSpellInfo()->Id == 51582) // Rocket Boots Engaged + else if (GetSpellEntry()->Id == 51582) // Rocket Boots Engaged { if (m_caster->IsInWater()) return SPELL_FAILED_ONLY_ABOVEWATER; } - else if (GetSpellInfo()->SpellIconID==156) // Holy Shock + else if (GetSpellEntry()->SpellIconID==156) // Holy Shock { // spell different for friends and enemies // hart version required facing if (m_targets.getUnitTarget() && !m_caster->IsFriendlyTo(m_targets.getUnitTarget()) && !m_caster->HasInArc(M_PI, m_targets.getUnitTarget())) return SPELL_FAILED_UNIT_NOT_INFRONT; } - else if (GetSpellInfo()->Id == 19938) // Awaken Peon + else if (GetSpellEntry()->Id == 19938) // Awaken Peon { Unit *unit = m_targets.getUnitTarget(); if (!unit || !unit->HasAura(17743, 0)) @@ -4045,7 +4060,7 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_SCHOOL_DAMAGE: { // Hammer of Wrath - if (GetSpellInfo()->SpellVisual == 7250) + if (GetSpellEntry()->SpellVisual == 7250) { if (!m_targets.getUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; @@ -4057,7 +4072,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_LEARN_SPELL: { - if (GetSpellInfo()->EffectImplicitTargetA[i] != TARGET_UNIT_PET) + if (GetSpellEntry()->EffectImplicitTargetA[i] != TARGET_UNIT_PET) break; Pet* pet = m_caster->GetPet(); @@ -4065,7 +4080,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet) return SPELL_FAILED_NO_PET; - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellInfo()->EffectTriggerSpell[i]); + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellEntry()->EffectTriggerSpell[i]); if (!learn_spellproto) return SPELL_FAILED_NOT_KNOWN; @@ -4073,20 +4088,20 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) return SPELL_FAILED_TOO_MANY_SKILLS; - if (GetSpellInfo()->spellLevel > pet->getLevel()) + if (GetSpellEntry()->spellLevel > pet->getLevel()) return SPELL_FAILED_LOWLEVEL; if (!pet->HasTPForSpell(learn_spellproto->Id)) return SPELL_FAILED_TRAINING_POINTS; - if (!pet->IsRightSpellIdForPet(GetSpellInfo()->EffectTriggerSpell[i])) + if (!pet->IsRightSpellIdForPet(GetSpellEntry()->EffectTriggerSpell[i])) return SPELL_FAILED_NO_PET; // Don't know what to put here, anyway this will happen only in trying to bug/cheat break; } case SPELL_EFFECT_TRANS_DOOR: { - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellInfo()->SpellFamilyFlags & 0x80000000) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellEntry()->SpellFamilyFlags & 0x80000000) { if (m_caster->ToPlayer() && m_caster->ToPlayer()->GetBattleGround()) return SPELL_FAILED_NOT_IN_BATTLEGROUND; @@ -4100,7 +4115,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet) return SPELL_FAILED_NO_PET; - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellInfo()->EffectTriggerSpell[i]); + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellEntry()->EffectTriggerSpell[i]); if (!learn_spellproto) return SPELL_FAILED_NOT_KNOWN; @@ -4108,13 +4123,13 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) return SPELL_FAILED_TOO_MANY_SKILLS; - if (GetSpellInfo()->spellLevel > pet->getLevel()) + if (GetSpellEntry()->spellLevel > pet->getLevel()) return SPELL_FAILED_LOWLEVEL; if (!pet->HasTPForSpell(learn_spellproto->Id)) return SPELL_FAILED_TRAINING_POINTS; - if (!pet->IsRightSpellIdForPet(GetSpellInfo()->EffectTriggerSpell[i])) + if (!pet->IsRightSpellIdForPet(GetSpellEntry()->EffectTriggerSpell[i])) return SPELL_FAILED_NO_PET; // Don't know what to put here, anyway this will happen only in trying to bug/cheat break; @@ -4146,7 +4161,7 @@ SpellCastResult Spell::CheckCast(bool strict) // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Unit* target = m_targets.getUnitTarget()) - if (target!=m_caster && target->getPowerType()!=GetSpellInfo()->EffectMiscValue[i]) + if (target!=m_caster && target->getPowerType()!=GetSpellEntry()->EffectMiscValue[i]) return SPELL_FAILED_BAD_TARGETS; break; } @@ -4175,11 +4190,13 @@ SpellCastResult Spell::CheckCast(bool strict) float angle = m_caster->GetAngle(target) - m_caster->GetOrientation() - M_PI; m_caster->GetValidPointInAngle(dest, 2.0f, angle, false); - _path.setPathLengthLimit(SpellMgr::GetSpellMaxRange(GetSpellInfo()) * 1.5f); - _path.calculate(dest.x, dest.y, dest.z); + _path.setPathLengthLimit(SpellMgr::GetSpellMaxRange(GetSpellEntry()) * 1.5f); + bool result = _path.calculate(dest.x, dest.y, dest.z); if (_path.getPathType() & PATHFIND_SHORT) return SPELL_FAILED_OUT_OF_RANGE; + else if (!result) + return SPELL_FAILED_NOPATH; } break; } @@ -4216,15 +4233,15 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_OPEN_LOCK_ITEM: case SPELL_EFFECT_OPEN_LOCK: { - if (GetSpellInfo()->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT && - GetSpellInfo()->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT_ITEM) + if (GetSpellEntry()->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT && + GetSpellEntry()->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT_ITEM) break; if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc. // we need a go target in case of TARGET_GAMEOBJECT - || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT && !m_targets.getGOTarget() + || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT && !m_targets.getGOTarget() // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM - || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT_ITEM && !m_targets.getGOTarget() && + || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT_ITEM && !m_targets.getGOTarget() && (!m_targets.getItemTarget() || !m_targets.getItemTarget()->GetProto()->LockID || m_targets.getItemTarget()->GetOwner() != m_caster)) return SPELL_FAILED_BAD_TARGETS; @@ -4265,7 +4282,7 @@ SpellCastResult Spell::CheckCast(bool strict) break; } - case SPELL_EFFECT_SUMMON_DEAD_PET: + case SPELL_EFFECT_RESURRECT_PET: { Creature *pet = m_caster->GetPet(); if (!pet) @@ -4281,7 +4298,7 @@ SpellCastResult Spell::CheckCast(bool strict) // These won't show up in m_caster->GetPetGUID() case SPELL_EFFECT_SUMMON: { - switch (GetSpellInfo()->EffectMiscValueB[i]) + switch (GetSpellEntry()->EffectMiscValueB[i]) { case SUMMON_TYPE_POSESSED: case SUMMON_TYPE_POSESSED2: @@ -4339,14 +4356,16 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_BAD_TARGETS; - if (!dynamic_cast(m_caster)->GetSelection()) + const Player * pCaster = m_caster->ToPlayer(); + + if (!pCaster->GetSelection()) return SPELL_FAILED_BAD_TARGETS; Player* target = m_targets.getUnitTarget()->ToPlayer(); - if (!target || m_caster == target || !target->IsInSameGroupWith(dynamic_cast(m_caster))) + if (!target || m_caster == target || (!target->IsInSameRaidWith(pCaster) && m_spellInfo->Id != 48955)) return SPELL_FAILED_BAD_TARGETS; - if (m_caster->ToPlayer() && m_caster->ToPlayer()->GetBattleGround()) + if (pCaster->GetBattleGround()) return SPELL_FAILED_DONT_REPORT; // Ritual of Summoning Effect is triggered so don't report // check if our map is dungeon @@ -4355,11 +4374,31 @@ SpellCastResult Spell::CheckCast(bool strict) InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(m_caster->GetMapId()); if (!instance) return SPELL_FAILED_TARGET_NOT_IN_INSTANCE; + if (!target->Satisfy(sObjectMgr.GetAccessRequirement(instance->access_id), m_caster->GetMapId())) return SPELL_FAILED_BAD_TARGETS; + + // if is in instance and summoner and summoned have different instance id's don't summon + if (!target->CanBeSummonedBy(pCaster)) + return SPELL_FAILED_TARGET_LOCKED_TO_RAID_INSTANCE; } break; } + case SPELL_EFFECT_FRIEND_SUMMON: + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + + if (((Player*) m_caster)->GetSelection() == NULL) + return SPELL_FAILED_BAD_TARGETS; + + Player* target = sObjectMgr.GetPlayer(((Player*) m_caster)->GetSelection()); + + if (!target || !target->IsReferAFriendLinked(((Player*) m_caster))) + return SPELL_FAILED_BAD_TARGETS; + + break; + } case SPELL_EFFECT_LEAP: case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER: { @@ -4374,7 +4413,7 @@ SpellCastResult Spell::CheckCast(bool strict) { //Do not allow use of Trinket before BG starts if (m_caster->GetTypeId()==TYPEID_PLAYER) - if (GetSpellInfo()->Id == 22563 || GetSpellInfo()->Id == 22564) + if (GetSpellEntry()->Id == 22563 || GetSpellEntry()->Id == 22564) if (BattleGround const *bg = ((Player*)m_caster)->GetBattleGround()) if (bg->GetStatus() != STATUS_IN_PROGRESS) return SPELL_FAILED_TRY_AGAIN; @@ -4389,7 +4428,7 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_ENERGIZE: { // Consume Magic - if (GetSpellInfo()->Id == 32676) + if (GetSpellEntry()->Id == 32676) { if (m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_UNKNOWN; @@ -4430,11 +4469,11 @@ SpellCastResult Spell::CheckCast(bool strict) for (int i = 0; i < 3; i++) { - switch (GetSpellInfo()->EffectApplyAuraName[i]) + switch (GetSpellEntry()->EffectApplyAuraName[i]) { case SPELL_AURA_DUMMY: { - if (GetSpellInfo()->Id == 1515) + if (GetSpellEntry()->Id == 1515) { if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; @@ -4468,6 +4507,10 @@ SpellCastResult Spell::CheckCast(bool strict) if (!m_targets.getUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + if (Unit *owner = m_targets.getUnitTarget()->GetOwner()) + if (owner->GetTypeId() == TYPEID_PLAYER) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + if (m_targets.getUnitTarget()->GetCharmerGUID()) return SPELL_FAILED_CHARMED; @@ -4485,7 +4528,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_NO_MOUNTS_ALLOWED; // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells - if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !GetSpellInfo()->AreaId) + if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !IsTriggeredSpell() && !GetSpellEntry()->AreaId) return SPELL_FAILED_NO_MOUNTS_ALLOWED; uint32 areaid = m_caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)m_caster)->GetCachedArea() : m_caster->GetAreaId(); @@ -4506,7 +4549,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!m_targets.getUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - // can be casted at non-friendly unit or own pet/charm + // can be cast at non-friendly unit or own pet/charm if (m_caster->IsFriendlyTo(m_targets.getUnitTarget())) return SPELL_FAILED_TARGET_FRIENDLY; @@ -4537,12 +4580,35 @@ SpellCastResult Spell::CheckCast(bool strict) break; } + case SPELL_AURA_MIRROR_IMAGE: + { + Unit* pTarget = m_targets.getUnitTarget(); + + // In case of TARGET_SCRIPT, we have already added a target. Use it here (and find a better solution) + if (m_UniqueTargetInfo.size() == 1) + pTarget = m_caster->GetMap()->GetCreature(m_UniqueTargetInfo.front().targetGUID); + + if (!pTarget) + return SPELL_FAILED_BAD_TARGETS; + + if (pTarget->GetTypeId() != TYPEID_UNIT) // Target must be creature. TODO: Check if target can also be player + return SPELL_FAILED_BAD_TARGETS; + + if (pTarget == m_caster) // Clone self can't be accepted + return SPELL_FAILED_BAD_TARGETS; + + // It is assumed that target can not be cloned if already cloned by same or other clone auras + if (!pTarget->GetAurasByType(SPELL_AURA_MIRROR_IMAGE).empty()) + return SPELL_FAILED_BAD_TARGETS; + + break; + } default: break; } } - if (!SpellMgr::SpellIgnoreLOS(GetSpellInfo(), 0)) + if (!SpellMgr::SpellIgnoreLOS(GetSpellEntry(), 0)) { if (!m_targets.getUnitTarget() && !m_targets.getGOTarget() && !m_targets.getItemTarget()) if (m_targets.m_destX && m_targets.m_destY && m_targets.m_destZ && !m_caster->IsWithinLOS(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ)) @@ -4550,7 +4616,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // check if caster has at least 1 combo point for spells that require combo points - if ((GetSpellInfo()->AttributesEx & (SPELL_ATTR_EX_REQ_COMBO_POINTS1 | SPELL_ATTR_EX_REQ_COMBO_POINTS2)) && m_caster->ToPlayer() && !m_caster->ToPlayer()->GetComboPoints() && !m_IsTriggeredSpell) + if ((GetSpellEntry()->AttributesEx & (SPELL_ATTR_EX_REQ_COMBO_POINTS1 | SPELL_ATTR_EX_REQ_COMBO_POINTS2)) && m_caster->ToPlayer() && !m_caster->ToPlayer()->GetComboPoints() && !IsTriggeredSpell()) return SPELL_FAILED_NO_COMBO_POINTS; // all ok @@ -4562,9 +4628,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) if (!m_caster->isAlive()) return SPELL_FAILED_CASTER_DEAD; - if (m_caster->IsNonMeleeSpellCasted(false) && !m_IsTriggeredSpell) //prevent spellcast interruption by another spellcast + if (m_caster->IsNonMeleeSpellCast(false) && !IsTriggeredSpell()) //prevent spellcast interruption by another spellcast return SPELL_FAILED_SPELL_IN_PROGRESS; - if (m_caster->isInCombat() && SpellMgr::IsNonCombatSpell(GetSpellInfo())) + if (m_caster->isInCombat() && SpellMgr::IsNonCombatSpell(GetSpellEntry())) return SPELL_FAILED_AFFECTING_COMBAT; if (m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->isPet() || m_caster->isCharmed())) @@ -4579,7 +4645,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target) bool need = false; for (uint32 i = 0;i<3;i++) { - if (GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ALLY || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_PARTY || GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_DST_TARGET_ENEMY) + if (GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ALLY || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_PARTY || GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_DST_TARGET_ENEMY) { need = true; if (!target) @@ -4601,7 +4667,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target) return SPELL_FAILED_BAD_TARGETS; } //cooldown - if (((Creature*)m_caster)->HasSpellCooldown(GetSpellInfo()->Id)) + if (((Creature*)m_caster)->HasSpellCooldown(GetSpellEntry()->Id)) return SPELL_FAILED_NOT_READY; } @@ -4613,7 +4679,7 @@ SpellCastResult Spell::CheckCasterAuras() const // Flag drop spells totally immuned to caster auras // FIXME: find more nice check for all totally immuned spells // AttributesEx3 & 0x10000000? - if (GetSpellInfo()->Id==23336 || GetSpellInfo()->Id==23334 || GetSpellInfo()->Id==34991) + if (GetSpellEntry()->Id==23336 || GetSpellEntry()->Id==23334 || GetSpellEntry()->Id==34991) return SPELL_CAST_OK; uint8 school_immune = 0; @@ -4622,34 +4688,34 @@ SpellCastResult Spell::CheckCasterAuras() const //Check if the spell grants school or mechanic immunity. //We use bitmasks so the loop is done only once and not on every aura check below. - if (GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) + if (GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) { for (int i = 0;i < 3; i ++) { - if (GetSpellInfo()->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) - school_immune |= uint32(GetSpellInfo()->EffectMiscValue[i]); - else if (GetSpellInfo()->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) - mechanic_immune |= 1 << uint32(GetSpellInfo()->EffectMiscValue[i]); - else if (GetSpellInfo()->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) - dispel_immune |= SpellMgr::GetDispellMask(DispelType(GetSpellInfo()->EffectMiscValue[i])); + if (GetSpellEntry()->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) + school_immune |= uint32(GetSpellEntry()->EffectMiscValue[i]); + else if (GetSpellEntry()->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) + mechanic_immune |= 1 << uint32(GetSpellEntry()->EffectMiscValue[i]); + else if (GetSpellEntry()->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) + dispel_immune |= SpellMgr::GetDispellMask(DispelType(GetSpellEntry()->EffectMiscValue[i])); } //immune movement impairment and loss of control - if (GetSpellInfo()->Id==(uint32)42292) + if (GetSpellEntry()->Id==(uint32)42292) mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; } //Check whether the cast should be prevented by any state you might have. SpellCastResult prevented_reason = SPELL_CAST_OK; // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out - if (!(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) && m_caster->HasAuraType(SPELL_AURA_MOD_STUN)) + if (!(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) && m_caster->HasAuraType(SPELL_AURA_MOD_STUN)) prevented_reason = SPELL_FAILED_STUNNED; - else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED) && !(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED) && !(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) prevented_reason = SPELL_FAILED_CONFUSED; - else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING) && !(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING) && !(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) prevented_reason = SPELL_FAILED_FLEEING; - else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED) && GetSpellInfo()->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) + else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED) && GetSpellEntry()->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) prevented_reason = SPELL_FAILED_SILENCED; - else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) && GetSpellInfo()->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) + else if (m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) && GetSpellEntry()->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) prevented_reason = SPELL_FAILED_PACIFIED; // Attr must make flag drop spell totally immune from all effects @@ -4676,30 +4742,30 @@ SpellCastResult Spell::CheckCasterAuras() const switch (itr->second->GetModifier()->m_auraname) { case SPELL_AURA_MOD_STUN: - if (!(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) + if (!(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) return SPELL_FAILED_STUNNED; break; case SPELL_AURA_MOD_CONFUSE: - if (!(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + if (!(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) return SPELL_FAILED_CONFUSED; break; case SPELL_AURA_MOD_FEAR: - if (!(GetSpellInfo()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + if (!(GetSpellEntry()->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) return SPELL_FAILED_FLEEING; break; case SPELL_AURA_MOD_SILENCE: case SPELL_AURA_MOD_PACIFY: case SPELL_AURA_MOD_PACIFY_SILENCE: - if (GetSpellInfo()->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) + if (GetSpellEntry()->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) return SPELL_FAILED_PACIFIED; - else if (GetSpellInfo()->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) + else if (GetSpellEntry()->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) return SPELL_FAILED_SILENCED; break; } } } } - //You are prevented from casting and the spell casted does not grant immunity. Return a failed error. + //You are prevented from casting and the spell cast does not grant immunity. Return a failed error. else return prevented_reason; } @@ -4713,22 +4779,22 @@ bool Spell::CanAutoCast(Unit* target) for (uint32 j = 0;j<3;j++) { - if (GetSpellInfo()->Effect[j] == SPELL_EFFECT_APPLY_AURA) + if (GetSpellEntry()->Effect[j] == SPELL_EFFECT_APPLY_AURA) { - if (GetSpellInfo()->StackAmount <= 1) + if (GetSpellEntry()->StackAmount <= 1) { - if (target->HasAura(GetSpellInfo()->Id, j)) + if (target->HasAura(GetSpellEntry()->Id, j)) return false; } else { - if (target->GetAuras().count(Unit::spellEffectPair(GetSpellInfo()->Id, j)) >= GetSpellInfo()->StackAmount) + if (target->GetAuras().count(Unit::spellEffectPair(GetSpellEntry()->Id, j)) >= GetSpellEntry()->StackAmount) return false; } } - else if (SpellMgr::IsAreaAuraEffect(GetSpellInfo()->Effect[j])) + else if (SpellMgr::IsAreaAuraEffect(GetSpellEntry()->Effect[j])) { - if (target->HasAura(GetSpellInfo()->Id, j)) + if (target->HasAura(GetSpellEntry()->Id, j)) return false; } } @@ -4757,7 +4823,7 @@ SpellCastResult Spell::CheckRange(bool strict) GameObject *pGoTarget = m_targets.getGOTarget(); // self cast doesn't need range checking -- also for Starshards fix - if (GetSpellInfo()->rangeIndex == 1) + if (GetSpellEntry()->rangeIndex == 1) return SPELL_CAST_OK; // i do not know why we need this @@ -4766,13 +4832,13 @@ SpellCastResult Spell::CheckRange(bool strict) else //add radius of caster and ~5 yds "give" range_mod = 6.25;*/ - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex); + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex); float max_range = SpellMgr::GetSpellMaxRange(srange); // + range_mod; float min_range = SpellMgr::GetSpellMinRange(srange); uint32 range_type = SpellMgr::GetSpellRangeType(srange); if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RANGE, max_range, this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RANGE, max_range, this); if (target && target != m_caster) { @@ -4794,7 +4860,7 @@ SpellCastResult Spell::CheckRange(bool strict) return SPELL_FAILED_TOO_CLOSE; if (m_caster->GetTypeId() == TYPEID_PLAYER && - (GetSpellInfo()->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(M_PI, target)) + (GetSpellEntry()->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(M_PI, target)) return SPELL_FAILED_UNIT_NOT_INFRONT; } @@ -4812,7 +4878,7 @@ SpellCastResult Spell::CheckRange(bool strict) return SPELL_FAILED_OUT_OF_RANGE; if (min_range && dist < min_range) return SPELL_FAILED_TOO_CLOSE; - if ( m_caster->GetTypeId() == TYPEID_PLAYER && (GetSpellInfo()->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(M_PI, pGoTarget)) + if ( m_caster->GetTypeId() == TYPEID_PLAYER && (GetSpellEntry()->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(M_PI, pGoTarget)) return SPELL_FAILED_NOT_INFRONT; break; case GAMEOBJECT_TYPE_CHEST: @@ -4841,20 +4907,20 @@ SpellCastResult Spell::CheckPower() return SPELL_CAST_OK; // health as power used - need check health amount - if (GetSpellInfo()->powerType == POWER_HEALTH) + if (GetSpellEntry()->powerType == POWER_HEALTH) { if (m_caster->GetHealth() <= m_powerCost) return SPELL_FAILED_CASTER_AURASTATE; return SPELL_CAST_OK; } // Check valid power type - if (GetSpellInfo()->powerType >= MAX_POWERS) + if (GetSpellEntry()->powerType >= MAX_POWERS) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::CheckMana: Unknown power type '%d'", GetSpellInfo()->powerType); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::CheckMana: Unknown power type '%d'", GetSpellEntry()->powerType); return SPELL_FAILED_UNKNOWN; } // Check power amount - Powers powerType = Powers(GetSpellInfo()->powerType); + Powers powerType = Powers(GetSpellEntry()->powerType); if (m_caster->GetPower(powerType) < m_powerCost) return SPELL_FAILED_NO_POWER; else @@ -4896,10 +4962,10 @@ SpellCastResult Spell::CheckItems() for (int i = 0; i < 3; i++) { // skip check, pet not required like checks, and for TARGET_PET m_targets.getUnitTarget() is not the real target but the caster - if (GetSpellInfo()->EffectImplicitTargetA[i] == TARGET_UNIT_PET) + if (GetSpellEntry()->EffectImplicitTargetA[i] == TARGET_UNIT_PET) continue; - if (GetSpellInfo()->Effect[i] == SPELL_EFFECT_HEAL) + if (GetSpellEntry()->Effect[i] == SPELL_EFFECT_HEAL) { if (m_targets.getUnitTarget()->GetHealth() == m_targets.getUnitTarget()->GetMaxHealth()) { @@ -4914,15 +4980,15 @@ SpellCastResult Spell::CheckItems() } // Mana Potion, Rage Potion, Thistle Tea(Rogue), ... - if (GetSpellInfo()->Effect[i] == SPELL_EFFECT_ENERGIZE) + if (GetSpellEntry()->Effect[i] == SPELL_EFFECT_ENERGIZE) { - if (GetSpellInfo()->EffectMiscValue[i] < 0 || GetSpellInfo()->EffectMiscValue[i] >= MAX_POWERS) + if (GetSpellEntry()->EffectMiscValue[i] < 0 || GetSpellEntry()->EffectMiscValue[i] >= MAX_POWERS) { failReason = SPELL_FAILED_ALREADY_AT_FULL_POWER; continue; } - Powers power = Powers(GetSpellInfo()->EffectMiscValue[i]); + Powers power = Powers(GetSpellEntry()->EffectMiscValue[i]); if (m_targets.getUnitTarget()->GetPower(power) == m_targets.getUnitTarget()->GetMaxPower(power)) { failReason = SPELL_FAILED_ALREADY_AT_FULL_POWER; @@ -4949,41 +5015,41 @@ SpellCastResult Spell::CheckItems() if (!m_targets.getItemTarget()) return SPELL_FAILED_ITEM_GONE; - if (!m_targets.getItemTarget()->IsFitToSpellRequirements(GetSpellInfo())) + if (!m_targets.getItemTarget()->IsFitToSpellRequirements(GetSpellEntry())) return SPELL_FAILED_EQUIPPED_ITEM_CLASS; } // if not item target then required item must be equipped else { - if (m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->HasItemFitToSpellReqirements(GetSpellInfo())) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->HasItemFitToSpellReqirements(GetSpellEntry())) return SPELL_FAILED_EQUIPPED_ITEM_CLASS; } // check spell focus object - if (GetSpellInfo()->RequiresSpellFocus) + if (GetSpellEntry()->RequiresSpellFocus) { GameObject* ok = NULL; - Hellground::GameObjectFocusCheck go_check(m_caster,GetSpellInfo()->RequiresSpellFocus); + Hellground::GameObjectFocusCheck go_check(m_caster,GetSpellEntry()->RequiresSpellFocus); Hellground::ObjectSearcher checker(ok,go_check); Cell::VisitGridObjects(m_caster, checker, m_caster->GetMap()->GetVisibilityDistance()); - if (!ok) + if (!ok || !ok->isSpawned()) return SPELL_FAILED_REQUIRES_SPELL_FOCUS; focusObject = ok; // game object found in range } // check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case. - if (!m_IsTriggeredSpell && !p_caster->CanNoReagentCast(GetSpellInfo())) + if (!IsTriggeredSpell() && !p_caster->CanNoReagentCast(GetSpellEntry())) { for (uint32 i=0;i<8;i++) { - if (GetSpellInfo()->Reagent[i] <= 0) + if (GetSpellEntry()->Reagent[i] <= 0) continue; - uint32 itemid = GetSpellInfo()->Reagent[i]; - uint32 itemcount = GetSpellInfo()->ReagentCount[i]; + uint32 itemid = GetSpellEntry()->Reagent[i]; + uint32 itemcount = GetSpellEntry()->ReagentCount[i]; // if CastItem is also spell reagent if (m_CastItem && m_CastItem->GetEntry() == itemid) @@ -5011,9 +5077,9 @@ SpellCastResult Spell::CheckItems() uint32 totems = 2; for (int i = 0; i < 2; ++i) { - if (GetSpellInfo()->Totem[i] != 0) + if (GetSpellEntry()->Totem[i] != 0) { - if (p_caster->HasItemCount(GetSpellInfo()->Totem[i],1)) + if (p_caster->HasItemCount(GetSpellEntry()->Totem[i],1)) { totems -= 1; continue; @@ -5028,9 +5094,9 @@ SpellCastResult Spell::CheckItems() uint32 TotemCategory = 2; for (int i=0;i<2;++i) { - if (GetSpellInfo()->TotemCategory[i] != 0) + if (GetSpellEntry()->TotemCategory[i] != 0) { - if (p_caster->HasItemTotemCategory(GetSpellInfo()->TotemCategory[i])) + if (p_caster->HasItemTotemCategory(GetSpellEntry()->TotemCategory[i])) { TotemCategory -= 1; continue; @@ -5045,14 +5111,14 @@ SpellCastResult Spell::CheckItems() // special checks for spell effects for (int i = 0; i < 3; i++) { - switch (GetSpellInfo()->Effect[i]) + switch (GetSpellEntry()->Effect[i]) { case SPELL_EFFECT_CREATE_ITEM: { - if (!m_IsTriggeredSpell && GetSpellInfo()->EffectItemType[i]) + if (!IsTriggeredSpell() && GetSpellEntry()->EffectItemType[i]) { ItemPosCountVec dest; - uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellInfo()->EffectItemType[i], 1); + uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellEntry()->EffectItemType[i], 1); if (msg != EQUIP_ERR_OK) { p_caster->SendEquipError(msg, NULL, NULL); @@ -5067,18 +5133,14 @@ SpellCastResult Spell::CheckItems() if (!targetItem) return SPELL_FAILED_ITEM_NOT_FOUND; - if (targetItem->GetProto()->ItemLevel < GetSpellInfo()->baseLevel) + if (targetItem->GetProto()->ItemLevel < GetSpellEntry()->baseLevel) return SPELL_FAILED_LOWLEVEL; + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(GetSpellEntry()->EffectMiscValue[0]); + if (!pEnchant) + return SPELL_FAILED_ERROR; // Not allow enchant in trade slot for some enchant type - if (targetItem->GetOwner() != m_caster) - { - uint32 enchant_id = GetSpellInfo()->EffectMiscValue[i]; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!pEnchant) - return SPELL_FAILED_ERROR; - if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) - return SPELL_FAILED_NOT_TRADEABLE; - } + if (targetItem->GetOwner() != m_caster && (GetSpellEntry()->AttributesEx2 & (SPELL_ATTR_EX2_NOT_USABLE_VIA_TRADE|SPELL_ATTR_EX2_UNK3))) + return SPELL_FAILED_NOT_TRADEABLE; break; } case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: @@ -5086,16 +5148,14 @@ SpellCastResult Spell::CheckItems() Item *item = m_targets.getItemTarget(); if (!item) return SPELL_FAILED_ITEM_NOT_FOUND; + if (item->GetProto()->ItemLevel < GetSpellEntry()->spellLevel) + return SPELL_FAILED_LOWLEVEL; + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(GetSpellEntry()->EffectMiscValue[0]); + if (!pEnchant) + return SPELL_FAILED_ERROR; // Not allow enchant in trade slot for some enchant type - if (item->GetOwner() != m_caster) - { - uint32 enchant_id = GetSpellInfo()->EffectMiscValue[i]; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!pEnchant) - return SPELL_FAILED_ERROR; - if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) - return SPELL_FAILED_NOT_TRADEABLE; - } + if (item->GetOwner() != m_caster && (GetSpellEntry()->AttributesEx2 & (SPELL_ATTR_EX2_NOT_USABLE_VIA_TRADE|SPELL_ATTR_EX2_UNK3))) + return SPELL_FAILED_NOT_TRADEABLE; break; } case SPELL_EFFECT_ENCHANT_HELD_ITEM: @@ -5232,12 +5292,12 @@ void Spell::Delayed() // only called in DealDamage() // return; // spell is active and can't be time-backed // spells not loosing casting time (slam, dynamites, bombs..) - //if(!(GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE)) + //if(!(GetSpellEntry()->InterruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE)) // return; //check resist chance int32 resistChance = 100; //must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(GetSpellInfo()->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); + ((Player*)m_caster)->ApplySpellMod(GetSpellEntry()->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; if (roll_chance_i(resistChance)) return; @@ -5252,7 +5312,7 @@ void Spell::Delayed() // only called in DealDamage() else m_timer += delaytime; - sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage",GetSpellInfo()->Id,delaytime); + sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage",GetSpellEntry()->Id,delaytime); WorldPacket data(SMSG_SPELL_DELAYED, 8+4); data << m_caster->GetPackGUID(); @@ -5268,7 +5328,7 @@ void Spell::DelayedChannel() //check resist chance int32 resistChance = 100; //must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(GetSpellInfo()->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); + ((Player*)m_caster)->ApplySpellMod(GetSpellEntry()->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; if (roll_chance_i(resistChance)) return; @@ -5283,7 +5343,7 @@ void Spell::DelayedChannel() else m_timer -= delaytime; - sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", GetSpellInfo()->Id, delaytime, m_timer); + sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", GetSpellEntry()->Id, delaytime, m_timer); for (std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) { @@ -5297,7 +5357,7 @@ void Spell::DelayedChannel() { for (int j=0;j<3;j++) if (ihit->effectMask & (1<DelayAura(GetSpellInfo()->Id, j, delaytime); + unit->DelayAura(GetSpellEntry()->Id, j, delaytime); } } @@ -5306,7 +5366,7 @@ void Spell::DelayedChannel() for (int j = 0; j < 3; j++) { // partially interrupt persistent area auras - DynamicObject* dynObj = m_caster->GetDynObject(GetSpellInfo()->Id, j); + DynamicObject* dynObj = m_caster->GetDynObject(GetSpellEntry()->Id, j); if (dynObj) dynObj->Delay(delaytime); } @@ -5332,15 +5392,15 @@ void Spell::UpdatePointers() bool Spell::IsAffectedBy(SpellEntry const *spellInfo, uint32 effectId) { - return sSpellMgr.IsAffectedBySpell(GetSpellInfo(),spellInfo->Id,effectId,spellInfo->EffectItemType[effectId]); + return sSpellMgr.IsAffectedBySpell(GetSpellEntry(),spellInfo->Id,effectId,spellInfo->EffectItemType[effectId]); } bool Spell::CheckTargetCreatureType(Unit* target) const { - uint32 spellCreatureTargetMask = GetSpellInfo()->TargetCreatureType; + uint32 spellCreatureTargetMask = GetSpellEntry()->TargetCreatureType; // Curse of Doom : not find another way to fix spell target check :/ - if (GetSpellInfo()->SpellFamilyName==SPELLFAMILY_WARLOCK && GetSpellInfo()->SpellFamilyFlags == 0x0200000000LL) + if (GetSpellEntry()->SpellFamilyName==SPELLFAMILY_WARLOCK && GetSpellEntry()->SpellFamilyFlags == 0x0200000000LL) { // not allow cast at player if (target->isCharmedOwnedByPlayerOrPlayer()) @@ -5349,8 +5409,8 @@ bool Spell::CheckTargetCreatureType(Unit* target) const spellCreatureTargetMask = 0x7FF; } - // Dismiss Pet and Taming Lesson skipped - if (GetSpellInfo()->Id == 2641 || GetSpellInfo()->Id == 23356) + // Dismiss Pet and Taming Lesson skipped and Control Roskipped + if (GetSpellEntry()->Id == 2641 || GetSpellEntry()->Id == 23356 || GetSpellEntry()->Id == 30009) spellCreatureTargetMask = 0; if (spellCreatureTargetMask) @@ -5368,7 +5428,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() return(CURRENT_MELEE_SPELL); else if (IsAutoRepeat()) return(CURRENT_AUTOREPEAT_SPELL); - else if (SpellMgr::IsChanneledSpell(GetSpellInfo())) + else if (SpellMgr::IsChanneledSpell(GetSpellEntry())) return(CURRENT_CHANNELED_SPELL); else return(CURRENT_GENERIC_SPELL); @@ -5376,7 +5436,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() bool Spell::CanIgnoreNotAttackableFlags() { - switch(GetSpellInfo()->Id) + switch(GetSpellEntry()->Id) { case 14813: // Dark Iron Drunk Mug case 32958: // Crystal Channel @@ -5390,19 +5450,19 @@ bool Spell::CanIgnoreNotAttackableFlags() bool Spell::CheckTarget(Unit* target, uint32 eff) { - if (GetSpellInfo()->Effect[eff] == SPELL_EFFECT_APPLY_AURA && (GetSpellInfo()->EffectImplicitTargetA[eff] == TARGET_UNIT_PARTY_TARGET || - GetSpellInfo()->EffectImplicitTargetA[eff] == TARGET_UNIT_CLASS_TARGET) && target->getLevel() < GetSpellInfo()->spellLevel) + if (GetSpellEntry()->Effect[eff] == SPELL_EFFECT_APPLY_AURA && (GetSpellEntry()->EffectImplicitTargetA[eff] == TARGET_UNIT_PARTY_TARGET || + GetSpellEntry()->EffectImplicitTargetA[eff] == TARGET_UNIT_CLASS_TARGET) && target->getLevel() < GetSpellEntry()->spellLevel) return false; // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) - if (GetSpellInfo()->EffectImplicitTargetA[eff] != TARGET_UNIT_CASTER) + if (GetSpellEntry()->EffectImplicitTargetA[eff] != TARGET_UNIT_CASTER) { if (!CheckTargetCreatureType(target)) return false; } // hack for level req - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Songflower Serenade case 15366: @@ -5420,12 +5480,12 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) } } - if (GetSpellInfo()->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY && target->GetTypeId() != TYPEID_PLAYER && - GetSpellInfo()->EffectImplicitTargetA[eff] != TARGET_UNIT_CASTER) + if (GetSpellEntry()->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY && target->GetTypeId() != TYPEID_PLAYER && + GetSpellEntry()->EffectImplicitTargetA[eff] != TARGET_UNIT_CASTER) return false; - if (GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF && m_caster == target && - !(GetSpellInfo()->EffectImplicitTargetA[eff] == TARGET_UNIT_CASTER && GetSpellInfo()->EffectImplicitTargetB[eff] == 0)) + if (GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF && m_caster == target && + !(GetSpellEntry()->EffectImplicitTargetA[eff] == TARGET_UNIT_CASTER && GetSpellEntry()->EffectImplicitTargetB[eff] == 0)) return false; // Check targets for not_selectable unit flag and remove @@ -5443,26 +5503,28 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) if (((Player*)target)->GetVisibility() == VISIBILITY_OFF) return false; - if (((Player*)target)->isGameMaster() && !SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + if (((Player*)target)->isGameMaster() && !SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) return false; } //Do not check LOS for triggered spells - if (m_IsTriggeredSpell && !m_caster->ToTotem()) + if (IsTriggeredSpell() && !m_caster->ToTotem()) return true; //Check targets for LOS visibility (except spells without range limitations) - switch (GetSpellInfo()->Effect[eff]) + switch (GetSpellEntry()->Effect[eff]) { + case SPELL_EFFECT_FRIEND_SUMMON: case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere break; case SPELL_EFFECT_DUMMY: - if (GetSpellInfo()->Id!=20577) // Cannibalize + if (GetSpellEntry()->Id!=20577) // Cannibalize break; //fall through + case SPELL_EFFECT_RESURRECT: case SPELL_EFFECT_RESURRECT_NEW: // player far away, maybe his corpse near? - if (target!=m_caster && !SpellMgr::SpellIgnoreLOS(GetSpellInfo(), eff) && !target->IsWithinLOSInMap(m_caster)) + if (target!=m_caster && !SpellMgr::SpellIgnoreLOS(GetSpellEntry(), eff) && !target->IsWithinLOSInMap(m_caster)) { if (!m_targets.getCorpseTargetGUID()) return false; @@ -5474,14 +5536,14 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) if (target->GetGUID()!=corpse->GetOwnerGUID()) return false; - if (!SpellMgr::SpellIgnoreLOS(GetSpellInfo(), eff) && !corpse->IsWithinLOSInMap(m_caster)) + if (!SpellMgr::SpellIgnoreLOS(GetSpellEntry(), eff) && !corpse->IsWithinLOSInMap(m_caster)) return false; } // all ok by some way or another, skip normal check break; default: // normal case - if (target!=m_caster && !SpellMgr::SpellIgnoreLOS(GetSpellInfo(), eff) && !target->IsWithinLOSInMap(m_caster)) + if (target!=m_caster && !SpellMgr::SpellIgnoreLOS(GetSpellEntry(), eff) && !target->IsWithinLOSInMap(m_caster)) return false; break; @@ -5497,9 +5559,9 @@ Unit* Spell::SelectMagnetTarget() if (!target) return NULL; - if (GetSpellInfo()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) + if (GetSpellEntry()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) { - if (GetSpellInfo()->Attributes & (SPELL_ATTR_ABILITY | SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || GetSpellInfo()->AttributesEx & SPELL_ATTR_EX_CANT_BE_REDIRECTED) + if (GetSpellEntry()->Attributes & (SPELL_ATTR_ABILITY | SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) || GetSpellEntry()->AttributesEx & SPELL_ATTR_EX_CANT_BE_REDIRECTED) return target; if (target->HasAuraType(SPELL_AURA_SPELL_MAGNET)) @@ -5533,7 +5595,7 @@ Unit* Spell::SelectMagnetTarget() } } } - else if(GetSpellInfo()->DmgClass == SPELL_DAMAGE_CLASS_MELEE || GetSpellInfo()->DmgClass == SPELL_DAMAGE_CLASS_RANGED) + else if(GetSpellEntry()->DmgClass == SPELL_DAMAGE_CLASS_MELEE || GetSpellEntry()->DmgClass == SPELL_DAMAGE_CLASS_RANGED) { if (target->HasAuraType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER)) { @@ -5562,8 +5624,8 @@ Unit* Spell::SelectMagnetTarget() bool Spell::IsNeedSendToClient() const { - return GetSpellInfo()->SpellVisual!=0 || SpellMgr::IsChanneledSpell(GetSpellInfo()) || - GetSpellInfo()->speed > 0.0f || !m_triggeredByAuraSpell && !m_IsTriggeredSpell; + return GetSpellEntry()->SpellVisual!=0 || SpellMgr::IsChanneledSpell(GetSpellEntry()) || + GetSpellEntry()->speed > 0.0f || !m_triggeredByAuraSpell && !IsTriggeredSpell(); } bool Spell::HaveTargetsForEffect(uint8 effect) const @@ -5610,7 +5672,7 @@ SpellEvent::~SpellEvent() else { sLog.outLog(LOG_DEFAULT, "ERROR: ~SpellEvent: %s %u tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", - (m_Spell->GetCaster()->GetTypeId()==TYPEID_PLAYER?"Player":"Creature"), m_Spell->GetCaster()->GetGUIDLow(),m_Spell->GetSpellInfo()->Id); + (m_Spell->GetCaster()->GetTypeId()==TYPEID_PLAYER?"Player":"Creature"), m_Spell->GetCaster()->GetGUIDLow(),m_Spell->GetSpellEntry()->Id); } } @@ -5642,13 +5704,13 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time) { // no, we aren't, do the typical update // check, if we have channeled spell on our hands - if (SpellMgr::IsChanneledSpell(m_Spell->GetSpellInfo())) + if (SpellMgr::IsChanneledSpell(m_Spell->GetSpellEntry())) { - // evented channeled spell is processed separately, casted once after delay, and not destroyed till finish + // evented channeled spell is processed separately, cast once after delay, and not destroyed till finish // check, if we have casting anything else except this channeled spell and autorepeat - if (m_Spell->GetCaster()->IsNonMeleeSpellCasted(false, true, true)) + if (m_Spell->GetCaster()->IsNonMeleeSpellCast(false, true, true)) { - // another non-melee non-delayed spell is casted now, abort + // another non-melee non-delayed spell is cast now, abort m_Spell->cancel(); } // Check if target of channeled spell still in range @@ -5739,7 +5801,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk reqKey = true; // wrong locktype, skip - if (uint32(GetSpellInfo()->EffectMiscValue[effIndex]) != lockInfo->Index[j]) + if (uint32(GetSpellEntry()->EffectMiscValue[effIndex]) != lockInfo->Index[j]) continue; skillId = SkillByLockType(LockType(lockInfo->Index[j])); @@ -5747,7 +5809,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk if (skillId != SKILL_NONE) { // skill bonus provided by casting spell (mostly item spells) - // add the damage modifier from the spell casted (cheat lock / skeleton key etc.) (use m_currentBasePoints, CalculateDamage returns wrong value) + // add the damage modifier from the spell cast (cheat lock / skeleton key etc.) (use m_currentBasePoints, CalculateDamage returns wrong value) uint32 spellSkillBonus = uint32(m_currentBasePoints[effIndex]+1); reqSkillValue = lockInfo->Skill[j]; @@ -5793,10 +5855,10 @@ bool Spell::IsValidSingleTargetSpell(Unit const* target) const { for (int i = 0; i < 3; ++i) { - if (!IsValidSingleTargetEffect(target, Targets(GetSpellInfo()->EffectImplicitTargetA[i]))) + if (!IsValidSingleTargetEffect(target, Targets(GetSpellEntry()->EffectImplicitTargetA[i]))) return false; // Need to check B? - //if(!IsValidSingleTargetEffect(GetSpellInfo()->EffectImplicitTargetB[i], target) + //if(!IsValidSingleTargetEffect(GetSpellEntry()->EffectImplicitTargetB[i], target) // return false; } return true; @@ -5810,11 +5872,11 @@ void Spell::CalculateDamageDoneForAllTargets() if (m_applyMultiplierMask & (1 << i)) { // Get multiplier - multiplier[i] = GetSpellInfo()->DmgMultiplier[i]; + multiplier[i] = GetSpellEntry()->DmgMultiplier[i]; // Apply multiplier mods if (m_originalCaster) if (Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier[i], this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier[i], this); } } @@ -5837,16 +5899,16 @@ void Spell::CalculateDamageDoneForAllTargets() { target.damage += CalculateDamageDone(unit, mask, multiplier); if (m_originalCaster) - target.crit = m_originalCaster->isSpellCrit(unit, GetSpellInfo(), m_spellSchoolMask, m_attackType); + target.crit = m_originalCaster->isSpellCrit(unit, GetSpellEntry(), m_spellSchoolMask, m_attackType); else - target.crit = m_caster->isSpellCrit(unit, GetSpellInfo(), m_spellSchoolMask, m_attackType); + target.crit = m_caster->isSpellCrit(unit, GetSpellEntry(), m_spellSchoolMask, m_attackType); } else if (target.missCondition == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) { if (target.reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him { target.damage += CalculateDamageDone(m_caster, mask, multiplier); - target.crit = m_caster->isSpellCrit(m_caster, GetSpellInfo(), m_spellSchoolMask, m_attackType); + target.crit = m_caster->isSpellCrit(m_caster, GetSpellEntry(), m_spellSchoolMask, m_attackType); } } } @@ -5863,7 +5925,7 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul m_damage = 0; damage = CalculateDamage(i, NULL); - switch (GetSpellInfo()->Effect[i]) + switch (GetSpellEntry()->Effect[i]) { case SPELL_EFFECT_SCHOOL_DAMAGE: SpellDamageSchoolDmg(i); @@ -5881,8 +5943,8 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul if (m_damage > 0) { - if (IsAreaEffectTarget[GetSpellInfo()->EffectImplicitTargetA[i]] || IsAreaEffectTarget[GetSpellInfo()->EffectImplicitTargetB[i]] - || GetSpellInfo()->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) + if (IsAreaEffectTarget[GetSpellEntry()->EffectImplicitTargetA[i]] || IsAreaEffectTarget[GetSpellEntry()->EffectImplicitTargetB[i]] + || GetSpellEntry()->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) { if (int32 reducedPct = unit->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE)) m_damage = m_damage * (100 + reducedPct) / 100; @@ -5906,15 +5968,15 @@ void Spell::SetSpellValue(SpellValueMod mod, int32 value) switch (mod) { case SPELLVALUE_BASE_POINT0: - m_spellValue->EffectBasePoints[0] = value - int32(GetSpellInfo()->EffectBaseDice[0]); + m_spellValue->EffectBasePoints[0] = value - int32(GetSpellEntry()->EffectBaseDice[0]); m_currentBasePoints[0] = m_spellValue->EffectBasePoints[0]; //this should be removed in the future break; case SPELLVALUE_BASE_POINT1: - m_spellValue->EffectBasePoints[1] = value - int32(GetSpellInfo()->EffectBaseDice[1]); + m_spellValue->EffectBasePoints[1] = value - int32(GetSpellEntry()->EffectBaseDice[1]); m_currentBasePoints[1] = m_spellValue->EffectBasePoints[1]; break; case SPELLVALUE_BASE_POINT2: - m_spellValue->EffectBasePoints[2] = value - int32(GetSpellInfo()->EffectBaseDice[2]); + m_spellValue->EffectBasePoints[2] = value - int32(GetSpellEntry()->EffectBaseDice[2]); m_currentBasePoints[2] = m_spellValue->EffectBasePoints[2]; break; case SPELLVALUE_MAX_TARGETS: @@ -5933,27 +5995,27 @@ bool Spell::HasGlobalCooldown() { // Only player or controlled units have global cooldown if (m_caster->GetCharmInfo()) - return m_caster->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(GetSpellInfo()); + return m_caster->GetCharmInfo()->GetCooldownMgr().HasGlobalCooldown(GetSpellEntry()); else if (m_caster->GetTypeId() == TYPEID_PLAYER) - return ((Player*)m_caster)->GetGlobalCooldownMgr().HasGlobalCooldown(GetSpellInfo()); + return ((Player*)m_caster)->GetCooldownMgr().HasGlobalCooldown(GetSpellEntry()); else return false; } void Spell::TriggerGlobalCooldown() { - int32 gcd = GetSpellInfo()->StartRecoveryTime; + int32 gcd = GetSpellEntry()->StartRecoveryTime; if (!gcd) return; // Global cooldown can't leave range 1..1.5 secs - // There are some spells (mostly not casted directly by player) that have < 1 sec and > 1.5 sec global cooldowns + // There are some spells (mostly not cast directly by player) that have < 1 sec and > 1.5 sec global cooldowns // but as tests show are not affected by any spell mods. - if (GetSpellInfo()->StartRecoveryTime >= MIN_GCD && GetSpellInfo()->StartRecoveryTime <= MAX_GCD) + if (GetSpellEntry()->StartRecoveryTime >= MIN_GCD && GetSpellEntry()->StartRecoveryTime <= MAX_GCD) { // gcd modifier auras are applied only to own spells and only players have such mods //if (m_caster->GetTypeId() == TYPEID_PLAYER) - // ((Player*)m_caster)->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this); + // ((Player*)m_caster)->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this); // Apply haste rating gcd = int32(float(gcd) * m_caster->GetFloatValue(UNIT_MOD_CAST_SPEED)); @@ -5965,14 +6027,14 @@ void Spell::TriggerGlobalCooldown() // Only players or controlled units have global cooldown if (m_caster->GetCharmInfo()) - m_caster->GetCharmInfo()->GetGlobalCooldownMgr().AddGlobalCooldown(GetSpellInfo(), gcd); + m_caster->GetCharmInfo()->GetCooldownMgr().AddGlobalCooldown(GetSpellEntry(), gcd); else if (m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->GetGlobalCooldownMgr().AddGlobalCooldown(GetSpellInfo(), gcd); + ((Player*)m_caster)->GetCooldownMgr().AddGlobalCooldown(GetSpellEntry(), gcd); } void Spell::CancelGlobalCooldown() { - if (!GetSpellInfo()->StartRecoveryTime) + if (!GetSpellEntry()->StartRecoveryTime) return; // Cancel global cooldown when interrupting current cast @@ -5981,7 +6043,7 @@ void Spell::CancelGlobalCooldown() // Only players or controlled units have global cooldown if (m_caster->GetCharmInfo()) - m_caster->GetCharmInfo()->GetGlobalCooldownMgr().CancelGlobalCooldown(GetSpellInfo()); + m_caster->GetCharmInfo()->GetCooldownMgr().CancelGlobalCooldown(GetSpellEntry()); else if (m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->GetGlobalCooldownMgr().CancelGlobalCooldown(GetSpellInfo()); + ((Player*)m_caster)->GetCooldownMgr().CancelGlobalCooldown(GetSpellEntry()); } diff --git a/src/game/Spell.h b/src/game/Spell.h index e54aca12a..8f525179d 100755 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __SPELL_H -#define __SPELL_H +#ifndef HELLGROUND_SPELL_H +#define HELLGROUND_SPELL_H #include "GridDefines.h" #include "SharedDefines.h" @@ -154,6 +154,7 @@ class SpellCastTargets uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID.GetRawValue(); } void setCorpseTarget(Corpse* corpse); + Corpse *getCorpseTarget() const { return m_corpseTarget; } uint64 getItemTargetGUID() const { return m_itemTargetGUID.GetRawValue(); } Item* getItemTarget() const { return m_itemTarget; } uint32 getItemTargetEntry() const { return m_itemTargetEntry; } @@ -184,6 +185,7 @@ class SpellCastTargets Unit *m_unitTarget; GameObject *m_GOTarget; Item *m_itemTarget; + Corpse* m_corpseTarget; // object GUID/etc, can be used always ObjectGuid m_unitTargetGUID; @@ -330,8 +332,9 @@ class Spell void EffectSummonCritter(uint32 i); void EffectKnockBack(uint32 i); void EffectPlayerPull(uint32 i); + void EffectSuspendGravity(uint32 i); void EffectDispelMechanic(uint32 i); - void EffectSummonDeadPet(uint32 i); + void EffectResurrectPet(uint32 i); void EffectDestroyAllTotems(uint32 i); void EffectDurabilityDamage(uint32 i); void EffectSkill(uint32 i); @@ -353,6 +356,7 @@ class Spell void EffectQuestFail(uint32 i); void EffectRedirectThreat(uint32 i); void EffectPlayMusic(uint32 i); + void EffectFriendSummon(uint32 eff_idx); Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL, bool skipCheck = false); ~Spell(); @@ -382,7 +386,7 @@ class Spell SpellCastResult CheckPower(); SpellCastResult CheckCasterAuras() const; - int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(GetSpellInfo(),i,m_currentBasePoints[i],target); } + int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(GetSpellEntry(),i,m_currentBasePoints[i],target); } bool HaveTargetsForEffect(uint8 effect) const; void Delayed(); @@ -434,19 +438,19 @@ class Spell void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; } bool IsNextMeleeSwingSpell() const { - return GetSpellInfo()->Attributes & (SPELL_ATTR_ON_NEXT_SWING_1|SPELL_ATTR_ON_NEXT_SWING_2); + return GetSpellEntry()->Attributes & (SPELL_ATTR_ON_NEXT_SWING_1|SPELL_ATTR_ON_NEXT_SWING_2); } bool IsRangedSpell() const { - return GetSpellInfo()->Attributes & SPELL_ATTR_RANGED; + return GetSpellEntry()->Attributes & SPELL_ATTR_RANGED; } bool IsDelayedSpell() const { - return GetSpellInfo()->speed > 0.0f || GetSpellInfo()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY; + return GetSpellEntry()->speed > 0.0f || GetSpellEntry()->AttributesCu & SPELL_ATTR_CU_FAKE_DELAY; } bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; } - bool IsMeleeAttackResetSpell() const { return !m_IsTriggeredSpell && (GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } - bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && /*IsRangedSpell() &&*/ !(GetSpellInfo()->AttributesEx2 & SPELL_ATTR_EX2_NOT_RESET_AUTOSHOT); } + bool IsMeleeAttackResetSpell() const { return !m_IsTriggeredSpell && (GetSpellEntry()->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } + bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && /*IsRangedSpell() &&*/ !(GetSpellEntry()->AttributesEx2 & SPELL_ATTR_EX2_NOT_RESET_AUTOSHOT); } bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; } void SetReferencedFromCurrent(bool yes) { m_referencedFromCurrentSpell = yes; } @@ -488,7 +492,7 @@ class Spell void SetSpellValue(SpellValueMod mod, int32 value); - SpellEntry const* GetSpellInfo() const { return m_spellInfo; } + SpellEntry const* GetSpellEntry() const { return m_spellInfo; } protected: bool HasGlobalCooldown(); @@ -630,6 +634,10 @@ class Spell uint32 m_timer; Position m_cast; + + bool IsTriggeredSpell() const { return m_IsTriggeredSpell; } + bool IsAutoShootSpell() const { return IsAutoRepeat() && IsRangedSpell(); } + bool m_IsTriggeredSpell; // if need this can be replaced by Aura copy diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 9f49879db..331bef019 100755 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef HELLGROUND_SPELLAURADEFINES_H #define HELLGROUND_SPELLAURADEFINES_H @@ -160,7 +161,7 @@ enum AuraType SPELL_AURA_ADD_TARGET_TRIGGER = 109, SPELL_AURA_MOD_POWER_REGEN_PERCENT = 110, SPELL_AURA_ADD_CASTER_HIT_TRIGGER = 111, - SPELL_AURA_OVERRIDE_CLASS_SCRIPTS = 112, + SPELL_AURA_override_CLASS_SCRIPTS = 112, SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN = 113, SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT = 114, SPELL_AURA_MOD_HEALING = 115, @@ -295,7 +296,7 @@ enum AuraType SPELL_AURA_COMPREHEND_LANGUAGE = 244, SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS = 245, SPELL_AURA_246 = 246, - SPELL_AURA_247 = 247, + SPELL_AURA_MIRROR_IMAGE = 247, SPELL_AURA_MOD_COMBAT_RESULT_CHANCE = 248, SPELL_AURA_249 = 249, SPELL_AURA_MOD_INCREASE_HEALTH_2 = 250, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6f61b2482..eb1a21121 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -167,7 +167,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleNoImmediateEffect, //109 SPELL_AURA_ADD_TARGET_TRIGGER &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT &Aura::HandleNoImmediateEffect, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Spell::SelectMagnetTarget and Unit::AttackerStateUpdate - &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS + &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_override_CLASS_SCRIPTS &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim @@ -302,7 +302,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleComprehendLanguage, //244 Comprehend language &Aura::HandleUnused, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS &Aura::HandleUnused, //246 unused - &Aura::HandleUnused, //247 unused + &Aura::HandleAuraMirrorImage, //247 SPELL_AURA_MIRROR_IMAGE target to become a clone of the caster &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst &Aura::HandleNULL, //249 &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2 @@ -792,13 +792,13 @@ void AreaAura::Update(uint32 diff) if (!CheckTarget(*tIter)) continue; - if (SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel())) + if (SpellEntry const *actualSpellEntry = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel())) { AreaAura *aur; - if (actualSpellInfo == GetSpellProto()) - aur = new AreaAura(actualSpellInfo, m_effIndex, &m_modifier.m_amount, (*tIter), caster, NULL); + if (actualSpellEntry == GetSpellProto()) + aur = new AreaAura(actualSpellEntry, m_effIndex, &m_modifier.m_amount, (*tIter), caster, NULL); else - aur = new AreaAura(actualSpellInfo, m_effIndex, NULL, (*tIter), caster, NULL); + aur = new AreaAura(actualSpellEntry, m_effIndex, NULL, (*tIter), caster, NULL); (*tIter)->AddAura(aur); @@ -1396,14 +1396,14 @@ void Aura::TriggerSpell() uint64 originalCasterGUID = GetCasterGUID(); - SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); - SpellEntry const *auraSpellInfo = GetSpellProto(); - uint32 auraId = auraSpellInfo->Id; + SpellEntry const *triggeredSpellEntry = sSpellStore.LookupEntry(trigger_spell_id); + SpellEntry const *auraSpellEntry = GetSpellProto(); + uint32 auraId = auraSpellEntry->Id; // specific code for cases with no trigger spell provided in field - if (triggeredSpellInfo == NULL) + if (triggeredSpellEntry == NULL) { - switch (auraSpellInfo->SpellFamilyName) + switch (auraSpellEntry->SpellFamilyName) { case SPELLFAMILY_GENERIC: { @@ -1861,7 +1861,7 @@ void Aura::TriggerSpell() return; float fX, fY, fZ; - target->GetClosePoint(fX, fY, fZ, target->GetObjectBoundingRadius(), 20.0f); + target->GetNearPoint(fX, fY, fZ, target->GetObjectBoundingRadius(), 20.0f); target->SummonCreature(22408, fX, fY, fZ, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); return; } @@ -1871,8 +1871,17 @@ void Aura::TriggerSpell() // case 39259: break; // // Hellfire - The Exorcism, Jules releases darkness, aura // case 39306: break; -// // Inferno -// case 39346: break; +// // Inferno - Raging Fires in Mechanar + case 39346: + { + if (caster->GetTypeId() != TYPEID_UNIT) + return; + if (!caster->GetInstanceData()) + return; + int32 damage = (caster->GetInstanceData()->instance->IsHeroic() ? 1880 : 940); + caster->CastCustomSpell((Unit*)NULL, 35283, &damage, NULL, NULL, true, 0, this, originalCasterGUID); + break; + } // // Enchanted Weapons // case 39489: break; // // Shadow Bolt Whirl @@ -2000,8 +2009,10 @@ void Aura::TriggerSpell() // case 44035: break; // // Curse of Boundless Agony // case 45050: break; + // Open Portal Periodic + case 45994: trigger_spell_id = 45976; break; // // Earthquake -// case 46240: break; + case 46240: trigger_spell_id = 46243; break; // Personalized Weather case 46736: trigger_spell_id = 46737; break; // // Stay Submerged @@ -2036,7 +2047,7 @@ void Aura::TriggerSpell() if (!m_duration) m_target->CastSpell(m_target, 32612, true, NULL, this); else if (m_tickNumber < 5) - m_target->getHostilRefManager().addThreatPercent(-(int32)(100/(6-m_tickNumber))); + m_target->getHostileRefManager().addThreatPercent(-(int32)(100/(6-m_tickNumber))); return; } default: @@ -2242,8 +2253,8 @@ void Aura::TriggerSpell() break; } // Reget trigger spell proto - triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); - if (triggeredSpellInfo == NULL) + triggeredSpellEntry = sSpellStore.LookupEntry(trigger_spell_id); + if (triggeredSpellEntry == NULL) { sLog.outDebug("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex()); return; @@ -2257,7 +2268,7 @@ void Aura::TriggerSpell() // Curse of Idiocy case 1010: { - // TODO: spell casted by result in correct way mostly + // TODO: spell cast by result in correct way mostly // BUT: // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell // but must show affect apply like item casting @@ -2301,7 +2312,7 @@ void Aura::TriggerSpell() // Negative Energy Periodic case 46284: { - caster->CastCustomSpell(trigger_spell_id, SPELLVALUE_MAX_TARGETS, m_tickNumber / 10 + 1, NULL, true, NULL, this, originalCasterGUID); + caster->CastCustomSpell(trigger_spell_id, SPELLVALUE_MAX_TARGETS, m_tickNumber / 15 + 1, NULL, true, NULL, this, originalCasterGUID); return; } // Charge Rage & Deadly Strike random targeting @@ -2310,8 +2321,8 @@ void Aura::TriggerSpell() { if (caster->CanHaveThreatList()) { - std::list& m_threatlist = caster->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); + std::list& m_threatlist = caster->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); while (m_threatlist.size()) { i = m_threatlist.begin(); @@ -2336,10 +2347,10 @@ void Aura::TriggerSpell() if (caster->CanHaveThreatList()) { target = NULL; - std::list targets(caster->getThreatManager().getThreatList()); + std::list targets(caster->getThreatManager().getThreatList()); while (!targets.empty()) { - std::list::iterator i = targets.begin(); + std::list::iterator i = targets.begin(); advance(i, rand()%targets.size()); Unit *unit = caster->GetUnit((*i)->getUnitGuid()); if (unit && unit->GetTypeId() == TYPEID_PLAYER && !unit->IsWithinDistInMap(caster, 18)) @@ -2353,7 +2364,7 @@ void Aura::TriggerSpell() if (!target) return; - caster->CastSpell(target, triggeredSpellInfo, true, 0, this, originalCasterGUID); + caster->CastSpell(target, triggeredSpellEntry, true, 0, this, originalCasterGUID); return; } } @@ -2364,7 +2375,7 @@ void Aura::TriggerSpell() // Burn should self-damage Phoenix case 44197: { - uint32 damage = caster->CalculateSpellDamage(triggeredSpellInfo, 0, 1750,caster); + uint32 damage = caster->CalculateSpellDamage(triggeredSpellEntry, 0, 1750,caster); caster->DealDamage(caster, damage, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_FIRE, GetSpellProto(), false); break; } @@ -2390,10 +2401,10 @@ void Aura::TriggerSpell() break; } } - if (!SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(triggeredSpellInfo->rangeIndex))) + if (!SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(triggeredSpellEntry->rangeIndex))) target = m_target; //for druid dispel poison - m_target->CastSpell(target, triggeredSpellInfo, true, 0, this, originalCasterGUID); + m_target->CastSpell(target, triggeredSpellEntry, true, 0, this, originalCasterGUID); } Unit* Aura::GetTriggerTarget() const @@ -2427,16 +2438,16 @@ void Aura::TriggerSpellWithValue() basepoints = 0; } - SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id); + SpellEntry const *triggeredSpellEntry = sSpellStore.LookupEntry(trigger_spell_id); int32 bp[3]; // damage triggered from spell might not only be processed by first effect (but always EffectDieSides equal 1) - if (triggeredSpellInfo) + if (triggeredSpellEntry) { uint8 j = 0; for (uint8 i=0;i<3;++i) { bp[i] = 0; - if (triggeredSpellInfo->EffectDieSides[i] == 1) + if (triggeredSpellEntry->EffectDieSides[i] == 1) j = i; } bp[j] = basepoints; @@ -2531,10 +2542,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 40133: // Summon Fire Elemental caster->SummonCreature(23099, -2459.64, 4754.64, 153.20, 4.89, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); break; - case 39850: // Rocket Blast - if (roll_chance_i(20)) // backfire stun - m_target->CastSpell(m_target, 51581, true, NULL, this); - return; case 6946: // Curse of Bleakheart if (!m_target->HasAura(6947, 0)) m_target->CastSpell(m_target, 6947, true); @@ -2555,10 +2562,14 @@ void Aura::HandleAuraDummy(bool apply, bool Real) } return; } - case 45042: // Power Circle (Shifting Naaru Silver trinket) + case 45043: // Power Circle (Shifting Naaru Silver trinket) { - if (m_target->GetTypeId() == TYPEID_PLAYER && m_target->GetGUID() == caster->GetGUID()) - caster->CastSpell(caster, 45044, true); + if (caster && m_target->GetTypeId() == TYPEID_PLAYER && m_target->GetGUID() == caster->GetGUID()) + { + if (apply) + caster->CastSpell(caster, 45044, true); + return; + } return; } case 39246: // Q: The Big Bone Worm @@ -2572,10 +2583,10 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { int32 count = urand(0,1) ? 2 : 4; for(int i = 0; i < count; ++i) - caster->SummonCreature(urand(0,1) ? 22482 : 22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + caster->SummonCreature(urand(0,1) ? 22482 : 22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); } else - caster->SummonCreature(22038, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + caster->SummonCreature(22038, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); } return; } @@ -2587,12 +2598,12 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (Unit* caster = GetCaster()) { if(urand(0,1) == 0) - caster->SummonCreature(22482, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + caster->SummonCreature(22482, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); else { - caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + caster->SummonCreature(22483, m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); } } return; @@ -2703,15 +2714,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) m_target->RemoveAurasDueToSpell(6947); return; } - case 45934: // Dark Fiend - { - if (m_removeMode == AURA_REMOVE_BY_DISPEL) - m_target->Kill(m_target, true); - return; - } case 46308: // Burning Winds { - m_target->CastSpell(m_target,47287,true,NULL,this); // casted only at creatures at spawn + m_target->CastSpell(m_target,47287,true,NULL,this); // cast only at creatures at spawn return; } case 34477: // Misdirection @@ -2722,8 +2727,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 40251: // Vengeful Spirit { Map *pMap = m_target->GetMap(); - if (((InstanceMap*)pMap)->GetInstanceData()) - ((InstanceMap*)pMap)->GetInstanceData()->SetData64(29, m_target->GetGUID()); + InstanceData* data = ((InstanceMap*)pMap)->GetInstanceData(); + if (data && data->GetData(20) == 1) + data->SetData64(29, m_target->GetGUID()); else break; @@ -3037,7 +3043,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // Improved Aspect of the Viper if (GetId() == 38390) { - if (m_target->GetTypeId() == TYPEID_PLAYER) + if (m_target->GetTypeId() != TYPEID_PLAYER) return; if (apply) @@ -3066,7 +3072,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // Improved Weapon Totems if (GetSpellProto()->SpellIconID == 57) { - if (m_target->GetTypeId()==TYPEID_PLAYER) + if (m_target->GetTypeId()!=TYPEID_PLAYER) return; if (apply) @@ -3099,7 +3105,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // Sentry Totem if (GetId() == 6495) { - if (caster->GetTypeId() == TYPEID_PLAYER) + if (caster->GetTypeId() != TYPEID_PLAYER) return; if (apply) @@ -3477,7 +3483,29 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) else { if (modelid > 0) - m_target->SetDisplayId(m_target->GetNativeDisplayId()); + { + Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM); + if (otherTransforms.empty()) + { + m_target->SetDisplayId(m_target->GetNativeDisplayId()); + m_target->setTransForm(0); + } + else + { + // look for other transform auras + Aura* handledAura = *otherTransforms.begin(); + for (Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i) + { + // negative auras are preferred + if (!SpellMgr::IsPositiveSpell((*i)->GetSpellProto()->Id)) + { + handledAura = *i; + break; + } + } + handledAura->ApplyModifier(true, true); + } + } m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE); m_target->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2); @@ -3521,8 +3549,30 @@ void Aura::HandleAuraTransform(bool apply, bool Real) { if (apply) { + if (m_target->HasAura(36897) || GetId() == 36897) // transporter malfuction special, other transform effect only changes between models + { + uint32 rand = urand(1,4); + switch (rand) + { + case 1: m_target->SetDisplayId(20322); break; + case 2: m_target->SetDisplayId(20321); break; + case 3: m_target->SetDisplayId(20319); break; + case 4: m_target->SetDisplayId(20316); break; + } + } + else if (m_target->HasAura(36899) || GetId() == 36899) + { + uint32 rand = urand(1,4); + switch (rand) + { + case 1: m_target->SetDisplayId(20323); break; + case 2: m_target->SetDisplayId(20320); break; + case 3: m_target->SetDisplayId(20318); break; + case 4: m_target->SetDisplayId(20317); break; + } + } // special case (spell specific functionality) - if (m_modifier.m_miscvalue==0) + else if (m_modifier.m_miscvalue==0) { // player applied only if (m_target->GetTypeId() != TYPEID_PLAYER) @@ -3946,6 +3996,9 @@ void Aura::HandleModFear(bool apply, bool Real) if (!apply && GetTarget()->HasAuraType(GetModifier()->m_auraname)) return; + + if (GetTarget()->HasAuraTypeWithFamilyFlags(SPELL_AURA_PREVENTS_FLEEING,5,2147483648) || GetTarget()->HasAura(16231)) //Curse of Recklessnes + return; m_target->SetFeared(apply, GetCaster()); } @@ -4009,7 +4062,7 @@ void Aura::HandleFeignDeath(bool apply, bool Real) // feign death in pve bool resisted = false; - HostilReference *ref = m_target->getHostilRefManager().getFirst(); + HostileReference *ref = m_target->getHostileRefManager().getFirst(); while(ref) { Unit* target = ref->getSource()->getOwner(); @@ -4040,7 +4093,7 @@ void Aura::HandleFeignDeath(bool apply, bool Real) if (target->m_currentSpells[i] && target->m_currentSpells[i]->m_targets.getUnitTargetGUID() == m_target->GetGUID()) target->InterruptSpell(i, false); - m_target->getHostilRefManager().deleteReference(target); + m_target->getHostileRefManager().deleteReference(target); if(target->getVictimGUID() == m_target->GetGUID()) target->AttackStop(); } @@ -4144,8 +4197,8 @@ void Aura::HandleModStealth(bool apply, bool Real) if (pTarget->GetVisibility() != VISIBILITY_OFF) pTarget->SetVisibility(VISIBILITY_GROUP_STEALTH); - // for RACE_NIGHTELF stealth - if (pTarget->GetTypeId() == TYPEID_PLAYER && spell_id == 20580) + // for RACE_NIGHTELF improved stealth from shadowmeld (this should actually be a learned spell) + if(m_target->GetTypeId()==TYPEID_PLAYER && m_target->getRace() == RACE_NIGHTELF) pTarget->CastSpell(pTarget, 21009, true, NULL, this); } } @@ -4154,10 +4207,6 @@ void Aura::HandleModStealth(bool apply, bool Real) // only at real aura remove if (Real) { - // for RACE_NIGHTELF stealth - if (pTarget->GetTypeId() == TYPEID_PLAYER && spell_id == 20580) - pTarget->RemoveAurasDueToSpell(21009); - // if last SPELL_AURA_MOD_STEALTH and no GM invisibility if (!pTarget->HasAuraType(SPELL_AURA_MOD_STEALTH) && pTarget->GetVisibility()!=VISIBILITY_OFF) { @@ -4290,7 +4339,7 @@ void Aura::HandleAuraModSilence(bool apply, bool Real) for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++) { Spell* currentSpell = m_target->m_currentSpells[i]; - if (currentSpell && currentSpell->GetSpellInfo()->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) + if (currentSpell && currentSpell->GetSpellEntry()->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) { uint32 state = currentSpell->getState(); // Stop spells on prepare or casting state @@ -4377,7 +4426,7 @@ void Aura::HandleAuraModTotalThreat(bool apply, bool Real) else threatMod = float(-GetModifierValue()); - m_target->getHostilRefManager().threatAssist(caster, threatMod); + m_target->getHostileRefManager().threatAssist(caster, threatMod); } void Aura::HandleModTaunt(bool apply, bool Real) @@ -5061,7 +5110,7 @@ void Aura::HandlePeriodicHeal(bool apply, bool Real) { if (Unit* caster = GetCaster()) { - Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) { int32 tickcount = SpellMgr::GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; @@ -5334,7 +5383,7 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) { if (Unit* caster = GetCaster()) { - Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& classScripts = caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator k = classScripts.begin(); k != classScripts.end(); ++k) { int32 tickcount = SpellMgr::GetSpellDuration(m_spellProto) / m_spellProto->EffectAmplitude[m_effIndex]; @@ -5451,6 +5500,21 @@ void Aura::HandleAuraModResistance(bool apply, bool Real) { m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE,apply); } + + if (apply) + switch (m_spellProto->Id){ + case 1490: // Curse of the Elements 1-4 + case 11721: + case 11722: + case 27228: + case 704: // Curse of Recklesness 1-5 + case 7658: + case 7659: + case 11717: + case 27226: + m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + break; + } } void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real) @@ -5738,7 +5802,7 @@ void Aura::HandleModRegen(bool apply, bool Real) // eating { SpellEntry const *spellProto = GetSpellProto(); if (spellProto) - m_target->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, spellProto); + m_target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, spellProto); } } } @@ -5839,7 +5903,8 @@ void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) if (int32(m_target->GetHealth()) > m_modifier.m_amount) m_target->ModifyHealth(-m_modifier.m_amount); else - m_target->SetHealth(1); + m_target->SetHealth(1, !m_target->isAlive()); + m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(GetModifierValue()), apply); } } @@ -5942,7 +6007,8 @@ void Aura::HandleAuraModCritPercent(bool apply, bool Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) - ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply); + if (!pItem->IsBroken()) + ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply); } // mods must be applied base at equipped weapon class and subclass comparison @@ -6045,6 +6111,8 @@ void Aura::HandleHaste(bool apply, bool Real) void Aura::HandleAuraModRangedHaste(bool apply, bool Real) { + if (m_spellProto->Id == 44972 && apply) // thor'idal + m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_RANGED_AMMO_HASTE); m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, GetModifierValue(), apply); } @@ -6053,6 +6121,9 @@ void Aura::HandleRangedAmmoHaste(bool apply, bool Real) if (m_target->GetTypeId() != TYPEID_PLAYER) return; + if (apply) + m_target->RemoveAurasDueToSpell(44972); // thor'idal + m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,GetModifierValue(), apply); } @@ -6145,7 +6216,8 @@ void Aura::HandleModDamageDone(bool apply, bool Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) - ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); + if (!pItem->IsBroken()) + ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); } // m_modifier.m_miscvalue is bitmask of spell schools @@ -6228,7 +6300,8 @@ void Aura::HandleModDamagePercentDone(bool apply, bool Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i))) - ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); + if (!pItem->IsBroken()) + ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply); } // m_modifier.m_miscvalue is bitmask of spell schools @@ -6367,6 +6440,7 @@ void Aura::HandleShapeshiftBoosts(bool apply) break; case FORM_FLIGHT: spellId = 33948; + spellId2 = 34764; break; case FORM_FLIGHT_EPIC: spellId = 40122; @@ -6685,6 +6759,14 @@ void Aura::CleanupTriggeredSpells() return; } + // Check if Shadow Embrace should be removed + if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellProto->SpellFamilyFlags & 0x0000001100000402LL) + { + // if target don't have any other siphon/corruption auras from caster then remove shadow embrance auras (by caster) + if (!m_target->HasAuraByCasterWithFamilyFlags(GetCasterGUID(), SPELLFAMILY_WARLOCK, 0x0000001100000402LL, this)) + m_target->RemoveAurasWithFamilyFlagsAndTypeByCaster(SPELLFAMILY_WARLOCK, 0x0000000080000000LL, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, GetCasterGUID()); + } + uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()]; if (!tSpellId) return; @@ -6761,7 +6843,7 @@ void Aura::HandleSchoolAbsorb(bool apply, bool Real) // apply threat equal to 1/2 healing threat for absorb value if (caster->GetTypeId() == TYPEID_PLAYER) - m_target->getHostilRefManager().threatAssist(caster, float(m_modifier.m_amount) * 0.25f, GetSpellProto()); + m_target->getHostileRefManager().threatAssist(caster, float(m_modifier.m_amount) * 0.25f, GetSpellProto()); } } } @@ -7047,7 +7129,7 @@ void Aura::PeriodicTick() if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x8)) { // find talent max bonus percentage - Unit::AuraList const& mClassScriptAuras = pCaster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& mClassScriptAuras = pCaster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator i = mClassScriptAuras.begin(); i != mClassScriptAuras.end(); ++i) { if ((*i)->GetModifier()->m_miscvalue == 4992 || (*i)->GetModifier()->m_miscvalue == 4993) @@ -7140,11 +7222,11 @@ void Aura::PeriodicTick() pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto); uint32 new_damage = pCaster->DealDamage(&damageInfo, DOT, spellProto, false); - if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false)) + if (!target->isAlive() && pCaster->IsNonMeleeSpellCast(false)) { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) { - if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->GetSpellInfo()->Id == spellProto->Id) + if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->GetSpellEntry()->Id == spellProto->Id) pCaster->m_currentSpells[i]->cancel(); } } @@ -7156,7 +7238,7 @@ void Aura::PeriodicTick() uint32 heal = pCaster->SpellHealingBonus(spellProto, uint32(new_damage * multiplier), DOT, pCaster); int32 gain = pCaster->ModifyHealth(heal); - pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto); + pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f, spellProto); // change it pCaster->SendHealSpellLog(pCaster, spellProto->Id, heal); @@ -7212,7 +7294,8 @@ void Aura::PeriodicTick() //Do check before because m_modifier.auraName can be invalidate by DealDamage. bool procSpell = (m_modifier.m_auraname == SPELL_AURA_PERIODIC_HEAL); // && m_target != pCaster); - m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); + if (pCaster->isInCombat()) + m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); Unit* target = m_target; // aura can be deleted in DealDamage SpellEntry const* spellProto = GetSpellProto(); @@ -7360,7 +7443,7 @@ void Aura::PeriodicTick() int32 gain = m_target->ModifyPower(power,pdamage); if (Unit* pCaster = GetCaster()) - m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); + m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); break; } case SPELL_AURA_OBS_MOD_MANA: @@ -7389,7 +7472,7 @@ void Aura::PeriodicTick() int32 gain = m_target->ModifyPower(POWER_MANA, pdamage); if (Unit* pCaster = GetCaster()) - m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); + m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto()); break; } case SPELL_AURA_POWER_BURN_MANA: @@ -7791,18 +7874,48 @@ void Aura::PeriodicDummyTick() m_target->CastSpell(m_target, 45959, true); break; } -// // Darkness -// case 45996: break; +// // Darkness - summon Dark Fiends on tick no 2 + case 45996: + { + Unit* caster = GetCaster(); + if(!caster) + return; + if(GetTickNumber() == 2) + { + for(uint8 i = 0; i < 8; i++) + caster->CastSpell((Unit*)NULL, 46000 + i, true); + } + break; + } // // Summon Blood Elves Periodic case 46041: { - m_target->CastSpell(m_target, 46037, true, NULL, this); - m_target->CastSpell(m_target, roll_chance_i(50) ? 46038 : 46039, true, NULL, this); - m_target->CastSpell(m_target, 46040, true, NULL, this); + Unit* caster = GetCaster(); + if(!caster) + return; + for(uint8 i = 0; i < 4; ++i) + caster->CastSpell((Unit*)NULL, 46037+i, true, 0, this); // up ramp Berserkers & Fury Mages break; } // // Transform Visual Missile Periodic -// case 46205: break; + case 46205: + { + Unit* caster = GetCaster(); + if(!caster) + return; + if(GetTickNumber() > 12) + { + caster->RemoveAurasDueToSpell(46205); + caster->CombatStop(); + return; + } + if(GetTickNumber() == 1 || roll_chance_i(33)) + { + caster->CastSpell((Unit*)NULL, 46178, true, 0, this); + caster->CastSpell((Unit*)NULL, 46208, true, 0, this); + } + break; + } // // Find Opening Beam End // case 46333: break; // // Ice Spear Control Aura @@ -7859,6 +7972,22 @@ void Aura::HandlePreventFleeing(bool apply, bool Real) { if (!Real) return; + + Unit* target = GetTarget(); + if (!target) + return; + + if (apply && ((GetSpellProto()->SpellFamilyName == 5 && GetSpellProto()->SpellFamilyFlags == 2147483648) || GetId() == (16231))) + target->SetFeared(false, target); + + if (!apply) + { + Unit::AuraList list = target->GetAurasByType(SPELL_AURA_MOD_FEAR); + if (list.empty()) + return; + + target->SetFeared(true, (*list.begin())->GetCaster()); + } } void Aura::HandleManaShield(bool apply, bool Real) @@ -7905,6 +8034,44 @@ void Aura::HandleArenaPreparation(bool apply, bool Real) m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION); } +void Aura::HandleAuraMirrorImage(bool apply, bool Real) +{ + if (!Real) + return; + + // Target of aura should always be creature (ref Spell::CheckCast) + Creature* pCreature = (Creature*)GetTarget(); + + // Caster can be player or creature, the unit who pCreature will become an clone of. + Unit* caster = GetCaster(); + + if (apply) + { + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, caster->getRace()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, caster->getClass()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, caster->getGender()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, caster->getPowerType()); + + pCreature->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); + + pCreature->SetDisplayId(caster->GetNativeDisplayId()); + } + else + { + const CreatureInfo* cinfo = pCreature->GetCreatureInfo(); + const CreatureModelInfo* minfo = sObjectMgr.GetCreatureModelInfo(pCreature->GetNativeDisplayId()); + + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, 0); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->classNum); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, 0); + + pCreature->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); + + pCreature->SetDisplayId(pCreature->GetNativeDisplayId()); + } +} + void Aura::HandleAuraMeleeAPAttackerBonus(bool apply, bool Real) { if (!Real) @@ -7917,7 +8084,7 @@ void Aura::HandleAuraMeleeAPAttackerBonus(bool apply, bool Real) { if (Unit* caster = GetCaster()) { - Unit::AuraList overrideClassScriptAuras = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList overrideClassScriptAuras = caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::iterator i = overrideClassScriptAuras.begin(); i != overrideClassScriptAuras.end();) { switch ((*i)->GetSpellProto()->Id) diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 170293141..60b6bdb32 100755 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,13 +10,14 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef HELLGROUND_SPELLAURAS_H #define HELLGROUND_SPELLAURAS_H @@ -223,6 +224,7 @@ class HELLGROUND_IMPORT_EXPORT Aura void HandlePreventFleeing(bool apply, bool Real); void HandleManaShield(bool apply, bool Real); void HandleArenaPreparation(bool apply, bool Real); + void HandleAuraMirrorImage(bool apply, bool Real); void HandleAuraMeleeAPAttackerBonus(bool apply, bool Real); virtual ~Aura(); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index e15a40bc4..0457d7c81 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -60,6 +60,9 @@ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "PathFinder.h" +#include "luaengine/HookMgr.h" + +#include pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { @@ -172,7 +175,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectSummonObject, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC - &Spell::EffectSummonDeadPet, //109 SPELL_EFFECT_SUMMON_DEAD_PET + &Spell::EffectResurrectPet, //109 SPELL_EFFECT_RESURRECT_PET &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE &Spell::EffectSummonDemon, //112 SPELL_EFFECT_SUMMON_DEMON @@ -208,14 +211,14 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectTriggerSpellWithValue, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER &Spell::EffectKnockBack, //144 SPELL_EFFECT_KNOCK_BACK_2 Spectral Blast - &Spell::EffectPlayerPull, //145 SPELL_EFFECT_145 Black Hole Effect + &Spell::EffectSuspendGravity, //145 SPELL_EFFECT_SUSPEND_GRAVITY Black Hole Effect &Spell::EffectUnused, //146 SPELL_EFFECT_146 unused &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail &Spell::EffectUnused, //148 SPELL_EFFECT_148 unused &Spell::EffectCharge2, //149 SPELL_EFFECT_CHARGE2 swoop &Spell::EffectUnused, //150 SPELL_EFFECT_150 unused &Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2 - &Spell::EffectNULL, //152 SPELL_EFFECT_152 summon Refer-a-Friend + &Spell::EffectFriendSummon, //152 SPELL_EFFECT_FRIEND_SUMMON summon Refer-a-Friend &Spell::EffectNULL, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry }; @@ -231,24 +234,36 @@ void Spell::EffectUnused(uint32 /*i*/) void Spell::EffectResurrectNew(uint32 i) { - if (!unitTarget || unitTarget->isAlive()) + if (!unitTarget || !unitTarget->IsInWorld() || unitTarget->isAlive()) return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) - return; + if (Player* pTarget = unitTarget->ToPlayer()) + { + if (pTarget->isRessurectRequested()) // already have one active request + return; - if (!unitTarget->IsInWorld()) - return; + uint32 health = damage; + uint32 mana = GetSpellEntry()->EffectMiscValue[i]; + pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + SendResurrectRequest(pTarget); + } + else if (Pet* pet = unitTarget->ToPet()) + { + if (pet->getPetType() != HUNTER_PET || pet->isAlive()) + return; - Player* pTarget = ((Player*)unitTarget); + float x, y, z; + m_caster->GetPosition(x, y, z); + pet->NearTeleportTo(x, y, z, m_caster->GetOrientation()); - if (pTarget->isRessurectRequested()) // already have one active request - return; + pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + pet->setDeathState(ALIVE); + pet->clearUnitState(UNIT_STAT_ALL_STATE); + pet->SetHealth(uint32(damage)); - uint32 health = damage; - uint32 mana = GetSpellInfo()->EffectMiscValue[i]; - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); - SendResurrectRequest(pTarget); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + } } void Spell::EffectInstaKill(uint32 /*i*/) @@ -257,7 +272,7 @@ void Spell::EffectInstaKill(uint32 /*i*/) return; // Demonic Sacrifice - if (GetSpellInfo()->Id==18788 && unitTarget->GetTypeId()==TYPEID_UNIT) + if (GetSpellEntry()->Id==18788 && unitTarget->GetTypeId()==TYPEID_UNIT) { uint32 entry = unitTarget->GetEntry(); uint32 spellID; @@ -290,12 +305,12 @@ void Spell::EffectEnvirinmentalDMG(uint32 i) // Note: this hack with damage replace required until GO casting not implemented // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support - // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc - damage = GetSpellInfo()->CalculateSimpleValue(i); + // currently each enemy selected explicitly and self cast damage, we prevent apply self cast spell bonuses/etc + damage = GetSpellEntry()->CalculateSimpleValue(i); - m_caster->CalcAbsorbResist(m_caster,SpellMgr::GetSpellSchoolMask(GetSpellInfo()), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + m_caster->CalcAbsorbResist(m_caster,SpellMgr::GetSpellSchoolMask(GetSpellEntry()), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); - m_caster->SendSpellNonMeleeDamageLog(m_caster, GetSpellInfo()->Id, damage, SpellMgr::GetSpellSchoolMask(GetSpellInfo()), absorb, resist, false, 0, false); + m_caster->SendSpellNonMeleeDamageLog(m_caster, GetSpellEntry()->Id, damage, SpellMgr::GetSpellSchoolMask(GetSpellEntry()), absorb, resist, false, 0, false); if (m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->EnvironmentalDamage(DAMAGE_FIRE,damage); } @@ -307,7 +322,7 @@ void Spell::EffectSchoolDMG(uint32 effect_idx) void Spell::SpellDamageSchoolDmg(uint32 effect_idx) { // what the fuck is done here? o.O - SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellInfo()->Id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellEntry()->Id); if (!spellInfo) return; @@ -369,6 +384,13 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) switch (spellInfo->Id) // better way to check unknown { + // Priestess of Torment - whirlwind dmg should also mana burn + case 46271: + { + if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER) + m_caster->CastSpell(unitTarget, 46266, true); + break; + } case 35354: //Hand of Death { if (unitTarget && unitTarget->HasAura(38528,0)) //Protection of Elune @@ -413,6 +435,11 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) case 38441: damage = unitTarget->GetMaxHealth() / 2; break; + //sonic boom + case 33666: + case 38795: + damage = unitTarget->GetHealth()*90/100; + break; } break; } @@ -457,7 +484,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) // T5 bonus - increase immolate damage on incinerate hit if (m_caster->HasAura(37384, 0)) { - // look for immolate casted by m_caster + // look for immolate cast by m_caster Unit::AuraList const &mPeriodic = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); for (Unit::AuraList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { @@ -484,7 +511,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) // T5 bonus - increase corruption on shadow bolt hit if (m_caster->HasAura(37384, 0)) { - // look for corruption casted by m_caster + // look for corruption cast by m_caster Unit::AuraList const &mPeriodic = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); for (Unit::AuraList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { @@ -539,7 +566,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) // Starfire else if (spellInfo->SpellFamilyFlags & 0x0004LL) { - Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) { // Starfire Bonus (caster) @@ -707,7 +734,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) if (spellInfo->SpellFamilyFlags & 0x0003LL) { bool stop = false; - Unit::AuraList const& auras = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& auras = m_caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { switch ((*itr)->GetId()) @@ -762,11 +789,11 @@ void Spell::EffectDummy(uint32 i) int32 bp = 0; // selection by spell family - switch (GetSpellInfo()->SpellFamilyName) + switch (GetSpellEntry()->SpellFamilyName) { case SPELLFAMILY_GENERIC: { - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 17950: // Shadow Portal { @@ -778,7 +805,31 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(unitTarget, spell_list[urand(0, 5)], true); return; } - case 46476: + case 46292: // Cataclysm Breath + { + // Cataclysm Spells + const uint32 spell_list[8] = + { + 46293, // Corrosive Poison + 46294, // Fevered Fatigue + 46295, // Hex + 46296, // Necrotic Poison + 46297, // Piercing Shadow + 46298, // Shrink + 46299, // Wavering Will + 46300 // Withered Touch + }; + + std::vector debuff_list; + for (uint8 i = 0; i < 8; ++i) + debuff_list.push_back(spell_list[i]); + std::random_shuffle(debuff_list.begin(), debuff_list.end()); + debuff_list.resize(urand(5, 6)); + for (std::vector::iterator itr = debuff_list.begin(); itr != debuff_list.end(); itr++) + m_caster->CastSpell((Unit*)NULL, *itr, true); + return; + } + case 46476: // Sunblade Protector Activated { if(!m_originalCaster) return; @@ -795,7 +846,7 @@ void Spell::EffectDummy(uint32 i) if (i == 0) { float x,y,z; - m_caster->GetClosePoint(x,y,z, 0.0f, 10.0f, 0.0f); + m_caster->GetNearPoint(x,y,z, 0.0f, 10.0f, 0.0f); if (Creature *pDruid = m_caster->SummonCreature(22423, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 40000)) { pDruid->CastSpell(pDruid, 39158, true); @@ -817,7 +868,7 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(unitTarget, 39123, true); float x, y, z; - unitTarget->GetClosePoint(x,y,z, 0.0f, 0.0f, unitTarget->GetAngle(m_caster)); + unitTarget->GetNearPoint(x,y,z, 0.0f, 0.0f, unitTarget->GetAngle(m_caster)); m_caster->GetMotionMaster()->MovePoint(0, x, y, z); break; @@ -838,7 +889,7 @@ void Spell::EffectDummy(uint32 i) break; } // Illidan Stormrage: Throw Glaive (Summon Glaive after throw;p - case 39635: + case 39849: { unitTarget->CastSpell(unitTarget, 41466, true); if (unitTarget->GetTypeId() == TYPEID_UNIT) @@ -848,6 +899,14 @@ void Spell::EffectDummy(uint32 i) } return; } + // Illidan Stormrage: Return Glaive + case 39873: + { + if (unitTarget->GetTypeId() == TYPEID_PLAYER) + return; + + m_caster->CastSpell(unitTarget, 39635, true); + } case 38002: { if (m_caster->GetTypeId() != TYPEID_PLAYER) @@ -871,15 +930,15 @@ void Spell::EffectDummy(uint32 i) if (((Player*)m_caster)->GetQuestStatus(10427) == QUEST_STATUS_INCOMPLETE) { // Get Sleep Visual (34664) - SpellEntry const *sleepSpellInfo = sSpellStore.LookupEntry(34664); - if (sleepSpellInfo) // Make the creature sleep in peace :) + SpellEntry const *sleepSpellEntry = sSpellStore.LookupEntry(34664); + if (sleepSpellEntry) // Make the creature sleep in peace :) { m_caster->AttackStop(); unitTarget->RemoveAllAuras(); unitTarget->DeleteThreatList(); unitTarget->CombatStop(); - SpellEntry const *sleepSpellInfo = sSpellStore.LookupEntry(34664); - Aura* sleepAura = CreateAura(sleepSpellInfo, 0, NULL, unitTarget,unitTarget, 0); + SpellEntry const *sleepSpellEntry = sSpellStore.LookupEntry(34664); + Aura* sleepAura = CreateAura(sleepSpellEntry, 0, NULL, unitTarget,unitTarget, 0); unitTarget->AddAura(sleepAura); // Apply Visual Sleep unitTarget->addUnitState(UNIT_STAT_STUNNED); @@ -887,7 +946,7 @@ void Spell::EffectDummy(uint32 i) unitTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } // Add q objecive + 1 - ((Player*)m_caster)->CastedCreatureOrGO(20982, unitTarget->GetGUID(), 35771); + ((Player*)m_caster)->CastCreatureOrGO(20982, unitTarget->GetGUID(), 35771); } return; } @@ -914,6 +973,7 @@ void Spell::EffectDummy(uint32 i) m_caster->DealDamage(unitTarget, unitTarget->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } } + return; } // Six Demon Bag, TODO: Search and add more spells to cast with normal dmg (100 ~ 200), Shadow bolt, Fireball, Summon Felhunter case 14537: @@ -988,7 +1048,7 @@ void Spell::EffectDummy(uint32 i) } } // Encapsulate Voidwalker - case 29364: + /*case 29364: // It's never used. The spell has other effects { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->isPet()) return; @@ -1010,7 +1070,7 @@ void Spell::EffectDummy(uint32 i) pGameObj->SetRespawnTime(0); pGameObj->SetOwnerGUID(m_caster->GetGUID()); //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); - pGameObj->SetSpellId(GetSpellInfo()->Id); + pGameObj->SetSpellId(GetSpellEntry()->Id); creatureTarget->GetMap()->Add(pGameObj); @@ -1019,7 +1079,7 @@ void Spell::EffectDummy(uint32 i) m_caster->BroadcastPacket(&data,true); return; - } + }*/ case 8063: // Deviate Fish { if (m_caster->GetTypeId() != TYPEID_PLAYER) @@ -1259,6 +1319,16 @@ void Spell::EffectDummy(uint32 i) m_caster->CastSpell(m_caster,spell_id,true,NULL); return; } + case 19250: // Placing Smokey's Explosives + { + if(i == 0) + { + focusObject->SetLootState(GO_JUST_DEACTIVATED); + m_caster->CastSpell(m_caster, 19237, true); + ((Player*)m_caster)->KilledMonster(12247, m_caster->GetMap()->GetCreatureGUID(12247)); + } + return; + } case 20577: // Cannibalize if (unitTarget) m_caster->CastSpell(m_caster,20578,false,NULL); @@ -1576,7 +1646,7 @@ void Spell::EffectDummy(uint32 i) Player* plr = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself(); GameObject* ok = NULL; - Hellground::GameObjectFocusCheck go_check(plr,GetSpellInfo()->RequiresSpellFocus); + Hellground::GameObjectFocusCheck go_check(plr,GetSpellEntry()->RequiresSpellFocus); Hellground::ObjectSearcher checker(ok,go_check); Cell::VisitGridObjects(plr, checker, plr->GetMap()->GetVisibilityDistance()); @@ -1584,10 +1654,10 @@ void Spell::EffectDummy(uint32 i) if (!ok) { WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); data << uint8(SPELL_FAILED_REQUIRES_SPELL_FOCUS); data << uint8(m_cast_count); - data << uint32(GetSpellInfo()->RequiresSpellFocus); + data << uint32(GetSpellEntry()->RequiresSpellFocus); plr->SendPacketToSelf(&data); return; } @@ -1600,7 +1670,7 @@ void Spell::EffectDummy(uint32 i) case 44997: // Converting Sentry remove corpse { if(unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) - ((Creature*)unitTarget)->RemoveCorpse(); + unitTarget->ToCreature()->DisappearAndDie(); return; } case 45030: // Impale Emissary @@ -1730,7 +1800,7 @@ void Spell::EffectDummy(uint32 i) } //All IconID Check in there - switch (GetSpellInfo()->SpellIconID) + switch (GetSpellEntry()->SpellIconID) { // Berserking (troll racial traits) case 1661: @@ -1755,8 +1825,24 @@ void Spell::EffectDummy(uint32 i) break; } case SPELLFAMILY_MAGE: - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { + case 30610: // Wrath of the Titans + { + + if (!m_caster->getVictim()) + return; + + switch (rand()%5) + { + case 0: m_caster->CastSpell(m_caster->getVictim(), 30605, true); break; // Blast of Aman'Thul: Arcane + case 1: m_caster->CastSpell(m_caster->getVictim(), 30606, true); break; // Bolt of Eonar: Nature + case 2: m_caster->CastSpell(m_caster->getVictim(), 30607, true); break; // Flame of Khaz'goroth: Fire + case 3: m_caster->CastSpell(m_caster->getVictim(), 30608, true); break; // Spite of Sargeras: Shadow + case 4: m_caster->CastSpell(m_caster->getVictim(), 30609, true); break; // Chill of Norgannon: Frost + } + return; + } case 11958: // Cold Snap { if (m_caster->GetTypeId()!=TYPEID_PLAYER) @@ -1878,24 +1964,24 @@ void Spell::EffectDummy(uint32 i) break; case SPELLFAMILY_WARRIOR: // Charge - if (GetSpellInfo()->SpellFamilyFlags & 0x1 && GetSpellInfo()->SpellVisual == 867) + if (GetSpellEntry()->SpellFamilyFlags & 0x1 && GetSpellEntry()->SpellVisual == 867) { int32 chargeBasePoints0 = damage; m_caster->CastCustomSpell(m_caster,34846,&chargeBasePoints0,NULL,NULL,true); return; } // Execute - if (GetSpellInfo()->SpellFamilyFlags & 0x20000000) + if (GetSpellEntry()->SpellFamilyFlags & 0x20000000) { if (!unitTarget) return; spell_id = 20647; - bp = damage + int32((m_caster->GetPower(POWER_RAGE) - GetPowerCost()) * GetSpellInfo()->DmgMultiplier[i]); + bp = damage + int32((m_caster->GetPower(POWER_RAGE) - GetPowerCost()) * GetSpellEntry()->DmgMultiplier[i]); m_caster->SetPower(POWER_RAGE,0); break; } - if (GetSpellInfo()->Id==21977) //Warrior's Wrath + if (GetSpellEntry()->Id==21977) //Warrior's Wrath { if (!unitTarget) return; @@ -1906,14 +1992,14 @@ void Spell::EffectDummy(uint32 i) break; case SPELLFAMILY_WARLOCK: //Life Tap (only it have this with dummy effect) - if (GetSpellInfo()->SpellFamilyFlags == 0x40000) + if (GetSpellEntry()->SpellFamilyFlags == 0x40000) { float cost = damage; if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_COST, cost,this); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_COST, cost,this); - int32 dmg = m_caster->SpellDamageBonus(m_caster, GetSpellInfo(),uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); + int32 dmg = m_caster->SpellDamageBonus(m_caster, GetSpellEntry(),uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); if (int32(m_caster->GetHealth()) > dmg) { @@ -1933,7 +2019,7 @@ void Spell::EffectDummy(uint32 i) m_caster->CastCustomSpell(m_caster,31818,&mana,NULL,NULL,true,NULL); // Mana Feed - int32 manaFeedVal = m_caster->CalculateSpellDamage(GetSpellInfo(),1, GetSpellInfo()->EffectBasePoints[1],m_caster); + int32 manaFeedVal = m_caster->CalculateSpellDamage(GetSpellEntry(),1, GetSpellEntry()->EffectBasePoints[1],m_caster); manaFeedVal = manaFeedVal * mana / 100; if (manaFeedVal > 0) m_caster->CastCustomSpell(m_caster,32553,&manaFeedVal,NULL,NULL,true,NULL); @@ -1944,7 +2030,7 @@ void Spell::EffectDummy(uint32 i) } break; case SPELLFAMILY_PRIEST: - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 28598: // Touch of Weakness triggered spell { @@ -1971,7 +2057,7 @@ void Spell::EffectDummy(uint32 i) } break; case SPELLFAMILY_DRUID: - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 5420: // Tree of Life passive { @@ -1985,7 +2071,7 @@ void Spell::EffectDummy(uint32 i) } break; case SPELLFAMILY_ROGUE: - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 31231: // Cheat Death { @@ -2050,7 +2136,7 @@ void Spell::EffectDummy(uint32 i) break; case SPELLFAMILY_HUNTER: // Kill command - if (GetSpellInfo()->SpellFamilyFlags & 0x00080000000000LL) + if (GetSpellEntry()->SpellFamilyFlags & 0x00080000000000LL) { if (m_caster->getClass()!=CLASS_HUNTER) return; @@ -2064,11 +2150,11 @@ void Spell::EffectDummy(uint32 i) return; uint32 spell_id = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 34026: spell_id = 34027; break; // rank 1 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in KC",GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in KC",GetSpellEntry()->Id); return; } @@ -2076,7 +2162,7 @@ void Spell::EffectDummy(uint32 i) return; } - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 23989: //Readiness talent { @@ -2109,7 +2195,7 @@ void Spell::EffectDummy(uint32 i) } break; case SPELLFAMILY_PALADIN: - switch (GetSpellInfo()->SpellIconID) + switch (GetSpellEntry()->SpellIconID) { case 156: // Holy Shock { @@ -2119,7 +2205,7 @@ void Spell::EffectDummy(uint32 i) int hurt = 0; int heal = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 20473: hurt = 25912; heal = 25914; break; case 20929: hurt = 25911; heal = 25913; break; @@ -2127,7 +2213,7 @@ void Spell::EffectDummy(uint32 i) case 27174: hurt = 27176; heal = 27175; break; case 33072: hurt = 33073; heal = 33074; break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in HS",GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in HS",GetSpellEntry()->Id); return; } @@ -2143,7 +2229,7 @@ void Spell::EffectDummy(uint32 i) if (!unitTarget) return; - uint32 spell_id = GetSpellInfo()->EffectBasePoints[i]+1;//m_currentBasePoints[i]+1; + uint32 spell_id = GetSpellEntry()->EffectBasePoints[i]+1;//m_currentBasePoints[i]+1; SpellEntry const* spell_proto = sSpellStore.LookupEntry(spell_id); if (!spell_proto) return; @@ -2155,7 +2241,7 @@ void Spell::EffectDummy(uint32 i) mod->op = SPELLMOD_DAMAGE; mod->value = -50; mod->type = SPELLMOD_PCT; - mod->spellId = GetSpellInfo()->Id; + mod->spellId = GetSpellEntry()->Id; mod->effectId = i; mod->lastAffected = NULL; mod->mask = 0x0000020000000000LL; @@ -2173,7 +2259,7 @@ void Spell::EffectDummy(uint32 i) } } - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 31789: // Righteous Defense (step 1) { @@ -2183,8 +2269,8 @@ void Spell::EffectDummy(uint32 i) if (!unitTarget || unitTarget->getAttackers().empty()) { // clear cooldown at fail - if (m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellCooldown(GetSpellInfo()->Id, true); + if (m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*) m_caster)->RemoveSpellCooldown(GetSpellEntry()->Id, true); SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); return; @@ -2192,7 +2278,7 @@ void Spell::EffectDummy(uint32 i) // Righteous Defense (step 2) (in old version 31980 dummy effect) // Clear targets for eff 1 - for (std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + for (std::list::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if (ihit->deleted) continue; @@ -2201,17 +2287,16 @@ void Spell::EffectDummy(uint32 i) } // not empty (checked) - Unit::AttackerSet const& attackers = unitTarget->getAttackers(); + Unit::AttackerSet attackers(unitTarget->getAttackers()); // chance to be selected from list - float chance = 100.0f/attackers.size(); - uint32 count=0; - for (Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr) + uint32 maxTargets = std::min(3, attackers.size()); + for (uint32 i = 0; i < maxTargets; ++i) { - if (!roll_chance_f(chance)) - continue; - ++count; - AddUnitTarget((*aItr), 1); + Unit::AttackerSet::const_iterator aItr = attackers.begin(); + std::advance(aItr, urand(0, attackers.size() - 1)); + AddUnitTarget(*aItr, 1); + attackers.erase(*aItr); } // now let next effect cast spell at each target. @@ -2240,7 +2325,7 @@ void Spell::EffectDummy(uint32 i) case SPELLFAMILY_SHAMAN: // Flametongue Weapon Proc - if (GetSpellInfo()->SpellFamilyFlags & 0x200000) + if (GetSpellEntry()->SpellFamilyFlags & 0x200000) { if (m_caster->GetTypeId() != TYPEID_PLAYER) return; @@ -2250,24 +2335,24 @@ void Spell::EffectDummy(uint32 i) if (m_CastItem && m_CastItem->GetSlot() == EQUIPMENT_SLOT_MAINHAND) mainhand = true; - bp = m_caster->GetAttackTime(mainhand ? BASE_ATTACK : OFF_ATTACK) * (GetSpellInfo()->EffectBasePoints[0]+1) / 100000; + bp = m_caster->GetAttackTime(mainhand ? BASE_ATTACK : OFF_ATTACK) * (GetSpellEntry()->EffectBasePoints[0]+1) / 100000; spell_id = 10444; break; } // Flametongue Totem Proc - if (GetSpellInfo()->SpellFamilyFlags & 0x400000000) + if (GetSpellEntry()->SpellFamilyFlags & 0x400000000) { - bp = m_caster->GetAttackTime(BASE_ATTACK) * (GetSpellInfo()->EffectBasePoints[0]+1) / 100000; + bp = m_caster->GetAttackTime(BASE_ATTACK) * (GetSpellEntry()->EffectBasePoints[0]+1) / 100000; spell_id = 16368; break; } //Shaman Rockbiter Weapon - if (GetSpellInfo()->SpellFamilyFlags == 0x400000) + if (GetSpellEntry()->SpellFamilyFlags == 0x400000) { uint32 spell_id = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 8017: spell_id = 36494; break; // Rank 1 case 8018: spell_id = 36750; break; // Rank 2 @@ -2279,7 +2364,7 @@ void Spell::EffectDummy(uint32 i) case 25479: spell_id = 36775; break; // Rank 8 case 25485: spell_id = 36499; break; // Rank 9 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in RW",GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectDummy: Spell %u not handled in RW",GetSpellEntry()->Id); return; } @@ -2298,7 +2383,7 @@ void Spell::EffectDummy(uint32 i) { if (Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(j))) { - if (item->IsFitToSpellRequirements(GetSpellInfo())) + if (item->IsFitToSpellRequirements(GetSpellEntry())) { Spell *spell = new Spell(m_caster, spellInfo, true); @@ -2316,7 +2401,7 @@ void Spell::EffectDummy(uint32 i) return; } - if (GetSpellInfo()->Id == 39610) // Mana-Tide Totem effect + if (GetSpellEntry()->Id == 39610) // Mana-Tide Totem effect { if (!unitTarget || unitTarget->getPowerType() != POWER_MANA) return; @@ -2337,7 +2422,7 @@ void Spell::EffectDummy(uint32 i) if (!spellInfo) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectDummy of spell %u: triggering unknown spell id %i\n", GetSpellInfo()->Id, spell_id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectDummy of spell %u: triggering unknown spell id %i\n", GetSpellEntry()->Id, spell_id); return; } @@ -2349,7 +2434,7 @@ void Spell::EffectDummy(uint32 i) } // pet auras - if (PetAura const* petSpell = sSpellMgr.GetPetAura(GetSpellInfo()->Id)) + if (PetAura const* petSpell = sSpellMgr.GetPetAura(GetSpellEntry()->Id)) { m_caster->AddPetAura(petSpell); return; @@ -2358,23 +2443,23 @@ void Spell::EffectDummy(uint32 i) // Script based implementation. Must be used only for not good for implementation in core spell effects // So called only for not proccessed cases if (gameObjTarget) - sScriptMgr.OnEffectDummy(m_caster, GetSpellInfo()->Id, i, gameObjTarget); + sScriptMgr.OnEffectDummy(m_caster, GetSpellEntry()->Id, i, gameObjTarget); else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) - sScriptMgr.OnEffectDummy(m_caster, GetSpellInfo()->Id, i, (Creature*)unitTarget); + sScriptMgr.OnEffectDummy(m_caster, GetSpellEntry()->Id, i, (Creature*)unitTarget); else if (itemTarget) - sScriptMgr.OnEffectDummy(m_caster, GetSpellInfo()->Id, i, itemTarget); + sScriptMgr.OnEffectDummy(m_caster, GetSpellEntry()->Id, i, itemTarget); } void Spell::EffectTriggerSpellWithValue(uint32 i) { - uint32 triggered_spell_id = GetSpellInfo()->EffectTriggerSpell[i]; + uint32 triggered_spell_id = GetSpellEntry()->EffectTriggerSpell[i]; // normal case SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); if (!spellInfo) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i\n", GetSpellInfo()->Id,triggered_spell_id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i\n", GetSpellEntry()->Id,triggered_spell_id); return; } @@ -2384,12 +2469,12 @@ void Spell::EffectTriggerSpellWithValue(uint32 i) void Spell::EffectTriggerRitualOfSummoning(uint32 i) { - uint32 triggered_spell_id = GetSpellInfo()->EffectTriggerSpell[i]; + uint32 triggered_spell_id = GetSpellEntry()->EffectTriggerSpell[i]; SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); if (!spellInfo) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", GetSpellInfo()->Id,triggered_spell_id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", GetSpellEntry()->Id,triggered_spell_id); return; } @@ -2400,7 +2485,7 @@ void Spell::EffectTriggerRitualOfSummoning(uint32 i) targets.setUnitTarget(unitTarget); spell->prepare(&targets); - m_caster->SetCurrentCastedSpell(spell); + m_caster->SetCurrentCastSpell(spell); spell->m_selfContainer = &(m_caster->m_currentSpells[spell->GetCurrentContainer()]); } @@ -2410,14 +2495,14 @@ void Spell::EffectForceCast(uint32 i) if (!unitTarget) return; - uint32 triggered_spell_id = GetSpellInfo()->EffectTriggerSpell[i]; + uint32 triggered_spell_id = GetSpellEntry()->EffectTriggerSpell[i]; // normal case SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); if (!spellInfo) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectForceCast of spell %u: triggering unknown spell id %i", GetSpellInfo()->Id,triggered_spell_id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectForceCast of spell %u: triggering unknown spell id %i", GetSpellEntry()->Id,triggered_spell_id); return; } @@ -2426,7 +2511,7 @@ void Spell::EffectForceCast(uint32 i) void Spell::EffectTriggerSpell(uint32 i) { - uint32 triggered_spell_id = GetSpellInfo()->EffectTriggerSpell[i]; + uint32 triggered_spell_id = GetSpellEntry()->EffectTriggerSpell[i]; // special cases switch (triggered_spell_id) @@ -2440,8 +2525,7 @@ void Spell::EffectTriggerSpell(uint32 i) // Vanish case 18461: { - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); + m_caster->RemoveMovementImpairingAuras(); m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED); // if this spell is given to NPC it must handle rest by it's own AI @@ -2610,7 +2694,7 @@ void Spell::EffectTriggerSpell(uint32 i) if (!spellInfo) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerSpell of spell %u: triggering unknown spell id %i", GetSpellInfo()->Id,triggered_spell_id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerSpell of spell %u: triggering unknown spell id %i", GetSpellEntry()->Id,triggered_spell_id); return; } @@ -2646,12 +2730,12 @@ void Spell::EffectTriggerSpell(uint32 i) } } - // some triggered spells must be casted instantly (for example, if next effect case instant kill caster) + // some triggered spells must be cast instantly (for example, if next effect case instant kill caster) /*bool instant = false; for (uint32 j = i+1; j < 3; ++j) { - if (GetSpellInfo()->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER - && (GetSpellInfo()->Effect[j]==SPELL_EFFECT_INSTAKILL)) + if (GetSpellEntry()->EffectImplicitTargetA[j] == TARGET_UNIT_CASTER + && (GetSpellEntry()->Effect[j]==SPELL_EFFECT_INSTAKILL)) { instant = true; break; @@ -2665,7 +2749,7 @@ void Spell::EffectTriggerSpell(uint32 i) void Spell::EffectTriggerMissileSpell(uint32 effect_idx) { - uint32 triggered_spell_id = GetSpellInfo()->EffectTriggerSpell[effect_idx]; + uint32 triggered_spell_id = GetSpellEntry()->EffectTriggerSpell[effect_idx]; // normal case SpellEntry const *spellInfo = sSpellStore.LookupEntry(triggered_spell_id); @@ -2673,7 +2757,7 @@ void Spell::EffectTriggerMissileSpell(uint32 effect_idx) if (!spellInfo) { sLog.outLog(LOG_DEFAULT, "ERROR: EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u", - GetSpellInfo()->Id,effect_idx,triggered_spell_id); + GetSpellEntry()->Id,effect_idx,triggered_spell_id); return; } @@ -2716,10 +2800,12 @@ void Spell::EffectTriggerMissileSpell(uint32 effect_idx) SpellCastTargets targets; - if (triggered_spell_id == 44008) // Static Disruption needs direct targeting + if (!spellInfo->IsDestTargetEffect(effect_idx)) +// if (triggered_spell_id == 44008) // Static Disruption needs direct targeting targets.setUnitTarget(unitTarget); else targets.setDestination(m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ); + spell->m_CastItem = m_CastItem; spell->prepare(&targets, NULL); } @@ -2732,7 +2818,7 @@ void Spell::EffectTeleportUnits(uint32 i) // If not exist data for dest location - return if (!m_targets.HasDst()) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectTeleportUnits - does not have destination for spell ID %u\n", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectTeleportUnits - does not have destination for spell ID %u\n", GetSpellEntry()->Id); return; } // Init dest coordinates @@ -2762,7 +2848,7 @@ void Spell::EffectTeleportUnits(uint32 i) ((Player*)unitTarget)->TeleportTo(mapid, dest.x, dest.y, dest.z, dest.o, unitTarget == m_caster ? TELE_TO_SPELL : 0); // post effects for TARGET_DST_DB - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Dimensional Ripper - Everlook case 23442: @@ -2873,7 +2959,7 @@ void Spell::EffectApplyAura(uint32 i) return; // what the fuck is done here? o.O - SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellInfo()->Id); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(GetSpellEntry()->Id); if (!spellInfo) return; @@ -2887,6 +2973,14 @@ void Spell::EffectApplyAura(uint32 i) (unitTarget->GetTypeId()!=TYPEID_PLAYER || !((Player*)unitTarget)->GetSession()->PlayerLoading())) return; + // hacky GCD for Black Hole Effect dummy aura + if (spellInfo->Id == 46230 && unitTarget->HasAura(46230, 2)) + { + if(Aura* aur = unitTarget->GetAura(46230, 2)) + if(aur->GetAuraDuration() >= 3400) + return; + } + Unit* caster = m_originalCasterGUID ? m_originalCaster : m_caster; if (!caster) return; @@ -2952,13 +3046,13 @@ void Spell::EffectApplyAura(uint32 i) else if ((spellInfo->AttributesEx & 0x20) && (spellInfo->AttributesEx2 & 0x20000)) spellId = 23230; // Blood Fury - Healing Reduction - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(spellId); - if (AdditionalSpellInfo) + SpellEntry const *AdditionalSpellEntry = sSpellStore.LookupEntry(spellId); + if (AdditionalSpellEntry) { // applied at target by target - Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, 0, NULL, unitTarget,unitTarget, 0); + Aura* AdditionalAura = CreateAura(AdditionalSpellEntry, 0, NULL, unitTarget,unitTarget, 0); unitTarget->AddAura(AdditionalAura); - sLog.outDebug("Spell: Additional Aura is: %u", AdditionalSpellInfo->EffectApplyAuraName[0]); + sLog.outDebug("Spell: Additional Aura is: %u", AdditionalSpellEntry->EffectApplyAuraName[0]); } } @@ -2973,7 +3067,7 @@ void Spell::EffectUnlearnSpecialization(uint32 i) return; Player *_player = (Player*)unitTarget; - uint32 spellToUnlearn = GetSpellInfo()->EffectTriggerSpell[i]; + uint32 spellToUnlearn = GetSpellEntry()->EffectTriggerSpell[i]; _player->removeSpell(spellToUnlearn); @@ -2982,10 +3076,10 @@ void Spell::EffectUnlearnSpecialization(uint32 i) void Spell::EffectPowerDrain(uint32 i) { - if (GetSpellInfo()->EffectMiscValue[i] < 0 || GetSpellInfo()->EffectMiscValue[i] >= MAX_POWERS) + if (GetSpellEntry()->EffectMiscValue[i] < 0 || GetSpellEntry()->EffectMiscValue[i] >= MAX_POWERS) return; - Powers drain_power = Powers(GetSpellInfo()->EffectMiscValue[i]); + Powers drain_power = Powers(GetSpellEntry()->EffectMiscValue[i]); if (!unitTarget) return; @@ -2999,7 +3093,7 @@ void Spell::EffectPowerDrain(uint32 i) uint32 curPower = unitTarget->GetPower(drain_power); //add spell damage bonus - damage=m_caster->SpellDamageBonus(unitTarget,GetSpellInfo(),uint32(damage),SPELL_DIRECT_DAMAGE); + damage=m_caster->SpellDamageBonus(unitTarget,GetSpellEntry(),uint32(damage),SPELL_DIRECT_DAMAGE); // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) uint32 power = damage; @@ -3016,24 +3110,24 @@ void Spell::EffectPowerDrain(uint32 i) if (drain_power == POWER_MANA) { - float manaMultiplier = GetSpellInfo()->EffectMultipleValue[i]; + float manaMultiplier = GetSpellEntry()->EffectMultipleValue[i]; if (manaMultiplier==0) manaMultiplier = 1; if (Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_MULTIPLE_VALUE, manaMultiplier); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_MULTIPLE_VALUE, manaMultiplier); int32 gain = int32(new_damage*manaMultiplier); m_caster->ModifyPower(POWER_MANA,gain); //send log - m_caster->SendEnergizeSpellLog(m_caster, GetSpellInfo()->Id,gain,POWER_MANA); + m_caster->SendEnergizeSpellLog(m_caster, GetSpellEntry()->Id,gain,POWER_MANA); } } void Spell::EffectSendEvent(uint32 EffectIndex) { - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Summon Arcane Elemental case 40134: @@ -3056,7 +3150,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) pBelmara->setFaction(35); pBelmara->MonsterSay("I can't sleep without a good bedtime story. Now I'm cerain to rest well.", LANG_UNIVERSAL, 0); - ((Player*)m_caster)->CastedCreatureOrGO(19547, pBelmara->GetGUID(), GetSpellInfo()->Id); + ((Player*)m_caster)->CastCreatureOrGO(19547, pBelmara->GetGUID(), GetSpellEntry()->Id); } break; } @@ -3071,7 +3165,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) pLuminrath->setFaction(35); pLuminrath->MonsterSay("I can't possibly go out without my cloak. I hope it's in here...", LANG_UNIVERSAL, 0); - ((Player*)m_caster)->CastedCreatureOrGO(19548, pLuminrath->GetGUID(), GetSpellInfo()->Id); + ((Player*)m_caster)->CastCreatureOrGO(19548, pLuminrath->GetGUID(), GetSpellEntry()->Id); } break; } @@ -3086,7 +3180,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) pCohlien->setFaction(35); pCohlien->MonsterSay("Phew! There's my lucky hat. I've been looking for it everywhere.", LANG_UNIVERSAL, 0); - ((Player*)m_caster)->CastedCreatureOrGO(19550, pCohlien->GetGUID(), GetSpellInfo()->Id); + ((Player*)m_caster)->CastCreatureOrGO(19550, pCohlien->GetGUID(), GetSpellEntry()->Id); } break; } @@ -3101,7 +3195,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) pDathric->setFaction(35); pDathric->MonsterSay("I don't know what I was thinking, going out without my sword. I would've put it on if I'd seen it here...", LANG_UNIVERSAL, 0); - ((Player*)m_caster)->CastedCreatureOrGO(19549, pDathric->GetGUID(), GetSpellInfo()->Id); + ((Player*)m_caster)->CastCreatureOrGO(19549, pDathric->GetGUID(), GetSpellEntry()->Id); } break; } @@ -3112,7 +3206,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); if (bg && bg->GetStatus() == STATUS_IN_PROGRESS) { - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 23333: // Pickup Horde Flag /*do not uncomment . @@ -3156,22 +3250,22 @@ void Spell::EffectSendEvent(uint32 EffectIndex) */ break; default: - sLog.outDebug("Unknown spellid %u in BG event", GetSpellInfo()->Id); + sLog.outDebug("Unknown spellid %u in BG event", GetSpellEntry()->Id); break; } } } - sLog.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", GetSpellInfo()->EffectMiscValue[EffectIndex], GetSpellInfo()->Id); - if (!sScriptMgr.OnProcessEvent(GetSpellInfo()->EffectMiscValue[EffectIndex], m_caster, focusObject, true)) - m_caster->GetMap()->ScriptsStart(sEventScripts, GetSpellInfo()->EffectMiscValue[EffectIndex], m_caster, focusObject); + sLog.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", GetSpellEntry()->EffectMiscValue[EffectIndex], GetSpellEntry()->Id); + if (!sScriptMgr.OnProcessEvent(GetSpellEntry()->EffectMiscValue[EffectIndex], m_caster, focusObject, true)) + m_caster->GetMap()->ScriptsStart(sEventScripts, GetSpellEntry()->EffectMiscValue[EffectIndex], m_caster, focusObject); } void Spell::EffectPowerBurn(uint32 i) { - if (GetSpellInfo()->EffectMiscValue[i] < 0 || GetSpellInfo()->EffectMiscValue[i] >= MAX_POWERS) + if (GetSpellEntry()->EffectMiscValue[i] < 0 || GetSpellEntry()->EffectMiscValue[i] >= MAX_POWERS) return; - Powers powertype = Powers(GetSpellInfo()->EffectMiscValue[i]); + Powers powertype = Powers(GetSpellEntry()->EffectMiscValue[i]); if (!unitTarget) return; @@ -3192,10 +3286,10 @@ void Spell::EffectPowerBurn(uint32 i) int32 new_damage = (curPower < power) ? curPower : power; unitTarget->ModifyPower(powertype,-new_damage); - float multiplier = GetSpellInfo()->EffectMultipleValue[i]; + float multiplier = GetSpellEntry()->EffectMultipleValue[i]; if (Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); new_damage = int32(new_damage*multiplier); //m_damage+=new_damage; should not apply spell bonus @@ -3224,7 +3318,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/) int32 addhealth = damage; // Vessel of the Naaru (Vial of the Sunwell trinket) - if (GetSpellInfo()->Id == 45064) + if (GetSpellEntry()->Id == 45064) { // Amount of heal - depends from stacked Holy Energy int damageAmount = 0; @@ -3238,7 +3332,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/) addhealth += damageAmount; } // Swiftmend - consumes Regrowth or Rejuvenation - else if (GetSpellInfo()->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND)) + else if (GetSpellEntry()->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND)) { Unit::AuraList const& RejorRegr = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); // find most short by duration @@ -3278,10 +3372,10 @@ void Spell::SpellDamageHeal(uint32 /*i*/) unitTarget->RemoveAurasByCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID()); //addhealth += tickheal * tickcount; - //addhealth = caster->SpellHealingBonus(GetSpellInfo(), addhealth,HEAL, unitTarget); + //addhealth = caster->SpellHealingBonus(GetSpellEntry(), addhealth,HEAL, unitTarget); } else - addhealth = caster->SpellHealingBonus(GetSpellInfo(), addhealth,HEAL, unitTarget); + addhealth = caster->SpellHealingBonus(GetSpellEntry(), addhealth,HEAL, unitTarget); m_damage -= addhealth; } @@ -3299,10 +3393,10 @@ void Spell::EffectHealPct(uint32 /*i*/) return; uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; - caster->SendHealSpellLog(unitTarget, GetSpellInfo()->Id, addhealth, false); + caster->SendHealSpellLog(unitTarget, GetSpellEntry()->Id, addhealth, false); int32 gain = unitTarget->ModifyHealth(int32(addhealth)); - unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, GetSpellInfo()); + unitTarget->getHostileRefManager().threatAssist(m_caster, float(gain) * 0.5f, GetSpellEntry()); if (caster->GetTypeId()==TYPEID_PLAYER) if (BattleGround *bg = ((Player*)caster)->GetBattleGround()) @@ -3322,8 +3416,8 @@ void Spell::EffectHealMechanical(uint32 /*i*/) if (!caster) return; - uint32 addhealth = caster->SpellHealingBonus(GetSpellInfo(), uint32(damage), HEAL, unitTarget); - caster->SendHealSpellLog(unitTarget, GetSpellInfo()->Id, addhealth, false); + uint32 addhealth = caster->SpellHealingBonus(GetSpellEntry(), uint32(damage), HEAL, unitTarget); + caster->SendHealSpellLog(unitTarget, GetSpellEntry()->Id, addhealth, false); unitTarget->ModifyHealth(int32(damage)); } } @@ -3340,15 +3434,15 @@ void Spell::EffectHealthLeech(uint32 i) sLog.outDebug("HealthLeech :%i", damage); - float multiplier = GetSpellInfo()->EffectMultipleValue[i]; + float multiplier = GetSpellEntry()->EffectMultipleValue[i]; multiplier = multiplier ? multiplier : 1.0; if (Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); int32 new_damage = 0; uint32 curHealth = unitTarget->GetHealth(); - new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, GetSpellInfo()->Id, damage, m_IsTriggeredSpell, true); + new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, GetSpellEntry()->Id, damage, m_IsTriggeredSpell, true); if (curHealth < new_damage) new_damage = curHealth; @@ -3357,12 +3451,12 @@ void Spell::EffectHealthLeech(uint32 i) if (m_caster->isAlive()) { - new_damage = m_caster->SpellHealingBonus(GetSpellInfo(), new_damage, HEAL, m_caster); + new_damage = m_caster->SpellHealingBonus(GetSpellEntry(), new_damage, HEAL, m_caster); int32 gain = m_caster->ModifyHealth(new_damage); - m_caster->getHostilRefManager().threatAssist(m_caster, gain * 0.5f, GetSpellInfo()); + m_caster->getHostileRefManager().threatAssist(m_caster, gain * 0.5f, GetSpellEntry()); - m_caster->SendHealSpellLog(m_caster, GetSpellInfo()->Id, uint32(new_damage)); + m_caster->SendHealSpellLog(m_caster, GetSpellEntry()->Id, uint32(new_damage)); } // m_healthLeech+=tmpvalue; // m_damage+=new_damage; @@ -3386,11 +3480,11 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) uint32 num_to_add; // TODO: maybe all this can be replaced by using correct calculated `damage` value - if (pProto->Class != ITEM_CLASS_CONSUMABLE || GetSpellInfo()->SpellFamilyName != SPELLFAMILY_MAGE) + if (pProto->Class != ITEM_CLASS_CONSUMABLE || GetSpellEntry()->SpellFamilyName != SPELLFAMILY_MAGE) { num_to_add = damage; /*int32 basePoints = m_currentBasePoints[i]; - int32 randomPoints = GetSpellInfo()->EffectDieSides[i]; + int32 randomPoints = GetSpellEntry()->EffectDieSides[i]; if (randomPoints) num_to_add = basePoints + irand(1, randomPoints); else @@ -3398,12 +3492,12 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) } else if (pProto->MaxCount == 1) num_to_add = 1; - else if (player->getLevel() >= GetSpellInfo()->spellLevel) + else if (player->getLevel() >= GetSpellEntry()->spellLevel) { num_to_add = damage; /*int32 basePoints = m_currentBasePoints[i]; - float pointPerLevel = GetSpellInfo()->EffectRealPointsPerLevel[i]; - num_to_add = basePoints + 1 + uint32((player->getLevel() - GetSpellInfo()->spellLevel)*pointPerLevel);*/ + float pointPerLevel = GetSpellEntry()->EffectRealPointsPerLevel[i]; + num_to_add = basePoints + 1 + uint32((player->getLevel() - GetSpellEntry()->spellLevel)*pointPerLevel);*/ } else num_to_add = 2; @@ -3420,7 +3514,7 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) // the maximum number of created additional items uint8 additionalMaxNum=0; // get the chance and maximum number for creating extra items - if (canCreateExtraItems(player, GetSpellInfo()->Id, additionalCreateChance, additionalMaxNum)) + if (canCreateExtraItems(player, GetSpellEntry()->Id, additionalCreateChance, additionalMaxNum)) { // roll with this chance till we roll not to create or we create the max num while (roll_chance_f(additionalCreateChance) && items_count<=additionalMaxNum) @@ -3468,27 +3562,27 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype) player->SendNewItem(pItem, num_to_add, true, true); // we succeeded in creating at least one item, so a levelup is possible - player->UpdateCraftSkill(GetSpellInfo()->Id); + player->UpdateCraftSkill(GetSpellEntry()->Id); } } void Spell::EffectCreateItem(uint32 i) { - DoCreateItem(i,GetSpellInfo()->EffectItemType[i]); + DoCreateItem(i,GetSpellEntry()->EffectItemType[i]); } void Spell::EffectPersistentAA(uint32 i) { - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); if (Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_RADIUS, radius); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_RADIUS, radius); Unit *caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster; - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); if (Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id, SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(GetSpellEntry()->Id, SPELLMOD_DURATION, duration); DynamicObject* dynObj = new DynamicObject; - if (!dynObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, GetSpellInfo()->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + if (!dynObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, GetSpellEntry()->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) { delete dynObj; return; @@ -3513,20 +3607,20 @@ void Spell::EffectEnergize(uint32 i) if (!unitTarget->isAlive()) return; - if (GetSpellInfo()->EffectMiscValue[i] < 0 || GetSpellInfo()->EffectMiscValue[i] >= MAX_POWERS) + if (GetSpellEntry()->EffectMiscValue[i] < 0 || GetSpellEntry()->EffectMiscValue[i] >= MAX_POWERS) return; // Don't energize targets with other power type - if (unitTarget->getPowerType() != GetSpellInfo()->EffectMiscValue[i]) + if (unitTarget->getPowerType() != GetSpellEntry()->EffectMiscValue[i]) return; //Serpent Coil Braid - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellInfo()->SpellFamilyFlags == 0x10000000000LL) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellEntry()->SpellFamilyFlags == 0x10000000000LL) if (unitTarget->HasAura(37447, 0)) unitTarget->CastSpell(unitTarget,37445,true); // Alchemist Stone - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_POTION) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_POTION) if (Aura *aura = unitTarget->GetAura(17619, 0)) { int32 bp = damage * 4 / 10; @@ -3536,7 +3630,7 @@ void Spell::EffectEnergize(uint32 i) // Some level depends spells int multiplier = 0; int level_diff = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Restore Energy case 9512: @@ -3563,7 +3657,7 @@ void Spell::EffectEnergize(uint32 i) if (damage < 0) return; - Powers power = Powers(GetSpellInfo()->EffectMiscValue[i]); + Powers power = Powers(GetSpellEntry()->EffectMiscValue[i]); if (unitTarget->GetMaxPower(power) == 0) return; @@ -3571,13 +3665,13 @@ void Spell::EffectEnergize(uint32 i) int32 gain = unitTarget->ModifyPower(power,damage); //No threat from life tap - if (GetSpellInfo()->Id != 31818) - unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, GetSpellInfo()); + if (GetSpellEntry()->Id != 31818) + unitTarget->getHostileRefManager().threatAssist(m_caster, float(gain) * 0.5f, GetSpellEntry()); - m_caster->SendEnergizeSpellLog(unitTarget, GetSpellInfo()->Id, damage, power); + m_caster->SendEnergizeSpellLog(unitTarget, GetSpellEntry()->Id, damage, power); // Mad Alchemist's Potion - if (GetSpellInfo()->Id == 45051) + if (GetSpellEntry()->Id == 45051) { // find elixirs on target uint32 elixir_mask = 0; @@ -3603,7 +3697,7 @@ void Spell::EffectEnergize(uint32 i) continue; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); - if (spellInfo && (spellInfo->spellLevel < GetSpellInfo()->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) + if (spellInfo && (spellInfo->spellLevel < GetSpellEntry()->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) continue; elixirs.push_back(itr->first); @@ -3626,10 +3720,10 @@ void Spell::EffectEnergisePct(uint32 i) if (!unitTarget->isAlive()) return; - if (GetSpellInfo()->EffectMiscValue[i] < 0 || GetSpellInfo()->EffectMiscValue[i] >= MAX_POWERS) + if (GetSpellEntry()->EffectMiscValue[i] < 0 || GetSpellEntry()->EffectMiscValue[i] >= MAX_POWERS) return; - Powers power = Powers(GetSpellInfo()->EffectMiscValue[i]); + Powers power = Powers(GetSpellEntry()->EffectMiscValue[i]); uint32 maxPower = unitTarget->GetMaxPower(power); if (maxPower == 0) @@ -3637,8 +3731,8 @@ void Spell::EffectEnergisePct(uint32 i) uint32 gain = damage * maxPower / 100; int32 realGain = unitTarget->ModifyPower(power, gain); - unitTarget->getHostilRefManager().threatAssist(m_caster, float(realGain) * 0.5f, GetSpellInfo()); - m_caster->SendEnergizeSpellLog(unitTarget, GetSpellInfo()->Id, realGain, power); + unitTarget->getHostileRefManager().threatAssist(m_caster, float(realGain) * 0.5f, GetSpellEntry()); + m_caster->SendEnergizeSpellLog(unitTarget, GetSpellEntry()->Id, realGain, power); } @@ -3755,7 +3849,7 @@ void Spell::EffectSummonChangeItem(uint32 i) if (m_CastItem->GetOwnerGUID()!=player->GetGUID()) return; - uint32 newitemid = GetSpellInfo()->EffectItemType[i]; + uint32 newitemid = GetSpellEntry()->EffectItemType[i]; if (!newitemid) return; @@ -3849,13 +3943,13 @@ void Spell::EffectProficiency(uint32 /*i*/) return; Player *p_target = (Player*)unitTarget; - uint32 subClassMask = GetSpellInfo()->EquippedItemSubClassMask; - if (GetSpellInfo()->EquippedItemClass == 2 && !(p_target->GetWeaponProficiency() & subClassMask)) + uint32 subClassMask = GetSpellEntry()->EquippedItemSubClassMask; + if (GetSpellEntry()->EquippedItemClass == 2 && !(p_target->GetWeaponProficiency() & subClassMask)) { p_target->AddWeaponProficiency(subClassMask); p_target->SendProficiency(uint8(0x02),p_target->GetWeaponProficiency()); } - if (GetSpellInfo()->EquippedItemClass == 4 && !(p_target->GetArmorProficiency() & subClassMask)) + if (GetSpellEntry()->EquippedItemClass == 4 && !(p_target->GetArmorProficiency() & subClassMask)) { p_target->AddArmorProficiency(subClassMask); p_target->SendProficiency(uint8(0x04),p_target->GetArmorProficiency()); @@ -3869,13 +3963,13 @@ void Spell::EffectApplyAreaAura(uint32 i) if (!unitTarget->isAlive()) return; - AreaAura* Aur = new AreaAura(GetSpellInfo(), i, &damage, unitTarget, m_caster, m_CastItem); + AreaAura* Aur = new AreaAura(GetSpellEntry(), i, &damage, unitTarget, m_caster, m_CastItem); unitTarget->AddAura(Aur); } void Spell::EffectSummonType(uint32 i) { - switch (GetSpellInfo()->EffectMiscValueB[i]) + switch (GetSpellEntry()->EffectMiscValueB[i]) { case SUMMON_TYPE_GUARDIAN: EffectSummonGuardian(i); @@ -3912,14 +4006,14 @@ void Spell::EffectSummonType(uint32 i) case SUMMON_TYPE_UNKNOWN5: break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: EffectSummonType: Unhandled summon type %u", GetSpellInfo()->EffectMiscValueB[i]); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectSummonType: Unhandled summon type %u", GetSpellEntry()->EffectMiscValueB[i]); break; } } void Spell::EffectSummon(uint32 i) { - uint32 pet_entry = GetSpellInfo()->EffectMiscValue[i]; + uint32 pet_entry = GetSpellEntry()->EffectMiscValue[i]; if (!pet_entry) return; @@ -3943,15 +4037,15 @@ void Spell::EffectSummon(uint32 i) z = m_targets.m_destZ; } else - m_caster->GetClosePoint(x,y,z,owner->GetObjectSize()); + m_caster->GetNearPoint(x,y,z,owner->GetObjectSize()); - Pet *spawnCreature = owner->SummonPet(pet_entry, x, y, z, m_caster->GetOrientation(), SUMMON_PET, SpellMgr::GetSpellDuration(GetSpellInfo())); + Pet *spawnCreature = owner->SummonPet(pet_entry, x, y, z, m_caster->GetOrientation(), SUMMON_PET, SpellMgr::GetSpellDuration(GetSpellEntry())); if (!spawnCreature) return; spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); - spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); std::string name = owner->GetName(); name.append(petTypeSuffix[spawnCreature->getPetType()]); @@ -3975,7 +4069,7 @@ void Spell::EffectLearnSpell(uint32 i) Player *player = (Player*)unitTarget; - uint32 spellToLearn = (GetSpellInfo()->Id==SPELL_ID_GENERIC_LEARN) ? damage : GetSpellInfo()->EffectTriggerSpell[i]; + uint32 spellToLearn = (GetSpellEntry()->Id==SPELL_ID_GENERIC_LEARN) ? damage : GetSpellEntry()->EffectTriggerSpell[i]; player->learnSpell(spellToLearn); sLog.outDebug("Spell: Player %u have learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow()); @@ -3988,6 +4082,9 @@ void Spell::EffectDispel(uint32 i) if (unitTarget->IsHostileTo(m_caster)) { + // make this additional immunity check here for mass dispel + if (unitTarget->IsImmunedToDamage(SpellMgr::GetSpellSchoolMask(GetSpellEntry()),true)) + return; m_caster->SetInCombatWith(unitTarget); unitTarget->SetInCombatWith(m_caster); } @@ -3996,7 +4093,7 @@ void Spell::EffectDispel(uint32 i) std::vector dispel_list; // Create dispel mask by dispel type - uint32 dispel_type = GetSpellInfo()->EffectMiscValue[i]; + uint32 dispel_type = GetSpellEntry()->EffectMiscValue[i]; uint32 dispelMask = SpellMgr::GetDispellMask(DispelType(dispel_type)); Unit::AuraMap const& auras = unitTarget->GetAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) @@ -4011,6 +4108,7 @@ void Spell::EffectDispel(uint32 i) if (aur->IsPositive() == unitTarget->IsFriendlyTo(m_caster)) continue; } + // Add every aura stack to dispel list for (uint32 stack_amount = 0; stack_amount < aur->GetStackAmount(); ++stack_amount) dispel_list.push_back(aur); @@ -4072,7 +4170,7 @@ void Spell::EffectDispel(uint32 i) WorldPacket data(SMSG_SPELLDISPELLOG, 8+8+4+1+4+count*5); data << unitTarget->GetPackGUID(); // Victim GUID data << m_caster->GetPackGUID(); // Caster GUID - data << uint32(GetSpellInfo()->Id); // dispel spell id + data << uint32(GetSpellEntry()->Id); // dispel spell id data << uint8(0); // not used data << uint32(count); // count for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) @@ -4092,10 +4190,10 @@ void Spell::EffectDispel(uint32 i) // On succes dispel // Devour Magic - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_WARLOCK && GetSpellInfo()->Category == 12) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_WARLOCK && GetSpellEntry()->Category == 12) { uint32 heal_spell = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 19505: heal_spell = 19658; break; case 19731: heal_spell = 19732; break; @@ -4104,7 +4202,7 @@ void Spell::EffectDispel(uint32 i) case 27276: heal_spell = 27278; break; case 27277: heal_spell = 27279; break; default: - sLog.outDebug("Spell for Devour Magic %d not handled in Spell::EffectDispel", GetSpellInfo()->Id); + sLog.outDebug("Spell for Devour Magic %d not handled in Spell::EffectDispel", GetSpellEntry()->Id); break; } if (heal_spell) @@ -4118,7 +4216,7 @@ void Spell::EffectDispel(uint32 i) WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); data << uint64(m_caster->GetGUID()); // Caster GUID data << uint64(unitTarget->GetGUID()); // Victim GUID - data << uint32(GetSpellInfo()->Id); // dispel spell id + data << uint32(GetSpellEntry()->Id); // dispel spell id for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j) data << uint32(*j); // Spell Id m_caster->BroadcastPacket(&data, true); @@ -4192,10 +4290,10 @@ void Spell::EffectAddFarsight(uint32 i) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); DynamicObject* dynObj = new DynamicObject; - if (!dynObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, GetSpellInfo()->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + if (!dynObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, GetSpellEntry()->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) { delete dynObj; return; @@ -4205,7 +4303,7 @@ void Spell::EffectAddFarsight(uint32 i) dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); m_caster->AddDynObject(dynObj); - dynObj->setActive(true); //must before add to map to be put in world container + //dynObj->setActive(true); //must before add to map to be put in world container m_caster->GetMap()->Add(dynObj); //grid will also be loaded m_caster->UpdateVisibilityAndView(); @@ -4215,7 +4313,7 @@ void Spell::EffectAddFarsight(uint32 i) void Spell::EffectSummonWild(uint32 i) { - uint32 creature_entry = GetSpellInfo()->EffectMiscValue[i]; + uint32 creature_entry = GetSpellEntry()->EffectMiscValue[i]; if (!creature_entry) return; @@ -4243,7 +4341,7 @@ void Spell::EffectSummonWild(uint32 i) float center_y = m_targets.m_destY; float center_z = m_targets.m_destZ; - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); int32 amount = damage > 0 ? damage : 1; @@ -4266,11 +4364,11 @@ void Spell::EffectSummonWild(uint32 i) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(px,py,pz,3.0f); + m_caster->GetNearPoint(px,py,pz,3.0f); - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; + TemporarySummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; if (m_originalCaster) m_originalCaster->SummonCreature(creature_entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); @@ -4281,45 +4379,60 @@ void Spell::EffectSummonWild(uint32 i) void Spell::EffectSummonGuardian(uint32 i) { - uint32 pet_entry = GetSpellInfo()->EffectMiscValue[i]; + uint32 pet_entry = GetSpellEntry()->EffectMiscValue[i]; if (!pet_entry) return; // Jewelery statue case (totem like) - if (GetSpellInfo()->SpellIconID==2056) + if (GetSpellEntry()->SpellIconID==2056) { EffectSummonTotem(i); return; } // set timer for unsummon - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); Player *caster = NULL; if (m_originalCaster) { - if (m_originalCaster->GetTypeId() == TYPEID_PLAYER) - caster = (Player*)m_originalCaster; - else if (((Creature*)m_originalCaster)->isTotem()) - { - if (((Creature*)m_originalCaster)->GetEntry() == 15439 || ((Creature*)m_originalCaster)->GetEntry() == 15430) - { - float px, py, pz; - m_caster->GetClosePoint(px,py,pz,m_caster->GetObjectSize()); - if (caster = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself()) - if (Pet *spawnCreature = caster->SummonPet(GetSpellInfo()->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(), GUARDIAN_PET, duration)) - { - spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); - spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); - spawnCreature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); - spawnCreature->SetOwnerGUID(m_caster->GetGUID()); - spawnCreature->SetReactState(REACT_AGGRESSIVE); - return; - } - } - else - caster = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); - } + if (m_originalCaster->GetTypeId() == TYPEID_PLAYER) + caster = (Player*)m_originalCaster; + else if (((Creature*)m_originalCaster)->isTotem()) + { + if (((Creature*)m_originalCaster)->GetEntry() == 15439 || ((Creature*)m_originalCaster)->GetEntry() == 15430) + { + float px, py, pz; + m_caster->GetNearPoint(px,py,pz,m_caster->GetObjectSize()); + if (caster = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Pet *spawnCreature = caster->SummonPet(GetSpellEntry()->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(), GUARDIAN_PET, duration)) + { + spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); + spawnCreature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + spawnCreature->SetOwnerGUID(m_caster->GetGUID()); + spawnCreature->SetReactState(REACT_DEFENSIVE); + + float healthfactor = (frand(0.15, 0.30)); + float manafactor = (frand(0.2, 0.8)); + spawnCreature->SetMaxHealth(spawnCreature->GetMaxHealth() + caster->GetHealthBonusFromStamina() * healthfactor); + spawnCreature->SetHealth(spawnCreature->GetMaxHealth() + caster->GetHealthBonusFromStamina() * healthfactor); + if(spawnCreature->GetEntry() == 15438) + { + spawnCreature->SetMaxPower(POWER_MANA, (spawnCreature->GetMaxPower(POWER_MANA) + caster->GetManaBonusFromIntellect() * manafactor)); + spawnCreature->SetPower(POWER_MANA,(spawnCreature->GetMaxPower(POWER_MANA) + caster->GetManaBonusFromIntellect() * manafactor)); + } + //Precise values are impossible to find. This values (+ 10-30%) are the conclusion of all available proofs, lovered by 10%. + //After checking the impact on the game if may be lowered to 10%. + //Mana bonus must be much lover, due to conclusion of spells costs. + //Bonus spell damage is not confirmed, so it's NOT implemented. + + return; + } + } + else + caster = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself(); + } } if (!caster) @@ -4327,14 +4440,24 @@ void Spell::EffectSummonGuardian(uint32 i) EffectSummonWild(i); return; } - - // Search old Guardian only for players (if casted spell not have duration or cooldown) + + // Search old Guardian only for players (if cast spell not have duration or cooldown) // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time // so this code hack in fact - if (duration <= 0 || SpellMgr::GetSpellRecoveryTime(GetSpellInfo())==0) + if (duration <= 0 || SpellMgr::GetSpellRecoveryTime(GetSpellEntry())==0) if (caster->HasGuardianWithEntry(pet_entry)) - return; // find old guardian, ignore summon + return; // find old guardian, ignore summon + auto guardians = caster->GetGuardians(); + if (guardians.size() >= 5 && !caster->GetSession()->HasPermissions(PERM_GMT)) + { + std::stringstream stream; + stream << "Guardians summoning exploit(spellid: " << GetSpellEntry()->Id << "), guardians count: " << guardians.size(); + + sWorld.SendGMText(LANG_POSSIBLE_CHEAT, stream.str().c_str(), caster->GetName(), caster->GetName()); + sLog.outLog(LOG_CHEAT, "Possible cheater: %s, trying to exploit guardians(spellid: %d), guardians count: %d.", caster->GetName(), GetSpellEntry()->Id, guardians.size()); + } + // in another case summon new uint32 level = caster->getLevel(); @@ -4357,7 +4480,7 @@ void Spell::EffectSummonGuardian(uint32 i) float center_y = m_targets.m_destY; float center_z = m_targets.m_destZ; - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); int32 amount = damage > 0 ? damage : 1; @@ -4380,21 +4503,21 @@ void Spell::EffectSummonGuardian(uint32 i) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(px,py,pz,m_caster->GetObjectSize()); + m_caster->GetNearPoint(px,py,pz,m_caster->GetObjectSize()); - Pet *spawnCreature = caster->SummonPet(GetSpellInfo()->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(), GUARDIAN_PET, duration); + Pet *spawnCreature = caster->SummonPet(GetSpellEntry()->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(), GUARDIAN_PET, duration); if (!spawnCreature) return; spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); - spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); spawnCreature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); } } void Spell::EffectSummonPossessed(uint32 i) { - uint32 entry = GetSpellInfo()->EffectMiscValue[i]; + uint32 entry = GetSpellEntry()->EffectMiscValue[i]; if (!entry) return; @@ -4404,15 +4527,15 @@ void Spell::EffectSummonPossessed(uint32 i) uint32 level = m_caster->getLevel(); float x, y, z; - m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); + m_caster->GetNearPoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); Pet* pet = ((Player*)m_caster)->SummonPet(entry, x, y, z + 0.5f, m_caster->GetOrientation(), POSSESSED_PET, duration); if (!pet) return; - pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); pet->SetCharmedOrPossessedBy(m_caster, true); } @@ -4428,10 +4551,10 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i) if(!m_targets.HasDst()) { - float dis = SpellMgr::GetSpellRadius(GetSpellInfo(),i,false); + float dis = SpellMgr::GetSpellRadius(GetSpellEntry(),i,false); float fx,fy,fz; - m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); + m_caster->GetNearPoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); if (mapid == unitTarget->GetMapId()) unitTarget->NearTeleportTo(fx, fy, fz, -m_caster->GetOrientation(), unitTarget == m_caster); @@ -4454,7 +4577,7 @@ void Spell::EffectLearnSkill(uint32 i) if (damage < 0) return; - uint32 skillid = GetSpellInfo()->EffectMiscValue[i]; + uint32 skillid = GetSpellEntry()->EffectMiscValue[i]; uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid); ((Player*)unitTarget)->SetSkill(skillid, skillval?skillval:1, damage*75); } @@ -4464,7 +4587,7 @@ void Spell::EffectAddHonor(uint32 /*i*/) if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", GetSpellInfo()->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); + sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", GetSpellEntry()->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); // TODO: find formula for honor reward based on player's level! @@ -4477,7 +4600,7 @@ void Spell::EffectTradeSkill(uint32 /*i*/) { if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - // uint32 skillid = GetSpellInfo()->EffectMiscValue[i]; + // uint32 skillid = GetSpellEntry()->EffectMiscValue[i]; // uint16 skillmax = ((Player*)unitTarget)->(skillid); // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75); } @@ -4491,11 +4614,11 @@ void Spell::EffectEnchantItemPerm(uint32 i) Player* p_caster = (Player*)m_caster; - p_caster->UpdateCraftSkill(GetSpellInfo()->Id); + p_caster->UpdateCraftSkill(GetSpellEntry()->Id); - if (GetSpellInfo()->EffectMiscValue[i]) + if (GetSpellEntry()->EffectMiscValue[i]) { - uint32 enchant_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 enchant_id = GetSpellEntry()->EffectMiscValue[i]; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) @@ -4506,7 +4629,7 @@ void Spell::EffectEnchantItemPerm(uint32 i) if (!item_owner) return; - if (item_owner!=p_caster && p_caster->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (item_owner!=p_caster && p_caster->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), @@ -4534,10 +4657,10 @@ void Spell::EffectEnchantItemTmp(uint32 i) if (!itemTarget) return; - uint32 enchant_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 enchant_id = GetSpellEntry()->EffectMiscValue[i]; // Shaman Rockbiter Weapon - if (i==0 && GetSpellInfo()->Effect[1]==SPELL_EFFECT_DUMMY) + if (i==0 && GetSpellEntry()->Effect[1]==SPELL_EFFECT_DUMMY) { int32 enchanting_damage = CalculateDamage(1, NULL);//+1; @@ -4592,14 +4715,14 @@ void Spell::EffectEnchantItemTmp(uint32 i) if (!enchant_id) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",GetSpellInfo()->Id,i); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",GetSpellEntry()->Id,i); return; } SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",GetSpellInfo()->Id,i,enchant_id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",GetSpellEntry()->Id,i,enchant_id); return; } @@ -4607,26 +4730,26 @@ void Spell::EffectEnchantItemTmp(uint32 i) uint32 duration; // rogue family enchantments exception by duration - if (GetSpellInfo()->Id==38615) + if (GetSpellEntry()->Id==38615) duration = 1800; // 30 mins // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) - else if (GetSpellInfo()->SpellFamilyName==SPELLFAMILY_ROGUE) + else if (GetSpellEntry()->SpellFamilyName==SPELLFAMILY_ROGUE) duration = 3600; // 1 hour // shaman family enchantments - else if (GetSpellInfo()->SpellFamilyName==SPELLFAMILY_SHAMAN) + else if (GetSpellEntry()->SpellFamilyName==SPELLFAMILY_SHAMAN) duration = 1800; // 30 mins // other cases with this SpellVisual already selected - else if (GetSpellInfo()->SpellVisual==215) + else if (GetSpellEntry()->SpellVisual==215) duration = 1800; // 30 mins // some fishing pole bonuses - else if (GetSpellInfo()->SpellVisual==563) + else if (GetSpellEntry()->SpellVisual==563) duration = 600; // 10 mins // shaman rockbiter enchantments - else if (GetSpellInfo()->SpellVisual==0) + else if (GetSpellEntry()->SpellVisual==0) duration = 1800; // 30 mins - else if (GetSpellInfo()->Id==29702) + else if (GetSpellEntry()->Id==29702) duration = 300; // 5 mins - else if (GetSpellInfo()->Id==37360) + else if (GetSpellEntry()->Id==37360) duration = 300; // 5 mins // default case else @@ -4637,7 +4760,7 @@ void Spell::EffectEnchantItemTmp(uint32 i) if (!item_owner) return; - if (item_owner!=p_caster && p_caster->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (item_owner!=p_caster && p_caster->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), @@ -4677,7 +4800,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) //SendChannelUpdate(0); finish(); - Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget,GetSpellInfo()->Id); + Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget,GetSpellEntry()->Id); if (!pet) return; // kill original creature @@ -4721,7 +4844,7 @@ void Spell::EffectSummonPet(uint32 i) return; } - uint32 petentry = GetSpellInfo()->EffectMiscValue[i]; + uint32 petentry = GetSpellEntry()->EffectMiscValue[i]; Pet *OldSummon = owner->GetPet(); @@ -4746,7 +4869,7 @@ void Spell::EffectSummonPet(uint32 i) pz = m_targets.m_destZ; } else - owner->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); + owner->GetNearPoint(px, py, pz, OldSummon->GetObjectSize()); OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); owner->GetMap()->Add((Creature*)OldSummon); @@ -4781,7 +4904,7 @@ void Spell::EffectSummonPet(uint32 i) z = m_targets.m_destZ; } else - owner->GetClosePoint(x, y, z, owner->GetObjectSize()); + owner->GetNearPoint(x, y, z, owner->GetObjectSize()); Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0); if (!pet) @@ -4795,7 +4918,7 @@ void Spell::EffectSummonPet(uint32 i) pet->SetReactState(REACT_DEFENSIVE); } - pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); // this enables popup window (pet dismiss, cancel), hunter pet additional flags set later pet->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); @@ -4820,7 +4943,7 @@ void Spell::EffectLearnPetSpell(uint32 i) if (!pet->isAlive()) return; - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellInfo()->EffectTriggerSpell[i]); + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(GetSpellEntry()->EffectTriggerSpell[i]); if (!learn_spellproto) return; @@ -4862,7 +4985,7 @@ void Spell::EffectTaunt(uint32 /*i*/) //Set aggro victim to caster if (!unitTarget->getThreatManager().getOnlineContainer().empty()) - if (HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster)) + if (HostileReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster)) unitTarget->getThreatManager().setCurrentVictim(forcedVictim); if (((Creature*)unitTarget)->IsAIEnabled) @@ -4885,7 +5008,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) // and handle all effects at once for (int j = 0; j < 3; j++) { - switch (GetSpellInfo()->Effect[j]) + switch (GetSpellEntry()->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -4903,14 +5026,14 @@ void Spell::SpellDamageWeaponDmg(uint32 i) int32 fixed_bonus = 0; int32 spell_bonus = 0; // bonus specific for spell - switch (GetSpellInfo()->SpellFamilyName) + switch (GetSpellEntry()->SpellFamilyName) { case SPELLFAMILY_WARRIOR: { // Heroic Strike - if (GetSpellInfo()->SpellFamilyFlags & 0x40) + if (GetSpellEntry()->SpellFamilyFlags & 0x40) { - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Heroic Strike r10 + r11 case 29707: @@ -4921,7 +5044,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) { if ((*iter)->GetSpellProto()->SpellIconID == 15 && (*iter)->GetSpellProto()->Dispel == 0) { - fixed_bonus += (GetSpellInfo()->Id == 29707) ? 61 : 72; + fixed_bonus += (GetSpellEntry()->Id == 29707) ? 61 : 72; break; } } @@ -4931,7 +5054,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) break; } // Devastate bonus and sunder armor refresh - else if (GetSpellInfo()->SpellVisual == 671 && GetSpellInfo()->SpellIconID == 1508) + else if (GetSpellEntry()->SpellVisual == 671 && GetSpellEntry()->SpellIconID == 1508) { uint32 stack = 0; @@ -4952,7 +5075,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) for (int j = 0; j < 3; j++) { - if (GetSpellInfo()->Effect[j] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) + if (GetSpellEntry()->Effect[j] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) { fixed_bonus += (stack - 1) * CalculateDamage(j, unitTarget); break; @@ -4974,7 +5097,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) continue; if (spellInfo->SpellFamilyFlags == SPELLFAMILYFLAG_WARRIOR_SUNDERARMOR - && spellInfo->Id != GetSpellInfo()->Id + && spellInfo->Id != GetSpellEntry()->Id && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR) { m_caster->CastSpell(unitTarget, spellInfo, true); @@ -4988,13 +5111,13 @@ void Spell::SpellDamageWeaponDmg(uint32 i) case SPELLFAMILY_ROGUE: { // Hemorrhage - if (GetSpellInfo()->SpellFamilyFlags & 0x2000000) + if (GetSpellEntry()->SpellFamilyFlags & 0x2000000) { if (m_caster->GetTypeId()==TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget, 1); } // Mutilate (for each hand) - else if (GetSpellInfo()->SpellFamilyFlags & 0x600000000LL) + else if (GetSpellEntry()->SpellFamilyFlags & 0x600000000LL) { Unit::AuraMap const& auras = unitTarget->GetAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) @@ -5011,10 +5134,10 @@ void Spell::SpellDamageWeaponDmg(uint32 i) case SPELLFAMILY_PALADIN: { // Seal of Command - receive benefit from Spell Damage and Healing - if (GetSpellInfo()->SpellFamilyFlags & 0x00000002000000LL) + if (GetSpellEntry()->SpellFamilyFlags & 0x00000002000000LL) { - spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonus(SpellMgr::GetSpellSchoolMask(GetSpellInfo()))); - spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonusForVictim(SpellMgr::GetSpellSchoolMask(GetSpellInfo()), unitTarget)); + spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonus(SpellMgr::GetSpellSchoolMask(GetSpellEntry()))); + spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonusForVictim(SpellMgr::GetSpellSchoolMask(GetSpellEntry()), unitTarget)); } break; } @@ -5022,9 +5145,9 @@ void Spell::SpellDamageWeaponDmg(uint32 i) { // Skyshatter Harness item set bonus // Stormstrike - if (GetSpellInfo()->SpellFamilyFlags & 0x001000000000LL) + if (GetSpellEntry()->SpellFamilyFlags & 0x001000000000LL) { - Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (Unit::AuraList::const_iterator citr = m_OverrideClassScript.begin(); citr != m_OverrideClassScript.end(); ++citr) { // Stormstrike AP Buff @@ -5040,13 +5163,13 @@ void Spell::SpellDamageWeaponDmg(uint32 i) case SPELLFAMILY_DRUID: { // Mangle (Cat): CP - if (GetSpellInfo()->SpellFamilyFlags==0x0000040000000000LL) + if (GetSpellEntry()->SpellFamilyFlags==0x0000040000000000LL) { if (m_caster->GetTypeId()==TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget,1); } // Maim interrupt (s3, s4 gloves bonus) - if (GetSpellInfo()->Id == 22570 && m_caster->HasAura(44835, 0)) + if (GetSpellEntry()->Id == 22570 && m_caster->HasAura(44835, 0)) m_caster->CastSpell(unitTarget, 32747, true); break; } @@ -5056,7 +5179,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) float weaponDamagePercentMod = 1.0; for (int j = 0; j < 3; ++j) { - switch (GetSpellInfo()->Effect[j]) + switch (GetSpellEntry()->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -5104,7 +5227,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) { // We assume that a spell have at most one fixed_bonus // and at most one weaponDamagePercentMod - switch (GetSpellInfo()->Effect[j]) + switch (GetSpellEntry()->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -5130,7 +5253,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) uint32 eff_damage = uint32(weaponDamage > 0 ? weaponDamage : 0); // Add melee damage bonuses (also check for negative) - m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, GetSpellInfo()); + m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, GetSpellEntry()); m_damage+= eff_damage; // take ammo @@ -5186,7 +5309,7 @@ void Spell::EffectHealMaxHealth(uint32 /*i*/) uint32 addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth(); // Lay on Hands - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PALADIN && GetSpellInfo()->SpellFamilyFlags & 0x0000000000008000) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_PALADIN && GetSpellEntry()->SpellFamilyFlags & 0x0000000000008000) { if (!m_originalCaster || m_originalCaster->IsHostileTo(unitTarget)) return; @@ -5201,31 +5324,45 @@ void Spell::EffectHealMaxHealth(uint32 /*i*/) unitTarget->SetHealth(unitTarget->GetMaxHealth()); if (m_originalCaster) - m_originalCaster->SendHealSpellLog(unitTarget, GetSpellInfo()->Id, addhealth, false); + m_originalCaster->SendHealSpellLog(unitTarget, GetSpellEntry()->Id, addhealth, false); } void Spell::EffectInterruptCast(uint32 i) { - if (!unitTarget) - return; - if (!unitTarget->isAlive()) + if (!unitTarget || !unitTarget->isAlive()) return; // TODO: not all spells that used this effect apply cooldown at school spells // also exist case: apply cooldown to interrupted cast only and to all spells for (uint32 k = CURRENT_FIRST_NON_MELEE_SPELL; k < CURRENT_MAX_SPELL; k++) { - if (unitTarget->m_currentSpells[k]) + if (Spell* spell = unitTarget->m_currentSpells[k]) { + const SpellEntry* curSpellEntry = spell->GetSpellEntry(); // check if we can interrupt spell - if ((unitTarget->m_currentSpells[k]->getState() == SPELL_STATE_CASTING || (unitTarget->m_currentSpells[k]->getState() == SPELL_STATE_PREPARING && unitTarget->m_currentSpells[k]->GetCastTime() > 0.0f)) && unitTarget->m_currentSpells[k]->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && unitTarget->m_currentSpells[k]->GetSpellInfo()->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) + if ((spell->getState() == SPELL_STATE_CASTING || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) && + curSpellEntry->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && + ((k == CURRENT_GENERIC_SPELL && curSpellEntry->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) || + (k == CURRENT_CHANNELED_SPELL && curSpellEntry->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_MOVEMENT))) { if (m_originalCaster) { - int32 duration = m_originalCaster->CalculateSpellDuration(GetSpellInfo(), i, unitTarget); - unitTarget->ProhibitSpellScholl(SpellMgr::GetSpellSchoolMask(unitTarget->m_currentSpells[k]->GetSpellInfo()), duration/*GetSpellDuration(GetSpellInfo())*/); + int32 duration = m_originalCaster->CalculateSpellDuration(GetSpellEntry(), i, unitTarget); + unitTarget->ProhibitSpellSchool(SpellMgr::GetSpellSchoolMask(curSpellEntry), duration /* GetSpellDuration(GetSpellEntry())? */); } - unitTarget->InterruptSpell(k,false); + + // has to be sent before InterruptSpell call + WorldPacket data(SMSG_SPELLLOGEXECUTE, (8+4+4+4+4+8+4)); + data << m_caster->GetPackGUID(); + data << uint32(GetSpellEntry()->Id); + data << uint32(1); // effect count + data << uint32(SPELL_EFFECT_INTERRUPT_CAST); + data << uint32(1); // target count + data << unitTarget->GetPackGUID(); + data << uint32(curSpellEntry->Id); + m_caster->BroadcastPacket(&data, true); + + unitTarget->InterruptSpell(k, false); } } } @@ -5233,7 +5370,7 @@ void Spell::EffectInterruptCast(uint32 i) void Spell::EffectSummonObjectWild(uint32 i) { - uint32 gameobject_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 gameobject_id = GetSpellEntry()->EffectMiscValue[i]; GameObject* pGameObj = new GameObject; @@ -5249,7 +5386,7 @@ void Spell::EffectSummonObjectWild(uint32 i) z = m_targets.m_destZ; } else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + m_caster->GetNearPoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); Map *map = target->GetMap(); @@ -5260,9 +5397,9 @@ void Spell::EffectSummonObjectWild(uint32 i) return; } - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(GetSpellInfo()->Id); + pGameObj->SetSpellId(GetSpellEntry()->Id); if (pGameObj->GetGoType() != GAMEOBJECT_TYPE_FLAGDROP) // make dropped flag clickable for other players (not set owner guid (created by) for this)... { @@ -5310,7 +5447,7 @@ void Spell::EffectSummonObjectWild(uint32 i) x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY)) { linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); - linkedGO->SetSpellId(GetSpellInfo()->Id); + linkedGO->SetSpellId(GetSpellEntry()->Id); m_caster->AddGameObject(linkedGO); map->Add(linkedGO); @@ -5327,7 +5464,7 @@ void Spell::EffectSummonObjectWild(uint32 i) void Spell::EffectScriptEffect(uint32 effIndex) { // TODO: we must implement hunter pet summon at login there (spell 6962) - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // we need script here, because KillCreadit in DB is used for diff quest :p case 32314: @@ -5537,15 +5674,15 @@ void Spell::EffectScriptEffect(uint32 effIndex) uint32 GravityLapseSpellId = 44219; // Id for first teleport spell uint32 GravityLapseDOT = (m_caster->GetMap()->IsHeroic()?44226:49887); // knocback + damage - uint32 GravityLapseChannel = 44251; // visual self-casted, triggers AoE beams + uint32 GravityLapseChannel = 44251; // visual self-cast, triggers AoE beams uint8 counter = 0; - std::list PlayerList = m_caster->getThreatManager().getThreatList(); + std::list PlayerList = m_caster->getThreatManager().getThreatList(); if(PlayerList.empty() && m_caster->isInCombat()) ((Creature*)m_caster)->AI()->EnterEvadeMode(); - for(std::list::iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + for(std::list::iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { Unit* pUnit = m_caster->GetMap()->GetUnit((*i)->getUnitGuid()); if(!pUnit) @@ -5660,7 +5797,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) {22103,22104,22105} // Master Healthstone }; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 6201: itemtype=itypes[0][rank];break; // Minor Healthstone case 6202: itemtype=itypes[1][rank];break; // Lesser Healthstone @@ -5697,7 +5834,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) return; uint32 spellid = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 25140: spellid = 32571; break; case 25143: spellid = 32572; break; @@ -5751,7 +5888,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) uint8 race = m_caster->getRace(); uint32 spellId = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 24194: switch (race) @@ -6002,7 +6139,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) m_caster->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 0, dbcitem->ID); // Unclear what this spell should do - unitTarget->CastSpell(m_caster, GetSpellInfo()->EffectBasePoints[effIndex], true); + unitTarget->CastSpell(m_caster, GetSpellEntry()->EffectBasePoints[effIndex], true); } } return; @@ -6050,25 +6187,24 @@ void Spell::EffectScriptEffect(uint32 effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - //if (unitTarget->GetMap()-> IsDungeon() || unitTarget->GetMap()->IsRaid()) - // return; + unitTarget->Mount(22653); - if (GetVirtualMapForMapAndZone(unitTarget->GetMapId(),((Player*)unitTarget)->GetCachedZone()) != 530) + if (GetVirtualMapForMapAndZone(unitTarget->GetMapId(), ((Player*)unitTarget)->GetCachedZone()) != 530) { - switch (((Player*)unitTarget)->GetBaseSkillValue(762)) + switch (((Player*)unitTarget)->GetBaseSkillValue(SKILL_RIDING)) { - case 75: unitTarget->CastSpell(unitTarget, 51621, false); break;; - case 150: case 225: case 300: unitTarget->CastSpell(unitTarget, 48024, false); break; + case 75: unitTarget->CastSpell(unitTarget, 51621, true); break;; + case 150: case 225: case 300: unitTarget->CastSpell(unitTarget, 48024, true); break; default: break; } }else { - switch (((Player*)unitTarget)->GetBaseSkillValue(762)) + switch (((Player*)unitTarget)->GetBaseSkillValue(SKILL_RIDING)) { - case 75: unitTarget->CastSpell(unitTarget, 51621, false); break;; - case 150: unitTarget->CastSpell(unitTarget, 48024, false); break; - case 225: unitTarget->CastSpell(unitTarget, 51617, false); break; - case 300: unitTarget->CastSpell(unitTarget, 48023, false); break; + case 75: unitTarget->CastSpell(unitTarget, 51621, true); break;; + case 150: unitTarget->CastSpell(unitTarget, 48024, true); break; + case 225: unitTarget->CastSpell(unitTarget, 51617, true); break; + case 300: unitTarget->CastSpell(unitTarget, 48023, true); break; default: break; } } @@ -6079,9 +6215,9 @@ void Spell::EffectScriptEffect(uint32 effIndex) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - if (GetVirtualMapForMapAndZone(unitTarget->GetMapId(),((Player*)unitTarget)->GetCachedZone()) != 530) + if (GetVirtualMapForMapAndZone(unitTarget->GetMapId(), ((Player*)unitTarget)->GetCachedZone()) != 530) { - switch (((Player*)unitTarget)->GetBaseSkillValue(762)) + switch (((Player*)unitTarget)->GetBaseSkillValue(SKILL_RIDING)) { case 75: unitTarget->CastSpell(unitTarget, 42681, true); break;; case 150: case 225: case 300: unitTarget->CastSpell(unitTarget, 42683, true); break; @@ -6090,7 +6226,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) } else { - switch (((Player*)unitTarget)->GetBaseSkillValue(762)) + switch (((Player*)unitTarget)->GetBaseSkillValue(SKILL_RIDING)) { case 75: unitTarget->CastSpell(unitTarget, 42681, true); break;; case 150: unitTarget->CastSpell(unitTarget, 42684, true); break; @@ -6123,7 +6259,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 26528: { uint32 summon_spell_entry = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 26532: //green summon_spell_entry = 26533; @@ -6185,7 +6321,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) switch(unitTarget->GetEntry()) { case 24108: - //((Player*)m_caster)->CastedCreatureOrGO(unitTarget->GetEntry(), unitTarget->GetGUID(), 0); + //((Player*)m_caster)->CastCreatureOrGO(unitTarget->GetEntry(), unitTarget->GetGUID(), 0); m_caster->CastSpell(m_caster, 47173, true); break; case 23709: @@ -6197,15 +6333,20 @@ void Spell::EffectScriptEffect(uint32 effIndex) } break; } + case 40638: //Willy Focus + { + m_caster->CastSpell(unitTarget, damage ,false); + break; + } } if (!unitTarget || !unitTarget->isAlive()) // can we remove this check? { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u in EffectScriptEffect does not have unitTarget", GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell %u in EffectScriptEffect does not have unitTarget", GetSpellEntry()->Id); return; } - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Dreaming Glory case 28698: @@ -6259,7 +6400,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 45141: case 45151: { //Workaround for Range ... should be global for every ScriptEffect - float radius = SpellMgr::GetSpellRadius(GetSpellInfo(), effIndex, false); + float radius = SpellMgr::GetSpellRadius(GetSpellEntry(), effIndex, false); //if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) <= radius && !unitTarget->HasAura(46394,0) && unitTarget != m_caster) if(!unitTarget->HasAura(46394, 0) && unitTarget != m_caster) unitTarget->CastSpell(unitTarget,46394,true, 0, 0, m_originalCasterGUID); @@ -6285,15 +6426,28 @@ void Spell::EffectScriptEffect(uint32 effIndex) m_caster->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 1, dbcitem->ID); // Unclear what this spell should do - unitTarget->CastSpell(m_caster, GetSpellInfo()->EffectBasePoints[effIndex], true); + unitTarget->CastSpell(m_caster, GetSpellEntry()->EffectBasePoints[effIndex], true); } } return; } - // Negative Energy + // Negative Energy - Entropius case 46289: - m_caster->CastSpell(unitTarget, 46285, true); + { + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + int32 damage = irand(1885, 2115); + m_caster->CastCustomSpell(unitTarget, 46285, &damage, 0, 0, true, 0, 0, m_caster->GetGUID()); + damage /= 2; + if(Unit* target_2 = unitTarget->ToPlayer()->GetNextRandomRaidMember(10.0f, true)) + { + unitTarget->CastCustomSpell(target_2, 46285, &damage, 0, 0, true, 0, 0, m_caster->GetGUID()); + damage /= 2; + if(Unit* target_3 = target_2->ToPlayer()->GetNextRandomRaidMember(10.0f, true)) + target_2->CastCustomSpell(target_3, 46285, &damage, 0, 0, true, 0, 0, m_caster->GetGUID()); + } return; + } //5,000 Gold case 46642: { @@ -6422,9 +6576,9 @@ void Spell::EffectScriptEffect(uint32 effIndex) break; } - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PALADIN) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_PALADIN) { - switch (GetSpellInfo()->SpellFamilyFlags) + switch (GetSpellEntry()->SpellFamilyFlags) { // Judgement case 0x800000: @@ -6477,8 +6631,8 @@ void Spell::EffectScriptEffect(uint32 effIndex) } // normal DB scripted effect - sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", GetSpellInfo()->Id); - m_caster->GetMap()->ScriptsStart(sSpellScripts, GetSpellInfo()->Id, m_caster, unitTarget); + sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", GetSpellEntry()->Id); + m_caster->GetMap()->ScriptsStart(sSpellScripts, GetSpellEntry()->Id, m_caster, unitTarget); } void Spell::EffectSanctuary(uint32 /*i*/) @@ -6509,9 +6663,9 @@ void Spell::EffectSanctuary(uint32 /*i*/) } unitTarget->CombatStop(); - unitTarget->getHostilRefManager().deleteReferences(); // stop all fighting + unitTarget->getHostileRefManager().deleteReferences(); // stop all fighting // Vanish allows to remove all threat and cast regular stealth so other spells can be used - if (GetSpellInfo()->SpellFamilyName == SPELLFAMILY_ROGUE && (GetSpellInfo()->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_VANISH)) + if (GetSpellEntry()->SpellFamilyName == SPELLFAMILY_ROGUE && (GetSpellEntry()->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_VANISH)) { ((Player *)m_caster)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); } @@ -6564,7 +6718,7 @@ void Spell::EffectDuel(uint32 i) //CREATE DUEL FLAG OBJECT GameObject* pGameObj = new GameObject; - uint32 gameobject_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 gameobject_id = GetSpellEntry()->EffectMiscValue[i]; Map *map = m_caster->GetMap(); if (!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, @@ -6579,9 +6733,9 @@ void Spell::EffectDuel(uint32 i) pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction()); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1); - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(GetSpellInfo()->Id); + pGameObj->SetSpellId(GetSpellEntry()->Id); m_caster->AddGameObject(pGameObj); map->Add(pGameObj); @@ -6611,6 +6765,9 @@ void Spell::EffectDuel(uint32 i) caster->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); target->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); + + // used by eluna + sHookMgr->OnDuelRequest(target, caster); } void Spell::EffectStuck(uint32 /*i*/) @@ -6657,18 +6814,22 @@ void Spell::EffectSummonPlayer(uint32 /*i*/) if (unitTarget->GetDummyAura(23445)) return; + if (!unitTarget->ToPlayer()->CanBeSummonedBy(m_caster->ToPlayer())) + return; + + const Player * pCaster = m_caster->ToPlayer(); float x,y,z; - m_caster->GetClosePoint(x,y,z,unitTarget->GetObjectSize()); + m_caster->GetNearPoint(x,y,z,unitTarget->GetObjectSize()); - ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); + unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(),x,y,z); - uint32 zoneid = m_caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)m_caster)->GetCachedZone() : m_caster->GetZoneId(); + uint32 zoneid = pCaster ? pCaster->GetCachedZone() : m_caster->GetZoneId(); WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4); data << uint64(m_caster->GetGUID()); // summoner guid data << uint32(zoneid); // summoner zone data << uint32(MAX_PLAYER_SUMMON_DELAY*1000); // auto decline after msecs - ((Player*)unitTarget)->SendPacketToSelf(&data); + unitTarget->ToPlayer()->SendPacketToSelf(&data); } static ScriptInfo generateActivateCommand() @@ -6685,7 +6846,7 @@ void Spell::EffectActivateObject(uint32 effect_idx) static ScriptInfo activateCommand = generateActivateCommand(); - int32 delay_secs = GetSpellInfo()->EffectMiscValue[effect_idx]; + int32 delay_secs = GetSpellEntry()->EffectMiscValue[effect_idx]; gameObjTarget->GetMap()->ScriptCommandStart(activateCommand, delay_secs, m_caster, gameObjTarget); } @@ -6693,7 +6854,7 @@ void Spell::EffectActivateObject(uint32 effect_idx) void Spell::EffectSummonTotem(uint32 i) { uint8 slot = 0; - switch (GetSpellInfo()->EffectMiscValueB[i]) + switch (GetSpellEntry()->EffectMiscValueB[i]) { case SUMMON_TYPE_TOTEM_SLOT1: slot = 0; break; case SUMMON_TYPE_TOTEM_SLOT2: slot = 1; break; @@ -6727,7 +6888,7 @@ void Spell::EffectSummonTotem(uint32 i) dest.z = m_targets.m_destZ; Totem* pTotem = new Totem; - if (!pTotem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), GetSpellInfo()->EffectMiscValue[i], team, dest.x, dest.y, dest.z, m_caster->GetOrientation())) + if (!pTotem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), GetSpellEntry()->EffectMiscValue[i], team, dest.x, dest.y, dest.z, m_caster->GetOrientation())) { delete pTotem; return; @@ -6737,11 +6898,11 @@ void Spell::EffectSummonTotem(uint32 i) m_caster->m_TotemSlot[slot] = pTotem->GetGUID(); pTotem->SetOwner(m_caster->GetGUID()); - pTotem->SetTypeBySummonSpell(GetSpellInfo()); // must be after Create call where m_spells initilized + pTotem->SetTypeBySummonSpell(GetSpellEntry()); // must be after Create call where m_spells initilized - int32 duration=SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration=SpellMgr::GetSpellDuration(GetSpellEntry()); if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo()->Id,SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(GetSpellEntry()->Id,SPELLMOD_DURATION, duration); pTotem->SetDuration(duration); @@ -6751,11 +6912,11 @@ void Spell::EffectSummonTotem(uint32 i) pTotem->SetHealth(damage); } - pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL,GetSpellInfo()->Id); + pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL,GetSpellEntry()->Id); pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); - pTotem->ApplySpellImmune(GetSpellInfo()->Id,IMMUNITY_STATE,SPELL_AURA_MOD_FEAR,true); - pTotem->ApplySpellImmune(GetSpellInfo()->Id,IMMUNITY_STATE,SPELL_AURA_TRANSFORM,true); + pTotem->ApplySpellImmune(GetSpellEntry()->Id,IMMUNITY_STATE,SPELL_AURA_MOD_FEAR,true); + pTotem->ApplySpellImmune(GetSpellEntry()->Id,IMMUNITY_STATE,SPELL_AURA_TRANSFORM,true); if (slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) { @@ -6763,7 +6924,7 @@ void Spell::EffectSummonTotem(uint32 i) data << uint8(slot); data << uint64(pTotem->GetGUID()); data << uint32(duration); - data << uint32(GetSpellInfo()->Id); + data << uint32(GetSpellEntry()->Id); ((Player*)m_caster)->SendPacketToSelf(&data); } @@ -6786,10 +6947,10 @@ void Spell::EffectEnchantHeldItem(uint32 i) if (!item ->IsEquipped()) return; - if (GetSpellInfo()->EffectMiscValue[i]) + if (GetSpellEntry()->EffectMiscValue[i]) { - uint32 enchant_id = GetSpellInfo()->EffectMiscValue[i]; - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); //Try duration index first .. + uint32 enchant_id = GetSpellEntry()->EffectMiscValue[i]; + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); //Try duration index first .. if (!duration) duration = damage;//+1; //Base points after .. if (!duration) @@ -6821,7 +6982,7 @@ void Spell::EffectDisEnchant(uint32 /*i*/) if (!itemTarget || !itemTarget->GetProto()->DisenchantID) return; - p_caster->UpdateCraftSkill(GetSpellInfo()->Id); + p_caster->UpdateCraftSkill(GetSpellEntry()->Id); ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(),LOOT_DISENCHANTING); @@ -6868,7 +7029,7 @@ void Spell::EffectFeedPet(uint32 i) _player->DestroyItemCount(itemTarget,count,true); // TODO: fix crash when a spell has two effects, both pointed at the same item target - m_caster->CastCustomSpell(m_caster,GetSpellInfo()->EffectTriggerSpell[i],&benefit,NULL,NULL,true); + m_caster->CastCustomSpell(m_caster,GetSpellEntry()->EffectTriggerSpell[i],&benefit,NULL,NULL,true); } void Spell::EffectDismissPet(uint32 /*i*/) @@ -6887,10 +7048,10 @@ void Spell::EffectDismissPet(uint32 /*i*/) void Spell::EffectSummonObject(uint32 i) { - uint32 go_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 go_id = GetSpellEntry()->EffectMiscValue[i]; uint8 slot = 0; - switch (GetSpellInfo()->Effect[i]) + switch (GetSpellEntry()->Effect[i]) { case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; @@ -6920,7 +7081,7 @@ void Spell::EffectSummonObject(uint32 i) } // Summon in random point all other units if location present else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + m_caster->GetNearPoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); Map *map = m_caster->GetMap(); if (!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map, x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) @@ -6930,9 +7091,9 @@ void Spell::EffectSummonObject(uint32 i) } //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL,m_caster->getLevel()); - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(GetSpellInfo()->Id); + pGameObj->SetSpellId(GetSpellEntry()->Id); m_caster->AddGameObject(pGameObj); map->Add(pGameObj); @@ -6945,17 +7106,10 @@ void Spell::EffectSummonObject(uint32 i) void Spell::EffectResurrect(uint32 /*effIndex*/) { - if (!unitTarget) - return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || !unitTarget->IsInWorld() || unitTarget->isAlive()) return; - if (unitTarget->isAlive()) - return; - if (!unitTarget->IsInWorld()) - return; - - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { // Defibrillate (Goblin Jumper Cables) have 33% chance on success case 8342: @@ -6977,16 +7131,34 @@ void Spell::EffectResurrect(uint32 /*effIndex*/) break; } - Player* pTarget = ((Player*)unitTarget); + if (Player* pTarget = unitTarget->ToPlayer()) + { + if (pTarget->isRessurectRequested()) // already have one active request + return; - if (pTarget->isRessurectRequested()) // already have one active request - return; + uint32 health = pTarget->GetMaxHealth() * damage / 100; + uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; + + pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + SendResurrectRequest(pTarget); + } + else if (Pet* pet = unitTarget->ToPet()) + { + if (pet->getPetType() != HUNTER_PET || pet->isAlive()) + return; + + float x, y, z; + m_caster->GetPosition(x, y, z); + pet->NearTeleportTo(x, y, z, m_caster->GetOrientation()); - uint32 health = pTarget->GetMaxHealth() * damage / 100; - uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; + pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + pet->setDeathState(ALIVE); + pet->clearUnitState(UNIT_STAT_ALL_STATE); + pet->SetHealth(uint32(pet->GetMaxHealth() * damage / 100)); - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); - SendResurrectRequest(pTarget); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + } } void Spell::EffectAddExtraAttacks(uint32 /*i*/) @@ -7035,7 +7207,7 @@ void Spell::EffectLeapForward(uint32 i) if (unitTarget->IsTaxiFlying()) return; - if (GetSpellInfo()->rangeIndex == 1) //self range + if (GetSpellEntry()->rangeIndex == 1) //self range { Position dest; dest.x = m_targets.m_destX; @@ -7051,7 +7223,7 @@ void Spell::EffectLeapBack(uint32 i) if (unitTarget->IsTaxiFlying()) return; - m_caster->KnockBackFrom(unitTarget,float(GetSpellInfo()->EffectMiscValue[i])/10,float(damage)/10); + m_caster->KnockBackFrom(unitTarget,float(GetSpellEntry()->EffectMiscValue[i])/10,float(damage)/10); } void Spell::EffectReputation(uint32 i) @@ -7063,7 +7235,7 @@ void Spell::EffectReputation(uint32 i) int32 rep_change = damage;//+1; // field store reputation change -1 - uint32 faction_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 faction_id = GetSpellEntry()->EffectMiscValue[i]; FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); @@ -7082,7 +7254,7 @@ void Spell::EffectQuestComplete(uint32 i) Player *_player = (Player*)m_caster; - uint32 quest_id = GetSpellInfo()->EffectMiscValue[i]; + uint32 quest_id = GetSpellEntry()->EffectMiscValue[i]; _player->AreaExploredOrEventHappens(quest_id); } @@ -7102,7 +7274,7 @@ void Spell::EffectSelfResurrect(uint32 i) if (damage < 0) { health = uint32(-damage); - mana = GetSpellInfo()->EffectMiscValue[i]; + mana = GetSpellEntry()->EffectMiscValue[i]; } // percent case else @@ -7172,7 +7344,7 @@ void Spell::EffectCharge(uint32 /*i*/) m_caster->GetMotionMaster()->MoveCharge(_path); // not all charge effects used in negative spells - if (!SpellMgr::IsPositiveSpell(GetSpellInfo()->Id) && m_caster->GetTypeId() == TYPEID_PLAYER) + if (!SpellMgr::IsPositiveSpell(GetSpellEntry()->Id) && m_caster->GetTypeId() == TYPEID_PLAYER) m_caster->Attack(target, true); } @@ -7205,7 +7377,7 @@ void Spell::EffectCharge2(uint32 /*i*/) m_caster->GetMotionMaster()->MoveCharge(_path); // not all charge effects used in negative spells - if (!SpellMgr::IsPositiveSpell(GetSpellInfo()->Id)) + if (!SpellMgr::IsPositiveSpell(GetSpellEntry()->Id)) m_caster->Attack(unitTarget, true); } @@ -7215,7 +7387,7 @@ void Spell::EffectSummonCritter(uint32 i) return; Player* player = (Player*)m_caster; - uint32 pet_entry = GetSpellInfo()->EffectMiscValue[i]; + uint32 pet_entry = GetSpellEntry()->EffectMiscValue[i]; if (!pet_entry) return; @@ -7240,7 +7412,7 @@ void Spell::EffectSummonCritter(uint32 i) if (!critter->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_PET), map, pet_entry, pet_number)) { - sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectSummonCritter, spellid %u: no such creature entry %u", GetSpellInfo()->Id, pet_entry); + sLog.outLog(LOG_DEFAULT, "ERROR: Spell::EffectSummonCritter, spellid %u: no such creature entry %u", GetSpellEntry()->Id, pet_entry); delete critter; return; } @@ -7255,7 +7427,7 @@ void Spell::EffectSummonCritter(uint32 i) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(x,y,z,critter->GetObjectSize()); + m_caster->GetNearPoint(x,y,z,critter->GetObjectSize()); critter->Relocate(x,y,z,m_caster->GetOrientation()); @@ -7270,7 +7442,7 @@ void Spell::EffectSummonCritter(uint32 i) critter->SetOwnerGUID(m_caster->GetGUID()); critter->SetCreatorGUID(m_caster->GetGUID()); critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellEntry()->Id); critter->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter... critter->SetMaxHealth(1); @@ -7279,7 +7451,7 @@ void Spell::EffectSummonCritter(uint32 i) critter->SetUInt32Value(UNIT_NPC_FLAGS, critter->GetCreatureInfo()->npcflag); // some mini-pets have quests // set timer for unsummon - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); if (duration > 0) critter->SetDuration(duration); @@ -7296,7 +7468,10 @@ void Spell::EffectKnockBack(uint32 i) if (!unitTarget) return; - unitTarget->KnockBackFrom(m_caster,float(GetSpellInfo()->EffectMiscValue[i])/10,float(damage)/10); + if (GetSpellEntry()->Id == 37852) // Watery Grave Explosion; + unitTarget->SetStunned(false); // stunned state has to be removed manually here before aura expires to allow self knockback + + unitTarget->KnockBackFrom(m_caster,float(GetSpellEntry()->EffectMiscValue[i])/10,float(damage)/10); } void Spell::EffectSendTaxi(uint32 i) @@ -7304,7 +7479,7 @@ void Spell::EffectSendTaxi(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(GetSpellInfo()->EffectMiscValue[i]); + TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(GetSpellEntry()->EffectMiscValue[i]); if (!entry) return; @@ -7315,7 +7490,7 @@ void Spell::EffectSendTaxi(uint32 i) nodes[1] = entry->to; uint32 mountid = 0; - switch (GetSpellInfo()->Id) + switch (GetSpellEntry()->Id) { case 31606: // Stormcrow Amulet mountid = 17447; @@ -7349,7 +7524,30 @@ void Spell::EffectPlayerPull(uint32 i) if (damage && dist > damage) dist = damage; - unitTarget->KnockBackFrom(m_caster, -dist, GetSpellInfo()->EffectMiscValue[i]/10.0); + unitTarget->KnockBackFrom(m_caster, -dist, GetSpellEntry()->EffectMiscValue[i]/10.0); +} + +void Spell::EffectSuspendGravity(uint32 i) +{ + if (!unitTarget) + return; + + float dist = unitTarget->GetDistance2d(m_caster); + WorldLocation wLoc; + float diff_z; + unitTarget->GetPosition(wLoc); + float ground_z = m_caster->GetTerrain()->GetHeight(wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, true); + diff_z = unitTarget->GetPositionZ() - ground_z; + + // for now this has to only support one spell + if(unitTarget->HasAura(46230, 2)) + { + if(Aura* aur = unitTarget->GetAura(46230, 2)) + if(aur->GetAuraDuration() < 3400) + unitTarget->KnockBackFrom(m_caster, dist-frand(7, 14), diff_z < 1.5 ? GetSpellEntry()->EffectMiscValue[i]/10.0 : 0); + } + else + unitTarget->KnockBackFrom(m_caster, dist-frand(7, 14), diff_z < 1.5 ? GetSpellEntry()->EffectMiscValue[i]/10.0 : 0); } void Spell::EffectDispelMechanic(uint32 i) @@ -7365,7 +7563,7 @@ void Spell::EffectDispelMechanic(uint32 i) // Fill possible dispel list std::list dispel_list; - uint32 mechanic = GetSpellInfo()->EffectMiscValue[i]; + uint32 mechanic = GetSpellEntry()->EffectMiscValue[i]; Unit::AuraMap& Auras = unitTarget->GetAuras(); for (Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); ++iter) { @@ -7426,7 +7624,7 @@ void Spell::EffectDispelMechanic(uint32 i) WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); data << uint64(m_caster->GetGUID()); // Caster GUID data << uint64(unitTarget->GetGUID()); // Victim GUID - data << uint32(GetSpellInfo()->Id); // dispel spell id + data << uint32(GetSpellEntry()->Id); // dispel spell id for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j) data << uint32(*j); // Spell Id m_caster->BroadcastPacket(&data, true); @@ -7436,7 +7634,7 @@ void Spell::EffectDispelMechanic(uint32 i) return; } -void Spell::EffectSummonDeadPet(uint32 /*i*/) +void Spell::EffectResurrectPet(uint32 /*i*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) return; @@ -7490,7 +7688,7 @@ void Spell::EffectDestroyAllTotems(uint32 /*i*/) } int32 gain = m_caster->ModifyPower(POWER_MANA,int32(mana)); - m_caster->SendEnergizeSpellLog(m_caster, GetSpellInfo()->Id, gain, POWER_MANA); + m_caster->SendEnergizeSpellLog(m_caster, GetSpellEntry()->Id, gain, POWER_MANA); } void Spell::EffectDurabilityDamage(uint32 i) @@ -7498,7 +7696,7 @@ void Spell::EffectDurabilityDamage(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - int32 slot = GetSpellInfo()->EffectMiscValue[i]; + int32 slot = GetSpellEntry()->EffectMiscValue[i]; // FIXME: some spells effects have value -1/-2 // Possibly its mean -1 all player equipped items and -2 all items @@ -7521,7 +7719,7 @@ void Spell::EffectDurabilityDamagePCT(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - int32 slot = GetSpellInfo()->EffectMiscValue[i]; + int32 slot = GetSpellEntry()->EffectMiscValue[i]; // FIXME: some spells effects have value -1/-2 // Possibly its mean -1 all player equipped items and -2 all items @@ -7552,10 +7750,10 @@ void Spell::EffectModifyThreatPercent(uint32 /*effIndex*/) void Spell::EffectTransmitted(uint32 effIndex) { - uint32 name_id = GetSpellInfo()->EffectMiscValue[effIndex]; + uint32 name_id = GetSpellEntry()->EffectMiscValue[effIndex]; // Create Soulwell hack - if (GetSpellInfo()->Id == 29886) + if (GetSpellEntry()->Id == 29886) { if (m_caster->HasAura(18693, 0)) //imp healthstone rank 2 name_id = 183511; @@ -7568,7 +7766,7 @@ void Spell::EffectTransmitted(uint32 effIndex) if (!goinfo) { - sLog.outLog(LOG_DB_ERR, "Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id, GetSpellInfo()->Id); + sLog.outLog(LOG_DB_ERR, "Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id, GetSpellEntry()->Id); return; } @@ -7581,46 +7779,23 @@ void Spell::EffectTransmitted(uint32 effIndex) fz = m_targets.m_destZ; } //FIXME: this can be better check for most objects but still hack - else if (GetSpellInfo()->EffectRadiusIndex[effIndex] && GetSpellInfo()->speed==0) + else if (GetSpellEntry()->EffectRadiusIndex[effIndex] && GetSpellEntry()->speed==0) { - float dis = SpellMgr::GetSpellRadius(GetSpellInfo(),effIndex,false); - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + float dis = SpellMgr::GetSpellRadius(GetSpellEntry(),effIndex,false); + m_caster->GetNearPoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); } else { - float min_dis = SpellMgr::GetSpellMinRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); - float max_dis = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellInfo()->rangeIndex)); + float min_dis = SpellMgr::GetSpellMinRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); + float max_dis = SpellMgr::GetSpellMaxRange(sSpellRangeStore.LookupEntry(GetSpellEntry()->rangeIndex)); float dis = rand_norm() * (max_dis - min_dis) + min_dis; - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + m_caster->GetNearPoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); } Map *cMap = m_caster->GetMap(); - if (goinfo->type == GAMEOBJECT_TYPE_FISHINGNODE) - { - GridMapLiquidData liqData; - /*if(cMap->GetId() == 548 && m_caster->GetDistance(36.69, -416.38, -19.9645) <= 16) //center of strange pool // Hack to prevent fishing bobber from failing to land on fishing hole - { - fx = 36.69 +irand(-8,8); - fy = -416.38 +irand(-8,8); - fz = -19.9645; - - } - else */if (!m_caster->GetTerrain()->IsInWater(fx, fy, fz + 1.f/* -0.5f */, &liqData)) // Hack to prevent fishing bobber from failing to land on fishing hole - { - // but this is not proper, we really need to ignore not materialized objects - SendCastResult(SPELL_FAILED_NOT_HERE); - SendChannelUpdate(0); - return; - } - - // replace by water level in this case - //if(cMap->GetId() != 548) - fz = liqData.level; - } - // if gameobject is summoning object, it should be spawned right on caster's position - else if (goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) + if (goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) { m_caster->GetPosition(fx,fy,fz); } @@ -7634,7 +7809,7 @@ void Spell::EffectTransmitted(uint32 effIndex) return; } - int32 duration = SpellMgr::GetSpellDuration(GetSpellInfo()); + int32 duration = SpellMgr::GetSpellDuration(GetSpellEntry()); switch (goinfo->type) { @@ -7643,8 +7818,8 @@ void Spell::EffectTransmitted(uint32 effIndex) m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID()); m_caster->AddGameObject(pGameObj); // will removed at spell cancel - // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(GetSpellInfo())) - // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(GetSpellInfo())-FISHING_BOBBER_READY_TIME) + // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(GetSpellEntry())) + // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(GetSpellEntry())-FISHING_BOBBER_READY_TIME) int32 lastSec = 0; switch (urand(0, 3)) { @@ -7662,7 +7837,7 @@ void Spell::EffectTransmitted(uint32 effIndex) if (m_caster->GetTypeId()==TYPEID_PLAYER) { pGameObj->AddUniqueUse((Player*)m_caster); - //m_caster->AddGameObject(pGameObj); // will removed at spell cancel + m_caster->AddGameObject(pGameObj); // will removed at spell cancel pGameObj->SetLootState(GO_ACTIVATED); pGameObj->SetTarget(((Player*)m_caster)->GetSelection()); } @@ -7681,7 +7856,7 @@ void Spell::EffectTransmitted(uint32 effIndex) pGameObj->SetOwnerGUID(m_caster->GetGUID()); //pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); - pGameObj->SetSpellId(GetSpellInfo()->Id); + pGameObj->SetSpellId(GetSpellEntry()->Id); DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted\n"); //m_caster->AddGameObject(pGameObj); @@ -7701,7 +7876,7 @@ void Spell::EffectTransmitted(uint32 effIndex) { linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); //linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); - linkedGO->SetSpellId(GetSpellInfo()->Id); + linkedGO->SetSpellId(GetSpellEntry()->Id); linkedGO->SetOwnerGUID(m_caster->GetGUID()); linkedGO->GetMap()->Add(linkedGO); @@ -7747,7 +7922,7 @@ void Spell::EffectSummonDemon(uint32 i) float px = m_targets.m_destX; float py = m_targets.m_destY; float pz = m_targets.m_destZ; - int32 creature_ID = GetSpellInfo()->EffectMiscValue[i]; + int32 creature_ID = GetSpellEntry()->EffectMiscValue[i]; Creature* Charmed = m_caster->SummonCreature(creature_ID, px, py, pz, m_caster->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,3600000); if (!Charmed) @@ -7805,7 +7980,7 @@ void Spell::EffectSpiritHeal(uint32 /*i*/) if (!unitTarget->IsInWorld()) return; - //GetSpellInfo()->EffectBasePoints[i]; == 99 (percent?) + //GetSpellEntry()->EffectBasePoints[i]; == 99 (percent?) //((Player*)unitTarget)->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA)); ((Player*)unitTarget)->ResurrectPlayer(1.0f); ((Player*)unitTarget)->SpawnCorpseBones(); @@ -7831,7 +8006,7 @@ void Spell::EffectStealBeneficialBuff(uint32 i) std::vector steal_list; // Create dispel mask by dispel type - uint32 dispelMask = SpellMgr::GetDispellMask(DispelType(GetSpellInfo()->EffectMiscValue[i])); + uint32 dispelMask = SpellMgr::GetDispellMask(DispelType(GetSpellEntry()->EffectMiscValue[i])); Unit::AuraMap const& auras = unitTarget->GetAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -7898,7 +8073,7 @@ void Spell::EffectStealBeneficialBuff(uint32 i) WorldPacket data(SMSG_SPELLSTEALLOG, 8+8+4+1+4+count*5); data << unitTarget->GetPackGUID(); // Victim GUID data << m_caster->GetPackGUID(); // Caster GUID - data << uint32(GetSpellInfo()->Id); // dispel spell id + data << uint32(GetSpellEntry()->Id); // dispel spell id data << uint8(0); // not used data << uint32(count); // count for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) @@ -7918,7 +8093,7 @@ void Spell::EffectStealBeneficialBuff(uint32 i) WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); data << uint64(m_caster->GetGUID()); // Caster GUID data << uint64(unitTarget->GetGUID()); // Victim GUID - data << uint32(GetSpellInfo()->Id); // dispel spell id + data << uint32(GetSpellEntry()->Id); // dispel spell id for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j) data << uint32(*j); // Spell Id m_caster->BroadcastPacket(&data, true); @@ -7931,7 +8106,7 @@ void Spell::EffectKillCredit(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - ((Player*)unitTarget)->RewardPlayerAndGroupAtEvent(GetSpellInfo()->EffectMiscValue[i], unitTarget); + ((Player*)unitTarget)->RewardPlayerAndGroupAtEvent(GetSpellEntry()->EffectMiscValue[i], unitTarget); } void Spell::EffectQuestFail(uint32 i) @@ -7939,7 +8114,7 @@ void Spell::EffectQuestFail(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - ((Player*)unitTarget)->FailQuest(GetSpellInfo()->EffectMiscValue[i]); + ((Player*)unitTarget)->FailQuest(GetSpellEntry()->EffectMiscValue[i]); } void Spell::EffectRedirectThreat(uint32 /*i*/) @@ -7953,11 +8128,11 @@ void Spell::EffectPlayMusic(uint32 i) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - uint32 soundid = GetSpellInfo()->EffectMiscValue[i]; + uint32 soundid = GetSpellEntry()->EffectMiscValue[i]; if (!sSoundEntriesStore.LookupEntry(soundid)) { - sLog.outLog(LOG_DEFAULT, "ERROR: EffectPlayMusic: Sound (Id: %u) not exist in spell %u.",soundid,GetSpellInfo()->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: EffectPlayMusic: Sound (Id: %u) not exist in spell %u.",soundid,GetSpellEntry()->Id); return; } @@ -7965,3 +8140,30 @@ void Spell::EffectPlayMusic(uint32 i) data << uint32(soundid); ((Player*)unitTarget)->SendPacketToSelf(&data); } + +void Spell::EffectFriendSummon(uint32 eff_idx) +{ + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + uint64 selection = ((Player*) m_caster)->GetSelection(); + if (selection == NULL || !IS_PLAYER_GUID(selection)) + { + DEBUG_LOG("Spell::EffectFriendSummon is called, but no selection or selection is not player"); + return; + } + + Player* target = ObjectAccessor::GetPlayer(selection); + if (target == nullptr) + return; + + WorldLocation location; + location.mapid = m_caster->GetMapId(); + location.coord_x = m_caster->GetPositionX(); + location.coord_y = m_caster->GetPositionY(); + location.coord_z = m_caster->GetPositionZ(); + location.orientation = m_caster->GetOrientation(); + + target->InterruptTaxiFlying(); + target->TeleportTo(location); +} diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 2883181ad..5d18bcf59 100755 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -175,7 +175,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) // use triggered flag only for items with many spell casts and for not first cast int count = 0; - for (int i = 0; i < 5; ++i) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { _Spell const& spellData = pItem->GetProto()->Spells[i]; @@ -329,7 +329,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) return; } - // not have spell or spell passive and not casted by client + // not have spell or spell passive and not cast by client if (!_player->HasSpell(spellId) || SpellMgr::IsPassiveSpell(spellId)) { //cheater? kick? ban? @@ -343,14 +343,14 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) // auto-selection buff level base at target level (in spellInfo) if (Unit* target = targets.getUnitTarget()) { - // if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message - if (SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(spellInfo, target->getLevel())) - spellInfo = actualSpellInfo; + // if rank not found then function return NULL but in explicit cast case original spell can be cast and later failed with appropriate error message + if (SpellEntry const *actualSpellEntry = sSpellMgr.SelectAuraRankForPlayerLevel(spellInfo, target->getLevel())) + spellInfo = actualSpellEntry; } if (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_AUTOREPEAT_FLAG) { - if (_player->m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && _player->m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Id == spellInfo->Id) + if (_player->m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && _player->m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellEntry()->Id == spellInfo->Id) return; } @@ -366,7 +366,7 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) uint32 spellId; recvPacket >> spellId; - if (!_player->isCharmed() && !_player->isPossessed() && _player->IsNonMeleeSpellCasted(false)) + if (!_player->isCharmed() && !_player->isPossessed() && _player->IsNonMeleeSpellCast(false)) _player->InterruptNonMeleeSpells(false,spellId,false); } @@ -408,11 +408,11 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) return; } - // channeled spell case (it currently casted then) + // channeled spell case (it currently cast then) if (SpellMgr::IsChanneledSpell(spellInfo)) { if (_player->m_currentSpells[CURRENT_CHANNELED_SPELL] && - _player->m_currentSpells[CURRENT_CHANNELED_SPELL]->GetSpellInfo()->Id==spellId) + _player->m_currentSpells[CURRENT_CHANNELED_SPELL]->GetSpellEntry()->Id==spellId) _player->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } @@ -518,3 +518,86 @@ void WorldSession::HandleSelfResOpcode(WorldPacket & /*recv_data*/) } } +void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) +{ + sLog.outDebug("WORLD: CMSG_GET_MIRRORIMAGE_DATA"); + + ObjectGuid guid; + recv_data >> guid; + + Creature* pCreature = _player->GetMap()->GetCreature(guid); + + if (!pCreature) + return; + + Unit::AuraList const& images = pCreature->GetAurasByType(SPELL_AURA_MIRROR_IMAGE); + + if (images.empty()) + return; + + Unit* pCaster = images.front()->GetCaster(); + + WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68); + + data << guid; + data << (uint32)pCreature->GetDisplayId(); + + data << (uint8)pCreature->getRace(); + data << (uint8)pCreature->getGender(); + // data << (uint8)pCreature->getClass(); + + if (pCaster && pCaster->GetTypeId() == TYPEID_PLAYER) + { + Player* pPlayer = (Player*)pCaster; + + // skin, face, hair, haircolor + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 0); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 1); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 2); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 3); + + // facial hair + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES_2, 0); + + // guild id + data << (uint32)pPlayer->GetGuildId(); + + if (pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) + data << (uint32)0; + else + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_HEAD); + + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_SHOULDERS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_BODY); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_CHEST); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_WAIST); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_LEGS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_FEET); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_WRISTS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_HANDS); + + if (pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) + data << (uint32)0; + else + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_BACK); + + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD); + } + else + { + // No data when cloner is not player, data is taken from CreatureDisplayInfoExtraEntry by model already + data << (uint8)0; + data << (uint8)0; + data << (uint8)0; + data << (uint8)0; + + data << (uint8)0; + + data << (uint32)0; + + for (int i = 0; i < 11; ++i) + data << (uint32)0; + } + + SendPacket(&data); +} diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index d184d190d..190d69ada 100755 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Unit.h" @@ -58,7 +58,7 @@ SpellMgr::SpellMgr() case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: //105 case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: //106 case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: //107 - case SPELL_EFFECT_SUMMON_DEAD_PET: //109 + case SPELL_EFFECT_RESURRECT_PET: //109 case SPELL_EFFECT_SUMMON_DEMON: //112 case SPELL_EFFECT_TRIGGER_SPELL_2: //151 ritual of summon EffectTargetType[i] = SPELL_REQUIRE_DEST; @@ -120,6 +120,7 @@ SpellMgr::SpellMgr() case TARGET_UNIT_NEARBY_ALLY_UNK: case TARGET_UNIT_NEARBY_ENTRY: case TARGET_UNIT_NEARBY_RAID: + case TARGET_OBJECT_USE: SpellTargetType[i] = TARGET_TYPE_UNIT_NEARBY; break; case TARGET_UNIT_AREA_ENEMY_SRC: @@ -426,7 +427,7 @@ SpellSpecific SpellMgr::GetSpellSpecific(uint32 spellId) if (!spellInfo) return SPELL_NORMAL; - if (spellInfo->AttributesCu & SPELL_ATTR_CU_TREAT_AS_WELL_FEED) + if (spellInfo->AttributesCu & SPELL_ATTR_CU_TREAT_AS_WELL_FED) return SPELL_WELL_FED; switch (spellInfo->SpellFamilyName) @@ -705,7 +706,7 @@ bool SpellMgr::IsPositiveEffect(uint32 spellId, uint32 effIndex) case 40616: // Fel Rage 2 case 41625: // Fel Rage 3 case 46787: // Fel Rage scale - case 32375: // Mass Dispell on friendly targets + case 38318: // Orb of Blackwhelp return true; case 46392: // Focused Assault case 46393: // Brutal Assault @@ -725,9 +726,16 @@ bool SpellMgr::IsPositiveEffect(uint32 spellId, uint32 effIndex) case 30421: // Neterspite - Player buffs(3) case 30422: case 30423: + case 30457: // Complete Vulnerability case 47002: // Noxious Fumes (not sure if needed, just in case) case 41350: // Aura of Desire + case 43501: // Siphon Soul (Hexlord Spell) return false; + case 32375: + if(effIndex == 0) // Mass Dispel on friendly targets + return true; + else // Mass Dispel on enemy targets + return false; } switch (spellproto->SpellFamilyName) @@ -772,7 +780,7 @@ bool SpellMgr::IsPositiveEffect(uint32 spellId, uint32 effIndex) { case SPELL_AURA_DUMMY: { - // dummy aura can be positive or negative dependent from casted spell + // dummy aura can be positive or negative dependent from cast spell switch (spellproto->Id) { case 13139: // net-o-matic special effect @@ -837,15 +845,15 @@ bool SpellMgr::IsPositiveEffect(uint32 spellId, uint32 effIndex) case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: return false; case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also. - // part of negative spell if casted at self (prevent cancel) + // part of negative spell if cast at self (prevent cancel) if (spellproto->EffectImplicitTargetA[effIndex] == TARGET_UNIT_TARGET_ANY) return false; - // part of negative spell if casted at self (prevent cancel) + // part of negative spell if cast at self (prevent cancel) else if (spellproto->EffectImplicitTargetA[effIndex] == TARGET_UNIT_CASTER) return false; break; case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also - // part of positive spell if casted at self + // part of positive spell if cast at self if (spellproto->EffectImplicitTargetA[effIndex] != TARGET_UNIT_CASTER) return false; // but not this if this first effect (don't found batter check) @@ -1015,10 +1023,10 @@ SpellCastResult SpellMgr::GetErrorAtShapeshiftedCast (SpellEntry const *spellInf uint32 stanceMask = (form ? 1 << (form - 1) : 0); - if (stanceMask & spellInfo->StancesNot) // can explicitly not be casted in this stance + if (stanceMask & spellInfo->StancesNot) // can explicitly not be cast in this stance return SPELL_FAILED_NOT_SHAPESHIFT; - if (stanceMask & spellInfo->Stances) // can explicitly be casted in this stance + if (stanceMask & spellInfo->Stances) // can explicitly be cast in this stance return SPELL_CAST_OK; bool actAsShifted = false; @@ -2058,13 +2066,13 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell for (uint32 nextSpellId = spellInfo->Id; nextSpellId != 0; nextSpellId = GetPrevSpellInChain(nextSpellId)) { - SpellEntry const *nextSpellInfo = sSpellStore.LookupEntry(nextSpellId); - if (!nextSpellInfo) + SpellEntry const *nextSpellEntry = sSpellStore.LookupEntry(nextSpellId); + if (!nextSpellEntry) break; // if found appropriate level - if (playerLevel + 10 >= nextSpellInfo->spellLevel) - return nextSpellInfo; + if (playerLevel + 10 >= nextSpellEntry->spellLevel) + return nextSpellEntry; // one rank less then } @@ -2184,37 +2192,37 @@ void SpellMgr::LoadSpellChains() if (mSkillLineAbilityMap.lower_bound(spell_id)->second->id!=ability_id) continue; - SpellEntry const *SpellInfo=sSpellStore.LookupEntry(spell_id); - if (!SpellInfo) + SpellEntry const *SpellEntry=sSpellStore.LookupEntry(spell_id); + if (!SpellEntry) continue; - std::string sRank = SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; + std::string sRank = SpellEntry->Rank[sWorld.GetDefaultDbcLocale()]; if (sRank.empty()) continue; //exception to polymorph spells-make pig and turtle other chain than sheep - if ((SpellInfo->SpellFamilyName==SPELLFAMILY_MAGE) && (SpellInfo->SpellFamilyFlags & 0x1000000) && (SpellInfo->SpellIconID!=82)) + if ((SpellEntry->SpellFamilyName==SPELLFAMILY_MAGE) && (SpellEntry->SpellFamilyFlags & 0x1000000) && (SpellEntry->SpellIconID!=82)) continue; SpellRankEntry entry; SpellRankValue value; entry.SkillId=AbilityInfo->skillId; - entry.SpellName=SpellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; - entry.DurationIndex=SpellInfo->DurationIndex; - entry.RangeIndex=SpellInfo->rangeIndex; - entry.ProcFlags=SpellInfo->procFlags; - entry.SpellFamilyFlags=SpellInfo->SpellFamilyFlags; - entry.TargetAuraState=SpellInfo->TargetAuraState; - entry.SpellVisual=SpellInfo->SpellVisual; - entry.ManaCost=SpellInfo->manaCost; + entry.SpellName=SpellEntry->SpellName[sWorld.GetDefaultDbcLocale()]; + entry.DurationIndex=SpellEntry->DurationIndex; + entry.RangeIndex=SpellEntry->rangeIndex; + entry.ProcFlags=SpellEntry->procFlags; + entry.SpellFamilyFlags=SpellEntry->SpellFamilyFlags; + entry.TargetAuraState=SpellEntry->TargetAuraState; + entry.SpellVisual=SpellEntry->SpellVisual; + entry.ManaCost=SpellEntry->manaCost; for (;;) { AbilityInfo=mSkillLineAbilityMap.lower_bound(spell_id)->second; value.Id=spell_id; - value.Rank=SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; + value.Rank=SpellEntry->Rank[sWorld.GetDefaultDbcLocale()]; RankMap.insert(std::pair(entry,value)); spell_id=AbilityInfo->forward_spellid; - SpellInfo=sSpellStore.LookupEntry(spell_id); - if (!SpellInfo) + SpellEntry=sSpellStore.LookupEntry(spell_id); + if (!SpellEntry) break; } } @@ -2266,10 +2274,10 @@ void SpellMgr::LoadSpellChains() { for (std::multimap::iterator itr2 = RankMap.lower_bound(entry);itr2!=RankMap.upper_bound(entry);itr2++) { - SpellEntry const *SpellInfo=sSpellStore.LookupEntry(itr2->second.Id); - if (SpellInfo->spellLevelsecond.Id); + if (SpellEntry->spellLevelspellLevel; + min_spell_lvl=SpellEntry->spellLevel; min_itr=itr2; } } @@ -2357,6 +2365,48 @@ void SpellMgr::LoadSpellChains() mSpellChains[spell_id].last = 40120; mSpellChains[spell_id].rank = 2; + // Blessing of Kings + spell_id = 20217; + mSpellChains[spell_id].prev = 0; + mSpellChains[spell_id].next = 25898; + mSpellChains[spell_id].first = 20217; + mSpellChains[spell_id].last = 25898; + mSpellChains[spell_id].rank = 1; + + // Greater Blessing of Kings + spell_id = 25898; + mSpellChains[spell_id].prev = 20217; + mSpellChains[spell_id].next = 0; + mSpellChains[spell_id].first = 20217; + mSpellChains[spell_id].last = 25898; + mSpellChains[spell_id].rank = 2; + + // Greater Blessing of Sanctuary I + spell_id = 25899; + mSpellChains[spell_id].prev = 27168; // BoS V + mSpellChains[spell_id].next = 27169; // GBoS II + mSpellChains[spell_id].first = 20911; // BoS I + mSpellChains[spell_id].last = 27169; // GBoS II + mSpellChains[spell_id].rank = 6; + + // link BoS V with GBoS I + mSpellChains[27168].next = spell_id; + + // Greater Blessing of Sanctuary II + spell_id = 27169; + mSpellChains[spell_id].prev = 25899; // GBoS I + mSpellChains[spell_id].next = 0; // none + mSpellChains[spell_id].first = 20911; // BoS I + mSpellChains[spell_id].last = 27169; // GBoS II + mSpellChains[spell_id].rank = 7; + + // set GBoS II as last for all BoS ranks + mSpellChains[20911].last = spell_id; + mSpellChains[20912].last = spell_id; + mSpellChains[20913].last = spell_id; + mSpellChains[20914].last = spell_id; + mSpellChains[27168].last = spell_id; + //uncomment these two lines to print yourself list of spell_chains on startup // for (UNORDERED_MAP::iterator itr=mSpellChains.begin();itr!=mSpellChains.end();itr++) // sLog.outString("Id: %u, Rank: %d , %s",itr->first,itr->second.rank, sSpellStore.LookupEntry(itr->first)->Rank[sWorld.GetDefaultDbcLocale()]); @@ -2704,6 +2754,9 @@ void SpellMgr::LoadSpellCustomAttr() break; case SPELL_AURA_MOD_ROOT: case SPELL_AURA_MOD_DECREASE_SPEED: + // Creature daze exception + if (spellInfo->Id == 1604) + break; spellInfo->AttributesCu |= SPELL_ATTR_CU_MOVEMENT_IMPAIR; break; case SPELL_AURA_MOD_POSSESS: @@ -2730,11 +2783,13 @@ void SpellMgr::LoadSpellCustomAttr() break; case SPELL_EFFECT_CHARGE: case SPELL_EFFECT_CHARGE2: - if (!spellInfo->speed && !spellInfo->SpellFamilyName) + if (!spellInfo->speed && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR) spellInfo->speed = SPEED_CHARGE; spellInfo->AttributesCu |= SPELL_ATTR_CU_CHARGE; break; case SPELL_EFFECT_TRIGGER_SPELL: + if (spellInfo->Id == 39897) // Mass Dispel should not have effect_trigger_missile? to be verified now + break; if (IsPositionTarget(spellInfo->EffectImplicitTargetA[j]) || spellInfo->Targets & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) spellInfo->Effect[j] = SPELL_EFFECT_TRIGGER_MISSILE; @@ -2752,7 +2807,7 @@ void SpellMgr::LoadSpellCustomAttr() if (spellInfo->SpellVisual == 3879) spellInfo->AttributesCu |= SPELL_ATTR_CU_CONE_BACK; - if (spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && spellInfo->SpellFamilyFlags & 0x1000LL && spellInfo->SpellIconID == 494) + if ((spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && spellInfo->SpellFamilyFlags & 0x1000LL && spellInfo->SpellIconID == 494) || spellInfo->Id == 33745 /* Lacerate */) spellInfo->AttributesCu |= SPELL_ATTR_CU_IGNORE_ARMOR; // Modify SchoolMask to allow them critically heal @@ -2764,7 +2819,7 @@ void SpellMgr::LoadSpellCustomAttr() if (spellInfo->Effect[0] == SPELL_EFFECT_STUCK) { if (IsChanneledSpell(spellInfo)) - spellInfo->ChannelInterruptFlags &= ~CHANNEL_FLAG_MOVEMENT; + spellInfo->ChannelInterruptFlags &= ~CHANNEL_INTERRUPT_FLAG_MOVEMENT; else spellInfo->InterruptFlags &= ~SPELL_INTERRUPT_FLAG_MOVEMENT; } @@ -2780,15 +2835,30 @@ void SpellMgr::LoadSpellCustomAttr() { case SPELLFAMILY_GENERIC: { + if (spellInfo->Id == 52009) + spellInfo->EffectMiscValue[0] = 20865; // Goblin Rocket Launcher - if (spellInfo->SpellIconID == 184 && spellInfo->Attributes == 4259840) + else if (spellInfo->SpellIconID == 184 && spellInfo->Attributes == 4259840) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; - // Siphon Essence - else if (spellInfo->AttributesEx == 268435456 && spellInfo->SpellIconID == 2027) - spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; - + else if (spellInfo->Id == 15852) + spellInfo->Dispel = DISPEL_NONE; + else if (spellInfo->Id == 46337) // Crab disguise + spellInfo->AuraInterruptFlags |= AURA_INTERRUPT_FLAG_CAST; + else if (spellInfo->SpellIconID == 2367) // remove flag from steam tonk & crashin trashin racers + spellInfo->AttributesEx4 &= ~SPELL_ATTR_EX4_FORCE_TRIGGERED; + else if (spellInfo->Id == 34171 || spellInfo->Id == 37956) // underbat tentacle lash + spellInfo->AttributesEx2 |= SPELL_ATTR_EX2_FROM_BEHIND; break; } + case SPELLFAMILY_SHAMAN: + { + // Flametongue weapon proc + /*if (spellInfo->SpellFamilyFlags & 2097152 && spellInfo->SpellVisual == 0) + spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF;*/ // Flametongue totem proc procs spell 16368 + if (spellInfo->Id == 16368) + spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; + break; + } case SPELLFAMILY_PALADIN: { // Judgement & seal of Light @@ -2804,7 +2874,8 @@ void SpellMgr::LoadSpellCustomAttr() // Devotion Aura else if (spellInfo->SpellFamilyFlags & 0x40 && spellInfo->SpellIconID == 291) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SCROLL_STACK; - + else if (spellInfo->Id == 25997) // Eye for an eye + spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; break; } case SPELLFAMILY_PRIEST: @@ -2812,7 +2883,9 @@ void SpellMgr::LoadSpellCustomAttr() // Mana Burn if (spellInfo->SpellFamilyFlags & 0x10LL && spellInfo->SpellIconID == 212) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; - + // Health Link T5 Hunter/Warlock bonus + else if (spellInfo->Id == 37382) + spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; // Reflective Shield else if (!spellInfo->SpellFamilyFlags && spellInfo->SpellIconID == 566) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; @@ -2826,7 +2899,20 @@ void SpellMgr::LoadSpellCustomAttr() // Power Word: Fortitude/Prayer of Fortitude else if (spellInfo->SpellFamilyFlags & 0x08 && spellInfo->SpellVisual == 278) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SCROLL_STACK; - + // surge of light + else if (spellInfo->Id == 33151) + spellInfo->EffectApplyAuraName[2] = SPELLMOD_FLAT; + // mass dispel simplification - combine 3 spells limiting triggering + else if (spellInfo->Id == 32375) + { + spellInfo->Effect[1] = SPELL_EFFECT_DISPEL; + spellInfo->EffectRadiusIndex[1] = 18; + spellInfo->EffectMiscValue[1] = 1; + spellInfo->Effect[2] = SPELL_EFFECT_TRIGGER_SPELL; + spellInfo->EffectImplicitTargetA[2] = TARGET_UNIT_AREA_ENEMY_DST; + spellInfo->EffectRadiusIndex[2] = 13; + spellInfo->EffectTriggerSpell[2] = 39897; + } break; } case SPELLFAMILY_MAGE: @@ -2861,37 +2947,38 @@ void SpellMgr::LoadSpellCustomAttr() switch (i) { /* FIXED DAMAGE SPELLS */ - // Ignite - case 12654: + case 12654: // Ignite spellInfo->AttributesCu |= SPELL_ATTR_CU_FIXED_DAMAGE; break; + case 20532: // Intense Heat (Majordomo Executus lava pit) + spellInfo->AttributesEx2 |= SPELL_ATTR_EX2_CANT_CRIT; + // no break here /* NO SPELL DMG COEFF */ - // Enduring Light - T6 proc - case 40471: - // Judgement of Blood - case 32221: - case 32220: - // Flame Cap, Scalding Water, Fiery Blaze - case 28715: - case 37284: - case 6297: - // Deathfrost - case 46579: - // Mana Tap - case 28734: - // SW: Death - case 32409: + case 16614: // Storm Gauntlets + case 7714: // Fiery Plate Gauntlets + case 40471: // Enduring Light - T6 proc + case 40472: // Enduring Judgement - T6 proc + case 32221: // Seal of Blood + case 32220: // Judgement of Blood + case 28715: // Flame Cap + case 37284: // Scalding Water + case 6297: // Fiery Blaze + case 46579: // Deathfrost + case 28734: // Mana Tap + case 32409: // SW: Death + // Six Demon Bag spells - case 45297: // Chain Lightning - case 2310: // Frostbolt! - case 9487: // Fireball ! - // Shattered Sun Pendant of Acumen: Scryers ex proc - case 45429: - // Heart of Wyrmthalak: Flame Lash proc - case 27655: - case 45055: - // Arcane Torrent - case 28733: + case 45297: // Chain Lightning + case 23102: // Frostbolt + case 9487: // Fireball + + case 45429: // Shattered Sun Pendant of Acumen: Scryers ex proc + case 27655: // Heart of Wyrmthalak: Flame Lash proc + case 45055: // Shadow Bolt (Timbal's Focusing Crystal) + case 37661: // The Lightning Capacitor, lightning bolt spell + case 28733: // Arcane Torrent + case 43731: // Lightning Zap on critters (Stormchops) + case 43733: // Lightning Zap on others (Stormchops) spellInfo->AttributesCu |= SPELL_ATTR_CU_NO_SPELL_DMG_COEFF; break; /* WELL FEED */ @@ -2911,11 +2998,13 @@ void SpellMgr::LoadSpellCustomAttr() case 18193: case 18125: case 18192: - case 23697: case 18141: case 18194: case 18222: - spellInfo->AttributesCu |= SPELL_ATTR_CU_TREAT_AS_WELL_FEED; + case 22730: + case 23697: + case 25661: // Dirge's Kickin' Chimaerok Chops + spellInfo->AttributesCu |= SPELL_ATTR_CU_TREAT_AS_WELL_FED; break; /* Scrolls - no stack */ case 8112: // Spirit I @@ -2956,6 +3045,14 @@ void SpellMgr::LoadSpellCustomAttr() spellInfo->EffectImplicitTargetA[0] = spellInfo->EffectImplicitTargetA[1] = TARGET_UNIT_CASTER; spellInfo->EffectImplicitTargetB[0] = spellInfo->EffectImplicitTargetB[1] = 0; break; + /* WARLOCK CUSTOM ATTRIBUTES */ + case 27285: // Seed of Corruption - final boom damage + spellInfo->AttributesEx3 |= SPELL_ATTR_EX3_CANT_TRIGGER_PROC; + break; + /* HUNTER CUSTOM ATTRIBUTES */ + case 1543: // Flare no longer produces combat + spellInfo->AttributesEx3 |= SPELL_ATTR_EX3_NO_INITIAL_AGGRO; + break; // Triggered spells that should be delayed case 20272: // Illumination case 32848: // Mana Restore @@ -2993,11 +3090,33 @@ void SpellMgr::LoadSpellCustomAttr() spellInfo->EffectBasePoints[1] = 2; break; /****************/ - // Leggins of BeastMastery - case 38297: + case 40447: // BT: Akama - Soul Channel + spellInfo->Effect[0] = 0; + break; + case 29538: + spellInfo->EffectApplyAuraName[0] = 0; + break; + case 24311: // Powerful Healing Ward + spellInfo->CastingTimeIndex = 14; + break; + case 24178: // Will of Hakkar + spellInfo->AttributesEx |= SPELL_ATTR_EX_CHANNELED_1; + break; + case 28282: // Ashbringer + spellInfo->Effect[2] = SPELL_EFFECT_APPLY_AURA; + spellInfo->EffectImplicitTargetA[2] = TARGET_UNIT_CASTER; + spellInfo->EffectApplyAuraName[2] = SPELL_AURA_FORCE_REACTION; + spellInfo->EffectMiscValue[2] = 56; // Scarlet Crusade + spellInfo->EffectBasePoints[2] = 4; // Friendly + break; + case 38297: // Leggins of BeastMastery spellInfo->Effect[0] = 0; spellInfo->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; break; + case 41350: + case 41337: + spellInfo->Attributes |= SPELL_ATTR_CANT_CANCEL; + break; // do NOT remove encapsulate on druid shapeshift, attribute is added higher, so is safe to remove it here case 45665: spellInfo->AttributesCu &= ~SPELL_ATTR_CU_MOVEMENT_IMPAIR; @@ -3051,6 +3170,9 @@ void SpellMgr::LoadSpellCustomAttr() case 43268: spellInfo->MaxAffectedTargets = 2; break; + case 45150: + spellInfo->AttributesEx2 |= SPELL_ATTR_EX2_IGNORE_LOS; + break; } break; case 44978: @@ -3084,8 +3206,6 @@ void SpellMgr::LoadSpellCustomAttr() case 41376: // Spite case 29576: // Multi-Shot case 37790: // Spread Shot - case 46771: // Flame Sear - case 45248: // Shadow Blades case 41303: // Soul Drain case 31298: // Anetheron: Sleep case 30004: // Aran: Flame Wreath @@ -3109,6 +3229,7 @@ void SpellMgr::LoadSpellCustomAttr() case 37676: // Insidious Whisper case 46008: // Negative Energy case 45641: // Fire Bloom + case 46771: // Flame Sear spellInfo->MaxAffectedTargets = 5; break; case 40827: // Sinful Beam @@ -3124,10 +3245,6 @@ void SpellMgr::LoadSpellCustomAttr() case 12494: // Frostbite spellInfo->Attributes |= SPELL_ATTR_BREAKABLE_BY_DAMAGE; break; - case 38794: case 33711: // Murmur's Touch - spellInfo->MaxAffectedTargets = 1; - spellInfo->EffectTriggerSpell[0] = 33760; - break; case 32727: // Arena Preparation - remove invisibility aura case 44949: // Whirlwind's offhand attack - TODO: remove this (50% weapon damage effect) spellInfo->Effect[1] = 0; @@ -3207,11 +3324,20 @@ void SpellMgr::LoadSpellCustomAttr() break; case 37363: // set 5y radius instead of 25y spellInfo->EffectRadiusIndex[0] = 8; - spellInfo->EffectRadiusIndex[0] = 8; + spellInfo->EffectRadiusIndex[1] = 8; + spellInfo->EffectMiscValue[1] = 50; break; case 42835: // set visual only spellInfo->Effect[0] = 0; break; + case 46037: + case 46040: + spellInfo->EffectBasePoints[1] = 1; + case 46038: + case 46039: + spellInfo->AttributesEx2 |= SPELL_ATTR_EX2_IGNORE_LOS; + break; + case 21358: // Aqual Quintessence / Eternal Quintessence case 47977: // Broom Broom case 42679: case 42673: @@ -3226,6 +3352,7 @@ void SpellMgr::LoadSpellCustomAttr() spellInfo->EffectTriggerSpell[1] = 43731; spellInfo->EffectImplicitTargetA[1] = 1; spellInfo->EffectImplicitTargetB[1] = 0; + spellInfo->AttributesCu |= SPELL_ATTR_CU_TREAT_AS_WELL_FED; break; case 41470: //Judgement of Command should be reflectable spellInfo->AttributesEx2 = 0; @@ -3281,13 +3408,14 @@ void SpellMgr::LoadSpellCustomAttr() spellInfo->EffectImplicitTargetA[1] = 1; break; case 37370: // Kelidan the breaker - vortex - spellInfo->EffectMiscValue[0] /= 2; + spellInfo->EffectMiscValue[0] /= 3; break; case 41345: // Infatuation (BT Trash) spellInfo->AttributesEx2 &= ~SPELL_ATTR_EX2_IGNORE_LOS; break; case 43383: // Spirit Bolts (HexLord) - spellInfo->ChannelInterruptFlags |= CHANNEL_FLAG_MOVEMENT; + spellInfo->ChannelInterruptFlags |= CHANNEL_INTERRUPT_FLAG_MOVEMENT; + spellInfo->InterruptFlags &= ~SPELL_INTERRUPT_FLAG_INTERRUPT; break; case 29962: // Summon Elemental (Shade of Aran) case 37053: @@ -3332,12 +3460,68 @@ void SpellMgr::LoadSpellCustomAttr() break; case 31790: // Righteous Defense taunt spellInfo->DmgClass = SPELL_DAMAGE_CLASS_MELEE; + spellInfo->Attributes |= SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK; + break; + case 28509: // Greater Mana Regeneration - Elixir of Major Mageblood + case 24363: // Mana Regeneration - Mageblood Potion + case 31462: // Moonwell Restoration + case 36746: // Shadowy Fortitude + case 36749: // Arcane Might + case 42965: // Tricky Treat + spellInfo->Attributes = 0x28000000LL; // Remove when entering arena - Originally has flag 0x28000100LL but the attribute 0x100 makes them non-removable on arena. + // Not known for sure, but logically these spells should be removed. How that was on blizz? Don't know for sure, but i think everyone would use that if so. (or maybe it wasn't used cause it's pretty expensive) + // Anyway on free-realms it's abused - so remove it on arena. + break; + case 20271: // Paladins Judgement + spellInfo->AttributesEx3 &= ~SPELL_ATTR_EX3_CANT_TRIGGER_PROC; + break; + case 30502: // Dark Spin + spellInfo->Effect[0] = 0; + spellInfo->Effect[1] = 0; + spellInfo->Effect[2] = 0; + break; + case 38629: // Poison Keg + spellInfo->RecoveryTime = 1080; + break; + case 25678: + spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_TARGET_ANY; + break; + case 40129: // Summon Air Elemental (by quest [The Soul Cannon of Reth'hedron], fix cast freeze - fix quest) + spellInfo->AttributesEx &= ~SPELL_ATTR_EX_CHANNELED_1; + break; + case 6495: // Sentry totem + spellInfo->EffectRadiusIndex[0] = 0; + break; + case 33666: ///sonic boom. the radius is less than 34 yards, because the tank and melee also can avoid it. + case 38795: + spellInfo->EffectRadiusIndex[0] = 9; + spellInfo->EffectRadiusIndex[1] = 9; + spellInfo->EffectRadiusIndex[2] = 9; + break; + case 33711: // Murmur's Touch + spellInfo->MaxAffectedTargets = 1; + spellInfo->EffectTriggerSpell[0] = 33760; + break; + case 38794: + spellInfo->Effect[1] = 0; + spellInfo->MaxAffectedTargets = 1; + spellInfo->EffectTriggerSpell[0] = 33760; + break; + case 36717: //energy discharge + spellInfo->MaxAffectedTargets = 1; + spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_NEARBY_ENEMY; + break; + case 38829: // energy discharge hc + spellInfo->MaxAffectedTargets = 1; + break; + case 29838: //Second Wind (Rank 2) + spellInfo->procFlags &= ~PROC_FLAG_ON_TAKE_PERIODIC; break; default: break; } } - CreatureAI::FillAISpellInfo(); + CreatureAI::FillAISpellEntry(); } // TODO: move this to database along with slot position in cast bar @@ -3356,6 +3540,7 @@ void SpellMgr::LoadCustomSpellCooldowns(SpellEntry* spellInfo) break; // 6 sec cooldown case 44639: // Frost Arrow + case 46082: // Shadow Bolt Volley spellInfo->RecoveryTime = 6000; break; // 8 sec cooldown @@ -3411,6 +3596,10 @@ void SpellMgr::LoadCustomSpellCooldowns(SpellEntry* spellInfo) case 16054: // Flames of the Black Flight spellInfo->RecoveryTime = 10800000; break; + case 44935: //Expose Razorthorn Root + case 29992: //Quest spell - needs cooldown to be able to add to possessed unit + spellInfo->RecoveryTime = 1080; + break; default: break; } @@ -3567,8 +3756,10 @@ bool SpellMgr::IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_i { // hack moved from Player::UpdateAreaDependentAuras <--- is still needed ? Oo i don't think so ... if (spellInfo->Id == 38157) + { if (area_id == 3522 || area_id == 3785) return true; + } // normal case if (spellInfo->AreaId && spellInfo->AreaId != zone_id && spellInfo->AreaId != area_id) @@ -3621,6 +3812,19 @@ bool SpellMgr::IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_i return false; } + case 48025: // Headless Horseman's Mount + case 42684: // Swift Magic Broom + case 42683: + { + MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); + if (!mapEntry) + return false; + + if (!mapEntry->IsMountAllowed()) + return false; + + return true; + } case 23333: // Warsong Flag case 23335: // Silverwing Flag case 46392: // Focused Assault @@ -3692,7 +3896,7 @@ bool SpellMgr::IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_i } case 40216: // Dragonmaw Illusion case 42016: // Dragonmaw Illusion - return area_id == 3759 || area_id == 3966 || area_id == 3939 || area_id == 3965; + return area_id == 3759 || area_id == 3966 || area_id == 3939 || area_id == 3965 || area_id == 3967; case 2584: // Waiting to Resurrect case 22011: // Spirit Heal Channel case 22012: // Spirit Heal @@ -3926,17 +4130,17 @@ bool SpellMgr::IsDispelSpell( SpellEntry const *spellInfo ) bool SpellMgr::isSpellBreakStealth( SpellEntry const* spellInfo ) { - return !(spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH); + return spellInfo && !(spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH); } bool SpellMgr::IsChanneledSpell( SpellEntry const* spellInfo ) { - return (spellInfo->AttributesEx & (SPELL_ATTR_EX_CHANNELED_1 | SPELL_ATTR_EX_CHANNELED_2)); + return spellInfo && spellInfo->AttributesEx & (SPELL_ATTR_EX_CHANNELED_1 | SPELL_ATTR_EX_CHANNELED_2); } bool SpellMgr::NeedsComboPoints( SpellEntry const* spellInfo ) { - return (spellInfo->AttributesEx & (SPELL_ATTR_EX_REQ_COMBO_POINTS1 | SPELL_ATTR_EX_REQ_COMBO_POINTS2)); + return spellInfo && spellInfo->AttributesEx & (SPELL_ATTR_EX_REQ_COMBO_POINTS1 | SPELL_ATTR_EX_REQ_COMBO_POINTS2); } SpellSchoolMask SpellMgr::GetSpellSchoolMask( SpellEntry const* spellInfo ) @@ -4253,3 +4457,18 @@ bool SpellMgr::IsPositionTarget(uint32 target) } return false; } + +bool SpellMgr::IsTauntSpell(SpellEntry const* spellInfo) +{ + if (!spellInfo) + return false; + + for (uint8 i = 0; i < 3; ++i) + { + if (spellInfo->Effect[i] == SPELL_EFFECT_ATTACK_ME) + return true; + else if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_TAUNT) + return true; + } + return false; +} diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 0cf332e62..e06542a6b 100755 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _SPELLMGR_H -#define _SPELLMGR_H +#ifndef HELLGROUND_SPELLMGR_H +#define HELLGROUND_SPELLMGR_H // For static or at-server-startup loaded spell data // For more high level function for sSpellStore data @@ -162,11 +162,11 @@ enum ProcFlags PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT = 0x00000100, // 08 Successful Ranged attack by Spell that use ranged weapon PROC_FLAG_TAKEN_RANGED_SPELL_HIT = 0x00000200, // 09 Taken damage by Spell that use ranged weapon - PROC_FLAG_SUCCESSFUL_POSITIVE_AOE_HIT = 0x00000400, // 10 Successful AoE (not 100% shure unused) - PROC_FLAG_TAKEN_POSITIVE_AOE = 0x00000800, // 11 Taken AoE (not 100% shure unused) + PROC_FLAG_SUCCESSFUL_POSITIVE_AOE_HIT = 0x00000400, // 10 Successful AoE (unused) + PROC_FLAG_TAKEN_POSITIVE_AOE = 0x00000800, // 11 Taken AoE (unused) - PROC_FLAG_SUCCESSFUL_AOE_SPELL_HIT = 0x00001000, // 12 Successful AoE damage spell hit (not 100% shure unused) - PROC_FLAG_TAKEN_AOE_SPELL_HIT = 0x00002000, // 13 Taken AoE damage spell hit (not 100% shure unused) + PROC_FLAG_SUCCESSFUL_AOE_SPELL_HIT = 0x00001000, // 12 Successful AoE damage spell hit (unused) + PROC_FLAG_TAKEN_AOE_SPELL_HIT = 0x00002000, // 13 Taken AoE damage spell hit (unused) PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL = 0x00004000, // 14 Successful cast positive spell (by default only on healing) PROC_FLAG_TAKEN_POSITIVE_SPELL = 0x00008000, // 15 Taken positive spell hit (by default only on healing) @@ -411,7 +411,7 @@ enum AttributesCu SPELL_ATTR_CU_FAKE_DELAY = 0x00010000, SPELL_ATTR_CU_FIXED_DAMAGE = 0x00020000, // ignore all %dmg done, %dmg taken auras SPELL_ATTR_CU_NO_SPELL_DMG_COEFF = 0x00040000, // to those spells won't be applied and bonuses from spell dmg - SPELL_ATTR_CU_TREAT_AS_WELL_FEED = 0x00080000, + SPELL_ATTR_CU_TREAT_AS_WELL_FED = 0x00080000, SPELL_ATTR_CU_NO_SCROLL_STACK = 0x00100000 // for spells which can't stack with scrolls (must be also applied to scroll spells) }; @@ -738,6 +738,7 @@ class HELLGROUND_IMPORT_EXPORT SpellMgr static bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group); static DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group); + static bool IsTauntSpell(SpellEntry const* spellInfo); static bool IsBinaryResistable(SpellEntry const* spellInfo); static bool IsPartialyResistable(SpellEntry const* spellInfo); static bool SpellIgnoreLOS(SpellEntry const* spellInfo, uint8 effIdx); diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index b84cc7a42..468c78907 100755 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -296,12 +296,12 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) switch (m_form) { case FORM_CAT: - val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break; + val2 = getLevel()*mLevelMult + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break; case FORM_BEAR: case FORM_DIREBEAR: - val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + val2 = getLevel()*mLevelMult + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; case FORM_MOONKIN: - val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + val2 = getLevel()*mLevelMult + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; default: val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; } diff --git a/src/game/StateMgr.cpp b/src/game/StateMgr.cpp index b98b706b8..188a07ef3 100644 --- a/src/game/StateMgr.cpp +++ b/src/game/StateMgr.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2012 /dev/rsa for MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* StateMgr based on idea and part of code from SilverIce (http:://github.com/SilverIce */ @@ -81,17 +82,20 @@ class StunnedState : public IdleMovementGenerator if (target->GetTypeId() == TYPEID_PLAYER) target->SetStandState(UNIT_STAND_STATE_STAND); - target->SendMeleeAttackStop(NULL); + target->SendMeleeAttackStop(0); WorldPacket data(SMSG_FORCE_MOVE_ROOT, target->GetPackGUID().size() + 4); data << target->GetPackGUID(); data << uint32(0); target->BroadcastPacket(&data, true); + + //target->SetFacingTo(target->GetOrientation()); } bool Update(Unit &unit, const uint32 &) { unit.SetSelection(0); + //unit.SetFacingToObject(&unit); return true; } @@ -143,7 +147,7 @@ class RootState : public IdleMovementGenerator target->m_movementInfo.RemoveMovementFlag(MOVEFLAG_MOVING); target->m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); - target->SendMeleeAttackStop(NULL); + target->SendMeleeAttackStop(0); if (target->GetTypeId() == TYPEID_PLAYER) { @@ -187,6 +191,9 @@ class RootState : public IdleMovementGenerator target->SetSelection(target->getVictimGUID()); + if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->hasIgnoreVictimSelection()) + target->SetSelection(0); + target->AddEvent(new AttackResumeEvent(*target), ATTACK_DISPLAY_DELAY); } }; @@ -215,7 +222,7 @@ class FeignDeathState : public IdleMovementGenerator target->InterruptNonMeleeSpells(true); target->CombatStop(); - target->getHostilRefManager().deleteReferences(); + target->getHostileRefManager().deleteReferences(); target->addUnitState(UNIT_STAT_DIED); //target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); @@ -270,7 +277,7 @@ class TaxiState : public FlightPathMovementGenerator m_previewDisplayId = u.GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); u.Mount(m_displayId); } - u.getHostilRefManager().setOnlineOfflineState(false); + u.getHostileRefManager().setOnlineOfflineState(false); u.addUnitState(UNIT_STAT_TAXI_FLIGHT); u.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); _Initialize(u); @@ -283,7 +290,7 @@ class TaxiState : public FlightPathMovementGenerator u.Unmount(); u.clearUnitState(UNIT_STAT_TAXI_FLIGHT); u.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - u.getHostilRefManager().setOnlineOfflineState(true); + u.getHostileRefManager().setOnlineOfflineState(true); if(u.pvpInfo.inHostileArea) u.CastSpell(&u, 2479, true); diff --git a/src/game/StateMgr.h b/src/game/StateMgr.h index cee1ac358..776e92ba7 100644 --- a/src/game/StateMgr.h +++ b/src/game/StateMgr.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2012 /dev/rsa for MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,17 +9,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* StateMgr based on idea and part of code from SilverIce (http:://github.com/SilverIce */ -#ifndef _STATEMGR_H -#define _STATEMGR_H +#ifndef HELLGROUND_STATEMGR_H +#define HELLGROUND_STATEMGR_H #include "LockedVector.h" #include "Common.h" diff --git a/src/game/StateMgrImpl.h b/src/game/StateMgrImpl.h index 98fffe460..05bfa7daa 100644 --- a/src/game/StateMgrImpl.h +++ b/src/game/StateMgrImpl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _STATEMGRIMPL_H -#define _STATEMGRIMPL_H +#ifndef HELLGROUND_STATEMGRIMPL_H +#define HELLGROUND_STATEMGRIMPL_H #include "Common.h" #pragma once diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 46d295de1..ca65e7b41 100755 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2012 TrinityCore * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2012 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ByteBuffer.h" @@ -75,7 +77,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) } // to at _offset distance from target and _angle from target facing - _target->GetClosePoint(x, y, z, owner.GetObjectSize(), _offset, _angle); + _target->GetNearPoint(x, y, z, owner.GetObjectSize(), _offset, _angle); } if (!_path) @@ -83,8 +85,8 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) // allow pets following their master to cheat while generating paths bool forceDest = (owner.GetObjectGuid().IsPet() && owner.hasUnitState(UNIT_STAT_FOLLOW)); - _path->calculate(x, y, z, forceDest); - if (_path->getPathType() & PATHFIND_NOPATH) + bool result = _path->calculate(x, y, z, forceDest); + if (!result || _path->getPathType() & PATHFIND_NOPATH) return; _targetReached = false; @@ -192,6 +194,10 @@ bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_ template void ChaseMovementGenerator::_reachTarget(T &owner) { + if (Creature *creature = owner.ToCreature()) + if (creature->IsAIEnabled) + creature->AI()->MovementInform(CHASE_MOTION_TYPE, 2); + if (owner.IsWithinMeleeRange(this->_target.getTarget())) owner.Attack(this->_target.getTarget(),true); } @@ -211,6 +217,9 @@ void ChaseMovementGenerator::Initialize(Creature &owner) owner.SetWalk(false); owner.addUnitState(UNIT_STAT_CHASE); _setTargetLocation(owner); + + if (owner.IsAIEnabled) + owner.AI()->MovementInform(CHASE_MOTION_TYPE, 1); } template @@ -220,6 +229,9 @@ void ChaseMovementGenerator::Finalize(T &owner) if (Creature* creature = owner.ToCreature()) { + if (creature->IsAIEnabled) + creature->AI()->MovementInform(CHASE_MOTION_TYPE, 0); + if (creature->isPet()) return; diff --git a/src/game/TargetedMovementGenerator.h b/src/game/TargetedMovementGenerator.h index 483268aaf..12fe93ae9 100755 --- a/src/game/TargetedMovementGenerator.h +++ b/src/game/TargetedMovementGenerator.h @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2012 TrinityCore * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2012 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef HELLGROUND_TARGETEDMOVEMENTGENERATOR_H diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index 8a7a7c900..94030564b 100755 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index b27313284..3ee6d34a9 100755 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -160,7 +160,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff) Creature::Update(update_diff, diff); } -void TemporarySummon::Summon(TempSummonType type, uint32 lifetime) +void TemporarySummon::Summon(TemporarySummonType type, uint32 lifetime) { m_type = type; m_timer = lifetime; diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index f8ec4d944..cadb957de 100755 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_TEMPSUMMON_H -#define TRINITYCORE_TEMPSUMMON_H +#ifndef HELLGROUND_TEMPSUMMON_H +#define HELLGROUND_TEMPSUMMON_H #include "Creature.h" #include "ObjectAccessor.h" @@ -34,12 +34,12 @@ class TemporarySummon : public Creature Creature::RemoveFromWorld(); } void Update(uint32 update_diff, uint32 time); - void Summon(TempSummonType type, uint32 lifetime); + void Summon(TemporarySummonType type, uint32 lifetime); void UnSummon(); void SaveToDB(); Unit* GetSummoner() const { return m_summoner ? GetMap()->GetUnit(m_summoner) : NULL; } private: - TempSummonType m_type; + TemporarySummonType m_type; uint32 m_timer; uint32 m_lifetime; uint64 m_summoner; diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 32018b544..393349cdf 100755 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,10 +50,10 @@ float ThreatCalcHelper::calcThreat(Unit* pHatedUnit, Unit* pHatingUnit, float pT } //============================================================ -//================= HostilReference ========================== +//================= HostileReference ========================= //============================================================ -HostilReference::HostilReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat) +HostileReference::HostileReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat) { iThreat = pThreat; iTempThreatModifyer = 0.0f; @@ -65,14 +65,14 @@ HostilReference::HostilReference(Unit* pUnit, ThreatManager *pThreatManager, flo //============================================================ // Tell our refTo (target) object that we have a link -void HostilReference::targetObjectBuildLink() +void HostileReference::targetObjectBuildLink() { getTarget()->addHatedBy(this); } //============================================================ // Tell our refTo (taget) object, that the link is cut -void HostilReference::targetObjectDestroyLink() +void HostileReference::targetObjectDestroyLink() { getTarget()->removeHatedBy(this); } @@ -80,7 +80,7 @@ void HostilReference::targetObjectDestroyLink() //============================================================ // Tell our refFrom (source) object, that the link is cut (Target destroyed) -void HostilReference::sourceObjectDestroyLink() +void HostileReference::sourceObjectDestroyLink() { setOnlineOfflineState(false); } @@ -88,7 +88,7 @@ void HostilReference::sourceObjectDestroyLink() //============================================================ // Inform the source, that the status of the reference changed -void HostilReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent) +void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent) { if (getSource()) getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); @@ -96,7 +96,7 @@ void HostilReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefSt //============================================================ -void HostilReference::addThreat(float pMod) +void HostileReference::addThreat(float pMod) { iThreat += pMod; // the threat is changed. Source and target unit have to be availabe @@ -121,7 +121,7 @@ void HostilReference::addThreat(float pMod) //============================================================ // check, if source can reach target and set the status -void HostilReference::updateOnlineStatus() +void HostileReference::updateOnlineStatus() { bool online = false; bool accessible = false; @@ -158,7 +158,7 @@ void HostilReference::updateOnlineStatus() //============================================================ // set the status and fire the event on status change -void HostilReference::setOnlineOfflineState(bool pIsOnline) +void HostileReference::setOnlineOfflineState(bool pIsOnline) { if (iOnline != pIsOnline) { @@ -173,7 +173,7 @@ void HostilReference::setOnlineOfflineState(bool pIsOnline) //============================================================ -void HostilReference::setAccessibleState(bool pIsAccessible) +void HostileReference::setAccessibleState(bool pIsAccessible) { if (iAccessible != pIsAccessible) { @@ -188,7 +188,7 @@ void HostilReference::setAccessibleState(bool pIsAccessible) // prepare the reference for deleting // this is called be the target -void HostilReference::removeReference() +void HostileReference::removeReference() { invalidate(); @@ -198,7 +198,7 @@ void HostilReference::removeReference() //============================================================ -Unit* HostilReference::getSourceUnit() +Unit* HostileReference::getSourceUnit() { return (getSource()->getOwner()); } @@ -209,7 +209,7 @@ Unit* HostilReference::getSourceUnit() void ThreatContainer::clearReferences() { - for (std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); delete (*i); @@ -218,12 +218,15 @@ void ThreatContainer::clearReferences() } //============================================================ -// Return the HostilReference of NULL, if not found -HostilReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) +// Return the HostileReference of NULL, if not found +HostileReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) { - HostilReference* result = NULL; + HostileReference* result = NULL; + if (!pVictim) + return NULL; + uint64 guid = pVictim->GetGUID(); - for (std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { if ((*i)->getUnitGuid() == guid) { @@ -238,9 +241,9 @@ HostilReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) //============================================================ // Add the threat, if we find the reference -HostilReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) +HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) { - HostilReference* ref = getReferenceByTarget(pVictim); + HostileReference* ref = getReferenceByTarget(pVictim); if (ref) ref->addThreat(pThreat); return ref; @@ -250,7 +253,7 @@ HostilReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent) { - if (HostilReference* ref = getReferenceByTarget(pVictim)) + if (HostileReference* ref = getReferenceByTarget(pVictim)) { if (pPercent < -100) { @@ -264,7 +267,7 @@ void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent) //============================================================ -bool HostilReferenceSortPredicate(const HostilReference* lhs, const HostilReference* rhs) +bool HostileReferenceSortPredicate(const HostileReference* lhs, const HostileReference* rhs) { // std::list::sort ordering predicate must be: (Pred(x,y)&&Pred(y,x))==false return lhs->getThreat() > rhs->getThreat(); // reverse sorting @@ -277,7 +280,7 @@ void ThreatContainer::update() { if (iDirty && iThreatList.size() >1) { - iThreatList.sort(HostilReferenceSortPredicate); + iThreatList.sort(HostileReferenceSortPredicate); } iDirty = false; } @@ -291,14 +294,14 @@ bool DropAggro(Creature* pAttacker, Unit * target) if (target->IsImmunedToDamage(pAttacker->GetMeleeDamageSchoolMask(), false)) return true; - // if target is immune to actually casted spell - i think it's not good check because we don't switch spell target to proper one - if (pAttacker->IsNonMeleeSpellCasted(false)) + // if target is immune to actually cast spell - i think it's not good check because we don't switch spell target to proper one + if (pAttacker->IsNonMeleeSpellCast(false)) { SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NONE; if (Spell* pSpell = pAttacker->m_currentSpells[CURRENT_GENERIC_SPELL]) - schoolMask = SpellSchoolMask(pSpell->GetSpellInfo()->SchoolMask); + schoolMask = SpellSchoolMask(pSpell->GetSpellEntry()->SchoolMask); else if (Spell* pSpell = pAttacker->m_currentSpells[CURRENT_CHANNELED_SPELL]) - schoolMask = SpellSchoolMask(pSpell->GetSpellInfo()->SchoolMask); + schoolMask = SpellSchoolMask(pSpell->GetSpellEntry()->SchoolMask); if (target->IsImmunedToDamage(schoolMask, false)) return true; @@ -343,16 +346,16 @@ bool DropAggro(Creature* pAttacker, Unit * target) // return the next best victim // could be the current victim -HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilReference* pCurrentVictim) +HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostileReference* pCurrentVictim) { - HostilReference* currentRef = NULL; + HostileReference* currentRef = NULL; bool found = false; bool noPriorityTargetFound = false; - std::list::iterator lastRef = iThreatList.end(); + std::list::iterator lastRef = iThreatList.end(); lastRef--; - for (std::list::iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) + for (std::list::iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) { currentRef = (*iter); @@ -469,7 +472,7 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, SpellSchoolMask scho void ThreatManager::_addThreat(Unit *pVictim, float threat) { - HostilReference* ref = iThreatContainer.addThreat(pVictim, threat); + HostileReference* ref = iThreatContainer.addThreat(pVictim, threat); // Ref is not in the online refs, search the offline refs next if (!ref) ref = iThreatOfflineContainer.addThreat(pVictim, threat); @@ -477,11 +480,11 @@ void ThreatManager::_addThreat(Unit *pVictim, float threat) if (!ref) // there was no ref => create a new one { // threat has to be 0 here - HostilReference* hostilReference = new HostilReference(pVictim, this, 0); - iThreatContainer.addReference(hostilReference); - hostilReference->addThreat(threat); // now we add the real threat + HostileReference* hostileRef = new HostileReference(pVictim, this, 0); + iThreatContainer.addReference(hostileRef); + hostileRef->addThreat(threat); // now we add the real threat if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) - hostilReference->setOnlineOfflineState(false); // GM is always offline + hostileRef->setOnlineOfflineState(false); // GM is always offline } } @@ -497,7 +500,7 @@ void ThreatManager::modifyThreatPercent(Unit *pVictim, int32 pPercent) Unit* ThreatManager::getHostilTarget() { iThreatContainer.update(); - HostilReference* nextVictim = iThreatContainer.selectNextVictim((Creature*) getOwner(), getCurrentVictim()); + HostileReference* nextVictim = iThreatContainer.selectNextVictim((Creature*) getOwner(), getCurrentVictim()); setCurrentVictim(nextVictim); return getCurrentVictim() != NULL ? getCurrentVictim()->getTarget() : NULL; } @@ -506,8 +509,11 @@ Unit* ThreatManager::getHostilTarget() float ThreatManager::getThreat(Unit *pVictim, bool pAlsoSearchOfflineList) { + if (!pVictim) + return NULL; + float threat = 0.0f; - HostilReference* ref = iThreatContainer.getReferenceByTarget(pVictim); + HostileReference* ref = iThreatContainer.getReferenceByTarget(pVictim); if (!ref && pAlsoSearchOfflineList) ref = iThreatOfflineContainer.getReferenceByTarget(pVictim); if (ref) @@ -519,7 +525,7 @@ float ThreatManager::getThreat(Unit *pVictim, bool pAlsoSearchOfflineList) void ThreatManager::tauntApply(Unit* pTaunter) { - HostilReference* ref = iThreatContainer.getReferenceByTarget(pTaunter); + HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter); if (getCurrentVictim() && ref && (ref->getThreat() < getCurrentVictim()->getThreat())) { if (ref->getTempThreatModifyer() == 0.0f) @@ -532,16 +538,16 @@ void ThreatManager::tauntApply(Unit* pTaunter) void ThreatManager::tauntFadeOut(Unit *pTaunter) { - HostilReference* ref = iThreatContainer.getReferenceByTarget(pTaunter); + HostileReference* ref = iThreatContainer.getReferenceByTarget(pTaunter); if (ref) ref->resetTempThreat(); } //============================================================ -void ThreatManager::setCurrentVictim(HostilReference* pHostilReference) +void ThreatManager::setCurrentVictim(HostileReference* pHostileReference) { - iCurrentVictim = pHostilReference; + iCurrentVictim = pHostileReference; } //============================================================ @@ -552,44 +558,44 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat { threatRefStatusChangeEvent->setThreatManager(this); // now we can set the threat manager - HostilReference* hostilReference = threatRefStatusChangeEvent->getReference(); + HostileReference* hostileRef = threatRefStatusChangeEvent->getReference(); switch(threatRefStatusChangeEvent->getType()) { case UEV_THREAT_REF_THREAT_CHANGE: - if ((getCurrentVictim() == hostilReference && threatRefStatusChangeEvent->getFValue()<0.0f) || - (getCurrentVictim() != hostilReference && threatRefStatusChangeEvent->getFValue()>0.0f)) + if ((getCurrentVictim() == hostileRef && threatRefStatusChangeEvent->getFValue()<0.0f) || + (getCurrentVictim() != hostileRef && threatRefStatusChangeEvent->getFValue()>0.0f)) setDirty(true); // the order in the threat list might have changed break; case UEV_THREAT_REF_ONLINE_STATUS: - if (!hostilReference->isOnline()) + if (!hostileRef->isOnline()) { - if (hostilReference == getCurrentVictim()) + if (hostileRef == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } - iThreatContainer.remove(hostilReference); - iThreatOfflineContainer.addReference(hostilReference); + iThreatContainer.remove(hostileRef); + iThreatOfflineContainer.addReference(hostileRef); } else { - if (getCurrentVictim() && hostilReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) + if (getCurrentVictim() && hostileRef->getThreat() > (1.1f * getCurrentVictim()->getThreat())) setDirty(true); - iThreatContainer.addReference(hostilReference); - iThreatOfflineContainer.remove(hostilReference); + iThreatContainer.addReference(hostileRef); + iThreatOfflineContainer.remove(hostileRef); } break; case UEV_THREAT_REF_REMOVE_FROM_LIST: - if (hostilReference == getCurrentVictim()) + if (hostileRef == getCurrentVictim()) { setCurrentVictim(NULL); setDirty(true); } - if (hostilReference->isOnline()) - iThreatContainer.remove(hostilReference); + if (hostileRef ->isOnline()) + iThreatContainer.remove(hostileRef); else - iThreatOfflineContainer.remove(hostilReference); + iThreatOfflineContainer.remove(hostileRef); break; } } diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h index 29e8947fa..2a3f57e15 100755 --- a/src/game/ThreatManager.h +++ b/src/game/ThreatManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _THREATMANAGER -#define _THREATMANAGER +#ifndef HELLGROUND_THREATMANAGER_H +#define HELLGROUND_THREATMANAGER_H #include "Common.h" #include "SharedDefines.h" @@ -46,10 +46,10 @@ class ThreatCalcHelper //============================================================== -class HELLGROUND_IMPORT_EXPORT HostilReference : public Reference +class HELLGROUND_IMPORT_EXPORT HostileReference : public Reference { public: - HostilReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat); + HostileReference(Unit* pUnit, ThreatManager *pThreatManager, float pThreat); //================================================= void addThreat(float pMod); @@ -89,7 +89,7 @@ class HELLGROUND_IMPORT_EXPORT HostilReference : public Reference::next()); } + HostileReference* next() { return ((HostileReference*) Reference::next()); } //================================================= @@ -135,13 +135,13 @@ class ThreatManager; class HELLGROUND_IMPORT_EXPORT ThreatContainer { private: - std::list iThreatList; + std::list iThreatList; bool iDirty; protected: friend class ThreatManager; - void remove(HostilReference* pRef) { iThreatList.remove(pRef); } - void addReference(HostilReference* pHostilReference) { iThreatList.push_back(pHostilReference); } + void remove(HostileReference* pRef) { iThreatList.remove(pRef); } + void addReference(HostileReference* pHostileReference) { iThreatList.push_back(pHostileReference); } void clearReferences(); // Sort the list if necessary void update(); @@ -149,11 +149,11 @@ class HELLGROUND_IMPORT_EXPORT ThreatContainer ThreatContainer() { iDirty = false; } ~ThreatContainer() { clearReferences(); } - HostilReference* addThreat(Unit* pVictim, float pThreat); + HostileReference* addThreat(Unit* pVictim, float pThreat); void modifyThreatPercent(Unit *pVictim, int32 percent); - HostilReference* selectNextVictim(Creature* pAttacker, HostilReference* pCurrentVictim); + HostileReference* selectNextVictim(Creature* pAttacker, HostileReference* pCurrentVictim); void setDirty(bool pDirty) { iDirty = pDirty; } @@ -161,11 +161,11 @@ class HELLGROUND_IMPORT_EXPORT ThreatContainer bool empty() { return(iThreatList.empty()); } - HostilReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } + HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } - HostilReference* getReferenceByTarget(Unit* pVictim); + HostileReference* getReferenceByTarget(Unit* pVictim); - std::list& getThreatList() { return iThreatList; } + std::list& getThreatList() { return iThreatList; } }; //================================================= @@ -173,7 +173,7 @@ class HELLGROUND_IMPORT_EXPORT ThreatContainer class HELLGROUND_IMPORT_EXPORT ThreatManager { public: - friend class HostilReference; + friend class HostileReference; explicit ThreatManager(Unit *pOwner); @@ -190,7 +190,7 @@ class HELLGROUND_IMPORT_EXPORT ThreatManager void processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent); - HostilReference* getCurrentVictim() { return iCurrentVictim; } + HostileReference* getCurrentVictim() { return iCurrentVictim; } Unit* getOwner() { return iOwner; } @@ -199,19 +199,19 @@ class HELLGROUND_IMPORT_EXPORT ThreatManager void tauntApply(Unit* pTaunter); void tauntFadeOut(Unit *pTaunter); - void setCurrentVictim(HostilReference* pHostilReference); + void setCurrentVictim(HostileReference* pHostileReference); void setDirty(bool pDirty) { iThreatContainer.setDirty(pDirty); } // methods to access the lists from the outside to do sume dirty manipulation (scriping and such) // I hope they are used as little as possible. - std::list& getThreatList() { return iThreatContainer.getThreatList(); } - std::list& getOfflieThreatList() { return iThreatOfflineContainer.getThreatList(); } + std::list& getThreatList() { return iThreatContainer.getThreatList(); } + std::list& getOfflieThreatList() { return iThreatOfflineContainer.getThreatList(); } ThreatContainer& getOnlineContainer() { return iThreatContainer; } ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; } private: - HostilReference* iCurrentVictim; + HostileReference* iCurrentVictim; Unit* iOwner; ThreatContainer iThreatContainer; ThreatContainer iThreatOfflineContainer; diff --git a/src/game/TicketHandler.cpp b/src/game/TicketHandler.cpp index 0965f8a2c..33103ec78 100755 --- a/src/game/TicketHandler.cpp +++ b/src/game/TicketHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Language.h" @@ -27,6 +27,7 @@ #include "TicketMgr.h" #include "World.h" #include "Chat.h" +#include "luaengine/HookMgr.h" void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recv_data) { @@ -70,6 +71,9 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recv_data) // remove ticket by player, shouldn't happen sTicketMgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID()); + // used by eluna + sHookMgr->OnGmTicketCreate(_player, ticketText); + // add ticket sTicketMgr.AddGMTicket(ticket, false); @@ -122,12 +126,16 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recv_data) sWorld.SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->guid); + sHookMgr->OnGmTicketUpdate(_player, ticket->message); } void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recv_data*/) { // NO recv_data, NO packet check size + // used by eluna + sHookMgr->OnGmTicketDelete(_player); + GM_Ticket* ticket = sTicketMgr.GetGMTicketByPlayer(GetPlayer()->GetGUID()); // CHeck for Ticket diff --git a/src/game/TicketMgr.cpp b/src/game/TicketMgr.cpp index 6336b6734..3c22154b7 100755 --- a/src/game/TicketMgr.cpp +++ b/src/game/TicketMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "TicketMgr.h" diff --git a/src/game/TicketMgr.h b/src/game/TicketMgr.h index 018b1520e..1b6ab02e0 100755 --- a/src/game/TicketMgr.h +++ b/src/game/TicketMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _sTicketMgr_H -#define _sTicketMgr_H +#ifndef HELLGROUND_TICKETMGR_H +#define HELLGROUND_TICKETMGR_H #include "ace/Singleton.h" diff --git a/src/game/Tools.cpp b/src/game/Tools.cpp index 775f48681..da7124dab 100755 --- a/src/game/Tools.cpp +++ b/src/game/Tools.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Tools.h b/src/game/Tools.h index f6aa79c84..e63f06a12 100755 --- a/src/game/Tools.h +++ b/src/game/Tools.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef HELLGROUND_TOOLS_H #define HELLGROUND_TOOLS_H diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 5eb8bba43..78694d66d 100755 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include "ObjectMgr.h" #include "SpellMgr.h" #include "CreatureAI.h" +#include "luaengine/HookMgr.h" Totem::Totem() : Creature() { @@ -107,6 +108,9 @@ void Totem::Summon(Unit* owner) // call JustSummoned function when totem summoned from spell if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled) ((Creature*)owner)->AI()->JustSummoned(this); + + if (Unit* summoner = owner->ToUnit()) + sHookMgr->OnSummoned(this, summoner); } void Totem::UnSummon() @@ -176,13 +180,13 @@ Unit *Totem::GetOwner() void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto) { - // Get spell casted by totem + // Get spell cast by totem SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell()); if (totemSpell) { - // If spell have cast time -> so its active totem - if (SpellMgr::GetSpellCastTime(totemSpell)) + if(~totemSpell->Attributes & SPELL_ATTR_PASSIVE) m_type = TOTEM_ACTIVE; + } if (spellProto->SpellIconID==2056) m_type = TOTEM_STATUE; //Jewelery statue @@ -190,16 +194,21 @@ void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto) bool Totem::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) { -/* for (int i=0;i<3;i++) + if (!(spellInfo->AttributesCu & SPELL_ATTR_CU_DIRECT_DAMAGE)) { - switch (spellInfo->EffectApplyAuraName[i]) + for (int i=0;i<3;i++) { - case SPELL_AURA_PERIODIC_DAMAGE: - case SPELL_AURA_PERIODIC_LEECH: - return true; - default: - continue; + switch (spellInfo->EffectApplyAuraName[i]) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_MOD_FEAR: + case SPELL_AURA_TRANSFORM: + return true; + default: + continue; + } } - }*/ + } return Creature::IsImmunedToSpell(spellInfo, useCharges); } diff --git a/src/game/Totem.h b/src/game/Totem.h index 4a768a34a..a4354b7c5 100755 --- a/src/game/Totem.h +++ b/src/game/Totem.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_TOTEM_H -#define TRINITYCORE_TOTEM_H +#ifndef HELLGROUND_TOTEM_H +#define HELLGROUND_TOTEM_H #include "Creature.h" diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 39c96b177..c2d462f55 100755 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,6 @@ TotemAI::Permissible(const Creature *creature) TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_totem(static_cast(*c)), i_victimGuid(0) { - c->addUnitState(UNIT_STAT_CANNOT_TURN); } void TotemAI::MoveInLineOfSight(Unit *) @@ -51,6 +50,7 @@ void TotemAI::MoveInLineOfSight(Unit *) void TotemAI::EnterEvadeMode() { + i_totem.addUnitState(UNIT_STAT_STUNNED); i_totem.CombatStop(); } @@ -59,7 +59,9 @@ void TotemAI::UpdateAI(const uint32 /*diff*/) if (i_totem.GetTotemType() != TOTEM_ACTIVE) return; - if (!i_totem.isAlive() || i_totem.IsNonMeleeSpellCasted(false)) + i_totem.SetSelection(0); + + if (!i_totem.isAlive() || i_totem.IsNonMeleeSpellCast(false)) return; // Search spell @@ -81,8 +83,8 @@ void TotemAI::UpdateAI(const uint32 /*diff*/) // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if (!victim || (!SpellMgr::SpellIgnoreLOS(spellInfo, 0) && !i_totem.IsWithinLOSInMap(victim)) || - !victim->isTargetableForAttack() || !i_totem.IsWithinDistInMap(victim, max_range) || - (i_totem.IsFriendlyTo(victim) && victim != &i_totem) || !victim->isVisibleForOrDetect(&i_totem, &i_totem, false)) + !victim->isTargetableForAttack() || !i_totem.IsWithinDistInMap(victim, max_range) || + (i_totem.IsFriendlyTo(victim) && victim != &i_totem) || !victim->isVisibleForOrDetect(&i_totem, &i_totem, false)) { victim = NULL; @@ -95,15 +97,19 @@ void TotemAI::UpdateAI(const uint32 /*diff*/) // If have target if (victim) { + //this should prevent target-type totems from attacking from unattackable zones and attacking while being unattackable + if ((i_totem.isInSanctuary() || victim->isInSanctuary()) && victim->GetCharmerOrOwnerPlayerOrPlayerItself()) + return; // remember i_victimGuid = victim->GetGUID(); // attack - //i_totem.SetInFront(victim); // client change orientation by self - i_totem.CastSpell(victim, i_totem.GetSpell(), false); + i_totem.CastSpell(victim, i_totem.GetSpell(), false, NULL, NULL, i_totem.GetOwner()->GetGUID()); } else i_victimGuid = 0; + + //i_totem.SetFacingToObject(&i_totem); } bool TotemAI::IsVisible(Unit *) const diff --git a/src/game/TotemAI.h b/src/game/TotemAI.h index f640a9d20..b71bc31c5 100755 --- a/src/game/TotemAI.h +++ b/src/game/TotemAI.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp old mode 100755 new mode 100644 index 074a1577a..bb99b17db --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -134,7 +134,7 @@ void WorldSession::SendUpdateTrade() data << (uint32) TRADE_SLOT_COUNT; // trade slots count/number?, = next field in most cases data << (uint32) TRADE_SLOT_COUNT; // trade slots count/number?, = prev field in most cases data << (uint32) _player->pTrader->tradeGold; // trader gold - data << (uint32) 0; // spell casted on lowest slot item + data << (uint32) 0; // spell cast on lowest slot item for (uint8 i = 0; i < TRADE_SLOT_COUNT; i++) { @@ -196,7 +196,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { // logging sLog.outDebug("partner storing: %u",myItems[i]->GetGUIDLow()); - if (_player->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), @@ -204,7 +204,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId()); } - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), myItems[i]->GetProto()->Name1,myItems[i]->GetEntry(),myItems[i]->GetCount(), _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId()); @@ -216,7 +216,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { // logging sLog.outDebug("player storing: %u",hisItems[i]->GetGUIDLow()); - if (_player->pTrader->GetSession()->GetPermissions() & PERM_GMT && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) + if (_player->pTrader->GetSession()->HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { sLog.outCommand(_player->pTrader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(), @@ -224,7 +224,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) _player->GetName(),_player->GetSession()->GetAccountId()); } - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(), hisItems[i]->GetProto()->Name1,hisItems[i]->GetEntry(),hisItems[i]->GetCount(), _player->GetName(),_player->GetSession()->GetAccountId()); @@ -427,14 +427,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) // logging money if (sWorld.getConfig(CONFIG_GM_LOG_TRADE)) { - if (_player->GetSession()->GetPermissions() & PERM_GMT && _player->tradeGold > 0) + if (_player->GetSession()->HasPermissions(PERM_GMT) && _player->tradeGold > 0) { sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), _player->tradeGold, _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId()); } - if (_player->pTrader->GetSession()->GetPermissions() & PERM_GMT && _player->pTrader->tradeGold > 0) + if (_player->pTrader->GetSession()->HasPermissions(PERM_GMT) && _player->pTrader->tradeGold > 0) { sLog.outCommand(_player->pTrader->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(), @@ -445,14 +445,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) if (_player->tradeGold > 0) { - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", _player->GetName(),_player->GetSession()->GetAccountId(), _player->tradeGold, _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId()); } if (_player->pTrader->tradeGold > 0) { - sLog.outLog(LOG_MAIL, "Player %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", + sLog.outLog(LOG_TRADE, "Player %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(), _player->pTrader->tradeGold, _player->GetName(),_player->GetSession()->GetAccountId()); diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 2d9b8ab48..5d39794ff 100755 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Transports.h b/src/game/Transports.h index 770dab498..eced95614 100755 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRANSPORTS_H -#define TRANSPORTS_H +#ifndef HELLGROUND_TRANSPORTS_H +#define HELLGROUND_TRANSPORTS_H #include "GameObject.h" diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6517fec32..6f3c4abd1 100755 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -55,7 +55,7 @@ #include "MovementGenerator.h" #include "movement/MoveSplineInit.h" #include "movement/MoveSpline.h" - +#include "luaengine/HookMgr.h" #include @@ -80,7 +80,7 @@ static Unit::AuraTypeSet GenerateAttakerProcCastAuraTypes() auraTypes.insert(SPELL_AURA_DUMMY); auraTypes.insert(SPELL_AURA_PROC_TRIGGER_SPELL); auraTypes.insert(SPELL_AURA_MOD_HASTE); - auraTypes.insert(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + auraTypes.insert(SPELL_AURA_override_CLASS_SCRIPTS); return auraTypes; } @@ -150,7 +150,7 @@ bool IsPassiveStackableSpell(uint32 spellId) for (int j = 0; j < 3; ++j) { - if (std::find(procAuraTypes.begin(),procAuraTypes.end(),spellProto->EffectApplyAuraName[j])!=procAuraTypes.end()) + if (procAuraTypes.find(Unit::AuraTypeSet::value_type(spellProto->EffectApplyAuraName[j])) != procAuraTypes.end()) return false; } @@ -261,7 +261,7 @@ bool CastSpellEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Unit::Unit() : WorldObject(), i_motionMaster(this), movespline(new Movement::MoveSpline()), - _threatManager(this), _hostilRefManager(this), m_stateMgr(this), + _threatManager(this), _hostileRefManager(this), m_stateMgr(this), IsAIEnabled(false), NeedChangeAI(false), i_AI(NULL), i_disabledAI(NULL), m_procDeep(0), m_AI_locked(false), m_removedAurasCount(0) { @@ -363,6 +363,8 @@ Unit::Unit() : m_GMToSendCombatStats = 0; _AINotifyScheduled = false; + + WorthHonor = false; } //////////////////////////////////////////////////////////// @@ -448,7 +450,7 @@ void Unit::Update(uint32 update_diff, uint32 p_time) // update combat timer only for players and pets if (isInCombat() && isCharmedOwnedByPlayerOrPlayer()) { - if (getHostilRefManager().isEmpty()) + if (getHostileRefManager().isEmpty()) { // m_CombatTimer set at aura start and it will be freeze until aura removing if (m_CombatTimer <= update_diff) @@ -589,7 +591,7 @@ void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, uint32 attacker_number = getAttackers().size(); if (attacker_number > 0) --attacker_number; - GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm() + GetNearPoint(x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm() , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0)); } @@ -599,13 +601,7 @@ void Unit::RemoveMovementImpairingAuras() { SpellEntry const* spellInfo = iter->second->GetSpellProto(); if (spellInfo->AttributesCu & SPELL_ATTR_CU_MOVEMENT_IMPAIR) - { - // do NOT remove Dazed effect on shape shift - if (spellInfo->Id == 1604) - ++iter; - else - RemoveAura(iter); - } + RemoveAura(iter); else ++iter; } @@ -663,7 +659,7 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) return false; } -void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) +void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except, bool PositiveOnly) { if (!(m_interruptMask & flag)) return; @@ -675,7 +671,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) Aura *aur = *iter; ++iter; - if (aur && (aur->GetSpellProto()->AuraInterruptFlags & flag)) + if (aur && (aur->GetSpellProto()->AuraInterruptFlags & flag) && (!PositiveOnly || aur->IsPositive())) { if (aur->IsInUse()) sLog.outLog(LOG_DEFAULT, "ERROR: Aura %u is trying to remove itself! Flag %u. May cause crash!", aur->GetId(), flag); @@ -694,8 +690,8 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) // interrupt channeled spell if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) if (spell->getState() == SPELL_STATE_CASTING - && (spell->GetSpellInfo()->ChannelInterruptFlags & flag) - && spell->GetSpellInfo()->Id != except) + && (spell->GetSpellEntry()->ChannelInterruptFlags & flag) + && spell->GetSpellEntry()->Id != except) InterruptNonMeleeSpells(false); UpdateInterruptMask(); @@ -711,7 +707,7 @@ void Unit::UpdateInterruptMask() } if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) if (spell->getState() == SPELL_STATE_CASTING) - m_interruptMask |= spell->GetSpellInfo()->ChannelInterruptFlags; + m_interruptMask |= spell->GetSpellEntry()->ChannelInterruptFlags; } bool Unit::HasAuraType(AuraType auraType) const @@ -743,6 +739,25 @@ uint32 Unit::GetAurasAmountByMiscValue(AuraType auraType, uint32 misc) return count; } +bool Unit::HasAuraByCasterWithFamilyFlags(uint64 pCaster, uint32 familyName, uint64 familyFlags, const Aura * except) const +{ + const AuraMap & tmpMap = GetAuras(); + SpellEntry const * tmpSpellEntry; + for (AuraMap::const_iterator itr = tmpMap.begin(); itr != tmpMap.end(); ++itr) + { + if ((!except || except != itr->second)) + { + if (tmpSpellEntry = itr->second->GetSpellProto()) + { + if (tmpSpellEntry->SpellFamilyName == familyName && tmpSpellEntry->SpellFamilyFlags & familyFlags && (itr->second->GetCasterGUID() == pCaster)) + return true; + } + } + } + + return false; +} + /* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) { @@ -817,12 +832,9 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons return 0; //You don't lose health from damage taken from another player while in a sanctuary - if (pVictim != this && isCharmedOwnedByPlayerOrPlayer() && pVictim->isCharmedOwnedByPlayerOrPlayer() && pVictim->GetOwner() != this) - { - const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); - if (area && area->flags & AREA_FLAG_SANCTUARY) //sanctuary - return 0; - } + if (pVictim != this && isCharmedOwnedByPlayerOrPlayer() && pVictim->isCharmedOwnedByPlayerOrPlayer() && + pVictim->GetOwner() != this && pVictim->isInSanctuary()) + return 0; // Do not deal damage from AoE spells when target is immune to it if (!pVictim->isAttackableByAOE() && spellProto && SpellMgr::IsAreaOfEffectSpell(spellProto)) @@ -834,6 +846,9 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons if (spellProto && SpellCantDealDmgToPlayer(spellProto->Id)) return 0; + if (pVictim->ToPlayer()->HasCheatState(PlayerCheatState::God)) + return 0; + // Handle Blessed Life if (pVictim->getClass() == CLASS_PALADIN) { @@ -888,7 +903,7 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons //Script Event damage made on players by Unit if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) if (damageInfo->damage) - ((Creature*)this)->AI()->DamageMade(pVictim, damageInfo->damage, damagetype == DIRECT_DAMAGE); + ((Creature*)this)->AI()->DamageMade(pVictim, damageInfo->damage, damagetype == DIRECT_DAMAGE, damageInfo->schoolMask); if (damageInfo->damage || damageInfo->absorb) { @@ -897,10 +912,16 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DAMAGE, spellProto ? spellProto->Id : 0); pVictim->RemoveSpellbyDamageTaken(damageInfo->damage, spellProto ? spellProto->Id : 0); } - + else// if (spellProto->AttributesEx4 & SPELL_ATTR_EX4_DAMAGE_DOESNT_BREAK_AURAS) // if got here - 100% got this attribute + pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DAMAGE, spellProto->Id, true); // Rage from any damage taken if (pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) ((Player*)pVictim)->RewardRage(damageInfo->rageDamage, 0, false); + + if (Spell* spell = pVictim->m_currentSpells[CURRENT_GENERIC_SPELL]) + if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) + if(spell->GetSpellEntry()->Id == 21651 || spell->GetSpellEntry()->Id == 26868) + pVictim->InterruptSpell(CURRENT_GENERIC_SPELL,true,true); } if (damageInfo->damage) @@ -1015,6 +1036,8 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons { if (!spellProto || !(spellProto->AttributesEx4 & SPELL_ATTR_EX4_DAMAGE_DOESNT_BREAK_AURAS)) pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE, spellProto ? spellProto->Id : 0); + else // if (spellProto->AttributesEx4 & SPELL_ATTR_EX4_DAMAGE_DOESNT_BREAK_AURAS) // 100% got this attribute + pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE, spellProto->Id, true); } if (pVictim->GetTypeId() != TYPEID_PLAYER) @@ -1037,7 +1060,7 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons { // random durability for items (HIT TAKEN) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) + if (roll_chance_f(sWorld.getConfig(RATE_DURABILITY_LOSS_DAMAGE))) { EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); ((Player*)pVictim)->DurabilityPointLossForEquipSlot(slot); @@ -1047,7 +1070,7 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons if (GetTypeId()==TYPEID_PLAYER) { // random durability for items (HIT DONE) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) + if (roll_chance_f(sWorld.getConfig(RATE_DURABILITY_LOSS_DAMAGE))) { EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); ((Player*)this)->DurabilityPointLossForEquipSlot(slot); @@ -1064,7 +1087,7 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons { if (spell->getState() == SPELL_STATE_PREPARING) { - uint32 interruptFlags = spell->GetSpellInfo()->InterruptFlags; + uint32 interruptFlags = spell->GetSpellEntry()->InterruptFlags; if (interruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE) pVictim->InterruptNonMeleeSpells(false); else if (interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK) @@ -1077,8 +1100,8 @@ uint32 Unit::DealDamage(DamageLog *damageInfo, DamageEffectType damagetype, cons { if (spell->getState() == SPELL_STATE_CASTING) { - uint32 channelInterruptFlags = spell->GetSpellInfo()->ChannelInterruptFlags; - if (damagetype != DOT && channelInterruptFlags & CHANNEL_FLAG_DELAY) + uint32 channelInterruptFlags = spell->GetSpellEntry()->ChannelInterruptFlags; + if (damagetype != DOT && channelInterruptFlags & CHANNEL_INTERRUPT_FLAG_DELAY) spell->DelayedChannel(); } } @@ -1121,7 +1144,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, DamageEffectType damagetyp void Unit::CastStop(uint32 except_spellid) { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) - if (m_currentSpells[i] && m_currentSpells[i]->GetSpellInfo()->Id!=except_spellid) + if (m_currentSpells[i] && m_currentSpells[i]->GetSpellEntry()->Id!=except_spellid) InterruptSpell(i,false, false); } @@ -1251,6 +1274,10 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); + // for max targets spell mod, custom values should be here, before filling target map + for (CustomSpellValues::const_iterator itr = value.begin(); itr != value.end(); ++itr) + spell->SetSpellValue(itr->first, itr->second); + // if victim is defined use it, if not, search for targets if (Victim) targets.setUnitTarget(Victim); @@ -1266,9 +1293,6 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* spell->m_CastItem = castItem; } - for (CustomSpellValues::const_iterator itr = value.begin(); itr != value.end(); ++itr) - spell->SetSpellValue(itr->first, itr->second); - spell->prepare(&targets, triggeredByAura); } @@ -1491,17 +1515,9 @@ void Unit::DealSpellDamage(SpellDamageLog *damageInfo, bool durabilityLoss) //You don't lose health from damage taken from another player while in a sanctuary //You still see it in the combat log though - if (pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) - { - const AreaTableEntry *area = GetAreaEntryByAreaID(((Player*)pVictim)->GetCachedArea()); - if (area && area->flags & 0x800) //sanctuary - return; - - // prevent cross-zone attack: caster in sanctuary, victim not - area = GetAreaEntryByAreaID(((Player*)this)->GetCachedArea()); - if (area && area->flags & 0x800) - return; - } + if (pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER && + (pVictim->isInSanctuary() || isInSanctuary())) + return; // update at damage Judgement aura duration that applied by attacker at victim if (damageInfo->damage && spellProto->Id == 35395) @@ -1618,12 +1634,8 @@ void Unit::DealMeleeDamage(MeleeDamageLog *damageInfo, bool durabilityLoss) //You don't lose health from damage taken from another player while in a sanctuary //You still see it in the combat log though - if (pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) - { - const AreaTableEntry *area = GetAreaEntryByAreaID(((Player*)pVictim)->GetCachedArea()); - if (area && area->flags & 0x800) //sanctuary - return; - } + if (pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->isInSanctuary()) + return; // Hmmmm dont like this emotes cloent must by self do all animations if (damageInfo->hitInfo & HITINFO_CRITICALHIT) @@ -1814,35 +1826,38 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff if (schoolMask & ~SPELL_SCHOOL_MASK_NORMAL) { // Get base victim resistance for school - float tmpvalue2 = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)); + float victimResistance = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)); // Ignore resistance by self SPELL_AURA_MOD_TARGET_RESISTANCE aura if(GetTypeId() == TYPEID_PLAYER) - tmpvalue2 += (float)GetInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE); + victimResistance += (float)GetInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE); else - tmpvalue2 += (float)GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask); + victimResistance += (float)GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask); + + if (Player* player = ToPlayer()) + victimResistance -= float(player->GetSpellPenetrationItemMod()); - if (tmpvalue2 < 0.0f || schoolMask & SPELL_SCHOOL_MASK_HOLY) - tmpvalue2 = 0.0f; + if (victimResistance < 0.0f || schoolMask & SPELL_SCHOOL_MASK_HOLY) + victimResistance = 0.0f; if (Creature* pCre = pVictim->ToCreature()) { int32 leveldiff = int32(pCre->getLevelForTarget(this)) - int32(getLevelForTarget(pCre)); if (leveldiff > 0) - tmpvalue2 += leveldiff * 5; + victimResistance += leveldiff * 5; } - tmpvalue2 *= (float)(0.15f / getLevel()); - if (tmpvalue2 < 0.0f) - tmpvalue2 = 0.0f; - if (tmpvalue2 > 0.75f) - tmpvalue2 = 0.75f; + victimResistance *= (float)(0.15f / getLevel()); + if (victimResistance < 0.0f) + victimResistance = 0.0f; + if (victimResistance > 0.75f) + victimResistance = 0.75f; uint32 ran = urand(0, 10000); uint32 faq[4] = {24,6,4,6}; uint8 m = 0; float Binom = 0.0f; for (uint8 i = 0; i < 4; i++) { - Binom += 240000 *(powf(tmpvalue2, i) * powf((1-tmpvalue2), (4-i)))/faq[i]; + Binom += 240000 *(powf(victimResistance, i) * powf((1-victimResistance), (4-i)))/faq[i]; if (ran > Binom) ++m; else @@ -1923,7 +1938,7 @@ void Unit::CalcAbsorb(Unit *pVictim,SpellSchoolMask schoolMask, const uint32 dam { if (Unit* caster = (*i)->GetCaster()) { - AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (AuraList::const_iterator k = vOverRideCS.begin(); k != vOverRideCS.end(); ++k) { switch ((*k)->GetModifier()->m_miscvalue) @@ -2169,7 +2184,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex if (attType == RANGED_ATTACK) return; // ignore ranged case - // melee attack spell casted at main hand attack only + // melee attack spell cast at main hand attack only if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL] && !extra) { m_currentSpells[CURRENT_MELEE_SPELL]->cast(); @@ -2232,10 +2247,6 @@ void Unit::RollMeleeHit(MeleeDamageLog *damageInfo) const // stunned target cannot dodge and this is check in GetUnitDodgeChance() (returned 0 in this case) float dodge_chance = damageInfo->target->GetUnitDodgeChance(); - if(HasAuraType(SPELL_AURA_MOD_ENEMY_DODGE)) - dodge_chance += GetTotalAuraModifier(SPELL_AURA_MOD_ENEMY_DODGE); - if(dodge_chance < 0) - dodge_chance = 0; float block_chance = damageInfo->target->GetUnitBlockChance(); float parry_chance = damageInfo->target->GetUnitParryChance(); @@ -2338,6 +2349,8 @@ void Unit::RollMeleeHit(MeleeDamageLog *damageInfo, int32 crit_chance, int32 mis dodge_chance -= expertise_reduction + skillBonus; // Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE dodge_chance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; + // Modify dodge chance by SPELL_AURA_MOD_ENEMY_DODGE + dodge_chance += GetTotalAuraModifier(SPELL_AURA_MOD_ENEMY_DODGE) * 100; if (dodge_chance > 0) { SendCombatStats("RollMeleeHit: dodge chance = %d", pVictim, dodge_chance); @@ -2401,8 +2414,8 @@ void Unit::RollMeleeHit(MeleeDamageLog *damageInfo, int32 crit_chance, int32 mis if (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK_ON_ATTACK) block_chance = 0; - - if (Player* player = const_cast(ToPlayer())) + + if (Player* player = const_cast(pVictim->ToPlayer())) { Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!tmpitem || !tmpitem->GetProto()->Block) @@ -2579,27 +2592,24 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const return (100.0f - lvlPenalty) * lvlFactor / 100.0f; } -void Unit::SendMeleeAttackStart(Unit* pVictim) +void Unit::SendMeleeAttackStart(uint64 victimGUID) { WorldPacket data(SMSG_ATTACKSTART, 8+8); data << uint64(GetGUID()); - data << uint64(pVictim->GetGUID()); + data << uint64(victimGUID); BroadcastPacket(&data, true); DEBUG_LOG("WORLD: Sent SMSG_ATTACKSTART"); } -void Unit::SendMeleeAttackStop(Unit* victim) +void Unit::SendMeleeAttackStop( uint64 victimGUID ) { - if (!victim) - return; - - WorldPacket data(SMSG_ATTACKSTOP, (4+16)); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (4+16)); // we guess size data << GetPackGUID(); - data << victim->GetPackGUID(); // can be 0x00... + data << victimGUID; // can be 0x00... data << uint32(0); // can be 0x1 BroadcastPacket(&data, true); - sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId()==TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId()==TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow()); + sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId()==TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (IS_PLAYER_GUID(victimGUID) ? "player" : "creature"),victimGUID); } int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const @@ -2613,7 +2623,7 @@ uint32 Unit::GetCurrentSpellId() const { for (int i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) if(m_currentSpells[i]) - return m_currentSpells[i]->GetSpellInfo()->Id; + return m_currentSpells[i]->GetSpellEntry()->Id; return 0; } @@ -2625,7 +2635,7 @@ Spell* Unit::GetCurrentSpell(CurrentSpellTypes type) const SpellEntry const* Unit::GetCurrentSpellProto(CurrentSpellTypes type) const { - return (m_currentSpells[type] ? m_currentSpells[type]->GetSpellInfo() : NULL); + return (m_currentSpells[type] ? m_currentSpells[type]->GetSpellEntry() : NULL); } bool Unit::isSpellBlocked(Unit *pVictim, SpellEntry const *spellProto, WeaponAttackType attackType) @@ -2672,6 +2682,13 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, // Spellmod from SPELLMOD_RESIST_MISS_CHANCE if (spellId) { + if (pVictim->GetObjectGuid().IsCreature() && pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_1PCT_TAUNT_RESIST) + { + const SpellEntry* spellInfo = sSpellStore.LookupEntry(spellId); + if (SpellMgr::IsTauntSpell(spellInfo)) + return 1.0f; + } + if (Player *modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, HitChance); } @@ -2680,7 +2697,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, float miss_chance= 100.0f - HitChance; if (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CANT_MISS) - return 0; + return 0.0f; // Bonuses from attacker aura and ratings if (attType == RANGED_ATTACK) @@ -2747,14 +2764,14 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell, uint32 tmp = 0; - bool isCasting = pVictim->IsNonMeleeSpellCasted(false); + bool isCasting = pVictim->IsNonMeleeSpellCast(false); bool lostControl = pVictim->hasUnitState(UNIT_STAT_LOST_CONTROL); bool canDodge = !isCasting && !lostControl; bool canParry = !isCasting && !lostControl; bool canBlock = spell->AttributesEx3 & SPELL_ATTR_EX3_UNK3 && !isCasting && !lostControl; - if (Player* player = ToPlayer()) + if (Player* player = pVictim->ToPlayer()) { Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!tmpitem || !tmpitem->GetProto()->Block) @@ -2766,7 +2783,8 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell, canBlock = false; //We use SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY until right Attribute was found - bool canMiss = !(spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && cMiss || spell->AttributesEx3 & SPELL_ATTR_EX3_CANT_MISS; + bool canMiss = !(spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && cMiss || + spell->AttributesEx3 & SPELL_ATTR_EX3_CANT_MISS || spell->AttributesEx3 & SPELL_ATTR_EX3_UNK15; if (canMiss) { @@ -2786,13 +2804,22 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell, if (roll < tmp) return SPELL_MISS_RESIST; - // Same spells cannot be parry/dodge + // Some spells cannot be parried, dodged nor blocked if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) return SPELL_MISS_NONE; - // Ranged attack can`t miss too + // Handle ranged attacks if (attType == RANGED_ATTACK) - return SPELL_MISS_NONE; + { + // Wand attacks can't miss + if (spell->Category == 351) + return SPELL_MISS_NONE; + + // Other ranged attacks cannot be parried or dodged + // Can be blocked under suitable circumstances + canParry = false; + canDodge = false; + } // Check for attack from behind if (!pVictim->HasInArc(M_PI,this)) @@ -2923,6 +2950,12 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (HitChance < 100) HitChance = 100; if (HitChance > 9900) HitChance = 9900; + if (pVictim->GetObjectGuid().IsCreature() && pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_1PCT_TAUNT_RESIST) + { + if (SpellMgr::IsTauntSpell(spell)) + HitChance = 9900; + } + SendCombatStats("MagicSpellHitResult (id=%d): hit chance = %d", pVictim, spell->Id, HitChance); uint32 rand = urand(0,10000); if (rand > HitChance) @@ -2957,9 +2990,9 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool if (pVictim->IsImmunedToSpell(spell,true)) return SPELL_MISS_IMMUNE; - // All positive spells can`t miss + // All positive spells + dispels on friendly target can`t miss // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! - if (SpellMgr::IsPositiveSpell(spell->Id) + if ((SpellMgr::IsPositiveSpell(spell->Id) || SpellMgr::IsDispel(spell)) &&(!IsHostileTo(pVictim))) //prevent from affecting enemy by "positive" spell return SPELL_MISS_NONE; @@ -2986,7 +3019,7 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL); for (Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i) if ((*i)->GetModifier()->m_miscvalue & SpellMgr::GetSpellSchoolMask(spell)) - reflectchance = (*i)->GetModifierValue(); + reflectchance += (*i)->GetModifierValue(); if (reflectchance > 0 && roll_chance_i(reflectchance)) { @@ -3046,7 +3079,7 @@ float Unit::GetUnitDodgeChance() const float Unit::GetUnitParryChance() const { - if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_LOST_CONTROL)) + if (IsNonMeleeSpellCast(false) || hasUnitState(UNIT_STAT_LOST_CONTROL)) return 0.0f; float chance = 0.0f; @@ -3082,7 +3115,7 @@ float Unit::GetUnitParryChance() const float Unit::GetUnitBlockChance() const { - if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_LOST_CONTROL)) + if (IsNonMeleeSpellCast(false) || hasUnitState(UNIT_STAT_LOST_CONTROL)) return 0.0f; if (GetTypeId() == TYPEID_PLAYER) @@ -3274,10 +3307,10 @@ void Unit::_UpdateSpells(uint32 time) void Unit::_UpdateAutoRepeatSpell() { //check "realtime" interrupts - if ((GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCasted(false,false,true)) + if ((GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCast(false,false,true)) { // cancel wand shoot - if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Category == 351) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellEntry()->Category == 351) InterruptSpell(CURRENT_AUTOREPEAT_SPELL); m_AutoRepeatFirstCast = true; return; @@ -3300,7 +3333,7 @@ void Unit::_UpdateAutoRepeatSpell() } // we want to shoot - Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo(), true, 0); + Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellEntry(), true, 0); spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets)); if (!IsStandState()) @@ -3311,7 +3344,7 @@ void Unit::_UpdateAutoRepeatSpell() } } -void Unit::SetCurrentCastedSpell(Spell* spell) +void Unit::SetCurrentCastSpell(Spell* spell) { ASSERT(spell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells @@ -3334,7 +3367,7 @@ void Unit::SetCurrentCastedSpell(Spell* spell) if (Spell* current = GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)) { // break autorepeat if not Auto Shot - if (current->GetSpellInfo()->Category == 351) + if (current->GetSpellEntry()->Category == 351) InterruptSpell(CURRENT_AUTOREPEAT_SPELL); m_AutoRepeatFirstCast = true; @@ -3355,7 +3388,7 @@ void Unit::SetCurrentCastedSpell(Spell* spell) if (Spell* current = GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)) { // break autorepeat if not Auto Shot - if (current->GetSpellInfo()->Category == 351) + if (current->GetSpellEntry()->Category == 351) InterruptSpell(CURRENT_AUTOREPEAT_SPELL); } @@ -3367,7 +3400,7 @@ void Unit::SetCurrentCastedSpell(Spell* spell) case CURRENT_AUTOREPEAT_SPELL: { // only Auto Shoot does not break anything - if (spell->GetSpellInfo()->Category == 351) + if (spell->GetSpellEntry()->Category == 351) { // generic autorepeats break generic non-delayed and channeled non-delayed spells InterruptSpell(CURRENT_GENERIC_SPELL,false); @@ -3428,18 +3461,18 @@ void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/) spell->finish(ok); } -bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const +bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const { // We don't do loop here to explicitly show that melee spell is excluded. // Maybe later some special spells will be excluded too. - // generic spells are casted when they are not finished and not delayed + // generic spells are cast when they are not finished and not delayed if (Spell* current = GetCurrentSpell(CURRENT_GENERIC_SPELL)) { if (current->getState() != SPELL_STATE_FINISHED && (withDelayed || current->getState() != SPELL_STATE_DELAYED)) return true; } - // channeled spells may be delayed, but they are still considered casted + // channeled spells may be delayed, but they are still considered cast else if (!skipChanneled) { if (Spell* current = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) @@ -3449,7 +3482,7 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip } } - // autorepeat spells may be finished or delayed, but they are still considered casted + // autorepeat spells may be finished or delayed, but they are still considered cast else if (!skipAutorepeat && GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)) return true; @@ -3459,22 +3492,22 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withInstant) { // generic spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo()->Id==spell_id)) + if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry()->Id==spell_id)) InterruptSpell(CURRENT_GENERIC_SPELL,withDelayed,withInstant); // autorepeat spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellInfo()->Id==spell_id)) + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->GetSpellEntry()->Id==spell_id)) InterruptSpell(CURRENT_AUTOREPEAT_SPELL,withDelayed,withInstant); // channeled spells are interrupted if they are not finished, even if they are delayed - if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->GetSpellInfo()->Id==spell_id)) + if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->GetSpellEntry()->Id==spell_id)) InterruptSpell(CURRENT_CHANNELED_SPELL,true,true); } Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const { for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - if (m_currentSpells[i] && m_currentSpells[i]->GetSpellInfo()->Id==spell_id) + if (m_currentSpells[i] && m_currentSpells[i]->GetSpellEntry()->Id==spell_id) return m_currentSpells[i]; return NULL; } @@ -3777,7 +3810,7 @@ bool Unit::AddAura(Aura *Aur) return false; } - SpellEntry const* aurSpellInfo = Aur->GetSpellProto(); + SpellEntry const* aurSpellEntry = Aur->GetSpellProto(); spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); @@ -3788,7 +3821,7 @@ bool Unit::AddAura(Aura *Aur) bool isDotOrHot = false; for (uint8 i = 0; i < 3; i++) { - switch (aurSpellInfo->EffectApplyAuraName[i]) + switch (aurSpellEntry->EffectApplyAuraName[i]) { // DOT or HOT from different casters will stack case SPELL_AURA_PERIODIC_DAMAGE: @@ -3820,7 +3853,7 @@ bool Unit::AddAura(Aura *Aur) continue; } - if (aurSpellInfo->Id == 28093 || aurSpellInfo->Id == 20007) // Allow mongoose procs from different weapons stack + if (aurSpellEntry->Id == 28093 || aurSpellEntry->Id == 20007) // Allow mongoose procs from different weapons stack { if (Aur->GetCastItemGUID() != i2->second->GetCastItemGUID()) { @@ -3834,17 +3867,17 @@ bool Unit::AddAura(Aura *Aur) if (!stackModified) { // replace aura if next will > spell StackAmount - if (aurSpellInfo->StackAmount) + if (aurSpellEntry->StackAmount) { // prevent adding stack more than once stackModified = true; Aur->SetStackAmount(i2->second->GetStackAmount()); Aur->SetPeriodicTimer(i2->second->GetPeriodicTimer()); - if (Aur->GetStackAmount() < aurSpellInfo->StackAmount) + if (Aur->GetStackAmount() < aurSpellEntry->StackAmount) Aur->SetStackAmount(Aur->GetStackAmount()+1); } - // this will allow to stack dots and hots casted by different creatures - if(i2->second->GetCasterGUID() == Aur->GetCasterGUID() || Aur->StackNotByCaster() || aurSpellInfo->StackAmount) + // this will allow to stack dots and hots cast by different creatures + if(i2->second->GetCasterGUID() == Aur->GetCasterGUID() || Aur->StackNotByCaster() || aurSpellEntry->StackAmount) { RemoveAura(i2, AURA_REMOVE_BY_STACK); i2 = m_Auras.lower_bound(spair); @@ -3889,7 +3922,7 @@ bool Unit::AddAura(Aura *Aur) for (AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr) { if ((*itr)->GetTarget() != Aur->GetTarget() && - SpellMgr::IsSingleTargetSpells((*itr)->GetSpellProto(),aurSpellInfo)) + SpellMgr::IsSingleTargetSpells((*itr)->GetSpellProto(),aurSpellEntry)) { if ((*itr)->IsInUse()) { @@ -4128,6 +4161,25 @@ void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID) } } +void Unit::RemoveAurasWithFamilyFlagsAndTypeByCaster(uint32 familyName, uint64 familyFlags, AuraType aurType, uint64 casterGUID) +{ + Unit::AuraList const& auras = GetAurasByType(aurType); + for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end();) + { + if ((*itr)->GetCasterGUID() == casterGUID) + { + SpellEntry const* itr_spell = (*itr)->GetSpellProto(); + if (itr_spell && itr_spell->SpellFamilyName == familyName && (itr_spell->SpellFamilyFlags & familyFlags)) + { + RemoveAurasDueToSpell(itr_spell->Id); + itr = auras.begin(); + continue; + } + } + ++itr; + } +} + void Unit::SetAurasDurationByCasterSpell(uint32 spellId, uint64 casterGUID, int32 duration) { for (uint8 i = 0; i < 3; ++i) @@ -4467,7 +4519,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) m_Auras.erase(i); ++m_removedAurasCount; // internal count used by unit update - SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); + SpellEntry const* AurSpellEntry = Aur->GetSpellProto(); Unit* caster = NULL; Aur->UnregisterSingleCastAura(); @@ -4495,7 +4547,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) // Statue unsummoned at aura remove Totem* statue = NULL; bool channeled = false; - if (Aur->GetAuraDuration() && !Aur->IsPersistent() && SpellMgr::IsChanneledSpell(AurSpellInfo)) + if (Aur->GetAuraDuration() && !Aur->IsPersistent() && SpellMgr::IsChanneledSpell(AurSpellEntry)) { if (!caster) // can be already located for IsSingleTargetSpell case caster = Aur->GetCaster(); @@ -4507,12 +4559,12 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) //prevent recurential call && caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) { - if (caster==this || !SpellMgr::IsAreaOfEffectSpell(AurSpellInfo)) + if (caster==this || !SpellMgr::IsAreaOfEffectSpell(AurSpellEntry)) { // remove auras only for non-aoe spells or when chanelled aura is removed // because aoe spells don't require aura on target to continue - if (AurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]!=SPELL_AURA_PERIODIC_DUMMY - && AurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]!= SPELL_AURA_DUMMY) + if (AurSpellEntry->EffectApplyAuraName[Aur->GetEffIndex()]!=SPELL_AURA_PERIODIC_DUMMY + && AurSpellEntry->EffectApplyAuraName[Aur->GetEffIndex()]!= SPELL_AURA_DUMMY) //don't stop channeling of scripted spells (this is actually a hack) { caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); @@ -4530,10 +4582,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) { for (int i = 0; i < 3; ++i) { - if (AurSpellInfo->Effect[i] == SPELL_EFFECT_SUMMON && - (AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED || - AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED2 || - AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED3)) + if (AurSpellEntry->Effect[i] == SPELL_EFFECT_SUMMON && + (AurSpellEntry->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED || + AurSpellEntry->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED2 || + AurSpellEntry->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED3)) { ((Player*)caster)->StopCastingCharm(); break; @@ -5519,7 +5571,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu } else if (dummySpell->SpellIconID == 1697) // Second Wind { - // only for spells and hit/crit (trigger start always) and not start from self casted spells (5530 Mace Stun Effect for example) + // only for spells and hit/crit (trigger start always) and not start from self cast spells (5530 Mace Stun Effect for example) if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) return false; // Need stun or root mechanic @@ -5631,7 +5683,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu return false; // heal amount - basepoints0 = damage * triggeredByAura->GetModifier()->m_amount/100; + basepoints0 = damage * 0.01 * triggeredByAura->GetModifier()->m_amount; triggered_spell_id = 37382; break; } @@ -6216,7 +6268,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu basepoints0 = triggeredByAura->GetModifier()->m_amount; triggered_spell_id = 379; - // Adding cooldown to earth shield caster, so earth shield casted on creature still will have cooldown + // Adding cooldown to earth shield caster, so earth shield cast on creature still will have cooldown if (Unit *caster = triggeredByAura->GetCaster()) if (caster->GetTypeId() == TYPEID_PLAYER && cooldown) { @@ -6325,13 +6377,13 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) { // Get triggered aura spell info - SpellEntry const* auraSpellInfo = triggeredByAura->GetSpellProto(); + SpellEntry const* auraSpellEntry = triggeredByAura->GetSpellProto(); // Basepoints of trigger aura int32 triggerAmount = triggeredByAura->GetModifier()->m_amount; // Set trigger spell id, target, custom basepoints - uint32 trigger_spell_id = auraSpellInfo->EffectTriggerSpell[triggeredByAura->GetEffIndex()]; + uint32 trigger_spell_id = auraSpellEntry->EffectTriggerSpell[triggeredByAura->GetEffIndex()]; Unit* target = NULL; int32 basepoints0 = 0; @@ -6341,9 +6393,12 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; + if (castItem && !isAlive()) + return false; + // Try handle unknown trigger spells if (sSpellStore.LookupEntry(trigger_spell_id) == NULL) - switch (auraSpellInfo->SpellFamilyName) + switch (auraSpellEntry->SpellFamilyName) { //===================================================================== // Generic class @@ -6351,58 +6406,58 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // ..... //===================================================================== case SPELLFAMILY_GENERIC: -// if (auraSpellInfo->Id==34082) // Advantaged State (DND) +// if (auraSpellEntry->Id==34082) // Advantaged State (DND) // trigger_spell_id = ???; - if (auraSpellInfo->Id == 23780) // Aegis of Preservation (Aegis of Preservation trinket) + if (auraSpellEntry->Id == 23780) // Aegis of Preservation (Aegis of Preservation trinket) trigger_spell_id = 23781; -// else if (auraSpellInfo->Id==43504) // Alterac Valley OnKill Proc Aura +// else if (auraSpellEntry->Id==43504) // Alterac Valley OnKill Proc Aura // trigger_spell_id = ; -// else if (auraSpellInfo->Id==37030) // Chaotic Temperament +// else if (auraSpellEntry->Id==37030) // Chaotic Temperament // trigger_spell_id = ; - else if (auraSpellInfo->Id==43820) // Charm of the Witch Doctor (Amani Charm of the Witch Doctor trinket) + else if (auraSpellEntry->Id==43820) // Charm of the Witch Doctor (Amani Charm of the Witch Doctor trinket) { // Pct value stored in dummy - basepoints0 = pVictim->GetCreateHealth() * auraSpellInfo->EffectBasePoints[1] / 100; + basepoints0 = pVictim->GetCreateHealth() * auraSpellEntry->EffectBasePoints[1] / 100; target = pVictim; break; } - else if (auraSpellInfo->Id==41248) // Consuming Strikes + else if (auraSpellEntry->Id==41248) // Consuming Strikes { basepoints0 = damage; target = pVictim; trigger_spell_id = 41249; } -// else if (auraSpellInfo->Id==41054) // Copy Weapon +// else if (auraSpellEntry->Id==41054) // Copy Weapon // trigger_spell_id = 41055; -// else if (auraSpellInfo->Id==31255) // Deadly Swiftness (Rank 1) +// else if (auraSpellEntry->Id==31255) // Deadly Swiftness (Rank 1) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==5301) // Defensive State (DND) +// else if (auraSpellEntry->Id==5301) // Defensive State (DND) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==13358) // Defensive State (DND) +// else if (auraSpellEntry->Id==13358) // Defensive State (DND) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==16092) // Defensive State (DND) +// else if (auraSpellEntry->Id==16092) // Defensive State (DND) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==24949) // Defensive State 2 (DND) +// else if (auraSpellEntry->Id==24949) // Defensive State 2 (DND) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==40329) // Demo Shout Sensor +// else if (auraSpellEntry->Id==40329) // Demo Shout Sensor // trigger_spell_id = ; // Desperate Defense (Stonescythe Whelp, Stonescythe Alpha, Stonescythe Ambusher) - else if (auraSpellInfo->Id == 33896) + else if (auraSpellEntry->Id == 33896) trigger_spell_id = 33898; -// else if (auraSpellInfo->Id==18943) // Double Attack +// else if (auraSpellEntry->Id==18943) // Double Attack // trigger_spell_id = ; -// else if (auraSpellInfo->Id==19194) // Double Attack +// else if (auraSpellEntry->Id==19194) // Double Attack // trigger_spell_id = ; -// else if (auraSpellInfo->Id==19817) // Double Attack +// else if (auraSpellEntry->Id==19817) // Double Attack // trigger_spell_id = ; -// else if (auraSpellInfo->Id==19818) // Double Attack +// else if (auraSpellEntry->Id==19818) // Double Attack // trigger_spell_id = ; -// else if (auraSpellInfo->Id==22835) // Drunken Rage +// else if (auraSpellEntry->Id==22835) // Drunken Rage // trigger_spell_id = 14822; /* - else if (auraSpellInfo->SpellIconID==191) // Elemental Response + else if (auraSpellEntry->SpellIconID==191) // Elemental Response { - switch (auraSpellInfo->Id && auraSpellInfo->AttributesEx==0) + switch (auraSpellEntry->Id && auraSpellEntry->AttributesEx==0) { case 34191: case 34329: @@ -6410,7 +6465,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case 34582: case 36733:break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Elemental Response",auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Elemental Response",auraSpellEntry->Id); return false; } //This generic aura self-triggers a different spell for each school of magic that lands on the wearer: @@ -6424,32 +6479,32 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELL_SCHOOL_HOLY: trigger_spell_id = 34197;break;//Holy: 34197 case SPELL_SCHOOL_NORMAL: trigger_spell_id = 34198;break;//Physical: 34198 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u Elemental Response wrong school",auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u Elemental Response wrong school",auraSpellEntry->Id); return false; } }*/ -// else if (auraSpellInfo->Id==6542) // Enraged Defense +// else if (auraSpellEntry->Id==6542) // Enraged Defense // trigger_spell_id = ; -// else if (auraSpellInfo->Id==40364) // Entangling Roots Sensor +// else if (auraSpellEntry->Id==40364) // Entangling Roots Sensor // trigger_spell_id = ; -// else if (auraSpellInfo->Id==33207) // Gossip NPC Periodic - Fidget +// else if (auraSpellEntry->Id==33207) // Gossip NPC Periodic - Fidget // trigger_spell_id = ; -// else if (auraSpellInfo->Id==35321) // Gushing Wound +// else if (auraSpellEntry->Id==35321) // Gushing Wound // trigger_spell_id = ; -// else if (auraSpellInfo->Id==38363) // Gushing Wound +// else if (auraSpellEntry->Id==38363) // Gushing Wound // trigger_spell_id = ; -// else if (auraSpellInfo->Id==39215) // Gushing Wound +// else if (auraSpellEntry->Id==39215) // Gushing Wound // trigger_spell_id = ; -// else if (auraSpellInfo->Id==40250) // Improved Duration +// else if (auraSpellEntry->Id==40250) // Improved Duration // trigger_spell_id = ; - else if (auraSpellInfo->Id == 24905) // Moonkin Form (Passive) + else if (auraSpellEntry->Id == 24905) // Moonkin Form (Passive) { // Elune's Touch (instead non-existed triggered spell) 30% from AP trigger_spell_id = 33926; basepoints0 = GetTotalAttackPowerValue(BASE_ATTACK) * 30 / 100; target = this; } - else if (auraSpellInfo->Id == 46939 || auraSpellInfo->Id == 27522) + else if (auraSpellEntry->Id == 46939 || auraSpellEntry->Id == 27522) { // On successful melee or ranged attack gain $29471s1 mana and if possible drain $27526s1 mana from the target. if (pVictim && pVictim->GetPower(POWER_MANA)) @@ -6458,20 +6513,20 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB CastSpell(this, 29471, true, castItem, triggeredByAura); return true; } -// else if (auraSpellInfo->Id==43453) // Rune Ward +// else if (auraSpellEntry->Id==43453) // Rune Ward // trigger_spell_id = ; -// else if (auraSpellInfo->Id==7137) // Shadow Charge (Rank 1) +// else if (auraSpellEntry->Id==7137) // Shadow Charge (Rank 1) // trigger_spell_id = ; // Shaleskin (Shaleskin Flayer, Shaleskin Ripper) 30023 trigger -// else if (auraSpellInfo->Id==36576) +// else if (auraSpellEntry->Id==36576) // trigger_spell_id = ; -// else if (auraSpellInfo->Id==34783) // Spell Reflection +// else if (auraSpellEntry->Id==34783) // Spell Reflection // trigger_spell_id = ; -// else if (auraSpellInfo->Id==36096) // Spell Reflection +// else if (auraSpellEntry->Id==36096) // Spell Reflection // trigger_spell_id = ; -// else if (auraSpellInfo->Id==36207) // Steal Weapon +// else if (auraSpellEntry->Id==36207) // Steal Weapon // trigger_spell_id = ; -// else if (auraSpellInfo->Id==35205) // Vanish +// else if (auraSpellEntry->Id==35205) // Vanish break; //===================================================================== // Mage @@ -6480,16 +6535,16 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB //===================================================================== case SPELLFAMILY_MAGE: // Blazing Speed - if (auraSpellInfo->SpellIconID == 2127) + if (auraSpellEntry->SpellIconID == 2127) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 31641: // Rank 1 case 31642: // Rank 2 trigger_spell_id = 31643; break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Blazing Speed",auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Blazing Speed",auraSpellEntry->Id); return false; } } @@ -6501,15 +6556,15 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB //===================================================================== case SPELLFAMILY_WARRIOR: // Rampage - if (auraSpellInfo->SpellIconID == 2006 && auraSpellInfo->SpellFamilyFlags==0x100000) + if (auraSpellEntry->SpellIconID == 2006 && auraSpellEntry->SpellFamilyFlags==0x100000) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 29801: trigger_spell_id = 30029; break; // Rank 1 case 30030: trigger_spell_id = 30031; break; // Rank 2 case 30033: trigger_spell_id = 30032; break; // Rank 3 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in Rampage",auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in Rampage",auraSpellEntry->Id); return false; } } @@ -6523,7 +6578,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELLFAMILY_WARLOCK: { // Pyroclasm - if (auraSpellInfo->SpellIconID == 1137) + if (auraSpellEntry->SpellIconID == 1137) { if (!pVictim || !pVictim->isAlive() || pVictim == this || procSpell == NULL) return false; @@ -6541,7 +6596,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // Calculate chance = baseChance / tick float chance = 0; - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 18096: chance = 13.0f / tick; break; case 18073: chance = 26.0f / tick; break; @@ -6553,7 +6608,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB trigger_spell_id = 18093; } // Drain Soul - else if (auraSpellInfo->SpellFamilyFlags & 0x0000000000004000LL) + else if (auraSpellEntry->SpellFamilyFlags & 0x0000000000004000LL) { Unit::AuraList const& mAddFlatModifier = GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER); for (Unit::AuraList::const_iterator i = mAddFlatModifier.begin(); i != mAddFlatModifier.end(); ++i) @@ -6580,12 +6635,12 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELLFAMILY_PRIEST: { // Greater Heal Refund - if (auraSpellInfo->Id==37594) + if (auraSpellEntry->Id==37594) trigger_spell_id = 37595; // Shadowguard - else if (auraSpellInfo->SpellFamilyFlags==0x100080000000LL && auraSpellInfo->SpellVisual==7958) + else if (auraSpellEntry->SpellFamilyFlags==0x100080000000LL && auraSpellEntry->SpellVisual==7958) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 18137: trigger_spell_id = 28377; break; // Rank 1 case 19308: trigger_spell_id = 28378; break; // Rank 2 @@ -6595,20 +6650,20 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case 19312: trigger_spell_id = 28382; break; // Rank 6 case 25477: trigger_spell_id = 28385; break; // Rank 7 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in SG", auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in SG", auraSpellEntry->Id); return false; } } // Blessed Recovery - else if (auraSpellInfo->SpellIconID == 1875) + else if (auraSpellEntry->SpellIconID == 1875) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 27811: trigger_spell_id = 27813; break; case 27815: trigger_spell_id = 27817; break; case 27816: trigger_spell_id = 27818; break; default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in BR", auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in BR", auraSpellEntry->Id); return false; } basepoints0 = damage * triggerAmount / 100 / 3; @@ -6626,7 +6681,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELLFAMILY_DRUID: { // Druid Forms Trinket - if (auraSpellInfo->Id==37336) + if (auraSpellEntry->Id==37336) { switch (m_form) { @@ -6640,10 +6695,10 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return false; } } -// else if (auraSpellInfo->Id==40363)// Entangling Roots () +// else if (auraSpellEntry->Id==40363)// Entangling Roots () // trigger_spell_id = ????; // Leader of the Pack - else if (auraSpellInfo->Id == 24932) + else if (auraSpellEntry->Id == 24932) { if (triggerAmount == 0) return false; @@ -6658,7 +6713,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // ...... //===================================================================== //case SPELLFAMILY_HUNTER: - // switch (auraSpellInfo->Id) + // switch (auraSpellEntry->Id) // { // } //break; @@ -6675,15 +6730,15 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELLFAMILY_PALADIN: { // Healing Discount - if (auraSpellInfo->Id==37705) + if (auraSpellEntry->Id==37705) { trigger_spell_id = 37706; target = this; } // Judgement of Light and Judgement of Wisdom - else if (auraSpellInfo->SpellFamilyFlags & 0x0000000000080000LL) + else if (auraSpellEntry->SpellFamilyFlags & 0x0000000000080000LL) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { // Judgement of Light case 20185: trigger_spell_id = 20267;break; // Rank 1 @@ -6697,7 +6752,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case 20355: trigger_spell_id = 20353;break; // Rank 3 case 27164: trigger_spell_id = 27165;break; // Rank 4 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Judgement of Light/Wisdom", auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u miss posibly Judgement of Light/Wisdom", auraSpellEntry->Id); return false; } @@ -6712,7 +6767,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // Improved Judgement of Light: bonus heal from t4 set if (Unit *caster = triggeredByAura->GetCaster()) { - if (auraSpellInfo->SpellIconID == 299) + if (auraSpellEntry->SpellIconID == 299) { if (Aura *aur = caster->GetAura(37182, 0)) { @@ -6725,11 +6780,11 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return true; // no hidden cooldown } // Illumination - else if (auraSpellInfo->SpellIconID==241) + else if (auraSpellEntry->SpellIconID==241) { if (!procSpell) return false; - // procspell is triggered spell but we need mana cost of original casted spell + // procspell is triggered spell but we need mana cost of original cast spell uint32 originalSpellId = procSpell->Id; // Holy Shock if (procSpell->SpellFamilyFlags & 0x1000000000000LL) // Holy Shock heal @@ -6753,12 +6808,12 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return false; } // percent stored in effect 1 (class scripts) base points - basepoints0 = originalSpell->manaCost*(auraSpellInfo->EffectBasePoints[1]+1)/100; + basepoints0 = originalSpell->manaCost*(auraSpellEntry->EffectBasePoints[1]+1)/100; trigger_spell_id = 20272; target = this; } // Lightning Capacitor - else if (auraSpellInfo->Id==37657) + else if (auraSpellEntry->Id==37657) { if (!pVictim || !pVictim->isAlive()) return false; @@ -6768,8 +6823,6 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB if (ToPlayer()->HasSpellCooldown(trigger_spell_id)) return false; - ToPlayer()->AddSpellCooldown(trigger_spell_id,0, time(NULL) + cooldown); - // stacking CastSpell(this, 37658, true, NULL, triggeredByAura); // counting @@ -6783,7 +6836,6 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB RemoveAurasDueToSpell(37658); target = pVictim; - cooldown = 0; } break; } @@ -6797,9 +6849,9 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case SPELLFAMILY_SHAMAN: { //Lightning Shield (overwrite non existing triggered spell call in spell.dbc - if (auraSpellInfo->SpellFamilyFlags==0x00000400 && auraSpellInfo->SpellVisual==37) + if (auraSpellEntry->SpellFamilyFlags==0x00000400 && auraSpellEntry->SpellVisual==37) { - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { case 324: trigger_spell_id = 26364; break; // Rank 1 case 325: trigger_spell_id = 26365; break; // Rank 2 @@ -6811,21 +6863,21 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case 25469: trigger_spell_id = 26371; break; // Rank 8 case 25472: trigger_spell_id = 26372; break; // Rank 9 default: - sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in LShield", auraSpellInfo->Id); + sLog.outLog(LOG_DEFAULT, "ERROR: Unit::HandleProcTriggerSpell: Spell %u not handled in LShield", auraSpellEntry->Id); return false; } } // Lightning Shield (The Ten Storms set) - else if (auraSpellInfo->Id == 23551) + else if (auraSpellEntry->Id == 23551) { trigger_spell_id = 23552; target = pVictim; } // Damage from Lightning Shield (The Ten Storms set) - else if (auraSpellInfo->Id == 23552) + else if (auraSpellEntry->Id == 23552) trigger_spell_id = 27635; // Mana Surge (The Earthfury set) - else if (auraSpellInfo->Id == 23572) + else if (auraSpellEntry->Id == 23572) { if (!procSpell) return false; @@ -6833,7 +6885,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB trigger_spell_id = 23571; target = this; } - else if (auraSpellInfo->SpellIconID == 2013) //Nature's Guardian + else if (auraSpellEntry->SpellIconID == 2013) //Nature's Guardian { // Check health condition - should drop to less 30% (damage deal after this!) if (!(10*(int32(GetHealth() - damage)) < 3 * GetMaxHealth())) @@ -6858,7 +6910,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB if (triggerEntry == NULL) { // Not cast unknown spell - sLog.outDebug("Unit::HandleProcTriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex()); + sLog.outDebug("Unit::HandleProcTriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",auraSpellEntry->Id,triggeredByAura->GetEffIndex()); return false; } @@ -6887,7 +6939,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // Custom requirements (not listed in procEx) Warning! damage dealing after this // Custom triggered spells - switch (auraSpellInfo->Id) + switch (auraSpellEntry->Id) { // Persistent Shield (Scarab Brooch trinket) // This spell originally trigger 13567 - Dummy Trigger (vs dummy effect) @@ -6979,17 +7031,22 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB } else if (!(procFlags & (PROC_FLAG_TAKEN_MELEE_HIT | PROC_FLAG_TAKEN_MELEE_SPELL_HIT))) return false; + break; } // Trinket - Hand of Justice case 15600: { float chance = 0; chance = 6.02-0.067*getLevel(); - if (!roll_chance_f(chance)) + if (roll_chance_f(chance)) + { + trigger_spell_id = 15601; + break; + } + else + { return false; - - trigger_spell_id = 15601; - + } break; } } @@ -7026,7 +7083,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB case 14157: // Ruthlessness { // avoid double proc, and dont proc from deadly throw - if (procSpell->Id == 26679 || pVictim == this) + if (procSpell->Id == 26679 || !pVictim || pVictim == this) return false; break; } @@ -7053,6 +7110,13 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return false; break; } + //Gift of the Doomsayer + case 36174: + case 39011: + { + target = triggeredByAura ? triggeredByAura->GetCaster() : NULL; + break; + } case 41914: case 41917: { @@ -7570,7 +7634,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if (meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING)) { addUnitState(UNIT_STAT_MELEE_ATTACKING); - SendMeleeAttackStart(victim); + SendMeleeAttackStart(victim->GetGUID()); return true; } return false; @@ -7628,7 +7692,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) resetAttackTimer(OFF_ATTACK); if (meleeAttack) - SendMeleeAttackStart(victim); + SendMeleeAttackStart(victim->GetGUID()); return true; } @@ -7638,10 +7702,7 @@ bool Unit::AttackStop() if (!m_attacking) return false; - Unit* victim = m_attacking; - m_attacking->_removeAttacker(this); - m_attacking = NULL; //Clear our target SetUInt64Value(UNIT_FIELD_TARGET, 0); @@ -7657,14 +7718,15 @@ bool Unit::AttackStop() ((Creature*)this)->SetNoSearchAssistance(false); } - SendMeleeAttackStop(victim); + SendMeleeAttackStop(m_attacking->GetGUID()); + m_attacking = NULL; return true; } void Unit::CombatStop(bool cast) { - if (cast && IsNonMeleeSpellCasted(false)) + if (cast && IsNonMeleeSpellCast(false)) InterruptNonMeleeSpells(false); AttackStop(); @@ -8032,7 +8094,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 TakenTotalMod *= ((*i)->GetModifierValue() +100.0f)/100.0f; // .. taken pct: scripted (increases damage of * against targets *) - AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { switch ((*i)->GetModifier()->m_miscvalue) @@ -8094,6 +8156,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 { case SPELLFAMILY_GENERIC: // Siphon Essence - 0% + if (spellProto->Id == 40293) + { + CastingTime = 0; + } // Darkmoon Card: Vengeance - 0.1% if (spellProto->SpellVisual == 9850 && spellProto->SpellIconID == 2230) { @@ -8130,6 +8196,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Fireball - 100% of Fire Damage, DoT - 0% of Fire Damage else if ((spellProto->SpellFamilyFlags & 0x1LL) && spellProto->SpellIconID == 185) { + DotFactor = damagetype == DOT ? 0.0f : 1.0f; CastingTime = damagetype == DOT ? 0 : 3500; } // Arcane Missiles triggered spell @@ -8469,7 +8536,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM // scripted (increase crit chance ... against ... target by x% if (pVictim->isFrozen()) // Shatter { - AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { switch ((*i)->GetModifier()->m_miscvalue) @@ -8501,8 +8568,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM default: return false; } - // percent done - // only players use intelligence for critical chance computations + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, extraChance); @@ -8573,7 +8639,8 @@ uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, spellProto->Id == 22845 || spellProto->Id == 33504 || spellProto->Id == 34299 || spellProto->Id == 27813 || spellProto->Id == 27817 || spellProto->Id == 27818 || - spellProto->Id == 5707 || spellProto->Id == 33110) + spellProto->Id == 5707 || spellProto->Id == 33110 || + spellProto->Id == 37382 || spellProto->Id == 25608) return healamount*TotalMod; int32 AdvertisedBenefit = SpellBaseHealingBonus(SpellMgr::GetSpellSchoolMask(spellProto)); @@ -8622,7 +8689,7 @@ uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, // Lesser Healing Wave if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags & 0x80) { - AuraList const& classScriptsAuras = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& classScriptsAuras = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (AuraList::const_iterator i = classScriptsAuras.begin(); i != classScriptsAuras.end(); i++) { // Increased Lesser Healing Wave (few items has this effect) @@ -8860,14 +8927,15 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) if (!spellInfo) return false; - // If Spel has this flag cannot be resisted/immuned/etc + // If spell has this flag, it cannot be resisted/immuned/etc if (spellInfo->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) return false; - SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; - for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) - if (itr->type == spellInfo->Dispel) - return true; + SpellImmuneList const& stateList = m_spellImmune[IMMUNITY_STATE]; + for (SpellImmuneList::const_iterator itr = stateList.begin(); itr != stateList.end(); ++itr) + for (uint32 i = 0; i < 3; ++i) + if (itr->type == spellInfo->EffectApplyAuraName[i]) + return true; if (!(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity !(spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) // can remove immune (by dispell or immune it) @@ -8880,23 +8948,20 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) return true; } + SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; + for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) + if (itr->type == spellInfo->Dispel) + return true; + SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - { if (itr->type == spellInfo->Mechanic) - { return true; - } - } SpellImmuneList const& idList = m_spellImmune[IMMUNITY_ID]; for (SpellImmuneList::const_iterator itr = idList.begin(); itr != idList.end(); ++itr) - { if (itr->type == spellInfo->Id) - { return true; - } - } return false; } @@ -8969,9 +9034,37 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT float TakenTotalMod = 1; // ..done - // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage + // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage. BUT for other spellschools than physical - must be applied. (example - paladins seal of command + sanctity aura) // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage + if (spellProto && (SpellMgr::GetSpellSchoolMask(spellProto) & GetMeleeDamageSchoolMask()) == 0) + { + AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + for (AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) + { + switch ((*i)->GetId()) + { + case 6057: // M Wand Spec 1 + case 6085: // M Wand Spec 2 + case 14524: // P Wand Spec 1 + case 14525: // P Wand Spec 2 + case 14526: // P Wand Spec 3 + case 14527: // P Wand Spec 4 + case 14528: // P Wand Spec 5 + //if (spellProto->Id != 5019) // Wand Shoot - Has spellschoolmask PHYSICAL - so always continue; + continue; + default: + break; + } + + if (((*i)->GetModifier()->m_miscvalue & SpellMgr::GetSpellSchoolMask(spellProto)) && + (GetTypeId() != TYPEID_PLAYER || ((Player*)this)->HasItemFitToSpellReqirements((*i)->GetSpellProto()))) + { + DoneTotalMod *= ((*i)->GetModifierValue() +100.0f)/100.0f; + } + } + } + AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for (AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) if (creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) @@ -9017,7 +9110,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT } // .. taken pct: class scripts - AuraList const& mclassScritAuras = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mclassScritAuras = GetAurasByType(SPELL_AURA_override_CLASS_SCRIPTS); for (AuraList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i) { switch ((*i)->GetMiscValue()) @@ -9265,11 +9358,14 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) if (GetTypeId() == TYPEID_PLAYER) { - if (GetCurrentSpell(CURRENT_GENERIC_SPELL) && GetCurrentSpell(CURRENT_GENERIC_SPELL)->getState() != SPELL_STATE_FINISHED) - { - if (GetCurrentSpellProto(CURRENT_GENERIC_SPELL)->Attributes & SPELL_ATTR_CANT_USED_IN_COMBAT) + // used by eluna + sHookMgr->OnPlayerEnterCombat(ToPlayer(), enemy); + + if (Spell *spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) + if (spell->getState() != SPELL_STATE_FINISHED && + spell->GetSpellEntry()->Attributes & SPELL_ATTR_CANT_USED_IN_COMBAT && + spell->GetSpellEntry()->SpellFamilyName != SPELLFAMILY_WARRIOR) InterruptSpell(CURRENT_GENERIC_SPELL); - } if (Pet* pet = GetPet()) pet->SetInCombatState(PvP, enemy); @@ -9316,6 +9412,10 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + // used by eluna + if (GetTypeId() == TYPEID_PLAYER) + sHookMgr->OnPlayerLeaveCombat(ToPlayer()); + // Player's state will be cleared in Player::UpdateContestedPvP if (Creature *creature = ToCreature()) { @@ -9331,13 +9431,21 @@ void Unit::ClearInCombat() if (Unit *owner = GetOwner()) { for (int i = 0; i < MAX_MOVE_TYPE; ++i) - SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true); + { + float owner_speed = owner->GetSpeedRate(UnitMoveType(i)); + int32 owner_slow = owner->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); + int32 owner_slow_non_stack = owner->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK); + owner_slow = owner_slow < owner_slow_non_stack ? owner_slow : owner_slow_non_stack; + if (owner_slow) + owner_speed *=100.0f/(100.0f + owner_slow); // now we have owners speed without slow + SetSpeed(UnitMoveType(i), owner_speed*1.15f, true); + return; + } } } else if (!isCharmed()) return; - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } @@ -9410,7 +9518,9 @@ bool Unit::isAttackableByAOE() const int32 Unit::ModifyHealth(int32 dVal) { - if (GetTypeId() == TYPEID_UNIT && (((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_DAMAGE_TAKEN)) + if (dVal < 0 && GetTypeId() == TYPEID_UNIT && (((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_DAMAGE_TAKEN)) + return 0; + if (dVal > 0 && GetTypeId() == TYPEID_UNIT && (((Creature *)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_HEALING_TAKEN)) return 0; int32 gain = 0; @@ -9672,10 +9782,17 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) if (GetTypeId() == TYPEID_UNIT && ToCreature()->isPet() && hasUnitState(UNIT_STAT_FOLLOW) && !isInCombat()) { if (Unit* owner = GetOwner()) - { - SetSpeed(mtype, owner->GetSpeedRate(mtype) *1.15f, forced); - return; - } + if (!owner->isInCombat()) + { + float owner_speed = owner->GetSpeedRate(mtype); + int32 owner_slow = owner->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); + int32 owner_slow_non_stack = owner->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK); + owner_slow = owner_slow < owner_slow_non_stack ? owner_slow : owner_slow_non_stack; + if (owner_slow) + owner_speed *=100.0f/(100.0f + owner_slow); // now we have owners speed without slow + SetSpeed(mtype, owner_speed*1.15f, forced); + return; + } } break; default: @@ -9723,11 +9840,13 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) if(HasAuraType(SPELL_AURA_MOD_SPEED_MOUNTED)) // Use for Ragged Flying Carpet & MgT Kael'thas Gravity Lapse main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_SPEED_MOUNTED); else if (IsMounted()) // Use on mount auras + { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); - else // Use not mount (shapeshift for example) auras (should stack) + stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS); + non_stack_bonus = (100.0 + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK))/100.0f; + } + else // Use not mount (only used in flight form, swift flight form, charm of swift flight); flight forms are not afected by any other effects. main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_SPEED_FLIGHT); - stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS); - non_stack_bonus = (100.0 + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK))/100.0f; break; } case MOVE_FLIGHT_BACK: @@ -9855,10 +9974,10 @@ void Unit::setDeathState(DeathState s) { CombatStop(); DeleteThreatList(); - getHostilRefManager().deleteReferences(); + getHostileRefManager().deleteReferences(); ClearComboPointHolders(); // any combo points pointed to unit lost at it death - if (IsNonMeleeSpellCasted(false)) + if (IsNonMeleeSpellCast(false)) InterruptNonMeleeSpells(false); } @@ -9910,7 +10029,7 @@ bool Unit::CanHaveThreatList() const return false; // only alive units can have threat list - if (!isAlive()) + if (!isAlive() || isDying()) return false; // totems can not have threat list @@ -10036,10 +10155,13 @@ Unit* Creature::SelectVictim() if (!HasAuraType(SPELL_AURA_MOD_TAUNT)) target = getThreatManager().getHostilTarget(); else - target = getVictim(); + return getVictim(); } } + if (IsOutOfThreatArea(target)) + target = NULL; + if (target) { if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CANNOT_TURN)) @@ -10058,7 +10180,7 @@ Unit* Creature::SelectVictim() // search nearby enemy before enter evade mode if (HasReactState(REACT_AGGRESSIVE)) { - target = SelectNearestTarget(45.0f); + target = SelectNearestTarget(25.0f); if (target && !IsOutOfThreatArea(target)) return target; } @@ -10109,12 +10231,12 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel); float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; - // prevent random generator from getting confused by spells casted with Unit::CastCustomSpell + // prevent random generator from getting confused by spells cast with Unit::CastCustomSpell int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:irand(spellProto->EffectBaseDice[effect_index], randomPoints); int32 value = basePoints + randvalue; // hacky formula for lowlvl spells with high spelldmg after spelllevel calc - if (getLevel() < 13 && GetObjectGuid().IsCreature() && value > int32(GetMaxHealth()*0.09) && !ToCreature()->isTrigger() && GetEntry() != WORLD_TRIGGER) + if (getLevel() < 13 && GetObjectGuid().IsCreature() && value > int32(GetMaxHealth()*0.09) && !ToCreature()->isTrigger() && GetEntry() != WORLD_TRIGGER && !(GetOwner() && GetOwner()->GetTypeId() == TYPEID_PLAYER)) value = int32(GetMaxHealth()*0.07); //random damage @@ -10202,7 +10324,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) if(group == DIMINISHING_ENSLAVE) return DiminishingLevels(i->hitCount); - // If last spell was casted more than 15 seconds ago - reset the count. + // If last spell was cast more than 15 seconds ago - reset the count. if (i->stack==0 && WorldTimer::getMSTimeDiff(i->hitTime,WorldTimer::getMSTime()) > 15000) { i->hitCount = DIMINISHING_LEVEL_1; @@ -10267,7 +10389,7 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un float mod = 1.0f; - // Some diminishings applies to mobs too (for example, Stun) // Freezing trap exception, since it is casted by GO ? + // Some diminishings applies to mobs too (for example, Stun) // Freezing trap exception, since it is cast by GO ? if ((SpellMgr::GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && (targetOwner ? targetOwner->GetTypeId() : GetTypeId()) == TYPEID_PLAYER) || SpellMgr::GetDiminishingReturnsGroupType(group) == DRTYPE_ALL || (spellInfo && spellInfo ->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo ->SpellFamilyFlags & 0x00000000008LL)) { DiminishingLevels diminish = Level; @@ -10782,7 +10904,7 @@ void Unit::RemoveFromWorld() // cleanup if (IsInWorld()) { - getHostilRefManager().deleteReferences(); + getHostileRefManager().deleteReferences(); RemoveBindSightAuras(); RemoveNotOwnSingleTargetAuras(); @@ -10806,11 +10928,11 @@ void Unit::CleanupsBeforeDelete() RemoveAllAuras(); InterruptNonMeleeSpells(true); - KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList + KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList CombatStop(); ClearComboPointHolders(); DeleteThreatList(); - getHostilRefManager().setOnlineOfflineState(false); + getHostileRefManager().setOnlineOfflineState(false); RemoveAllGameObjects(); RemoveAllDynObjects(); @@ -10825,7 +10947,7 @@ void Unit::UpdateCharmAI() if (i_disabledAI) // disabled AI must be primary AI { - if (!isCharmed() || GetEntry() == 24922) // allow Razorthorn Ravager to switch to ScriptedAI when charmed + if (!isCharmed() || GetEntry() == 24922) // allow Razorthorn Ravager to switch to CreatureAI when charmed { delete i_AI; @@ -10921,7 +11043,7 @@ void InitTriggerAuraData() isTriggerAura[SPELL_AURA_SPELL_MAGNET] = true; isTriggerAura[SPELL_AURA_MOD_ATTACK_POWER] = true; isTriggerAura[SPELL_AURA_ADD_CASTER_HIT_TRIGGER] = true; - isTriggerAura[SPELL_AURA_OVERRIDE_CLASS_SCRIPTS] = true; + isTriggerAura[SPELL_AURA_override_CLASS_SCRIPTS] = true; isTriggerAura[SPELL_AURA_MOD_MECHANIC_RESISTANCE] = true; isTriggerAura[SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS] = true; isTriggerAura[SPELL_AURA_MOD_HASTE] = true; @@ -10990,14 +11112,14 @@ void Unit::ProcDamageAndSpellfor (bool isVictim, Unit * pTarget, uint32 procFlag if (GetTypeId() == TYPEID_PLAYER) { // On melee based hit/miss/resist need update skill (for victim and attacker) - if (procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST)) + if (procExtra & (PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST|PROC_EX_IMMUNE)) { if (pTarget->GetTypeId() != TYPEID_PLAYER && !(pTarget->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_DAMAGE_TAKEN)) ((Player*)this)->UpdateCombatSkills(pTarget, attType, isVictim); } // Update defence if player is victim and parry/dodge/block if (isVictim && procExtra&(PROC_EX_DODGE|PROC_EX_PARRY|PROC_EX_BLOCK)) - ((Player*)this)->UpdateDefense(); + ((Player*)this)->UpdateCombatSkills(pTarget,attType,true); } // If exist crit/parry/dodge/block need update aura state (for victim and attacker) if (procExtra & (PROC_EX_CRITICAL_HIT|PROC_EX_PARRY|PROC_EX_DODGE|PROC_EX_BLOCK)) @@ -11153,7 +11275,7 @@ void Unit::ProcDamageAndSpellfor (bool isVictim, Unit * pTarget, uint32 procFlag continue; break; } - case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: + case SPELL_AURA_override_CLASS_SCRIPTS: { sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", spellInfo->Id,(isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId()); if (!HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell, cooldown)) @@ -11612,7 +11734,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply) uint32 Unit::GetCastingTimeForBonus(SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime) { - // Not apply this to creature casted spells with casttime==0 + // Not apply this to creature cast spells with casttime==0 if (CastingTime==0 && GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) return 3500; @@ -11944,7 +12066,7 @@ bool Unit::HandleMendingAuraProc(Aura* triggeredByAura) if (Unit* target = GetNextRandomRaidMember(radius)) { - // aura will applied from caster, but spell casted from current aura holder + // aura will applied from caster, but spell cast from current aura holder SpellModifier *mod = new SpellModifier; mod->op = SPELLMOD_CHARGES; mod->value = jumps-5; // negative @@ -12178,6 +12300,10 @@ void Unit::UpdateVisibilityAndView() void Unit::Kill(Unit *pVictim, bool durabilityLoss) { + // Prevent double kill the exact unit + if (!pVictim->GetHealth()) + return; + pVictim->SetHealth(0); // find player: owner of controlled `this` or `this` itself maybe @@ -12375,31 +12501,30 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) if (m->IsDungeon() && creditedPlayer) { - if (m->IsRaid() || m->IsHeroic()) + // log boss kills + if (creatureVictim->GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS) { - if (creatureVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) - ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); - - // Killer == Player - if (creditedPlayer && creatureVictim->GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS) + std::stringstream ss; + ss << "BossEntry: " << creatureVictim->GetEntry() << " InstanceId: " << creatureVictim->GetInstanceId() + << " MapId: " << m->GetId() << " Players: "; + if (Group *group = creditedPlayer->GetGroup()) { - Player *killer = creditedPlayer; - std::stringstream ss; - ss << "BossEntry: " << creatureVictim->GetEntry() << " InstanceId: " << creatureVictim->GetInstanceId() - << " MapId: " << m->GetId() << " Players: "; - if (Group *group = killer->GetGroup()) + for (GroupReference *i = group->GetFirstMember(); true; i = i->next()) { - for (GroupReference *i = group->GetFirstMember(); true; i = i->next()) - { - if (Player *member = i->getSource()) - ss << member->GetName() << ":(" << member->GetGUIDLow() << ") "; + if (Player *member = i->getSource()) + ss << member->GetName() << ":(" << member->GetGUIDLow() << ") "; - if (!i->hasNext()) - break; - } + if (!i->hasNext()) + break; } - sLog.outLog(LOG_BOSS, ss.str().c_str()); } + sLog.outLog(LOG_BOSS, ss.str().c_str()); + } + + if (m->IsRaid() || m->IsHeroic()) + { + if (creatureVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); } else { @@ -12443,6 +12568,25 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) ((Player*)this)->RemoveCharmAuras(); } + if (Creature* killer = ToCreature()) + { + // used by eluna + if (Player* killed = pVictim->ToPlayer()) + sHookMgr->OnPlayerKilledByCreature(killer, killed); + } + else if (Player* killer = ToPlayer()) + { + if (Player* killed = pVictim->ToPlayer()) + sHookMgr->OnPVPKill(killer, killed); + else if (Creature* killed = pVictim->ToCreature()) + { + // used by eluna + sHookMgr->OnCreatureKill(killer, killed); + } + } + + + // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) if (player && player->InBattleGround()) { @@ -12619,7 +12763,7 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer) CastStop(); CombatStop(); //TODO: CombatStop(true) may cause crash (interrupt spells) - getHostilRefManager().deleteReferences(); + getHostileRefManager().deleteReferences(); DeleteThreatList(); SetCharmerGUID(0); RestoreFaction(); @@ -12907,6 +13051,9 @@ void Unit::KnockBack(float angle, float horizontalSpeed, float verticalSpeed) } else { + if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE) || !CanFreeMove()) + return; + float dis = horizontalSpeed; float ox, oy, oz; @@ -12950,7 +13097,7 @@ bool Unit::HasEventAISummonedUnits() return i_AI->HasEventAISummonedUnits(); } -Unit* Unit::GetNextRandomRaidMember(float radius) +Unit* Unit::GetNextRandomRaidMember(float radius, bool PlayerOnly) { Player *pPlayer = GetCharmerOrOwnerPlayerOrPlayerItself(); if (!pPlayer) @@ -12976,7 +13123,7 @@ Unit* Unit::GetNextRandomRaidMember(float radius) nearMembers.push_back(Target); if (Pet *pet = Target->GetPet()) - if (pet != this && IsWithinDistInMap(pet, radius) && + if (!PlayerOnly && pet != this && IsWithinDistInMap(pet, radius) && !pet->HasInvisibilityAura() && !IsHostileTo(pet) && !pet->HasAuraType(SPELL_AURA_MOD_UNATTACKABLE) && pet->isAlive()) nearMembers.push_back(pet); @@ -13164,3 +13311,12 @@ void Unit::SetRooted(bool apply) else GetUnitStateMgr().DropAction(UNIT_ACTION_ROOT); } + +bool Unit::isInSanctuary() +{ + const AreaTableEntry *area = GetAreaEntryByAreaID(GetAreaId()); + if (area && area->flags & AREA_FLAG_SANCTUARY) + return true; + + return false; +} diff --git a/src/game/Unit.h b/src/game/Unit.h index 7fd6c38e4..0bd631df0 100755 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __UNIT_H -#define __UNIT_H +#ifndef HELLGROUND_UNIT_H +#define HELLGROUND_UNIT_H #include "Common.h" #include "Object.h" @@ -28,7 +28,7 @@ #include "UpdateFields.h" #include "SharedDefines.h" #include "ThreatManager.h" -#include "HostilRefManager.h" +#include "HostileRefManager.h" #include "FollowerReference.h" #include "FollowerRefManager.h" #include "Utilities/EventProcessor.h" @@ -52,11 +52,12 @@ enum SpellInterruptFlags enum SpellChannelInterruptFlags { - CHANNEL_FLAG_DAMAGE = 0x0002, - CHANNEL_FLAG_MOVEMENT = 0x0008, - CHANNEL_FLAG_TURNING = 0x0010, - CHANNEL_FLAG_DAMAGE2 = 0x0080, - CHANNEL_FLAG_DELAY = 0x4000 + // CHANNEL_INTERRUPT_FLAG_DAMAGE = 0x0002, + // CHANNEL_INTERRUPT_FLAG_INTERRUPT = 0x0004, + CHANNEL_INTERRUPT_FLAG_MOVEMENT = 0x0008, + // CHANNEL_INTERRUPT_FLAG_TURNING = 0x0010, + // CHANNEL_INTERRUPT_FLAG_DAMAGE2 = 0x0080, + CHANNEL_INTERRUPT_FLAG_DELAY = 0x4000 }; enum SpellAuraInterruptFlags @@ -541,6 +542,7 @@ enum UnitFlags2 { UNIT_FLAG2_FEIGN_DEATH = 0x00000001, UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, + UNIT_FLAG2_CLONED = 0x00000010, // Used in SPELL_AURA_MIRROR_IMAGE UNIT_FLAG2_FORCE_MOVE = 0x00000040, UNIT_FLAG2_UNKNOWN1 = 0x00000800 }; @@ -880,6 +882,8 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject uint32 m_extraAttacks; bool m_canDualWield; + bool isInSanctuary(); + void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*) { AttackerSet::iterator itr = m_attackers.find(pAttacker); @@ -913,8 +917,8 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject void CombatStop(bool cast = false); void CombatStopWithPets(bool cast = false); Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE, Unit* target = NULL) const; - void SendMeleeAttackStop(Unit* victim); - void SendMeleeAttackStart(Unit* pVictim); + void SendMeleeAttackStop(uint64 victimGUID); + void SendMeleeAttackStart(uint64 victimGUID); void addUnitState(uint32 f) { m_state |= f; } bool hasUnitState(const uint32 f) const { return (m_state & f); } @@ -934,6 +938,8 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject uint32 getClassMask() const { return 1 << (getClass()-1); } uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); } + virtual float GetXPMod() const { return 1.0f; } + float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); } void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); } uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; } @@ -978,7 +984,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject bool IsInRaidWith(Unit const* unit) const; void GetPartyMember(std::list &units, float dist); void GetRaidMember(std::list &units, float dist); - Unit* GetNextRandomRaidMember(float radius); + Unit* GetNextRandomRaidMember(float radius, bool PlayerOnly = false); bool IsContestedGuard() const { if (FactionTemplateEntry const* entry = getFactionTemplateEntry()) @@ -1095,6 +1101,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject uint32 GetAurasAmountByMiscValue(AuraType auraType, uint32 misc); bool hasNegativeAuraWithInterruptFlag(uint32 flag); bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint64 familyFlags) const; + bool HasAuraByCasterWithFamilyFlags(uint64 pCaster, uint32 familyName, uint64 familyFlags, const Aura * except = NULL) const; bool HasAura(uint32 spellId, uint32 effIndex) const { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); @@ -1157,6 +1164,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject virtual void MoveOutOfRange(Player &) {}; bool isAlive() const { return (m_deathState == ALIVE); }; + bool isDying() const { return (m_deathState == JUST_DIED); }; bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }; DeathState getDeathState() { return m_deathState; }; virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet @@ -1243,13 +1251,14 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject void RemoveAurasDueToSpellByCancel(uint32 spellId); void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo, Unit * caster); void RemoveNotOwnSingleTargetAuras(); + void RemoveAurasWithFamilyFlagsAndTypeByCaster(uint32 familyName, uint64 familyFlags, AuraType aurType, uint64 casterGUID); void RemoveSpellsCausingAura(AuraType auraType); void RemoveAuraTypeByCaster(AuraType auraType, uint64 casterGUID); void RemoveRankAurasDueToSpell(uint32 spellId); bool RemoveNoStackAurasDueToAura(Aura *Aur); void RemoveAurasWithAttribute(uint32 flags, bool notPassiveOnly = false); - void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0); + void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0, bool PositiveOnly = false); void RemoveAurasWithDispelType(DispelType type); void RemoveAurasDueToRaidTeleport(); void RemoveAllAurasButPermanent(); // WARLOCK PET unbuff after resummon with current PET @@ -1285,15 +1294,16 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } float GetCreateStat(Stats stat) const { return m_createStats[stat]; } - void SetCurrentCastedSpell(Spell * pSpell); - virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { } + void SetCurrentCastSpell(Spell * pSpell); + virtual void ProhibitSpellSchool(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/) { } + void InterruptSpell(uint32 spellType, bool withDelayed = true, bool withInstant = true); void FinishSpell(CurrentSpellTypes spellType, bool ok = true); - // set withDelayed to true to account delayed spells as casted - // delayed+channeled spells are always accounted as casted + // set withDelayed to true to account delayed spells as cast + // delayed+channeled spells are always accounted as cast // we can skip channeled or delayed checks using flags - bool IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const; + bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const; // set withDelayed to true to interrupt delayed spells too // delayed+channeled spells are always interrupted @@ -1394,6 +1404,8 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject Position _notifiedPosition; + bool WorthHonor; + private: bool _AINotifyScheduled; @@ -1412,11 +1424,11 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject void TauntApply(Unit* pVictim); void TauntFadeOut(Unit *taunter); - HostilRefManager& getHostilRefManager() { return _hostilRefManager; } + HostileRefManager& getHostileRefManager() { return _hostileRefManager; } ThreatManager& getThreatManager() { return _threatManager; } - void addHatedBy(HostilReference* pHostilReference) { getHostilRefManager().insertFirst(pHostilReference); }; - void removeHatedBy(HostilReference* /*pHostilReference*/) { /* nothing to do yet */ } + void addHatedBy(HostileReference* pHostileReference) { getHostileRefManager().insertFirst(pHostileReference); }; + void removeHatedBy(HostileReference* /*pHostileReference*/) { /* nothing to do yet */ } Aura* GetAura(uint32 spellId, uint32 effindex); AuraMap & GetAuras() { return m_Auras; } @@ -1602,7 +1614,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject Player* GetGMToSendCombatStats() const { return m_GMToSendCombatStats ? GetPlayer(m_GMToSendCombatStats) : NULL; } void SetGMToSendCombatStats(uint64 guid) { m_GMToSendCombatStats = guid; } void SendCombatStats(const char* str, Unit *pVictim, ...) const; - + bool RollPRD(float baseChance, float extraChance, uint32 spellId); // Movement info @@ -1645,7 +1657,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject AuraList m_removedAuras; AuraList *m_modAuras; - AuraList m_scAuras; // casted singlecast auras + AuraList m_scAuras; // cast singlecast auras AuraList m_interruptableAuras; AuraList m_ccAuras; uint32 m_interruptMask; @@ -1690,7 +1702,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject Diminishing m_Diminishing; // Manage all Units that are threatened by us - HostilRefManager _hostilRefManager; + HostileRefManager _hostileRefManager; ThreatManager _threatManager; FollowerRefManager m_FollowingRefManager; @@ -1704,7 +1716,7 @@ class HELLGROUND_IMPORT_EXPORT Unit : public WorldObject uint64 m_GMToSendCombatStats; UNORDERED_MAP m_PRDMap; - + void UpdateSplineMovement(uint32 t_diff); TimeTrackerSmall m_movesplineTimer; }; diff --git a/src/game/UnitAI.cpp b/src/game/UnitAI.cpp index 5f703e435..1396d9731 100644 --- a/src/game/UnitAI.cpp +++ b/src/game/UnitAI.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "UnitAI.h" @@ -49,7 +49,7 @@ void UnitAI::DoMeleeAttackIfReady() // set selection back to attacked victim if not selected (after spell casting) if(me->GetTypeId() == TYPEID_UNIT) { - if(((Creature*)me)->GetSelection() != me->getVictimGUID()) + if(((Creature*)me)->GetSelection() != me->getVictimGUID() && !((Creature*)me)->hasIgnoreVictimSelection()) ((Creature*)me)->SetSelection(me->getVictimGUID()); } @@ -211,8 +211,8 @@ Unit* UnitAI::SelectUnit(SelectAggroTarget targetType, uint32 position, float ma void UnitAI::SelectUnitList(std::list &targetList, uint32 num, SelectAggroTarget targetType, float max_dist, bool playerOnly, uint64 excludeGUID, float min_dist) { - const std::list &threatlist = me->getThreatManager().getThreatList(); - for (std::list::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + const std::list &threatlist = me->getThreatManager().getThreatList(); + for (std::list::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) targetList.push_back((*itr)->getTarget()); if (playerOnly) @@ -344,8 +344,8 @@ float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive) void UnitAI::DoCast(uint32 spellId) { Unit *target = NULL; - //sLog.outLog(LOG_DEFAULT, "ERROR: aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target); - switch (AISpellInfo[spellId].target) + //sLog.outLog(LOG_DEFAULT, "ERROR: aggre %u %u", spellId, (uint32)AISpellEntry[spellId].target); + switch (AISpellEntry[spellId].target) { default: case AITARGET_SELF: target = me; break; @@ -381,11 +381,11 @@ void UnitAI::DoCast(uint32 spellId) #define UPDATE_TARGET(a) {if(AIInfo->targettarget=a;} -void UnitAI::FillAISpellInfo() +void UnitAI::FillAISpellEntry() { - AISpellInfo = new AISpellInfoType[GetSpellStore()->GetNumRows()]; + AISpellEntry = new AISpellEntryType[GetSpellStore()->GetNumRows()]; - AISpellInfoType *AIInfo = AISpellInfo; + AISpellEntryType *AIInfo = AISpellEntry; const SpellEntry * spellInfo; for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i, ++AIInfo) @@ -444,7 +444,7 @@ bool UnitAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) if (!Triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; - if (!Triggered && me->GetTypeId() == TYPEID_PLAYER && ((Player*)me)->GetGlobalCooldownMgr().HasGlobalCooldown(Spell)) + if (!Triggered && me->GetTypeId() == TYPEID_PLAYER && ((Player*)me)->GetCooldownMgr().HasGlobalCooldown(Spell)) return false; if (!Triggered && me->GetTypeId() == TYPEID_PLAYER && ((Player*)me)->HasSpellCooldown(Spell->Id)) diff --git a/src/game/UnitAI.h b/src/game/UnitAI.h index f74726eba..ed89ca338 100644 --- a/src/game/UnitAI.h +++ b/src/game/UnitAI.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ class Unit; class Player; -struct AISpellInfoType; +struct AISpellEntryType; //Selection method used by SelectTarget enum SelectAggroTarget @@ -131,8 +131,8 @@ class HELLGROUND_EXPORT UnitAI void SelectUnitList(std::list &targetList, uint32 num, SelectAggroTarget target, float dist, bool playerOnly, uint64 exclude = 0, float mindist = 0.0f); - static AISpellInfoType *AISpellInfo; - static void FillAISpellInfo(); + static AISpellEntryType *AISpellEntry; + static void FillAISpellEntry(); private: Unit *ReturnTargetHelper(SelectAggroTarget target, uint32 position, std::list &targetList); diff --git a/src/game/UnitEvents.h b/src/game/UnitEvents.h index 0fbd96104..8c7c84113 100755 --- a/src/game/UnitEvents.h +++ b/src/game/UnitEvents.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,22 +10,22 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _UNITEVENTS -#define _UNITEVENTS +#ifndef HELLGROUND_UNITEVENTS_H +#define HELLGROUND_UNITEVENTS_H #include "Common.h" class ThreatContainer; class ThreatManager; -class HostilReference; +class HostileReference; //============================================================== //============================================================== @@ -87,7 +87,7 @@ class HELLGROUND_IMPORT_EXPORT UnitBaseEvent class HELLGROUND_IMPORT_EXPORT ThreatRefStatusChangeEvent : public UnitBaseEvent { private: - HostilReference* iHostilReference; + HostileReference* iHostileReference; union { float iFValue; @@ -96,13 +96,13 @@ class HELLGROUND_IMPORT_EXPORT ThreatRefStatusChangeEvent : public UnitBaseEvent }; ThreatManager* iThreatManager; public: - ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType) { iHostilReference = NULL; } + ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType) { iHostileReference = NULL; } - ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; } + ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference) : UnitBaseEvent(pType) { iHostileReference = pHostileReference; } - ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, float pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iFValue = pValue; } + ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, float pValue) : UnitBaseEvent(pType) { iHostileReference = pHostileReference; iFValue = pValue; } - ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, bool pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iBValue = pValue; } + ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, bool pValue) : UnitBaseEvent(pType) { iHostileReference = pHostileReference; iBValue = pValue; } int32 getIValue() const { return iIValue; } @@ -112,7 +112,7 @@ class HELLGROUND_IMPORT_EXPORT ThreatRefStatusChangeEvent : public UnitBaseEvent void setBValue(bool pValue) { iBValue = pValue; } - HostilReference* getReference() const { return iHostilReference; } + HostileReference* getReference() const { return iHostileReference; } void setThreatManager(ThreatManager* pThreatManager) { iThreatManager = pThreatManager; } @@ -127,7 +127,7 @@ class HELLGROUND_IMPORT_EXPORT ThreatManagerEvent : public ThreatRefStatusChange ThreatContainer* iThreatContainer; public: ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType) {} - ThreatManagerEvent(uint32 pType, HostilReference* pHostilReference) : ThreatRefStatusChangeEvent(pType, pHostilReference) {} + ThreatManagerEvent(uint32 pType, HostileReference* pHostileReference) : ThreatRefStatusChangeEvent(pType, pHostileReference) {} void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; } diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index 3de062646..f5c0ee4cb 100755 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index 777639ee7..8abf8fbb0 100755 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __UPDATEDATA_H -#define __UPDATEDATA_H +#ifndef HELLGROUND_UPDATEDATA_H +#define HELLGROUND_UPDATEDATA_H class WorldPacket; diff --git a/src/game/UpdateFields.h b/src/game/UpdateFields.h index 95a1f811e..1c39d735a 100755 --- a/src/game/UpdateFields.h +++ b/src/game/UpdateFields.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _UPDATEFIELDS_AUTO_H -#define _UPDATEFIELDS_AUTO_H +#ifndef HELLGROUND_UPDATEFIELDS_AUTO_H +#define HELLGROUND_UPDATEFIELDS_AUTO_H // Auto generated for version 2, 4, 3, 8606 diff --git a/src/game/UpdateMask.h b/src/game/UpdateMask.h index 5643b5d11..624498792 100755 --- a/src/game/UpdateMask.h +++ b/src/game/UpdateMask.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __UPDATEMASK_H -#define __UPDATEMASK_H +#ifndef HELLGROUND_UPDATEMASK_H +#define HELLGROUND_UPDATEMASK_H #include "UpdateFields.h" #include "Log.h" diff --git a/src/game/VoiceChatHandler.cpp b/src/game/VoiceChatHandler.cpp index a8b6e457e..356105524 100755 --- a/src/game/VoiceChatHandler.cpp +++ b/src/game/VoiceChatHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/WardenBase.cpp b/src/game/WardenBase.cpp index 6c5bb6bb8..31fbd954f 100644 --- a/src/game/WardenBase.cpp +++ b/src/game/WardenBase.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -30,15 +31,19 @@ #include "WardenBase.h" #include "WardenWin.h" -WardenBase::WardenBase() : iCrypto(16), oCrypto(16), m_WardenCheckTimer(10000/*10 sec*/), m_WardenKickTimer(0), m_WardenDataSent(false), m_initialized(false) +WardenBase::WardenBase() : iCrypto(16), oCrypto(16), m_WardenCheckTimer(10000/*10 sec*/), m_WardenKickTimer(0), m_WardenDataSent(false), + m_initialized(false), m_checkIntervalMin(25000), m_checkIntervalMax(35000), m_maxMemChecks(3), m_maxRandomChecks(5) { } WardenBase::~WardenBase() { - delete[] Module->CompressedData; - delete Module; - Module = NULL; + if (Module != NULL) + { + delete[] Module->CompressedData; + delete Module; + Module = NULL; + } m_initialized = false; } @@ -122,6 +127,7 @@ void WardenBase::RequestModule() WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenModuleUse)); pkt.append((uint8*)&Request, sizeof(WardenModuleUse)); Client->SendPacket(&pkt); + m_WardenDataSent = true; } void WardenBase::Update() @@ -145,8 +151,7 @@ void WardenBase::Update() if (diff >= m_WardenCheckTimer) { RequestData(); - // 25-35 second - m_WardenCheckTimer = urand(25000, 35000); + m_WardenCheckTimer = urand(m_checkIntervalMin, m_checkIntervalMax); } else m_WardenCheckTimer -= diff; diff --git a/src/game/WardenBase.h b/src/game/WardenBase.h index 77a2e9ce4..5bcc727bb 100644 --- a/src/game/WardenBase.h +++ b/src/game/WardenBase.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_BASE_H -#define _WARDEN_BASE_H +#ifndef HELLGROUND_WARDEN_BASE_H +#define HELLGROUND_WARDEN_BASE_H #include "Auth/SARC4.h" #include @@ -90,6 +91,7 @@ class WardenBase { friend class WardenWin; friend class WardenMac; + friend class WardenChat; public: WardenBase(); @@ -126,6 +128,11 @@ class WardenBase uint32 m_WardenTimer; ClientWardenModule *Module; bool m_initialized; + + uint32 m_checkIntervalMin; + uint32 m_checkIntervalMax; + uint32 m_maxMemChecks; + uint32 m_maxRandomChecks; }; #endif diff --git a/src/game/WardenChat.cpp b/src/game/WardenChat.cpp new file mode 100644 index 000000000..fa22f5ddf --- /dev/null +++ b/src/game/WardenChat.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "WardenChat.h" + +#include "WorldSession.h" + +WardenChat::WardenChat() +{ +} + +WardenChat::~WardenChat() +{ +} + +void WardenChat::Init(WorldSession *pClient, BigNumber *K) +{ + Client = pClient; + Module = GetModuleForClient(Client); +} + +ClientWardenModule *WardenChat::GetModuleForClient(WorldSession *session) +{ + return NULL; +} + +void WardenChat::InitializeModule() +{ +} + +void WardenChat::RequestHash() +{ +} + +void WardenChat::HandleHashResult(ByteBuffer &buff) +{ +} + +void WardenChat::RequestData() +{ +} + +void WardenChat::HandleData(ByteBuffer &buff) +{ +} diff --git a/src/game/WardenChat.h b/src/game/WardenChat.h new file mode 100644 index 000000000..6adab4308 --- /dev/null +++ b/src/game/WardenChat.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_WARDEN_CHAT_H +#define HELLGROUND_WARDEN_CHAT_H + +#include "ByteBuffer.h" +#include "WardenBase.h" + +class BigNumber; +class WardenBase; +class WorldSession; + +class WardenChat : public WardenBase +{ + public: + WardenChat(); + ~WardenChat(); + + void Init(WorldSession *pClient, BigNumber *K); + ClientWardenModule *GetModuleForClient(WorldSession *session); + void InitializeModule(); + void RequestHash(); + void HandleHashResult(ByteBuffer &buff); + void RequestData(); + void HandleData(ByteBuffer &buff); +}; +#endif diff --git a/src/game/WardenDataStorage.cpp b/src/game/WardenDataStorage.cpp index 10e521a2d..e35f7fed1 100644 --- a/src/game/WardenDataStorage.cpp +++ b/src/game/WardenDataStorage.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" diff --git a/src/game/WardenDataStorage.h b/src/game/WardenDataStorage.h index 651a7be4a..4aa7a6e6a 100644 --- a/src/game/WardenDataStorage.h +++ b/src/game/WardenDataStorage.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_DATA_STORAGE_H -#define _WARDEN_DATA_STORAGE_H +#ifndef HELLGROUND_WARDEN_DATA_STORAGE_H +#define HELLGROUND_WARDEN_DATA_STORAGE_H #include "ace/Singleton.h" diff --git a/src/game/WardenMac.cpp b/src/game/WardenMac.cpp index a6b34c8ec..6fbada0b0 100644 --- a/src/game/WardenMac.cpp +++ b/src/game/WardenMac.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Auth/WardenKeyGeneration.h" @@ -112,11 +113,15 @@ void WardenMac::RequestHash() WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenHashRequest)); pkt.append((uint8*)&Request, sizeof(WardenHashRequest)); Client->SendPacket(&pkt); + + m_initialized = true; + m_WardenTimer = WorldTimer::getMSTime(); } void WardenMac::HandleHashResult(ByteBuffer &buff) { - + m_WardenDataSent = false; + m_WardenKickTimer = 0; // test int keyIn[4]; @@ -172,10 +177,6 @@ void WardenMac::HandleHashResult(ByteBuffer &buff) iCrypto.Init(InputKey); oCrypto.Init(OutputKey); - - m_initialized = true; - - m_WardenTimer = WorldTimer::getMSTime(); } void WardenMac::RequestData() diff --git a/src/game/WardenMac.h b/src/game/WardenMac.h index 3d8a36d46..8c38b7bdb 100644 --- a/src/game/WardenMac.h +++ b/src/game/WardenMac.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_MAC_H -#define _WARDEN_MAC_H +#ifndef HELLGROUND_WARDEN_MAC_H +#define HELLGROUND_WARDEN_MAC_H #include "Auth/SARC4.h" #include @@ -27,7 +28,7 @@ class WorldSession; class WardenBase; -class WardenMac : WardenBase +class WardenMac : public WardenBase { public: WardenMac(); diff --git a/src/game/WardenModuleMac.h b/src/game/WardenModuleMac.h index baa6326ea..f6c7f51d5 100644 --- a/src/game/WardenModuleMac.h +++ b/src/game/WardenModuleMac.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_MODULE_MAC_H -#define _WARDEN_MODULE_MAC_H +#ifndef HELLGROUND_WARDEN_MODULE_MAC_H +#define HELLGROUND_WARDEN_MODULE_MAC_H uint8 Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data[9318] = { diff --git a/src/game/WardenModuleWin.h b/src/game/WardenModuleWin.h index 0fa64e632..56009400a 100644 --- a/src/game/WardenModuleWin.h +++ b/src/game/WardenModuleWin.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_MODULE_WIN_H -#define _WARDEN_MODULE_WIN_H +#ifndef HELLGROUND_WARDEN_MODULE_WIN_H +#define HELLGROUND_WARDEN_MODULE_WIN_H uint8 Module_79C0768D657977D697E10BAD956CCED1_Data[18756] = { diff --git a/src/game/WardenWin.cpp b/src/game/WardenWin.cpp index 1eb6c0927..4f7497adf 100644 --- a/src/game/WardenWin.cpp +++ b/src/game/WardenWin.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Auth/Hmac.h" @@ -74,6 +75,14 @@ void WardenWin::Init(WorldSession *pClient, BigNumber *K) // PrintHexArray(" Module Key: ", Module->Key, 16, true); // PrintHexArray(" Module ID: ", Module->ID, 16, true); RequestModule(); + + m_initialized = true; + m_WardenTimer = WorldTimer::getMSTime(); + + m_checkIntervalMin = sWorld.getConfig(CONFIG_WARDEN_CHECK_INTERVAL_MIN); + m_checkIntervalMax = sWorld.getConfig(CONFIG_WARDEN_CHECK_INTERVAL_MAX); + m_maxMemChecks = sWorld.getConfig(CONFIG_WARDEN_MEM_CHECK_MAX); + m_maxRandomChecks = sWorld.getConfig(CONFIG_WARDEN_RANDOM_CHECK_MAX); } ClientWardenModule *WardenWin::GetModuleForClient(WorldSession *session) @@ -160,6 +169,9 @@ void WardenWin::RequestHash() void WardenWin::HandleHashResult(ByteBuffer &buff) { + m_WardenDataSent = false; + m_WardenKickTimer = 0; + buff.rpos(buff.wpos()); const uint8 validHash[20] = { 0x56, 0x8C, 0x05, 0x4C, 0x78, 0x1A, 0x97, 0x2A, 0x60, 0x37, 0xA2, 0x29, 0x0C, 0x22, 0xB5, 0x25, 0x71, 0xA0, 0x6F, 0x4E }; @@ -187,10 +199,6 @@ void WardenWin::HandleHashResult(ByteBuffer &buff) iCrypto.Init(InputKey); oCrypto.Init(OutputKey); - - m_initialized = true; - - m_WardenTimer = WorldTimer::getMSTime(); } void WardenWin::RequestData() @@ -213,7 +221,7 @@ void WardenWin::RequestData() SendDataId.clear(); - for (int i = 0; i < 3; ++i) // for now include 3 MEM_CHECK's + for (int i = 0; i < m_maxMemChecks; ++i) // for now include 3 MEM_CHECK's { if (MemCheck.empty()) break; @@ -225,7 +233,7 @@ void WardenWin::RequestData() ByteBuffer buff; buff << uint8(WARDEN_SMSG_CHEAT_CHECKS_REQUEST); - uint32 count = (maxid > 5 ? 5 : maxid); + uint32 count = (maxid > m_maxRandomChecks ? m_maxRandomChecks : maxid); for (int i = 0; i < count; ++i) // for now include 5 random checks { @@ -391,7 +399,7 @@ void WardenWin::HandleData(ByteBuffer &buff) uint8 type; std::stringstream ids; - ids << "failed checks: "; + ids << "AntiCheat failed checks: "; for (std::vector::iterator itr = SendDataId.begin(); itr != SendDataId.end(); ++itr) { @@ -439,10 +447,12 @@ void WardenWin::HandleData(ByteBuffer &buff) } sLog.outLog(LOG_WARDEN, "RESULT MEM_CHECK fail CheckId %u account Id %u got: %s should be: %s;", *itr, Client->GetAccountId(), tmpStrContents.c_str(), tmpStrByteArray.c_str()); + if(*itr != sWorld.getConfig(CONFIG_WARDEN_LOG_ONLY_CHECK)) + { + ids << *itr << " "; + found = true; + } - ids << *itr << " "; - - found = true; buff.rpos(buff.rpos() + rd->Length); continue; } @@ -464,7 +474,8 @@ void WardenWin::HandleData(ByteBuffer &buff) sLog.outLog(LOG_WARDEN, "RESULT MODULE_CHECK fail, CheckId %u account Id %u", *itr, Client->GetAccountId()); if (type == DRIVER_CHECK) sLog.outLog(LOG_WARDEN, "RESULT DRIVER_CHECK fail, CheckId %u account Id %u", *itr, Client->GetAccountId()); - //found = true; + ids << *itr << " "; + found = true; buff.rpos(buff.rpos() + 1); continue; } diff --git a/src/game/WardenWin.h b/src/game/WardenWin.h index cec7035bd..728d34bfe 100644 --- a/src/game/WardenWin.h +++ b/src/game/WardenWin.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WARDEN_WIN_H -#define _WARDEN_WIN_H +#ifndef HELLGROUND_WARDEN_WIN_H +#define HELLGROUND_WARDEN_WIN_H #include "Auth/SARC4.h" #include @@ -82,7 +83,7 @@ struct WardenInitModuleRequest class WorldSession; class WardenBase; -class WardenWin : WardenBase +class WardenWin : public WardenBase { public: WardenWin(); diff --git a/src/game/WaypointMgr.cpp b/src/game/WaypointMgr.cpp index 363a50663..c9702295b 100644 --- a/src/game/WaypointMgr.cpp +++ b/src/game/WaypointMgr.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/WaypointMgr.h b/src/game/WaypointMgr.h index addefa813..54c02b1af 100644 --- a/src/game/WaypointMgr.h +++ b/src/game/WaypointMgr.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef HELLGROUND_WAYPOINTMANAGER_H -#define HELLGROUND_WAYPOINTMANAGER_H +#ifndef HELLGROUND_WAYPOINTMGR_H +#define HELLGROUND_WAYPOINTMGR_H #include diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 692c9954e..4774b7818 100755 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //Basic headers #include "WaypointMovementGenerator.h" diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index c18092c1a..6e730170b 100755 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2012 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Weather.cpp b/src/game/Weather.cpp index 943bda766..98eb804e6 100755 --- a/src/game/Weather.cpp +++ b/src/game/Weather.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/game/Weather.h b/src/game/Weather.h index d6ff4e579..84f4070e1 100755 --- a/src/game/Weather.h +++ b/src/game/Weather.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef __WEATHER_H -#define __WEATHER_H +#ifndef HELLGROUND_WEATHER_H +#define HELLGROUND_WEATHER_H #include "Common.h" #include "SharedDefines.h" diff --git a/src/game/World.cpp b/src/game/World.cpp old mode 100755 new mode 100644 index 503d07542..a0b31b739 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -66,11 +66,12 @@ #include "CreatureEventAIMgr.h" #include "WardenDataStorage.h" #include "WorldEventProcessor.h" - +#include "luaengine/HookMgr.h" //#include "Timer.h" - +#include "GuildMgr.h" #include +extern bool StartEluna(); volatile bool World::m_stopEvent = false; uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; volatile uint32 World::m_worldLoopCounter = 0; @@ -111,7 +112,7 @@ void MapUpdateDiffInfo::PrintCumulativeMapUpdateDiff() World::World() { m_playerLimit = 0; - m_requiredPermissionMask = 0; + m_requiredPermissionMask = PERM_PLAYER; m_allowMovement = true; m_ShutdownMask = 0; m_ShutdownTimer = 0; @@ -274,7 +275,6 @@ void World::AddSession_ (WorldSession* s) m_sessions[s->GetAccountId()] = s; uint32 Sessions = GetActiveAndQueuedSessionCount (); - uint32 pLimit = GetPlayerAmountLimit (); uint32 QueueSize = GetQueueSize (); //number of players in the queue //so we don't count the user trying to @@ -282,7 +282,7 @@ void World::AddSession_ (WorldSession* s) if (decrease_session) --Sessions; - if (pLimit > 0 && Sessions >= pLimit && !(s->GetPermissions () & PERM_GMT)) + if (m_playerLimit > 0 && Sessions >= m_playerLimit && !s->HasPermissions(PERM_GMT_HDEV)) { if (!sObjectMgr.IsUnqueuedAccount(s->GetAccountId()) && !HasRecentlyDisconnected(s)) { @@ -304,10 +304,10 @@ void World::AddSession_ (WorldSession* s) UpdateMaxSessionCounters(); // Updates the population - if (pLimit > 0) + if (m_playerLimit > 0) { float popu = GetActiveSessionCount (); //updated number of users on the server - popu /= pLimit; + popu /= m_playerLimit; popu *= 2; AccountsDatabase.PExecute ("UPDATE realms SET population = '%f' WHERE realm_id = '%u'", popu, realmID); sLog.outDetail ("Server Population (%f).", popu); @@ -469,265 +469,506 @@ Weather* World::AddWeather(uint32 zone_id) /// Initialize config values void World::LoadConfigSettings(bool reload) { - if (reload) + if (reload && !sConfig.Reload()) { - if (!sConfig.Reload()) - { - sLog.outLog(LOG_DEFAULT, "ERROR: World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); - return; - } - //TODO Check if config is outdated + sLog.outLog(LOG_DEFAULT, "ERROR: World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); + return; } - ///- Read the player limit and the Message of the day from the config file - SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true); - SetMotd(sConfig.GetStringDefault("Motd", "Welcome to a Trinity Core Server.")); - - ///- Get string for new logins (newly created characters) - SetNewCharString(sConfig.GetStringDefault("PlayerStart.String", "")); + std::string dataPath = sConfig.GetStringDefault("DataDir", "./"); + if (dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\') + dataPath.append("/"); - ///- Send server info on login? - m_configs[CONFIG_ENABLE_SINFO_LOGIN] = sConfig.GetIntDefault("Server.LoginInfo", 0); - - ///- Read all rates from the config file - rate_values[RATE_HEALTH] = sConfig.GetFloatDefault("Rate.Health", 1); - if (rate_values[RATE_HEALTH] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: Rate.Health (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_HEALTH]); - rate_values[RATE_HEALTH] = 1; - } - rate_values[RATE_POWER_MANA] = sConfig.GetFloatDefault("Rate.Mana", 1); - if (rate_values[RATE_POWER_MANA] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: Rate.Mana (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_MANA]); - rate_values[RATE_POWER_MANA] = 1; - } - rate_values[RATE_POWER_RAGE_INCOME] = sConfig.GetFloatDefault("Rate.Rage.Income", 1); - rate_values[RATE_POWER_RAGE_LOSS] = sConfig.GetFloatDefault("Rate.Rage.Loss", 1); - if (rate_values[RATE_POWER_RAGE_LOSS] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: Rate.Rage.Loss (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_RAGE_LOSS]); - rate_values[RATE_POWER_RAGE_LOSS] = 1; - } - rate_values[RATE_POWER_FOCUS] = sConfig.GetFloatDefault("Rate.Focus", 1.0f); - rate_values[RATE_LOYALTY] = sConfig.GetFloatDefault("Rate.Loyalty", 1.0f); - rate_values[RATE_SKILL_DISCOVERY] = sConfig.GetFloatDefault("Rate.Skill.Discovery", 1.0f); - rate_values[RATE_DROP_ITEM_POOR] = sConfig.GetFloatDefault("Rate.Drop.Item.Poor", 1.0f); - rate_values[RATE_DROP_ITEM_NORMAL] = sConfig.GetFloatDefault("Rate.Drop.Item.Normal", 1.0f); - rate_values[RATE_DROP_ITEM_UNCOMMON] = sConfig.GetFloatDefault("Rate.Drop.Item.Uncommon", 1.0f); - rate_values[RATE_DROP_ITEM_RARE] = sConfig.GetFloatDefault("Rate.Drop.Item.Rare", 1.0f); - rate_values[RATE_DROP_ITEM_EPIC] = sConfig.GetFloatDefault("Rate.Drop.Item.Epic", 1.0f); - rate_values[RATE_DROP_ITEM_LEGENDARY] = sConfig.GetFloatDefault("Rate.Drop.Item.Legendary", 1.0f); - rate_values[RATE_DROP_ITEM_ARTIFACT] = sConfig.GetFloatDefault("Rate.Drop.Item.Artifact", 1.0f); - rate_values[RATE_DROP_ITEM_REFERENCED] = sConfig.GetFloatDefault("Rate.Drop.Item.Referenced", 1.0f); - rate_values[RATE_DROP_MONEY] = sConfig.GetFloatDefault("Rate.Drop.Money", 1.0f); - rate_values[RATE_XP_KILL] = sConfig.GetFloatDefault("Rate.XP.Kill", 1.0f); - rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f); - rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f); - rate_values[RATE_XP_PAST_70] = sConfig.GetFloatDefault("Rate.XP.PastLevel70", 1.0f); - rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f); - rate_values[RATE_REPUTATION_LOWLEVEL_KILL] = sConfig.GetFloatDefault("Rate.Reputation.LowLevel.Kill", 0.2f); - rate_values[RATE_REPUTATION_LOWLEVEL_QUEST] = sConfig.GetFloatDefault("Rate.Reputation.LowLevel.Quest", 1.0f); - rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.Damage", 1.0f); - rate_values[RATE_CREATURE_NORMAL_HP] = sConfig.GetFloatDefault("Rate.Creature.Normal.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.HP", 1.0f); - rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_AGGRO] = sConfig.GetFloatDefault("Rate.Creature.Aggro", 1.0f); - rate_values[RATE_CREATURE_GUARD_AGGRO] = sConfig.GetFloatDefault("Rate.Creature.Guard.Aggro", 1.5f); - rate_values[RATE_REST_INGAME] = sConfig.GetFloatDefault("Rate.Rest.InGame", 1.0f); - rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = sConfig.GetFloatDefault("Rate.Rest.Offline.InTavernOrCity", 1.0f); - rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = sConfig.GetFloatDefault("Rate.Rest.Offline.InWilderness", 1.0f); - rate_values[RATE_DAMAGE_FALL] = sConfig.GetFloatDefault("Rate.Damage.Fall", 1.0f); - rate_values[RATE_AUCTION_TIME] = sConfig.GetFloatDefault("Rate.Auction.Time", 1.0f); - rate_values[RATE_AUCTION_DEPOSIT] = sConfig.GetFloatDefault("Rate.Auction.Deposit", 1.0f); - rate_values[RATE_AUCTION_CUT] = sConfig.GetFloatDefault("Rate.Auction.Cut", 1.0f); - rate_values[RATE_HONOR] = sConfig.GetFloatDefault("Rate.Honor",1.0f); - rate_values[RATE_MINING_AMOUNT] = sConfig.GetFloatDefault("Rate.Mining.Amount",1.0f); - rate_values[RATE_MINING_NEXT] = sConfig.GetFloatDefault("Rate.Mining.Next",1.0f); - rate_values[RATE_INSTANCE_RESET_TIME] = sConfig.GetFloatDefault("Rate.InstanceResetTime",1.0f); - rate_values[RATE_TALENT] = sConfig.GetFloatDefault("Rate.Talent",1.0f); - if (rate_values[RATE_TALENT] < 0.0f) - { - sLog.outLog(LOG_DEFAULT, "ERROR: Rate.Talent (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_TALENT]); - rate_values[RATE_TALENT] = 1.0f; - } - rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted",0.5f); - - rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage",0.5f); - if (rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f) - { - sLog.outLog(LOG_DEFAULT, "ERROR: DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]); - rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb",0.5f); - if (rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f) - { - sLog.outLog(LOG_DEFAULT, "ERROR: DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]); - rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry",0.05f); - if (rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f) - { - sLog.outLog(LOG_DEFAULT, "ERROR: DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]); - rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block",0.05f); - if (rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f) - { - sLog.outLog(LOG_DEFAULT, "ERROR: DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]); - rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f; - } - - ///- Read other configuration items from the config file - - m_configs[CONFIG_AUTOBROADCAST_INTERVAL] = (sConfig.GetIntDefault("AutoBroadcast.Timer", 35)*MINUTE*1000); - m_configs[CONFIG_GUILD_ANN_INTERVAL] = (sConfig.GetIntDefault("GuildAnnounce.Timer", 1)*MINUTE*1000); - m_configs[CONFIG_GUILD_ANN_COOLDOWN] = (sConfig.GetIntDefault("GuildAnnounce.Cooldown", 60)*MINUTE); - m_configs[CONFIG_GUILD_ANN_LENGTH] = sConfig.GetIntDefault("GuildAnnounce.Length", 60); - - m_configs[CONFIG_ENABLE_PASSIVE_ANTICHEAT] = sConfig.GetIntDefault("AntiCheat.Enable", 1); - - m_configs[CONFIG_RETURNOLDMAILS_MODE] = sConfig.GetIntDefault("Mail.OldReturnMode", 0); - m_configs[CONFIG_RETURNOLDMAILS_INTERVAL] = sConfig.GetIntDefault("Mail.OldReturnTimer", 60); - - m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1); - if (m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) + if (reload) { - sLog.outLog(LOG_DEFAULT, "ERROR: Compression level (%i) must be in range 1..9. Using default compression level (1).",m_configs[CONFIG_COMPRESSION]); - m_configs[CONFIG_COMPRESSION] = 1; + if (dataPath!=m_dataPath) + sLog.outLog(LOG_DEFAULT, "ERROR: DataDir option can't be changed at .conf file reload, using current value (%s).",m_dataPath.c_str()); } - m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true); - m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true); - m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 900000); - m_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfig.GetIntDefault("DisconnectToleranceInterval", 0); - - m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 300000); - if (m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) + else { - sLog.outLog(LOG_DEFAULT, "ERROR: GridCleanUpDelay (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_GRIDCLEAN],MIN_GRID_DELAY); - m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY; + m_dataPath = dataPath; + sLog.outString("Using DataDir %s",m_dataPath.c_str()); } - if (reload) - sMapMgr.SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]); - m_configs[CONFIG_BATTLEGROUND_ANNOUNCE_START] = sConfig.GetIntDefault("BattleGround.AnnounceStart", 0); - m_configs[CONFIG_BATTLEGROUND_QUEUE_INFO] = sConfig.GetIntDefault("BattleGround.QueueInfo", 0); + // === Load section === + // Performance settings + SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); + loadConfig(CONFIG_ADDON_CHANNEL, "AddonChannel", false); + loadConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, "SaveRespawnTimeImmediately", true); + loadConfig(CONFIG_GRID_UNLOAD, "GridUnload", true); - m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100); - if (m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) - { - sLog.outLog(LOG_DEFAULT, "ERROR: MapUpdateInterval (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_MAPUPDATE],MIN_MAP_UPDATE_DELAY); - m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY; - } + loadConfig(CONFIG_INTERVAL_CHANGEWEATHER, "ChangeWeatherInterval", 600000); + loadConfig(CONFIG_INTERVAL_SAVE, "PlayerSaveInterval", 900000); + loadConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE, "DisconnectToleranceInterval", 0); - m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 600000); + loadConfig(CONFIG_NUMTHREADS, "MapUpdate.Threads", 1); + if (m_configs[CONFIG_NUMTHREADS] < 1) + m_configs[CONFIG_NUMTHREADS] = 1; + loadConfig(CONFIG_MAPUPDATE_MAXVISITORS, "MapUpdate.UpdateVisitorsMax", 0); + loadConfig(CONFIG_CUMULATIVE_LOG_METHOD, "MapUpdate.CumulativeLogMethod", 0); - if (reload) - { - uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); - if (val!=m_configs[CONFIG_PORT_WORLD]) - sLog.outLog(LOG_DEFAULT, "ERROR: WorldServerPort option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); - } + sessionThreads = sConfig.GetIntDefault("SessionUpdate.Threads", 0); + loadConfig(CONFIG_SESSION_UPDATE_MAX_TIME, "SessionUpdate.MaxTime", 1000); + loadConfig(CONFIG_SESSION_UPDATE_OVERTIME_METHOD, "SessionUpdate.Method", 3); + loadConfig(CONFIG_SESSION_UPDATE_VERBOSE_LOG, "SessionUpdate.VerboseLog", 0); + loadConfig(CONFIG_SESSION_UPDATE_IDLE_KICK, "SessionUpdate.IdleKickTimer", 15*MINUTE*IN_MILISECONDS); + loadConfig(CONFIG_SESSION_UPDATE_MIN_LOG_DIFF, "SessionUpdate.MinLogDiff", 25); + loadConfig(CONFIG_INTERVAL_LOG_UPDATE, "RecordUpdateTimeDiffInterval", 60000); + loadConfig(CONFIG_MIN_LOG_UPDATE, "MinRecordUpdateTimeDiff", 10); + + // Server settings + if (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) + m_configs[CONFIG_DECLINED_NAMES_USED] = true; else - m_configs[CONFIG_PORT_WORLD] = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); + loadConfig(CONFIG_DECLINED_NAMES_USED, "DeclinedNames", false); + loadConfig(CONFIG_STRICT_PLAYER_NAMES, "StrictPlayerNames", 0); + loadConfig(CONFIG_STRICT_CHARTER_NAMES, "StrictCharterNames", 0); + loadConfig(CONFIG_STRICT_PET_NAMES, "StrictPetNames", 0); + loadConfig(CONFIG_ACTIVE_BANS_UPDATE_TIME, "ActiveBansUpdateTime", 30000); + loadConfig(CONFIG_ELUNA_ENABLED, "LuaEngine.Enabled", false); + + // Server customization basic + loadConfig(CONFIG_CHARACTERS_CREATING_DISABLED, "CharactersCreatingDisabled", 0); + loadConfig(CONFIG_START_ALL_TAXI_PATHS, "PlayerStart.AllFlightPaths", false); + loadConfig(CONFIG_START_ALL_REP, "PlayerStart.AllReputation", false); + loadConfig(CONFIG_START_ALL_SPELLS, "PlayerStart.AllSpells", false); + loadConfig(CONFIG_START_ALL_EXPLORED, "PlayerStart.MapsExplored", false); + SetNewCharString(sConfig.GetStringDefault("PlayerStart.String", "")); - if (reload) + loadConfig(CONFIG_ALWAYS_MAXSKILL, "AlwaysMaxWeaponSkill", false); + loadConfig(CONFIG_CAST_UNSTUCK, "CastUnstuck", true); + loadConfig(CONFIG_DAILY_BLIZZLIKE, "DailyQuest.Blizzlike", true); + loadConfig(CONFIG_DAILY_MAX_PER_DAY, "DailyQuest.MaxPerDay", 25); + loadConfig(CONFIG_DISABLE_DUEL, "DisableDuel", false); + loadConfig(CONFIG_DISABLE_PVP, "DisablePVP", false); + loadConfig(CONFIG_EVENT_ANNOUNCE, "EventAnnounce", 0); + loadConfig(CONFIG_FFA_DISALLOWGROUP, "FFA.DisallowGroup", false); + loadConfig(CONFIG_HONOR_AFTER_DUEL, "HonorPointsAfterDuel", 0); + if (m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) + m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; + loadConfig(CONFIG_INSTANCE_IGNORE_LEVEL, "Instance.IgnoreLevel", false); + loadConfig(CONFIG_INSTANCE_IGNORE_RAID, "Instance.IgnoreRaid", false); + loadConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL, "MaxPrimaryTradeSkill", 2); + SetMotd(sConfig.GetStringDefault("Motd", "Welcome to a HellgroundCore Server.")); + loadConfig(CONFIG_PVP_TOKEN_ENABLE, "PvPToken.Enable", false); + loadConfig(CONFIG_PVP_TOKEN_ID, "PvPToken.ItemID", 29434); + loadConfig(CONFIG_PVP_TOKEN_COUNT, "PvPToken.ItemCount", 1); + if (m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) + m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; + loadConfig(CONFIG_PVP_TOKEN_MAP_TYPE, "PvPToken.MapAllowType", 4); + loadConfig(CONFIG_ENABLE_SINFO_LOGIN, "Server.LoginInfo", 0); + loadConfig(CONFIG_SHOW_KICK_IN_WORLD, "ShowKickInWorld", false); + + loadConfig(CONFIG_DONT_DELETE_CHARS, "DontDeleteChars", false); + loadConfig(CONFIG_DONT_DELETE_CHARS_LVL, "DontDeleteCharsLvl", 40); + loadConfig(CONFIG_KEEP_DELETED_CHARS_TIME, "KeepDeletedCharsTime", 31); + + // Server customization advanced + loadConfig(CONFIG_WEATHER, "ActivateWeather",true); + loadConfig(CONFIG_ENABLE_SORT_AUCTIONS, "Auction.EnableSort", true); + loadConfig(CONFIG_AUTOBROADCAST_INTERVAL, "AutoBroadcast.Timer", 35*MINUTE*1000); + loadConfig(CONFIG_GROUPLEADER_RECONNECT_PERIOD, "GroupLeaderReconnectPeriod", 180); + loadConfig(CONFIG_INSTANCE_RESET_TIME_HOUR, "Instance.ResetTimeHour", 4); + loadConfig(CONFIG_INSTANCE_UNLOAD_DELAY, "Instance.UnloadDelay", 1800000); + loadConfig(CONFIG_MAIL_DELIVERY_DELAY, "Mail.DeliveryDelay", HOUR); + loadConfig(CONFIG_EXTERNAL_MAIL, "Mail.External", 0); + loadConfig(CONFIG_EXTERNAL_MAIL_INTERVAL, "Mail.ExternalInterval", 1); + loadConfig(CONFIG_GM_MAIL, "Mail.GmInstantSend", 1); + loadConfig(CONFIG_RETURNOLDMAILS_MODE, "Mail.OldReturnMode", 0); + loadConfig(CONFIG_RETURNOLDMAILS_INTERVAL, "Mail.OldReturnTimer", 60); + loadConfig(CONFIG_GROUP_XP_DISTANCE, "MaxGroupXPDistance", 74); + loadConfig(CONFIG_MAX_WHO, "MaxWhoListReturns", 49); + loadConfig(CONFIG_NO_RESET_TALENT_COST, "NoResetTalentsCost", false); + loadConfig(CONFIG_RABBIT_DAY, "Rabbit.Day", 0); + loadConfig(CONFIG_SKILL_PROSPECTING, "SkillChance.Prospecting",false); + + // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100) + loadConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, "Quests.LowLevelHideDiff", 4); + if (m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL) + m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = MAX_LEVEL; + loadConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, "Quests.HighLevelHideDiff", 7); + if (m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL) + m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = MAX_LEVEL; + + std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", ""); + char * forbiddenMaps = new char[forbiddenmaps.length() + 1]; + forbiddenMaps[forbiddenmaps.length()] = 0; + strncpy(forbiddenMaps, forbiddenmaps.c_str(), forbiddenmaps.length()); + const char * delim = ", "; + char * token = strtok(forbiddenMaps, delim); + while (token != NULL) { - uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - if (val != m_configs[CONFIG_SOCKET_SELECTTIME]) - sLog.outLog(LOG_DEFAULT, "ERROR: SocketSelectTime option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_SOCKET_SELECTTIME]); + int32 mapid = strtol(token, NULL, 10); + m_forbiddenMapIds.insert(mapid); + token = strtok(NULL,delim); } - else - m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); + delete[] forbiddenMaps; + + loadConfig(CONFIG_GUILD_ANN_INTERVAL, "GuildAnnounce.Timer", 1*MINUTE*1000); + loadConfig(CONFIG_GUILD_ANN_COOLDOWN, "GuildAnnounce.Cooldown", 60*MINUTE); + loadConfig(CONFIG_GUILD_ANN_LENGTH, "GuildAnnounce.Length", 60); + + loadConfig(CONFIG_ENABLE_CUSTOM_XP_RATES, "EnableCustomXPRates", true); + loadConfig(CONFIG_XP_RATE_MODIFY_ITEM_ENTRY, "XPRateModifyItem.Entry",0); + loadConfig(CONFIG_XP_RATE_MODIFY_ITEM_PCT, "XPRateModifyItem.Pct",5); + + // Player interaction + loadConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS, "AllowTwoSide.Accounts", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND, "AllowTwoSide.AddFriend", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT, "AllowTwoSide.Interaction.Chat", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, "AllowTwoSide.Interaction.Channel", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, "AllowTwoSide.Interaction.Group", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, "AllowTwoSide.Interaction.Guild", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, "AllowTwoSide.Interaction.Auction", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL, "AllowTwoSide.Interaction.Mail", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_TRADE, "AllowTwoSide.Trade", false); + loadConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST, "AllowTwoSide.WhoList", false); + loadConfig(CONFIG_TALENTS_INSPECTING, "TalentsInspecting", true); + + // Chat settings + loadConfig(CONFIG_GLOBAL_TRADE_CHANNEL, "Channel.GlobalTradeChannel",false); + loadConfig(CONFIG_PRIVATE_CHANNEL_LIMIT, "Channel.PrivateLimitCount", 20); + loadConfig(CONFIG_RESTRICTED_LFG_CHANNEL, "Channel.RestrictedLfg", true); + loadConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, "Channel.SilentlyGMJoin", false); + loadConfig(CONFIG_CHAT_DENY_MASK, "Chat.DenyMask", 0); + loadConfig(CONFIG_CHAT_MINIMUM_LVL, "Chat.MinimumLevel", 5); + loadConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING, "ChatFakeMessagePreventing", false); + loadConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT, "ChatFlood.MessageCount",10); + loadConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY, "ChatFlood.MessageDelay",1); + loadConfig(CONFIG_CHATFLOOD_MUTE_TIME, "ChatFlood.MuteTime",10); + + // Game master settings + loadConfig(CONFIG_GM_LOGIN_STATE, "GM.LoginState",2); + loadConfig(CONFIG_GM_VISIBLE_STATE, "GM.Visible", 2); + loadConfig(CONFIG_GM_CHAT, "GM.Chat",2); + loadConfig(CONFIG_GM_WISPERING_TO, "GM.WhisperingTo",2); + loadConfig(CONFIG_GM_IN_GM_LIST, "GM.InGMList",false); + loadConfig(CONFIG_GM_IN_WHO_LIST, "GM.InWhoList",false); + loadConfig(CONFIG_GM_LOG_TRADE, "GM.LogTrade", false); + loadConfig(CONFIG_ALLOW_GM_GROUP, "GM.AllowInvite", false); + loadConfig(CONFIG_ALLOW_GM_FRIEND, "GM.AllowFriend", false); + loadConfig(CONFIG_GM_TRUSTED_LEVEL, "GM.TrustedLevel", PERM_HIGH_GMT); + + loadConfig(CONFIG_COMMAND_LOG_PERMISSION, "CommandLogPermission", PERM_GMT_DEV); + loadConfig(CONFIG_INSTANT_LOGOUT, "InstantLogout", PERM_GMT_DEV); + loadConfig(CONFIG_MIN_GM_TEXT_LVL, "MinGMTextLevel", PERM_GMT_HDEV); + loadConfig(CONFIG_DISABLE_BREATHING, "DisableWaterBreath", PERM_CONSOLE); + loadConfig(CONFIG_HIDE_GAMEMASTER_ACCOUNTS, "HideGameMasterAccounts", true); + + // Server rates + loadConfig(RATE_HEALTH, "Rate.Health", 1.0f); + loadConfig(RATE_POWER_MANA, "Rate.Mana", 1.0f); + loadConfig(RATE_POWER_RAGE_INCOME, "Rate.Rage.Income", 1.0f); + loadConfig(RATE_POWER_RAGE_LOSS, "Rate.Rage.Loss", 1.0f); + loadConfig(RATE_POWER_FOCUS, "Rate.Focus", 1.0f); + loadConfig(RATE_LOYALTY, "Rate.Loyalty", 1.0f); + loadConfig(RATE_SKILL_DISCOVERY, "Rate.Skill.Discovery", 1.0f); + loadConfig(RATE_DROP_ITEM_POOR, "Rate.Drop.Item.Poor", 1.0f); + loadConfig(RATE_DROP_ITEM_NORMAL, "Rate.Drop.Item.Normal", 1.0f); + loadConfig(RATE_DROP_ITEM_UNCOMMON, "Rate.Drop.Item.Uncommon", 1.0f); + loadConfig(RATE_DROP_ITEM_RARE, "Rate.Drop.Item.Rare", 1.0f); + loadConfig(RATE_DROP_ITEM_EPIC, "Rate.Drop.Item.Epic", 1.0f); + loadConfig(RATE_DROP_ITEM_LEGENDARY, "Rate.Drop.Item.Legendary", 1.0f); + loadConfig(RATE_DROP_ITEM_ARTIFACT, "Rate.Drop.Item.Artifact", 1.0f); + loadConfig(RATE_DROP_ITEM_REFERENCED, "Rate.Drop.Item.Referenced", 1.0f); + loadConfig(RATE_DROP_MONEY, "Rate.Drop.Money", 1.0f); + loadConfig(RATE_XP_KILL, "Rate.XP.Kill", 1.0f); + loadConfig(RATE_XP_QUEST, "Rate.XP.Quest", 1.0f); + loadConfig(RATE_XP_EXPLORE, "Rate.XP.Explore", 1.0f); + loadConfig(RATE_XP_PAST_70, "Rate.XP.PastLevel70", 1.0f); + + loadConfig(RATE_REST_INGAME, "Rate.Rest.InGame", 1.0f); + loadConfig(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY, "Rate.Rest.Offline.InTavernOrCity", 1.0f); + loadConfig(RATE_REST_OFFLINE_IN_WILDERNESS, "Rate.Rest.Offline.InWilderness", 1.0f); + loadConfig(RATE_DAMAGE_FALL, "Rate.Damage.Fall", 1.0f); + loadConfig(RATE_AUCTION_TIME, "Rate.Auction.Time", 1.0f); + loadConfig(RATE_AUCTION_DEPOSIT, "Rate.Auction.Deposit", 1.0f); + loadConfig(RATE_AUCTION_CUT, "Rate.Auction.Cut", 1.0f); + loadConfig(RATE_HONOR, "Rate.Honor",1.0f); + loadConfig(RATE_MINING_AMOUNT, "Rate.Mining.Amount",1.0f); + loadConfig(RATE_MINING_NEXT, "Rate.Mining.Next",1.0f); + loadConfig(RATE_TALENT, "Rate.Talent",1.0f); + loadConfig(RATE_REPUTATION_GAIN, "Rate.Reputation.Gain", 1.0f); + loadConfig(RATE_REPUTATION_LOWLEVEL_KILL, "Rate.Reputation.LowLevel.Kill", 0.2f); + loadConfig(RATE_REPUTATION_LOWLEVEL_QUEST, "Rate.Reputation.LowLevel.Quest", 1.0f); + loadConfig(RATE_INSTANCE_RESET_TIME, "Rate.InstanceResetTime", 1.0f); + loadConfig(RATE_DURABILITY_LOSS_DAMAGE, "DurabilityLossChance.Damage", 0.5f); + loadConfig(RATE_DURABILITY_LOSS_ABSORB, "DurabilityLossChance.Absorb", 0.5f); + loadConfig(RATE_DURABILITY_LOSS_BLOCK, "DurabilityLossChance.Block", 0.05f); + loadConfig(RATE_DURABILITY_LOSS_PARRY, "DurabilityLossChance.Parry", 0.05f); + + loadConfig(CONFIG_SKILL_GAIN_CRAFTING, "SkillGain.Crafting", 1); + loadConfig(CONFIG_SKILL_GAIN_DEFENSE, "SkillGain.Defense", 1); + loadConfig(CONFIG_SKILL_GAIN_GATHERING, "SkillGain.Gathering", 1); + loadConfig(CONFIG_SKILL_GAIN_WEAPON, "SkillGain.Weapon", 1); + loadConfig(CONFIG_SKILL_CHANCE_ORANGE, "SkillChance.Orange",100); + loadConfig(CONFIG_SKILL_CHANCE_YELLOW, "SkillChance.Yellow",75); + loadConfig(CONFIG_SKILL_CHANCE_GREEN, "SkillChance.Green",25); + loadConfig(CONFIG_SKILL_CHANCE_GREY, "SkillChance.Grey",0); + loadConfig(CONFIG_SKILL_CHANCE_MINING_STEPS, "SkillChance.MiningSteps",75); + loadConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS, "SkillChance.SkinningSteps",75); + + loadConfig(CONFIG_DEATH_SICKNESS_LEVEL, "Death.SicknessLevel", 11); + loadConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP, "Death.CorpseReclaimDelay.PvP", true); + loadConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE, "Death.CorpseReclaimDelay.PvE", true); + loadConfig(CONFIG_DEATH_BONES_WORLD, "Death.Bones.World", true); + loadConfig(CONFIG_DEATH_BONES_BG_OR_ARENA, "Death.Bones.BattlegroundOrArena", true); + + // Creature settings + loadConfig(RATE_CREATURE_AGGRO, "Rate.Creature.Aggro", 1.0f); + loadConfig(RATE_CREATURE_GUARD_AGGRO, "Rate.Creature.Guard.Aggro", 1.5f); + loadConfig(RATE_CORPSE_DECAY_LOOTED, "Rate.Corpse.Decay.Looted",0.5f); + loadConfig(RATE_CREATURE_NORMAL_DAMAGE, "Rate.Creature.Normal.Damage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_ELITE_DAMAGE, "Rate.Creature.Elite.Elite.Damage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RAREELITE_DAMAGE, "Rate.Creature.Elite.RAREELITE.Damage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE, "Rate.Creature.Elite.WORLDBOSS.Damage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RARE_DAMAGE, "Rate.Creature.Elite.RARE.Damage", 1.0f); + loadConfig(RATE_CREATURE_NORMAL_SPELLDAMAGE, "Rate.Creature.Normal.SpellDamage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE, "Rate.Creature.Elite.Elite.SpellDamage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE, "Rate.Creature.Elite.RAREELITE.SpellDamage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE, "Rate.Creature.Elite.WORLDBOSS.SpellDamage", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RARE_SPELLDAMAGE, "Rate.Creature.Elite.RARE.SpellDamage", 1.0f); + loadConfig(RATE_CREATURE_NORMAL_HP, "Rate.Creature.Normal.HP", 1.0f); + loadConfig(RATE_CREATURE_ELITE_ELITE_HP, "Rate.Creature.Elite.Elite.HP", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RAREELITE_HP, "Rate.Creature.Elite.RAREELITE.HP", 1.0f); + loadConfig(RATE_CREATURE_ELITE_WORLDBOSS_HP, "Rate.Creature.Elite.WORLDBOSS.HP", 1.0f); + loadConfig(RATE_CREATURE_ELITE_RARE_HP, "Rate.Creature.Elite.RARE.HP", 1.0f); + + loadConfig(CONFIG_CORPSE_DECAY_NORMAL, "Corpse.Decay.NORMAL", 60); + loadConfig(CONFIG_CORPSE_DECAY_RARE, "Corpse.Decay.RARE", 300); + loadConfig(CONFIG_CORPSE_DECAY_ELITE, "Corpse.Decay.ELITE", 300); + loadConfig(CONFIG_CORPSE_DECAY_RAREELITE, "Corpse.Decay.RAREELITE", 300); + loadConfig(CONFIG_CORPSE_DECAY_WORLDBOSS, "Corpse.Decay.WORLDBOSS", 3600); + loadConfig(CONFIG_LISTEN_RANGE_SAY, "ListenRange.Say", 25); + loadConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE, "ListenRange.TextEmote", 25); + loadConfig(CONFIG_LISTEN_RANGE_YELL, "ListenRange.Yell", 300); + + loadConfig(CONFIG_WAYPOINT_MOVEMENT_ACTIVE_ON_CONTINENTS, "AutoActive.WaypointMovement.Continents", true); + loadConfig(CONFIG_WAYPOINT_MOVEMENT_ACTIVE_IN_INSTANCES, "AutoActive.WaypointMovement.Instances", true); + loadConfig(CONFIG_COMBAT_ACTIVE_ON_CONTINENTS, "AutoActive.Combat.Continents", true); + loadConfig(CONFIG_COMBAT_ACTIVE_IN_INSTANCES, "AutoActive.Combat.Instances", true); + loadConfig(CONFIG_COMBAT_ACTIVE_FOR_PLAYERS_ONLY, "AutoActive.Combat.PlayersOnly", false); + + loadConfig(CONFIG_SIGHT_GUARD, "GuarderSight", 50); + loadConfig(CONFIG_SIGHT_MONSTER, "MonsterSight", 50); + loadConfig(CONFIG_EVADE_HOMEDIST, "Creature.Evade.DistanceToHome", 50); + loadConfig(CONFIG_EVADE_TARGETDIST, "Creature.Evade.DistanceToTarget", 45); + + loadConfig(CONFIG_CREATURE_RESTORE_STATE, "Creature.RestoreStateTimer", 5000); + loadConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS, "CreatureFamilyAssistanceRadius", 10); + loadConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY, "CreatureFamilyAssistanceDelay", 1500); + loadConfig(CONFIG_CREATURE_FAMILY_FLEE_RADIUS, "CreatureFamilyFleeAssistanceRadius", 30); + loadConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY, "CreatureFamilyFleeDelay", 7000); + loadConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF, "WorldBossLevelDiff",3); + + // Arena settings + loadConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE, "Arena.MaxRatingDifference", 0); + loadConfig(CONFIG_ARENA_RATING_DISCARD_TIMER, "Arena.RatingDiscardTimer",300000); + loadConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, "Arena.AutoDistributePoints", false); + loadConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, "Arena.AutoDistributeInterval", 7); + loadConfig(CONFIG_ENABLE_FAKE_WHO_ON_ARENA, "Arena.EnableFakeWho", false); + loadConfig(CONFIG_ENABLE_FAKE_WHO_IN_GUILD, "Arena.EnableFakeWho.ForGuild", false); + loadConfig(CONFIG_ARENA_LOG_EXTENDED_INFO, "Arena.LogExtendedInfo", false); + + loadConfig(CONFIG_ENABLE_HIDDEN_RATING, "Arena.EnableMMR", false); + loadConfig(CONFIG_ENABLE_HIDDEN_RATING_PENALTY, "Arena.EnableMMRPenalty", false); + loadConfig(CONFIG_HIDDEN_RATING_PENALTY, "Arena.MMRPenalty", 150); + loadConfig(CONFIG_ENABLE_HIDDEN_RATING_LOWER_LOSS, "Arena.MMRSpecialLossCalc", false); + + loadConfig(CONFIG_ENABLE_ARENA_STEP_BY_STEP_MATCHING, "Arena.StepByStep.Enable",false); + loadConfig(CONFIG_ARENA_STEP_BY_STEP_TIME, "Arena.StepByStep.Time",60000); + loadConfig(CONFIG_ARENA_STEP_BY_STEP_VALUE, "Arena.StepByStep.Value",100); + loadConfig(CONFIG_ARENA_END_AFTER_TIME, "Arena.EndAfter.Time",0); + loadConfig(CONFIG_ARENA_END_AFTER_ALWAYS_DRAW, "Arena.EndAfter.AlwaysDraw",false); + loadConfig(CONFIG_ARENA_STATUS_INFO, "Arena.StatusInfo"); + loadConfig(CONFIG_ARENA_ELO_COEFFICIENT, "Arena.ELOCoefficient",32); + loadConfig(CONFIG_ARENA_DAILY_REQUIREMENT, "Arena.DailyRequirement",0); + loadConfig(CONFIG_ARENA_DAILY_AP_REWARD, "Arena.DailyAPReward",0); + loadConfig(CONFIG_ARENA_READY_START_TIMER, "Arena.ReadyStartTimer", 5000); + + // Battleground settings + loadConfig(CONFIG_BATTLEGROUND_ANNOUNCE_START, "BattleGround.AnnounceStart", 0); + loadConfig(CONFIG_BATTLEGROUND_CAST_DESERTER, "Battleground.CastDeserter", true); + loadConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE, "Battleground.InvitationType", 1); + loadConfig(CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH, "BattleGround.PremadeGroupWaitForMatch", 10 * MINUTE * IN_MILISECONDS); + loadConfig(CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, "BattleGround.PrematureFinishTimer", 0); + loadConfig(CONFIG_PREMATURE_BG_REWARD, "Battleground.PrematureReward", true); + loadConfig(CONFIG_BATTLEGROUND_QUEUE_INFO, "BattleGround.QueueInfo", 0); + loadConfig(CONFIG_BG_START_MUSIC, "Battleground.StartMusic", false); + loadConfig(CONFIG_BATTLEGROUND_TIMER_INFO, "BattleGround.TimerInfo"); + loadConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_ENABLED, "BattleGround.WSGEndAfter.Enabled",false); + loadConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_TIME, "BatleGround.WSGEndAfter.Time",1800000); + loadConfig(CONFIG_BATTLEGROUND_WSG_END_AFTER_ALWAYS_DRAW, "BattleGround.WSGEndAfter.AlwaysDraw",true); + + // Vmaps/mmaps + loadConfig(CONFIG_VMAP_LOS_ENABLED, "vmap.enableLOS", true); + sLog.outString("WORLD: vmap los %sabled", getConfig(CONFIG_VMAP_LOS_ENABLED) ? "en" : "dis"); + + std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); + VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); + + loadConfig(CONFIG_VMAP_INDOOR_CHECK, "vmap.enableIndoorCheck", true); + loadConfig(CONFIG_PET_LOS, "vmap.petLOS", false); + loadConfig(CONFIG_VMAP_TOTEM, "vmap.totem", false); - m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); - /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define - m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); - m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50); + loadConfig(CONFIG_MMAP_ENABLED, "mmap.enabled", true); + sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_MMAP_ENABLED) ? "en" : "dis"); + // visibility and radiuses + loadConfig(CONFIG_GROUP_VISIBILITY, "Visibility.GroupMode", 0); + m_activeObjectUpdateDistanceOnContinents = sConfig.GetIntDefault("Visibility.Distance.ActiveObjectUpdate.Continents", DEFAULT_VISIBILITY_DISTANCE); + m_activeObjectUpdateDistanceInInstances = sConfig.GetIntDefault("Visibility.Distance.ActiveObjectUpdate.Instances", DEFAULT_VISIBILITY_DISTANCE); + + // movement + loadConfig(CONFIG_TARGET_POS_RECALCULATION_RANGE, "Movement.RecalculateRange", 2); + if (m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] < 0) + m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] = 0; + if (m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] > 5) + m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] = 5; + loadConfig(CONFIG_TARGET_POS_RECHECK_TIMER, "Movement.RecheckTimer", 100); + loadConfig(CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_ON_CONTINENTS, "Movement.WaypointPathfinding.Continents", true); + loadConfig(CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_IN_INSTANCES, "Movement.WaypointPathfinding.Instances", true); + + // CoreBalancer + loadConfig(CONFIG_COREBALANCER_ENABLED, "CoreBalancer.Enable", false); + loadConfig(CONFIG_COREBALANCER_PLAYABLE_DIFF, "CoreBalancer.PlayableDiff", 200); + loadConfig(CONFIG_COREBALANCER_INTERVAL, "CoreBalancer.BalanceInterval", 300000); + loadConfig(CONFIG_COREBALANCER_VISIBILITY_PENALTY, "CoreBalancer.VisibilityPenalty", 25); + + // VMSS system + loadConfig(CONFIG_VMSS_ENABLE, "VMSS.Enable", false); + loadConfig(CONFIG_VMSS_MAPFREEMETHOD, "VMSS.MapFreeMethod", 0); + loadConfig(CONFIG_VMSS_FREEZECHECKPERIOD, "VMSS.FreezeCheckPeriod", 1000); + loadConfig(CONFIG_VMSS_FREEZEDETECTTIME, "VMSS.MapFreezeDetectTime", 1000); + + // Warden/anticheat + loadConfig(CONFIG_WARDEN_ENABLED, "Warden.Enabled", true); + loadConfig(CONFIG_WARDEN_KICK, "Warden.Kick", true); + loadConfig(CONFIG_WARDEN_BAN, "Warden.Ban", true); + loadConfig(CONFIG_WARDEN_LOG_ONLY_CHECK, "Warden.LogOnlyCheck",0); + loadConfig(CONFIG_WARDEN_CHECK_INTERVAL_MIN, "Warden.CheckIntervalMin",25000); + loadConfig(CONFIG_WARDEN_CHECK_INTERVAL_MAX, "Warden.CheckIntervalMax",35000); + loadConfig(CONFIG_WARDEN_MEM_CHECK_MAX, "Warden.MemCheckMax",3); + loadConfig(CONFIG_WARDEN_RANDOM_CHECK_MAX, "Warden.RandomCheckMax",5); + loadConfig(CONFIG_ENABLE_PASSIVE_ANTICHEAT, "AntiCheat.Enable", 1); + loadConfig(CONFIG_ANTICHEAT_CUMULATIVE_DELAY, "AntiCheat.CumulativeDelay",5* IN_MILISECONDS); + loadConfig(CONFIG_ANTICHEAT_SPEEDHACK_TOLERANCE, "AntiCheat.SpeedhackTolerance",1.00f); + + // RaF + loadConfig(CONFIG_UINT32_RAF_MAXGRANTLEVEL, "RAF.MaxGrantLevel", 60); + loadConfig(CONFIG_UINT32_RAF_MAXREFERALS, "RAF.MaxReferals", 5); + loadConfig(CONFIG_UINT32_RAF_MAXREFERERS, "RAF.MaxReferers", 5); + loadConfig(CONFIG_FLOAT_RATE_RAF_XP, "Rate.RAF.XP", 3.0f); + loadConfig(CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL, "Rate.RAF.LevelPerLevel", 0.5f); + + // Ganking penalty + loadConfig(CONFIG_ENABLE_GANKING_PENALTY, "PVP.EnableGankingPenalty", false); + loadConfig(CONFIG_GANKING_PENALTY_EXPIRE, "PVP.GankingPenaltyExpireTime", 600000); + loadConfig(CONFIG_GANKING_KILLS_ALERT, "PVP.GankingPenaltyKillsAlert", 10); + loadConfig(CONFIG_GANKING_PENALTY_PER_KILL , "PVP.GankingPenaltyPerKill", 0.1); + + // Network + loadConfig(CONFIG_KICK_PLAYER_ON_BAD_PACKET, "Network.KickOnBadPacket", true); + + // === Reload only section === if (reload) { - uint32 val = sConfig.GetIntDefault("GameType", 0); - if (val!=m_configs[CONFIG_GAME_TYPE]) - sLog.outLog(LOG_DEFAULT, "ERROR: GameType option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); + if (sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT) != m_configs[CONFIG_PORT_WORLD]) + sLog.outLog(LOG_DEFAULT, "ERROR: WorldServerPort option can't be changed at .conf file reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); + + // Performance settings + if (sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME) != m_configs[CONFIG_SOCKET_SELECTTIME]) + sLog.outLog(LOG_DEFAULT, "ERROR: SocketSelectTime option can't be changed at .conf file reload, using current value (%u).",m_configs[CONFIG_SOCKET_SELECTTIME]); + sMapMgr.SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]); + m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); + m_timers[WUPDATE_UPTIME].Reset(); + + // Server settings + if (sConfig.GetIntDefault("GameType", 0) != m_configs[CONFIG_GAME_TYPE]) + sLog.outLog(LOG_DEFAULT, "ERROR: GameType option can't be changed at .conf file reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); + if (sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT) != m_configs[CONFIG_REALM_ZONE]) + sLog.outLog(LOG_DEFAULT, "ERROR: RealmZone option can't be changed at .conf file reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); + if ( sConfig.GetIntDefault("Expansion",1) != m_configs[CONFIG_EXPANSION]) + sLog.outLog(LOG_DEFAULT, "ERROR: Expansion option can't be changed at .conf file reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); + + // Server customization basic + if (sConfig.GetIntDefault("MaxPlayerLevel", 70) != m_configs[CONFIG_MAX_PLAYER_LEVEL]) + sLog.outLog(LOG_DEFAULT, "ERROR: MaxPlayerLevel option can't be changed at config reload, using current value (%u).",m_configs[CONFIG_MAX_PLAYER_LEVEL]); + } + // === Not-reload only section === else - m_configs[CONFIG_GAME_TYPE] = sConfig.GetIntDefault("GameType", 0); + { + loadConfig(CONFIG_PORT_WORLD, "WorldServerPort", DEFAULT_WORLDSERVER_PORT); + // Performance settings + loadConfig(CONFIG_SOCKET_SELECTTIME, "SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - if (reload) + // Server settings + loadConfig(CONFIG_GAME_TYPE, "GameType", 0); + loadConfig(CONFIG_REALM_ZONE, "RealmZone", REALM_ZONE_DEVELOPMENT); + loadConfig(CONFIG_EXPANSION, "Expansion",1); + + // Server customization basic + loadConfig(CONFIG_MAX_PLAYER_LEVEL, "MaxPlayerLevel", 70); + if (m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL) + { + sLog.outLog(LOG_DEFAULT, "ERROR: MaxPlayerLevel (%i) must be in range 1..%u. Set to %u.",m_configs[CONFIG_MAX_PLAYER_LEVEL],MAX_LEVEL,MAX_LEVEL); + m_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL; + } + } + + // === Warns section === + // Performance settings + loadConfig(CONFIG_COMPRESSION, "Compression", 1); + if (m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) { - uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); - if (val!=m_configs[CONFIG_REALM_ZONE]) - sLog.outLog(LOG_DEFAULT, "ERROR: RealmZone option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); + sLog.outLog(LOG_DEFAULT, "ERROR: Compression level (%i) must be in range 1..9. Using default compression level (1).",m_configs[CONFIG_COMPRESSION]); + m_configs[CONFIG_COMPRESSION] = 1; } - else - m_configs[CONFIG_REALM_ZONE] = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); - - m_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfig.GetBoolDefault("AllowTwoSide.Accounts", false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Chat",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false); - m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false); - m_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = sConfig.GetBoolDefault("AllowTwoSide.trade", false); - m_configs[CONFIG_STRICT_PLAYER_NAMES] = sConfig.GetIntDefault("StrictPlayerNames", 0); - m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault("StrictCharterNames", 0); - m_configs[CONFIG_STRICT_PET_NAMES] = sConfig.GetIntDefault("StrictPetNames", 0); - - m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault("CharactersCreatingDisabled", 0); - - m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10); - if (m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) + + loadConfig(CONFIG_MAX_OVERSPEED_PINGS, "MaxOverspeedPings",2); + if (m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) { - sLog.outLog(LOG_DEFAULT, "ERROR: CharactersPerRealm (%i) must be in range 1..10. Set to 10.",m_configs[CONFIG_CHARACTERS_PER_REALM]); - m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; + sLog.outLog(LOG_DEFAULT, "ERROR: MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check. Set to 2.",m_configs[CONFIG_MAX_OVERSPEED_PINGS]); + m_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2; } - // must be after CONFIG_CHARACTERS_PER_REALM - m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50); - if (m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) + loadConfig(CONFIG_INTERVAL_GRIDCLEAN, "GridCleanUpDelay", 300000); + if (m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) { - sLog.outLog(LOG_DEFAULT, "ERROR: CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT],m_configs[CONFIG_CHARACTERS_PER_REALM]); - m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM]; + sLog.outLog(LOG_DEFAULT, "ERROR: GridCleanUpDelay (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_GRIDCLEAN],MIN_GRID_DELAY); + m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY; } - m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0); - if (m_configs[CONFIG_SKIP_CINEMATICS] < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) + loadConfig(CONFIG_INTERVAL_MAPUPDATE, "MapUpdateInterval", 100); + if (m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) { - sLog.outLog(LOG_DEFAULT, "ERROR: SkipCinematics (%i) must be in range 0..2. Set to 0.",m_configs[CONFIG_SKIP_CINEMATICS]); - m_configs[CONFIG_SKIP_CINEMATICS] = 0; + sLog.outLog(LOG_DEFAULT, "ERROR: MapUpdateInterval (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_MAPUPDATE],MIN_MAP_UPDATE_DELAY); + m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY; } - if (reload) + loadConfig(CONFIG_UPTIME_UPDATE, "UpdateUptimeInterval", 10); + if (m_configs[CONFIG_UPTIME_UPDATE]<=0) { - uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", 70); - if (val!=m_configs[CONFIG_MAX_PLAYER_LEVEL]) - sLog.outLog(LOG_DEFAULT, "ERROR: MaxPlayerLevel option can't be changed at config reload, using current value (%u).",m_configs[CONFIG_MAX_PLAYER_LEVEL]); + sLog.outLog(LOG_DEFAULT, "ERROR: UpdateUptimeInterval (%i) must be > 0, set to default 10.",m_configs[CONFIG_UPTIME_UPDATE]); + m_configs[CONFIG_UPTIME_UPDATE] = 10; } - else - m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", 70); - - if (m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL) + // Server settings + loadConfig(CONFIG_CHARACTERS_PER_REALM, "CharactersPerRealm", 10); + if (m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) { - sLog.outLog(LOG_DEFAULT, "ERROR: MaxPlayerLevel (%i) must be in range 1..%u. Set to %u.",m_configs[CONFIG_MAX_PLAYER_LEVEL],MAX_LEVEL,MAX_LEVEL); - m_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL; + sLog.outLog(LOG_DEFAULT, "ERROR: CharactersPerRealm (%i) must be in range 1..10. Set to 10.",m_configs[CONFIG_CHARACTERS_PER_REALM]); + m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; } - m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1); + loadConfig(CONFIG_CHARACTERS_PER_ACCOUNT, "CharactersPerAccount", 50); + if (m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) + { + sLog.outLog(LOG_DEFAULT, "ERROR: CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT],m_configs[CONFIG_CHARACTERS_PER_REALM]); + m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM]; + } + // Server customization basic + loadConfig(CONFIG_START_PLAYER_LEVEL, "StartPlayerLevel", 1); if (m_configs[CONFIG_START_PLAYER_LEVEL] < 1) { sLog.outLog(LOG_DEFAULT, "ERROR: StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 1.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); @@ -739,7 +980,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL]; } - m_configs[CONFIG_START_PLAYER_MONEY] = sConfig.GetIntDefault("StartPlayerMoney", 0); + loadConfig(CONFIG_START_PLAYER_MONEY,"StartPlayerMoney", 0); if (m_configs[CONFIG_START_PLAYER_MONEY] < 0) { sLog.outLog(LOG_DEFAULT, "ERROR: StartPlayerMoney (%i) must be in range 0..%u. Set to %u.",m_configs[CONFIG_START_PLAYER_MONEY],MAX_MONEY_AMOUNT,0); @@ -752,14 +993,14 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_PLAYER_MONEY] = MAX_MONEY_AMOUNT; } - m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000); + loadConfig(CONFIG_MAX_HONOR_POINTS, "MaxHonorPoints", 75000); if (m_configs[CONFIG_MAX_HONOR_POINTS] < 0) { sLog.outLog(LOG_DEFAULT, "ERROR: MaxHonorPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_HONOR_POINTS]); m_configs[CONFIG_MAX_HONOR_POINTS] = 0; } - m_configs[CONFIG_START_HONOR_POINTS] = sConfig.GetIntDefault("StartHonorPoints", 0); + loadConfig(CONFIG_START_HONOR_POINTS, "StartHonorPoints", 0); if (m_configs[CONFIG_START_HONOR_POINTS] < 0) { sLog.outLog(LOG_DEFAULT, "ERROR: StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.", @@ -773,14 +1014,14 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_HONOR_POINTS] = m_configs[CONFIG_MAX_HONOR_POINTS]; } - m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000); + loadConfig(CONFIG_MAX_ARENA_POINTS, "MaxArenaPoints", 5000); if (m_configs[CONFIG_MAX_ARENA_POINTS] < 0) { sLog.outLog(LOG_DEFAULT, "ERROR: MaxArenaPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_ARENA_POINTS]); m_configs[CONFIG_MAX_ARENA_POINTS] = 0; } - m_configs[CONFIG_START_ARENA_POINTS] = sConfig.GetIntDefault("StartArenaPoints", 0); + loadConfig(CONFIG_START_ARENA_POINTS, "StartArenaPoints", 0); if (m_configs[CONFIG_START_ARENA_POINTS] < 0) { sLog.outLog(LOG_DEFAULT, "ERROR: StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.", @@ -794,38 +1035,23 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_ARENA_POINTS] = m_configs[CONFIG_MAX_ARENA_POINTS]; } - m_configs[CONFIG_ALL_TAXI_PATHS] = sConfig.GetBoolDefault("AllFlightPaths", false); - - m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false); - m_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfig.GetBoolDefault("Instance.IgnoreRaid", false); - - m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true); - m_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfig.GetIntDefault("Battleground.InvitationType", 1); - m_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfig.GetIntDefault("BattleGround.PremadeGroupWaitForMatch", 10 * MINUTE * IN_MILISECONDS); - - m_configs[CONFIG_CAST_UNSTUCK] = sConfig.GetBoolDefault("CastUnstuck", true); - m_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfig.GetIntDefault("Instance.ResetTimeHour", 4); - m_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = sConfig.GetIntDefault("Instance.UnloadDelay", 1800000); - - m_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfig.GetIntDefault("MaxPrimaryTradeSkill", 2); - m_configs[CONFIG_MIN_PETITION_SIGNS] = sConfig.GetIntDefault("MinPetitionSigns", 9); + // Server customization advanced + loadConfig(CONFIG_MIN_PETITION_SIGNS, "MinPetitionSigns", 9); if (m_configs[CONFIG_MIN_PETITION_SIGNS] > 9) { sLog.outLog(LOG_DEFAULT, "ERROR: MinPetitionSigns (%i) must be in range 0..9. Set to 9.",m_configs[CONFIG_MIN_PETITION_SIGNS]); m_configs[CONFIG_MIN_PETITION_SIGNS] = 9; } - m_configs[CONFIG_GM_LOGIN_STATE] = sConfig.GetIntDefault("GM.LoginState",2); - m_configs[CONFIG_GM_VISIBLE_STATE] = sConfig.GetIntDefault("GM.Visible", 2); - m_configs[CONFIG_GM_CHAT] = sConfig.GetIntDefault("GM.Chat",2); - m_configs[CONFIG_GM_WISPERING_TO] = sConfig.GetIntDefault("GM.WhisperingTo",2); - m_configs[CONFIG_GM_IN_GM_LIST] = sConfig.GetBoolDefault("GM.InGMList",false); - m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList",false); - m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); - m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); - m_configs[CONFIG_ALLOW_GM_GROUP] = sConfig.GetBoolDefault("GM.AllowInvite", false); - m_configs[CONFIG_ALLOW_GM_FRIEND] = sConfig.GetBoolDefault("GM.AllowFriend", false); - m_configs[CONFIG_GM_TRUSTED_LEVEL] = sConfig.GetIntDefault("GM.TrustedLevel", 3); + loadConfig(CONFIG_SKIP_CINEMATICS, "SkipCinematics", 0); + if (m_configs[CONFIG_SKIP_CINEMATICS] < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) + { + sLog.outLog(LOG_DEFAULT, "ERROR: SkipCinematics (%i) must be in range 0..2. Set to 0.",m_configs[CONFIG_SKIP_CINEMATICS]); + m_configs[CONFIG_SKIP_CINEMATICS] = 0; + } + + // Game master settings + loadConfig(CONFIG_START_GM_LEVEL, "GM.StartLevel", 1); if (m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) { sLog.outLog(LOG_DEFAULT, "ERROR: GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u.", @@ -838,295 +1064,14 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_START_GM_LEVEL] = MAX_LEVEL; } - m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay", HOUR); - m_configs[CONFIG_EXTERNAL_MAIL] = sConfig.GetIntDefault("ExternalMail", 0); - m_configs[CONFIG_EXTERNAL_MAIL_INTERVAL] = sConfig.GetIntDefault("ExternalMailInterval", 1); - m_configs[CONFIG_GM_MAIL] = sConfig.GetBoolDefault("MailGmInstantSend", 1); - - m_configs[CONFIG_UPTIME_UPDATE] = sConfig.GetIntDefault("UpdateUptimeInterval", 10); - if (m_configs[CONFIG_UPTIME_UPDATE]<=0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: UpdateUptimeInterval (%i) must be > 0, set to default 10.",m_configs[CONFIG_UPTIME_UPDATE]); - m_configs[CONFIG_UPTIME_UPDATE] = 10; - } - if (reload) - { - m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); - m_timers[WUPDATE_UPTIME].Reset(); - } - - m_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfig.GetIntDefault("SkillChance.Orange",100); - m_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfig.GetIntDefault("SkillChance.Yellow",75); - m_configs[CONFIG_SKILL_CHANCE_GREEN] = sConfig.GetIntDefault("SkillChance.Green",25); - m_configs[CONFIG_SKILL_CHANCE_GREY] = sConfig.GetIntDefault("SkillChance.Grey",0); - - m_configs[CONFIG_SKILL_CHANCE_MINING_STEPS] = sConfig.GetIntDefault("SkillChance.MiningSteps",75); - m_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS] = sConfig.GetIntDefault("SkillChance.SkinningSteps",75); - - m_configs[CONFIG_SKILL_PROSPECTING] = sConfig.GetBoolDefault("SkillChance.Prospecting",false); - - m_configs[CONFIG_SKILL_GAIN_CRAFTING] = sConfig.GetIntDefault("SkillGain.Crafting", 1); - if (m_configs[CONFIG_SKILL_GAIN_CRAFTING] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: SkillGain.Crafting (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_CRAFTING]); - m_configs[CONFIG_SKILL_GAIN_CRAFTING] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_DEFENSE] = sConfig.GetIntDefault("SkillGain.Defense", 1); - if (m_configs[CONFIG_SKILL_GAIN_DEFENSE] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: SkillGain.Defense (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_DEFENSE]); - m_configs[CONFIG_SKILL_GAIN_DEFENSE] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_GATHERING] = sConfig.GetIntDefault("SkillGain.Gathering", 1); - if (m_configs[CONFIG_SKILL_GAIN_GATHERING] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: SkillGain.Gathering (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_GATHERING]); - m_configs[CONFIG_SKILL_GAIN_GATHERING] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_WEAPON] = sConfig.GetIntDefault("SkillGain.Weapon", 1); - if (m_configs[CONFIG_SKILL_GAIN_WEAPON] < 0) - { - sLog.outLog(LOG_DEFAULT, "ERROR: SkillGain.Weapon (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_WEAPON]); - m_configs[CONFIG_SKILL_GAIN_WEAPON] = 1; - } - - m_configs[CONFIG_MAX_OVERSPEED_PINGS] = sConfig.GetIntDefault("MaxOverspeedPings",2); - if (m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) - { - sLog.outLog(LOG_DEFAULT, "ERROR: MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check. Set to 2.",m_configs[CONFIG_MAX_OVERSPEED_PINGS]); - m_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2; - } - - m_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY] = sConfig.GetBoolDefault("SaveRespawnTimeImmediately",true); - m_configs[CONFIG_WEATHER] = sConfig.GetBoolDefault("ActivateWeather",true); - - m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetIntDefault("DisableWaterBreath", PERM_CONSOLE); - - m_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL] = sConfig.GetBoolDefault("AlwaysMaxSkillForLevel", false); - - if (reload) - { - uint32 val = sConfig.GetIntDefault("Expansion",1); - if (val!=m_configs[CONFIG_EXPANSION]) - sLog.outLog(LOG_DEFAULT, "ERROR: Expansion option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); - } - else - m_configs[CONFIG_EXPANSION] = sConfig.GetIntDefault("Expansion",1); - - m_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT] = sConfig.GetIntDefault("ChatFlood.MessageCount",10); - m_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY] = sConfig.GetIntDefault("ChatFlood.MessageDelay",1); - m_configs[CONFIG_CHATFLOOD_MUTE_TIME] = sConfig.GetIntDefault("ChatFlood.MuteTime",10); - - m_configs[CONFIG_EVENT_ANNOUNCE] = sConfig.GetIntDefault("Event.Announce",0); - - m_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyFleeAssistanceRadius",30); - m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistanceRadius",10); - m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = sConfig.GetIntDefault("CreatureFamilyAssistanceDelay",1500); - m_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY] = sConfig.GetIntDefault("CreatureFamilyFleeDelay",7000); - - m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3); - - // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100) - m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff", 4); - if (m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL) - m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = MAX_LEVEL; - m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff", 7); - if (m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL) - m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = MAX_LEVEL; - - m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true); - m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false); - - m_configs[CONFIG_TALENTS_INSPECTING] = sConfig.GetBoolDefault("TalentsInspecting", true); - m_configs[CONFIG_DISABLE_DUEL] = sConfig.GetBoolDefault("DisableDuel", false); - m_configs[CONFIG_DISABLE_PVP] = sConfig.GetBoolDefault("DisablePVP", false); - m_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING] = sConfig.GetBoolDefault("ChatFakeMessagePreventing", false); - - m_configs[CONFIG_CORPSE_DECAY_NORMAL] = sConfig.GetIntDefault("Corpse.Decay.NORMAL", 60); - m_configs[CONFIG_CORPSE_DECAY_RARE] = sConfig.GetIntDefault("Corpse.Decay.RARE", 300); - m_configs[CONFIG_CORPSE_DECAY_ELITE] = sConfig.GetIntDefault("Corpse.Decay.ELITE", 300); - m_configs[CONFIG_CORPSE_DECAY_RAREELITE] = sConfig.GetIntDefault("Corpse.Decay.RAREELITE", 300); - m_configs[CONFIG_CORPSE_DECAY_WORLDBOSS] = sConfig.GetIntDefault("Corpse.Decay.WORLDBOSS", 3600); - - m_configs[CONFIG_DEATH_SICKNESS_LEVEL] = sConfig.GetIntDefault("Death.SicknessLevel", 11); - m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvP", true); - m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvE", true); - m_configs[CONFIG_DEATH_BONES_WORLD] = sConfig.GetBoolDefault("Death.Bones.World", true); - m_configs[CONFIG_DEATH_BONES_BG_OR_ARENA] = sConfig.GetBoolDefault("Death.Bones.BattlegroundOrArena", true); - - m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 60); - - // always use declined names in the russian client - m_configs[CONFIG_DECLINED_NAMES_USED] = - (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); - - m_configs[CONFIG_LISTEN_RANGE_SAY] = sConfig.GetIntDefault("ListenRange.Say", 25); - m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25); - m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300); - - m_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = sConfig.GetIntDefault("Arena.MaxRatingDifference", 0); - m_configs[CONFIG_ARENA_RATING_DISCARD_TIMER] = sConfig.GetIntDefault("Arena.RatingDiscardTimer",300000); - m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS] = sConfig.GetBoolDefault("Arena.AutoDistributePoints", false); - m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS] = sConfig.GetIntDefault("Arena.AutoDistributeInterval", 7); - m_configs[CONFIG_ARENA_LOG_EXTENDED_INFO] = sConfig.GetBoolDefault("ArenaLogExtendedInfo", false); - - m_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfig.GetIntDefault("BattleGround.PrematureFinishTimer", 0); - m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetIntDefault("InstantLogout", PERM_GMT); - - m_configs[CONFIG_GROUPLEADER_RECONNECT_PERIOD] = sConfig.GetIntDefault("GroupLeaderReconnectPeriod", 180); - - m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); + // visibility and radiuses + m_VisibleObjectGreyDistance = sConfig.GetIntDefault("Visibility.Distance.Grey.Object", 10); if (m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { sLog.outLog(LOG_DEFAULT, "ERROR: Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; } - m_activeObjectUpdateDistanceOnContinents = sConfig.GetIntDefault("Visibility.Distance.ActiveObjectUpdate.Continents", DEFAULT_VISIBILITY_DISTANCE); - m_activeObjectUpdateDistanceInInstances = sConfig.GetIntDefault("Visibility.Distance.ActiveObjectUpdate.Instances", DEFAULT_VISIBILITY_DISTANCE); - m_configs[CONFIG_WAYPOINT_MOVEMENT_ACTIVE_ON_CONTINENTS] = sConfig.GetBoolDefault("AutoActive.WaypointMovement.Continents", true); - m_configs[CONFIG_WAYPOINT_MOVEMENT_ACTIVE_IN_INSTANCES] = sConfig.GetBoolDefault("AutoActive.WaypointMovement.Instances", true); - m_configs[CONFIG_COMBAT_ACTIVE_ON_CONTINENTS] = sConfig.GetBoolDefault("AutoActive.Combat.Continents", true); - m_configs[CONFIG_COMBAT_ACTIVE_IN_INSTANCES] = sConfig.GetBoolDefault("AutoActive.Combat.Instances", true); - m_configs[CONFIG_COMBAT_ACTIVE_FOR_PLAYERS_ONLY] = sConfig.GetBoolDefault("AutoActive.Combat.PlayersOnly", false); - - m_configs[CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_ON_CONTINENTS] = sConfig.GetBoolDefault("Movement.WaypointPathfinding.Continents", true); - m_configs[CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_IN_INSTANCES] = sConfig.GetBoolDefault("Movement.WaypointPathfinding.Instances", true); - - m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetIntDefault("Movement.RecalculateRange", 2); - - if (m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] < 0) - m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] = 0; - - if (m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] > 5) - m_configs[CONFIG_TARGET_POS_RECALCULATION_RANGE] = 5; - - m_configs[CONFIG_TARGET_POS_RECHECK_TIMER] = sConfig.GetIntDefault("Movement.RecheckTimer", 100); - - ///- Read the "Data" directory from the config file - std::string dataPath = sConfig.GetStringDefault("DataDir","./"); - if (dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\') - dataPath.append("/"); - - if (reload) - { - if (dataPath!=m_dataPath) - sLog.outLog(LOG_DEFAULT, "ERROR: DataDir option can't be changed at Trinityd.conf reload, using current value (%s).",m_dataPath.c_str()); - } - else - { - m_dataPath = dataPath; - sLog.outString("Using DataDir %s",m_dataPath.c_str()); - } - - m_configs[CONFIG_VMAP_LOS_ENABLED] = sConfig.GetIntDefault("vmap.enableLOS", true); - sLog.outString("WORLD: vmap los %sabled", getConfig(CONFIG_VMAP_LOS_ENABLED) ? "en" : "dis"); - - std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); - - VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); - m_configs[CONFIG_VMAP_INDOOR_CHECK] = sConfig.GetBoolDefault("vmap.enableIndoorCheck", true); - - m_configs[CONFIG_MAX_WHO] = sConfig.GetIntDefault("MaxWhoListReturns", 49); - m_configs[CONFIG_PET_LOS] = sConfig.GetBoolDefault("vmap.petLOS", false); - m_configs[CONFIG_VMAP_TOTEM] = sConfig.GetBoolDefault("vmap.totem", false); - - m_configs[CONFIG_PREMATURE_BG_REWARD] = sConfig.GetBoolDefault("Battleground.PrematureReward", true); - m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); - m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); - m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); - if (m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) - m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; - m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); - m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); - m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false); - m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false); - m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); - m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); - m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); - if (m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) - m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; - m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false); - m_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfig.GetBoolDefault("ShowKickInWorld", false); - m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000); - m_configs[CONFIG_MIN_LOG_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeDiff", 10); - m_configs[CONFIG_MIN_LOG_SESSION_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeSessionDiff", 25); - m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads",1); - m_configs[CONFIG_CUMULATIVE_LOG_METHOD] = sConfig.GetIntDefault("MapUpdate.CumulativeLogMethod",0); - - if (m_configs[CONFIG_NUMTHREADS] < 1) - m_configs[CONFIG_NUMTHREADS] = 1; - - m_configs[CONFIG_MAPUPDATE_MAXVISITORS] = sConfig.GetIntDefault("MapUpdate.UpdateVisitorsMax", 0); - - std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", ""); - char * forbiddenMaps = new char[forbiddenmaps.length() + 1]; - forbiddenMaps[forbiddenmaps.length()] = 0; - strncpy(forbiddenMaps, forbiddenmaps.c_str(), forbiddenmaps.length()); - const char * delim = ","; - char * token = strtok(forbiddenMaps, delim); - while (token != NULL) - { - int32 mapid = strtol(token, NULL, 10); - m_forbiddenMapIds.insert(mapid); - token = strtok(NULL,delim); - } - delete[] forbiddenMaps; - - m_configs[CONFIG_MIN_GM_TEXT_LVL] = sConfig.GetIntDefault("MinGMTextLevel", 1); - m_configs[CONFIG_WARDEN_ENABLED] = sConfig.GetBoolDefault("Warden.Enabled", true); - m_configs[CONFIG_WARDEN_KICK] = sConfig.GetBoolDefault("Warden.Kick", true); - m_configs[CONFIG_WARDEN_BAN] = sConfig.GetBoolDefault("Warden.Ban", true); - m_configs[CONFIG_DONT_DELETE_CHARS] = sConfig.GetBoolDefault("DontDeleteChars", false); - m_configs[CONFIG_DONT_DELETE_CHARS_LVL] = sConfig.GetIntDefault("DontDeleteCharsLvl", 40); - m_configs[CONFIG_KEEP_DELETED_CHARS_TIME] = sConfig.GetIntDefault("KeepDeletedCharsTime", 31); - - m_configs[CONFIG_ENABLE_SORT_AUCTIONS] = sConfig.GetBoolDefault("Auction.EnableSort", true); - - m_configs[CONFIG_CHAT_DENY_MASK] = sConfig.GetIntDefault("Chat.DenyMask", 0); - m_configs[CONFIG_CHAT_MINIMUM_LVL] = sConfig.GetIntDefault("Chat.MinimumLevel", 5); - - m_configs[CONFIG_ENABLE_HIDDEN_RATING] = sConfig.GetBoolDefault("Arena.EnableMMR", false); - m_configs[CONFIG_ENABLE_HIDDEN_RATING_PENALTY] = sConfig.GetBoolDefault("Arena.EnableMMRPenalty", false); - m_configs[CONFIG_HIDDEN_RATING_PENALTY] = sConfig.GetIntDefault("Arena.MMRPenalty", 150); - m_configs[CONFIG_ENABLE_HIDDEN_RATING_LOWER_LOSS] = sConfig.GetBoolDefault("Arena.MMRSpecialLossCalc", false); - - m_configs[CONFIG_ENABLE_FAKE_WHO_ON_ARENA] = sConfig.GetBoolDefault("Arena.EnableFakeWho", false); - m_configs[CONFIG_ENABLE_FAKE_WHO_IN_GUILD] = sConfig.GetBoolDefault("Arena.EnableFakeWho.ForGuild", false); - - sessionThreads = sConfig.GetIntDefault("SessionUpdate.Threads", 0); - - // VMSS system - m_configs[CONFIG_VMSS_ENABLE] = sConfig.GetBoolDefault("VMSS.Enable", false); - m_configs[CONFIG_VMSS_MAPFREEMETHOD] = sConfig.GetIntDefault("VMSS.MapFreeMethod", 0); - m_configs[CONFIG_VMSS_FREEZECHECKPERIOD] = sConfig.GetIntDefault("VMSS.FreezeCheckPeriod", 1000); - m_configs[CONFIG_VMSS_FREEZEDETECTTIME] = sConfig.GetIntDefault("VMSS.MapFreezeDetectTime", 1000); - - m_configs[CONFIG_ENABLE_CUSTOM_XP_RATES] = sConfig.GetBoolDefault("EnableCustomXPRates", true); - - m_configs[CONFIG_SESSION_UPDATE_MAX_TIME] = sConfig.GetIntDefault("SessionUpdate.MaxTime", 1000); - m_configs[CONFIG_SESSION_UPDATE_OVERTIME_METHOD] = sConfig.GetIntDefault("SessionUpdate.Method", 3); - m_configs[CONFIG_SESSION_UPDATE_VERBOSE_LOG] = sConfig.GetIntDefault("SessionUpdate.VerboseLog", 0); - m_configs[CONFIG_SESSION_UPDATE_IDLE_KICK] = sConfig.GetIntDefault("SessionUpdate.IdleKickTimer", 15*MINUTE*IN_MILISECONDS); - - m_configs[CONFIG_KICK_PLAYER_ON_BAD_PACKET] = sConfig.GetBoolDefault("Network.KickOnBadPacket", true); - - m_configs[CONFIG_MIN_GM_COMMAND_LOG_LEVEL] = sConfig.GetIntDefault("GmLogMinLevel", 1); - - m_configs[CONFIG_PRIVATE_CHANNEL_LIMIT] = sConfig.GetIntDefault("Channel.PrivateLimitCount", 20); - - m_configs[CONFIG_MMAP_ENABLED] = sConfig.GetIntDefault("mmap.enabled", true); - sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_MMAP_ENABLED) ? "en" : "dis"); - - m_configs[CONFIG_COREBALANCER_ENABLED] = sConfig.GetBoolDefault("CoreBalancer.Enable", false); - m_configs[CONFIG_COREBALANCER_PLAYABLE_DIFF] = sConfig.GetIntDefault("CoreBalancer.PlayableDiff", 200); - m_configs[CONFIG_COREBALANCER_INTERVAL] = sConfig.GetIntDefault("CoreBalancer.BalanceInterval", 300000); - m_configs[CONFIG_COREBALANCER_VISIBILITY_PENALTY] = sConfig.GetIntDefault("CoreBalancer.VisibilityPenalty", 25); - - m_configs[CONFIG_CREATURE_RESTORE_STATE] = sConfig.GetIntDefault("Creature.RestoreStateTimer", 5000); } /// Initialize the World @@ -1154,7 +1099,7 @@ void World::SetInitialWorldSettings() ||m_configs[CONFIG_EXPANSION] && ( !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f))) { - sLog.outLog(LOG_DEFAULT, "ERROR: Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the Trinityd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); + sLog.outLog(LOG_DEFAULT, "ERROR: Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the .conf file.",m_dataPath.c_str(),m_dataPath.c_str()); exit(1); } @@ -1180,6 +1125,9 @@ void World::SetInitialWorldSettings() LoadDBCStores(m_dataPath); DetectDBCLang(); + sLog.outString("Loading Terrain specific data..."); + sTerrainMgr.LoadTerrainSpecifics(); + sLog.outString("Loading Script Names..."); sScriptMgr.LoadScriptNames(); @@ -1389,7 +1337,7 @@ void World::SetInitialWorldSettings() sAuctionMgr.LoadAuctions(); sLog.outString("Loading Guilds..."); - sObjectMgr.LoadGuilds(); + sGuildMgr.LoadGuilds(); sLog.outString("Loading ArenaTeams..."); sObjectMgr.LoadArenaTeams(); @@ -1416,7 +1364,7 @@ void World::SetInitialWorldSettings() sObjectMgr.LoadNpcOptions(); sLog.outString("Loading vendors..."); - sObjectMgr.LoadVendors(); // must be after load CreatureTemplate and ItemTemplate + sObjectMgr.LoadVendors(); // must be after load CreatureTemplate and ItemPrototype sLog.outString("Loading trainers..."); sObjectMgr.LoadTrainerSpell(); // must be after load CreatureTemplate @@ -1461,12 +1409,13 @@ void World::SetInitialWorldSettings() sLog.outString("Loading CreatureEventAI Scripts..."); sCreatureEAIMgr.LoadCreatureEventAI_Scripts(); - sLog.outString("Loading Terrain specific data..."); - sTerrainMgr.LoadTerrainSpecifics(); - sLog.outString("Initializing Scripts..."); sScriptMgr.LoadScriptLibrary(HELLGROUND_SCRIPT_NAME); + ///- Initialize Lua Engine + sLog.outString("Initialize Eluna Lua Engine..."); + StartEluna(); + ///- Initialize game time and timers sLog.outDebug("DEBUG:: Initialize game time and timers"); m_gameTime = time(NULL); @@ -1495,6 +1444,7 @@ void World::SetInitialWorldSettings() m_timers[WUPDATE_GUILD_ANNOUNCES].SetInterval(getConfig(CONFIG_GUILD_ANN_INTERVAL)); m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILISECONDS); // check for chars to delete every day m_timers[WUPDATE_OLDMAILS].SetInterval(getConfig(CONFIG_RETURNOLDMAILS_INTERVAL)*1000); + m_timers[WUPDATE_ACTIVE_BANS].SetInterval(getConfig(CONFIG_ACTIVE_BANS_UPDATE_TIME)); //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions @@ -1529,7 +1479,7 @@ void World::SetInitialWorldSettings() sOutdoorPvPMgr.InitOutdoorPvP(); sLog.outString("Deleting expired IP bans..."); - AccountsDatabase.Execute("DELETE FROM ip_banned WHERE unban_date <= UNIX_TIMESTAMP() AND unban_date <> ban_date"); + AccountsDatabase.Execute("DELETE FROM ip_banned WHERE expiration_date <= UNIX_TIMESTAMP() AND expiration_date <> punishment_date"); sLog.outString("Starting objects Pooling system..."); sPoolMgr.Initialize(); @@ -1559,7 +1509,7 @@ void World::SetInitialWorldSettings() void World::DetectDBCLang() { - uint32 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255); + uint32 m_lang_confid = sConfig.GetIntDefault("Locale", 255); if (m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) { @@ -1649,9 +1599,9 @@ void World::Update(uint32 diff) sLog.outLog(LOG_DEFAULT, "[Diff]: Update time diff: %u, avg: %u. Players online: %u.", m_curAvgUpdateTime, m_avgUpdateTime, GetActiveSessionCount()); sLog.outLog(LOG_DIFF, "Update time diff: %u, avg: %u. Players online: %u.", m_curAvgUpdateTime, m_avgUpdateTime, GetActiveSessionCount()); - sLog.outLog(LOG_STATUS, "%u %u %u %u %u %u %s %u %u %u %u", + sLog.outLog(LOG_STATUS, "%u %u %u %u %u %u %s %u %u %u %u %u", GetUptime(), GetActiveSessionCount(), GetMaxActiveSessionCount(), GetQueuedSessionCount(), GetMaxQueuedSessionCount(), - GetPlayerAmountLimit(), _REVISION, m_curAvgUpdateTime, m_avgUpdateTime, loggedInAlliances.value(), loggedInHordes.value()); + m_playerLimit, _REVISION, m_curAvgUpdateTime, m_avgUpdateTime, loggedInAlliances.value(), loggedInHordes.value(), sWorld.GetGameTime()); m_updateTimeSum = m_updateTime; m_updateTimeCount = 1; @@ -1792,7 +1742,7 @@ void World::Update(uint32 diff) std::advance(itr, rand() % m_Autobroadcasts.size()); msg = *itr; - sWorld.SendWorldText(LANG_AUTO_ANN, msg.c_str()); + sWorld.SendWorldText(LANG_AUTO_ANN, ACC_DISABLED_BROADCAST, msg.c_str()); } diffRecorder.RecordTimeFor("Send Autobroadcast"); @@ -1805,7 +1755,7 @@ void World::Update(uint32 diff) if (!m_GuildAnnounces[0].empty()) { std::list >::iterator itr = m_GuildAnnounces[0].begin(); - std::string guildName = sObjectMgr.GetGuildNameById(PAIR64_LOPART(itr->first)); + std::string guildName = sGuildMgr.GetGuildNameById(PAIR64_LOPART(itr->first)); sWorld.SendGuildAnnounce(PAIR64_HIPART(itr->first), guildName.c_str(), itr->second.c_str()); m_GuildAnnounces[0].pop_front(); @@ -1814,7 +1764,7 @@ void World::Update(uint32 diff) if (!m_GuildAnnounces[1].empty()) { std::list >::iterator itr = m_GuildAnnounces[1].begin(); - std::string guildName = sObjectMgr.GetGuildNameById(PAIR64_LOPART(itr->first)); + std::string guildName = sGuildMgr.GetGuildNameById(PAIR64_LOPART(itr->first)); sWorld.SendGuildAnnounce(PAIR64_HIPART(itr->first), guildName.c_str(), itr->second.c_str()); m_GuildAnnounces[1].pop_front(); @@ -1872,7 +1822,20 @@ void World::Update(uint32 diff) m_timers[WUPDATE_EVENTS].Reset(); diffRecorder.RecordTimeFor("UpdateGameEvents"); } + + if (m_timers[WUPDATE_ACTIVE_BANS].Passed()) + { + m_timers[WUPDATE_ACTIVE_BANS].Reset(); + static SqlStatementID updateBansStmt; + SqlStatement stmt = AccountsDatabase.CreateStatement(updateBansStmt, "UPDATE account_punishment " + "SET active = 0 WHERE expiration_date <= UNIX_TIMESTAMP() AND expiration_date <> punishment_date " + "AND punishment_type_id IN (?,?,?)"); + stmt.addUInt8(PUNISHMENT_BAN); + stmt.addUInt8(PUNISHMENT_MUTE); + stmt.addUInt8(PUNISHMENT_TROLLMUTE); + stmt.Execute(); + } /// // update the instance reset times @@ -1886,6 +1849,9 @@ void World::Update(uint32 diff) //cleanup unused GridMap objects as well as VMaps sTerrainMgr.Update(diff); diffRecorder.RecordTimeFor("UpdateTerrainMGR"); + + ///- used by eluna + sHookMgr->OnWorldUpdate(diff); } void World::UpdateSessions(const uint32 & diff) @@ -1986,7 +1952,7 @@ void World::SendGuildAnnounce(uint32 team, ...) data_list = &data_cache[cache_idx]; - char const* text = sObjectMgr.GetTrinityString(LANG_GUILD_ANNOUNCE,loc_idx); + char const* text = sObjectMgr.GetHellgroundString(LANG_GUILD_ANNOUNCE,loc_idx); char buf[1000]; @@ -2026,7 +1992,7 @@ void World::SendGlobalGMMessage(WorldPacket *packet, WorldSession *self, uint32 itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld() && itr->second != self && - itr->second->GetPermissions() & PERM_GMT && + itr->second->HasPermissions(sWorld.getConfig(CONFIG_MIN_GM_TEXT_LVL)) && (team == 0 || itr->second->GetPlayer()->GetTeam() == team)) { itr->second->SendPacket(packet); @@ -2035,13 +2001,13 @@ void World::SendGlobalGMMessage(WorldPacket *packet, WorldSession *self, uint32 } /// Send a System Message to all players (except self if mentioned) -void World::SendWorldText(int32 string_id, ...) +void World::SendWorldText(int32 string_id, uint32 preventFlags, ...) { std::vector > data_cache; // 0 = default, i => i-1 locale index for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) { - if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) + if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() || itr->second->IsAccountFlagged(AccountFlags(preventFlags))) continue; uint32 loc_idx = itr->second->GetSessionDbLocaleIndex(); @@ -2057,12 +2023,12 @@ void World::SendWorldText(int32 string_id, ...) data_list = &data_cache[cache_idx]; - char const* text = sObjectMgr.GetTrinityString(string_id,loc_idx); + char const* text = sObjectMgr.GetHellgroundString(string_id,loc_idx); char buf[1000]; va_list argptr; - va_start(argptr, string_id); + va_start(argptr, preventFlags); vsnprintf(buf,1000, text, argptr); va_end(argptr); @@ -2118,7 +2084,7 @@ void World::SendWorldTextForLevels(uint32 minLevel, uint32 maxLevel, uint32 prev data_list = &data_cache[cache_idx]; - char const* text = sObjectMgr.GetTrinityString(string_id,loc_idx); + char const* text = sObjectMgr.GetHellgroundString(string_id,loc_idx); char buf[1000]; @@ -2171,7 +2137,7 @@ void World::SendGMText(int32 string_id, ...) data_list = &data_cache[cache_idx]; - char const* text = sObjectMgr.GetTrinityString(string_id,loc_idx); + char const* text = sObjectMgr.GetHellgroundString(string_id,loc_idx); char buf[1000]; @@ -2193,7 +2159,7 @@ void World::SendGMText(int32 string_id, ...) data_list = &data_cache[cache_idx]; for (int i = 0; i < data_list->size(); ++i) - if (itr->second->GetPermissions() & sWorld.getConfig(CONFIG_MIN_GM_TEXT_LVL)) + if (itr->second->HasPermissions(sWorld.getConfig(CONFIG_MIN_GM_TEXT_LVL))) itr->second->SendPacket((*data_list)[i]); } @@ -2262,7 +2228,7 @@ void World::KickAllWithoutPermissions(uint64 perms) { // session not removed at kick and will removed in next update tick for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if (itr->second->GetPermissions() & perms) + if (itr->second->HasPermissions(perms)) itr->second->KickPlayer(); } @@ -2348,7 +2314,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameIPOrMail, std::string uint32 account = fieldsAccount[0].GetUInt32(); uint32 permissions = PERM_PLAYER; - QueryResultAutoPtr resultAccPerm = AccountsDatabase.PQuery("SELECT permiossion_mask FROM account_permissions WHERE account_id = '%u' AND realm_id = '%u')", account, realmID); + QueryResultAutoPtr resultAccPerm = AccountsDatabase.PQuery("SELECT permission_mask FROM account_permissions WHERE account_id = '%u' AND realm_id = '%u')", account, realmID); if (resultAccPerm) { Field* fieldsAccId = resultAccPerm->Fetch(); @@ -2362,7 +2328,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameIPOrMail, std::string if (mode != BAN_IP && mode != BAN_EMAIL) { //No SQL injection as strings are escaped - AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s')", + AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", account, PUNISHMENT_BAN, duration_secs, safe_author.c_str(), reason.c_str()); } @@ -2400,7 +2366,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameIPOrMail) return false; //NO SQL injection as account is uint32 - AccountsDatabase.PExecute("UPDATE account_punishment SET expiration_date = UNIX_TIMESTAMP() WHERE account_id = '%u' AND punishment_type_id = '%u'", account, PUNISHMENT_BAN); + AccountsDatabase.PExecute("UPDATE account_punishment SET active = '0' WHERE account_id = '%u' AND punishment_type_id = '%u'", account, PUNISHMENT_BAN); break; } @@ -2632,9 +2598,17 @@ void World::SelectRandomHeroicDungeonDaily() currentId = eventId; sGameEventMgr.StopEvent(eventId, true); } - GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + if (sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + else{ + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 1400 WHERE entry = %u", eventId); + sGameEventMgr.StartEvent(eventId, true); + } } + if (!sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return; + uint8 random = urand(HeroicEventStart, HeroicEventEnd); while (random == currentId) random = urand(HeroicEventStart, HeroicEventEnd); @@ -2662,9 +2636,17 @@ void World::SelectRandomDungeonDaily() currentId = eventId; sGameEventMgr.StopEvent(eventId, true); } - GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + if (sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + else{ + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 1400 WHERE entry = %u", eventId); + sGameEventMgr.StartEvent(eventId, true); + } } + if (!sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return; + uint8 random = urand(DungeonEventStart, DungeonEventEnd); while (random == currentId) random = urand(DungeonEventStart, DungeonEventEnd); @@ -2692,9 +2674,17 @@ void World::SelectRandomCookingDaily() currentId = eventId; sGameEventMgr.StopEvent(eventId, true); } - GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + if (sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + else{ + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 1400 WHERE entry = %u", eventId); + sGameEventMgr.StartEvent(eventId, true); + } } + if (!sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return; + uint8 random = urand(CookingEventStart, CookingEventEnd); while (random == currentId) random = urand(CookingEventStart, CookingEventEnd); @@ -2717,15 +2707,22 @@ void World::SelectRandomFishingDaily() uint8 currentId = 0; for (uint8 eventId = FishingEventStart; eventId <= FishingEventEnd; ++eventId) { - GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); - if (sGameEventMgr.IsActiveEvent(eventId)) { currentId = eventId; sGameEventMgr.StopEvent(eventId, true); } + if (sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + else{ + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 1400 WHERE entry = %u", eventId); + sGameEventMgr.StartEvent(eventId, true); + } } + if (!sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return; + uint8 random = urand(FishingEventStart, FishingEventEnd); while (random == currentId) random = urand(FishingEventStart, FishingEventEnd); @@ -2753,9 +2750,17 @@ void World::SelectRandomPvPDaily() currentId = eventId; sGameEventMgr.StopEvent(eventId); } - GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + if (sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 5184000 WHERE entry = %u", eventId); + else{ + GameDataDatabase.PExecute("UPDATE game_event SET occurence = 1400 WHERE entry = %u", eventId); + sGameEventMgr.StartEvent(eventId, true); + } } + if (!sWorld.getConfig(CONFIG_DAILY_BLIZZLIKE)) + return; + uint8 random = urand(PvPEventStart, PvPEventEnd);; while (random == currentId) random = urand(PvPEventStart, PvPEventEnd); @@ -2771,6 +2776,7 @@ void World::ResetDailyQuests() { sLog.outDetail("Daily quests reset for all characters."); RealmDataDatabase.Execute("DELETE FROM character_queststatus_daily"); + RealmDataDatabase.Execute("UPDATE character_stats_ro SET dailyarenawins = 0"); for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) if (itr->second->GetPlayer()) itr->second->GetPlayer()->ResetDailyQuestStatus(); @@ -2784,9 +2790,21 @@ void World::ResetDailyQuests() //sGameEventMgr.LoadFromDB(); } -void World::SetPlayerLimit(int32 limit, bool needUpdate) +void World::SetPlayerLimit(int32 limit) { - m_playerLimit = limit; + if(limit >= 0) + { + m_playerLimit = limit; + m_requiredPermissionMask = PERM_PLAYER; + return; + } + + if(limit == -1) + m_requiredPermissionMask = PERM_GMT_DEV; + if(limit == -2) + m_requiredPermissionMask = PERM_HIGH_GMT | PERM_HEAD_DEVELOPER; + if(limit == -3) + m_requiredPermissionMask = PERM_ADM; } void World::UpdateMaxSessionCounters() @@ -2871,6 +2889,24 @@ void World::SetLoggedInCharsCount(TeamId team, uint32 val) } } +void World::loadConfig(WorldConfigs index, const char* name, int32 def) +{ + if (index < CONFIG_VALUE_COUNT) + m_configs[index] = sConfig.GetIntDefault(name, def); +} + +void World::loadConfig(Rates index, const char* name, float def) +{ + if (index < MAX_RATES) + rate_values[index] = sConfig.GetFloatDefault(name, def); +} + +void World::loadConfig(WorldConfigs index, const char* name, bool def) +{ + if (index < CONFIG_VALUE_COUNT) + m_configs[index] = sConfig.GetBoolDefault(name, def); +} + CBTresholds World::GetCoreBalancerTreshold() { return _coreBalancer.GetTreshold(); diff --git a/src/game/World.h b/src/game/World.h old mode 100755 new mode 100644 index 8e60475d4..87a851e7b --- a/src/game/World.h +++ b/src/game/World.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,20 +10,20 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup world The World /// @{ /// \file -#ifndef __WORLD_H -#define __WORLD_H +#ifndef HELLGROUND_WORLD_H +#define HELLGROUND_WORLD_H #include "ace/Singleton.h" @@ -90,6 +90,7 @@ enum WorldTimers WUPDATE_GUILD_ANNOUNCES = 8, WUPDATE_DELETECHARS = 9, WUPDATE_OLDMAILS = 10, + WUPDATE_ACTIVE_BANS = 11, WUPDATE_COUNT }; @@ -97,38 +98,50 @@ enum WorldTimers /// Configuration elements enum WorldConfigs { - CONFIG_COMPRESSION = 0, + CONFIG_PORT_WORLD = 0, + + // Performance settings + CONFIG_COMPRESSION, + CONFIG_MAX_OVERSPEED_PINGS, + CONFIG_ADDON_CHANNEL, + CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, CONFIG_GRID_UNLOAD, - CONFIG_VMAP_INDOOR_CHECK, - CONFIG_INTERVAL_SAVE, + + CONFIG_SOCKET_SELECTTIME, CONFIG_INTERVAL_GRIDCLEAN, CONFIG_INTERVAL_MAPUPDATE, CONFIG_INTERVAL_CHANGEWEATHER, + CONFIG_INTERVAL_SAVE, CONFIG_INTERVAL_DISCONNECT_TOLERANCE, - CONFIG_PORT_WORLD, - CONFIG_SOCKET_SELECTTIME, - CONFIG_GROUP_XP_DISTANCE, - CONFIG_SIGHT_MONSTER, - CONFIG_SIGHT_GUARDER, + CONFIG_UPTIME_UPDATE, + + CONFIG_NUMTHREADS, + CONFIG_MAPUPDATE_MAXVISITORS, + CONFIG_CUMULATIVE_LOG_METHOD, + + CONFIG_SESSION_UPDATE_MAX_TIME, + CONFIG_SESSION_UPDATE_OVERTIME_METHOD, + CONFIG_SESSION_UPDATE_VERBOSE_LOG, + CONFIG_SESSION_UPDATE_IDLE_KICK, + CONFIG_SESSION_UPDATE_MIN_LOG_DIFF, + CONFIG_INTERVAL_LOG_UPDATE, + CONFIG_MIN_LOG_UPDATE, + + // Server settings CONFIG_GAME_TYPE, CONFIG_REALM_ZONE, - CONFIG_ALLOW_TWO_SIDE_ACCOUNTS, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, - CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL, - CONFIG_ALLOW_TWO_SIDE_WHO_LIST, - CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND, - CONFIG_ALLOW_TWO_SIDE_TRADE, + CONFIG_EXPANSION, + CONFIG_DECLINED_NAMES_USED, CONFIG_STRICT_PLAYER_NAMES, CONFIG_STRICT_CHARTER_NAMES, CONFIG_STRICT_PET_NAMES, - CONFIG_CHARACTERS_CREATING_DISABLED, - CONFIG_CHARACTERS_PER_ACCOUNT, CONFIG_CHARACTERS_PER_REALM, - CONFIG_SKIP_CINEMATICS, + CONFIG_CHARACTERS_PER_ACCOUNT, + CONFIG_ACTIVE_BANS_UPDATE_TIME, + CONFIG_ELUNA_ENABLED, + + // Server customization basic + CONFIG_CHARACTERS_CREATING_DISABLED, CONFIG_MAX_PLAYER_LEVEL, CONFIG_START_PLAYER_LEVEL, CONFIG_START_PLAYER_MONEY, @@ -136,14 +149,91 @@ enum WorldConfigs CONFIG_START_HONOR_POINTS, CONFIG_MAX_ARENA_POINTS, CONFIG_START_ARENA_POINTS, + CONFIG_START_ALL_TAXI_PATHS, + CONFIG_START_ALL_REP, + CONFIG_START_ALL_SPELLS, + CONFIG_START_ALL_EXPLORED, + + CONFIG_ALWAYS_MAXSKILL, + CONFIG_CAST_UNSTUCK, + CONFIG_DAILY_BLIZZLIKE, + CONFIG_DAILY_MAX_PER_DAY, + CONFIG_DISABLE_DUEL, + CONFIG_DISABLE_PVP, + CONFIG_EVENT_ANNOUNCE, + CONFIG_FFA_DISALLOWGROUP, + CONFIG_HONOR_AFTER_DUEL, CONFIG_INSTANCE_IGNORE_LEVEL, CONFIG_INSTANCE_IGNORE_RAID, - CONFIG_BATTLEGROUND_CAST_DESERTER, + CONFIG_MAX_PRIMARY_TRADE_SKILL, + CONFIG_PVP_TOKEN_ENABLE, + CONFIG_PVP_TOKEN_ID, + CONFIG_PVP_TOKEN_COUNT, + CONFIG_PVP_TOKEN_MAP_TYPE, + CONFIG_ENABLE_SINFO_LOGIN, + CONFIG_SHOW_KICK_IN_WORLD, + + CONFIG_DONT_DELETE_CHARS, + CONFIG_DONT_DELETE_CHARS_LVL, + CONFIG_KEEP_DELETED_CHARS_TIME, + + // Server customization advanced + CONFIG_WEATHER, + CONFIG_ENABLE_SORT_AUCTIONS, + CONFIG_AUTOBROADCAST_INTERVAL, + CONFIG_GROUPLEADER_RECONNECT_PERIOD, CONFIG_INSTANCE_RESET_TIME_HOUR, CONFIG_INSTANCE_UNLOAD_DELAY, - CONFIG_CAST_UNSTUCK, - CONFIG_MAX_PRIMARY_TRADE_SKILL, + CONFIG_MAIL_DELIVERY_DELAY, + CONFIG_EXTERNAL_MAIL, + CONFIG_EXTERNAL_MAIL_INTERVAL, + CONFIG_GM_MAIL, + CONFIG_RETURNOLDMAILS_MODE, + CONFIG_RETURNOLDMAILS_INTERVAL, + CONFIG_GROUP_XP_DISTANCE, + CONFIG_MAX_WHO, CONFIG_MIN_PETITION_SIGNS, + CONFIG_NO_RESET_TALENT_COST, + CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, + CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, + CONFIG_RABBIT_DAY, + CONFIG_SKIP_CINEMATICS, + CONFIG_SKILL_PROSPECTING, + + CONFIG_GUILD_ANN_INTERVAL, + CONFIG_GUILD_ANN_COOLDOWN, + CONFIG_GUILD_ANN_LENGTH, + + CONFIG_ENABLE_CUSTOM_XP_RATES, + CONFIG_XP_RATE_MODIFY_ITEM_ENTRY, + CONFIG_XP_RATE_MODIFY_ITEM_PCT, + + // Player interaction + CONFIG_ALLOW_TWO_SIDE_ACCOUNTS, + CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, + CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL, + CONFIG_ALLOW_TWO_SIDE_TRADE, + CONFIG_ALLOW_TWO_SIDE_WHO_LIST, + CONFIG_TALENTS_INSPECTING, + + // Chat settings + CONFIG_PRIVATE_CHANNEL_LIMIT, + CONFIG_GLOBAL_TRADE_CHANNEL, + CONFIG_RESTRICTED_LFG_CHANNEL, + CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, + CONFIG_CHAT_DENY_MASK, + CONFIG_CHAT_MINIMUM_LVL, + CONFIG_CHAT_FAKE_MESSAGE_PREVENTING, + CONFIG_CHATFLOOD_MESSAGE_COUNT, + CONFIG_CHATFLOOD_MESSAGE_DELAY, + CONFIG_CHATFLOOD_MUTE_TIME, + + // Game master settings CONFIG_GM_LOGIN_STATE, CONFIG_GM_VISIBLE_STATE, CONFIG_GM_CHAT, @@ -151,175 +241,155 @@ enum WorldConfigs CONFIG_GM_IN_GM_LIST, CONFIG_GM_IN_WHO_LIST, CONFIG_GM_LOG_TRADE, - CONFIG_GM_TRUSTED_LEVEL, CONFIG_START_GM_LEVEL, CONFIG_ALLOW_GM_GROUP, CONFIG_ALLOW_GM_FRIEND, - CONFIG_GROUP_VISIBILITY, - CONFIG_MAIL_DELIVERY_DELAY, - CONFIG_EXTERNAL_MAIL, - CONFIG_EXTERNAL_MAIL_INTERVAL, - CONFIG_GM_MAIL, - CONFIG_UPTIME_UPDATE, + CONFIG_GM_TRUSTED_LEVEL, + + CONFIG_COMMAND_LOG_PERMISSION, + CONFIG_INSTANT_LOGOUT, + CONFIG_MIN_GM_TEXT_LVL, + CONFIG_DISABLE_BREATHING, + CONFIG_HIDE_GAMEMASTER_ACCOUNTS, + + // Server rates + CONFIG_SKILL_GAIN_CRAFTING, + CONFIG_SKILL_GAIN_DEFENSE, + CONFIG_SKILL_GAIN_GATHERING, + CONFIG_SKILL_GAIN_WEAPON, CONFIG_SKILL_CHANCE_ORANGE, CONFIG_SKILL_CHANCE_YELLOW, CONFIG_SKILL_CHANCE_GREEN, CONFIG_SKILL_CHANCE_GREY, CONFIG_SKILL_CHANCE_MINING_STEPS, CONFIG_SKILL_CHANCE_SKINNING_STEPS, - CONFIG_SKILL_PROSPECTING, - CONFIG_SKILL_GAIN_CRAFTING, - CONFIG_SKILL_GAIN_DEFENSE, - CONFIG_SKILL_GAIN_GATHERING, - CONFIG_SKILL_GAIN_WEAPON, - CONFIG_MAX_OVERSPEED_PINGS, - CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, - CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL, - CONFIG_WEATHER, - CONFIG_EXPANSION, - CONFIG_CHATFLOOD_MESSAGE_COUNT, - CONFIG_CHATFLOOD_MESSAGE_DELAY, - CONFIG_CHATFLOOD_MUTE_TIME, - CONFIG_EVENT_ANNOUNCE, - CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS, - CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS, - CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY, - CONFIG_CREATURE_FAMILY_FLEE_DELAY, - CONFIG_WORLD_BOSS_LEVEL_DIFF, - CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, - CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, - CONFIG_RESTRICTED_LFG_CHANNEL, - CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, - CONFIG_TALENTS_INSPECTING, - CONFIG_CHAT_FAKE_MESSAGE_PREVENTING, - CONFIG_CORPSE_DECAY_NORMAL, - CONFIG_CORPSE_DECAY_RARE, - CONFIG_CORPSE_DECAY_ELITE, - CONFIG_CORPSE_DECAY_RAREELITE, - CONFIG_CORPSE_DECAY_WORLDBOSS, - CONFIG_ADDON_CHANNEL, + CONFIG_DEATH_SICKNESS_LEVEL, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE, CONFIG_DEATH_BONES_WORLD, CONFIG_DEATH_BONES_BG_OR_ARENA, - CONFIG_THREAT_RADIUS, - CONFIG_INSTANT_LOGOUT, - CONFIG_GROUPLEADER_RECONNECT_PERIOD, - CONFIG_DISABLE_BREATHING, - CONFIG_ALL_TAXI_PATHS, - CONFIG_DECLINED_NAMES_USED, + + // Creature settings + CONFIG_CORPSE_DECAY_NORMAL, + CONFIG_CORPSE_DECAY_RARE, + CONFIG_CORPSE_DECAY_ELITE, + CONFIG_CORPSE_DECAY_RAREELITE, + CONFIG_CORPSE_DECAY_WORLDBOSS, CONFIG_LISTEN_RANGE_SAY, CONFIG_LISTEN_RANGE_TEXTEMOTE, CONFIG_LISTEN_RANGE_YELL, + + CONFIG_WAYPOINT_MOVEMENT_ACTIVE_ON_CONTINENTS, + CONFIG_WAYPOINT_MOVEMENT_ACTIVE_IN_INSTANCES, + CONFIG_COMBAT_ACTIVE_ON_CONTINENTS, + CONFIG_COMBAT_ACTIVE_IN_INSTANCES, + CONFIG_COMBAT_ACTIVE_FOR_PLAYERS_ONLY, + + CONFIG_SIGHT_GUARD, + CONFIG_SIGHT_MONSTER, + CONFIG_EVADE_HOMEDIST, + CONFIG_EVADE_TARGETDIST, + + CONFIG_CREATURE_RESTORE_STATE, + CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS, + CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY, + CONFIG_CREATURE_FAMILY_FLEE_RADIUS, + CONFIG_CREATURE_FAMILY_FLEE_DELAY, + CONFIG_WORLD_BOSS_LEVEL_DIFF, + + // Arena settings CONFIG_ARENA_MAX_RATING_DIFFERENCE, CONFIG_ARENA_RATING_DISCARD_TIMER, CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, + CONFIG_ENABLE_FAKE_WHO_ON_ARENA, + CONFIG_ENABLE_FAKE_WHO_IN_GUILD, CONFIG_ARENA_LOG_EXTENDED_INFO, + CONFIG_ARENA_READY_START_TIMER, + + CONFIG_ENABLE_HIDDEN_RATING, + CONFIG_ENABLE_HIDDEN_RATING_PENALTY, + CONFIG_HIDDEN_RATING_PENALTY, + CONFIG_ENABLE_HIDDEN_RATING_LOWER_LOSS, + CONFIG_ENABLE_ARENA_STEP_BY_STEP_MATCHING, + CONFIG_ARENA_STEP_BY_STEP_TIME, + CONFIG_ARENA_STEP_BY_STEP_VALUE, + CONFIG_ARENA_END_AFTER_TIME, + CONFIG_ARENA_END_AFTER_ALWAYS_DRAW, + CONFIG_ARENA_STATUS_INFO, + CONFIG_ARENA_ELO_COEFFICIENT, + CONFIG_ARENA_DAILY_REQUIREMENT, + CONFIG_ARENA_DAILY_AP_REWARD, + + // Battleground settings + CONFIG_BATTLEGROUND_ANNOUNCE_START, + CONFIG_BATTLEGROUND_CAST_DESERTER, CONFIG_BATTLEGROUND_INVITATION_TYPE, CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH, CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, - CONFIG_BATTLEGROUND_ANNOUNCE_START, + CONFIG_PREMATURE_BG_REWARD, CONFIG_BATTLEGROUND_QUEUE_INFO, - - CONFIG_MAX_WHO, CONFIG_BG_START_MUSIC, - CONFIG_START_ALL_SPELLS, - CONFIG_HONOR_AFTER_DUEL, - CONFIG_START_ALL_EXPLORED, - CONFIG_START_ALL_REP, - CONFIG_ALWAYS_MAXSKILL, - CONFIG_PVP_TOKEN_ENABLE, - CONFIG_PVP_TOKEN_MAP_TYPE, - CONFIG_PVP_TOKEN_ID, - CONFIG_PVP_TOKEN_COUNT, - CONFIG_NO_RESET_TALENT_COST, - CONFIG_SHOW_KICK_IN_WORLD, - CONFIG_INTERVAL_LOG_UPDATE, - CONFIG_MIN_LOG_UPDATE, - CONFIG_MIN_LOG_SESSION_UPDATE, - CONFIG_ENABLE_SINFO_LOGIN, - CONFIG_PREMATURE_BG_REWARD, + CONFIG_BATTLEGROUND_TIMER_INFO, + CONFIG_BATTLEGROUND_WSG_END_AFTER_ENABLED, + CONFIG_BATTLEGROUND_WSG_END_AFTER_TIME, + CONFIG_BATTLEGROUND_WSG_END_AFTER_ALWAYS_DRAW, + + // vmaps/mmaps + CONFIG_VMAP_LOS_ENABLED, + CONFIG_VMAP_INDOOR_CHECK, CONFIG_PET_LOS, CONFIG_VMAP_TOTEM, - CONFIG_NUMTHREADS, - CONFIG_CUMULATIVE_LOG_METHOD, - CONFIG_MAPUPDATE_MAXVISITORS, - CONFIG_AUTOBROADCAST_INTERVAL, - CONFIG_GUILD_ANN_INTERVAL, - CONFIG_GUILD_ANN_COOLDOWN, - CONFIG_GUILD_ANN_LENGTH, - CONFIG_DISABLE_DUEL, - CONFIG_DISABLE_PVP, - CONFIG_MIN_GM_TEXT_LVL, - CONFIG_WARDEN_ENABLED, - CONFIG_WARDEN_KICK, - CONFIG_WARDEN_BAN, - - CONFIG_DONT_DELETE_CHARS, - CONFIG_DONT_DELETE_CHARS_LVL, - CONFIG_KEEP_DELETED_CHARS_TIME, - - CONFIG_ENABLE_SORT_AUCTIONS, - - CONFIG_RETURNOLDMAILS_MODE, - CONFIG_RETURNOLDMAILS_INTERVAL, - - CONFIG_CHAT_DENY_MASK, - CONFIG_CHAT_MINIMUM_LVL, - - CONFIG_ENABLE_HIDDEN_RATING, - CONFIG_ENABLE_HIDDEN_RATING_PENALTY, - CONFIG_HIDDEN_RATING_PENALTY, - CONFIG_ENABLE_HIDDEN_RATING_LOWER_LOSS, - - CONFIG_ENABLE_FAKE_WHO_ON_ARENA, - CONFIG_ENABLE_FAKE_WHO_IN_GUILD, - - CONFIG_VMSS_MAPFREEMETHOD, - CONFIG_VMSS_FREEZECHECKPERIOD, - CONFIG_VMSS_FREEZEDETECTTIME, - CONFIG_VMSS_ENABLE, - - CONFIG_ENABLE_CUSTOM_XP_RATES, - - CONFIG_ENABLE_PASSIVE_ANTICHEAT, - - CONFIG_SESSION_UPDATE_MAX_TIME, - CONFIG_SESSION_UPDATE_OVERTIME_METHOD, - CONFIG_SESSION_UPDATE_VERBOSE_LOG, - CONFIG_SESSION_UPDATE_IDLE_KICK, - - CONFIG_KICK_PLAYER_ON_BAD_PACKET, - - CONFIG_MIN_GM_COMMAND_LOG_LEVEL, - - CONFIG_WAYPOINT_MOVEMENT_ACTIVE_ON_CONTINENTS, - CONFIG_WAYPOINT_MOVEMENT_ACTIVE_IN_INSTANCES, - CONFIG_COMBAT_ACTIVE_ON_CONTINENTS, - CONFIG_COMBAT_ACTIVE_IN_INSTANCES, - CONFIG_COMBAT_ACTIVE_FOR_PLAYERS_ONLY, - - CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_ON_CONTINENTS, - CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_IN_INSTANCES, + CONFIG_MMAP_ENABLED, + // visibility and radiuses + CONFIG_GROUP_VISIBILITY, + + // movement CONFIG_TARGET_POS_RECALCULATION_RANGE, CONFIG_TARGET_POS_RECHECK_TIMER, + CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_ON_CONTINENTS, + CONFIG_WAYPOINT_MOVEMENT_PATHFINDING_IN_INSTANCES, - CONFIG_PRIVATE_CHANNEL_LIMIT, - - CONFIG_VMAP_LOS_ENABLED, - CONFIG_MMAP_ENABLED, - + // CoreBalancer CONFIG_COREBALANCER_ENABLED, CONFIG_COREBALANCER_PLAYABLE_DIFF, CONFIG_COREBALANCER_INTERVAL, CONFIG_COREBALANCER_VISIBILITY_PENALTY, - CONFIG_CREATURE_RESTORE_STATE, + // VMSS system + CONFIG_VMSS_ENABLE, + CONFIG_VMSS_MAPFREEMETHOD, + CONFIG_VMSS_FREEZECHECKPERIOD, + CONFIG_VMSS_FREEZEDETECTTIME, + + // Warden/anticheat + CONFIG_WARDEN_ENABLED, + CONFIG_WARDEN_KICK, + CONFIG_WARDEN_BAN, + CONFIG_WARDEN_LOG_ONLY_CHECK, + CONFIG_WARDEN_CHECK_INTERVAL_MIN, + CONFIG_WARDEN_CHECK_INTERVAL_MAX, + CONFIG_WARDEN_MEM_CHECK_MAX, + CONFIG_WARDEN_RANDOM_CHECK_MAX, + CONFIG_ENABLE_PASSIVE_ANTICHEAT, + CONFIG_ANTICHEAT_CUMULATIVE_DELAY, + + // RaF + CONFIG_UINT32_RAF_MAXGRANTLEVEL, + CONFIG_UINT32_RAF_MAXREFERALS, + CONFIG_UINT32_RAF_MAXREFERERS, + // Ganking penalty + CONFIG_ENABLE_GANKING_PENALTY, + CONFIG_GANKING_PENALTY_EXPIRE, + CONFIG_GANKING_KILLS_ALERT, + + // Network + CONFIG_KICK_PLAYER_ON_BAD_PACKET, + CONFIG_VALUE_COUNT }; @@ -331,6 +401,7 @@ enum Rates RATE_POWER_RAGE_INCOME, RATE_POWER_RAGE_LOSS, RATE_POWER_FOCUS, + RATE_LOYALTY, RATE_SKILL_DISCOVERY, RATE_DROP_ITEM_POOR, RATE_DROP_ITEM_NORMAL, @@ -345,26 +416,7 @@ enum Rates RATE_XP_QUEST, RATE_XP_EXPLORE, RATE_XP_PAST_70, - RATE_REPUTATION_GAIN, - RATE_REPUTATION_LOWLEVEL_KILL, - RATE_REPUTATION_LOWLEVEL_QUEST, - RATE_CREATURE_NORMAL_HP, - RATE_CREATURE_ELITE_ELITE_HP, - RATE_CREATURE_ELITE_RAREELITE_HP, - RATE_CREATURE_ELITE_WORLDBOSS_HP, - RATE_CREATURE_ELITE_RARE_HP, - RATE_CREATURE_NORMAL_DAMAGE, - RATE_CREATURE_ELITE_ELITE_DAMAGE, - RATE_CREATURE_ELITE_RAREELITE_DAMAGE, - RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE, - RATE_CREATURE_ELITE_RARE_DAMAGE, - RATE_CREATURE_NORMAL_SPELLDAMAGE, - RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE, - RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE, - RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE, - RATE_CREATURE_ELITE_RARE_SPELLDAMAGE, - RATE_CREATURE_AGGRO, - RATE_CREATURE_GUARD_AGGRO, + RATE_REST_INGAME, RATE_REST_OFFLINE_IN_TAVERN_OR_CITY, RATE_REST_OFFLINE_IN_WILDERNESS, @@ -376,13 +428,39 @@ enum Rates RATE_MINING_AMOUNT, RATE_MINING_NEXT, RATE_TALENT, - RATE_LOYALTY, - RATE_CORPSE_DECAY_LOOTED, + RATE_REPUTATION_GAIN, + RATE_REPUTATION_LOWLEVEL_KILL, + RATE_REPUTATION_LOWLEVEL_QUEST, RATE_INSTANCE_RESET_TIME, RATE_DURABILITY_LOSS_DAMAGE, - RATE_DURABILITY_LOSS_PARRY, RATE_DURABILITY_LOSS_ABSORB, RATE_DURABILITY_LOSS_BLOCK, + RATE_DURABILITY_LOSS_PARRY, + + RATE_CREATURE_AGGRO, + RATE_CREATURE_GUARD_AGGRO, + RATE_CORPSE_DECAY_LOOTED, + RATE_CREATURE_NORMAL_DAMAGE, + RATE_CREATURE_ELITE_ELITE_DAMAGE, + RATE_CREATURE_ELITE_RAREELITE_DAMAGE, + RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE, + RATE_CREATURE_ELITE_RARE_DAMAGE, + RATE_CREATURE_NORMAL_SPELLDAMAGE, + RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE, + RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE, + RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE, + RATE_CREATURE_ELITE_RARE_SPELLDAMAGE, + RATE_CREATURE_NORMAL_HP, + RATE_CREATURE_ELITE_ELITE_HP, + RATE_CREATURE_ELITE_RAREELITE_HP, + RATE_CREATURE_ELITE_WORLDBOSS_HP, + RATE_CREATURE_ELITE_RARE_HP, + + CONFIG_GANKING_PENALTY_PER_KILL, + CONFIG_FLOAT_RATE_RAF_XP, + CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL, + + CONFIG_ANTICHEAT_SPEEDHACK_TOLERANCE, MAX_RATES }; @@ -452,6 +530,7 @@ enum RealmZone #define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table #define SCRIPT_COMMAND_PLAY_SOUND 18 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent) #define SCRIPT_COMMAND_KILL 19 // datalong removecorpse +#define SCRIPT_COMMAND_SET_INST_DATA 20 // source = any, datalong = type, datalong2 = data /// Storage class for commands issued for delayed execution @@ -602,6 +681,7 @@ class HELLGROUND_EXPORT World uint32 GetActiveAndQueuedSessionCount() const { return m_sessions.size(); } uint32 GetActiveSessionCount() const { return m_sessions.size() - m_QueuedPlayer.size(); } uint32 GetQueuedSessionCount() const { return m_QueuedPlayer.size(); } + const SessionMap& GetAllSessions() const { return m_sessions; } uint32 GetLoggedInCharsCount(TeamId team); uint32 ModifyLoggedInCharsCount(TeamId team, int val); @@ -617,12 +697,11 @@ class HELLGROUND_EXPORT World void RemoveWeather(uint32 zone_id); /// Get the active session server limit (or security level limitations) - uint32 GetPlayerAmountLimit() const { return m_playerLimit >= 0 ? m_playerLimit : 0; } + uint32 GetPlayerAmountLimit() const { return m_playerLimit; } uint64 GetMinimumPermissionMask() const { return m_requiredPermissionMask; } /// Set the active session server limit (or security level limitation) - void SetPlayerLimit(int32 limit, bool needUpdate = false); - void SetMinimumPermissionMask(uint64 perms) { m_requiredPermissionMask = perms; } + void SetPlayerLimit(int32 limit); //player Queue typedef std::list Queue; @@ -676,7 +755,7 @@ class HELLGROUND_EXPORT World void QueueGuildAnnounce(uint32 guildid, uint32 team, std::string &msg); void SendGuildAnnounce(uint32 team, ...); - void SendWorldText(int32 string_id, ...); + void SendWorldText(int32 string_id, uint32 preventFlags, ...); void SendWorldTextForLevels(uint32 minLevel, uint32 maxLevel, uint32 preventFlags, int32 string_id, ...); void SendGlobalText(const char* text, WorldSession *self); void SendGMText(int32 string_id, ...); @@ -703,27 +782,33 @@ class HELLGROUND_EXPORT World void Update(uint32 diff); void UpdateSessions(const uint32 & diff); - /// Set a server rate (see #Rates) - void setRate(Rates rate,float value) { rate_values[rate]=value; } - /// Get a server rate (see #Rates) - float getRate(Rates rate) const { return rate_values[rate]; } + void setConfig(WorldConfigs index, uint32 value) + { + if (index < CONFIG_VALUE_COUNT) + m_configs[index] = value; + } + + /* Unused + void setConfig(Rates index, float value) + { + if (index < MAX_RATES) + rate_values[index] = value; + }*/ - /// Set a server configuration element (see #WorldConfigs) - void setConfig(uint32 index,uint32 value) + uint32 getConfig(WorldConfigs index) const { - if (index + * Copyright (C) 2012-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,15 +8,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldEventProcessor.h" +#include "ObjectAccessor.h" #include "Player.h" @@ -51,9 +52,11 @@ void WorldEventProcessor::ExecuteEvents() // get and remove event from queue WorldEvent* event = curr->second; - _events.erase(curr); - event->Execute(); + if (Player* player = ObjectAccessor::GetPlayer(curr->first)) + event->Execute(); + + _events.erase(curr); delete event; } } diff --git a/src/game/WorldEventProcessor.h b/src/game/WorldEventProcessor.h index c1776cf85..1ad435bb4 100644 --- a/src/game/WorldEventProcessor.h +++ b/src/game/WorldEventProcessor.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 HellGround + * Copyright (C) 2012-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +8,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WORLDEVENTPROCESSOR_H -#define WORLDEVENTPROCESSOR_H +#ifndef HELLGROUND_WORLDEVENTPROCESSOR_H +#define HELLGROUND_WORLDEVENTPROCESSOR_H #include diff --git a/src/game/WorldLog.cpp b/src/game/WorldLog.cpp deleted file mode 100755 index 7671689ac..000000000 --- a/src/game/WorldLog.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** \file - \ingroup u2w -*/ - -#include "WorldLog.h" -#include "Config/Config.h" - -#define WORLD_LOG_FILE_STRING "world.log" - -/// Open the log file (if specified so in the configuration file) -void WorldLog::Initialize() -{ - std::string logsDir = sConfig.GetStringDefault("LogsDir",""); - - if (!logsDir.empty()) - { - if ((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\')) - logsDir.append("/"); - } - - std::string logname = sConfig.GetStringDefault("WorldLogFile", ""); - if (!logname.empty()) - { - i_file = fopen((logsDir+logname).c_str(), "w"); - } -} - diff --git a/src/game/WorldLog.h b/src/game/WorldLog.h deleted file mode 100755 index 1784a9e3a..000000000 --- a/src/game/WorldLog.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/// \addtogroup u2w -/// @{ -/// \file - -#ifndef HELLGROUND_WORLDLOG_H -#define HELLGROUND_WORLDLOG_H - -#include "ace/Singleton.h" - -#include "Common.h" -#include "Log.h" - -#include - -/// %Log packets to a file -class WorldLog -{ - friend class ACE_Singleton; - WorldLog() : i_file(NULL) { Initialize(); } - WorldLog(const WorldLog &); - WorldLog& operator=(const WorldLog &); - - ACE_Thread_Mutex Lock; - - /// Close the file in destructor - ~WorldLog() - { - if (i_file != NULL) - fclose(i_file); - i_file = NULL; - } - - public: - void Initialize(); - /// Is the world logger active? - bool LogWorld(void) const { return (i_file != NULL); } - /// %Log to the file - void Log(char const *fmt, ...) - { - if (LogWorld()) - { - ACE_GUARD(ACE_Thread_Mutex, Guard, Lock); - //ASSERT(i_file); - - va_list args; - va_start(args, fmt); - vfprintf(i_file, fmt, args); - va_end(args); - - fflush(i_file); - } - } - - private: - FILE *i_file; -}; - -#define sWorldLog (*ACE_Singleton::instance()) - -#endif -/// @} diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index c5b3eab75..8c049ea96 100755 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -45,6 +45,9 @@ #include "SocialMgr.h" #include "WardenWin.h" #include "WardenMac.h" +#include "WardenChat.h" +#include "luaengine/HookMgr.h" +#include "GuildMgr.h" bool MapSessionFilter::Process(WorldPacket * packet) { @@ -88,11 +91,12 @@ bool WorldSessionFilter::Process(WorldPacket* packet) } /// WorldSession constructor -WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint64 permissions, uint8 expansion, LocaleConstant locale, time_t mute_time, std::string mute_reason, uint64 accFlags, uint16 opcDisabled) : +WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint64 permissions, uint8 expansion, LocaleConstant locale, time_t mute_time, std::string mute_reason, time_t trollmute_time, std::string trollmute_reason, uint64 accFlags, uint16 opcDisabled) : LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time), m_muteReason(mute_reason), -_player(NULL), m_Socket(sock), m_permissions(permissions), _accountId(id), m_expansion(expansion), m_opcodesDisabled(opcDisabled), +m_trollmuteTime(trollmute_time), m_trollmuteReason(trollmute_reason), _player(NULL), m_Socket(sock), +m_permissions(permissions), _accountId(id), m_expansion(expansion), m_opcodesDisabled(opcDisabled), m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), -_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerSave(false), m_playerRecentlyLogout(false), m_latency(0), +_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerSave(false), m_playerRecentlyLogout(false), m_latency(0), m_clientTimeDelay(0), m_accFlags(accFlags), m_Warden(NULL) { _mailSendTimer.Reset(5*IN_MILISECONDS); @@ -160,7 +164,7 @@ char const* WorldSession::GetPlayerName() const void WorldSession::SaveOpcodesDisableFlags() { static SqlStatementID saveOpcodesDisabled; - SqlStatement stmt = AccountsDatabase.CreateStatement(saveOpcodesDisabled, "UPDATE account SET opcodesDisabled = ? WHERE id = ?"); + SqlStatement stmt = AccountsDatabase.CreateStatement(saveOpcodesDisabled, "UPDATE account SET opcodes_disabled = ? WHERE account_id = ?"); stmt.PExecute(m_opcodesDisabled, GetAccountId()); } @@ -176,11 +180,16 @@ void WorldSession::RemoveOpcodeDisableFlag(uint16 flag) SaveOpcodesDisableFlags(); } -void WorldSession::SaveAccountFlags() +void WorldSession::SaveAccountFlags(uint32 accountId, uint64 flags) { - static SqlStatementID saveAccountFlags; + SqlStatementID saveAccountFlags; SqlStatement stmt = AccountsDatabase.CreateStatement(saveAccountFlags, "UPDATE account SET account_flags = ? WHERE account_id = ?"); - stmt.PExecute(m_accFlags, GetAccountId()); + stmt.PExecute(flags, accountId); +} + +void WorldSession::SaveAccountFlags() +{ + SaveAccountFlags(GetAccountId(), m_accFlags); } void WorldSession::AddAccountFlag(AccountFlags flag) @@ -247,13 +256,13 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) if (!new_packet) return; - OpcodesCooldown::iterator opItr = _opcodesCooldown.find(new_packet->GetOpcode()); - if (opItr != _opcodesCooldown.end()) + auto i = _opcodesCooldown.find(new_packet->GetOpcode()); + if (i != _opcodesCooldown.end()) { - if (opItr->second.Passed()) - opItr->second.Reset(); - else + if (!i->second.Passed()) return; + + i->second.SetCurrent(0); } _recvQueue.add(new_packet); @@ -273,6 +282,9 @@ void WorldSession::ProcessPacket(WorldPacket* packet) if (!packet) return; + //if (!sHookMgr->OnPacketReceive(this, *packet)) + // return; + if (packet->GetOpcode() >= NUM_MSG_TYPES) { sLog.outLog(LOG_DEFAULT, "ERROR: SESSION: received non-existed opcode %s (0x%.4X)", @@ -293,6 +305,12 @@ void WorldSession::ProcessPacket(WorldPacket* packet) } else if (_player->IsInWorld()) (this->*opHandle.handler)(*packet); + else if (_player->HasTeleportTimerPassed(_player->GetSession()->HasPermissions(PERM_GMT_DEV)?10000 : 60000)) + //player should not be in game yet but sends opcodes, 60 sec lag is hard to belive, unstuck him + { + HandleMoveWorldportAckOpcode(); + (this->*opHandle.handler)(*packet); + } // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; @@ -400,14 +418,14 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) overtime = true; } - if (overtime && !(GetPermissions() & PERM_GMT)) + if (overtime && !HasPermissions(PERM_GMT)) { switch (sWorld.getConfig(CONFIG_SESSION_UPDATE_OVERTIME_METHOD)) { case OVERTIME_IPBAN: - AccountsDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'CONSOLE', 'bye bye')", GetRemoteAddress().c_str()); + AccountsDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'CONSOLE', 'bye bye', '1')", GetRemoteAddress().c_str()); case OVERTIME_ACCBAN: - AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'CONSOLE', 'bye bye')", GetAccountId(), PUNISHMENT_BAN); + AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'CONSOLE', 'bye bye', '1')", GetAccountId(), PUNISHMENT_BAN); case OVERTIME_KICK: KickPlayer(); case OVERTIME_LOG: @@ -419,11 +437,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) bool logverbose = false; if (verbose == 1) // log only if overtime - if (overtime && !(GetPermissions() & PERM_GMT) && sWorld.getConfig(CONFIG_SESSION_UPDATE_OVERTIME_METHOD) >= OVERTIME_LOG) + if (overtime && !HasPermissions(PERM_GMT) && sWorld.getConfig(CONFIG_SESSION_UPDATE_OVERTIME_METHOD) >= OVERTIME_LOG) logverbose = true; if (verbose == 2) // log if session update is logged as slow - if (overtimediff > sWorld.getConfig(CONFIG_MIN_LOG_SESSION_UPDATE)) + if (overtimediff > sWorld.getConfig(CONFIG_SESSION_UPDATE_MIN_LOG_DIFF)) logverbose = true; if (logverbose) @@ -486,11 +504,16 @@ void WorldSession::LogoutPlayer(bool Save) if (uint64 lguid = GetPlayer()->GetLootGUID()) DoLootRelease(lguid); + ///- used by eluna + sHookMgr->OnLogout(_player); + sLog.outLog(LOG_CHAR, "Account: %u Character:[%s] (guid:%u) Logged out.", + GetAccountId(),_player->GetName(),_player->GetGUIDLow()); + ///- If the player just died before logging out, make him appear as a ghost //FIXME: logout must be delayed in case lost connection with client in time of combat if (_player->GetDeathTimer()) { - _player->getHostilRefManager().deleteReferences(); + _player->getHostileRefManager().deleteReferences(); _player->BuildPlayerRepop(); _player->RepopAtGraveyard(); } @@ -499,7 +522,7 @@ void WorldSession::LogoutPlayer(bool Save) if (!_player->getAttackers().empty() || (_player->GetMap() && _player->GetMap()->EncounterInProgress(_player))) { _player->CombatStop(); - _player->getHostilRefManager().setOnlineOfflineState(false); + _player->getHostileRefManager().setOnlineOfflineState(false); _player->RemoveAllAurasOnDeath(); // build set of player who attack _player or who have pet attacking of _player @@ -546,6 +569,11 @@ void WorldSession::LogoutPlayer(bool Save) _player->BuildPlayerRepop(); _player->RepopAtGraveyard(); } + else + { + _player->RemoveSpellsCausingAura(SPELL_AURA_MOD_UNATTACKABLE); + _player->RemoveCharmAuras(); + } } //drop a flag if player is carrying it @@ -564,7 +592,7 @@ void WorldSession::LogoutPlayer(bool Save) } ///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members - Guild *guild = sObjectMgr.GetGuildById(_player->GetGuildId()); + Guild *guild = sGuildMgr.GetGuildById(_player->GetGuildId()); if (guild) { guild->LoadPlayerStatsByGuid(_player->GetGUID()); @@ -695,7 +723,7 @@ void WorldSession::SendNotification(const char *format,...) void WorldSession::SendNotification(int32 string_id,...) { - char const* format = GetTrinityString(string_id); + char const* format = GetHellgroundString(string_id); if (format) { va_list ap; @@ -711,9 +739,9 @@ void WorldSession::SendNotification(int32 string_id,...) } } -const char * WorldSession::GetTrinityString(int32 entry) const +const char * WorldSession::GetHellgroundString(int32 entry) const { - return sObjectMgr.GetTrinityString(entry,GetSessionDbLocaleIndex()); + return sObjectMgr.GetHellgroundString(entry,GetSessionDbLocaleIndex()); } void WorldSession::Handle_NULL(WorldPacket& recvPacket) @@ -766,10 +794,14 @@ void WorldSession::InitWarden(BigNumber *K, uint8& OperatingSystem) switch (OperatingSystem) { case CLIENT_OS_WIN: - m_Warden = (WardenBase*)new WardenWin(); + m_Warden = new WardenWin(); break; case CLIENT_OS_OSX: -// m_Warden = (WardenBase*)new WardenMac(); +// m_Warden = new WardenMac(); + sLog.outLog(LOG_WARDEN, "Client %u got OSX client operating system (%i)", GetAccountId(), OperatingSystem); + break; + case CLIENT_OS_CHAT: + m_Warden = new WardenChat(); break; default: sLog.outLog(LOG_WARDEN, "Client %u got unsupported operating system (%i)", GetAccountId(), OperatingSystem); @@ -793,7 +825,7 @@ uint32 WorldSession::RecordSessionTimeDiff(const char *text, ...) uint32 thisTime = WorldTimer::getMSTime(); uint32 diff = WorldTimer::getMSTimeDiff(m_currentSessionTime, thisTime); - if (diff > sWorld.getConfig(CONFIG_MIN_LOG_SESSION_UPDATE)) + if (diff > sWorld.getConfig(CONFIG_SESSION_UPDATE_MIN_LOG_DIFF)) { va_list ap; char str [256]; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h old mode 100755 new mode 100644 index 10f56d1b4..fda75d0e9 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2011 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef __WORLDSESSION_H -#define __WORLDSESSION_H +#ifndef HELLGROUND_WORLDSESSION_H +#define HELLGROUND_WORLDSESSION_H #include "Common.h" #include "Log.h" @@ -70,6 +70,7 @@ enum AccountFlags ACC_BLIZZLIKE_RATES = 0x0008, // enables fully blizzlike rates for account. ex: XP, QXP etc ACC_HIDE_BONES = 0x0010, // client won't show bones created from corpses ACC_DISABLED_BGANN = 0x0020, // BG start announce will be disabled for this account + ACC_DISABLED_BROADCAST = 0x0040, // Broadcast accounces will be disabled for this account }; enum PartyOperation @@ -152,7 +153,7 @@ class HELLGROUND_IMPORT_EXPORT WorldSession { friend class CharacterHandler; public: - WorldSession(uint32 id, WorldSocket *sock, uint64 permissions, uint8 expansion, LocaleConstant locale, time_t mute_time = 0, std::string mute_reason = "", uint64 accFlags = 0, uint16 opcDisabled = 0); + WorldSession(uint32 id, WorldSocket *sock, uint64 permissions, uint8 expansion, LocaleConstant locale, time_t mute_time = 0, std::string mute_reason = "", time_t trollmute_time = 0, std::string trollmute_reason = "", uint64 accFlags = 0, uint16 opcDisabled = 0); ~WorldSession(); bool PlayerLoading() const { return m_playerLoading; } @@ -178,6 +179,7 @@ class HELLGROUND_IMPORT_EXPORT WorldSession uint32 RecordVerboseTimeDiff(bool reset); uint64 GetPermissions() const { return m_permissions; } + bool HasPermissions(uint64 perms) const { return m_permissions & perms; } uint32 GetAccountId() const { return _accountId; } Player* GetPlayer() const { return _player; } char const* GetPlayerName() const; @@ -187,6 +189,8 @@ class HELLGROUND_IMPORT_EXPORT WorldSession uint8 Expansion() const { return m_expansion; } void SaveAccountFlags(); + static void SaveAccountFlags(uint32 accountId, uint64 flags); + bool IsAccountFlagged(AccountFlags flag) const { return m_accFlags & flag; } void AddAccountFlag(AccountFlags flag); void RemoveAccountFlag(AccountFlags flag); @@ -306,16 +310,20 @@ class HELLGROUND_IMPORT_EXPORT WorldSession // Account mute time time_t m_muteTime; std::string m_muteReason; + time_t m_trollmuteTime; + std::string m_trollmuteReason; // Locales LocaleConstant GetSessionDbcLocale() const { return m_sessionDbcLocale; } int GetSessionDbLocaleIndex() const { return m_sessionDbLocaleIndex; } - const char *GetTrinityString(int32 entry) const; + const char *GetHellgroundString(int32 entry) const; uint32 GetLatency() const { return m_latency; } void SetLatency(uint32 latency) { m_latency = latency; } uint32 getDialogStatus(Player *pPlayer, Object* questgiver, uint32 defstatus); + void ResetClientTimeDelay() { m_clientTimeDelay = 0; } + public: // opcodes handlers void Handle_NULL(WorldPacket& recvPacket); // not used @@ -471,7 +479,6 @@ class HELLGROUND_IMPORT_EXPORT WorldSession void HandleTurnInPetitionOpcode(WorldPacket& recv_data); void HandleGuildQueryOpcode(WorldPacket& recvPacket); - void HandleGuildCreateOpcode(WorldPacket& recvPacket); void HandleGuildInviteOpcode(WorldPacket& recvPacket); void HandleGuildRemoveOpcode(WorldPacket& recvPacket); void HandleGuildAcceptOpcode(WorldPacket& recvPacket); @@ -738,13 +745,22 @@ class HELLGROUND_IMPORT_EXPORT WorldSession void HandleGuildBankBuyTab(WorldPacket& recv_data); void HandleGuildBankTabText(WorldPacket& recv_data); void HandleGuildBankSetTabText(WorldPacket& recv_data); - - private: + + // Other + void HandleGetMirrorimageData(WorldPacket& recv_data); + + void HandleGrantLevel(WorldPacket& recv_data); + void HandleAcceptGrantLevel(WorldPacket& recv_data); + + private: // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); bool CheckMailBox(ObjectGuid& guid); + + uint32 m_clientTimeDelay; + // logging helper void logUnexpectedOpcode(WorldPacket *packet, const char * reason); Player *_player; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index a51189182..d150042b7 100755 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -1,22 +1,22 @@ /* -* Copyright(C) 2005-2008 MaNGOS -* -* Copyright(C) 2008 Trinity -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include #include @@ -45,8 +45,8 @@ #include "WorldSession.h" #include "WorldSocketMgr.h" #include "Log.h" -#include "WorldLog.h" #include "DBCStores.h" +#include "luaengine/HookMgr.h" #if defined(__GNUC__) #pragma pack(1) @@ -141,26 +141,8 @@ int WorldSocket::SendPacket(const WorldPacket& pct) if (closing_) return -1; - // Dump outgoing packet. - if (sWorldLog.LogWorld()) - { - sWorldLog.Log("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s(0x%.4X)\nDATA:\n", - (uint32) get_handle(), - pct.size(), - LookupOpcodeName(pct.GetOpcode()), - pct.GetOpcode()); - - uint32 p = 0; - while (p < pct.size()) - { - for (uint32 j = 0; j < 16 && p < pct.size(); j++) - sWorldLog.Log("%.2X ", const_cast(pct)[p++]); - - sWorldLog.Log("\n"); - } - - sWorldLog.Log("\n\n"); - } + //if (!sHookMgr->OnPacketSend(m_Session, *const_cast(&pct))) + // return 0; if (iSendPacket(pct) == -1) { @@ -578,25 +560,6 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) if (closing_) return -1; - // Dump received packet. - if (sWorldLog.LogWorld()) - { - sWorldLog.Log("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s(0x%.4X)\nDATA:\n", - (uint32) get_handle(), - new_pct->size(), - LookupOpcodeName(new_pct->GetOpcode()), - new_pct->GetOpcode()); - - uint32 p = 0; - while (p < new_pct->size()) - { - for (uint32 j = 0; j < 16 && p < new_pct->size(); j++) - sWorldLog.Log("%.2X ",(*new_pct)[p++]); - sWorldLog.Log("\n"); - } - sWorldLog.Log("\n\n"); - } - try { switch (opcode) @@ -621,6 +584,12 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) if (m_Session != NULL) { + if((operatingSystem == CLIENT_OS_CHAT) && !IsChatOpcode(opcode)) + { + sLog.outLog(LOG_WARDEN, "Chat Client for account %u send illegal opcode %u",m_Session->GetAccountId(),opcode); + if (sWorld.getConfig(CONFIG_WARDEN_KICK)) + m_Session->KickPlayer(); + } // OK ,give the packet to WorldSession aptr.release(); // WARNINIG here we call it with locks held. @@ -754,7 +723,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) Field* fields = result->Fetch(); std::string lastLocalIp = fields[12].GetString(); - uint8 operatingSystem = fields[11].GetUInt8(); + operatingSystem = fields[11].GetUInt8(); expansion =((sWorld.getConfig(CONFIG_EXPANSION) > fields[7].GetUInt8()) ? fields[7].GetUInt8() : sWorld.getConfig(CONFIG_EXPANSION)); N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); @@ -774,7 +743,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) OPENSSL_free((void*) vStr); ///- Re-check ip locking(same check as in realmd). - if (fields[4].GetUInt8() == 1) // if ip is locked + if (fields[4].GetUInt8() == ACCOUNT_STATE_IP_LOCKED) // if ip is locked { if (strcmp(fields[3].GetString(), GetRemoteAddress().c_str())) { @@ -807,7 +776,8 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) "FROM account_punishment " "WHERE account_id = '%u' " "AND punishment_type_id = '%u' " - "AND expiration_date > UNIX_TIMESTAMP()", + "AND active = 1 " + "AND (expiration_date > UNIX_TIMESTAMP() OR expiration_date = punishment_date)", id, PUNISHMENT_BAN); if (banresult) // if account banned @@ -823,7 +793,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) // Check locked state for server sWorld.UpdateRequiredPermissions(); uint64 minimumPermissions = sWorld.GetMinimumPermissionMask(); - sLog.outDebug("Allowed Level: %u Player Level %u", minimumPermissions, permissionMask); + sLog.outDebug("Allowed permission mask: %u Player permission mask: %u", minimumPermissions, permissionMask); if (!(permissionMask & minimumPermissions)) { WorldPacket Packet(SMSG_AUTH_RESPONSE, 1); @@ -873,7 +843,6 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) // Update the last_ip in the database // No SQL injection, username escaped. static SqlStatementID updAccount; - SqlStatement stmt = AccountsDatabase.CreateStatement(updAccount, "UPDATE account SET last_ip = ? WHERE account_id = ?"); stmt.PExecute(address.c_str(), id); @@ -883,9 +852,11 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) "reason " "FROM account_punishment " "WHERE account_id = '%u' " - "AND expiration_date > UNIX_TIMESTAMP() " + "AND active = 1 " + "AND punishment_type_id = '%u' " + "AND (expiration_date > UNIX_TIMESTAMP() OR expiration_date = punishment_date) " "ORDER BY expiration_date DESC LIMIT 1", - id); + id,PUNISHMENT_MUTE); time_t mutetime; std::string mutereason; @@ -902,17 +873,44 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) mutereason = ""; } + muteresult = AccountsDatabase.PQuery("SELECT " + "expiration_date, " + "reason " + "FROM account_punishment " + "WHERE account_id = '%u' " + "AND active = 1 " + "AND punishment_type_id = '%u' " + "AND (expiration_date > UNIX_TIMESTAMP() OR expiration_date = punishment_date) " + "ORDER BY expiration_date DESC LIMIT 1", + id,PUNISHMENT_TROLLMUTE); + + time_t trollmutetime; + std::string trollmutereason; + + if (muteresult) + { + Field* mutefields = muteresult->Fetch(); + trollmutetime = time_t(mutefields[0].GetUInt64()); + trollmutereason = mutefields[1].GetString(); + } + else + { + trollmutetime = 0; + trollmutereason = ""; + } + // NOTE ATM the socket is singlethreaded, have this in mind ... - ACE_NEW_RETURN(m_Session, WorldSession(id, this, permissionMask, expansion, locale, mutetime, mutereason, accFlags, opcDis), -1); + ACE_NEW_RETURN(m_Session, WorldSession(id, this, permissionMask, expansion, locale, mutetime, mutereason, trollmutetime, trollmutereason, accFlags, opcDis), -1); m_Crypt.SetKey(&K); m_Crypt.Init(); AccountsDatabase.escape_string(lastLocalIp); + AccountsDatabase.PExecute("INSERT INTO account_login VALUES ('%u', NOW(), '%s', '%s', '%u')", id, address.c_str(), lastLocalIp.c_str(),IPToLocation(address)); - AccountsDatabase.PExecute("INSERT INTO account_login VALUES ('%u', UNIX_TIMESTAMP(), '%s', '%s')", id, address.c_str(), lastLocalIp.c_str()); - - m_Session->InitWarden(&K, operatingSystem); + // Initialize Warden system only if it is enabled by config + if (sWorld.getConfig(CONFIG_WARDEN_ENABLED)) + m_Session->InitWarden(&K, operatingSystem); // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec ACE_OS::sleep(ACE_Time_Value(0, 10000)); @@ -960,7 +958,7 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket) { ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); - if (m_Session && !(m_Session->GetPermissions() & PERM_GMT)) + if (m_Session && !m_Session->HasPermissions(PERM_GMT)) { sLog.outLog(LOG_DEFAULT, "ERROR: WorldSocket::HandlePing: Player kicked for " "overspeeded pings address = %s", @@ -979,7 +977,10 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket) ACE_GUARD_RETURN(LockType, Guard, m_SessionLock, -1); if (m_Session) + { m_Session->SetLatency(latency); + m_Session->ResetClientTimeDelay(); + } else { sLog.outLog(LOG_DEFAULT, "ERROR: WorldSocket::HandlePing: peer sent CMSG_PING, " @@ -1050,3 +1051,58 @@ bool WorldSocket::iFlushPacketQueue() return haveone; } + +bool WorldSocket::IsChatOpcode(uint16 opcode) +{ + switch(opcode) + { + case CMSG_CHAR_ENUM: //0x037 + case CMSG_PLAYER_LOGIN: //0x03D + case CMSG_LOGOUT_REQUEST: //0x04B + case CMSG_NAME_QUERY: //0x050 + case CMSG_ITEM_QUERY_SINGLE: //0x056 + case CMSG_QUEST_QUERY: //0x05C + case CMSG_WHO: //0x062 + case CMSG_CONTACT_LIST: //0x066 + case CMSG_ADD_FRIEND: //0x069 + case CMSG_DEL_FRIEND: //0x06A + case CMSG_ADD_IGNORE: //0x06C + case CMSG_DEL_IGNORE: //0x06D + case CMSG_GUILD_ROSTER: //0x089 + case CMSG_MESSAGECHAT: //0x095 + case CMSG_JOIN_CHANNEL: //0x097 + case CMSG_LEAVE_CHANNEL: //0x098 + case CMSG_CHANNEL_LIST: //0x09A + case CMSG_EMOTE: //0x102 + case CMSG_TEXT_EMOTE: //0x104 + case CMSG_ITEM_NAME_QUERY: //0x2C4 + return true; + } + return false; +} + +uint32 WorldSocket::IPToLocation(const std::string& IP) +{ + std::ostringstream ret; + uint32 addressAsNumber = 0; + std::istringstream TempAddress(IP); + int addrBlock; + + TempAddress >> addrBlock; TempAddress.get(); addressAsNumber += addrBlock; addressAsNumber *= 256; + TempAddress >> addrBlock; TempAddress.get(); addressAsNumber += addrBlock; addressAsNumber *= 256; + TempAddress >> addrBlock; TempAddress.get(); addressAsNumber += addrBlock; addressAsNumber *= 256; + TempAddress >> addrBlock; addressAsNumber += addrBlock; + + QueryResultAutoPtr result = GameDataDatabase.PQuery( + "SELECT locId FROM blocks " + "WHERE endIpNum >= %u order by endIpNum limit 1;",addressAsNumber,addressAsNumber); + + if (!result) + { + ret << "Unknown Location for Ip " << IP << " (" << addressAsNumber << ")"; + sLog.outString("%s", ret.str().c_str()); + return 0; + } + + return result->Fetch()[0].GetUInt32(); +} diff --git a/src/game/WorldSocket.h b/src/game/WorldSocket.h index 34f41edf9..4abbe7167 100755 --- a/src/game/WorldSocket.h +++ b/src/game/WorldSocket.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \addtogroup u2w User to World Communication @@ -24,8 +24,8 @@ * \author Derex */ -#ifndef _WORLDSOCKET_H -#define _WORLDSOCKET_H +#ifndef HELLGROUND_WORLDSOCKET_H +#define HELLGROUND_WORLDSOCKET_H #include #include @@ -181,6 +181,10 @@ class WorldSocket : protected WorldHandler /// to mark the socket for output). bool iFlushPacketQueue (); + // Use to check if custom chat only client can use such opcode + bool IsChatOpcode(uint16 opcode); + + static uint32 IPToLocation(const std::string& IP); private: /// Time in which the last ping was received ACE_Time_Value m_LastPingTime; @@ -228,6 +232,8 @@ class WorldSocket : protected WorldHandler bool m_OutActive; uint32 m_Seed; + + uint8 operatingSystem; // stores client's operating system }; #endif /* _WORLDSOCKET_H */ diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 0d216b627..68ee5fec6 100755 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2011 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file WorldSocketMgr.cpp diff --git a/src/game/WorldSocketMgr.h b/src/game/WorldSocketMgr.h index e9ca074a8..510cdc79e 100755 --- a/src/game/WorldSocketMgr.h +++ b/src/game/WorldSocketMgr.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2011 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ * \author Derex */ -#ifndef __WORLDSOCKETMGR_H -#define __WORLDSOCKETMGR_H +#ifndef HELLGROUND_WORLDSOCKETMGR_H +#define HELLGROUND_WORLDSOCKETMGR_H #include #include diff --git a/src/game/ZoneScript.h b/src/game/ZoneScript.h index 7d7d5e78d..afa3ce2ec 100644 --- a/src/game/ZoneScript.h +++ b/src/game/ZoneScript.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008-2009 Trinity + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef ZONE_SCRIPT_H_ -#define ZONE_SCRIPT_H_ +#ifndef HELLGROUND_ZONE_SCRIPT_H +#define HELLGROUND_ZONE_SCRIPT_H #include "Common.h" #include "Creature.h" @@ -35,6 +36,7 @@ class HELLGROUND_IMPORT_EXPORT ZoneScript virtual uint32 GetGameObjectEntry(uint32 guidlow, uint32 entry) { return entry; } virtual void OnCreatureCreate(Creature *, bool add) {} + virtual void OnCreatureDeath(Creature* /*creature*/) {} virtual void OnGameObjectCreate(GameObject *go, bool add) {} //All-purpose data storage 64 bit diff --git a/src/game/luaengine/AuraMethods.h b/src/game/luaengine/AuraMethods.h new file mode 100644 index 000000000..7dbf31ec6 --- /dev/null +++ b/src/game/luaengine/AuraMethods.h @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef AURAMETHODS_H +#define AURAMETHODS_H + +namespace LuaAura +{ + int GetCaster(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetCaster()); + return 1; + } + + int GetCasterGUID(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetCasterGUID()); + return 1; + } + + int GetCasterLevel(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetCaster()->getLevel()); + return 1; + } + + int GetDuration(lua_State* L, Aura* aura) + { +#ifdef MANGOS + sEluna->Push(L, aura->GetAuraDuration()); +#else + sEluna->Push(L, aura->GetDuration()); +#endif + return 1; + } + + int GetCharges(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetStackAmount()); + return 1; + } + + int GetAuraId(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetId()); + return 1; + } + + int GetMaxDuration(lua_State* L, Aura* aura) + { +#ifdef MANGOS + sEluna->Push(L, aura->GetAuraMaxDuration()); +#else + sEluna->Push(L, aura->GetMaxDuration()); +#endif + return 1; + } + + int GetStackAmount(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetStackAmount()); + return 1; + } + + int SetDuration(lua_State* L, Aura* aura) + { + int duration = sEluna->CHECKVAL(L, 2); + + aura->SetAuraDuration(duration); + return 0; + } + + int SetMaxDuration(lua_State* L, Aura* aura) + { + int duration = sEluna->CHECKVAL(L, 2); + + aura->SetAuraMaxDuration(duration); + return 0; + } + + int SetStackAmount(lua_State* L, Aura* aura) + { + int amount = sEluna->CHECKVAL(L, 2); + int duration = sEluna->CHECKVAL(L, 2); + + aura->SetStackAmount(amount); + return 0; + } + + int Remove(lua_State* L, Aura* aura) + { + int duration = sEluna->CHECKVAL(L, 2); + + aura->_RemoveAura(); + return 0; + } + + int GetOwner(lua_State* L, Aura* aura) + { + sEluna->Push(L, aura->GetTarget()); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/CorpseMethods.h b/src/game/luaengine/CorpseMethods.h new file mode 100644 index 000000000..64f4425c7 --- /dev/null +++ b/src/game/luaengine/CorpseMethods.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef CORPSEMETHODS_H +#define CORPSEMETHODS_H + +namespace LuaCorpse +{ + // GetOwnerGUID() + int GetOwnerGUID(lua_State* L, Corpse* corpse) + { + sEluna->Push(L, corpse->GetOwnerGUID()); + return 1; + } + + // GetGhostTime() + int GetGhostTime(lua_State* L, Corpse* corpse) + { + sEluna->Push(L, uint32(corpse->GetGhostTime())); + return 1; + } + + // GetType() + int GetType(lua_State* L, Corpse* corpse) + { + sEluna->Push(L, corpse->GetType()); + return 1; + } + + // ResetGhostTime() + int ResetGhostTime(lua_State* L, Corpse* corpse) + { + corpse->ResetGhostTime(); + return 0; + } + + // SaveToDB() + int SaveToDB(lua_State* L, Corpse* corpse) + { + corpse->SaveToDB(); + return 0; + } + + // DeleteBonesFromWorld() + int DeleteBonesFromWorld(lua_State* L, Corpse* corpse) + { + corpse->DeleteBonesFromWorld(); + return 0; + } +}; +#endif diff --git a/src/game/luaengine/CreatureMethods.h b/src/game/luaengine/CreatureMethods.h new file mode 100644 index 000000000..883d9515c --- /dev/null +++ b/src/game/luaengine/CreatureMethods.h @@ -0,0 +1,584 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef CREATUREMETHODS_H +#define CREATUREMETHODS_H + +namespace LuaCreature +{ + /*int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->IsDamageEnoughForLootingAndReward()); + return 1; + }*/ + + int IsReputationGainDisabled(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->IsReputationGainDisabled()); + return 1; + } + + int SetDisableReputationGain(lua_State* L, Creature* creature) + { + bool disable = sEluna->CHECKVAL(L, 2, true); + + creature->SetDisableReputationGain(disable); + return 0; + } + + int IsRegeneratingHealth(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isRegeneratingHealth()); + return 1; + } + + int HasInvolvedQuest(lua_State* L, Creature* creature) + { + uint32 quest_id = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->hasInvolvedQuest(quest_id)); + return 1; + } + + int SetInCombatWithZone(lua_State* L, Creature* creature) + { + creature->SetInCombatWithZone(); + return 0; + } + + int SetRespawnRadius(lua_State* L, Creature* creature) + { + float dist = sEluna->CHECKVAL(L, 2); + + creature->SetRespawnRadius(dist); + return 0; + } + + int GetRespawnRadius(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetRespawnRadius()); + return 1; + } + + int Respawn(lua_State* L, Creature* creature) + { + creature->Respawn(); + return 0; + } + + int SetRespawnDelay(lua_State* L, Creature* creature) + { + uint32 delay = sEluna->CHECKVAL(L, 2); + + creature->SetRespawnDelay(delay); + return 0; + } + + int GetRespawnDelay(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetRespawnDelay()); + return 1; + } + + int DespawnOrUnsummon(lua_State* L, Creature* creature) + { + uint32 msTimeToDespawn = sEluna->CHECKVAL(L, 2, 0); + +#ifdef MANGOS + creature->ForcedDespawn(msTimeToDespawn); +#else + creature->DespawnOrUnsummon(msTimeToDespawn); +#endif + return 0; + } + + int RemoveCorpse(lua_State* L, Creature* creature) + { + creature->RemoveCorpse(); + return 0; + } + + int SetDefaultMovementType(lua_State* L, Creature* creature) + { + int32 type = sEluna->CHECKVAL(L, 2); + + creature->SetDefaultMovementType((MovementGeneratorType)type); + return 0; + } + + int GetDefaultMovementType(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetDefaultMovementType()); + return 1; + } + + int IsTargetAcceptable(lua_State* L, Creature* creature) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, creature->isTargetableForAttack()); + return 1; + } + + int CanAssistTo(lua_State* L, Creature* creature) + { + Unit* u = sEluna->CHECKOBJ(L, 2); + Unit* enemy = sEluna->CHECKOBJ(L, 3); + bool checkfaction = sEluna->CHECKVAL(L, 4, true); + + sEluna->Push(L, creature->CanAssistTo(u, enemy, checkfaction)); + return 1; + } + + int HasSearchedAssistance(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->HasSearchedAssistance()); + return 1; + } + + int SetNoSearchAssistance(lua_State* L, Creature* creature) + { + bool val = sEluna->CHECKVAL(L, 2, true); + + creature->SetNoSearchAssistance(val); + return 0; + } + + int SetNoCallAssistance(lua_State* L, Creature* creature) + { + bool val = sEluna->CHECKVAL(L, 2, true); + + creature->SetNoCallAssistance(val); + return 0; + } + + int CallAssistance(lua_State* L, Creature* creature) + { + creature->CallAssistance(); + return 0; + } + + int CallForHelp(lua_State* L, Creature* creature) + { + float radius = sEluna->CHECKVAL(L, 2); + + creature->CallForHelp(radius); + return 0; + } + + int FleeToGetAssistance(lua_State* L, Creature* creature) + { + creature->DoFleeToGetAssistance(); + return 0; + } + + int GetAggroRange(lua_State* L, Creature* creature) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, creature->GetAttackDistance(target)); + return 1; + } + + int GetAttackDistance(lua_State* L, Creature* creature) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, creature->GetAttackDistance(target)); + return 1; + } + + /*int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side + { + Unit* target = sEluna->CHECKOBJ(L, 2); + bool force = sEluna->CHECKVAL(L, 3, true); + + sEluna->Push(L, creature->CanStartAttack(target, force)); + return 1; + }*/ + + /*int ResetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + creature->ResetLootMode(); + return 0; + }*/ + + /*int RemoveLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + uint16 lootMode = sEluna->CHECKVAL(L, 2); + + creature->RemoveLootMode(lootMode); + return 0; + }*/ + + /*int AddLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + uint16 lootMode = sEluna->CHECKVAL(L, 2); + + creature->AddLootMode(lootMode); + return 0; + }*/ + + /*int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + uint16 lootMode = sEluna->CHECKVAL(L, 2); + + creature->SetLootMode(lootMode); + return 0; + }*/ + + /*int HasLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + uint16 lootMode = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->HasLootMode(lootMode)); + return 1; + }*/ + + /*int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features + { + sEluna->Push(L, creature->GetLootMode()); + return 1; + }*/ + + + int HasLootRecipient(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->hasLootRecipient()); + return 1; + } + + int GetLootRecipient(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetLootRecipient()); + return 1; + } + + int SetDeathState(lua_State* L, Creature* creature) + { + int32 state = sEluna->CHECKVAL(L, 2); + + creature->setDeathState((DeathState)state); + return 0; + } + + int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ? + { + bool enable = sEluna->CHECKVAL(L, 2, true); + + creature->SetWalk(enable); + return 0; + } + + int SetReactState(lua_State* L, Creature* creature) + { + int32 state = sEluna->CHECKVAL(L, 2); + + creature->SetReactState((ReactStates)state); + return 0; + } + + int GetReactState(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetReactState()); + return 1; + } + + int HasReactState(lua_State* L, Creature* creature) + { + int32 state = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->HasReactState((ReactStates)state)); + return 1; + } + + int CanSwim(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->CanSwim()); + return 1; + } + + int CanWalk(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->CanWalk()); + return 1; + } + + /*int SetDisableGravity(lua_State* L, Creature* creature) + { + bool disable = sEluna->CHECKVAL(L, 2, true); + bool packetOnly = sEluna->CHECKVAL(L, 3, false); + + sEluna->Push(L, creature->SetDisableGravity(disable, packetOnly)); + return 1; + }*/ + + int SetHover(lua_State* L, Creature* creature) + { + bool enable = sEluna->CHECKVAL(L, 2, true); + +#ifdef MANGOS + creature->SetLevitate(enable); +#else + creature->SetHover(enable); +#endif + return 0; + } + + int IsInEvadeMode(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->IsInEvadeMode()); + return 1; + } + + int IsElite(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isElite()); + return 1; + } + + int IsGuard(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isGuard()); + return 1; + } + + int IsTrigger(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isTrigger()); + return 1; + } + + int IsCivilian(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isCivilian()); + return 1; + } + + int IsRacialLeader(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isRacialLeader()); + return 1; + } + + int HasCategoryCooldown(lua_State* L, Creature* creature) + { + uint32 spell = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->HasCategoryCooldown(spell)); + return 1; + } + + int GetScriptName(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetScriptName()); + return 1; + } + + int GetAIName(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetAIName()); + return 1; + } + + int GetScriptId(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetScriptId()); + return 1; + } + + int GetHomePosition(lua_State* L, Creature* creature) + { + float x, y, z, o; + creature->GetHomePosition(x, y, z, o); + + sEluna->Push(L, x); + sEluna->Push(L, y); + sEluna->Push(L, z); + sEluna->Push(L, o); + return 4; + } + + int AttackStart(lua_State* L, Creature* creature) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + + creature->AI()->AttackStart(target); + return 0; + } + + int GetAITarget(lua_State* L, Creature* creature) + { + uint32 targetType = sEluna->CHECKVAL(L, 2); + bool playerOnly = sEluna->CHECKVAL(L, 3, false); + uint32 position = sEluna->CHECKVAL(L, 4, 0); + float dist = sEluna->CHECKVAL(L, 5, 0.0f); + int32 aura = sEluna->CHECKVAL(L, 6, 0); + + const std::list & threatList = creature->getThreatManager().getThreatList(); + if (position >= threatList.size()) + { + sEluna->Push(L); + return 1; + } + + std::list targetList; + for (std::list::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + { + Unit* target = (*itr)->getTarget(); + if (!target) + continue; + if (playerOnly && target->GetTypeId() != TYPEID_PLAYER) + continue; + if (aura > 0 && !target->HasAura(aura)) + continue; + else if (aura < 0 && target->HasAura(-aura)) + continue; + if (dist > 0.0f && !creature->IsWithinDist(target, dist)) + continue; + targetList.push_back(target); + } + + if (position >= targetList.size()) + { + sEluna->Push(L); + return 1; + } + + if (targetType == SELECT_TARGET_NEAREST || targetType == SELECT_TARGET_FARTHEST) + targetList.sort(Eluna::ObjectDistanceOrderPred(creature)); + + switch (targetType) + { + case SELECT_TARGET_NEAREST: + case SELECT_TARGET_TOPAGGRO: + { + std::list::const_iterator itr = targetList.begin(); + std::advance(itr, position); + sEluna->Push(L, *itr); + return 1; + } + case SELECT_TARGET_FARTHEST: + case SELECT_TARGET_BOTTOMAGGRO: + { + std::list::reverse_iterator ritr = targetList.rbegin(); + std::advance(ritr, position); + sEluna->Push(L, *ritr); + return 1; + } + case SELECT_TARGET_RANDOM: + { + std::list::const_iterator itr = targetList.begin(); + std::advance(itr, urand(position, targetList.size() - 1)); + sEluna->Push(L, *itr); + return 1; + } + default: + luaL_argerror(L, 2, "SelectAggroTarget expected"); + } + + sEluna->Push(L); + return 1; + } + + int GetAITargets(lua_State* L, Creature* creature) + { + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + std::list const& threatList = creature->getThreatManager().getThreatList(); + std::list::const_iterator itr; + for (itr = threatList.begin(); itr != threatList.end(); ++itr) + { + Unit* target = (*itr)->getTarget(); + if (!target) + continue; + ++i; + sEluna->Push(L, i); + sEluna->Push(L, target); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + + int GetAITargetsCount(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->getThreatManager().getThreatList().size()); + return 1; + } + + int IsWorldBoss(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->isWorldBoss()); + return 1; + } + + int GetNPCFlags(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS)); + return 1; + } + + int SetNPCFlags(lua_State* L, Creature* creature) + { + uint32 flags = sEluna->CHECKVAL(L, 2); + + creature->SetUInt32Value(UNIT_NPC_FLAGS, flags); + return 0; + } + + int HasSpell(lua_State* L, Creature* creature) + { + uint32 id = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->HasSpell(id)); + return 1; + } + + int HasQuest(lua_State* L, Creature* creature) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->hasQuest(questId)); + return 1; + } + + int SaveToDB(lua_State* L, Creature* creature) + { + creature->SaveToDB(); + return 0; + } + + int HasSpellCooldown(lua_State* L, Creature* creature) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, creature->HasSpellCooldown(spellId)); + return 1; + } + + int GetShieldBlockValue(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->GetShieldBlockValue()); + return 1; + } + + int CanFly(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->CanFly()); + return 1; + } + + int SelectVictim(lua_State* L, Creature* creature) + { + sEluna->Push(L, creature->SelectVictim()); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/GameObjectMethods.h b/src/game/luaengine/GameObjectMethods.h new file mode 100644 index 000000000..8479c23dc --- /dev/null +++ b/src/game/luaengine/GameObjectMethods.h @@ -0,0 +1,161 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef GAMEOBJECTMETHODS_H +#define GAMEOBJECTMETHODS_H + +namespace LuaGameObject +{ + int HasQuest(lua_State* L, GameObject* go) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, go->hasQuest(questId)); + return 1; + } + + int IsSpawned(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + sEluna->Push(L, false); + else + sEluna->Push(L, go->isSpawned()); + return 1; + } + + int IsTransport(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + sEluna->Push(L, false); + else + sEluna->Push(L, go->IsTransport()); + return 1; + } + + /*int IsDestructible(lua_State* L, GameObject* go) // TODO: Implementation core side + { + if (!go || !go->IsInWorld()) + sEluna->Push(L, false); + else + sEluna->Push(L, go->IsDestructibleBuilding()); + return 1; + }*/ + + int IsActive(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + sEluna->Push(L, false); + else + sEluna->Push(L, go->isActiveObject()); + return 1; + } + + int SaveToDB(lua_State* L, GameObject* go) + { + go->SaveToDB(); + return 0; + } + + int RemoveFromWorld(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + bool del = sEluna->CHECKVAL(L, 2, false); + if (del) + go->DeleteFromDB(); + go->RemoveFromWorld(); + return 0; + } + + int UseDoorOrButton(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + uint32 delay = sEluna->CHECKVAL(L, 2, 0); + + go->UseDoorOrButton(delay); + return 0; + } + + int SetGoState(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + uint32 state = sEluna->CHECKVAL(L, 2, 0); + + if (state == 0) + go->SetGoState(GO_STATE_ACTIVE); + else if (state == 1) + go->SetGoState(GO_STATE_READY); + else if (state == 2) + go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); + + return 0; + } + + int GetGoState(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + sEluna->Push(L, go->GetGoState()); + return 1; + } + + int SetLootState(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + uint32 state = sEluna->CHECKVAL(L, 2, 0); + + if (state == 0) + go->SetLootState(GO_NOT_READY); + else if (state == 1) + go->SetLootState(GO_READY); + else if (state == 2) + go->SetLootState(GO_ACTIVATED); + else if (state == 3) + go->SetLootState(GO_JUST_DEACTIVATED); + + return 0; + } + + int GetLootState(lua_State* L, GameObject* go) + { + if (!go || !go->IsInWorld()) + return 0; + + sEluna->Push(L, go->getLootState()); + return 1; + } + + int Despawn(lua_State* L, GameObject* go) + { + uint32 delay = sEluna->CHECKVAL(L, 2, 1); + if (!delay) + delay = 1; + + go->SetSpawnedByDefault(false); + go->SetRespawnTime(delay); + return 0; + } + + int Respawn(lua_State* L, GameObject* go) + { + uint32 delay = sEluna->CHECKVAL(L, 2, 1); + if (!delay) + delay = 1; + + go->SetSpawnedByDefault(true); + go->SetRespawnTime(delay); + return 0; + } +}; +#endif diff --git a/src/game/luaengine/GlobalMethods.h b/src/game/luaengine/GlobalMethods.h new file mode 100644 index 000000000..c547bbded --- /dev/null +++ b/src/game/luaengine/GlobalMethods.h @@ -0,0 +1,885 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef GLOBALMETHODS_H +#define GLOBALMETHODS_H + +#include "revision.h" + +extern bool StartEluna(); + +namespace LuaGlobalFunctions +{ + int RegisterPacketEvent(lua_State* L) + { + lua_settop(L, 2); + uint32 ev = sEluna->CHECKVAL(L, 1); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_PACKET, 0, ev, functionRef); + return 0; + } + + int RegisterServerEvent(lua_State* L) + { + lua_settop(L, 2); + uint32 ev = sEluna->CHECKVAL(L, 1); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_SERVER, 0, ev, functionRef); + return 0; + } + + int RegisterPlayerEvent(lua_State* L) + { + lua_settop(L, 2); + uint32 ev = sEluna->CHECKVAL(L, 1); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_PLAYER, 0, ev, functionRef); + return 0; + } + + int RegisterGuildEvent(lua_State* L) + { + lua_settop(L, 2); + uint32 ev = sEluna->CHECKVAL(L, 1); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_GUILD, 0, ev, functionRef); + return 0; + } + + int RegisterGroupEvent(lua_State* L) + { + lua_settop(L, 2); + uint32 ev = sEluna->CHECKVAL(L, 1); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_GROUP, 0, ev, functionRef); + return 0; + } + + int RegisterCreatureGossipEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_CREATURE_GOSSIP, entry, ev, functionRef); + return 0; + } + + int RegisterGameObjectGossipEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_GAMEOBJECT_GOSSIP, entry, ev, functionRef); + return 0; + } + + int RegisterItemEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_ITEM, entry, ev, functionRef); + return 0; + } + + int RegisterItemGossipEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_ITEM_GOSSIP, entry, ev, functionRef); + return 0; + } + + int RegisterPlayerGossipEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 menu_id = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_PLAYER_GOSSIP, menu_id, ev, functionRef); + return 0; + } + + int RegisterCreatureEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_CREATURE, entry, ev, functionRef); + return 0; + } + + int RegisterGameObjectEvent(lua_State* L) + { + lua_settop(L, 3); + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 ev = sEluna->CHECKVAL(L, 2); + luaL_checktype(L, lua_gettop(L), LUA_TFUNCTION); + int functionRef = lua_ref(L, true); + if (functionRef > 0) + sEluna->Register(REGTYPE_GAMEOBJECT, entry, ev, functionRef); + return 0; + } + + int GetLuaEngine(lua_State* L) + { + sEluna->Push(L, "ElunaEngine"); + return 1; + } + + int GetCoreName(lua_State* L) + { + sEluna->Push(L, "HellGroundCore"); + return 1; + } + + int GetCoreVersion(lua_State* L) + { + sEluna->Push(L, _REVISION); + return 1; + } + + int GetQuest(lua_State* L) + { + uint32 questId = sEluna->CHECKVAL(L, 1); + + sEluna->Push(L, sObjectMgr.GetQuestTemplate(questId)); + return 1; + } + + int ReloadEluna(lua_State* L) + { + sEluna->Push(L, StartEluna()); + return 1; + } + + int GetPlayerByGUID(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, sObjectAccessor.FindPlayer(uint64(guid))); + return 1; + } + + int GetPlayerByName(lua_State* L) + { + const char* message = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, sObjectAccessor.GetPlayerByName(message)); + return 1; + } + + int GetGameTime(lua_State* L) + { + time_t time = sWorld.GetGameTime(); + if (time < 0) + sEluna->Push(L, int32(time)); + else + sEluna->Push(L, uint32(time)); + return 1; + } + + int SendWorldMessage(lua_State* L) + { + const char* message = sEluna->CHECKVAL(L, 1); + sWorld.SendServerMessage(SERVER_MSG_STRING, message); + return 0; + } + + int GetPlayersInWorld(lua_State* L) + { + uint32 team = sEluna->CHECKVAL(L, 1, TEAM_NEUTRAL); + bool onlyGM = sEluna->CHECKVAL(L, 2, false); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + SessionMap const& sessions = sWorld.GetAllSessions(); + for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) + { + if (Player* player = it->second->GetPlayer()) + { + if (player->GetSession() && ((team >= TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster()))) + { + ++i; + sEluna->Push(L, i); + sEluna->Push(L, player); + lua_settable(L, tbl); + } + } + } + + lua_settop(L, tbl); // push table to top of stack + return 1; + } + + int GetPlayersInMap(lua_State* L) + { + uint32 mapID = sEluna->CHECKVAL(L, 1); + uint32 instanceID = sEluna->CHECKVAL(L, 2, 0); + uint32 team = sEluna->CHECKVAL(L, 3, TEAM_NEUTRAL); + + Map* map = sMapMgr.FindMap(mapID, instanceID); + if (!map) + return 0; + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + Map::PlayerList const& players = map->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + Player* player = itr->getSource(); + if (!player) + continue; + if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team)) + { + ++i; + sEluna->Push(L, i); + sEluna->Push(L, player); + lua_settable(L, tbl); + } + } + + lua_settop(L, tbl); + return 1; + } + + int WorldDBQuery(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + if (!query) + return 0; + + QueryResultAutoPtr result = GameDataDatabase.Query(query); + if (!result) + return 0; + + sEluna->Push(L, result); + return 1; + } + + int WorldDBExecute(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + GameDataDatabase.Execute(query); + return 0; + } + + int CharDBQuery(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + + QueryResultAutoPtr result = RealmDataDatabase.Query(query); + if (!result) + return 0; + + sEluna->Push(L, result); + return 1; + } + + int CharDBExecute(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + RealmDataDatabase.Execute(query); + return 0; + } + + int AuthDBQuery(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + + QueryResultAutoPtr result = AccountsDatabase.Query(query); + if (!result) + return 0; + + sEluna->Push(L, result); + return 1; + } + + int AuthDBExecute(lua_State* L) + { + const char* query = sEluna->CHECKVAL(L, 1); + AccountsDatabase.Execute(query); + return 0; + } + + int GetGuildByName(lua_State* L) + { + const char* name = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, sGuildMgr.GetGuildByName(name)); + return 1; + } + + int GetMapById(lua_State* L) + { + uint32 mapid = sEluna->CHECKVAL(L, 1); + uint32 instance = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, sMapMgr.FindMap(mapid, instance)); + return 1; + } + + int GetGuildByLeaderGUID(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + + sEluna->Push(L, sGuildMgr.GetGuildByLeader(uint64(guid))); + return 1; + } + + int GetPlayerCount(lua_State* L) + { + sEluna->Push(L, sWorld.GetActiveSessionCount()); + return 1; + } + + int GetPlayerGUID(lua_State* L) + { + uint32 lowguid = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + return 1; + } + + int GetItemGUID(lua_State* L) + { + uint32 lowguid = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); + return 1; + } + + int GetObjectGUID(lua_State* L) + { + uint32 lowguid = sEluna->CHECKVAL(L, 1); + uint32 entry = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); + return 1; + } + + int GetUnitGUID(lua_State* L) + { + uint32 lowguid = sEluna->CHECKVAL(L, 1); + uint32 entry = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); + return 1; + } + + int CreateLuaEvent(lua_State* L) + { + luaL_checktype(L, 1, LUA_TFUNCTION); + uint32 delay = sEluna->CHECKVAL(L, 2); + uint32 repeats = sEluna->CHECKVAL(L, 3); + + lua_settop(L, 1); + int functionRef = lua_ref(L, true); + functionRef = sEluna->m_EventMgr.AddEvent(&sEluna->m_EventMgr.GlobalEvents, functionRef, delay, repeats); + if (functionRef) + sEluna->Push(L, functionRef); + else + sEluna->Push(L); + return 1; + } + + int RemoveEventById(lua_State* L) + { + int eventId = sEluna->CHECKVAL(L, 1); + bool all_Events = sEluna->CHECKVAL(L, 1, false); + + if (all_Events) + sEluna->m_EventMgr.RemoveEvent(eventId); + else + sEluna->m_EventMgr.RemoveEvent(&sEluna->m_EventMgr.GlobalEvents, eventId); + return 0; + } + + int RemoveEvents(lua_State* L) + { + bool all_Events = sEluna->CHECKVAL(L, 1, false); + + if (all_Events) + sEluna->m_EventMgr.RemoveEvents(); + else + sEluna->m_EventMgr.GlobalEvents.KillAllEvents(true); + return 0; + } + + int PerformIngameSpawn(lua_State* L) + { + int spawntype = sEluna->CHECKVAL(L, 1); + uint32 entry = sEluna->CHECKVAL(L, 2); + uint32 mapID = sEluna->CHECKVAL(L, 3); + uint32 instanceID = sEluna->CHECKVAL(L, 4); + float x = sEluna->CHECKVAL(L, 5); + float y = sEluna->CHECKVAL(L, 6); + float z = sEluna->CHECKVAL(L, 7); + float o = sEluna->CHECKVAL(L, 8); + bool save = sEluna->CHECKVAL(L, 9, false); + uint32 durorresptime = sEluna->CHECKVAL(L, 10, 0); + + Map* map = sMapMgr.FindMap(mapID, instanceID); + if (!map) + return 0; + + if (spawntype == 1) // spawn creature + { + if (save) + { + CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry); + if (!cinfo) + return 0; + + Creature* pCreature = new Creature; + // used guids from specially reserved range (can be 0 if no free values) + uint32 lowguid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT); + if (!lowguid) + return 0; + + if (!pCreature->Create(lowguid, map, entry, 0,x,y,z,o)) + { + delete pCreature; + return 0; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + + uint32 db_guid = pCreature->GetGUIDLow(); + + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + pCreature->LoadFromDB(db_guid, map); + + map->Add(pCreature); + sObjectMgr.AddCreatureToGrid(db_guid, sObjectMgr.GetCreatureData(db_guid)); + if (durorresptime) + pCreature->ForcedDespawn(durorresptime); + + sEluna->Push(L, pCreature); + } + else + { + CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(entry); + if (!cinfo) + return 0; + + TemporarySummon* pCreature = new TemporarySummon(uint64(uint64(0))); + + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, entry, TEAM_NONE,x,y,z,o)) + { + delete pCreature; + return NULL; + } + + // Also initializes the AI and MMGen + pCreature->Summon(durorresptime ? TEMPSUMMON_TIMED_OR_DEAD_DESPAWN : TEMPSUMMON_MANUAL_DESPAWN, durorresptime); + + sEluna->Push(L, pCreature); + } + + return 1; + } + + if (spawntype == 2) // Spawn object + { + if (save) + { + const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(entry); + if (!gInfo) + return 0; + + // used guids from specially reserved range (can be 0 if no free values) + uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); + if (!db_lowGUID) + return 0; + + GameObject* pGameObj = new GameObject; + if (!pGameObj->Create(db_lowGUID, gInfo->id, map, x, y, z, o,0,0,0,0,0,GO_STATE_READY)) + { + delete pGameObj; + return 0; + } + + if (durorresptime) + pGameObj->SetRespawnTime(durorresptime); + + // fill the gameobject data and save to the db + pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + + // this will generate a new guid if the object is in an instance + if (!pGameObj->LoadFromDB(db_lowGUID, map)) + { + delete pGameObj; + return false; + } + + // DEBUG_LOG(GetMangosString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); + + map->Add(pGameObj); + + sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); + + sEluna->Push(L, pGameObj); + } + else + { + GameObject* pGameObj = new GameObject; + + if (!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, x, y, z, o,0,0,0,0,0,GO_STATE_READY)) + { + delete pGameObj; + return NULL; + } + + pGameObj->SetRespawnTime(durorresptime / IN_MILISECONDS); + + map->Add(pGameObj); + + sEluna->Push(L, pGameObj); + } + return 1; + } + return 0; + } + + // CreatePacket(opcode, size) + int CreatePacket(lua_State* L) + { + uint32 opcode = sEluna->CHECKVAL(L, 1); + uint32 size = sEluna->CHECKVAL(L, 2); + if (opcode >= NUM_MSG_TYPES) + return luaL_argerror(L, 1, "valid opcode expected"); + + sEluna->Push(L, new WorldPacket((Opcodes)opcode, size)); + return 1; + } + + int AddVendorItem(lua_State* L) + { + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 item = sEluna->CHECKVAL(L, 2); + int maxcount = sEluna->CHECKVAL(L, 3); + uint32 incrtime = sEluna->CHECKVAL(L, 4); + uint32 extendedcost = sEluna->CHECKVAL(L, 5); + + if (!sObjectMgr.IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost)) + return 0; + + sObjectMgr.AddVendorItem(entry, item, maxcount, incrtime, extendedcost); + return 0; + } + + int VendorRemoveItem(lua_State* L) + { + uint32 entry = sEluna->CHECKVAL(L, 1); + uint32 item = sEluna->CHECKVAL(L, 2); + if (!sObjectMgr.GetCreatureTemplate(entry)) + return luaL_argerror(L, 1, "valid CreatureEntry expected"); + + sObjectMgr.RemoveVendorItem(entry, item); + return 0; + } + + int VendorRemoveAllItems(lua_State* L) + { + uint32 entry = sEluna->CHECKVAL(L, 1); + + VendorItemData const* items = sObjectMgr.GetNpcVendorItemList(entry); + if (!items || items->Empty()) + return 0; + + VendorItemList const itemlist = items->m_items; + for (VendorItemList::const_iterator itr = itemlist.begin(); itr != itemlist.end(); ++itr) + sObjectMgr.RemoveVendorItem(entry, (*itr)->item); + return 0; + } + + int Kick(lua_State* L) + { + Player* player = sEluna->CHECKOBJ(L, 1); + player->GetSession()->KickPlayer(); + return 0; + } + + int Ban(lua_State* L) + { + int banMode = sEluna->CHECKVAL(L, 1); + const char* nameOrIP_cstr = sEluna->CHECKVAL(L, 2); + const char* duration = sEluna->CHECKVAL(L, 3); + const char* reason = sEluna->CHECKVAL(L, 4); + Player* whoBanned = sEluna->CHECKOBJ(L, 5); + std::string nameOrIP(nameOrIP_cstr); + + switch (banMode) + { + case BAN_ACCOUNT: + if (!AccountMgr::normalizeString(nameOrIP)) + return 0; + break; + case BAN_CHARACTER: + if (!normalizePlayerName(nameOrIP)) + return 0; + break; + case BAN_IP: + if (!IsIPAddress(nameOrIP.c_str())) + return 0; + break; + default: + return 0; + } + + switch (sWorld.BanAccount((BanMode)banMode, nameOrIP, duration, reason, whoBanned->GetSession() ? whoBanned->GetName() : "")) + { + case BAN_SUCCESS: + if (duration > 0) + ChatHandler(whoBanned->GetSession()).PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), duration, reason); + else + ChatHandler(whoBanned->GetSession()).PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reason); + break; + case BAN_SYNTAX_ERROR: + return 0; + case BAN_NOTFOUND: + return 0; + } + return 0; + } + + int GetGUIDLow(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + + sEluna->Push(L, GUID_LOPART(guid)); + return 1; + } + + int SendMail(lua_State* L) + { + int i = 0; + std::string subject = luaL_checkstring(L, ++i); + std::string text = luaL_checkstring(L, ++i); + uint32 receiverGUIDLow = luaL_checkunsigned(L, ++i); + Player* senderPlayer = sEluna->CHECKOBJ(L, ++i); + uint32 stationary = luaL_optunsigned(L, ++i, MAIL_STATIONERY_DEFAULT); + uint32 delay = luaL_optunsigned(L, ++i, 0); + int32 argAmount = lua_gettop(L); + + MailSender sender(MAIL_NORMAL, senderPlayer ? senderPlayer->GetGUIDLow() : 0, (MailStationery)stationary); + MailDraft draft(subject, text); + + uint8 addedItems = 0; + while (addedItems <= MAX_MAIL_ITEMS && i+2 <= argAmount) + { + uint32 entry = luaL_checkunsigned(L, ++i); + uint32 amount = luaL_checkunsigned(L, ++i); + + ItemPrototype const* item_proto = ObjectMgr::GetItemPrototype(entry); + if (!item_proto) + { + luaL_error(L, "Item entry %d does not exist", entry); + continue; + } + if (amount < 1 || (item_proto->MaxCount > 0 && amount > uint32(item_proto->MaxCount))) + { + luaL_error(L, "Item entry %d has invalid amount %d", entry, amount); + continue; + } + if (Item* item = Item::CreateItem(entry, amount, senderPlayer ? senderPlayer : 0)) + { + item->SaveToDB(); + draft.AddItem(item); + ++addedItems; + } + } + + draft.SendMailTo(MailReceiver(ObjectGuid(HIGHGUID_PLAYER, receiverGUIDLow)), sender, MAIL_CHECK_MASK_NONE, delay); + return 0; + } + + // bit_and(a, b) + int bit_and(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + uint32 b = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, a & b); + return 1; + } + + // bit_or(a, b) + int bit_or(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + uint32 b = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, a | b); + return 1; + } + + // bit_lshift(a, b) + int bit_lshift(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + uint32 b = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, a << b); + return 1; + } + + // bit_rshift(a, b) + int bit_rshift(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + uint32 b = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, a >> b); + return 1; + } + + // bit_xor(a, b) + int bit_xor(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + uint32 b = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, a ^ b); + return 1; + } + + // bit_not(a) + int bit_not(lua_State* L) + { + uint32 a = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, ~ a); + return 1; + } + + int GetGUIDType(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, GUID_HIPART(guid)); + return 1; + } + + int GetGUIDEntry(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + sEluna->Push(L, GUID_ENPART(guid)); + return 1; + } + + int GetItemLink(lua_State* L) + { + /* + LOCALE_enUS = 0, + LOCALE_koKR = 1, + LOCALE_frFR = 2, + LOCALE_deDE = 3, + LOCALE_zhCN = 4, + LOCALE_zhTW = 5, + LOCALE_esES = 6, + LOCALE_esMX = 7, + LOCALE_ruRU = 8 + */ + uint32 entry = sEluna->CHECKVAL(L, 1); + int loc_idx = sEluna->CHECKVAL(L, 2, LOCALE_enUS); + if (loc_idx < 0 || loc_idx >= MAX_LOCALE) + return luaL_argerror(L, 2, "valid LocaleConstant expected"); + + const ItemPrototype* temp = sObjectMgr.GetItemPrototype(entry); + if (!temp) + return luaL_argerror(L, 1, "valid ItemEntry expected"); + + std::string name = temp->Name1; + + std::ostringstream oss; + oss << std::dec << + "|Hitem:" << entry << ":0:0:0:0:0:0:0:0:0|h[" << name << "]|h|r"; + + sEluna->Push(L, oss.str()); + return 1; + } + + int AddCorpse(lua_State* L) + { + Corpse* corpse = sEluna->CHECKOBJ(L, 1); + + sObjectAccessor.AddCorpse(corpse); + return 0; + } + + int RemoveCorpse(lua_State* L) + { + Corpse* corpse = sEluna->CHECKOBJ(L, 1); + sObjectAccessor.RemoveCorpse(corpse); + return 1; + } + + int ConvertCorpseForPlayer(lua_State* L) + { + uint64 guid = sEluna->CHECKVAL(L, 1); + bool insignia = sEluna->CHECKVAL(L, 2, false); + + sEluna->Push(L, sObjectAccessor.ConvertCorpseForPlayer(uint64(guid), insignia)); + return 0; + } + + int RemoveOldCorpses(lua_State* L) + { + sObjectAccessor.RemoveOldCorpses(); + return 0; + } + + int FindWeather(lua_State* L) + { + uint32 zoneId = sEluna->CHECKVAL(L, 1); + Weather* weather = sWorld.FindWeather(zoneId); + sEluna->Push(L, weather); + return 1; + } + + int AddWeather(lua_State* L) + { + uint32 zoneId = sEluna->CHECKVAL(L, 1); + Weather* weather = sWorld.AddWeather(zoneId); + sEluna->Push(L, weather); + return 1; + } + + int RemoveWeather(lua_State* L) + { + uint32 zoneId = sEluna->CHECKVAL(L, 1); + sWorld.RemoveWeather(zoneId); + return 0; + } + + int SendFineWeatherToPlayer(lua_State* L) + { + Player* player = sEluna->CHECKOBJ(L, 1); + Weather::SendFineWeatherUpdateToPlayer(player); + return 0; + } +} +#endif diff --git a/src/game/luaengine/GroupMethods.h b/src/game/luaengine/GroupMethods.h new file mode 100644 index 000000000..18d235ae9 --- /dev/null +++ b/src/game/luaengine/GroupMethods.h @@ -0,0 +1,206 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef GROUPMETHODS_H +#define GROUPMETHODS_H + +namespace LuaGroup +{ + int GetMembers(lua_State* L, Group* group) + { + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next()) + { +#ifdef MANGOS + Player* member = itr->getSource(); +#else + Player* member = itr->GetSource(); +#endif + + if (!member || !member->GetSession()) + continue; + + ++i; + sEluna->Push(L, i); + sEluna->Push(L, member); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); // push table to top of stack + return 1; + } + + int GetLeaderGUID(lua_State* L, Group* group) + { + sEluna->Push(L, group->GetLeaderGUID()); + return 1; + } + + int GetLeader(lua_State* L, Group* group) + { + sEluna->Push(L, sObjectAccessor.FindPlayer(group->GetLeaderGUID())); + return 1; + } + + int ChangeLeader(lua_State* L, Group* group) + { + Player* leader = sEluna->CHECKOBJ(L, 2); + + group->ChangeLeader(leader->GetGUID()); + return 0; + } + + int IsLeader(lua_State* L, Group* group) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, group->IsLeader(uint64(guid))); + return 1; + } + + // SendPacket(packet, sendToPlayersInBattleground[, ignoreguid]) + int SendPacket(lua_State* L, Group* group) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + bool ignorePlayersInBg = sEluna->CHECKVAL(L, 3); + uint64 ignore = sEluna->CHECKVAL(L, 4); + + group->BroadcastPacket(data, ignorePlayersInBg, -1, (uint64)ignore); + return 0; + } + + int AddInvite(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, group->AddInvite(player)); + return 1; + } + + int RemoveMember(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint32 method = sEluna->CHECKVAL(L, 3, 0); + +#ifdef MANGOS + sEluna->Push(L, group->RemoveMember(player->GetGUID(), method)); +#else + sEluna->Push(L, group->RemoveMember(player->GetGUID(), (RemoveMethod)method)); +#endif + return 1; + } + + int Disband(lua_State* L, Group* group) + { + group->Disband(); + return 0; + } + + int IsFull(lua_State* L, Group* group) + { + sEluna->Push(L, group->IsFull()); + return 1; + } + + /*int isLFGGroup(lua_State* L, Group* group) // TODO: Implementation + { + sEluna->Push(L, group->isLFGGroup()); + return 1; + }*/ + + int isRaidGroup(lua_State* L, Group* group) + { + sEluna->Push(L, group->isRaidGroup()); + return 1; + } + + int isBGGroup(lua_State* L, Group* group) + { + sEluna->Push(L, group->isBGGroup()); + return 1; + } + + /*int isBFGroup(lua_State* L, Group* group) // TODO: Implementation + { + sEluna->Push(L, group->isBFGroup()); + return 1; + }*/ + + int IsMember(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + sEluna->Push(L, group->IsMember(player->GetGUID())); + return 1; + } + + int IsAssistant(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, group->IsAssistant(player->GetGUID())); + return 1; + } + + int SameSubGroup(lua_State* L, Group* group) + { + Player* player1 = sEluna->CHECKOBJ(L, 2); + Player* player2 = sEluna->CHECKOBJ(L, 3); + sEluna->Push(L, group->SameSubGroup(player1, player2)); + return 1; + } + + int HasFreeSlotSubGroup(lua_State* L, Group* group) + { + uint8 subGroup = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, group->HasFreeSlotSubGroup(subGroup)); + return 1; + } + + int GetMemberGUID(lua_State* L, Group* group) + { + const char* name = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, group->GetMemberGUID(name)); + return 1; + } + + int GetMembersCount(lua_State* L, Group* group) + { + sEluna->Push(L, group->GetMembersCount()); + return 1; + } + + /*int ConvertToLFG(lua_State* L, Group* group) // TODO: Implementation + { + group->ConvertToLFG(); + return 0; + }*/ + + int ConvertToRaid(lua_State* L, Group* group) + { + group->ConvertToRaid(); + return 0; + } + + int ChangeMembersGroup(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint8 groupID = sEluna->CHECKVAL(L, 3); + + group->ChangeMembersGroup(player->GetGUID(), groupID); + return 0; + } + + int GetMemberGroup(lua_State* L, Group* group) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, group->GetMemberGroup(player->GetGUID())); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/GuildMethods.h b/src/game/luaengine/GuildMethods.h new file mode 100644 index 000000000..eb4fd4d5a --- /dev/null +++ b/src/game/luaengine/GuildMethods.h @@ -0,0 +1,188 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef GUILDMETHODS_H +#define GUILDMETHODS_H + +namespace LuaGuild +{ + int GetMembers(lua_State* L, Guild* guild) + { + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + SessionMap const& sessions = sWorld.GetAllSessions(); + for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) + { + if (Player* player = it->second->GetPlayer()) + { + if (player->GetSession() && (player->GetGuildId() == guild->GetId())) + { + ++i; + sEluna->Push(L, i); + sEluna->Push(L, player); + lua_settable(L, tbl); + } + } + } + + lua_settop(L, tbl); // push table to top of stack + return 1; + } + + int GetMemberCount(lua_State* L, Guild* guild) + { + sEluna->Push(L, guild->GetMemberSize()); + return 1; + } + + int GetLeader(lua_State* L, Guild* guild) + { + sEluna->Push(L, sObjectAccessor.FindPlayer(guild->GetLeader())); + return 1; + } + + int SetLeader(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + guild->SetLeader(player->GetGUID()); + return 0; + } + + int GetLeaderGUID(lua_State* L, Guild* guild) + { + sEluna->Push(L, guild->GetLeader()); + return 1; + } + + // SendPacketToGuild(packet) + int SendPacket(lua_State* L, Guild* guild) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + + guild->BroadcastPacket(data); + return 0; + } + + // SendPacketToRankedInGuild(packet, rankId) + int SendPacketToRanked(lua_State* L, Guild* guild) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + uint8 ranked = sEluna->CHECKVAL(L, 3); + + guild->BroadcastPacketToRank(data, ranked); + return 0; + } + + int Disband(lua_State* L, Guild* guild) + { + guild->Disband(); + return 0; + } + + int GetId(lua_State* L, Guild* guild) + { + sEluna->Push(L, guild->GetId()); + return 1; + } + + int GetName(lua_State* L, Guild* guild) + { + sEluna->Push(L, guild->GetName()); + return 1; + } + + int GetMOTD(lua_State* L, Guild* guild) + { + sEluna->Push(L, guild->GetMOTD()); + return 1; + } + + int GetInfo(lua_State* L, Guild* guild) + { +#ifdef MANGOS + sEluna->Push(L, guild->GetGINFO()); +#else + sEluna->Push(L, guild->GetInfo()); +#endif + return 1; + } + + int AddMember(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint8 rankId = sEluna->CHECKVAL(L, 3, 0); + + guild->AddMember(player->GetGUID(), rankId); + return 0; + } + + int DeleteMember(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + bool isDisbanding = sEluna->CHECKVAL(L, 3, false); + +#ifdef MANGOS + guild->DelMember(player->GetGUID(), isDisbanding); +#else + guild->DeleteMember(player->GetGUID(), isDisbanding); +#endif + return 0; + } + + int ChangeMemberRank(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint8 newRank = sEluna->CHECKVAL(L, 3); + + guild->ChangeRank(player->GetGUID(), newRank); + return 0; + } + + int SetBankTabText(lua_State* L, Guild* guild) + { + uint8 tabId = sEluna->CHECKVAL(L, 2); + const char* text = sEluna->CHECKVAL(L, 3); +#ifdef MANGOS + guild->SetGuildBankTabText(tabId, text); +#else + guild->SetBankTabText(tabId, text); +#endif + return 0; + } + + // Move to Player methods + int WithdrawBankMoney(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint32 money = sEluna->CHECKVAL(L, 3); +#ifdef MANGOS + if (guild->GetGuildBankMoney() < money) + return 0; + guild->SetBankMoney(guild->GetGuildBankMoney() - money); +#else + guild->HandleMemberWithdrawMoney(player->GetSession(), money); +#endif + return 0; + } + + // Move to Player methods + int DepositBankMoney(lua_State* L, Guild* guild) + { + Player* player = sEluna->CHECKOBJ(L, 2); + uint32 money = sEluna->CHECKVAL(L, 3); + +#ifdef MANGOS + guild->SetBankMoney(guild->GetGuildBankMoney() + money); +#else + guild->HandleMemberDepositMoney(player->GetSession(), money); +#endif + return 0; + } +}; +#endif diff --git a/src/game/luaengine/HookMgr.cpp b/src/game/luaengine/HookMgr.cpp new file mode 100644 index 000000000..b5ab9209d --- /dev/null +++ b/src/game/luaengine/HookMgr.cpp @@ -0,0 +1,1755 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#include "LuaEngine.h" +#include "luaengine/HookMgr.h" + +extern bool StartEluna(); +bool HookMgr::OnCommand(Player* player, const char* text) +{ + ELUNA_GUARD(false); + + char* creload = strtok((char*)text, " "); + char* celuna = strtok(NULL, ""); + if (creload && celuna) + { + std::string reload(creload); + std::string eluna(celuna); + std::transform(reload.begin(), reload.end(), reload.begin(), ::tolower); + if (reload == "reload") + { + std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower); + if (std::string("eluna").find(eluna) == 0) + { + sWorld.SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna..."); + StartEluna(); + return false; + } + } + } + bool result = true; + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_COMMAND)) + return result; + + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, text); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + result = sEluna->CHECKVAL(sEluna->L, i, result); + } + sEluna->PlayerEventBindings.EndCall(); + return result; +} + +void HookMgr::OnWorldUpdate(uint32 diff) +{ + ELUNA_GUARD(void()); + sEluna->m_EventMgr.Update(diff); + if (!sEluna->ServerEventBindings.BeginCall(WORLD_EVENT_ON_UPDATE)) + return; + sEluna->Push(sEluna->L, diff); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +void HookMgr::OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LOOT_ITEM)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pItem); + sEluna->Push(sEluna->L, count); + sEluna->Push(sEluna->L, guid); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnLootMoney(Player* pPlayer, uint32 amount) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LOOT_MONEY)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, amount); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnFirstLogin(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_FIRST_LOGIN)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnRepop(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_REPOP)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnResurrect(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_RESURRECT)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnQuestAbandon(Player* pPlayer, uint32 questId) +{ + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_QUEST_ABANDON)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, questId); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnGmTicketCreate(Player* pPlayer, std::string& ticketText) +{ + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_CREATE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, ticketText); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnGmTicketUpdate(Player* pPlayer, std::string& ticketText) +{ + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_UPDATE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, ticketText); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnGmTicketDelete(Player* pPlayer) +{ + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GM_TICKET_DELETE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_EQUIP)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pItem); + sEluna->Push(sEluna->L, bag); + sEluna->Push(sEluna->L, slot); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +InventoryResult HookMgr::OnCanUseItem(const Player* pPlayer, uint32 itemEntry) +{ + ELUNA_GUARD(EQUIP_ERR_OK); + InventoryResult result = EQUIP_ERR_OK; + if (sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_CAN_USE_ITEM)) + { + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, itemEntry); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + uint32 res = lua_tounsigned(sEluna->L, i); + if (res != EQUIP_ERR_OK) + result = (InventoryResult)res; + } + sEluna->PlayerEventBindings.EndCall(); + } + return result; +} + +void HookMgr::HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code) +{ + ELUNA_GUARD(void()); + int bind = sEluna->ItemGossipBindings.GetBind(item->GetEntry(), GOSSIP_EVENT_ON_SELECT); + if (bind) + { + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, item); + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + if (code.empty()) + lua_pushnil(sEluna->L); + else + sEluna->Push(sEluna->L, code); + sEluna->ExecuteCall(6, 0); + } +} + +void HookMgr::HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, std::string code) +{ + ELUNA_GUARD(void()); + int bind = sEluna->playerGossipBindings.GetBind(menuId, GOSSIP_EVENT_ON_SELECT); + if (bind) + { + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); // receiver + sEluna->Push(sEluna->L, pPlayer); // sender, just not to mess up the amount of args. + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + if (code.empty()) + lua_pushnil(sEluna->L); + else + sEluna->Push(sEluna->L, code); + sEluna->Push(sEluna->L, menuId); + sEluna->ExecuteCall(7, 0); + } +} + +void HookMgr::OnEngineRestart() +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(ELUNA_EVENT_ON_RESTART)) + return; + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +// item +bool HookMgr::OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, Item* pTarget) +{ + ELUNA_GUARD(false); + int bind = sEluna->ItemEventBindings.GetBind(pTarget->GetEntry(), ITEM_EVENT_ON_DUMMY_EFFECT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, ITEM_EVENT_ON_DUMMY_EFFECT); + sEluna->Push(sEluna->L, pCaster); + sEluna->Push(sEluna->L, spellId); + sEluna->Push(sEluna->L, effIndex); + sEluna->Push(sEluna->L, pTarget); + sEluna->ExecuteCall(5, 0); + return true; +} + +bool HookMgr::OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->ItemEventBindings.GetBind(pItem->GetEntry(), ITEM_EVENT_ON_QUEST_ACCEPT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, ITEM_EVENT_ON_QUEST_ACCEPT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pItem); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets) +{ + ELUNA_GUARD(false); + int bind1 = sEluna->ItemGossipBindings.GetBind(pItem->GetEntry(), GOSSIP_EVENT_ON_HELLO); + int bind2 = sEluna->ItemEventBindings.GetBind(pItem->GetEntry(), ITEM_EVENT_ON_USE); + if (!bind1 && !bind2) + return false; + if (bind1) + { + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind1); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_HELLO); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pItem); + sEluna->ExecuteCall(3, 0); + } + if (bind2) + { + sEluna->BeginCall(bind2); + sEluna->Push(sEluna->L, ITEM_EVENT_ON_USE); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pItem); + + if (GameObject* target = targets.getGOTarget()) + sEluna->Push(sEluna->L, target); + else if (Item* target = targets.getItemTarget()) + sEluna->Push(sEluna->L, target); + else if (Corpse* target = targets.getCorpseTarget()) + sEluna->Push(sEluna->L, target); + else if (Unit* target = targets.getUnitTarget()) + sEluna->Push(sEluna->L, target); + else + sEluna->Push(sEluna->L); + + sEluna->ExecuteCall(4, 0); + } + // pPlayer->SendEquipError((InventoryResult)83, pItem, NULL); + return false; +} + +bool HookMgr::OnExpire(Player* pPlayer, ItemPrototype const* pProto) +{ + ELUNA_GUARD(false); + int bind = sEluna->ItemEventBindings.GetBind(pProto->ItemId, ITEM_EVENT_ON_EXPIRE); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, ITEM_EVENT_ON_EXPIRE); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pProto->ItemId); + sEluna->ExecuteCall(3, 0); + return true; +} +// creature +bool HookMgr::OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, Creature* pTarget) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pTarget->GetEntry(), CREATURE_EVENT_ON_DUMMY_EFFECT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_DUMMY_EFFECT); + sEluna->Push(sEluna->L, pCaster); + sEluna->Push(sEluna->L, spellId); + sEluna->Push(sEluna->L, effIndex); + sEluna->Push(sEluna->L, pTarget); + sEluna->ExecuteCall(5, 0); + return true; +} + +bool HookMgr::OnGossipHello(Player* pPlayer, Creature* pCreature) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureGossipBindings.GetBind(pCreature->GetEntry(), GOSSIP_EVENT_ON_HELLO); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_HELLO); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->ExecuteCall(3, 0); + return true; +} + +bool HookMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureGossipBindings.GetBind(pCreature->GetEntry(), GOSSIP_EVENT_ON_SELECT); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + sEluna->ExecuteCall(5, 0); + return true; +} + +bool HookMgr::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureGossipBindings.GetBind(pCreature->GetEntry(), GOSSIP_EVENT_ON_SELECT); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + sEluna->Push(sEluna->L, code); + sEluna->ExecuteCall(6, 0); + return true; +} + +bool HookMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_ACCEPT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_QUEST_ACCEPT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnQuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_SELECT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_QUEST_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_COMPLETE); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_QUEST_COMPLETE); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_QUEST_REWARD); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_QUEST_REWARD); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +uint32 HookMgr::GetDialogStatus(Player* pPlayer, Creature* pCreature) +{ + ELUNA_GUARD(0); + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_DIALOG_STATUS); + if (!bind) + return 0; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_DIALOG_STATUS); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pCreature); + sEluna->ExecuteCall(3, 0); + return DIALOG_STATUS_SCRIPTED_NO_STATUS; +} + +void HookMgr::OnSummoned(Creature* pCreature, Unit* pSummoner) +{ + int bind = sEluna->CreatureEventBindings.GetBind(pCreature->GetEntry(), CREATURE_EVENT_ON_SUMMONED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_SUMMONED); + sEluna->Push(sEluna->L, pCreature); + sEluna->Push(sEluna->L, pSummoner); + sEluna->ExecuteCall(3, 0); +} + +// gameobject +bool HookMgr::OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, GameObject* pTarget) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectEventBindings.GetBind(pTarget->GetEntry(), GAMEOBJECT_EVENT_ON_DUMMY_EFFECT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_DUMMY_EFFECT); + sEluna->Push(sEluna->L, pCaster); + sEluna->Push(sEluna->L, spellId); + sEluna->Push(sEluna->L, effIndex); + sEluna->Push(sEluna->L, pTarget); + sEluna->ExecuteCall(5, 0); + return true; +} + +bool HookMgr::OnGossipHello(Player* pPlayer, GameObject* pGameObject) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectGossipBindings.GetBind(pGameObject->GetEntry(), GOSSIP_EVENT_ON_HELLO); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_HELLO); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->ExecuteCall(3, 0); + return true; +} + +bool HookMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectGossipBindings.GetBind(pGameObject->GetEntry(), GOSSIP_EVENT_ON_SELECT); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + sEluna->ExecuteCall(5, 0); + return true; +} + +bool HookMgr::OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectGossipBindings.GetBind(pGameObject->GetEntry(), GOSSIP_EVENT_ON_SELECT); + if (!bind) + return false; + pPlayer->PlayerTalkClass->ClearMenus(); + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GOSSIP_EVENT_ON_SELECT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, sender); + sEluna->Push(sEluna->L, action); + sEluna->Push(sEluna->L, code); + sEluna->ExecuteCall(6, 0); + return true; +} + +bool HookMgr::OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_QUEST_ACCEPT); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_QUEST_ACCEPT); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnQuestComplete(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->CreatureEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_QUEST_COMPLETE); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_QUEST_COMPLETE); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +bool HookMgr::OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest) +{ + ELUNA_GUARD(false); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_QUEST_REWARD); + if (!bind) + return false; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_QUEST_REWARD); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, pQuest); + sEluna->ExecuteCall(4, 0); + return true; +} + +uint32 HookMgr::GetDialogStatus(Player* pPlayer, GameObject* pGameObject) +{ + ELUNA_GUARD(0); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_DIALOG_STATUS); + if (!bind) + return 0; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_DIALOG_STATUS); + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pGameObject); + sEluna->ExecuteCall(3, 0); + return DIALOG_STATUS_SCRIPTED_NO_STATUS; // DIALOG_STATUS_UNDEFINED +} + +void HookMgr::OnDestroyed(GameObject* pGameObject, Player* pPlayer) +{ + ELUNA_GUARD(void()); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_DESTROYED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_DESTROYED); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, pPlayer); + sEluna->ExecuteCall(3, 0); +} + +void HookMgr::OnDamaged(GameObject* pGameObject, Player* pPlayer) +{ + ELUNA_GUARD(void()); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_DAMAGED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_DAMAGED); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, pPlayer); + sEluna->ExecuteCall(3, 0); +} + +void HookMgr::OnLootStateChanged(GameObject* pGameObject, uint32 state, Unit* pUnit) +{ + ELUNA_GUARD(void()); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, state); + sEluna->Push(sEluna->L, pUnit); + sEluna->ExecuteCall(4, 0); +} + +void HookMgr::OnGameObjectStateChanged(GameObject* pGameObject, uint32 state) +{ + ELUNA_GUARD(void()); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, state); + sEluna->ExecuteCall(3, 0); +} +// Player +void HookMgr::OnPlayerEnterCombat(Player* pPlayer, Unit* pEnemy) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_ENTER_COMBAT)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pEnemy); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnPlayerLeaveCombat(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LEAVE_COMBAT)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnPVPKill(Player* pKiller, Player* pKilled) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_KILL_PLAYER)) + return; + sEluna->Push(sEluna->L, pKiller); + sEluna->Push(sEluna->L, pKilled); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnCreatureKill(Player* pKiller, Creature* pKilled) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_KILL_CREATURE)) + return; + sEluna->Push(sEluna->L, pKiller); + sEluna->Push(sEluna->L, pKilled); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_KILLED_BY_CREATURE)) + return; + sEluna->Push(sEluna->L, pKiller); + sEluna->Push(sEluna->L, pKilled); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnLevelChanged(Player* pPlayer, uint8 oldLevel) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LEVEL_CHANGE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, oldLevel); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_TALENTS_CHANGE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, newPoints); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnTalentsReset(Player* pPlayer, bool noCost) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_TALENTS_RESET)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, noCost); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnMoneyChanged(Player* pPlayer, int32& amount) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_MONEY_CHANGE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, amount); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GIVE_XP)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, amount); + sEluna->Push(sEluna->L, pVictim); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_REPUTATION_CHANGE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, factionID); + sEluna->Push(sEluna->L, standing); + sEluna->Push(sEluna->L, incremental); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnDuelRequest(Player* pTarget, Player* pChallenger) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_DUEL_REQUEST)) + return; + sEluna->Push(sEluna->L, pTarget); + sEluna->Push(sEluna->L, pChallenger); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnDuelStart(Player* pStarter, Player* pChallenger) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_DUEL_START)) + return; + sEluna->Push(sEluna->L, pStarter); + sEluna->Push(sEluna->L, pChallenger); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnDuelEnd(Player* pWinner, Player* pLoser, DuelCompleteType type) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_DUEL_END)) + return; + sEluna->Push(sEluna->L, pWinner); + sEluna->Push(sEluna->L, pLoser); + sEluna->Push(sEluna->L, type); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_WHISPER)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, msg); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, lang); + sEluna->Push(sEluna->L, pReceiver); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnEmote(Player* pPlayer, uint32 emote) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_EMOTE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, emote); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_TEXT_EMOTE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, textEmote); + sEluna->Push(sEluna->L, emoteNum); + sEluna->Push(sEluna->L, guid); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_SPELL_CAST)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pSpell); + sEluna->Push(sEluna->L, skipCheck); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnLogin(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LOGIN)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnLogout(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_LOGOUT)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnCreate(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_CHARACTER_CREATE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnDelete(uint32 guidlow) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_CHARACTER_DELETE)) + return; + sEluna->Push(sEluna->L, guidlow); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnSave(Player* pPlayer) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_SAVE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnBindToInstance(Player* pPlayer, DungeonDifficulties difficulty, uint32 mapid, bool permanent) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_BIND_TO_INSTANCE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, difficulty); + sEluna->Push(sEluna->L, mapid); + sEluna->Push(sEluna->L, permanent); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_UPDATE_ZONE)) + return; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, newZone); + sEluna->Push(sEluna->L, newArea); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +void HookMgr::OnMapChanged(Player* player) +{ + ELUNA_GUARD(void()); + if (!sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_MAP_CHANGE)) + return; + sEluna->Push(sEluna->L, player); + sEluna->PlayerEventBindings.ExecuteCall(); + sEluna->PlayerEventBindings.EndCall(); +} + +bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg) +{ + ELUNA_GUARD(true); + bool result = true; + if (sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_CHAT)) + { + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, msg); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, lang); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + if (!lua_toboolean(sEluna->L, i)) + result = false; + } + sEluna->PlayerEventBindings.EndCall(); + } + return result; +} + +bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup) +{ + ELUNA_GUARD(true); + bool result = true; + if (sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GROUP_CHAT)) + { + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, msg); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, lang); + sEluna->Push(sEluna->L, pGroup); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + if (!lua_toboolean(sEluna->L, i)) + result = false; + } + sEluna->PlayerEventBindings.EndCall(); + } + return result; +} + +bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild) +{ + ELUNA_GUARD(true); + bool result = true; + if (sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_GUILD_CHAT)) + { + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, msg); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, lang); + sEluna->Push(sEluna->L, pGuild); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + if (!lua_toboolean(sEluna->L, i)) + result = false; + } + sEluna->PlayerEventBindings.EndCall(); + } + return result; +} + +bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel) +{ + ELUNA_GUARD(true); + bool result = true; + if (sEluna->PlayerEventBindings.BeginCall(PLAYER_EVENT_ON_CHANNEL_CHAT)) + { + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, msg); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, lang); + sEluna->Push(sEluna->L, pChannel->GetChannelId()); + sEluna->PlayerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + if (!lua_toboolean(sEluna->L, i)) + result = false; + } + sEluna->PlayerEventBindings.EndCall(); + } + return result; +} + +// areatrigger +bool HookMgr::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger) +{ + ELUNA_GUARD(false); + if (!sEluna->ServerEventBindings.BeginCall(TRIGGER_EVENT_ON_TRIGGER)) + return false; + sEluna->Push(sEluna->L, pPlayer); + sEluna->Push(sEluna->L, pTrigger->id); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); + return false; +} +// weather +void HookMgr::OnChange(Weather* weather, WeatherState state, float grade) +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(WEATHER_EVENT_ON_CHANGE)) + return; + sEluna->Push(sEluna->L, (weather->GetZone())); + sEluna->Push(sEluna->L, state); + sEluna->Push(sEluna->L, grade); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} +// transport +void HookMgr::OnAddPassenger(Transport* transport, Player* player) +{ + ELUNA_GUARD(void()); +} +void HookMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature) +{ + ELUNA_GUARD(void()); +} +void HookMgr::OnRemovePassenger(Transport* transport, Player* player) +{ + ELUNA_GUARD(void()); +} +void HookMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z) +{ + ELUNA_GUARD(void()); +} +// Auction House +void HookMgr::OnAdd(AuctionHouseObject* ah) +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(AUCTION_EVENT_ON_ADD)) + return; + sEluna->Push(sEluna->L, (ah)); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +void HookMgr::OnRemove(AuctionHouseObject* ah) +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(AUCTION_EVENT_ON_REMOVE)) + return; + sEluna->Push(sEluna->L, (ah)); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +void HookMgr::OnSuccessful(AuctionHouseObject* ah) +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(AUCTION_EVENT_ON_SUCCESSFUL)) + return; + sEluna->Push(sEluna->L, (ah)); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +void HookMgr::OnExpire(AuctionHouseObject* ah) +{ + ELUNA_GUARD(void()); + if (!sEluna->ServerEventBindings.BeginCall(AUCTION_EVENT_ON_EXPIRE)) + return; + sEluna->Push(sEluna->L, (ah)); + sEluna->ServerEventBindings.ExecuteCall(); + sEluna->ServerEventBindings.EndCall(); +} + +// Packet +bool HookMgr::OnPacketSend(WorldSession* session, WorldPacket& packet) +{ + ELUNA_GUARD(true); + bool result = true; + Player* player = NULL; + if (session) + player = session->GetPlayer(); + if (sEluna->ServerEventBindings.BeginCall(SERVER_EVENT_ON_PACKET_SEND)) + { + sEluna->Push(sEluna->L, new WorldPacket(packet)); + sEluna->Push(sEluna->L, player); + sEluna->ServerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + WorldPacket* data = sEluna->CHECKOBJ(sEluna->L, i, false); + if (data) + packet = *data; + if (!sEluna->CHECKOBJ(sEluna->L, i, true)) + result = false; + } + sEluna->ServerEventBindings.EndCall(); + } + if (sEluna->PacketEventBindings.BeginCall(packet.GetOpcode())) + { + sEluna->Push(sEluna->L, new WorldPacket(packet)); + sEluna->Push(sEluna->L, player); + sEluna->PacketEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + WorldPacket* data = sEluna->CHECKOBJ(sEluna->L, i, false); + if (data) + packet = *data; + if (!sEluna->CHECKOBJ(sEluna->L, i, true)) + result = false; + } + sEluna->PacketEventBindings.EndCall(); + } + return result; +} +bool HookMgr::OnPacketReceive(WorldSession* session, WorldPacket& packet) +{ + ELUNA_GUARD(true); + bool result = true; + Player* player = NULL; + if (session) + player = session->GetPlayer(); + if (sEluna->ServerEventBindings.BeginCall(SERVER_EVENT_ON_PACKET_RECEIVE)) + { + sEluna->Push(sEluna->L, new WorldPacket(packet)); + sEluna->Push(sEluna->L, player); + sEluna->ServerEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + WorldPacket* data = sEluna->CHECKOBJ(sEluna->L, i, false); + if (data) + packet = *data; + if (!sEluna->CHECKOBJ(sEluna->L, i, true)) + result = false; + } + sEluna->ServerEventBindings.EndCall(); + } + if (sEluna->PacketEventBindings.BeginCall(packet.GetOpcode())) + { + sEluna->Push(sEluna->L, new WorldPacket(packet)); + sEluna->Push(sEluna->L, player); + sEluna->PacketEventBindings.ExecuteCall(); + for (int i = 1; i <= lua_gettop(sEluna->L); ++i) + { + if (lua_isnoneornil(sEluna->L, i)) + continue; + WorldPacket* data = sEluna->CHECKOBJ(sEluna->L, i, false); + if (data) + packet = *data; + if (!sEluna->CHECKOBJ(sEluna->L, i, true)) + result = false; + } + sEluna->PacketEventBindings.EndCall(); + } + return result; +} + +struct ElunaCreatureAI : CreatureAI +{ + ElunaCreatureAI(Creature* creature) : CreatureAI(creature) { } + ~ElunaCreatureAI() { } + + //Called at World update tick + void UpdateAI(const uint32 diff) override + { + ELUNA_GUARD(void()); + + //Check if we have a current target + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE); + if (!bind) + return; + + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_AIUPDATE); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, diff); + sEluna->ExecuteCall(3, 0); + } + + //Called for reaction at enter to combat if not in combat yet (enemy can be NULL) + //Called at creature aggro either by MoveInLOS or Attack Start + void EnterCombat(Unit* target) override + { + ELUNA_GUARD(void()); + CreatureAI::EnterCombat(target); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_ENTER_COMBAT); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_ENTER_COMBAT); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, target); + sEluna->ExecuteCall(3, 0); + } + + // Called at any Damage from any attacker (before damage apply) + void DamageTaken(Unit* attacker, uint32& damage) override + { + ELUNA_GUARD(void()); + CreatureAI::DamageTaken(attacker, damage); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_DAMAGE_TAKEN); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_DAMAGE_TAKEN); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, attacker); + sEluna->Push(sEluna->L, damage); + sEluna->ExecuteCall(4, 0); + } + + //Called at creature death + void JustDied(Unit* killer) override + { + ELUNA_GUARD(void()); + CreatureAI::JustDied(killer); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_DIED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_DIED); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, killer); + sEluna->ExecuteCall(3, 0); + } + + //Called at creature killing another unit + void KilledUnit(Unit* victim) override + { + ELUNA_GUARD(void()); + CreatureAI::KilledUnit(victim); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_TARGET_DIED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_TARGET_DIED); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, victim); + sEluna->ExecuteCall(3, 0); + } + + // Called when the creature summon successfully other creature + void JustSummoned(Creature* summon) override + { + ELUNA_GUARD(void()); + CreatureAI::JustSummoned(summon); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, summon); + sEluna->ExecuteCall(3, 0); + } + + // Called when a summoned creature is despawned + void SummonedCreatureDespawn(Creature* summon) override + { + ELUNA_GUARD(void()); + CreatureAI::SummonedCreatureDespawn(summon); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, summon); + sEluna->ExecuteCall(3, 0); + } + + //Called at waypoint reached or PointMovement end + void MovementInform(uint32 type, uint32 id) override + { + ELUNA_GUARD(void()); + CreatureAI::MovementInform(type, id); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_REACH_WP); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_REACH_WP); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, type); + sEluna->Push(sEluna->L, id); + sEluna->ExecuteCall(4, 0); + } + + // Called before EnterCombat even before the creature is in combat. + void AttackStart(Unit* target) override + { + ELUNA_GUARD(void()); + CreatureAI::AttackStart(target); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_PRE_COMBAT); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_PRE_COMBAT); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, target); + sEluna->ExecuteCall(3, 0); + } + + // Called for reaction at stopping attack at no attackers or targets + void EnterEvadeMode() override + { + ELUNA_GUARD(void()); + CreatureAI::EnterEvadeMode(); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_LEAVE_COMBAT); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_LEAVE_COMBAT); + sEluna->Push(sEluna->L, me); + sEluna->ExecuteCall(2, 0); + } + + // Called when creature is spawned or respawned (for reseting variables) + void JustRespawned() override + { + ELUNA_GUARD(void()); + CreatureAI::JustRespawned(); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_SPAWN); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_SPAWN); + sEluna->Push(sEluna->L, me); + sEluna->ExecuteCall(2, 0); + } + + // Called at reaching home after evade + void JustReachedHome() override + { + ELUNA_GUARD(void()); + CreatureAI::JustReachedHome(); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_REACH_HOME); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_REACH_HOME); + sEluna->Push(sEluna->L, me); + sEluna->ExecuteCall(2, 0); + } + + // Called at text emote receive from player + void ReceiveEmote(Player* player, uint32 emoteId) override + { + ELUNA_GUARD(void()); + CreatureAI::ReceiveEmote(player, emoteId); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_RECEIVE_EMOTE); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_RECEIVE_EMOTE); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, emoteId); + sEluna->ExecuteCall(4, 0); + } + + // Called when hit by a spell + void SpellHit(Unit* caster, SpellEntry const* spell) override + { + ELUNA_GUARD(void()); + CreatureAI::SpellHit(caster, spell); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_HIT_BY_SPELL); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_HIT_BY_SPELL); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, caster); + sEluna->Push(sEluna->L, spell->Id); // Pass spell object? + sEluna->ExecuteCall(4, 0); + } + + // Called when spell hits a target + void SpellHitTarget(Unit* target, SpellEntry const* spell) override + { + ELUNA_GUARD(void()); + CreatureAI::SpellHitTarget(target, spell); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_SPELL_HIT_TARGET); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_SPELL_HIT_TARGET); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, target); + sEluna->Push(sEluna->L, spell->Id); // Pass spell object? + sEluna->ExecuteCall(4, 0); + } + + //Called at creature reset either by death or evade + void Reset() override + { + ELUNA_GUARD(void()); + CreatureAI::Reset(); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_RESET); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_RESET); + sEluna->Push(sEluna->L, me); + sEluna->ExecuteCall(2, 0); + } + + // Called when the creature is summoned successfully by other creature + void IsSummonedBy(Unit* summoner) override + { + CreatureAI::IsSummonedBy(summoner); + sHookMgr->OnSummoned(me, summoner); + } + + void OnCharmed(bool apply) override + { + ELUNA_GUARD(void()); + CreatureAI::OnCharmed(apply); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_CHARMED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_CHARMED); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, apply); + sEluna->ExecuteCall(3, 0); + } + + void PassengerBoarded(Unit* passenger, int8 seatId, bool apply) override + { + ELUNA_GUARD(void()); + CreatureAI::PassengerBoarded(passenger, seatId, apply); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_PASSANGER_BOARDED); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_PASSANGER_BOARDED); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, passenger); + sEluna->Push(sEluna->L, seatId); + sEluna->Push(sEluna->L, apply); + sEluna->ExecuteCall(5, 0); + } + + // Called if IsVisible(Unit* who) is true at each who move, reaction at visibility zone enter + void MoveInLineOfSight(Unit* who) override + { + ELUNA_GUARD(void()); + CreatureAI::MoveInLineOfSight(who); + int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS); + sEluna->Push(sEluna->L, me); + sEluna->Push(sEluna->L, who); + sEluna->ExecuteCall(3, 0); + } +}; + +void HookMgr::UpdateAI(GameObject* pGameObject, uint32 diff) +{ + ELUNA_GUARD(void()); + int bind = sEluna->GameObjectEventBindings.GetBind(pGameObject->GetEntry(), GAMEOBJECT_EVENT_ON_AIUPDATE); + if (!bind) + return; + sEluna->BeginCall(bind); + sEluna->Push(sEluna->L, GAMEOBJECT_EVENT_ON_AIUPDATE); + sEluna->Push(sEluna->L, pGameObject); + sEluna->Push(sEluna->L, diff); + sEluna->ExecuteCall(3, 0); +} + +void HookMgr::OnAddMember(Guild* guild, Player* player, uint32 plRank) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_ADD_MEMBER)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, plRank); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_REMOVE_MEMBER)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, isDisbanding); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnMOTDChanged(Guild* guild, const std::string& newMotd) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_MOTD_CHANGE)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, newMotd); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnInfoChanged(Guild* guild, const std::string& newInfo) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_INFO_CHANGE)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, newInfo); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnCreate(Guild* guild, Player* leader, const std::string& name) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_CREATE)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, leader); + sEluna->Push(sEluna->L, name); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnDisband(Guild* guild) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_DISBAND)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32 &amount, bool isRepair) // isRepair not a part of Mangos, implement? +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_MONEY_WITHDRAW)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, amount); + sEluna->Push(sEluna->L, isRepair); // isRepair not a part of Mangos, implement? + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnMemberDepositMoney(Guild* guild, Player* player, uint32 &amount) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_MONEY_DEPOSIT)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, amount); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, + bool isDestBank, uint8 destContainer, uint8 destSlotId) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_ITEM_MOVE)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, player); + sEluna->Push(sEluna->L, pItem); + sEluna->Push(sEluna->L, isSrcBank); + sEluna->Push(sEluna->L, srcContainer); + sEluna->Push(sEluna->L, srcSlotId); + sEluna->Push(sEluna->L, isDestBank); + sEluna->Push(sEluna->L, destContainer); + sEluna->Push(sEluna->L, destSlotId); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_EVENT)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, eventType); + sEluna->Push(sEluna->L, playerGuid1); + sEluna->Push(sEluna->L, playerGuid2); + sEluna->Push(sEluna->L, newRank); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} + +void HookMgr::OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +{ + ELUNA_GUARD(void()); + if (!sEluna->GuildEventBindings.BeginCall(GUILD_EVENT_ON_BANK_EVENT)) + return; + sEluna->Push(sEluna->L, guild); + sEluna->Push(sEluna->L, eventType); + sEluna->Push(sEluna->L, tabId); + sEluna->Push(sEluna->L, playerGuid); + sEluna->Push(sEluna->L, itemOrMoney); + sEluna->Push(sEluna->L, itemStackCount); + sEluna->Push(sEluna->L, destTabId); + sEluna->GuildEventBindings.ExecuteCall(); + sEluna->GuildEventBindings.EndCall(); +} +// Group +void HookMgr::OnAddMember(Group* group, uint64 guid) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_MEMBER_ADD)) + return; + sEluna->Push(sEluna->L, group); + sEluna->Push(sEluna->L, guid); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +void HookMgr::OnInviteMember(Group* group, uint64 guid) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_MEMBER_INVITE)) + return; + sEluna->Push(sEluna->L, group); + sEluna->Push(sEluna->L, guid); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +void HookMgr::OnRemoveMember(Group* group, uint64 guid, uint8 method) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_MEMBER_REMOVE)) + return; + sEluna->Push(sEluna->L, group); + sEluna->Push(sEluna->L, guid); + sEluna->Push(sEluna->L, method); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +void HookMgr::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_LEADER_CHANGE)) + return; + sEluna->Push(sEluna->L, group); + sEluna->Push(sEluna->L, newLeaderGuid); + sEluna->Push(sEluna->L, oldLeaderGuid); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +void HookMgr::OnDisband(Group* group) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_DISBAND)) + return; + sEluna->Push(sEluna->L, group); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +void HookMgr::OnCreate(Group* group, uint64 leaderGuid, GroupType groupType) +{ + ELUNA_GUARD(void()); + if (!sEluna->GroupEventBindings.BeginCall(GROUP_EVENT_ON_CREATE)) + return; + sEluna->Push(sEluna->L, group); + sEluna->Push(sEluna->L, leaderGuid); + sEluna->Push(sEluna->L, groupType); + sEluna->GroupEventBindings.ExecuteCall(); + sEluna->GroupEventBindings.EndCall(); +} + +CreatureAI* HookMgr::GetAI(Creature* creature) +{ + ELUNA_GUARD(NULL); + if (!sEluna->CreatureEventBindings.GetBindMap(creature->GetEntry())) + return NULL; + return new ElunaCreatureAI(creature); +} + +void AddElunaScripts() +{ +} diff --git a/src/game/luaengine/HookMgr.h b/src/game/luaengine/HookMgr.h new file mode 100644 index 000000000..9c49c0801 --- /dev/null +++ b/src/game/luaengine/HookMgr.h @@ -0,0 +1,427 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef LUAHOOKS_H +#define LUAHOOKS_H + +#include "Includes.h" + +// Base +#include "Common.h" +#include "SharedDefines.h" +#include +#include +// enums +#include "Player.h" +#include "Group.h" +#include "Item.h" +#include "Weather.h" + +struct AreaTriggerEntry; +class CreatureAI; +class AuctionHouseObject; +class Channel; +class Creature; +class CreatureAI; +class GameObject; +class Guild; +class Group; +class Item; +class Player; +class Quest; +class Spell; +class SpellCastTargets; +class Transport; +class Unit; +class Weather; +class WorldPacket; + +enum RegisterTypes +{ + REGTYPE_PACKET, + REGTYPE_SERVER, + REGTYPE_PLAYER, + REGTYPE_GUILD, + REGTYPE_GROUP, + REGTYPE_CREATURE, + REGTYPE_VEHICLE, + REGTYPE_CREATURE_GOSSIP, + REGTYPE_GAMEOBJECT, + REGTYPE_GAMEOBJECT_GOSSIP, + REGTYPE_ITEM, + REGTYPE_ITEM_GOSSIP, + REGTYPE_PLAYER_GOSSIP, + REGTYPE_COUNT +}; + +// RegisterPacketEvent(Opcode, function) +// SERVER_EVENT_ON_PACKET_RECEIVE = 5, // (event, packet, player) - Player only if accessible. Can return false or a new packet +// SERVER_EVENT_ON_PACKET_RECEIVE_UNKNOWN = 6, // Not Implemented +// SERVER_EVENT_ON_PACKET_SEND = 7, // (event, packet, player) - Player only if accessible. Can return false or a new packet + +// RegisterServerEvent(EventId, function) +enum ServerEvents +{ + // Server + SERVER_EVENT_ON_NETWORK_START = 1, // Not Implemented + SERVER_EVENT_ON_NETWORK_STOP = 2, // Not Implemented + SERVER_EVENT_ON_SOCKET_OPEN = 3, // Not Implemented + SERVER_EVENT_ON_SOCKET_CLOSE = 4, // Not Implemented + SERVER_EVENT_ON_PACKET_RECEIVE = 5, // (event, packet, player) - Player only if accessible. Can return false or a new packet + SERVER_EVENT_ON_PACKET_RECEIVE_UNKNOWN = 6, // Not Implemented + SERVER_EVENT_ON_PACKET_SEND = 7, // (event, packet, player) - Player only if accessible. Can return false or a new packet + + // World // Not implemented on mangos + WORLD_EVENT_ON_OPEN_STATE_CHANGE = 8, // (event, open) + WORLD_EVENT_ON_CONFIG_LOAD = 9, // (event, reload) + WORLD_EVENT_ON_MOTD_CHANGE = 10, // (event, newMOTD) + WORLD_EVENT_ON_SHUTDOWN_INIT = 11, // (event, code, mask) + WORLD_EVENT_ON_SHUTDOWN_CANCEL = 12, // (event) + WORLD_EVENT_ON_UPDATE = 13, // (event, diff) + WORLD_EVENT_ON_STARTUP = 14, // (event) + WORLD_EVENT_ON_SHUTDOWN = 15, // (event) + + // Eluna + ELUNA_EVENT_ON_RESTART = 16, // (event) + + // Map + MAP_EVENT_ON_CREATE = 17, // Not Implemented + MAP_EVENT_ON_DESTROY = 18, // Not Implemented + MAP_EVENT_ON_LOAD = 19, // Not Implemented + MAP_EVENT_ON_UNLOAD = 20, // Not Implemented + MAP_EVENT_ON_PLAYER_ENTER = 21, // Not Implemented + MAP_EVENT_ON_PLAYER_LEAVE = 22, // Not Implemented + MAP_EVENT_ON_UPDATE = 23, // Not Implemented + + // Area trigger + TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) + + // Weather + WEATHER_EVENT_ON_CHANGE = 25, // (event, weather, state, grade) + + // Auction house + AUCTION_EVENT_ON_ADD = 26, // (event, AHObject) + AUCTION_EVENT_ON_REMOVE = 27, // (event, AHObject) + AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, AHObject) // NOT SUPPORTED YET + AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET + + SERVER_EVENT_COUNT +}; + +// RegisterPlayerEvent(eventId, function) +enum PlayerEvents +{ + PLAYER_EVENT_ON_CHARACTER_CREATE = 1, // (event, player) + PLAYER_EVENT_ON_CHARACTER_DELETE = 2, // (event, guid) + PLAYER_EVENT_ON_LOGIN = 3, // (event, player) + PLAYER_EVENT_ON_LOGOUT = 4, // (event, player) + PLAYER_EVENT_ON_SPELL_CAST = 5, // (event, player, spell, skipCheck) + PLAYER_EVENT_ON_KILL_PLAYER = 6, // (event, killer, killed) + PLAYER_EVENT_ON_KILL_CREATURE = 7, // (event, killer, killed) + PLAYER_EVENT_ON_KILLED_BY_CREATURE = 8, // (event, killer, killed) + PLAYER_EVENT_ON_DUEL_REQUEST = 9, // (event, target, challenger) + PLAYER_EVENT_ON_DUEL_START = 10, // (event, player1, player2) + PLAYER_EVENT_ON_DUEL_END = 11, // (event, winner, loser, type) + PLAYER_EVENT_ON_GIVE_XP = 12, // (event, player, amount, victim) + PLAYER_EVENT_ON_LEVEL_CHANGE = 13, // (event, player, oldLevel) + PLAYER_EVENT_ON_MONEY_CHANGE = 14, // (event, player, amount) + PLAYER_EVENT_ON_REPUTATION_CHANGE = 15, // (event, player, factionId, standing, incremental) + PLAYER_EVENT_ON_TALENTS_CHANGE = 16, // (event, player, points) + PLAYER_EVENT_ON_TALENTS_RESET = 17, // (event, player, noCost) + PLAYER_EVENT_ON_CHAT = 18, // (event, player, msg, Type, lang) - Can return false + PLAYER_EVENT_ON_WHISPER = 19, // (event, player, msg, Type, lang, receiver) + PLAYER_EVENT_ON_GROUP_CHAT = 20, // (event, player, msg, Type, lang, group) - Can return false + PLAYER_EVENT_ON_GUILD_CHAT = 21, // (event, player, msg, Type, lang, guild) - Can return false + PLAYER_EVENT_ON_CHANNEL_CHAT = 22, // (event, player, msg, Type, lang, channel) - Can return false + PLAYER_EVENT_ON_EMOTE = 23, // (event, player, emote) - Not triggered on any known emote + PLAYER_EVENT_ON_TEXT_EMOTE = 24, // (event, player, textEmote, emoteNum, guid) + PLAYER_EVENT_ON_SAVE = 25, // (event, player) + PLAYER_EVENT_ON_BIND_TO_INSTANCE = 26, // (event, player, difficulty, mapid, permanent) + PLAYER_EVENT_ON_UPDATE_ZONE = 27, // (event, player, newZone, newArea) + PLAYER_EVENT_ON_MAP_CHANGE = 28, // (event, player) + + // Custom + PLAYER_EVENT_ON_EQUIP = 29, // (event, player, item, bag, slot) + PLAYER_EVENT_ON_FIRST_LOGIN = 30, // (event, player) + PLAYER_EVENT_ON_CAN_USE_ITEM = 31, // (event, player, itemEntry) + PLAYER_EVENT_ON_LOOT_ITEM = 32, // (event, player, item, count) + PLAYER_EVENT_ON_ENTER_COMBAT = 33, // (event, player, enemy) + PLAYER_EVENT_ON_LEAVE_COMBAT = 34, // (event, player) + PLAYER_EVENT_ON_REPOP = 35, // (event, player) + PLAYER_EVENT_ON_RESURRECT = 36, // (event, player) + PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount) + PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId) + PLAYER_EVENT_ON_GM_TICKET_CREATE = 39, // (event, player, ticketText) + PLAYER_EVENT_ON_GM_TICKET_UPDATE = 40, // (event, player, ticketText) + PLAYER_EVENT_ON_GM_TICKET_DELETE = 41, // (event, player) + PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - Can return false + + PLAYER_EVENT_COUNT +}; + +// RegisterGuildEvent(eventId, function) +enum GuildEventTypes +{ + // Guild + GUILD_EVENT_ON_ADD_MEMBER = 1, // (event, guild, player, rank) + GUILD_EVENT_ON_REMOVE_MEMBER = 2, // (event, guild, isDisbanding) + GUILD_EVENT_ON_MOTD_CHANGE = 3, // (event, guild, newMotd) + GUILD_EVENT_ON_INFO_CHANGE = 4, // (event, guild, newInfo) + GUILD_EVENT_ON_CREATE = 5, // (event, guild, leader, name) + GUILD_EVENT_ON_DISBAND = 6, // (event, guild) + GUILD_EVENT_ON_MONEY_WITHDRAW = 7, // (event, guild, player, amount, isRepair) + GUILD_EVENT_ON_MONEY_DEPOSIT = 8, // (event, guild, player, amount) + GUILD_EVENT_ON_ITEM_MOVE = 9, // (event, guild, player, item, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId) + GUILD_EVENT_ON_EVENT = 10, // (event, guild, eventType, plrGUIDLow1, plrGUIDLow2, newRank) + GUILD_EVENT_ON_BANK_EVENT = 11, // (event, guild, eventType, tabId, playerGUIDLow, itemOrMoney, itemStackCount, destTabId) + + GUILD_EVENT_COUNT +}; + +// RegisterGroupEvent(eventId, function) +enum GroupEvents +{ + // Group + GROUP_EVENT_ON_MEMBER_ADD = 1, // (event, group, guid) + GROUP_EVENT_ON_MEMBER_INVITE = 2, // (event, group, guid) + GROUP_EVENT_ON_MEMBER_REMOVE = 3, // (event, group, guid, method, kicker, reason) + GROUP_EVENT_ON_LEADER_CHANGE = 4, // (event, group, newLeaderGuid, oldLeaderGuid) + GROUP_EVENT_ON_DISBAND = 5, // (event, group) + GROUP_EVENT_ON_CREATE = 6, // (event, group, leaderGuid, groupType) + + GROUP_EVENT_COUNT +}; + +// RegisterVehicleEvent(eventId, function) +enum VehicleEvents +{ + VEHICLE_EVENT_ON_INSTALL = 1, + VEHICLE_EVENT_ON_UNINSTALL = 2, + VEHICLE_EVENT_ON_RESET = 3, + VEHICLE_EVENT_ON_INSTALL_ACCESSORY = 4, + VEHICLE_EVENT_ON_ADD_PASSENGER = 5, + VEHICLE_EVENT_ON_REMOVE_PASSENGER = 6, + + VEHICLE_EVENT_COUNT +}; + +// RegisterCreatureEvent(entry, EventId, function) +enum CreatureEvents +{ + CREATURE_EVENT_ON_ENTER_COMBAT = 1, // (event, creature, target) + CREATURE_EVENT_ON_LEAVE_COMBAT = 2, // (event, creature) + CREATURE_EVENT_ON_TARGET_DIED = 3, // (event, creature, victim) + CREATURE_EVENT_ON_DIED = 4, // (event, creature, killer) + CREATURE_EVENT_ON_SPAWN = 5, // (event, creature) + CREATURE_EVENT_ON_REACH_WP = 6, // (event, creature, type, id) + CREATURE_EVENT_ON_AIUPDATE = 7, // (event, creature, diff) + CREATURE_EVENT_ON_RECEIVE_EMOTE = 8, // (event, creature, player, emoteid) + CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) + CREATURE_EVENT_ON_PRE_COMBAT = 10, // (event, creature, target) + CREATURE_EVENT_ON_ATTACKED_AT = 11, // (event, creature, attacker) + CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) + CREATURE_EVENT_ON_OWNER_ATTACKED_AT = 13, // (event, creature, attacker) + CREATURE_EVENT_ON_HIT_BY_SPELL = 14, // (event, creature, caster, spellid) + CREATURE_EVENT_ON_SPELL_HIT_TARGET = 15, // (event, creature, target, spellid) + CREATURE_EVENT_ON_SPELL_CLICK = 16, // (event, creature, clicker) + CREATURE_EVENT_ON_CHARMED = 17, // (event, creature, apply) + CREATURE_EVENT_ON_POSSESS = 18, // (event, creature, apply) + CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE = 19, // (event, creature, summon) + CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN = 20, // (event, creature, summon) + CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED = 21, // (event, creature, summon, killer) + CREATURE_EVENT_ON_SUMMONED = 22, // (event, creature, summoner) + CREATURE_EVENT_ON_RESET = 23, // (event, creature) + CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature) + CREATURE_EVENT_ON_CAN_RESPAWN = 25, // (event, creature) + CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) + CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit) + CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS = 28, // (event, creature, unit) + CREATURE_EVENT_ON_PASSANGER_BOARDED = 29, // (event, creature, passanger, seatid, apply) + CREATURE_EVENT_ON_DUMMY_EFFECT = 30, // (event, caster, spellid, effindex, creature) + CREATURE_EVENT_ON_QUEST_ACCEPT = 31, // (event, player, creature, quest) + CREATURE_EVENT_ON_QUEST_SELECT = 32, // (event, player, creature, quest) + CREATURE_EVENT_ON_QUEST_COMPLETE = 33, // (event, player, creature, quest) + CREATURE_EVENT_ON_QUEST_REWARD = 34, // (event, player, creature, quest, opt) + CREATURE_EVENT_ON_DIALOG_STATUS = 35, // (event, player, creature) + CREATURE_EVENT_COUNT +}; + +// RegisterGameObjectEvent(entry, EventId, function) +enum GameObjectEvents +{ + GAMEOBJECT_EVENT_ON_AIUPDATE = 1, // (event, go, diff) + GAMEOBJECT_EVENT_ON_RESET = 2, // (event, go) // TODO + GAMEOBJECT_EVENT_ON_DUMMY_EFFECT = 3, // (event, caster, spellid, effindex, go) + GAMEOBJECT_EVENT_ON_QUEST_ACCEPT = 4, // (event, player, go, quest) + GAMEOBJECT_EVENT_ON_QUEST_REWARD = 5, // (event, player, go, quest, opt) + GAMEOBJECT_EVENT_ON_DIALOG_STATUS = 6, // (event, player, go) + GAMEOBJECT_EVENT_ON_DESTROYED = 7, // (event, go, player) // TODO + GAMEOBJECT_EVENT_ON_DAMAGED = 8, // (event, go, player) // TODO + GAMEOBJECT_EVENT_ON_LOOT_STATE_CHANGE = 9, // (event, go, state, unit) // TODO + GAMEOBJECT_EVENT_ON_GO_STATE_CHANGED = 10, // (event, go, state) // TODO + GAMEOBJECT_EVENT_ON_QUEST_COMPLETE = 11, // (event, player, go, quest) + GAMEOBJECT_EVENT_COUNT +}; + +// RegisterItemEvent(entry, EventId, function) +enum ItemEvents +{ + ITEM_EVENT_ON_DUMMY_EFFECT = 1, // (event, caster, spellid, effindex, item) + ITEM_EVENT_ON_USE = 2, // (event, player, item, target) + ITEM_EVENT_ON_QUEST_ACCEPT = 3, // (event, player, item, quest) + ITEM_EVENT_ON_EXPIRE = 4, // (event, player, itemid) + ITEM_EVENT_COUNT +}; + +// RegisterCreatureGossipEvent(entry, EventId, function) +// RegisterGameObjectGossipEvent(entry, EventId, function) +// RegisterItemGossipEvent(entry, EventId, function) +// RegisterPlayerGossipEvent(menu_id, EventId, function) +enum GossipEvents +{ + GOSSIP_EVENT_ON_HELLO = 1, // (event, player, object) - Object is the Creature/GameObject/Item + GOSSIP_EVENT_ON_SELECT = 2, // (event, player, object, sender, intid, code, menu_id) - Object is the Creature/GameObject/Item/Player, menu_id is only for player gossip + GOSSIP_EVENT_COUNT +}; + +class HookMgr +{ +public: + CreatureAI* GetAI(Creature* creature); + + /* Custom */ + bool OnCommand(Player* player, const char* text); + void OnWorldUpdate(uint32 diff); + void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, uint64 guid); + void OnLootMoney(Player* pPlayer, uint32 amount); + void OnFirstLogin(Player* pPlayer); + void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot); + void OnRepop(Player* pPlayer); + void OnResurrect(Player* pPlayer); + void OnQuestAbandon(Player* pPlayer, uint32 questId); // Not on TC + void OnGmTicketCreate(Player* pPlayer, std::string& ticketText); // Not on TC + void OnGmTicketUpdate(Player* pPlayer, std::string& ticketText); // Not on TC + void OnGmTicketDelete(Player* pPlayer); // Not on TC + InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry); + void OnEngineRestart(); + + /* Item */ + bool OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, Item* pTarget); + bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest); + bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets); + bool OnExpire(Player* pPlayer, ItemPrototype const* pProto); + void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code); + + /* Creature */ + bool OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, Creature* pTarget); + bool OnGossipHello(Player* pPlayer, Creature* pCreature); + bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action); + bool OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code); + bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest); + bool OnQuestSelect(Player* pPlayer, Creature* pCreature, Quest const* pQuest); + bool OnQuestComplete(Player* pPlayer, Creature* pCreature, Quest const* pQuest); + bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest); + uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature); // Not on TC + void OnSummoned(Creature* creature, Unit* summoner); + + /* GameObject */ + bool OnDummyEffect(Unit* pCaster, uint32 spellId, uint8 effIndex, GameObject* pTarget); + bool OnGossipHello(Player* pPlayer, GameObject* pGameObject); + bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action); + bool OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code); + bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); + bool OnQuestComplete(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); + bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest); + bool OnGameObjectUse(Player* pPlayer, GameObject* pGameObject) { return false; }; // TODO? Not on TC + uint32 GetDialogStatus(Player* pPlayer, GameObject* pGameObject); + void OnDestroyed(GameObject* pGameObject, Player* pPlayer); // TODO + void OnDamaged(GameObject* pGameObject, Player* pPlayer); // TODO + void OnLootStateChanged(GameObject* pGameObject, uint32 state, Unit* pUnit); // TODO + void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state); // TODO + void UpdateAI(GameObject* pGameObject, uint32 diff); + + /* Packet */ + bool OnPacketSend(WorldSession* session, WorldPacket& packet); + bool OnPacketReceive(WorldSession* session, WorldPacket& packet); + + /* Player */ + void OnPlayerEnterCombat(Player* pPlayer, Unit* pEnemy); + void OnPlayerLeaveCombat(Player* pPlayer); + void OnPVPKill(Player* pKiller, Player* pKilled); + void OnCreatureKill(Player* pKiller, Creature* pKilled); + void OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled); + void OnLevelChanged(Player* pPlayer, uint8 oldLevel); + void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints); + void OnTalentsReset(Player* pPlayer, bool noCost); + void OnMoneyChanged(Player* pPlayer, int32& amount); + void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim); + void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental); + void OnDuelRequest(Player* pTarget, Player* pChallenger); + void OnDuelStart(Player* pStarter, Player* pChallenger); + void OnDuelEnd(Player* pWinner, Player* pLoser, DuelCompleteType type); + void OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver); + bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg); + bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup); + bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild); + bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel); + void OnEmote(Player* pPlayer, uint32 emote); + void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, uint64 guid); + void OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck); + void OnLogin(Player* pPlayer); + void OnLogout(Player* pPlayer); + void OnCreate(Player* pPlayer); + void OnDelete(uint32 guid); + void OnSave(Player* pPlayer); + void OnBindToInstance(Player* pPlayer, DungeonDifficulties difficulty, uint32 mapid, bool permanent); + void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea); + void OnMapChanged(Player* pPlayer); // TODO + void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, std::string code); + + /* AreaTrigger */ + bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger); + + /* Weather */ + void OnChange(Weather* weather, WeatherState state, float grade); // TODO + + /* Auction House */ + void OnAdd(AuctionHouseObject* auctionHouse); + void OnRemove(AuctionHouseObject* auctionHouse); + void OnSuccessful(AuctionHouseObject* auctionHouse); + void OnExpire(AuctionHouseObject* auctionHouse); + + /* Condition */ + + /* Transport */ + void OnAddPassenger(Transport* transport, Player* player); // TODO + void OnAddCreaturePassenger(Transport* transport, Creature* creature); // TODO + void OnRemovePassenger(Transport* transport, Player* player); // TODO + void OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z); // TODO + + /* Guild */ + void OnAddMember(Guild* guild, Player* player, uint32 plRank); + void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding); + void OnMOTDChanged(Guild* guild, const std::string& newMotd); + void OnInfoChanged(Guild* guild, const std::string& newInfo); + void OnCreate(Guild* guild, Player* leader, const std::string& name); // TODO: Implement to TC + void OnDisband(Guild* guild); + void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair); + void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount); + void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); // TODO: Implement + void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); // TODO: Implement + void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); + + /* Group */ + void OnAddMember(Group* group, uint64 guid); + void OnInviteMember(Group* group, uint64 guid); + void OnRemoveMember(Group* group, uint64 guid, uint8 method); + void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid); + void OnDisband(Group* group); + void OnCreate(Group* group, uint64 leaderGuid, GroupType groupType); +}; + +#define sHookMgr ACE_Singleton::instance() + +#endif diff --git a/src/game/luaengine/Includes.h b/src/game/luaengine/Includes.h new file mode 100644 index 000000000..280abe0a5 --- /dev/null +++ b/src/game/luaengine/Includes.h @@ -0,0 +1,16 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef INCLUDES_H +#define INCLUDES_H + +#define MANGOS +// #define TRINITY +#define TBC +// #define WOTLK +// #define CATA + +#endif diff --git a/src/game/luaengine/ItemMethods.h b/src/game/luaengine/ItemMethods.h new file mode 100644 index 000000000..688f2537c --- /dev/null +++ b/src/game/luaengine/ItemMethods.h @@ -0,0 +1,386 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef ITEMMETHODS_H +#define ITEMMETHODS_H + +namespace LuaItem +{ + int GetItemLink(lua_State* L, Item* item) // TODO: Implement + { + // LOCALE_enUS = 0, + // LOCALE_koKR = 1, + // LOCALE_frFR = 2, + // LOCALE_deDE = 3, + // LOCALE_zhCN = 4, + // LOCALE_zhTW = 5, + // LOCALE_esES = 6, + // LOCALE_esMX = 7, + // LOCALE_ruRU = 8 + + int loc_idx = sEluna->CHECKVAL(L, 2, LOCALE_enUS); + if (loc_idx < 0 || loc_idx >= MAX_LOCALE) + return luaL_argerror(L, 2, "valid LocaleConstant expected"); + + const ItemPrototype* temp = item->GetProto(); + std::string name = temp->Name1; + + std::ostringstream oss; + oss << std::dec << + "|Hitem:" << temp->ItemId << ":" << + item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_2) << ":" << + item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_3) << ":" << + item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" << + item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" << + (uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r"; + + sEluna->Push(L, oss.str()); + return 1; + } + + int GetGUID(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetGUIDLow()); + return 1; + } + + int GetOwnerGUID(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetOwnerGUID()); + return 1; + } + + int GetOwner(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetOwner()); + return 1; + } + + int SetOwner(lua_State* L, Item* item) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + item->SetOwnerGUID(player->GetGUID()); + return 0; + } + + int SetBinding(lua_State* L, Item* item) + { + bool soulbound = sEluna->CHECKVAL(L, 2); + + item->SetBinding(soulbound); + return 0; + } + + int IsSoulBound(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsSoulBound()); + return 1; + } + + int IsBoundByEnchant(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsBoundByEnchant()); + return 1; + } + + int IsNotBoundToPlayer(lua_State* L, Item* item) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, item->IsBindedNotWith(player->GetGUID())); + return 1; + } + + int IsBag(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsBag()); + return 1; + } + + int IsBroken(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsBroken()); + return 1; + } + + int CanBeTraded(lua_State* L, Item* item) + { + sEluna->Push(L, item->CanBeTraded()); + return 1; + } + + int IsInTrade(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsInTrade()); + return 1; + } + + int GetCount(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetCount()); + return 1; + } + + int SetCount(lua_State* L, Item* item) + { + uint32 count = sEluna->CHECKVAL(L, 2); + item->SetCount(count); + return 0; + } + + int GetMaxStackCount(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetMaxStackCount()); + return 1; + } + + int GetSlot(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetSlot()); + return 1; + } + + int GetBagSlot(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetBagSlot()); + return 1; + } + + int IsInBag(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsInBag()); + return 1; + } + + int IsEquipped(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsEquipped()); + return 1; + } + + int HasQuest(lua_State* L, Item* item) + { + uint32 quest = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, item->hasQuest(quest)); + return 1; + } + + int IsPotion(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsPotion()); + return 1; + } + + int IsConjuredConsumable(lua_State* L, Item* item) + { + sEluna->Push(L, item->IsConjuredConsumable()); + return 1; + } + + int SetEnchantment(lua_State* L, Item* item) + { + Player* owner = item->GetOwner(); + if (!owner) + { + sEluna->Push(L, false); + return 1; + } + + uint32 enchant = sEluna->CHECKVAL(L, 2); + if (!sSpellItemEnchantmentStore.LookupEntry(enchant)) + { + sEluna->Push(L, false); + return 1; + } + + EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL(L, 3); + if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) + return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); + + owner->ApplyEnchantment(item, slot, false); + item->SetEnchantment(slot, enchant, 0, 0); + owner->ApplyEnchantment(item, slot, true); + sEluna->Push(L, true); + return 1; + } + + int ClearEnchantment(lua_State* L, Item* item) + { + Player* owner = item->GetOwner(); + if (!owner) + { + sEluna->Push(L, false); + return 1; + } + + EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL(L, 2); + if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) + return luaL_argerror(L, 2, "valid EnchantmentSlot expected"); + + if (!item->GetEnchantmentId(slot)) + { + sEluna->Push(L, false); + return 1; + } + + owner->ApplyEnchantment(item, slot, false); + item->ClearEnchantment(slot); + sEluna->Push(L, true); + return 1; + } + + int GetGUIDLow(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetGUIDLow()); + return 1; + } + + int GetEnchantmentId(lua_State* L, Item* item) + { + uint32 enchant_slot = sEluna->CHECKVAL(L, 2); + + if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT) + return 0; + + sEluna->Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); + return 1; + } + + int GetSpellId(lua_State* L, Item* item) + { + uint32 index = sEluna->CHECKVAL(L, 2); + if (index >= MAX_ITEM_PROTO_SPELLS) + return luaL_argerror(L, 2, "valid SpellIndex expected"); + + sEluna->Push(L, item->GetProto()->Spells[index].SpellId); + return 1; + } + + int GetSpellTrigger(lua_State* L, Item* item) + { + uint32 index = sEluna->CHECKVAL(L, 2); + if (index >= MAX_ITEM_PROTO_SPELLS) + return luaL_argerror(L, 2, "valid SpellIndex expected"); + + sEluna->Push(L, item->GetProto()->Spells[index].SpellTrigger); + return 1; + } + + int GetClass(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->Class); + return 1; + } + + int GetSubClass(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->SubClass); + return 1; + } + + int GetName(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->Name1); + return 1; + } + + int GetDisplayId(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->DisplayInfoID); + return 1; + } + + int GetQuality(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->Quality); + return 1; + } + + int GetBuyCount(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->BuyCount); + return 1; + } + + int GetBuyPrice(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->BuyPrice); + return 1; + } + + int GetSellPrice(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->SellPrice); + return 1; + } + + int GetInventoryType(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->InventoryType); + return 1; + } + + int GetAllowableClass(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->AllowableClass); + return 1; + } + + int GetAllowableRace(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->AllowableRace); + return 1; + } + + int GetItemLevel(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->ItemLevel); + return 1; + } + + int GetRequiredLevel(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->RequiredLevel); + return 1; + } + + int GetRandomProperty(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->RandomProperty); + return 1; + } + + int GetRandomSuffix(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->RandomSuffix); + return 1; + } + + int GetItemSet(lua_State* L, Item* item) + { + sEluna->Push(L, item->GetProto()->ItemSet); + return 1; + } + + int GetBagSize(lua_State* L, Item* item) + { + if (Bag* bag = item->IsBag() ? (Bag*)item : nullptr) + sEluna->Push(L, bag->GetBagSize()); + else + sEluna->Push(L, 0); + return 1; + } + + int SaveToDB(lua_State* L, Item* item) + { + item->SaveToDB(); + return 0; + } +}; +#endif diff --git a/src/game/luaengine/LuaEngine.cpp b/src/game/luaengine/LuaEngine.cpp new file mode 100644 index 000000000..014c05577 --- /dev/null +++ b/src/game/luaengine/LuaEngine.cpp @@ -0,0 +1,816 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#include "LuaEngine.h" + +#if PLATFORM == PLATFORM_UNIX +#include +#endif + +extern void RegisterFunctions(lua_State* L); +extern void AddElunaScripts(); + +// Start or restart eluna. Returns true if started +bool StartEluna() +{ + if (!sWorld.getConfig(CONFIG_ELUNA_ENABLED)) + { + sLog.outLog(LOG_DEFAULT,"[Eluna]: LuaEngine is Disabled. (If you want to use it please enable in config)"); + return false; + } + + ELUNA_GUARD(false); + bool restart = false; + if (sEluna->L) + { + restart = true; + sHookMgr->OnEngineRestart(); + sLog.outLog(LOG_DEFAULT,"[Eluna]: Restarting Lua Engine"); + + // Unregisters and stops all timed events + sEluna->m_EventMgr.RemoveEvents(); + + // Remove bindings + sEluna->PacketEventBindings.Clear(); + sEluna->ServerEventBindings.Clear(); + sEluna->PlayerEventBindings.Clear(); + sEluna->GuildEventBindings.Clear(); + sEluna->GroupEventBindings.Clear(); + + sEluna->CreatureEventBindings.Clear(); + sEluna->CreatureGossipBindings.Clear(); + sEluna->GameObjectEventBindings.Clear(); + sEluna->GameObjectGossipBindings.Clear(); + sEluna->ItemEventBindings.Clear(); + sEluna->ItemGossipBindings.Clear(); + sEluna->playerGossipBindings.Clear(); + sEluna->VehicleEventBindings.Clear(); + + lua_close(sEluna->L); + } + else + AddElunaScripts(); + + // Check config file for eluna is enabled or disabled + if (!sWorld.getConfig(CONFIG_ELUNA_ENABLED)) + { + sLog.outLog(LOG_DEFAULT,"[Eluna]: LuaEngine is Disabled. (If you want to use it please set config in 'hellgroundcore.conf')"); + return false; + } + + sEluna->L = luaL_newstate(); + sLog.outLog(LOG_DEFAULT,"[Eluna]: Lua Engine loaded."); + + LoadedScripts loadedScripts; + sEluna->LoadDirectory("lua_scripts", &loadedScripts); + luaL_openlibs(sEluna->L); + RegisterFunctions(sEluna->L); + + // Randomize math.random() + //luaL_dostring(sEluna->L, "math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )"); + + uint32 count = 0; + char filename[200]; + for (std::set::const_iterator itr = loadedScripts.begin(); itr != loadedScripts.end(); ++itr) + { + strcpy(filename, itr->c_str()); + if (luaL_loadfile(sEluna->L, filename) != 0) + { + sLog.outLog(LOG_DEFAULT,"[Eluna]: Error loading file `%s`.", itr->c_str()); + sEluna->report(sEluna->L); + } + else + { + int err = lua_ppcall(sEluna->L, 0, 0, 0); + if (err != 0 && err == LUA_ERRRUN) + { + sLog.outLog(LOG_DEFAULT,"[Eluna]: Error loading file `%s`.", itr->c_str()); + sEluna->report(sEluna->L); + } + } + ++count; + } + + /* + if (restart) + { + //! Iterate over every supported source type (creature and gameobject) + //! Not entirely sure how this will affect units in non-loaded grids. + { + HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); + HashMapHolder::MapType& m = HashMapHolder::GetContainer(); + for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) + { + if (itr->second->IsInWorld()) // must check? + // if(sEluna->CreatureEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna? + itr->second->AIM_Initialize(); + } + } + + { + HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); + HashMapHolder::MapType& m = HashMapHolder::GetContainer(); + for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) + { + if (itr->second->IsInWorld()) // must check? + // if(sEluna->GameObjectEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna? + itr->second->AIM_Initialize(); + } + } + } + */ + + sLog.outLog(LOG_DEFAULT, "[Eluna]: Loaded %u Lua scripts..", count); + return true; +} + +// Loads lua scripts from given directory +void Eluna::LoadDirectory(char* Dirname, LoadedScripts* lscr) +{ +#ifdef WIN32 + HANDLE hFile; + WIN32_FIND_DATA FindData; + memset(&FindData, 0, sizeof(FindData)); + char SearchName[MAX_PATH]; + + strcpy(SearchName, Dirname); + strcat(SearchName, "\\*.*"); + + hFile = FindFirstFile(SearchName, &FindData); + if (hFile == INVALID_HANDLE_VALUE) + { + sLog.outLog(LOG_DEFAULT,"[Eluna]: Error No `lua_scripts` directory found! Creating a 'lua_scripts' directory."); + CreateDirectory("lua_scripts", NULL); + return; + } + + FindNextFile(hFile, &FindData); + while (FindNextFile(hFile, &FindData)) + { + if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + strcpy(SearchName, Dirname); + strcat(SearchName, "\\"); + strcat(SearchName, FindData.cFileName); + LoadDirectory(SearchName, lscr); + } + else + { + std::string fname = Dirname; + fname += "\\"; + fname += FindData.cFileName; + size_t len = strlen(fname.c_str()); + int i = 0; + char ext[MAX_PATH]; + while (len > 0) + { + ext[i++] = fname[--len]; + if (fname[len] == '.') + break; + } + ext[i++] = '\0'; + if (!_stricmp(ext, "aul.")) + { + sLog.outDebug("eluna", "[Eluna]: Load File: %s", fname.c_str()); + lscr->insert(fname); + } + } + } + FindClose(hFile); +#else + char* dir = strrchr(Dirname, '/'); + if (strcmp(Dirname, "..") == 0 || strcmp(Dirname, ".") == 0) + return; + + if (dir && (strcmp(dir, "/..") == 0 || strcmp(dir, "/.") == 0 || strcmp(dir, "/.svn") == 0)) + return; + + struct dirent** list; + int fileCount = scandir(Dirname, &list, 0, 0); + + if (fileCount <= 0 || !list) + return; + + struct stat attributes; + bool error; + while (fileCount--) + { + char _path[200]; + sprintf(_path, "%s/%s", Dirname, list[fileCount]->d_name); + if (stat(_path, &attributes) == -1) + { + error = true; + sLog.outLog(LOG_DEFAULT,"[Eluna]: Error opening `%s`", _path); + } + else + error = false; + + if (!error && S_ISDIR(attributes.st_mode)) + LoadDirectory((char*)_path, lscr); + else + { + char* ext = strrchr(list[fileCount]->d_name, '.'); + if (ext && !strcmp(ext, ".lua")) + lscr->insert(_path); + } + free(list[fileCount]); + } + free(list); +#endif +} + +void Eluna::report(lua_State* L) +{ + const char* msg = lua_tostring(L, -1); + while (msg) + { + lua_pop(L, -1); + sLog.outLog(LOG_DEFAULT,"%s", msg); + msg = lua_tostring(L, -1); + } +} + +void Eluna::BeginCall(int fReference) +{ + lua_settop(L, 0); // stack should be empty + lua_rawgeti(L, LUA_REGISTRYINDEX, (fReference)); +} + +bool Eluna::ExecuteCall(int params, int res) +{ + bool ret = true; + int top = lua_gettop(L); + + if (lua_type(L, top - params) == LUA_TFUNCTION) // is function + { + if (lua_ppcall(L, params, res, 0)) + { + report(L); + ret = false; + } + } + else + { + ret = false; + if (params > 0) + { + for (int i = top; i >= (top - params); i--) + { + if (!lua_isnone(L, i)) + lua_remove(L, i); + } + } + } + return ret; +} + +void Eluna::EndCall(int res) +{ + for (int i = res; i > 0; i--) + { + if (!lua_isnone(L, res)) + lua_remove(L, res); + } +} + +void Eluna::Push(lua_State* L) +{ + lua_pushnil(L); +} +void Eluna::Push(lua_State* L, const uint64 l) +{ + std::ostringstream ss; + ss << l; + sEluna->Push(L, ss.str()); +} +void Eluna::Push(lua_State* L, const int64 l) +{ + std::ostringstream ss; + ss << l; + sEluna->Push(L, ss.str()); +} +void Eluna::Push(lua_State* L, const uint32 u) +{ + lua_pushunsigned(L, u); +} +void Eluna::Push(lua_State* L, const int32 i) +{ + lua_pushinteger(L, i); +} +void Eluna::Push(lua_State* L, const double d) +{ + lua_pushnumber(L, d); +} +void Eluna::Push(lua_State* L, const float f) +{ + lua_pushnumber(L, f); +} +void Eluna::Push(lua_State* L, const bool b) +{ + lua_pushboolean(L, b); +} +void Eluna::Push(lua_State* L, const std::string str) +{ + lua_pushstring(L, str.c_str()); +} +void Eluna::Push(lua_State* L, const char* str) +{ + lua_pushstring(L, str); +} +void Eluna::Push(lua_State* L, Pet const* pet) +{ + Push(L, pet->ToCreature()); +} +void Eluna::Push(lua_State* L, TemporarySummon const* summon) +{ + Push(L, summon->ToCreature()); +} +void Eluna::Push(lua_State* L, Unit const* unit) +{ + if (!unit) + { + Push(L); + return; + } + switch (unit->GetTypeId()) + { + case TYPEID_UNIT: + Push(L, unit->ToCreature()); + break; + case TYPEID_PLAYER: + Push(L, unit->ToPlayer()); + break; + default: + ElunaTemplate::push(L, unit); + } +} +void Eluna::Push(lua_State* L, WorldObject const* obj) +{ + if (!obj) + { + Push(L); + return; + } + switch (obj->GetTypeId()) + { + case TYPEID_UNIT: + Push(L, obj->ToCreature()); + break; + case TYPEID_PLAYER: + Push(L, obj->ToPlayer()); + break; + case TYPEID_GAMEOBJECT: + Push(L, obj->ToGameObject()); + break; + case TYPEID_CORPSE: + Push(L, obj->ToCorpse()); + break; + default: + ElunaTemplate::push(L, obj); + } +} +template<> bool Eluna::CHECKVAL(lua_State* L, int narg) +{ + return !lua_toboolean(L, narg) ? false : luaL_optnumber(L, narg, 1) ? true : false; +} +template<> bool Eluna::CHECKVAL(lua_State* L, int narg, bool def) +{ + return lua_isnone(L, narg) ? def : !lua_toboolean(L, narg) ? false : luaL_optnumber(L, narg, 1) ? true : false; +} +template<> float Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checknumber(L, narg); +} +template<> float Eluna::CHECKVAL(lua_State* L, int narg, float def) +{ + return luaL_optnumber(L, narg, def); +} +template<> double Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checknumber(L, narg); +} +template<> double Eluna::CHECKVAL(lua_State* L, int narg, double def) +{ + return luaL_optnumber(L, narg, def); +} +template<> int8 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkint(L, narg); +} +template<> int8 Eluna::CHECKVAL(lua_State* L, int narg, int8 def) +{ + return luaL_optint(L, narg, def); +} +template<> uint8 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkunsigned(L, narg); +} +template<> uint8 Eluna::CHECKVAL(lua_State* L, int narg, uint8 def) +{ + return luaL_optunsigned(L, narg, def); +} +template<> int16 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkint(L, narg); +} +template<> int16 Eluna::CHECKVAL(lua_State* L, int narg, int16 def) +{ + return luaL_optint(L, narg, def); +} +template<> uint16 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkunsigned(L, narg); +} +template<> uint16 Eluna::CHECKVAL(lua_State* L, int narg, uint16 def) +{ + return luaL_optunsigned(L, narg, def); +} +template<> uint32 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkunsigned(L, narg); +} +template<> uint32 Eluna::CHECKVAL(lua_State* L, int narg, uint32 def) +{ + return luaL_optunsigned(L, narg, def); +} +template<> int32 Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checklong(L, narg); +} +template<> int32 Eluna::CHECKVAL(lua_State* L, int narg, int32 def) +{ + return luaL_optlong(L, narg, def); +} +template<> const char* Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkstring(L, narg); +} +template<> const char* Eluna::CHECKVAL(lua_State* L, int narg, const char* def) +{ + return luaL_optstring(L, narg, def); +} +template<> std::string Eluna::CHECKVAL(lua_State* L, int narg) +{ + return luaL_checkstring(L, narg); +} +template<> std::string Eluna::CHECKVAL(lua_State* L, int narg, std::string def) +{ + return luaL_optstring(L, narg, def.c_str()); +} +template<> uint64 Eluna::CHECKVAL(lua_State* L, int narg) +{ + const char* c_str = luaL_optstring(L, narg, NULL); + if (!c_str) + return luaL_argerror(L, narg, "uint64 (as string) expected"); + uint64 l = 0; + sscanf(c_str, UI64FMTD, &l); + return l; +} +template<> uint64 Eluna::CHECKVAL(lua_State* L, int narg, uint64 def) +{ + const char* c_str = luaL_checkstring(L, narg); + if (!c_str) + return def; + uint64 l = 0; + sscanf(c_str, UI64FMTD, &l); + return l; +} +template<> int64 Eluna::CHECKVAL(lua_State* L, int narg) +{ + const char* c_str = luaL_optstring(L, narg, NULL); + if (!c_str) + return luaL_argerror(L, narg, "int64 (as string) expected"); + int64 l = 0; + sscanf(c_str, SI64FMTD, &l); + return l; +} +template<> int64 Eluna::CHECKVAL(lua_State* L, int narg, int64 def) +{ + const char* c_str = luaL_checkstring(L, narg); + if (!c_str) + return def; + int64 l = 0; + sscanf(c_str, SI64FMTD, &l); + return l; +} +#define TEST_OBJ(T, O, E, F)\ +{\ + if (!O || !O->F())\ +{\ + if (E)\ +{\ + std::string errmsg(ElunaTemplate::tname);\ + errmsg += " expected";\ + luaL_argerror(L, narg, errmsg.c_str());\ +}\ + return NULL;\ +}\ + return O->F();\ +} +template<> Unit* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) +{ + WorldObject* obj = CHECKOBJ(L, narg, false); + TEST_OBJ(Unit, obj, error, ToUnit); +} +template<> Player* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) +{ + WorldObject* obj = CHECKOBJ(L, narg, false); + TEST_OBJ(Player, obj, error, ToPlayer); +} +template<> Creature* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) +{ + WorldObject* obj = CHECKOBJ(L, narg, false); + TEST_OBJ(Creature, obj, error, ToCreature); +} +template<> GameObject* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) +{ + WorldObject* obj = CHECKOBJ(L, narg, false); + TEST_OBJ(GameObject, obj, error, ToGameObject); +} +template<> Corpse* Eluna::CHECKOBJ(lua_State* L, int narg, bool error) +{ + WorldObject* obj = CHECKOBJ(L, narg, false); + TEST_OBJ(Corpse, obj, error, ToCorpse); +} +#undef TEST_OBJ + +// Saves the function reference ID given to the register type's store for given entry under the given event +void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef) +{ + switch (regtype) + { + case REGTYPE_PACKET: + if (evt < NUM_MSG_TYPES) + { + PacketEventBindings.Insert(evt, functionRef); + return; + } + break; + + case REGTYPE_SERVER: + if (evt < SERVER_EVENT_COUNT) + { + ServerEventBindings.Insert(evt, functionRef); + return; + } + break; + + case REGTYPE_PLAYER: + if (evt < PLAYER_EVENT_COUNT) + { + PlayerEventBindings.Insert(evt, functionRef); + return; + } + break; + + case REGTYPE_GUILD: + if (evt < GUILD_EVENT_COUNT) + { + GuildEventBindings.Insert(evt, functionRef); + return; + } + break; + + case REGTYPE_GROUP: + if (evt < GROUP_EVENT_COUNT) + { + GroupEventBindings.Insert(evt, functionRef); + return; + } + break; + + case REGTYPE_CREATURE: + if (evt < CREATURE_EVENT_COUNT) + { + if (!sObjectMgr.GetCreatureTemplate(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a creature with (ID: %d)!", id); + return; + } + + sEluna->CreatureEventBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_CREATURE_GOSSIP: + if (evt < GOSSIP_EVENT_COUNT) + { + if (!sObjectMgr.GetCreatureTemplate(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a creature with (ID: %d)!", id); + return; + } + + sEluna->CreatureGossipBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_GAMEOBJECT: + if (evt < GAMEOBJECT_EVENT_COUNT) + { + if (!sObjectMgr.GetGameObjectInfo(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id); + return; + } + + sEluna->GameObjectEventBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_GAMEOBJECT_GOSSIP: + if (evt < GOSSIP_EVENT_COUNT) + { + if (!sObjectMgr.GetGameObjectInfo(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id); + return; + } + + sEluna->GameObjectGossipBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_ITEM: + if (evt < ITEM_EVENT_COUNT) + { + if (!sObjectMgr.GetItemPrototype(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a item with (ID: %d)!", id); + return; + } + + sEluna->ItemEventBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_ITEM_GOSSIP: + if (evt < GOSSIP_EVENT_COUNT) + { + if (!sObjectMgr.GetItemPrototype(id)) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Couldn't find a item with (ID: %d)!", id); + return; + } + + sEluna->ItemGossipBindings.Insert(id, evt, functionRef); + return; + } + break; + + case REGTYPE_PLAYER_GOSSIP: + if (evt < GOSSIP_EVENT_COUNT) + { + sEluna->playerGossipBindings.Insert(id, evt, functionRef); + return; + } + break; + + default: + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Unknown register type (regtype %d, id %d, event %d)", regtype, id, evt); + return; + } + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, functionRef); + luaL_error(L, "Unknown event type (regtype %d, id %d, event %d)", regtype, id, evt); +} + +void Eluna::EventBind::Clear() +{ + for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr) + { + for (ElunaBindingMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it)); + itr->second.clear(); + } + Bindings.clear(); +} + +void Eluna::EventBind::Insert(int eventId, int funcRef) +{ + Bindings[eventId].push_back(funcRef); +} + +bool Eluna::EventBind::BeginCall(int eventId) const +{ + if (Bindings.empty()) + return false; + if (Bindings.find(eventId) == Bindings.end()) + return false; + lua_settop(sEluna->L, 0); // stack should be empty + sEluna->Push(sEluna->L, eventId); + return true; +} + +void Eluna::EventBind::ExecuteCall() +{ + int eventId = sEluna->CHECKVAL(sEluna->L, 1); + int params = lua_gettop(sEluna->L); + for (ElunaBindingMap::const_iterator it = Bindings[eventId].begin(); it != Bindings[eventId].end(); ++it) + { + lua_rawgeti(sEluna->L, LUA_REGISTRYINDEX, (*it)); // Fetch function + for (int i = 1; i <= params; ++i) // Copy original pushed params + lua_pushvalue(sEluna->L, i); + sEluna->ExecuteCall(params, LUA_MULTRET); // Do call and leave results to stack + } + for (int i = params; i > 0; --i) // Remove original pushed params + if (!lua_isnone(sEluna->L, i)) + lua_remove(sEluna->L, i); + // Results in stack, otherwise stack clean +} + +void Eluna::EventBind::EndCall() const +{ + lua_settop(sEluna->L, 0); // stack should be empty +}; + +void Eluna::EntryBind::Clear() +{ + for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr) + { + for (ElunaBindingMap::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, it->second); + itr->second.clear(); + } + Bindings.clear(); +} + +void Eluna::EntryBind::Insert(uint32 entryId, int eventId, int funcRef) +{ + if (Bindings[entryId][eventId]) + { + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // free the unused ref + luaL_error(sEluna->L, "A function is already registered for entry (%d) event (%d)", entryId, eventId); + } + else + Bindings[entryId][eventId] = funcRef; +} + +EventMgr::LuaEvent::LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj) : + events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj) +{ + if (_events) + sEluna->m_EventMgr.LuaEvents[_events].insert(this); // Able to access the event if we have the processor +} + +EventMgr::LuaEvent::~LuaEvent() +{ + if (events) + { + // Attempt to remove the pointer from LuaEvents + EventMgr::EventMap::const_iterator it = sEluna->m_EventMgr.LuaEvents.find(events); // Get event set + if (it != sEluna->m_EventMgr.LuaEvents.end()) + sEluna->m_EventMgr.LuaEvents[events].erase(this);// Remove pointer + } + luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // Free lua function ref +} + +bool EventMgr::LuaEvent::Execute(uint64 time, uint32 diff) +{ + ELUNA_GUARD(false); + bool remove = (calls == 1); + if (!remove) + events->AddEvent(this, events->CalculateTime(delay)); // Reschedule before calling incase RemoveEvents used + sEluna->BeginCall(funcRef); + sEluna->Push(sEluna->L, funcRef); + sEluna->Push(sEluna->L, delay); + sEluna->Push(sEluna->L, calls); + if (!remove && calls) + --calls; + sEluna->Push(sEluna->L, obj); + sEluna->ExecuteCall(4, 0); + return remove; // Destory (true) event if not run +} + +// Lua taxi helper functions +uint32 LuaTaxiMgr::nodeId = 500; +void LuaTaxiMgr::StartTaxi(Player* player, uint32 pathid) +{ + if (pathid >= sTaxiPathNodesByPath.size()) + return; + + TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid]; + if (path.size() < 2) + return; + + std::vector nodes; + nodes.resize(2); + nodes[0] = path[0].index; + nodes[1] = path[path.size() - 1].index; + + player->ActivateTaxiPathTo(nodes); +} diff --git a/src/game/luaengine/LuaEngine.h b/src/game/luaengine/LuaEngine.h new file mode 100644 index 000000000..f124753a4 --- /dev/null +++ b/src/game/luaengine/LuaEngine.h @@ -0,0 +1,615 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef __ELUNA__H +#define __ELUNA__H + +extern "C" +{ +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} + +#include "Includes.h" +#include "luaengine/HookMgr.h" + +// Required +#include "AccountMgr.h" +#include "ArenaTeam.h" +#include "AuctionHouseMgr.h" +#include "Cell.h" +#include "CellImpl.h" +#include "Chat.h" +#include "Channel.h" +#include "DBCStores.h" +#include "GossipDef.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "Group.h" +#include "Guild.h" +#include "Language.h" +#include "Mail.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" +#include "Pet.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" +#include "Spell.h" +#include "SpellAuras.h" +#include "SpellMgr.h" +#include "TemporarySummon.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "ReactorAI.h" +#include "GuildMgr.h" + +typedef std::set LoadedScripts; + +#ifdef NOT_USE_ELUNA_HOOKS +#define ELUNA_GUARD(a) return a; +#else +#define ELUNA_GUARD(b) \ + ACE_Guard< ACE_Thread_Mutex > ELUNA_GUARD_OBJECT (sEluna->lock); +#endif + +template +struct ElunaRegister +{ + const char* name; + int(*mfunc)(lua_State*, T*); +}; + +template +class ElunaTemplate +{ +public: + static const char* tname; + static bool manageMemory; + + static int type(lua_State* L) + { + lua_pushstring(L, tname); + return 1; + } + + static int gcT(lua_State* L) + { + if (!manageMemory) + return 0; + T* obj = check(L, 1); + delete obj; // Deleting NULL should be safe + return 1; + } + + // name will be used as type name + // If gc is true, lua will handle the memory management for object pushed + // gc should be used if pushing for example WorldPacket, + // that will only be needed on lua side and will not be managed by TC/mangos/ + static void Register(lua_State* L, const char* name, bool gc = false) + { + tname = name; + manageMemory = gc; + + lua_settop(L, 0); // clean stack + + lua_newtable(L); + int methods = lua_gettop(L); + + luaL_newmetatable(L, tname); + int metatable = lua_gettop(L); + + // store method table in globals so that + // scripts can add functions in Lua + lua_pushvalue(L, methods); + lua_setglobal(L, tname); + + // hide metatable + lua_pushvalue(L, methods); + lua_setfield(L, metatable, "__metatable"); + + lua_pushvalue(L, methods); + lua_setfield(L, metatable, "__index"); + + lua_pushcfunction(L, tostringT); + lua_setfield(L, metatable, "__tostring"); + + lua_pushcfunction(L, gcT); + lua_setfield(L, metatable, "__gc"); + + lua_newtable(L); + lua_setmetatable(L, methods); + } + + template + static void SetMethods(lua_State* L, ElunaRegister* methodTable) + { + if (!methodTable) + return; + if (!lua_istable(L, 1)) + return; + lua_pushstring(L, "GetObjectType"); + lua_pushcclosure(L, type, 0); + lua_settable(L, 1); + for (; methodTable->name; ++methodTable) + { + lua_pushstring(L, methodTable->name); + lua_pushlightuserdata(L, (void*)methodTable); + lua_pushcclosure(L, thunk, 1); + lua_settable(L, 1); + } + } + + static int push(lua_State* L, T const* obj) + { + if (!obj) + { + lua_pushnil(L); + return lua_gettop(L); + } + luaL_getmetatable(L, tname); + if (lua_isnoneornil(L, -1)) + return luaL_error(L, "%s missing metatable", tname); + T const** ptrHold = (T const**)lua_newuserdata(L, sizeof(T**)); + if (ptrHold) + { + *ptrHold = obj; + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); + } + lua_replace(L, -2); + return lua_gettop(L); + } + + static T* check(lua_State* L, int narg, bool error = true) + { + T** ptrHold = static_cast(lua_touserdata(L, narg)); + if (!ptrHold) + { + if (error) + { + std::string errmsg(ElunaTemplate::tname); + errmsg += " expected"; + luaL_argerror(L, narg, errmsg.c_str()); + } + return NULL; + } + return *ptrHold; + } + + static int thunk(lua_State* L) + { + T* obj = check(L, 1); // get self + ElunaRegister* l = static_cast*>(lua_touserdata(L, lua_upvalueindex(1))); + if (!obj) + return 0; + return l->mfunc(L, obj); + } + + static int tostringT(lua_State* L) + { + char buff[32]; + T** ptrHold = (T**)lua_touserdata(L, 1); + sprintf(buff, "%p", *ptrHold); + lua_pushfstring(L, "%s (%s)", tname, buff); + return 1; + } +}; + +struct EventMgr +{ + struct LuaEvent; + + typedef std::set EventSet; + typedef std::map EventMap; + // typedef UNORDERED_MAP ProcessorMap; + + EventMap LuaEvents; // LuaEvents[processor] = {LuaEvent, LuaEvent...} + // ProcessorMap Processors; // Processors[guid] = processor + EventProcessor GlobalEvents; + + struct LuaEvent : public BasicEvent + { + LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj); + + ~LuaEvent(); + + // Should never execute on dead events + bool Execute(uint64 time, uint32 diff); + + EventProcessor* events; // Pointer to events (holds the timed event) + int funcRef; // Lua function reference ID, also used as event ID + uint32 delay; // Delay between event calls + uint32 calls; // Amount of calls to make, 0 for infinite + Object* obj; // Object to push + }; + + // Should be run on world tick + void Update(uint32 diff) + { + GlobalEvents.Update(diff); + } + + // Updates processor stored for guid || remove from Update() + // Should be run on gameobject tick + /*void Update(uint64 guid, uint32 diff) + { + if (Processors.find(guid) == Processors.end()) + return; + Processors[guid].Update(diff); + }*/ + + // Aborts all lua events + void KillAllEvents(EventProcessor* events) + { + if (!events) + return; + if (LuaEvents.empty()) + return; + EventMap::const_iterator it = LuaEvents.find(events); // Get event set + if (it == LuaEvents.end()) + return; + if (it->second.empty()) + return; + for (EventSet::const_iterator itr = it->second.begin(); itr != it->second.end();) // Loop events + (*(itr++))->to_Abort = true; // Abort event + } + + // Remove all timed events + void RemoveEvents() + { + if (!LuaEvents.empty()) + for (EventMap::const_iterator it = LuaEvents.begin(); it != LuaEvents.end();) // loop processors + KillAllEvents((it++)->first); + LuaEvents.clear(); // remove pointers + // This is handled automatically on delete + // for (ProcessorMap::iterator it = Processors.begin(); it != Processors.end();) + // (it++)->second.KillAllEvents(true); + // Processors.clear(); // remove guid saved processors + GlobalEvents.KillAllEvents(true); + } + + // Remove timed events from processor + void RemoveEvents(EventProcessor* events) + { + if (!events) + return; + KillAllEvents(events); + LuaEvents.erase(events); // remove pointer set + } + + // Remove timed events from guid + // void RemoveEvents(uint64 guid) + //{ + // if (Processors.empty()) + // return; + // if (Processors.find(guid) != Processors.end()) + // LuaEvents.erase(&Processors[guid]); + // // Processors[guid].KillAllEvents(true); // remove events + // Processors.erase(guid); // remove processor + //} + + // Adds a new event to the processor and returns the eventID or 0 (Never negative) + int AddEvent(EventProcessor* events, int funcRef, uint32 delay, uint32 calls, Object* obj = NULL) + { + if (!events || funcRef <= 0) // If funcRef <= 0, function reference failed + return 0; // on fail always return 0. funcRef can be negative. + events->AddEvent(new LuaEvent(events, funcRef, delay, calls, obj), events->CalculateTime(delay)); + return funcRef; // return the event ID + } + + // Creates a processor for the guid if needed and adds the event to it + // int AddEvent(uint64 guid, int funcRef, uint32 delay, uint32 calls, Object* obj = NULL) + //{ + // if (!guid) // 0 should be unused + // return 0; + // return AddEvent(&Processors[guid], funcRef, delay, calls, obj); + //} + + // Finds the event that has the ID from events + LuaEvent* GetEvent(EventProcessor* events, int eventId) + { + if (!events || !eventId) + return NULL; + if (LuaEvents.empty()) + return NULL; + EventMap::const_iterator it = LuaEvents.find(events); // Get event set + if (it == LuaEvents.end()) + return NULL; + if (it->second.empty()) + return NULL; + for (EventSet::const_iterator itr = it->second.begin(); itr != it->second.end(); ++itr) // Loop events + if ((*itr) && (*itr)->funcRef == eventId) // Check if the event has our ID + return *itr; // Return the event if found + return NULL; + } + + // Remove the event with the eventId from processor + // Returns true if event is removed + bool RemoveEvent(EventProcessor* events, int eventId) // eventId = funcRef + { + if (!events || !eventId) + return false; + LuaEvent* luaEvent = GetEvent(events, eventId); + if (!luaEvent) + return false; + luaEvent->to_Abort = true; // Set to remove on next call + LuaEvents[events].erase(luaEvent); // Remove pointer + return true; + } + + // Remove event by ID from processor stored for guid + /*bool RemoveEvent(uint64 guid, int eventId) + { + if (Processors.empty()) + return false; + if (!guid || Processors.find(guid) == Processors.end()) + return false; + return RemoveEvent(&Processors[guid], eventId); + }*/ + + // Removes the eventId from all events + void RemoveEvent(int eventId) + { + if (!eventId) + return; + if (LuaEvents.empty()) + return; + for (EventMap::const_iterator it = LuaEvents.begin(); it != LuaEvents.end();) // loop processors + if (RemoveEvent((it++)->first, eventId)) + break; // succesfully remove the event, stop loop. + } + + ~EventMgr() + { + RemoveEvents(); + } +}; + +class Eluna +{ +public: + friend class ScriptMgr; + lua_State* L; + EventMgr m_EventMgr; + ACE_Thread_Mutex lock; + + Eluna() + { + L = NULL; + } + + ~Eluna() + { + } + + struct EventBind + { + typedef std::vector ElunaBindingMap; + typedef std::map ElunaEntryMap; + + ~EventBind() + { + Clear(); + } + + void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset) + void Insert(int eventId, int funcRef); // Inserts a new registered event + + // Gets the binding std::map containing all registered events with the function refs for the entry + ElunaBindingMap* GetBindMap(int eventId) + { + if (Bindings.empty()) + return NULL; + ElunaEntryMap::iterator itr = Bindings.find(eventId); + if (itr == Bindings.end()) + return NULL; + + return &itr->second; + } + + // Checks if there are events for ID, if so, cleans stack and pushes eventId + bool BeginCall(int eventId) const; + // Loops through all registered events for the eventId at stack index 1 + // Copies the whole stack as arguments for the called function. Before Executing, push all params to stack! + // Leaves return values from all functions in order to the stack. + void ExecuteCall(); + void EndCall() const; + + ElunaEntryMap Bindings; // Binding store Bindings[eventId] = {funcRef}; + }; + + struct EntryBind + { + typedef std::map ElunaBindingMap; + typedef std::map ElunaEntryMap; + + ~EntryBind() + { + Clear(); + } + + void Clear(); // unregisters all registered functions and clears all registered events from the bind std::maps (reset) + void Insert(uint32 entryId, int eventId, int funcRef); // Inserts a new registered event + + // Gets the function ref of an entry for an event + int GetBind(uint32 entryId, int eventId) const + { + if (Bindings.empty()) + return 0; + ElunaEntryMap::const_iterator itr = Bindings.find(entryId); + if (itr == Bindings.end() || itr->second.empty()) + return 0; + ElunaBindingMap::const_iterator itr2 = itr->second.find(eventId); + if (itr2 == itr->second.end()) + return 0; + return itr2->second; + } + + // Gets the binding std::map containing all registered events with the function refs for the entry + const ElunaBindingMap* GetBindMap(uint32 entryId) const + { + if (Bindings.empty()) + return NULL; + ElunaEntryMap::const_iterator itr = Bindings.find(entryId); + if (itr == Bindings.end()) + return NULL; + + return &itr->second; + } + + // Returns true if the entry has registered binds + bool HasBinds(uint32 entryId) const + { + if (Bindings.empty()) + return false; + return Bindings.find(entryId) != Bindings.end(); + } + + ElunaEntryMap Bindings; // Binding store Bindings[entryId][eventId] = funcRef; + }; + + // Use templates for EventBind + EventBind PacketEventBindings; + EventBind ServerEventBindings; + EventBind PlayerEventBindings; + EventBind GuildEventBindings; + EventBind GroupEventBindings; + EventBind VehicleEventBindings; + + EntryBind CreatureEventBindings; + EntryBind CreatureGossipBindings; + EntryBind GameObjectEventBindings; + EntryBind GameObjectGossipBindings; + EntryBind ItemEventBindings; + EntryBind ItemGossipBindings; + EntryBind playerGossipBindings; + + static void report(lua_State*); + void Register(uint8 reg, uint32 id, uint32 evt, int func); + void BeginCall(int fReference); + bool ExecuteCall(int params, int res); + void EndCall(int res); + void LoadDirectory(char* directory, LoadedScripts* scr); + + // Pushes + void Push(lua_State*); // nil + void Push(lua_State*, const uint64); + void Push(lua_State*, const int64); + void Push(lua_State*, const uint32); + void Push(lua_State*, const int32); + void Push(lua_State*, const bool); + void Push(lua_State*, const float); + void Push(lua_State*, const double); + void Push(lua_State*, const char*); + void Push(lua_State*, const std::string); + template void Push(lua_State* L, T const* ptr) + { + ElunaTemplate::push(L, ptr); + } + void Push(lua_State* L, WorldObject const* obj); + void Push(lua_State* L, Unit const* unit); + void Push(lua_State* L, Pet const* pet); + void Push(lua_State* L, TemporarySummon const* summon); + + // Checks + template T CHECKVAL(lua_State* L, int narg); + template T CHECKVAL(lua_State* L, int narg, T def); + template T* CHECKOBJ(lua_State* L, int narg, bool error = true) + { + return ElunaTemplate::check(L, narg, error); + } + + struct ObjectGUIDCheck + { + ObjectGUIDCheck(uint64 guid) : _guid(guid) { } + bool operator()(WorldObject* object) + { + return object->GetGUID() == _guid; + } + + uint64 _guid; + }; + + // Binary predicate to sort WorldObjects based on the distance to a reference WorldObject + struct ObjectDistanceOrderPred + { + ObjectDistanceOrderPred(WorldObject const* pRefObj, bool ascending = true) : m_refObj(pRefObj), m_ascending(ascending) { } + bool operator()(WorldObject const* pLeft, WorldObject const* pRight) const + { + return m_ascending ? m_refObj->GetDistanceOrder(pLeft, pRight) : !m_refObj->GetDistanceOrder(pLeft, pRight); + } + + WorldObject const* m_refObj; + const bool m_ascending; + }; + + // Doesn't get self + struct WorldObjectInRangeCheck + { + WorldObjectInRangeCheck(bool nearest, WorldObject const* obj, float range, + uint16 typeMask = 0, uint32 entry = 0, uint32 hostile = 0) : i_nearest(nearest), + i_obj(obj), i_range(range), i_typeMask(typeMask), i_entry(entry), i_hostile(hostile) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(WorldObject* u) + { + if (i_typeMask && !u->isType(TypeMask(i_typeMask))) + return false; + if (i_entry && u->GetEntry() != i_entry) + return false; + if (i_obj->GetGUID() == u->GetGUID()) + return false; + if (!i_obj->IsWithinDistInMap(u, i_range)) + return false; + if (Unit* unit = u->ToUnit()) + { + if (!unit->isAlive()) + return false; + + if (i_hostile) + { + if (const Unit* obj = i_obj->ToUnit()) + { + if ((i_hostile == 1) != obj->IsHostileTo(unit)) + return false; + } + } + } + if (i_nearest) + i_range = i_obj->GetDistance(u); + return true; + } + + WorldObject const* i_obj; + float i_range; + uint16 i_typeMask; + uint32 i_entry; + bool i_nearest; + uint32 i_hostile; + + WorldObjectInRangeCheck(WorldObjectInRangeCheck const&); + }; +}; +template<> Unit* Eluna::CHECKOBJ(lua_State* L, int narg, bool error); +template<> Player* Eluna::CHECKOBJ(lua_State* L, int narg, bool error); +template<> Creature* Eluna::CHECKOBJ(lua_State* L, int narg, bool error); +template<> GameObject* Eluna::CHECKOBJ(lua_State* L, int narg, bool error); +template<> Corpse* Eluna::CHECKOBJ(lua_State* L, int narg, bool error); + +#define sEluna ACE_Singleton::instance() + +class LuaTaxiMgr +{ +private: + static uint32 nodeId; +public: + static void StartTaxi(Player* player, uint32 pathid); +}; +#endif diff --git a/src/game/luaengine/LuaFunctions.cpp b/src/game/luaengine/LuaFunctions.cpp new file mode 100644 index 000000000..e3aab5839 --- /dev/null +++ b/src/game/luaengine/LuaFunctions.cpp @@ -0,0 +1,1069 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +// Eluna +#include "LuaEngine.h" +// Methods +#include "GlobalMethods.h" +#include "ObjectMethods.h" +#include "WorldObjectMethods.h" +#include "UnitMethods.h" +#include "PlayerMethods.h" +#include "CreatureMethods.h" +#include "GroupMethods.h" +#include "GuildMethods.h" +#include "GameObjectMethods.h" +#include "QueryMethods.h" +#include "AuraMethods.h" +#include "ItemMethods.h" +#include "WorldPacketMethods.h" +#include "SpellMethods.h" +#include "QuestMethods.h" +#include "MapMethods.h" +#include "CorpseMethods.h" +#include "WeatherMethods.h" + +void RegisterGlobals(lua_State* L) +{ + // Hooks + lua_register(L, "RegisterPacketEvent", &LuaGlobalFunctions::RegisterPacketEvent); // RegisterPacketEvent(opcodeID, function) + lua_register(L, "RegisterServerEvent", &LuaGlobalFunctions::RegisterServerEvent); // RegisterServerEvent(event, function) + lua_register(L, "RegisterPlayerEvent", &LuaGlobalFunctions::RegisterPlayerEvent); // RegisterPlayerEvent(event, function) + lua_register(L, "RegisterGuildEvent", &LuaGlobalFunctions::RegisterGuildEvent); // RegisterGuildEvent(event, function) + lua_register(L, "RegisterGroupEvent", &LuaGlobalFunctions::RegisterGroupEvent); // RegisterGroupEvent(event, function) + lua_register(L, "RegisterCreatureEvent", &LuaGlobalFunctions::RegisterCreatureEvent); // RegisterCreatureEvent(entry, event, function) + lua_register(L, "RegisterCreatureGossipEvent", &LuaGlobalFunctions::RegisterCreatureGossipEvent); // RegisterCreatureGossipEvent(entry, event, function) + lua_register(L, "RegisterGameObjectEvent", &LuaGlobalFunctions::RegisterGameObjectEvent); // RegisterGameObjectEvent(entry, event, function) + lua_register(L, "RegisterGameObjectGossipEvent", &LuaGlobalFunctions::RegisterGameObjectGossipEvent); // RegisterGameObjectGossipEvent(entry, event, function) + lua_register(L, "RegisterItemEvent", &LuaGlobalFunctions::RegisterItemEvent); // RegisterItemEvent(entry, event, function) + lua_register(L, "RegisterItemGossipEvent", &LuaGlobalFunctions::RegisterItemGossipEvent); // RegisterItemGossipEvent(entry, event, function) + lua_register(L, "RegisterPlayerGossipEvent", &LuaGlobalFunctions::RegisterPlayerGossipEvent); // RegisterPlayerGossipEvent(menu_id, event, function) + + // Getters + lua_register(L, "GetLuaEngine", &LuaGlobalFunctions::GetLuaEngine); // GetLuaEngine() - Returns ElunaEngine + lua_register(L, "GetCoreName", &LuaGlobalFunctions::GetCoreName); // GetCoreName() - Returns core name + lua_register(L, "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion); // GetCoreVersion() - Returns core version string + lua_register(L, "GetQuest", &LuaGlobalFunctions::GetQuest); // GetQuest(questId) - Returns quest object + lua_register(L, "GetPlayerByGUID", &LuaGlobalFunctions::GetPlayerByGUID); // GetPlayerByGUID(guid) - Returns player object by GUID + lua_register(L, "GetPlayerByName", &LuaGlobalFunctions::GetPlayerByName); // GetPlayerByName(name) - Returns player object by player name + lua_register(L, "GetGameTime", &LuaGlobalFunctions::GetGameTime); // GetGameTime() - Returns game time + lua_register(L, "GetPlayersInWorld", &LuaGlobalFunctions::GetPlayersInWorld); // GetPlayersInWorld([team, onlyGM]) - Returns a table with all player objects. Team can be 0 for ally, 1 for horde and 2 for neutral + lua_register(L, "GetPlayersInMap", &LuaGlobalFunctions::GetPlayersInMap); // GetPlayersInWorld(mapId[, instanceId, team]) - Returns a table with all player objects in map. Team can be 0 for ally, 1 for horde and 2 for neutral + lua_register(L, "GetGuildByName", &LuaGlobalFunctions::GetGuildByName); // GetGuildByName(name) - Returns guild object by the guild name + lua_register(L, "GetGuildByLeaderGUID", &LuaGlobalFunctions::GetGuildByLeaderGUID); // GetGuildByLeaderGUID(guid) - Returns guild by it's leader's guid + lua_register(L, "GetPlayerCount", &LuaGlobalFunctions::GetPlayerCount); // GetPlayerCount() - Returns the server's player count + lua_register(L, "GetPlayerGUID", &LuaGlobalFunctions::GetPlayerGUID); // GetPlayerGUID(lowguid) - Generates GUID (uint64) string from player lowguid UNDOCUMENTED + lua_register(L, "GetItemGUID", &LuaGlobalFunctions::GetItemGUID); // GetItemGUID(lowguid) - Generates GUID (uint64) string from item lowguid UNDOCUMENTED + lua_register(L, "GetObjectGUID", &LuaGlobalFunctions::GetObjectGUID); // GetObjectGUID(lowguid, entry) - Generates GUID (uint64) string from gameobject lowguid and entry UNDOCUMENTED + lua_register(L, "GetUnitGUID", &LuaGlobalFunctions::GetUnitGUID); // GetUnitGUID(lowguid, entry) - Generates GUID (uint64) string from unit (creature) lowguid and entry UNDOCUMENTED + lua_register(L, "GetGUIDLow", &LuaGlobalFunctions::GetGUIDLow); // GetGUIDLow(guid) - Returns GUIDLow (uint32) from guid (uint64 as string) UNDOCUMENTED + lua_register(L, "GetGUIDType", &LuaGlobalFunctions::GetGUIDType); // GetGUIDType(guid) - Returns Type (uint32) from guid (uint64 as string) UNDOCUMENTED + lua_register(L, "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry); // GetGUIDEntry(guid) - Returns Entry (uint32) from guid (uint64 as string), may be always 0 UNDOCUMENTED + lua_register(L, "bit_not", &LuaGlobalFunctions::bit_not); // bit_not(a) - Returns ~a UNDOCUMENTED + lua_register(L, "bit_xor", &LuaGlobalFunctions::bit_xor); // bit_xor(a, b) - Returns a ^ b UNDOCUMENTED + lua_register(L, "bit_rshift", &LuaGlobalFunctions::bit_rshift); // bit_rshift(a, b) - Returns a >> b UNDOCUMENTED + lua_register(L, "bit_lshift", &LuaGlobalFunctions::bit_lshift); // bit_lshift(a, b) - Returns a << b UNDOCUMENTED + lua_register(L, "bit_or", &LuaGlobalFunctions::bit_or); // bit_or(a, b) - Returns a | b UNDOCUMENTED + lua_register(L, "bit_and", &LuaGlobalFunctions::bit_and); // bit_and(a, b) - Returns a & b UNDOCUMENTED + lua_register(L, "GetItemLink", &LuaGlobalFunctions::GetItemLink); // GetItemLink(entry[, localeIndex]) - Returns the shift clickable link of the item. Item name translated if translate available for provided locale index UNDOCUMENTED + lua_register(L, "GetMapById", &LuaGlobalFunctions::GetMapById); // GetMapById(mapId, instance) - Returns map object of id specified. UNDOCUMENTED + + // Other + // lua_register(L, "ReloadEluna", &LuaGlobalFunctions::ReloadEluna); // ReloadEluna() - Reload's Eluna engine. Returns true if reload succesful. + lua_register(L, "SendWorldMessage", &LuaGlobalFunctions::SendWorldMessage); // SendWorldMessage(msg) - Sends a broadcast message to everyone + lua_register(L, "WorldDBQuery", &LuaGlobalFunctions::WorldDBQuery); // WorldDBQuery(sql) - Executes given SQL query to world database instantly and returns a QueryResult object + lua_register(L, "WorldDBExecute", &LuaGlobalFunctions::WorldDBExecute); // WorldDBExecute(sql) - Executes given SQL query to world database (not instant) + lua_register(L, "CharDBQuery", &LuaGlobalFunctions::CharDBQuery); // CharDBQuery(sql) - Executes given SQL query to character database instantly and returns a QueryResult object + lua_register(L, "CharDBExecute", &LuaGlobalFunctions::CharDBExecute); // CharDBExecute(sql) - Executes given SQL query to character database (not instant) + lua_register(L, "AuthDBQuery", &LuaGlobalFunctions::AuthDBQuery); // AuthDBQuery(sql) - Executes given SQL query to auth/logon database instantly and returns a QueryResult object + lua_register(L, "AuthDBExecute", &LuaGlobalFunctions::AuthDBExecute); // AuthDBExecute(sql) - Executes given SQL query to auth/logon database (not instant) + lua_register(L, "CreateLuaEvent", &LuaGlobalFunctions::CreateLuaEvent); // CreateLuaEvent(function, delay, calls) - Creates a global timed event. Returns Event ID. Calls set to 0 calls infinitely. + lua_register(L, "RemoveEventById", &LuaGlobalFunctions::RemoveEventById); // RemoveEventById(eventId, [all_events]) - Removes a global timed event by it's ID. If all_events is true, can remove any timed event by ID (unit, gameobject, global..) + lua_register(L, "RemoveEvents", &LuaGlobalFunctions::RemoveEvents); // RemoveEvents([all_events]) - Removes all global timed events. Removes all timed events (unit, gameobject, global) if all_events is true + lua_register(L, "PerformIngameSpawn", &LuaGlobalFunctions::PerformIngameSpawn); // PerformIngameSpawn(spawntype, entry, mapid, instanceid, x, y, z, o[, save, DurOrResptime, phase]) - spawntype: 1 Creature, 2 Object. DurOrResptime is respawntime for gameobjects and despawntime for creatures if creature is not saved. Returns spawned creature/gameobject + lua_register(L, "CreatePacket", &LuaGlobalFunctions::CreatePacket); // CreatePacket(opcode, size) - Creates a new packet object + lua_register(L, "AddVendorItem", &LuaGlobalFunctions::AddVendorItem); // AddVendorItem(entry, itemId, maxcount, incrtime, extendedcost) - Adds an item to vendor entry. + lua_register(L, "VendorRemoveItem", &LuaGlobalFunctions::VendorRemoveItem); // VendorRemoveItem(entry, item) - Removes an item from vendor entry + lua_register(L, "VendorRemoveAllItems", &LuaGlobalFunctions::VendorRemoveAllItems); // VendorRemoveAllItems(entry) - Removes all items from vendor entry + lua_register(L, "Kick", &LuaGlobalFunctions::Kick); // Kick(player) - Kicks given player + lua_register(L, "Ban", &LuaGlobalFunctions::Ban); // Ban(banMode(integer), nameOrIP(string), duration(string), reason(string), player(whoBanned)) - Banmode: 0 account, 1 character, 2 IP + lua_register(L, "SendMail", &LuaGlobalFunctions::SendMail); // SendMail(subject, text, receiverLowGUID[, sender, stationary, delay, itemEntry, itemAmount, itemEntry2, itemAmount2...]) - Sends a mail to player with lowguid. use nil to use default values on optional arguments. Sender is an optional player object. UNDOCUMENTED + lua_register(L, "AddCorpse", &LuaGlobalFunctions::AddCorpse); // AddCorpse(corpse) - Adds the player's corpse to the world. More specifically, the cell. + lua_register(L, "RemoveCorpse", &LuaGlobalFunctions::RemoveCorpse); // RemoveCorpse(corpse) - Removes the player's corpse from the world. + lua_register(L, "ConvertCorpseForPlayer", &LuaGlobalFunctions::ConvertCorpseForPlayer); // ConvertCorpseFromPlayer(guid[, insignia]) - Converts the player's corpse to bones. Adding insignia for PvP is optional (true or false). + lua_register(L, "RemoveOldCorpses", &LuaGlobalFunctions::RemoveOldCorpses); // RemoveOldCorpses() - Converts (removes) old corpses that aren't bones. + lua_register(L, "FindWeather", &LuaGlobalFunctions::FindWeather); // FindWeather(zoneId) - Finds the weather by zoneId and returns the weather + lua_register(L, "AddWeather", &LuaGlobalFunctions::AddWeather); // AddWeather(zoneId) - Adds weather to the following zone, also returns weather + lua_register(L, "RemoveWeather", &LuaGlobalFunctions::RemoveWeather); // RemoveWeather(zoneId) - Removes weather from a zone + lua_register(L, "SendFineWeatherToPlayer", &LuaGlobalFunctions::SendFineWeatherToPlayer); // SendFineWeatherToPlayer(player) - Sends WEATHER_STATE_FINE weather to the +} + +ElunaRegister ObjectMethods[] = +{ + // Getters + {"GetEntry", &LuaObject::GetEntry}, // :GetEntry() - Returns the object's entryId + {"GetGUID", &LuaObject::GetGUID}, // :GetGUID() - Returns uint64 guid as hex string + {"GetGUIDLow", &LuaObject::GetGUIDLow}, // :GetGUIDLow() - Returns uint32 guid (low guid) that is used in database. + {"GetInt32Value", &LuaObject::GetInt32Value}, // :GetInt32Value(index) - returns an int value from object fields + {"GetUInt32Value", &LuaObject::GetUInt32Value}, // :GetUInt32Value(index) - returns an uint value from object fields + {"GetFloatValue", &LuaObject::GetFloatValue}, // :GetFloatValue(index) - returns a float value from object fields + {"GetByteValue", &LuaObject::GetByteValue}, // :GetByteValue(index, offset) - returns a byte value from object fields + {"GetUInt16Value", &LuaObject::GetUInt16Value}, // :GetUInt16Value(index, offset) - returns a uint16 value from object fields + {"GetTypeId", &LuaObject::GetTypeId}, // :GetTypeId() - Returns the object's typeId + + // Setters + {"SetInt32Value", &LuaObject::SetInt32Value}, // :SetInt32Value(index, value) - Sets an int value for the object + {"SetUInt32Value", &LuaObject::SetUInt32Value}, // :SetUInt32Value(index, value) - Sets an uint value for the object + {"SetFloatValue", &LuaObject::SetFloatValue}, // :SetFloatValue(index, value) - Sets a float value for the object + {"SetByteValue", &LuaObject::SetByteValue}, // :SetByteValue(index, offset, value) - Sets a byte value for the object + {"SetUInt16Value", &LuaObject::SetUInt16Value}, // :SetUInt16Value(index, offset, value) - Sets an uint16 value for the object + {"SetInt16Value", &LuaObject::SetInt16Value}, // :SetInt16Value(index, offset, value) - Sets an int16 value for the object + {"SetFlag", &LuaObject::SetFlag}, // :SetFlag(index, flag) + + // Boolean + {"IsInWorld", &LuaObject::IsInWorld}, // :IsInWorld() - Returns if the object is in world + {"HasFlag", &LuaObject::HasFlag}, // :HasFlag(index, flag) + + + {"RemoveFlag", &LuaObject::RemoveFlag}, // :RemoveFlag(index, flag) + + {NULL, NULL}, +}; + +ElunaRegister WorldObjectMethods[] = +{ + // Other + {"ToGameObject", &LuaWorldObject::ToGameObject}, // :ToGameObject() + {"ToUnit", &LuaWorldObject::ToUnit}, // :ToUnit() + {"ToCreature", &LuaWorldObject::ToCreature}, // :ToCreature() + {"ToPlayer", &LuaWorldObject::ToPlayer}, // :ToPlayer() + {"ToCorpse", &LuaWorldObject::ToCorpse}, // :ToCorpse() + + // Getters + {"GetName", &LuaWorldObject::GetName}, // :GetName() + {"GetMap", &LuaWorldObject::GetMap}, // :GetMap() - Returns the WorldObject's current map object + {"GetInstanceId", &LuaWorldObject::GetInstanceId}, // :GetInstanceId() + {"GetAreaId", &LuaWorldObject::GetAreaId}, // :GetAreaId() + {"GetZoneId", &LuaWorldObject::GetZoneId}, // :GetZoneId() + {"GetMapId", &LuaWorldObject::GetMapId}, // :GetMapId() - Returns the WorldObject's current map ID + {"GetX", &LuaWorldObject::GetX}, // :GetX() + {"GetY", &LuaWorldObject::GetY}, // :GetY() + {"GetZ", &LuaWorldObject::GetZ}, // :GetZ() + {"GetO", &LuaWorldObject::GetO}, // :GetO() + {"GetLocation", &LuaWorldObject::GetLocation}, // :GetLocation() - returns X, Y, Z and O co - ords (in that order) + {"GetPlayersInRange", &LuaWorldObject::GetPlayersInRange}, // :GetPlayersInRange([range]) - Returns a table with players in range of the WorldObject. + {"GetCreaturesInRange", &LuaWorldObject::GetCreaturesInRange}, // :GetCreaturesInRange([range, entry]) - Returns a table with creatures of given entry in range of the WorldObject. + {"GetGameObjectsInRange", &LuaWorldObject::GetGameObjectsInRange}, // :GetGameObjectsInRange([range, entry]) - Returns a table with gameobjects of given entry in range of the WorldObject. + {"GetNearestPlayer", &LuaWorldObject::GetNearestPlayer}, // :GetNearestPlayer([range]) - Returns nearest player in sight or given range. + {"GetNearestGameObject", &LuaWorldObject::GetNearestGameObject}, // :GetNearestGameObject([range, entry]) - Returns nearest gameobject with given entry in sight or given range entry can be 0 or nil for any. + {"GetNearestCreature", &LuaWorldObject::GetNearestCreature}, // :GetNearestCreature([range, entry]) - Returns nearest creature with given entry in sight or given range entry can be 0 or nil for any. + {"GetNearObject", &LuaWorldObject::GetNearObject}, // :GetNearObject([nearest, range, typemask, entry, hostile]) - Returns nearest WorldObject or table of objects in given range with given typemask (can contain several types) with given entry if given. Hostile can be 0 for any, 1 hostile, 2 friendly + {"GetWorldObject", &LuaWorldObject::GetWorldObject}, // :GetWorldObject(guid) - Returns a world object (creature, player, gameobject) from the guid. The world object returned must be on the same map as the world object in the arguments. + {"GetDistance", &LuaWorldObject::GetDistance}, // :GetDistance(WorldObject or x, y, z) - Returns the distance between 2 objects or location + {"GetRelativePoint", &LuaWorldObject::GetRelativePoint}, // :GetRelativePoint(dist, rad) - Returns the x, y and z of a point dist away from worldobject. + {"GetAngle", &LuaWorldObject::GetAngle}, // :GetAngle(WorldObject or x, y) - Returns angle between world object and target or x and y coords. + + // Other + {"SummonGameObject", &LuaWorldObject::SummonGameObject}, // :SummonGameObject(entry, x, y, z, o[, respawnDelay]) - Spawns an object to location. Returns the object or nil + {"SpawnCreature", &LuaWorldObject::SpawnCreature}, // :SpawnCreature(entry, x, y, z, o[, spawnType, despawnDelay]) - Spawns a creature to location that despawns after given time (0 for infinite). Returns the creature or nil + {"SendPacket", &LuaWorldObject::SendPacket}, // :SendPacket(packet) - Sends a specified packet to everyone around + + {NULL, NULL}, +}; + +ElunaRegister UnitMethods[] = +{ + // Getters + {"GetLevel", &LuaUnit::GetLevel}, // :GetLevel() + {"GetHealth", &LuaUnit::GetHealth}, // :GetHealth() + {"GetDisplayId", &LuaUnit::GetDisplayId}, // :GetDisplayId() + {"GetNativeDisplayId", &LuaUnit::GetNativeDisplayId}, // :GetNativeDisplayId() + {"GetPower", &LuaUnit::GetPower}, // :GetPower(index) - returns power at index. Index can be omitted + {"GetMaxPower", &LuaUnit::GetMaxPower}, // :GetMaxPower(index) - returns power at index. Index can be omitted + {"GetPowerType", &LuaUnit::GetPowerType}, // :GetPowerType() - Returns the power type + {"GetMaxHealth", &LuaUnit::GetMaxHealth}, // :GetMaxHealth() + {"GetHealthPct", &LuaUnit::GetHealthPct}, // :GetHealthPct() + {"GetPowerPct", &LuaUnit::GetPowerPct}, // :GetPowerPct(power_id) + {"GetGender", &LuaUnit::GetGender}, // :GetGender() - returns the gender where male = 0 female = 1 + {"GetRace", &LuaUnit::GetRace}, // :GetRace() + {"GetClass", &LuaUnit::GetClass}, // :GetClass() + {"GetClassAsString", &LuaUnit::GetClassAsString}, // :GetClassAsString() + {"GetAura", &LuaUnit::GetAura}, // :GetAura(spellID) - returns aura object + {"GetCombatTime", &LuaUnit::GetCombatTime}, // :GetCombatTime() - Returns how long the unit has been in combat + {"GetFaction", &LuaUnit::GetFaction}, // :GetFaction() - Returns the unit's factionId + {"GetCurrentSpell", &LuaUnit::GetCurrentSpell}, // :GetCurrentSpell(type) - Returns the currently cast spell of given type if any + {"GetCreatureType", &LuaUnit::GetCreatureType}, // :GetCreatureType() - Returns the unit's type + {"GetMountId", &LuaUnit::GetMountId}, // :GetMountId() + {"GetOwnerGUID", &LuaUnit::GetOwnerGUID}, // :GetOwnerGUID() - Returns the GUID of the owner + {"GetOwner", &LuaUnit::GetOwner}, // :GetOwner() - Returns the owner + {"GetFriendlyUnitsInRange", &LuaUnit::GetFriendlyUnitsInRange}, // :GetFriendlyUnitsInRange([range]) - Returns a list of friendly units in range, can return nil + {"GetUnfriendlyUnitsInRange", &LuaUnit::GetUnfriendlyUnitsInRange}, // :GetUnfriendlyUnitsInRange([range]) - Returns a list of unfriendly units in range, can return nil + {"GetOwnerGUID", &LuaUnit::GetOwnerGUID}, // :GetOwnerGUID() - Returns the UNIT_FIELD_SUMMONEDBY owner + {"GetCreatorGUID", &LuaUnit::GetCreatorGUID}, // :GetCreatorGUID() - Returns the UNIT_FIELD_CREATEDBY creator + {"GetMinionGUID", &LuaUnit::GetMinionGUID}, // :GetMinionGUID() - Returns the UNIT_FIELD_SUMMON unit's minion GUID + {"GetCharmerGUID", &LuaUnit::GetCharmerGUID}, // :GetCharmerGUID() - Returns the UNIT_FIELD_CHARMEDBY charmer + {"GetCharmGUID", &LuaUnit::GetCharmGUID}, // :GetCharmGUID() - Returns the unit's UNIT_FIELD_CHARM guid + {"GetPetGUID", &LuaUnit::GetPetGUID}, // :GetPetGUID() - Returns the unit's pet GUID + {"GetControllerGUID", &LuaUnit::GetControllerGUID}, // :GetControllerGUID() - Returns the Charmer or Owner GUID + {"GetControllerGUIDS", &LuaUnit::GetControllerGUIDS}, // :GetControllerGUIDS() - Returns the charmer, owner or unit's own GUID + {"GetStandState", &LuaUnit::GetStandState}, // :GetStandState() - Returns the unit's stand state + {"GetVictim", &LuaUnit::GetVictim}, // :GetVictim() - Returns creature's current target + {"GetStat", &LuaUnit::GetStat}, // :GetStat(stat) + {"GetBaseSpellPower", &LuaUnit::GetBaseSpellPower}, // :GetBaseSpellPower() + + // Setters + {"SetFaction", &LuaUnit::SetFaction}, // :SetFaction(factionId) - Sets the unit's faction + {"SetLevel", &LuaUnit::SetLevel}, // :SetLevel(amount) + {"SetHealth", &LuaUnit::SetHealth}, // :SetHealth(amount) + {"SetMaxHealth", &LuaUnit::SetMaxHealth}, // :SetMaxHealth(amount) + {"SetPower", &LuaUnit::SetPower}, // :SetPower(index, amount) + {"SetMaxPower", &LuaUnit::SetMaxPower}, // :SetMaxPower(index, amount) + {"SetDisplayId", &LuaUnit::SetDisplayId}, // :SetDisplayId(id) + {"SetNativeDisplayId", &LuaUnit::SetNativeDisplayId}, // :SetNativeDisplayId(id) + {"SetFacing", &LuaUnit::SetFacing}, // :SetFacing(o) - Sets the Unit facing to arg + {"SetFacingToObject", &LuaUnit::SetFacingToObject}, // :SetFacingToObject(worldObject) - Sets the Unit facing towards the WorldObject + {"SetSpeed", &LuaUnit::SetSpeed}, // :SetSpeed(type, speed[, forced]) - Sets speed for the movement type (0 = walk, 1 = run ..) + // {"SetStunned", &LuaUnit::SetStunned}, // :SetStunned([enable]) - Stuns or removes stun + // {"SetRooted", &LuaUnit::SetRooted}, // :SetRooted([enable]) - Roots or removes root + // {"SetConfused", &LuaUnit::SetConfused}, // :SetConfused([enable]) - Sets confused or removes confusion + // {"SetFeared", &LuaUnit::SetFeared}, // :SetFeared([enable]) - Fears or removes fear + {"SetPvP", &LuaUnit::SetPvP}, // :SetPvP([apply]) - Sets the units PvP on or off + // {"SetCanFly", &LuaUnit::SetCanFly}, // :SetCanFly(apply) + // {"SetVisible", &LuaUnit::SetVisible}, // :SetVisible(x) + {"SetOwnerGUID", &LuaUnit::SetOwnerGUID}, // :SetOwnerGUID(guid) - Sets the guid of the owner + {"SetName", &LuaUnit::SetName}, // :SetName(name) - Sets the unit's name + {"SetCreatorGUID", &LuaUnit::SetCreatorGUID}, // :SetOwnerGUID(uint64 ownerGUID) - Sets the owner's guid of a summoned creature, etc + {"SetCharmerGUID", &LuaUnit::SetCharmerGUID}, // :SetCharmerGUID(uint64 ownerGUID) - Sets the UNIT_FIELD_CHARMEDBY charmer GUID + {"SetStandState", &LuaUnit::SetStandState}, // :SetStandState(state) - Sets the stand state (Stand, Kneel, sleep, etc) of the unit + + // Boolean + {"IsAlive", &LuaUnit::IsAlive}, // :IsAlive() + {"IsDead", &LuaUnit::IsDead}, // :IsDead() - Returns true if the unit is dead, false if they are alive + {"IsDying", &LuaUnit::IsDying}, // :IsDying() - Returns true if the unit death state is JUST_DIED. + {"IsPvPFlagged", &LuaUnit::IsPvPFlagged}, // :IsPvPFlagged() + {"IsInCombat", &LuaUnit::IsInCombat}, // :IsInCombat() + {"IsBanker", &LuaUnit::IsBanker}, // :IsBanker() - Returns true if the unit is a banker, false if not + {"IsBattleMaster", &LuaUnit::IsBattleMaster}, // :IsBattleMaster() - Returns true if the unit is a battle master, false if not + {"IsCharmed", &LuaUnit::IsCharmed}, // :IsCharmed() - Returns true if the unit is charmed, false if not + {"IsArmorer", &LuaUnit::IsArmorer}, // :IsArmorer() - Returns true if the unit is an Armorer, false if not + {"IsAttackingPlayer", &LuaUnit::IsAttackingPlayer}, // :IsAttackingPlayer() - Returns true if the unit is attacking a player, false if not + {"IsInWater", &LuaUnit::IsInWater}, // :IsInWater() - Returns true if the unit is in water + {"IsUnderWater", &LuaUnit::IsUnderWater}, // :IsUnderWater() - Returns true if the unit is under water + {"IsAuctioneer", &LuaUnit::IsAuctioneer}, // :IsAuctioneer() + {"IsGuildMaster", &LuaUnit::IsGuildMaster}, // :IsGuildMaster() + {"IsInnkeeper", &LuaUnit::IsInnkeeper}, // :IsInnkeeper() + {"IsTrainer", &LuaUnit::IsTrainer}, // :IsTrainer() + {"IsGossip", &LuaUnit::IsGossip}, // :IsGossip() + {"IsTaxi", &LuaUnit::IsTaxi}, // :IsTaxi() + {"IsSpiritHealer", &LuaUnit::IsSpiritHealer}, // :IsSpiritHealer() + {"IsSpiritGuide", &LuaUnit::IsSpiritGuide}, // :IsSpiritGuide() + {"IsTabardDesigner", &LuaUnit::IsTabardDesigner}, // :IsSpiritGuide() + {"IsServiceProvider", &LuaUnit::IsServiceProvider}, // :IsServiceProvider() + {"IsSpiritService", &LuaUnit::IsSpiritService}, // :IsSpiritService() + {"HealthBelowPct", &LuaUnit::HealthBelowPct}, // :HealthBelowPct(int32 pct) + {"HealthAbovePct", &LuaUnit::HealthAbovePct}, // :HealthAbovePct(int32 pct) + {"IsMounted", &LuaUnit::IsMounted}, // :IsMounted() + {"AttackStop", &LuaUnit::AttackStop}, // :AttackStop() + {"Attack", &LuaUnit::Attack}, // :Attack(who[, meleeAttack]) + // {"IsVisible", &LuaUnit::IsVisible}, // :IsVisible() + // {"IsMoving", &LuaUnit::IsMoving}, // :IsMoving() + // {"IsFlying", &LuaUnit::IsFlying}, // :IsFlying() + {"IsStopped", &LuaUnit::IsStopped}, // :IsStopped() + {"HasUnitState", &LuaUnit::HasUnitState}, // :HasUnitState(state) - state from UnitState enum + {"IsQuestGiver", &LuaUnit::IsQuestGiver}, // :IsQuestGiver() - Returns true if the unit is a quest giver, false if not + {"IsWithinDistInMap", &LuaUnit::IsWithinDistInMap}, // :IsWithinDistInMap(worldObject, radius) - Returns if the unit is within distance in map of the worldObject + {"IsInAccessiblePlaceFor", &LuaUnit::IsInAccessiblePlaceFor}, // :IsInAccessiblePlaceFor(creature) - Returns if the unit is in an accessible place for the specified creature + {"IsVendor", &LuaUnit::IsVendor}, // :IsVendor() - Returns if the unit is a vendor or not + {"IsWithinLoS", &LuaUnit::IsWithinLoS}, // :IsWithinLoS(x, y, z) + // {"IsRooted", &LuaUnit::IsRooted}, // :IsRooted() + {"IsFullHealth", &LuaUnit::IsFullHealth}, // :IsFullHealth() - Returns if the unit is full health + {"HasAura", &LuaUnit::HasAura}, // :HasAura(spellId) - Returns true if the unit has the aura from the spell + {"IsStandState", &LuaUnit::IsStandState}, // :IsStandState() - Returns true if the unit is standing + + // Other + {"RegisterEvent", &LuaUnit::RegisterEvent}, // :RegisterEvent(function, delay, calls) + {"RemoveEventById", &LuaUnit::RemoveEventById}, // :RemoveEventById(eventID) + {"RemoveEvents", &LuaUnit::RemoveEvents}, // :RemoveEvents() + {"AddAura", &LuaUnit::AddAura}, // :AddAura(spellId, target) - Adds an aura to the specified target + {"RemoveAura", &LuaUnit::RemoveAura}, // :RemoveAura(spellId[, casterGUID]) - Removes an aura from the unit by the spellId, casterGUID(Original caster) is optional + {"RemoveAllAuras", &LuaUnit::RemoveAllAuras}, // :RemoveAllAuras() - Removes all the unit's auras + {"ClearInCombat", &LuaUnit::ClearInCombat}, // :ClearInCombat() - Clears the unit's combat list (unit will be out of combat), resets the timer to 0, etc + {"DeMorph", &LuaUnit::DeMorph}, // :DeMorph() - Sets display back to native + {"SendUnitWhisper", &LuaUnit::SendUnitWhisper}, // :SendUnitWhisper(msg, receiver[, bossWhisper]) - Sends a whisper to the receiver + {"SendUnitEmote", &LuaUnit::SendUnitEmote}, // :SendUnitEmote(msg[, receiver, bossEmote]) - Sends a text emote + {"SendUnitSay", &LuaUnit::SendUnitSay}, // :SendUnitSay(msg, language) - Sends a "Say" message with the specified language (all languages: 0) + {"SendUnitYell", &LuaUnit::SendUnitYell}, // :SendUnitYell(msg, language) - Sends a "Yell" message with the specified language (all languages: 0) + {"CastSpell", &LuaUnit::CastSpell}, // :CastSpell(target, spellID[, triggered]) - Casts spell on target (player/npc/creature), if triggered is true then instant cast + {"CastSpellAoF", &LuaUnit::CastSpellAoF}, // :CastSpellAoF(x, y, z, spellID[, triggered]) - Casts the spell on coordinates, if triggered is false has mana cost and cast time + {"PlayDirectSound", &LuaUnit::PlayDirectSound}, // :PlayDirectSound(soundId, player) - Unit plays soundID to player, or everyone around if no player + {"PlayDistanceSound", &LuaUnit::PlayDistanceSound}, // :PlayDistanceSound(soundId, player) - Unit plays soundID to player, or everyone around if no player. The sound fades the further you are + // {"Kill", &LuaUnit::Kill}, // :Kill(target, durabilityLoss) - Unit kills the target. Durabilityloss is true by default + {"StopSpellCast", &LuaUnit::StopSpellCast}, // :StopSpellCast(spellId(optional)) - Stops the unit from casting a spell. If a spellId is defined, it will stop that unit from casting that spell + {"InterruptSpell", &LuaUnit::InterruptSpell}, // :InterruptSpell(spellType, delayed(optional)) - Interrupts the unit's spell by the spellType. If delayed is true it will skip if the spell is delayed. + {"SendChatMessageToPlayer", &LuaUnit::SendChatMessageToPlayer}, // :SendChatMessageToPlayer(type, lang, msg, target) - Unit sends a chat message to the given target player + {"Emote", &LuaUnit::Emote}, // :Emote(emote) + {"Dismount", &LuaUnit::Dismount}, // :Dismount() - Dismounts the unit. + {"Mount", &LuaUnit::Mount}, // :Mount(displayId) - Mounts the unit on the specified displayId. + // {"RestoreDisplayId", &LuaUnit::RestoreDisplayId}, // :RestoreDisplayId() + // {"RestoreFaction", &LuaUnit::RestoreFaction}, // :RestoreFaction() + // {"RemoveBindSightAuras", &LuaUnit::RemoveBindSightAuras}, // :RemoveBindSightAuras() + // {"RemoveCharmAuras", &LuaUnit::RemoveCharmAuras}, // :RemoveCharmAuras() + {"ClearThreatList", &LuaUnit::ClearThreatList}, // :ClearThreatList() + {"ClearUnitState", &LuaUnit::ClearUnitState}, // :ClearUnitState(state) + {"AddUnitState", &LuaUnit::AddUnitState}, // :AddUnitState(state) + // {"DisableMelee", &LuaUnit::DisableMelee}, // :DisableMelee([disable]) - if true, enables + // {"SummonGuardian", &LuaUnit::SummonGuardian}, // :SummonGuardian(entry, x, y, z, o[, duration]) - summons a guardian to location. Scales with summoner, is friendly to him and guards him. + {"NearTeleport", &LuaUnit::NearTeleport}, // :NearTeleport(x, y, z, o) - Teleports to give coordinates. Does not leave combat or unsummon pet. + {"MoveIdle", &LuaUnit::MoveIdle}, // :MoveIdle() + {"MoveRandom", &LuaUnit::MoveRandom}, // :MoveRandom(radius) + {"MoveHome", &LuaUnit::MoveHome}, // :MoveHome() + {"MoveFollow", &LuaUnit::MoveFollow}, // :MoveFollow(target[, dist, angle]) + {"MoveChase", &LuaUnit::MoveChase}, // :MoveChase(target[, dist, angle]) + {"MoveConfused", &LuaUnit::MoveConfused}, // :MoveConfused() + {"MoveFleeing", &LuaUnit::MoveFleeing}, // :MoveFleeing(enemy[, time]) + {"MoveTo", &LuaUnit::MoveTo}, // :MoveTo(id, x, y, z[, genPath]) - Moves to point. id is sent to WP reach hook. genPath defaults to true + {"MoveStop", &LuaUnit::MoveStop}, // :MoveStop() + {"MoveExpire", &LuaUnit::MoveExpire}, // :MoveExpire([reset]) + {"MoveClear", &LuaUnit::MoveClear}, // :MoveClear([reset]) + + { NULL, NULL }, +}; + +ElunaRegister PlayerMethods[] = +{ + // Getters + {"GetSelection", &LuaPlayer::GetSelection}, // :GetSelection() + {"GetGMRank", &LuaPlayer::GetGMRank}, // :GetSecurity() + {"GetGuildId", &LuaPlayer::GetGuildId}, // :GetGuildId() - nil on no guild + {"GetCoinage", &LuaPlayer::GetCoinage}, // :GetCoinage() + {"GetTeam", &LuaPlayer::GetTeam}, // :GetTeam() - returns the player's team. 0 for ally, 1 for horde + {"GetItemCount", &LuaPlayer::GetItemCount}, // :GetItemCount(item_id[, check_bank]) + {"GetGroup", &LuaPlayer::GetGroup}, // :GetGroup() + {"GetGuild", &LuaPlayer::GetGuild}, // :GetGuild() + {"GetAccountId", &LuaPlayer::GetAccountId}, // :GetAccountId() + {"GetAccountName", &LuaPlayer::GetAccountName}, // :GetAccountName() + {"GetArenaPoints", &LuaPlayer::GetArenaPoints}, // :GetArenaPoints() + {"GetHonorPoints", &LuaPlayer::GetHonorPoints}, // :GetHonorPoints() + {"GetLifetimeKills", &LuaPlayer::GetLifetimeKills}, // :GetLifetimeKills() - Returns the player's lifetime (honorable) kills + {"GetPlayerIP", &LuaPlayer::GetPlayerIP}, // :GetPlayerIP() - Returns the player's IP Address + {"GetLevelPlayedTime", &LuaPlayer::GetLevelPlayedTime}, // :GetLevelPlayedTime() - Returns the player's played time at that level + {"GetTotalPlayedTime", &LuaPlayer::GetTotalPlayedTime}, // :GetTotalPlayedTime() - Returns the total played time of that player + {"GetItemByPos", &LuaPlayer::GetItemByPos}, // :GetItemByPos(bag, slot) - Returns item in given slot in a bag (bag: 19-22 slot : 0-35) or inventory (bag: -1 slot : 0-38) + {"GetReputation", &LuaPlayer::GetReputation}, // :GetReputation(faction) - Gets player's reputation with given faction + {"GetEquippedItemBySlot", &LuaPlayer::GetEquippedItemBySlot}, // :GetEquippedItemBySlot(slotId) - Returns equipped item by slot + {"GetQuestLevel", &LuaPlayer::GetQuestLevel}, // :GetQuestLevel(quest) - Returns quest's level + {"GetChatTag", &LuaPlayer::GetChatTag}, // :GetChatTag() - Returns player chat tag ID + {"GetRestBonus", &LuaPlayer::GetRestBonus}, // :GetRestBonus() - Gets player's rest bonus + {"GetRestType", &LuaPlayer::GetRestType}, // :GetRestType() - Returns the player's rest type + {"GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount}, // :GetReqKillOrCastCurrentCount(questId, entry) - Gets the objective (kill or cast) current count done + {"GetQuestStatus", &LuaPlayer::GetQuestStatus}, // :GetQuestStatus(entry) - Gets the quest's status + {"GetInGameTime", &LuaPlayer::GetInGameTime}, // :GetInGameTime() - Returns player's ingame time + {"GetComboPoints", &LuaPlayer::GetComboPoints}, // :GetComboPoints() - Returns player's combo points + {"GetComboTarget", &LuaPlayer::GetComboTarget}, // :GetComboTarget() - Returns the player's combo target + {"GetGuildName", &LuaPlayer::GetGuildName}, // :GetGuildName() - Returns player's guild's name or nil + {"GetFreeTalentPoints", &LuaPlayer::GetFreeTalentPoints}, // :GetFreeTalentPoints() - Returns the amount of unused talent points + {"GetSpellCooldownDelay", &LuaPlayer::GetSpellCooldownDelay}, // :GetSpellCooldownDelay(spellId) - Returns the spell's cooldown + {"GetGuildRank", &LuaPlayer::GetGuildRank}, // :GetGuildRank() - Gets the player's guild rank + {"GetDifficulty", &LuaPlayer::GetDifficulty}, // :GetDifficulty([isRaid]) - Returns the current difficulty + {"GetHealthBonusFromStamina", &LuaPlayer::GetHealthBonusFromStamina}, // :GetHealthBonusFromStamina() - Returns the HP bonus from stamina + {"GetManaBonusFromIntellect", &LuaPlayer::GetManaBonusFromIntellect}, // :GetManaBonusFromIntellect() - Returns the mana bonus from intellect + {"GetMaxSkillValue", &LuaPlayer::GetMaxSkillValue}, // :GetMaxSkillValue(skill) - Gets max skill value for the given skill + {"GetPureMaxSkillValue", &LuaPlayer::GetPureMaxSkillValue}, // :GetPureMaxSkillValue(skill) - Gets max base skill value + {"GetSkillValue", &LuaPlayer::GetSkillValue}, // :GetSkillValue(skill) - Gets current skill value + {"GetBaseSkillValue", &LuaPlayer::GetBaseSkillValue}, // :GetBaseSkillValue(skill) - Gets current base skill value (no temp bonus) + {"GetPureSkillValue", &LuaPlayer::GetPureSkillValue}, // :GetPureSkillValue(skill) - Gets current base skill value (no bonuses) + {"GetSkillTempBonusValue", &LuaPlayer::GetSkillTempBonusValue}, // :GetSkillTempBonusValue(skill) - Returns current temp bonus + {"GetReputationRank", &LuaPlayer::GetReputationRank}, // :GetReputationRank(faction) - Returns the reputation rank with given faction + {"GetDrunkValue", &LuaPlayer::GetDrunkValue}, // :GetDrunkValue() - Returns the current drunkness value + {"GetBattlegroundId", &LuaPlayer::GetBattlegroundId}, // :GetBattlegroundId() - Returns the player's current battleground ID + {"GetBattlegroundTypeId", &LuaPlayer::GetBattlegroundTypeId}, // :GetBattlegroundTypeId() - Returns the player's current battleground type ID + {"GetXPRestBonus", &LuaPlayer::GetXPRestBonus}, // :GetXPRestBonus(xp) - Returns the rested bonus XP from given XP + {"GetRestTime", &LuaPlayer::GetRestTime}, // :GetRestTime() - Returns the timed rested + {"GetGroupInvite", &LuaPlayer::GetGroupInvite}, // :GetGroupInvite() - Returns the group invited to + {"GetSubGroup", &LuaPlayer::GetSubGroup}, // :GetSubGroup() - Gets the player's current subgroup ID + {"GetNextRandomRaidMember", &LuaPlayer::GetNextRandomRaidMember}, // :GetNextRandomRaidMember(radius) - Gets a random raid member in given radius + {"GetOriginalGroup", &LuaPlayer::GetOriginalGroup}, // :GetOriginalGroup() - Gets the original group object + {"GetOriginalSubGroup", &LuaPlayer::GetOriginalSubGroup}, // :GetOriginalSubGroup() - Returns the original subgroup ID + {"GetLatency", &LuaPlayer::GetLatency}, // :GetLatency() - Returns player's latency + // {"GetRecruiterId", &LuaPlayer::GetRecruiterId}, // :GetRecruiterId() - Returns player's recruiter's ID + {"GetDbLocaleIndex", &LuaPlayer::GetDbLocaleIndex}, // :GetDbLocaleIndex() - Returns locale index + {"GetDbcLocale", &LuaPlayer::GetDbcLocale}, // :GetDbcLocale() - Returns DBC locale + {"GetCorpse", &LuaPlayer::GetCorpse}, // :GetCorpse() - Returns the player's corpse + {"GetQuestRewardStatus", &LuaPlayer::GetQuestRewardStatus}, // :GetQuestRewardStatus(questId) - Returns the true/false of the quest reward status + {"GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue}, // :GetShieldBlockValue() - Returns block value + + // Setters + {"AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax}, // :AdvanceSkillsToMax() - Advances all currently known skills to the currently known max level + {"AdvanceSkill", &LuaPlayer::AdvanceSkill}, // :AdvanceSkill(skill_id, step) - Advances skill by ID and the amount(step) + {"AdvanceAllSkills", &LuaPlayer::AdvanceAllSkills}, // :AdvanceAllSkills(value) - Advances all current skills to your input(value) + {"AddLifetimeKills", &LuaPlayer::AddLifetimeKills}, // :AddLifetimeKills(val) - Adds lifetime (honorable) kills to your current lifetime kills + {"SetCoinage", &LuaPlayer::SetCoinage}, // :SetCoinage(amount) - sets plr's coinage to this + {"SetKnownTitle", &LuaPlayer::SetKnownTitle}, // :SetKnownTitle(id) + {"SetLifetimeKills", &LuaPlayer::SetLifetimeKills}, // :SetLifetimeKills(val) - Sets the overall lifetime (honorable) kills of the player + {"SetGameMaster", &LuaPlayer::SetGameMaster}, // :SetGameMaster([on]) - Sets GM mode on or off + {"SetGMChat", &LuaPlayer::SetGMChat}, // :SetGMChat([on]) - Sets GM chat on or off + {"SetTaxiCheat", &LuaPlayer::SetTaxiCheat}, // :SetTaxiCheat([on]) - Sets taxi cheat on or off + {"SetGMVisible", &LuaPlayer::SetGMVisible}, // :SetGMVisible([on]) - Sets gm visibility on or off + {"SetPvPDeath", &LuaPlayer::SetPvPDeath}, // :SetPvPDeath([on]) - Sets PvP death on or off + {"SetAcceptWhispers", &LuaPlayer::SetAcceptWhispers}, // :SetAcceptWhispers([on]) - Sets whisper accepting death on or off + {"SetRestBonus", &LuaPlayer::SetRestBonus}, // :SetRestBonus(bonusrate) - Sets new restbonus rate + {"SetRestType", &LuaPlayer::SetRestType}, // :SetRestType() - Sets rest type + {"SetQuestStatus", &LuaPlayer::SetQuestStatus}, // :SetQuestStatus(entry, status) - Sets the quest's status + {"SetReputation", &LuaPlayer::SetReputation}, // :SetReputation(faction, value) - Sets the faction reputation for the player + {"SetFreeTalentPoints", &LuaPlayer::SetFreeTalentPoints}, // :SetFreeTalentPoints(points) - Sets the amount of unused talent points + {"SetGuildRank", &LuaPlayer::SetGuildRank}, // :SetGuildRank(rank) - Sets player's guild rank + // {"SetMovement", &LuaPlayer::SetMovement}, // :SetMovement(type) - Sets player's movement type + {"SetSkill", &LuaPlayer::SetSkill}, // :SetSkill(skill, step, currVal, maxVal) - Sets the skill's boundaries and value + {"SetFactionForRace", &LuaPlayer::SetFactionForRace}, // :SetFactionForRace(race) - Sets the faction by raceID + {"SetDrunkValue", &LuaPlayer::SetDrunkValue}, // :SetDrunkValue(newDrunkValue) - Sets drunkness value + {"SetRestTime", &LuaPlayer::SetRestTime}, // :SetRestTime(value) - Sets the rested time + {"SetAtLoginFlag", &LuaPlayer::SetAtLoginFlag}, // :SetAtLoginFlag(flag) - Adds an at login flag + {"SetPlayerLock", &LuaPlayer::SetPlayerLock}, // :SetPlayerLock(on/off) + {"SetGender", &LuaPlayer::SetGender}, // :SetGender(value) - 0 = male 1 = female + {"SetSheath", &LuaPlayer::SetSheath}, // :SetSheath(SheathState) - Sets player's sheathstate + + // Boolean + {"IsInGroup", &LuaPlayer::IsInGroup}, // :IsInGroup() + {"IsInGuild", &LuaPlayer::IsInGuild}, // :IsInGuild() + {"IsGM", &LuaPlayer::IsGM}, // :IsGM() + {"IsAlliance", &LuaPlayer::IsAlliance}, // :IsAlliance() + {"IsHorde", &LuaPlayer::IsHorde}, // :IsHorde() + {"HasTitle", &LuaPlayer::HasTitle}, // :HasTitle(id) + {"HasItem", &LuaPlayer::HasItem}, // :HasItem(itemId[, count, check_bank]) - Returns true if the player has the item(itemId) and specified count, else it will return false + {"Teleport", &LuaPlayer::Teleport}, // :Teleport(Map, X, Y, Z, O) - Teleports player to specified co - ordinates. Returns true if success and false if not + {"IsInArenaTeam", &LuaPlayer::IsInArenaTeam}, // :IsInArenaTeam(type) - type : 0 = 2v2, 1 = 3v3, 2 = 5v5 + {"CanEquipItem", &LuaPlayer::CanEquipItem}, // :CanEquipItem(entry/item, slot) - Returns true if the player can equip given item/item entry + {"ToggleAFK", &LuaPlayer::ToggleAFK}, // :ToggleAFK() - Toggles AFK state for player + {"ToggleDND", &LuaPlayer::ToggleDND}, // :ToggleDND() - Toggles DND state for player + {"IsAFK", &LuaPlayer::IsAFK}, // :IsAFK() - Returns true if the player is afk + {"IsDND", &LuaPlayer::IsDND}, // :IsDND() - Returns true if the player is in dnd mode + {"IsAcceptingWhispers", &LuaPlayer::IsAcceptingWhispers}, // :IsAcceptWhispers() - Returns true if the player accepts whispers + {"IsGMChat", &LuaPlayer::IsGMChat}, // :IsGMChat() - Returns true if the player has GM chat on + {"IsTaxiCheater", &LuaPlayer::IsTaxiCheater}, // :IsTaxiCheater() - Returns true if the player has taxi cheat on + {"IsGMVisible", &LuaPlayer::IsGMVisible}, // :IsGMVisible() - Returns true if the player is GM visible + {"HasQuest", &LuaPlayer::HasQuest}, // :HasQuest(entry) - Returns true if player has the quest + {"InBattlegroundQueue", &LuaPlayer::InBattlegroundQueue}, // :InBattlegroundQueue() - Returns true if the player is in a battleground queue + // {"IsImmuneToEnvironmentalDamage", &LuaPlayer::IsImmuneToEnvironmentalDamage}, // :IsImmuneToEnvironmentalDamage() - Returns true if the player is immune to enviromental damage + {"CanSpeak", &LuaPlayer::CanSpeak}, // :CanSpeak() - Returns true if the player can speak + {"HasAtLoginFlag", &LuaPlayer::HasAtLoginFlag}, // :HasAtLoginFlag(flag) - returns true if the player has the login flag + // {"InRandomLfgDungeon", &LuaPlayer::InRandomLfgDungeon}, // :InRandomLfgDungeon() - Returns true if the player is in a random LFG dungeon + // {"HasPendingBind", &LuaPlayer::HasPendingBind}, // :HasPendingBind() - Returns true if the player has a pending instance bind + {"CanUninviteFromGroup", &LuaPlayer::CanUninviteFromGroup}, // :CanUninviteFromGroup() - Returns true if the player can uninvite from group + {"IsRested", &LuaPlayer::IsRested}, // :IsRested() - Returns true if the player is rested + // {"CanFlyInZone", &LuaPlayer::CanFlyInZone}, // :CanFlyInZone(mapid, zone) - Returns true if the player can fly in the area + // {"IsNeverVisible", &LuaPlayer::IsNeverVisible}, // :IsNeverVisible() - Returns true if the player is never visible + {"IsVisibleForPlayer", &LuaPlayer::IsVisibleForPlayer}, // :IsVisibleForPlayer(player) - Returns true if the player is visible for the target player + // {"IsUsingLfg", &LuaPlayer::IsUsingLfg}, // :IsUsingLfg() - Returns true if the player is using LFG + {"HasQuestForItem", &LuaPlayer::HasQuestForItem}, // :HasQuestForItem(entry) - Returns true if the player has the quest for the item + {"HasQuestForGO", &LuaPlayer::HasQuestForGO}, // :HasQuestForGO(entry) - Returns true if the player has the quest for the gameobject + {"CanShareQuest", &LuaPlayer::CanShareQuest}, // :CanShareQuest(entry) - Returns true if the quest entry is shareable by the player + // {"HasReceivedQuestReward", &LuaPlayer::HasReceivedQuestReward}, // :HasReceivedQuestReward(entry) - Returns true if the player has recieved the quest's reward + {"IsInSameGroupWith", &LuaPlayer::IsInSameGroupWith}, // :IsInSameGroupWith(player) - Returns true if the players are in the same group + {"IsInSameRaidWith", &LuaPlayer::IsInSameRaidWith}, // :IsInSameRaidWith(player) - Returns true if the players are in the same raid + {"IsGroupVisibleFor", &LuaPlayer::IsGroupVisibleFor}, // :IsGroupVisibleFor(player) - Player is group visible for the target + {"HasSkill", &LuaPlayer::HasSkill}, // :HasSkill(skill) - Returns true if the player has the skill + {"CanParry", &LuaPlayer::CanParry}, // :CanParry() - Returns true if the player can parry + {"CanBlock", &LuaPlayer::CanBlock}, // :CanBlock() - Returns true if the player can block + {"InBattleground", &LuaPlayer::InBattleground}, // :InBattleground() - Returns true if the player is in a battleground + {"InArena", &LuaPlayer::InArena}, // :InArena() - Returns true if the player is in an arena + // {"IsOutdoorPvPActive", &LuaPlayer::IsOutdoorPvPActive}, // :IsOutdoorPvPActive() - Returns true if the player is outdoor pvp active + // {"IsARecruiter", &LuaPlayer::IsARecruiter}, // :IsARecruiter() - Returns true if the player is a recruiter + {"CanUseItem", &LuaPlayer::CanUseItem}, // :CanUseItem(item/entry) - Returns true if the player can use the item or item entry + {"HasSpell", &LuaPlayer::HasSpell}, // :HasSpell(id) + {"HasSpellCooldown", &LuaPlayer::HasSpellCooldown}, // :HasSpellCooldown(spellId) - Returns true if the spell is on cooldown + {"IsInWater", &LuaPlayer::IsInWater}, // :IsInWater() - Returns true if the player is in water + {"CanFly", &LuaPlayer::CanFly}, // :CanFly() - Returns true if the player can fly + {"IsMoving", &LuaPlayer::IsMoving}, // :IsMoving() + {"IsFlying", &LuaPlayer::IsFlying}, // :IsFlying() + + // Gossip + {"GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem}, // :GossipMenuAddItem(icon, msg, sender, intid[, code, popup, money]) + {"GossipSendMenu", &LuaPlayer::GossipSendMenu}, // :GossipSendMenu(npc_text, unit[, menu_id]) - If unit is a player, you need to use a menu_id. menu_id is used to hook the gossip select function to the menu + {"GossipComplete", &LuaPlayer::GossipComplete}, // :GossipComplete() + {"GossipClearMenu", &LuaPlayer::GossipClearMenu}, // :GossipClearMenu() - Clears the gossip menu of options. Pretty much only useful with player gossip. Need to use before creating a new menu for the player + + // Other + {"SendBroadcastMessage", &LuaPlayer::SendBroadcastMessage}, // :SendBroadcastMessage(message) + {"SendAreaTriggerMessage", &LuaPlayer::SendAreaTriggerMessage}, // :SendAreaTriggerMessage(message) - Sends a yellow message in the middle of your screen + {"SendNotification", &LuaPlayer::SendNotification}, // :SendNotification(message) - Sends a red message in the middle of your screen + {"SendPacket", &LuaPlayer::SendPacket}, // :SendPacket(packet, selfOnly) - Sends a packet to player or everyone around also if selfOnly is false + {"SendVendorWindow", &LuaPlayer::SendVendorWindow}, // :SendVendorWindow(unit) - Sends the unit's vendor window to the player + {"ModifyMoney", &LuaPlayer::ModifyMoney}, // :ModifyMoney(amount[, sendError]) - Modifies (does not set) money (copper count) of the player. Amount can be negative to remove copper + {"LearnSpell", &LuaPlayer::LearnSpell}, // :LearnSpell(id) - learns the given spell + {"RemoveItem", &LuaPlayer::RemoveItem}, // :RemoveItem(item/entry, amount) - Removes amount of item from player + {"RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills}, // :RemoveLifetimeKills(val) - Removes a specified amount(val) of the player's lifetime (honorable) kills + {"ResurrectPlayer", &LuaPlayer::ResurrectPlayer}, // :ResurrectPlayer([percent[, sickness(bool)]]) - Resurrects the player at percentage, player gets resurrection sickness if sickness set to true + {"PlaySoundToPlayer", &LuaPlayer::PlaySoundToPlayer}, // :PlaySoundToPlayer(soundId) - Plays the specified sound to the player + {"EquipItem", &LuaPlayer::EquipItem}, // :EquipItem(entry/item, slot) - Equips given item or item entry for player to given slot. Returns the equipped item or nil + {"ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown}, // :ResetSpellCooldown(spellId, update(bool~optional)) - Resets cooldown of the specified spellId. If update is true, it will send WorldPacket SMSG_CLEAR_COOLDOWN to the player, else it will just clear the spellId from m_spellCooldowns. This is true by default + {"ResetTypeCooldowns", &LuaPlayer::ResetTypeCooldowns}, // :ResetTypeCooldowns(category, update(bool~optional)) - Resets all cooldowns for the spell category(type). If update is true, it will send WorldPacket SMSG_CLEAR_COOLDOWN to the player, else it will just clear the spellId from m_spellCooldowns. This is true by default + {"ResetAllCooldowns", &LuaPlayer::ResetAllCooldowns}, // :ResetAllCooldowns() - Resets all spell cooldowns + {"GiveLevel", &LuaPlayer::GiveLevel}, // :GiveLevel(level) - Gives levels to the player + {"GiveXP", &LuaPlayer::GiveXP}, // :GiveXP(xp[, victim, pureXP, triggerHook]) - Gives XP to the player. If pure is false, bonuses are count in. If triggerHook is false, GiveXp hook is not triggered. + // {"RemovePet", &LuaPlayer::RemovePet}, // :RemovePet([mode, returnreagent]) - Removes the player's pet. Mode determines if the pet is saved and how + // {"SummonPet", &LuaPlayer::SummonPet}, // :SummonPet(entry, x, y, z, o, petType, despwtime) - Summons a pet for the player + {"Say", &LuaPlayer::Say}, // :Say(text, lang) - The player says the text + {"Yell", &LuaPlayer::Yell}, // :Yell(text, lang) - The player yells the text + {"TextEmote", &LuaPlayer::TextEmote}, // :TextEmote(text) - The player does a textemote with the text + {"Whisper", &LuaPlayer::Whisper}, // :Whisper(text, lang, receiverGuid) - The player whispers the text to the guid + {"CompleteQuest", &LuaPlayer::CompleteQuest}, // :CompleteQuest(entry) - Completes a quest by entry + {"IncompleteQuest", &LuaPlayer::IncompleteQuest}, // :IncompleteQuest(entry) - Uncompletes the quest by entry for the player + {"FailQuest", &LuaPlayer::FailQuest}, // :FailQuest(entry) - Player fails the quest entry + // {"RemoveActiveQuest", &LuaPlayer::RemoveActiveQuest}, // :RemoveActiveQuest(entry) - Removes an active quest + // {"RemoveRewardedQuest", &LuaPlayer::RemoveRewardedQuest}, // :RemoveRewardedQuest(entry) - Removes a rewarded quest + {"AreaExploredOrEventHappens", &LuaPlayer::AreaExploredOrEventHappens}, // :AreaExploredOrEventHappens(questId) - Satisfies an area or event requrement for the questId + {"GroupEventHappens", &LuaPlayer::GroupEventHappens}, // :GroupEventHappens(questId, worldObject) - Satisfies a group event for the questId with the world object + {"KilledMonsterCredit", &LuaPlayer::KilledMonsterCredit}, // :KilledMonsterCredit(entry) - Satisfies a monsterkill for the player + // {"KilledPlayerCredit", &LuaPlayer::KilledPlayerCredit}, // :KilledPlayerCredit() - Satisfies a player kill for the player + // {"KillGOCredit", &LuaPlayer::KillGOCredit}, // :KillGOCredit(GOEntry[, GUID]) - Credits the player for destroying a GO, guid is optional + {"TalkedToCreature", &LuaPlayer::TalkedToCreature}, // :TalkedToCreature(npcEntry, creature) - Satisfies creature talk objective for the player + {"AddComboPoints", &LuaPlayer::AddComboPoints}, // :AddComboPoints(target, count[, spell]) - Adds combo points to the target for the player + // {"GainSpellComboPoints", &LuaPlayer::GainSpellComboPoints}, // :GainSpellComboPoints(amount) - Player gains spell combo points + {"ClearComboPoints", &LuaPlayer::ClearComboPoints}, // :ClearComboPoints() - Clears player's combo points + {"RemoveSpell", &LuaPlayer::RemoveSpell}, // :RemoveSpell(entry[, disabled, learn_low_rank]) - Removes (unlearn) the given spell + {"ResetTalents", &LuaPlayer::ResetTalents}, // :ResetTalents([no_cost]) - Resets player's talents + {"ResetTalentsCost", &LuaPlayer::ResetTalentsCost}, // :ResetTalentsCost() - Returns the reset talents cost + // {"AddTalent", &LuaPlayer::AddTalent}, // :AddTalent(spellid, spec, learning) - Adds a talent spell for the player to given spec + {"RemoveFromGroup", &LuaPlayer::RemoveFromGroup}, // :RemoveFromGroup() - Removes the player from his group + {"KillPlayer", &LuaPlayer::KillPlayer}, // :KillPlayer() - Kills the player + {"DurabilityLossAll", &LuaPlayer::DurabilityLossAll}, // :DurabilityLossAll(percent[, inventory]) - The player's items lose durability. Inventory true by default + {"DurabilityLoss", &LuaPlayer::DurabilityLoss}, // :DurabilityLoss(item, percent) - The given item loses durability + {"DurabilityPointsLoss", &LuaPlayer::DurabilityPointsLoss}, // :DurabilityPointsLoss(item, points) - The given item loses durability + {"DurabilityPointsLossAll", &LuaPlayer::DurabilityPointsLossAll}, // :DurabilityPointsLossAll(points, inventory) - Player's items lose durability + {"DurabilityPointLossForEquipSlot", &LuaPlayer::DurabilityPointLossForEquipSlot}, // :DurabilityPointLossForEquipSlot(slot) - Causes durability loss for the item in the given slot + {"DurabilityRepairAll", &LuaPlayer::DurabilityRepairAll}, // :DurabilityRepairAll([has_cost, discount, guildBank]) - Repairs all durability + {"DurabilityRepair", &LuaPlayer::DurabilityRepair}, // :DurabilityRepair(position[, has_cost, discount, guildBank]) - Repairs item durability of item in given position + {"ModifyHonorPoints", &LuaPlayer::ModifyHonorPoints}, // :ModifyHonorPoints(amount) - Modifies the player's honor points + {"ModifyArenaPoints", &LuaPlayer::ModifyArenaPoints}, // :ModifyArenaPoints(amount) - Modifies the player's arena points + {"LeaveBattleground", &LuaPlayer::LeaveBattleground}, // :LeaveBattleground([teleToEntryPoint]) - The player leaves the battleground + // {"BindToInstance", &LuaPlayer::BindToInstance}, // :BindToInstance() - Binds the player to the current instance + {"UnbindInstance", &LuaPlayer::UnbindInstance}, // :UnbindInstance(map, difficulty) - Unbinds the player from an instance + {"KickPlayer", &LuaPlayer::KickPlayer}, // :KickPlayer() - Kicks player from server + {"LogoutPlayer", &LuaPlayer::LogoutPlayer}, // :LogoutPlayer([save]) - Logs the player out and saves if true + {"SendTrainerList", &LuaPlayer::SendTrainerList}, // :SendTrainerList(WorldObject) - Sends trainer list from object to player + {"SendListInventory", &LuaPlayer::SendListInventory}, // :SendListInventory(WorldObject) - Sends vendor list from object to player + {"SendShowBank", &LuaPlayer::SendShowBank}, // :SendShowBank(WorldObject) - Sends bank window from object to player + {"SendTabardVendorActivate", &LuaPlayer::SendTabardVendorActivate}, // :SendTabardVendorActivate(WorldObject) - Sends tabard vendor window from object to player + {"SendSpiritResurrect", &LuaPlayer::SendSpiritResurrect}, // :SendSpiritResurrect() - Sends resurrect window to player + {"SendTaxiMenu", &LuaPlayer::SendTaxiMenu}, // :SendTaxiMenu(creature) - Sends flight window to player from creature + {"RewardQuest", &LuaPlayer::RewardQuest}, // :RewardQuest(entry) - Gives quest rewards for the player + {"SendAuctionMenu", &LuaPlayer::SendAuctionMenu}, // :SendAuctionMenu(unit) - Sends auction window to player. Auction house is sent by object. + {"StartTaxi", &LuaPlayer::StartTaxi}, // :StartTaxi(pathId) - player starts the given flight path + {"GossipSendPOI", &LuaPlayer::GossipSendPOI}, // :GossipSendPOI(X, Y, Icon, Flags, Data, Name) - Sends a point of interest to the player + {"GossipAddQuests", &LuaPlayer::GossipAddQuests}, // :GossipAddQuests(unit) - Adds unit's quests to player's gossip menu + {"SendQuestTemplate", &LuaPlayer::SendQuestTemplate}, // :SendQuestTemplate(questId, activeAccept) -- Sends quest template to player + {"SpawnBones", &LuaPlayer::SpawnBones}, // :SpawnBones() - Removes the player's corpse and spawns bones + {"RemovedInsignia", &LuaPlayer::RemovedInsignia}, // :RemovedInsignia(looter) - Looter removes the player's corpse, looting the player and replacing with lootable bones + {"CreateCorpse", &LuaPlayer::CreateCorpse}, // :CreateCorpse() - Creates the player's corpse + {"SummonPlayer", &LuaPlayer::SummonPlayer}, // :SummonPlayer(player, map, x, y, z, zoneId[, delay]) - Sends a popup to the player asking if he wants to be summoned if yes, teleported to coords. ZoneID defines the location name shown in the popup Delay is the time until the popup closes automatically. + {"SaveToDB", &LuaPlayer::SaveToDB}, // :SaveToDB() - Saves to database + + {NULL, NULL}, +}; + +ElunaRegister CreatureMethods[] = +{ + // Getters + {"GetAITarget", &LuaCreature::GetAITarget}, // :GetAITarget(type[, playeronly, position, distance, aura]) - Get an unit in threat list + {"GetAITargets", &LuaCreature::GetAITargets}, // :GetAITargets() - Get units in threat list + {"GetAITargetsCount", &LuaCreature::GetAITargetsCount}, // :GetAITargetsCount() - Get threat list size + {"GetHomePosition", &LuaCreature::GetHomePosition}, // :GetHomePosition() - Returns x,y,z,o of spawn position + {"GetScriptId", &LuaCreature::GetScriptId}, // :GetScriptId() - Returns creature's script ID + {"GetAIName", &LuaCreature::GetAIName}, // :GetAIName() - Returns creature's AI name + {"GetScriptName", &LuaCreature::GetScriptName}, // :GetScriptName() - Returns creature's script name + {"GetReactState", &LuaCreature::GetReactState}, // :GetReactState() - Returns creature's react state + {"GetAttackDistance", &LuaCreature::GetAttackDistance}, // :GetAttackDistance(unit) - Returns attack distance to unit + {"GetAggroRange", &LuaCreature::GetAggroRange}, // :GetAggroRange(unit) - Returns aggro distance to unit + {"GetDefaultMovementType", &LuaCreature::GetDefaultMovementType}, // :GetDefaultMovementType() - Returns default movement type + {"GetRespawnDelay", &LuaCreature::GetRespawnDelay}, // :GetRespawnDelay() - Returns respawn delay + {"GetRespawnRadius", &LuaCreature::GetRespawnRadius}, // :GetRespawnRadius() - Returns respawn radius + // {"GetWaypointPath", &LuaCreature::GetWaypointPath}, // :GetWaypointPath() - Returns waypoint path ID + // {"GetCurrentWaypointId", &LuaCreature::GetCurrentWaypointId}, // :GetCurrentWaypointId() - Returns waypoint ID + // {"GetLootMode", &LuaCreature::GetLootMode}, // :GetLootMode() - Returns loot mode + {"GetLootRecipient", &LuaCreature::GetLootRecipient}, // :GetLootRecipient() - Returns loot receiver + {"GetNPCFlags", &LuaCreature::GetNPCFlags}, // :GetNPCFlags() - Returns NPC flags + {"GetShieldBlockValue", &LuaCreature::GetShieldBlockValue}, // :GetShieldBlockValue() - Returns block value + + // Setters + {"SetHover", &LuaCreature::SetHover}, // :SetHover([enable]) - Sets hover on or off + // {"SetDisableGravity", &LuaCreature::SetDisableGravity}, // :SetDisableGravity([disable, packetOnly]) - Disables or enables gravity + {"SetReactState", &LuaCreature::SetReactState}, // :SetReactState(state) - Sets react state + {"SetNoCallAssistance", &LuaCreature::SetNoCallAssistance}, // :SetNoCallAssistance([noCall]) - Sets call assistance to false or true + {"SetNoSearchAssistance", &LuaCreature::SetNoSearchAssistance}, // :SetNoSearchAssistance([noSearch]) - Sets assistance searhing to false or true + {"SetDefaultMovementType", &LuaCreature::SetDefaultMovementType}, // :SetDefaultMovementType(type) - Sets default movement type + {"SetRespawnDelay", &LuaCreature::SetRespawnDelay}, // :SetRespawnDelay(delay) - Sets the respawn delay + {"SetRespawnRadius", &LuaCreature::SetRespawnRadius}, // :SetRespawnRadius(dist) - Sets the respawn radius + {"SetInCombatWithZone", &LuaCreature::SetInCombatWithZone}, // :SetInCombatWithZone() - Sets the creature in combat with everyone in zone + {"SetDisableReputationGain", &LuaCreature::SetDisableReputationGain}, // :SetDisableReputationGain([disable]) - Disables or enables reputation gain from creature + // {"SetLootMode", &LuaCreature::SetLootMode}, // :SetLootMode(lootMode) - Sets the lootmode + {"SetNPCFlags", &LuaCreature::SetNPCFlags}, // :SetNPCFlags(flags) - Sets NPC flags + {"SetDeathState", &LuaCreature::SetDeathState}, // :SetDeathState(value) - 0 = alive 1 = just died 2 = corpse 3 = dead + {"SetWalk", &LuaCreature::SetWalk}, // :SetWalk([enable]) - If false, creature runs, otherwise walks + + // Booleans + {"IsWorldBoss", &LuaCreature::IsWorldBoss}, // :IsWorldBoss() - Returns true if the creature is a WorldBoss, false if not + {"IsRacialLeader", &LuaCreature::IsRacialLeader}, // :IsRacialLeader() - Returns true if the creature is a racial leader, false if not + {"IsCivilian", &LuaCreature::IsCivilian}, // :IsCivilian() - Returns true if the creature is a civilian, false if not + // {"IsTrigger", &LuaCreature::IsTrigger}, // :IsTrigger() - Returns true if the creature is a trigger, false if not + {"IsGuard", &LuaCreature::IsGuard}, // :IsGuard() - Returns true if the creature is a guard, false if not + {"IsElite", &LuaCreature::IsElite}, // :IsElite() - Returns true if the creature is an elite, false if not + {"IsInEvadeMode", &LuaCreature::IsInEvadeMode}, // :IsInEvadeMode() - Returns true if the creature is in evade mode, false if not + {"HasCategoryCooldown", &LuaCreature::HasCategoryCooldown}, // :HasCategoryCooldown(spellId) - Returns true if the creature has a cooldown for the spell's category + {"CanWalk", &LuaCreature::CanWalk}, // :CanWalk() - Returns true if the creature can walk + {"CanSwim", &LuaCreature::CanSwim}, // :CanSwim() - Returns true if the creature can swim + {"HasReactState", &LuaCreature::HasReactState}, // :HasReactState(state) - Returns true if the creature has react state + // {"CanStartAttack", &LuaCreature::CanStartAttack}, // :CanStartAttack(unit[, force]) - Returns true if the creature can attack the unit + {"HasSearchedAssistance", &LuaCreature::HasSearchedAssistance}, // :HasSearchedAssistance() - Returns true if the creature has searched assistance + {"CanAssistTo", &LuaCreature::CanAssistTo}, // :CanAssistTo(unit, enemy[, checkfaction]) - Returns true if the creature can assist unit with enemy + {"IsTargetAcceptable", &LuaCreature::IsTargetAcceptable}, // :IsTargetAcceptable(unit) - Returns true if the creature can target unit + {"HasInvolvedQuest", &LuaCreature::HasInvolvedQuest}, // :HasInvolvedQuest(questId) - Returns true if the creature can finish the quest for players + {"IsRegeneratingHealth", &LuaCreature::IsRegeneratingHealth}, // :IsRegeneratingHealth() - Returns true if the creature is regenerating health + {"IsReputationGainDisabled", &LuaCreature::IsReputationGainDisabled}, // :IsReputationGainDisabled() - Returns true if the creature has reputation gain disabled + // {"IsDamageEnoughForLootingAndReward", &LuaCreature::IsDamageEnoughForLootingAndReward}, // :IsDamageEnoughForLootingAndReward() + // {"HasLootMode", &LuaCreature::HasLootMode}, + {"HasSpell", &LuaCreature::HasSpell}, // :HasSpell(id) + {"HasQuest", &LuaCreature::HasQuest}, // :HasQuest(id) + {"HasSpellCooldown", &LuaCreature::HasSpellCooldown}, // :HasSpellCooldown(spellId) - Returns true if the spell is on cooldown + {"CanFly", &LuaCreature::CanFly}, // :CanFly() - Returns true if the creature can fly + + // Other + // {"Despawn", &LuaCreature::Despawn}, // :Despawn([despawnDelay]) - Creature despawns after given time + {"FleeToGetAssistance", &LuaCreature::FleeToGetAssistance}, // :FleeToGetAssistance() - Creature flees for assistance + {"CallForHelp", &LuaCreature::CallForHelp}, // :CallForHelp(radius) - Creature calls for help from units in radius + {"CallAssistance", &LuaCreature::CallAssistance}, // :CallAssistance() - Creature calls for assistance + {"RemoveCorpse", &LuaCreature::RemoveCorpse}, // :RemoveCorpse([setSpawnTime]) - Removes corpse + {"DespawnOrUnsummon", &LuaCreature::DespawnOrUnsummon}, // :DespawnOrUnsummon([Delay]) - Despawns the creature after delay if given + {"Respawn", &LuaCreature::Respawn}, // :Respawn([force]) - Respawns the creature + // {"AddLootMode", &LuaCreature::AddLootMode}, // :AddLootMode(lootMode) + // {"DealDamage", &LuaCreature::DealDamage}, // :DealDamage(target, amount) - Deals damage to target (if target) : if no target, unit will damage self + // {"SendCreatureTalk", &LuaCreature::SendCreatureTalk}, // :SendCreatureTalk(id, playerGUID) - Sends a chat message to a playerGUID (player) by id. Id can be found in creature_text under the 'group_id' column + {"AttackStart", &LuaCreature::AttackStart}, // :AttackStart(target) - Creature attacks the specified target + // {"ResetLootMode", &LuaCreature::ResetLootMode}, + // {"RemoveLootMode", &LuaCreature::RemoveLootMode}, + {"SaveToDB", &LuaCreature::SaveToDB}, // :SaveToDB() - Saves to database + {"SelectVictim", &LuaCreature::SelectVictim}, // :SelectVictim() - Selects a victim + + {NULL, NULL}, +}; + +ElunaRegister GameObjectMethods[] = +{ + // Getters + {"GetGoState", &LuaGameObject::GetGoState}, // :GetGoState() - Returns state + {"GetLootState", &LuaGameObject::GetLootState}, // :GetLootState() - Returns loot state + + // Setters + {"SetGoState", &LuaGameObject::SetGoState}, + {"SetLootState", &LuaGameObject::SetLootState}, + + // Boolean + {"IsTransport", &LuaGameObject::IsTransport}, // :IsTransport() + // {"IsDestructible", &LuaGameObject::IsDestructible}, // :IsDestructible() + {"IsActive", &LuaGameObject::IsActive}, // :IsActive() + {"HasQuest", &LuaGameObject::HasQuest}, // :HasQuest(questId) + {"IsSpawned", &LuaGameObject::IsSpawned}, // :IsSpawned() + + // Other + {"RemoveFromWorld", &LuaGameObject::RemoveFromWorld}, // :RemoveFromWorld(del) + {"UseDoorOrButton", &LuaGameObject::UseDoorOrButton}, // :UseDoorOrButton(delay) - Activates/closes/opens after X delay UNDOCUMENTED + {"Despawn", &LuaGameObject::Despawn}, // :Despawn([delay]) - Despawns the object after delay + {"Respawn", &LuaGameObject::Respawn}, // :Respawn([delay]) - respawns the object after delay + {"SaveToDB", &LuaGameObject::SaveToDB}, // :SaveToDB() - Saves to database + + { NULL, NULL }, +}; + +ElunaRegister ItemMethods[] = +{ + // Getters + {"GetOwnerGUID", &LuaItem::GetOwnerGUID}, // :GetOwnerGUID() - Returns the owner's guid + {"GetOwner", &LuaItem::GetOwner}, // :GetOwner() - Returns the owner object (player) + {"GetCount", &LuaItem::GetCount}, // :GetCount() - Returns item stack count + {"GetMaxStackCount", &LuaItem::GetMaxStackCount}, // :GetMaxStackCount() - Returns item max stack count + {"GetSlot", &LuaItem::GetSlot}, // :GetSlot() - returns the slot the item is in + {"GetBagSlot", &LuaItem::GetBagSlot}, // :GetBagSlot() - returns the bagslot of the bag the item is in + {"GetEnchantmentId", &LuaItem::GetEnchantmentId}, // :GetEnchantmentId(enchant_slot) - Returns the enchantment in given slot. (permanent = 0) + {"GetSpellId", &LuaItem::GetSpellId}, // :GetSpellId(index) - Returns spellID at given index (0 - 4) + {"GetSpellTrigger", &LuaItem::GetSpellTrigger}, // :GetSpellTrigger(index) - Returns spell trigger at given index (0 - 4) + {"GetItemLink", &LuaItem::GetItemLink}, // :GetItemLink([localeID]) - Returns the shift clickable link of the item. Name translated if locale given and exists + {"GetClass", &LuaItem::GetClass}, // :GetClass() + {"GetSubClass", &LuaItem::GetSubClass}, // :GetSubClass() + {"GetName", &LuaItem::GetName}, // :GetName() + {"GetDisplayId", &LuaItem::GetDisplayId}, // :GetDisplayId() + {"GetQuality", &LuaItem::GetQuality}, // :GetQuality() + {"GetBuyCount", &LuaItem::GetBuyCount}, // :GetBuyCount() + {"GetBuyPrice", &LuaItem::GetBuyPrice}, // :GetBuyPrice() + {"GetSellPrice", &LuaItem::GetSellPrice}, // :GetSellPrice() + {"GetInventoryType", &LuaItem::GetInventoryType}, // :GetInventoryType() + {"GetAllowableClass", &LuaItem::GetAllowableClass}, // :GetAllowableClass() + {"GetAllowableRace", &LuaItem::GetAllowableRace}, // :GetAllowableRace() + {"GetItemLevel", &LuaItem::GetItemLevel}, // :GetItemLevel() + {"GetRequiredLevel", &LuaItem::GetRequiredLevel}, // :GetRequiredLevel() + {"GetRandomProperty", &LuaItem::GetRandomProperty}, // :GetRandomProperty() + {"GetRandomSuffix", &LuaItem::GetRandomSuffix}, // :GetRandomSuffix() + {"GetItemSet", &LuaItem::GetItemSet}, // :GetItemSet() + {"GetBagSize", &LuaItem::GetBagSize}, // :GetBagSize() + + // Setters + {"SetOwner", &LuaItem::SetOwner}, // :SetOwner(player) - Sets the owner of the item + {"SetBinding", &LuaItem::SetBinding}, // :SetBinding(bound) - Sets the item binding to true or false + {"SetCount", &LuaItem::SetCount}, // :SetCount(count) - Sets the item count + + // Boolean + {"IsSoulBound", &LuaItem::IsSoulBound}, // :IsSoulBound() - Returns true if the item is soulbound + {"IsBoundByEnchant", &LuaItem::IsBoundByEnchant}, // :IsBoundByEnchant() - Returns true if the item is bound with an enchant + {"IsNotBoundToPlayer", &LuaItem::IsNotBoundToPlayer}, // :IsNotBoundToPlayer(player) - Returns true if the item is not bound with player + {"IsBag", &LuaItem::IsBag}, // :IsBag() - Returns true if the item is a bag + {"IsBroken", &LuaItem::IsBroken}, // :IsBroken() - Returns true if the item is broken + {"CanBeTraded", &LuaItem::CanBeTraded}, // :CanBeTraded() - Returns true if the item can be traded + {"IsInTrade", &LuaItem::IsInTrade}, // :IsInTrade() - Returns true if the item is in trade + {"IsInBag", &LuaItem::IsInBag}, // :IsInBag() - Returns true if the item is in a bag + {"IsEquipped", &LuaItem::IsEquipped}, // :IsEquipped() - Returns true if the item is equipped + {"HasQuest", &LuaItem::HasQuest}, // :HasQuest(questId) - Returns true if the item starts the quest + {"IsPotion", &LuaItem::IsPotion}, // :IsPotion() - Returns true if the item is a potion + {"IsConjuredConsumable", &LuaItem::IsConjuredConsumable}, // :IsConjuredConsumable() - Returns true if the item is a conjured consumable + // {"IsRefundExpired", &LuaItem::IsRefundExpired}, // :IsRefundExpired() - Returns true if the item's refund time has expired + {"SetEnchantment", &LuaItem::SetEnchantment}, // :SetEnchantment(enchantid, enchantmentslot) - Sets a new enchantment for the item. Returns true on success + {"ClearEnchantment", &LuaItem::ClearEnchantment}, // :ClearEnchantment(enchantmentslot) - Removes the enchantment from the item if one exists. Returns true on success + + // Other + {"SaveToDB", &LuaItem::SaveToDB}, // :SaveToDB() - Saves to database + + {NULL, NULL}, +}; + +ElunaRegister AuraMethods[] = +{ + // Getters + {"GetCaster", &LuaAura::GetCaster}, // :GetCaster() - Returns caster as object + {"GetCasterGUID", &LuaAura::GetCasterGUID}, // :GetCasterGUID() - Returns caster as GUID + {"GetCasterLevel", &LuaAura::GetCasterLevel}, // :GetCasterLevel() - Returns casters level + {"GetDuration", &LuaAura::GetDuration}, // :GetDuration() - Returns remaining duration + {"GetMaxDuration", &LuaAura::GetMaxDuration}, // :GetMaxDuration() - Returns maximum duration + {"GetCharges", &LuaAura::GetCharges}, // :GetCharges() - Returns remaining charges + {"GetAuraId", &LuaAura::GetAuraId}, // :GetAuraId() - Returns aura ID + {"GetStackAmount", &LuaAura::GetStackAmount}, // :GetStackAmount() - Returns current stack amount + {"GetOwner", &LuaAura::GetOwner}, // :GetOwner() - Gets the unit wearing the aura + + // Setters + {"SetDuration", &LuaAura::SetDuration}, // :SetDuration(duration) - Sets remaining duration + {"SetMaxDuration", &LuaAura::SetMaxDuration}, // :SetMaxDuration(duration) - Sets maximum duration + {"SetStackAmount", &LuaAura::SetStackAmount}, // :SetStackAmount(amount) - Sets current stack amount + + // Other + {"Remove", &LuaAura::Remove}, // :Remove() - Removes the aura + + {NULL, NULL}, +}; + +ElunaRegister SpellMethods[] = +{ + // Getters + {"GetCaster", &LuaSpell::GetCaster}, // :GetCaster() - Returns the spell's caster (UNIT) + {"GetCastTime", &LuaSpell::GetCastTime}, // :GetCastTime() - Returns the spell cast time + {"GetEntry", &LuaSpell::GetId}, // :GetEntry() - Returns the spell's ID + {"GetPowerCost", &LuaSpell::GetPowerCost}, // :GetPowerCost() - Returns the spell's power cost (mana, energy, rage, etc) + {"GetTargetDest", &LuaSpell::GetTargetDest}, // :GetTargetDest() - Returns the target destination (x,y,z,o,map) or nil. Orientation and map may be 0. + {"GetTarget", &LuaSpell::GetTarget}, // :GetTarget() - Returns spell cast target (item, worldobject) + + // Setters + {"SetAutoRepeat", &LuaSpell::SetAutoRepeat}, // :SetAutoRepeat(boolean) + + // Boolean + {"IsAutoRepeat", &LuaSpell::IsAutoRepeat}, // :IsAutoRepeat() + + // Other + {"Cancel", &LuaSpell::cancel}, // :Cancel() - Cancels the spell casting + {"Cast", &LuaSpell::Cast}, // :Cast(skipCheck) - Casts the spell (if true, removes the check for instant spells, etc) + {"Finish", &LuaSpell::Finish}, // :Finish() - Finishes the spell (SPELL_STATE_FINISH) + + {NULL, NULL}, +}; + +ElunaRegister QuestMethods[] = +{ + // Getters + {"GetId", &LuaQuest::GetId}, // :GetId() - Returns the quest's Id + {"GetLevel", &LuaQuest::GetLevel}, // :GetLevel() - Returns the quest's level + // {"GetMaxLevel", &LuaQuest::GetMaxLevel}, // :GetMaxLevel() - Returns the quest's max level + {"GetMinLevel", &LuaQuest::GetMinLevel}, // :GetMinLevel() - Returns the quest's min level + {"GetNextQuestId", &LuaQuest::GetNextQuestId}, // :GetNextQuestId() - Returns the quest's next quest ID + {"GetPrevQuestId", &LuaQuest::GetPrevQuestId}, // :GetPrevQuestId() - Returns the quest's previous quest ID + {"GetNextQuestInChain", &LuaQuest::GetNextQuestInChain}, // :GetNexQuestInChain() - Returns the next quest in its chain + {"GetFlags", &LuaQuest::GetFlags}, // :GetFlags() - Returns the quest's flags + {"GetType", &LuaQuest::GetType}, // :GetType() - Returns the quest's type + + // Boolean + {"HasFlag", &LuaQuest::HasFlag}, // :HasFlag(flag) - Returns true or false if the quest has the specified flag + {"IsDaily", &LuaQuest::IsDaily}, // :IsDaily() - Returns true or false if the quest is a daily + {"IsRepeatable", &LuaQuest::IsRepeatable}, // :IsRepeatable() - Returns true or false if the quest is repeatable + + // Setters + {"SetFlag", &LuaQuest::SetFlag}, // :SetFlag(flag) - Sets the flag of the quest by the specified flag + + {NULL, NULL}, +}; + +ElunaRegister GroupMethods[] = +{ + // Getters + {"GetMembers", &LuaGroup::GetMembers}, // :GetMembers() - returns a table the players in this group. (Online?) + {"GetLeaderGUID", &LuaGroup::GetLeaderGUID}, + {"GetLeader", &LuaGroup::GetLeader}, + {"GetMemberGroup", &LuaGroup::GetMemberGroup}, // :GetMemberGroup(player) - Returns the player's subgroup ID + {"GetMemberGUID", &LuaGroup::GetMemberGUID}, // :GetMemberGUID("name") - Returns the member's GUID + {"GetMembersCount", &LuaGroup::GetMembersCount}, // :GetMembersCount() - Returns the member count of the group + + // Setters + {"SetLeader", &LuaGroup::ChangeLeader}, // :SetLeader(Player) - Sets the player as the new leader + {"SetMembersGroup", &LuaGroup::ChangeMembersGroup}, // :ChangeMembersGroup(player, subGroup) - Changes the member's subgroup + + // Boolean + {"IsLeader", &LuaGroup::IsLeader}, // :IsLeader(GUID) + {"AddInvite", &LuaGroup::AddInvite}, // :AddInvite(player) - Adds a an invite to player. Returns true if succesful + {"RemoveMember", &LuaGroup::RemoveMember}, // :RemoveMember(player) - Removes player from group. Returns true on success + {"Disband", &LuaGroup::Disband}, // :Disband() - Disbands the group + {"IsFull", &LuaGroup::IsFull}, // :IsFull() - Returns true if the group is full + // {"IsLFGGroup", &LuaGroup::isLFGGroup}, // :IsLFGGroup() - Returns true if the group is an LFG group + {"IsRaidGroup", &LuaGroup::isRaidGroup}, // :IsRaidGroup() - Returns true if the group is a raid group + {"IsBGGroup", &LuaGroup::isBGGroup}, // :IsBGGroup() - Returns true if the group is a battleground group + // {"IsBFGroup", &LuaGroup::isBFGroup}, // :IsBFGroup() - Returns true if the group is a battlefield group + {"IsMember", &LuaGroup::IsMember}, // :IsMember(player) - Returns true if the player is a member of the group + {"IsAssistant", &LuaGroup::IsAssistant}, // :IsAssistant(player) - returns true if the player is an assistant in the group + {"SameSubGroup", &LuaGroup::SameSubGroup}, // :SameSubGroup(player1, player2) - Returns true if the players are in the same subgroup in the group + {"HasFreeSlotSubGroup", &LuaGroup::HasFreeSlotSubGroup}, // :HasFreeSlotSubGroup(subGroup) - Returns true if the subgroupID has free slots + + // Other + {"SendPacket", &LuaGroup::SendPacket}, // :SendPacket(packet, sendToPlayersInBattleground[, ignoreguid]) - Sends a specified packet to the group with the choice (true/false) to send it to players in a battleground. Optionally ignores given player guid + // {"ConvertToLFG", &LuaGroup::ConvertToLFG}, // :ConvertToLFG() - Converts the group to an LFG group + {"ConvertToRaid", &LuaGroup::ConvertToRaid}, // :ConvertToRaid() - Converts the group to a raid group + + {NULL, NULL}, +}; + +ElunaRegister GuildMethods[] = +{ + // Getters + {"GetMembers", &LuaGuild::GetMembers}, // :GetMembers() - returns a table containing the players in this guild. (Online?) + {"GetLeader", &LuaGuild::GetLeader}, // :GetLeader() - Returns the guild learder's object + {"GetLeaderGUID", &LuaGuild::GetLeaderGUID}, // :GetLeaderGUID() - Returns the guild learder's guid + {"GetId", &LuaGuild::GetId}, // :GetId() - Gets the guild's ID + {"GetName", &LuaGuild::GetName}, // :GetName() - Gets the guild name + {"GetMOTD", &LuaGuild::GetMOTD}, // :GetMOTD() - Gets the guild MOTD string + {"GetInfo", &LuaGuild::GetInfo}, // :GetInfo() - Gets the guild info string + {"GetMemberCount", &LuaGuild::GetMemberCount}, // :GetMemberCount() - Returns the amount of players in the guild + + // Setters + {"SetBankTabText", &LuaGuild::SetBankTabText}, // :SetBankTabText(tabId, text) + {"SetMemberRank", &LuaGuild::ChangeMemberRank}, // :SetMemberRank(player, newRank) - Sets the player rank in the guild to the new rank + {"SetLeader", &LuaGuild::SetLeader}, // :SetLeader() - Sets the guild's leader + + // Boolean + + // Other + {"ChangeMemberRank", &LuaGuild::ChangeMemberRank}, // :ChangeMemberRank(player, rankId) - Changes players rank to rank specified + {"SendPacket", &LuaGuild::SendPacket}, // :SendPacket(packet) - sends packet to guild + {"SendPacketToRanked", &LuaGuild::SendPacketToRanked}, // :SendPacketToRanked(packet, rankId) - sends packet to guild, specifying a rankId will only send the packet to your ranked members + {"Disband", &LuaGuild::Disband}, // :Disband() - Disbands the guild + {"AddMember", &LuaGuild::AddMember}, // :AddMember(player, rank) - adds the player to the guild. Rank is optional + {"DeleteMember", &LuaGuild::DeleteMember}, // :DeleteMember(player, disbanding, kicked) - Deletes the player from the guild. Disbanding and kicked are optional bools + {"DepositBankMoney", &LuaGuild::DepositBankMoney}, // :DepositBankMoney(money) - Deposits money into the guild bank + {"WithdrawBankMoney", &LuaGuild::WithdrawBankMoney}, // :WithdrawBankMoney(money) - Withdraws money from the guild bank + + {NULL, NULL}, +}; + +ElunaRegister QueryMethods[] = +{ + {"NextRow", &LuaQuery::NextRow}, // :NextRow() - Advances to next rown in the query. Returns true if there is a next row, otherwise false + {"GetColumnCount", &LuaQuery::GetColumnCount}, // :GetColumnCount() - Gets the column count of the query + {"GetRowCount", &LuaQuery::GetRowCount}, // :GetRowCount() - Gets the row count of the query + + {"GetBool", &LuaQuery::GetBool}, // :GetBool(column) - returns a bool from a number column (for example tinyint) + {"GetUInt8", &LuaQuery::GetUInt8}, // :GetUInt8(column) - returns the value of an unsigned tinyint column + {"GetUInt16", &LuaQuery::GetUInt16}, // :GetUInt16(column) - returns the value of a unsigned smallint column + {"GetUInt32", &LuaQuery::GetUInt32}, // :GetUInt32(column) - returns the value of an unsigned int or mediumint column + {"GetUInt64", &LuaQuery::GetUInt64}, // :GetUInt64(column) - returns the value of an unsigned bigint column as string + {"GetInt16", &LuaQuery::GetInt16}, // :GetInt16(column) - returns the value of a smallint column + {"GetInt32", &LuaQuery::GetInt32}, // :GetInt32(column) - returns the value of an int or mediumint column + {"GetInt64", &LuaQuery::GetInt64}, // :GetInt64(column) - returns the value of a bigint column as string + {"GetFloat", &LuaQuery::GetFloat}, // :GetFloat(column) - returns the value of a float column + {"GetString", &LuaQuery::GetString}, // :GetString(column) - returns the value of a string column + {"IsNull", &LuaQuery::IsNull}, // :IsNull(column) - returns true if the column is null + + {NULL, NULL}, +}; + +ElunaRegister PacketMethods[] = +{ + // Getters + {"GetOpcode", &LuaPacket::GetOpcode}, // :GetOpcode() - Returns an opcode + {"GetSize", &LuaPacket::GetSize}, // :GetSize() - Returns the packet size + + // Setters + {"SetOpcode", &LuaPacket::SetOpcode}, // :SetOpcode(opcode) - Sets the opcode by specifying an opcode + + // Readers + {"ReadByte", &LuaPacket::ReadByte}, // :ReadByte() - Reads an int8 value + {"ReadUByte", &LuaPacket::ReadUByte}, // :ReadUByte() - Reads an uint8 value + {"ReadShort", &LuaPacket::ReadShort}, // :ReadShort() - Reads an int16 value + {"ReadUShort", &LuaPacket::ReadUShort}, // :ReadUShort() - Reads an uint16 value + {"ReadLong", &LuaPacket::ReadLong}, // :ReadLong() - Reads an int32 value + {"ReadULong", &LuaPacket::ReadULong}, // :ReadULong() - Reads an uint32 value + {"ReadGUID", &LuaPacket::ReadGUID}, // :ReadGUID() - Reads an uint64 value + {"ReadString", &LuaPacket::ReadString}, // :ReadString() - Reads a string value + {"ReadFloat", &LuaPacket::ReadFloat}, // :ReadFloat() - Reads a float value + {"ReadDouble", &LuaPacket::ReadDouble}, // :ReadDouble() - Reads a double value + + // Writers + {"WriteByte", &LuaPacket::WriteByte}, // :WriteByte(val) - Writes an int8 value + {"WriteUByte", &LuaPacket::WriteUByte}, // :WriteUByte(val) - Writes a uint8 value + {"WriteShort", &LuaPacket::WriteShort}, // :WriteShort(val) - Writes an int16 value + {"WriteUShort", &LuaPacket::WriteUShort}, // :WriteUShort(val) - Writes a uint16 value + {"WriteLong", &LuaPacket::WriteLong}, // :WriteLong(val) - Writes an int32 value + {"WriteULong", &LuaPacket::WriteULong}, // :WriteULong(val) - Writes a uint32 value + {"WriteGUID", &LuaPacket::WriteGUID}, // :WriteGUID(guid) - Writes a uint64 value + {"WriteString", &LuaPacket::WriteString}, // :WriteString(val) - Writes a string value + {"WriteFloat", &LuaPacket::WriteFloat}, // :WriteFloat(val) - Writes a float value + {"WriteDouble", &LuaPacket::WriteDouble}, // :WriteDouble(val) - Writes a double value + + {NULL, NULL}, +}; + +ElunaRegister MapMethods[] = +{ + // Getters + {"GetName", &LuaMap::GetName}, // :GetName() - Returns the map's name UNDOCUMENTED + {"GetInstanceId", &LuaMap::GetInstanceId}, // :GetInstanceId() - Returns the map's instance ID UNDOCUMENTED + {"GetPlayerCount", &LuaMap::GetPlayerCount}, // :GetPlayerCount() - Returns the amount of players on map except GM's UNDOCUMENTED + {"GetMapId", &LuaMap::GetMapId}, // :GetMapId() - Returns the map's ID UNDOCUMENTED + {"GetAreaId", &LuaMap::GetAreaId}, // :GetAreaId(x, y, z) - Returns the map's area ID based on coords UNDOCUMENTED + {"GetHeight", &LuaMap::GetHeight}, // :GetHeight(x, y[, phasemask]) - Returns ground Z coordinate. UNDOCUMENTED + + // Booleans + {"IsArena", &LuaMap::IsArena}, // :IsArena() - Returns the true if the map is an arena, else false UNDOCUMENTED + {"IsBattleground", &LuaMap::IsBattleground}, // :IsBattleground() - Returns the true if the map is a battleground, else false UNDOCUMENTED + {"IsDungeon", &LuaMap::IsDungeon}, // :IsDungeon() - Returns the true if the map is a dungeon , else false UNDOCUMENTED + {"IsEmpty", &LuaMap::IsEmpty}, // :IsEmpty() - Returns the true if the map is empty, else false UNDOCUMENTED + {"IsHeroic", &LuaMap::IsHeroic}, // :IsHeroic() - Returns the true if the map is a heroic dungeon, else false UNDOCUMENTED + {"IsRaid", &LuaMap::IsRaid}, // :IsRaid() - Returns the true if the map is a raid map, else false UNDOCUMENTED + + {NULL, NULL}, +}; + +ElunaRegister CorpseMethods[] = +{ + {"GetOwnerGUID", &LuaCorpse::GetOwnerGUID}, // :GetOwnerGUID() - Returns the corpse owner GUID + {"GetGhostTime", &LuaCorpse::GetGhostTime}, // :GetGhostTime() - Returns the ghost time of a corpse + {"GetType", &LuaCorpse::GetType}, // :GetType() - Returns the (CorpseType) of a corpse + {"ResetGhostTime", &LuaCorpse::ResetGhostTime}, // :ResetGhostTime() - Resets the corpse's ghost time + {"SaveToDB", &LuaCorpse::SaveToDB}, // :SaveToDB() - Saves to database + {"DeleteBonesFromWorld", &LuaCorpse::DeleteBonesFromWorld}, // :DeleteBonesFromWorld() - Deletes all bones from the world + + {NULL, NULL} +}; + +ElunaRegister WeatherMethods[] = +{ + // Getters + {"GetZoneId", &LuaWeather::GetZoneId}, // :GetZoneId() - Returns the weather's zoneId + + // Setters + {"SetWeather", &LuaWeather::SetWeather}, // :SetWeather(weatherType, grade) - Sets the weather by weather type and grade + + // Boolean + {"Regenerate", &LuaWeather::Regenerate}, // :Regenerate() - Calculates weather, returns true if the weather changed + {"UpdateWeather", &LuaWeather::UpdateWeather}, // :UpdateWeather() - Updates the weather in a zone that has players in it, returns false if players aren't found + + // Other + {"SendWeatherUpdateToPlayer", &LuaWeather::SendWeatherUpdateToPlayer}, // :SendWeatherUpdateToPlayer(player) - Sends weather update to the player + + {NULL, NULL} +}; + +ElunaRegister AuctionMethods[] = +{ + {NULL, NULL} +}; + +template const char* ElunaTemplate::tname = NULL; +template bool ElunaTemplate::manageMemory = false; + +void RegisterFunctions(lua_State* L) +{ + RegisterGlobals(L); + lua_settop(L, 0); // clean stack + + ElunaTemplate::Register(L, "Object"); + ElunaTemplate::SetMethods(L, ObjectMethods); + + ElunaTemplate::Register(L, "WorldObject"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + + ElunaTemplate::Register(L, "Unit"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + ElunaTemplate::SetMethods(L, UnitMethods); + + ElunaTemplate::Register(L, "Player"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + ElunaTemplate::SetMethods(L, UnitMethods); + ElunaTemplate::SetMethods(L, PlayerMethods); + + ElunaTemplate::Register(L, "Creature"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + ElunaTemplate::SetMethods(L, UnitMethods); + ElunaTemplate::SetMethods(L, CreatureMethods); + + ElunaTemplate::Register(L, "GameObject"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + ElunaTemplate::SetMethods(L, GameObjectMethods); + + ElunaTemplate::Register(L, "Corpse"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, WorldObjectMethods); + ElunaTemplate::SetMethods(L, CorpseMethods); + + ElunaTemplate::Register(L, "Item"); + ElunaTemplate::SetMethods(L, ObjectMethods); + ElunaTemplate::SetMethods(L, ItemMethods); + + ElunaTemplate::Register(L, "Group"); + ElunaTemplate::SetMethods(L, GroupMethods); + + ElunaTemplate::Register(L, "Guild"); + ElunaTemplate::SetMethods(L, GuildMethods); + + ElunaTemplate::Register(L, "Aura"); + ElunaTemplate::SetMethods(L, AuraMethods); + + ElunaTemplate::Register(L, "Spell"); + ElunaTemplate::SetMethods(L, SpellMethods); + + ElunaTemplate::Register(L, "Quest"); + ElunaTemplate::SetMethods(L, QuestMethods); + + ElunaTemplate::Register(L, "Map"); + ElunaTemplate::SetMethods(L, MapMethods); + + ElunaTemplate::Register(L, "Weather"); + ElunaTemplate::SetMethods(L, WeatherMethods); + + ElunaTemplate::Register(L, "AuctionHouseObject"); + ElunaTemplate::SetMethods(L, AuctionMethods); + + ElunaTemplate::Register(L, "WorldPacket", true); + ElunaTemplate::SetMethods(L, PacketMethods); + + ElunaTemplate::Register(L, "QueryResult", true); + ElunaTemplate::SetMethods(L, QueryMethods); + + lua_settop(L, 0); // clean stack +} diff --git a/src/game/luaengine/MapMethods.h b/src/game/luaengine/MapMethods.h new file mode 100644 index 000000000..98f33fa54 --- /dev/null +++ b/src/game/luaengine/MapMethods.h @@ -0,0 +1,93 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef MAPMETHODS_H +#define MAPMETHODS_H + +namespace LuaMap +{ + int GetName(lua_State* L, Map* map) + { + sEluna->Push(L, map->GetMapName()); + return 1; + } + + int GetHeight(lua_State* L, Map* map) + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + float z = map->GetTerrain()->GetHeight(x, y, MAX_HEIGHT); + if (z == INVALID_HEIGHT) + return 0; + sEluna->Push(L, z); + return 1; + } + + int GetInstanceId(lua_State* L, Map* map) + { + sEluna->Push(L, map->GetInstanceId()); + return 1; + } + + int GetPlayerCount(lua_State* L, Map* map) + { + sEluna->Push(L, map->GetPlayersCountExceptGMs()); + return 1; + } + + int GetMapId(lua_State* L, Map* map) + { + sEluna->Push(L, map->GetId()); + return 1; + } + + int GetAreaId(lua_State* L, Map* map) + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + float z = sEluna->CHECKVAL(L, 4); + + sEluna->Push(L, map->GetTerrain()->GetAreaId(x, y, z)); + return 1; + } + + int IsArena(lua_State* L, Map* map) + { + sEluna->Push(L, map->IsBattleArena()); + return 1; + } + + int IsBattleground(lua_State* L, Map* map) + { + sEluna->Push(L, map->IsBattleGround()); + return 1; + } + + int IsDungeon(lua_State* L, Map* map) + { + sEluna->Push(L, map->IsDungeon()); + return 1; + } + + int IsEmpty(lua_State* L, Map* map) + { + sEluna->Push(L, map->isEmpty()); + return 1; + } + + int IsHeroic(lua_State* L, Map* map) + { + sEluna->Push(L, map->IsHeroic()); + return 1; + } + + int IsRaid(lua_State* L, Map* map) + { + sEluna->Push(L, map->IsRaid()); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/ObjectMethods.h b/src/game/luaengine/ObjectMethods.h new file mode 100644 index 000000000..af8c5d7e6 --- /dev/null +++ b/src/game/luaengine/ObjectMethods.h @@ -0,0 +1,141 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef OBJECTMETHODS_H +#define OBJECTMETHODS_H + +namespace LuaObject +{ + int RemoveFlag(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint32 flag = sEluna->CHECKVAL(L, 3); + + obj->RemoveFlag(index, flag); + return 0; + } + int SetFlag(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint32 flag = sEluna->CHECKVAL(L, 3); + + obj->SetFlag(index, flag); + return 0; + } + int HasFlag(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint32 flag = sEluna->CHECKVAL(L, 3); + + sEluna->Push(L, obj->HasFlag(index, flag)); + return 1; + } + int GetInt32Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, obj->GetInt32Value(index)); + return 1; + } + int GetUInt32Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, obj->GetUInt32Value(index)); + return 1; + } + int GetFloatValue(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, obj->GetFloatValue(index)); + return 1; + } + int GetByteValue(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint8 offset = sEluna->CHECKVAL(L, 3); + sEluna->Push(L, obj->GetByteValue(index, offset)); + return 1; + } + int GetUInt16Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint8 offset = sEluna->CHECKVAL(L, 3); + sEluna->Push(L, obj->GetUInt16Value(index, offset)); + return 1; + } + int SetInt32Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + int32 value = sEluna->CHECKVAL(L, 3); + obj->SetInt32Value(index, value); + return 0; + } + int SetUInt32Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint32 value = sEluna->CHECKVAL(L, 3); + obj->SetUInt32Value(index, value); + return 0; + } + int SetFloatValue(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + float value = sEluna->CHECKVAL(L, 3); + + obj->SetFloatValue(index, value); + return 0; + } + int SetByteValue(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint8 offset = sEluna->CHECKVAL(L, 3); + uint8 value = sEluna->CHECKVAL(L, 4); + obj->SetByteValue(index, offset, value); + return 0; + } + int SetUInt16Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint8 offset = sEluna->CHECKVAL(L, 3); + uint16 value = sEluna->CHECKVAL(L, 4); + obj->SetUInt16Value(index, offset, value); + return 0; + } + int SetInt16Value(lua_State* L, Object* obj) + { + uint16 index = sEluna->CHECKVAL(L, 2); + uint8 offset = sEluna->CHECKVAL(L, 3); + int16 value = sEluna->CHECKVAL(L, 4); + obj->SetInt16Value(index, offset, value); + return 0; + } + + static int GetEntry(lua_State* L, Object* obj) + { + sEluna->Push(L, obj->GetEntry()); + return 1; + } + static int GetGUID(lua_State* L, Object* obj) + { + sEluna->Push(L, obj->GetGUID()); + return 1; + } + static int GetGUIDLow(lua_State* L, Object* obj) + { + sEluna->Push(L, obj->GetGUIDLow()); + return 1; + } + static int GetTypeId(lua_State* L, Object* obj) + { + sEluna->Push(L, obj->GetTypeId()); + return 1; + } + static int IsInWorld(lua_State* L, Object* obj) + { + sEluna->Push(L, obj->IsInWorld()); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/PlayerMethods.h b/src/game/luaengine/PlayerMethods.h new file mode 100644 index 000000000..3fb007b62 --- /dev/null +++ b/src/game/luaengine/PlayerMethods.h @@ -0,0 +1,2015 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef PLAYERMETHODS_H +#define PLAYERMETHODS_H + +namespace LuaPlayer +{ + int SaveToDB(lua_State* L, Player* player) + { + player->SaveToDB(); + return 0; + } + + int HasQuest(lua_State* L, Player* player) + { + uint32 quest = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->IsActiveQuest(quest)); + return 1; + } + + int HasSpell(lua_State* L, Player* player) + { + uint32 id = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasSpell(id)); + return 1; + } + + int SummonPlayer(lua_State* L, Player* player) + { + Player* target = sEluna->CHECKOBJ(L, 2); + uint32 map = sEluna->CHECKVAL(L, 3); + float x = sEluna->CHECKVAL(L, 4); + float y = sEluna->CHECKVAL(L, 5); + float z = sEluna->CHECKVAL(L, 6); + float zoneId = sEluna->CHECKVAL(L, 7); + uint32 delay = sEluna->CHECKVAL(L, 8, 0); + if (!MapManager::IsValidMapCoord(map, x, y, z)) + return 0; + + target->SetSummonPoint(map, x, y, z); + WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); + data << uint64(player->GetGUIDLow()); + data << uint32(zoneId); + data << uint32(delay ? delay* IN_MILISECONDS : MAX_PLAYER_SUMMON_DELAY * IN_MILISECONDS); + target->GetSession()->SendPacket(&data); + return 0; + } + + int CreateCorpse(lua_State* L, Player* player) + { + player->CreateCorpse(); + return 0; + } + + int RewardQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + Quest const* quest = sObjectMgr.GetQuestTemplate(entry); + if (quest) + player->RewardQuest(quest, 0, player); + return 0; + } + + /*int IsARecruiter(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->IsARecruiter() || (player->GetSession()->GetRecruiterId() != 0)); + return 1; + }*/ + + /*int GetRecruiterId(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetRecruiterId()); + return 1; + }*/ + + /*int GetSelectedPlayer(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSelectedPlayer()); + return 1; + }*/ + + /*int GetSelectedUnit(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSelectedUnit()); + return 1; + }*/ + + int GetLatency(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetLatency()); + return 1; + } + + int SendAuctionMenu(lua_State* L, Player* player) + { + Unit* unit = sEluna->CHECKOBJ(L, 2); + + AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit); + + if (!ahEntry) + return 0; + + WorldPacket data(MSG_AUCTION_HELLO, 12); + data << uint64(unit->GetGUIDLow()); + data << uint32(ahEntry->houseId); + data << uint8(1); + player->GetSession()->SendPacket(&data); + return 0; + } + + int SendTaxiMenu(lua_State* L, Player* player) + { + Creature* creature = sEluna->CHECKOBJ(L, 2); + + player->GetSession()->SendTaxiMenu(creature); + return 0; + } + + int SendSpiritResurrect(lua_State* L, Player* player) + { + player->GetSession()->SendSpiritResurrect(); + return 0; + } + + int SendTabardVendorActivate(lua_State* L, Player* player) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + + player->GetSession()->SendTabardVendorActivate(obj->GetGUID()); + return 0; + } + + int SendShowBank(lua_State* L, Player* player) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + + player->GetSession()->SendShowBank(obj->GetGUID()); + return 0; + } + + int SendListInventory(lua_State* L, Player* player) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + uint32 entry = sEluna->CHECKVAL(L, 3, 0); + + player->GetSession()->SendListInventory(obj->GetGUID()), entry; + return 0; + } + + int SendTrainerList(lua_State* L, Player* player) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + + player->GetSession()->SendTrainerList(obj->GetGUID()); + return 0; + } + + int LogoutPlayer(lua_State* L, Player* player) + { + bool save = sEluna->CHECKVAL(L, 2, true); + + player->GetSession()->LogoutPlayer(save); + return 0; + } + + int GetOriginalSubGroup(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetOriginalSubGroup()); + return 1; + } + + int GetOriginalGroup(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetOriginalGroup()); + return 1; + } + + int CanUninviteFromGroup(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanUninviteFromGroup() == PARTY_RESULT_OK); + return 1; + } + + int GetNextRandomRaidMember(lua_State* L, Player* player) + { + float radius = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetNextRandomRaidMember(radius)); + return 1; + } + + int GetSubGroup(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSubGroup()); + return 1; + } + + int GetGroupInvite(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetGroupInvite()); + return 1; + } + + /*int HasPendingBind(lua_State* L, Player* player) + { + sEluna->Push(L, player->PendingHasPendingBind()); + return 1; + }*/ + + int UnbindInstance(lua_State* L, Player* player) + { + uint32 map = sEluna->CHECKVAL(L, 2); + uint32 difficulty = sEluna->CHECKVAL(L, 3); + + if (difficulty < TOTAL_DIFFICULTIES) + player->UnbindInstance(map, (DungeonDifficulties)difficulty); + return 0; + } + + /*int BindToInstance(lua_State* L, Player* player) + { + player->BindToInstance(); + return 0; + }*/ + + int SetAtLoginFlag(lua_State* L, Player* player) + { + uint32 flag = sEluna->CHECKVAL(L, 2); + + player->SetAtLoginFlag((AtLoginFlags)flag); + return 0; + } + + /*int InRandomLfgDungeon(lua_State* L, Player* player) + { + sEluna->Push(L, player->inRandomLfgDungeon()); + return 1; + }*/ + + /*int IsUsingLfg(lua_State* L, Player* player) + { + sEluna->Push(L, player->isUsingLfg()); + return 1; + }*/ + + int HasAtLoginFlag(lua_State* L, Player* player) + { + uint32 flag = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasAtLoginFlag((AtLoginFlags)flag)); + return 1; + } + + int IsVisibleForPlayer(lua_State* L, Player* player) + { + Player* target = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, player->IsVisibleGloballyfor(target)); + return 1; + } + + /*int IsNeverVisible(lua_State* L, Player* player) + { + sEluna->Push(L, player->IsNeverVisible()); + return 1; + }*/ + + /*int CanFlyInZone(lua_State* L, Player* player) + { + uint32 mapid = sEluna->CHECKVAL(L, 2); + uint32 zone = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->IsKnowHowFlyIn(mapid, zone)); + return 1; + }*/ + + int SetRestTime(lua_State* L, Player* player) + { + uint32 value = sEluna->CHECKVAL(L, 2); + + player->SetRestTime(value); + return 0; + } + + int GetRestTime(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetRestTime()); + return 1; + } + + int GetXPRestBonus(lua_State* L, Player* player) + { + uint32 xp = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetXPRestBonus(xp)); + return 1; + } + + int CanSpeak(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanSpeak()); + return 1; + } + + /*int IsImmuneToEnvironmentalDamage(lua_State* L, Player* player) + { + sEluna->Push(L, player->IsImmuneToEnvironmentalDamage()); + return 1; + }*/ + + int IsRested(lua_State* L, Player* player) + { + sEluna->Push(L, player->isRested()); + return 1; + } + + int LeaveBattleground(lua_State* L, Player* player) + { + bool teleToEntryPoint = sEluna->CHECKVAL(L, 2, true); + + player->LeaveBattleground(teleToEntryPoint); + return 0; + } + + int InBattlegroundQueue(lua_State* L, Player* player) + { + sEluna->Push(L, player->InBattleGroundQueue()); + return 1; + } + + int GetBattlegroundTypeId(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetBattleGroundTypeId()); + return 1; + } + + int GetBattlegroundId(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetBattleGroundId()); + return 1; + } + + /*int IsOutdoorPvPActive(lua_State* L, Player* player) + { + sEluna->Push(L, player->IsOutdoorPvPActive()); + return 1; + }*/ + + int InArena(lua_State* L, Player* player) + { + sEluna->Push(L, player->InArena()); + return 1; + } + + int InBattleground(lua_State* L, Player* player) + { + sEluna->Push(L, player->InBattleGround()); + return 1; + } + + int CanBlock(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanBlock()); + return 1; + } + + int CanParry(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanParry()); + return 1; + } + + int GetDrunkValue(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetDrunkValue()); + return 1; + } + + int SetDrunkValue(lua_State* L, Player* player) + { + uint8 newDrunkValue = sEluna->CHECKVAL(L, 2); + + player->SetDrunkValue(newDrunkValue); + return 0; + } + + int ModifyArenaPoints(lua_State* L, Player* player) + { + int32 amount = sEluna->CHECKVAL(L, 2); + + player->ModifyArenaPoints(amount); + return 0; + } + + int ModifyHonorPoints(lua_State* L, Player* player) + { + int32 amount = sEluna->CHECKVAL(L, 2); + + player->ModifyHonorPoints(amount); + return 0; + } + + int GetReputationRank(lua_State* L, Player* player) + { + uint32 faction = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetReputationRank(faction)); + return 1; + } + + int SetFactionForRace(lua_State* L, Player* player) + { + uint8 race = sEluna->CHECKVAL(L, 2); + + player->setFactionForRace(race); + return 0; + } + + int SetSkill(lua_State* L, Player* player) + { + uint16 id = sEluna->CHECKVAL(L, 2); + uint16 currVal = sEluna->CHECKVAL(L, 3); + uint16 maxVal = sEluna->CHECKVAL(L, 4); + + player->SetSkill(id, currVal, maxVal); + return 0; + } + + int HasSkill(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasSkill(skill)); + return 1; + } + + int GetSkillTempBonusValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetSkillTempBonusValue(skill)); + return 1; + } + + int GetPureSkillValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetPureSkillValue(skill)); + return 1; + } + + int GetBaseSkillValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetBaseSkillValue(skill)); + return 1; + } + + int GetSkillValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetSkillValue(skill)); + return 1; + } + + int GetPureMaxSkillValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetPureMaxSkillValue(skill)); + return 1; + } + + int GetMaxSkillValue(lua_State* L, Player* player) + { + uint32 skill = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetMaxSkillValue(skill)); + return 1; + } + + /*int SetMovement(lua_State* L, Player* player) + { + int32 pType = sEluna->CHECKVAL(L, 2); + + player->SetMovement((PlayerMovementType)pType); + return 0; + }*/ + + int DurabilityRepair(lua_State* L, Player* player) + { + uint16 position = sEluna->CHECKVAL(L, 2); + bool cost = sEluna->CHECKVAL(L, 3, true); + float discountMod = sEluna->CHECKVAL(L, 4); + bool guildBank = sEluna->CHECKVAL(L, 5, false); + + sEluna->Push(L, player->DurabilityRepair(position, cost, discountMod, guildBank)); + return 1; + } + + int DurabilityRepairAll(lua_State* L, Player* player) + { + bool cost = sEluna->CHECKVAL(L, 2, true); + float discountMod = sEluna->CHECKVAL(L, 3); + bool guildBank = sEluna->CHECKVAL(L, 4, false); + + sEluna->Push(L, player->DurabilityRepairAll(cost, discountMod, guildBank)); + return 1; + } + + int DurabilityPointLossForEquipSlot(lua_State* L, Player* player) + { + int32 slot = sEluna->CHECKVAL(L, 2); + + if (slot >= EQUIPMENT_SLOT_START && slot < EQUIPMENT_SLOT_END) + player->DurabilityPointLossForEquipSlot((EquipmentSlots)slot); + return 0; + } + + int DurabilityPointsLossAll(lua_State* L, Player* player) + { + int32 points = sEluna->CHECKVAL(L, 2); + bool inventory = sEluna->CHECKVAL(L, 3, true); + + player->DurabilityPointsLossAll(points, inventory); + return 0; + } + + int DurabilityPointsLoss(lua_State* L, Player* player) + { + Item* item = sEluna->CHECKOBJ(L, 2); + int32 points = sEluna->CHECKVAL(L, 3); + + player->DurabilityPointsLoss(item, points); + return 0; + } + + int DurabilityLoss(lua_State* L, Player* player) + { + Item* item = sEluna->CHECKOBJ(L, 2); + double percent = sEluna->CHECKVAL(L, 3); + + player->DurabilityLoss(item, percent); + return 0; + } + + int DurabilityLossAll(lua_State* L, Player* player) + { + double percent = sEluna->CHECKVAL(L, 2); + bool inventory = sEluna->CHECKVAL(L, 3, true); + + player->DurabilityLossAll(percent, inventory); + return 0; + } + + int KillPlayer(lua_State* L, Player* player) + { + player->KillPlayer(); + return 0; + } + + int GetManaBonusFromIntellect(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetManaBonusFromIntellect()); + return 1; + } + + int GetHealthBonusFromStamina(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetHealthBonusFromStamina()); + return 1; + } + + int GetDifficulty(lua_State* L, Player* player) + { +#ifdef TBC + sEluna->Push(L, player->GetDifficulty()); +#else + bool isRaid = sEluna->CHECKVAL(L, 2, true); + sEluna->Push(L, player->GetDifficulty(isRaid)); +#endif + return 1; + } + + int GetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods + { + sEluna->Push(L, player->GetRank()); + return 1; + } + + int SetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods + { + uint8 rank = sEluna->CHECKVAL(L, 2); + + if (!player->GetGuildId()) + return 0; + + player->SetRank(rank); + return 0; + } + + int RemoveFromGroup(lua_State* L, Player* player) + { + if (!player->GetGroup()) + return 0; + + player->RemoveFromGroup(); + return 0; + } + + int IsGroupVisibleFor(lua_State* L, Player* player) + { + Player* target = sEluna->CHECKOBJ(L, 2); + sEluna->Push(L, player->IsGroupVisiblefor(target)); + return 1; + } + + int IsInSameRaidWith(lua_State* L, Player* player) + { + Player* target = sEluna->CHECKOBJ(L, 2); + sEluna->Push(L, player->IsInSameRaidWith(target)); + return 1; + } + + int IsInSameGroupWith(lua_State* L, Player* player) + { + Player* target = sEluna->CHECKOBJ(L, 2); + sEluna->Push(L, player->IsInSameGroupWith(target)); + return 1; + } + + int GetSpellCooldownDelay(lua_State* L, Player* player) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, uint32(player->GetSpellCooldownDelay(spellId))); + return 1; + } + + /*int AddTalent(lua_State* L, Player* player) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + uint8 spec = sEluna->CHECKVAL(L, 3); + bool learning = sEluna->CHECKVAL(L, 4, true); + if (spec >= MAX_TALENT_SPECS) + sEluna->Push(L, false); + else + sEluna->Push(L, player->AddTalent(spellId, spec, learning)); + return 1; + }*/ + + int ResetTalentsCost(lua_State* L, Player* player) + { + sEluna->Push(L, player->resetTalentsCost()); + return 1; + } + + int ResetTalents(lua_State* L, Player* player) + { + bool no_cost = sEluna->CHECKVAL(L, 2, true); + + player->resetTalents(no_cost); + return 0; + } + + int SetFreeTalentPoints(lua_State* L, Player* player) + { + uint32 points = sEluna->CHECKVAL(L, 2); + + player->SetFreeTalentPoints(points); +#ifndef TBC + player->SendTalentsInfoData(false); +#endif + return 0; + } + + int GetFreeTalentPoints(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetFreeTalentPoints()); + return 1; + } + + int GetGuildName(lua_State* L, Player* player) + { + if (!player->GetGuildId()) + return 0; + sEluna->Push(L, sGuildMgr.GetGuildNameById(player->GetGuildId())); + return 1; + } + + int GetReputation(lua_State* L, Player* player) + { + uint32 faction = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetReputationMgr().GetReputation(faction)); + return 1; + } + + int SetReputation(lua_State* L, Player* player) + { + uint32 faction = sEluna->CHECKVAL(L, 2); + int32 value = sEluna->CHECKVAL(L, 3); + + FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction); + player->GetReputationMgr().SetReputation(factionEntry, value); + return 0; + } + + int RemoveSpell(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + bool disabled = sEluna->CHECKVAL(L, 3, false); + bool learn_low_rank = sEluna->CHECKVAL(L, 4, true); + + player->removeSpell(entry, disabled); + return 0; + } + + int ClearComboPoints(lua_State* L, Player* player) + { + player->ClearComboPoints(); + return 0; + } + + /*int GainSpellComboPoints(lua_State* L, Player* player) + { + int8 count = sEluna->CHECKVAL(L, 2); + + player->GainSpellComboPoints(count); + return 0; + }*/ + + int AddComboPoints(lua_State* L, Player* player) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + int8 count = sEluna->CHECKVAL(L, 3); + + player->AddComboPoints(target, count); + return 0; + } + + int GetComboTarget(lua_State* L, Player* player) + { + sEluna->Push(L, Unit::GetUnit(*player, player->GetComboTarget())); + return 1; + } + + int GetComboPoints(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetComboPoints()); + return 1; + } + + /*int HasReceivedQuestReward(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->IsQuestRewarded(entry)); + return 1; + }*/ + + int GetInGameTime(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetInGameTime()); + return 1; + } + + int TalkedToCreature(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + Creature* creature = sEluna->CHECKOBJ(L, 3); + + player->TalkedToCreature(entry, creature->GetGUID()); + return 0; + } + + /*int KillGOCredit(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + uint64 guid = sEluna->CHECKVAL(L, 3); + player->KillCreditGO(entry, guid); + return 0; + }*/ + + /*int KilledPlayerCredit(lua_State* L, Player* player) + { + player->KilledPlayerCredit(); + return 0; + }*/ + + int KilledMonsterCredit(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->KilledMonster(entry, player->GetGUID()); + return 0; + } + + int GroupEventHappens(lua_State* L, Player* player) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + WorldObject* obj = sEluna->CHECKOBJ(L, 3); + + player->GroupEventHappens(questId, obj); + return 0; + } + + int AreaExploredOrEventHappens(lua_State* L, Player* player) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + + player->AreaExploredOrEventHappens(questId); + return 0; + } + + int CanShareQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->CanShareQuest(entry)); + return 1; + } + + int HasQuestForGO(lua_State* L, Player* player) + { + + int32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasQuestForGO(entry)); + return 1; + } + + int HasQuestForItem(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasQuestForItem(entry)); + return 1; + } + + int GetReqKillOrCastCurrentCount(lua_State* L, Player* player) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + int32 entry = sEluna->CHECKVAL(L, 3); + + sEluna->Push(L, player->GetReqKillOrCastCurrentCount(questId, entry)); + return 1; + } + + /*int RemoveRewardedQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->RemoveRewardedQuest(entry); + return 0; + }*/ + + /*int RemoveActiveQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->RemoveActiveQuest(entry); + return 0; + }*/ + + int SetQuestStatus(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + uint32 status = sEluna->CHECKVAL(L, 3); + if (status >= MAX_QUEST_STATUS) + return 0; + + player->SetQuestStatus(entry, (QuestStatus)status); + return 0; + } + + int GetQuestStatus(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetQuestStatus(entry)); + return 1; + } + + int GetQuestRewardStatus(lua_State* L, Player* player) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->GetQuestRewardStatus(questId)); + return 1; + } + + int FailQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->FailQuest(entry); + return 0; + } + + int IncompleteQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->IncompleteQuest(entry); + return 0; + } + + int CompleteQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + player->CompleteQuest(entry); + return 0; + } + + int IsActiveQuest(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->IsActiveQuest(entry)); + return 1; + } + + int GetQuestLevel(lua_State* L, Player* player) + { + Quest* quest = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, player->GetQuestOrPlayerLevel(quest)); + return 1; + } + + int GetEquippedItemBySlot(lua_State* L, Player* player) + { + uint8 slot = sEluna->CHECKVAL(L, 2); + if (slot >= EQUIPMENT_SLOT_END) + return 0; + + Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + sEluna->Push(L, item); + return 1; + } + + int Whisper(lua_State* L, Player* player) + { + std::string text = sEluna->CHECKVAL(L, 2); + uint32 lang = sEluna->CHECKVAL(L, 3); + uint64 guid = sEluna->CHECKVAL(L, 4); + + player->Whisper(text, lang, uint64(guid)); + return 0; + } + + int TextEmote(lua_State* L, Player* player) + { + std::string text = sEluna->CHECKVAL(L, 2); + + player->TextEmote(text); + return 0; + } + + int Yell(lua_State* L, Player* player) + { + std::string text = sEluna->CHECKVAL(L, 2); + uint32 lang = sEluna->CHECKVAL(L, 3); + + player->Yell(text, lang); + return 0; + } + + int Say(lua_State* L, Player* player) + { + std::string text = sEluna->CHECKVAL(L, 2); + uint32 lang = sEluna->CHECKVAL(L, 3); + + player->Say(text, lang); + return 0; + } + + /*int SummonPet(lua_State* L, Player* player) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + float o = sEluna->CHECKVAL(L, 6); + uint32 petType = sEluna->CHECKVAL(L, 7); + uint32 despwtime = sEluna->CHECKVAL(L, 8); + + if (petType >= MAX_PET_TYPE) + return 0; + + player->SummonPet(entry, x, y, z, o, (PetType)petType, despwtime); + return 0; + }*/ + + /*int RemovePet(lua_State* L, Player* player) + { + int mode = sEluna->CHECKVAL(L, 2, PET_SAVE_AS_DELETED); + bool returnreagent = sEluna->CHECKVAL(L, 2, false); + + if (!player->GetPet()) + return 0; + + player->RemovePet(player->GetPet(), (PetSaveMode)mode, returnreagent); + return 0; + }*/ + + int GetRestType(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetRestType()); + return 1; + } + + int SetRestType(lua_State* L, Player* player) + { + int type = sEluna->CHECKVAL(L, 2); + + player->SetRestType((RestType)type); + return 0; + } + + int SetRestBonus(lua_State* L, Player* player) + { + float bonus = sEluna->CHECKVAL(L, 2); + + player->SetRestBonus(bonus); + return 0; + } + + int GetRestBonus(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetRestBonus()); + return 1; + } + + int GiveLevel(lua_State* L, Player* player) + { + uint8 level = sEluna->CHECKVAL(L, 2); + + player->GiveLevel(level); + return 0; + } + + int GiveXP(lua_State* L, Player* player) + { + uint32 xp = sEluna->CHECKVAL(L, 2); + Unit* victim = sEluna->CHECKOBJ(L, 3, false); + bool pureXP = sEluna->CHECKVAL(L, 4, true); + bool triggerHook = sEluna->CHECKVAL(L, 5, true); + + if (xp < 1) + return 0; + + if (!player->isAlive()) + return 0; + + uint32 level = player->getLevel(); + + if (triggerHook) + sHookMgr->OnGiveXP(player, xp, victim); + + // XP to money conversion processed in Player::RewardQuest + if (level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + return 0; + + if (!pureXP) + { + if (victim) + { + // handle SPELL_AURA_MOD_KILL_XP_PCT auras + Unit::AuraList const& ModXPPctAuras = player->GetAurasByType(SPELL_AURA_MOD_XP_PCT); + for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i) + xp = uint32(xp * (1.0f + (*i)->GetModifier()->m_amount / 100.0f)); + } + } + + // XP resting bonus for kill + uint32 rested_bonus_xp = victim ? player->GetXPRestBonus(xp) : 0; + + player->SendLogXPGain(xp, victim, rested_bonus_xp, false); + + uint32 curXP = player->GetUInt32Value(PLAYER_XP); + uint32 nextLvlXP = player->GetUInt32Value(PLAYER_NEXT_LEVEL_XP); + uint32 newXP = curXP + xp + rested_bonus_xp; + + while (newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + newXP -= nextLvlXP; + + if (level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + player->GiveLevel(level + 1); + + level = player->getLevel(); + nextLvlXP = player->GetUInt32Value(PLAYER_NEXT_LEVEL_XP); + } + + player->SetUInt32Value(PLAYER_XP, newXP); + return 0; + } + + int IsGMVisible(lua_State* L, Player* player) + { + sEluna->Push(L, player->isGMVisible()); + return 1; + } + + int IsTaxiCheater(lua_State* L, Player* player) + { + sEluna->Push(L, player->isTaxiCheater()); + return 1; + } + + int IsGMChat(lua_State* L, Player* player) + { + sEluna->Push(L, player->isGMChat()); + return 1; + } + + int IsAcceptingWhispers(lua_State* L, Player* player) + { + sEluna->Push(L, player->isAcceptWhispers()); + return 1; + } + + int SetAcceptWhispers(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetAcceptWhispers(on); + return 0; + } + + int SetPvPDeath(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetPvPDeath(on); + return 0; + } + + int SetGMVisible(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetGMVisible(on); + return 0; + } + + int SetTaxiCheat(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetTaxiCheater(on); + return 0; + } + + int SetGMChat(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetGMChat(on); + return 0; + } + + int SetGameMaster(lua_State* L, Player* player) + { + bool on = sEluna->CHECKVAL(L, 2, true); + + player->SetGameMaster(on); + return 0; + } + + int GetChatTag(lua_State* L, Player* player) + { + sEluna->Push(L, player->chatTag()); + return 1; + } + + int IsDND(lua_State* L, Player* player) + { + sEluna->Push(L, player->isDND()); + return 1; + } + + int IsAFK(lua_State* L, Player* player) + { + sEluna->Push(L, player->isAFK()); + return 1; + } + + int ToggleDND(lua_State* L, Player* player) + { + player->ToggleDND(); + return 0; + } + + int ToggleAFK(lua_State* L, Player* player) + { + player->ToggleAFK(); + return 0; + } + /*int GetNearbyGameObject(lua_State* L, Player* player) + { + sEluna->Push(L, ChatHandler(player->GetSession()).GetNearbyGameObject()); + return 1; + }*/ + + int EquipItem(lua_State* L, Player* player) + { + uint16 dest = 0; + Item* item = sEluna->CHECKOBJ(L, 2, false); + uint32 slot = sEluna->CHECKVAL(L, 3); + + if (slot >= INVENTORY_SLOT_BAG_END) + return 0; + + if (!item) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + item = Item::CreateItem(entry, 1, player); + if (!item) + return 0; + + uint8 result = player->CanEquipItem(slot, dest, item, false); + if (result != EQUIP_ERR_OK) + { + delete item; + return 0; + } + player->ItemAddedQuestCheck(entry, 1); + } + else + { + uint8 result = player->CanEquipItem(slot, dest, item, false); + if (result != EQUIP_ERR_OK) + return 0; + player->RemoveItem(item->GetBagSlot(), item->GetSlot(), true); + } + + sEluna->Push(L, player->EquipItem(dest, item, true)); + return 1; + } + + int CanEquipItem(lua_State* L, Player* player) + { + Item* item = sEluna->CHECKOBJ(L, 2, false); + uint32 slot = sEluna->CHECKVAL(L, 3); + if (slot >= EQUIPMENT_SLOT_END) + { + sEluna->Push(L, false); + return 1; + } + + if (!item) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + uint16 dest; + uint8 msg = player->CanEquipNewItem(slot, dest, entry, false); + if (msg != EQUIP_ERR_OK) + { + sEluna->Push(L, false); + return 1; + } + } + else + { + uint16 dest; + uint8 msg = player->CanEquipItem(slot, dest, item, false); + if (msg != EQUIP_ERR_OK) + { + sEluna->Push(L, false); + return 1; + } + } + sEluna->Push(L, true); + return 1; + } + + int GetItemByPos(lua_State* L, Player* player) + { + /* + bag = -1 for inventory and backpack, 19-22 other bags + slots 0-18 equipment + slots 19-22 bags + slots 23-38 backpack + slots 0-35 other bags + */ + uint8 bag = sEluna->CHECKVAL(L, 2); + uint8 slot = sEluna->CHECKVAL(L, 3); + + sEluna->Push(L, player->GetItemByPos(bag, slot)); + return 1; + } + + int GetArenaPoints(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetArenaPoints()); + return 1; + } + + int SetGender(lua_State* L, Player* player) + { + uint32 _gender = sEluna->CHECKVAL(L, 2); + + Gender gender; + switch (_gender) + { + case 0: + gender = GENDER_MALE; + break; + case 1: + gender = GENDER_FEMALE; + break; + default: + return luaL_argerror(L, 2, "valid Gender expected"); + } + + player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); + player->SetByteValue(PLAYER_BYTES_3, 0, gender); + return 0; + } + + int GetHonorPoints(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetHonorPoints()); + return 1; + } + + int GetSelection(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetMap()->GetUnit(player->GetSelection())); + return 1; + } + + int GetGMRank(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetPermissions()); + return 1; + } + + int GetCoinage(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetMoney()); + return 1; + } + + int GetGuildId(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetGuildId()); + return 1; + } + + int GetTeam(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetTeamId()); + return 1; + } + + int GetItemCount(lua_State* L, Player* player) + { + int id = sEluna->CHECKVAL(L, 2); + bool checkinBank = sEluna->CHECKVAL(L, 3, false); + sEluna->Push(L, player->GetItemCount(id, checkinBank)); + return 1; + } + + int GetLifetimeKills(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); + return 1; + } + + int GetPlayerIP(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetRemoteAddress()); + return 1; + } + + int GetLevelPlayedTime(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetLevelPlayedTime()); + return 1; + } + + int GetTotalPlayedTime(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetTotalPlayedTime()); + return 1; + } + + int GetGuild(lua_State* L, Player* player) + { + sEluna->Push(L, sGuildMgr.GetGuildById(player->GetGuildId())); + return 1; + } + + int GetGroup(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetGroup()); + return 1; + } + + int SetLifetimeKills(lua_State* L, Player* player) + { + uint32 val = sEluna->CHECKVAL(L, 2); + player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, val); + return 0; + } + + int SetCoinage(lua_State* L, Player* player) + { + uint32 amt = sEluna->CHECKVAL(L, 2); + player->SetMoney(amt); + return 0; + } + + int SetKnownTitle(lua_State* L, Player* player) + { + uint32 id = sEluna->CHECKVAL(L, 2); + CharTitlesEntry const* t = sCharTitlesStore.LookupEntry(id); + if (t) + player->SetTitle(t); + return 0; + } + + int AdvanceSkillsToMax(lua_State* L, Player* player) + { + player->UpdateSkillsToMaxSkillsForLevel(); + return 0; + } + + int AdvanceAllSkills(lua_State* L, Player* player) + { + uint32 step = sEluna->CHECKVAL(L, 2); + + if (!step) + return 0; + + static const uint32 skillsArray[] = { SKILL_BOWS, SKILL_CROSSBOWS, SKILL_DAGGERS, SKILL_DEFENSE, SKILL_UNARMED, SKILL_GUNS, SKILL_AXES, SKILL_MACES, SKILL_SWORDS, SKILL_POLEARMS, + SKILL_STAVES, SKILL_2H_AXES, SKILL_2H_MACES, SKILL_2H_SWORDS, SKILL_WANDS, SKILL_SHIELD, SKILL_FISHING, SKILL_MINING, SKILL_ENCHANTING, SKILL_BLACKSMITHING, + SKILL_ALCHEMY, SKILL_HERBALISM, SKILL_ENGINERING, SKILL_JEWELCRAFTING, SKILL_LEATHERWORKING, SKILL_LOCKPICKING, SKILL_SKINNING, SKILL_TAILORING, + }; + static const uint32 skillsSize = sizeof(skillsArray) / sizeof(*skillsArray); + + for (int i = 0; i < skillsSize; ++i) + { + if (player->HasSkill(skillsArray[i])) + player->UpdateSkill(skillsArray[i], step); + } + return 0; + } + + int AdvanceSkill(lua_State* L, Player* player) + { + uint32 _skillId = sEluna->CHECKVAL(L, 2); + uint32 _step = sEluna->CHECKVAL(L, 3); + if (_skillId && _step) + { + if (player->HasSkill(_skillId)) + player->UpdateSkill(_skillId, _step); + } + return 0; + } + + int IsInGroup(lua_State* L, Player* player) + { + sEluna->Push(L, (player->GetGroup() != NULL)); + return 1; + } + + int IsInGuild(lua_State* L, Player* player) + { + sEluna->Push(L, (player->GetGuildId() != 0)); + return 1; + } + + int IsGM(lua_State* L, Player* player) + { +#ifdef MANGOS + sEluna->Push(L, player->isGameMaster()); +#else + sEluna->Push(L, player->IsGameMaster()); +#endif + return 1; + } + + int IsInArenaTeam(lua_State* L, Player* player) + { + uint32 type = sEluna->CHECKVAL(L, 2); + if (type < MAX_ARENA_SLOT && player->GetArenaTeamId(type)) + sEluna->Push(L, true); + else + sEluna->Push(L, false); + return 1; + } + + int IsHorde(lua_State* L, Player* player) + { + sEluna->Push(L, (player->GetTeam() == HORDE)); + return 1; + } + + int IsAlliance(lua_State* L, Player* player) + { + sEluna->Push(L, (player->GetTeam() == ALLIANCE)); + return 1; + } + + int HasTitle(lua_State* L, Player* player) + { + uint32 id = sEluna->CHECKVAL(L, 2); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (titleInfo) + sEluna->Push(L, player->HasTitle(titleInfo)); + else + sEluna->Push(L, false); + return 1; + } + + int HasItem(lua_State* L, Player* player) + { + uint32 itemId = sEluna->CHECKVAL(L, 2); + uint32 count = sEluna->CHECKVAL(L, 3, 1); + bool check_bank = sEluna->CHECKVAL(L, 4, false); + sEluna->Push(L, player->HasItemCount(itemId, count, check_bank)); + return 1; + } + + int Teleport(lua_State* L, Player* player) + { + uint32 mapId = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + float o = sEluna->CHECKVAL(L, 6); +#ifdef MANGOS + if (player->IsTaxiFlying()) +#else + if (player->IsInFlight()) +#endif + { + player->GetMotionMaster()->MovementExpired(); + player->m_taxi.ClearTaxiDestinations(); + } + sEluna->Push(L, player->TeleportTo(mapId, x, y, z, o)); + return 1; + } + + int AddLifetimeKills(lua_State* L, Player* player) + { + uint32 val = sEluna->CHECKVAL(L, 2); + uint32 currentKills = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS); + player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val); + return 0; + } + + int RemoveItem(lua_State* L, Player* player) + { + Item* item = sEluna->CHECKOBJ(L, 2, false); + uint32 itemCount = sEluna->CHECKVAL(L, 3); + if (!item) + { + uint32 itemId = sEluna->CHECKVAL(L, 2); + player->DestroyItemCount(itemId, itemCount, true); + } + else + player->DestroyItemCount(item, itemCount, true); + return 0; + } + + int RemoveLifetimeKills(lua_State* L, Player* player) + { + uint32 val = sEluna->CHECKVAL(L, 2); + uint32 currentKills = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS); + if (val > currentKills) + val = currentKills; + player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills - val); + return 0; + } + + int ResetSpellCooldown(lua_State* L, Player* player) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + bool update = sEluna->CHECKVAL(L, 3, true); + player->RemoveSpellCooldown(spellId, update); + return 0; + } + + int ResetTypeCooldowns(lua_State* L, Player* player) + { + uint32 category = sEluna->CHECKVAL(L, 2); + bool update = sEluna->CHECKVAL(L, 3, true); + player->RemoveSpellCooldown(category, update); + return 0; + } + + int ResetAllCooldowns(lua_State* L, Player* player) + { + player->RemoveAllSpellCooldown(); + return 0; + } + + int SendBroadcastMessage(lua_State* L, Player* player) + { + const char* message = sEluna->CHECKVAL(L, 2); + if (std::string(message).length() > 0) + ChatHandler(player->GetSession()).SendSysMessage(message); + return 0; + } + + int SendAreaTriggerMessage(lua_State* L, Player* player) + { + const char* msg = sEluna->CHECKVAL(L, 2); + if (std::string(msg).length() > 0) + player->GetSession()->SendAreaTriggerMessage(msg); + return 0; + } + + int SendNotification(lua_State* L, Player* player) + { + const char* msg = sEluna->CHECKVAL(L, 2); + if (std::string(msg).length() > 0) + player->GetSession()->SendNotification(msg); + return 0; + } + + int SendPacketToPlayer(lua_State* L, Player* player) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + player->GetSession()->SendPacket(data); + return 0; + } + + int SendPacket(lua_State* L, Player* player) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + bool selfOnly = sEluna->CHECKVAL(L, 3, true); + if (selfOnly) + player->GetSession()->SendPacket(data); + else + player->BroadcastPacket(data, true); + return 0; + } + + int SendVendorWindow(lua_State* L, Player* player) + { + Unit* sendTo = sEluna->CHECKOBJ(L, 2); + player->GetSession()->SendListInventory(sendTo->GetGUID()); + return 0; + } + + int KickPlayer(lua_State* L, Player* player) + { + player->GetSession()->KickPlayer(); + return 0; + } + + int ModifyMoney(lua_State* L, Player* player) + { + int32 amt = sEluna->CHECKVAL(L, 2); + + player->ModifyMoney(amt); + return 1; + } + + int LearnSpell(lua_State* L, Player* player) + { + uint32 id = sEluna->CHECKVAL(L, 2); + player->learnSpell(id); + return 0; + } + + int ResurrectPlayer(lua_State* L, Player* player) + { + float percent = sEluna->CHECKVAL(L, 2, 100.0f); + bool sickness = sEluna->CHECKVAL(L, 3, false); + player->ResurrectPlayer(percent, sickness); + player->SpawnCorpseBones(); + return 0; + } + + int GetAccountId(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetAccountId()); + return 1; + } + + int GetAccountName(lua_State* L, Player* player) + { + std::string accName; + if (AccountMgr::GetName(player->GetSession()->GetAccountId(), accName)) + sEluna->Push(L, accName); + else + return 0; + return 1; + } + + int GetCorpse(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetCorpse()); + return 1; + } + + int GossipMenuAddItem(lua_State* L, Player* player) + { + uint32 _icon = sEluna->CHECKVAL(L, 2); + const char* msg = sEluna->CHECKVAL(L, 3); + uint32 _sender = sEluna->CHECKVAL(L, 4); + uint32 _intid = sEluna->CHECKVAL(L, 5); + bool _code = sEluna->CHECKVAL(L, 6, false); + const char* _promptMsg = sEluna->CHECKVAL(L, 7, ""); + uint32 _money = sEluna->CHECKVAL(L, 8, 0); +#ifdef MANGOS + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _money, _code); +#else + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code); +#endif + return 0; + } + + int GossipComplete(lua_State* L, Player* player) + { +#ifdef MANGOS + player->PlayerTalkClass->CloseGossip(); +#else + player->PlayerTalkClass->SendCloseGossip(); +#endif + return 0; + } + + int GossipSendMenu(lua_State* L, Player* player) + { + uint32 _npcText = sEluna->CHECKVAL(L, 2); + WorldObject* sender = sEluna->CHECKOBJ(L, 3); + player->PlayerTalkClass->SendGossipMenu(_npcText, sender->GetGUID()); + return 0; + } + + int GossipClearMenu(lua_State* L, Player* player) + { + player->PlayerTalkClass->ClearMenus(); + return 0; + } + + int PlaySoundToPlayer(lua_State* L, Player* player) + { + uint32 soundId = sEluna->CHECKVAL(L, 2); + SoundEntriesEntry const* soundEntry = sSoundEntriesStore.LookupEntry(soundId); + if (!soundEntry) + return 0; + + player->PlayDirectSound(soundId, player); + return 0; + } + + int StartTaxi(lua_State* L, Player* player) + { + uint32 pathId = sEluna->CHECKVAL(L, 2); + + LuaTaxiMgr::StartTaxi(player, pathId); + return 0; + } + + int SetPlayerLock(lua_State* L, Player* player) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + + if (apply) + { + player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); + player->SetClientControl(player, 0); + } + else + { + player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); + player->SetClientControl(player, 1); + } + return 0; + } + + int GossipSendPOI(lua_State* L, Player* player) + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + uint32 icon = sEluna->CHECKVAL(L, 4); + uint32 flags = sEluna->CHECKVAL(L, 5); + uint32 data = sEluna->CHECKVAL(L, 6); + std::string iconText = sEluna->CHECKVAL(L, 6); + + WorldPacket packet(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); + packet << flags; + packet << x; + packet << y; + packet << icon; + packet << data; + packet << iconText; + player->GetSession()->SendPacket(&packet); + return 0; + } + + int GossipAddQuests(lua_State* L, Player* player) + { + WorldObject* source = sEluna->CHECKOBJ(L, 2); + + if (source->GetTypeId() == TYPEID_UNIT) + { + if (source->GetUInt32Value(UNIT_NPC_FLAGS) & UNIT_NPC_FLAG_QUESTGIVER) + player->PrepareQuestMenu(source->GetGUID()); + } + else if (source->GetTypeId() == TYPEID_GAMEOBJECT) + { + if (source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) + player->PrepareQuestMenu(source->GetGUID()); + } + return 0; + } + + int SendQuestTemplate(lua_State* L, Player* player) + { + uint32 questId = sEluna->CHECKVAL(L, 2); + bool activeAccept = sEluna->CHECKVAL(L, 3, true); + + Quest const* quest = sObjectMgr.GetQuestTemplate(questId); + if (!quest) + return 0; + + player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GetGUID(), activeAccept); + return 0; + } + + int SpawnBones(lua_State* L, Player* player) + { + player->SpawnCorpseBones(); + return 0; + } + + int RemovedInsignia(lua_State* L, Player* player) + { + Player* looter = sEluna->CHECKOBJ(L, 2); + player->RemovedInsignia(looter); + return 0; + } + + int GetDbLocaleIndex(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetSessionDbLocaleIndex()); + return 1; + } + + int GetDbcLocale(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSession()->GetSessionDbcLocale()); + return 1; + } + + int CanUseItem(lua_State* L, Player* player) + { + Item* item = sEluna->CHECKOBJ(L, 2, false); + if (item) + sEluna->Push(L, player->CanUseItem(item)); + else + { + uint32 entry = sEluna->CHECKVAL(L, 2); + const ItemPrototype* temp = sObjectMgr.GetItemPrototype(entry); + if (temp) + sEluna->Push(L, player->CanUseItem(temp)); + else + sEluna->Push(L, EQUIP_ERR_ITEM_NOT_FOUND); + } + return 1; + } + + int HasSpellCooldown(lua_State* L, Player* player) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, player->HasSpellCooldown(spellId)); + return 1; + } + + int GetShieldBlockValue(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetShieldBlockValue()); + return 1; + } + + int IsInWater(lua_State* L, Player* player) + { + sEluna->Push(L, player->IsInWater()); + return 1; + } + + int SetSheath(lua_State* L, Player* player) + { + uint32 sheathed = sEluna->CHECKVAL(L, 2); + if (sheathed >= MAX_SHEATH_STATE) + return 0; + + player->SetSheath((SheathState)sheathed); + return 0; + } + + int CanFly(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanFly()); + return 1; + } + + int IsMoving(lua_State* L, Player* player) // enable for unit when mangos support it + { + sEluna->Push(L, player->isMoving()); + return 1; + } + + int IsFlying(lua_State* L, Player* player) // enable for unit when mangos support it + { + sEluna->Push(L, player->IsFlying()); + return 1; + } + +#ifndef TBC + int HasTalent(lua_State* L, Player* player) + { + uint32 talentId = sEluna->CHECKVAL(L, 2); + uint8 spec = sEluna->CHECKVAL(L, 3); + if (spec >= MAX_TALENT_SPECS) + sEluna->Push(L, false); + else + sEluna->Push(L, player->HasTalent(talentId, spec)); + return 1; + } + + int GetPhaseMaskForSpawn(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetPhaseMaskForSpawn()); + return 1; + } + + int CanTitanGrip(lua_State* L, Player* player) + { + sEluna->Push(L, player->CanTitanGrip()); + return 1; + } + + int GetSpecsCount(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetSpecsCount()); + return 1; + } + + int GetActiveSpec(lua_State* L, Player* player) + { + sEluna->Push(L, player->GetActiveSpec()); + return 1; + } + + int ResetPetTalents(lua_State* L, Player* player) + { +#ifdef MANGOS + Pet* pet = player->GetPet(); + Pet::resetTalentsForAllPetsOf(player, pet); + if (pet) + player->SendTalentsInfoData(true); +#else + player->ResetPetTalents(); + player->SendTalentsInfoData(true); +#endif + return 0; + } + + int ResetAchievements(lua_State* L, Player* player) + { +#ifdef MANGOS + player->GetAchievementMgr().Reset(); +#else + player->ResetAchievements(); +#endif + return 0; + } + + int HasAchieved(lua_State* L, Player* player) + { + uint32 achievementId = sEluna->CHECKVAL(L, 2); + +#ifdef MANGOS + sEluna->Push(L, player->GetAchievementMgr().HasAchievement(achievementId)); +#else + sEluna->Push(L, player->HasAchieved(achievementId)); +#endif + return 1; + } + + int SendMailMenu(lua_State* L, Player* player) + { + GameObject* object = sEluna->CHECKOBJ(L, 2); + + WorldPacket data(SMSG_SHOW_MAILBOX, 8); + data << uint64(object->GetGUIDLow()); + player->GetSession()->HandleGetMailList(data); + return 0; + } +#endif +}; +#endif diff --git a/src/game/luaengine/QueryMethods.h b/src/game/luaengine/QueryMethods.h new file mode 100644 index 000000000..6eaf35f60 --- /dev/null +++ b/src/game/luaengine/QueryMethods.h @@ -0,0 +1,165 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef QUERYMETHODS_H +#define QUERYMETHODS_H + +#ifdef MANGOS +#define RESULT result +#else +#define RESULT (*result) +#endif +namespace LuaQuery +{ + int NextRow(lua_State* L, QueryResult* result) + { + if (!result) + sEluna->Push(L, false); + else + sEluna->Push(L, RESULT->NextRow()); + return 1; + } + + int GetColumnCount(lua_State* L, QueryResult* result) + { + if (!result) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->GetFieldCount()); + return 1; + } + + int GetRowCount(lua_State* L, QueryResult* result) + { + if (!result) + sEluna->Push(L, 0); + else + { + if (RESULT->GetRowCount() > (uint32) - 1) + sEluna->Push(L, (uint32) - 1); + else + sEluna->Push(L, RESULT->GetRowCount()); + } + return 1; + } + + int IsNull(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, true); + else +#ifdef MANGOS + sEluna->Push(L, RESULT->Fetch()[col].IsNULL()); +#else + sEluna->Push(L, RESULT->Fetch()[col].IsNull()); +#endif + return 1; + } + + int GetBool(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, false); + else + sEluna->Push(L, RESULT->Fetch()[col].GetBool()); + return 1; + } + + int GetUInt8(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetUInt8()); + return 1; + } + + int GetUInt16(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetUInt16()); + return 1; + } + + int GetUInt32(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetUInt32()); + return 1; + } + + int GetUInt64(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetUInt64()); + return 1; + } + + int GetInt16(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetInt16()); + return 1; + } + + int GetInt32(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetInt32()); + return 1; + } + + int GetInt64(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0); + else + sEluna->Push(L, RESULT->Fetch()[col].GetInt64()); + return 1; + } + + int GetFloat(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, 0.0f); + else + sEluna->Push(L, RESULT->Fetch()[col].GetFloat()); + return 1; + } + + int GetString(lua_State* L, QueryResult* result) + { + uint32 col = sEluna->CHECKVAL(L, 2); + if (!result || col >= RESULT->GetFieldCount()) + sEluna->Push(L, ""); + else + sEluna->Push(L, RESULT->Fetch()[col].GetString()); + return 1; + } +}; +#undef RESULT + +#endif diff --git a/src/game/luaengine/QuestMethods.h b/src/game/luaengine/QuestMethods.h new file mode 100644 index 000000000..b4fa65a8e --- /dev/null +++ b/src/game/luaengine/QuestMethods.h @@ -0,0 +1,92 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef QUESTMETHODS_H +#define QUESTMETHODS_H + +namespace LuaQuest +{ + int GetId(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetQuestId()); + return 1; + } + + int GetLevel(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetQuestLevel()); + return 1; + } + + /*int GetMaxLevel(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetMaxLevel()); + return 1; + }*/ + + int GetMinLevel(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetMinLevel()); + return 1; + } + + int GetNextQuestId(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetNextQuestId()); + return 1; + } + + int GetPrevQuestId(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetPrevQuestId()); + return 1; + } + + int GetNextQuestInChain(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetNextQuestInChain()); + return 1; + } + + int GetFlags(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetFlags()); + return 1; + } + + int GetType(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->GetType()); + return 1; + } + + int HasFlag(lua_State* L, Quest* quest) + { + uint32 flag = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, quest->HasFlag(flag)); + return 1; + } + + int IsDaily(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->IsDaily()); + return 1; + } + + int IsRepeatable(lua_State* L, Quest* quest) + { + sEluna->Push(L, quest->IsRepeatable()); + return 1; + } + + int SetFlag(lua_State* L, Quest* quest) + { + uint32 flag = sEluna->CHECKVAL(L, 2); + quest->SetFlag(flag); + return 0; + } +}; +#endif diff --git a/src/game/luaengine/SpellMethods.h b/src/game/luaengine/SpellMethods.h new file mode 100644 index 000000000..9e3e181b9 --- /dev/null +++ b/src/game/luaengine/SpellMethods.h @@ -0,0 +1,98 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef SPELLMETHODS_H +#define SPELLMETHODS_H + +namespace LuaSpell +{ + int GetCaster(lua_State* L, Spell* spell) + { + sEluna->Push(L, spell->GetCaster()); + return 1; + } + + int GetCastTime(lua_State* L, Spell* spell) + { + sEluna->Push(L, spell->GetCastTime()); + return 1; + } + + int GetId(lua_State* L, Spell* spell) + { + sEluna->Push(L, spell->GetSpellEntry()->Id); + return 1; + } + + int GetPowerCost(lua_State* L, Spell* spell) + { + sEluna->Push(L, spell->GetPowerCost()); + return 1; + } + + int Cast(lua_State* L, Spell* spell) + { + bool skipCheck = sEluna->CHECKVAL(L, 2); + spell->cast(skipCheck); + return 0; + } + + int IsAutoRepeat(lua_State* L, Spell* spell) + { + sEluna->Push(L, spell->IsAutoRepeat()); + return 1; + } + + int SetAutoRepeat(lua_State* L, Spell* spell) + { + bool repeat = sEluna->CHECKVAL(L, 2); + spell->SetAutoRepeat(repeat); + return 0; + } + + int cancel(lua_State* L, Spell* spell) + { + spell->cancel(); + return 0; + } + + // Finish() + int Finish(lua_State* L, Spell* spell) + { + spell->finish(); + return 0; + } + + int GetTargetDest(lua_State* L, Spell* spell) + { + + if (!spell->m_targets.HasDst()) + return 0; + + sEluna->Push(L, spell->m_targets.m_destX); + sEluna->Push(L, spell->m_targets.m_destY); + sEluna->Push(L, spell->m_targets.m_destZ); + return 3; + } + + int GetTarget(lua_State* L, Spell* spell) + { + + if (GameObject* target = spell->m_targets.getGOTarget()) + sEluna->Push(sEluna->L, target); + else if (Item* target = spell->m_targets.getItemTarget()) + sEluna->Push(sEluna->L, target); + else if (Corpse* target = spell->m_targets.getCorpseTarget()) + sEluna->Push(sEluna->L, target); + else if (Unit* target = spell->m_targets.getUnitTarget()) + sEluna->Push(sEluna->L, target); + else + sEluna->Push(sEluna->L); + + return 1; + } +}; +#endif diff --git a/src/game/luaengine/UnitMethods.h b/src/game/luaengine/UnitMethods.h new file mode 100644 index 000000000..1b842395f --- /dev/null +++ b/src/game/luaengine/UnitMethods.h @@ -0,0 +1,1323 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef UNITMETHODS_H +#define UNITMETHODS_H + +namespace LuaUnit +{ + int Attack(lua_State* L, Unit* unit) + { + Unit* who = sEluna->CHECKOBJ(L, 2); + bool meleeAttack = sEluna->CHECKVAL(L, 3, false); + + sEluna->Push(L, unit->Attack(who, meleeAttack)); + return 1; + } + + int ClearThreatList(lua_State* L, Unit* unit) + { + unit->getThreatManager().clearReferences(); + return 0; + } + + int SetOwnerGUID(lua_State* L, Unit* unit) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + + unit->SetOwnerGUID(uint64(guid)); + return 0; + } + + int GetOwner(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetOwner()); + return 1; + } + + int GetOwnerGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetOwnerGUID()); + return 1; + } + + int GetMap(lua_State* L, Unit* unit) + { + Map* map = unit->GetMap(); + sEluna->Push(L, map); + return 1; + } + + int Mount(lua_State* L, Unit* unit) + { + uint32 displayId = sEluna->CHECKVAL(L, 2); + + unit->Mount(displayId); + return 0; + } + + int Dismount(lua_State* L, Unit* unit) + { + if (unit->IsMounted()) + { + unit->Unmount(); + unit->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); + } + + return 0; + } + + int IsMounted(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsMounted()); + return 1; + } + + int IsWithinLoS(lua_State* L, Unit* unit) + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + float z = sEluna->CHECKVAL(L, 4); + + sEluna->Push(L, unit->IsWithinLOS(x, y, z)); + return 1; + } + + int IsRooted(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isInRoots() || unit->hasUnitState(UNIT_STAT_ROOT)); + return 1; + } + + int IsFullHealth(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetHealth() == unit->GetMaxHealth()); + return 1; + } + + int IsWithinDistInMap(lua_State* L, Unit* unit) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + float radius = sEluna->CHECKVAL(L, 3); + + sEluna->Push(L, unit->IsWithinDistInMap(obj, radius)); + return 1; + } + + int IsInAccessiblePlaceFor(lua_State* L, Unit* unit) + { + Creature* creature = sEluna->CHECKOBJ(L, 2); + + sEluna->Push(L, unit->isInAccessiblePlacefor(creature)); + return 1; + } + + int GetMountId(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetMountID()); + return 1; + } + + int GetDistance(lua_State* L, Unit* unit) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2, false); + if (obj && obj->IsInWorld()) + sEluna->Push(L, unit->GetDistance(obj)); + else + { + float X = sEluna->CHECKVAL(L, 2); + float Y = sEluna->CHECKVAL(L, 3); + float Z = sEluna->CHECKVAL(L, 4); + sEluna->Push(L, unit->GetDistance(X, Y, Z)); + } + return 1; + } + + int GetCreatorGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCreatorGUID()); + return 1; + } + + int GetMinionGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetPetGUID()); + return 1; + } + + int GetCharmerGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCharmerGUID()); + return 1; + } + + int GetCharmGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCharmGUID()); + return 1; + } + + int GetPetGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetPetGUID()); + return 1; + } + + int GetControllerGUID(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCharmerOrOwnerGUID()); + return 1; + } + + int GetControllerGUIDS(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCharmerOrOwnerOrOwnGUID()); + return 1; + } + + int GetStat(lua_State* L, Unit* unit) + { + uint32 stat = sEluna->CHECKVAL(L, 2); + + if (stat >= MAX_STATS) + return 0; + + sEluna->Push(L, unit->GetStat((Stats)stat)); + return 1; + } + + int GetBaseSpellPower(lua_State* L, Unit* unit) + { + uint32 spellschool = sEluna->CHECKVAL(L, 2); + + if (spellschool >= MAX_SPELL_SCHOOL) + return 0; + + sEluna->Push(L, unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool)); + return 1; + } + + int SetPvP(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + + unit->SetPvP(apply); + return 0; + } + + int IsAuctioneer(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isAuctioner()); + return 1; + } + + int IsGuildMaster(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isGuildMaster()); + return 1; + } + + int IsInnkeeper(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isInnkeeper()); + return 1; + } + + int IsTrainer(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isTrainer()); + return 1; + } + + int IsGossip(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isGossip()); + return 1; + } + + int IsTaxi(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isTaxi()); + return 1; + } + + int IsSpiritHealer(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isSpiritHealer()); + return 1; + } + + int IsSpiritGuide(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isSpiritGuide()); + return 1; + } + + int IsTabardDesigner(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isTabardDesigner()); + return 1; + } + + int IsServiceProvider(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isServiceProvider()); + return 1; + } + + int IsSpiritService(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isSpiritService()); + return 1; + } + + int HealthBelowPct(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->HealthBelowPct(sEluna->CHECKVAL(L, 2))); + return 1; + } + + int HealthAbovePct(lua_State* L, Unit* unit) + { + sEluna->Push(L, !unit->HealthBelowPct(sEluna->CHECKVAL(L, 2))); + return 1; + } + + int Emote(lua_State* L, Unit* unit) + { + unit->HandleEmoteCommand(sEluna->CHECKVAL(L, 2)); + return 0; + } + + int IsUnderWater(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsUnderWater()); + return 1; + } + + int IsInWater(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsInWater()); + return 1; + } + + int GetVictim(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getVictim()); + return 1; + } + + int SendChatMessageToPlayer(lua_State* L, Unit* unit) + { + uint8 type = sEluna->CHECKVAL(L, 2); + uint32 lang = sEluna->CHECKVAL(L, 3); + const char* msg = sEluna->CHECKVAL(L, 4); + Player* target = sEluna->CHECKOBJ(L, 5); + if (type == CHAT_MSG_CHANNEL) + return 0; + + WorldPacket* data = new WorldPacket(); + uint32 messageLength = (uint32)strlen(msg) + 1; + data->Initialize(SMSG_MESSAGECHAT, 100); + *data << (uint8)type; + *data << lang; + *data << unit->GetGUIDLow(); + *data << uint32(0); + *data << unit->GetGUIDLow(); + *data << messageLength; + *data << msg; + if (unit->ToPlayer() && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) + *data << uint8(unit->ToPlayer()->chatTag()); + else + *data << uint8(0); + target->GetSession()->SendPacket(data); + return 0; + } + + int GetCurrentSpell(lua_State* L, Unit* unit) + { + uint32 type = sEluna->CHECKVAL(L, 2); + if (type >= CURRENT_MAX_SPELL) + return luaL_argerror(L, 2, "valid CurrentSpellTypes expected"); + sEluna->Push(L, unit->GetCurrentSpell(CurrentSpellTypes(type))); + return 1; + } + + int GetStandState(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getStandState()); + return 0; + } + + static void PrepareMove(Unit* unit) + { + unit->GetMotionMaster()->MovementExpired(); // Chase + unit->StopMoving(); // Some + unit->GetMotionMaster()->Clear(); // all + } + + int MoveStop(lua_State* L, Unit* unit) + { + unit->StopMoving(); + return 0; + } + + int MoveExpire(lua_State* L, Unit* unit) + { + bool reset = sEluna->CHECKVAL(L, 2, true); + unit->GetMotionMaster()->MovementExpired(reset); + return 0; + } + + int MoveClear(lua_State* L, Unit* unit) + { + bool reset = sEluna->CHECKVAL(L, 2, true); + unit->GetMotionMaster()->Clear(reset); + return 0; + } + + int MoveIdle(lua_State* L, Unit* unit) + { + // PrepareMove(unit); + unit->GetMotionMaster()->MoveIdle(); + return 0; + } + + int MoveRandom(lua_State* L, Unit* unit) + { + float radius = sEluna->CHECKVAL(L, 2); + // PrepareMove(unit); + float x, y, z; + unit->GetPosition(x, y, z); + unit->GetMotionMaster()->MoveRandom(radius); + return 0; + } + + int MoveHome(lua_State* L, Unit* unit) + { + // PrepareMove(unit); + unit->GetMotionMaster()->MoveTargetedHome(); + return 0; + } + + int MoveFollow(lua_State* L, Unit* unit) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + float dist = sEluna->CHECKVAL(L, 3, 0.0f); + float angle = sEluna->CHECKVAL(L, 4, 0.0f); + // PrepareMove(unit); + unit->GetMotionMaster()->MoveFollow(target, dist, angle); + return 0; + } + + int MoveChase(lua_State* L, Unit* unit) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + float dist = sEluna->CHECKVAL(L, 3, 0.0f); + float angle = sEluna->CHECKVAL(L, 4, 0.0f); + // PrepareMove(unit); + unit->GetMotionMaster()->MoveChase(target, dist, angle); + return 0; + } + + int MoveConfused(lua_State* L, Unit* unit) + { + // PrepareMove(unit); + unit->GetMotionMaster()->MoveConfused(); + return 0; + } + + int MoveFleeing(lua_State* L, Unit* unit) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + uint32 time = sEluna->CHECKVAL(L, 3, 0); + // PrepareMove(unit); + unit->GetMotionMaster()->MoveFleeing(target, time); + return 0; + } + + int MoveTo(lua_State* L, Unit* unit) + { + uint32 id = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + bool genPath = sEluna->CHECKVAL(L, 6, true); + // PrepareMove(unit); + unit->GetMotionMaster()->MovePoint(id, x, y, z, genPath); + return 0; + } + + int SetName(lua_State* L, Unit* unit) + { + const char* name = sEluna->CHECKVAL(L, 2); + if (std::string(name).length() > 0) + unit->SetName(name); + return 0; + } + + int SetStunned(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + + unit->SetStunned(apply); + return 0; + } + + int SetRooted(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + unit->SetRooted(apply); + return 0; + } + + int SetConfused(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + unit->SetConfused(apply); + return 0; + } + + int SetFeared(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + unit->SetFeared(apply, nullptr); + return 0; + } + + int SetSpeed(lua_State* L, Unit* unit) + { + uint32 type = sEluna->CHECKVAL(L, 2); + float rate = sEluna->CHECKVAL(L, 3); + bool forced = sEluna->CHECKVAL(L, 4, false); + if (type >= MAX_MOVE_TYPE) + return luaL_argerror(L, 2, "valid UnitMoveType expected"); + unit->SetSpeed((UnitMoveType)type, rate, forced); + return 0; + } + + int GetDisplayId(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetDisplayId()); + return 1; + } + + int GetNativeDisplayId(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetNativeDisplayId()); + return 1; + } + + int GetLevel(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getLevel()); + return 1; + } + + int GetHealth(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetHealth()); + return 1; + } + + int GetPower(lua_State* L, Unit* unit) + { + int type = sEluna->CHECKVAL(L, 2, -1); + if (type == -1) + { + + switch (unit->getClass()) + { + case 1: + type = POWER_RAGE; + break; + case 4: + type = POWER_ENERGY; + break; + case 2: + case 3: + case 5: + case 7: + case 8: + case 9: + case 11: + type = POWER_MANA; + break; + default: + type = POWER_MANA; + } + } + else if (type < 0 || type >= 12) + return luaL_argerror(L, 2, "valid Powers expected"); + + sEluna->Push(L, unit->GetPower((Powers) type)); + return 1; + } + + int GetMaxPower(lua_State* L, Unit* unit) + { + int type = sEluna->CHECKVAL(L, 2, -1); + if (type == -1) + { + + switch (unit->getClass()) + { + case 1: + type = POWER_RAGE; + break; + case 4: + type = POWER_ENERGY; + break; + case 2: + case 3: + case 5: + case 7: + case 8: + case 9: + case 11: + type = POWER_MANA; + break; + default: + type = POWER_MANA; + } + } + else if (type < 0 || type >= 12) + return luaL_argerror(L, 2, "valid Powers expected"); + + sEluna->Push(L, unit->GetMaxPower((Powers) type)); + return 1; + } + + int GetPowerType(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getPowerType()); + return 1; + } + + int GetMaxHealth(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetMaxHealth()); + return 1; + } + + int GetHealthPct(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetHealth()/unit->GetMaxHealth() * 100.0f); + return 1; + } + + int GetPowerPct(lua_State* L, Unit* unit) + { + float percent = (unit->GetPower(unit->getPowerType()) / unit->GetMaxPower(unit->getPowerType())) * 100; + sEluna->Push(L, percent); + return 1; + } + + int GetGender(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getGender()); + return 1; + } + + int GetRace(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getRace()); + return 1; + } + + int GetClass(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getClass()); + return 1; + } + + int GetCreatureType(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCreatureType()); + return 1; + } + + int GetClassAsString(lua_State* L, Unit* unit) + { + const char* str = NULL; + switch (unit->getClass()) + { + case 1: + str = "Warrior"; + break; + case 2: + str = "Paladin"; + break; + case 3: + str = "Hunter"; + break; + case 4: + str = "Rogue"; + break; + case 5: + str = "Priest"; + break; + case 7: + str = "Shaman"; + break; + case 8: + str = "Mage"; + break; + case 9: + str = "Warlock"; + break; + case 11: + str = "Druid"; + break; + default: + str = NULL; + break; + } + + sEluna->Push(L, str); + return 1; + } + + int GetFaction(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->getFaction()); + return 1; + } + + int SetFaction(lua_State* L, Unit* unit) + { + uint32 factionId = sEluna->CHECKVAL(L, 2); + unit->setFaction(factionId); + return 0; + } + + int SetLevel(lua_State* L, Unit* unit) + { + uint32 newLevel = sEluna->CHECKVAL(L, 2); + unit->SetLevel(newLevel); + return 0; + } + + int SetHealth(lua_State* L, Unit* unit) + { + uint32 amt = sEluna->CHECKVAL(L, 2); + unit->SetHealth(amt); + return 0; + } + + int SetMaxHealth(lua_State* L, Unit* unit) + { + uint32 amt = sEluna->CHECKVAL(L, 2); + unit->SetMaxHealth(amt); + return 0; + } + + int SetPower(lua_State* L, Unit* unit) + { + int type = sEluna->CHECKVAL(L, 2); + uint32 amt = sEluna->CHECKVAL(L, 3); + + switch (type) + { + case POWER_MANA: + unit->SetPower(POWER_MANA, amt); + break; + case POWER_RAGE: + unit->SetPower(POWER_RAGE, amt); + break; + case POWER_ENERGY: + unit->SetPower(POWER_ENERGY, amt); + break; + default: + return luaL_argerror(L, 2, "valid Powers expected"); + break; + } + return 0; + } + + int SetMaxPower(lua_State* L, Unit* unit) + { + int type = sEluna->CHECKVAL(L, 2); + uint32 amt = sEluna->CHECKVAL(L, 3); + + switch (type) + { + case POWER_MANA: + unit->SetMaxPower(POWER_MANA, amt); + break; + case POWER_RAGE: + unit->SetMaxPower(POWER_RAGE, amt); + break; + case POWER_ENERGY: + unit->SetMaxPower(POWER_ENERGY, amt); + break; + default: + return luaL_argerror(L, 2, "valid Powers expected"); + break; + } + return 0; + } + + int SetDisplayId(lua_State* L, Unit* unit) + { + uint32 model = sEluna->CHECKVAL(L, 2); + unit->SetDisplayId(model); + return 0; + } + + int SetNativeDisplayId(lua_State* L, Unit* unit) + { + uint32 model = sEluna->CHECKVAL(L, 2); + unit->SetNativeDisplayId(model); + return 0; + } + + int SetFacing(lua_State* L, Unit* unit) + { + float o = sEluna->CHECKVAL(L, 2); + unit->SetFacingTo(o); + return 0; + } + + int SetFacingToObject(lua_State* L, Unit* unit) + { + WorldObject* obj = sEluna->CHECKOBJ(L, 2); + unit->SetFacingToObject(obj); + return 0; + } + + int SetCreatorGUID(lua_State* L, Unit* unit) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + unit->SetOwnerGUID(uint64(guid)); + return 0; + } + + int SetCharmerGUID(lua_State* L, Unit* unit) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + unit->SetCharmerGUID(uint64(guid)); + return 0; + } + + int SetStandState(lua_State* L, Unit* unit) + { + uint8 state = sEluna->CHECKVAL(L, 2); + unit->SetStandState(state); + return 0; + } + + int IsAlive(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isAlive()); + return 1; + } + + int IsDead(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isDead()); + return 1; + } + + int IsDying(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isDying()); + return 1; + } + + int IsBanker(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isBanker()); + return 1; + } + + int IsVendor(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isVendor()); + return 1; + } + + int IsBattleMaster(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isBattleMaster()); + return 1; + } + + int IsCharmed(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isCharmed()); + return 1; + } + + int IsArmorer(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isArmorer()); + return 1; + } + + int IsAttackingPlayer(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isAttackingPlayer()); + return 1; + } + + int IsInWorld(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsInWorld()); + return 1; + } + + int IsPvPFlagged(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsPvP()); + return 1; + } + + int IsInCombat(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isInCombat()); + return 1; + } + + int SendUnitWhisper(lua_State* L, Unit* unit) + { + const char* msg = sEluna->CHECKVAL(L, 2); + Player* receiver = sEluna->CHECKOBJ(L, 3); + bool bossWhisper = sEluna->CHECKVAL(L, 4, false); + if (std::string(msg).length() > 0) + unit->MonsterWhisper(msg, receiver->GetGUID(), bossWhisper); + return 0; + } + + int SendUnitEmote(lua_State* L, Unit* unit) + { + const char* msg = sEluna->CHECKVAL(L, 2); + Unit* receiver = sEluna->CHECKOBJ(L, 3, false); + bool bossEmote = sEluna->CHECKVAL(L, 4, false); + if (std::string(msg).length() > 0) + unit->MonsterTextEmote(msg, receiver->GetGUID(), bossEmote); + return 0; + } + + int SendUnitSay(lua_State* L, Unit* unit) + { + const char* msg = sEluna->CHECKVAL(L, 2); + uint32 language = sEluna->CHECKVAL(L, 3); + if (std::string(msg).length() > 0) + unit->MonsterSay(msg, language, unit->GetGUID()); + return 0; + } + + int SendUnitYell(lua_State* L, Unit* unit) + { + const char* msg = sEluna->CHECKVAL(L, 2); + uint32 language = sEluna->CHECKVAL(L, 3); + if (std::string(msg).length() > 0) + unit->MonsterYell(msg, language, unit->GetGUID()); + return 0; + } + + int DeMorph(lua_State* L, Unit* unit) + { + unit->DeMorph(); + return 0; + } + + int CastSpell(lua_State* L, Unit* unit) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + uint32 spell = sEluna->CHECKVAL(L, 3); + bool triggered = sEluna->CHECKVAL(L, 4, false); + SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell); + if (!spellEntry) + return 0; + + unit->CastSpell(target, spell, triggered); + return 0; + } + + int CastSpellAoF(lua_State* L, Unit* unit) + { + float _x = sEluna->CHECKVAL(L, 2); + float _y = sEluna->CHECKVAL(L, 3); + float _z = sEluna->CHECKVAL(L, 4); + uint32 spell = sEluna->CHECKVAL(L, 5); + bool triggered = sEluna->CHECKVAL(L, 6, true); + unit->CastSpell(_x, _y, _z, spell, triggered); + return 0; + } + + int GetAura(lua_State* L, Unit* unit) + { + uint32 spellID = sEluna->CHECKVAL(L, 2); + sEluna->Push(L, unit->GetAura(spellID, 0)); + return 1; + } + + int GetCombatTime(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->GetCombatTimer()); + return 1; + } + + int ClearInCombat(lua_State* L, Unit* unit) + { + unit->ClearInCombat(); + return 0; + } + + int StopSpellCast(lua_State* L, Unit* unit) + { + uint32 spellId = sEluna->CHECKVAL(L, 2, 0); + unit->CastStop(spellId); + return 0; + } + + int InterruptSpell(lua_State* L, Unit* unit) + { + int spellType = sEluna->CHECKVAL(L, 2); + bool delayed = sEluna->CHECKVAL(L, 3, true); + switch (spellType) + { + case 0: + spellType = CURRENT_MELEE_SPELL; + break; + case 1: + spellType = CURRENT_GENERIC_SPELL; + break; + case 2: + spellType = CURRENT_CHANNELED_SPELL; + break; + case 3: + spellType = CURRENT_AUTOREPEAT_SPELL; + break; + } + unit->InterruptSpell((CurrentSpellTypes)spellType, delayed); + return 0; + } + + int AddAura(lua_State* L, Unit* unit) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + Unit* target = sEluna->CHECKOBJ(L, 3); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) + return 0; + + unit->AddAura(spellId, target); + return 0; + } + + int HasAura(lua_State* L, Unit* unit) + { + uint32 spell = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, unit->HasAura(spell)); + return 1; + } + + int IsStandState(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsStandState()); + return 1; + } + + int RemoveAura(lua_State* L, Unit* unit) + { + uint32 spellId = sEluna->CHECKVAL(L, 2); + unit->RemoveAurasDueToSpell(spellId); + return 0; + } + + int RemoveAllAuras(lua_State* L, Unit* unit) + { + unit->RemoveAllAuras(); + return 0; + } + + int PlayDirectSound(lua_State* L, Unit* unit) + { + uint32 soundId = sEluna->CHECKVAL(L, 2); + Player* player = sEluna->CHECKOBJ(L, 3, false); + if (!sSoundEntriesStore.LookupEntry(soundId)) + return 0; + + if (player) + unit->PlayDirectSound(soundId, player); + else + unit->PlayDirectSound(soundId); + return 0; + } + + int PlayDistanceSound(lua_State* L, Unit* unit) + { + uint32 soundId = sEluna->CHECKVAL(L, 2); + Player* player = sEluna->CHECKOBJ(L, 3, false); + if (!sSoundEntriesStore.LookupEntry(soundId)) + return 0; + + if (player) + unit->PlayDistanceSound(soundId, player); + else + unit->PlayDistanceSound(soundId); + return 0; + } + + int Kill(lua_State* L, Unit* unit) + { + Unit* target = sEluna->CHECKOBJ(L, 2); + bool durLoss = sEluna->CHECKVAL(L, 3, true); + unit->Kill(target, durLoss); + return 0; + } + + int RegisterEvent(lua_State* L, Unit* unit) + { + luaL_checktype(L, 2, LUA_TFUNCTION); + uint32 delay = sEluna->CHECKVAL(L, 3); + uint32 repeats = sEluna->CHECKVAL(L, 4); + + lua_settop(L, 2); + int functionRef = lua_ref(L, true); + functionRef = sEluna->m_EventMgr.AddEvent(&unit->m_Events, functionRef, delay, repeats, unit); + if (functionRef) + sEluna->Push(L, functionRef); + else + sEluna->Push(L); + return 1; + } + + int RemoveEventById(lua_State* L, Unit* unit) + { + int eventId = sEluna->CHECKVAL(L, 2); + sEluna->m_EventMgr.RemoveEvent(&unit->m_Events, eventId); + return 0; + } + + int RemoveEvents(lua_State* L, Unit* unit) + { + sEluna->m_EventMgr.RemoveEvents(&unit->m_Events); + return 0; + } + + int GetFriendlyUnitsInRange(lua_State* L, Unit* unit) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + + std::list list; + + Hellground::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range); + Hellground::UnitListSearcher searcher(list, checker); + Cell::VisitAllObjects(unit, searcher, range); + + Eluna::ObjectGUIDCheck guidCheck(unit->GetGUID()); + list.remove_if(guidCheck); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + + int GetUnfriendlyUnitsInRange(lua_State* L, Unit* unit) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + + std::list list; + + Hellground::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range); + Hellground::UnitListSearcher searcher(list, checker); + Cell::VisitAllObjects(unit, searcher, range); + + Eluna::ObjectGUIDCheck guidCheck(unit->GetGUID()); + list.remove_if(guidCheck); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + + int AttackStop(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->AttackStop()); + return 1; + } + + /*int SetCanFly(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + unit->SetCanFly(apply); + return 0; + }*/ + + /*int SetVisible(lua_State* L, Unit* unit) + { + bool x = sEluna->CHECKVAL(L, 2, true); + unit->SetVisible(x); + return 0; + }*/ + + /*int IsVisible(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsVisible()); + return 1; + }*/ + + /*int IsMoving(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isMoving()); + return 1; + }*/ + + /*int IsFlying(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsFlying()); + return 1; + }*/ + + int IsStopped(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->IsStopped()); + return 1; + } + + int IsQuestGiver(lua_State* L, Unit* unit) + { + sEluna->Push(L, unit->isQuestGiver()); + return 1; + } + + /*int RestoreDisplayId(lua_State* L, Unit* unit) + { + unit->RestoreDisplayId(); + return 0; + }*/ + + /*int RestoreFaction(lua_State* L, Unit* unit) + { + unit->RestoreFaction(); + return 0; + }*/ + + /*int RemoveBindSightAuras(lua_State* L, Unit* unit) + { + unit->RemoveBindSightAuras(); + return 0; + }*/ + + /*int RemoveCharmAuras(lua_State* L, Unit* unit) + { + unit->RemoveCharmAuras(); + return 0; + }*/ + + int AddUnitState(lua_State* L, Unit* unit) + { + uint32 state = sEluna->CHECKVAL(L, 2); + + unit->addUnitState(state); + return 0; + } + + int ClearUnitState(lua_State* L, Unit* unit) + { + uint32 state = sEluna->CHECKVAL(L, 2); + + unit->clearUnitState(state); + return 0; + } + + int HasUnitState(lua_State* L, Unit* unit) + { + uint32 state = sEluna->CHECKVAL(L, 2); + + sEluna->Push(L, unit->hasUnitState(state)); + return 1; + } + + int NearTeleport(lua_State* L, Unit* unit) + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + float z = sEluna->CHECKVAL(L, 4); + float o = sEluna->CHECKVAL(L, 5); + + unit->NearTeleportTo(x, y, z, o); + return 1; + } + + /*int DisableMelee(lua_State* L, Unit* unit) + { + bool apply = sEluna->CHECKVAL(L, 2, true); + + if (apply) + unit->AddUnitState(UNIT_STATE_CANNOT_AUTOATTACK); + else + unit->ClearUnitState(UNIT_STATE_CANNOT_AUTOATTACK); + return 0; + }*/ + + /*int SummonGuardian(lua_State* L, Unit* unit) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + float o = sEluna->CHECKVAL(L, 6); + uint32 desp = sEluna->CHECKVAL(L, 7, 0); + + SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(61); + if (!properties) + return 0; + Position pos; + pos.Relocate(x,y,z,o); + TemporarySummon* summon = unit->GetMap()->SummonCreature(entry, pos, properties, desp, unit); + + if (!summon) + return 0; + + if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) + ((Guardian*)summon)->InitStatsForLevel(unit->getLevel()); + + if (properties && properties->Category == SUMMON_CATEGORY_ALLY) + summon->setFaction(unit->getFaction()); + if (summon->GetEntry() == 27893) + { + if (uint32 weapon = unit->GetUInt32Value(PLAYER_VISIBLE_ITEM_16_ENTRYID)) + { + summon->SetDisplayId(11686); + summon->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, weapon); + } + else + summon->SetDisplayId(1126); + } + summon->AI()->EnterEvadeMode(); + + sEluna->Push(L, summon); + return 1; + }*/ + +}; +#endif diff --git a/src/game/luaengine/WeatherMethods.h b/src/game/luaengine/WeatherMethods.h new file mode 100644 index 000000000..e2c29cd5c --- /dev/null +++ b/src/game/luaengine/WeatherMethods.h @@ -0,0 +1,48 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef WEATHERMETHODS_H +#define WEATHERMETHODS_H + +namespace LuaWeather +{ + int GetZoneId(lua_State* L, Weather* weather) + { + sEluna->Push(L, weather->GetZone()); + return 1; + } + + int SetWeather(lua_State* L, Weather* weather) + { + uint32 weatherType = sEluna->CHECKVAL(L, 2); + float grade = sEluna->CHECKVAL(L, 3); + + weather->SetWeather((WeatherType)weatherType, grade); + return 0; + } + + int SendWeatherUpdateToPlayer(lua_State* L, Weather* weather) + { + Player* player = sEluna->CHECKOBJ(L, 2); + + weather->SendWeatherUpdateToPlayer(player); + return 0; + } + + int Regenerate(lua_State* L, Weather* weather) + { + sEluna->Push(L, weather->ReGenerate()); + return 1; + } + + int UpdateWeather(lua_State* L, Weather* weather) + { + sEluna->Push(L, weather->UpdateWeather()); + return 1; + } +}; + +#endif diff --git a/src/game/luaengine/WorldObjectMethods.h b/src/game/luaengine/WorldObjectMethods.h new file mode 100644 index 000000000..8b539423d --- /dev/null +++ b/src/game/luaengine/WorldObjectMethods.h @@ -0,0 +1,378 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef WORLDOBJECTMETHODS_H +#define WORLDOBJECTMETHODS_H + +namespace LuaWorldObject +{ + static int ToCorpse(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->ToCorpse()); + return 1; + } + static int ToGameObject(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->ToGameObject()); + return 1; + } + static int ToUnit(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->ToUnit()); + return 1; + } + static int ToCreature(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->ToCreature()); + return 1; + } + static int ToPlayer(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->ToPlayer()); + return 1; + } + int GetName(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetName()); + return 1; + } + int GetMap(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetMap()); + return 1; + } + + int GetInstanceId(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetInstanceId()); + return 1; + } + int GetAreaId(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetAreaId()); + return 1; + } + int GetZoneId(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetZoneId()); + return 1; + } + int GetMapId(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetMapId()); + return 1; + } + int GetX(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetPositionX()); + return 1; + } + int GetY(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetPositionY()); + return 1; + } + int GetZ(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetPositionZ()); + return 1; + } + int GetO(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetOrientation()); + return 1; + } + int GetLocation(lua_State* L, WorldObject* obj) + { + sEluna->Push(L, obj->GetPositionX()); + sEluna->Push(L, obj->GetPositionY()); + sEluna->Push(L, obj->GetPositionZ()); + sEluna->Push(L, obj->GetOrientation()); + return 4; + } + int GetNearestPlayer(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + + Unit* target = NULL; + Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER); + + Hellground::UnitLastSearcher searcher(target, checker); + Cell::VisitWorldObjects(obj, searcher, range); + + sEluna->Push(L, target); + return 1; + } + int GetNearestGameObject(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + uint32 entry = sEluna->CHECKVAL(L, 3, 0); + + GameObject* target = NULL; + Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry); + + Hellground::ObjectLastSearcher searcher(target, checker); + Cell::VisitGridObjects(obj, searcher, range); + + sEluna->Push(L, target); + return 1; + } + int GetNearestCreature(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + uint32 entry = sEluna->CHECKVAL(L, 3, 0); + + Creature* target = NULL; + Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry); + + Hellground::ObjectLastSearcher searcher(target, checker); + Cell::VisitGridObjects(obj, searcher, range); + + sEluna->Push(L, target); + return 1; + } + int GetPlayersInRange(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + + std::list list; + Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER); + + Hellground::ObjectListSearcher searcher(list, checker); + Cell::VisitWorldObjects(obj, searcher, range); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + int GetCreaturesInRange(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + uint32 entry = sEluna->CHECKVAL(L, 3, 0); + + std::list list; + Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry); + + Hellground::ObjectListSearcher searcher(list, checker); + Cell::VisitGridObjects(obj, searcher, range); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + int GetGameObjectsInRange(lua_State* L, WorldObject* obj) + { + float range = sEluna->CHECKVAL(L, 2, SIZE_OF_GRIDS); + uint32 entry = sEluna->CHECKVAL(L, 3, 0); + + std::list list; + Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry); + + Hellground::ObjectListSearcher searcher(list, checker); + Cell::VisitGridObjects(obj, searcher, range); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + int GetNearObject(lua_State* L, WorldObject* obj) + { + bool nearest = sEluna->CHECKVAL(L, 2, true); + float range = sEluna->CHECKVAL(L, 3, SIZE_OF_GRIDS); + uint16 type = sEluna->CHECKVAL(L, 4, 0); // TypeMask + uint32 entry = sEluna->CHECKVAL(L, 5, 0); + uint32 hostile = sEluna->CHECKVAL(L, 6, 0); // 0 none, 1 hostile, 2 friendly + + float x, y, z; + obj->GetPosition(x, y, z); + Eluna::WorldObjectInRangeCheck checker(nearest, obj, range, type, entry, hostile); + if (nearest) + { + WorldObject* target = NULL; + + Hellground::ObjectLastSearcher searcher(target, checker); + Cell::VisitAllObjects(obj, searcher, range); + + sEluna->Push(L, target); + return 1; + } + else + { + std::list list; + + Hellground::ObjectListSearcher searcher(list, checker); + Cell::VisitAllObjects(obj, searcher, range); + + lua_newtable(L); + int tbl = lua_gettop(L); + uint32 i = 0; + + for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) + { + sEluna->Push(L, ++i); + sEluna->Push(L, *it); + lua_settable(L, tbl); + } + + lua_settop(L, tbl); + return 1; + } + + return 0; + } + int GetWorldObject(lua_State* L, WorldObject* obj) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + + switch (GUID_HIPART(guid)) + { + case HIGHGUID_PLAYER: sEluna->Push(L, sObjectAccessor.GetPlayer(uint64(guid))); break; + case HIGHGUID_TRANSPORT: + case HIGHGUID_MO_TRANSPORT: + case HIGHGUID_GAMEOBJECT: sEluna->Push(L, obj->GetMap()->GetGameObject(uint64(guid))); break; + case HIGHGUID_UNIT: sEluna->Push(L, obj->GetMap()->GetCreature(uint64(guid))); break; + case HIGHGUID_PET: sEluna->Push(L, sObjectAccessor.GetPet(uint64(guid))); break; + default: return 0; + } + return 1; + } + + int GetDistance(lua_State* L, WorldObject* obj) + { + WorldObject* target = sEluna->CHECKOBJ(L, 2, false); + if (target && target->IsInWorld()) + sEluna->Push(L, obj->GetDistance(target)); + else + { + float X = sEluna->CHECKVAL(L, 2); + float Y = sEluna->CHECKVAL(L, 3); + float Z = sEluna->CHECKVAL(L, 4); + sEluna->Push(L, obj->GetDistance(X, Y, Z)); + } + return 1; + } + + int GetRelativePoint(lua_State* L, WorldObject* obj) + { + float dist = sEluna->CHECKVAL(L, 2); + float rad = sEluna->CHECKVAL(L, 3); + + float x, y, z; + obj->GetNearPoint(x, y, z, 0.0f, dist, rad); + + sEluna->Push(L, x); + sEluna->Push(L, y); + sEluna->Push(L, z); + return 3; + } + + int GetAngle(lua_State* L, WorldObject* obj) + { + WorldObject* target = sEluna->CHECKOBJ(L, 2, false); + + if (target && target->IsInWorld()) + sEluna->Push(L, obj->GetAngle(target)); + else + { + float x = sEluna->CHECKVAL(L, 2); + float y = sEluna->CHECKVAL(L, 3); + sEluna->Push(L, obj->GetAngle(x, y)); + } + return 1; + } + + int SendPacket(lua_State* L, WorldObject* obj) + { + WorldPacket* data = sEluna->CHECKOBJ(L, 2); + obj->BroadcastPacket(data, true); + return 0; + } + + int SummonGameObject(lua_State* L, WorldObject* obj) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + float o = sEluna->CHECKVAL(L, 6); + uint32 respawnDelay = sEluna->CHECKVAL(L, 7, 30); + + sEluna->Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay)); + return 1; + } + + int SpawnCreature(lua_State* L, WorldObject* obj) + { + uint32 entry = sEluna->CHECKVAL(L, 2); + float x = sEluna->CHECKVAL(L, 3); + float y = sEluna->CHECKVAL(L, 4); + float z = sEluna->CHECKVAL(L, 5); + float o = sEluna->CHECKVAL(L, 6); + uint32 spawnType = sEluna->CHECKVAL(L, 7, 8); + uint32 despawnTimer = sEluna->CHECKVAL(L, 8, 0); + + TemporarySummonType type; + switch (spawnType) + { + case 1: + type = TEMPSUMMON_TIMED_OR_DEAD_DESPAWN; + break; + case 2: + type = TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN; + break; + case 3: + type = TEMPSUMMON_TIMED_DESPAWN; + break; + case 5: + type = TEMPSUMMON_CORPSE_DESPAWN; + break; + case 6: + type = TEMPSUMMON_CORPSE_TIMED_DESPAWN; + break; + case 7: + type = TEMPSUMMON_DEAD_DESPAWN; + break; + case 8: + type = TEMPSUMMON_MANUAL_DESPAWN; + break; + default: + return luaL_argerror(L, 7, "valid SpawnType expected"); + } + sEluna->Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer)); + return 1; + } +}; +#endif diff --git a/src/game/luaengine/WorldPacketMethods.h b/src/game/luaengine/WorldPacketMethods.h new file mode 100644 index 000000000..41bed4db6 --- /dev/null +++ b/src/game/luaengine/WorldPacketMethods.h @@ -0,0 +1,207 @@ +/* +* Copyright (C) 2010 - 2014 Eluna Lua Engine +* This program is free software licensed under GPL version 3 +* Please see the included DOCS/LICENSE.TXT for more information +*/ + +#ifndef WORLDPACKETMETHODS_H +#define WORLDPACKETMETHODS_H + +namespace LuaPacket +{ + // GetOpcode() + int GetOpcode(lua_State* L, WorldPacket* packet) + { + sEluna->Push(L, packet->GetOpcode()); + return 1; + } + + // GetSize() + int GetSize(lua_State* L, WorldPacket* packet) + { + sEluna->Push(L, packet->size()); + return 1; + } + + // SetOpcode(opcode) + int SetOpcode(lua_State* L, WorldPacket* packet) + { + uint32 opcode = sEluna->CHECKVAL(L, 2); + if (opcode >= NUM_MSG_TYPES) + return luaL_argerror(L, 2, "valid opcode expected"); + packet->SetOpcode((Opcodes)opcode); + return 0; + } + + // ReadByte() + int ReadByte(lua_State* L, WorldPacket* packet) + { + int8 byte; + (*packet) >> byte; + sEluna->Push(L, byte); + return 1; + } + + // ReadUByte() + int ReadUByte(lua_State* L, WorldPacket* packet) + { + uint8 byte; + (*packet) >> byte; + sEluna->Push(L, byte); + return 1; + } + + // ReadShort() + int ReadShort(lua_State* L, WorldPacket* packet) + { + int16 _short; + (*packet) >> _short; + sEluna->Push(L, _short); + return 1; + } + + // ReadUShort() + int ReadUShort(lua_State* L, WorldPacket* packet) + { + uint16 _ushort; + (*packet) >> _ushort; + sEluna->Push(L, _ushort); + return 1; + } + + // ReadLong() + int ReadLong(lua_State* L, WorldPacket* packet) + { + int32 _long; + (*packet) >> _long; + sEluna->Push(L, _long); + return 1; + } + + // ReadULong() + int ReadULong(lua_State* L, WorldPacket* packet) + { + uint32 _ulong; + (*packet) >> _ulong; + sEluna->Push(L, _ulong); + return 1; + } + + // ReadFloat() + int ReadFloat(lua_State* L, WorldPacket* packet) + { + float _val; + (*packet) >> _val; + sEluna->Push(L, _val); + return 1; + } + + // ReadDouble() + int ReadDouble(lua_State* L, WorldPacket* packet) + { + double _val; + (*packet) >> _val; + sEluna->Push(L, _val); + return 1; + } + + // ReadGUID() + int ReadGUID(lua_State* L, WorldPacket* packet) + { + uint64 guid; + (*packet) >> guid; + sEluna->Push(L, guid); + return 1; + } + + // ReadString() + int ReadString(lua_State* L, WorldPacket* packet) + { + std::string _val; + (*packet) >> _val; + sEluna->Push(L, _val); + return 1; + } + + // WriteGUID(guid) + int WriteGUID(lua_State* L, WorldPacket* packet) + { + uint64 guid = sEluna->CHECKVAL(L, 2); + (*packet) << guid; + return 0; + } + + // WriteString(string) + int WriteString(lua_State* L, WorldPacket* packet) + { + std::string _val = sEluna->CHECKVAL(L, 2); + (*packet) << _val; + return 0; + } + + // WriteBye(byte) + int WriteByte(lua_State* L, WorldPacket* packet) + { + int8 byte = sEluna->CHECKVAL(L, 2); + (*packet) << byte; + return 0; + } + + // WriteUByte(byte) + int WriteUByte(lua_State* L, WorldPacket* packet) + { + uint8 byte = sEluna->CHECKVAL(L, 2); + (*packet) << byte; + return 0; + } + + // WriteUShort(short) + int WriteUShort(lua_State* L, WorldPacket* packet) + { + uint16 _ushort = sEluna->CHECKVAL(L, 2); + (*packet) << _ushort; + return 0; + } + + // WriteShort(short) + int WriteShort(lua_State* L, WorldPacket* packet) + { + int16 _short = sEluna->CHECKVAL(L, 2); + (*packet) << _short; + return 0; + } + + // WriteLong(long) + int WriteLong(lua_State* L, WorldPacket* packet) + { + int32 _long = sEluna->CHECKVAL(L, 2); + (*packet) << _long; + return 0; + } + + // WriteULong(long) + int WriteULong(lua_State* L, WorldPacket* packet) + { + uint32 _ulong = sEluna->CHECKVAL(L, 2); + (*packet) << _ulong; + return 0; + } + + // WriteFloat(float) + int WriteFloat(lua_State* L, WorldPacket* packet) + { + float _val = sEluna->CHECKVAL(L, 2); + (*packet) << _val; + return 0; + } + + // WriteDouble(double) + int WriteDouble(lua_State* L, WorldPacket* packet) + { + double _val = sEluna->CHECKVAL(L, 2); + (*packet) << _val; + return 0; + } +}; + +#endif diff --git a/src/game/movemap/MoveMap.cpp b/src/game/movemap/MoveMap.cpp index c0000b37a..0d87a93be 100644 --- a/src/game/movemap/MoveMap.cpp +++ b/src/game/movemap/MoveMap.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "GridMap.h" diff --git a/src/game/movemap/MoveMap.h b/src/game/movemap/MoveMap.h index 62010a6f8..69fd3f2b5 100644 --- a/src/game/movemap/MoveMap.h +++ b/src/game/movemap/MoveMap.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MOVE_MAP_H -#define _MOVE_MAP_H +#ifndef HELLGROUND_MOVE_MAP_H +#define HELLGROUND_MOVE_MAP_H #include "Utilities/UnorderedMap.h" diff --git a/src/game/movemap/MoveMapSharedDefines.h b/src/game/movemap/MoveMapSharedDefines.h index e9c0b02ae..da5411327 100644 --- a/src/game/movemap/MoveMapSharedDefines.h +++ b/src/game/movemap/MoveMapSharedDefines.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MOVE_MAP_SHARED_DEFINES_H -#define _MOVE_MAP_SHARED_DEFINES_H +#ifndef HELLGROUND_MOVE_MAP_SHARED_DEFINES_H +#define HELLGROUND_MOVE_MAP_SHARED_DEFINES_H #include "Platform/Define.h" #include "../recastnavigation/Detour/Include/DetourNavMesh.h" diff --git a/src/game/movemap/PathFinder.cpp b/src/game/movemap/PathFinder.cpp index fdb409fbc..4b67eaf76 100644 --- a/src/game/movemap/PathFinder.cpp +++ b/src/game/movemap/PathFinder.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MoveMap.h" @@ -50,12 +51,16 @@ PathFinder::~PathFinder() bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest) { + float x, y, z; + m_sourceUnit->GetPosition(x, y, z); + + if (!Hellground::IsValidMapCoord(destX, destY, destZ) || !Hellground::IsValidMapCoord(x, y, z)) + return false; + Vector3 oldDest = getEndPosition(); Vector3 dest(destX, destY, destZ); setEndPosition(dest); - float x, y, z; - m_sourceUnit->GetPosition(x, y, z); Vector3 start(x, y, z); setStartPosition(start); @@ -457,6 +462,8 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint) for (uint32 i = 0; i < pointCount; ++i) m_pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); + NormalizePath(); + // first point is always our current location - we need the next one setActualEndPosition(m_pathPoints[pointCount-1]); @@ -483,6 +490,12 @@ void PathFinder::BuildPointPath(const float *startPoint, const float *endPoint) //DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::BuildPointPath path type %d size %d poly-size %d\n", m_type, pointCount, m_polyLength); } +void PathFinder::NormalizePath() +{ + for (uint32 i = 0; i < m_pathPoints.size(); ++i) + m_sourceUnit->UpdateAllowedPositionZ(m_pathPoints[i].x, m_pathPoints[i].y, m_pathPoints[i].z); +} + void PathFinder::BuildShortcut() { //DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::BuildShortcut :: making shortcut\n"); @@ -496,6 +509,8 @@ void PathFinder::BuildShortcut() m_pathPoints[0] = getStartPosition(); m_pathPoints[1] = getActualEndPosition(); + NormalizePath(); + m_type = PATHFIND_SHORTCUT; } diff --git a/src/game/movemap/PathFinder.h b/src/game/movemap/PathFinder.h index be2f323a4..d30211c73 100644 --- a/src/game/movemap/PathFinder.h +++ b/src/game/movemap/PathFinder.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2012 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOS_PATH_FINDER_H -#define MANGOS_PATH_FINDER_H +#ifndef HELLGROUND_PATH_FINDER_H +#define HELLGROUND_PATH_FINDER_H #include "MoveMapSharedDefines.h" #include "../recastnavigation/Detour/Include/DetourNavMesh.h" @@ -119,6 +120,8 @@ class PathFinder void BuildPointPath(const float *startPoint, const float *endPoint); void BuildShortcut(); + void NormalizePath(); + NavTerrain getNavTerrain(float x, float y, float z); void createFilter(); void updateFilter(); diff --git a/src/game/movement/MoveSpline.cpp b/src/game/movement/MoveSpline.cpp index ec1398de0..17c1cc4e7 100644 --- a/src/game/movement/MoveSpline.cpp +++ b/src/game/movement/MoveSpline.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MoveSpline.h" diff --git a/src/game/movement/MoveSpline.h b/src/game/movement/MoveSpline.h index e98469467..5df5c8729 100644 --- a/src/game/movement/MoveSpline.h +++ b/src/game/movement/MoveSpline.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_MOVEPLINE_H -#define MANGOSSERVER_MOVEPLINE_H +#ifndef HELLGROUND_MOVEPLINE_H +#define HELLGROUND_MOVEPLINE_H #include "spline.h" #include "MoveSplineInitArgs.h" diff --git a/src/game/movement/MoveSplineFlag.h b/src/game/movement/MoveSplineFlag.h index 0b8ed0e1c..85a359e45 100644 --- a/src/game/movement/MoveSplineFlag.h +++ b/src/game/movement/MoveSplineFlag.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_MOVESPLINEFLAG_H -#define MANGOSSERVER_MOVESPLINEFLAG_H +#ifndef HELLGROUND_MOVESPLINEFLAG_H +#define HELLGROUND_MOVESPLINEFLAG_H #include "typedefs.h" #include diff --git a/src/game/movement/MoveSplineInit.cpp b/src/game/movement/MoveSplineInit.cpp index e76f42c96..dc0c8c93a 100644 --- a/src/game/movement/MoveSplineInit.cpp +++ b/src/game/movement/MoveSplineInit.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MoveSplineInit.h" diff --git a/src/game/movement/MoveSplineInit.h b/src/game/movement/MoveSplineInit.h index 870d80f58..d5acb5979 100644 --- a/src/game/movement/MoveSplineInit.h +++ b/src/game/movement/MoveSplineInit.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_MOVESPLINEINIT_H -#define MANGOSSERVER_MOVESPLINEINIT_H +#ifndef HELLGROUND_MOVESPLINEINIT_H +#define HELLGROUND_MOVESPLINEINIT_H #include "MoveSplineInitArgs.h" #include "movemap/PathFinder.h" @@ -110,18 +111,20 @@ namespace Movement inline void MoveSplineInit::MoveTo(const Vector3& dest, bool generatePath, bool forceDestination) { - if(generatePath) + if (generatePath) { PathFinder path(&unit); - path.calculate(dest.x, dest.y, dest.z, forceDestination); - MovebyPath(path.getPath()); - } - else - { - args.path_Idx_offset = 0; - args.path.resize(2); - args.path[1] = dest; + bool result = path.calculate(dest.x, dest.y, dest.z, forceDestination); + if (result && path.getPathType() & ~PATHFIND_NOPATH) + { + MovebyPath(path.getPath()); + return; + } } + + args.path_Idx_offset = 0; + args.path.resize(2); + args.path[1] = dest; } inline void MoveSplineInit::SetFacing(Vector3 const& spot) diff --git a/src/game/movement/MoveSplineInitArgs.h b/src/game/movement/MoveSplineInitArgs.h index 96292c8d5..521724292 100644 --- a/src/game/movement/MoveSplineInitArgs.h +++ b/src/game/movement/MoveSplineInitArgs.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_MOVESPLINEINIT_ARGS_H -#define MANGOSSERVER_MOVESPLINEINIT_ARGS_H +#ifndef HELLGROUND_MOVESPLINEINIT_ARGS_H +#define HELLGROUND_MOVESPLINEINIT_ARGS_H #include "MoveSplineFlag.h" #include diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp index aed0e7ddf..61af9dc3e 100644 --- a/src/game/movement/packet_builder.cpp +++ b/src/game/movement/packet_builder.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "packet_builder.h" diff --git a/src/game/movement/packet_builder.h b/src/game/movement/packet_builder.h index 8206bd174..8fb6ad971 100644 --- a/src/game/movement/packet_builder.h +++ b/src/game/movement/packet_builder.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_PACKET_BUILDER_H -#define MANGOSSERVER_PACKET_BUILDER_H +#ifndef HELLGROUND_PACKET_BUILDER_H +#define HELLGROUND_PACKET_BUILDER_H class ByteBuffer; class WorldPacket; diff --git a/src/game/movement/spline.cpp b/src/game/movement/spline.cpp index 9e3159485..d7af86e5c 100644 --- a/src/game/movement/spline.cpp +++ b/src/game/movement/spline.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "spline.h" diff --git a/src/game/movement/spline.h b/src/game/movement/spline.h index a00b458c5..9ee308ff9 100644 --- a/src/game/movement/spline.h +++ b/src/game/movement/spline.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_SPLINE_H -#define MANGOSSERVER_SPLINE_H +#ifndef HELLGROUND_SPLINE_H +#define HELLGROUND_SPLINE_H #include "typedefs.h" #include diff --git a/src/game/movement/spline.impl.h b/src/game/movement/spline.impl.h index eded2d8c9..1a62fe6db 100644 --- a/src/game/movement/spline.impl.h +++ b/src/game/movement/spline.impl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,14 +9,17 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef HELLGROUND_SPLINEIMPL_H +#define HELLGROUND_SPLINEIMPL_H + namespace Movement { template void Spline::evaluate_percent( float t, Vector3 & c ) const @@ -95,3 +99,5 @@ template void Spline::clear() } } + +#endif diff --git a/src/game/movement/typedefs.h b/src/game/movement/typedefs.h index 5178bdec9..69cb1bae9 100644 --- a/src/game/movement/typedefs.h +++ b/src/game/movement/typedefs.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MANGOSSERVER_TYPEDEFS_H -#define MANGOSSERVER_TYPEDEFS_H +#ifndef HELLGROUND_TYPEDEFS_H +#define HELLGROUND_TYPEDEFS_H #include "Common.h" diff --git a/src/game/movement/util.cpp b/src/game/movement/util.cpp index 7624cf987..b3bed23ba 100644 --- a/src/game/movement/util.cpp +++ b/src/game/movement/util.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MoveSplineFlag.h" diff --git a/src/game/pchdef.cpp b/src/game/pchdef.cpp index 01a5b1661..39ebeffca 100644 --- a/src/game/pchdef.cpp +++ b/src/game/pchdef.cpp @@ -1 +1,19 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "pchdef.h" diff --git a/src/game/pchdef.h b/src/game/pchdef.h index 0a1aa78e8..4ecc5a71e 100644 --- a/src/game/pchdef.h +++ b/src/game/pchdef.h @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + //add here most rarely modified headers to speed up debug build compilation #include "WorldSocket.h" // must be first to make ACE happy with ACE includes in it #include "Common.h" diff --git a/src/game/vmap/BIH.cpp b/src/game/vmap/BIH.cpp index 8e954f7c5..a7d9584c7 100644 --- a/src/game/vmap/BIH.cpp +++ b/src/game/vmap/BIH.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "BIH.h" diff --git a/src/game/vmap/BIH.h b/src/game/vmap/BIH.h index 1b8552f54..1fbd19c4c 100644 --- a/src/game/vmap/BIH.h +++ b/src/game/vmap/BIH.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _BIH_H -#define _BIH_H +#ifndef HELLGROUND_BIH_H +#define HELLGROUND_BIH_H #include #include diff --git a/src/game/vmap/IVMapManager.h b/src/game/vmap/IVMapManager.h index 1fb45e713..bda98ae91 100755 --- a/src/game/vmap/IVMapManager.h +++ b/src/game/vmap/IVMapManager.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _IVMAPMANAGER_H -#define _IVMAPMANAGER_H +#ifndef HELLGROUND_IVMAPMANAGER_H +#define HELLGROUND_IVMAPMANAGER_H #include #include diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index e823b7d1c..7ff379624 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapTree.h" diff --git a/src/game/vmap/MapTree.h b/src/game/vmap/MapTree.h index 475213734..11571cf0d 100644 --- a/src/game/vmap/MapTree.h +++ b/src/game/vmap/MapTree.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MAPTREE_H -#define _MAPTREE_H +#ifndef HELLGROUND_MAPTREE_H +#define HELLGROUND_MAPTREE_H #include "Platform/Define.h" #include "Utilities/UnorderedMap.h" diff --git a/src/game/vmap/ModelInstance.cpp b/src/game/vmap/ModelInstance.cpp index 351600aae..49f955334 100644 --- a/src/game/vmap/ModelInstance.cpp +++ b/src/game/vmap/ModelInstance.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ModelInstance.h" diff --git a/src/game/vmap/ModelInstance.h b/src/game/vmap/ModelInstance.h index 04f5437da..5153800ef 100644 --- a/src/game/vmap/ModelInstance.h +++ b/src/game/vmap/ModelInstance.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _MODELINSTANCE_H_ -#define _MODELINSTANCE_H_ +#ifndef HELLGROUND_MODELINSTANCE_H +#define HELLGROUND_MODELINSTANCE_H #include #include diff --git a/src/game/vmap/PipeWrapper.cpp b/src/game/vmap/PipeWrapper.cpp index 7d07482f7..554711f25 100644 --- a/src/game/vmap/PipeWrapper.cpp +++ b/src/game/vmap/PipeWrapper.cpp @@ -1,7 +1,23 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "PipeWrapper.h" -#include "Config/Config.h" #include "Log.h" - #include namespace VMAP @@ -136,86 +152,5 @@ namespace VMAP m_connected = true; } - MultiProcessLog::MultiProcessLog() : m_logFile(NULL) - { - std::string logsDir = sConfig.GetStringDefault("LogsDir",""); - if(!logsDir.empty()) - { - if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\')) - logsDir.append("/"); - } - - std::string logfn = sConfig.GetStringDefault("LogFile", ""); - if(logfn.empty()) - return; - - std::stringstream postfix; - postfix << "_" << ACE_OS::getpid(); - - if(sConfig.GetBoolDefault("LogTimestamp",false)) - postfix << "_" << Log::GetTimestampStr(); - - size_t dot_pos = logfn.find_last_of("."); - if(dot_pos != logfn.npos) - logfn.insert(dot_pos, postfix.str()); - else - logfn += postfix.str(); - - m_logFile = fopen((logsDir+logfn).c_str(), "w"); - - m_includeTime = sConfig.GetBoolDefault("LogTime", false); - } - - MultiProcessLog::~MultiProcessLog() - { - if(m_logFile) - fclose(m_logFile); - } - - void MultiProcessLog::outString(const char *str, ...) - { - if( !str ) - return; - - UTF8PRINTF(stdout,str,); - printf( "\n" ); - - if(m_logFile) - { - Log::outTimestamp(m_logFile); - - va_list ap; - va_start(ap, str); - vfprintf(m_logFile, str, ap); - fprintf(m_logFile, "\n" ); - va_end(ap); - - fflush(m_logFile); - } - fflush(stdout); - } - - void MultiProcessLog::outError(const char *str, ...) - { - if( !str ) - return; - - UTF8PRINTF(stdout,str,); - printf( "\n" ); - - if(m_logFile) - { - Log::outTimestamp(m_logFile); - fprintf(m_logFile, "ERROR:" ); - - va_list ap; - va_start(ap, str); - vfprintf(m_logFile, str, ap); - va_end(ap); - - fprintf(m_logFile, "\n" ); - fflush(m_logFile); - } - } } diff --git a/src/game/vmap/PipeWrapper.h b/src/game/vmap/PipeWrapper.h index 97cd5a8b3..2349d325c 100644 --- a/src/game/vmap/PipeWrapper.h +++ b/src/game/vmap/PipeWrapper.h @@ -1,5 +1,23 @@ -#ifndef _PIPEWRAPPER_H -#define _PIPEWRAPPER_H +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_PIPEWRAPPER_H +#define HELLGROUND_PIPEWRAPPER_H #include "Common.h" #include "Util.h" @@ -8,8 +26,6 @@ #include #include -#define sLogMP (*ACE_Singleton::instance()) - class ByteBuffer; namespace VMAP @@ -91,20 +107,6 @@ namespace VMAP LockType m_lock; }; - class MultiProcessLog - { - public: - explicit MultiProcessLog(); - ~MultiProcessLog(); - - void outString(const char *fmt, ...); - void outError(const char *fmt, ...); - - private: - FILE* m_logFile; - bool m_includeTime; - }; - } #include "PipeWrapperImpl.h" diff --git a/src/game/vmap/PipeWrapperImpl.h b/src/game/vmap/PipeWrapperImpl.h index 8ba3632bf..39b000c9d 100644 --- a/src/game/vmap/PipeWrapperImpl.h +++ b/src/game/vmap/PipeWrapperImpl.h @@ -1,5 +1,23 @@ -#ifndef _PIPEWRAPPERIMPL_H_ -#define _PIPEWRAPPERIMPL_H_ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_PIPEWRAPPERIMPL_H +#define HELLGROUND_PIPEWRAPPERIMPL_H #include "ByteBuffer.h" diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index 0eb937aba..a3f89a6db 100755 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -1,21 +1,22 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #include "WorldModel.h" #include "TileAssembler.h" #include "MapTree.h" diff --git a/src/game/vmap/TileAssembler.h b/src/game/vmap/TileAssembler.h index b26735708..cd59e13c1 100755 --- a/src/game/vmap/TileAssembler.h +++ b/src/game/vmap/TileAssembler.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _TILEASSEMBLER_H_ -#define _TILEASSEMBLER_H_ +#ifndef HELLGROUND_TILEASSEMBLER_H +#define HELLGROUND_TILEASSEMBLER_H #include #include diff --git a/src/game/vmap/VMapCluster.cpp b/src/game/vmap/VMapCluster.cpp index 1f61e996f..dccc573ca 100644 --- a/src/game/vmap/VMapCluster.cpp +++ b/src/game/vmap/VMapCluster.cpp @@ -1,8 +1,26 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "VMapCluster.h" -#include "Config/Config.h" #include "ByteBuffer.h" #include "IVMapManager.h" #include "VMapFactory.h" +#include "../World.h" #include #include @@ -220,7 +238,7 @@ namespace VMAP VMapClusterProcess::VMapClusterProcess(uint32 processId) : m_processId(processId), m_masterPid(0) { // data path for vmaps loading - m_dataPath = sConfig.GetStringDefault("DataDir","./"); + m_dataPath = sWorld.GetDataPath(); if (m_dataPath.at(m_dataPath.length()-1)!='/' && m_dataPath.at(m_dataPath.length()-1)!='\\') m_dataPath.append("/"); diff --git a/src/game/vmap/VMapCluster.h b/src/game/vmap/VMapCluster.h index f995bc9ae..66b8dc974 100644 --- a/src/game/vmap/VMapCluster.h +++ b/src/game/vmap/VMapCluster.h @@ -1,5 +1,23 @@ -#ifndef _VMAPCLUSTER_H -#define _VMAPCLUSTER_H +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_VMAPCLUSTER_H +#define HELLGROUND_VMAPCLUSTER_H #include "PipeWrapper.h" #include "Common.h" diff --git a/src/game/vmap/VMapDefinitions.h b/src/game/vmap/VMapDefinitions.h index 6e0064447..0a36f89ce 100755 --- a/src/game/vmap/VMapDefinitions.h +++ b/src/game/vmap/VMapDefinitions.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _VMAPDEFINITIONS_H -#define _VMAPDEFINITIONS_H +#ifndef HELLGROUND_VMAPDEFINITIONS_H +#define HELLGROUND_VMAPDEFINITIONS_H #include #define LIQUID_TILE_SIZE (533.333f / 128.f) diff --git a/src/game/vmap/VMapFactory.cpp b/src/game/vmap/VMapFactory.cpp index 561bf0dfa..c8f18b58b 100755 --- a/src/game/vmap/VMapFactory.cpp +++ b/src/game/vmap/VMapFactory.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include diff --git a/src/game/vmap/VMapFactory.h b/src/game/vmap/VMapFactory.h index 8dc2c0193..6c276ed79 100755 --- a/src/game/vmap/VMapFactory.h +++ b/src/game/vmap/VMapFactory.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _VMAPFACTORY_H -#define _VMAPFACTORY_H +#ifndef HELLGROUND_VMAPFACTORY_H +#define HELLGROUND_VMAPFACTORY_H #include "IVMapManager.h" diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index db1de240f..b0e62f9d4 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include diff --git a/src/game/vmap/VMapManager2.h b/src/game/vmap/VMapManager2.h index c3def61e5..42cc5e63e 100644 --- a/src/game/vmap/VMapManager2.h +++ b/src/game/vmap/VMapManager2.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _VMAPMANAGER2_H -#define _VMAPMANAGER2_H +#ifndef HELLGROUND_VMAPMANAGER2_H +#define HELLGROUND_VMAPMANAGER2_H #include "IVMapManager.h" #include "Utilities/UnorderedMap.h" diff --git a/src/game/vmap/VMapTools.h b/src/game/vmap/VMapTools.h index dbbd9af92..feb0007bc 100755 --- a/src/game/vmap/VMapTools.h +++ b/src/game/vmap/VMapTools.h @@ -1,23 +1,24 @@ /* -* Copyright (C) 2005-2010 MaNGOS -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _VMAPTOOLS_H -#define _VMAPTOOLS_H + * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_VMAPTOOLS_H +#define HELLGROUND_VMAPTOOLS_H #include #include diff --git a/src/game/vmap/WorldModel.cpp b/src/game/vmap/WorldModel.cpp index 8cb45b7c3..4d4fd2945 100644 --- a/src/game/vmap/WorldModel.cpp +++ b/src/game/vmap/WorldModel.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldModel.h" diff --git a/src/game/vmap/WorldModel.h b/src/game/vmap/WorldModel.h index 4720e2c89..ce694988b 100644 --- a/src/game/vmap/WorldModel.h +++ b/src/game/vmap/WorldModel.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2010 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _WORLDMODEL_H -#define _WORLDMODEL_H +#ifndef HELLGROUND_WORLDMODEL_H +#define HELLGROUND_WORLDMODEL_H #include #include diff --git a/src/trinitycore/CMakeLists.txt b/src/hellgroundcore/CMakeLists.txt old mode 100755 new mode 100644 similarity index 83% rename from src/trinitycore/CMakeLists.txt rename to src/hellgroundcore/CMakeLists.txt index 5c9877d9c..f6d32e54b --- a/src/trinitycore/CMakeLists.txt +++ b/src/hellgroundcore/CMakeLists.txt @@ -1,84 +1,84 @@ - -set(EXECUTABLE_NAME trinitycore) -file(GLOB_RECURSE EXECUTABLE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) - -if(WIN32) - list(APPEND EXECUTABLE_SRCS - TrinityCore.rc - ) -endif() - -include_directories( - ${CMAKE_SOURCE_DIR}/src/shared - ${CMAKE_SOURCE_DIR}/src/shared/Database - ${CMAKE_SOURCE_DIR}/dep/include - ${CMAKE_SOURCE_DIR}/src/framework - ${CMAKE_SOURCE_DIR}/src/game - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/shared - ${ACE_INCLUDE_DIR} - ${MYSQL_INCLUDE_DIR} - ${OPENSSL_INCLUDE_DIR} -) - -add_executable(${EXECUTABLE_NAME} - ${EXECUTABLE_SRCS} -) - -add_dependencies(${EXECUTABLE_NAME} revision.h) -if(NOT ACE_USE_EXTERNAL) - add_dependencies(${EXECUTABLE_NAME} ACE_Project) -# add_dependencies(${EXECUTABLE_NAME} ace) -endif() - -target_link_libraries(${EXECUTABLE_NAME} - game - shared - framework - g3dlib - ${ACE_LIBRARIES} - ${READLINE_LIBRARIES} - ${OPENSSL_LIBRARIES} -) - -if(WIN32) - target_link_libraries(${EXECUTABLE_NAME} - zlib - optimized ${MYSQL_LIBRARY} - debug ${MYSQL_DEBUG_LIBRARY} - ) - if(PLATFORM MATCHES X86) - target_link_libraries(${EXECUTABLE_NAME}) - endif() -endif() - -if(UNIX) - target_link_libraries(${EXECUTABLE_NAME} - ${MYSQL_LIBRARY} - ${ZLIB_LIBRARIES} - ${OPENSSL_EXTRA_LIBRARIES} - ) -endif() - -set(EXECUTABLE_LINK_FLAGS "") - -if(UNIX) - set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS} -rdynamic") -endif() - -if(APPLE) - set(EXECUTABLE_LINK_FLAGS "-framework Carbon ${EXECUTABLE_LINK_FLAGS}") -endif() - -set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS - "${EXECUTABLE_LINK_FLAGS}" -) - -install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BIN_DIR}) -#install(FILES run-mangosd DESTINATION ${BIN_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/trinitycore.conf.dist ${CMAKE_CURRENT_BINARY_DIR}/trinitycore.conf.dist) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trinitycore.conf.dist DESTINATION ${CONF_DIR}) - -if(WIN32 AND MSVC) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/\${BUILD_TYPE}/${EXECUTABLE_NAME}.pdb DESTINATION ${BIN_DIR} CONFIGURATIONS Debug) -endif() + +set(EXECUTABLE_NAME hellgroundcore) +file(GLOB_RECURSE EXECUTABLE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) + +if(WIN32) + list(APPEND EXECUTABLE_SRCS + HellgroundCore.rc + ) +endif() + +include_directories( + ${CMAKE_SOURCE_DIR}/src/shared + ${CMAKE_SOURCE_DIR}/src/shared/Database + ${CMAKE_SOURCE_DIR}/dep/include + ${CMAKE_SOURCE_DIR}/src/framework + ${CMAKE_SOURCE_DIR}/src/game + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/shared + ${ACE_INCLUDE_DIR} + ${MYSQL_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} +) + +add_executable(${EXECUTABLE_NAME} + ${EXECUTABLE_SRCS} +) + +add_dependencies(${EXECUTABLE_NAME} revision.h) +if(NOT ACE_USE_EXTERNAL) + add_dependencies(${EXECUTABLE_NAME} ACE_Project) +# add_dependencies(${EXECUTABLE_NAME} ace) +endif() + +target_link_libraries(${EXECUTABLE_NAME} + game + shared + framework + g3dlib + ${ACE_LIBRARIES} + ${READLINE_LIBRARIES} + ${OPENSSL_LIBRARIES} +) + +if(WIN32) + target_link_libraries(${EXECUTABLE_NAME} + zlib + optimized ${MYSQL_LIBRARY} + debug ${MYSQL_DEBUG_LIBRARY} + ) + if(PLATFORM MATCHES X86) + target_link_libraries(${EXECUTABLE_NAME}) + endif() +endif() + +if(UNIX) + target_link_libraries(${EXECUTABLE_NAME} + ${MYSQL_LIBRARY} + ${ZLIB_LIBRARIES} + ${OPENSSL_EXTRA_LIBRARIES} + ) +endif() + +set(EXECUTABLE_LINK_FLAGS "") + +if(UNIX) + set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS} -rdynamic") +endif() + +if(APPLE) + set(EXECUTABLE_LINK_FLAGS "-framework Carbon ${EXECUTABLE_LINK_FLAGS}") +endif() + +set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS + "${EXECUTABLE_LINK_FLAGS}" +) + +install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BIN_DIR}) +#install(FILES run-mangosd DESTINATION ${BIN_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hellgroundcore.conf.dist ${CMAKE_CURRENT_BINARY_DIR}/hellgroundcore.conf.dist) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hellgroundcore.conf.dist DESTINATION ${CONF_DIR}) + +if(WIN32 AND MSVC) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/\${BUILD_TYPE}/${EXECUTABLE_NAME}.pdb DESTINATION ${BIN_DIR} CONFIGURATIONS Debug) +endif() diff --git a/src/trinitycore/CliRunnable.cpp b/src/hellgroundcore/CliRunnable.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/trinitycore/CliRunnable.cpp rename to src/hellgroundcore/CliRunnable.cpp index d8b6b1213..93356947a --- a/src/trinitycore/CliRunnable.cpp +++ b/src/hellgroundcore/CliRunnable.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup Trinityd @@ -116,7 +116,7 @@ bool ChatHandler::HandleAccountDeleteCommand(const char* args) return false; std::string account_name = account_name_str; - if(!AccountMgr::normilizeString(account_name)) + if(!AccountMgr::normalizeString(account_name)) { PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); SetSentErrorMessage(true); @@ -134,11 +134,9 @@ bool ChatHandler::HandleAccountDeleteCommand(const char* args) /// Commands not recommended call from chat, but support anyway if(m_session) { - uint32 targetPermissions = AccountMgr::GetPermissions(account_id); - /// can delete only for account with less security /// This is also reject self apply in fact - if (targetPermissions >= m_session->GetPermissions()) + if (AccountMgr::GetPermissions(account_id) >= m_session->GetPermissions()) { SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); SetSentErrorMessage (true); @@ -329,11 +327,18 @@ bool ChatHandler::HandleAccountSpecialLogCommand(const char* args) else session->AddAccountFlag(ACC_SPECIAL_LOG); } + else + { + if (accFlags & ACC_SPECIAL_LOG) + WorldSession::SaveAccountFlags(account_id, accFlags &= ~ACC_SPECIAL_LOG); + else + WorldSession::SaveAccountFlags(account_id, accFlags |= ACC_SPECIAL_LOG); + } if (accFlags & ACC_SPECIAL_LOG) - PSendSysMessage("SpecialLog have been disabled for account: %u.", account_id); - else PSendSysMessage("SpecialLog have been enabled for account: %u.", account_id); + else + PSendSysMessage("SpecialLog have been disabled for account: %u.", account_id); } else { @@ -367,6 +372,13 @@ bool ChatHandler::HandleAccountWhispLogCommand(const char* args) else session->AddAccountFlag(ACC_WHISPER_LOG); } + else + { + if (accFlags & ACC_WHISPER_LOG) + WorldSession::SaveAccountFlags(account_id, accFlags &= ~ACC_WHISPER_LOG); + else + WorldSession::SaveAccountFlags(account_id, accFlags |= ACC_WHISPER_LOG); + } if (accFlags & ACC_WHISPER_LOG) PSendSysMessage("WhispLog have been disabled for account: %u.", account_id); @@ -383,20 +395,6 @@ bool ChatHandler::HandleAccountWhispLogCommand(const char* args) return true; } -/// Set the level of logging -bool ChatHandler::HandleServerSetLogLevelCommand(const char *args) -{ - if(!*args) - return false; - - char *NewLevel = strtok((char*)args, " "); - if (!NewLevel) - return false; - - sLog.SetLogLevel(NewLevel); - return true; -} - /// set diff time record interval bool ChatHandler::HandleServerSetDiffTimeCommand(const char *args) { diff --git a/src/trinitycore/CliRunnable.h b/src/hellgroundcore/CliRunnable.h old mode 100755 new mode 100644 similarity index 78% rename from src/trinitycore/CliRunnable.h rename to src/hellgroundcore/CliRunnable.h index f33aa8629..59362da79 --- a/src/trinitycore/CliRunnable.h +++ b/src/hellgroundcore/CliRunnable.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef __CLIRUNNABLE_H -#define __CLIRUNNABLE_H +#ifndef HELLGROUND_CLIRUNNABLE_H +#define HELLGROUND_CLIRUNNABLE_H /// Command Line Interface handling thread class CliRunnable : public ACE_Based::Runnable diff --git a/src/trinitycore/TrinityCore.rc b/src/hellgroundcore/HellgroundCore.rc old mode 100755 new mode 100644 similarity index 81% rename from src/trinitycore/TrinityCore.rc rename to src/hellgroundcore/HellgroundCore.rc index ed2453e79..0f4a0e74b --- a/src/trinitycore/TrinityCore.rc +++ b/src/hellgroundcore/HellgroundCore.rc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +8,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "resource.h" @@ -69,12 +69,12 @@ BEGIN BEGIN BLOCK "080004b0" BEGIN - VALUE "FileDescription", "TrinityCore" + VALUE "FileDescription", "HellgroundCore" VALUE "FileVersion", STRFILEVER - VALUE "InternalName", "TrinityCore" - VALUE "LegalCopyright", "Copyright (C) 2008-2009" - VALUE "OriginalFilename", "TrinityCore.exe" - VALUE "ProductName", "TrinityCore" + VALUE "InternalName", "HellgroundCore" + VALUE "LegalCopyright", "Copyright (C) 2008-2014" + VALUE "OriginalFilename", "HellgroundCore.exe" + VALUE "ProductName", "HellgroundCore" VALUE "ProductVersion", STRPRODUCTVER END END diff --git a/src/trinitycore/Main.cpp b/src/hellgroundcore/Main.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/trinitycore/Main.cpp rename to src/hellgroundcore/Main.cpp index d54072faa..cdf3b0b2d --- a/src/trinitycore/Main.cpp +++ b/src/hellgroundcore/Main.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup Trinityd Trinity Daemon @@ -37,8 +37,8 @@ #ifdef WIN32 #include "ServiceWin32.h" -char serviceName[] = "Trinityd"; -char serviceLongName[] = "Trinity core service"; +char serviceName[] = "Hellground"; +char serviceLongName[] = "hellground core service"; char serviceDescription[] = "Massive Network Game Object Server"; #else #include "PosixDaemon.h" @@ -75,7 +75,7 @@ void usage(const char *prog) , prog); } -/// Launch the Trinity server +/// Launch the server extern int main(int argc, char **argv) { ///- Command line parsing @@ -217,7 +217,7 @@ extern int main(int argc, char **argv) if (confVersion < _HELLGROUND_CORE_CONFVER) { sLog.outLog(LOG_DEFAULT, "ERROR: *********************************************************************************"); - sLog.outLog(LOG_DEFAULT, "ERROR: WARNING: Your trinitycore.conf version indicates your conf file is out of date!"); + sLog.outLog(LOG_DEFAULT, "ERROR: WARNING: Your hellgroundcore.conf version indicates your conf file is out of date!"); sLog.outLog(LOG_DEFAULT, "ERROR: Please check for updates, as your current default values may cause"); sLog.outLog(LOG_DEFAULT, "ERROR: strange behavior."); sLog.outLog(LOG_DEFAULT, "ERROR: *********************************************************************************"); @@ -239,7 +239,7 @@ extern int main(int argc, char **argv) // at sMaster return function exist with codes // 0 - normal shutdown // 1 - shutdown at error - // 2 - restart command used, this code can be used by restarter for restart Trinityd + // 2 - restart command used, this code can be used by restarter for restart } /// @} diff --git a/src/trinitycore/Master.cpp b/src/hellgroundcore/Master.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/trinitycore/Master.cpp rename to src/hellgroundcore/Master.cpp index 0d272a774..c75895752 --- a/src/trinitycore/Master.cpp +++ b/src/hellgroundcore/Master.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -116,15 +116,14 @@ int Master::Run() sLog.outString("%s (core-daemon)", _FULLVERSION); sLog.outString(" to stop.\n"); - sLog.outTitle(" ______ __"); - sLog.outTitle("/\\__ _\\ __ __/\\ \\__"); - sLog.outTitle("\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\ ,_\\ __ __"); - sLog.outTitle(" \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\"); - sLog.outTitle(" \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\"); - sLog.outTitle(" \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\"); - sLog.outTitle(" \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\"); - sLog.outTitle(" C O R E /\\___/"); - sLog.outTitle("http://TrinityCore.org \\/__/\n"); + outstring_log(" _ _ _ _ _____ _ "); + outstring_log("| | | | | | | __ \\ | |"); + outstring_log("| |_| | ___| | | | \\/_ __ ___ _ _ _ __ __| |"); + outstring_log("| _ |/ _ \\ | | | __| '__/ _ \\| | | | '_ \\ / _` |"); + outstring_log("| | | | __/ | | |_\\ \\ | | (_) | |_| | | | | (_| |"); + outstring_log("\\_| |_/\\___|_|_|\\____/_| \\___/ \\__,_|_| |_|\\__,_|"); + outstring_log("http://hellground.net based on http://TrinityCore.org"); + outstring_log("Hellground Script initializing %s", _FULLVERSION); /// worldd PID file creation std::string pidfile = sConfig.GetStringDefault("PidFile", ""); @@ -149,8 +148,7 @@ int Master::Run() return 1; // set server offline (not connectable) - AccountsDatabase.DirectPExecute("UPDATE realmlist SET realmflags = (realmflags & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID); - + AccountsDatabase.DirectPExecute("UPDATE realms SET flags = flags | %u WHERE realm_id = '%u'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID); ///- Initialize the World sWorld.SetInitialWorldSettings(); @@ -222,7 +220,7 @@ int Master::Run() if(!curAff) { - sLog.outLog(LOG_DEFAULT, "ERROR: Processors marked in UseProcessors bitmask (hex) %x not accessible for Trinityd. Accessible processors bitmask (hex): %x", Aff, appAff); + sLog.outLog(LOG_DEFAULT, "ERROR: Processors marked in UseProcessors bitmask (hex) %x not accessible for Hellground. Accessible processors bitmask (hex): %x", Aff, appAff); } else { @@ -240,9 +238,9 @@ int Master::Run() if(Prio) { if(SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) - sLog.outString("TrinityCore process priority class set to HIGH"); + sLog.outString("HellgroundCore process priority class set to HIGH"); else - sLog.outLog(LOG_DEFAULT, "ERROR: Can't set TrinityCore process priority class."); + sLog.outLog(LOG_DEFAULT, "ERROR: Can't set HellgroundCore process priority class."); } } #endif @@ -406,9 +404,6 @@ bool Master::_StartDB() ///- Clean the database before starting clearOnlineAccounts(); - ///- Insert version info into DB - GameDataDatabase.PExecute("UPDATE `version` SET `core_version` = '%s', `core_revision` = '%s'", _FULLVERSION, _REVISION); - sWorld.LoadDBVersion(); //sLog.outString("Using %s", sWorld.GetDBVersion()); @@ -449,9 +444,9 @@ void Master::_OnSignal(int s) case SIGABRT: { ACE_thread_t const threadId = ACE_OS::thr_self(); + ACE_Stack_Trace stackTrace; if (MapUpdateInfo const* mapUpdateInfo = sMapMgr.GetMapUpdater()->GetMapUpdateInfo(threadId)) { - ACE_Stack_Trace stackTrace; sLog.outLog(LOG_CRASH, "CRASH[%i]: mapid: %u, instanceid: %u", s, mapUpdateInfo->GetId(), mapUpdateInfo->GetInstanceId()); sLog.outLog(LOG_CRASH, "\r\n************ BackTrace *************\r\n%s\r\n***********************************\r\n", stackTrace.c_str()); @@ -460,14 +455,13 @@ void Master::_OnSignal(int s) sMapMgr.GetMapUpdater()->unregister_thread(ACE_OS::thr_self()); sMapMgr.GetMapUpdater()->update_finished(); - - ACE_OS::thr_exit(); - break; + } + else + { + sLog.outLog(LOG_CRASH, "Signal Handler: Thread is not virtual map server. Stopping world."); + sLog.outLog(LOG_CRASH, "\r\n************ BackTrace *************\r\n%s\r\n***********************************\r\n", stackTrace.c_str()); } - ACE_Stack_Trace stackTrace; - sLog.outLog(LOG_CRASH, "Signal Handler: Thread is not virtual map server. Stopping world."); - sLog.outLog(LOG_CRASH, "\r\n************ BackTrace *************\r\n%s\r\n***********************************\r\n", stackTrace.c_str()); ACE_SIGACTION action; action.sa_handler = SIG_DFL; diff --git a/src/trinitycore/Master.h b/src/hellgroundcore/Master.h old mode 100755 new mode 100644 similarity index 83% rename from src/trinitycore/Master.h rename to src/hellgroundcore/Master.h index db9bdbd7a..7b2b40fc2 --- a/src/trinitycore/Master.h +++ b/src/hellgroundcore/Master.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef _MASTER_H -#define _MASTER_H +#ifndef HELLGROUND_MASTER_H +#define HELLGROUND_MASTER_H #include diff --git a/src/trinitycore/TrinityCore.ico b/src/hellgroundcore/TrinityCore.ico old mode 100755 new mode 100644 similarity index 100% rename from src/trinitycore/TrinityCore.ico rename to src/hellgroundcore/TrinityCore.ico diff --git a/src/trinitycore/WorldRunnable.cpp b/src/hellgroundcore/WorldRunnable.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/trinitycore/WorldRunnable.cpp rename to src/hellgroundcore/WorldRunnable.cpp index 988f49681..c1748b6a4 --- a/src/trinitycore/WorldRunnable.cpp +++ b/src/hellgroundcore/WorldRunnable.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file diff --git a/src/trinitycore/WorldRunnable.h b/src/hellgroundcore/WorldRunnable.h old mode 100755 new mode 100644 similarity index 77% rename from src/trinitycore/WorldRunnable.h rename to src/hellgroundcore/WorldRunnable.h index 592c02b14..7b947da1c --- a/src/trinitycore/WorldRunnable.h +++ b/src/hellgroundcore/WorldRunnable.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ /// @{ /// \file -#ifndef __WORLDRUNNABLE_H -#define __WORLDRUNNABLE_H +#ifndef HELLGROUND_WORLDRUNNABLE_H +#define HELLGROUND_WORLDRUNNABLE_H /// Heartbeat thread for the World class WorldRunnable : public ACE_Based::Runnable diff --git a/src/trinitycore/trinitycore.conf.dist b/src/hellgroundcore/hellgroundcore.conf.dist old mode 100755 new mode 100644 similarity index 76% rename from src/trinitycore/trinitycore.conf.dist rename to src/hellgroundcore/hellgroundcore.conf.dist index b1e4089e4..ff88cff9e --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/hellgroundcore/hellgroundcore.conf.dist @@ -1,1795 +1,1938 @@ -########################################## -# Trinity Core worldd configuration file # -########################################## -[CoreConf] -ConfVersion=2012070901 - -################################################################################################################### -# CONNECTIONS AND DIRECTORIES -# -# RealmID -# RealmID must match the realmlist inside the realmd database -# -# DataDir -# Data directory setting. -# Important: DataDir needs to be quoted, as it is a string which may contain space characters. -# Important: In linux daemon mode string must be full path. -# Example: "/share/trinitycore" -# -# LogsDir -# Logs directory setting. -# Important: Logs dir must exists, or all logs need to be disabled -# Default: "" - no log directory prefix, if used log names isn't absolute path -# then logs will be stored in current directory for run program. -# -# -# LoginDatabaseInfo -# WorldDatabaseInfo -# CharacterDatabaseInfo -# Database connection settings for the world server. -# Default: hostname;port;username;password;database -# .;somenumber;username;password;database - use named pipes at Windows -# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini -# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux -# Unix sockets: experimental, not tested -# -# LoginDatabaseConnections -# WorldDatabaseConnections -# CharacterDatabaseConnections -# Amount of connections to database which will be used for SELECT queries. Maximum 16 connections per database. -# Please, note, for data consistency only one connection for each database is used for transactions and async SELECTs. -# So formula to find out how many connections will be established: X = �_connections + 1 -# Default: 1 connection for SELECT statements -# -# MaxPingTime -# Settings for maximum database-ping interval (minutes between pings) -# -# WorldServerPort -# Default WorldServerPort -# -# BindIP -# Bind World Server to IP/hostname -# -################################################################################################################### - -RealmID = 1 -DataDir = "." -LogsDir = "" -LoginDatabaseInfo = "127.0.0.1;3306;trinity;trinity;realmd" -WorldDatabaseInfo = "127.0.0.1;3306;trinity;trinity;world" -CharacterDatabaseInfo = "127.0.0.1;3306;trinity;trinity;characters" -LoginDatabaseConnections = 1 -WorldDatabaseConnections = 1 -CharacterDatabaseConnections = 1 -MaxPingTime = 30 -WorldServerPort = 8085 -BindIP = "0.0.0.0" - -################################################################################################################### -# SCRIPTING SETTINGS -# -# Locale -# Setting for current (DBC) locale to use -# -# EventAI Error reporting -# 0 - Only startup (Default) -# 1 - Startup errors and Runtime event errors -# 2 - Startup errors, Runtime event errors, and Creation errors -################################################################################################################### - -Locale = 0 -EAIErrorLevel = 2 - -################################################################################################################### -# PERFORMANCE SETINGS -# -# UseProcessors -# Used processors mask for multi-processors system (Used only at Windows) -# Default: 0 (selected by OS) -# number (bitmask value of selected processors) -# -# ProcessPriority -# Process priority setting (Used only at Windows) -# Default: 1 (HIGH) -# 0 (Normal) -# -# Compression -# Compression level for update packages sent to client (1..9) -# Default: 1 (speed) -# 9 (best compression) -# -# PlayerLimit -# Maximum number of players in the world. Excluding Mods, GM's and Admins -# Default: 100 -# 0 (for infinite players) -# -1 (for Mods, GM's and Admins only) -# -2 (for GM's and Admins only) -# -3 (for Admins only) -# -# SaveRespawnTimeImmediately -# Save respawn time for creatures at death and for gameobjects at use/open -# Default: 1 (save creature/gameobject respawn time without waiting grid unload) -# 0 (save creature/gameobject respawn time at grid unload) -# -# MaxOverspeedPings -# Maximum overspeed ping count before player kick (minimum is 2, 0 used for disable check) -# Default: 2 -# -# GridUnload -# Unload grids (if you have lot memory you can disable it to speed up player move to new grids second time) -# Default: 1 (unload grids) -# 0 (do not unload grids) -# -# SocketSelectTime -# Socket select time (in milliseconds) -# Default: 10000 -# -# GridCleanUpDelay -# Grid clean up delay (in milliseconds) -# Default: 300000 (5 min) -# -# MapUpdateInterval -# Map update interval (in milliseconds) -# Default: 100 -# -# ChangeWeatherInterval -# Weather update interval (in milliseconds) -# Default: 600000 (10 min) -# -# PlayerSaveInterval -# Player save interval (in milliseconds) -# Default: 900000 (15 min) -# -# DisconnectToleranceInterval -# Tolerance for disconnected players before putting in the queue. (in seconds) -# Default: 0 (disabled) -# -# vmap.enableLOS -# Enable/Disable VMmap support for line of sight -# Default: 1 (true) -# 0 (false) -# -# vmap.losMaps -# Map ids where LOS calculations will be enabled. -# -# vmap.ignoreSpellIds -# These spells are ignored for LoS calculation -# List of ids with delimiter ',' -# -# vmap.petLOS -# Check LOS for pets, to avoid them going through walls etc. -# Default: 0 (disable, less CPU usage) -# 1 (enable, each pet attack command will check for LOS) -# -# vmap.totem -# Use VMAP for totem summon place calculation -# Default: 0 (disable, less CPU usage) -# 1 (enable, each totem created check LOS) -# -# vmap.enableCluster -# Enable/Disable VMmap calculations in cluster -# Default: 0 (false) -# 1 (true) -# -# vmap.clusterProcesses -# Number of calculation processes created in cluster -# -# mmap.enabled -# Enable/Disable pathfinding using mmaps -# Default: 1 (enable) -# 0 (disable) -# -# mmap.ignoreMapIds -# Disable mmap pathfinding on the listed maps. -# List of map ids with delimiter ',' -# -# DetectPosCollision -# Check final move position, summon position, etc for visible collision with other objects or -# wall (wall only if vmaps are enabled) -# Default: 1 (enable, required more CPU power usage) -# 0 (disable, less nice position selection but will less CPU power usage) -# -# TargetPosRecalculateRange -# Max distance from movement target point (+moving unit size) and targeted object (+size) -# after that new target movmeent point calculated. Max: melee attack range (5), min: contact range (0.5) -# More distance let have better performence, less distance let have more sensitive reaction at target move. -# Default: 1.5 -# -# UpdateUptimeInterval -# Update realm uptime period in minutes (for save data in 'uptime' table). Must be > 0 -# Default: 10 (minutes) -# -# MaxCoreStuckTime -# Periodically check if the process got freezed, if this is the case force crash after the specified -# amount of seconds. Must be > 0. Recommended > 10 secs if you use this. -# Default: 0 (Disabled) -# -# AddonChannel -# Permit/disable the use of the addon channel through the server -# (some client side addons can stop work correctly with disabled addon channel) -# Default: 1 (permit addon channel) -# 0 (do not permit addon channel) -# -# MapUpdate.Threads -# Number of threads to update maps. -# Default: 1 -# -# MapUpdate.CumulativeLogMethod -# Activate a more detailed Log Feature for Map Update -# Requires define MAP_UPDATE_DIFF_INFO -# Default: 0 Log will be Printed as Sum on each RecordUpdateTimeDiffInterval -# 1 Log will be Printed on each Map Update Cycle -# -# SessionUpdate.Threads -# Number of threads to update sessions (0 - disable). -# WARNING: DON'T use if you don't know what you are doing ... this feature waits for -# necessary improvements. -# Default: 0 -# -# SessionUpdate.MaxTime -# Max time to update sessions. If session update time will be greater then method from -# SessionUpdate.Method will be called. Time in ms. -# Default: 1000 -# -# SessionUpdate.Method -# Method to call when single session update time will be greater than SessionUpdate.MaxTime. -# 0 - Do nothing -# 1 - Log -# 2 - Kick player + log -# 3 - Ban account + log (Default) -# 4 - Ban ip and account + log -# -# SessionUpdate.VerboseLog -# Enables session verbose log (prints to session diff log file if max time was exceeded) -# Default: 0 (disabled) -# 1 Log if diff is greater then SessionUpdate.MaxTime -# 2 Log if diff is greater then MinRecordUpdateTimeSessionDiff -# -################################################################################################################### - -UseProcessors = 0 -ProcessPriority = 1 -Compression = 1 -PlayerLimit = 100 -SaveRespawnTimeImmediately = 1 -MaxOverspeedPings = 2 -GridUnload = 1 -SocketSelectTime = 10000 -GridCleanUpDelay = 300000 -MapUpdateInterval = 100 -ChangeWeatherInterval = 600000 -PlayerSaveInterval = 900000 -DisconnectToleranceInterval = 0 - -vmap.enableLOS = 0 -vmap.losMaps = "" -vmap.ignoreSpellIds = "7720" -vmap.petLOS = 0 -vmap.totem = 0 -vmap.enableCluster = 0 -vmap.clusterProcesses = 4 - -mmap.enabled = 1 -mmap.ignoreMapIds = "" - -UpdateUptimeInterval = 10 -MaxCoreStuckTime = 0 -AddonChannel = 1 - -MapUpdate.Threads = 1 -MapUpdate.UpdateVisitorsMax = 20 -MapUpdate.CumulativeLogMethod = 0 - -SessionUpdate.Threads = 1 -SessionUpdate.MaxTime = 1000 -SessionUpdate.Method = 3 -SessionUpdate.VerboseLog = 0 - -# SessionUpdate.IdleKickTimer -# Max time that user can spend in character selection screen -# Default: 900000 (ms) - 15 min -# - -SessionUpdate.IdleKickTimer = 900000 - -# DBDiffLog.LogTime -# Query who reaches the Time will be Logged -# Is a kind of SlowQueryLog. Time in ms. -# Default: 10 - -DBDiffLog.LogTime = 10 - -################################################################################################################### -# SERVER LOGGING -# -# LogSQL -# Enable logging of GM commands - all SQL code will be written to a log file -# All commands are written to a file: YYYY-MM-DD_logSQL.sql -# If a new day starts (00:00:00) then a new file is created - the old file will not be deleted. -# Default: 1 - Write SQL code to logfile -# 0 - Do not log -# -# PidFile -# World daemon PID file -# Important: In linux daemon mode string must be full path. -# Default: "" - do not create PID file -# "./worldd.pid" - create PID file (recommended name) -# -# LogLevel -# Server console level of logging -# 0 = Minimum; 1 = Basic&Error; 2 = Detail; 3 = Full/Debug -# Default: 3 -# -# LogTime -# Include time in server console output [hh:mm:ss] -# Default: 0 (no time) -# 1 (print time) -# -# LogFile -# Logfile name -# Default: "Server.log" -# "" - Empty name disable creating log file -# -# LogTimestamp -# Logfile with timestamp of server start in name -# Default: 0 - no timestamp in name -# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext -# -# LogFileLevel -# Server file level of logging -# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug -# Default: 0 -# -# LogFilter_TransportMoves -# LogFilter_CreatureMoves -# LogFilter_VisibilityChanges -# Log filters -# Default: 1 - not include with any log level -# 0 - include in log if log level permit -# -# WorldLogFile -# Packet logging file for the worldserver -# Default: "world.log" -# -# DBErrorLogFile -# Log file of DB errors detected at server run -# Default: "DBErrors.log" -# -# CharLogFile -# Character operations logfile name -# Default: "Char.log" -# "" - Empty name disable creating log file -# -# CharLogTimestamp -# Logfile with timestamp of server start in name -# Default: 0 - no timestamp in name -# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext -# -# GmLogFile -# Log file of gm commands -# Default: "gm_commands.log" -# "" - Empty name for disable -# -# GmLogTimestamp -# GM Logfile with timestamp of server start in name -# Default: 0 - no timestamp in name -# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext -# -# GmLogPerAccount -# GM Logfiles with GM account id (Note: logs not created if GmLogFile not set) -# Default: 0 - add gm log data to single log file -# 1 - add gm log data to account specific log files with name -# in form Logname_#ID_YYYY-MM-DD_HH-MM-SS.Ext -# or form Logname_#ID.Ext -# -# GmLogMinLevel -# Min GM Level to log commands -# Default: 1 -# -# ArenaLogFile -# Log file of arena fights and arena team creations -# Default: "" - do not create arena log file -# -# ArenaLogExtendedInfo -# Extended Info Log file of arena fights and arena team creations -# Default: 0 - extended arena logs off -# 1 - extended arena logs on -# -# -# LogColors -# Color for messages (format "normal_color details_color debug_color error_color") -# Colors: 0 - BLACK, 1 - RED, 2 - GREEN, 3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 - CYAN, 7 - GREY, -# 8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE -# Default: "" - none colors -# Example: "13 7 11 9" -# -# WardenLogFile -# Log file of Warden -# Default: "warden.log" -# "" - Empty name for disable -# -# CheatLogFile -# Log file of passive anticheat -# Default: "cheat.log" -# "" - Empty name for disable -# -# MailLogFile -# Log file of sending in game mails -# Default: "sendmail.log" -# "" - Empty name for disable -# -# GannLogFile -# Log file of guild announce feature -# Default: "guildann.log" -# "" - Empty name for disable -# -# AuctionLogFile -# Log file of auction house -# Default: "auction.log" -# "" - Empty name for disable -# -# DiffLogFile -# Update Diff log file -# Default: "diff.log" -# "" - Empty name for disable -# -# SessionDiffLogFile -# Session update Diff log file -# Default: "sessiondiff.log" -# "" - Empty name for disable -# -# CrashLogFile -# Log file for crash stacktrace -# Default: "crash.log" -# "" - Empty name for disable -# -# DBDiffFile -# Log file for DB Query Duration -# Default: "querydiff.log" -# "" - Empty name for disable -# -# StatusParserFile -# Log file for third party parsers -# Default: "parser.prsr" -# "" - Empty name for disable -# -################################################################################################################### - -LogSQL = 1 -PidFile = "" -LogLevel = 1 -LogTime = 0 -LogFile = "Server.log" -LogTimestamp = 0 -LogFileLevel = 0 -LogFilter_TransportMoves = 1 -LogFilter_CreatureMoves = 1 -LogFilter_VisibilityChanges = 1 -WorldLogFile = "" -DBErrorLogFile = "db_errors.log" -CharLogFile = "characters.log" -CharLogTimestamp = 0 -GmLogFile = "gm_commands.log" -GmLogTimestamp = 0 -GmLogPerAccount = 0 -GmLogMinLevel = 1 -ArenaLogFile = "" -ArenaLogExtendedInfo = 1 -CheatLogFile = "cheat.log" -MailLogFile = "sendmail.log" -GannLogFile = "guildann.log" -WhispLogDir = "whisps/" -LogColors = "" -WardenLogFile = "warden.log" -AuctionLogFile = "auction.log" -DiffLogFile = "diff.log" -SessionDiffLogFile = "sessiondiff.log" -CrashLogFile = "crash.log" -DBDiffFile = "querydiff.log" - -StatusParserFile = "parser.prsr" - -################################################################################################################### -# SERVER SETTINGS -# -# GameType -# Server realm style -# 0 = NORMAL;1 = PVP; 4 = NORMAL; 6 = RP; 8 = RPPVP -# also custom type: 16 FFA_PVP (free for all pvp mode like arena PvP in all zones except rest -# activated places and sanctuaries) -# -# RealmZone -# Server realm zone (set allowed alphabet in character names/etc). See also Strict*Names options. -# -# 1 Development - any language (Default) -# 2 United States - extended-Latin -# 3 Oceanic - extended-Latin -# 4 Latin America - extended-Latin -# 5 Tournament - basic-Latin at create, any at login -# 6 Korea - East-Asian -# 7 Tournament - basic-Latin at create, any at login -# 8 English - extended-Latin -# 9 German - extended-Latin -# 10 French - extended-Latin -# 11 Spanish - extended-Latin -# 12 Russian - Cyrillic -# 13 Tournament - basic-Latin at create, any at login -# 14 Taiwan - East-Asian -# 15 Tournament - basic-Latin at create, any at login -# 16 China - East-Asian -# 17 CN1 - basic-Latin at create, any at login -# 18 CN2 - basic-Latin at create, any at login -# 19 CN3 - basic-Latin at create, any at login -# 20 CN4 - basic-Latin at create, any at login -# 21 CN5 - basic-Latin at create, any at login -# 22 CN6 - basic-Latin at create, any at login -# 23 CN7 - basic-Latin at create, any at login -# 24 CN8 - basic-Latin at create, any at login -# 25 Tournament - basic-Latin at create, any at login -# 26 Test Server - any language -# 27 Tournament - basic-Latin at create, any at login -# 28 QA Server - any language -# 29 CN9 - basic-Latin at create, any at login -# -# Expansion -# Allow server use content from expansion -# 2 - check expansion 2 maps existence, and if client support expansion 2 and account have -# expansion 2 setting then allow visit expansion 2 maps, allow create new class character) -# Default: 1 - check expansion 1 maps existence, and if client support expansion 1 and account have -# expansion 1 setting then allow visit expansion 1 maps, allow create new races character) -# 0 - not check expansion maps existence, not allow wisit its, not allow create new race or new class -# characters, ignore account expansion setting) -# -# DBC.Locale -# DBC Language Settings -# 0 = English; 1 = Korean; 2 = French; 3 = German; 4 = Chinese; 5 = Taiwanese; 6 = Spanish; 7 = Spanish Mexico -# 8 = Russian; 255 = Auto Detect (Default) -# -# DeclinedNames -# Allow russian clients to set and use declined names -# Default: 0 - do not use declined names, except when the Russian RealmZone is set -# 1 - use declined names -# -# StrictPlayerNames -# Limit player name to language specific symbols set, not allow create characters, and set rename request and disconnect at not allowed symbols name -# Default: 0 disable (but limited server timezone dependent client check) -# 1 basic latin characters (strict) -# 2 realm zone specific (strict). See RealmZone setting. -# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts -# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). -# 3 basic latin characters + server timezone specific -# -# StrictCharterNames -# Limit guild/arena team charter names to language specific symbols set, not allow create charters with allowed symbols in name -# Default: 0 disable -# 1 basic latin characters (strict) -# 2 realm zone specific (strict). See RealmZone setting. -# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts -# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). -# 3 basic latin characters + server timezone specific -# -# StrictPetNames -# Limit pet names to language specific symbols set -# Default: 0 disable -# 1 basic latin characters (strict) -# 2 realm zone specific (strict). See RealmZone setting. -# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts -# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). -# 3 basic latin characters + server timezone specific -# -# CharactersCreatingDisabled -# Disable characters creating for specific team or any (non-player accounts not affected) -# Default: 0 - enabled -# 1 - disabled only for Alliance -# 2 - disabled only for Horde -# 3 - disabled for both teams -# -# MaxWhoListReturns -# Set the maximum number of players returned in the /who list and interface. -# Default: 49 (stable) -# -# CharactersPerAccount -# Limit numbers of characters per account (at all realms). -# Note: this setting limit character creating at _current_ realm base at characters amount at all realms -# Default: 50 -# The number must be >= CharactersPerRealm -# -# CharactersPerRealm -# Limit numbers of characters for account at realm -# Default: 10 (client limitation) -# The number must be between 1 and 10 -# -# SkipCinematics -# Disable in-game script movie at first character's login(allows to prevent buggy intro in case of custom start location coordinates) -# Default: 0 - show intro for each new characrer -# 1 - show intro only for first character of selected race -# 2 - disable intro show in all cases -# -# MaxPlayerLevel -# Max level that can be reached by player for experience (in range from 1 to 255). -# Change not recommended -# Default: 70 -# -# StartPlayerLevel -# Staring level that have character at creating (in range 1 to MaxPlayerLevel) -# Default: 1 -# -# StartPlayerMoney -# Amount of money that new players will start with. -# If you want to start with silver, use for example 100 (100 copper = 1 silver) -# Default: 0 -# -# MaxHonorPoints -# Max honor points that player can have. -# Default: 75000 -# -# StartHonorPoints -# Amount of honor that new players will start with -# Default: 0 -# -# MaxArenaPoints -# Max arena points that player can have. -# Default: 5000 -# -# StartArenaPoints -# Amount of arena points that new players will start with -# Default: 0 -# -# InstantLogout -# Enable or disable instant logout for security level (0..4) or high (NOT in combat/while dueling/while falling) -# Default: 1 (Mods/GMs/Admins) -# -# GroupLeaderReconnectPeriod -# The time the leader of a group has to reconnect before the lead goes to another player (also applies for a server crash) -# Default: 180 (seconds) -# -# DisableWaterBreath -# Disable/enable waterbreathing for security level (0..4) or high -# Default: 4 (None) -# -# AllFlightPaths -# Players will start with all flight paths (Note: ALL flight paths, not only player's team) -# Default: 0 (true) -# 1 (false) -# -# AlwaysMaxSkillForLevel -# Players will automatically gain max level dependent (weapon/defense) skill when logging in, leveling up etc. -# Default: 0 (true) -# 1 (false) -# -# ActivateWeather -# Activate weather system -# Default: 1 (true) -# 0 (false) -# -# Battleground.CastDeserter -# Cast or not Deserter spell at player who leave battleground in progress -# Default: 1 (true) -# 0 (false) -# -# Battleground.PrematureReward -# Reward players in case of prematurely finished BG -# Default: 1 (true) -# 0 (false) -# -# Battleground.InvitationType -# Set Battleground invitation type -# Default: 0 (normal - invite as much players to bg as possible, don't bother with ballance) -# 1 (Experimental - don't allow to invite much more players of one faction) -# -# BattleGround.PremadeGroupWaitForMatch -# The time in which premade group of 1 faction waits in BG Queue for premade group of other faction -# Default: 1800000 (30 minutes) -# 0 - disable (not recommended) -# -# CastUnstuck -# Allow cast or not Unstuck spell at .start or client Help option use -# Default: 1 (true) -# 0 (false) -# -# Instance.IgnoreLevel -# Ignore level requirement to enter instance -# Default: 0 (false) -# 1 (true) -# -# Instance.IgnoreRaid -# Ignore raid requirement to enter instance -# Default: 0 (false) -# 1 (true) -# -# Instance.ResetTimeHour -# The hour of the day (0-23) when the global instance resets occur. -# Default: 4 -# -# Instance.UnloadDelay -# Unload the instance map from memory after some time if no players are inside. -# Default: 1800000 (miliseconds, i.e 30 minutes) -# 0 (instance maps are kept in memory until they are reset) -# -# Quests.LowLevelHideDiff -# Quest level difference to hide for player low level quests: -# if player_level > quest_level + LowLevelQuestsHideDiff then quest "!" mark not show for quest giver -# Default: 4 -# -1 (show all available quests marks) -# -# Quests.HighLevelHideDiff -# Quest level difference to hide for player high level quests: -# if player_level < quest_min_level - HighLevelQuestsHideDiff then quest "!" mark not show for quest giver -# Default: 7 -# -1 (show all available quests marks) -# -# MaxPrimaryTradeSkill -# Max count that player can learn the primary trade skill. -# Default: 2 -# Max : 10 -# -# MinPetitionSigns -# Min signatures count to creating guild (0..9). -# Default: 9 -# -# MaxGroupXPDistance -# Max distance to creature for group memeber to get XP at creature death. -# Default: 74 -# -# MailDeliveryDelay -# Mail delivery delay time for item sending -# Default: 3600 sec (1 hour) -# -# ExternalMail -# Enable external mail delivery from mail_external table. -# Default: 0 (disabled) -# 1 (enabled) -# -# ExternalMailInterval -# Mail delivery delay time for item sending from mail_external table, in minutes. -# Default: 1 minute -# -# MailGmInstantSend -# If GM sends mail, recipient receives it instantly -# Default: 1 -# -# SkillChance.Prospecting -# For prospecting skillup not possible by default, but can be allowed as custom setting -# Default: 0 - no skilups -# 1 - skilups possible -# -# Event.Announce -# Default: 0 (false) -# 1 (true) -# -# BeepAtStart -# Beep at core start finished (mostly work only at Unix/Linux systems) -# Default: 1 (true) -# 0 (false) -# -# ShowProgressBars -# Control show progress bars for load steps at server startup -# Default: 1 (true) 0(false) -# -# Motd -# Message of the Day. Displayed at worldlogin for every user ('@' for a newline). -# -# Server.LoginInfo -# Enable/disable sending server info (core version) on login. -# Default: 0 - disable -# 1 - enable -# -# DontDeleteChars -# If enabled characters to delete will be moved to account with id 1 (arena teams, guilds and mails will be deleted, name will be changed). -# Uses stored procedure "PreventCharDelete(characterGuid)" -# Default: 0 - disable -# 1 - enable -# -# DontDeleteCharsLvl -# Minimum character lvl for "DontDeleteChars" option. -# Default: 40 -# -# KeepDeletedCharsTime -# After this time characters from "DontDeleteChars" option will be deleted. (time in days) (0 - infinity) -# Default: 31 -# -# MinGMTextLevel -# Minimum gm lvl for SendGMText. -# Default: 1 -# -# RealmBans -# Enable/Disable realm specific account bans system -# While enabled, .ban command bans account only for specific realm, .unban command can unban accounts, which were banned for this realm only. -# Main disadvantage is absence of correct client message if account banned for specific realm. In this case just disconnect client. -# NOTE: For correct work, must be enabled in auth server config also. -# Default: 0 (Disabled) -# 1 (Enabled) -# -################################################################################################################### - -GameType = 1 -RealmZone = 1 -Expansion = 1 -DBC.Locale = 255 -DeclinedNames = 0 -StrictPlayerNames = 0 -StrictCharterNames = 0 -StrictPetNames = 0 -MaxWhoListReturns = 49 -CharactersCreatingDisabled = 0 -CharactersPerAccount = 50 -CharactersPerRealm = 10 -SkipCinematics = 0 -MaxPlayerLevel = 70 -StartPlayerLevel = 1 -StartPlayerMoney = 0 -MaxHonorPoints = 75000 -StartHonorPoints = 0 -MaxArenaPoints = 5000 -StartArenaPoints = 0 -InstantLogout = 1 -GroupLeaderReconnectPeriod = 180 -DisableWaterBreath = 4 -AllFlightPaths = 0 -AlwaysMaxSkillForLevel = 0 -ActivateWeather = 1 -Battleground.CastDeserter = 1 -Battleground.InvitationType = 1 -BattleGround.PremadeGroupWaitForMatch = 300000 -Battleground.PrematureReward = 1 -CastUnstuck = 1 -Instance.IgnoreLevel = 0 -Instance.IgnoreRaid = 0 -Instance.ResetTimeHour = 4 -Instance.UnloadDelay = 1800000 -Quests.LowLevelHideDiff = 4 -Quests.HighLevelHideDiff = 7 -MaxPrimaryTradeSkill = 2 -MinPetitionSigns = 9 -MaxGroupXPDistance = 74 -MailDeliveryDelay = 3600 -ExternalMail = 0 -ExternalMailInterval = 1 -MailGmInstantSend=1 -SkillChance.Prospecting = 0 -Event.Announce = 0 -BeepAtStart = 1 -ShowProgressBars = 1 -Motd = "HellGround.pl" -Server.LoginInfo = 0 - -DontDeleteChars = 0 -DontDeleteCharsLvl = 40 -KeepDeletedCharsTime = 31 -MinGMTextLevel = 1 -RealmBans = 0 - -################################################################################################################### -# PLAYER INTERACTION -# -# AllowTwoSide.Accounts -# Allow or not accounts to create characters in the 2 teams in any game type. -# Default: 0 (Not allowed) -# 1 (Allowed) -# -# AllowTwoSide.Interaction.Chat -# AllowTwoSide.Interaction.Channel -# AllowTwoSide.Interaction.Group -# AllowTwoSide.Interaction.Guild -# AllowTwoSide.Interaction.Auction -# AllowTwoSide.Interaction.Mail -# Allow or not common :chat(say,yell);channel(chat)group(join)guild(join);merge all auction houses for players from -# different teams, send mail to different team. -# Default: 0 (Not allowed) -# 1 (Allowed) -# -# AllowTwoSide.WhoList -# Allow or not show player from both team in who list. -# Default: 0 (Not allowed) -# 1 (Allowed) -# -# AllowTwoSide.AddFriend -# Allow or not adding friends from other team in friend list. -# Default: 0 (Not allowed) -# 1 (Allowed) -# -# AllowTwoSide.Trade -# Allow or not trading with other team in party. -# Default: 0 (Not allowed) -# 1 (Allowed) -# -# TalentsInspecting -# Allow other players see character talents in inspect dialog (Characters in Gamemaster mode can -# inspect talents always) -# Default: 1 (allow) -# 0 (not allow) -# -# DisableDuel -# Default: 0 (enabled) -# 1 (disabled duel) -# -# DisablePVP -# Disallow players to togle pvp -# Default: 0 (enable) -# 1 (disable pvp) -# -################################################################################################################### - -AllowTwoSide.Accounts = 0 -AllowTwoSide.Interaction.Chat = 0 -AllowTwoSide.Interaction.Channel = 0 -AllowTwoSide.Interaction.Group = 0 -AllowTwoSide.Interaction.Guild = 0 -AllowTwoSide.Interaction.Auction = 0 -AllowTwoSide.Interaction.Mail = 0 -AllowTwoSide.WhoList = 0 -AllowTwoSide.AddFriend = 0 -AllowTwoSide.Trade = 0 -TalentsInspecting = 1 -DisableDuel = 0 -DisablePVP = 0 - -################################################################################################################### -# CREATURE SETTINGS -# -# ThreatRadius -# Radius for creature to evade after being pulled away from combat start point -# If ThreatRadius is less than creature aggro radius then aggro radius will be used -# Default: 60 yards -# -# Rate.Creature.Aggro -# Aggro radius percent or off. -# Default: 1 - 100% -# 1.5 - 150% -# 0 - off (0%) -# -# Rate.Creature.Guard.Aggro -# Aggro radius percent for guards or off. -# 1 - 100% -# Default: 1.5 - 150% -# 0 - off (0%) -# -# CreatureFamilyAssistanceRadius -# Creature family assistance radius -# Default: 10 -# 0 - off -# -# CreatureFamilyAssistanceDelay -# Reaction time for creature assistance call -# Default: 1500 (1.5s) -# -# WorldBossLevelDiff -# Difference for boss dynamic level with target -# Default: 3 -# -# Corpse.Decay.NORMAL -# Corpse.Decay.RARE -# Corpse.Decay.ELITE -# Corpse.Decay.RAREELITE -# Corpse.Decay.WORLDBOSS -# Seconds until creature corpse will decay without being looted or skinned. -# Default: 60, 300, 300, 300, 3600 -# -# Rate.Corpse.Decay.Looted -# Controls how long the creature corpse stays after it had been looted, as a multiplier of its Corpse.Decay.* config. -# Default: 0.5 -# -# Rate.Creature.Normal.Damage -# Rate.Creature.Elite.Elite.Damage -# Rate.Creature.Elite.RAREELITE.Damage -# Rate.Creature.Elite.WORLDBOSS.Damage -# Rate.Creature.Elite.RARE.Damage -# Creature Damage Rates. -# Examples: 2 - creatures will damage 2x, 1.7 - 1.7x. -# -# Rate.Creature.Normal.SpellDamage -# Rate.Creature.Elite.Elite.SpellDamage -# Rate.Creature.Elite.RAREELITE.SpellDamage -# Rate.Creature.Elite.WORLDBOSS.SpellDamag -# Rate.Creature.Elite.RARE.SpellDamage -# Creature Spell Damage Rates. -# Examples: 2 - creatures will damage with spells 2x, 1.7 - 1.7x. -# -# Rate.Creature.Normal.HP -# Rate.Creature.Elite.Elite.HP -# Rate.Creature.Elite.RAREELITE.HP -# Rate.Creature.Elite.WORLDBOSS.HP -# Rate.Creature.Elite.RARE.HP -# Creature Health Ammount Modifier. -# Examples: 2 - creatures have 2x health, 1.7 - 1.7x. -# -# ListenRange.Say -# Distance from player to listen text that creature (or other world object) say -# Default: 25 -# -# ListenRange.TextEmote -# Distance from player to listen textemote that creature (or other world object) say -# Default: 25 -# -# ListenRange.Yell -# Distance from player to listen text that creature (or other world object) yell -# Default: 300 -# -# AutoActive.WaypointMovement.Continents -# AutoActive.WaypointMovement.Instances -# Set to 0 if you don't want to creatures using waypoint movemet become automaticly active -# Default: 1 -# -# AutoActive.Combat.Continents -# AutoActive.Combat.Instances -# Set to 0 if you don't want to creatures in combat to become automaticly active -# Default: 1 -# -# AutoActive.Combat.PlayersOnly -# Set to 1 if you wan't to creatures in combat to become automaticly active only when they have player on target -# Have no effect when both AutoActive.Combat.Continents and AutoActive.Combat.Instances are set to 0 -# Default: 0 -# -# -# MonsterSight -# Dist from which monster can see. -# Default: 50 -# -# GuarderSight -# Dist from which guard can see. -# Default: 50 -# -################################################################################################################### - -ThreatRadius = 60 -Rate.Creature.Aggro = 1 -CreatureFamilyAssistanceRadius = 10 -CreatureFamilyAssistanceDelay = 1500 -WorldBossLevelDiff = 3 -Corpse.Decay.NORMAL = 60 -Corpse.Decay.RARE = 300 -Corpse.Decay.ELITE = 300 -Corpse.Decay.RAREELITE = 300 -Corpse.Decay.WORLDBOSS = 3600 -Rate.Corpse.Decay.Looted = 0.5 -Rate.Creature.Normal.Damage = 1 -Rate.Creature.Elite.Elite.Damage = 1 -Rate.Creature.Elite.RAREELITE.Damage = 1 -Rate.Creature.Elite.WORLDBOSS.Damage = 1 -Rate.Creature.Elite.RARE.Damage = 1 -Rate.Creature.Normal.SpellDamage = 1 -Rate.Creature.Elite.Elite.SpellDamage = 1 -Rate.Creature.Elite.RAREELITE.SpellDamage = 1 -Rate.Creature.Elite.WORLDBOSS.SpellDamage = 1 -Rate.Creature.Elite.RARE.SpellDamage = 1 -Rate.Creature.Normal.HP = 1 -Rate.Creature.Elite.Elite.HP = 1 -Rate.Creature.Elite.RAREELITE.HP = 1 -Rate.Creature.Elite.WORLDBOSS.HP = 1 -Rate.Creature.Elite.RARE.HP = 1 -ListenRange.Say = 40 -ListenRange.TextEmote = 40 -ListenRange.Yell = 300 -AutoActive.WaypointMovement.Continents = 1 -AutoActive.WaypointMovement.Instances = 1 -AutoActive.Combat.Continents = 1 -AutoActive.Combat.Instances = 1 -AutoActive.Combat.PlayersOnly = 0 - -################################################################################################################### -# CHAT SETTINGS -# -# ChatFakeMessagePreventing -# Chat protection from creating fake messages using a lot spaces (other invisible symbols), -# not applied to addon language messages, but can prevent working old addons -# that use normal languages for sending data to another clients. -# Default: 0 (disible fake messages preventing) -# 1 (enabled fake messages preventing) -# -# ChatFlood.MessageCount -# Chat anti-flood protection, haste message count to activate protection -# Default: 10 -# 0 (disible anti-flood protection) -# -# ChatFlood.MessageDelay -# Chat anti-flood protection, minimum message delay to count message -# Default: 1 (in secs) -# -# ChatFlood.MuteTime -# Chat anti-flood protection, mute time at activation flood protection (not saved) -# Default: 10 (in secs) -# -# Channel.RestrictedLfg -# Restrict use LookupForGroup channel only registered in LFG tool players -# Default: 1 (allow join to channel only if active in LFG) -# 0 (allow join to channel in any time) -# -# Channel.SilentlyGMJoin -# Silently join GM characters (security level > 1) to channels -# Default: 0 (join announcement in normal way) -# 1 (GM join without announcement) -# -# Chat.DenyMask -# Mask to disable chat if player don't have required lvl from Chat.MinimumLevel option. -# Default: 0 (don't block anything) -# 1 (say, yell) -# 2 (emote, text emote) -# 4 (party, raid, BG) -# 8 (guild) -# 16 (whisp) -# 32 (channels) -# 64 (addon) -# -# Chat.MinimumLevel -# Minimum level to use chat masked in Chat.DenyMask option. -# Default: 5 -# -# Channel.PrivateLimitCount -# Maximum count of players which can be on private chat channel (without world, engworld, handel channels). -# Type 0 to turn off this feature. -# Default: 20 -# -################################################################################################################### - -ChatFakeMessagePreventing = 0 -ChatFlood.MessageCount = 10 -ChatFlood.MessageDelay = 1 -ChatFlood.MuteTime = 10 -Channel.RestrictedLfg = 1 -Channel.SilentlyGMJoin = 0 -Channel.PrivateLimitCount = 20 - -################################################################################################################### -# GAME MASTER SETTINGS -# -# GM.LoginState -# GM mode at login -# Default: 2 (last save state) -# 0 (disable) -# 1 (enable) -# -# GM.Visible -# GM visibility at login -# Default: 2 (last save state) -# 0 (invisible) -# 1 (visible) -# -# GM.Chat -# GM chat mode at login -# Default: 2 (last save state) -# 0 (disable) -# 1 (enable) -# -# GM.WhisperingTo -# Is GM accepting whispers from player by default or not. -# Default: 2 (last save state) -# 0 (disable) -# 1 (enable) -# -# GM.InGMList -# Is GM showed in GM list (if visible) in non-GM state (.gmoff) -# Default: 0 (false) -# 1 (true) -# -# GM.InWhoList -# Is GM showed in who list (if visible). -# Default: 0 (false) -# 1 (true) -# -# GM.LogTrade -# Include GM trade and trade slot enchanting operations in GM log if it enable -# Default: 1 (include) -# 0 (not include) -# -# GM.StartLevel -# GM starting level (1-255) -# Default: 1 -# -# GM.AllowInvite -# Is GM accepting invites from players by default or not -# Default: 0 (false) -# 1 (true) -# -# GM.AllowFriend -# Are players allowed to add GMs to their friend list -# Default: 0 (false) -# 1 (true) -# -# GM.TrustedLevel -# On which security level give access to additional player data -# Default: 3 (rootgm) -################################################################################################################### - -GM.LoginState = 2 -GM.Visible = 2 -GM.Chat = 2 -GM.WhisperingTo = 2 -GM.InGMList = 0 -GM.InWhoList = 0 -GM.LogTrade = 1 -GM.StartLevel = 70 -GM.AllowInvite = 0 -GM.AllowFriend = 0 -GM.TrustedLevel = 3 - -################################################################################################################### -# VISIBILITY AND RADIUSES -# -# Visibility.GroupMode -# Group visibility modes -# Default: 0 (standard setting: only members from same group can 100% auto detect invisible player) -# 1 (raid members 100% auto detect invisible player from same raid) -# 2 (players from same team can 100% auto detect invisible player) -# -# Visibility.Distance.Object -# Visible distance for gameobject, dynobject, bodies, corpses, bones -# Min limit is iteraction distance (5) -# -# Visibility.Distance.InFlight -# Visible distance for player in flight -# Min limit is 0 (not show any objects) -# -# Visibility.Distance.Grey.Unit -# Visibility grey distance for creatures/players (fast changing objects) -# addition to appropriate object type Visibility.Distance.* use in case visibility removing to -# object (except corpse around distences) If D is distance and G is grey distance then object -# make visible if distance to it <= D but make non visible if distance > D+G -# Default: 1 (yard) -# -# Visibility.Distance.Grey.Object -# Visibility grey distance for dynobjects/gameobjects/corpses/creature bodies -# Default: 10 (yards) -# -# Visibility.Distance.ActiveObjectUpdate.Continents -# Visibility.Distance.ActiveObjectUpdate.Instances -# Range in which objects around active objects (not players) will be updated -# -# -################################################################################################################### - -Visibility.GroupMode = 0 - -Visibility.Distance.ActiveObjectUpdate.Continents = 132 -Visibility.Distance.ActiveObjectUpdate.Instances = 132 - -################################################################################################################### -# MOVEMENT -# -# Movement.RecalculateRange -# Minimal range after which creature will recalculate movement for chase/follow movegen, higher = less stress on CPU -# Default: 1 (yards) -# Range: 0-5 (yards) -# -# Movement.RecheckTimer -# How often perform check, if target moved and wee need to updte our destination -# Default: 100 (ms) -# -################################################################################################################### - -Movement.RecalculateRange = 1 -Movement.RecheckTimer = 100 - -# Movement..WaypointPathfinding.* -# Decides if WaypointMovegen have to generate movepath between nodes ot go in straight line -# Default: 1 (on) - -Movement.WaypointPathfinding.Continents = 1 -Movement.WaypointPathfinding.Instances = 1 - -################################################################################################################### -# COREBALANCER -# -# CoreBalancer.Enable -# Allows or not core to improve performance by disabling features -# Default: 0 - disabled -# 1 - enabled -# -# CoreBalancer.PlayableDiff -# When server average diff is higher than this value balancing will be performed -# Default: 200 -# -# CoreBalancer.BalanceInterval -# Interval after which average diff will be checked against playable diff and balance if needed performed -# Default: 300000 (ms) -# -# CoreBalancer.VisibilityPenalty -# Penalty to all visibilities on specific treshold -# Default: 25 (yards) -# -################################################################################################################### - -CoreBalancer.Enable = 0 -CoreBalancer.PlayableDiff = 200 -CoreBalancer.BalanceInterval = 300000 -CoreBalancer.VisibilityPenalty = 25 - -################################################################################################################### -# SERVER RATES -# -# Rate.Health -# Rate.Mana -# Rate.Rage.Income -# Rate.Rage.Loss -# Rate.Focus -# Rate.Loyalty -# Health and power regeneration and rage income from damage. -# Default: 1 -# -# Rate.Skill.Discovery -# Skill Discovery Rates -# Default: 1 -# -# Rate.Drop.Item.Poor -# Rate.Drop.Item.Normal -# Rate.Drop.Item.Uncommon -# Rate.Drop.Item.Rare -# Rate.Drop.Item.Epic -# Rate.Drop.Item.Legendary -# Rate.Drop.Item.Artifact -# Rate.Drop.Item.Referenced -# Rate.Drop.Money -# Drop rates (items by quality and money) -# Default: 1 -# -# Rate.Drop.Money -# Drop rates -# Default: 1 -# -# Rate.XP.Kill -# Rate.XP.Quest -# Rate.XP.Explore -# XP rates -# Default: 1 -# -# Rate.XP.PastLevel70 -# XP needed per level past 70 (Rates below 1 not recommended) -# Default: 1 -# -# Rate.Rest.InGame -# Rate.Rest.Offline.InTavernOrCity -# Rate.Rest.Offline.InWilderness -# Resting points grow rates (1 - normal, 2 - double rate, 0.5 - half rate, etc) from standard values -# -# Rate.Damage.Fall -# Damage after fall rate. (1 - standard, 2 - double damage, 0.5 - half damage, etc) -# -# Rate.Auction.Time -# Rate.Auction.Deposit -# Rate.Auction.Cut -# Auction rates (auction time, deposit get at auction start, auction cut from price at auction end) -# -# Rate.Honor -# Honor gain rate -# -# Rate.Mining.Amount -# Rate.Mining.Next -# Mining Rates (Mining.Amount changes minimum/maximum usetimes of a deposit, -# Mining.Next changes chance to have next use of a deposit) -# -# Rate.Talent -# Talent Point rates -# Default: 1 -# -# Rate.Reputation.Gain -# Reputation Gain rate -# Default: 1 -# -# Rate.Reputation.LowLevel.Kill -# Reputation Gain form low level kill (grey creture) -# Default: 0.2 -# -# Rate.Reputation.LowLevel.Quest -# Reputation Gain rate -# Default: 1 -# -# Rate.InstanceResetTime -# Multiplier for the number of days in between global raid/heroic instance resets. -# Default: 1 -# -# SkillGain.Crafting -# SkillGain.Defense -# SkillGain.Gathering -# SkillGain.Weapon -# crafting/defense/gathering/weapon skills gain at skill grow (1,2,...) -# Default: 1 -# -# SkillChance.Orange -# SkillChance.Yellow -# SkillChance.Green -# SkillChance.Grey -# Skill chance values (0..100) -# Default: 100-75-25-0 -# -# SkillChance.MiningSteps -# SkillChance.SkinningSteps -# For skinning and Mining chance decrease with skill level. -# Default: 0 - no decrease -# 75 - in 2 times each 75 skill points -# -# DurabilityLossChance.Damage -# Chance lost one from equiped items durability point at damage apply or receive. -# Default: 0.5 (100/0.5 = 200) Each 200 damage apply one from 19 possible equipped items -# -# DurabilityLossChance.Absorb -# Chance lost one from armor items durability point at damage absorb. -# Default: 0.5 (100/0.5 = 200) Each 200 absorbs apply one from 15 possible armor equipped items -# -# DurabilityLossChance.Parry -# Chance lost weapon durability point at parry. -# Default: 0.05 (100/0.05 = 2000) Each 2000 parry attacks main weapon lost point -# -# DurabilityLossChance.Block -# Chance lost sheild durability point at damage block. -# Default: 0.05 (100/0.05 = 2000) Each 2000 partly or full blocked attacks shield lost point -# -# Death.SicknessLevel -# Starting Character start gain sickness at spirit resurrection (1 min) -# Default: 11 -# -10 - character will have full time (10min) sickness at 1 level -# maxplayerlevel+1 - chaarcter will not have sickess at any level -# -# Death.CorpseReclaimDelay.PvP -# Death.CorpseReclaimDelay.PvE -# Enabled/disabled increase corpse reclaim delay at often PvP/PvE deaths -# Default: 1 (enabled) -# 0 (disabled) -# -# Death.Bones.World -# Death.Bones.BattlegroundOrArena -# Enabled/disabled creating bones instead corpse at resurrection (in normal zones/instacnes, or battleground/arenas) -# Default: 1 (enabled) -# 0 (disabled) -# -################################################################################################################### - -Rate.Health = 1 -Rate.Mana = 1 -Rate.Rage.Income = 1 -Rate.Rage.Loss = 1 -Rate.Focus = 1 -Rate.Loyalty = 1 -Rate.Skill.Discovery = 1 -Rate.Drop.Item.Poor = 1 -Rate.Drop.Item.Normal = 1 -Rate.Drop.Item.Uncommon = 1 -Rate.Drop.Item.Rare = 1 -Rate.Drop.Item.Epic = 1 -Rate.Drop.Item.Legendary = 1 -Rate.Drop.Item.Artifact = 1 -Rate.Drop.Item.Referenced = 1 -Rate.Drop.Money = 1 -Rate.XP.Kill = 1 -Rate.XP.Quest = 1 -Rate.XP.Explore = 1 -Rate.XP.PastLevel70 = 1 -Rate.Rest.InGame = 1 -Rate.Rest.Offline.InTavernOrCity = 1 -Rate.Rest.Offline.InWilderness = 1 -Rate.Damage.Fall = 1 -Rate.Auction.Time = 1 -Rate.Auction.Deposit = 1 -Rate.Auction.Cut = 1 -Rate.Honor = 1 -Rate.Mining.Amount = 1 -Rate.Mining.Next = 1 -Rate.Talent = 1 -Rate.Reputation.Gain = 1 -Rate.Reputation.LowLevel.Kill = 0.2 -Rate.Reputation.LowLevel.Quest = 1 -Rate.InstanceResetTime = 1 -SkillGain.Crafting = 1 -SkillGain.Defense = 1 -SkillGain.Gathering = 1 -SkillGain.Weapon = 1 -SkillChance.Orange = 100 -SkillChance.Yellow = 75 -SkillChance.Green = 25 -SkillChance.Grey = 0 -SkillChance.MiningSteps = 0 -SkillChance.SkinningSteps = 0 -DurabilityLossChance.Damage = 0.5 -DurabilityLossChance.Absorb = 0.5 -DurabilityLossChance.Parry = 0.05 -DurabilityLossChance.Block = 0.05 -Death.SicknessLevel = 11 -Death.CorpseReclaimDelay.PvP = 1 -Death.CorpseReclaimDelay.PvE = 0 -Death.Bones.World = 1 -Death.Bones.BattlegroundOrArena = 1 - -################################################################################################################### -# -# Rated arena matches config -# -# MaxRatingDifference: the maximum rating difference between two groups in rated matches -# Default: 0 (disable, rating difference is discarded) -# -# RatingDiscardTimer: after the specified milliseconds has passed, -# rating information will be discarded when selecting teams for matches -# also initiates an update by this timer -# Default: 60000 -# -# AutoDistributePoints: set if arena points should be distributed automatically, or by GM command -# Default: 0 (disable) (recommended): use gm command or sql query to distribute the points -# 1 (enable): arena points are distributed automatically -# -# AutoDistributeInterval: how often should the distribution take place -# if automatic distribution is enabled -# in days -# Default: 7 (weekly) -# -# EnableMMR: MMR (Matchmaking rating) should be enabled ? -# Default: 0 (disabled) -# -# EnableMMRPenalty: MMRPenalty check should be enabled ? -# Default: 0 (disabled) -# -# EnableMMRPenalty: MMR Penalty applied to MMR if MMR > teamRating + penalty -# Default: 0 (disabled) -# -# EnableFakeWho: Enables/Disables fake who list to fake real position of players in arena -# Default: 0 (disabled) -# -# EnableFakeWho.ForGuild: Adds guild roster support for above option -# Default: 0 (disabled) -# -################################################################################################################### - -Arena.MaxRatingDifference = 0 -Arena.RatingDiscardTimer = 60000 -Arena.AutoDistributePoints = 0 -Arena.AutoDistributeInterval = 7 - -Arena.EnableMMR = 0 -Arena.EnableMMRPenalty = 0 -Arena.MMRPenalty = 150 -Arena.MMRSpecialLossCalc = 0 - -Arena.EnableFakeWho = 0 -Arena.EnableFakeWho.ForGuild = 0 - -################################################################################################################### -# -# Battleground config -# -# PrematureFinishTimer: the time to end the bg if there are less than minplayersperteam on one side -# in milliseconds -# Default: 300000 -# 0 - disable -# -# BattleGround.AnnounceStart: Accounces bg start. -# Default: 0 - disable -# 1 - enable -# -# BattleGround.QueueInfo: sends info about queue on queue join -# Default: 0 - disable -# 1 - enable -# -################################################################################################################### - -BattleGround.PrematureFinishTimer = 300000 -BattleGround.AnnounceStart = 0 -BattleGround.QueueInfo = 0 - -################################################################################################################### -# -# NETWORK CONFIG -# -# Network.Threads -# Number of threads for network, recommend 1 thread per 1000 connections. -# Default: 1 -# -# Network.OutKBuff -# The size of the output kernel buffer used ( SO_SNDBUF socket option, tcp manual ). -# Default: -1 (Use system default setting) -# -# Network.OutUBuff -# Userspace buffer for output. This is amount of memory reserved per each connection. -# Default: 65536 -# -# Network.TcpNoDelay: -# TCP Nagle algorithm setting -# Default: 0 (enable Nagle algorithm, less traffic, more latency) -# 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency) -# -# Network.KickOnBadPacket -# Kick player on bad packet format. -# Default: 0 - do not kick -# 1 - kick -# -################################################################################################################### - -Network.Threads = 1 -Network.OutKBuff = -1 -Network.OutUBuff = 65536 -Network.TcpNodelay = 1 -Network.KickOnBadPacket = 1 - -################################################################################################################### -# CUSTOM SERVER OPTIONS -# -# PlayerStart.AllReputation -# Players will start with most of the high level reputations that are needed for items, mounts etc. -# If there are any reputation faction you want to be added, just tell me. -# -# PlayerStart.AllSpells -# If enabled, players will start with all their class spells (not talents). Useful for instant 70 servers. -# You must import playercreateinfo_spell_custom.sql, it's included in the SQL folder. -# Default: 0 - off -# 1 - on -# -# PlayerStart.MapsExplored -# Players will start with all maps explored if enabled -# -# MusicInBattleground -# If enabled, "L70ETC - Power of the horde" will be played when BG starts ;) -# -# HonorPointsAfterDuel -# The amount of honor points the duel winner will get after a duel. -# Default: 0 - disable -# -# AlwaysMaxWeaponSkill -# Players will automatically gain max weapon/defense skill when logging in, leveling up etc. -# -# PvPToken.Enable -# Enable/disable PvP Token System. Players will get a token after slaying another player that gives honor. -# -# PvPToken.MapAllowType -# Where players can receive the pvp token -# 4 - In all maps -# 3 - In battlegrounds only -# 2 - In FFA areas only (gurubashi arena etc) -# 1 - In battlegrounds AND FFA areas only -# -# PvPToken.ItemID -# The item players will get after killing someone if PvP Token system is enabled. -# Default: 29434 - Badge of justice -# -# PvPToken.ItemCount -# Modify the item ID count - Default: 1 -# -# NoResetTalentsCost -# Enable or disable no cost when reseting talents -# -# ForbiddenMaps -# map ids that users below SEC_GAMEMASTER cannot enter, with delimiter ',' -# Default: "" -# example: "538,90" -# Note that it's HIGHLY DISCOURAGED to forbid starting maps (0, 1, 530)! -# -# ShowKickInWorld -# determines wether a message is broadcasted to the entire server when a player gets kicked -# Default: 0 -# 1 = Enable -# 0 = Disable -# -# RecordUpdateTimeDiffInterval -# record update time diff to the log file -# update diff can be used as a criterion of performance -# diff < 300: good performance -# diff > 600: bad performance, may be caused by high cpu usage -# Default: 60000 (diff is written into log every 60000 ms or 1 minute. -# >0 = Interval -# 0 = Disable -# -# MinRecordUpdateTimeDiff -# only record update time diff which is greater than this value -# -# MinRecordUpdateTimeSessionDiff -# only record session update time diff which is greater than this value -# -# PlayerStart.String -# If set to anything else than "", this string will be displayed to players when they login -# to a newly created character. -# Default: "" - send no text -# -################################################################################################################### - -PlayerStart.AllReputation = 0 -PlayerStart.AllSpells = 0 -PlayerStart.MapsExplored = 0 -MusicInBattleground = 0 -HonorPointsAfterDuel = 0 -AlwaysMaxWeaponSkill = 0 -PvPToken.Enable = 0 -PvPToken.MapAllowType = 4 -PvPToken.ItemID = 29434 -PvPToken.ItemCount = 1 -NoResetTalentsCost = 0 -ShowKickInWorld = 0 -RecordUpdateTimeDiffInterval = 60000 -MinRecordUpdateTimeDiff = 10 -MinRecordUpdateTimeSessionDiff = 25 -PlayerStart.String = "" - -################################################################################################################### -# Virtual map serving system (VMSS) configuration -# -# VMSS.Enable -# Enabling VMSS support (signals handling) -# Default: 0 - off -# 1 - on -# -# VMSS.MapFreeMethod -# Method for freeing breaked map -# 0 - safe cleaning (clean auras, save and logout player) -# 1 - not safe cleaning (kick players, not clean auras, not save players/worldstates) -# 2 - not safe cleaning (another type - logout players without save) -# Default: 0 -# -# VMSS.FreezeCheckPeriod -# Time period (in milliseconds) for activate FreezeDetect thread -# Default: 1000 (1 sec) - default mangos freeze detect period. -# -# VMSS.MapFreezeDetectTime -# Time (in milliseconds) for detect freeze in map thread -# Default: 1000 (1 sec) -# -################################################################################################################### - -VMSS.Enable = 0 -VMSS.MapFreeMethod = 0 -VMSS.FreezeCheckPeriod = 1000 -VMSS.MapFreezeDetectTime = 1000 - -################################################################################################################### -# -# AutoBroadcast.Timer -# set interval between sending next advertising on chat(in minutes) -# 0 = disable autoannounce (default) -# -# Auction.EnableSort -# Enable or disable auctions sorting feature. -# 1 = enable sorting (default) -# 0 = disable sorting -# -# Mail.OldReturnMode -# 0 - Return old mails only once per day. -# 1 - Return old mails based on Mail.ReturnTimer. -# Default: 1 -# -# Mail.OldReturnTimer -# If Mail.OldReturnMode is set to 1 then this value contains time beatween each old mails return attempt (in seconds). -# Default: 60 -# -# Warden.Enabled -# Enable warden anticheat -# Default: 1 (Enabled) -# 0 (Disabled) -# -# Warden.Kick -# Kick player on failed check -# Default: 0 (Disabled) -# 1 (Enabled) -# -# Warden.Ban -# Ban player on failed check -# Default: 0 (Disabled) -# 1 (Enabled) -# -# AntiCheat.Enable -# Enable passive anticheat -# Default: 1 (Enabled) -# 0 (Disabled) -# -# GuildAnnounce.Timer -# Interval beetwean guild announces (in minutes) -# Default: 1 -# -# GuildAnnounce.Cooldown -# Cooldown beetwean guild announces from same guild (in minutes) -# Default: 60 -# -# GuildAnnounce.Length -# Maximum length of guild announce message -# Default: 60 -# -################################################################################################################### - -AutoBroadcast.Timer = 0 -Auction.EnableSort = 1 - -Mail.OldReturnMode = 0 -Mail.OldReturnTimer = 60 - -Warden.Enabled = 1 -Warden.Kick = 0 -Warden.Ban = 0 - -AntiCheat.Enable = 1 - -# Creature.RestoreStateTimer -# Timer after which creature will restore its original state from PASSIVE after reaching home -# Default: 5000 - -Creature.RestoreStateTimer = 5000 +############################################ +# Hellground Core world configuration file # +############################################ +[CoreConf] +ConfVersion=2014022101 + +################################################################################################################### +# DATABASES AND DIRECTORIES +# +# RealmID +# RealmID must match the realmlist inside the realmd database +# +# DataDir +# Data directory setting. +# Important: DataDir needs to be quoted, as it is a string which may contain space characters. +# Important: In linux daemon mode string must be full path. +# Example: "/share/hellgroundcore" +# +# LogsDir +# Logs directory setting. +# Important: Logs dir must exists, or all logs need to be disabled +# Default: "" - no log directory prefix, if used log names isn't absolute path +# then logs will be stored in current directory for run program. +# +# +# LoginDatabaseInfo +# WorldDatabaseInfo +# CharacterDatabaseInfo +# Database connection settings for the world server. +# Default: hostname;port;username;password;database +# .;somenumber;username;password;database - use named pipes at Windows +# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini +# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux +# Unix sockets: experimental, not tested +# +# LoginDatabaseConnections +# WorldDatabaseConnections +# CharacterDatabaseConnections +# Amount of connections to database which will be used for SELECT queries. Maximum 16 connections per database. +# Please, note, for data consistency only one connection for each database is used for transactions and async SELECTs. +# So formula to find out how many connections will be established: X = �_connections + 1 +# Default: 1 connection for SELECT statements +# +# MaxPingTime +# Settings for maximum database-ping interval (minutes between pings) +# +# WorldServerPort +# Default 8085 +# +# BindIP +# Bind World Server to IP/hostname +# +################################################################################################################### + +RealmID = 1 +DataDir = "." +LogsDir = "" +LoginDatabaseInfo = "127.0.0.1;3306;username;password;realmd" +WorldDatabaseInfo = "127.0.0.1;3306;username;password;world" +CharacterDatabaseInfo = "127.0.0.1;3306;username;password;characters" +LoginDatabaseConnections = 1 +WorldDatabaseConnections = 1 +CharacterDatabaseConnections = 1 +MaxPingTime = 30 +WorldServerPort = 8085 +BindIP = "0.0.0.0" + +################################################################################################################### +# SERVER LOGGING +# +# LogSQL +# Enable logging of GM commands - all SQL code will be written to a log file +# All commands are written to a file: YYYY-MM-DD_logSQL.sql +# If a new day starts (00:00:00) then a new file is created - the old file will not be deleted. +# Default: 1 - Write SQL code to logfile +# 0 - Do not log +# +# PidFile +# World daemon PID file +# Important: In linux daemon mode string must be full path. +# Default: "" - do not create PID file +# "./worldd.pid" - create PID file (recommended name) +# +# LogTime +# Include time in server console output [hh:mm:ss] +# Default: 0 (no time) +# 1 (print time) +# +# GmLogFile +# Log file of gm commands +# Default: "gm_commands.log" +# "" - Empty name for disable +# +# LogFile +# Main log file name +# Default: "Server.log" +# "" - Empty name for disable +# +# StatusParserFile +# Log file for third party parsers +# Default: "parser.prsr" +# "" - Empty name for disable +# +# CharLogFile +# Character operations log file name +# Default: "Char.log" +# "" - Empty name for disable +# +# DBErrorLogFile +# Log file of DB errors detected at server run +# Default: "DBErrors.log" +# "" - Empty name for disable +# +# ArenaLogFile +# Log file of arena fights and arena team creations +# Default: "" - Empty name for disable +# +# CheatLogFile +# Log file of passive anticheat +# Default: "cheat.log" +# "" - Empty name for disable +# +# SpecialLogFile +# Log for special use +# Default: "" - Empty name for disable +# +# MailLogFile +# Log file of sending in game mails (don't store informations about items/money - for this use TradeLogFile !) +# Default: "sendmail.log" +# "" - Empty name for disable +# +# GannLogFile +# Log file of guild announce feature +# Default: "guildann.log" +# "" - Empty name for disable +# +# BossLogFile +# Log file of boss fights/ loots +# Default: "" - Empty name for disable +# +# WardenLogFile +# Log file of Warden +# Default: "warden.log" +# "" - Empty name for disable +# +# AuctionLogFile +# Log file of auction house +# Default: "auction.log" +# "" - Empty name for disable +# +# DiffLogFile +# Update Diff log file +# Default: "diff.log" +# "" - Empty name for disable +# +# SessionDiffLogFile +# Session update Diff log file +# Default: "sessiondiff.log" +# "" - Empty name for disable +# +# CrashLogFile +# Log file for crash stacktrace +# Default: "crash.log" +# "" - Empty name for disable +# +# DBDiffFile +# Log file for DB Query Duration +# Default: "querydiff.log" +# "" - Empty name for disable +# +# ExpLogFile +# Log file for exp gain +# Default: "exp.log" +# "" - Empty name for disable +# +# TradeLogFile +# Log file for trading items/money via trade/mail option +# Default: "trade.log" +# "" - Empty name for disable +# +# RaceChangeLogFile +# Log file for changing race +# Default: "race_change.log" +# "" - Empty name for disable +# +# WhispLogDir +# Directory for whisp logs +# Default: "whisps/" +# +# GmLogTimestamp +# LogTimestamp +# CharLogTimestamp +# Should starting timestamp be added to log names (for GmLogFile,LogFile, CharLogFile) +# Default: 0 - no timestamp in name +# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext +# +# LogFileLevel +# Main log level +# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug +# Default: 0 +# +# LogFilter_TransportMoves +# LogFilter_CreatureMoves +# LogFilter_VisibilityChanges +# Log filters +# Default: 1 - not include with any log level +# 0 - include in log if log level permit +# +# GmLogPerAccount +# GM Logfiles with GM account id (Note: logs not created if GmLogFile not set) +# Default: 0 - add gm log data to single log file +# 1 - add gm log data to account specific log files with name +# in form Logname_#ID_YYYY-MM-DD_HH-MM-SS.Ext +# or form Logname_#ID.Ext +# +# GmLogMinLevel +# Min GM Level to log commands +# Default: 1 +# +# DBDiffLog.LogTime +# Query who reaches the Time will be Logged +# Is a kind of SlowQueryLog. Time in ms. +# Default: 10 +# +# EventAI Error reporting +# 0 - Only startup (Default) +# 1 - Startup errors and Runtime event errors +# 2 - Startup errors, Runtime event errors, and Creation errors +# +################################################################################################################### + +LogSQL = 1 +PidFile = "" +LogTime = 0 + +GmLogFile = "gm_commands.log" +LogFile = "Server.log" +StatusParserFile = "parser.prsr" +CharLogFile = "characters.log" +DBErrorLogFile = "db_errors.log" +ArenaLogFile = "" +CheatLogFile = "cheat.log" +SpecialLogFile = "special.log" +MailLogFile = "sendmail.log" +GannLogFile = "guildann.log" +BossLogFile = "boss.log" +WardenLogFile = "warden.log" +AuctionLogFile = "auction.log" +DiffLogFile = "diff.log" +SessionDiffLogFile = "sessiondiff.log" +CrashLogFile = "crash.log" +DBDiffFile = "querydiff.log" +ExpLogFile = "exp.log" +TradeLogFile = "trade.log" +RaceChangeLogFile = "race_change.log" +WhispLogDir = "whisps/" + +GmLogTimestamp = 0 +LogTimestamp = 0 +CharLogTimestamp = 0 +LogFileLevel = 0 +LogFilter_TransportMoves = 1 +LogFilter_CreatureMoves = 1 +LogFilter_VisibilityChanges = 1 +GmLogPerAccount = 0 +GmLogMinLevel = 1 + +DBDiffLog.LogTime = 10 +EAIErrorLevel = 0 + +################################################################################################################### +# PERFORMANCE SETINGS +# +# UseProcessors +# Used processors mask for multi-processors system (Used only at Windows) +# Default: 0 (selected by OS) +# number (bitmask value of selected processors) +# +# ProcessPriority +# Process priority setting (Used only at Windows) +# Default: 1 (HIGH) +# 0 (Normal) +# +# Compression +# Compression level for update packages sent to client (1..9) +# Default: 1 (speed) +# 9 (best compression) +# +# PlayerLimit +# Maximum number of players in the world. Excluding Mods, GM's and Admins +# Default: 100 +# 0 (for infinite players) +# -1 (for Mods, GM's and Admins only) +# -2 (for GM's and Admins only) +# -3 (for Admins only) +# +# AddonChannel +# Permit/disable the use of the addon channel through the server +# (some client side addons can stop work correctly with disabled addon channel) +# Default: 1 (permit addon channel) +# 0 (do not permit addon channel) +# +# SaveRespawnTimeImmediately +# Save respawn time for creatures at death and for gameobjects at use/open +# Default: 1 (save creature/gameobject respawn time without waiting grid unload) +# 0 (save creature/gameobject respawn time at grid unload) +# +# MaxOverspeedPings +# Maximum overspeed ping count before player kick (minimum is 2, 0 used for disable check) +# Default: 2 +# +# GridUnload +# Unload grids (if you have lot memory you can disable it to speed up player move to new grids second time) +# Default: 1 (unload grids) +# 0 (do not unload grids) +# +# SocketSelectTime +# Socket select time (in milliseconds) +# Default: 10000 +# +# GridCleanUpDelay +# Grid clean up delay (in milliseconds) +# Default: 300000 (5 min) +# +# MapUpdateInterval +# Map update interval (in milliseconds) +# Default: 100 +# +# ChangeWeatherInterval +# Weather update interval (in milliseconds) +# Default: 600000 (10 min) +# +# PlayerSaveInterval +# Player save interval (in milliseconds) +# Default: 900000 (15 min) +# +# DisconnectToleranceInterval +# Tolerance for disconnected players before putting in the queue. (in seconds) +# Default: 0 (disabled) +# +# UpdateUptimeInterval +# Update realm uptime period in minutes (for save data in 'uptime' table). Must be > 0 (in minutes) +# Default: 10 +# +# MapUpdate.Threads +# Number of threads to update maps. +# Default: 1 +# +# MapUpdate.UpdateVisitorsMax +# Max number of creatures updated by single visitor. +# Default: 20 +# +# MapUpdate.CumulativeLogMethod +# Activate a more detailed Log Feature for Map Update +# Requires define MAP_UPDATE_DIFF_INFO +# Default: 0 Log will be Printed as Sum on each RecordUpdateTimeDiffInterval +# 1 Log will be Printed on each Map Update Cycle +# +# SessionUpdate.Threads +# Number of threads to update sessions (0 - disable). +# WARNING: DON'T use if you don't know what you are doing ... this feature waits for +# necessary improvements. +# Default: 0 +# +# SessionUpdate.MaxTime +# Max time to update sessions. If session update time will be greater then method from +# SessionUpdate.Method will be called. (in milliseconds) +# Default: 1000 +# +# SessionUpdate.Method +# Method to call when single session update time will be greater than SessionUpdate.MaxTime. +# 0 - Do nothing +# 1 - Log +# 2 - Kick player + log +# 3 - Ban account + log (Default) +# 4 - Ban ip and account + log +# +# SessionUpdate.VerboseLog +# Enables session verbose log (prints to session diff log file if max time was exceeded) +# Default: 0 (disabled) +# 1 Log if diff is greater then SessionUpdate.MaxTime +# 2 Log if diff is greater then SessionUpdate.MinLogDiff +# +# SessionUpdate.IdleKickTimer +# Max time that user can spend in character selection screen (in milliseconds) +# Default: 900000 (15 min) +# +# SessionUpdate.MinLogDiff +# Min diff time for session to be logged (in milliseconds) +# Default: 25 +# +# RecordUpdateTimeDiffInterval +# record update time diff to the log file +# update diff can be used as a criterion of performance +# diff < 300: good performance +# diff > 600: bad performance, may be caused by high cpu usage +# Default: 60000 (diff is written into log every 60000 ms or 1 minute. +# >0 = Interval +# 0 = Disable +# +# MinRecordUpdateTimeDiff +# only record update time diff which is greater than this value (in milliseconds) +# Default: 300 +# +################################################################################################################### + +UseProcessors = 0 +ProcessPriority = 1 +Compression = 1 +PlayerLimit = 100 +SaveRespawnTimeImmediately = 1 +AddonChannel = 1 +MaxOverspeedPings = 2 +GridUnload = 1 + +SocketSelectTime = 10000 +GridCleanUpDelay = 300000 +MapUpdateInterval = 100 +ChangeWeatherInterval = 600000 +PlayerSaveInterval = 900000 +DisconnectToleranceInterval = 0 +UpdateUptimeInterval = 10 + +MapUpdate.Threads = 1 +MapUpdate.UpdateVisitorsMax = 20 +MapUpdate.CumulativeLogMethod = 0 + +SessionUpdate.Threads = 1 +SessionUpdate.MaxTime = 1000 +SessionUpdate.Method = 3 +SessionUpdate.VerboseLog = 0 +SessionUpdate.IdleKickTimer = 900000 +SessionUpdate.MinLogDiff = 25 +RecordUpdateTimeDiffInterval = 60000 +MinRecordUpdateTimeDiff = 300 + +################################################################################################################### +# SERVER SETTINGS +# +# GameType +# Server realm style +# 0 = NORMAL;1 = PVP; 4 = NORMAL; 6 = RP; 8 = RPPVP +# also custom type: 16 FFA_PVP (free for all pvp mode like arena PvP in all zones except rest +# activated places and sanctuaries) +# +# RealmZone +# Server realm zone (set allowed alphabet in character names/etc). See also Strict*Names options. +# +# 1 Development - any language (Default) +# 2 United States - extended-Latin +# 3 Oceanic - extended-Latin +# 4 Latin America - extended-Latin +# 5 Tournament - basic-Latin at create, any at login +# 6 Korea - East-Asian +# 7 Tournament - basic-Latin at create, any at login +# 8 English - extended-Latin +# 9 German - extended-Latin +# 10 French - extended-Latin +# 11 Spanish - extended-Latin +# 12 Russian - Cyrillic +# 13 Tournament - basic-Latin at create, any at login +# 14 Taiwan - East-Asian +# 15 Tournament - basic-Latin at create, any at login +# 16 China - East-Asian +# 17 CN1 - basic-Latin at create, any at login +# 18 CN2 - basic-Latin at create, any at login +# 19 CN3 - basic-Latin at create, any at login +# 20 CN4 - basic-Latin at create, any at login +# 21 CN5 - basic-Latin at create, any at login +# 22 CN6 - basic-Latin at create, any at login +# 23 CN7 - basic-Latin at create, any at login +# 24 CN8 - basic-Latin at create, any at login +# 25 Tournament - basic-Latin at create, any at login +# 26 Test Server - any language +# 27 Tournament - basic-Latin at create, any at login +# 28 QA Server - any language +# 29 CN9 - basic-Latin at create, any at login +# +# Expansion +# Allow server use content from expansion +# 2 - check expansion 2 maps existence, and if client support expansion 2 and account have +# expansion 2 setting then allow visit expansion 2 maps, allow create new class character) +# Default: 1 - check expansion 1 maps existence, and if client support expansion 1 and account have +# expansion 1 setting then allow visit expansion 1 maps, allow create new races character) +# 0 - not check expansion maps existence, not allow visit it, not allow create new race or new class +# characters, ignore account expansion setting) +# +# Locale +# DBC Language Settings +# 0 = English; 1 = Korean; 2 = French; 3 = German; 4 = Chinese; 5 = Taiwanese; 6 = Spanish; 7 = Spanish Mexico +# 8 = Russian; 255 = Auto Detect (Default) +# +# DeclinedNames +# Allow russian clients to set and use declined names +# Default: 0 - do not use declined names, except when the Russian RealmZone is set +# 1 - use declined names +# +# StrictPlayerNames +# Limit player name to language specific symbols set, not allow create characters, and set rename request and disconnect at not allowed symbols name +# Default: 0 disable (but limited server timezone dependent client check) +# 1 basic latin characters (strict) +# 2 realm zone specific (strict). See RealmZone setting. +# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts +# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). +# 3 basic latin characters + server timezone specific +# +# StrictCharterNames +# Limit guild/arena team charter names to language specific symbols set, not allow create charters with allowed symbols in name +# Default: 0 disable +# 1 basic latin characters (strict) +# 2 realm zone specific (strict). See RealmZone setting. +# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts +# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). +# 3 basic latin characters + server timezone specific +# +# StrictPetNames +# Limit pet names to language specific symbols set +# Default: 0 disable +# 1 basic latin characters (strict) +# 2 realm zone specific (strict). See RealmZone setting. +# Note: In any case if you want correctly see character name at client this client must have apporopriate fonts +# (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts). +# 3 basic latin characters + server timezone specific +# +# CharactersPerRealm +# Limit numbers of characters for account at realm +# Default: 10 (client limitation) +# The number must be between 1 and 10 +# +# CharactersPerAccount +# Limit numbers of characters per account (at all realms). +# Note: this setting limit character creating at _current_ realm base at characters amount at all realms +# Default: 50 +# The number must be >= CharactersPerRealm +# +# ActiveBansUpdateTime +# Interval to update bans expiration in milliseconds +# Default: 30000 (half minute) +# +# LuaEngine.Enabled +# Enables Eluna lua engine +# Default: 0 (false) +# +# BeepAtStart +# Beep at core start finished (mostly work only at Unix/Linux systems) +# Default: 1 (true) +# 0 (false) +# +# ShowProgressBars +# Control show progress bars for load steps at server startup +# Default: 1 (true) 0(false) +# +# RealmBans +# Enable/Disable realm specific account bans system +# While enabled, .ban command bans account only for specific realm, .unban command can unban accounts, which were banned for this realm only. +# Main disadvantage is absence of correct client message if account banned for specific realm. In this case just disconnect client. +# NOTE: For correct work, must be enabled in auth server config also. +# Default: 0 (Disabled) +# 1 (Enabled) +# +################################################################################################################### + +GameType = 1 +RealmZone = 1 +Expansion = 1 +Locale = 255 +DeclinedNames = 0 +StrictPlayerNames = 0 +StrictCharterNames = 0 +StrictPetNames = 0 +CharactersPerRealm = 10 +CharactersPerAccount = 50 +ActiveBansUpdateTime = 30000 +LuaEngine.Enabled = 0 + +BeepAtStart = 1 +ShowProgressBars = 1 +RealmBans = 0 + +################################################################################################################### +# SERVER CUSTOMIZATION BASIC +# +# CharactersCreatingDisabled +# Disable characters creating for specific team or any (non-player accounts not affected) +# Default: 0 - enabled +# 1 - disabled only for Alliance +# 2 - disabled only for Horde +# 3 - disabled for both teams +# +# MaxPlayerLevel +# Max level that can be reached by player for experience (in range from 1 to 255). +# Change not recommended +# Default: 70 +# +# StartPlayerLevel +# Staring level that have character at creating (in range 1 to MaxPlayerLevel) +# Default: 1 +# +# StartPlayerMoney +# Amount of money that new players will start with. +# If you want to start with silver, use for example 100 (100 copper = 1 silver) +# Default: 0 +# +# MaxHonorPoints +# Max honor points that player can have. +# Default: 75000 +# +# StartHonorPoints +# Amount of honor that new players will start with +# Default: 0 +# +# MaxArenaPoints +# Max arena points that player can have. +# Default: 5000 +# +# StartArenaPoints +# Amount of arena points that new players will start with +# Default: 0 +# +# PlayerStart.AllFlightPaths +# Players will start with all flight paths (Note: ALL flight paths, not only player's team) +# Default: 0 (true) +# 1 (false) +# +# PlayerStart.AllReputation +# Players will start with most of the high level reputations that are needed for items, mounts etc. +# If there are any reputation faction you want to be added, just tell me. +# +# PlayerStart.AllSpells +# If enabled, players will start with all their class spells (not talents). Useful for instant 70 servers. +# You must import playercreateinfo_spell_custom.sql, it's included in the SQL folder. +# Default: 0 - off +# 1 - on +# +# PlayerStart.MapsExplored +# Players will start with all maps explored if enabled +# +# PlayerStart.String +# If set to anything else than "", this string will be displayed to players when they login +# to a newly created character. +# Default: "" - send no text +# +# AlwaysMaxWeaponSkill +# Players will automatically gain max weapon/defense skill when logging in, leveling up etc. +# +# CastUnstuck +# Allow cast or not Unstuck spell at .start or client Help option use +# Default: 1 (true) +# 0 (false) +# +# DailyQuest.Blizzlike +# Enable blizzlike random selection of a daily quest. If false - all daily quests will be available to complete once a day. +# Take effect after next daily quest reset (06.00 AM) +# Default: 1 +# +# DailyQuest.MaxPerDay +# The maximum number of daily quests, that can be completed in one day. +# However, client will be show error messages, as if standart 25 daily quest would be available. +# Default: 25 +# +# DisableDuel +# Default: 0 (enabled) +# 1 (disabled duel) +# +# DisablePVP +# Disallow players to togle pvp +# Default: 0 (enable) +# 1 (disable pvp) +# +# EventAnnounce +# Default: 0 (false) +# 1 (true) +# +# FFA.DisallowGroup +# Disallow players to create groups while in FFA area +# Default: 0 +# +# HonorPointsAfterDuel +# The amount of honor points the duel winner will get after a duel. +# Default: 0 - disable +# +# Instance.IgnoreLevel +# Ignore level requirement to enter instance +# Default: 0 (false) +# 1 (true) +# +# Instance.IgnoreRaid +# Ignore raid requirement to enter instance +# Default: 0 (false) +# 1 (true) +# +# MaxPrimaryTradeSkill +# Max count that player can learn the primary trade skill. +# Default: 2 +# Max : 10 +# +# Motd +# Message of the Day. Displayed at worldlogin for every user ('@' for a newline). +# +# PvPToken.Enable +# Enable/disable PvP Token System. Players will get a token after slaying another player that gives honor. +# +# PvPToken.ItemID +# The item players will get after killing someone if PvP Token system is enabled. +# Default: 29434 - Badge of justice +# +# PvPToken.ItemCount +# Modify the item ID count - Default: 1 +# +# PvPToken.MapAllowType +# Where players can receive the pvp token +# 4 - In all maps +# 3 - In battlegrounds only +# 2 - In FFA areas only (gurubashi arena etc) +# 1 - In battlegrounds AND FFA areas only +# +# ShowKickInWorld +# determines wether a message is broadcast to the entire server when a player gets kicked +# Default: 0 +# 1 = Enable +# 0 = Disable +# +# Server.LoginInfo +# Enable/disable sending server info (core version) on login. +# Default: 0 - disable +# 1 - enable +# +# DontDeleteChars +# If enabled characters to delete will be moved to account with id 1 (arena teams, guilds and mails will be deleted, name will be changed). +# Uses stored procedure "PreventCharDelete(characterGuid)" +# Default: 0 - disable +# 1 - enable +# +# DontDeleteCharsLvl +# Minimum character lvl for "DontDeleteChars" option. +# Default: 40 +# +# KeepDeletedCharsTime +# After this time characters from "DontDeleteChars" option will be deleted. (time in days) (0 - infinity) +# Default: 31 +# +################################################################################################################### + +CharactersCreatingDisabled = 0 +MaxPlayerLevel = 70 +StartPlayerLevel = 1 +StartPlayerMoney = 0 +MaxHonorPoints = 75000 +StartHonorPoints = 0 +MaxArenaPoints = 5000 +StartArenaPoints = 0 +PlayerStart.AllFlightPaths = 0 +PlayerStart.AllReputation = 0 +PlayerStart.AllSpells = 0 +PlayerStart.MapsExplored = 0 +PlayerStart.String = "" + +AlwaysMaxWeaponSkill = 0 +CastUnstuck = 1 +DailyQuest.Blizzlike = 1 +DailyQuest.MaxPerDay = 25 +DisableDuel = 0 +DisablePVP = 0 +EventAnnounce = 0 +FFA.DisallowGroup = 0 +HonorPointsAfterDuel = 0 +Instance.IgnoreLevel = 0 +Instance.IgnoreRaid = 0 +MaxPrimaryTradeSkill = 2 +Motd = "HellGround.pl" +PvPToken.Enable = 0 +PvPToken.ItemID = 29434 +PvPToken.ItemCount = 1 +PvPToken.MapAllowType = 4 +Server.LoginInfo = 0 +ShowKickInWorld = 0 + +DontDeleteChars = 0 +DontDeleteCharsLvl = 40 +KeepDeletedCharsTime = 31 + +################################################################################################################### +# SERVER CUSOMIZATION ADVANCED +# +# ActivateWeather +# Activate weather system +# Default: 1 (true) +# 0 (false) +# +# Auction.EnableSort +# Enable or disable auctions sorting feature. +# 1 = enable sorting (default) +# 0 = disable sorting +# +# AutoBroadcast.Timer +# set interval between sending next advertising on chat(in minutes) +# 0 = disable autoannounce (default) +# +# GroupLeaderReconnectPeriod +# The time the leader of a group has to reconnect before the lead goes to another player (also applies for a server crash) +# Default: 180 (seconds) +# +# Instance.ResetTimeHour +# The hour of the day (0-23) when the global instance resets occur. +# Default: 4 +# +# Instance.UnloadDelay +# Unload the instance map from memory after some time if no players are inside. +# Default: 1800000 (miliseconds, i.e 30 minutes) +# 0 (instance maps are kept in memory until they are reset) +# +# Mail.DeliveryDelay +# Mail delivery delay time for item sending +# Default: 3600 sec (1 hour) +# +# Mail.External +# Enable external mail delivery from mail_external table. +# Default: 0 (disabled) +# 1 (enabled) +# +# Mail.ExternalInterval +# Mail delivery delay time for item sending from mail_external table, in minutes. +# Default: 1 minute +# +# Mail.GmInstantSend +# If GM sends mail, recipient receives it instantly +# Default: 1 +# +# Mail.OldReturnMode +# 0 - Return old mails only once per day. +# 1 - Return old mails based on Mail.ReturnTimer. +# Default: 1 +# +# Mail.OldReturnTimer +# If Mail.OldReturnMode is set to 1 then this value contains time beatween each old mails return attempt (in seconds). +# Default: 60 +# +# MaxGroupXPDistance +# Max distance to creature for group memeber to get XP at creature death. +# Default: 74 +# +# MaxWhoListReturns +# Set the maximum number of players returned in the /who list and interface. +# Default: 49 (stable) +# +# MinPetitionSigns +# Min signatures count to creating guild (0..9). +# Default: 9 +# +# NoResetTalentsCost +# Enable or disable no cost when reseting talents +# +# Quests.LowLevelHideDiff +# Quest level difference to hide for player low level quests: +# if player_level > quest_level + LowLevelQuestsHideDiff then quest "!" mark not show for quest giver +# Default: 4 +# -1 (show all available quests marks) +# +# Quests.HighLevelHideDiff +# Quest level difference to hide for player high level quests: +# if player_level < quest_min_level - HighLevelQuestsHideDiff then quest "!" mark not show for quest giver +# Default: 7 +# -1 (show all available quests marks) +# +# RabbitDay +# Set to Rabbit Day (date in unix time), only the day and month are considered, the year is not important +# Default: 0 (off) +# Suggested: 954547200 (April 1st, 2000) +# +# SkipCinematics +# Disable in-game script movie at first character's login(allows to prevent buggy intro in case of custom start location coordinates) +# Default: 0 - show intro for each new characrer +# 1 - show intro only for first character of selected race +# 2 - disable intro show in all cases +# +# SkillChance.Prospecting +# For prospecting skillup not possible by default, but can be allowed as custom setting +# Default: 0 - no skilups +# 1 - skilups possible +# +# ForbiddenMaps +# map ids that users below SEC_GAMEMASTER cannot enter, with delimiter ',' +# Default: "" +# example: "538,90" +# Note that it's HIGHLY DISCOURAGED to forbid starting maps (0, 1, 530)! +# +# GuildAnnounce.Timer +# Interval beetwean guild announces (in minutes) +# Default: 1 +# +# GuildAnnounce.Cooldown +# Cooldown beetwean guild announces from same guild (in minutes) +# Default: 60 +# +# GuildAnnounce.Length +# Maximum length of guild announce message +# Default: 60 +# +# EnableCustomXPRates +# If enabled players can switch between blizzlike and server rate +# +# XPRateModifyItem.Entry +# Entry of item which when equipped gives bonus to XP by XPRateModifyItem.Pct % +# Default: 0 (disabled) +# +################################################################################################################### + +ActivateWeather = 1 +Auction.EnableSort = 1 +AutoBroadcast.Timer = 0 +GroupLeaderReconnectPeriod = 180 +Instance.ResetTimeHour = 4 +Instance.UnloadDelay = 1800000 +Mail.DeliveryDelay = 3600 +Mail.External = 0 +Mail.ExternalInterval = 1 +Mail.GmInstantSend = 1 +Mail.OldReturnMode = 1 +Mail.OldReturnTime = 60 +MaxGroupXPDistance = 74 +MaxWhoListReturns = 49 +MinPetitionSigns = 9 +NoResetTalentsCost = 0 +Quests.LowLevelHideDiff = 4 +Quests.HighLevelHideDiff = 7 +RabbitDay = 0 +SkipCinematics = 0 +SkillChance.Prospecting = 0 +ForbiddenMaps = "" + +GuildAnnounce.Timer = 1 +GuildAnnounce.Cooldown = 60 +GuildAnnounce.Length = 60 + +EnableCustomXPRates = 1 +XPRateModifyItem.Entry = 0 +XPRateModifyItem.Pct = 5 + +################################################################################################################### +# PLAYER INTERACTION +# +# AllowTwoSide.Accounts +# Allow or not accounts to create characters in the 2 teams in any game type. +# Default: 0 (Not allowed) +# 1 (Allowed) +# +# AllowTwoSide.AddFriend +# Allow or not adding friends from other team in friend list. +# Default: 0 (Not allowed) +# 1 (Allowed) +# +# AllowTwoSide.Interaction.Chat +# AllowTwoSide.Interaction.Channel +# AllowTwoSide.Interaction.Group +# AllowTwoSide.Interaction.Guild +# AllowTwoSide.Interaction.Auction +# AllowTwoSide.Interaction.Mail +# Allow or not common :chat(say,yell);channel(chat)group(join)guild(join);merge all auction houses for players from +# different teams, send mail to different team. +# Default: 0 (Not allowed) +# 1 (Allowed) +# +# AllowTwoSide.Trade +# Allow or not trading with other team in party. +# Default: 0 (Not allowed) +# 1 (Allowed) +# +# AllowTwoSide.WhoList +# Allow or not show player from both team in who list. +# Default: 0 (Not allowed) +# 1 (Allowed) +# +# TalentsInspecting +# Allow other players see character talents in inspect dialog (Characters in Gamemaster mode can +# inspect talents always) +# Default: 1 (allow) +# 0 (not allow) +# +################################################################################################################### + +AllowTwoSide.Accounts = 0 +AllowTwoSide.AddFriend = 0 +AllowTwoSide.Interaction.Chat = 0 +AllowTwoSide.Interaction.Channel = 0 +AllowTwoSide.Interaction.Group = 0 +AllowTwoSide.Interaction.Guild = 0 +AllowTwoSide.Interaction.Auction = 0 +AllowTwoSide.Interaction.Mail = 0 +AllowTwoSide.Trade = 0 +AllowTwoSide.WhoList = 0 +TalentsInspecting = 1 + +################################################################################################################### +# CHAT SETTINGS +# +# Channel.GlobalTradeChannel +# Make Trade channel world-wide +# Default: 0 (zone dependent) +# 1 (world-wide) +# +# Channel.PrivateLimitCount +# Maximum count of players which can be on private chat channel (without world, engworld, handel channels). +# Type 0 to turn off this feature. +# Default: 20 +# +# Channel.RestrictedLfg +# Restrict use LookupForGroup channel only registered in LFG tool players +# Default: 1 (allow join to channel only if active in LFG) +# 0 (allow join to channel in any time) +# +# Channel.SilentlyGMJoin +# Silently join GM characters (security level > 1) to channels +# Default: 0 (join announcement in normal way) +# 1 (GM join without announcement) +# +# Chat.DenyMask +# Mask to disable chat if player don't have required lvl from Chat.MinimumLevel option. +# Default: 0 (don't block anything) +# 1 (say, yell) +# 2 (emote, text emote) +# 4 (party, raid, BG) +# 8 (guild) +# 16 (whisp) +# 32 (channels) +# 64 (addon) +# +# Chat.MinimumLevel +# Minimum level to use chat masked in Chat.DenyMask option. +# Default: 5 +# +# ChatFakeMessagePreventing +# Chat protection from creating fake messages using a lot spaces (other invisible symbols), +# not applied to addon language messages, but can prevent working old addons +# that use normal languages for sending data to another clients. +# Default: 0 (disible fake messages preventing) +# 1 (enabled fake messages preventing) +# +# ChatFlood.MessageCount +# Chat anti-flood protection, haste message count to activate protection +# Default: 10 +# 0 (disible anti-flood protection) +# +# ChatFlood.MessageDelay +# Chat anti-flood protection, minimum message delay to count message +# Default: 1 (in secs) +# +# ChatFlood.MuteTime +# Chat anti-flood protection, mute time at activation flood protection (not saved) +# Default: 10 (in secs) +# +################################################################################################################### + +Channel.GlobalTradeChannel = 0 +Channel.PrivateLimitCount = 20 +Channel.RestrictedLfg = 1 +Channel.SilentlyGMJoin = 0 +Chat.DenyMask = 0 +Chat.MinimumLevel = 5 +ChatFakeMessagePreventing = 0 +ChatFlood.MessageCount = 10 +ChatFlood.MessageDelay = 1 +ChatFlood.MuteTime = 10 + + +################################################################################################################### +# GAME MASTER SETTINGS +# +# GM.LoginState +# GM mode at login +# Default: 2 (last save state) +# 0 (disable) +# 1 (enable) +# +# GM.Visible +# GM visibility at login +# Default: 2 (last save state) +# 0 (invisible) +# 1 (visible) +# +# GM.Chat +# GM chat mode at login +# Default: 2 (last save state) +# 0 (disable) +# 1 (enable) +# +# GM.WhisperingTo +# Is GM accepting whispers from player by default or not. +# Default: 2 (last save state) +# 0 (disable) +# 1 (enable) +# +# GM.InGMList +# Is GM showed in GM list (if visible) in non-GM state (.gmoff) +# Default: 0 (false) +# 1 (true) +# +# GM.InWhoList +# Is GM showed in who list (if visible). +# Default: 0 (false) +# 1 (true) +# +# GM.LogTrade +# Include GM trade and trade slot enchanting operations in GM log if it enable +# Default: 1 (include) +# 0 (not include) +# +# GM.StartLevel +# GM starting level (1-255) +# Default: 1 +# +# GM.AllowInvite +# Is GM accepting invites from players by default or not +# Default: 0 (false) +# 1 (true) +# +# GM.AllowFriend +# Are players allowed to add GMs to their friend list +# Default: 0 (false) +# 1 (true) +# +# GM.TrustedLevel +# Permission mask needed to access additional player data +# Default: 14336 (hgms/admins) +# +# CommandLogPermission +# Permission mask for logging commands +# Default: 16130 (devs/gms/admins) +# +# InstantLogout +# Permission mask needed to logout instantly. +# Default: 16130 (devs/gms/admins) +# +# MinGMTextLevel +# Permission mask for SendGMText. +# Default: 16128 (hdev/gms/admins) +# +# DisableWaterBreath +# Disable/enable waterbreathing for security level (0..4) or high +# Default: 8388608 (console - none) +# +# HideGameMasterAccounts +# Enable/disable hiding gamemaster's accounts in .lookup player ip command results. +# Default: 1 (enable hiding) +# 0 (disable hiding) +# +################################################################################################################### + +GM.LoginState = 2 +GM.Visible = 2 +GM.Chat = 2 +GM.WhisperingTo = 2 +GM.InGMList = 0 +GM.InWhoList = 0 +GM.LogTrade = 1 +GM.StartLevel = 70 +GM.AllowInvite = 0 +GM.AllowFriend = 0 +GM.TrustedLevel = 14336 + +CommandLogPermission = 16130 +InstantLogout = 16130 +MinGMTextLevel = 16128 +DisableWaterBreath = 8388608 +HideGameMasterAccounts = 1 + +################################################################################################################### +# SERVER RATES +# +# Rate.Health +# Rate.Mana +# Rate.Rage.Income +# Rate.Rage.Loss +# Rate.Focus +# Rate.Loyalty +# Health and power regeneration and rage income from damage. +# Default: 1 +# +# Rate.Skill.Discovery +# Skill Discovery Rates +# Default: 1 +# +# Rate.Drop.Item.Poor +# Rate.Drop.Item.Normal +# Rate.Drop.Item.Uncommon +# Rate.Drop.Item.Rare +# Rate.Drop.Item.Epic +# Rate.Drop.Item.Legendary +# Rate.Drop.Item.Artifact +# Rate.Drop.Item.Referenced +# Rate.Drop.Money +# Drop rates (items by quality and money) +# Default: 1 +# +# Rate.Drop.Money +# Drop rates +# Default: 1 +# +# Rate.XP.Kill +# Rate.XP.Quest +# Rate.XP.Explore +# XP rates +# Default: 1 +# +# Rate.XP.PastLevel70 +# XP needed per level past 70 (Rates below 1 not recommended) +# Default: 1 +# +# Rate.Rest.InGame +# Rate.Rest.Offline.InTavernOrCity +# Rate.Rest.Offline.InWilderness +# Resting points grow rates (1 - normal, 2 - double rate, 0.5 - half rate, etc) from standard values +# +# Rate.Damage.Fall +# Damage after fall rate. (1 - standard, 2 - double damage, 0.5 - half damage, etc) +# +# Rate.Auction.Time +# Rate.Auction.Deposit +# Rate.Auction.Cut +# Auction rates (auction time, deposit get at auction start, auction cut from price at auction end) +# +# Rate.Honor +# Honor gain rate +# +# Rate.Mining.Amount +# Rate.Mining.Next +# Mining Rates (Mining.Amount changes minimum/maximum usetimes of a deposit, +# Mining.Next changes chance to have next use of a deposit) +# +# Rate.Talent +# Talent Point rates +# Default: 1 +# +# Rate.Reputation.Gain +# Reputation Gain rate +# Default: 1 +# +# Rate.Reputation.LowLevel.Kill +# Reputation Gain form low level kill (grey creture) +# Default: 0.2 +# +# Rate.Reputation.LowLevel.Quest +# Reputation Gain rate +# Default: 1 +# +# Rate.InstanceResetTime +# Multiplier for the number of days in between global raid/heroic instance resets. +# Default: 1 +# +# DurabilityLossChance.Damage +# Chance lost one from equiped items durability point at damage apply or receive. +# Default: 0.5 (100/0.5 = 200) Each 200 damage apply one from 19 possible equipped items +# +# DurabilityLossChance.Absorb +# Chance lost one from armor items durability point at damage absorb. +# Default: 0.5 (100/0.5 = 200) Each 200 absorbs apply one from 15 possible armor equipped items +# +# DurabilityLossChance.Parry +# Chance lost weapon durability point at parry. +# Default: 0.05 (100/0.05 = 2000) Each 2000 parry attacks main weapon lost point +# +# DurabilityLossChance.Block +# Chance lost sheild durability point at damage block. +# Default: 0.05 (100/0.05 = 2000) Each 2000 partly or full blocked attacks shield lost point +# +# SkillGain.Crafting +# SkillGain.Defense +# SkillGain.Gathering +# SkillGain.Weapon +# crafting/defense/gathering/weapon skills gain at skill grow (1,2,...) +# Default: 1 +# +# SkillChance.Orange +# SkillChance.Yellow +# SkillChance.Green +# SkillChance.Grey +# Skill chance values (0..100) +# Default: 100-75-25-0 +# +# SkillChance.MiningSteps +# SkillChance.SkinningSteps +# For skinning and Mining chance decrease with skill level. +# Default: 0 - no decrease +# 75 - in 2 times each 75 skill points +# +# Death.SicknessLevel +# Starting Character start gain sickness at spirit resurrection (1 min) +# Default: 11 +# -10 - character will have full time (10min) sickness at 1 level +# maxplayerlevel+1 - chaarcter will not have sickess at any level +# +# Death.CorpseReclaimDelay.PvP +# Death.CorpseReclaimDelay.PvE +# Enabled/disabled increase corpse reclaim delay at often PvP/PvE deaths +# Default: 1 (enabled) +# 0 (disabled) +# +# Death.Bones.World +# Death.Bones.BattlegroundOrArena +# Enabled/disabled creating bones instead corpse at resurrection (in normal zones/instacnes, or battleground/arenas) +# Default: 1 (enabled) +# 0 (disabled) +# +################################################################################################################### + +Rate.Health = 1 +Rate.Mana = 1 +Rate.Rage.Income = 1 +Rate.Rage.Loss = 1 +Rate.Focus = 1 +Rate.Loyalty = 1 +Rate.Skill.Discovery = 1 +Rate.Drop.Item.Poor = 1 +Rate.Drop.Item.Normal = 1 +Rate.Drop.Item.Uncommon = 1 +Rate.Drop.Item.Rare = 1 +Rate.Drop.Item.Epic = 1 +Rate.Drop.Item.Legendary = 1 +Rate.Drop.Item.Artifact = 1 +Rate.Drop.Item.Referenced = 1 +Rate.Drop.Money = 1 +Rate.XP.Kill = 1 +Rate.XP.Quest = 1 +Rate.XP.Explore = 1 +Rate.XP.PastLevel70 = 1 + +Rate.Rest.InGame = 1 +Rate.Rest.Offline.InTavernOrCity = 1 +Rate.Rest.Offline.InWilderness = 1 +Rate.Damage.Fall = 1 +Rate.Auction.Time = 1 +Rate.Auction.Deposit = 1 +Rate.Auction.Cut = 1 +Rate.Honor = 1 +Rate.Mining.Amount = 1 +Rate.Mining.Next = 1 +Rate.Talent = 1 +Rate.Reputation.Gain = 1 +Rate.Reputation.LowLevel.Kill = 0.2 +Rate.Reputation.LowLevel.Quest = 1 +Rate.InstanceResetTime = 1 +DurabilityLossChance.Damage = 0.5 +DurabilityLossChance.Absorb = 0.5 +DurabilityLossChance.Parry = 0.05 +DurabilityLossChance.Block = 0.05 + +SkillGain.Crafting = 1 +SkillGain.Defense = 1 +SkillGain.Gathering = 1 +SkillGain.Weapon = 1 +SkillChance.Orange = 100 +SkillChance.Yellow = 75 +SkillChance.Green = 25 +SkillChance.Grey = 0 +SkillChance.MiningSteps = 0 +SkillChance.SkinningSteps = 0 + +Death.SicknessLevel = 11 +Death.CorpseReclaimDelay.PvP = 1 +Death.CorpseReclaimDelay.PvE = 0 +Death.Bones.World = 1 +Death.Bones.BattlegroundOrArena = 1 + +################################################################################################################### +# CREATURE SETTINGS +# +# Rate.Creature.Aggro +# Aggro radius percent or off. +# Default: 1 - 100% +# 1.5 - 150% +# 0 - off (0%) +# +# Rate.Creature.Guard.Aggro +# Aggro radius percent for guards or off. +# 1 - 100% +# Default: 1.5 - 150% +# 0 - off (0%) +# +# Rate.Corpse.Decay.Looted +# Controls how long the creature corpse stays after it had been looted, as a multiplier of its Corpse.Decay.* config. +# Default: 0.5 +# +# Rate.Creature.Normal.Damage +# Rate.Creature.Elite.Elite.Damage +# Rate.Creature.Elite.RAREELITE.Damage +# Rate.Creature.Elite.WORLDBOSS.Damage +# Rate.Creature.Elite.RARE.Damage +# Creature Damage Rates. +# Examples: 2 - creatures will damage 2x, 1.7 - 1.7x. +# +# Rate.Creature.Normal.SpellDamage +# Rate.Creature.Elite.Elite.SpellDamage +# Rate.Creature.Elite.RAREELITE.SpellDamage +# Rate.Creature.Elite.WORLDBOSS.SpellDamag +# Rate.Creature.Elite.RARE.SpellDamage +# Creature Spell Damage Rates. +# Examples: 2 - creatures will damage with spells 2x, 1.7 - 1.7x. +# +# Rate.Creature.Normal.HP +# Rate.Creature.Elite.Elite.HP +# Rate.Creature.Elite.RAREELITE.HP +# Rate.Creature.Elite.WORLDBOSS.HP +# Rate.Creature.Elite.RARE.HP +# Creature Health Ammount Modifier. +# Examples: 2 - creatures have 2x health, 1.7 - 1.7x. +# +# Corpse.Decay.NORMAL +# Corpse.Decay.RARE +# Corpse.Decay.ELITE +# Corpse.Decay.RAREELITE +# Corpse.Decay.WORLDBOSS +# Seconds until creature corpse will decay without being looted or skinned. +# Default: 60, 300, 300, 300, 3600 +# +# ListenRange.Say +# Distance from player to listen text that creature (or other world object) say +# Default: 25 +# +# ListenRange.TextEmote +# Distance from player to listen textemote that creature (or other world object) say +# Default: 25 +# +# ListenRange.Yell +# Distance from player to listen text that creature (or other world object) yell +# Default: 300 +# +# AutoActive.WaypointMovement.Continents +# AutoActive.WaypointMovement.Instances +# Set to 0 if you don't want to creatures using waypoint movemet become automaticly active +# Default: 1 +# +# AutoActive.Combat.Continents +# AutoActive.Combat.Instances +# Set to 0 if you don't want to creatures in combat to become automaticly active +# Default: 1 +# +# AutoActive.Combat.PlayersOnly +# Set to 1 if you wan't to creatures in combat to become automaticly active only when they have player on target +# Have no effect when both AutoActive.Combat.Continents and AutoActive.Combat.Instances are set to 0 +# Default: 0 +# +# GuardSight +# MonsterSight +# Dist from which guard/monster can see. +# Default: 50 +# +# Creature.Evade.DistanceToHome +# Maximum distance creature can be from home before evading (continents only) +# Default: 40 +# +# Creature.Evade.DistanceToTarget +# Maximum distance creature can be from target before evading (continents only) +# Default: 45 +# +# Creature.RestoreStateTimer +# Timer after which creature will restore its original state from PASSIVE after reaching home +# Default: 5000 +# +# CreatureFamilyAssistanceDelay +# Reaction time for creature assistance call +# Default: 1500 (1.5s) +# +# CreatureFamilyAssistanceRadius +# Creature family assistance radius +# Default: 10 +# 0 - off +# +# WorldBossLevelDiff +# Difference for boss dynamic level with target +# Default: 3 +# +################################################################################################################### + +Rate.Creature.Aggro = 1 +Rate.Creature.Guard.Aggro = 1.5 +Rate.Corpse.Decay.Looted = 0.5 +Rate.Creature.Normal.Damage = 1 +Rate.Creature.Elite.Elite.Damage = 1 +Rate.Creature.Elite.RAREELITE.Damage = 1 +Rate.Creature.Elite.WORLDBOSS.Damage = 1 +Rate.Creature.Elite.RARE.Damage = 1 +Rate.Creature.Normal.SpellDamage = 1 +Rate.Creature.Elite.Elite.SpellDamage = 1 +Rate.Creature.Elite.RAREELITE.SpellDamage = 1 +Rate.Creature.Elite.WORLDBOSS.SpellDamage = 1 +Rate.Creature.Elite.RARE.SpellDamage = 1 +Rate.Creature.Normal.HP = 1 +Rate.Creature.Elite.Elite.HP = 1 +Rate.Creature.Elite.RAREELITE.HP = 1 +Rate.Creature.Elite.WORLDBOSS.HP = 1 +Rate.Creature.Elite.RARE.HP = 1 + +Corpse.Decay.NORMAL = 60 +Corpse.Decay.RARE = 300 +Corpse.Decay.ELITE = 300 +Corpse.Decay.RAREELITE = 300 +Corpse.Decay.WORLDBOSS = 3600 +ListenRange.Say = 40 +ListenRange.TextEmote = 40 +ListenRange.Yell = 300 + +AutoActive.WaypointMovement.Continents = 1 +AutoActive.WaypointMovement.Instances = 1 +AutoActive.Combat.Continents = 1 +AutoActive.Combat.Instances = 1 +AutoActive.Combat.PlayersOnly = 0 + +GuardSight = 50 +MonsterSight = 50 +Creature.Evade.DistanceToHome = 40 +Creature.Evade.DistanceToTarget = 45 + +Creature.RestoreStateTimer = 5000 +CreatureFamilyAssistanceRadius = 10 +CreatureFamilyAssistanceDelay = 1500 +WorldBossLevelDiff = 3 + +################################################################################################################### +# ARENA SETTINGS +# +# MaxRatingDifference: the maximum rating difference between two groups in rated matches +# Default: 0 (disable, rating difference is discarded) +# +# RatingDiscardTimer: after the specified milliseconds has passed, +# rating information will be discarded when selecting teams for matches +# also initiates an update by this timer +# Default: 60000 +# +# AutoDistributePoints: set if arena points should be distributed automatically, or by GM command +# Default: 0 (disable) (recommended): use gm command or sql query to distribute the points +# 1 (enable): arena points are distributed automatically +# +# AutoDistributeInterval: how often should the distribution take place +# if automatic distribution is enabled +# in days +# Default: 7 (weekly) +# +# EnableMMR: MMR (Matchmaking rating) should be enabled ? +# Default: 0 (disabled) +# +# EnableMMRPenalty: MMRPenalty check should be enabled ? +# Default: 0 (disabled) +# +# EnableMMRPenalty: MMR Penalty applied to MMR if MMR > teamRating + penalty +# Default: 0 (disabled) +# +# EnableFakeWho: Enables/Disables fake who list to fake real position of players in arena +# Default: 0 (disabled) +# +# EnableFakeWho.ForGuild: Adds guild roster support for above option +# Default: 0 (disabled) +# +# LogExtendedInfo: Extended Info Log file of arena fights and arena team creations +# Default: 0 (disabled) +# +# StepByStep: while selecting teams for matches, max rating difference will be decreased by Value every Time miliseconds +# Default: 0, 60000, 100 +# +# EndAfter.Time: rated arena ends after this time (in milliseconds) +# Default: 0 (disabled) +# +# EndAfter.AlwaysDraw: if this is enabled match ended by timer will be considered tie +# Default: 0 (win for team which has more members alive) +# +# StatusInfo: Display number of players in arena when using .server pvp command +# Default: 1 (enabled) +# +# ELOCoefficient: Allows to change coefficient used for calculating rating change after win/lose +# Default: 32 +# +# DailyRequirement: number of wins needed to recive daily arena reward +# Default: 0 (disabled) +# +# DailyAPReward: AP reward for daily arena +# Default: 0 +# +# ReadyStartTimer: timer to set when everyone on arena are ready to fight +# Default: 5000 +# +################################################################################################################### + +Arena.MaxRatingDifference = 0 +Arena.RatingDiscardTimer = 60000 +Arena.AutoDistributePoints = 0 +Arena.AutoDistributeInterval = 7 +Arena.EnableFakeWho = 0 +Arena.EnableFakeWho.ForGuild = 0 +Arena.LogExtendedInfo = 0 + +Arena.EnableMMR = 0 +Arena.EnableMMRPenalty = 0 +Arena.MMRPenalty = 150 +Arena.MMRSpecialLossCalc = 0 + +Arena.StepByStep.Enable = 0 +Arena.StepByStep.Time = 60000 +Arena.StepByStep.Value = 100 +Arena.EndAfter.Time = 0 +Arena.EndAfter.AlwaysDraw = 0 +Arena.StatusInfo = 1 +Arena.ELOCoefficient = 32 +Arena.DailyRequirement = 0 +Arena.DailyAPReward = 0 +Arena.ReadyStartTimer = 5000 + +################################################################################################################### +# BATTLEGROUND SETTINGS +# +# +# AnnounceStart: Accounces bg start. +# Default: 0 - disable +# 1 - enable +# +# CastDeserter: Cast or not Deserter spell at player who leave battleground in progress +# Default: 1 - enable +# 0 - disable +# +# InvitationType: Set Battleground invitation type +# Default: 0 (normal - invite as much players to bg as possible, don't bother with ballance) +# 1 (Experimental - don't allow to invite much more players of one faction) +# +# PremadeGroupWaitForMatch: The time in which premade group of 1 faction waits in BG Queue for premade group of other faction +# Default: 1800000 (30 minutes) +# 0 - disable (not recommended) +# +# PrematureFinishTimer: the time to end the bg if there are less than minplayersperteam on one side +# in milliseconds +# Default: 300000 +# 0 - disable +# +# PrematureReward: Reward players in case of prematurely finished BG +# Default: 1 - enable +# 0 - disable +# +# QueueInfo: sends info about queue on queue join +# Default: 0 - disable +# 1 - enable +# +# StartMusic: If enabled, "L70ETC - Power of the horde" will be played when BG starts ;) +# +# TimerInfo: Enables warnings if BG is supposed to be closed by lack of players +# +# WSGEndAfter: Prevent WSG from lasting forever, sets maximum Time in milliseconds. +# if AlwaysDraw is disabled side with more points wins, elsewhere theres always a tie +# +################################################################################################################### + +BattleGround.AnnounceStart = 0 +Battleground.CastDeserter = 1 +Battleground.InvitationType = 1 +BattleGround.PremadeGroupWaitForMatch = 300000 +BattleGround.PrematureFinishTimer = 300000 +Battleground.PrematureReward = 1 +BattleGround.QueueInfo = 0 + +BattleGround.StartMusic = 0 +BattleGround.TimerInfo = 0 + +BattleGround.WSGEndAfter.Enabled = 0 +BattleGround.WSGEndAfter.Time = 1800000 +BattleGround.WSGEndAfter.AlwaysDraw = 0 + +################################################################################################################### +# VMAPS/MMAPS +# +# vmap.enableLOS +# Enable/Disable VMmap support for line of sight +# Default: 0 (false) +# 1 (true) +# +# vmap.ignoreSpellIds +# These spells are ignored for LoS calculation +# List of ids with delimiter ',' +# Default: "7720" - ritual of summoning effect +# +# vmap.enableIndoorCheck +# Enables checking indoor/outdoor state +# Default: 1 (enable) +# +# vmap.petLOS +# Check LOS for pets, to avoid them going through walls etc. +# Default: 0 (disable, less CPU usage) +# 1 (enable, each pet attack command will check for LOS) +# +# vmap.totem +# Use VMAP for totem summon place calculation +# Default: 0 (disable, less CPU usage) +# 1 (enable, each totem created check LOS) +# +# vmap.enableCluster +# Enable/Disable VMmap calculations in cluster +# Default: 0 (false) +# 1 (true) +# +# vmap.clusterProcesses +# Number of calculation processes created in cluster +# +# mmap.enabled +# Enable/Disable pathfinding using mmaps +# Default: 0 (disable) +# 1 (enable) +# +################################################################################################################### + +vmap.enableLOS = 0 +vmap.ignoreSpellIds = "7720" +vmap.enableIndoorCheck = 1 +vmap.petLOS = 0 +vmap.totem = 0 +vmap.enableCluster = 0 +vmap.clusterProcesses = 4 +mmap.enabled = 0 + +################################################################################################################### +# VISIBILITY AND RADIUSES +# +# Visibility.GroupMode +# Group visibility modes +# Default: 0 (standard setting: only members from same group can 100% auto detect invisible player) +# 1 (raid members 100% auto detect invisible player from same raid) +# 2 (players from same team can 100% auto detect invisible player) +# +# Visibility.Distance.Grey.Object +# Visibility grey distance for dynobjects/gameobjects/corpses/creature bodies +# Default: 10 (yards) +# +# Visibility.Distance.ActiveObjectUpdate.Continents +# Visibility.Distance.ActiveObjectUpdate.Instances +# Range in which objects around active objects (not players) will be updated +# +# +################################################################################################################### + +Visibility.GroupMode = 1 +Visibility.Distance.Grey.Object = 10 +Visibility.Distance.ActiveObjectUpdate.Continents = 132 +Visibility.Distance.ActiveObjectUpdate.Instances = 132 + +################################################################################################################### +# MOVEMENT +# +# Movement.RecalculateRange +# Minimal range after which creature will recalculate movement for chase/follow movegen, higher = less stress on CPU +# Default: 1 (yards) +# Range: 0-5 (yards) +# +# Movement.RecheckTimer +# How often perform check, if target moved and wee need to updte our destination +# Default: 100 (ms) +# +# Movement..WaypointPathfinding.* +# Decides if WaypointMovegen have to generate movepath between nodes ot go in straight line +# Default: 1 (on) +# +################################################################################################################### + +Movement.RecalculateRange = 1 +Movement.RecheckTimer = 100 +Movement.WaypointPathfinding.Continents = 1 +Movement.WaypointPathfinding.Instances = 1 + +################################################################################################################### +# COREBALANCER +# +# CoreBalancer.Enable +# Allows or not core to improve performance by disabling features +# Default: 0 - disabled +# 1 - enabled +# +# CoreBalancer.PlayableDiff +# When server average diff is higher than this value balancing will be performed +# Default: 200 +# +# CoreBalancer.BalanceInterval +# Interval after which average diff will be checked against playable diff and balance if needed performed +# Default: 300000 (ms) +# +# CoreBalancer.VisibilityPenalty +# Penalty to all visibilities on specific treshold +# Default: 25 (yards) +# +################################################################################################################### + +CoreBalancer.Enable = 0 +CoreBalancer.PlayableDiff = 200 +CoreBalancer.BalanceInterval = 300000 +CoreBalancer.VisibilityPenalty = 25 + +################################################################################################################### +# Virtual map serving system (VMSS) configuration +# +# VMSS.Enable +# Enabling VMSS support (signals handling) +# Default: 0 - off +# 1 - on +# +# VMSS.MapFreeMethod +# Method for freeing breaked map +# 0 - safe cleaning (clean auras, save and logout player) +# 1 - not safe cleaning (kick players, not clean auras, not save players/worldstates) +# 2 - not safe cleaning (another type - logout players without save) +# Default: 0 +# +# VMSS.FreezeCheckPeriod +# Time period (in milliseconds) for activate FreezeDetect thread +# Default: 1000 (1 sec) - default mangos freeze detect period. +# +# VMSS.MapFreezeDetectTime +# Time (in milliseconds) for detect freeze in map thread +# Default: 1000 (1 sec) +# +################################################################################################################### + +VMSS.Enable = 0 +VMSS.MapFreeMethod = 0 +VMSS.FreezeCheckPeriod = 1000 +VMSS.MapFreezeDetectTime = 1000 + +################################################################################################################### +# WARDEN/ANTICHEAT +# Warden.Enabled +# Enable warden anticheat +# Default: 1 (Enabled) +# 0 (Disabled) +# +# Warden.Kick +# Kick player on failed check +# Default: 0 (Disabled) +# 1 (Enabled) +# +# Warden.Ban +# Ban player on failed check +# Default: 0 (Disabled) +# 1 (Enabled) +# +# Warden.LogOnlyCheck +# Warden check for testing, failed check with this number will only be logged, no punishing +# Default: 0 (Disabled) +# +# Warden.CheckIntervalMin +# Warden.CheckIntervalMax +# Minimum/maximum time between warden checks (miliseconds) +# Default: 25000 ; 35000 (25-35 seconds) +# +# Warden.MemCheckMax +# Warden.RandomCheckMax +# Number of memory checks/random checks send each time by warden +# Default: 3 ; 5 +# +# AntiCheat.Enable +# Enable passive anticheat +# Default: 1 (Enabled) +# 0 (Disabled) +# +# AntiCheat.CumulativeDelay +# Minimum time delay between anticheat reports for one player (in milliseconds) +# Default: 5000 +# +# AntiCheat.SpeedhackTolerance +# Float value describing tolerance of speedhack check (eg 1.05 : 5% over limit is acceptable) +# Default: 1.00 (no tolerance!) +# +################################################################################################################### + +Warden.Enabled = 1 +Warden.Kick = 0 +Warden.Ban = 0 +Warden.LogOnlyCheck = 0 +Warden.CheckIntervalMin = 25000 +Warden.CheckIntervalMax = 35000 +Warden.MemCheckMax = 3 +Warden.RandomCheckMax = 5 +AntiCheat.Enable = 1 +AntiCheat.CumulativeDelay = 5000 +AntiCheat.SpeedhackTolerance = 1.00 + +################################################################################################################### +# Refer-A-Friend system by Mas0n +# RAF.MaxGrantLevel = 60 (max level for granting level bonuses) +# RAF.MaxReferals = 5 (max referals for one account) +# RAF.MaxReferers = 5 (max referred accounts for one account) +# Rate.RAF.XP = 3 (XP bonus for referred friends in party) +# Rate.RAF.LevelPerLevel = 0.5 (bonus levels per referal level) +# +################################################################################################################### + +RAF.MaxGrantLevel = 60 +RAF.MaxReferals = 5 +RAF.MaxReferers = 5 +Rate.RAF.XP = 3 +Rate.RAF.LevelPerLevel = 0.5 + +################################################################################################################### +# Ganking penalty system +# +# PVP.EnableGankingPenalty = 1 ( on / off ) +# PVP.GankingPenaltyExpireTime = 600 ( time in secs that need to pass after kill, to penalty wear off ) +# PVP.GankingPenaltyKillsAlert = 10 ( consecutive kills count after which GM will receive notice ) +# PVP.GankingPenaltyPerKill = 0.1 ( per kill honor penalty ) +# +################################################################################################################### + +PVP.EnableGankingPenalty = 1 +PVP.GankingPenaltyExpireTime = 600; +PVP.GankingPenaltyPerKill = 0.1 +PVP.GankingPenaltyKillsAlert = 10 + +################################################################################################################### +# +# NETWORK CONFIG +# +# Network.Threads +# Number of threads for network, recommend 1 thread per 1000 connections. +# Default: 1 +# +# Network.OutKBuff +# The size of the output kernel buffer used ( SO_SNDBUF socket option, tcp manual ). +# Default: -1 (Use system default setting) +# +# Network.OutUBuff +# Userspace buffer for output. This is amount of memory reserved per each connection. +# Default: 65536 +# +# Network.TcpNoDelay: +# TCP Nagle algorithm setting +# Default: 0 (enable Nagle algorithm, less traffic, more latency) +# 1 (TCP_NO_DELAY, disable Nagle algorithm, more traffic but less latency) +# +# Network.KickOnBadPacket +# Kick player with modified packets (possible cheaters) +# Default: 0 +# +################################################################################################################### + +Network.Threads = 1 +Network.OutKBuff = -1 +Network.OutUBuff = 65536 +Network.TcpNodelay = 1 +Network.KickOnBadPacket = 0 diff --git a/src/trinityrealm/resource.h b/src/hellgroundcore/resource.h old mode 100755 new mode 100644 similarity index 92% rename from src/trinityrealm/resource.h rename to src/hellgroundcore/resource.h index fbc730320..c7cec41a6 --- a/src/trinityrealm/resource.h +++ b/src/hellgroundcore/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by TrinityCore.rc +// Used by HellgroundCore.rc // // Next default values for new objects diff --git a/src/trinityrealm/AuthCodes.h b/src/hellgroundrealm/AuthCodes.h old mode 100755 new mode 100644 similarity index 95% rename from src/trinityrealm/AuthCodes.h rename to src/hellgroundrealm/AuthCodes.h index 1dcc1bb05..7d1025edd --- a/src/trinityrealm/AuthCodes.h +++ b/src/hellgroundrealm/AuthCodes.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,20 +9,20 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file \ingroup realmd */ -#ifndef _AUTHCODES_H -#define _AUTHCODES_H +#ifndef HELLGROUND_AUTHCODES_H +#define HELLGROUND_AUTHCODES_H enum eAuthCmd { diff --git a/src/trinityrealm/AuthSocket.cpp b/src/hellgroundrealm/AuthSocket.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/trinityrealm/AuthSocket.cpp rename to src/hellgroundrealm/AuthSocket.cpp index 40b75a0f6..4f672a1db --- a/src/trinityrealm/AuthSocket.cpp +++ b/src/hellgroundrealm/AuthSocket.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -22,11 +23,11 @@ #include "Common.h" #include "Database/DatabaseEnv.h" -#include "Config/Config.h" #include "Log.h" #include "RealmList.h" #include "AuthSocket.h" #include "AuthCodes.h" +#include "TOTP.h" #include "PatchHandler.h" #include @@ -187,7 +188,7 @@ AuthSocket::AuthSocket() g.SetDword(7); _authed = false; - accountPermissionMask = PERM_PLAYER; + accountPermissionMask_ = PERM_PLAYER; _build = 0; patch_ = ACE_INVALID_HANDLE; @@ -209,7 +210,6 @@ void AuthSocket::OnAccept() /// Read the packet from the client void AuthSocket::OnRead() { - printf("%s\n", __FUNCTION__); uint8 _cmd; while (1) { @@ -251,7 +251,6 @@ void AuthSocket::OnRead() /// Make the SRP6 calculation from hash in dB void AuthSocket::_SetVSFields(const std::string& rI) { - printf("%s\n", __FUNCTION__); s.SetRand(s_BYTE_SIZE * 8); BigNumber I; @@ -285,7 +284,6 @@ void AuthSocket::_SetVSFields(const std::string& rI) void AuthSocket::SendProof(Sha1Hash sha) { - printf("%s\n", __FUNCTION__); switch(_build) { case 5875: // 1.12.1 @@ -329,7 +327,6 @@ PatternList AuthSocket::pattern_banned = PatternList(); /// Logon Challenge command handler bool AuthSocket::_HandleLogonChallenge() { - printf("%s\n", __FUNCTION__); DEBUG_LOG("Entering _HandleLogonChallenge"); if (recv_len() < sizeof(sAuthLogonChallenge_C)) return false; @@ -367,20 +364,30 @@ bool AuthSocket::_HandleLogonChallenge() EndianConvert(ch->timezone_bias); EndianConvert(*((uint32*)(&ch->ip[0]))); - if (ch->os[3]) operatingSystem.push_back(ch->os[3]); - if (ch->os[2]) operatingSystem.push_back(ch->os[2]); - if (ch->os[1]) operatingSystem.push_back(ch->os[1]); - if (ch->os[0]) operatingSystem.push_back(ch->os[0]); - std::stringstream tmpLocalIp; tmpLocalIp << (uint32)ch->ip[0] << "." << (uint32)ch->ip[1] << "." << (uint32)ch->ip[2] << "." << (uint32)ch->ip[3]; - localIp = tmpLocalIp.str(); + localIp_ = tmpLocalIp.str(); ByteBuffer pkt; _login = (const char*)ch->I; _build = ch->build; + std::string operatingSystem_ = (const char*)ch->os; + + // Restore string order as its byte order is reversed + std::reverse(operatingSystem_.begin(), operatingSystem_.end()); + + if (operatingSystem_ == "Win") + OS = CLIENT_OS_WIN; + else if (operatingSystem_ == "OSX") + OS = CLIENT_OS_OSX; + else if (sRealmList.GetChatboxOsName() != "" && operatingSystem_ == sRealmList.GetChatboxOsName()) + OS = CLIENT_OS_CHAT; + else { + sLog.outLog(LOG_WARDEN, "Client %s got unsupported operating system (%s)", _login.c_str(), operatingSystem_.c_str()); + return false; + } ///- Normalize account name //utf8ToUpperOnlyLatin(_login); -- client already send account in expected form @@ -398,7 +405,7 @@ bool AuthSocket::_HandleLogonChallenge() #ifdef REGEX_NAMESPACE for (PatternList::const_iterator i = pattern_banned.begin(); i != pattern_banned.end(); ++i) { - if (REGEX_NAMESPACE::regex_match(address.c_str(), i->first) && REGEX_NAMESPACE::regex_match(localIp.c_str(), i->second)) + if (REGEX_NAMESPACE::regex_match(address.c_str(), i->first) && REGEX_NAMESPACE::regex_match(localIp_.c_str(), i->second)) { pkt<< (uint8) WOW_FAIL_UNKNOWN_ACCOUNT; send((char const*)pkt.contents(), pkt.size()); @@ -413,8 +420,6 @@ bool AuthSocket::_HandleLogonChallenge() AccountsDatabase.escape_string(address); QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT * FROM ip_banned WHERE ip = '%s'", address.c_str()); - printf("%s: 1\n", __FUNCTION__); - if (result) // ip banned { sLog.outBasic("[AuthChallenge] Banned ip %s tries to login!", get_remote_address().c_str()); @@ -423,13 +428,11 @@ bool AuthSocket::_HandleLogonChallenge() return true; } - printf("%s: 2\n", __FUNCTION__); ///- Get the account details from the account table // No SQL injection (escaped user name) - result = AccountsDatabase.PQuery("SELECT pass_hash, account.account_id, account_state_id, last_ip, permission_mask, v, s, email " + result = AccountsDatabase.PQuery("SELECT pass_hash, account.account_id, account_state_id, token_key, last_ip, permission_mask, email " "FROM account JOIN account_permissions ON account.account_id = account_permissions.account_id " - " JOIN account_session ON account.account_id = account_session.account_id " "WHERE username = '%s'", _safelogin.c_str()); if (!result) // account not exists @@ -438,7 +441,6 @@ bool AuthSocket::_HandleLogonChallenge() send((char const*)pkt.contents(), pkt.size()); return true; } - printf("%s: 3\n", __FUNCTION__); Field * fields = result->Fetch(); @@ -449,10 +451,10 @@ bool AuthSocket::_HandleLogonChallenge() { DEBUG_LOG("[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), (*result)[3].GetString()); DEBUG_LOG("[AuthChallenge] Player address is '%s'", get_remote_address().c_str()); - if (strcmp(fields[3].GetString(), get_remote_address().c_str())) + if (strcmp(fields[4].GetString(), get_remote_address().c_str())) { DEBUG_LOG("[AuthChallenge] Account IP differs"); - pkt << uint8(WOW_FAIL_SUSPENDED); + pkt << (uint8) WOW_FAIL_LOCKED_ENFORCED; send((char const*)pkt.contents(), pkt.size()); return true; } @@ -472,12 +474,11 @@ bool AuthSocket::_HandleLogonChallenge() DEBUG_LOG("[AuthChallenge] Account '%s' is not locked to ip or frozen", _login.c_str()); break; } - printf("%s: 4\n", __FUNCTION__); - ///- If the account is banned, reject the logon attempt QueryResultAutoPtr banresult = AccountsDatabase.PQuery("SELECT punishment_date, expiration_date " "FROM account_punishment " - "WHERE account_id = '%u' AND punishment_type_id = '%u' AND (punishment_date = expiration_date OR expiration_date > UNIX_TIMESTAMP())", (*result)[1].GetUInt32(), PUNISHMENT_BAN); + "WHERE account_id = '%u' AND punishment_type_id = '%u' AND active = 1 " + "AND (punishment_date = expiration_date OR expiration_date > UNIX_TIMESTAMP())", (*result)[1].GetUInt32(), PUNISHMENT_BAN); if (banresult) { @@ -495,9 +496,8 @@ bool AuthSocket::_HandleLogonChallenge() send((char const*)pkt.contents(), pkt.size()); return true; } - printf("%s: 5\n", __FUNCTION__); - QueryResultAutoPtr emailbanresult = AccountsDatabase.PQuery("SELECT email FROM email_banned WHERE email = '%s'", (*result)[7].GetString()); + QueryResultAutoPtr emailbanresult = AccountsDatabase.PQuery("SELECT email FROM email_banned WHERE email = '%s'", (*result)[5].GetString()); if (emailbanresult) { pkt << uint8(WOW_FAIL_BANNED); @@ -506,26 +506,11 @@ bool AuthSocket::_HandleLogonChallenge() send((char const*)pkt.contents(), pkt.size()); return true; } - printf("%s: 6\n", __FUNCTION__); ///- Get the password from the account table, upper it, and make the SRP6 calculation std::string rI = fields[0].GetCppString(); - ///- Don't calculate (v, s) if there are already some in the database - std::string databaseV = fields[5].GetCppString(); - std::string databaseS = fields[6].GetCppString(); - - DEBUG_LOG("database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str()); - - // multiply with 2, bytes are stored as hexstring - if (databaseV.size() != s_BYTE_SIZE*2 || databaseS.size() != s_BYTE_SIZE*2) - _SetVSFields(rI); - else - { - s.SetHexStr(databaseS.c_str()); - v.SetHexStr(databaseV.c_str()); - } - printf("%s: 7\n", __FUNCTION__); + _SetVSFields(rI); b.SetRand(19 * 8); BigNumber gmod = g.ModExp(b, N); @@ -548,6 +533,11 @@ bool AuthSocket::_HandleLogonChallenge() pkt.append(s.AsByteArray(), s.GetNumBytes());// 32 bytes pkt.append(unk3.AsByteArray(16), 16); uint8 securityFlags = 0; + // Check if token is used + _tokenKey = fields[3].GetString(); + if (!_tokenKey.empty()) + securityFlags = 4; + pkt << uint8(securityFlags); // security flags (0x0...0x04) if (securityFlags & 0x01) // PIN input @@ -568,7 +558,7 @@ bool AuthSocket::_HandleLogonChallenge() if (securityFlags & 0x04) // Security token input pkt << uint8(1); - accountPermissionMask = fields[4].GetUInt64(); + accountPermissionMask_ = fields[4].GetUInt64(); _localizationName.resize(4); for (int i = 0; i < 4; ++i) @@ -583,7 +573,6 @@ bool AuthSocket::_HandleLogonChallenge() /// Logon Proof command handler bool AuthSocket::_HandleLogonProof() { - printf("%s\n", __FUNCTION__); DEBUG_LOG("Entering _HandleLogonProof"); ///- Read the packet sAuthLogonProof_C lp; @@ -680,6 +669,25 @@ bool AuthSocket::_HandleLogonProof() sha.Initialize(); sha.UpdateData(t1, 16); sha.Finalize(); + + // Check auth token + if ((lp.securityFlags & 0x04) || !_tokenKey.empty()) + { + uint8 size; + recv((char*)&size, 1); + char* token = new char[size + 1]; + token[size] = '\0'; + recv(token, size); + unsigned int validToken = TOTP::GenerateToken(_tokenKey.c_str()); + unsigned int incomingToken = atoi(token); + delete[] token; + if (validToken != incomingToken) + { + char data[4] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0}; + send(data, sizeof(data)); + return false; + } + } for (int i = 0; i < 20; ++i) { vK[i * 2] = sha.GetDigest()[i]; @@ -732,19 +740,6 @@ bool AuthSocket::_HandleLogonProof() { sLog.outBasic("User '%s' successfully authenticated", _login.c_str()); - uint8 OS; - - if (!strcmp(operatingSystem.c_str(), "Win")) - OS = CLIENT_OS_WIN; - else if (!strcmp(operatingSystem.c_str(), "OSX")) - OS = CLIENT_OS_OSX; - else - { - OS = CLIENT_OS_UNKNOWN; - AccountsDatabase.escape_string(operatingSystem); - sLog.outLog(LOG_WARDEN, "Client %s got unsupported operating system (%s)", _safelogin.c_str(), operatingSystem.c_str()); - } - ///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account // No SQL injection (escaped user name) and IP address as received by socket const char* K_hex = K.AsHexStr(); @@ -773,10 +768,10 @@ bool AuthSocket::_HandleLogonProof() AccountsDatabase.DirectPExecute("UPDATE account_session SET session_key = '%s' WHERE account_id = '%u'", K_hex, accId); static SqlStatementID updateAccount; - SqlStatement stmt = AccountsDatabase.CreateStatement(updateAccount, "UPDATE account SET last_ip = ?, last_local_ip = ?, last_login = UNIX_TIMESTAMP(), locale_id = ?, failed_logins = 0, client_os_version_id = ? WHERE account_id = ?"); + SqlStatement stmt = AccountsDatabase.CreateStatement(updateAccount, "UPDATE account SET last_ip = ?, last_local_ip = ?, last_login = NOW(), locale_id = ?, failed_logins = 0, client_os_version_id = ? WHERE account_id = ?"); std::string tmpIp = get_remote_address(); stmt.addString(tmpIp.c_str()); - stmt.addString(localIp.c_str()); + stmt.addString(localIp_.c_str()); stmt.addUInt8(uint8(GetLocaleByName(_localizationName))); stmt.addUInt8(OS); stmt.addUInt32(accId); @@ -809,8 +804,8 @@ bool AuthSocket::_HandleLogonProof() } sLog.outBasic("[AuthChallenge] account %s tried to login with wrong password!",_login.c_str ()); - uint32 MaxWrongPassCount = sConfig.GetIntDefault("WrongPass.MaxCount", 0); - if (MaxWrongPassCount > 0) + + if (sRealmList.GetWrongPassCount()) { static SqlStatementID updateAccountFailedLogins; //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP @@ -823,27 +818,24 @@ bool AuthSocket::_HandleLogonProof() Field* fields = loginfail->Fetch(); uint32 failed_logins = fields[1].GetUInt32(); - if (failed_logins >= MaxWrongPassCount) + if (failed_logins >= sRealmList.GetWrongPassCount()) { - uint32 WrongPassBanTime = sConfig.GetIntDefault("WrongPass.BanTime", 600); - bool WrongPassBanType = sConfig.GetBoolDefault("WrongPass.BanType", false); - - if (WrongPassBanType) + if (sRealmList.GetWrongPassBanType()) { uint32 acc_id = fields[0].GetUInt32(); - AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, 'Realm', 'Incorrect password for: %u times. Ban for: %u seconds')", - acc_id, PUNISHMENT_BAN, WrongPassBanTime, failed_logins, WrongPassBanTime); + AccountsDatabase.PExecute("INSERT INTO account_punishment VALUES ('%u', '%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, 'Realm', 'Incorrect password for: %u times. Ban for: %u seconds', '1')", + acc_id, PUNISHMENT_BAN, sRealmList.GetWrongPassBanTime(), failed_logins, sRealmList.GetWrongPassBanTime()); sLog.outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times", - _login.c_str(), WrongPassBanTime, failed_logins); + _login.c_str(), sRealmList.GetWrongPassBanTime(), failed_logins); } else { std::string current_ip = get_remote_address(); AccountsDatabase.escape_string(current_ip); AccountsDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Realm','Incorrect password for: %u times. Ban for: %u seconds')", - current_ip.c_str(), WrongPassBanTime, failed_logins, WrongPassBanTime); + current_ip.c_str(), sRealmList.GetWrongPassBanTime(), failed_logins, sRealmList.GetWrongPassBanTime()); sLog.outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", - current_ip.c_str(), WrongPassBanTime, _login.c_str(), failed_logins); + current_ip.c_str(), sRealmList.GetWrongPassBanTime(), _login.c_str(), failed_logins); } } } @@ -890,7 +882,7 @@ bool AuthSocket::_HandleReconnectChallenge() EndianConvert(ch->build); _build = ch->build; - QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT session_key FROM account JOIN account_session ON account.account_id = account_session_account_id WHERE username = '%s'", _safelogin.c_str()); + QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT session_key FROM account JOIN account_session ON account.account_id = account_session.account_id WHERE username = '%s'", _safelogin.c_str()); // Stop if the account is not found if (!result) @@ -1039,7 +1031,7 @@ void AuthSocket::LoadRealmlist(ByteBuffer &pkt, uint32 acctid) } // Show offline state for unsupported client builds and locked realms (1.x clients not support locked state show) - if (!ok_build || !(i->second.requiredPermissionMask & accountPermissionMask)) + if (!ok_build || !(i->second.requiredPermissionMask & accountPermissionMask_)) realmflags = RealmFlags(realmflags | REALM_FLAG_OFFLINE); pkt << uint32(i->second.icon); // realm type @@ -1087,7 +1079,7 @@ void AuthSocket::LoadRealmlist(ByteBuffer &pkt, uint32 acctid) if (!buildInfo) buildInfo = &i->second.realmBuildInfo; - uint8 lock = (i->second.requiredPermissionMask & accountPermissionMask) ? 0 : 1; + uint8 lock = (i->second.requiredPermissionMask & accountPermissionMask_) ? 0 : 1; RealmFlags realmFlags = i->second.realmflags; diff --git a/src/trinityrealm/AuthSocket.h b/src/hellgroundrealm/AuthSocket.h old mode 100755 new mode 100644 similarity index 71% rename from src/trinityrealm/AuthSocket.h rename to src/hellgroundrealm/AuthSocket.h index 926378935..a777df65d --- a/src/trinityrealm/AuthSocket.h +++ b/src/hellgroundrealm/AuthSocket.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,39 +9,28 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup realmd /// @{ /// \file -#ifndef _AUTHSOCKET_H -#define _AUTHSOCKET_H +#ifndef HELLGROUND_AUTHSOCKET_H +#define HELLGROUND_AUTHSOCKET_H #include "Common.h" #include "Auth/BigNumber.h" #include "Auth/Sha1.h" #include "ByteBuffer.h" -// gcc 4.6+ will set __GXX_EXPERIMENTAL_CXX0X__ to 1 if compiled with -std=c++0x -#if COMPILER == COMPILER_GNU/* && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) && __GXX_EXPERIMENTAL_CXX0X__ //use c++11 library for GCC >= 4.6 -#include -#define REGEX_NAMESPACE std -// tr1::regex were added with gcc 4.3.0 -#elif COMPILER == COMPILER_GNU && (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)//use tr1 library for old gcc -#include -#define REGEX_NAMESPACE std::tr1*/ -#include -#define REGEX_NAMESPACE boost -#elif COMPILER == COMPILER_MICROSOFT //use c++11 library for >= VS2010 + #include #define REGEX_NAMESPACE std -#endif #include "BufferedSocket.h" @@ -89,15 +79,15 @@ class AuthSocket: public BufferedSocket bool _authed; std::string _login; + std::string _tokenKey; std::string _safelogin; - std::string operatingSystem; - std::string localIp; - + std::string localIp_; + uint8 OS; // Since GetLocaleByName() is _NOT_ bijective, we have to store the locale as a string. Otherwise we can't differ // between enUS and enGB, which is important for the patch system std::string _localizationName; uint16 _build; - uint64 accountPermissionMask; + uint64 accountPermissionMask_; ACE_HANDLE patch_; diff --git a/src/trinityrealm/BufferedSocket.cpp b/src/hellgroundrealm/BufferedSocket.cpp similarity index 96% rename from src/trinityrealm/BufferedSocket.cpp rename to src/hellgroundrealm/BufferedSocket.cpp index 01f75de7e..8ddc74248 100644 --- a/src/trinityrealm/BufferedSocket.cpp +++ b/src/hellgroundrealm/BufferedSocket.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file diff --git a/src/trinityrealm/BufferedSocket.h b/src/hellgroundrealm/BufferedSocket.h similarity index 88% rename from src/trinityrealm/BufferedSocket.h rename to src/hellgroundrealm/BufferedSocket.h index 102910d28..791e9cdac 100644 --- a/src/trinityrealm/BufferedSocket.h +++ b/src/hellgroundrealm/BufferedSocket.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,20 +9,20 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file \ingroup realmd */ -#ifndef _BUFFEREDSOCKET_H_ -#define _BUFFEREDSOCKET_H_ +#ifndef HELLGROUND_BUFFEREDSOCKET_H +#define HELLGROUND_BUFFEREDSOCKET_H #include #include diff --git a/src/trinityrealm/CMakeLists.txt b/src/hellgroundrealm/CMakeLists.txt old mode 100755 new mode 100644 similarity index 84% rename from src/trinityrealm/CMakeLists.txt rename to src/hellgroundrealm/CMakeLists.txt index 84f732aaf..41640ac67 --- a/src/trinityrealm/CMakeLists.txt +++ b/src/hellgroundrealm/CMakeLists.txt @@ -1,16 +1,15 @@ -set(EXECUTABLE_NAME trinityrealm) +set(EXECUTABLE_NAME hellgroundrealm) file(GLOB_RECURSE EXECUTABLE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) if(WIN32) list(APPEND EXECUTABLE_SRCS - TrinityRealm.rc + HellgroundRealm.rc ) endif() include_directories( ${CMAKE_SOURCE_DIR}/src/shared ${CMAKE_BINARY_DIR}/dep - ${CMAKE_BINARY_DIR}/dep/boost ${CMAKE_SOURCE_DIR}/src/framework ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/src/shared @@ -48,7 +47,6 @@ endif() if(UNIX) target_link_libraries(${EXECUTABLE_NAME} ${MYSQL_LIBRARY} - ${Boost_REGEX_LIBRARY} ${OPENSSL_EXTRA_LIBRARIES} ) endif() @@ -68,7 +66,7 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ) install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BIN_DIR}) -install(FILES trinityrealm.conf.dist DESTINATION ${CONF_DIR} RENAME trinityrealm.conf.dist) +install(FILES hellgroundrealm.conf.dist DESTINATION ${CONF_DIR} RENAME hellgroundrealm.conf.dist) if(WIN32 AND MSVC) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/\${BUILD_TYPE}/${EXECUTABLE_NAME}.pdb DESTINATION ${BIN_DIR} CONFIGURATIONS Debug) diff --git a/src/trinityrealm/TrinityRealm.rc b/src/hellgroundrealm/HellgroundRealm.rc old mode 100755 new mode 100644 similarity index 81% rename from src/trinityrealm/TrinityRealm.rc rename to src/hellgroundrealm/HellgroundRealm.rc index 729a11fd5..1ac693439 --- a/src/trinityrealm/TrinityRealm.rc +++ b/src/hellgroundrealm/HellgroundRealm.rc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +8,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "resource.h" @@ -69,12 +69,12 @@ BEGIN BEGIN BLOCK "080004b0" BEGIN - VALUE "FileDescription", "TrinityRealm" + VALUE "FileDescription", "HellgroundRealm" VALUE "FileVersion", STRFILEVER - VALUE "InternalName", "TrinityRealm" - VALUE "LegalCopyright", "Copyright (C) 2008-2009" - VALUE "OriginalFilename", "TrinityRealm.exe" - VALUE "ProductName", "TrinityRealm" + VALUE "InternalName", "HellgroundRealm" + VALUE "LegalCopyright", "Copyright (C) 2008-2014" + VALUE "OriginalFilename", "HellgroundRealm.exe" + VALUE "ProductName", "HellgroundRealm" VALUE "ProductVersion", STRPRODUCTVER END END diff --git a/src/trinityrealm/Main.cpp b/src/hellgroundrealm/Main.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/trinityrealm/Main.cpp rename to src/hellgroundrealm/Main.cpp index 6af549f7e..777296821 --- a/src/trinityrealm/Main.cpp +++ b/src/hellgroundrealm/Main.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup realmd Realm Daemon @@ -45,7 +46,7 @@ #ifdef WIN32 #include "ServiceWin32.h" char serviceName[] = "realmd"; -char serviceLongName[] = "Trinity realm service"; +char serviceLongName[] = "Hellground realm service"; char serviceDescription[] = "Massive Network Game Object Server"; #else #include "PosixDaemon.h" @@ -193,7 +194,7 @@ extern int main(int argc, char **argv) if (confVersion < _REALMDCONFVERSION) { sLog.outLog(LOG_DEFAULT, "ERROR: **********************************************************************************"); - sLog.outLog(LOG_DEFAULT, "ERROR: WARNING: Your trinityrealm.conf version indicates your conf file is out of date!"); + sLog.outLog(LOG_DEFAULT, "ERROR: WARNING: Your hellgroundrealm.conf version indicates your conf file is out of date!"); sLog.outLog(LOG_DEFAULT, "ERROR: Please check for updates, as your current default values may cause"); sLog.outLog(LOG_DEFAULT, "ERROR: strange behavior."); sLog.outLog(LOG_DEFAULT, "ERROR: **********************************************************************************"); @@ -237,10 +238,11 @@ extern int main(int argc, char **argv) if(!StartDB()) return 1; - ///- Get the list of realms for the server - sRealmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); + ///- start realm list + sRealmList.Initialize(); if (sRealmList.size() == 0) sLog.outLog(LOG_DEFAULT, "ERROR: No valid realms specified."); + #ifdef REGEX_NAMESPACE QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT ip_pattern, local_ip_pattern FROM pattern_banned"); @@ -260,7 +262,7 @@ extern int main(int argc, char **argv) // cleanup query // set expired bans to inactive - AccountsDatabase.Execute("DELETE FROM ip_banned WHERE unban_date <= UNIX_TIMESTAMP() AND unban_date <> ban_date"); + AccountsDatabase.Execute("DELETE FROM ip_banned WHERE expiration_date <= UNIX_TIMESTAMP() AND expiration_date <> punishment_date"); ///- Launch the listening network socket ACE_Acceptor acceptor; @@ -272,7 +274,7 @@ extern int main(int argc, char **argv) if (acceptor.open(bind_addr, ACE_Reactor::instance(), ACE_NONBLOCK) == -1) { - sLog.outLog(LOG_DEFAULT, "ERROR: TrinityRealm can not bind to %s:%d", bind_ip.c_str(), rmport); + sLog.outLog(LOG_DEFAULT, "ERROR: HellgroundRealm can not bind to %s:%d", bind_ip.c_str(), rmport); return 1; } @@ -313,9 +315,9 @@ extern int main(int argc, char **argv) if(Prio) { if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS)) - sLog.outString("TrinityRealm process priority class set to HIGH"); + sLog.outString("HellgroundRealm process priority class set to HIGH"); else - sLog.outLog(LOG_DEFAULT, "ERROR: Can't set TrinityRealm process priority class."); + sLog.outLog(LOG_DEFAULT, "ERROR: Can't set HellgroundRealm process priority class."); } } #endif @@ -427,4 +429,16 @@ void UnhookSignals() #endif } +void RealmList::Initialize() +{ + m_UpdateInterval = sConfig.GetIntDefault("RealmsStateUpdateDelay", 20); + m_WrongPassCount = sConfig.GetIntDefault("WrongPass.MaxCount", 0); + m_WrongPassBanTime = sConfig.GetIntDefault("WrongPass.BanTime", 600); + m_WrongPassBanType = sConfig.GetBoolDefault("WrongPass.BanType", false); + m_ChatboxOsName = sConfig.GetStringDefault("ChatboxClientOsName",""); + + ///- Get the content of the realmlist table in the database + UpdateRealms(true); +} + /// @} diff --git a/src/trinityrealm/PatchHandler.cpp b/src/hellgroundrealm/PatchHandler.cpp similarity index 95% rename from src/trinityrealm/PatchHandler.cpp rename to src/hellgroundrealm/PatchHandler.cpp index 9314688f7..0431e1aed 100644 --- a/src/trinityrealm/PatchHandler.cpp +++ b/src/hellgroundrealm/PatchHandler.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file diff --git a/src/trinityrealm/PatchHandler.h b/src/hellgroundrealm/PatchHandler.h similarity index 88% rename from src/trinityrealm/PatchHandler.h rename to src/hellgroundrealm/PatchHandler.h index 4798caf81..89bf44303 100644 --- a/src/trinityrealm/PatchHandler.h +++ b/src/hellgroundrealm/PatchHandler.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,20 +9,20 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file \ingroup realmd */ -#ifndef _PATCHHANDLER_H_ -#define _PATCHHANDLER_H_ +#ifndef HELLGROUND_PATCHHANDLER_H +#define HELLGROUND_PATCHHANDLER_H #include #include diff --git a/src/trinityrealm/RealmList.cpp b/src/hellgroundrealm/RealmList.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/trinityrealm/RealmList.cpp rename to src/hellgroundrealm/RealmList.cpp index fb20dc7f0..f2f6dc56a --- a/src/trinityrealm/RealmList.cpp +++ b/src/hellgroundrealm/RealmList.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -69,15 +70,6 @@ RealmList& sRealmList return realmlist; } -/// Load the realm list from the database -void RealmList::Initialize(uint32 updateInterval) -{ - m_UpdateInterval = updateInterval; - - ///- Get the content of the realmlist table in the database - UpdateRealms(true); -} - void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags realmflags, uint8 timezone, uint64 requiredPermissionMask, float popu, const std::string& builds) { ///- Create new if not exist or update existed diff --git a/src/trinityrealm/RealmList.h b/src/hellgroundrealm/RealmList.h old mode 100755 new mode 100644 similarity index 77% rename from src/trinityrealm/RealmList.h rename to src/hellgroundrealm/RealmList.h index 2ddce88a7..5b52071e1 --- a/src/trinityrealm/RealmList.h +++ b/src/hellgroundrealm/RealmList.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,20 +9,20 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup realmd /// @{ /// \file -#ifndef _REALMLIST_H -#define _REALMLIST_H +#ifndef HELLGROUND_REALMLIST_H +#define HELLGROUND_REALMLIST_H #include "Common.h" @@ -63,13 +64,17 @@ class RealmList RealmList(); ~RealmList() {} - void Initialize(uint32 updateInterval); + void Initialize(); void UpdateIfNeed(); RealmMap::const_iterator begin() const { return m_realms.begin(); } RealmMap::const_iterator end() const { return m_realms.end(); } uint32 size() const { return m_realms.size(); } + std::string GetChatboxOsName() const {return m_ChatboxOsName;} + uint32 GetWrongPassCount() const {return m_WrongPassCount;} + uint32 GetWrongPassBanTime() const {return m_WrongPassBanTime;} + bool GetWrongPassBanType() const {return m_WrongPassBanType;} private: void UpdateRealms(bool init); void UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, RealmFlags realmflags, uint8 timezone, uint64 requiredPermissionMask, float popu, const std::string& builds); @@ -77,6 +82,10 @@ class RealmList RealmMap m_realms; ///< Internal map of realms uint32 m_UpdateInterval; time_t m_NextUpdateTime; + std::string m_ChatboxOsName; + uint32 m_WrongPassCount; + uint32 m_WrongPassBanTime; + bool m_WrongPassBanType; }; #define sRealmList RealmList::Instance() diff --git a/src/hellgroundrealm/TOTP.cpp b/src/hellgroundrealm/TOTP.cpp new file mode 100644 index 000000000..44d05540a --- /dev/null +++ b/src/hellgroundrealm/TOTP.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "TOTP.h" +#include + +int base32_decode(const char* encoded, char* result, int bufSize) +{ + // Base32 implementation + // Copyright 2010 Google Inc. + // Author: Markus Gutschke + // Licensed under the Apache License, Version 2.0 + int buffer = 0; + int bitsLeft = 0; + int count = 0; + for (const char *ptr = encoded; count < bufSize && *ptr; ++ptr) + { + char ch = *ptr; + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || ch == '-') + continue; + buffer <<= 5; + + // Deal with commonly mistyped characters + if (ch == '0') + ch = 'O'; + else if (ch == '1') + ch = 'L'; + else if (ch == '8') + ch = 'B'; + + // Look up one base32 digit + if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) + ch = (ch & 0x1F) - 1; + else if (ch >= '2' && ch <= '7') + ch -= '2' - 26; + else + return -1; + + buffer |= ch; + bitsLeft += 5; + if (bitsLeft >= 8) + { + result[count++] = buffer >> (bitsLeft - 8); + bitsLeft -= 8; + } + } + + if (count < bufSize) + result[count] = '\000'; + return count; +} + +#define HMAC_RES_SIZE 20 + +namespace TOTP +{ + unsigned int GenerateToken(const char* b32key) + { + size_t keySize = strlen(b32key); + int bufsize = (keySize + 7)/8*5; + char* encoded = new char[bufsize]; + memset(encoded, 0, bufsize); + unsigned int hmacResSize = HMAC_RES_SIZE; + unsigned char hmacRes[HMAC_RES_SIZE]; + unsigned long timestamp = time(NULL)/30; + unsigned char challenge[8]; + + for (int i = 8; i--;timestamp >>= 8) + challenge[i] = timestamp; + + base32_decode(b32key, encoded, bufsize); + HMAC(EVP_sha1(), encoded, bufsize, challenge, 8, hmacRes, &hmacResSize); + unsigned int offset = hmacRes[19] & 0xF; + unsigned int truncHash = (hmacRes[offset] << 24) | (hmacRes[offset+1] << 16 )| (hmacRes[offset+2] << 8) | (hmacRes[offset+3]); + truncHash &= 0x7FFFFFFF; + + delete[] encoded; + + return truncHash % 1000000; + } +} diff --git a/src/hellgroundrealm/TOTP.h b/src/hellgroundrealm/TOTP.h new file mode 100644 index 000000000..89b131df4 --- /dev/null +++ b/src/hellgroundrealm/TOTP.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_TOTP_H +#define HELLGROUND_TOPT_H + +#include "openssl/hmac.h" +#include "openssl/evp.h" + +namespace TOTP +{ + unsigned int GenerateToken(const char* b32key); +} + +#endif \ No newline at end of file diff --git a/src/trinityrealm/TrinityRealm.ico b/src/hellgroundrealm/TrinityRealm.ico old mode 100755 new mode 100644 similarity index 100% rename from src/trinityrealm/TrinityRealm.ico rename to src/hellgroundrealm/TrinityRealm.ico diff --git a/src/trinityrealm/trinityrealm.conf.dist b/src/hellgroundrealm/hellgroundrealm.conf.dist old mode 100755 new mode 100644 similarity index 81% rename from src/trinityrealm/trinityrealm.conf.dist rename to src/hellgroundrealm/hellgroundrealm.conf.dist index 3e39446d9..32af81b38 --- a/src/trinityrealm/trinityrealm.conf.dist +++ b/src/hellgroundrealm/hellgroundrealm.conf.dist @@ -1,128 +1,119 @@ -########################################## -# Trinity Core realmd configuration file # -########################################## -[RealmConf] -ConfVersion=2011092901 - -################################################################################################################### -# REALMD SETTINGS -# -# LoginDatabaseInfo -# Database connection settings for the realm server. -# Default: hostname;port;username;password;database -# .;somenumber;username;password;database - use named pipes at Windows -# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini -# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux -# Unix sockets: experimental, not tested -# -# LogsDir -# Logs directory setting. -# Important: Logs dir must exists, or all logs be disable -# Important: In linux daemon mode string must be full path. -# Default: "" - no log directory prefix, if used log names isn't absolute path then logs will be -# stored in current directory for run program. -# -# MaxPingTime -# Settings for maximum database-ping interval (minutes between pings) -# -# RealmServerPort -# Default RealmServerPort -# -# BindIP -# Bind Realm Server to IP/hostname -# -# PidFile -# Realmd daemon PID file -# Important: In linux daemon mode string must be full path. -# Default: "" - do not create PID file -# "./realmd.pid" - create PID file (recommended name) -# -# LogLevel -# Server console level of logging -# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug -# Default: 0 -# -# LogTime -# Include time in server console output [hh:mm:ss] -# Default: 0 (no time) -# 1 (print time) -# -# LogFile -# Logfile name -# Default: "realmd.log" -# "" - empty name disable creating log file -# -# LogTimestamp -# Logfile with timestamp of server start in name -# Default: 0 - no timestamp in name -# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext -# -# LogFileLevel -# Server file level of logging -# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug -# Default: 0 -# -# LogColors -# Color for messages (format "normal_color details_color debug_color error_color) -# Colors: 0 - BLACK, 1 - RED, 2 - GREEN, 3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 - CYAN, 7 - GREY, -# 8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE -# Default: "" - none colors -# "13 7 11 9" - for example :) -# -# UseProcessors -# Used processors mask for multi-processors system (Used only at Windows) -# Default: 0 (selected by OS) -# number (bitmask value of selected processors) -# -# ProcessPriority -# Process proirity setting (Used only at Windows) -# Default: 1 (HIGH) -# 0 (Normal) -# -# RealmsStateUpdateDelay -# Realm list Update up delay (updated at realm list request if delay expired). -# Default: 20 -# 0 (Disabled) -# -# WrongPass.MaxCount -# Number of login attemps with wrong password before the account or IP is banned -# Default: 0 (Never ban) -# -# WrongPass.BanTime -# Duration of the ban in seconds (0 means permanent ban) -# Default: 600 -# -# WrongPass.BanType -# Ban the IP or account on which login is attempted -# Default: 0 (Ban IP) -# 1 (Ban Account) -# -# RealmBans -# Enable/Disable realm specific account bans system -# While enabled, .ban command bans account only for specific realm, .unban command can unban accounts, which were banned for this realm only. -# Main disadvantage is absence of correct client message if account banned for specific realm. In this case just disconnect client. -# NOTE: For correct work, must be enabled in world server config also. -# Default: 0 (Disabled) -# 1 (Enabled) -# -################################################################################################################### - -LoginDatabaseInfo = "127.0.0.1;3306;trinity;trinity;realmd" -LogsDir = "" -MaxPingTime = 30 -RealmServerPort = 3724 -BindIP = "0.0.0.0" -PidFile = "" -LogLevel = 0 -LogTime = 0 -LogFile = "realmd.log" -LogTimestamp = 0 -LogFileLevel = 0 -LogColors = "" -UseProcessors = 0 -ProcessPriority = 1 -RealmsStateUpdateDelay = 20 -WrongPass.MaxCount = 0 -WrongPass.BanTime = 600 -WrongPass.BanType = 0 -RealmBans = 0 +####################################### +# HellgroundRealm configuration file # +####################################### +[RealmConf] +ConfVersion=2014021201 + +################################################################################################################### +# REALM SETTINGS +# +# LoginDatabaseInfo +# Database connection settings for the realm server. +# Default: hostname;port;username;password;database +# .;somenumber;username;password;database - use named pipes at Windows +# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini +# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux +# Unix sockets: experimental, not tested +# +# MaxPingTime +# Settings for maximum database-ping interval (minutes between pings) +# +# RealmServerPort +# Default RealmServerPort +# +# BindIP +# Bind Realm Server to IP/hostname +# +# UseProcessors +# Used processors mask for multi-processors system (Used only at Windows) +# Default: 0 (selected by OS) +# number (bitmask value of selected processors) +# +# ProcessPriority +# Process proirity setting (Used only at Windows) +# Default: 1 (HIGH) +# 0 (Normal) +# +# RealmsStateUpdateDelay +# Realm list Update up delay (updated at realm list request if delay expired). +# Default: 20 +# 0 (Disabled) +# +# WrongPass.MaxCount +# Number of login attemps with wrong password before the account or IP is banned +# Default: 0 (Never ban) +# +# WrongPass.BanTime +# Duration of the ban in seconds (0 means permanent ban) +# Default: 600 +# +# WrongPass.BanType +# Ban the IP or account on which login is attempted +# Default: 0 (Ban IP) +# 1 (Ban Account) +# +# RealmBans +# Enable/Disable realm specific account bans system +# While enabled, .ban command bans account only for specific realm, .unban command can unban accounts, which were banned for this realm only. +# Main disadvantage is absence of correct client message if account banned for specific realm. In this case just disconnect client. +# NOTE: For correct work, must be enabled in world server config also. +# Default: 0 (Disabled) +# 1 (Enabled) +# +# ChatboxClientOsName +# OS name send by custom WoW client to distinguish itself from official clients +# Default: "Cha" +# +################################################################################################################### + +LoginDatabaseInfo = "127.0.0.1;3306;trinity;trinity;realmd" +MaxPingTime = 30 +RealmServerPort = 3724 +BindIP = "0.0.0.0" +UseProcessors = 0 +ProcessPriority = 1 +RealmsStateUpdateDelay = 20 +WrongPass.MaxCount = 0 +WrongPass.BanTime = 600 +WrongPass.BanType = 0 +RealmBans = 0 +ChatboxClientOsName = "Cha" + +################################################################################################################### +# REALM LOGGING +# +# LogsDir +# Logs directory setting. +# Important: Logs dir must exists, or all logs be disable +# Important: In linux daemon mode string must be full path. +# Default: "" - no log directory prefix, if used log names isn't absolute path then logs will be +# stored in current directory for run program. +# +# PidFile +# Realmd daemon PID file +# Important: In linux daemon mode string must be full path. +# Default: "" - do not create PID file +# "./realmd.pid" - create PID file (recommended name) +# +# LogFile +# Logfile name +# Default: "realmd.log" +# "" - empty name disable creating log file +# +# LogTimestamp +# Logfile with timestamp of server start in name +# Default: 0 - no timestamp in name +# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext +# +# LogFileLevel +# Server file level of logging +# 0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug +# Default: 0 +# +################################################################################################################### + +LogsDir = "" +PidFile = "" +LogFile = "realmd.log" +LogTimestamp = 0 +LogFileLevel = 0 diff --git a/src/trinitycore/resource.h b/src/hellgroundrealm/resource.h old mode 100755 new mode 100644 similarity index 100% rename from src/trinitycore/resource.h rename to src/hellgroundrealm/resource.h diff --git a/src/scripts/CMakeLists.txt b/src/scripts/CMakeLists.txt index 4654e7ea2..74098f846 100755 --- a/src/scripts/CMakeLists.txt +++ b/src/scripts/CMakeLists.txt @@ -1,74 +1,74 @@ -file(GLOB_RECURSE trinityscript_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/dep/include/g3dlite - ${CMAKE_SOURCE_DIR}/dep/include - ${CMAKE_SOURCE_DIR}/src/game - ${CMAKE_SOURCE_DIR}/src/game/movemap - ${CMAKE_SOURCE_DIR}/src/game/vmap - ${CMAKE_SOURCE_DIR}/src/shared - ${CMAKE_SOURCE_DIR}/src/shared/Database - ${CMAKE_SOURCE_DIR}/src/framework - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/shared - ${MYSQL_INCLUDE_DIR} - ${ACE_INCLUDE_DIR} -) - -source_group("Scripts" - REGULAR_EXPRESSION .* -) - -source_group("Manager" - REGULAR_EXPRESSION ScriptMgr -) - -source_group("System" - REGULAR_EXPRESSION ScriptLoader|system|sc_gossip|sc_instance|precompiled -) - -source_group("Bosses" - REGULAR_EXPRESSION boss* -) - -source_group("Instances" - REGULAR_EXPRESSION instance* -) - -source_group("Areatrigger" - REGULAR_EXPRESSION areatrigger* -) - -source_group("Creatures and Npcs" - REGULAR_EXPRESSION mob|npc|npcs|guard -) - -source_group("Items" - REGULAR_EXPRESSION item* -) - -source_group("Game Objects" - REGULAR_EXPRESSION go* -) - -source_group("Spells" - REGULAR_EXPRESSION spell* -) -source_group("AI" - REGULAR_EXPRESSION escort_ai|follower_ai|simple_ai|sc_creature -) - -add_library(trinityscript SHARED ${trinityscript_SRCS}) - -add_definitions(-D_TRINITY_SCRIPT_CONFIG='"${CONF_DIR}/trinitycore.conf"') - -IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - SET_TARGET_PROPERTIES(trinityscript PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") -ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - -target_link_libraries(trinityscript) - -set_target_properties(trinityscript PROPERTIES VERSION 4.2.0 SOVERSION 4) -install(TARGETS trinityscript DESTINATION lib) +file(GLOB_RECURSE hellgroundscript_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/dep/include/g3dlite + ${CMAKE_SOURCE_DIR}/dep/include + ${CMAKE_SOURCE_DIR}/src/game + ${CMAKE_SOURCE_DIR}/src/game/movemap + ${CMAKE_SOURCE_DIR}/src/game/vmap + ${CMAKE_SOURCE_DIR}/src/shared + ${CMAKE_SOURCE_DIR}/src/shared/Database + ${CMAKE_SOURCE_DIR}/src/framework + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/shared + ${MYSQL_INCLUDE_DIR} + ${ACE_INCLUDE_DIR} +) + +source_group("Scripts" + REGULAR_EXPRESSION .* +) + +source_group("Manager" + REGULAR_EXPRESSION ScriptMgr +) + +source_group("System" + REGULAR_EXPRESSION ScriptLoader|system|sc_gossip|sc_instance|precompiled +) + +source_group("Bosses" + REGULAR_EXPRESSION boss* +) + +source_group("Instances" + REGULAR_EXPRESSION instance* +) + +source_group("Areatrigger" + REGULAR_EXPRESSION areatrigger* +) + +source_group("Creatures and Npcs" + REGULAR_EXPRESSION mob|npc|npcs|guard +) + +source_group("Items" + REGULAR_EXPRESSION item* +) + +source_group("Game Objects" + REGULAR_EXPRESSION go* +) + +source_group("Spells" + REGULAR_EXPRESSION spell* +) +source_group("AI" + REGULAR_EXPRESSION escort_ai|follower_ai|simple_ai|sc_creature +) + +add_library(hellgroundscript SHARED ${hellgroundscript_SRCS}) + +add_definitions(-D_TRINITY_SCRIPT_CONFIG='"${CONF_DIR}/hellgroundcore.conf"' -DTHIS_IS_SCRIPT_DLL) + +IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") + SET_TARGET_PROPERTIES(hellgroundscript PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") +ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") + +target_link_libraries(hellgroundscript) + +set_target_properties(hellgroundscript PROPERTIES VERSION 4.2.0 SOVERSION 4) +install(TARGETS hellgroundscript DESTINATION lib) diff --git a/src/scripts/ScriptMgr.cpp b/src/scripts/ScriptMgr.cpp index 96855a558..c8ac81f91 100755 --- a/src/scripts/ScriptMgr.cpp +++ b/src/scripts/ScriptMgr.cpp @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2008 TrinityScript - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "Database/DatabaseEnv.h" @@ -12,10 +27,10 @@ #include "../game/ScriptMgr.h" -#define _FULLVERSION "TrinityScript" +#define _FULLVERSION "HellgroundScript" #ifndef _HELLGROUND_SCRIPT_CONFIG -# define _HELLGROUND_SCRIPT_CONFIG "trinitycore.conf" +# define _HELLGROUND_SCRIPT_CONFIG "hellgroundcore.conf" #endif // _HELLGROUND_SCRIPT_CONFIG int num_sc_scripts; @@ -54,15 +69,15 @@ void FreeScriptLibrary() HELLGROUND_DLL_EXPORT void InitScriptLibrary() { - //Trinity Script startup - outstring_log(" _____ _ _ _ ____ _ _"); - outstring_log("|_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ "); - outstring_log(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \'__| | \'_ \\| __|"); - outstring_log(" | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ "); - outstring_log(" |_||_| |_|_| |_|_|\\__|\\__, |____/ \\___|_| |_| .__/ \\__|"); - outstring_log(" |___/ |_| "); - outstring_log("Trinity Script initializing %s", _FULLVERSION); - outstring_log(""); + //Hellground Script startup + outstring_log(" _ _ _ _ _____ _ "); + outstring_log("| | | | | | | __ \\ | |"); + outstring_log("| |_| | ___| | | | \\/_ __ ___ _ _ _ __ __| |"); + outstring_log("| _ |/ _ \\ | | | __| '__/ _ \\| | | | '_ \\ / _` |"); + outstring_log("| | | | __/ | | |_\\ \\ | | (_) | |_| | | | | (_| |"); + outstring_log("\\_| |_/\\___|_|_|\\____/_| \\___/ \\__,_|_| |_|\\__,_|"); + outstring_log("http://hellground.net based on http://TrinityCore.org"); + outstring_log("Hellground Script initializing %s", _FULLVERSION); //Load database (must be called after TScriptConfig.SetSource). In case it failed, no need to even try load. LoadDatabase(); @@ -252,7 +267,7 @@ void Script::RegisterSelf(bool bReportError) HELLGROUND_DLL_EXPORT char const* GetScriptLibraryVersion() { - return "Default Trinity scripting library"; + return "Default Hellground scripting library"; } HELLGROUND_DLL_EXPORT diff --git a/src/scripts/ScriptMgr.h b/src/scripts/ScriptMgr.h index 992caf8ec..0c3dce248 100755 --- a/src/scripts/ScriptMgr.h +++ b/src/scripts/ScriptMgr.h @@ -1,9 +1,23 @@ -/* Copyright (C) 2008 Trinity +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * Thanks to the original authors: ScriptDev2 * - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_SCRIPTMGR_H #define SC_SCRIPTMGR_H @@ -29,7 +43,7 @@ struct ItemPrototype; #define MAX_SCRIPTS 5000 //72 bytes each (approx 351kb) #define VISIBLE_RANGE (166.0f) //MAX visible range (size of grid) -#define DEFAULT_TEXT "" +#define DEFAULT_TEXT "" struct Script { diff --git a/src/scripts/docs/EventAI.txt b/src/scripts/docs/EventAI.txt index 37064b63e..ed76690ea 100755 --- a/src/scripts/docs/EventAI.txt +++ b/src/scripts/docs/EventAI.txt @@ -108,7 +108,7 @@ Params are always read from Param1, then Param2, then Param3. 24 ACTION_T_EVADE No Params Forces the creature to evade. Wiping all threat and dropping combat. 25 ACTION_T_FLEE No Params Causes the .creature to flee. Please use this action instead of directly casting this spell so we may change this when a more correct approach is found. 26 ACTION_T_QUEST_EVENT_ALL QuestId Calls GroupEventHappens with (param1). Only used if it's _expected_ event should complete for all players in current party -27 ACTION_T_CASTCREATUREGO_ALL QuestId, SpellId Calls CastedCreatureOrGo for all players on the threat list with QuestID(Param1) and SpellId(Param2) +27 ACTION_T_CASTCREATUREGO_ALL QuestId, SpellId Calls CastCreatureOrGO for all players on the threat list with QuestID(Param1) and SpellId(Param2) 28 ACTION_T_REMOVEAURASFROMSPELL Target, Spellid Removes all auras on Target caused by Spellid 29 ACTION_T_RANGED_MOVEMENT Distance, Angle Changes the movement generator type to a ranged type. Note: Default melee type can still be done with this. Specify 0 angle and 0 distance. 30 ACTION_T_RANDOM_PHASE PhaseId1, PhaseId2, PhaseId3 Sets the phase to the id between 3 params* @@ -438,7 +438,7 @@ Parameter 1: CreatureID - The Creature Template ID to be Summoned. The value her Parameter 2: SpellId - The Spell ID to use to simulate the cast. The value used in this field needs to be a valid Spell ID. Parameter 3: Target - The Target Type defining whom the quest credit should be given to. The value in this field needs to be a valid target type as specified in the reference tables below. -This action will call CastedCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature. +This action will call CastCreatureOrGO() function for the player. It can be used to give quest credit for casting a spell on the creature. This is commonly used for NPC's who have a special requirement to have a Spell cast on them to complete a quest. ----------------------------- diff --git a/src/scripts/trinityscripts.rc b/src/scripts/hellgroundscripts.rc old mode 100755 new mode 100644 similarity index 79% rename from src/scripts/trinityscripts.rc rename to src/scripts/hellgroundscripts.rc index f93bed123..9fba40825 --- a/src/scripts/trinityscripts.rc +++ b/src/scripts/hellgroundscripts.rc @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,15 +9,15 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../trinitycore/resource.h" +#include "../hellgroundcore/resource.h" #include "../shared/revision.h" #define APSTUDIO_READONLY_SYMBOLS @@ -69,12 +70,12 @@ BEGIN BEGIN BLOCK "080004b0" BEGIN - VALUE "FileDescription", "TrinityScripts" + VALUE "FileDescription", "HellgroundScripts" VALUE "FileVersion", STRFILEVER - VALUE "InternalName", "TrinityScripts" - VALUE "LegalCopyright", "Copyright (C) 2008-2009" - VALUE "OriginalFilename", "TrinityScripts.dll" - VALUE "ProductName", "TrinityScripts" + VALUE "InternalName", "HellgroundScripts" + VALUE "LegalCopyright", "Copyright (C) 2008-2014" + VALUE "OriginalFilename", "HellgroundScripts.dll" + VALUE "ProductName", "HellgroundScripts" VALUE "ProductVersion", STRPRODUCTVER END END diff --git a/src/scripts/include/escort_ai.cpp b/src/scripts/include/escort_ai.cpp index 603e7c7bf..75637ce49 100644 --- a/src/scripts/include/escort_ai.cpp +++ b/src/scripts/include/escort_ai.cpp @@ -1,6 +1,20 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -32,7 +46,8 @@ npc_escortAI::npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature), QuestForEscort(NULL), CanInstantRespawn(false), CanReturnToStart(false), - ScriptWP(false) + ScriptWP(false), + ClearWaypoints(false) {} void npc_escortAI::AttackStart(Unit* pWho) @@ -42,12 +57,14 @@ void npc_escortAI::AttackStart(Unit* pWho) if (me->Attack(pWho, true)) { - //stop movement and attack the target && set the correct wp - //if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) - // CurrentWP = ReachedLastWP; + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE && !HasEscortState(STATE_ESCORT_INCOMBAT)) + AddEscortState(STATE_ESCORT_INCOMBAT); if (IsCombatMovement()) + { + me->StopMoving(); me->GetMotionMaster()->MoveChase(pWho); + } } } @@ -177,7 +194,6 @@ void npc_escortAI::EnterEvadeMode() if (HasEscortState(STATE_ESCORT_ESCORTING)) { - AddEscortState(STATE_ESCORT_RETURNING); ReturnToLastPoint(); } else @@ -217,7 +233,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange() void npc_escortAI::UpdateAI(const uint32 uiDiff) { //Waypoint Updating - if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->getVictim() && WPWaitTimer && !HasEscortState(STATE_ESCORT_RETURNING)) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->isInCombat() && WPWaitTimer && !HasEscortState(STATE_ESCORT_INCOMBAT)) { if (WPWaitTimer <= uiDiff) { @@ -251,6 +267,13 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } else { + if (ClearWaypoints) + { + WaypointList.clear(); + RemoveEscortState(STATE_ESCORT_ESCORTING); + ScriptWP = false; + } + debug_log("TSCR: EscortAI reached end of waypoints with Despawn off"); return; @@ -272,7 +295,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } //Check if player or any member of his group is within range - if (HasEscortState(STATE_ESCORT_ESCORTING) && PlayerGUID && !me->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING)) + if (HasEscortState(STATE_ESCORT_ESCORTING) && PlayerGUID && !me->isInCombat() && !HasEscortState(STATE_ESCORT_INCOMBAT)) { if (PlayerCheckTimer < uiDiff) { @@ -310,7 +333,7 @@ void npc_escortAI::UpdateEscortAI(const uint32 uiDiff) void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) { - if (uiMoveType != POINT_MOTION_TYPE || !HasEscortState(STATE_ESCORT_ESCORTING)) + if (uiMoveType != POINT_MOTION_TYPE || !HasEscortState(STATE_ESCORT_ESCORTING) || me->isInCombat()) return; //Combat start position reached, continue waypoint movement @@ -324,7 +347,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) me->SetWalk(true); me->GetUnitStateMgr().InitDefaults(false); - RemoveEscortState(STATE_ESCORT_RETURNING); + RemoveEscortState(STATE_ESCORT_INCOMBAT); if (!WPWaitTimer) WPWaitTimer = 1; @@ -334,7 +357,6 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) debug_log("TSCR: EscortAI has returned to original home location and will continue from beginning of waypoint list."); CurrentWP = WaypointList.begin(); - ReachedLastWP = WaypointList.begin(); WPWaitTimer = 1; } else @@ -352,7 +374,8 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) WaypointReached(CurrentWP->id); WPWaitTimer = CurrentWP->WaitTimeMs + 1; - ReachedLastWP = CurrentWP++; + + ++CurrentWP; } } @@ -362,16 +385,7 @@ void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 Wait WaypointList.push_back(t); - // i think SD2 no longer uses this function ScriptWP = true; - /*PointMovement wp; - wp.CreatureEntry = me->GetEntry(); - wp.PointId = id; - wp.m_fX = x; - wp.m_fY = y; - wp.m_fZ = z; - wp.WaitTime = WaitTimeMs; - PointMovementMap[wp.CreatureEntry].push_back(wp);*/ } void npc_escortAI::FillPointMovementListForCreature() diff --git a/src/scripts/include/escort_ai.h b/src/scripts/include/escort_ai.h index ec934202a..e47857fdc 100644 --- a/src/scripts/include/escort_ai.h +++ b/src/scripts/include/escort_ai.h @@ -32,8 +32,8 @@ enum eEscortState { STATE_ESCORT_NONE = 0x000, //nothing in progress STATE_ESCORT_ESCORTING = 0x001, //escort are in progress - STATE_ESCORT_RETURNING = 0x002, //escort is returning after being in combat - STATE_ESCORT_PAUSED = 0x004 //will not proceed with waypoints before state is removed + STATE_ESCORT_INCOMBAT = 0x002, //escort is in combat + STATE_ESCORT_PAUSED = 0x004, //will not proceed with waypoints before state is removed }; struct npc_escortAI : public ScriptedAI @@ -82,6 +82,7 @@ struct npc_escortAI : public ScriptedAI bool GetAttack() { return IsActiveAttacker; }//used in EnterEvadeMode override void SetCanAttack(bool attack) { IsActiveAttacker = attack; } uint64 GetEventStarterGUID() { return PlayerGUID; } + void SetClearWaypoints(bool clear) { ClearWaypoints = clear; } protected: Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*m_creature, PlayerGUID); } @@ -104,7 +105,6 @@ struct npc_escortAI : public ScriptedAI std::list WaypointList; std::list::iterator CurrentWP; - std::list::iterator ReachedLastWP; bool IsActiveAttacker; //obsolete, determined by faction. bool IsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK) @@ -113,5 +113,6 @@ struct npc_escortAI : public ScriptedAI bool DespawnAtEnd; bool DespawnAtFar; bool ScriptWP; + bool ClearWaypoints; //clear WaypointList and drop escort if DespawnAtEnd is off }; #endif diff --git a/src/scripts/include/follower_ai.cpp b/src/scripts/include/follower_ai.cpp index a9816c50a..67d0fcd08 100644 --- a/src/scripts/include/follower_ai.cpp +++ b/src/scripts/include/follower_ai.cpp @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: FollowerAI diff --git a/src/scripts/include/follower_ai.h b/src/scripts/include/follower_ai.h index 2b10bfa93..fdf8a2c81 100644 --- a/src/scripts/include/follower_ai.h +++ b/src/scripts/include/follower_ai.h @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_FOLLOWERAI_H #define SC_FOLLOWERAI_H diff --git a/src/scripts/include/precompiled.cpp b/src/scripts/include/precompiled.cpp index 8863d83ac..a43d37313 100755 --- a/src/scripts/include/precompiled.cpp +++ b/src/scripts/include/precompiled.cpp @@ -1,5 +1,20 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" diff --git a/src/scripts/include/precompiled.h b/src/scripts/include/precompiled.h index 35992f3d0..3ba520fc6 100755 --- a/src/scripts/include/precompiled.h +++ b/src/scripts/include/precompiled.h @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_PRECOMPILED_H #define SC_PRECOMPILED_H @@ -20,7 +35,6 @@ #include "sc_instance.h" #include "CombatAI.h" #include "PassiveAI.h" -#include "Config/Config.h" #ifdef WIN32 #include diff --git a/src/scripts/include/sc_creature.cpp b/src/scripts/include/sc_creature.cpp index a512f1816..77b1cf595 100755 --- a/src/scripts/include/sc_creature.cpp +++ b/src/scripts/include/sc_creature.cpp @@ -1,9 +1,23 @@ -/* Copyright (C) 2008 Trinity +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * Thanks to the original authors: ScriptDev2 * - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "Item.h" @@ -27,6 +41,18 @@ void SummonList::DoAction(uint32 entry, uint32 info) summon->AI()->DoAction(info); } } + +void SummonList::Cast(uint32 entry, uint32 spell, Unit* target) +{ + for (iterator i = begin(); i != end(); ) + { + Creature *summon = Unit::GetCreature(*m_creature, *i); + i++; + if(summon && (!entry || summon->GetEntry() == entry)) + summon->CastSpell(target, spell, true); + } +} + void SummonList::Despawn(Creature *summon) { uint64 guid = summon->GetGUID(); @@ -315,12 +341,12 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff) return; } - bool casted = false; + bool cast = false; - if (m_creature->hasUnitState(UNIT_STAT_CASTING)) - casted = true; + if (m_creature->hasUnitState(UNIT_STAT_CASTING) || me->IsNonMeleeSpellCast(true)) + cast = true; - if (!spellList.empty() && !casted) + if (!spellList.empty() && !cast) { SpellToCast temp(spellList.front()); spellList.pop_front(); @@ -332,16 +358,24 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff) if (!temp.spellId) return; - if (temp.scriptTextEntry) - DoScriptText(temp.scriptTextEntry, m_creature, m_creature->getVictim()); - if (temp.isDestCast) { m_creature->CastSpell(temp.castDest[0], temp.castDest[1], temp.castDest[2], temp.spellId, temp.triggered); - casted = true; + cast = true; return; } + if (temp.scriptTextEntry) + { + if (temp.targetGUID && temp.setAsTarget) + { + if (Unit* target = m_creature->GetUnit(temp.targetGUID)) + DoScriptText(temp.scriptTextEntry, m_creature, target); + } + else + DoScriptText(temp.scriptTextEntry, m_creature, m_creature->getVictim()); + } + if (temp.targetGUID) { Unit * tempU = m_creature->GetUnit(*m_creature, temp.targetGUID); @@ -349,7 +383,7 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff) if (tempU && tempU->IsInWorld() && tempU->isAlive() && tempU->IsInMap(m_creature)) if (temp.spellId) { - if(temp.setAsTarget) + if(temp.setAsTarget && !m_creature->hasIgnoreVictimSelection()) m_creature->SetSelection(temp.targetGUID); if(temp.hasCustomValues) m_creature->CastCustomSpell(tempU, temp.spellId, &temp.damage[0], &temp.damage[1], &temp.damage[2], temp.triggered); @@ -365,14 +399,14 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff) m_creature->CastSpell((Unit*)NULL, temp.spellId, temp.triggered); } - casted = true; + cast = true; } if (autocast) { if (autocastTimer < diff) { - if (!casted) + if (!cast) { Unit * victim = NULL; @@ -415,7 +449,7 @@ void ScriptedAI::CastNextSpellIfAnyAndReady(uint32 diff) } } - if (victim) + if (victim && !m_creature->hasIgnoreVictimSelection()) { m_creature->SetSelection(victim->GetGUID()); // for autocast always target actual victim m_creature->CastSpell(victim, autocastId, false); @@ -448,7 +482,7 @@ void ScriptedAI::DoCastAOE(uint32 spellId, bool triggered) void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered) { - if (/*!who || */m_creature->IsNonMeleeSpellCasted(false)) + if (/*!who || */m_creature->IsNonMeleeSpellCast(false)) return; m_creature->CastSpell(who, spellInfo, triggered); @@ -506,14 +540,14 @@ void ScriptedAI::AddCustomSpellToCast(uint32 spellId, castTargetMode targetMode, spellList.push_back(temp); } -void ScriptedAI::AddSpellToCastWithScriptText(uint32 spellId, castTargetMode targetMode, int32 scriptTextEntry, bool triggered) +void ScriptedAI::AddSpellToCastWithScriptText(uint32 spellId, castTargetMode targetMode, int32 scriptTextEntry, bool triggered, bool visualTarget) { Unit *pTarget = SelectCastTarget(spellId, targetMode); if (!pTarget && targetMode != CAST_NULL) return; uint64 targetGUID = pTarget ? pTarget->GetGUID() : 0; - SpellToCast temp(targetGUID, spellId, triggered, scriptTextEntry, false); + SpellToCast temp(targetGUID, spellId, triggered, scriptTextEntry, visualTarget); spellList.push_back(temp); } @@ -526,7 +560,7 @@ void ScriptedAI::ForceSpellCast(Unit *victim, uint32 spellId, interruptSpell int m_creature->InterruptNonMeleeSpells(false); break; case INTERRUPT_AND_CAST_INSTANTLY: - if(visualTarget) + if(visualTarget && !m_creature->hasIgnoreVictimSelection()) m_creature->SetSelection(victim->GetGUID()); m_creature->CastSpell(victim, spellId, triggered); @@ -551,7 +585,7 @@ void ScriptedAI::ForceSpellCastWithScriptText(Unit *victim, uint32 spellId, int3 if (scriptTextEntry) DoScriptText(scriptTextEntry, m_creature, victim); - if (visualTarget) + if (visualTarget && !m_creature->hasIgnoreVictimSelection()) m_creature->SetSelection(victim->GetGUID()); m_creature->CastSpell(victim, spellId, triggered); @@ -713,18 +747,18 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* unit, uint32 sound) Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) { - return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime); + return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TemporarySummonType)type, despawntime); } SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 uiMechanic, SelectTargetType selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffects) { //No target so we can't cast if (!pTarget) - return false; + return NULL; //Silenced so we can't cast if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; + return NULL; //Using the extended script system we first create a list of viable spells SpellEntry const* apSpell[CREATURE_MAX_SPELLS]; @@ -908,8 +942,8 @@ void ScriptedAI::DoResetThreat() return; } - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator itr; + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator itr; for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) { diff --git a/src/scripts/include/sc_creature.h b/src/scripts/include/sc_creature.h index 4aeb91610..005898761 100755 --- a/src/scripts/include/sc_creature.h +++ b/src/scripts/include/sc_creature.h @@ -1,9 +1,23 @@ -/* Copyright (C) 2008 Trinity +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * Thanks to the original authors: ScriptDev2 * - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_CREATURE_H #define SC_CREATURE_H @@ -38,6 +52,7 @@ class SummonList : std::list bool isEmpty(); void AuraOnEntry(uint32 entry, uint32 spellId, bool apply); void DoAction(uint32 entry, uint32 info); + void Cast(uint32 entry, uint32 spell, Unit* target); private: Creature *m_creature; }; @@ -315,7 +330,7 @@ struct ScriptedAI : public CreatureAI void AddSpellToCast(uint32 spellId, castTargetMode targetMode = CAST_TANK, bool triggered = false, bool visualTarget = false); void AddCustomSpellToCast(uint32 spellId, castTargetMode targetMode, int32 dmg0 = 0, int32 dmg1 = 0, int32 dmg2 = 0, bool triggered = false); void AddSpellToCastWithScriptText(Unit* victim, uint32 spellId, int32 scriptTextEntry, bool triggered = false, bool visualTarget = false); - void AddSpellToCastWithScriptText(uint32 spellId, castTargetMode targetMode, int32 scriptTextEntry, bool triggered = false); + void AddSpellToCastWithScriptText(uint32 spellId, castTargetMode targetMode, int32 scriptTextEntry, bool triggered = false, bool visualTarget = false); //Forces spell cast by Id void ForceSpellCast(Unit* victim, uint32 spellId, interruptSpell interruptCurrent = DONT_INTERRUPT, bool triggered = false, bool visualTarget = false); diff --git a/src/scripts/include/sc_gossip.h b/src/scripts/include/sc_gossip.h index 74bc93694..eaca0bd71 100755 --- a/src/scripts/include/sc_gossip.h +++ b/src/scripts/include/sc_gossip.h @@ -1,12 +1,26 @@ -/* Copyright (C) 2008 Trinity +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * Thanks to the original authors: ScriptDev2 * - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef SC_PLAYER_H -#define SC_PLAYER_H +#ifndef SC_GOSSIP_H +#define SC_GOSSIP_H #include "Player.h" #include "GossipDef.h" diff --git a/src/scripts/include/sc_instance.h b/src/scripts/include/sc_instance.h index 3a6517889..fb4204584 100755 --- a/src/scripts/include/sc_instance.h +++ b/src/scripts/include/sc_instance.h @@ -1,6 +1,23 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * Thanks to the original authors: ScriptDev2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_INSTANCE_H #define SC_INSTANCE_H diff --git a/src/scripts/scripts/Eastern Kingdoms/alterac_mountains/alterac_mountains.cpp b/src/scripts/scripts/Eastern Kingdoms/alterac_mountains/alterac_mountains.cpp new file mode 100644 index 000000000..601cef331 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/alterac_mountains/alterac_mountains.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Alterac_Mountains +SD%Complete: 100 +SDComment: Quest support: 6681, 1713 +SDCategory: Alterac Mountains +EndScriptData */ + +/* ContentData +npc_ravenholdt +EndContentData */ + +#include "precompiled.h" +#include "escort_ai.h" + +/*###### +## npc_ravenholdt +######*/ + +struct npc_ravenholdtAI : public ScriptedAI +{ + npc_ravenholdtAI(Creature *creature) : ScriptedAI(creature) {} + + void Reset() { } + + void MoveInLineOfSight(Unit *who) + { + if (who->GetTypeId() == TYPEID_PLAYER) + if (((Player*)who)->GetQuestStatus(6681) == QUEST_STATUS_INCOMPLETE) + ((Player*)who)->KilledMonster(me->GetEntry(), me->GetGUID()); + } +}; + +CreatureAI* GetAI_npc_ravenholdt(Creature *creature) +{ + return new npc_ravenholdtAI (creature); +} + +/*###### +## npc_windwatcher +######*/ + +#define SAY_START -1900233 +#define SAY_SUMMONING -1900234 + +#define QUEST_SUMMONING 1713 +#define SPELL_SUMMON 8606 + +struct npc_windwatcherAI : public npc_escortAI +{ + npc_windwatcherAI(Creature* creature) : npc_escortAI(creature) {} + + void Reset() {} + + void EnterCombat(Unit* who){} + + void JustSummoned(Creature *summoned) + { + if (Player* player = GetPlayerForEscort()) + summoned->AI()->AttackStart(player); + } + + void WaypointReached(uint32 i) + { + Player* player = GetPlayerForEscort(); + + switch(i) + { + case 6: + DoScriptText(SAY_SUMMONING, me, player); + DoCast(me, SPELL_SUMMON); + break; + case 13: + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + me->SetFacingTo(1.39f); + break; + } + } +}; + +CreatureAI* GetAI_npc_windwatcher(Creature* creature) +{ + return new npc_windwatcherAI(creature); +} + +bool QuestAccept_npc_windwatcher(Player* player, Creature* creature, Quest const* quest) +{ + if (quest->GetQuestId() == QUEST_SUMMONING) + { + if (npc_escortAI* pEscortAI = CAST_AI(npc_windwatcherAI, creature->AI())) + { + pEscortAI->SetClearWaypoints(true); + pEscortAI->SetDespawnAtEnd(false); + pEscortAI->SetDespawnAtFar(false); + pEscortAI->Start(false, false, player->GetGUID(), quest); + } + DoScriptText(SAY_START, creature, player); + } + return true; +} + +/*###### +## npc_av_trinket_questgiver +######*/ + +uint32 av_insignia[12] = {17690, 17905, 17906, 17907, 17908, 17909, 17691, 17900, 17901, 17902, 17903, 17904}; +uint32 av_quests[12] = {7161, 7163, 7164, 7165, 7166, 7167, 7162, 7168, 7169, 7170, 7171, 7172}; +#define GOSSIP_AV_TRINKET "Restore Insignia." + +bool GossipHello_npc_av_trinket_questgiver(Player* player,Creature* creature) +{ + if( creature->isQuestGiver() ) + player->PrepareQuestMenu( creature->GetGUID() ); + + bool hasTrinket = false; + for(uint8 i=0;i<12;i++) + { + if(player->HasItemCount(av_insignia[i],1,true)) + { + hasTrinket = true; + break; + } + } + + if(!hasTrinket && (player->GetQuestStatus(7161) == QUEST_STATUS_COMPLETE || player->GetQuestStatus(7162) == QUEST_STATUS_COMPLETE)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_AV_TRINKET, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO); + + player->SEND_GOSSIP_MENU(creature->GetNpcTextId(),creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_av_trinket_questgiver(Player* player, Creature* creature, uint32 sender, uint32 action) +{ + if (action != GOSSIP_SENDER_INFO) + return true; + + for(uint8 i=0;i<12;i++) // check again just in case + { + if(player->HasItemCount(av_insignia[i],1,true)) + return true; + } + + uint8 trinketType = 255; + for(uint8 i=0;i<12;i++) + { + if(player->GetQuestStatus(av_quests[i]) == QUEST_STATUS_COMPLETE) + trinketType = i; + } + + if(trinketType == 255) //just in case + return true; + + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, av_insignia[trinketType], 1); + if (msg == EQUIP_ERR_OK) + { + Item* item = player->StoreNewItem(dest, av_insignia[trinketType], true); + player->SendNewItem(item,1,true,false,true); + } + player->CLOSE_GOSSIP_MENU(); + + return true; +} + +void AddSC_alterac_mountains() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_ravenholdt"; + newscript->GetAI = &GetAI_npc_ravenholdt; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_windwatcher"; + newscript->GetAI = &GetAI_npc_windwatcher; + newscript->pQuestAcceptNPC = &QuestAccept_npc_windwatcher; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_av_trinket_questgiver"; + newscript->pGossipHello = &GossipHello_npc_av_trinket_questgiver; + newscript->pGossipSelect = &GossipSelect_npc_av_trinket_questgiver; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/alterac_valley/boss_balinda.cpp b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_balinda.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/alterac_valley/boss_balinda.cpp rename to src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_balinda.cpp index a116af6ea..1c2e2cbc3 --- a/src/scripts/scripts/zone/alterac_valley/boss_balinda.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_balinda.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_drekthar.cpp b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_drekthar.cpp new file mode 100644 index 000000000..a21aa006d --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_drekthar.cpp @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_DrekThar +SD%Complete: 50% +SDComment: Some spells listed on wowwiki but doesn't exist on wowhead +EndScriptData */ + +#include "precompiled.h" + +#define YELL_AGGRO -2100000 + +#define YELL_EVADE -2100001 +#define YELL_RESPAWN -2100002 + +#define YELL_RANDOM1 -2100003 +#define YELL_RANDOM2 -2100004 +#define YELL_RANDOM3 -2100005 +#define YELL_RANDOM4 -2100006 +#define YELL_RANDOM5 -2100007 + + +#define SPELL_WHIRLWIND 15589 +#define SPELL_WHIRLWIND2 13736 +#define SPELL_KNOCKDOWN 19128 +#define SPELL_FRENZY 8269 +#define SPELL_SWEEPING_STRIKES 18765 // not sure +#define SPELL_CLEAVE 20677 // not sure +#define SPELL_WINDFURY 35886 // not sure +#define SPELL_STORMPIKE 51876 // not sure + +#define AV_DREKTHAR_NPC_COUNT 5 + +uint32 avDrekTharNpcId[AV_DREKTHAR_NPC_COUNT] = +{ + 14772, + 14777, + 14776, + 14773, + 11946 +}; + +struct boss_drektharAI : public ScriptedAI +{ + boss_drektharAI(Creature *c) : ScriptedAI(c) + { + m_creature->GetPosition(wLoc); + } + + uint32 WhirlwindTimer; + uint32 Whirlwind2Timer; + uint32 KnockdownTimer; + uint32 FrenzyTimer; + uint32 YellTimer; + uint32 CheckTimer; + WorldLocation wLoc; + + void Reset() + { + WhirlwindTimer = urand(0, 10000); + Whirlwind2Timer = urand(0, 15000); + KnockdownTimer = 12000; + FrenzyTimer = 6000; + YellTimer = urand(20000, 30000); //20 to 30 seconds + CheckTimer = 2000; + } + + void EnterCombat(Unit *who) + { + DoScriptText(YELL_AGGRO, m_creature); + + // pull rest + std::for_each(avDrekTharNpcId, avDrekTharNpcId + AV_DREKTHAR_NPC_COUNT, + [this, who] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isAlive() && c->IsAIEnabled && c->AI()) + c->AI()->AttackStart(who); + }); + } + + void JustRespawned() + { + Reset(); + DoScriptText(YELL_RESPAWN, m_creature); + } + + void EnterEvadeMode() + { + if (!me->isInCombat() || me->IsInEvadeMode()) + return; + + CreatureAI::EnterEvadeMode(); + + // evade rest + std::for_each(avDrekTharNpcId, avDrekTharNpcId + AV_DREKTHAR_NPC_COUNT, + [this] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isInCombat() && c->IsAIEnabled && c->AI()) + c->AI()->EnterEvadeMode(); + }); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (CheckTimer < diff) + { + if(!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) + EnterEvadeMode(); + + me->SetSpeed(MOVE_WALK, 2.0f, true); + me->SetSpeed(MOVE_RUN, 2.0f, true); + + CheckTimer = 2000; + } + else + CheckTimer -= diff; + + if (WhirlwindTimer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_WHIRLWIND); + WhirlwindTimer = urand(8000, 18000); + } + else + WhirlwindTimer -= diff; + + if (Whirlwind2Timer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_WHIRLWIND2); + Whirlwind2Timer = urand(7000, 25000); + } + else + Whirlwind2Timer -= diff; + + if (KnockdownTimer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_KNOCKDOWN); + KnockdownTimer = urand(10000, 15000); + } + else + KnockdownTimer -= diff; + + if (FrenzyTimer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_FRENZY); + FrenzyTimer = urand(20000, 25000); + } + else + FrenzyTimer -= diff; + + if (YellTimer < diff) + { + DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5), m_creature); + YellTimer = urand(20000, 30000); //20 to 30 seconds + } + else + YellTimer -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +enum AVDrekTharOfficerSpells +{ + AV_DT_CHARGE = 22911, + AV_DT_CLEAVE = 40504, + AV_DT_DEMOSHOUT = 23511, + AV_DT_WHIRLWIND = 13736, + AV_DT_ENRAGE = 8599 +}; + +struct boss_drektharOfficerAI : public ScriptedAI +{ + boss_drektharOfficerAI(Creature *c) : ScriptedAI(c) + { + m_creature->GetPosition(wLoc); + } + + uint32 chargeTimer; + uint32 cleaveTimer; + uint32 demoShoutTimer; + uint32 whirlwindTimer; + uint32 CheckTimer; + WorldLocation wLoc; + + void Reset() + { + chargeTimer = urand(7500, 20000); + cleaveTimer = urand(5000, 10000); + demoShoutTimer = urand(2000, 4000); + whirlwindTimer = urand(9000, 13000); + CheckTimer = 2000; + } + + void EnterCombat(Unit *who) + { + // pull rest + std::for_each(avDrekTharNpcId, avDrekTharNpcId + AV_DREKTHAR_NPC_COUNT, + [this, who] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isAlive() && c->IsAIEnabled && c->AI()) + c->AI()->AttackStart(who); + }); + } + + void JustRespawned() + { + Reset(); + } + + void EnterEvadeMode() + { + if (!me->isInCombat() || me->IsInEvadeMode()) + return; + + CreatureAI::EnterEvadeMode(); + + // evade rest + std::for_each(avDrekTharNpcId, avDrekTharNpcId + AV_DREKTHAR_NPC_COUNT, + [this] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isInCombat() && c->IsAIEnabled && c->AI()) + c->AI()->EnterEvadeMode(); + }); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (CheckTimer < diff) + { + if (!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) + EnterEvadeMode(); + + me->SetSpeed(MOVE_WALK, 1.5f, true); + me->SetSpeed(MOVE_RUN, 1.5f, true); + + CheckTimer = 2000; + } + else + CheckTimer -= diff; + + if (chargeTimer < diff) + { + Unit * target = SelectUnit(SELECT_TARGET_RANDOM, 0, 25.0f, true, 0, 8.0f); + + if (target) + AddSpellToCast(target, AV_DT_CHARGE); + + chargeTimer = urand(7500, 20000); + } + else + chargeTimer -= diff; + + if (cleaveTimer < diff) + { + AddSpellToCast(AV_DT_CLEAVE, CAST_TANK); + cleaveTimer = urand(5000, 10000); + } + else + cleaveTimer -= diff; + + if (demoShoutTimer < diff) + { + AddSpellToCast(AV_DT_DEMOSHOUT, CAST_NULL); + demoShoutTimer = urand(14000, 25000); + } + else + demoShoutTimer -= diff; + + if (whirlwindTimer < diff) + { + AddSpellToCast(AV_DT_WHIRLWIND, CAST_SELF); + whirlwindTimer = urand(9000, 13000); + } + else + whirlwindTimer -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_drekthar(Creature *_Creature) +{ + return new boss_drektharAI (_Creature); +} + +CreatureAI* GetAI_boss_drektharOfficer(Creature *_Creature) +{ + return new boss_drektharOfficerAI (_Creature); +} + +void AddSC_boss_drekthar() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "boss_drekthar"; + newscript->GetAI = &GetAI_boss_drekthar; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "boss_drekthar_officer"; + newscript->GetAI = &GetAI_boss_drektharOfficer; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/alterac_valley/boss_galvangar.cpp b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_galvangar.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/alterac_valley/boss_galvangar.cpp rename to src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_galvangar.cpp index 640fa3036..b533269ce --- a/src/scripts/scripts/zone/alterac_valley/boss_galvangar.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_galvangar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_vanndar.cpp b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_vanndar.cpp new file mode 100644 index 000000000..f669804fd --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/alterac_valley/boss_vanndar.cpp @@ -0,0 +1,335 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Vanndar +SD%Complete: +SDComment: Some spells listed on wowwiki but doesn't exist on wowhead +EndScriptData */ + +#include "precompiled.h" + +#define YELL_AGGRO -2100008 + +#define YELL_EVADE -2100009 +#define YELL_RESPAWN1 -2100010 +#define YELL_RESPAWN2 -2100011 + +#define YELL_RANDOM1 -2100012 +#define YELL_RANDOM2 -2100013 +#define YELL_RANDOM3 -2100014 +#define YELL_RANDOM4 -2100015 +#define YELL_RANDOM5 -2100016 +#define YELL_RANDOM6 -2100017 +#define YELL_RANDOM7 -2100018 + + +#define SPELL_AVATAR 19135 +#define SPELL_THUNDERCLAP 15588 +#define SPELL_STORMBOLT 20685 // not sure + +#define AV_VANDAR_NPC_COUNT 5 + +uint32 avVandarNpcIds[AV_VANDAR_NPC_COUNT] = +{ + 14762, + 14763, + 14764, + 14765, + 11948 +}; + +struct boss_vanndarAI : public ScriptedAI +{ + boss_vanndarAI(Creature *c) : ScriptedAI(c) + { + m_creature->GetPosition(wLoc); + } + + uint32 AvatarTimer; + uint32 ThunderclapTimer; + uint32 StormboltTimer; + uint32 YellTimer; + uint32 CheckTimer; + WorldLocation wLoc; + + void Reset() + { + AvatarTimer = 3000; + ThunderclapTimer = 4000; + StormboltTimer = 6000; + YellTimer = urand(20000, 30000); //20 to 30 seconds + CheckTimer = 2000; + } + + void EnterCombat(Unit *who) + { + DoScriptText(YELL_AGGRO, m_creature); + + // pull rest + std::for_each(avVandarNpcIds, avVandarNpcIds + AV_VANDAR_NPC_COUNT, + [this, who] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isAlive() && c->IsAIEnabled && c->AI()) + c->AI()->AttackStart(who); + }); + } + + void JustRespawned() + { + Reset(); + DoScriptText(RAND(YELL_RESPAWN1, YELL_RESPAWN2), m_creature); + } + + void EnterEvadeMode() + { + if (!me->isInCombat() || me->IsInEvadeMode()) + return; + + CreatureAI::EnterEvadeMode(); + + // evade rest + std::for_each(avVandarNpcIds, avVandarNpcIds + AV_VANDAR_NPC_COUNT, + [this] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->IsAIEnabled && c->AI()) + c->AI()->EnterEvadeMode(); + }); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (CheckTimer < diff) + { + if (!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) + EnterEvadeMode(); + + me->SetSpeed(MOVE_WALK, 2.0f, true); + me->SetSpeed(MOVE_RUN, 2.0f, true); + + CheckTimer = 2000; + } + else + CheckTimer -= diff; + + if (AvatarTimer < diff) + { + ForceSpellCast(m_creature->getVictim(), SPELL_AVATAR); + AvatarTimer = urand(15000, 20000); + } + else + AvatarTimer -= diff; + + if (ThunderclapTimer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_THUNDERCLAP); + ThunderclapTimer = urand(5000, 15000); + } + else + ThunderclapTimer -= diff; + + if (StormboltTimer < diff) + { + Unit * victim = SelectUnit(SELECT_TARGET_RANDOM, 1, 30.0f, true); + if (victim) + AddSpellToCast(victim, SPELL_STORMBOLT); + StormboltTimer = urand(10000, 25000); + } + else + StormboltTimer -= diff; + + if (YellTimer < diff) + { + DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5, YELL_RANDOM6, YELL_RANDOM7), m_creature); + YellTimer = urand(20000, 30000); //20 to 30 seconds + } + else + YellTimer -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +enum AVVanndarOfficerSpells +{ + AV_VO_CHARGE = 22911, + AV_VO_CLEAVE = 40504, + AV_VO_DEMOSHOUT = 23511, + AV_VO_WHIRLWIND = 13736, + AV_VO_ENRAGE = 8599 +}; + +struct boss_vanndarOfficerAI : public ScriptedAI +{ + boss_vanndarOfficerAI(Creature *c) : ScriptedAI(c) + { + m_creature->GetPosition(wLoc); + } + + uint32 chargeTimer; + uint32 cleaveTimer; + uint32 demoShoutTimer; + uint32 whirlwindTimer; + uint32 CheckTimer; + WorldLocation wLoc; + + void Reset() + { + chargeTimer = urand(7500, 20000); + cleaveTimer = urand(5000, 10000); + demoShoutTimer = urand(2000, 4000); + whirlwindTimer = urand(9000, 13000); + CheckTimer = 2000; + } + + void EnterCombat(Unit *who) + { + // pull rest + std::for_each(avVandarNpcIds, avVandarNpcIds + AV_VANDAR_NPC_COUNT, + [this, who] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isAlive() && c->IsAIEnabled && c->AI()) + c->AI()->AttackStart(who); + }); + } + + void JustRespawned() + { + Reset(); + } + + void EnterEvadeMode() + { + if (!me->isInCombat() || me->IsInEvadeMode()) + return; + + CreatureAI::EnterEvadeMode(); + + // evade rest + std::for_each(avVandarNpcIds, avVandarNpcIds + AV_VANDAR_NPC_COUNT, + [this] (uint32 a)->void + { + if (a == me->GetEntry()) + return; + + Creature * c = me->GetMap()->GetCreatureById(a); + if (c && c->isInCombat() && c->IsAIEnabled && c->AI()) + c->AI()->EnterEvadeMode(); + }); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (CheckTimer < diff) + { + if (!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) + EnterEvadeMode(); + + me->SetSpeed(MOVE_WALK, 1.5f, true); + me->SetSpeed(MOVE_RUN, 1.5f, true); + + CheckTimer = 2000; + } + else + CheckTimer -= diff; + + if (chargeTimer < diff) + { + Unit * target = SelectUnit(SELECT_TARGET_RANDOM, 0, 25.0f, true, 0, 8.0f); + + if (target) + AddSpellToCast(target, AV_VO_CHARGE); + + chargeTimer = urand(7500, 20000); + } + else + chargeTimer -= diff; + + if (cleaveTimer < diff) + { + AddSpellToCast(AV_VO_CLEAVE, CAST_TANK); + cleaveTimer = urand(5000, 10000); + } + else + cleaveTimer -= diff; + + if (demoShoutTimer < diff) + { + AddSpellToCast(AV_VO_DEMOSHOUT, CAST_NULL); + demoShoutTimer = urand(14000, 25000); + } + else + demoShoutTimer -= diff; + + if (whirlwindTimer < diff) + { + AddSpellToCast(AV_VO_WHIRLWIND, CAST_SELF); + whirlwindTimer = urand(9000, 13000); + } + else + whirlwindTimer -= diff; + + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_vanndar(Creature *_Creature) +{ + return new boss_vanndarAI (_Creature); +} + +CreatureAI* GetAI_boss_vanndarOfficer(Creature *_Creature) +{ + return new boss_vanndarOfficerAI (_Creature); +} + +void AddSC_boss_vanndar() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "boss_vanndar"; + newscript->GetAI = &GetAI_boss_vanndar; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "boss_vanndar_officer"; + newscript->GetAI = &GetAI_boss_vanndarOfficer; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/arathi_highlands/arathi_highlands.cpp b/src/scripts/scripts/Eastern Kingdoms/arathi_highlands/arathi_highlands.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/arathi_highlands/arathi_highlands.cpp rename to src/scripts/scripts/Eastern Kingdoms/arathi_highlands/arathi_highlands.cpp index 68434f8cb..0d2430fe5 --- a/src/scripts/scripts/zone/arathi_highlands/arathi_highlands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/arathi_highlands/arathi_highlands.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/blackrock_depths.cpp old mode 100755 new mode 100644 similarity index 61% rename from src/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/blackrock_depths.cpp index 0db4ce4b1..0e244cd01 --- a/src/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/blackrock_depths.cpp @@ -1,6 +1,8 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -18,7 +20,7 @@ /* ScriptData SDName: Blackrock_Depths SD%Complete: 95 -SDComment: Quest support: 4001, 4342, 7604, 4322. Vendor Lokhtos Darkbargainer. Need to rewrite the Jail Break support +SDComment: Quest support: 4001, 4342, 7604, 4322. Vendor Lokhtos Darkbargainer. SDCategory: Blackrock Depths EndScriptData */ @@ -79,9 +81,9 @@ bool AreaTrigger_at_ring_of_law(Player *player, AreaTriggerEntry const* at) { ScriptedInstance* pInstance = (player->GetInstanceData()); - if(pInstance) + if (pInstance) { - if(pInstance->GetData(TYPE_RING_OF_LAW) == IN_PROGRESS || pInstance->GetData(TYPE_RING_OF_LAW) == DONE) + if (pInstance->GetData(TYPE_RING_OF_LAW) == IN_PROGRESS || pInstance->GetData(TYPE_RING_OF_LAW) == DONE) return false; pInstance->SetData(TYPE_RING_OF_LAW,IN_PROGRESS); @@ -121,7 +123,7 @@ struct npc_grimstoneAI : public npc_escortAI void Reset() { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); EventPhase = 0; Event_Timer = 1000; @@ -141,7 +143,7 @@ struct npc_grimstoneAI : public npc_escortAI void DoGate(uint32 id, uint32 state) { - if (GameObject *go = GameObject::GetGameObject(*m_creature,pInstance->GetData64(id))) + if (GameObject *go = GameObject::GetGameObject(*me,pInstance->GetData64(id))) go->SetGoState(GOState(state)); debug_log("TSCR: npc_grimstone, arena gate update state."); @@ -150,7 +152,7 @@ struct npc_grimstoneAI : public npc_escortAI //TODO: move them to center void SummonRingMob() { - if (Creature* tmp = m_creature->SummonCreature(RingMob[MobSpawnId],608.960,-235.322,-53.907,1.857,TEMPSUMMON_DEAD_DESPAWN,0)) + if (Creature* tmp = me->SummonCreature(RingMob[MobSpawnId],608.960,-235.322,-53.907,1.857,TEMPSUMMON_DEAD_DESPAWN,0)) RingMobGUID[MobCount] = tmp->GetGUID(); ++MobCount; @@ -162,7 +164,7 @@ struct npc_grimstoneAI : public npc_escortAI //TODO: move them to center void SummonRingBoss() { - if (Creature* tmp = m_creature->SummonCreature(RingBoss[rand()%6],644.300,-175.989,-53.739,3.418,TEMPSUMMON_DEAD_DESPAWN,0)) + if (Creature* tmp = me->SummonCreature(RingBoss[rand()%6],644.300,-175.989,-53.739,3.418,TEMPSUMMON_DEAD_DESPAWN,0)) RingBossGUID = tmp->GetGUID(); MobDeath_Timer = 2500; @@ -173,12 +175,12 @@ struct npc_grimstoneAI : public npc_escortAI switch(i) { case 0: - DoScriptText(-1000002, m_creature);//2 + DoScriptText(-1000002, me);//2 CanWalk = false; Event_Timer = 5000; break; case 1: - DoScriptText(-1000003, m_creature);//4 + DoScriptText(-1000003, me);//4 CanWalk = false; Event_Timer = 5000; break; @@ -186,10 +188,10 @@ struct npc_grimstoneAI : public npc_escortAI CanWalk = false; break; case 3: - DoScriptText(-1000005, m_creature);//5 + DoScriptText(-1000005, me);//5 break; case 4: - DoScriptText(-1000006, m_creature);//6 + DoScriptText(-1000006, me);//6 CanWalk = false; Event_Timer = 5000; break; @@ -216,7 +218,7 @@ struct npc_grimstoneAI : public npc_escortAI if (RingBossGUID) { - Creature *boss = Unit::GetCreature(*m_creature,RingBossGUID); + Creature *boss = Unit::GetCreature(*me,RingBossGUID); if (boss && !boss->isAlive() && boss->isDead()) { RingBossGUID = 0; @@ -229,7 +231,7 @@ struct npc_grimstoneAI : public npc_escortAI for(uint8 i = 0; i < MOB_AMOUNT; i++) { - Creature *mob = Unit::GetCreature(*m_creature,RingMobGUID[i]); + Creature *mob = Unit::GetCreature(*me,RingMobGUID[i]); if (mob && !mob->isAlive() && mob->isDead()) { RingMobGUID[i] = 0; @@ -255,7 +257,7 @@ struct npc_grimstoneAI : public npc_escortAI switch(EventPhase) { case 0: - DoScriptText(-1000001, m_creature);//1 + DoScriptText(-1000001, me);//1 DoGate(DATA_ARENA4,1); Start(false, false); CanWalk = true; @@ -274,7 +276,7 @@ struct npc_grimstoneAI : public npc_escortAI break; case 4: CanWalk = true; - m_creature->SetVisibility(VISIBILITY_OFF); + me->SetVisibility(VISIBILITY_OFF); SummonRingMob(); Event_Timer = 8000; break; @@ -288,9 +290,9 @@ struct npc_grimstoneAI : public npc_escortAI Event_Timer = 0; break; case 7: - m_creature->SetVisibility(VISIBILITY_ON); + me->SetVisibility(VISIBILITY_ON); DoGate(DATA_ARENA1,1); - DoScriptText(-1000004, m_creature);//4 + DoScriptText(-1000004, me);//4 CanWalk = true; Event_Timer = 0; break; @@ -299,7 +301,7 @@ struct npc_grimstoneAI : public npc_escortAI Event_Timer = 5000; break; case 9: - m_creature->SetVisibility(VISIBILITY_OFF); + me->SetVisibility(VISIBILITY_OFF); SummonRingBoss(); Event_Timer = 0; break; @@ -323,9 +325,9 @@ struct npc_grimstoneAI : public npc_escortAI } }; -CreatureAI* GetAI_npc_grimstone(Creature *_Creature) +CreatureAI* GetAI_npc_grimstone(Creature *creature) { - npc_grimstoneAI* Grimstone_AI = new npc_grimstoneAI(_Creature); + npc_grimstoneAI* Grimstone_AI = new npc_grimstoneAI(creature); for(uint8 i = 0; i < 6; ++i) Grimstone_AI->AddWaypoint(i, RingLocations[i][0], RingLocations[i][1], RingLocations[i][2]); @@ -364,24 +366,24 @@ struct mob_phalanxAI : public ScriptedAI void UpdateAI(const uint32 diff) { //Return since we have no target - if(!UpdateVictim() ) + if (!UpdateVictim()) return; //ThunderClap_Timer - if( ThunderClap_Timer < diff ) + if (ThunderClap_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + DoCast(me->getVictim(),SPELL_THUNDERCLAP); ThunderClap_Timer = 10000; } else ThunderClap_Timer -= diff; //FireballVolley_Timer - if( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + if (me->GetHealth()*100 / me->GetMaxHealth() < 51) { if (FireballVolley_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FIREBALLVOLLEY); + DoCast(me->getVictim(),SPELL_FIREBALLVOLLEY); FireballVolley_Timer = 15000; } else @@ -389,9 +391,9 @@ struct mob_phalanxAI : public ScriptedAI } //MightyBlow_Timer - if( MightyBlow_Timer < diff ) + if (MightyBlow_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + DoCast(me->getVictim(),SPELL_MIGHTYBLOW); MightyBlow_Timer = 10000; } else @@ -400,9 +402,9 @@ struct mob_phalanxAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_mob_phalanx(Creature *_Creature) +CreatureAI* GetAI_mob_phalanx(Creature *creature) { - return new mob_phalanxAI (_Creature); + return new mob_phalanxAI (creature); } /*###### @@ -424,61 +426,61 @@ CreatureAI* GetAI_mob_phalanx(Creature *_Creature) #define GOSSIP_ITEM_KHARAN_9 "Indeed." #define GOSSIP_ITEM_KHARAN_10 "The door is open, Kharan. You are a free man." -bool GossipHello_npc_kharan_mighthammer(Player *player, Creature *_Creature) +bool GossipHello_npc_kharan_mighthammer(Player *player, Creature *creature) { - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); - if( player->GetQuestStatus(QUEST_4001) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KHARAN_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + if (player->GetQuestStatus(QUEST_4001) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - if( player->GetQuestStatus(4342) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KHARAN_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + if (player->GetQuestStatus(4342) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); if (player->GetTeam() == HORDE) - player->SEND_GOSSIP_MENU(2473, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2473, creature->GetGUID()); else - player->SEND_GOSSIP_MENU(2474, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2474, creature->GetGUID()); return true; } -bool GossipSelect_npc_kharan_mighthammer(Player *player, Creature *_Creature, uint32 sender, uint32 action) +bool GossipSelect_npc_kharan_mighthammer(Player *player, Creature *creature, uint32 sender, uint32 action) { switch (action) { case GOSSIP_ACTION_INFO_DEF+1: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(2475, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2475, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+2: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(2476, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2476, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+3: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(2477, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2477, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(2478, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2478, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(2479, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2479, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+6: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_8, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); - player->SEND_GOSSIP_MENU(2480, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2480, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+7: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_9, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8); - player->SEND_GOSSIP_MENU(2481, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2481, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+8: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KHARAN_10, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); - player->SEND_GOSSIP_MENU(2482, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2482, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+9: player->CLOSE_GOSSIP_MENU(); @@ -503,13 +505,13 @@ bool GossipSelect_npc_kharan_mighthammer(Player *player, Creature *_Creature, ui #define GOSSIP_ITEM_SHOW_ACCESS "Show me what I have access to, Lothos." #define GOSSIP_ITEM_GET_CONTRACT "Get Thorium Brotherhood Contract" -bool GossipHello_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature) +bool GossipHello_npc_lokhtos_darkbargainer(Player *player, Creature *creature) { - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); - if (_Creature->isVendor() && player->GetReputationMgr().GetRank(59) >= REP_FRIENDLY) - player->ADD_GOSSIP_ITEM( 1, GOSSIP_ITEM_SHOW_ACCESS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + if (creature->isVendor() && player->GetReputationMgr().GetRank(59) >= REP_FRIENDLY) + player->ADD_GOSSIP_ITEM(1, GOSSIP_ITEM_SHOW_ACCESS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); if (player->GetQuestRewardStatus(QUEST_A_BINDING_CONTRACT) != 1 && !player->HasItemCount(ITEM_THRORIUM_BROTHERHOOD_CONTRACT, 1, true) && @@ -519,14 +521,14 @@ bool GossipHello_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature) } if (player->GetReputationMgr().GetRank(59) < REP_FRIENDLY) - player->SEND_GOSSIP_MENU(3673, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(3673, creature->GetGUID()); else - player->SEND_GOSSIP_MENU(3677, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(3677, creature->GetGUID()); return true; } -bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *creature, uint32 sender, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF + 1) { @@ -534,125 +536,177 @@ bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature, player->CastSpell(player, SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND, false); } if (action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); + player->SEND_VENDORLIST(creature->GetGUID()); return true; } /*###### -## npc_dughal_stormwing +## npc_rocknot ######*/ -#define QUEST_JAIL_BREAK 4322 -#define SAY_DUGHAL_FREE "Thank you, $N! I'm free!!!" -#define GOSSIP_DUGHAL "You're free, Dughal! Get out of here!" +#define SAY_GOT_BEER -1230000 +#define SPELL_DRUNKEN_RAGE 14872 +#define QUEST_ALE 4295 -struct npc_dughal_stormwingAI : public npc_escortAI +float BarWpLocations[8][3]= { - npc_dughal_stormwingAI(Creature *c) : npc_escortAI(c) + {883.294861, -188.926300, -43.703655}, + {872.763550, -185.605621, -43.703655}, //b1 + {867.923401, -188.006393, -43.703655}, //b2 + {863.295898, -190.795212, -43.703655}, //b3 + {856.139587, -194.652756, -43.703655}, //b4 + {851.878906, -196.928131, -43.703655}, //b5 + {877.035217, -187.048080, -43.703655}, + {891.198000, -197.924000, -43.620400} //home +}; + +uint32 BarWpWait[8]= +{ + 0, + 5000, + 5000, + 5000, + 5000, + 15000, + 0, + 0 +}; + +struct npc_rocknotAI : public npc_escortAI +{ + npc_rocknotAI(Creature *c) : npc_escortAI(c) { - pInstance = (ScriptedInstance*)(c->GetInstanceData()); + pInstance = (c->GetInstanceData()); } - ScriptedInstance *pInstance; + ScriptedInstance* pInstance; - void WaypointReached(uint32 i) + uint32 BreakKeg_Timer; + uint32 BreakDoor_Timer; + + void Reset() { - Player *player = GetPlayerForEscort(); - if(!player) + if (HasEscortState(STATE_ESCORT_ESCORTING)) return; - switch(i) - { - case 0: - m_creature->Say(SAY_DUGHAL_FREE, LANG_UNIVERSAL, player->GetGUID()); - break; - case 2: - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pInstance->SetData(DATA_DUGHAL, DONE); - break; - } + BreakKeg_Timer = 0; + BreakDoor_Timer = 0; } - void Reset() + void EnterCombat(Unit *who) { } + + void DoGo(uint32 id, uint32 state) { - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + if (GameObject *go = GameObject::GetGameObject(*me,pInstance->GetData64(id))) + go->SetGoState(GOState(state)); } - void JustDied(Unit* killer) + void WaypointReached(uint32 i) { - if( HasEscortState(STATE_ESCORT_ESCORTING) && killer == m_creature) + if (!pInstance) + return; + + switch(i) { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pInstance->SetData(DATA_DUGHAL, DONE); + case 1: + me->HandleEmoteCommand(EMOTE_ONESHOT_KICK); + break; + case 2: + me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKUNARMED); + break; + case 3: + me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKUNARMED); + break; + case 4: + me->HandleEmoteCommand(EMOTE_ONESHOT_KICK); + break; + case 5: + me->HandleEmoteCommand(EMOTE_ONESHOT_KICK); + BreakKeg_Timer = 2000; + break; } } void UpdateAI(const uint32 diff) { - if(!pInstance || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) + if (!pInstance) return; - if(pInstance->GetData(DATA_QUEST_JAIL_BREAK) && pInstance->GetData(DATA_DUGHAL) == DONE ) + if (BreakKeg_Timer) { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (BreakKeg_Timer <= diff) + { + DoGo(DATA_GO_BAR_KEG,0); + BreakKeg_Timer = 0; + BreakDoor_Timer = 1000; + } + else + BreakKeg_Timer -= diff; } - else + + if (BreakDoor_Timer) { - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (BreakDoor_Timer <= diff) + { + DoGo(DATA_GO_BAR_DOOR,2); + DoGo(DATA_GO_BAR_KEG_TRAP,0); //doesn't work very well, leaving code here for future + //spell by trap has effect61, this indicate the bar go hostile + + if (Unit *tmp = Unit::GetUnit(*me,pInstance->GetData64(DATA_PHALANX))) + tmp->setFaction(14); + + //for later, this event(s) has alot more to it. + //optionally, DONE can trigger bar to go hostile. + pInstance->SetData(TYPE_BAR,DONE); + + BreakDoor_Timer = 0; + } + else + BreakDoor_Timer -= diff; } npc_escortAI::UpdateAI(diff); } }; -CreatureAI* GetAI_npc_dughal_stormwing(Creature *_Creature) +CreatureAI* GetAI_npc_rocknot(Creature *creature) { - npc_dughal_stormwingAI* dughal_stormwingAI = new npc_dughal_stormwingAI(_Creature); + npc_rocknotAI* Rocknot_AI = new npc_rocknotAI(creature); - dughal_stormwingAI->AddWaypoint(0, 280.42,-82.86, -77.12,0); - dughal_stormwingAI->AddWaypoint(1, 287.64,-87.01, -76.79,0); - dughal_stormwingAI->AddWaypoint(2, 354.63,-64.95, -67.53,0); + for(uint8 i = 0; i < 8; ++i) + Rocknot_AI->AddWaypoint(i, BarWpLocations[i][0], BarWpLocations[i][1], BarWpLocations[i][2], BarWpWait[i]); - return (CreatureAI*)dughal_stormwingAI; + return (CreatureAI*)Rocknot_AI; } -bool GossipHello_npc_dughal_stormwing(Player *player, Creature *_Creature) + +bool ChooseReward_npc_rocknot(Player *player, Creature *creature, const Quest *_Quest) { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + ScriptedInstance* pInstance = (creature->GetInstanceData()); - if(!pInstance) - return false; + if (!pInstance) + return true; - if(player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS ) - { - player->ADD_GOSSIP_ITEM(0, GOSSIP_DUGHAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2846, _Creature->GetGUID()); - } - return true; -} + if (pInstance->GetData(TYPE_BAR) == DONE || pInstance->GetData(TYPE_BAR) == SPECIAL) + return true; -bool GossipSelect_npc_dughal_stormwing(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + if (_Quest->GetQuestId() == QUEST_ALE) + { + if (pInstance->GetData(TYPE_BAR) != IN_PROGRESS) + pInstance->SetData(TYPE_BAR,IN_PROGRESS); - if(!pInstance) - return false; + pInstance->SetData(TYPE_BAR,SPECIAL); - if(action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - CAST_AI(npc_escortAI, (_Creature->AI()))->Start(false, false, player->GetGUID()); - _Creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - pInstance->SetData(DATA_QUEST_JAIL_BREAK, IN_PROGRESS); + //keep track of amount in instance script, returns SPECIAL if amount ok and event in progress + if (pInstance->GetData(TYPE_BAR) == SPECIAL) + { + DoScriptText(SAY_GOT_BEER, creature); + creature->CastSpell(creature,SPELL_DRUNKEN_RAGE,false); + if (npc_escortAI* pEscortAI = CAST_AI(npc_rocknotAI, creature->AI())) + pEscortAI->Start(false, false); + } } + return true; } @@ -660,6 +714,7 @@ bool GossipSelect_npc_dughal_stormwing(Player *player, Creature *_Creature, uint ## npc_marshal_windsor ######*/ +#define QUEST_JAIL_BREAK 4322 #define SAY_WINDSOR_AGGRO1 "You locked up the wrong Marshal. Prepare to be destroyed!" #define SAY_WINDSOR_AGGRO2 "I bet you're sorry now, aren't you !?!!" #define SAY_WINDSOR_AGGRO3 "You better hold me back $N or they are going to feel some prison house beatings." @@ -670,16 +725,7 @@ bool GossipSelect_npc_dughal_stormwing(Player *player, Creature *_Creature, uint #define SAY_WINDSOR_6 "This is it, $N. My stuff should be in that room. Cover me, I'm going in!" #define SAY_WINDSOR_9 "Ah, there it is!" #define MOB_ENTRY_REGINALD_WINDSOR 9682 - -enum WaitEvent -{ - NONE, - DUGHAL, - JAZ, - SHILL, - CREST, - TOBIAS -}; +#define GO_STORE_DOOR 170561 struct npc_marshal_windsorAI : public npc_escortAI { @@ -689,51 +735,59 @@ struct npc_marshal_windsorAI : public npc_escortAI } ScriptedInstance *pInstance; - uint8 WaitEvent; void WaypointReached(uint32 i) { Player *player = GetPlayerForEscort(); - if(!player) + + if (!player) return; - switch( i ) + switch (i) { case 1: - m_creature->Say(SAY_WINDSOR_1, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_WINDSOR_1, LANG_UNIVERSAL, player->GetGUID()); break; case 7: - m_creature->HandleEmoteCommand(EMOTE_STATE_POINT); - m_creature->Say(SAY_WINDSOR_4_1, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = DUGHAL; + me->HandleEmoteCommand(EMOTE_STATE_POINT); + me->Say(SAY_WINDSOR_4_1, LANG_UNIVERSAL, player->GetGUID()); + if (pInstance) + { + if (Creature* dughal = Unit::GetCreature(*me, pInstance->GetData64(DATA_DUGHAL))) + { + if (!dughal->isAlive()) + dughal->Respawn(); + dughal->SetVisibility(VISIBILITY_ON); + dughal->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } + SetEscortPaused(true); break; case 10: - m_creature->setFaction(534); + me->setFaction(534); break; case 12: - m_creature->Say(SAY_WINDSOR_6, LANG_UNIVERSAL, player->GetGUID()); - pInstance->SetData(DATA_SUPPLY_ROOM, IN_PROGRESS); + me->Say(SAY_WINDSOR_6, LANG_UNIVERSAL, player->GetGUID()); break; case 13: - m_creature->HandleEmoteCommand(EMOTE_STATE_USESTANDING);//EMOTE_STATE_WORK + if (GameObject* door = FindGameObject(GO_STORE_DOOR, INTERACTION_DISTANCE, me)) + door->UseDoorOrButton(60); + me->HandleEmoteCommand(EMOTE_STATE_USESTANDING); break; case 14: - m_creature->setFaction(11); + me->setFaction(11); break; case 16: - m_creature->Say(SAY_WINDSOR_9, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_WINDSOR_9, LANG_UNIVERSAL, player->GetGUID()); break; case 17: - m_creature->HandleEmoteCommand(EMOTE_STATE_USESTANDING);//EMOTE_STATE_WORK + me->HandleEmoteCommand(EMOTE_STATE_USESTANDING); break; - case 18: - break; - case 19: - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->SummonCreature(MOB_ENTRY_REGINALD_WINDSOR,403.61,-51.71,-63.92,3.600434,TEMPSUMMON_DEAD_DESPAWN ,0); - pInstance->SetData(DATA_SUPPLY_ROOM, DONE); + case 19: + if (Creature* reginald = me->SummonCreature(MOB_ENTRY_REGINALD_WINDSOR, 403.61, -51.71, -63.92, 3.600434, TEMPSUMMON_DEAD_DESPAWN , 0)) + pInstance->SetData64(DATA_REGINALD, reginald->GetGUID()); + me->SetVisibility(VISIBILITY_OFF); + me->ForcedDespawn(); break; } } @@ -743,76 +797,46 @@ struct npc_marshal_windsorAI : public npc_escortAI switch(rand()%3) { case 0: - m_creature->Say(SAY_WINDSOR_AGGRO1, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO1, LANG_UNIVERSAL, who->GetGUID()); break; case 1: - m_creature->Say(SAY_WINDSOR_AGGRO2, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO2, LANG_UNIVERSAL, who->GetGUID()); break; case 2: - m_creature->Say(SAY_WINDSOR_AGGRO3, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO3, LANG_UNIVERSAL, who->GetGUID()); break; } - } + } void Reset() { - WaitEvent = NONE; + me->setFaction(35); + + if (pInstance) + { + if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) + me->SetVisibility(VISIBILITY_ON); + else + me->SetVisibility(VISIBILITY_OFF); + } } - void JustDied(Unit *slayer) + void DoAction(const int32 param) { - pInstance->SetData(DATA_QUEST_JAIL_BREAK, FAIL); + SetEscortPaused(false); } - void UpdateAI(const uint32 diff) + void JustDied(Unit *slayer) { - if(!pInstance || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) - return; - - Player *player = GetPlayerForEscort(); - if(!player) - return; - - switch(WaitEvent) - { - case DUGHAL: - { - if(pInstance->GetData(DATA_DUGHAL) == NOT_STARTED) - { - SetEscortPaused(true); - pInstance->SetData(DATA_DUGHAL, IN_PROGRESS); - } - - if(pInstance->GetData(DATA_DUGHAL) == DONE) - { - SetEscortPaused(false); - m_creature->Say(SAY_WINDSOR_4_3, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = NONE; - } - } - break; - } - - if(pInstance->GetData(DATA_QUEST_JAIL_BREAK) && pInstance->GetData(DATA_SUPPLY_ROOM) == DONE ) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - else - { - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - npc_escortAI::UpdateAI(diff); + pInstance->SetData(DATA_QUEST_JAIL_BREAK, FAIL); } + + void UpdateEscortAI() {} }; -CreatureAI* GetAI_npc_marshal_windsor(Creature *_Creature) +CreatureAI* GetAI_npc_marshal_windsor(Creature *creature) { - npc_marshal_windsorAI* marshal_windsorAI = new npc_marshal_windsorAI(_Creature); + npc_marshal_windsorAI* marshal_windsorAI = new npc_marshal_windsorAI(creature); marshal_windsorAI->AddWaypoint(0, 316.336,-225.528, -77.7258,8000); marshal_windsorAI->AddWaypoint(1, 316.336,-225.528, -77.7258,2000); @@ -829,27 +853,28 @@ CreatureAI* GetAI_npc_marshal_windsor(Creature *_Creature) marshal_windsorAI->AddWaypoint(12, 400.98,-72.01, -62.31,0); marshal_windsorAI->AddWaypoint(13, 404.22,-62.30, -63.50,2300); marshal_windsorAI->AddWaypoint(14, 404.22,-62.30, -63.50,1500); - marshal_windsorAI->AddWaypoint(154, 407.65,-51.86, -63.96,0); + marshal_windsorAI->AddWaypoint(15, 407.65,-51.86, -63.96,0); marshal_windsorAI->AddWaypoint(16, 403.61,-51.71, -63.92,1000); - marshal_windsorAI->AddWaypoint(17, 403.61,-51.71, -63.92,2000); - marshal_windsorAI->AddWaypoint(18, 403.61,-51.71, -63.92,1000); - marshal_windsorAI->AddWaypoint(19, 403.61,-51.71, -63.92,0); + marshal_windsorAI->AddWaypoint(17, 403.61,-51.71, -63.92,3000); + marshal_windsorAI->AddWaypoint(18, 403.61,-51.71, -63.92,2000); + marshal_windsorAI->AddWaypoint(19, 403.61,-51.71, -63.92,1000); return (CreatureAI*)marshal_windsorAI; } -bool QuestAccept_npc_marshal_windsor(Player *player, Creature *creature, Quest const *quest ) +bool QuestAccept_npc_marshal_windsor(Player *player, Creature *creature, Quest const *quest) { - if( quest->GetQuestId() == QUEST_JAIL_BREAK ) + if (quest->GetQuestId() == QUEST_JAIL_BREAK) { ScriptedInstance *pInstance = (creature->GetInstanceData()); - if(!pInstance) + if (!pInstance) return false; - if( pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED ) + if (pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) { - CAST_AI(npc_escortAI, (creature->AI()))->Start(true, true, player->GetGUID()); + ((npc_escortAI*)(creature->AI()))->SetMaxPlayerDistance(88.0f); + CAST_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID()); pInstance->SetData64(Q_STARTER, player->GetGUID()); pInstance->SetData(DATA_QUEST_JAIL_BREAK, IN_PROGRESS); creature->setFaction(11); @@ -885,97 +910,129 @@ struct npc_marshal_reginald_windsorAI : public npc_escortAI } ScriptedInstance *pInstance; - uint8 WaitEvent; void WaypointReached(uint32 i) { - Player* player = GetPlayerForEscort(); - if(!player) + Player *player = GetPlayerForEscort(); + + if (!player) return; switch(i) { case 0: - m_creature->setFaction(11); - m_creature->Say(SAY_REGINALD_WINDSOR_0_1, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_0_1, LANG_UNIVERSAL, player->GetGUID()); break; case 1: - m_creature->Say(SAY_REGINALD_WINDSOR_0_2, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_0_2, LANG_UNIVERSAL, player->GetGUID()); break; case 7: - m_creature->Say(SAY_REGINALD_WINDSOR_5_1, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = JAZ; + me->HandleEmoteCommand(EMOTE_STATE_POINT); + me->Say(SAY_REGINALD_WINDSOR_5_1, LANG_UNIVERSAL, player->GetGUID()); + if (pInstance) + { + if (Creature* jaz = Unit::GetCreature(*me, pInstance->GetData64(DATA_JAZ))) + { + if (!jaz->isAlive()) + jaz->Respawn(); + jaz->SetVisibility(VISIBILITY_ON); + jaz->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } + SetEscortPaused(true); break; case 8: - m_creature->Say(SAY_REGINALD_WINDSOR_5_2, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_5_2, LANG_UNIVERSAL, player->GetGUID()); break; case 11: - m_creature->HandleEmoteCommand(EMOTE_STATE_POINT); - m_creature->Say(SAY_REGINALD_WINDSOR_7_1, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = SHILL; + me->HandleEmoteCommand(EMOTE_STATE_POINT); + me->Say(SAY_REGINALD_WINDSOR_7_1, LANG_UNIVERSAL, player->GetGUID()); + if (pInstance) + { + if (Creature* shill = Unit::GetCreature(*me, pInstance->GetData64(DATA_SHILL))) + { + if (!shill->isAlive()) + shill->Respawn(); + shill->SetVisibility(VISIBILITY_ON); + shill->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } + SetEscortPaused(true); break; case 12: - m_creature->Say(SAY_REGINALD_WINDSOR_7_2, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_7_2, LANG_UNIVERSAL, player->GetGUID()); break; case 13: - m_creature->Say(SAY_REGINALD_WINDSOR_7_3, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_7_3, LANG_UNIVERSAL, player->GetGUID()); break; case 20: - m_creature->HandleEmoteCommand(EMOTE_STATE_POINT); - m_creature->Say(SAY_REGINALD_WINDSOR_13_1, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = CREST; + me->HandleEmoteCommand(EMOTE_STATE_POINT); + me->Say(SAY_REGINALD_WINDSOR_13_1, LANG_UNIVERSAL, player->GetGUID()); + if (pInstance) + { + if (Creature* crest = Unit::GetCreature(*me, pInstance->GetData64(DATA_CREST))) + { + if (!crest->isAlive()) + crest->Respawn(); + crest->SetVisibility(VISIBILITY_ON); + crest->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } + SetEscortPaused(true); break; case 21: - m_creature->Say(SAY_REGINALD_WINDSOR_13_3, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_13_3, LANG_UNIVERSAL, player->GetGUID()); break; case 23: - m_creature->HandleEmoteCommand(EMOTE_STATE_POINT); - m_creature->Say(SAY_REGINALD_WINDSOR_14_1, LANG_UNIVERSAL, player->GetGUID()); - WaitEvent = TOBIAS; + me->HandleEmoteCommand(EMOTE_STATE_POINT); + me->Say(SAY_REGINALD_WINDSOR_14_1, LANG_UNIVERSAL, player->GetGUID()); + if (pInstance) + { + if (Creature* tobias = Unit::GetCreature(*me, pInstance->GetData64(DATA_TOBIAS))) + { + if (!tobias->isAlive()) + tobias->Respawn(); + tobias->SetVisibility(VISIBILITY_ON); + tobias->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } + SetEscortPaused(true); break; case 24: - m_creature->Say(SAY_REGINALD_WINDSOR_14_2, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_14_2, LANG_UNIVERSAL, player->GetGUID()); break; case 31: - m_creature->Say(SAY_REGINALD_WINDSOR_20_1, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_20_1, LANG_UNIVERSAL, player->GetGUID()); break; case 32: - m_creature->Say(SAY_REGINALD_WINDSOR_20_2, LANG_UNIVERSAL, player->GetGUID()); + me->Say(SAY_REGINALD_WINDSOR_20_2, LANG_UNIVERSAL, player->GetGUID()); - if(pInstance) + if (pInstance) { - if(Unit *qstarter = Unit::GetUnit(*m_creature, pInstance->GetData64(Q_STARTER))) - ((Player*)qstarter)->GroupEventHappens(QUEST_JAIL_BREAK, m_creature); + if (Unit *qstarter = Unit::GetUnit(*me, pInstance->GetData64(Q_STARTER))) + ((Player*)qstarter)->GroupEventHappens(QUEST_JAIL_BREAK, me); } - - m_creature->setDeathState(DEAD); - m_creature->RemoveCorpse(); + pInstance->SetData(DATA_QUEST_JAIL_BREAK, DONE); break; } } - void MoveInLineOfSight(Unit *who) + void Reset() { - if( HasEscortState(STATE_ESCORT_ESCORTING) ) - return; - - if( who->GetTypeId() == TYPEID_PLAYER ) + if (pInstance) { - if( ((Player*)who)->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE ) + if (Unit *qstarter = Unit::GetUnit(*me, pInstance->GetData64(Q_STARTER))) { - float Radius = 10.0; - if( m_creature->IsWithinDistInMap(who, Radius) ) - { - SetEscortPaused(false); - CAST_AI(npc_escortAI, (m_creature->AI()))->Start(true, true, who->GetGUID()); - } + ((npc_escortAI*)(me->AI()))->SetMaxPlayerDistance(88.0f); + CAST_AI(npc_escortAI, (me->AI()))->Start(true, true, qstarter->GetGUID()); + me->setFaction(11); } } } - void Reset() + void DoAction(const int32 param) { - WaitEvent = NONE; + SetEscortPaused(false); } void EnterCombat(Unit* who) @@ -983,104 +1040,29 @@ struct npc_marshal_reginald_windsorAI : public npc_escortAI switch(rand()%3) { case 0: - m_creature->Say(SAY_WINDSOR_AGGRO1, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO1, LANG_UNIVERSAL, who->GetGUID()); break; case 1: - m_creature->Say(SAY_WINDSOR_AGGRO2, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO2, LANG_UNIVERSAL, who->GetGUID()); break; case 2: - m_creature->Say(SAY_WINDSOR_AGGRO3, LANG_UNIVERSAL, who->GetGUID()); + me->Say(SAY_WINDSOR_AGGRO3, LANG_UNIVERSAL, who->GetGUID()); break; } } void JustDied(Unit *slayer) { - if(pInstance) + if (pInstance) pInstance->SetData(DATA_QUEST_JAIL_BREAK, FAIL); } - void UpdateAI(const uint32 diff) - { - if(!pInstance || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) - return; - - Player* player = GetPlayerForEscort(); - if(!player) - return; - - switch(WaitEvent) - { - case JAZ: - { - if(pInstance->GetData(DATA_JAZ) == NOT_STARTED) - { - SetEscortPaused(true); - pInstance->SetData(DATA_JAZ, IN_PROGRESS); - } - - if(pInstance->GetData(DATA_JAZ) == DONE) - { - SetEscortPaused(false); - WaitEvent = NONE; - } - } - break; - case SHILL: - { - if(pInstance->GetData(DATA_SHILL) == NOT_STARTED) - { - SetEscortPaused(true); - pInstance->SetData(DATA_SHILL, IN_PROGRESS); - } - - if(pInstance->GetData(DATA_SHILL) == DONE) - { - SetEscortPaused(false); - WaitEvent = NONE; - } - } - break; - case CREST: - { - if(pInstance->GetData(DATA_CREST) == NOT_STARTED) - { - SetEscortPaused(true); - m_creature->Say(SAY_REGINALD_WINDSOR_13_2, LANG_UNIVERSAL, player->GetGUID()); - pInstance->SetData(DATA_CREST, IN_PROGRESS); - } - - if(pInstance->GetData(DATA_CREST) == DONE) - { - SetEscortPaused(false); - WaitEvent = NONE; - } - } - break; - case TOBIAS: - { - if(pInstance->GetData(DATA_TOBIAS) == NOT_STARTED) - { - SetEscortPaused(true); - pInstance->SetData(DATA_TOBIAS, IN_PROGRESS); - } - - if(pInstance->GetData(DATA_TOBIAS) == DONE) - { - SetEscortPaused(false); - WaitEvent = NONE; - } - } - break; - } - - npc_escortAI::UpdateAI(diff); - } + void UpdateEscortAI() {} }; -CreatureAI* GetAI_npc_marshal_reginald_windsor(Creature *_Creature) +CreatureAI* GetAI_npc_marshal_reginald_windsor(Creature *creature) { - npc_marshal_reginald_windsorAI* marshal_reginald_windsorAI = new npc_marshal_reginald_windsorAI(_Creature); + npc_marshal_reginald_windsorAI* marshal_reginald_windsorAI = new npc_marshal_reginald_windsorAI(creature); marshal_reginald_windsorAI->AddWaypoint(0, 403.61,-52.71, -63.92,4000); marshal_reginald_windsorAI->AddWaypoint(1, 403.61,-52.71, -63.92,4000); @@ -1122,331 +1104,315 @@ CreatureAI* GetAI_npc_marshal_reginald_windsor(Creature *_Creature) } /*###### -## npc_tobias_seecher +## npc_dughal_stormwing ######*/ -#define SAY_TOBIAS_FREE "Thank you! I will run for safety immediately!" +#define SAY_DUGHAL_FREE "Thank you, $N! I'm free!!!" +#define GOSSIP_DUGHAL "You're free, Dughal! Get out of here!" -struct npc_tobias_seecherAI : public npc_escortAI +struct npc_dughal_stormwingAI : public npc_escortAI { - npc_tobias_seecherAI(Creature *c) :npc_escortAI(c) + npc_dughal_stormwingAI(Creature *c) : npc_escortAI(c) { pInstance = (ScriptedInstance*)(c->GetInstanceData()); } ScriptedInstance *pInstance; - void Reset() - { - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } - - void JustDied(Unit* killer) - { - if (HasEscortState(STATE_ESCORT_ESCORTING) && killer == m_creature) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - if(pInstance) - pInstance->SetData(DATA_TOBIAS,DONE); - } - } - void WaypointReached(uint32 i) { - Player* player = GetPlayerForEscort(); - if(!player) + Player *player = GetPlayerForEscort(); + + if (!player) return; switch(i) { - case 0: - m_creature->Say(SAY_TOBIAS_FREE, LANG_UNIVERSAL, player->GetGUID()); - break; - case 2: - pInstance->SetData(DATA_TOBIAS, DONE); - break; - case 4: - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + case 0: + me->Say(SAY_DUGHAL_FREE, LANG_UNIVERSAL, player->GetGUID()); + break; + case 2: + if (pInstance) + { + if (Creature* windsor = Unit::GetCreature(*me, pInstance->GetData64(DATA_WINDSOR))) + { + windsor->Say(SAY_WINDSOR_4_3, LANG_UNIVERSAL, player->GetGUID()); + windsor->AI()->DoAction(); + } + } break; } } - void UpdateAI(const uint32 diff) + void Reset() { - if(!pInstance || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == NOT_STARTED) - return; + me->SetVisibility(VISIBILITY_OFF); + } - if((pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == FAIL || pInstance->GetData(DATA_QUEST_JAIL_BREAK) == DONE) && pInstance->GetData(DATA_TOBIAS) == DONE ) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - else + void JustDied(Unit* killer) + { + if (pInstance) { - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (Creature* windsor = Unit::GetCreature(*me, pInstance->GetData64(DATA_WINDSOR))) + windsor->AI()->DoAction(); } - - npc_escortAI::UpdateAI(diff); } + + void UpdateEscortAI(const uint32 diff) {} }; -CreatureAI* GetAI_npc_tobias_seecher(Creature *_Creature) +CreatureAI* GetAI_npc_dughal_stormwing(Creature *creature) { - npc_tobias_seecherAI* tobias_seecherAI = new npc_tobias_seecherAI(_Creature); + npc_dughal_stormwingAI* dughal_stormwingAI = new npc_dughal_stormwingAI(creature); - tobias_seecherAI->AddWaypoint(0, 549.21, -281.07, -75.27); - tobias_seecherAI->AddWaypoint(1, 554.39, -267.39, -73.68); - tobias_seecherAI->AddWaypoint(2, 533.59, -249.38, -67.04); - tobias_seecherAI->AddWaypoint(3, 519.44, -217.02, -59.34); - tobias_seecherAI->AddWaypoint(4, 506.55, -153.49, -62.34); + dughal_stormwingAI->AddWaypoint(0, 280.42,-82.86, -77.12,0); + dughal_stormwingAI->AddWaypoint(1, 287.64,-87.01, -76.79,0); + dughal_stormwingAI->AddWaypoint(2, 354.63,-64.95, -67.53,1000); - return (CreatureAI*)tobias_seecherAI; + return (CreatureAI*)dughal_stormwingAI; } - -bool GossipHello_npc_tobias_seecher(Player *player, Creature *_Creature) +bool GossipHello_npc_dughal_stormwing(Player *player, Creature *creature) { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - if(!pInstance) + if (!pInstance) return false; - if(player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS ) + if (player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS) { - player->ADD_GOSSIP_ITEM(0, "Get out of here, Tobias, you're free!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2847, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_DUGHAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2846, creature->GetGUID()); } return true; } -bool GossipSelect_npc_tobias_seecher(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_dughal_stormwing(Player *player, Creature *creature, uint32 sender, uint32 action ) { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - if(!pInstance) + if (!pInstance) return false; if (action == GOSSIP_ACTION_INFO_DEF + 1) { player->CLOSE_GOSSIP_MENU(); - CAST_AI(npc_escortAI, (_Creature->AI()))->Start(false, false, player->GetGUID()); - _Creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - pInstance->SetData(DATA_TOBIAS,IN_PROGRESS); + ((npc_escortAI*)(creature->AI()))->SetDespawnAtFar(false); + CAST_AI(npc_escortAI, (creature->AI()))->Start(false, false, player->GetGUID()); } return true; } /*###### -## npc_rocknot +## npc_tobias_seecher ######*/ -#define SAY_GOT_BEER -1230000 -#define SPELL_DRUNKEN_RAGE 14872 -#define QUEST_ALE 4295 - -float BarWpLocations[8][3]= -{ - {883.294861, -188.926300, -43.703655}, - {872.763550, -185.605621, -43.703655}, //b1 - {867.923401, -188.006393, -43.703655}, //b2 - {863.295898, -190.795212, -43.703655}, //b3 - {856.139587, -194.652756, -43.703655}, //b4 - {851.878906, -196.928131, -43.703655}, //b5 - {877.035217, -187.048080, -43.703655}, - {891.198000, -197.924000, -43.620400} //home -}; - -uint32 BarWpWait[8]= -{ - 0, - 5000, - 5000, - 5000, - 5000, - 15000, - 0, - 0 -}; +#define SAY_TOBIAS_FREE "Thank you! I will run for safety immediately!" -struct npc_rocknotAI : public npc_escortAI +struct npc_tobias_seecherAI : public npc_escortAI { - npc_rocknotAI(Creature *c) : npc_escortAI(c) + npc_tobias_seecherAI(Creature *c) :npc_escortAI(c) { - pInstance = (c->GetInstanceData()); + pInstance = (ScriptedInstance*)(c->GetInstanceData()); } - ScriptedInstance* pInstance; - - uint32 BreakKeg_Timer; - uint32 BreakDoor_Timer; + ScriptedInstance *pInstance; void Reset() { - if (HasEscortState(STATE_ESCORT_ESCORTING)) - return; - - BreakKeg_Timer = 0; - BreakDoor_Timer = 0; + me->SetVisibility(VISIBILITY_OFF); } - void EnterCombat(Unit *who) { } - - void DoGo(uint32 id, uint32 state) + void JustDied(Unit* killer) { - if (GameObject *go = GameObject::GetGameObject(*m_creature,pInstance->GetData64(id))) - go->SetGoState(GOState(state)); + if (pInstance) + { + if (Creature* reginald = Unit::GetCreature(*me, pInstance->GetData64(DATA_REGINALD))) + reginald->AI()->DoAction(); + } } void WaypointReached(uint32 i) { - if (!pInstance) + Player* player = GetPlayerForEscort(); + + if (!player) return; switch(i) { - case 1: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_KICK); + case 0: + me->Say(SAY_TOBIAS_FREE, LANG_UNIVERSAL, player->GetGUID()); break; case 2: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKUNARMED); - break; - case 3: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKUNARMED); - break; - case 4: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_KICK); - break; - case 5: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_KICK); - BreakKeg_Timer = 2000; + if (pInstance) + { + if (Creature* reginald = Unit::GetCreature(*me, pInstance->GetData64(DATA_REGINALD))) + reginald->AI()->DoAction(); + } break; } } - void UpdateAI(const uint32 diff) - { - if (!pInstance) - return; + void UpdateEscortAI(const uint32 diff) {} +}; - if (BreakKeg_Timer) - { - if (BreakKeg_Timer <= diff) - { - DoGo(DATA_GO_BAR_KEG,0); - BreakKeg_Timer = 0; - BreakDoor_Timer = 1000; - } - else - BreakKeg_Timer -= diff; - } +CreatureAI* GetAI_npc_tobias_seecher(Creature *creature) +{ + npc_tobias_seecherAI* tobias_seecherAI = new npc_tobias_seecherAI(creature); - if (BreakDoor_Timer) - { - if (BreakDoor_Timer <= diff) - { - DoGo(DATA_GO_BAR_DOOR,2); - DoGo(DATA_GO_BAR_KEG_TRAP,0); //doesn't work very well, leaving code here for future - //spell by trap has effect61, this indicate the bar go hostile + tobias_seecherAI->AddWaypoint(0, 549.21, -281.07, -75.27); + tobias_seecherAI->AddWaypoint(1, 554.39, -267.39, -73.68); + tobias_seecherAI->AddWaypoint(2, 533.59, -249.38, -67.04); + tobias_seecherAI->AddWaypoint(3, 519.44, -217.02, -59.34); + tobias_seecherAI->AddWaypoint(4, 506.55, -153.49, -62.34); - if (Unit *tmp = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_PHALANX))) - tmp->setFaction(14); + return (CreatureAI*)tobias_seecherAI; +} - //for later, this event(s) has alot more to it. - //optionally, DONE can trigger bar to go hostile. - pInstance->SetData(TYPE_BAR,DONE); +bool GossipHello_npc_tobias_seecher(Player *player, Creature *creature) +{ + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - BreakDoor_Timer = 0; - } - else - BreakDoor_Timer -= diff; - } + if (!pInstance) + return false; - npc_escortAI::UpdateAI(diff); + if (player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS) + { + player->ADD_GOSSIP_ITEM(0, "Get out of here, Tobias, you're free!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2847, creature->GetGUID()); } -}; + return true; +} -CreatureAI* GetAI_npc_rocknot(Creature *_Creature) +bool GossipSelect_npc_tobias_seecher(Player *player, Creature *creature, uint32 sender, uint32 action ) { - npc_rocknotAI* Rocknot_AI = new npc_rocknotAI(_Creature); + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - for(uint8 i = 0; i < 8; ++i) - Rocknot_AI->AddWaypoint(i, BarWpLocations[i][0], BarWpLocations[i][1], BarWpLocations[i][2], BarWpWait[i]); + if (!pInstance) + return false; - return (CreatureAI*)Rocknot_AI; + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + ((npc_escortAI*)(creature->AI()))->SetDespawnAtFar(false); + CAST_AI(npc_escortAI, (creature->AI()))->Start(false, false, player->GetGUID()); + } + return true; } -bool ChooseReward_npc_rocknot(Player *player, Creature *_Creature, const Quest *_Quest) +//npc_shill +struct npc_shillAI : public npc_escortAI +{ + npc_shillAI(Creature *creature) :npc_escortAI(creature) + { + pInstance = (ScriptedInstance*)(creature->GetInstanceData()); + } + + ScriptedInstance *pInstance; + + void Reset() + { + me->SetVisibility(VISIBILITY_OFF); + } + + void WaypointReached(uint32 i) {} +}; + +CreatureAI* GetAI_npc_shill(Creature* creature) { - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); + return new npc_shillAI (creature); +} + +bool GossipHello_npc_shill(Player *player, Creature *creature) +{ + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); if (!pInstance) - return true; + return false; - if (pInstance->GetData(TYPE_BAR) == DONE || pInstance->GetData(TYPE_BAR) == SPECIAL) - return true; + if (player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS) + { + if (Creature* reginald = Unit::GetCreature(*creature, pInstance->GetData64(DATA_REGINALD))) + reginald->AI()->DoAction(); + } - if (_Quest->GetQuestId() == QUEST_ALE) + return true; +} + +//npc_crest +struct npc_crestAI : public npc_escortAI +{ + npc_crestAI(Creature *creature) :npc_escortAI(creature) { - if (pInstance->GetData(TYPE_BAR) != IN_PROGRESS) - pInstance->SetData(TYPE_BAR,IN_PROGRESS); + pInstance = (ScriptedInstance*)(creature->GetInstanceData()); + } - pInstance->SetData(TYPE_BAR,SPECIAL); + ScriptedInstance *pInstance; - //keep track of amount in instance script, returns SPECIAL if amount ok and event in progress - if (pInstance->GetData(TYPE_BAR) == SPECIAL) - { - DoScriptText(SAY_GOT_BEER, _Creature); - _Creature->CastSpell(_Creature,SPELL_DRUNKEN_RAGE,false); - if (npc_escortAI* pEscortAI = CAST_AI(npc_rocknotAI, _Creature->AI())) - pEscortAI->Start(false, false); - } + void Reset() + { + me->SetVisibility(VISIBILITY_OFF); } - return true; + void WaypointReached(uint32 i) {} +}; + +CreatureAI* GetAI_npc_crest(Creature* creature) +{ + return new npc_crestAI (creature); } -bool GossipHello_npc_shill(Player *player, Creature *_Creature) +bool GossipHello_npc_crest(Player *player, Creature *creature) { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - if(!pInstance) + if (!pInstance) return false; - if(player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS ) - pInstance->SetData(DATA_SHILL, DONE); + if (player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS) + { + if (Creature* reginald = Unit::GetCreature(*creature, pInstance->GetData64(DATA_REGINALD))) + reginald->AI()->DoAction(); + } return true; } -bool GossipHello_npc_crest(Player *player, Creature *_Creature) +//npc_jazz +struct npc_jazAI : public npc_escortAI { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + npc_jazAI(Creature *creature) :npc_escortAI(creature) + { + pInstance = (ScriptedInstance*)(creature->GetInstanceData()); + } - if(!pInstance) - return false; + ScriptedInstance *pInstance; - if(player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS ) - pInstance->SetData(DATA_CREST, DONE); + void Reset() + { + me->SetVisibility(VISIBILITY_OFF); + } - return true; + void WaypointReached(uint32 i) {} +}; + +CreatureAI* GetAI_npc_jaz(Creature* creature) +{ + return new npc_jazAI (creature); } -bool GossipHello_npc_jaz(Player *player, Creature *_Creature) +bool GossipHello_npc_jaz(Player *player, Creature *creature) { - ScriptedInstance *pInstance = (ScriptedInstance*)(_Creature->GetInstanceData()); + ScriptedInstance *pInstance = (ScriptedInstance*)(creature->GetInstanceData()); - if(!pInstance) + if (!pInstance) return false; - if(player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS ) - pInstance->SetData(DATA_JAZ, DONE); + if (player->GetQuestStatus(QUEST_JAIL_BREAK) == QUEST_STATUS_INCOMPLETE && pInstance->GetData(DATA_QUEST_JAIL_BREAK) == IN_PROGRESS) + { + if (Creature* reginald = Unit::GetCreature(*creature, pInstance->GetData64(DATA_REGINALD))) + reginald->AI()->DoAction(); + } return true; } @@ -1485,6 +1451,23 @@ void AddSC_blackrock_depths() newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer; newscript->RegisterSelf(); + newscript = new Script; + newscript->Name = "npc_rocknot"; + newscript->GetAI = &GetAI_npc_rocknot; + newscript->pQuestRewardedNPC = &ChooseReward_npc_rocknot; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_marshal_windsor"; + newscript->pQuestAcceptNPC = &QuestAccept_npc_marshal_windsor; + newscript->GetAI = &GetAI_npc_marshal_windsor; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_marshal_reginald_windsor"; + newscript->GetAI = &GetAI_npc_marshal_reginald_windsor; + newscript->RegisterSelf(); + newscript = new Script; newscript->Name="npc_dughal_stormwing"; newscript->pGossipHello = &GossipHello_npc_dughal_stormwing; @@ -1500,35 +1483,21 @@ void AddSC_blackrock_depths() newscript->RegisterSelf(); newscript = new Script; - newscript->Name="npc_marshal_windsor"; - newscript->pQuestAcceptNPC = &QuestAccept_npc_marshal_windsor; - newscript->GetAI = &GetAI_npc_marshal_windsor; + newscript->Name="npc_shill"; + newscript->pGossipHello = &GossipHello_npc_shill; + newscript->GetAI = &GetAI_npc_shill; newscript->RegisterSelf(); newscript = new Script; - newscript->Name="npc_marshal_reginald_windsor"; - newscript->GetAI = &GetAI_npc_marshal_reginald_windsor; + newscript->Name="npc_crest"; + newscript->pGossipHello = &GossipHello_npc_crest; + newscript->GetAI = &GetAI_npc_crest; newscript->RegisterSelf(); - newscript = new Script; - newscript->Name = "npc_rocknot"; - newscript->GetAI = &GetAI_npc_rocknot; - newscript->pQuestRewardedNPC = &ChooseReward_npc_rocknot; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_shill"; - newscript->pGossipHello = &GossipHello_npc_shill; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_crest"; - newscript->pGossipHello = &GossipHello_npc_crest; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_jaz"; - newscript->pGossipHello = &GossipHello_npc_jaz; - newscript->RegisterSelf(); + newscript = new Script; + newscript->Name="npc_jaz"; + newscript->pGossipHello = &GossipHello_npc_jaz; + newscript->GetAI = &GetAI_npc_jaz; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp old mode 100755 new mode 100644 similarity index 83% rename from src/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp index db858b463..4e0204b78 --- a/src/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -73,7 +76,7 @@ struct boss_ambassador_flamelashAI : public ScriptedAI //FireBlast_Timer if (FireBlast_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FIREBLAST); + DoCast(me->getVictim(),SPELL_FIREBLAST); FireBlast_Timer = 7000; } else @@ -82,10 +85,10 @@ struct boss_ambassador_flamelashAI : public ScriptedAI //Spirit_Timer if (Spirit_Timer < diff) { - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); + SummonSpirits(me->getVictim()); + SummonSpirits(me->getVictim()); + SummonSpirits(me->getVictim()); + SummonSpirits(me->getVictim()); Spirit_Timer = 30000; } @@ -95,9 +98,9 @@ struct boss_ambassador_flamelashAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_ambassador_flamelash(Creature *_Creature) +CreatureAI* GetAI_boss_ambassador_flamelash(Creature *creature) { - return new boss_ambassador_flamelashAI (_Creature); + return new boss_ambassador_flamelashAI (creature); } void AddSC_boss_ambassador_flamelash() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_anubshiah.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_anubshiah.cpp index 2a8a09617..abe4a8dca --- a/src/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_anubshiah.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -61,7 +64,7 @@ struct boss_anubshiahAI : public ScriptedAI //ShadowBolt_Timer if (ShadowBolt_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); + DoCast(me->getVictim(),SPELL_SHADOWBOLT); ShadowBolt_Timer = 7000; } else @@ -80,7 +83,7 @@ struct boss_anubshiahAI : public ScriptedAI //CurseOfWeakness_Timer if (CurseOfWeakness_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); + DoCast(me->getVictim(),SPELL_CURSEOFWEAKNESS); CurseOfWeakness_Timer = 45000; } else @@ -89,7 +92,7 @@ struct boss_anubshiahAI : public ScriptedAI //DemonArmor_Timer if (DemonArmor_Timer < diff) { - DoCast(m_creature,SPELL_DEMONARMOR); + DoCast(me,SPELL_DEMONARMOR); DemonArmor_Timer = 300000; } else @@ -109,9 +112,9 @@ struct boss_anubshiahAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_anubshiah(Creature *_Creature) +CreatureAI* GetAI_boss_anubshiah(Creature *creature) { - return new boss_anubshiahAI (_Creature); + return new boss_anubshiahAI (creature); } void AddSC_boss_anubshiah() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_coren_direbrew.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_coren_direbrew.cpp similarity index 85% rename from src/scripts/scripts/zone/blackrock_depths/boss_coren_direbrew.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_coren_direbrew.cpp index 4dc57e19b..b711c7ade 100644 --- a/src/scripts/scripts/zone/blackrock_depths/boss_coren_direbrew.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_coren_direbrew.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_blackrock_depths.h" @@ -132,9 +150,9 @@ struct boss_coren_direbrewAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_coren_direbrew(Creature *_Creature) +CreatureAI* GetAI_boss_coren_direbrew(Creature *creature) { - return new boss_coren_direbrewAI (_Creature); + return new boss_coren_direbrewAI (creature); } @@ -184,9 +202,9 @@ struct direbrew_starter_triggerAI : public ScriptedAI } }; -CreatureAI* GetAI_direbrew_starter_trigger(Creature *_Creature) +CreatureAI* GetAI_direbrew_starter_trigger(Creature *creature) { - return new direbrew_starter_triggerAI (_Creature); + return new direbrew_starter_triggerAI (creature); } void AddSC_boss_coren_direbrew() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp old mode 100755 new mode 100644 similarity index 81% rename from src/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp index 8b378f088..73eb1ab16 --- a/src/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_emperor_dagran_thaurissan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -53,6 +56,15 @@ struct boss_draganthaurissanAI : public ScriptedAI { DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); } + void JustDied(Unit*) + { + Unit* moira=FindCreature(8929,300,me); + if (moira && moira->isAlive()) + { + moira->setFaction(35); + moira->ToCreature()->AI()->_EnterEvadeMode(); + } + } void UpdateAI(const uint32 diff) { @@ -66,7 +78,7 @@ struct boss_draganthaurissanAI : public ScriptedAI target = SelectUnit(SELECT_TARGET_RANDOM,0); if (target) DoCast(target,SPELL_HANDOFTHAURISSAN); - //3 Hands of Thaurissan will be casted + //3 Hands of Thaurissan will be cast //if (Counter < 3) //{ // HandOfThaurissan_Timer = 1000; @@ -82,7 +94,7 @@ struct boss_draganthaurissanAI : public ScriptedAI //AvatarOfFlame_Timer if (AvatarOfFlame_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_AVATAROFFLAME); + DoCast(me->getVictim(),SPELL_AVATAROFFLAME); AvatarOfFlame_Timer = 18000; } else @@ -91,9 +103,9 @@ struct boss_draganthaurissanAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_draganthaurissan(Creature *_Creature) +CreatureAI* GetAI_boss_draganthaurissan(Creature *creature) { - return new boss_draganthaurissanAI (_Creature); + return new boss_draganthaurissanAI (creature); } void AddSC_boss_draganthaurissan() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_general_angerforge.cpp old mode 100755 new mode 100644 similarity index 83% rename from src/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_general_angerforge.cpp index 138d977d5..e999a5cac --- a/src/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_general_angerforge.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -109,7 +112,7 @@ struct boss_general_angerforgeAI : public ScriptedAI //MightyBlow_Timer if (MightyBlow_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + DoCast(me->getVictim(),SPELL_MIGHTYBLOW); MightyBlow_Timer = 18000; } else @@ -118,7 +121,7 @@ struct boss_general_angerforgeAI : public ScriptedAI //HamString_Timer if (HamString_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + DoCast(me->getVictim(),SPELL_HAMSTRING); HamString_Timer = 15000; } else @@ -127,21 +130,21 @@ struct boss_general_angerforgeAI : public ScriptedAI //Cleave_Timer if (Cleave_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); + DoCast(me->getVictim(),SPELL_CLEAVE); Cleave_Timer = 9000; } else Cleave_Timer -= diff; //Adds_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) + if ( me->GetHealth()*100 / me->GetMaxHealth() < 21 ) { if (Adds_Timer < diff) { // summon 3 Adds every 25s - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); + SummonAdds(me->getVictim()); + SummonAdds(me->getVictim()); + SummonAdds(me->getVictim()); Adds_Timer = 25000; } @@ -150,19 +153,19 @@ struct boss_general_angerforgeAI : public ScriptedAI } //Summon Medics - if ( !Medics && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) + if ( !Medics && me->GetHealth()*100 / me->GetMaxHealth() < 21 ) { - SummonMedics(m_creature->getVictim()); - SummonMedics(m_creature->getVictim()); + SummonMedics(me->getVictim()); + SummonMedics(me->getVictim()); Medics = true; } DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_general_angerforge(Creature *_Creature) +CreatureAI* GetAI_boss_general_angerforge(Creature *creature) { - return new boss_general_angerforgeAI (_Creature); + return new boss_general_angerforgeAI (creature); } void AddSC_boss_general_angerforge() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp old mode 100755 new mode 100644 similarity index 84% rename from src/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp index 05f7f200e..0aa0048e6 --- a/src/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_gorosh_the_dervish.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -52,7 +55,7 @@ struct boss_gorosh_the_dervishAI : public ScriptedAI //WhirlWind_Timer if (WhirlWind_Timer < diff) { - DoCast(m_creature,SPELL_WHIRLWIND); + DoCast(me,SPELL_WHIRLWIND); WhirlWind_Timer = 15000; } else @@ -61,7 +64,7 @@ struct boss_gorosh_the_dervishAI : public ScriptedAI //MortalStrike_Timer if (MortalStrike_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + DoCast(me->getVictim(),SPELL_MORTALSTRIKE); MortalStrike_Timer = 15000; } else @@ -70,9 +73,9 @@ struct boss_gorosh_the_dervishAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_gorosh_the_dervish(Creature *_Creature) +CreatureAI* GetAI_boss_gorosh_the_dervish(Creature *creature) { - return new boss_gorosh_the_dervishAI (_Creature); + return new boss_gorosh_the_dervishAI (creature); } void AddSC_boss_gorosh_the_dervish() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_grizzle.cpp old mode 100755 new mode 100644 similarity index 83% rename from src/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_grizzle.cpp index 73ae98719..1e17f9c64 --- a/src/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_grizzle.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -52,18 +55,18 @@ struct boss_grizzleAI : public ScriptedAI //GroundTremor_Timer if (GroundTremor_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_GROUNDTREMOR); + DoCast(me->getVictim(),SPELL_GROUNDTREMOR); GroundTremor_Timer = 8000; } else GroundTremor_Timer -= diff; //Frenzy_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + if ( me->GetHealth()*100 / me->GetMaxHealth() < 51 ) { if (Frenzy_Timer < diff) { - DoCast(m_creature,SPELL_FRENZY); + DoCast(me,SPELL_FRENZY); DoTextEmote("goes into a killing frenzy!",NULL); Frenzy_Timer = 15000; @@ -75,9 +78,9 @@ struct boss_grizzleAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_grizzle(Creature *_Creature) +CreatureAI* GetAI_boss_grizzle(Creature *creature) { - return new boss_grizzleAI (_Creature); + return new boss_grizzleAI (creature); } void AddSC_boss_grizzle() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp index e33e5a38e..3cc28cc81 --- a/src/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_high_interrogator_gerstahn.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -80,7 +83,7 @@ struct boss_high_interrogator_gerstahnAI : public ScriptedAI //PsychicScream_Timer if (PsychicScream_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_PSYCHICSCREAM); + DoCast(me->getVictim(),SPELL_PSYCHICSCREAM); PsychicScream_Timer = 30000; } else @@ -89,7 +92,7 @@ struct boss_high_interrogator_gerstahnAI : public ScriptedAI //ShadowShield_Timer if (ShadowShield_Timer < diff) { - DoCast(m_creature,SPELL_SHADOWSHIELD); + DoCast(me,SPELL_SHADOWSHIELD); ShadowShield_Timer = 25000; } else @@ -98,9 +101,9 @@ struct boss_high_interrogator_gerstahnAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_high_interrogator_gerstahn(Creature *_Creature) +CreatureAI* GetAI_boss_high_interrogator_gerstahn(Creature *creature) { - return new boss_high_interrogator_gerstahnAI (_Creature); + return new boss_high_interrogator_gerstahnAI (creature); } void AddSC_boss_high_interrogator_gerstahn() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_magmus.cpp old mode 100755 new mode 100644 similarity index 82% rename from src/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_magmus.cpp index 81076a146..70f48ff1f --- a/src/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_magmus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -52,18 +55,18 @@ struct boss_magmusAI : public ScriptedAI //FieryBurst_Timer if (FieryBurst_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FIERYBURST); + DoCast(me->getVictim(),SPELL_FIERYBURST); FieryBurst_Timer = 6000; } else FieryBurst_Timer -= diff; //WarStomp_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + if ( me->GetHealth()*100 / me->GetMaxHealth() < 51 ) { if (WarStomp_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_WARSTOMP); + DoCast(me->getVictim(),SPELL_WARSTOMP); WarStomp_Timer = 8000; } else @@ -73,9 +76,9 @@ struct boss_magmusAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_magmus(Creature *_Creature) +CreatureAI* GetAI_boss_magmus(Creature *creature) { - return new boss_magmusAI (_Creature); + return new boss_magmusAI (creature); } void AddSC_boss_magmus() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp old mode 100755 new mode 100644 similarity index 84% rename from src/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp index 8c008f189..417b22501 --- a/src/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_moira_bronzebeard.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,7 +19,7 @@ /* ScriptData SDName: Boss_Moira_Bronzbeard -SD%Complete: 90 +SD%Complete: 92 SDComment: Healing of Emperor NYI SDCategory: Blackrock Depths EndScriptData */ @@ -38,13 +41,10 @@ struct boss_moira_bronzebeardAI : public ScriptedAI uint32 MindBlast_Timer; uint32 ShadowWordPain_Timer; uint32 Smite_Timer; - Unit* PlayerHolder; - Unit* Target; bool Heal; void Reset() { - Target = NULL; Heal_Timer = 12000; //These times are probably wrong MindBlast_Timer = 16000; ShadowWordPain_Timer = 2000; @@ -64,7 +64,7 @@ struct boss_moira_bronzebeardAI : public ScriptedAI //MindBlast_Timer if (MindBlast_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + DoCast(me->getVictim(),SPELL_MINDBLAST); MindBlast_Timer = 14000; } else @@ -73,7 +73,7 @@ struct boss_moira_bronzebeardAI : public ScriptedAI //ShadowWordPain_Timer if (ShadowWordPain_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); + DoCast(me->getVictim(),SPELL_SHADOWWORDPAIN); ShadowWordPain_Timer = 18000; } else @@ -82,17 +82,18 @@ struct boss_moira_bronzebeardAI : public ScriptedAI //Smite_Timer if (Smite_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SMITE); + DoCast(me->getVictim(),SPELL_SMITE); Smite_Timer = 10000; } else Smite_Timer -= diff; + DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_boss_moira_bronzebeard(Creature *_Creature) +CreatureAI* GetAI_boss_moira_bronzebeard(Creature *creature) { - return new boss_moira_bronzebeardAI (_Creature); + return new boss_moira_bronzebeardAI (creature); } void AddSC_boss_moira_bronzebeard() diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_theldren.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_theldren.cpp similarity index 80% rename from src/scripts/scripts/zone/blackrock_depths/boss_theldren.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_theldren.cpp index cfcf1ba09..21af00581 100644 --- a/src/scripts/scripts/zone/blackrock_depths/boss_theldren.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_theldren.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_blackrock_depths.h" @@ -98,9 +116,9 @@ struct boss_theldrenAI : public ScriptedAI { boss_theldrenAI(Creature *c) : ScriptedAI(c) { - pInstance = m_creature->GetInstanceData(); + pInstance = me->GetInstanceData(); SelectAddEntry(); - for(uint8 i = 0; i < 4; ++i) + for (uint8 i = 0; i < 4; ++i) AddGUID[i] = 0; } @@ -119,7 +137,7 @@ struct boss_theldrenAI : public ScriptedAI void Reset() { - if(pInstance && pInstance->GetData(TYPE_THELDREN)!= DONE) + if (pInstance && pInstance->GetData(TYPE_THELDREN)!= DONE) pInstance->SetData(TYPE_THELDREN, NOT_STARTED); BattleShout_Timer = 6000; @@ -137,11 +155,11 @@ struct boss_theldrenAI : public ScriptedAI { DoZoneInCombat(); - for(uint8 i = 0; i < 4; ++i) + for (uint8 i = 0; i < 4; ++i) { - Unit* Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + Unit* Temp = Unit::GetUnit((*me),AddGUID[i]); + if (Temp && Temp->isAlive()) + ((Creature*)Temp)->AI()->AttackStart(me->getVictim()); else { EnterEvadeMode(); @@ -152,7 +170,7 @@ struct boss_theldrenAI : public ScriptedAI void JustDied(Unit* victim) { - if(pInstance) + if (pInstance) pInstance->SetData(TYPE_THELDREN, DONE); victim->SummonGameObject(GO_ARENA_SPOILS, 596.664, -188.699, -54.1551, 5.67734, 0, 0, 0.298313, -0.954468, 0); } @@ -165,7 +183,7 @@ struct boss_theldrenAI : public ScriptedAI if (BattleShout_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_BATTLE_SHOUT); + AddSpellToCast(me, SPELL_BATTLE_SHOUT); BattleShout_Timer = 10000; } else @@ -173,7 +191,7 @@ struct boss_theldrenAI : public ScriptedAI if (DemoralizingShout_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_DEMORALIZING_SHOUT); + AddSpellToCast(me, SPELL_DEMORALIZING_SHOUT); DemoralizingShout_Timer = 120000; } else @@ -181,7 +199,7 @@ struct boss_theldrenAI : public ScriptedAI if (Disarm_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_DISARM); + AddSpellToCast(me->getVictim(), SPELL_DISARM); Disarm_Timer = 60000; } else @@ -189,7 +207,7 @@ struct boss_theldrenAI : public ScriptedAI if (FrighteningShout_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_FRIGHTENING_SHOUT); + AddSpellToCast(me->getVictim(), SPELL_FRIGHTENING_SHOUT); FrighteningShout_Timer = 30000; } else @@ -197,7 +215,7 @@ struct boss_theldrenAI : public ScriptedAI if (Hamstring_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_HAMSTRING); + AddSpellToCast(me->getVictim(), SPELL_HAMSTRING); Hamstring_Timer = 30000; } else @@ -205,7 +223,7 @@ struct boss_theldrenAI : public ScriptedAI if (Intercept_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_INTERCEPT); + AddSpellToCast(me->getVictim(), SPELL_INTERCEPT); Intercept_Timer = 25000; } else @@ -213,15 +231,15 @@ struct boss_theldrenAI : public ScriptedAI if (MortalStrike_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); + AddSpellToCast(me->getVictim(), SPELL_MORTAL_STRIKE); MortalStrike_Timer = 15000; } else MortalStrike_Timer -= diff; - if(!DrinkHealingPotion_Used && HealthBelowPct(50)) + if (!DrinkHealingPotion_Used && HealthBelowPct(50)) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -233,27 +251,27 @@ struct boss_theldrenAI : public ScriptedAI { std::vector AddList; - for(uint8 i = 0; i < 8; ++i) + for (uint8 i = 0; i < 8; ++i) AddList.push_back(AddEntryList[i]); - while(AddList.size() > 4) + while (AddList.size() > 4) AddList.erase(AddList.begin()+rand()%AddList.size()); uint8 i = 0; - for(std::vector::iterator itr = AddList.begin(); itr != AddList.end(); ++itr, ++i) + for (std::vector::iterator itr = AddList.begin(); itr != AddList.end(); ++itr, ++i) AddEntry[i] = *itr; } void SpawnAdds() { - for(uint8 i = 0; i < 4; ++i) + for (uint8 i = 0; i < 4; ++i) { - Creature *pCreature = (Unit::GetCreature((*m_creature), AddGUID[i])); - if(!pCreature || !pCreature->isAlive()) + Creature *pCreature = (Unit::GetCreature((*me), AddGUID[i])); + if (!pCreature || !pCreature->isAlive()) { - if(pCreature) pCreature->setDeathState(DEAD); - pCreature = m_creature->SummonCreature(AddEntry[i], ArenaLocations[i][0], ArenaLocations[i][1], ArenaLocations[i][2], Orientation, TEMPSUMMON_DEAD_DESPAWN, 0); - if(pCreature) AddGUID[i] = pCreature->GetGUID(); + if (pCreature) pCreature->setDeathState(DEAD); + pCreature = me->SummonCreature(AddEntry[i], ArenaLocations[i][0], ArenaLocations[i][1], ArenaLocations[i][2], Orientation, TEMPSUMMON_DEAD_DESPAWN, 0); + if (pCreature) AddGUID[i] = pCreature->GetGUID(); } else { @@ -265,9 +283,9 @@ struct boss_theldrenAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_theldren(Creature *_Creature) +CreatureAI* GetAI_boss_theldren(Creature *creature) { - return new boss_theldrenAI (_Creature); + return new boss_theldrenAI (creature); } ////////////////////// @@ -307,9 +325,9 @@ struct boss_malgen_longspearAI : public ScriptedAI { DoZoneInCombat(); - Unit* Temp = Unit::GetUnit((*m_creature),PetGUID); - if(Temp && Temp->isAlive()) - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + Unit* Temp = Unit::GetUnit((*me),PetGUID); + if (Temp && Temp->isAlive()) + ((Creature*)Temp)->AI()->AttackStart(me->getVictim()); else { EnterEvadeMode(); @@ -326,11 +344,11 @@ struct boss_malgen_longspearAI : public ScriptedAI if (!UpdateVictim()) return; - DoStartNoMovement(m_creature->getVictim()); + DoStartNoMovement(me->getVictim()); if (FreezingTrap_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_FREEZING_TRAP); + AddSpellToCast(me, SPELL_FREEZING_TRAP); FreezingTrap_Timer = 60000; } else @@ -338,7 +356,7 @@ struct boss_malgen_longspearAI : public ScriptedAI if (AimedShot_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_AIMED_SHOT); + AddSpellToCast(me->getVictim(), SPELL_AIMED_SHOT); AimedShot_Timer = 10000; } else @@ -346,7 +364,7 @@ struct boss_malgen_longspearAI : public ScriptedAI if (ConclussiveShot_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_CONCLUSSIVE_SHOT); + AddSpellToCast(me->getVictim(), SPELL_CONCLUSSIVE_SHOT); ConclussiveShot_Timer = 8000; } else @@ -354,7 +372,7 @@ struct boss_malgen_longspearAI : public ScriptedAI if (MultiShot_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_MULTI_SHOT); + AddSpellToCast(me->getVictim(), SPELL_MULTI_SHOT); MultiShot_Timer = 5000; } else @@ -362,7 +380,7 @@ struct boss_malgen_longspearAI : public ScriptedAI if (Shoot_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SHOOT); + AddSpellToCast(me->getVictim(), SPELL_SHOOT); Shoot_Timer = 1500; } else @@ -370,15 +388,15 @@ struct boss_malgen_longspearAI : public ScriptedAI if (WingClip_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_WING_CLIP, true); + AddSpellToCast(me->getVictim(), SPELL_WING_CLIP, true); WingClip_Timer = 20000; } else WingClip_Timer -= diff; - if(!DrinkHealingPotion_Used && HealthBelowPct(50)) + if (!DrinkHealingPotion_Used && HealthBelowPct(50)) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -388,26 +406,26 @@ struct boss_malgen_longspearAI : public ScriptedAI void SpawnPet() { - Creature *pPet = (Unit::GetCreature((*m_creature), PetGUID)); - if(!pPet || !pPet->isAlive()) + Creature *pPet = (Unit::GetCreature((*me), PetGUID)); + if (!pPet || !pPet->isAlive()) { - if(pPet) pPet->setDeathState(DEAD); - pPet = m_creature->SummonCreature(AddEntryList[8], m_creature->GetPositionX(), m_creature->GetPositionY()+2, m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); - if(pPet) PetGUID = pPet->GetGUID(); + if (pPet) pPet->setDeathState(DEAD); + pPet = me->SummonCreature(AddEntryList[8], me->GetPositionX(), me->GetPositionY()+2, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0); + if (pPet) PetGUID = pPet->GetGUID(); } else { pPet->AI()->EnterEvadeMode(); - pPet->Relocate(m_creature->GetPositionX(), m_creature->GetPositionY()+2, m_creature->GetPositionZ(), m_creature->GetOrientation()); + pPet->Relocate(me->GetPositionX(), me->GetPositionY()+2, me->GetPositionZ(), me->GetOrientation()); pPet->StopMoving(); } } }; -CreatureAI* GetAI_boss_malgen_longspear(Creature *_Creature) +CreatureAI* GetAI_boss_malgen_longspear(Creature *creature) { - return new boss_malgen_longspearAI (_Creature); + return new boss_malgen_longspearAI (creature); } ////////////////////// @@ -454,7 +472,7 @@ struct boss_leftyAI : public ScriptedAI if (Knockdown_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_KNOCKDOWN); + AddSpellToCast(me->getVictim(), SPELL_KNOCKDOWN); Knockdown_Timer = 30000; } else @@ -462,7 +480,7 @@ struct boss_leftyAI : public ScriptedAI if (SnapKick_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SNAP_KICK); + AddSpellToCast(me->getVictim(), SPELL_SNAP_KICK); SnapKick_Timer = 15000; } else @@ -470,7 +488,7 @@ struct boss_leftyAI : public ScriptedAI if (FFFEHT_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_FFFEHT); + AddSpellToCast(me->getVictim(), SPELL_FFFEHT); FFFEHT_Timer = 30000; } else @@ -478,7 +496,7 @@ struct boss_leftyAI : public ScriptedAI if(!DrinkHealingPotion_Used && HealthBelowPct(50)) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -536,7 +554,7 @@ struct boss_rotfangAI : public ScriptedAI if (Eviscerate_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_EVISCERATE); + AddSpellToCast(me->getVictim(), SPELL_EVISCERATE); Eviscerate_Timer = 10000; } else @@ -544,7 +562,7 @@ struct boss_rotfangAI : public ScriptedAI if (Gouge_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_GOUGE); + AddSpellToCast(me->getVictim(), SPELL_GOUGE); Gouge_Timer = 120000; } else @@ -552,7 +570,7 @@ struct boss_rotfangAI : public ScriptedAI if (Kick_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_KICK); + AddSpellToCast(me->getVictim(), SPELL_KICK); Kick_Timer = 60000; } else @@ -560,7 +578,7 @@ struct boss_rotfangAI : public ScriptedAI if (KidneyShot_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_KIDNEY_SHOT); + AddSpellToCast(me->getVictim(), SPELL_KIDNEY_SHOT); KidneyShot_Timer = 30000; } else @@ -568,7 +586,7 @@ struct boss_rotfangAI : public ScriptedAI if (SinisterStrike_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SINISTER_STRIKE); + AddSpellToCast(me->getVictim(), SPELL_SINISTER_STRIKE); SinisterStrike_Timer = 30000; } else @@ -576,7 +594,7 @@ struct boss_rotfangAI : public ScriptedAI if (SlowingPoison_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SLOWING_POISON); + AddSpellToCast(me->getVictim(), SPELL_SLOWING_POISON); SlowingPoison_Timer = 25000; } else @@ -584,7 +602,7 @@ struct boss_rotfangAI : public ScriptedAI if (Vanish_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_VANISH); + AddSpellToCast(me->getVictim(), SPELL_VANISH); Vanish_Timer = 15000; } else @@ -592,7 +610,7 @@ struct boss_rotfangAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -644,7 +662,7 @@ struct boss_vajashniAI : public ScriptedAI if (!UpdateVictim()) return; - DoStartNoMovement(m_creature->getVictim()); + DoStartNoMovement(me->getVictim()); if (DispelMagic_Timer <= diff) { @@ -708,7 +726,7 @@ struct boss_vajashniAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -763,11 +781,11 @@ struct boss_volidaAI : public ScriptedAI if (!UpdateVictim()) return; - DoStartNoMovement(m_creature->getVictim()); + DoStartNoMovement(me->getVictim()); if (Blink_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_BLINK); + AddSpellToCast(me, SPELL_BLINK); Blink_Timer = 30000; } else @@ -786,7 +804,7 @@ struct boss_volidaAI : public ScriptedAI if (ConeOfCold_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_CONE_OF_COLD); + AddSpellToCast(me->getVictim(), SPELL_CONE_OF_COLD); ConeOfCold_Timer = 15000; } else @@ -794,7 +812,7 @@ struct boss_volidaAI : public ScriptedAI if (FrostNova_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_FROST_NOVA); + AddSpellToCast(me, SPELL_FROST_NOVA); FrostNova_Timer = 25000; } else @@ -802,7 +820,7 @@ struct boss_volidaAI : public ScriptedAI if (FrostBolt_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_FROSTBOLT); + AddSpellToCast(me->getVictim(), SPELL_FROSTBOLT); FrostBolt_Timer = 3500; } else @@ -810,7 +828,7 @@ struct boss_volidaAI : public ScriptedAI if (HealthBelowPct(20) && IceBlock_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_ICE_BLOCK); + AddSpellToCast(me, SPELL_ICE_BLOCK); IceBlock_Timer = 30000; } else @@ -818,7 +836,7 @@ struct boss_volidaAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -873,11 +891,11 @@ struct boss_snokhAI : public ScriptedAI if (!UpdateVictim()) return; - DoStartNoMovement(m_creature->getVictim()); + DoStartNoMovement(me->getVictim()); if (Blink_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_BLINK); + AddSpellToCast(me, SPELL_BLINK); Blink_Timer = 30000; } else @@ -896,7 +914,7 @@ struct boss_snokhAI : public ScriptedAI if (Scorch_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SCORCH); + AddSpellToCast(me->getVictim(), SPELL_SCORCH); Scorch_Timer = 5000; } else @@ -904,7 +922,7 @@ struct boss_snokhAI : public ScriptedAI if (BlastWave_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_BLAST_WAVE); + AddSpellToCast(me, SPELL_BLAST_WAVE); BlastWave_Timer = 15000; } else @@ -912,7 +930,7 @@ struct boss_snokhAI : public ScriptedAI if (Pyroblast_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_PYROBLAST); + AddSpellToCast(me->getVictim(), SPELL_PYROBLAST); Pyroblast_Timer = 25000; } else @@ -920,7 +938,7 @@ struct boss_snokhAI : public ScriptedAI if (Polymorph_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_POLYMORPH); + AddSpellToCast(me->getVictim(), SPELL_POLYMORPH); Polymorph_Timer = 15000; } else @@ -928,7 +946,7 @@ struct boss_snokhAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -985,7 +1003,7 @@ struct boss_korvAI : public ScriptedAI if (FrostShock_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_FROST_SHOCK); + AddSpellToCast(me->getVictim(), SPELL_FROST_SHOCK); FrostShock_Timer = 10000; } else @@ -993,7 +1011,7 @@ struct boss_korvAI : public ScriptedAI if (WarStamp_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_WAR_STOMP); + AddSpellToCast(me, SPELL_WAR_STOMP); WarStamp_Timer = 15000; } else @@ -1001,7 +1019,7 @@ struct boss_korvAI : public ScriptedAI if (Purge_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_PURGE); + AddSpellToCast(me->getVictim(), SPELL_PURGE); Purge_Timer = 7000; } else @@ -1020,7 +1038,7 @@ struct boss_korvAI : public ScriptedAI if (WindfuryT_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_WINDFURY_TOTEM); + AddSpellToCast(me, SPELL_WINDFURY_TOTEM); WindfuryT_Timer = 25000; } else @@ -1028,7 +1046,7 @@ struct boss_korvAI : public ScriptedAI if (EarthbindT_Timer <= diff) { - AddSpellToCast(m_creature, SPELL_EARTHBIND_TOTEM); + AddSpellToCast(me, SPELL_EARTHBIND_TOTEM); EarthbindT_Timer = 25000; } else @@ -1036,7 +1054,7 @@ struct boss_korvAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } @@ -1090,7 +1108,7 @@ struct boss_rezznikAI : public ScriptedAI if (Recombobulate_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_RECOMBOBULATE); + AddSpellToCast(me->getVictim(), SPELL_RECOMBOBULATE); Recombobulate_Timer = 11000; } else @@ -1098,7 +1116,7 @@ struct boss_rezznikAI : public ScriptedAI if (DarkIronBomb_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_DARK_IRON_BOMB); + AddSpellToCast(me->getVictim(), SPELL_DARK_IRON_BOMB); DarkIronBomb_Timer = 4000; } else @@ -1106,7 +1124,7 @@ struct boss_rezznikAI : public ScriptedAI if (GoblinGragonGun_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_GOBLIN_DRAGON_GUN); + AddSpellToCast(me->getVictim(), SPELL_GOBLIN_DRAGON_GUN); GoblinGragonGun_Timer = 12000; } else @@ -1114,7 +1132,7 @@ struct boss_rezznikAI : public ScriptedAI if (ExplosiveSheep_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_EXPLOSIVE_SHEEP); + AddSpellToCast(me->getVictim(), SPELL_EXPLOSIVE_SHEEP); ExplosiveSheep_Timer = 20000; } else @@ -1122,7 +1140,7 @@ struct boss_rezznikAI : public ScriptedAI if (SummonADragonling_Timer <= diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_SUMMON_ADRAGONLING); + AddSpellToCast(me->getVictim(), SPELL_SUMMON_ADRAGONLING); SummonADragonling_Timer = 3600000; } else @@ -1130,7 +1148,7 @@ struct boss_rezznikAI : public ScriptedAI if(HealthBelowPct(50) && !DrinkHealingPotion_Used) { - AddSpellToCast(m_creature, SPELL_DRINK_HEALING_POTION); + AddSpellToCast(me, SPELL_DRINK_HEALING_POTION); DrinkHealingPotion_Used = true; } diff --git a/src/scripts/scripts/zone/blackrock_depths/boss_tomb_of_seven.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_tomb_of_seven.cpp old mode 100755 new mode 100644 similarity index 61% rename from src/scripts/scripts/zone/blackrock_depths/boss_tomb_of_seven.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_tomb_of_seven.cpp index e5a2009ae..9788cc7ed --- a/src/scripts/scripts/zone/blackrock_depths/boss_tomb_of_seven.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/boss_tomb_of_seven.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,18 +9,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData SDName: Boss_Tomb_Of_Seven -SD%Complete: 50 -SDComment: Learning Smelt Dark Iron if tribute quest rewarded. Missing event and re-spawn GO Spectral Chalice +SD%Complete: 95 +SDComment: SDCategory: Blackrock Depths EndScriptData */ @@ -33,7 +36,12 @@ EndScriptData */ struct boss_angerrelAI : public ScriptedAI { - boss_angerrelAI(Creature *c) : ScriptedAI(c) {} + boss_angerrelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 SunderArmor_Timer; uint32 ShieldBlock_Timer; @@ -44,12 +52,28 @@ struct boss_angerrelAI : public ScriptedAI SunderArmor_Timer = 8000; ShieldBlock_Timer = 15000; Strike_Timer = 12000; + + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) @@ -58,7 +82,7 @@ struct boss_angerrelAI : public ScriptedAI //SunderArmor_Timer if (SunderArmor_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); + DoCast(me->getVictim(),SPELL_SUNDERARMOR); SunderArmor_Timer = 28000; } else @@ -67,7 +91,7 @@ struct boss_angerrelAI : public ScriptedAI //ShieldBlock_Timer if (ShieldBlock_Timer < diff) { - DoCast(m_creature,SPELL_SHIELDBLOCK); + DoCast(me,SPELL_SHIELDBLOCK); ShieldBlock_Timer = 25000; } else @@ -76,7 +100,7 @@ struct boss_angerrelAI : public ScriptedAI //Strike_Timer if (Strike_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_STRIKE); + DoCast(me->getVictim(),SPELL_STRIKE); Strike_Timer = 10000; } else @@ -86,9 +110,9 @@ struct boss_angerrelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_angerrel(Creature *_Creature) +CreatureAI* GetAI_boss_angerrel(Creature *creature) { - return new boss_angerrelAI (_Creature); + return new boss_angerrelAI (creature); } #define SPELL_SINISTERSTRIKE 15581 @@ -97,7 +121,12 @@ CreatureAI* GetAI_boss_angerrel(Creature *_Creature) struct boss_doperelAI : public ScriptedAI { - boss_doperelAI(Creature *c) : ScriptedAI(c) {} + boss_doperelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 SinisterStrike_Timer; uint32 BackStab_Timer; @@ -108,12 +137,28 @@ struct boss_doperelAI : public ScriptedAI SinisterStrike_Timer = 8000; BackStab_Timer = 12000; Gouge_Timer = 6000; + + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) @@ -122,7 +167,7 @@ struct boss_doperelAI : public ScriptedAI //SinisterStrike_Timer if (SinisterStrike_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SINISTERSTRIKE); + DoCast(me->getVictim(),SPELL_SINISTERSTRIKE); SinisterStrike_Timer = 7000; } else @@ -131,7 +176,7 @@ struct boss_doperelAI : public ScriptedAI //BackStab_Timer if (BackStab_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_BACKSTAB); + DoCast(me->getVictim(),SPELL_BACKSTAB); BackStab_Timer = 6000; } else @@ -140,7 +185,7 @@ struct boss_doperelAI : public ScriptedAI //Gouge_Timer if (Gouge_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_GOUGE); + DoCast(me->getVictim(),SPELL_GOUGE); Gouge_Timer = 8000; } else @@ -150,9 +195,9 @@ struct boss_doperelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_doperel(Creature *_Creature) +CreatureAI* GetAI_boss_doperel(Creature *creature) { - return new boss_doperelAI (_Creature); + return new boss_doperelAI (creature); } #define SPELL_SHADOWBOLT 17483 //Not sure if right ID @@ -161,7 +206,12 @@ CreatureAI* GetAI_boss_doperel(Creature *_Creature) struct boss_haterelAI : public ScriptedAI { - boss_haterelAI(Creature *c) : ScriptedAI(c) {} + boss_haterelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 ShadowBolt_Timer; uint32 ManaBurn_Timer; @@ -174,12 +224,28 @@ struct boss_haterelAI : public ScriptedAI ManaBurn_Timer = 3000; ShadowShield_Timer = 8000; Strike_Timer = 12000; + + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) @@ -210,7 +276,7 @@ struct boss_haterelAI : public ScriptedAI //ShadowShield_Timer if (ShadowShield_Timer < diff) { - DoCast(m_creature,SPELL_SHADOWSHIELD); + DoCast(me,SPELL_SHADOWSHIELD); ShadowShield_Timer = 25000; } else @@ -219,7 +285,7 @@ struct boss_haterelAI : public ScriptedAI //Strike_Timer if (Strike_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_STRIKE); + DoCast(me->getVictim(),SPELL_STRIKE); Strike_Timer = 10000; } else @@ -229,9 +295,9 @@ struct boss_haterelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_haterel(Creature *_Creature) +CreatureAI* GetAI_boss_haterel(Creature *creature) { - return new boss_haterelAI (_Creature); + return new boss_haterelAI (creature); } #define SPELL_MINDBLAST 15587 @@ -241,7 +307,12 @@ CreatureAI* GetAI_boss_haterel(Creature *_Creature) struct boss_vilerelAI : public ScriptedAI { - boss_vilerelAI(Creature *c) : ScriptedAI(c) {} + boss_vilerelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 MindBlast_Timer; uint32 Heal_Timer; @@ -254,12 +325,28 @@ struct boss_vilerelAI : public ScriptedAI Heal_Timer = 35000; PrayerOfHealing_Timer = 25000; Shield_Timer = 3000; + + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) @@ -268,7 +355,7 @@ struct boss_vilerelAI : public ScriptedAI //MindBlast_Timer if (MindBlast_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + DoCast(me->getVictim(),SPELL_MINDBLAST); MindBlast_Timer = 7000; } else @@ -277,7 +364,7 @@ struct boss_vilerelAI : public ScriptedAI //Heal_Timer if (Heal_Timer < diff) { - DoCast(m_creature,SPELL_HEAL); + DoCast(me,SPELL_HEAL); Heal_Timer = 20000; } else @@ -286,7 +373,7 @@ struct boss_vilerelAI : public ScriptedAI //PrayerOfHealing_Timer if (PrayerOfHealing_Timer < diff) { - DoCast(m_creature,SPELL_PRAYEROFHEALING); + DoCast(me,SPELL_PRAYEROFHEALING); PrayerOfHealing_Timer = 30000; } else @@ -295,7 +382,7 @@ struct boss_vilerelAI : public ScriptedAI //Shield_Timer if (Shield_Timer < diff) { - DoCast(m_creature,SPELL_SHIELD); + DoCast(me,SPELL_SHIELD); Shield_Timer = 30000; } else @@ -305,9 +392,9 @@ struct boss_vilerelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_vilerel(Creature *_Creature) +CreatureAI* GetAI_boss_vilerel(Creature *creature) { - return new boss_vilerelAI (_Creature); + return new boss_vilerelAI (creature); } #define SPELL_FROSTBOLT 16799 @@ -318,7 +405,12 @@ CreatureAI* GetAI_boss_vilerel(Creature *_Creature) struct boss_seethrelAI : public ScriptedAI { - boss_seethrelAI(Creature *c) : ScriptedAI(c) {} + boss_seethrelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 FrostArmor_Timer; uint32 Frostbolt_Timer; @@ -334,13 +426,28 @@ struct boss_seethrelAI : public ScriptedAI FrostNova_Timer = 12000; FrostWard_Timer = 25000; - m_creature->CastSpell(m_creature,SPELL_FROSTARMOR,true); + me->CastSpell(me,SPELL_FROSTARMOR,true); + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) @@ -349,7 +456,7 @@ struct boss_seethrelAI : public ScriptedAI //FrostArmor_Timer if (FrostArmor_Timer < diff) { - DoCast(m_creature, SPELL_FROSTARMOR); + DoCast(me, SPELL_FROSTARMOR); FrostArmor_Timer = 180000; } else @@ -358,7 +465,7 @@ struct boss_seethrelAI : public ScriptedAI //Frostbolt_Timer if (Frostbolt_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); + DoCast(me->getVictim(),SPELL_FROSTBOLT); Frostbolt_Timer = 15000; } else @@ -378,7 +485,7 @@ struct boss_seethrelAI : public ScriptedAI //FrostNova_Timer if (FrostNova_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); + DoCast(me->getVictim(),SPELL_FROSTNOVA); FrostNova_Timer = 14000; } else @@ -387,7 +494,7 @@ struct boss_seethrelAI : public ScriptedAI //FrostWard_Timer if (FrostWard_Timer < diff) { - DoCast(m_creature,SPELL_FROSTWARD); + DoCast(me,SPELL_FROSTWARD); FrostWard_Timer = 68000; } else @@ -397,9 +504,9 @@ struct boss_seethrelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_seethrel(Creature *_Creature) +CreatureAI* GetAI_boss_seethrel(Creature *creature) { - return new boss_seethrelAI (_Creature); + return new boss_seethrelAI (creature); } #define SPELL_HAMSTRING 9080 @@ -408,7 +515,12 @@ CreatureAI* GetAI_boss_seethrel(Creature *_Creature) struct boss_gloomrelAI : public ScriptedAI { - boss_gloomrelAI(Creature *c) : ScriptedAI(c) {} + boss_gloomrelAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 Hamstring_Timer; uint32 Cleave_Timer; @@ -420,13 +532,27 @@ struct boss_gloomrelAI : public ScriptedAI Cleave_Timer = 6000; MortalStrike_Timer = 10000; - m_creature->setFaction(FACTION_NEUTRAL); + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } + void EnterEvadeMode() + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, SPECIAL); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim() ) @@ -435,7 +561,7 @@ struct boss_gloomrelAI : public ScriptedAI //Hamstring_Timer if (Hamstring_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + DoCast(me->getVictim(),SPELL_HAMSTRING); Hamstring_Timer = 14000; } else @@ -444,7 +570,7 @@ struct boss_gloomrelAI : public ScriptedAI //Cleave_Timer if (Cleave_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); + DoCast(me->getVictim(),SPELL_CLEAVE); Cleave_Timer = 8000; } else @@ -453,7 +579,7 @@ struct boss_gloomrelAI : public ScriptedAI //MortalStrike_Timer if (MortalStrike_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + DoCast(me->getVictim(),SPELL_MORTALSTRIKE); MortalStrike_Timer = 12000; } else @@ -463,48 +589,48 @@ struct boss_gloomrelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_gloomrel(Creature *_Creature) +CreatureAI* GetAI_boss_gloomrel(Creature *creature) { - return new boss_gloomrelAI (_Creature); + return new boss_gloomrelAI (creature); } #define GOSSIP_ITEM_TEACH_1 "Teach me the art of smelting dark iron" #define GOSSIP_ITEM_TEACH_2 "Continue..." #define GOSSIP_ITEM_TRIBUTE "I want to pay tribute" -bool GossipHello_boss_gloomrel(Player *player, Creature *_Creature) +bool GossipHello_boss_gloomrel(Player *player, Creature *creature) { if (player->GetQuestRewardStatus(4083) == 1 && player->GetSkillValue(SKILL_MINING) >= 230 && !player->HasSpell(14891) ) player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TEACH_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); if (player->GetQuestRewardStatus(4083) == 0 && player->GetSkillValue(SKILL_MINING) >= 230) player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TRIBUTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2601, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2601, creature->GetGUID()); return true; } -bool GossipSelect_boss_gloomrel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_boss_gloomrel(Player *player, Creature *creature, uint32 sender, uint32 action ) { static uint64 SpectralChaliceGUID = 0; switch (action) { case GOSSIP_ACTION_INFO_DEF+1: player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TEACH_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(2606, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2606, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+11: player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 14894, false); + creature->CastSpell(player, 14894, false); break; case GOSSIP_ACTION_INFO_DEF+2: player->ADD_GOSSIP_ITEM(0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); - player->SEND_GOSSIP_MENU(2604, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(2604, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+22: player->CLOSE_GOSSIP_MENU(); - if(!_Creature->GetMap()->GetGameObject(SpectralChaliceGUID)) + if(!creature->GetMap()->GetGameObject(SpectralChaliceGUID)) { - GameObject *spectralChalice = _Creature->SummonGameObject(164869, 1232, -239, -85, 4.05, 0, 0, 0, 0, 0); + GameObject *spectralChalice = creature->SummonGameObject(164869, 1232, -239, -85, 4.05, 0, 0, 0, 0, 0); if(spectralChalice) SpectralChaliceGUID = spectralChalice->GetGUID(); } @@ -517,20 +643,26 @@ bool GossipSelect_boss_gloomrel(Player *player, Creature *_Creature, uint32 send #define SPELL_IMMOLATE 15505 #define SPELL_CURSEOFWEAKNESS 17227 #define SPELL_DEMONARMOR 11735 +#define SPELL_SUMMON_VOIDS 15092 +#define GO_CHEST_SEVEN 169243 struct boss_doomrelAI : public ScriptedAI { - boss_doomrelAI(Creature *c) : ScriptedAI(c) {} + boss_doomrelAI(Creature *c) : ScriptedAI(c), voids(me) + { + pInstance = (c->GetInstanceData()); + } + ScriptedInstance* pInstance; + + SummonList voids; uint32 ShadowVolley_Timer; uint32 Immolate_Timer; uint32 CurseOfWeakness_Timer; uint32 DemonArmor_Timer; bool Voidwalkers; - int Rand; - int RandX; - int RandY; - Creature* Summoned; + + uint64 DoomGUID; void Reset() { @@ -540,43 +672,83 @@ struct boss_doomrelAI : public ScriptedAI DemonArmor_Timer = 16000; Voidwalkers = false; - m_creature->setFaction(FACTION_NEUTRAL); + DoomGUID = 0; + + me->setFaction(FACTION_NEUTRAL); } void EnterCombat(Unit *who) { } - void SummonVoidwalkers(Unit* victim) + void JustSummoned(Creature* summoned) + { + voids.Summon(summoned); + summoned->AI()->AttackStart(me->getVictim()); + } + + void EnterEvadeMode() { - Rand = rand()%5; - switch (rand()%2) + voids.DespawnAll(); + + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, FAIL); + + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit *slayer) + { + if(pInstance) + pInstance->SetData(TYPE_TOMB_OF_SEVEN, DONE); + + slayer->SummonGameObject(GO_CHEST_SEVEN, 1265.96f, -284.121f, -78.2191, 3.8531f, 0, 0, 0, 0, 0); + } + + void DoAction(const int32 param) + { + switch (param) { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; + case 1: + DoomGUID = pInstance->GetData64(DATA_ANGERREL); + break; + case 2: + DoomGUID = pInstance->GetData64(DATA_SEETHREL); + break; + case 3: + DoomGUID = pInstance->GetData64(DATA_DOPEREL); + break; + case 4: + DoomGUID = pInstance->GetData64(DATA_GLOOMREL); + break; + case 5: + DoomGUID = pInstance->GetData64(DATA_VILEREL); + break; + case 6: + DoomGUID = pInstance->GetData64(DATA_HATEREL); + break; + default: + me->setFaction(FACTION_HOSTILE); + DoZoneInCombat(); + return; } - Rand = 0; - Rand = rand()%5; - switch (rand()%2) + + if (Creature *boss = me->GetCreature(DoomGUID)) { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; + boss->setFaction(FACTION_HOSTILE); + boss->AI()->DoZoneInCombat(); } - Rand = 0; - Summoned = DoSpawnCreature(16119, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); } void UpdateAI(const uint32 diff) { - if (!UpdateVictim() ) + if (!UpdateVictim()) return; //ShadowVolley_Timer if (ShadowVolley_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); + DoCast(me->getVictim(),SPELL_SHADOWBOLTVOLLEY); ShadowVolley_Timer = 12000; } else @@ -596,7 +768,7 @@ struct boss_doomrelAI : public ScriptedAI //CurseOfWeakness_Timer if (CurseOfWeakness_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); + DoCast(me->getVictim(),SPELL_CURSEOFWEAKNESS); CurseOfWeakness_Timer = 45000; } else @@ -605,18 +777,16 @@ struct boss_doomrelAI : public ScriptedAI //DemonArmor_Timer if (DemonArmor_Timer < diff) { - DoCast(m_creature,SPELL_DEMONARMOR); + DoCast(me,SPELL_DEMONARMOR); DemonArmor_Timer = 300000; } else DemonArmor_Timer -= diff; //Summon Voidwalkers - if (!Voidwalkers && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + if (!Voidwalkers && me->GetHealth()*100 / me->GetMaxHealth() < 51 ) { - SummonVoidwalkers(m_creature->getVictim()); - SummonVoidwalkers(m_creature->getVictim()); - SummonVoidwalkers(m_creature->getVictim()); + DoCast(me->getVictim(), SPELL_SUMMON_VOIDS); Voidwalkers = true; } @@ -624,35 +794,38 @@ struct boss_doomrelAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_doomrel(Creature *_Creature) +CreatureAI* GetAI_boss_doomrel(Creature *creature) { - return new boss_doomrelAI (_Creature); + return new boss_doomrelAI (creature); } #define GOSSIP_ITEM_CHALLENGE "Your bondage is at an end, Doom'rel. I challenge you!" +#define SAY_START "You have challenged the Seven, and now you will die!" -bool GossipHello_boss_doomrel(Player *player, Creature *_Creature) +bool GossipHello_boss_doomrel(Player *player, Creature *creature) { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_CHALLENGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2601, _Creature->GetGUID()); + ScriptedInstance *pInstance = (creature->GetInstanceData()); + + if (pInstance->GetData(TYPE_TOMB_OF_SEVEN) == NOT_STARTED || pInstance->GetData(TYPE_TOMB_OF_SEVEN) == FAIL) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_CHALLENGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2601, creature->GetGUID()); + } return true; } -bool GossipSelect_boss_doomrel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_boss_doomrel(Player *player, Creature *creature, uint32 sender, uint32 action ) { - switch (action) + ScriptedInstance *pInstance = (creature->GetInstanceData()); + + if (action == GOSSIP_ACTION_INFO_DEF + 1) { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2605, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - //start event here, below code just temporary - _Creature->setFaction(FACTION_HOSTILE); - break; + player->CLOSE_GOSSIP_MENU(); + creature->Say(SAY_START, LANG_UNIVERSAL, player->GetGUID()); + pInstance->SetData(TYPE_TOMB_OF_SEVEN, IN_PROGRESS); } + return true; } diff --git a/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/def_blackrock_depths.h b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/def_blackrock_depths.h new file mode 100644 index 000000000..90e0f0719 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/def_blackrock_depths.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_BLACKROCK_DEPTHS_H +#define SC_DEF_BLACKROCK_DEPTHS_H + +#define TYPE_RING_OF_LAW 1 +#define TYPE_VAULT 2 +#define TYPE_BAR 3 +#define TYPE_TOMB_OF_SEVEN 4 +#define TYPE_LYCEUM 5 +#define TYPE_IRON_HALL 6 +#define TYPE_THELDREN 7 + +#define DATA_EMPEROR 10 +#define DATA_PHALANX 11 + +#define DATA_ARENA1 12 +#define DATA_ARENA2 13 +#define DATA_ARENA3 14 +#define DATA_ARENA4 15 + +#define DATA_GO_BAR_KEG 16 +#define DATA_GO_BAR_KEG_TRAP 17 +#define DATA_GO_BAR_DOOR 18 + +#define DATA_QUEST_JAIL_BREAK 19 +#define DATA_DUGHAL 20 +#define DATA_OGRABISI 21 +#define DATA_SHILL 22 +#define DATA_JAZ 23 +#define DATA_TOBIAS 24 +#define DATA_CREST 25 +#define DATA_WINDSOR 26 +#define DATA_REGINALD 27 +#define Q_STARTER 28 + +#define DATA_ANGERREL 29 +#define DATA_DOPEREL 30 +#define DATA_HATEREL 31 +#define DATA_VILEREL 32 +#define DATA_SEETHREL 33 +#define DATA_GLOOMREL 34 +#define DATA_DOOMREL 35 + +#endif diff --git a/src/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/instance_blackrock_depths.cpp old mode 100755 new mode 100644 similarity index 58% rename from src/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_depths/instance_blackrock_depths.cpp index feb0e8bca..b0face368 --- a/src/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_depths/instance_blackrock_depths.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Blackrock_Depths @@ -21,21 +24,28 @@ SD%Complete: 100 SDCategory: Blackrock Depths EndScriptData */ -/* -update `creature_template` set `npcflag`='1',`ScriptName`='npc_dughal_stormwing' where `entry`='9022'; -update `creature_template` set `ScriptName`='npc_marshal_windsor' where `entry`='9023'; -update `creature_template` set `ScriptName`='npc_marshal_reginald_windsor' where `entry`='9682'; -update `creature_template` set `npcflag`='1',`ScriptName`='npc_tobias_seecher' where `entry`='9679'; -update `instance_template` set `script`='instance_blackrock_depths' where `map`='230'; -*/ - #include "precompiled.h" #include "def_blackrock_depths.h" -#define ENCOUNTERS 14 +#define ENCOUNTERS 8 #define C_EMPEROR 9019 #define C_PHALANX 9502 +#define NPC_ANGERREL 9035 +#define NPC_DOPEREL 9040 +#define NPC_HATEREL 9034 +#define NPC_VILEREL 9036 +#define NPC_SEETHREL 9038 +#define NPC_GLOOMREL 9037 +#define NPC_DOOMREL 9039 + +#define NPC_OGRABISI 9677 +#define NPC_SHILL 9678 +#define NPC_CREST 9680 +#define NPC_JAZ 9681 +#define NPC_TOBIAS 9679 +#define NPC_DUGHAL 9022 +#define NPC_WINDSOR 9023 #define GO_ARENA1 161525 #define GO_ARENA2 161522 @@ -63,6 +73,15 @@ struct instance_blackrock_depths : public ScriptedInstance uint64 EmperorGUID; uint64 PhalanxGUID; + uint64 DoomrelGUID; + uint64 OgrabisiGUID; + uint64 ShillGUID; + uint64 ChestGUID; + uint64 JazGUID; + uint64 TobiasGUID; + uint64 DughalGUID; + uint64 WindsorGUID; + uint64 ReginaldGUID; uint64 GoArena1GUID; uint64 GoArena2GUID; @@ -85,11 +104,23 @@ struct instance_blackrock_depths : public ScriptedInstance uint64 PlayerGUID; uint32 BarAleCount; + uint32 DoomCount; + + uint64 TombBossGUIDs[6]; void Initialize() { EmperorGUID = 0; PhalanxGUID = 0; + DoomrelGUID = 0; + OgrabisiGUID; + ShillGUID = 0; + ChestGUID = 0; + JazGUID = 0; + TobiasGUID = 0; + DughalGUID = 0; + WindsorGUID = 0; + ReginaldGUID = 0; GoArena1GUID = 0; GoArena2GUID = 0; @@ -110,6 +141,7 @@ struct instance_blackrock_depths : public ScriptedInstance GoThoneGUID = 0; BarAleCount = 0; + DoomCount = 0; for(uint8 i = 0; i < ENCOUNTERS; i++) Encounter[i] = NOT_STARTED; @@ -136,8 +168,22 @@ struct instance_blackrock_depths : public ScriptedInstance { switch(creature->GetEntry()) { - case C_EMPEROR: EmperorGUID = creature->GetGUID(); break; - case C_PHALANX: PhalanxGUID = creature->GetGUID(); break; + case C_EMPEROR: EmperorGUID = creature->GetGUID(); break; + case C_PHALANX: PhalanxGUID = creature->GetGUID(); break; + case NPC_WINDSOR: WindsorGUID = creature->GetGUID(); break; + case NPC_OGRABISI: OgrabisiGUID = creature->GetGUID(); break; + case NPC_SHILL: ShillGUID = creature->GetGUID(); break; + case NPC_CREST: ChestGUID = creature->GetGUID(); break; + case NPC_JAZ: JazGUID = creature->GetGUID(); break; + case NPC_TOBIAS: TobiasGUID = creature->GetGUID(); break; + case NPC_DUGHAL: DughalGUID = creature->GetGUID(); break; + case NPC_DOOMREL: DoomrelGUID = creature->GetGUID(); break; + case NPC_DOPEREL: TombBossGUIDs[0] = creature->GetGUID(); break; + case NPC_HATEREL: TombBossGUIDs[1] = creature->GetGUID(); break; + case NPC_VILEREL: TombBossGUIDs[2] = creature->GetGUID(); break; + case NPC_SEETHREL: TombBossGUIDs[3] = creature->GetGUID(); break; + case NPC_GLOOMREL: TombBossGUIDs[4] = creature->GetGUID(); break; + case NPC_ANGERREL: TombBossGUIDs[5] = creature->GetGUID(); break; } } @@ -157,7 +203,9 @@ struct instance_blackrock_depths : public ScriptedInstance case GO_BAR_KEG_TRAP: GoBarKegTrapGUID = go->GetGUID(); break; case GO_BAR_DOOR: GoBarDoorGUID = go->GetGUID(); break; case GO_TOMB_ENTER: GoTombEnterGUID = go->GetGUID(); break; - case GO_TOMB_EXIT: GoTombExitGUID = go->GetGUID(); break; + case GO_TOMB_EXIT: GoTombExitGUID = go->GetGUID(); + if (Encounter[3] == DONE) + HandleGameObject(GoTombExitGUID, 0); break; case GO_LYCEUM: GoLyceumGUID = go->GetGUID(); break; case GO_GOLEM_ROOM_N: GoGolemNGUID = go->GetGUID(); break; case GO_GOLEM_ROOM_S: GoGolemSGUID = go->GetGUID(); break; @@ -192,6 +240,41 @@ struct instance_blackrock_depths : public ScriptedInstance Encounter[2] = data; break; case TYPE_TOMB_OF_SEVEN: + if (data == IN_PROGRESS) + { + ++DoomCount; + if (Creature* Doomrel = instance->GetCreature(DoomrelGUID)) + Doomrel->AI()->DoAction(DoomCount); + + HandleGameObject(GoTombEnterGUID, 1); + } + if (data == SPECIAL) + { + ++DoomCount; + if (Creature* Doomrel = instance->GetCreature(DoomrelGUID)) + Doomrel->AI()->DoAction(DoomCount); + } + if (data == FAIL) + { + for (uint8 i = 0; i < 6; ++i) + { + if (Creature* boss = instance->GetCreature(TombBossGUIDs[i])) + { + if (!boss->isAlive()) + boss->Respawn(); + } + } + + DoomCount = 0; + + HandleGameObject(GoTombEnterGUID, 0); + } + if (data == DONE) + { + HandleGameObject(GoTombExitGUID, 0); + HandleGameObject(GoTombEnterGUID, 0); + } + Encounter[3] = data; break; case TYPE_LYCEUM: @@ -201,28 +284,13 @@ struct instance_blackrock_depths : public ScriptedInstance Encounter[5] = data; break; case DATA_QUEST_JAIL_BREAK: + if (data == FAIL) + Encounter[6] = NOT_STARTED; + Encounter[6] = data; break; - case DATA_SHILL: - Encounter[7] = data; - break; - case DATA_DUGHAL: - Encounter[8] = data; - break; - case DATA_CREST: - Encounter[9] = data; - break; - case DATA_JAZ: - Encounter[10] = data; - break; - case DATA_TOBIAS: - Encounter[11] = data; - break; - case DATA_SUPPLY_ROOM: - Encounter[12] = data; - break; case TYPE_THELDREN: - Encounter[13] = data; + Encounter[7] = data; break; } @@ -232,8 +300,13 @@ struct instance_blackrock_depths : public ScriptedInstance void SetData64(uint32 type, uint64 data) { - if(type == Q_STARTER) - PlayerGUID = data; + switch (type) + { + case Q_STARTER: + PlayerGUID = data; break; + case DATA_REGINALD: + ReginaldGUID = data; break; + } } uint32 GetData(uint32 type) @@ -257,20 +330,8 @@ struct instance_blackrock_depths : public ScriptedInstance return Encounter[5]; case DATA_QUEST_JAIL_BREAK: return Encounter[6]; - case DATA_SHILL: - return Encounter[7]; - case DATA_DUGHAL: - return Encounter[8]; - case DATA_CREST: - return Encounter[9]; - case DATA_JAZ: - return Encounter[10]; - case DATA_TOBIAS: - return Encounter[11]; - case DATA_SUPPLY_ROOM: - return Encounter[12]; case TYPE_THELDREN: - return Encounter[13]; + return Encounter[7]; } return 0; } @@ -299,10 +360,51 @@ struct instance_blackrock_depths : public ScriptedInstance return GoBarDoorGUID; case Q_STARTER: return PlayerGUID; + case DATA_WINDSOR: + return WindsorGUID; + case DATA_REGINALD: + return ReginaldGUID; + case DATA_OGRABISI: + return OgrabisiGUID; + case DATA_SHILL: + return ShillGUID; + case DATA_CREST: + return ChestGUID; + case DATA_JAZ: + return JazGUID; + case DATA_TOBIAS: + return TobiasGUID; + case DATA_DUGHAL: + return DughalGUID; + case DATA_ANGERREL: + return TombBossGUIDs[5]; + case DATA_DOPEREL: + return TombBossGUIDs[0]; + case DATA_HATEREL: + return TombBossGUIDs[1]; + case DATA_VILEREL: + return TombBossGUIDs[2]; + case DATA_SEETHREL: + return TombBossGUIDs[3]; + case DATA_GLOOMREL: + return TombBossGUIDs[4]; + case DATA_DOOMREL: + return DoomrelGUID; } return 0; } + void HandleGameObject(uint64 guid, uint32 state) + { + Player *player = GetPlayerInMap(); + + if (!player || !guid) + return; + + if (GameObject *go = GameObject::GetGameObject(*player,guid)) + go->SetGoState(GOState(state)); + } + std::string GetSaveData() { OUT_SAVE_INST_DATA; @@ -338,6 +440,9 @@ struct instance_blackrock_depths : public ScriptedInstance if (Encounter[i] == IN_PROGRESS) Encounter[i] = NOT_STARTED; + if (Encounter[3] == DONE) + HandleGameObject(GoTombExitGUID, 0); + OUT_LOAD_INST_DATA_COMPLETE; } }; diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_drakkisath.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_drakkisath.cpp index 299cfa604..46d176800 --- a/src/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_drakkisath.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_gyth.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_gyth.cpp index 82cb0338d..384fd920d --- a/src/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_gyth.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_halycon.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_halycon.cpp index bb6ed0e3e..6c5ccdadc --- a/src/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_halycon.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_highlord_omokk.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_highlord_omokk.cpp index baafe8db9..594936ca6 --- a/src/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_highlord_omokk.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_mother_smolderweb.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_mother_smolderweb.cpp index cbc83ddab..df60c717b --- a/src/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_mother_smolderweb.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +20,7 @@ /* ScriptData SDName: Boss_Mother_Smolderweb SD%Complete: 100 -SDComment: Uncertain how often mother's milk is casted +SDComment: Uncertain how often mother's milk is cast SDCategory: Blackrock Spire EndScriptData */ diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp index 9beab8719..c7c8460d0 --- a/src/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_overlord_wyrmthalak.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp new file mode 100644 index 000000000..dc6d401a6 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_pyroguard_emberseer.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Pyroguard_Emberseer +SD%Complete: 100 +SDComment: Event to activate Emberseer NYI +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" +#include "def_blackrock_spire.h" + +#define SPELL_FIRENOVA 16079 +#define SPELL_FLAMEBUFFET 16536 +#define SPELL_PYROBLAST 17274 +#define SPELL_GROWING 16048 +#define SPELL_TRANSFORM 16052 +#define SPELL_DESPAWN 16078 + +enum EmberseerEvents +{ + EMBERSEER_EVENT_GROWING = 1, + EMBERSEER_EVENT_TRANSFORM = 2, + EMBERSEER_EVENT_FIRENOVA = 3, + EMBERSEER_EVENT_FLAMEBUFFET = 4, + EMBERSEER_EVENT_PYROBLAST = 5 +}; + +struct boss_pyroguard_emberseerAI : public BossAI +{ + boss_pyroguard_emberseerAI(Creature *c) : BossAI(c, DATA_EMBERSEER) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; + + uint32 FireNova_Timer; + uint32 FlameBuffet_Timer; + uint32 PyroBlast_Timer; + void Reset() + { + FireNova_Timer = 6000; + FlameBuffet_Timer = 3000; + PyroBlast_Timer = 14000; + pInstance->SetData(bossId, NOT_STARTED); + events.Reset(); + + events.SetPhase(0); + } + + void DoAction(const int32 param) + { + switch(param) + { + case 1: //start event + { + events.SetPhase(1); + events.ScheduleEvent(EMBERSEER_EVENT_GROWING, 500, 0, 1); + events.ScheduleEvent(EMBERSEER_EVENT_TRANSFORM, 60000, 0, 1); + break; + } + } + BossAI::DoAction(param); + } + + void JustDied(Unit* killer) + { + events.Reset(); + pInstance->SetData(DATA_EMBERSEER, DONE); + + if (Creature *warden = GetClosestCreatureWithEntry(me, 99999, 60.0)) + warden->Kill(warden); + } + + void EnterEvadeMode() + { + me->CastSpell(me, SPELL_DESPAWN, false); + me->ForcedDespawn(); + pInstance->SetData(DATA_EMBERSEER, FAIL); + } + + void UpdateAI(const uint32 diff) + { + events.Update(diff); + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EMBERSEER_EVENT_GROWING: + { + me->CastSpell(me, SPELL_GROWING, true); + break; + } + case EMBERSEER_EVENT_TRANSFORM: + { + DoScriptText(-2100023, me); + DoScriptText(-2100024, me); + me->CastSpell(me, SPELL_TRANSFORM, true); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); + events.SetPhase(2); + events.ScheduleEvent(EMBERSEER_EVENT_FIRENOVA, 6000, 0, 2); + events.ScheduleEvent(EMBERSEER_EVENT_FLAMEBUFFET, 3000, 0, 2); + events.ScheduleEvent(EMBERSEER_EVENT_PYROBLAST, 14000, 0, 2); + break; + } + case EMBERSEER_EVENT_FIRENOVA: + { + AddSpellToCast(SPELL_FIRENOVA, CAST_SELF); + events.ScheduleEvent(EMBERSEER_EVENT_FIRENOVA, 6000, 0, 2); + break; + } + case EMBERSEER_EVENT_FLAMEBUFFET: + { + AddSpellToCast(SPELL_FLAMEBUFFET, CAST_TANK); + events.ScheduleEvent(EMBERSEER_EVENT_FLAMEBUFFET, 3000, 0, 2); + break; + } + case EMBERSEER_EVENT_PYROBLAST: + { + AddSpellToCast(SPELL_PYROBLAST, CAST_RANDOM); + events.ScheduleEvent(EMBERSEER_EVENT_PYROBLAST, 14000, 0, 2); + break; + } + } + } + + if (!UpdateVictim()) + { + return; + } + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_pyroguard_emberseer(Creature *_Creature) +{ + return new boss_pyroguard_emberseerAI (_Creature); +} + +void AddSC_boss_pyroguard_emberseer() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_pyroguard_emberseer"; + newscript->GetAI = &GetAI_boss_pyroguard_emberseer; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp index bf3acce70..6a12b0442 --- a/src/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_quartermaster_zigris.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_rend_blackhand.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_rend_blackhand.cpp index ecc60d00d..db14f9a2d --- a/src/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_rend_blackhand.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp index f1465f6fc..ce3f9f414 --- a/src/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_shadow_hunter_voshgajin.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_the_beast.cpp old mode 100755 new mode 100644 similarity index 84% rename from src/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_the_beast.cpp index 543607960..fce9569b4 --- a/src/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_the_beast.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -22,6 +25,7 @@ SDCategory: Blackrock Spire EndScriptData */ #include "precompiled.h" +#include "def_blackrock_spire.h" #define SPELL_FLAMEBREAK 16785 #define SPELL_IMMOLATE 20294 @@ -29,7 +33,12 @@ EndScriptData */ struct boss_thebeastAI : public ScriptedAI { - boss_thebeastAI(Creature *c) : ScriptedAI(c) {} + boss_thebeastAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; uint32 Flamebreak_Timer; uint32 Immolate_Timer; @@ -42,6 +51,7 @@ struct boss_thebeastAI : public ScriptedAI Immolate_Timer = 3000; TerrifyingRoar_Timer = 23000; checkTimer = 3000; + pInstance->SetData(DATA_THE_BEAST, NOT_STARTED); } void EnterCombat(Unit *who) @@ -55,6 +65,13 @@ struct boss_thebeastAI : public ScriptedAI EnterEvadeMode(); } + pInstance->SetData(DATA_THE_BEAST, IN_PROGRESS); + } + + void JustDied(Unit * killer) + { + if (pInstance) + pInstance->SetData(DATA_THE_BEAST, DONE); } void UpdateAI(const uint32 diff) diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_warmaster_voone.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_warmaster_voone.cpp index f6f3005e4..33a3cd3d7 --- a/src/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/boss_warmaster_voone.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/def_blackrock_spire.h b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/def_blackrock_spire.h new file mode 100644 index 000000000..fe2bf016b --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/def_blackrock_spire.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_BLACKROCK_SPIRE_H +#define SC_DEF_BLACKROCK_SPIRE_H + +#define DATA_RUNE_DOOR 0 +#define DATA_EMBERSEER 1 +#define DATA_THE_BEAST 2 + +#endif \ No newline at end of file diff --git a/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/instance_blackrock_spire.cpp b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/instance_blackrock_spire.cpp new file mode 100644 index 000000000..f19533bcc --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/blackrock_spire/instance_blackrock_spire.cpp @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2006-2007 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "precompiled.h" +#include "def_blackrock_spire.h" + +#define EMBERSEER_IN 175244 +#define EMBERSEER_OUT 175153 +#define BLACKROCK_ALTAR 175706 +#define BLACKHAND_INCARCERATOR 10316 +#define PYROGUARD_EMBERSEER 9816 + +#define ENCOUNTERS 3 + +struct instance_blackrock_spire : public ScriptedInstance +{ + instance_blackrock_spire(Map *map) : ScriptedInstance(map){}; + + uint32 Encounters[ENCOUNTERS]; + uint64 emberseerOut; + uint64 pyroguard_emberseerGUID; + + uint32 runesTimer; + std::set emberseerInDoorsGUID; + std::set runesDoorGUID; + std::set runesEmberGUID; + std::set channelersGUID; + + void Initialize() + { + for(uint8 i=0; i < ENCOUNTERS; ++i) + Encounters[i] = NOT_STARTED; + + runesDoorGUID.clear(); + runesEmberGUID.clear(); + emberseerInDoorsGUID.clear(); + channelersGUID.clear(); + emberseerOut = 0; + pyroguard_emberseerGUID = 0; + runesTimer = 3000; + } + + + void OnObjectCreate (GameObject* go) + { + switch(go->GetEntry()) + { + case 175194: + case 175195: + case 175196: + case 175197: + case 175198: + case 175199: + case 175200: + runesDoorGUID.insert(go->GetGUID()); + break; + + case 175187: + case 175267: + case 175268: + case 175269: + case 175270: + case 175271: + case 175272: + runesEmberGUID.insert(go->GetGUID()); + break; + + case EMBERSEER_IN: + emberseerInDoorsGUID.insert(go->GetGUID()); + if(GetData(DATA_RUNE_DOOR) == DONE) + HandleGameObject(go->GetGUID(), true); + break; + case EMBERSEER_OUT: + emberseerOut = go->GetGUID(); + if(GetData(DATA_EMBERSEER) == DONE) + HandleGameObject(emberseerOut, true); + break; + case BLACKROCK_ALTAR: + if(GetData(DATA_EMBERSEER) != NOT_STARTED) + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + break; + default: + break; + } + } + + void OnCreatureCreate(Creature *creature, uint32 entry) + { + switch (entry) + { + case PYROGUARD_EMBERSEER: + pyroguard_emberseerGUID = creature->GetGUID(); + break; + case BLACKHAND_INCARCERATOR: + channelersGUID.insert(creature->GetGUID()); + break; + default: + break; + } + } + + void Update(uint32 diff) + { + if(runesTimer <= diff && GetData(DATA_RUNE_DOOR) == NOT_STARTED) + { + bool runesUsed = false; + for(std::set::iterator i = runesDoorGUID.begin(); i != runesDoorGUID.end(); ++i) + { + if (GameObject* rune = instance->GetGameObject(*i)) + { + if (!(runesUsed = !(rune->GetGoState() == GO_STATE_ACTIVE))) + break; + } + } + + if(runesUsed) + { + SetData(DATA_RUNE_DOOR, DONE); + } + runesTimer = 3000; + } + else runesTimer -= diff; + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_RUNE_DOOR: + return Encounters[0]; + case DATA_EMBERSEER: + return Encounters[1]; + } + + return 0; + } + + void SetData (uint32 type, uint32 data) + { + switch(type) + { + case DATA_RUNE_DOOR: + { + if(Encounters[0] != DONE) + Encounters[0] = data; + + if(data == DONE) + { + for(std::set::iterator i = emberseerInDoorsGUID.begin(); i != emberseerInDoorsGUID.end(); ++i) + { + HandleGameObject(*i, true); + } + } + break; + } + case DATA_EMBERSEER: + { + if(Encounters[1] == DONE) return; + Encounters[1] = data; + + if(data == IN_PROGRESS && Encounters[0] != DONE) + LogPossibleCheaters("UBRS-Emberseer without runes"); + switch(data) + { + case IN_PROGRESS: + { + if(Creature *ember = GetCreature(pyroguard_emberseerGUID)) + { + ember->AI()->DoAction(1); + } + for(std::set::iterator i = emberseerInDoorsGUID.begin(); i != emberseerInDoorsGUID.end(); ++i) + { + HandleGameObject(*i , false); + } + for(std::set::iterator i = channelersGUID.begin(); i != channelersGUID.end(); ++i) + { + if(Creature * channeler = instance->GetCreature(*i)) + { + channeler->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); + channeler->FinishSpell(CURRENT_CHANNELED_SPELL); + channeler->AI()->DoZoneInCombat(); + } + } + for(std::set::iterator i = runesEmberGUID.begin(); i != runesEmberGUID.end(); ++i) + { + HandleGameObject(*i, true); + } + break; + } + case DONE: + { + HandleGameObject(emberseerOut, true); + } + case FAIL: + { + for(std::set::iterator i = emberseerInDoorsGUID.begin(); i != emberseerInDoorsGUID.end(); ++i) + { + HandleGameObject(*i, true); + } + for(std::set::iterator i = channelersGUID.begin(); i != channelersGUID.end(); ++i) + { + if(Creature * channeler = instance->GetCreature(*i)) + { + channeler->ForcedDespawn(); + } + } + for(std::set::iterator i = runesEmberGUID.begin(); i != runesEmberGUID.end(); ++i) + { + HandleGameObject(*i, false); + } + break; + } + } + break; + } + case DATA_THE_BEAST: + { + if(Encounters[2] != DONE) + Encounters[2] = data; + + if(data == IN_PROGRESS && Encounters[1] != DONE) + LogPossibleCheaters("UBRS-Beast without emberseer"); + } + } + + if (data == DONE || data == FAIL) + SaveToDB(); + } + + + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + + std::ostringstream stream; + stream << Encounters[0] << " "; + stream << Encounters[1] << " "; + stream << Encounters[2]; + + OUT_SAVE_INST_DATA_COMPLETE; + + return stream.str(); + } + + void Load(const char* in) + { + if (!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + + std::istringstream loadStream(in); + loadStream >> Encounters[0] >> Encounters[1] >> Encounters[2]; + + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounters[i] == IN_PROGRESS) + Encounters[i] = NOT_STARTED; + + OUT_LOAD_INST_DATA_COMPLETE; + + } + +}; + + + +InstanceData* GetInstanceData_instance_blackrock_spire(Map* map) +{ + return new instance_blackrock_spire(map); +} + +void AddSC_instance_blackrock_spire() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_blackrock_spire"; + newscript->GetInstanceData = &GetInstanceData_instance_blackrock_spire; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp index 83e722c89..642f5b04d --- a/src/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_broodlord_lashlayer.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_chromaggus.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_chromaggus.cpp index 9758d0f9f..a91352ed7 --- a/src/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_chromaggus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -231,8 +234,11 @@ struct boss_chromaggusAI : public ScriptedAI //Breath1_Timer if (Breath1_Timer < diff) { - DoCast(m_creature->getVictim(),Breath1_Spell); - Breath1_Timer = 60000; + if (Unit* target = m_creature->getVictim()) + { + DoCast(target,Breath1_Spell); + Breath1_Timer = 60000; + } } else Breath1_Timer -= diff; @@ -240,8 +246,11 @@ struct boss_chromaggusAI : public ScriptedAI //Breath2_Timer if (Breath2_Timer < diff) { - DoCast(m_creature->getVictim(),Breath2_Spell); - Breath2_Timer = 60000; + if (Unit* target = m_creature->getVictim()) + { + DoCast(m_creature->getVictim(),Breath2_Spell); + Breath2_Timer = 60000; + } } else Breath2_Timer -= diff; @@ -253,7 +262,7 @@ struct boss_chromaggusAI : public ScriptedAI SpellAfflict = RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, SPELL_BROODAF_RED, SPELL_BROODAF_BRONZE, SPELL_BROODAF_GREEN); - std::list::iterator i; + std::list::iterator i; for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end();) { diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_ebonroc.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_ebonroc.cpp index 670e4a49c..b3a7da95c --- a/src/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_ebonroc.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_firemaw.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_firemaw.cpp index 17cb1ef7e..eadb1843a --- a/src/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_firemaw.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_flamegor.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_flamegor.cpp index 62a17b72c..b2b8fe458 --- a/src/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_flamegor.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_nefarian.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_nefarian.cpp index 7fd8e1c7a..3c591c1d6 --- a/src/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_nefarian.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_razorgore.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_razorgore.cpp index d824c3e21..8bc40075a --- a/src/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_razorgore.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_vaelastrasz.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_vaelastrasz.cpp index 86f8de144..e33caae7d --- a/src/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_vaelastrasz.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -40,8 +43,8 @@ EndScriptData */ #define SPELL_BURNINGADRENALINE 23620 #define SPELL_CLEAVE 20684 //Chain cleave is most likely named something different and contains a dummy effect -#define QUEST_NEFARIUS_CORRUPTION 8730 -#define QUEST_THE_CHARGE_OF_THE_DRAGONFLIGHTS 8555 +#define QUEST_NEFARIUS_CORRUPTION 8730 +#define QUEST_THE_CHARGE_OF_THE_DRAGONFLIGHTS 8555 struct boss_vaelAI : public ScriptedAI { @@ -244,10 +247,10 @@ void SendDefaultMenu_boss_vael(Player *player, Creature *_Creature, uint32 actio player->CLOSE_GOSSIP_MENU(); ((boss_vaelAI*)_Creature->AI())->BeginSpeach((Unit*)player); } - else if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->PrepareQuestMenu(_Creature->GetGUID()); - player->SendPreparedQuest(_Creature->GetGUID()); + else if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->PrepareQuestMenu(_Creature->GetGUID()); + player->SendPreparedQuest(_Creature->GetGUID()); } } @@ -262,7 +265,7 @@ bool GossipSelect_boss_vael(Player *player, Creature *_Creature, uint32 sender, bool GossipHello_boss_vael(Player *player, Creature *_Creature) { player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - if ((player->GetQuestStatus(QUEST_THE_CHARGE_OF_THE_DRAGONFLIGHTS) == QUEST_STATUS_COMPLETE) && (player->GetQuestStatus(QUEST_NEFARIUS_CORRUPTION) == QUEST_STATUS_NONE)) + if ((player->GetQuestStatus(QUEST_THE_CHARGE_OF_THE_DRAGONFLIGHTS) == QUEST_STATUS_COMPLETE) && (player->GetQuestStatus(QUEST_NEFARIUS_CORRUPTION) == QUEST_STATUS_NONE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); player->SEND_GOSSIP_MENU(907,_Creature->GetGUID()); diff --git a/src/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_victor_nefarius.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_victor_nefarius.cpp index 9765ff02f..8c54612f5 --- a/src/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/boss_victor_nefarius.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blackwing_lair/def_blackwing_lair.h b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/def_blackwing_lair.h similarity index 100% rename from src/scripts/scripts/zone/blackwing_lair/def_blackwing_lair.h rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/def_blackwing_lair.h diff --git a/src/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/instance_blackwing_lair.cpp old mode 100755 new mode 100644 similarity index 87% rename from src/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp rename to src/scripts/scripts/Eastern Kingdoms/blackwing_lair/instance_blackwing_lair.cpp index ce5d06c42..928772462 --- a/src/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blackwing_lair/instance_blackwing_lair.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Blackwing_Lair diff --git a/src/scripts/scripts/zone/blasted_lands/blasted_lands.cpp b/src/scripts/scripts/Eastern Kingdoms/blasted_lands/blasted_lands.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/blasted_lands/blasted_lands.cpp rename to src/scripts/scripts/Eastern Kingdoms/blasted_lands/blasted_lands.cpp index 954792a10..19bedd071 --- a/src/scripts/scripts/zone/blasted_lands/blasted_lands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blasted_lands/blasted_lands.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/blasted_lands/boss_kruul.cpp b/src/scripts/scripts/Eastern Kingdoms/blasted_lands/boss_kruul.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/blasted_lands/boss_kruul.cpp rename to src/scripts/scripts/Eastern Kingdoms/blasted_lands/boss_kruul.cpp index cb319156a..bbe19c83c --- a/src/scripts/scripts/zone/blasted_lands/boss_kruul.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/blasted_lands/boss_kruul.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/burning_steppes/burning_steppes.cpp b/src/scripts/scripts/Eastern Kingdoms/burning_steppes/burning_steppes.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/burning_steppes/burning_steppes.cpp rename to src/scripts/scripts/Eastern Kingdoms/burning_steppes/burning_steppes.cpp index 38c4164eb..969878ccb --- a/src/scripts/scripts/zone/burning_steppes/burning_steppes.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/burning_steppes/burning_steppes.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -147,7 +150,7 @@ bool GOUse_go_proudtuskremains(Player *player, GameObject* _GO) if (!GetClosestCreatureWithEntry(_GO, NPC_SHANI_PROUDTUSK, 30.0f)) { float x,y,z; - player->GetClosePoint(x,y,z, 0.0f, 5.0f, frand(0, 2*M_PI)); + player->GetNearPoint(x,y,z, 0.0f, 5.0f, frand(0, 2*M_PI)); player->SummonCreature(NPC_SHANI_PROUDTUSK, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 120000); } else @@ -162,7 +165,7 @@ bool GOUse_go_proudtuskremains(Player *player, GameObject* _GO) // Spells #define SPELL_DRACO_INCARCINATRIX_900 16007 #define SPELL_CREATE_BROODLING_ESSENCE 16027 -#define SPELL_FIREBALL 13375 +#define SPELL_FIREBALL 13375 struct mob_broodlingessenceAI : public ScriptedAI { @@ -174,8 +177,8 @@ struct mob_broodlingessenceAI : public ScriptedAI void Reset() { - Fireball_Timer = 0; - onSpellEffect = false; + Fireball_Timer = 0; + onSpellEffect = false; } void EnterCombat(Unit *who){} @@ -183,18 +186,18 @@ struct mob_broodlingessenceAI : public ScriptedAI void SpellHit(Unit *caster, const SpellEntry *spell) { if(spell->Id == SPELL_DRACO_INCARCINATRIX_900) - { + { onSpellEffect = true; - } - } + } + } void JustDied(Unit* killer) { if(onSpellEffect) - { + { me->CastSpell(me, SPELL_CREATE_BROODLING_ESSENCE, true); - me->RemoveCorpse(); - } + me->RemoveCorpse(); + } } void UpdateAI(const uint32 diff) @@ -206,7 +209,7 @@ struct mob_broodlingessenceAI : public ScriptedAI //Fireball_Timer if (Fireball_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_FIREBALL); + DoCast(m_creature->getVictim(),SPELL_FIREBALL); Fireball_Timer = 10000; } else diff --git a/src/scripts/scripts/zone/deadmines/deadmines.cpp b/src/scripts/scripts/Eastern Kingdoms/deadmines/deadmines.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/deadmines/deadmines.cpp rename to src/scripts/scripts/Eastern Kingdoms/deadmines/deadmines.cpp index af8cc7971..6a073e6f0 --- a/src/scripts/scripts/zone/deadmines/deadmines.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/deadmines/deadmines.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/deadmines/def_deadmines.h b/src/scripts/scripts/Eastern Kingdoms/deadmines/def_deadmines.h new file mode 100644 index 000000000..7d183930d --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/deadmines/def_deadmines.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_DEADMINES_H +#define SC_DEF_DEADMINES_H + +#include "precompiled.h" + +#define CANNON_NOT_USED 1 +#define CANNON_GUNPOWDER_USED 2 +#define CANNON_BLAST_INITIATED 3 +#define PIRATES_ATTACK 4 +#define EVENT_DONE 5 + +#define EVENT_STATE 1 +#endif + diff --git a/src/scripts/scripts/zone/deadmines/instance_deadmines.cpp b/src/scripts/scripts/Eastern Kingdoms/deadmines/instance_deadmines.cpp old mode 100755 new mode 100644 similarity index 100% rename from src/scripts/scripts/zone/deadmines/instance_deadmines.cpp rename to src/scripts/scripts/Eastern Kingdoms/deadmines/instance_deadmines.cpp diff --git a/src/scripts/scripts/zone/dun_morogh/dun_morogh.cpp b/src/scripts/scripts/Eastern Kingdoms/dun_morogh/dun_morogh.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/dun_morogh/dun_morogh.cpp rename to src/scripts/scripts/Eastern Kingdoms/dun_morogh/dun_morogh.cpp index efd9f4a97..2adc3c527 --- a/src/scripts/scripts/zone/dun_morogh/dun_morogh.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/dun_morogh/dun_morogh.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/duskwood/duskwood.cpp b/src/scripts/scripts/Eastern Kingdoms/duskwood/duskwood.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/duskwood/duskwood.cpp rename to src/scripts/scripts/Eastern Kingdoms/duskwood/duskwood.cpp index e3da3106e..910b9c2c2 --- a/src/scripts/scripts/zone/duskwood/duskwood.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/duskwood/duskwood.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -39,7 +42,6 @@ bool AreaTrigger_at_twilight_grove(Player* pPlayer, AreaTriggerEntry const* at) if(TCorrupter) { TCorrupter->setFaction(14); - TCorrupter->SetMaxHealth(832750 * sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.HP", 1.0f)); CorrupterSummoned = true; } Unit* CorrupterSpeaker = pPlayer->SummonCreature(1,pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ()-1,0,TEMPSUMMON_TIMED_DESPAWN,15000); diff --git a/src/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp b/src/scripts/scripts/Eastern Kingdoms/eastern_plaguelands/eastern_plaguelands.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp rename to src/scripts/scripts/Eastern Kingdoms/eastern_plaguelands/eastern_plaguelands.cpp index 5e702d457..5f8f5c1b8 --- a/src/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/eastern_plaguelands/eastern_plaguelands.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -226,7 +229,7 @@ struct trigger_epic_staffAI : public TriggerAI for(int i = 0; i<3; i++) { float x,y,z; - me->GetClosePoint(x,y,z, 0.0f, 7.0f, frand(0, 2*M_PI)); + me->GetNearPoint(x,y,z, 0.0f, 7.0f, frand(0, 2*M_PI)); me->SummonCreature(NPC_SCOURGE_FOOTSOLDIER, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000); } Summon_Footsoldier_Timer = 20000; @@ -238,13 +241,13 @@ struct trigger_epic_staffAI : public TriggerAI for(int i = 0; i < 9; i++) { float x,y,z; - me->GetClosePoint(x,y,z, 0.0f, 6.0f, frand(0, 2*M_PI)); + me->GetNearPoint(x,y,z, 0.0f, 6.0f, frand(0, 2*M_PI)); me->SummonCreature(NPC_INJURED_PEASANT, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 45000); } for(int i = 0; i < 3; i++) { float x,y,z; - me->GetClosePoint(x,y,z, 0.0f, 6.0f, frand(0, 2*M_PI)); + me->GetNearPoint(x,y,z, 0.0f, 6.0f, frand(0, 2*M_PI)); me->SummonCreature(NPC_PLAGUED_PEASANT, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 45000); } Summon_Timer = 40000; diff --git a/src/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp b/src/scripts/scripts/Eastern Kingdoms/elwynn_forest/elwynn_forest.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp rename to src/scripts/scripts/Eastern Kingdoms/elwynn_forest/elwynn_forest.cpp index 1bbad7e56..adc34fc05 --- a/src/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/elwynn_forest/elwynn_forest.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/eversong_woods/eversong_woods.cpp b/src/scripts/scripts/Eastern Kingdoms/eversong_woods/eversong_woods.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/eversong_woods/eversong_woods.cpp rename to src/scripts/scripts/Eastern Kingdoms/eversong_woods/eversong_woods.cpp index ac64a7e08..e5958694e --- a/src/scripts/scripts/zone/eversong_woods/eversong_woods.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/eversong_woods/eversong_woods.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -47,7 +50,7 @@ struct mobs_mana_tappedAI : public ScriptedAI { if( caster->GetTypeId() == TYPEID_PLAYER) if( ((Player*)caster)->GetQuestStatus(8346) == QUEST_STATUS_INCOMPLETE && !((Player*)caster)->GetReqKillOrCastCurrentCount(8346, m_creature->GetEntry()) && spell->Id == 28734) - ((Player*)caster)->CastedCreatureOrGO(15468, m_creature->GetGUID(), spell->Id); + ((Player*)caster)->CastCreatureOrGO(15468, m_creature->GetGUID(), spell->Id); return; } }; diff --git a/src/scripts/scripts/zone/ghostlands/ghostlands.cpp b/src/scripts/scripts/Eastern Kingdoms/ghostlands/ghostlands.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/ghostlands/ghostlands.cpp rename to src/scripts/scripts/Eastern Kingdoms/ghostlands/ghostlands.cpp index 17ad2ce05..d28ac8f2e --- a/src/scripts/scripts/zone/ghostlands/ghostlands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/ghostlands/ghostlands.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/hinterlands/hinterlands.cpp b/src/scripts/scripts/Eastern Kingdoms/hinterlands/hinterlands.cpp similarity index 75% rename from src/scripts/scripts/zone/hinterlands/hinterlands.cpp rename to src/scripts/scripts/Eastern Kingdoms/hinterlands/hinterlands.cpp index 95884cde1..176b341d8 100644 --- a/src/scripts/scripts/zone/hinterlands/hinterlands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/hinterlands/hinterlands.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -56,6 +58,19 @@ struct npc_00x09hlAI : public npc_escortAI void Reset() { } + void EnterCombat(Unit* pWho) + { + if (pWho->GetEntry() == NPC_MARAUDING_OWL || pWho->GetEntry() == NPC_VILE_AMBUSHER) + return; + + DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), me); + } + + void JustSummoned(Creature* pSummoned) + { + pSummoned->AI()->AttackStart(me); + } + void WaypointReached(uint32 uiPointId) { Player* pPlayer = GetPlayerForEscort(); @@ -66,34 +81,59 @@ struct npc_00x09hlAI : public npc_escortAI { case 26: DoScriptText(SAY_OOX_AMBUSH, me); + break; + case 27: for (uint8 i = 0; i < 3; ++i) - me->SummonCreature(NPC_MARAUDING_OWL, 178.111f, -3801.58f, 128.37f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); + { + float x, y, z; + switch (i) + { + case 0: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 0.0f); + me->SummonCreature(NPC_MARAUDING_OWL, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 1: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 2.0f); + me->SummonCreature(NPC_MARAUDING_OWL, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 2: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 4.0f); + me->SummonCreature(NPC_MARAUDING_OWL, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + } break; - case 43: + case 44: DoScriptText(SAY_OOX_AMBUSH, me); + break; + case 45: for (uint8 i = 0; i < 3; ++i) - me->SummonCreature(NPC_VILE_AMBUSHER, -116.258f, -4211.96f, 121.878f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); + { + float x, y, z; + switch (i) + { + case 0: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 0.0f); + me->SummonCreature(NPC_VILE_AMBUSHER, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 1: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 2.0f); + me->SummonCreature(NPC_VILE_AMBUSHER, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 2: + me->GetNearPoint( x, y, z, 0.0f, 15.0f, 4.0f); + me->SummonCreature(NPC_VILE_AMBUSHER, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + } break; - case 64: + case 66: DoScriptText(SAY_OOX_END, me); if (Player* pPlayer = GetPlayerForEscort()) pPlayer->GroupEventHappens(QUEST_RESQUE_OOX_09, me); break; } } - - void EnterCombat(Unit* pWho) - { - if (pWho->GetEntry() == NPC_MARAUDING_OWL || pWho->GetEntry() == NPC_VILE_AMBUSHER) - return; - - DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), me); - } - - void JustSummoned(Creature* pSummoned) - { - pSummoned->AI()->AttackStart(me); - } }; bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest* pQuest) @@ -101,14 +141,10 @@ bool QuestAccept_npc_00x09hl(Player* pPlayer, Creature* pCreature, const Quest* if (pQuest->GetQuestId() == QUEST_RESQUE_OOX_09) { pCreature->SetStandState(UNIT_STAND_STATE_STAND); - pCreature->setFaction(113); - pCreature->SetHealth(pCreature->GetMaxHealth()); - pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); - DoScriptText(SAY_OOX_START, pCreature); if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hlAI, pCreature->AI())) - pEscortAI->Start(false, true, pPlayer->GetGUID(), pQuest); + pEscortAI->Start(true, true, pPlayer->GetGUID(), pQuest); } return true; } diff --git a/src/scripts/scripts/zone/ironforge/ironforge.cpp b/src/scripts/scripts/Eastern Kingdoms/ironforge/ironforge.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/ironforge/ironforge.cpp rename to src/scripts/scripts/Eastern Kingdoms/ironforge/ironforge.cpp index 674bf56bb..abb5de5bf --- a/src/scripts/scripts/zone/ironforge/ironforge.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/ironforge/ironforge.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp b/src/scripts/scripts/Eastern Kingdoms/isle_of_queldanas/isle_of_queldanas.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp rename to src/scripts/scripts/Eastern Kingdoms/isle_of_queldanas/isle_of_queldanas.cpp index a1031600a..fb61cfe4c --- a/src/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/isle_of_queldanas/isle_of_queldanas.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -35,7 +38,7 @@ EndContentData */ #include "GameEvent.h" /*###### -## npc_archmage_nethul (also used by Vindicator Moorba) +## npc_archmage_nethul ######*/ #define GOSSIP_SWP_STATE "What is the current progress on Sunwell's offensive?" @@ -54,9 +57,6 @@ bool GossipHello_npc_archmage_nethul(Player *player, Creature *_Creature) } } player->SEND_GOSSIP_MENU(12309,_Creature->GetGUID()); - // for Vindicator Moorba when gates event in SWP is finished - if(isGameEventActive(54) && _Creature->GetEntry() == 25632) - player->SEND_GOSSIP_MENU(12403,_Creature->GetGUID()); return true; } @@ -80,6 +80,8 @@ bool GossipSelect_npc_archmage_nethul(Player *player, Creature *_Creature, uint3 HandleWorldEventGossip(player, _Creature); player->SEND_GOSSIP_MENU(12403, _Creature->GetGUID()); break; + default: + break; } return true; } @@ -477,7 +479,7 @@ struct npc_flame_waveAI : public ScriptedAI float x, y, z; me->SetWalk(true); me->SetSpeed(MOVE_WALK, 1.7); - me->GetNearPoint(me, x, y, z, 0, 20, summoner->GetAngle(me)); + me->GetNearPoint( x, y, z, 0, 20, summoner->GetAngle(me)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(1, x, y, z); } @@ -797,7 +799,7 @@ struct npc_greengill_slaveAI : public ScriptedAI else { float x, y, z; - me->GetNearPoint(me, x, y, z, 0, 50, frand(0,2*M_PI)); + me->GetNearPoint( x, y, z, 0, 50, frand(0,2*M_PI)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(1, x, y, z); } @@ -811,7 +813,7 @@ struct npc_greengill_slaveAI : public ScriptedAI { me->CombatStop(); float x, y, z; - me->GetNearPoint(me, x, y, z, 0, 15, frand(0,2*M_PI)); + me->GetNearPoint( x, y, z, 0, 15, frand(0,2*M_PI)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(1, x, y, z); enrageTimer = 60000; diff --git a/src/scripts/scripts/zone/karazhan/boss_curator.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_curator.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/karazhan/boss_curator.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_curator.cpp index 14e80b949..5f7b97355 --- a/src/scripts/scripts/zone/karazhan/boss_curator.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_curator.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_maiden_of_virtue.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_maiden_of_virtue.cpp index bda031d2d..6b93abd1c --- a/src/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_maiden_of_virtue.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/karazhan/boss_midnight.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_midnight.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/karazhan/boss_midnight.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_midnight.cpp index f708b3cfc..ad6ff7e0b --- a/src/scripts/scripts/zone/karazhan/boss_midnight.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_midnight.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_moroes.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/karazhan/boss_moroes.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_moroes.cpp index 6ec8c41d4..9915aa371 --- a/src/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_moroes.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -77,10 +80,12 @@ struct boss_moroesAI : public ScriptedAI uint32 Blind_Timer; uint32 Gouge_Timer; uint32 Wait_Timer; + uint32 NonAttackable_Timer; uint32 CheckAdds_Timer; uint32 AddId[4]; bool InVanish; + bool NonAttackable; bool Enrage; void Reset() @@ -89,14 +94,21 @@ struct boss_moroesAI : public ScriptedAI Blind_Timer = 35000; Gouge_Timer = 23000; Wait_Timer = 0; + NonAttackable_Timer = 0; CheckAdds_Timer = 5000; Enrage = false; InVanish = false; + NonAttackable = false; if(m_creature->GetHealth() > 0) { SpawnAdds(); } + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + if(pInstance && pInstance->GetData(DATA_MOROES_EVENT) != DONE) pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); } @@ -280,6 +292,9 @@ struct boss_moroesAI : public ScriptedAI { DoCast(m_creature, SPELL_VANISH); InVanish = true; + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + NonAttackable = true; + NonAttackable_Timer = 12100; Vanish_Timer = 30000; Wait_Timer = 5000; } @@ -322,6 +337,15 @@ struct boss_moroesAI : public ScriptedAI if(!InVanish) DoMeleeAttackIfReady(); + + if(NonAttackable) + { + if(NonAttackable_Timer < diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + NonAttackable = false; + } else NonAttackable_Timer -= diff; + } } }; diff --git a/src/scripts/scripts/zone/karazhan/boss_netherspite.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_netherspite.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/karazhan/boss_netherspite.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_netherspite.cpp index 2a413405f..06702b9d2 --- a/src/scripts/scripts/zone/karazhan/boss_netherspite.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_netherspite.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + /* ScriptData SDName: Boss_Netherspite SD%Complete: 90 @@ -139,7 +157,7 @@ struct boss_netherspiteAI : public ScriptedAI { if(Creature *portal = Unit::GetCreature(*m_creature, PortalGUID[j])) { - // the one who's been casted upon before + // the one who's been cast upon before Unit *current = Unit::GetUnit(*portal, BeamTarget[j]); // temporary store for the best suitable beam reciever Unit *target = m_creature; @@ -309,7 +327,7 @@ struct boss_netherspiteAI : public ScriptedAI if(PhaseTimer < diff) { - if(!m_creature->IsNonMeleeSpellCasted(false)) + if(!m_creature->IsNonMeleeSpellCast(false)) { SwitchToBanishPhase(); return; @@ -341,7 +359,7 @@ struct boss_netherspiteAI : public ScriptedAI if(PhaseTimer < diff) { - if(!m_creature->IsNonMeleeSpellCasted(false)) + if(!m_creature->IsNonMeleeSpellCast(false)) { SwitchToPortalPhase(); return; diff --git a/src/scripts/scripts/zone/karazhan/boss_nightbane.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_nightbane.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/karazhan/boss_nightbane.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_nightbane.cpp index 70783d2d3..b7662431e --- a/src/scripts/scripts/zone/karazhan/boss_nightbane.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_nightbane.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_prince_malchezaar.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_prince_malchezaar.cpp index cf7d49966..3b102459f --- a/src/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_prince_malchezaar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -99,7 +102,12 @@ static InfernalPoint InfernalPoints[] = struct netherspite_infernalAI : public Scripted_NoMovementAI { netherspite_infernalAI(Creature *c) : Scripted_NoMovementAI(c) , - malchezaarGUID(0), HellfireTimer(0), CleanupTimer(0), point(NULL) {} + malchezaarGUID(0), HellfireTimer(0), CleanupTimer(0), point(NULL) + { + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_CASTING_SPEED, true); + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_HASTE_SPELLS, true); + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_STUN, true); + } uint32 HellfireTimer; uint32 CleanupTimer; @@ -329,14 +337,14 @@ struct boss_malchezaarAI : public ScriptedAI if(!info) return; - std::list t_list = m_creature->getThreatManager().getThreatList(); + std::list t_list = m_creature->getThreatManager().getThreatList(); std::vector targets; if(!t_list.size()) return; //begin + 1 , so we don't target the one with the highest threat - std::list::iterator itr = t_list.begin(); + std::list::iterator itr = t_list.begin(); std::advance(itr, 1); for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container { @@ -390,7 +398,6 @@ struct boss_malchezaarAI : public ScriptedAI { std::vector::iterator itr = positions.begin()+rand()%positions.size(); point = *itr; - positions.erase(itr); posX = point->x; posY = point->y; @@ -651,7 +658,7 @@ struct boss_malchezaarAI : public ScriptedAI void DoMeleeAttacksIfReady() { - if( m_creature->IsWithinMeleeRange(m_creature->getVictim()) && !m_creature->IsNonMeleeSpellCasted(false)) + if( m_creature->IsWithinMeleeRange(m_creature->getVictim()) && !m_creature->IsNonMeleeSpellCast(false)) { //Check for base attack if( m_creature->isAttackReady() && m_creature->getVictim() ) diff --git a/src/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_shade_of_aran.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_shade_of_aran.cpp index 548d29861..c8a365ca0 --- a/src/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_shade_of_aran.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -22,7 +25,7 @@ SDCategory: Karazhan EndScriptData */ #include "precompiled.h" -#include "../../creature/simple_ai.h" +#include "../../special/simple_ai.h" #include "def_karazhan.h" #include "GameObject.h" @@ -109,6 +112,10 @@ struct boss_aranAI : public ScriptedAI { pInstance = (c->GetInstanceData()); m_creature->GetPosition(wLoc); + + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_CASTING_SPEED, true); + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_HASTE_SPELLS, true); + me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_SILENCE, true); } ScriptedInstance* pInstance; @@ -288,7 +295,7 @@ struct boss_aranAI : public ScriptedAI //Normal casts if (NormalCastTimer < diff) { - if (!m_creature->IsNonMeleeSpellCasted(false)) + if (!m_creature->IsNonMeleeSpellCast(false)) { uint32 Spells[3]; uint8 AvailableSpells = 0; @@ -447,10 +454,10 @@ struct boss_aranAI : public ScriptedAI void SpellHit(Unit* pAttacker, const SpellEntry* spellEntry) { - //We only care about inturrupt effects and only if they are durring a spell currently being casted + //We only care about inturrupt effects and only if they are durring a spell currently being cast if ((spellEntry->Effect[0] != SPELL_EFFECT_INTERRUPT_CAST && spellEntry->Effect[1] != SPELL_EFFECT_INTERRUPT_CAST && - spellEntry->Effect[2] != SPELL_EFFECT_INTERRUPT_CAST) || !m_creature->IsNonMeleeSpellCasted(false)) + spellEntry->Effect[2] != SPELL_EFFECT_INTERRUPT_CAST) || !m_creature->IsNonMeleeSpellCast(false)) return; //Normally we would set the cooldown equal to the spell duration diff --git a/src/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_terestian_illhoof.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/boss_terestian_illhoof.cpp index efcc84bca..5047ac3e9 --- a/src/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/boss_terestian_illhoof.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -128,7 +131,7 @@ struct mob_kilrekAI : public ScriptedAI }else AmplifyTimer -= diff; //Chain cast - if (!m_creature->IsNonMeleeSpellCasted(false) && m_creature->IsWithinDistInMap(m_creature->getVictim(), 30)) + if (!m_creature->IsNonMeleeSpellCast(false) && m_creature->IsWithinDistInMap(m_creature->getVictim(), 30)) DoCast(m_creature->getVictim(),SPELL_FIREBOLT); else DoMeleeAttackIfReady(); } diff --git a/src/scripts/scripts/zone/karazhan/bosses_opera.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/bosses_opera.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/karazhan/bosses_opera.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/bosses_opera.cpp index 9c4654f73..ad2f23b17 --- a/src/scripts/scripts/zone/karazhan/bosses_opera.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/bosses_opera.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -1588,7 +1591,7 @@ struct npc_barnesAI : public ScriptedAI operaAdds.DespawnAll(); - if(pInstance) + if (pInstance && pInstance->GetData(DATA_OPERA_EVENT) != DONE) { Event = pInstance->GetData(DATA_OPERA_PERFORMANCE); diff --git a/src/scripts/scripts/zone/karazhan/chess_event.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.cpp similarity index 99% rename from src/scripts/scripts/zone/karazhan/chess_event.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.cpp index 45721ad22..b3120f9ea 100644 --- a/src/scripts/scripts/zone/karazhan/chess_event.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "chess_event.h" @@ -3020,7 +3038,8 @@ void boss_MedivhAI::SetOrientation(uint64 piece, ChessOrientation ori) if (tmpPiece) { pieceOri = tmpPiece->GetOrientation(); - + if (pieceOri <0) + pieceOri += 2* M_PI; if (pieceOri > ORI_N && pieceOri <= ORI_W) { tmpN = pieceOri - ORI_N; diff --git a/src/scripts/scripts/zone/karazhan/chess_event.h b/src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.h similarity index 95% rename from src/scripts/scripts/zone/karazhan/chess_event.h rename to src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.h index f25a65cca..3ae4200c8 100644 --- a/src/scripts/scripts/zone/karazhan/chess_event.h +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/chess_event.h @@ -1,5 +1,23 @@ -#ifndef CHESS_EVENT -#define CHESS_EVENT +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_CHESS_EVENT_H +#define SC_CHESS_EVENT_H /* ScriptData SDName: Chess_Event @@ -459,7 +477,7 @@ class npc_chesspieceAI : public Scripted_NoMovementAI void EnterEvadeMode(); void SetSpellsAndCooldowns(); - bool IsOnSelfSpell(uint32 spell); // check if spell can be only casted on self (like absorb) + bool IsOnSelfSpell(uint32 spell); // check if spell can be only cast on self (like absorb) bool IsHealingSpell(uint32 spell); bool IsNullTargetSpell(uint32 spell); diff --git a/src/scripts/scripts/zone/karazhan/def_karazhan.h b/src/scripts/scripts/Eastern Kingdoms/karazhan/def_karazhan.h similarity index 67% rename from src/scripts/scripts/zone/karazhan/def_karazhan.h rename to src/scripts/scripts/Eastern Kingdoms/karazhan/def_karazhan.h index 2bc36348d..216d549b3 100644 --- a/src/scripts/scripts/zone/karazhan/def_karazhan.h +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/def_karazhan.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_KARAZHAN_H -#define DEF_KARAZHAN_H +#ifndef SC_DEF_KARAZHAN_H +#define SC_DEF_KARAZHAN_H #define DATA_ATTUMEN_EVENT 1 #define DATA_MOROES_EVENT 2 diff --git a/src/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.cpp similarity index 96% rename from src/scripts/scripts/zone/karazhan/instance_karazhan.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.cpp index f9f563141..4b499cf42 100644 --- a/src/scripts/scripts/zone/karazhan/instance_karazhan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -128,6 +131,14 @@ uint32 GetEncounterForEntry(uint32 entry) } } +void instance_karazhan::HandleInitCreatureState(Creature * mob) +{ + if (!mob->GetTerrain()->IsLineOfSightEnabled()) + mob->SetAggroRange(15); + + InstanceData::HandleInitCreatureState(mob); +} + void instance_karazhan::OnCreatureCreate(Creature *creature, uint32 entry) { uint32 data = 0; @@ -157,18 +168,7 @@ void instance_karazhan::OnCreatureCreate(Creature *creature, uint32 entry) break; } - if (!creature->GetTerrain()->IsLineOfSightEnabled()) - creature->SetAggroRange(15); - - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } uint64 instance_karazhan::GetData64(uint32 data) diff --git a/src/scripts/scripts/zone/karazhan/instance_karazhan.h b/src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.h similarity index 97% rename from src/scripts/scripts/zone/karazhan/instance_karazhan.h rename to src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.h index ad589d72a..00d181013 100644 --- a/src/scripts/scripts/zone/karazhan/instance_karazhan.h +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/instance_karazhan.h @@ -79,6 +79,8 @@ struct instance_karazhan : public ScriptedInstance void Load(const char* in); + void HandleInitCreatureState(Creature * mob); + void Update(uint32 diff); }; diff --git a/src/scripts/scripts/zone/karazhan/karazhan.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/karazhan/karazhan.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan.cpp index e3d6726ba..dd2502100 --- a/src/scripts/scripts/zone/karazhan/karazhan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan.cpp @@ -1,4 +1,7 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 + /* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/karazhan/karazhan_trash.cpp b/src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan_trash.cpp similarity index 93% rename from src/scripts/scripts/zone/karazhan/karazhan_trash.cpp rename to src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan_trash.cpp index 1e747407f..02fba54a7 100644 --- a/src/scripts/scripts/zone/karazhan/karazhan_trash.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/karazhan/karazhan_trash.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_karazhan.h" @@ -313,7 +331,7 @@ struct mob_mana_warpAI : public ScriptedAI void DamageTaken(Unit* pDone_by, uint32& uiDamage) { - if(me->IsNonMeleeSpellCasted(true) && uiDamage > me->GetHealth()) + if(me->IsNonMeleeSpellCast(true) && uiDamage > me->GetHealth()) uiDamage = me->GetHealth() - 1; } diff --git a/src/scripts/scripts/zone/loch_modan/loch_modan.cpp b/src/scripts/scripts/Eastern Kingdoms/loch_modan/loch_modan.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/loch_modan/loch_modan.cpp rename to src/scripts/scripts/Eastern Kingdoms/loch_modan/loch_modan.cpp index d79f581d1..80751cf20 --- a/src/scripts/scripts/zone/loch_modan/loch_modan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/loch_modan/loch_modan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp index e77bd536c..30173800b --- a/src/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_felblood_kaelthas.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -275,7 +278,7 @@ struct boss_felblood_kaelthasAI : public ScriptedAI return; } - if(!UpdateVictim()) + if(!UpdateVictim() && Phase != 2) return; if(CheckTimer < diff) @@ -554,26 +557,25 @@ struct mob_arcane_sphereAI : public ScriptedAI { DoZoneInCombat(); m_creature->SetLevitate(true); - m_creature->SetSpeed(MOVE_FLIGHT, 0.5); + m_creature->SetSpeed(MOVE_FLIGHT, 0.6); DoCast(m_creature, SPELL_ARCANE_SPHERE_PASSIVE, true); - if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true)) - { - AttackStart(target); - me->AddThreat(target, 50000.0); - } DespawnTimer = 29000; - ChangeTargetTimer = 5000; + ChangeTargetTimer = 1000; CheckTimer = 1000; } - void UpdateAI(const uint32 diff) + void MovementInform(uint32 Type, uint32 Id) { - if(!UpdateVictim()) - ChangeTargetTimer = 0; + if(Type == POINT_MOTION_TYPE) + if(Id == 1) + ChangeTargetTimer = 0; + } + void UpdateAI(const uint32 diff) + { if(CheckTimer < diff) { - m_creature->SetSpeed(MOVE_FLIGHT, 0.5); // to be tested + m_creature->SetSpeed(MOVE_FLIGHT, 0.6); // to be tested if(pInstance && pInstance->GetData(DATA_KAELTHAS_EVENT) != IN_PROGRESS) DespawnTimer = 0; CheckTimer = 1000; @@ -582,7 +584,9 @@ struct mob_arcane_sphereAI : public ScriptedAI CheckTimer -= diff; if(DespawnTimer < diff) - me->Kill(me, false); + { + me->DisappearAndDie(); + } else DespawnTimer -= diff; @@ -590,10 +594,7 @@ struct mob_arcane_sphereAI : public ScriptedAI { DoResetThreat(); if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) - { - AttackStart(target); - me->AddThreat(target, 50000.0); - } + me->GetMotionMaster()->MovePoint(1, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false, true, UNIT_ACTION_DOWAYPOINTS); ChangeTargetTimer = 7000; // to be tested } else diff --git a/src/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_priestess_delrissa.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_priestess_delrissa.cpp index 07ee1397f..f7d859e86 --- a/src/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_priestess_delrissa.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -706,7 +709,7 @@ struct boss_kagani_nightstrikeAI : public boss_priestess_guestAI if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) { float x, y, z; - me->GetNearPoint(target, x, y, z, 0, 5.0, frand(0, 2*M_PI)); + me->GetNearPoint(x, y, z, 0, 5.0, frand(0, 2*M_PI)); AttackStart(target); me->AddThreat(target, 10000); me->GetMotionMaster()->MovePoint(0, x, y, z); @@ -729,7 +732,7 @@ struct boss_kagani_nightstrikeAI : public boss_priestess_guestAI Kick_Cooldown -= diff; } - if(canKick && (me->getVictim()->IsNonMeleeSpellCasted(true) || roll_chance_f(15.0))) + if(canKick && (me->getVictim()->IsNonMeleeSpellCast(true) || roll_chance_f(15.0))) { if(me->IsWithinMeleeRange(me->getVictim())) { @@ -946,7 +949,7 @@ struct mob_fizzleAI : public ScriptedAI #define SPELL_KNOCKDOWN (HeroicMode?46183:11428) #define SPELL_SNAP_KICK 46182 #define SPELL_FISTS_OF_ARCANE_FURY 44120 -#define SPELL_CHACRA_DRAIN 44121 +#define SPELL_HEALING_POTION 15503 struct boss_eramas_brightblazeAI : public boss_priestess_guestAI { @@ -1007,7 +1010,7 @@ struct boss_eramas_brightblazeAI : public boss_priestess_guestAI if(ChacraDrain_Timer < diff) { if(HeroicMode) - AddSpellToCast(SPELL_CHACRA_DRAIN, CAST_RANDOM); + AddSpellToCast(SPELL_HEALING_POTION, CAST_SELF); ChacraDrain_Timer = urand(10000, 20000); } else @@ -1148,7 +1151,7 @@ struct boss_yazzaiAI : public boss_priestess_guestAI if(!canBlink) { float x, y, z; - me->GetClosePoint(x, y, z, 0, 7.0, frand(0, 2*M_PI)); + me->GetNearPoint(x, y, z, 0, 7.0, frand(0, 2*M_PI)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(1, x, y, z); } @@ -1216,7 +1219,7 @@ struct boss_yazzaiAI : public boss_priestess_guestAI #define SPELL_INTERCEPT 27577 #define SPELL_DISARM 27581 #define SPELL_PIERCING_HOWL 23600 -#define SPELL_FRIGHTENING_SHOUT 19134 +#define SPELL_PSYCHIC_SCREAM 27610 #define SPELL_HAMSTRING 27584 #define SPELL_MORTAL_STRIKE 44268 @@ -1320,7 +1323,7 @@ struct boss_warlord_salarisAI : public boss_priestess_guestAI if(Frightening_Shout_Timer < diff) { - AddSpellToCast(SPELL_FRIGHTENING_SHOUT, CAST_NULL); + AddSpellToCast(SPELL_PSYCHIC_SCREAM, CAST_NULL); Frightening_Shout_Timer = urand(15000, 40000); } else @@ -1392,7 +1395,7 @@ struct boss_garaxxasAI : public boss_priestess_guestAI if(!Sliver) { float x, y, z; - me->GetNearPoint(me, x, y, z, 0, 3.0, frand(0, 2*M_PI)); + me->GetNearPoint( x, y, z, 0, 3.0, frand(0, 2*M_PI)); Creature* Sliver = m_creature->SummonCreature(NPC_SLIVER, x, y, z, me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); } @@ -1400,7 +1403,7 @@ struct boss_garaxxasAI : public boss_priestess_guestAI { ((Creature*)Sliver)->RemoveCorpse(); float x, y, z; - me->GetNearPoint(me, x, y, z, 0, 3.0, frand(0, 2*M_PI)); + me->GetNearPoint( x, y, z, 0, 3.0, frand(0, 2*M_PI)); Creature* Sliver = m_creature->SummonCreature(NPC_SLIVER, x, y, z, me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000); } GetSliver_Timer = 15000; @@ -1457,7 +1460,7 @@ struct boss_garaxxasAI : public boss_priestess_guestAI { ForceSpellCast(SPELL_WING_CLIP, CAST_TANK, INTERRUPT_AND_CAST); float x, y, z; - me->GetClosePoint(x, y, z, 0, 9.0, frand(0, 2*M_PI)); + me->GetNearPoint(x, y, z, 0, 9.0, frand(0, 2*M_PI)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(2, x, y, z); canWingClip = false; diff --git a/src/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_selin_fireheart.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_selin_fireheart.cpp index dae58f45e..020e7b97f --- a/src/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_selin_fireheart.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -125,7 +128,7 @@ struct boss_selin_fireheartAI : public ScriptedAI z = 4; break; default: - CrystalChosen->GetClosePoint(x, y, z, m_creature->GetObjectSize(), CONTACT_DISTANCE); + CrystalChosen->GetNearPoint(x, y, z, m_creature->GetObjectSize(), CONTACT_DISTANCE); } m_creature->SetWalk(false); @@ -264,7 +267,7 @@ struct boss_selin_fireheartAI : public ScriptedAI if(DrainCrystalTimer < diff) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) return; SelectNearestCrystal(); DrainCrystalTimer = HeroicMode? 13000 : 18000; @@ -320,7 +323,7 @@ struct mob_fel_crystalAI : public ScriptedAI uint32 data = pInstance->GetData(DATA_SELIN_EVENT); if(data == IN_PROGRESS) me->InterruptNonMeleeSpells(true, SPELL_FEL_CRYSTAL_VISUAL); - else if(data == NOT_STARTED && !me->IsNonMeleeSpellCasted(true)) + else if(data == NOT_STARTED && !me->IsNonMeleeSpellCast(true)) me->CastSpell((Unit*)NULL, SPELL_FEL_CRYSTAL_VISUAL, false); } Check_Timer = 2000; diff --git a/src/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_vexallus.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_vexallus.cpp index d0cfd7ee6..7e8bada32 --- a/src/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/boss_vexallus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/def_magisters_terrace.h old mode 100755 new mode 100644 similarity index 52% rename from src/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/def_magisters_terrace.h index b3901f1ed..c7af1dd63 --- a/src/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/def_magisters_terrace.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_MAGISTERS_TERRACE_H -#define DEF_MAGISTERS_TERRACE_H +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_MAGISTERS_TERRACE_H +#define SC_DEF_MAGISTERS_TERRACE_H #define DATA_SELIN_EVENT 1 #define DATA_VEXALLUS_EVENT 2 diff --git a/src/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/instance_magisters_terrace.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/instance_magisters_terrace.cpp index 42323a873..790bfa240 --- a/src/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/instance_magisters_terrace.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/magisters_terrace/magisters_terrace_trash.cpp b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/magisters_terrace_trash.cpp similarity index 95% rename from src/scripts/scripts/zone/magisters_terrace/magisters_terrace_trash.cpp rename to src/scripts/scripts/Eastern Kingdoms/magisters_terrace/magisters_terrace_trash.cpp index 4cd110a32..a36e73c91 100644 --- a/src/scripts/scripts/zone/magisters_terrace/magisters_terrace_trash.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/magisters_terrace/magisters_terrace_trash.cpp @@ -1,8 +1,19 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -110,13 +121,13 @@ struct mob_sunwell_mage_guardAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -214,7 +225,7 @@ struct mob_sunblade_magisterAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } @@ -225,7 +236,7 @@ struct mob_sunblade_magisterAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -269,7 +280,7 @@ struct mob_sunblade_magisterAI : public ScriptedAI struct mob_sunblade_warlockAI : public ScriptedAI { - mob_sunblade_warlockAI(Creature *c) : ScriptedAI(c) + mob_sunblade_warlockAI(Creature *c) : ScriptedAI(c), Summons(me) { pInstance = (c->GetInstanceData()); FelArmor_Timer = 120000; //check each 2 minutes @@ -277,6 +288,7 @@ struct mob_sunblade_warlockAI : public ScriptedAI } ScriptedInstance* pInstance; + SummonList Summons; uint32 SummonImp_Timer; uint32 FelArmor_Timer; @@ -319,6 +331,7 @@ struct mob_sunblade_warlockAI : public ScriptedAI pInstance->SetData(DATA_KAEL_TRASH_COUNTER, 1); } } + Summons.DespawnAll(); } void HandleOffCombatEffects() @@ -329,13 +342,14 @@ struct mob_sunblade_warlockAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } - void JustSummoned(Creature* summon) + void JustSummoned(Creature* summoned) { - SummonGUID = summon->GetGUID(); + SummonGUID = summoned->GetGUID(); + Summons.Summon(summoned); } void AttackStart(Unit* who) @@ -363,7 +377,7 @@ struct mob_sunblade_warlockAI : public ScriptedAI SummonImp_Timer -= diff; } - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -484,7 +498,7 @@ struct mob_sunblade_physicianAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } @@ -504,7 +518,7 @@ struct mob_sunblade_physicianAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -605,13 +619,13 @@ struct mob_sunblade_blood_knightAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -649,7 +663,10 @@ struct mob_sunblade_blood_knightAI : public ScriptedAI if(Holy_Light_Timer < diff) { Unit* healTarget = SelectLowestHpFriendly(40.0f, 10000); - AddSpellToCast(healTarget, SPELL_HOLY_LIGHT); + if (healTarget) + AddSpellToCast(healTarget, SPELL_HOLY_LIGHT); + else + AddSpellToCast(me, SPELL_HOLY_LIGHT); Holy_Light_Timer = urand(7000, 10000); } else @@ -697,7 +714,7 @@ struct mob_wretched_skulkerAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); if(roll_chance_f(10.0)) DoSay(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), 0, me->getVictim()); @@ -716,7 +733,7 @@ struct mob_wretched_skulkerAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -771,7 +788,7 @@ struct mob_wretched_bruiserAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); if(roll_chance_f(10.0)) DoSay(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), 0, me->getVictim()); @@ -790,7 +807,7 @@ struct mob_wretched_bruiserAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -851,7 +868,7 @@ struct mob_wretched_huskAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); if(roll_chance_f(10.0)) DoSay(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), 0, me->getVictim()); @@ -872,7 +889,7 @@ struct mob_wretched_huskAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -991,13 +1008,13 @@ struct mob_sister_of_tormentAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -1119,7 +1136,7 @@ struct mob_coilskar_witchAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } @@ -1130,7 +1147,7 @@ struct mob_coilskar_witchAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { @@ -1249,13 +1266,13 @@ struct mob_ethereum_smugglerAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } void UpdateAI(const uint32 diff) { - if(!me->IsNonMeleeSpellCasted(false) && !me->isInCombat()) + if(!me->IsNonMeleeSpellCast(false) && !me->isInCombat()) { if(OOCTimer < diff) { diff --git a/src/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_baron_geddon.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_baron_geddon.cpp index e5d5cba54..0aa4c5f6f --- a/src/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_baron_geddon.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_garr.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_garr.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/molten_core/boss_garr.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_garr.cpp index e824b056a..b7a7affce --- a/src/scripts/scripts/zone/molten_core/boss_garr.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_garr.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_gehennas.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_gehennas.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/molten_core/boss_gehennas.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_gehennas.cpp index a827a7d8a..e7593a8fc --- a/src/scripts/scripts/zone/molten_core/boss_gehennas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_gehennas.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_golemagg.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_golemagg.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/molten_core/boss_golemagg.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_golemagg.cpp index 370e5db98..306e21c55 --- a/src/scripts/scripts/zone/molten_core/boss_golemagg.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_golemagg.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -34,7 +37,7 @@ EndScriptData */ //-- CoreRager Spells -- #define SPELL_MANGLE 19820 -#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% +#define SPELL_AEGIS 20620 //This is self cast whenever we are below 50% struct boss_golemaggAI : public ScriptedAI { diff --git a/src/scripts/scripts/zone/molten_core/boss_lucifron.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_lucifron.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/molten_core/boss_lucifron.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_lucifron.cpp index 432bddf64..62418878a --- a/src/scripts/scripts/zone/molten_core/boss_lucifron.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_lucifron.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_magmadar.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_magmadar.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/molten_core/boss_magmadar.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_magmadar.cpp index b8cfab476..1e62d1ba3 --- a/src/scripts/scripts/zone/molten_core/boss_magmadar.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_magmadar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_majordomo_executus.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_majordomo_executus.cpp index 000ddfa2b..788f5b5e1 --- a/src/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_majordomo_executus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -45,7 +48,7 @@ EndScriptData */ #define SPELL_DAMAGE_REFLECTION 21075 #define SPELL_BLASTWAVE 20229 -#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% +#define SPELL_AEGIS 20620 //This is self cast whenever we are below 50% #define SPELL_TELEPORT 20618 #define SPELL_SUMMON_RAGNAROS 19774 #define SPELL_SHADOW_BOLT 21077 @@ -61,14 +64,14 @@ EndScriptData */ float AddLocations[8][4]= { - {753.044, -1186.86, -118.333, 2.54516}, - {755.028, -1172.57, -118.636, 3.3227}, - {748.181, -1161.33, -118.807, 3.99422}, - {742.781, -1197.79, -118.008, 1.91291}, - {752.798, -1166.29, -118.766, 3.63844}, - {743.136, -1157.67, -119.021, 4.16779}, - {748.553, -1193.14, -118.099, 2.22158}, - {736.539, -1199.47, -118.334, 1.69143} + {753.044, -1186.86, -118.333, 2.54516}, + {755.028, -1172.57, -118.636, 3.3227}, + {748.181, -1161.33, -118.807, 3.99422}, + {742.781, -1197.79, -118.008, 1.91291}, + {752.798, -1166.29, -118.766, 3.63844}, + {743.136, -1157.67, -119.021, 4.16779}, + {748.553, -1193.14, -118.099, 2.22158}, + {736.539, -1199.47, -118.334, 1.69143} }; struct boss_majordomoAI : public BossAI diff --git a/src/scripts/scripts/zone/molten_core/boss_ragnaros.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_ragnaros.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/molten_core/boss_ragnaros.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_ragnaros.cpp index 92ab67e23..c1abfcb9d --- a/src/scripts/scripts/zone/molten_core/boss_ragnaros.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_ragnaros.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -307,7 +310,7 @@ struct boss_ragnarosAI : public Scripted_NoMovementAI if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) { //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCast(false)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); diff --git a/src/scripts/scripts/zone/molten_core/boss_shazzrah.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_shazzrah.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/molten_core/boss_shazzrah.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_shazzrah.cpp index 4ce1305a1..ea7a9fadf --- a/src/scripts/scripts/zone/molten_core/boss_shazzrah.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_shazzrah.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_sulfuron_harbinger.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/boss_sulfuron_harbinger.cpp index ad3b3c0c0..67b152964 --- a/src/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/boss_sulfuron_harbinger.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/molten_core/def_molten_core.h b/src/scripts/scripts/Eastern Kingdoms/molten_core/def_molten_core.h old mode 100755 new mode 100644 similarity index 55% rename from src/scripts/scripts/zone/molten_core/def_molten_core.h rename to src/scripts/scripts/Eastern Kingdoms/molten_core/def_molten_core.h index 140c9f1de..adb68980b --- a/src/scripts/scripts/zone/molten_core/def_molten_core.h +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/def_molten_core.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_MOLTEN_CORE_H -#define DEF_MOLTEN_CORE_H +#ifndef SC_DEF_MOLTEN_CORE_H +#define SC_DEF_MOLTEN_CORE_H #define DATA_LUCIFRON_EVENT 0 #define DATA_MAGMADAR_EVENT 1 diff --git a/src/scripts/scripts/zone/molten_core/instance_molten_core.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/instance_molten_core.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/molten_core/instance_molten_core.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/instance_molten_core.cpp index 636896b70..daede99c4 --- a/src/scripts/scripts/zone/molten_core/instance_molten_core.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/instance_molten_core.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -248,15 +251,7 @@ struct instance_molten_core : public ScriptedInstance break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } uint64 GetData64 (uint32 identifier) @@ -372,7 +367,7 @@ struct instance_molten_core : public ScriptedInstance std::string GetSaveData() { OUT_SAVE_INST_DATA; - + std::ostringstream stream; stream << Encounter[0] << " "; stream << Encounter[1] << " "; diff --git a/src/scripts/scripts/zone/molten_core/molten_core.cpp b/src/scripts/scripts/Eastern Kingdoms/molten_core/molten_core.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/molten_core/molten_core.cpp rename to src/scripts/scripts/Eastern Kingdoms/molten_core/molten_core.cpp index adb254b1c..c1f167fb3 --- a/src/scripts/scripts/zone/molten_core/molten_core.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/molten_core/molten_core.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -26,7 +29,7 @@ mob_ancient_core_hound EndContentData */ #include "precompiled.h" -#include "../../creature/simple_ai.h" +#include "../../special/simple_ai.h" #define SPELL_CONE_OF_FIRE 19630 #define SPELL_BITE 19771 diff --git a/src/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_anubrekhan.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_anubrekhan.cpp index 5771ce329..5c4ab7c0c --- a/src/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_anubrekhan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_faerlina.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_faerlina.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/naxxramas/boss_faerlina.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_faerlina.cpp index d890a4ef6..1eed7fae9 --- a/src/scripts/scripts/zone/naxxramas/boss_faerlina.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_faerlina.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -39,7 +42,7 @@ enum FaerlinaTexts enum FaerlinaSpells { SPELL_POISONBOLT_VOLLEY = 28796, - SPELL_RAIN_OF_FIRE = 28794, //Not sure if targeted AoEs work if casted directly upon a player + SPELL_RAIN_OF_FIRE = 28794, //Not sure if targeted AoEs work if cast directly upon a player SPELL_ENRAGE = 28798 }; diff --git a/src/scripts/scripts/zone/naxxramas/boss_four_horsemen.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_four_horsemen.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/naxxramas/boss_four_horsemen.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_four_horsemen.cpp index bafbc90ca..2196c7701 --- a/src/scripts/scripts/zone/naxxramas/boss_four_horsemen.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_four_horsemen.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/naxxramas/boss_gluth.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gluth.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/naxxramas/boss_gluth.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gluth.cpp index d1633a20a..0d9f4b300 --- a/src/scripts/scripts/zone/naxxramas/boss_gluth.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gluth.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_gothik.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gothik.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/naxxramas/boss_gothik.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gothik.cpp index 18e833b55..7642b124c --- a/src/scripts/scripts/zone/naxxramas/boss_gothik.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_gothik.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_grobbulus.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_grobbulus.cpp index 8c001423f..4fdac5e97 --- a/src/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_grobbulus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_heigan.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_heigan.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/naxxramas/boss_heigan.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_heigan.cpp index 168cc11b1..094e41486 --- a/src/scripts/scripts/zone/naxxramas/boss_heigan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_heigan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_kelthuzad.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_kelthuzad.cpp index 7ca19a8fd..32ea8dfc7 --- a/src/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_kelthuzad.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -139,7 +142,7 @@ I also don't know the emotes #define WALKZ_RIGHT_NEAR 142.0141130 #define WALKO_RIGHT_NEAR 2.121412 -//spells to be casted +//spells to be cast #define SPELL_FROST_BOLT 28478 #define H_SPELL_FROST_BOLT 55802 #define SPELL_FROST_BOLT_NOVA 28479 diff --git a/src/scripts/scripts/zone/naxxramas/boss_loatheb.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_loatheb.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/naxxramas/boss_loatheb.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_loatheb.cpp index d3cba4aec..d92e5349e --- a/src/scripts/scripts/zone/naxxramas/boss_loatheb.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_loatheb.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_maexxna.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_maexxna.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/naxxramas/boss_maexxna.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_maexxna.cpp index b3795f45a..088b657ff --- a/src/scripts/scripts/zone/naxxramas/boss_maexxna.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_maexxna.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_noth.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_noth.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/naxxramas/boss_noth.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_noth.cpp index a77a0796c..774bd3c0b --- a/src/scripts/scripts/zone/naxxramas/boss_noth.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_noth.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_patchwerk.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_patchwerk.cpp index e8af1e20b..64cc05e43 --- a/src/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_patchwerk.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_razuvious.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_razuvious.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/naxxramas/boss_razuvious.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_razuvious.cpp index c9b372af8..be64606d5 --- a/src/scripts/scripts/zone/naxxramas/boss_razuvious.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_razuvious.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_sapphiron.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_sapphiron.cpp index 7e56553c8..ffe7baf1c --- a/src/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_sapphiron.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/naxxramas/boss_thaddius.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_thaddius.cpp old mode 100755 new mode 100644 similarity index 82% rename from src/scripts/scripts/zone/naxxramas/boss_thaddius.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_thaddius.cpp index 11aa9850f..753f12686 --- a/src/scripts/scripts/zone/naxxramas/boss_thaddius.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/boss_thaddius.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -106,6 +109,34 @@ struct boss_thaddiusAI : public BossAI events.ScheduleEvent(EVENT_POLARITY_SHIFT, 30000); events.ScheduleEvent(EVENT_BERSERK, 300000); events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, urand(15000, 45000)); // GUESSED + + me->SetReactState(REACT_PASSIVE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void EnterEvadeMode() + { + events.Reset(); + ClearCastQueue(); + + if (Creature *pStalagg = instance->GetCreature(instance->GetData64(DATA_STALAGG))) + if (!pStalagg->isAlive()) + pStalagg->Respawn(); + + if (Creature *pFeugen = instance->GetCreature(instance->GetData64(DATA_FEUGEN))) + if (!pFeugen->isAlive()) + pFeugen->Respawn(); + + CreatureAI::EnterEvadeMode(); + } + + void Engage() + { + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoZoneInCombat(); } void EnterCombat(Unit*) @@ -173,6 +204,8 @@ struct boss_thaddiusAI : public BossAI if (!UpdateVictim()) return; + DoSpecialThings(diff, DO_EVADE_CHECK, 100.0f); + events.Update(diff); while (uint32 eventId = events.ExecuteEvent()) { @@ -229,6 +262,15 @@ struct boss_stalaggAI : public BossAI me->RemoveAurasDueToSpell(SPELL_TESLA_PASSIVE_S); } + void EnterEvadeMode() + { + if (Creature *pFeugen = instance->GetCreature(instance->GetData64(DATA_FEUGEN))) + if (!pFeugen->isAlive()) + pFeugen->Respawn(); + + CreatureAI::EnterEvadeMode(); + } + void EnterCombat(Unit*) { DoScriptText(SAY_STAL_AGGRO, me); @@ -243,16 +285,21 @@ struct boss_stalaggAI : public BossAI void JustDied(Unit *pKiller) { - if (Creature* pFeugen = instance->GetCreature(instance->GetData64(DATA_FEUGEN))) + DoScriptText(SAY_STAL_DEATH, me); + + if (Creature *pFeugen = instance->GetCreature(instance->GetData64(DATA_FEUGEN))) { if (!pFeugen->HealthBelowPct(2)) { + me->setDeathState(JUST_DIED); me->Respawn(); return; } - } - DoScriptText(SAY_STAL_DEATH, me); + if (pFeugen->isDead()) + if (Creature *pThaddius = instance->GetCreature(instance->GetData64(DATA_THADDIUS))) + ((boss_thaddiusAI*) (pThaddius->AI()))->Engage(); + } } void UpdateAI(const uint32 diff) @@ -260,6 +307,8 @@ struct boss_stalaggAI : public BossAI if (!UpdateVictim()) return; + DoSpecialThings(diff, DO_EVADE_CHECK, 100.0f); + events.Update(diff); while (uint32 eventId = events.ExecuteEvent()) { @@ -317,6 +366,15 @@ struct boss_feugenAI : public BossAI me->RemoveAurasDueToSpell(SPELL_TESLA_PASSIVE_F); } + void EnterEvadeMode() + { + if (Creature *pStalagg = instance->GetCreature(instance->GetData64(DATA_STALAGG))) + if (!pStalagg->isAlive()) + pStalagg->Respawn(); + + CreatureAI::EnterEvadeMode(); + } + void EnterCombat(Unit*) { DoScriptText(SAY_FEUG_AGGRO, me); @@ -331,16 +389,21 @@ struct boss_feugenAI : public BossAI void JustDied(Unit *pKiller) { - if (Creature* pStalagg = instance->GetCreature(instance->GetData64(DATA_STALAGG))) + DoScriptText(SAY_FEUG_DEATH, me); + + if (Creature *pStalagg = instance->GetCreature(instance->GetData64(DATA_STALAGG))) { if (!pStalagg->HealthBelowPct(2)) { + me->setDeathState(JUST_DIED); me->Respawn(); return; } - } - DoScriptText(SAY_FEUG_DEATH, me); + if (pStalagg->isDead()) + if (Creature *pThaddius = instance->GetCreature(instance->GetData64(DATA_THADDIUS))) + ((boss_thaddiusAI*) (pThaddius->AI()))->Engage(); + } } void UpdateAI(const uint32 diff) @@ -348,6 +411,8 @@ struct boss_feugenAI : public BossAI if (!UpdateVictim()) return; + DoSpecialThings(diff, DO_EVADE_CHECK, 100.0f); + events.Update(diff); while (uint32 eventId = events.ExecuteEvent()) { diff --git a/src/scripts/scripts/zone/naxxramas/def_naxxramas.h b/src/scripts/scripts/Eastern Kingdoms/naxxramas/def_naxxramas.h similarity index 94% rename from src/scripts/scripts/zone/naxxramas/def_naxxramas.h rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/def_naxxramas.h index 45b88f6cb..17d503273 100644 --- a/src/scripts/scripts/zone/naxxramas/def_naxxramas.h +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/def_naxxramas.h @@ -19,4 +19,6 @@ #define DATA_STALAGG 15 #define DATA_FEUGEN 16 +#define ENCOUNTERS 17 + #endif diff --git a/src/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp b/src/scripts/scripts/Eastern Kingdoms/naxxramas/instance_naxxramas.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp rename to src/scripts/scripts/Eastern Kingdoms/naxxramas/instance_naxxramas.cpp index 204efcfed..6ee968c3d --- a/src/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/naxxramas/instance_naxxramas.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + /* ScriptData SDName: Instance_Naxxramas SD%Complete: 0 @@ -8,8 +26,6 @@ EndScriptData */ #include "precompiled.h" #include "def_naxxramas.h" -#define ENCOUNTERS 15 - // This spawns 5 corpse scarabs ontop of us (most likely the player casts this on death) #define SPELL_SELF_SPAWN_5 29105 @@ -28,6 +44,7 @@ struct instance_naxxramas : public ScriptedInstance uint8 deadHorsemans; + uint64 m_thaddiusGUID; uint64 m_stalaggGUID; uint64 m_feugenGUID; uint64 m_lady_blaumeuxGUID; @@ -42,6 +59,7 @@ struct instance_naxxramas : public ScriptedInstance for (uint8 i = 0; i < ENCOUNTERS; ++i) Encounters[i] = NOT_STARTED; + m_thaddiusGUID = 0; m_stalaggGUID = 0; m_feugenGUID = 0; deadHorsemans = 0; @@ -106,6 +124,9 @@ struct instance_naxxramas : public ScriptedInstance { switch (creature_entry) { + case 15928: + m_thaddiusGUID = creature->GetGUID(); + break; case 15929: m_stalaggGUID = creature->GetGUID(); break; @@ -116,15 +137,7 @@ struct instance_naxxramas : public ScriptedInstance break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void OnObjectCreate(GameObject* go){} @@ -264,6 +277,8 @@ struct instance_naxxramas : public ScriptedInstance { switch (identifier) { + case DATA_THADDIUS: + return m_thaddiusGUID; case DATA_STALAGG: return m_stalaggGUID; case DATA_FEUGEN: diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_arcanist_doan.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_arcanist_doan.cpp index aca2bd6dc..35ec77aad --- a/src/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_arcanist_doan.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -80,7 +83,7 @@ struct boss_arcanist_doanAI : public ScriptedAI return; //If we are <50% hp cast Arcane Bubble and start casting SPECIAL FIRE AOE - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCast(false)) { if (Polymorph_Timer < diff) { diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp index f7b1e92af..d23d017f0 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -52,7 +55,7 @@ struct boss_azshir_the_sleeplessAI : public ScriptedAI return; //If we are <50% hp cast Soul Siphon rank 1 - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCast(false)) { //SoulSiphon_Timer if (SoulSiphon_Timer < diff) diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp index 0f9be3203..5e2b4af07 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_bloodmage_thalnos.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_headless_horseman.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_headless_horseman.cpp index b7779b1d0..4ccc3572d --- a/src/scripts/scripts/zone/scarlet_monastery/boss_headless_horseman.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_headless_horseman.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -583,7 +586,7 @@ struct boss_headless_horsemanAI : public ScriptedAI caster->GetMotionMaster()->Clear(false); caster->GetMotionMaster()->MoveFollow(m_creature,6,rand()%6); //DoResetThreat();//not sure if need - std::list::iterator itr; + std::list::iterator itr; for(itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr) { Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_herod.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_herod.cpp index 66cefe19b..251ffd3c2 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_herod.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -78,7 +81,7 @@ struct boss_herodAI : public ScriptedAI return; //If we are <30% hp goes Enraged - if (!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) + if (!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCast(false)) { DoScriptText(EMOTE_ENRAGE, m_creature); DoScriptText(SAY_ENRAGE, m_creature); diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp index 1ab7c69b5..a5b84a220 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -65,7 +68,7 @@ struct boss_high_inquisitor_fairbanksAI : public ScriptedAI return; //If we are <45% hp cast Renew rank 6 or Flash heal rank 4 - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 45 && !m_creature->IsNonMeleeSpellCasted(false) && Healing_Timer < diff) + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 45 && !m_creature->IsNonMeleeSpellCast(false) && Healing_Timer < diff) { DoCast(m_creature->getVictim(),SPELL_RENEW6 || SPELL_FLASHHEAL4); Healing_Timer = 30000; diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp index afaeb93bb..891671d0f --- a/src/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_houndmaster_loksey.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -54,7 +57,7 @@ struct boss_houndmaster_lokseyAI : public ScriptedAI return; //If we are <10% hp cast healing spells at self and Mograine - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCasted(false) && Enrage_Timer < diff) + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCast(false) && Enrage_Timer < diff) { DoCast(m_creature,SPELL_ENRAGE); Enrage_Timer = 900000; diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp index c7be31a1c..aabc60fbb --- a/src/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_interrogator_vishas.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -60,7 +63,7 @@ struct boss_interrogator_vishasAI : public ScriptedAI return; //If we are low on hp Do sayings - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 60 && !m_creature->IsNonMeleeSpellCasted(false)) + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 60 && !m_creature->IsNonMeleeSpellCast(false)) { //Yell_Timer if (Yell_Timer < diff) @@ -74,7 +77,7 @@ struct boss_interrogator_vishasAI : public ScriptedAI }else Yell_Timer -= diff; } - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCast(false)) { //Yell_Timer if (Yell_Timer < diff) diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_mograine_and_whitemane.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/scarlet_monastery/boss_mograine_and_whitemane.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp index 4a3fc60ff..9ab3694a0 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_mograine_and_whitemane.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_mograine_and_whitemane.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -99,7 +102,7 @@ struct boss_scarlet_commander_mograineAI : public ScriptedAI return; //If we are <50% hp cast Arcane Bubble and start casting SPECIAL Arcane Explosion - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCast(false)) { //heal_Timer if (Heal_Timer < diff) diff --git a/src/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_scorn.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_scorn.cpp index 90a4468f0..a17711c75 --- a/src/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/boss_scorn.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/def_scarlet_monastery.h b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/def_scarlet_monastery.h new file mode 100644 index 000000000..c3aa5653f --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/def_scarlet_monastery.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SCARLET_MONASTERY_H +#define SC_DEF_SCARLET_MONASTERY_H + +#define TYPE_MOGRAINE_AND_WHITE_EVENT 1 +#define DATA_MOGRAINE 2 +#define DATA_WHITEMANE 3 +#define DATA_DOOR_WHITEMANE 4 + +#define DATA_HORSEMAN_EVENT 5 +#define GAMEOBJECT_PUMPKIN_SHRINE 6 +#endif + diff --git a/src/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp old mode 100755 new mode 100644 similarity index 82% rename from src/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp rename to src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp index 54652e47e..b552a1c4d --- a/src/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scarlet_monastery/instance_scarlet_monastery.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Scarlet_Monastery diff --git a/src/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_darkmaster_gandling.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_darkmaster_gandling.cpp index 0d5d5c7b9..a3d756282 --- a/src/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_darkmaster_gandling.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -23,7 +26,7 @@ EndScriptData */ #include "precompiled.h" -#define SPELL_ARCANEMISSILES 22272 +#define SPELL_ARCANEMISSILES 15791 #define SPELL_SHADOWSHIELD 22417 //Not right ID. But 12040 is wrong either. #define SPELL_CURSE 18702 diff --git a/src/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_death_knight_darkreaver.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_death_knight_darkreaver.cpp index 67853fa43..d69b46ac9 --- a/src/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_death_knight_darkreaver.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp index 33482c879..912d36c64 --- a/src/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_doctor_theolen_krastinov.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_illucia_barov.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_illucia_barov.cpp index 67fa19696..40baf2306 --- a/src/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_illucia_barov.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_instructor_malicia.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_instructor_malicia.cpp index a4321bb32..8a50751c3 --- a/src/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_instructor_malicia.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -103,7 +106,7 @@ struct boss_instructormaliciaAI : public ScriptedAI { DoCast(m_creature,SPELL_FLASHHEAL); - //5 Flashheals will be casted + //5 Flashheals will be cast if (FlashCounter < 2) { FlashHeal_Timer = 5000; @@ -121,7 +124,7 @@ struct boss_instructormaliciaAI : public ScriptedAI { DoCast(m_creature,SPELL_HEALINGTOUCH); - //3 Healingtouchs will be casted + //3 Healingtouchs will be cast if (HealingTouch_Timer < 2) { HealingTouch_Timer = 5500; diff --git a/src/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_jandice_barov.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_jandice_barov.cpp index eff1e30d6..5aa149403 --- a/src/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_jandice_barov.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_jandicebarov diff --git a/src/scripts/scripts/zone/scholomance/boss_kormok.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_kormok.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/scholomance/boss_kormok.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_kormok.cpp index c739c5afa..321565269 --- a/src/scripts/scripts/zone/scholomance/boss_kormok.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_kormok.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lord_alexei_barov.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lord_alexei_barov.cpp index 50bc61e56..3df7ad749 --- a/src/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lord_alexei_barov.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lorekeeper_polkelt.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lorekeeper_polkelt.cpp index 31584c4bf..1e5960a7e --- a/src/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_lorekeeper_polkelt.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_ras_frostwhisper.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_ras_frostwhisper.cpp index 6c70ee2af..a822dcd19 --- a/src/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_ras_frostwhisper.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_the_ravenian.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_the_ravenian.cpp index 23d19d3bf..2505ca1dd --- a/src/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_the_ravenian.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/scholomance/boss_vectus.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_vectus.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/scholomance/boss_vectus.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/boss_vectus.cpp index 93cd4b5eb..c7837669a --- a/src/scripts/scripts/zone/scholomance/boss_vectus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/boss_vectus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/scholomance/def_scholomance.h b/src/scripts/scripts/Eastern Kingdoms/scholomance/def_scholomance.h new file mode 100644 index 000000000..cb25b04ad --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/def_scholomance.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SCHOLOMANCE_H +#define SC_DEF_SCHOLOMANCE_H + +#define DATA_CANSPAWNGANDLING 1 +#define DATA_DOCTORTHEOLENKRASTINOV_DEATH 2 +#define DATA_INSTRUCTORMALICIA_DEATH 3 +#define DATA_LADYILLUCIABAROV_DEATH 4 +#define DATA_LORDALEXEIBAROV_DEATH 5 +#define DATA_LOREKEEPERPOLKELT_DEATH 6 +#define DATA_THERAVENIAN_DEATH 7 +#endif + diff --git a/src/scripts/scripts/zone/scholomance/instance_scholomance.cpp b/src/scripts/scripts/Eastern Kingdoms/scholomance/instance_scholomance.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/scholomance/instance_scholomance.cpp rename to src/scripts/scripts/Eastern Kingdoms/scholomance/instance_scholomance.cpp index 69ef0cec1..a777ad168 --- a/src/scripts/scripts/zone/scholomance/instance_scholomance.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/scholomance/instance_scholomance.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/searing_gorge/searing_gorge.cpp b/src/scripts/scripts/Eastern Kingdoms/searing_gorge/searing_gorge.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/searing_gorge/searing_gorge.cpp rename to src/scripts/scripts/Eastern Kingdoms/searing_gorge/searing_gorge.cpp index fff417bcf..6d60f3b1e --- a/src/scripts/scripts/zone/searing_gorge/searing_gorge.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/searing_gorge/searing_gorge.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/def_shadowfang_keep.h b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/def_shadowfang_keep.h new file mode 100644 index 000000000..4dc5c2be1 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/def_shadowfang_keep.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SHADOWFANG_H +#define SC_DEF_SHADOWFANG_H + +#define TYPE_FREE_NPC 1 +#define TYPE_RETHILGORE 2 +#define TYPE_FENRUS 3 +#define TYPE_NANDOS 4 +#endif + diff --git a/src/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp rename to src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp index 01a6c8a72..f561dfeb7 --- a/src/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/instance_shadowfang_keep.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/shadowfang_keep.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp rename to src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/shadowfang_keep.cpp index 3ec562762..aef529207 --- a/src/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/shadowfang_keep/shadowfang_keep.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/silvermoon/silvermoon_city.cpp b/src/scripts/scripts/Eastern Kingdoms/silvermoon/silvermoon_city.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/silvermoon/silvermoon_city.cpp rename to src/scripts/scripts/Eastern Kingdoms/silvermoon/silvermoon_city.cpp index 261567c99..0a6f2ba02 --- a/src/scripts/scripts/zone/silvermoon/silvermoon_city.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/silvermoon/silvermoon_city.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp b/src/scripts/scripts/Eastern Kingdoms/silverpine_forest/silverpine_forest.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp rename to src/scripts/scripts/Eastern Kingdoms/silverpine_forest/silverpine_forest.cpp index 6121e9110..10e3be633 --- a/src/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/silverpine_forest/silverpine_forest.cpp @@ -1,4 +1,7 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 + /* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/stormwind/stormwind_city.cpp b/src/scripts/scripts/Eastern Kingdoms/stormwind/stormwind_city.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/stormwind/stormwind_city.cpp rename to src/scripts/scripts/Eastern Kingdoms/stormwind/stormwind_city.cpp index f242950d3..e5d4663d8 --- a/src/scripts/scripts/zone/stormwind/stormwind_city.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stormwind/stormwind_city.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp b/src/scripts/scripts/Eastern Kingdoms/stranglethorn_vale/stranglethorn_vale.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp rename to src/scripts/scripts/Eastern Kingdoms/stranglethorn_vale/stranglethorn_vale.cpp index f414eab27..a5a53b1ba --- a/src/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stranglethorn_vale/stranglethorn_vale.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baron_rivendare.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baron_rivendare.cpp index 2be88c8de..23c3a33b8 --- a/src/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baron_rivendare.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Baron_Rivendare @@ -98,6 +101,8 @@ struct boss_baron_rivendareAI : public ScriptedAI MortalStrike_Timer = 12000; // RaiseDead_Timer = 30000; SummonSkeletons_Timer = 34000; + if (pInstance) + pInstance->SetData(TYPE_BARON,NOT_STARTED); } void EnterCombat(Unit *who) diff --git a/src/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baroness_anastari.cpp old mode 100755 new mode 100644 similarity index 74% rename from src/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baroness_anastari.cpp index 181f93fb8..514b53d9c --- a/src/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_baroness_anastari.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Baroness_Anastari @@ -53,12 +56,14 @@ struct boss_baroness_anastariAI : public ScriptedAI void EnterCombat(Unit *who) { + if (pInstance) + pInstance->SetData(TYPE_BARONESS,IN_PROGRESS); } void JustDied(Unit* Killer) { if (pInstance) - pInstance->SetData(TYPE_BARONESS,IN_PROGRESS); + pInstance->SetData(TYPE_BARONESS,SPECIAL); } void UpdateAI(const uint32 diff) diff --git a/src/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_cannon_master_willey.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_cannon_master_willey.cpp index 103a81771..cf4d9ef4a --- a/src/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_cannon_master_willey.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_cannon_master_willey diff --git a/src/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_dathrohan_balnazzar.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_dathrohan_balnazzar.cpp index 56d531bd1..180d3b4a9 --- a/src/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_dathrohan_balnazzar.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_darhrohan_balnazzar @@ -143,7 +146,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI if (!Transformed) { //CrusadersHammer - if (CrusadersHammer_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (CrusadersHammer_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 75) //50% chance to cast @@ -155,7 +158,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI }else CrusadersHammer_Timer -= diff; //CrusaderStrike - if (CrusaderStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (CrusaderStrike_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 60) //50% chance to cast @@ -167,7 +170,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI }else CrusaderStrike_Timer -= diff; //MindBlast - if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 70) //70% chance to cast @@ -179,7 +182,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI }else MindBlast_Timer -= diff; //HolyStrike - if (HolyStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (HolyStrike_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 50) //50% chance to cast @@ -191,7 +194,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI }else HolyStrike_Timer -= diff; //Dazed - if (Dazed_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (Dazed_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 50) //50% chance to cast @@ -217,7 +220,7 @@ struct boss_dathrohan_balnazzarAI : public ScriptedAI //MindBlast - if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCast(false)) { //Cast if (rand()%100 < 60) //70% chance to cast diff --git a/src/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_magistrate_barthilas.cpp old mode 100755 new mode 100644 similarity index 77% rename from src/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_magistrate_barthilas.cpp index 426dfd204..78656acaa --- a/src/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_magistrate_barthilas.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Magistrate_Barthilas diff --git a/src/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_maleki_the_pallid.cpp old mode 100755 new mode 100644 similarity index 67% rename from src/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_maleki_the_pallid.cpp index 73f0f04d6..4703bb395 --- a/src/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_maleki_the_pallid.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_maleki_the_pallid @@ -51,12 +54,14 @@ struct boss_maleki_the_pallidAI : public ScriptedAI void EnterCombat(Unit *who) { + if (pInstance) + pInstance->SetData(TYPE_PALLID,IN_PROGRESS); } void JustDied(Unit* Killer) { if (pInstance) - pInstance->SetData(TYPE_PALLID,IN_PROGRESS); + pInstance->SetData(TYPE_PALLID,SPECIAL); } void UpdateAI(const uint32 diff) diff --git a/src/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_nerubenkan.cpp old mode 100755 new mode 100644 similarity index 76% rename from src/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_nerubenkan.cpp index 15004945f..292207469 --- a/src/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_nerubenkan.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Nerubenkan @@ -57,12 +60,14 @@ struct boss_nerubenkanAI : public ScriptedAI void EnterCombat(Unit *who) { + if (pInstance) + pInstance->SetData(TYPE_NERUB,IN_PROGRESS); } void JustDied(Unit* Killer) { if (pInstance) - pInstance->SetData(TYPE_NERUB,IN_PROGRESS); + pInstance->SetData(TYPE_NERUB,SPECIAL); } void RaiseUndeadScarab(Unit* victim) diff --git a/src/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_order_of_silver_hand.cpp old mode 100755 new mode 100644 similarity index 82% rename from src/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_order_of_silver_hand.cpp index 164b34855..89fe7992f --- a/src/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_order_of_silver_hand.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Silver_Hand_Bosses diff --git a/src/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_postmaster_malown.cpp old mode 100755 new mode 100644 similarity index 80% rename from src/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_postmaster_malown.cpp index ee4511028..f4c8527ab --- a/src/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_postmaster_malown.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_postmaster_malown diff --git a/src/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_ramstein_the_gorger.cpp old mode 100755 new mode 100644 similarity index 54% rename from src/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_ramstein_the_gorger.cpp index b59c6bd7f..7a944449f --- a/src/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_ramstein_the_gorger.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Ramstein_The_Gorger @@ -22,7 +25,7 @@ SDCategory: Stratholme EndScriptData */ #include "precompiled.h" - #include "def_stratholme.h" +#include "def_stratholme.h" #define SPELL_TRAMPLE 5568 #define SPELL_KNOCKOUT 17307 @@ -40,11 +43,13 @@ struct boss_ramstein_the_gorgerAI : public ScriptedAI uint32 Trample_Timer; uint32 Knockout_Timer; + std::list summons; void Reset() { Trample_Timer = 3000; Knockout_Timer = 12000; + summons.clear(); } void EnterCombat(Unit *who) @@ -57,6 +62,18 @@ struct boss_ramstein_the_gorgerAI : public ScriptedAI m_creature->SummonCreature(C_MINDLESS_UNDEAD,3969.35,-3391.87,119.11,5.91,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000); if (pInstance) + pInstance->SetData(TYPE_RAMSTEIN,SPECIAL); + } + + void JustSummoned(Creature* c) + { + c->AI()->DoZoneInCombat(); + summons.push_back(c->GetGUID()); + } + + void SummonedCreatureDespawn(Creature*) + { + if (pInstance && pInstance->GetData(TYPE_RAMSTEIN) == SPECIAL && std::none_of(summons.begin(),summons.end(),[this](uint64 guid)-> bool {Creature *c = pInstance->GetCreature(guid) ; return c ? c->isAlive():false;})) pInstance->SetData(TYPE_RAMSTEIN,DONE); } @@ -82,6 +99,15 @@ struct boss_ramstein_the_gorgerAI : public ScriptedAI DoMeleeAttackIfReady(); } + + void EnterEvadeMode() + { + CreatureAI::EnterEvadeMode(); + if(pInstance) + { + pInstance->SetData(TYPE_RAMSTEIN,FAIL); + } + } }; CreatureAI* GetAI_boss_ramstein_the_gorger(Creature *_Creature) { diff --git a/src/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_timmy_the_cruel.cpp old mode 100755 new mode 100644 similarity index 62% rename from src/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/boss_timmy_the_cruel.cpp index f882b3795..790b0238c --- a/src/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/boss_timmy_the_cruel.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_timmy_the_cruel diff --git a/src/scripts/scripts/Eastern Kingdoms/stratholme/def_stratholme.h b/src/scripts/scripts/Eastern Kingdoms/stratholme/def_stratholme.h new file mode 100644 index 000000000..17a676149 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/def_stratholme.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_STRATHOLME_H +#define SC_DEF_STRATHOLME_H + +#define TYPE_BARON_RUN 1 +#define TYPE_BARONESS 2 +#define TYPE_NERUB 3 +#define TYPE_PALLID 4 +#define TYPE_RAMSTEIN 5 +#define TYPE_BARON 6 +#define TYPE_GAUNTLET_MOB 7 + +#define DATA_BARON 10 +#define DATA_YSIDA_TRIGGER 11 + +#define TYPE_SH_QUEST 20 +#define TYPE_SH_CATHELA 21 +#define TYPE_SH_GREGOR 22 +#define TYPE_SH_NEMAS 23 +#define TYPE_SH_VICAR 24 +#define TYPE_SH_AELMAR 25 + +#define QUEST_DEAD_MAN_PLEA 8945 +#define SPELL_BARON_ULTIMATUM 27861 +#endif + diff --git a/src/scripts/scripts/zone/stratholme/instance_stratholme.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/instance_stratholme.cpp old mode 100755 new mode 100644 similarity index 70% rename from src/scripts/scripts/zone/stratholme/instance_stratholme.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/instance_stratholme.cpp index 130375ff7..0ffbaafdf --- a/src/scripts/scripts/zone/stratholme/instance_stratholme.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/instance_stratholme.cpp @@ -1,22 +1,25 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: instance_stratholme -SD%Complete: 50 +SD%Complete: 60 SDComment: In progress. Undead side 75% implemented. Save/load not implemented. SDCategory: Stratholme EndScriptData */ @@ -45,6 +48,7 @@ EndScriptData */ #define C_ABOM_VENOM 10417 #define C_BLACK_GUARD 10394 #define C_YSIDA 16031 +#define C_ACOLYTE 10399 #define ENCOUNTERS 6 @@ -73,8 +77,11 @@ struct instance_stratholme : public ScriptedInstance uint64 baronGUID; uint64 ysidaTriggerGUID; uint64 ysidaGUID; - std::set crystalsGUID; + uint64 CrystalsGUID[3]; std::set abomnationGUID; + std::list acolyte1GUID; + std::list acolyte2GUID; + std::list acolyte3GUID; void Initialize() { @@ -82,7 +89,10 @@ struct instance_stratholme : public ScriptedInstance Encounter[i] = NOT_STARTED; for(uint8 i = 0; i < 5; i++) - IsSilverHandDead[5] = false; + IsSilverHandDead[i] = false; + + for(uint8 i = 0; i < 3; i++) + CrystalsGUID[i] = 0; BaronRun_Timer = 0; SlaugtherSquare_Timer = 0; @@ -100,8 +110,10 @@ struct instance_stratholme : public ScriptedInstance baronGUID = 0; ysidaTriggerGUID = 0; - crystalsGUID.clear(); abomnationGUID.clear(); + acolyte1GUID.clear(); + acolyte2GUID.clear(); + acolyte3GUID.clear(); } Player* GetPlayerInMap() @@ -123,8 +135,7 @@ struct instance_stratholme : public ScriptedInstance bool StartSlaugtherSquare() { - //change to DONE when crystals implemented - if (Encounter[1] == IN_PROGRESS && Encounter[2] == IN_PROGRESS && Encounter[3] == IN_PROGRESS) + if (Encounter[1] == DONE && Encounter[2] == DONE && Encounter[3] == DONE) { UpdateGoState(portGauntletGUID,0,false); UpdateGoState(portSlaugtherGUID,0,false); @@ -158,10 +169,29 @@ struct instance_stratholme : public ScriptedInstance { case C_BARON: baronGUID = creature->GetGUID(); break; case C_YSIDA_TRIGGER: ysidaTriggerGUID = creature->GetGUID(); break; - case C_CRYSTAL: crystalsGUID.insert(creature->GetGUID()); break; + case C_CRYSTAL: + { + if (creature->GetPositionX() > 4000) + CrystalsGUID[2] = creature->GetGUID(); + else if (creature->GetPositionY() < -3600) + CrystalsGUID[0] = creature->GetGUID(); + else + CrystalsGUID[1] = creature->GetGUID(); + break; + } case C_ABOM_BILE: case C_ABOM_VENOM: abomnationGUID.insert(creature->GetGUID()); break; case C_YSIDA: ysidaGUID = creature->GetGUID(); break; + case C_ACOLYTE: + { + if (creature->GetPositionX() > 4000) + acolyte3GUID.push_back(creature->GetGUID()); + else if (creature->GetPositionY() < -3600) + acolyte1GUID.push_back(creature->GetGUID()); + else + acolyte2GUID.push_back(creature->GetGUID()); + break; + } } } @@ -186,6 +216,15 @@ struct instance_stratholme : public ScriptedInstance } } + bool IsEncounterInProgress() const + { + for (uint8 i = 1; i < ENCOUNTERS; ++i) // do not check baron run event + if (Encounter[i] == IN_PROGRESS) + return true; + + return false; + } + void SetData(uint32 type, uint32 data) { Player *player = GetPlayerInMap(); @@ -218,23 +257,23 @@ struct instance_stratholme : public ScriptedInstance break; case TYPE_BARONESS: Encounter[1] = data; - if (data == IN_PROGRESS) + if (data == SPECIAL) UpdateGoState(ziggurat1GUID,0,false); - if (data == IN_PROGRESS) //change to DONE when crystals implemented + if (data == DONE) StartSlaugtherSquare(); break; case TYPE_NERUB: Encounter[2] = data; - if (data == IN_PROGRESS) + if (data == SPECIAL) UpdateGoState(ziggurat2GUID,0,false); - if (data == IN_PROGRESS) //change to DONE when crystals implemented + if (data == DONE) StartSlaugtherSquare(); break; case TYPE_PALLID: Encounter[3] = data; - if (data == IN_PROGRESS) + if (data == SPECIAL) UpdateGoState(ziggurat3GUID,0,false); - if (data == IN_PROGRESS) //change to DONE when crystals implemented + if (data == DONE) StartSlaugtherSquare(); break; case TYPE_RAMSTEIN: @@ -261,11 +300,22 @@ struct instance_stratholme : public ScriptedInstance debug_log("TSCR: Instance Stratholme: Ramstein spawned."); } else debug_log("TSCR: Instance Stratholme: %u Abomnation left to kill.",count); } - if (data == DONE) + if (data == SPECIAL) { SlaugtherSquare_Timer = 300000; + HandleGameObject(portGauntletGUID, true); debug_log("TSCR: Instance Stratholme: Slaugther event will continue in 5 minutes."); } + if (data == DONE) + { + SlaugtherSquare_Timer = 10000; + debug_log("TSCR: Instance Stratholme: Skeletons died, slaughter event will continue"); + } + if (data == FAIL) + { + HandleGameObject(portGauntletGUID, true); + data = SPECIAL; + } Encounter[4] = data; break; case TYPE_BARON: @@ -289,7 +339,7 @@ struct instance_stratholme : public ScriptedInstance if (pGroupie->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE) { - pGroupie->CastedCreatureOrGO(C_YSIDA, ysidaGUID,0); + pGroupie->CastCreatureOrGO(C_YSIDA, ysidaGUID,0); pGroupie->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA); } } @@ -298,7 +348,7 @@ struct instance_stratholme : public ScriptedInstance if (Unit *temp = Unit::GetUnit(*player,GetData64(DATA_BARON))) { - player->CastedCreatureOrGO(C_YSIDA, ysidaGUID,0); + player->CastCreatureOrGO(C_YSIDA, ysidaGUID,0); player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA); } SetData(TYPE_BARON_RUN,DONE); @@ -309,7 +359,8 @@ struct instance_stratholme : public ScriptedInstance { HandleGameObject(portGauntletGUID, true); } - Encounter[5] = data; + if (Encounter[5] != DONE) + Encounter[5] = data; break; case TYPE_SH_AELMAR: IsSilverHandDead[0] = (data) ? true : false; @@ -326,6 +377,30 @@ struct instance_stratholme : public ScriptedInstance case TYPE_SH_VICAR: IsSilverHandDead[4] = (data) ? true : false; break; + case TYPE_GAUNTLET_MOB: + if (data != 1) + break; + if (GetData(TYPE_NERUB) != DONE && std::none_of(acolyte2GUID.begin(),acolyte2GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;})) + { + Creature *c = GetCreature(CrystalsGUID[1]); + if(c && c->isAlive()) + c->Kill(c,false); + SetData(TYPE_NERUB,DONE); + } + if (GetData(TYPE_BARONESS) != DONE && std::none_of(acolyte1GUID.begin(),acolyte1GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;})) + { + Creature *c = GetCreature(CrystalsGUID[0]); + if(c && c->isAlive()) + c->Kill(c,false); + SetData(TYPE_BARONESS,DONE); + } + if (GetData(TYPE_PALLID) != DONE && std::none_of(acolyte3GUID.begin(),acolyte3GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;})) + { + Creature *c = GetCreature(CrystalsGUID[2]); + if(c && c->isAlive()) + c->Kill(c,false); + SetData(TYPE_PALLID,DONE); + } } } @@ -395,6 +470,43 @@ struct instance_stratholme : public ScriptedInstance }else SlaugtherSquare_Timer -= diff; } } + + void Load(const char* in) + { + if (!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + + std::istringstream loadStream(in); + loadStream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3] >> Encounter[4] >> Encounter[5]; + + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounter[i] == IN_PROGRESS) + Encounter[i] = NOT_STARTED; + + OUT_LOAD_INST_DATA_COMPLETE; + } + + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + + std::ostringstream stream; + stream << Encounter[0] << " "; + stream << Encounter[1] << " "; + stream << Encounter[2] << " "; + stream << Encounter[3] << " "; + stream << Encounter[4] << " "; + stream << Encounter[5]; + + OUT_SAVE_INST_DATA_COMPLETE; + + return stream.str(); + } }; InstanceData* GetInstanceData_instance_stratholme(Map* map) diff --git a/src/scripts/scripts/zone/stratholme/stratholme.cpp b/src/scripts/scripts/Eastern Kingdoms/stratholme/stratholme.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/stratholme/stratholme.cpp rename to src/scripts/scripts/Eastern Kingdoms/stratholme/stratholme.cpp index 5b245ee2a..1adf58bab --- a/src/scripts/scripts/zone/stratholme/stratholme.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/stratholme/stratholme.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_brutallus.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_brutallus.cpp index dd3f8a4b1..41c3388c1 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_brutallus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -117,16 +120,19 @@ struct boss_brutallusAI : public ScriptedAI Enraged = false; ForceSpellCast(me, SPELL_DUAL_WIELD, INTERRUPT_AND_CAST_INSTANTLY); - if (pInstance) - pInstance->SetData(DATA_BRUTALLUS_EVENT, NOT_STARTED); + pInstance->SetData(DATA_BRUTALLUS_EVENT, NOT_STARTED); me->CombatStop(); } void EnterCombat(Unit* /*pWho*/) { - if (pInstance && pInstance->GetData(DATA_KALECGOS_EVENT) == IN_PROGRESS) + if (pInstance->GetData(DATA_KALECGOS_EVENT) == IN_PROGRESS) + { + EnterEvadeMode(); return; - if (pInstance && pInstance->GetData(DATA_BRUTALLUS_INTRO_EVENT) == DONE) + } + + if (pInstance->GetData(DATA_BRUTALLUS_INTRO_EVENT) == DONE) { DoScriptText(YELL_AGGRO, me); BurnTimer = 20000; // just in case? @@ -136,9 +142,9 @@ struct boss_brutallusAI : public ScriptedAI void KilledUnit(Unit* /*victim*/) { - if (pInstance && pInstance->GetData(DATA_BRUTALLUS_INTRO_EVENT) == DONE && me->isAlive()) + if (pInstance->GetData(DATA_BRUTALLUS_INTRO_EVENT) == DONE && me->isAlive()) { - if(roll_chance_f(40.0)) + if (roll_chance_f(40.0)) DoScriptText(RAND(YELL_KILL1, YELL_KILL2, YELL_KILL3), me); } } @@ -151,7 +157,7 @@ struct boss_brutallusAI : public ScriptedAI void DamageMade(Unit* target, uint32 &damage, bool /*direct_damage*/) { - if(target->GetTypeId() == TYPEID_UNIT && target->GetEntry() == 24895) + if (target->GetTypeId() == TYPEID_UNIT && target->GetEntry() == 24895) damage *= 40; } @@ -167,15 +173,15 @@ struct boss_brutallusAI : public ScriptedAI DoScriptText(YELL_MADR_ICE_BARRIER, pMadrigosa); pMadrigosa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - for(uint8 i = 0; i < 8;++i) + for (uint8 i = 0; i < 8;++i) pMadrigosa->SetSpeed(UnitMoveType(i), 2.5); + pMadrigosa->GetMotionMaster()->MovePoint(1, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z); IntroPhaseTimer = 6500; ++IntroPhase; break; case 1: - if(pInstance) - pInstance->SetData(DATA_BRUTALLUS_INTRO_EVENT, IN_PROGRESS); + pInstance->SetData(DATA_BRUTALLUS_INTRO_EVENT, IN_PROGRESS); pMadrigosa->SetLevitate(false); pMadrigosa->SetWalk(true); pMadrigosa->HandleEmoteCommand(EMOTE_ONESHOT_LAND); @@ -493,8 +499,8 @@ struct npc_death_cloudAI : public ScriptedAI } else if (!me->IsWithinDist(pMadrigosa, 10.0f)) { + me->GetNearPoint(x, y, z, 0.0f, 10.0f, me->GetAngle(pMadrigosa)); z = me->GetPositionZ(); - me->GetNearPoint2D(x, y, 10, me->GetAngle(pMadrigosa)); me->UpdateAllowedPositionZ(x, y, z); me->GetMap()->CreatureRelocation(me, x, y, z, 0); Creature* Trigger = me->SummonTrigger(x, y, z, 0, SummonTimer*4); diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_eredar_twins.cpp old mode 100755 new mode 100644 similarity index 54% rename from src/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_eredar_twins.cpp index d9e523de3..b5653ee24 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_eredar_twins.cpp @@ -1,23 +1,26 @@ -/* Copyright (C) 2009 Trinity -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2009 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Eredar_Twins -SD%Complete: 80 -SDComment: make gobj 187366 casting SPELL_BLAZE_BURN, make order with xxx_Touched spells +SD%Complete: 95 +SDComment: final debugging EndScriptData */ #include "precompiled.h" @@ -59,6 +62,8 @@ enum Quotes enum Spells { //Lady Sacrolash spells + SPELL_DUAL_WIELD = 29651, + SPELL_SHADOWFORM = 45455, SPELL_DARK_TOUCHED = 45347, SPELL_SHADOW_BLADES = 45248, //10 secs SPELL_DARK_STRIKE = 45271, @@ -75,6 +80,7 @@ enum Spells SPELL_DARK_FLAME = 45345, //Grand Warlock Alythess spells + SPELL_FIREFORM = 45457, SPELL_PYROGENICS = 45230, //15secs SPELL_FLAME_TOUCHED = 45348, SPELL_CONFLAGRATION = 45342, //30-35 secs @@ -107,22 +113,22 @@ struct boss_sacrolashAI : public ScriptedAI InstanceData *pInstance; uint32 ShadowbladesTimer; - uint32 ShadownovaTimer; + uint32 SpecialTimer; uint32 ConfoundingblowTimer; uint32 ShadowimageTimer; - uint32 ConflagrationTimer; uint32 EnrageTimer; void Reset() { ShadowbladesTimer = 10000; - ShadownovaTimer = 30000; + SpecialTimer = 30000; ConfoundingblowTimer = 25000; - ShadowimageTimer = 20000; - ConflagrationTimer = 30000; + ShadowimageTimer = 14000; EnrageTimer = 360000; + DoCast(me, SPELL_SHADOWFORM); + DoCast(me, SPELL_DUAL_WIELD); - if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO == DONE)) + if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == DONE) me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); else me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -130,6 +136,18 @@ struct boss_sacrolashAI : public ScriptedAI pInstance->SetData(DATA_SACROLASH, NOT_STARTED); } + void EnterEvadeMode() + { + if (pInstance->GetData(DATA_ALYTHESS) == DONE) + { + if(Unit* Alythess = me->GetUnit(pInstance->GetData64(DATA_ALYTHESS))) + Alythess->ToCreature()->Respawn(); + pInstance->SetData(DATA_ALYTHESS, NOT_STARTED); + } + + ScriptedAI::EnterEvadeMode(); + } + void EnterCombat(Unit *who) { DoZoneInCombat(); @@ -142,6 +160,41 @@ struct boss_sacrolashAI : public ScriptedAI ScriptedAI::MoveInLineOfSight(who); } + void DamageMade(Unit* target, uint32 &damage, bool direct_damage, uint8 school_mask) + { + if(target->GetTypeId() == TYPEID_PLAYER && damage) + { + if(school_mask == SPELL_SCHOOL_MASK_SHADOW) + { + SpellEntry* DarkTouched = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_DARK_TOUCHED); + if(target->HasAura(SPELL_FLAME_TOUCHED)) + { + target->RemoveAurasDueToSpell(SPELL_FLAME_TOUCHED); + target->CastSpell(target, SPELL_DARK_FLAME, true); + } + if(!target->HasAura(SPELL_DARK_FLAME) && !target->ToPlayer()->GetCooldownMgr().HasSpellIdCooldown(DarkTouched)) + { + target->CastSpell(target, SPELL_DARK_TOUCHED, true); + target->ToPlayer()->GetCooldownMgr().AddSpellIdCooldown(DarkTouched, 1000); + } + } + if(school_mask == SPELL_SCHOOL_MASK_FIRE) + { + SpellEntry* FlameTouched = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_FLAME_TOUCHED); + if(target->HasAura(SPELL_DARK_TOUCHED)) + { + target->RemoveAurasDueToSpell(SPELL_DARK_TOUCHED); + target->CastSpell(target, SPELL_DARK_FLAME, true); + } + if(!target->HasAura(SPELL_DARK_FLAME) && !target->ToPlayer()->GetCooldownMgr().HasSpellIdCooldown(FlameTouched)) + { + target->CastSpell(target, SPELL_FLAME_TOUCHED, true);; + target->ToPlayer()->GetCooldownMgr().AddSpellIdCooldown(FlameTouched, 1000); + } + } + } + } + void KilledUnit(Unit *victim) { if (roll_chance_i(20)) @@ -156,7 +209,7 @@ struct boss_sacrolashAI : public ScriptedAI pInstance->SetData(DATA_EREDAR_TWINS_EVENT, DONE); } else - me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + me->SetLootRecipient(NULL); pInstance->SetData(DATA_SACROLASH, DONE); } @@ -167,36 +220,44 @@ struct boss_sacrolashAI : public ScriptedAI AddSpellToCastWithScriptText(SPELL_EMPOWER, CAST_SELF, YELL_SISTER_ALYTHESS_DEAD); } + // searches for one of 5 top threat targets from sisters' threat list, but not her main target + Unit* GetNovaTarget() + { + if(Creature* Alythess = me->GetCreature(pInstance->GetData64(DATA_ALYTHESS))) + { + Unit* target = Alythess->AI()->SelectUnit(SELECT_TARGET_TOPAGGRO, urand(0,4), 300.0f, true, Alythess->getVictimGUID()); + if(target && target->isAlive()) + return target; + } + return NULL; + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; - if (pInstance->GetData(DATA_ALYTHESS) == DONE) + if (SpecialTimer < diff) { - if (ConflagrationTimer < diff) + if (pInstance->GetData(DATA_ALYTHESS) == DONE) { - AddSpellToCast(SPELL_CONFLAGRATION, CAST_RANDOM); - ConflagrationTimer = urand(30000, 35000); + AddSpellToCastWithScriptText(SPELL_CONFLAGRATION, CAST_RANDOM_WITHOUT_TANK, EMOTE_CONFLAGRATION, false, true); + SpecialTimer = urand(14000, 16000); } - else - ConflagrationTimer -= diff; - } - - if (ShadownovaTimer < diff) - { - AddSpellToCastWithScriptText(SPELL_SHADOW_NOVA, CAST_RANDOM, EMOTE_SHADOW_NOVA); - if (pInstance->GetData(DATA_ALYTHESS) != DONE) + else + { + if(Unit* target = GetNovaTarget()) + AddSpellToCastWithScriptText(target, SPELL_SHADOW_NOVA, EMOTE_SHADOW_NOVA, false, true); DoScriptText(YELL_SHADOW_NOVA, me); - - ShadownovaTimer = urand(30000,35000); + SpecialTimer = urand(30000,35000); + } } else - ShadownovaTimer -= diff; + SpecialTimer -= diff; if (ConfoundingblowTimer < diff) { - AddSpellToCast(SPELL_CONFOUNDING_BLOW, CAST_RANDOM); + AddSpellToCast(SPELL_CONFOUNDING_BLOW, CAST_TANK); ConfoundingblowTimer = urand(20000, 25000); } else @@ -205,8 +266,7 @@ struct boss_sacrolashAI : public ScriptedAI if (ShadowimageTimer < diff) { for (int i = 0; i < 3; i++) - DoSpawnCreature(MOB_SHADOW_IMAGE,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN, 15000); - + DoSpawnCreature(MOB_SHADOW_IMAGE, 0, 0 , 0, frand(0, 2*M_PI), TEMPSUMMON_TIMED_DESPAWN, 15000); ShadowimageTimer = 20000; } else @@ -253,33 +313,44 @@ struct boss_alythessAI : public Scripted_NoMovementAI uint32 IntroStepCounter; uint32 IntroYellTimer; - uint32 ConflagrationTimer; + uint32 SpecialTimer; uint32 PyrogenicsTimer; - uint32 ShadownovaTimer; uint32 FlamesearTimer; uint32 EnrageTimer; void Reset() { - ConflagrationTimer = 45000; + SpecialTimer = urand(15000, 19000); PyrogenicsTimer = 15000; - ShadownovaTimer = 40000; EnrageTimer = 360000; - FlamesearTimer = 15000; - IntroYellTimer = 10000; + FlamesearTimer = urand(10000, 15000); + IntroYellTimer = 500; IntroStepCounter = 10; IntroDone = false; TrashWaveDone = false; - if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO == DONE)) + DoCast(me, SPELL_FIREFORM); + if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == DONE) me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); else me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pInstance->SetData(DATA_EREDAR_TWINS_EVENT, NOT_STARTED); pInstance->SetData(DATA_ALYTHESS, NOT_STARTED); - SetAutocast(SPELL_BLAZE, 3000, false); + SetAutocast(SPELL_BLAZE, 2700, true); + } + + void EnterEvadeMode() + { + if (pInstance->GetData(DATA_SACROLASH) == DONE) + { + if(Unit* Sacrolash = me->GetUnit(pInstance->GetData64(DATA_SACROLASH))) + Sacrolash->ToCreature()->Respawn(); + pInstance->SetData(DATA_SACROLASH, NOT_STARTED); + } + + ScriptedAI::EnterEvadeMode(); } void EnterCombat(Unit *who) @@ -288,29 +359,56 @@ struct boss_alythessAI : public Scripted_NoMovementAI pInstance->SetData(DATA_EREDAR_TWINS_EVENT, IN_PROGRESS); } - void MoveInLineOfSight(Unit *who) + void SetData(uint32 a, uint32 b) { - if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == NOT_STARTED && !TrashWaveDone && - !me->IsFriendlyTo(who) && me->IsWithinDistInMap(who, 100)) - { - if(Creature* Vanquisher = GetClosestCreatureWithEntry(me, 25486, 40, true)) - { - Vanquisher->Yell("Intruders! Do not let them into the Sanctum!", 0, who->GetGUID()); - //Vanquisher->GetMotionMaster()->MovePath(PATH_TRASH_WAVE1, false); - } - TrashWaveDone = true; - } - // to be redone - if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE && pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == NOT_STARTED && !me->IsFriendlyTo(who) && me->IsWithinDistInMap(who, 45)) + if(a == 1 && b == 1 && pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == NOT_STARTED) { IntroStepCounter = 0; pInstance->SetData(DATA_EREDAR_TWINS_INTRO, IN_PROGRESS); } + } + void MoveInLineOfSight(Unit *who) + { if (pInstance->GetData(DATA_EREDAR_TWINS_INTRO) == DONE) Scripted_NoMovementAI::MoveInLineOfSight(who); } + void DamageMade(Unit* target, uint32 &damage, bool direct_damage, uint8 school_mask) + { + if(target->GetTypeId() == TYPEID_PLAYER && damage) + { + if(school_mask == SPELL_SCHOOL_MASK_SHADOW) + { + SpellEntry* DarkTouched = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_DARK_TOUCHED); + if(target->HasAura(SPELL_FLAME_TOUCHED)) + { + target->RemoveAurasDueToSpell(SPELL_FLAME_TOUCHED); + target->CastSpell(target, SPELL_DARK_FLAME, true); + } + if(!target->HasAura(SPELL_DARK_FLAME) && !target->ToPlayer()->GetCooldownMgr().HasSpellIdCooldown(DarkTouched)) + { + target->CastSpell(target, SPELL_DARK_TOUCHED, true); + target->ToPlayer()->GetCooldownMgr().AddSpellIdCooldown(DarkTouched, 1000); + } + } + if(school_mask == SPELL_SCHOOL_MASK_FIRE) + { + SpellEntry* FlameTouched = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_FLAME_TOUCHED); + if(target->HasAura(SPELL_DARK_TOUCHED)) + { + target->RemoveAurasDueToSpell(SPELL_DARK_TOUCHED); + target->CastSpell(target, SPELL_DARK_FLAME, true); + } + if(!target->HasAura(SPELL_DARK_FLAME) && !target->ToPlayer()->GetCooldownMgr().HasSpellIdCooldown(FlameTouched)) + { + target->CastSpell(target, SPELL_FLAME_TOUCHED, true);; + target->ToPlayer()->GetCooldownMgr().AddSpellIdCooldown(FlameTouched, 1000); + } + } + } + } + void KilledUnit(Unit *victim) { if (roll_chance_i(20)) @@ -325,7 +423,7 @@ struct boss_alythessAI : public Scripted_NoMovementAI pInstance->SetData(DATA_EREDAR_TWINS_EVENT, DONE); } else - me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + me->SetLootRecipient(NULL); pInstance->SetData(DATA_ALYTHESS, DONE); } @@ -378,6 +476,19 @@ struct boss_alythessAI : public Scripted_NoMovementAI AddSpellToCastWithScriptText(SPELL_EMPOWER, CAST_SELF, YELL_SISTER_SACROLASH_DEAD); } + // searches for one of 5 top threat targets from sisters' threat list, but not her main target + Unit* GetConflagTarget() + { + if(Creature* Sacrolash = me->GetCreature(pInstance->GetData64(DATA_SACROLASH))) + { + + Unit* target = Sacrolash->AI()->SelectUnit(SELECT_TARGET_TOPAGGRO, urand(0,4), 300.0f, true, Sacrolash->getVictimGUID()); + if(target && target->isAlive()) + return target; + } + return NULL; + } + void UpdateAI(const uint32 diff) { if (IntroStepCounter < 10) @@ -393,33 +504,28 @@ struct boss_alythessAI : public Scripted_NoMovementAI if (!UpdateVictim()) return; - if (pInstance->GetData(DATA_SACROLASH) == DONE) + if (SpecialTimer < diff) { - if (ShadownovaTimer < diff) + if (pInstance->GetData(DATA_SACROLASH) == DONE) { - AddSpellToCast(SPELL_SHADOW_NOVA, CAST_RANDOM); - ShadownovaTimer = urand(30000, 35000); + AddSpellToCastWithScriptText(SPELL_SHADOW_NOVA, CAST_RANDOM_WITHOUT_TANK, EMOTE_SHADOW_NOVA, false, true); + SpecialTimer = urand(14000, 16000); } - else - ShadownovaTimer -= diff; - } - - if (ConflagrationTimer < diff) - { - AddSpellToCastWithScriptText(SPELL_CONFLAGRATION, CAST_RANDOM, EMOTE_CONFLAGRATION); - - if (pInstance->GetData(DATA_SACROLASH) != DONE) + else + { + if(Unit* target = GetConflagTarget()) + AddSpellToCastWithScriptText(target , SPELL_CONFLAGRATION, EMOTE_CONFLAGRATION, false, true); DoScriptText(YELL_CANFLAGRATION, me); - - ConflagrationTimer = urand(30000, 35000); + SpecialTimer = urand(30000,35000); + } } else - ConflagrationTimer -= diff; + SpecialTimer -= diff; if (FlamesearTimer < diff) { AddSpellToCast(SPELL_FLAME_SEAR, CAST_SELF); - FlamesearTimer = 15000; + FlamesearTimer = 10000; } else FlamesearTimer -=diff; @@ -452,14 +558,15 @@ CreatureAI* GetAI_boss_alythess(Creature *_Creature) struct mob_shadow_imageAI : public ScriptedAI { - mob_shadow_imageAI(Creature *c) : ScriptedAI(c) {} + mob_shadow_imageAI(Creature *c) : ScriptedAI(c) { pInstance = c->GetInstanceData(); } uint32 ShadowfuryTimer; uint32 DarkstrikeTimer; + InstanceData *pInstance; void Reset() { - ShadowfuryTimer = urand(5000, 20000); + ShadowfuryTimer = 1500; DarkstrikeTimer = 3000; } @@ -477,8 +584,30 @@ struct mob_shadow_imageAI : public ScriptedAI ForceSpellCast(SPELL_IMAGE_VISUAL, CAST_SELF, INTERRUPT_AND_CAST_INSTANTLY); DoZoneInCombat(); - if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) - AttackStart(pTarget); + //if (Unit *pTarget = SelectUnit(SELECT_TARGET_FARTHEST, urand(0, 4), 400, true)) + if(Creature* Alythess = me->GetCreature(pInstance->GetData64(DATA_ALYTHESS))) + { + if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0, 400, true, Alythess->getVictimGUID(), 10.0f)) + AttackStart(pTarget); + } + } + + void DamageMade(Unit* target, uint32 &damage, bool direct_damage, uint8 school_mask) + { + if(target->GetTypeId() == TYPEID_PLAYER && damage && school_mask == SPELL_SCHOOL_MASK_SHADOW) + { + SpellEntry* DarkTouched = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_DARK_TOUCHED); + if(target->HasAura(SPELL_FLAME_TOUCHED)) + { + target->RemoveAurasDueToSpell(SPELL_FLAME_TOUCHED); + target->CastSpell(target, SPELL_DARK_FLAME, true); + } + if(!target->HasAura(SPELL_DARK_FLAME) && !target->ToPlayer()->GetCooldownMgr().HasSpellIdCooldown(DarkTouched)) + { + target->CastSpell(target, SPELL_DARK_TOUCHED, true); + target->ToPlayer()->GetCooldownMgr().AddSpellIdCooldown(DarkTouched, 1000); + } + } } void UpdateAI(const uint32 diff) @@ -488,15 +617,19 @@ struct mob_shadow_imageAI : public ScriptedAI if (ShadowfuryTimer < diff) { - AddSpellToCast(SPELL_SHADOW_FURY, CAST_NULL); - ShadowfuryTimer = 10000; + if (me->IsWithinMeleeRange(me->getVictim()) && roll_chance_f(15)) + { + AddSpellToCast(SPELL_SHADOW_FURY, CAST_NULL); + ShadowfuryTimer = 5000; + } + ShadowfuryTimer = 1500; } else ShadowfuryTimer -= diff; if (DarkstrikeTimer < diff) { - if (!me->IsNonMeleeSpellCasted(false)) + if (!me->IsNonMeleeSpellCast(false)) { //If we are within range melee the target if (me->IsWithinMeleeRange(me->getVictim())) @@ -535,13 +668,3 @@ void AddSC_boss_eredar_twins() newscript->GetAI = &GetAI_mob_shadow_image; newscript->RegisterSelf(); } - -/* SQLe do wrzucenia - --- formation for sacrolash and alythess -REPLACE INTO creature_formations VALUES -(53687, 53668, 0, 0, 2), -(53687, 53687, 0, 0, 2); - - -*/ diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_felmyst.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_felmyst.cpp index eb18be7fc..88bf25822 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_felmyst.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2009 Trinity -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2009 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Felmyst @@ -236,7 +239,7 @@ struct boss_felmystAI : public ScriptedAI if(Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0)) { float x, y, z; - target->GetNearPoint(target, x, y, z, 0, 2, me->GetAngle(target)); + target->GetNearPoint(x, y, z, 0, 2, me->GetAngle(target)); me->UpdateAllowedPositionZ(x, y, z); me->GetMotionMaster()->MovePoint(0, x, y, z); } @@ -317,6 +320,7 @@ struct boss_felmystAI : public ScriptedAI if(p->isAlive() && p->HasAura(SPELL_FOG_CHARM, 0)) me->Kill(p, false); } + summons.DespawnAll(); } void DespawnSummons() @@ -363,6 +367,7 @@ struct boss_felmystAI : public ScriptedAI Timer[EVENT_ENCAPSULATE] = 30000; Timer[EVENT_FLIGHT] = 60000; Timer[EVENT_CHECK] = 1000; + //DoResetThreat(); break; case PHASE_FLIGHT: side = RAND(LEFT_SIDE, RIGHT_SIDE); diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kalecgos.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kalecgos.cpp index 894dc7b68..953db3ef6 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kalecgos.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Kalecgos @@ -533,7 +536,7 @@ struct boss_sathrovarrAI : public ScriptedAI void EnterCombat(Unit* who) { float x, y, z, ori; - me->GetClosePoint(x, y, z, 0, 6, me->GetAngle(me)); + me->GetNearPoint(x, y, z, 0, 6, me->GetAngle(me)); me->UpdateAllowedPositionZ(x, y, z); ori = me->GetAngle(x, y); Creature* Kalec = me->SummonCreature(MOB_KALEC, x, y, z, ori, TEMPSUMMON_CORPSE_DESPAWN, 0); @@ -747,13 +750,13 @@ struct boss_kalecAI : public ScriptedAI Unit* SelectUnitToRevitalize() { std::list RealmUnitList; - std::list& ThreatList = me->getThreatManager().getThreatList(); + std::list& ThreatList = me->getThreatManager().getThreatList(); RealmUnitList.clear(); if (ThreatList.empty()) return NULL; - for(std::list::iterator i = ThreatList.begin() ; i!=ThreatList.end() ; ++i) + for(std::list::iterator i = ThreatList.begin() ; i!=ThreatList.end() ; ++i) { Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid()); // only castable on players in spectral realm that have mana pool and are not revitalized yet diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_kiljaeden.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kiljaeden.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/sunwell_plateau/boss_kiljaeden.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kiljaeden.cpp index d98d956f1..fe123c5d6 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_kiljaeden.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_kiljaeden.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2009 Trinity +/* + * Copyright (C) 2009 TrinityCore + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -304,6 +307,11 @@ struct boss_kalecgos_kjAI : public ScriptedAI ScriptedInstance* pInstance; uint32 FelmystOutroTimer; + void Reset() + { + if(pInstance->GetData(DATA_EREDAR_TWINS_EVENT) == DONE) + me->SetVisibility(VISIBILITY_OFF); + } void MovementInform(uint32 Type, uint32 Id) { @@ -316,7 +324,7 @@ struct boss_kalecgos_kjAI : public ScriptedAI FelmystOutroTimer = 10000; break; case 60: // on starting phase 2 - me->ForcedDespawn(); + me->DisappearAndDie(); break; default: break; @@ -468,6 +476,8 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI void Reset() { + // just for now + me->SetVisibility(VISIBILITY_OFF); // TODO: Fix timers Timer[TIMER_KALEC_JOIN] = 26000; @@ -559,6 +569,12 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI void EnterCombat(Unit* who) { + // temporary + if(pInstance->GetData(DATA_MURU_EVENT) != DONE) + { + EnterEvadeMode(); + return; + } DoZoneInCombat(); DoScriptText(SAY_KJ_EMERGE, m_creature); @@ -608,14 +624,14 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI } break; case TIMER_SOUL_FLAY: - if(!m_creature->IsNonMeleeSpellCasted(false)){ + if(!m_creature->IsNonMeleeSpellCast(false)){ m_creature->CastSpell(m_creature->getVictim(), SPELL_SOUL_FLAY, false); m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_SOUL_FLAY_SLOW, true); Timer[TIMER_SOUL_FLAY] = 3500; } break; case TIMER_LEGION_LIGHTNING: - if(!m_creature->IsNonMeleeSpellCasted(false)){ + if(!m_creature->IsNonMeleeSpellCast(false)){ m_creature->RemoveAurasDueToSpell(SPELL_SOUL_FLAY); for(uint8 z = 0; z < 6; ++z){ randomPlayer = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true); @@ -628,7 +644,7 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI } break; case TIMER_FIRE_BLOOM: - if(!m_creature->IsNonMeleeSpellCasted(false)){ + if(!m_creature->IsNonMeleeSpellCast(false)){ m_creature->RemoveAurasDueToSpell(SPELL_SOUL_FLAY); DoCastAOE(SPELL_FIRE_BLOOM, false); Timer[TIMER_FIRE_BLOOM] = (Phase == PHASE_SACRIFICE) ? 25000 : 40000; // 25 seconds in PHASE_SACRIFICE @@ -646,7 +662,7 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI Timer[TIMER_SOUL_FLAY] = 2000; break; case TIMER_SHADOW_SPIKE: //Phase 3 - if(!m_creature->IsNonMeleeSpellCasted(false)){ + if(!m_creature->IsNonMeleeSpellCast(false)){ DoCastAOE(SPELL_SHADOW_SPIKE, false); Timer[TIMER_SHADOW_SPIKE] = 0; TimerIsDeactiveted[TIMER_SHADOW_SPIKE] = true; @@ -658,7 +674,7 @@ struct boss_kiljaedenAI : public Scripted_NoMovementAI Timer[TIMER_FLAME_DART] = 3000; //TODO Timer break; case TIMER_DARKNESS: //Phase 3 - if(!m_creature->IsNonMeleeSpellCasted(false)){ + if(!m_creature->IsNonMeleeSpellCast(false)){ // Begins to channel for 8 seconds, then deals 50'000 damage to all raid members. if(!IsInDarkness){ DoScriptText(EMOTE_KJ_DARKNESS, m_creature); @@ -864,6 +880,7 @@ struct mob_hand_of_the_deceiverAI : public ScriptedAI void Reset() { + DoCast(m_creature, SPELL_SHADOW_CHANNELING); // TODO: Timers! ShadowBoltVolleyTimer = 8000 + rand()%6000; // So they don't all cast it in the same moment. FelfirePortalTimer = 20000; @@ -901,8 +918,9 @@ struct mob_hand_of_the_deceiverAI : public ScriptedAI void UpdateAI(const uint32 diff) { + /* if(!m_creature->isInCombat()) - DoCast(m_creature, SPELL_SHADOW_CHANNELING); + DoCast(m_creature, SPELL_SHADOW_CHANNELING);*/ if(!UpdateVictim()) return; @@ -926,7 +944,7 @@ struct mob_hand_of_the_deceiverAI : public ScriptedAI Creature* Portal = DoSpawnCreature(CREATURE_FELFIRE_PORTAL, 0, 0,0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000); if(Portal) { - std::list::iterator itr; + std::list::iterator itr; for(itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) { Unit* pUnit = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); diff --git a/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_muru.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_muru.cpp new file mode 100644 index 000000000..54a5bc03b --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/boss_muru.cpp @@ -0,0 +1,1183 @@ +/* +* Copyright (C) 2009 TrinityCore +* Copyright (C) 2008-2014 Hellground +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +/* ScriptData +SDName: Boss_Muru/Entropius +SD%Complete: 99 +SDComment: +*/ + +/* Additional scripts + +* Shadowsword Berserker +* Shadowsword Fury Mage +* Void Sentinel +* Void Spawn + +*/ + +#include "precompiled.h" +#include "def_sunwell_plateau.h" + +// Muru & Entropius's spells +enum Spells +{ + SPELL_ENRAGE = 26662, + + // Muru's spells + SPELL_NEGATIVE_ENERGY_PERIODIC = 46009, //(trigger for 46008) + SPELL_OPEN_PORTAL_PERIODIC = 45994, //(trigger for 45976) + SPELL_DARKNESS_PERIODIC = 45998, //(trigger for 45999) + SPELL_SUMMON_BLOOD_ELVES_PERIODIC = 46041, //(trigger for 46037-46040) + SPELL_OPEN_ALL_PORTALS = 46177, + SPELL_SUMMON_VOID_SENTINEL = 45988, + SPELL_SUMMON_ENTROPIUS = 46217, + SPELL_ENTROPIUS_COSMETIC_SPAWN = 46223, + + // Entropius's spells + SPELL_DARKNESS = 46269, + SPELL_BLACK_HOLE = 46282, + SPELL_NEGATIVE_ENERGY_PERIODIC_E = 46284, + + // M'uru portal target spells + SPELL_SUMMON_VOID_SENTINEL_SUMMONER = 45978, + SPELL_SUMMON_VOID_SENTINEL_SUMMONER_VISUAL = 45989, + + // Void Sentinel's spells + SPELL_SHADOW_PULSE_PERIODIC = 46086, + SPELL_SUMMON_VOID_SPAWN = 46071, + SPELL_VOID_BLAST = 46161, + + // Void Spawn's spells + SPELL_SHADOW_BOLT_VOLLEY = 46082, + + //Dark Fiend spells + SPELL_DARKFIEND_AOE = 45944, + SPELL_DARKFIEND_VISUAL = 45936, + SPELL_DARKFIEND_SKIN = 45934, + + //Black Hole spells + SPELL_BLACK_HOLE_SUMMON_VISUAL = 46242, + SPELL_BLACK_HOLE_SUMMON_VISUAL_2 = 46247, + SPELL_BLACK_HOLE_VISUAL_2 = 46235, + SPELL_BLACK_HOLE_PASSIVE = 46228, + + // Darkness spells + SPELL_VOID_ZONE_PERIODIC = 46262, + SPELL_SUMMON_DARK_FIEND = 46263, + SPELL_VOID_ZONE_PRE_EFFECT_VISUAL = 46265, + + // additional spells used + SPELL_OPEN_PORTAL = 45977, + SPELL_OPEN_PORTAL_2 = 45976, + SPELL_TRANSFORM_VISUAL_MISSILE_PERIODIC = 46205 +}; + +enum Creatures +{ + CREATURE_WORLD_TRIGGER = 22515, + CREATURE_DARKNESS = 25879, + CREATURE_DARK_FIENDS = 25744, + CREATURE_BERSERKER = 25798, + CREATURE_FURY_MAGE = 25799, + CREATURE_VOID_SENTINEL = 25772, + CREATURE_VOID_SPAWN = 25824, + CREATURE_BLACK_HOLE = 25855, + BOSS_MURU = 25741, + BOSS_ENTROPIUS = 25840 +}; + +uint32 EnrageTimer = 600000; + +struct boss_muruAI : public Scripted_NoMovementAI +{ + boss_muruAI(Creature *c) : Scripted_NoMovementAI(c), Summons(me) + { + pInstance = c->GetInstanceData(); + me->SetAggroRange(20.0); + } + + ScriptedInstance* pInstance; + SummonList Summons; + + uint32 ResetTimer; + uint32 HumanoidStart; + uint32 TransitionTimer; + + void Reset() + { + ResetTimer = 0; + EnrageTimer = 600000; + HumanoidStart = 10000; + TransitionTimer = 0; + Summons.DespawnAll(); + + if(pInstance->GetData(DATA_EREDAR_TWINS_EVENT) == DONE) + { + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetVisibility(VISIBILITY_ON); + } + else + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetVisibility(VISIBILITY_OFF); + } + + pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED); + } + + void EnterEvadeMode() + { + CreatureAI::EnterEvadeMode(); + pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED); + me->SetVisibility(VISIBILITY_OFF); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Summons.DespawnAll(); + HumanoidStart = 10000; + ResetTimer = 30000; + } + + void EnterCombat(Unit *who) + { + me->SetIngoreVictimSelection(true); + DoCast(me, SPELL_NEGATIVE_ENERGY_PERIODIC); + DoCast(me, SPELL_OPEN_PORTAL_PERIODIC); + DoCast(me, SPELL_DARKNESS_PERIODIC); + } + + void MoveInLineOfSight(Unit *who) + { + if(ResetTimer) + return; + if(pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void DamageTaken(Unit* /*done_by*/, uint32 &damage) + { + if (damage >= me->GetHealth()) + { + damage = 0; + me->RemoveAllAuras(); + DoCast(me, SPELL_OPEN_ALL_PORTALS); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + TransitionTimer = 5000; + } + } + + void JustSummoned(Creature* summoned) + { + Summons.Summon(summoned); + } + + void UpdateAI(const uint32 diff) + { + if(ResetTimer) + { + if(ResetTimer <= diff) + { + me->SetVisibility(VISIBILITY_ON); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + ResetTimer = 0; + } + else + ResetTimer -= diff; + } + + if (!UpdateVictim()) + return; + + DoSpecialThings(diff, DO_COMBAT_N_EVADE, 80.0f); + + if (me->GetSelection()) + me->SetSelection(NULL); + + if (EnrageTimer < diff) + { + DoCast(me, SPELL_ENRAGE, true); + EnrageTimer = 60000; + } + else + EnrageTimer -= diff; + + if(HumanoidStart) + { + if(HumanoidStart <= diff) + { + pInstance->SetData(DATA_MURU_EVENT, IN_PROGRESS); + // if anyone trapped outside front door, evade + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 400, true, 0, 60)) + { + EnterEvadeMode(); + return; + } + DoCast(me, SPELL_SUMMON_BLOOD_ELVES_PERIODIC, true); + HumanoidStart = 0; + } + else + HumanoidStart -= diff; + } + + if(TransitionTimer) + { + if(TransitionTimer <= diff) + { + DoCast(me, SPELL_ENTROPIUS_COSMETIC_SPAWN); + DoCast(me, SPELL_SUMMON_ENTROPIUS); + me->RemoveAllAuras(); + TransitionTimer = 0; + } + else + TransitionTimer -= diff; + } + } +}; + +CreatureAI* GetAI_boss_muru(Creature *_Creature) +{ + return new boss_muruAI (_Creature); +} + +struct boss_entropiusAI : public ScriptedAI +{ + boss_entropiusAI(Creature *c) : ScriptedAI(c), Summons(m_creature) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + SummonList Summons; + + uint32 TransitionTimer; + uint32 DarknessTimer; + uint32 BlackHole; + + void Reset() + { + me->GetMotionMaster()->MoveIdle(); + DoZoneInCombat(80); + DarknessTimer = urand(6000, 8000); + BlackHole = urand(4000, 10000); + TransitionTimer = 3000; + me->SetRooted(true); + } + + void EnterEvadeMode() + { + if(Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + ((boss_muruAI*)Muru)->EnterEvadeMode(); + me->DisappearAndDie(); + Summons.DespawnAll(); + } + + void JustSummoned(Creature* summoned) + { + if( Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + ((boss_muruAI*)Muru)->JustSummoned(summoned); + Summons.Summon(summoned); + } + + void JustDied(Unit* killer) + { + if(killer->GetGUID() == me->GetGUID()) + return; + pInstance->SetData(DATA_MURU_EVENT, DONE); + if(Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + { + Muru->Kill(Muru, false); + Muru->ToCreature()->RemoveCorpse(); + } + Summons.DespawnAll(); + } + + void UpdateAI(const uint32 diff) + { + if (TransitionTimer) + { + if (TransitionTimer <= diff) + { + if(Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + { + Muru->SetVisibility(VISIBILITY_OFF); + Muru->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + me->SetRooted(false); + AttackStart(me->getVictim()); + DoCast(me, SPELL_NEGATIVE_ENERGY_PERIODIC_E); + TransitionTimer = 0; + } + else + TransitionTimer -= diff; + return; + } + + if (!UpdateVictim()) + return; + + DoSpecialThings(diff, DO_COMBAT_N_EVADE, 100.0f); + + if (EnrageTimer < diff) + { + AddSpellToCast(me, SPELL_ENRAGE); + EnrageTimer = 60000; + } + else + EnrageTimer -= diff; + + if (DarknessTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) + AddSpellToCast(target, SPELL_DARKNESS); + DarknessTimer = 15000; + } + else + DarknessTimer -= diff; + + if (BlackHole < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true, me->getVictimGUID(), 10.0)) + AddSpellToCast(target, SPELL_BLACK_HOLE); + BlackHole = urand(15000, 18000); + } + else + BlackHole -= diff; + + DoMeleeAttackIfReady(); + CastNextSpellIfAnyAndReady(); + } +}; + +CreatureAI* GetAI_boss_entropius(Creature *_Creature) +{ + return new boss_entropiusAI (_Creature); +} + +struct npc_muru_portalAI : public Scripted_NoMovementAI +{ + npc_muru_portalAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInstance = c->GetInstanceData(); + c->GetMotionMaster()->MoveIdle(); + } + + ScriptedInstance* pInstance; + Creature* Muru; + uint32 SummonTimer; + uint32 TransformTimer; + uint32 CheckTimer; + + void Reset() + { + SummonTimer = 0; + TransformTimer = 0; + CheckTimer = 1000; + } + + void EnterCombat(Unit *who) {} + + void JustSummoned(Creature* summoned) + { + if (summoned->GetEntry() == 25782) // Void Summoner + DoCast(summoned, SPELL_SUMMON_VOID_SENTINEL_SUMMONER_VISUAL); + + if( Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + ((boss_muruAI*)Muru)->JustSummoned(summoned); + } + + void SpellHit(Unit* caster, const SpellEntry* Spell) + { + switch (Spell->Id) + { + case SPELL_OPEN_ALL_PORTALS: + DoCast(me, SPELL_OPEN_PORTAL); + TransformTimer = 2000; + break; + case SPELL_OPEN_PORTAL_2: + DoCast(me, SPELL_OPEN_PORTAL); + SummonTimer = 5000; + break; + } + } + + void UpdateAI(const uint32 diff) + { + if(me->isInCombat()) + { + if (CheckTimer < diff) + { + if (pInstance->GetData(DATA_MURU_EVENT) == DONE || pInstance->GetData(DATA_MURU_EVENT) == NOT_STARTED) + EnterEvadeMode(); + CheckTimer = 1000; + } + else + CheckTimer -= diff; + } + + if(SummonTimer) + { + if(SummonTimer <= diff) + { + DoCast(me, SPELL_SUMMON_VOID_SENTINEL_SUMMONER); + SummonTimer = 0; + } + else + SummonTimer -= diff; + } + + if (TransformTimer) + { + if(TransformTimer <= diff) + { + DoCast(me, SPELL_TRANSFORM_VISUAL_MISSILE_PERIODIC); + TransformTimer = 0; + } + else + TransformTimer -= diff; + } + } +}; + +CreatureAI* GetAI_npc_muru_portal(Creature *_Creature) +{ + return new npc_muru_portalAI (_Creature); +} + +struct npc_void_summonerAI : public Scripted_NoMovementAI +{ + npc_void_summonerAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInstance = c->GetInstanceData(); + } + + uint32 SummonTimer; + ScriptedInstance* pInstance; + + void Reset() + { + SummonTimer = 2000; + } + + void JustSummoned(Creature* summoned) + { + if( Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + ((boss_muruAI*)Muru)->JustSummoned(summoned); + } + + void UpdateAI(const uint32 diff) + { + if (SummonTimer < diff) + { + DoCast(me, SPELL_SUMMON_VOID_SENTINEL); + SummonTimer = 10000; + } + else + SummonTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_void_summoner(Creature *_Creature) +{ + return new npc_void_summonerAI (_Creature); +} + +struct npc_dark_fiendAI : public ScriptedAI +{ + npc_dark_fiendAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 ActivationTimer; + uint32 CheckTimer; + uint32 DespawnTimer; + + void Reset() + { + ActivationTimer = 2000; + CheckTimer = 500; + DespawnTimer = 0; + me->SetRooted(true); + DoCast(me, SPELL_DARKFIEND_SKIN); + me->SetSpeed(MOVE_RUN, 0.55); + me->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.8f); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoZoneInCombat(100); + } + + void EnterEvadeMode() + { + me->DisappearAndDie(); + } + + void IsSummonedBy(Unit* Muru) + { + Muru->ToCreature()->AI()->JustSummoned(me); + } + + void DamageTaken(Unit* /*done_by*/, uint32 &damage) + { + if(damage > me->GetHealth()) + { + damage = 0; + me->SetRooted(true); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_DARKFIEND_VISUAL); + DespawnTimer = 3000; + } + } + + void UpdateAI(const uint32 diff) + { + if(!me->HasAura(SPELL_DARKFIEND_SKIN) && !DespawnTimer) + { + me->SetRooted(true); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_DARKFIEND_VISUAL); + DespawnTimer = 3000; + ActivationTimer = 0; + } + + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_NEAREST, 0, 100, true)) + { + me->SetRooted(false); + DoStartMovement(target); + me->getThreatManager().addThreat(target, 100000); + } + ActivationTimer = 0; + } + else + ActivationTimer -= diff; + return; + } + + if(DespawnTimer) + { + if(DespawnTimer <= diff) + { + me->DisappearAndDie(); + DespawnTimer = 0; + } + else + DespawnTimer -= diff; + } + + if (!UpdateVictim() || DespawnTimer) + return; + + if(CheckTimer < diff) + { + if(me->IsWithinDistInMap(me->getVictim(), 1.0)) + { + DoCast(((Unit*)NULL), SPELL_DARKFIEND_AOE); + me->SetRooted(true); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DespawnTimer = 500; + } + CheckTimer = 500; + } + else + CheckTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_dark_fiend(Creature *_Creature) +{ + return new npc_dark_fiendAI (_Creature); +} + +struct npc_void_sentinelAI : public ScriptedAI +{ + npc_void_sentinelAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 VoidBlastTimer; + uint32 ActivationTimer; + + void Reset() + { + float x,y,z,o; + me->GetHomePosition(x,y,z,o); + DoTeleportTo(x,y,71); + DoCast(me, SPELL_SHADOW_PULSE_PERIODIC); + VoidBlastTimer = urand(8000, 12000); + ActivationTimer = 1500; + me->SetRooted(true); + if(pInstance->GetData(DATA_MURU_EVENT) == NOT_STARTED) + me->DisappearAndDie(); + }; + + void EnterEvadeMode() + { + me->DisappearAndDie(); + } + + void IsSummonedBy(Unit* summoner) + { + if(Unit* Muru = me->GetUnit(pInstance->GetData64(DATA_MURU))) + Muru->ToCreature()->AI()->JustSummoned(me); + } + + void DamageTaken(Unit*, uint32 &damage) + { + if(damage >= me->GetHealth()) + { + damage = 0; + for(uint8 i = 0; i < 8; ++i) + DoCast(me, SPELL_SUMMON_VOID_SPAWN, true); + me->Kill(me, false); + } + } + + void UpdateAI(const uint32 diff) + { + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + ActivationTimer = 0; + DoZoneInCombat(100); + me->SetRooted(false); + } + else + ActivationTimer -= diff; + return; + } + + if (!UpdateVictim()) + return; + + if (VoidBlastTimer < diff) + { + DoCast(me->getVictim(), SPELL_VOID_BLAST, false); + VoidBlastTimer = 30000; + } + else + VoidBlastTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_void_sentinel(Creature *_Creature) +{ + return new npc_void_sentinelAI (_Creature); +} + +struct mob_void_spawnAI : public ScriptedAI +{ + mob_void_spawnAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 Volley; + uint32 ActivationTimer; + + void EnterEvadeMode() + { + me->DisappearAndDie(); + } + + void Reset() + { + Volley = urand(3000, 7000); + ActivationTimer = 2000; + me->SetRooted(true); + DoZoneInCombat(100); + if(pInstance->GetData(DATA_MURU_EVENT) == NOT_STARTED) + me->DisappearAndDie(); + }; + + void UpdateAI(const uint32 diff) + { + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + ActivationTimer = 0; + DoZoneInCombat(100); + me->SetRooted(false); + } + else + ActivationTimer -= diff; + return; + } + + if (!UpdateVictim()) + return; + + if (Volley < diff) + { + DoCast(me, SPELL_SHADOW_BOLT_VOLLEY); + Volley = urand(5000, 10000); + } + else + Volley -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_void_spawn(Creature *_Creature) +{ + return new mob_void_spawnAI (_Creature); +} + +struct npc_blackholeAI : public ScriptedAI +{ + npc_blackholeAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 DespawnTimer; + uint32 VisualTimer; + uint32 ActivationTimer; + uint32 ChasingTimer; + uint64 victimGUID; + + void Reset() + { + DespawnTimer = urand(15000, 17000); + me->SetLevitate(true); + me->SetSpeed(MOVE_FLIGHT, 0.5); + me->setFaction(14); + float x,y,z,o; + me->GetHomePosition(x,y,z,o); + DoTeleportTo(x,y,72); + VisualTimer = 2000; + ActivationTimer = 2000; + ChasingTimer = 0; + victimGUID = 0; + me->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->GetMotionMaster()->MoveIdle(); + } + + void MoveInLineOfSight(Unit *who) + { + if(!ChasingTimer) + return; + ScriptedAI::MoveInLineOfSight(who); + } + + void AttackStart(Unit* who) { return; } + + void IsSummonedBy(Unit*) + { + DoCast(me, SPELL_BLACK_HOLE_SUMMON_VISUAL, true); + } + + void UpdateAI(const uint32 diff) + { + if(VisualTimer) + { + if(VisualTimer <= diff) + { + DoCast(me, SPELL_BLACK_HOLE_SUMMON_VISUAL, true); + DoCast(me, SPELL_BLACK_HOLE_SUMMON_VISUAL_2, true); + VisualTimer = 0; + } + else + VisualTimer -= diff; + return; + } + + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + DoCast(me, SPELL_BLACK_HOLE_VISUAL_2, true); + DoCast(me, SPELL_BLACK_HOLE_PASSIVE, true); + ActivationTimer = 0; + if(Player* victim = GetClosestPlayer(me, 100)) + { + victimGUID = victim->GetGUID(); + me->GetMotionMaster()->MovePoint(0, victim->GetPositionX(), victim->GetPositionY(), 72.0, false); + } + ChasingTimer = 1000; + } + else + ActivationTimer -= diff; + } + + if(victimGUID && ChasingTimer) + { + if(ChasingTimer <= diff) + { + if (Unit* victim = me->GetUnit(victimGUID)) + { + if(me->IsWithinDistInMap(victim, 5.0)) + { + if(Unit* victim = SelectUnit(SELECT_TARGET_NEAREST, 0, 200, true, me->getVictimGUID(), 10.0)) + { + victimGUID = victim->GetGUID(); + me->GetMotionMaster()->MovePoint(0, victim->GetPositionX(), victim->GetPositionY(), 72.0, false); + } + } + else + me->GetMotionMaster()->MovePoint(0, victim->GetPositionX(), victim->GetPositionY(), 72.0, false); + } + ChasingTimer = 2000; + } + else + ChasingTimer -= diff; + } + + if (DespawnTimer < diff) + { + me->Kill(me, false); + me->RemoveCorpse(); + } + else + DespawnTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_blackhole(Creature *_Creature) +{ + return new npc_blackholeAI (_Creature); +} + +struct npc_darknessAI : public Scripted_NoMovementAI +{ + npc_darknessAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 VoidZoneTimer; + uint32 CheckTimer; + + void Reset() + { + DoCast(me, SPELL_VOID_ZONE_PRE_EFFECT_VISUAL, true); + VoidZoneTimer = 3000; + CheckTimer = 1000; + } + + void UpdateAI(const uint32 diff) + { + if(VoidZoneTimer) + { + if(VoidZoneTimer <= diff) + { + DoCast(me, SPELL_VOID_ZONE_PERIODIC); + DoCast(me, SPELL_SUMMON_DARK_FIEND); + me->RemoveAurasDueToSpell(SPELL_VOID_ZONE_PRE_EFFECT_VISUAL); + VoidZoneTimer = 0; + } + else + VoidZoneTimer -= diff; + } + if (CheckTimer) + { + if (pInstance->GetData(DATA_MURU_EVENT) == DONE || pInstance->GetData(DATA_MURU_EVENT) == NOT_STARTED) + me->DisappearAndDie(); + CheckTimer = 1000; + } + else + CheckTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_darkness(Creature *_Creature) +{ + return new npc_darknessAI (_Creature); +} + +/* +Shadowsword Fury Mage +*/ + +enum ShadowswordFuryMage +{ + SPELL_FEL_FIREBALL = 46101, + SPELL_SPELL_FURY = 46102 +}; + +struct mob_shadowsword_fury_mageAI : public ScriptedAI +{ + mob_shadowsword_fury_mageAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 SpellFury; + uint32 ActivationTimer; + WorldLocation wLoc; + + void Reset() + { + me->setActive(true); + ActivationTimer = 0; + if(Unit* Trigger = GetClosestCreatureWithEntry(me, CREATURE_WORLD_TRIGGER, 100)) + { + Trigger->GetPosition(wLoc); + me->GetMotionMaster()->MovePoint(1, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, false); + } + else + DoZoneInCombat(400.0f); + SpellFury = urand(25000, 35000); + } + + void OnAuraApply(Aura* aur, Unit* caster, bool stackApply) + { + if (aur->GetId() == SPELL_SPELL_FURY) + { + ClearCastQueue(); + SetAutocast(SPELL_FEL_FIREBALL, 1000, true); // 1 sec GCD + } + } + + void OnAuraRemove(Aura* aur, bool stackApply) + { + if (aur->GetId() == SPELL_SPELL_FURY) + { + ClearCastQueue(); + SetAutocast(SPELL_FEL_FIREBALL, RAND(6300, 8300), true); + } + } + + void MovementInform(uint32 Type, uint32 Id) + { + if(Type == POINT_MOTION_TYPE && Id == 1) + { + me->GetMotionMaster()->Clear(); + me->SetRooted(true); + ActivationTimer = 1000; + } + } + + void UpdateAI(const uint32 diff) + { + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) + { + if (me->GetSelection()) + me->SetSelection(NULL); + return; + } + + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + ActivationTimer = 0; + DoZoneInCombat(400); + me->SetRooted(false); + if(me->getVictim()) + DoStartMovement(me->getVictim()); + SetAutocast(SPELL_FEL_FIREBALL, RAND(6300, 8300), true); + } + else + ActivationTimer -= diff; + return; + } + + if(!UpdateVictim()) + return; + + if(SpellFury < diff) + { + ClearCastQueue(); + AddSpellToCast(SPELL_SPELL_FURY, CAST_SELF); + SpellFury = 60000; + } + else + SpellFury -= diff; + + CastNextSpellIfAnyAndReady(diff); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_shadowsword_fury_mage(Creature *_Creature) +{ + return new mob_shadowsword_fury_mageAI(_Creature); +} + +/* +Shadowsword Berserker +*/ + +enum ShadowswordBerserker +{ + SPELL_FLURRY = 46160, + SPELL_DUAL_WIELD = 29651, +}; + +struct mob_shadowsword_berserkerAI : public ScriptedAI +{ + mob_shadowsword_berserkerAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + WorldLocation wLoc; + uint32 Flurry; + uint32 ActivationTimer; + + void Reset() + { + me->setActive(true); + ActivationTimer = 0; + if(Unit* Trigger = GetClosestCreatureWithEntry(me, CREATURE_WORLD_TRIGGER, 100)) + { + Trigger->GetPosition(wLoc); + me->GetMotionMaster()->MovePoint(1, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, false); + } + else + DoZoneInCombat(400.0f); + DoCast(me, SPELL_DUAL_WIELD, true); + Flurry = urand(16000, 20000); + } + + void MovementInform(uint32 Type, uint32 Id) + { + if(Type == POINT_MOTION_TYPE && Id == 1) + { + me->GetMotionMaster()->Clear(); + me->SetRooted(true); + ActivationTimer = 1000; + } + } + + void UpdateAI(const uint32 diff) + { + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) + { + if (me->GetSelection()) + me->SetSelection(NULL); + return; + } + + if(ActivationTimer) + { + if(ActivationTimer <= diff) + { + ActivationTimer = 0; + DoZoneInCombat(400); + me->SetRooted(false); + if(me->getVictim()) + DoStartMovement(me->getVictim()); + } + else + ActivationTimer -= diff; + return; + } + + if(!UpdateVictim()) + return; + + if(Flurry < diff) + { + DoCast(me, SPELL_FLURRY); + Flurry = urand(15000, 20000); + } + else + Flurry -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_shadowsword_berserker(Creature *_Creature) +{ + return new mob_shadowsword_berserkerAI(_Creature); +} + +void AddSC_boss_muru() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_muru"; + newscript->GetAI = &GetAI_boss_muru; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="boss_entropius"; + newscript->GetAI = &GetAI_boss_entropius; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_muru_portal"; + newscript->GetAI = &GetAI_npc_muru_portal; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_void_summoner"; + newscript->GetAI = &GetAI_npc_void_summoner; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_dark_fiend"; + newscript->GetAI = &GetAI_npc_dark_fiend; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_void_sentinel"; + newscript->GetAI = &GetAI_npc_void_sentinel; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_void_spawn"; + newscript->GetAI = &GetAI_mob_void_spawn; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_blackhole"; + newscript->GetAI = &GetAI_npc_blackhole; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_darkness"; + newscript->GetAI = &GetAI_npc_darkness; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_shadowsword_fury_mage"; + newscript->GetAI = &GetAI_mob_shadowsword_fury_mage; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_shadowsword_berserker"; + newscript->GetAI = &GetAI_mob_shadowsword_berserker; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/def_sunwell_plateau.h old mode 100755 new mode 100644 similarity index 56% rename from src/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/def_sunwell_plateau.h index fe594da56..711818c2f --- a/src/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/def_sunwell_plateau.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_SUNWELLPLATEAU_H -#define DEF_SUNWELLPLATEAU_H +#ifndef SC_DEF_SUNWELLPLATEAU_H +#define SC_DEF_SUNWELLPLATEAU_H /*** Encounters ***/ #define DATA_KALECGOS_EVENT 1 @@ -13,7 +28,7 @@ #define DATA_EREDAR_TWINS_EVENT 5 #define DATA_MURU_EVENT 6 #define DATA_KILJAEDEN_EVENT 7 -#define DATA_TRASH_GAUNTLET_EVENT 8 +#define DATA_TRASH_GAUNTLET_EVENT 8 /*** Creatures ***/ #define DATA_KALECGOS_DRAGON 9 @@ -45,6 +60,9 @@ #define DATA_BRUTALLUS_TRIGGER 30 #define DATA_EREDAR_TWINS_INTRO 31 +#define DATA_KJ_TESTING_COUNTER 50 +#define DATA_KJ_TESTING 51 + #define SISTER_DEATH 1 #endif diff --git a/src/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp old mode 100755 new mode 100644 similarity index 73% rename from src/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp index e4e553d58..410d4b93a --- a/src/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/instance_sunwell_plateau.cpp @@ -1,11 +1,26 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Sunwell_Plateau -SD%Complete: 20 -SDComment: VERIFY SCRIPT, rename Gates +SD%Complete: 75 +SDComment: Muru testing SDCategory: Sunwell_Plateau EndScriptData */ @@ -69,13 +84,17 @@ struct instance_sunwell_plateau : public ScriptedInstance uint64 Collision_2; // Kalecgos Encounter uint64 FireBarrier; // Brutallus Encounter uint64 IceBarrier; // Brutallus Encounter - uint64 Gate[3]; + uint64 Gate[4]; + uint64 Archonisus; // Archonisus, the second gate /*** Misc ***/ uint32 KalecgosPhase; uint32 GauntletProgress; uint32 EredarTwinsIntro; + uint32 KJCounter; + uint32 KJTesting; + uint32 EredarTwinsAliveInfo[2]; void Initialize() @@ -114,6 +133,10 @@ struct instance_sunwell_plateau : public ScriptedInstance for(uint8 i = 0; i < ENCOUNTERS; ++i) Encounters[i] = NOT_STARTED; GauntletProgress = NOT_STARTED; + KJCounter = 10; + KJTesting = NOT_STARTED; + + requiredEncounterToMobs.clear(); } bool IsEncounterInProgress() const @@ -200,6 +223,26 @@ struct instance_sunwell_plateau : public ScriptedInstance } } + uint32 GetRequiredEncounterForEntry(uint32 entry) + { + switch (entry) + { + // Kil'jeaden + case 25315: + return DATA_MURU_EVENT; + // M'uru + case 25741: + case 25840: + return DATA_EREDAR_TWINS_EVENT; + // Eredar Twins + case 25166: + case 25165: + return DATA_FELMYST_EVENT; + default: + return 0; + } + } + void OnCreatureCreate(Creature* creature, uint32 entry) { switch(entry) @@ -248,19 +291,13 @@ struct instance_sunwell_plateau : public ScriptedInstance creature->SetFlag(UNIT_DYNAMIC_FLAGS, (UNIT_DYNFLAG_DEAD | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED)); } } + else + creature->SetReactState(REACT_PASSIVE); break; case 19871: BrutallusTrigger = creature->GetGUID(); break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void OnObjectCreate(GameObject* gobj) @@ -270,15 +307,40 @@ struct instance_sunwell_plateau : public ScriptedInstance case 188421: ForceField = gobj->GetGUID(); break; case 188523: Collision_1 = gobj->GetGUID(); break; case 188524: Collision_2 = gobj->GetGUID(); break; - case 188075: FireBarrier = gobj->GetGUID(); break; + case 188075: + FireBarrier = gobj->GetGUID(); + if(GetData(DATA_FELMYST_EVENT) == DONE) + HandleGameObject(FireBarrier, OPEN); + break; case 188119: IceBarrier = gobj->GetGUID(); break; // Eredar Twins Up - door 4 - case 187770: Gate[0] = gobj->GetGUID(); break; + case 187770: + Gate[0] = gobj->GetGUID(); + if(GetData(DATA_EREDAR_TWINS_EVENT) == DONE) + HandleGameObject(Gate[0], OPEN); + break; case 187990: // door 7 - if(gobj->GetGUIDLow() == 50110) // M'uru + if(gobj->GetDBTableGUIDLow() == 50110) // M'uru - entrance Gate[1] = gobj->GetGUID(); else // Eredar Twins Down - Gate[2] = gobj->GetGUID(); + { + Gate[2] = gobj->GetGUID(); + if(GetData(DATA_EREDAR_TWINS_EVENT) == DONE) + HandleGameObject(Gate[2], OPEN); + } + break; + case 188118: // door 8 - Muru ramp to Kil'jaeden + Gate[3] = gobj->GetGUID(); + if(GetData(DATA_MURU_EVENT) == DONE) + HandleGameObject(Gate[3], OPEN); + break; + case 187765: + Archonisus = gobj->GetGUID(); + /*if(GetData(DATA_MURU_EVENT) == DONE && GetData(DATA_KJ_TESTING) != DONE) + { + SetData(DATA_KJ_TESTING, IN_PROGRESS); + HandleGameObject(Archonisus, OPEN); + }*/ break; } } @@ -299,6 +361,8 @@ struct instance_sunwell_plateau : public ScriptedInstance case DATA_ALYTHESS: return EredarTwinsAliveInfo[0]; case DATA_SACROLASH: return EredarTwinsAliveInfo[1]; case DATA_EREDAR_TWINS_INTRO: return EredarTwinsIntro; + case DATA_KJ_TESTING_COUNTER: return KJCounter; + case DATA_KJ_TESTING: return KJTesting; } return 0; @@ -385,31 +449,49 @@ struct instance_sunwell_plateau : public ScriptedInstance HandleGameObject(Gate[0], OPEN); Encounters[4] = data; } - else + if(data == DONE) { HandleGameObject(Gate[0], OPEN); HandleGameObject(Gate[2], OPEN); + if(Player* pl = GetPlayerInMap()) + { + if(Unit* muru = pl->GetUnit(Muru)) + { + muru->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + muru->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + muru->SetVisibility(VISIBILITY_ON); + } + /*if(GetData(DATA_MURU_TESTING) != DONE) + { + SetData(DATA_MURU_TESTING, IN_PROGRESS); + HandleGameObject(Rohendor, OPEN); + }*/ + } } break; case DATA_MURU_EVENT: if(Encounters[5] != DONE) { - switch(data){ - case DONE: - HandleGameObject(Gate[4], OPEN); - HandleGameObject(Gate[3], OPEN); - break; + switch(data) + { case IN_PROGRESS: - HandleGameObject(Gate[4], CLOSE); + HandleGameObject(Gate[1], CLOSE); HandleGameObject(Gate[3], CLOSE); break; case NOT_STARTED: - HandleGameObject(Gate[4], CLOSE); - HandleGameObject(Gate[3], OPEN); + HandleGameObject(Gate[3], CLOSE); + HandleGameObject(Gate[1], OPEN); break; } Encounters[5] = data; } + if(data == DONE) + { + HandleGameObject(Gate[1], OPEN); + HandleGameObject(Gate[3], OPEN); + + // prepare KJ testing data here + } break; case DATA_KILJAEDEN_EVENT: if(Encounters[6] != DONE) @@ -452,10 +534,46 @@ struct instance_sunwell_plateau : public ScriptedInstance pSacrolash->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } break; + /*case DATA_KJ_TESTING: + if(KJTesting != DONE) + { + if(data == FAIL) + { + if(KJCounter) + { + --KJCounter; + SetData(DATA_KJ_TESTING_COUNTER, KJCounter); + if(!KJCounter) + data = DONE; + } + } + KJTesting = data; + } + break; + case DATA_KJ_TESTING_COUNTER: + KJCounter = data; + if(data) + { + KJTesting = IN_PROGRESS; + if(Player* pl = GetPlayerInMap()) + { + // to be changed!! + if(Unit* muru = pl->GetUnit(Muru)) + { + muru->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + muru->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + muru->SetVisibility(VISIBILITY_ON); + } + } + } + SaveToDB(); + break;*/ } if(data == DONE || data == FAIL) SaveToDB(); + + HandleRequiredEncounter(id); } void SetData64(uint32 id, uint64 guid) @@ -477,7 +595,9 @@ struct instance_sunwell_plateau : public ScriptedInstance stream << Encounters[3] << " "; stream << Encounters[4] << " "; stream << Encounters[5] << " "; - stream << Encounters[6]; + stream << Encounters[6] << " "; + stream << KJCounter << " "; + stream << KJTesting; OUT_SAVE_INST_DATA_COMPLETE; @@ -495,7 +615,7 @@ struct instance_sunwell_plateau : public ScriptedInstance OUT_LOAD_INST_DATA(in); std::istringstream stream(in); stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] - >> Encounters[4] >> Encounters[5] >> Encounters[6]; + >> Encounters[4] >> Encounters[5] >> Encounters[6] >> KJCounter >> KJTesting; for(uint8 i = 0; i < ENCOUNTERS; ++i) if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. Encounters[i] = NOT_STARTED; diff --git a/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau.cpp new file mode 100644 index 000000000..d2ad99f3e --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2009 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +/* ScriptData +SDName: Sunwell_Plateau +SD%Complete: 0 +SDComment: Placeholder, Epilogue after Kil'jaeden, Captain Selana Gossips +EndScriptData */ + +/* ContentData +npc_prophet_velen +npc_captain_selana +EndContentData */ + +#include "precompiled.h" +#include "def_sunwell_plateau.h" +#include "GameEvent.h" + +/*###### +## npc_prophet_velen +######*/ + +enum ProphetSpeeches +{ + PROPHET_SAY1 = -1580099, + PROPHET_SAY2 = -1580100, + PROPHET_SAY3 = -1580101, + PROPHET_SAY4 = -1580102, + PROPHET_SAY5 = -1580103, + PROPHET_SAY6 = -1580104, + PROPHET_SAY7 = -1580105, + PROPHET_SAY8 = -1580106 +}; + +enum LiadrinnSpeeches +{ + LIADRIN_SAY1 = -1580107, + LIADRIN_SAY2 = -1580108, + LIADRIN_SAY3 = -1580109 +}; + +/*###### +## npc_vindicator_moorba +######*/ + +#define GOSSIP_SWP_STATE "What is the current progress on Sunwell's offensive?" +#define GOSSIP_TELEPORT_APEX "With Kalecgos freed, can you provide a teleport up to Apex Point?" +#define GOSSIP_TELEPORT_SANCTUM "Now that Lady Sacrolash and Grand Warlock Alythess have been defeated, can you teleport me to the Witch's Sanctum." +#define GOSSIP_TELEPORT_SUNWELL "We've cleared the way to Kil'jaeden! Can you transport me close to the Sunwell?" + +bool GossipHello_npc_vindicator_moorba(Player *player, Creature *_Creature) +{ + ScriptedInstance* pInstance = _Creature->GetInstanceData(); + + for(uint32 i = 50; i < 54; ++i) + { + if(isGameEventActive(i)) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SWP_STATE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+i); + break; + } + } + + if (pInstance->GetData(DATA_MURU_EVENT) == DONE) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TELEPORT_SUNWELL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + else if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) == DONE) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TELEPORT_SANCTUM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + else if (pInstance->GetData(DATA_KALECGOS_EVENT) == DONE) + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TELEPORT_APEX, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + // when gates event in SWP is finished + if(isGameEventActive(54)) + player->SEND_GOSSIP_MENU(12403,_Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(12309,_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_vindicator_moorba(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->CastSpell(player, 46881, true); // teleport to Apex Point + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CastSpell(player, 46883, true); // teleport to Witch's Sanctum + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->CastSpell(player, 46884, true); // teleport close to the Sunwell + break; + case GOSSIP_ACTION_INFO_DEF+50: + HandleWorldEventGossip(player, _Creature); + player->SEND_GOSSIP_MENU(12400, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+51: + HandleWorldEventGossip(player, _Creature); + player->SEND_GOSSIP_MENU(12401, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+52: + HandleWorldEventGossip(player, _Creature); + player->SEND_GOSSIP_MENU(12402, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+54: + HandleWorldEventGossip(player, _Creature); + player->SEND_GOSSIP_MENU(12403, _Creature->GetGUID()); + break; + default: + break; + } + return true; +} + +/*###### +## npc_captain_selana +######*/ + +#define CS_GOSSIP1 "Give me a situation report, Captain." +#define CS_GOSSIP2 "What went wrong?" +#define CS_GOSSIP3 "Why did they stop?" +#define CS_GOSSIP4 "Your insight is appreciated." + +bool GossipHello_npc_captain_selana(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(12588, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_captain_selana(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(12589, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(12590, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(12591, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->SEND_GOSSIP_MENU(12592, _Creature->GetGUID()); + break; + } + return true; +} + +void AddSC_sunwell_plateau() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_vindicator_moorba"; + newscript->pGossipHello = &GossipHello_npc_vindicator_moorba; + newscript->pGossipSelect = &GossipSelect_npc_vindicator_moorba; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_captain_selana"; + newscript->pGossipHello = &GossipHello_npc_captain_selana; + newscript->pGossipSelect = &GossipSelect_npc_captain_selana; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau_trash.cpp b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau_trash.cpp similarity index 64% rename from src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau_trash.cpp rename to src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau_trash.cpp index 85ac2a4dc..09d42606f 100644 --- a/src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau_trash.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/sunwell_plateau/sunwell_plateau_trash.cpp @@ -1,13 +1,24 @@ -/* Copyright (C) 2008 - 2011 HellgroundDev +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData SDName: Sunwell_Plateau_Trash -SD%Complete: 27% (9/33) +SD%Complete: 100% (26/26) SDComment: Trash NPCs divided by to boss links SDCategory: Sunwell Plateau EndScriptData */ @@ -65,13 +76,6 @@ struct mob_sunblade_arch_mageAI : public ScriptedAI Blink = urand(10000, 18000); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void UpdateAI(const uint32 diff) @@ -154,13 +158,6 @@ struct mob_sunblade_cabalistAI : public ScriptedAI ScriptedAI::AttackStartNoMove(who, CHECK_TYPE_CASTER); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void JustSummoned(Creature* summon) @@ -247,13 +244,6 @@ struct mob_sunblade_dawn_priestAI : public ScriptedAI canSelfRenew = true; } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void UpdateAI(const uint32 diff) @@ -341,13 +331,6 @@ struct mob_sunblade_dusk_priestAI : public ScriptedAI MindFlay = urand(2000, 10000); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void UpdateAI(const uint32 diff) @@ -395,7 +378,7 @@ CreatureAI* GetAI_mob_sunblade_dusk_priest(Creature *_Creature) /**************** * Sunblade Protector - id 25507 - Immunities: bleed, snare, stun + Immunities: bleed, snare, stun, root *****************/ @@ -405,7 +388,9 @@ enum SunbladeProtector }; #define PROTECTOR_YELL "Unit entering energy conservation mode." -#define PROTECTOR_AGGRO "Enemy presence detected." +#define PROTECTOR_AGGRO_1 "Enemy presence detected." +#define PROTECTOR_AGGRO_2 "Local proximity threat detected. Exiting energy conservation mode." +#define PROTECTOR_ACTIVATED "Unit is now operational and attacking targets." struct mob_sunblade_protectorAI : public ScriptedAI { @@ -442,7 +427,9 @@ struct mob_sunblade_protectorAI : public ScriptedAI void EnterCombat(Unit*) { if(!isInactive) - DoYell(PROTECTOR_AGGRO, 0, me); + DoYell((urand(0,1) ? PROTECTOR_AGGRO_1 : PROTECTOR_AGGRO_2), 0, me); + else + DoYell(PROTECTOR_ACTIVATED, 0, me); DoZoneInCombat(80.0f); } @@ -502,13 +489,6 @@ struct mob_sunblade_scoutAI : public ScriptedAI SinisterStrike = urand(3000, 10000); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - bool ActivateProtector(Unit* who) { if(Unit* Protector = GetClosestCreatureWithEntry(me, 25507, 100, true, true)) @@ -518,7 +498,7 @@ struct mob_sunblade_scoutAI : public ScriptedAI DoYell(SCOUT_YELL, 0, who); float x, y, z; me->GetMotionMaster()->Clear(); - Protector->GetNearPoint(Protector, x, y, z, 0, urand(10, 20), Protector->GetAngle(me)); + Protector->GetNearPoint(x, y, z, 0, urand(10, 20), Protector->GetAngle(me)); Protector->UpdateAllowedPositionZ(x, y, z); me->SetWalk(false); me->GetMotionMaster()->MovePoint(0, x, y, z); @@ -614,13 +594,6 @@ struct mob_sunblade_slayerAI : public ScriptedAI DoCast(me, SPELL_DUAL_WIELD, true); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void AttackStart(Unit* who) @@ -677,7 +650,6 @@ CreatureAI* GetAI_mob_sunblade_slayer(Creature *_Creature) enum SunbladeVindicator { - SPELL_BRUTAL_STRIKE = 58460, SPELL_CLEAVE = 46559, SPELL_MORTAL_STRIKE = 44268 }; @@ -686,25 +658,16 @@ struct mob_sunblade_vindicatorAI : public ScriptedAI { mob_sunblade_vindicatorAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); } - uint32 BrutalStrike; uint32 Cleave; uint32 MortalStrike; void Reset() { ClearCastQueue(); - BrutalStrike = urand(1000, 5000); Cleave = urand(4000, 9000); MortalStrike = urand(5000, 15000); } - void EnterEvadeMode() - { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); - ScriptedAI::EnterEvadeMode(); - } - void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } void UpdateAI(const uint32 diff) @@ -712,14 +675,6 @@ struct mob_sunblade_vindicatorAI : public ScriptedAI if(!UpdateVictim()) return; - if(BrutalStrike < diff) - { - AddSpellToCast(SPELL_BRUTAL_STRIKE, CAST_TANK); - BrutalStrike = urand(5000,11000); - } - else - BrutalStrike -= diff; - if(Cleave < diff) { AddSpellToCast(SPELL_CLEAVE, CAST_TANK); @@ -766,11 +721,11 @@ CreatureAI* GetAI_mob_sunblade_vindicator(Creature *_Creature) /**************** * Shadowsword Assassin - id 25484 - Immunities: polymorph, disarm, stun + Immunities: disarm, fear, stun, polymorph *****************/ -#define GAUNTLET_PATH 2501 +#define GAUNTLET_PATH 2501 enum ShadowswordAssassin { @@ -806,10 +761,9 @@ struct mob_shadowsword_assassinAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } @@ -824,7 +778,7 @@ struct mob_shadowsword_assassinAI : public ScriptedAI { if (plr->isGameMaster() || plr->IsFriendlyTo(me)) continue; - if (plr->isAlive() && me->IsWithinDistInMap(plr, 40)) + if (plr->isAlive() && me->IsWithinDistInMap(plr, 35)) { DoCast(plr, SPELL_ASSASSINS_MARK, true); DoCast(plr, SPELL_SHADOWSTEP); @@ -836,9 +790,9 @@ struct mob_shadowsword_assassinAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE || who->GetTypeId() != TYPEID_PLAYER || me->getVictim() || me->IsInEvadeMode()) + if(!me->isAlive()) return; - if(me->IsWithinDistInMap(who, 50) && me->IsWithinLOSInMap(who)) + if(me->IsWithinLOSInMap(who) && !me->isInCombat()) DoRandomShadowstep(who); } @@ -885,7 +839,7 @@ CreatureAI* GetAI_mob_shadowsword_assassin(Creature *_Creature) /**************** * Shadowsword Commander - id 25837 - Immunities: polymorph, stun, fear + Immunities: polymorph, stun, fear, disarm, root, silence *****************/ @@ -904,7 +858,7 @@ enum ShadowswordCommander struct mob_shadowsword_commanderAI : public ScriptedAI { mob_shadowsword_commanderAI(Creature *c) : ScriptedAI(c) - { + { me->SetAggroRange(AGGRO_RANGE); pInstance = c->GetInstanceData(); } @@ -926,10 +880,9 @@ struct mob_shadowsword_commanderAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } @@ -937,14 +890,12 @@ struct mob_shadowsword_commanderAI : public ScriptedAI { if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) return; - DoZoneInCombat(80.0f); + DoZoneInCombat(80.0f); DoCast(me, SPELL_BATTLE_SHOUT); } void MoveInLineOfSight(Unit* who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; ScriptedAI::MoveInLineOfSight(who); } @@ -966,7 +917,7 @@ struct mob_shadowsword_commanderAI : public ScriptedAI if(Creature* ImpTrigger = GetClosestCreatureWithEntry(me, MOB_GAUNTLET_IMP_TRIGGER, 70)) TriggerGUID = ImpTrigger->GetGUID(); } - if(Yell_timer) + if(Yell_timer && TriggerGUID) { if(Yell_timer <= diff) { @@ -1010,7 +961,7 @@ CreatureAI* GetAI_mob_shadowsword_commander(Creature *_Creature) /**************** * Shadowsword Deathbringer - id 25485 - Immunities: root, stun, polymorph, interrupt, silence + Immunities: stun, polymorph, interrupt, silence *****************/ @@ -1030,6 +981,7 @@ struct mob_shadowsword_deathbringerAI : public ScriptedAI uint32 DiseaseBuffet; uint32 VolatileDisease; + uint32 DespawnTimer; ScriptedInstance* pInstance; void Reset() @@ -1037,6 +989,7 @@ struct mob_shadowsword_deathbringerAI : public ScriptedAI me->setActive(true); DiseaseBuffet = urand(5000, 10000); VolatileDisease = urand(3000, 6000); + DespawnTimer = 15000; DoCast(me, SPELL_DUAL_WIELD, true); } @@ -1044,6 +997,8 @@ struct mob_shadowsword_deathbringerAI : public ScriptedAI { if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + + ScriptedAI::EnterEvadeMode(); } void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } @@ -1056,6 +1011,14 @@ struct mob_shadowsword_deathbringerAI : public ScriptedAI void UpdateAI(const uint32 diff) { + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE && !me->isInCombat()) + { + if (DespawnTimer < diff) + me->ForcedDespawn(); + else + DespawnTimer -= diff; + } + if(!UpdateVictim()) return; @@ -1104,7 +1067,7 @@ struct mob_shadowsword_lifeshaperAI : public ScriptedAI mob_shadowsword_lifeshaperAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); - pInstance = c->GetInstanceData(); + pInstance = c->GetInstanceData(); } ScriptedInstance* pInstance; @@ -1118,6 +1081,8 @@ struct mob_shadowsword_lifeshaperAI : public ScriptedAI DrainLife = (4000, 10000); HealthFunnel = 8000; canFunnelHP = true; + if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE) + pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); } void JustDied(Unit* killer) @@ -1130,27 +1095,23 @@ struct mob_shadowsword_lifeshaperAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } void MoveInLineOfSight(Unit* who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; ScriptedAI::MoveInLineOfSight(who); } void EnterCombat(Unit*) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == NOT_STARTED) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, IN_PROGRESS); - DoZoneInCombat(80.0f); + + DoZoneInCombat(80.0f); } void UpdateAI(const uint32 diff) @@ -1228,6 +1189,8 @@ struct mob_shadowsword_manafiendAI : public ScriptedAI DoCast(me, SPELL_CHILLING_TOUCH_AURA); DrainMana = urand(3000, 5000); CheckTimer = 1000; + if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE) + pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); } void JustDied(Unit* killer) @@ -1240,26 +1203,22 @@ struct mob_shadowsword_manafiendAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } void MoveInLineOfSight(Unit* who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; ScriptedAI::MoveInLineOfSight(who); } void EnterCombat(Unit*) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == NOT_STARTED) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, IN_PROGRESS); + DoZoneInCombat(80.0f); } @@ -1314,7 +1273,7 @@ struct mob_shadowsword_soulbinderAI : public ScriptedAI mob_shadowsword_soulbinderAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); - pInstance = c->GetInstanceData(); + pInstance = c->GetInstanceData(); } ScriptedInstance* pInstance; @@ -1327,7 +1286,7 @@ struct mob_shadowsword_soulbinderAI : public ScriptedAI ClearCastQueue(); CurseOfExhaustion = urand(4000, 8000); Domination = urand(6000, 10000); - FlashOfDarkness = urand(2000, 4000); + FlashOfDarkness = urand(2000, 6000); } void JustDied(Unit* killer) @@ -1340,26 +1299,22 @@ struct mob_shadowsword_soulbinderAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } void MoveInLineOfSight(Unit* who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; ScriptedAI::MoveInLineOfSight(who); } void EnterCombat(Unit*) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == NOT_STARTED) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, IN_PROGRESS); + DoZoneInCombat(80.0f); } @@ -1405,7 +1360,7 @@ CreatureAI* GetAI_mob_shadowsword_soulbinder(Creature *_Creature) /**************** * Shadowsword Vanquisher - id 25486 - Immunities: polymorph, fear, taunt + Immunities: stun, disarm, taunt *****************/ @@ -1420,18 +1375,22 @@ struct mob_shadowsword_vanquisherAI : public ScriptedAI mob_shadowsword_vanquisherAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); - pInstance = c->GetInstanceData(); + pInstance = c->GetInstanceData(); + emote = false; } ScriptedInstance* pInstance; uint32 Cleave; uint32 MeltArmor; + bool emote; void Reset() { ClearCastQueue(); Cleave = urand(5000, 16000); MeltArmor = urand(3000, 10000); + if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE) + pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); } void JustDied(Unit* killer) @@ -1444,26 +1403,32 @@ struct mob_shadowsword_vanquisherAI : public ScriptedAI void EnterEvadeMode() { - if (CreatureGroup *formation = me->GetFormation()) - formation->RespawnFormation(me); if (pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + ScriptedAI::EnterEvadeMode(); } void MoveInLineOfSight(Unit* who) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; + if ((me->GetDBTableGUIDLow() == 44465 || me->GetDBTableGUIDLow() == 44468) && + who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 35) && !emote) + { + if (Creature* Manafiend = GetClosestCreatureWithEntry(me, 25483, 20)) + Manafiend->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_STATE_READY1H); + if (me->GetDBTableGUIDLow() == 44465) + me->Yell("Intruders! Do not let them into the Sanctum!", 0, who->GetGUID()); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_STATE_READY1H); + emote = true; + } ScriptedAI::MoveInLineOfSight(who); } void EnterCombat(Unit*) { - if(pInstance->GetData(DATA_FELMYST_EVENT) != DONE) - return; if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == NOT_STARTED) pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, IN_PROGRESS); + DoZoneInCombat(80.0f); } @@ -1499,9 +1464,9 @@ CreatureAI* GetAI_mob_shadowsword_vanquisher(Creature *_Creature) } /**************** -* Volatile Fiend - id 25486 +* Volatile Fiend - id 25851 - Immunities: + Immunities: banish, enslave, turn, fear, horror *****************/ @@ -1510,15 +1475,20 @@ enum VolatileFiend SPELL_BURNING_WINGS = 46308, SPELL_BURNING_DESTRUCTION = 47287, SPELL_BURNING_DESTRUCTION_EXPLOSION = 46218, - SPELL_FELFIRE_FISSION = 45779 // used in KJ fight? + SPELL_FELFIRE_FISSION = 45779 }; struct mob_volatile_fiendAI : public ScriptedAI { - mob_volatile_fiendAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); } + mob_volatile_fiendAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + me->SetAggroRange(AGGRO_RANGE); + } bool summoned, exploding; uint32 explosion_timer; + ScriptedInstance* pInstance; void Reset() { @@ -1530,8 +1500,11 @@ struct mob_volatile_fiendAI : public ScriptedAI void EnterCombat(Unit*) { DoZoneInCombat(80.0f); - DoCast(me, SPELL_BURNING_DESTRUCTION); - exploding = true; + if (summoned) + { + DoCast(me, SPELL_BURNING_DESTRUCTION); + exploding = true; + } } void IsSummonedBy(Unit *summoner) @@ -1542,9 +1515,18 @@ struct mob_volatile_fiendAI : public ScriptedAI me->GetMotionMaster()->MovePath(GAUNTLET_PATH, false); } + void DamageTaken(Unit* pDone_by, uint32& damage) + { + if (!summoned && damage > me->GetHealth()) + DoCast(me, SPELL_FELFIRE_FISSION, true); + } + void MoveInLineOfSight(Unit *who) { - if(who->GetTypeId() != TYPEID_PLAYER || !summoned || exploding) + if (!summoned && pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + if(who->GetTypeId() != TYPEID_PLAYER || (summoned && exploding)) return; ScriptedAI::MoveInLineOfSight(who); @@ -1552,6 +1534,10 @@ struct mob_volatile_fiendAI : public ScriptedAI void UpdateAI(const uint32 diff) { + if (summoned && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE && + !me->isInCombat() && pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) + pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, FAIL); + if(exploding) { if(explosion_timer < diff) @@ -1567,11 +1553,6 @@ struct mob_volatile_fiendAI : public ScriptedAI return; DoMeleeAttackIfReady(); - - if(!summoned) - return; - - // AI here for normal, not gauntlet-type Fiend? } }; @@ -1595,173 +1576,892 @@ CreatureAI* GetAI_mob_volatile_fiend(Creature *_Creature) * Oblivion Mage * Painbringer * Priestess of Torment - * Volatile Fiend - * Volatile Felfire Fiend - * Shadowsword Berserker - * Shadowsword Fury Mage - * Void Sentinel - * Void Spawn */ /**************** -* Apocalypse Guard - id -*****************/ - -/* ============================ -* -* KIL'JAEDEN -* -* ============================*/ - -/* Content Data - * Shadowsword Guardian - * Hand of the Deceiver -*/ +* Apocalypse Guard - id 25593 -/**************** -* Shadowsword Guardian - id -*****************/ + Immunities: banish, enslave, turn, horror, confuse, stun, fear, horror, silence -/**************** -* Gauntlet Imp Trigger - id 25848 -* *****************/ -#define SPELL_SUMMON_VISUAL 46172 +enum ApocalypseGuard +{ + SPELL_CLEAVE_3 = 40504, + SPELL_CORRUPTING_STRIKE = 45029, + SPELL_DEATH_COIL = 46283, + SPELL_INFERNAL_DEFENSE = 46287 +}; -struct npc_gauntlet_imp_triggerAI : public Scripted_NoMovementAI +struct mob_apocalypse_guardAI : public ScriptedAI { - npc_gauntlet_imp_triggerAI(Creature *c) : Scripted_NoMovementAI(c), summons(c) - { - me->SetAggroRange(1.0); + mob_apocalypse_guardAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); pInstance = c->GetInstanceData(); - me->GetPosition(wLoc); } ScriptedInstance* pInstance; - WorldLocation wLoc; - SummonList summons; - uint32 Deathbringer_timer; - uint32 Imp_timer; + uint32 Cleave; + uint32 CorruptingStrike; + uint32 DeathCoil; + bool InfernalDefense; void Reset() { - me->setActive(true); - Deathbringer_timer = 30000; - Imp_timer = 1000; - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - summons.DespawnAll(); + Cleave = urand(3500, 5500); + CorruptingStrike = urand(4000, 10000); + DeathCoil = urand(3000, 7000); + InfernalDefense = false; } - void JustRespawned() - { - pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, NOT_STARTED); - if(me->HasAura(SPELL_SUMMON_VISUAL)) - me->RemoveAura(SPELL_SUMMON_VISUAL, 0); - summons.DespawnAll(); - } - void JustSummoned(Creature *summon) + void MoveInLineOfSight(Unit* who) { - summons.Summon(summon); - } + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; - void EnterCombat(Unit* who) - { - return; + ScriptedAI::MoveInLineOfSight(who); } + void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } + void UpdateAI(const uint32 diff) { - if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) + if(!UpdateVictim()) + return; + + if(HealthBelowPct(7.0f) && !InfernalDefense) { - if(!me->HasAura(SPELL_SUMMON_VISUAL)) - DoCast(me, SPELL_SUMMON_VISUAL, true); + DoCast(me, SPELL_INFERNAL_DEFENSE, true); + InfernalDefense = true; + } - if(Imp_timer < diff) - { - me->SummonCreature(MOB_VOLATILE_FIEND, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, wLoc.orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - Imp_timer = 12000; - } - else - Imp_timer -= diff; + if(Cleave < diff) + { + AddSpellToCast(SPELL_CLEAVE_3, CAST_TANK); + Cleave = urand(4000, 8000); + } + else + Cleave -= diff; - if(Deathbringer_timer < diff) - { - me->SummonCreature(MOB_SHADOWSWORD_DEATHBRINGER, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, wLoc.orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); - Deathbringer_timer = 45000; - } - Deathbringer_timer -= diff; + if(CorruptingStrike < diff) + { + AddSpellToCast(SPELL_CORRUPTING_STRIKE, CAST_TANK); + CorruptingStrike = urand(6000, 12000); } + else + CorruptingStrike -= diff; - if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == FAIL) - JustRespawned(); + if(DeathCoil < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 30.0, true, me->getVictimGUID(), 5.0)) + AddSpellToCast(target, SPELL_DEATH_COIL, false, true); + DeathCoil = urand(7000, 12000); + } + else + DeathCoil -= diff; - if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE) - me->Kill(me, false); + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_npc_gauntlet_imp_trigger(Creature *_Creature) +CreatureAI* GetAI_mob_apocalypse_guard(Creature *_Creature) { - return new npc_gauntlet_imp_triggerAI(_Creature); + return new mob_apocalypse_guardAI(_Creature); } -void AddSC_sunwell_plateau_trash() -{ - Script *newscript; +/**************** +* Cataclysm Hound - id 25599 - // Kalecgos & Sathovarr & Brutallus & Felmyst - newscript = new Script; - newscript->Name = "mob_sunblade_arch_mage"; - newscript->GetAI = &GetAI_mob_sunblade_arch_mage; - newscript->RegisterSelf(); + Immunities: banish, enslave, turn, horror, root, confuse, stun, fear, horror, silence, taunt - newscript = new Script; - newscript->Name = "mob_sunblade_cabalist"; - newscript->GetAI = &GetAI_mob_sunblade_cabalist; - newscript->RegisterSelf(); +*****************/ - newscript = new Script; - newscript->Name = "mob_sunblade_dawn_priest"; - newscript->GetAI = &GetAI_mob_sunblade_dawn_priest; - newscript->RegisterSelf(); +enum CataclysmHound +{ + SPELL_ENRAGE = 47399, + SPELL_CATACLYSM_BREATH = 46292 +}; - newscript = new Script; - newscript->Name = "mob_sunblade_dusk_priest"; - newscript->GetAI = &GetAI_mob_sunblade_dusk_priest; - newscript->RegisterSelf(); +struct mob_cataclysm_houndAI : public ScriptedAI +{ + mob_cataclysm_houndAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } - newscript = new Script; - newscript->Name = "mob_sunblade_protector"; - newscript->GetAI = &GetAI_mob_sunblade_protector; - newscript->RegisterSelf(); + ScriptedInstance* pInstance; + uint32 Enrage; + uint32 CataclysmBreath; - newscript = new Script; - newscript->Name = "mob_sunblade_scout"; - newscript->GetAI = &GetAI_mob_sunblade_scout; - newscript->RegisterSelf(); + void Reset() + { + Enrage = urand(10000, 20000); + CataclysmBreath = urand(4000, 10000); + } - newscript = new Script; - newscript->Name = "mob_sunblade_slayer"; - newscript->GetAI = &GetAI_mob_sunblade_slayer; - newscript->RegisterSelf(); - newscript = new Script; - newscript->Name = "mob_sunblade_vindicator"; - newscript->GetAI = &GetAI_mob_sunblade_vindicator; - newscript->RegisterSelf(); + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; - // Eredar Twins - newscript = new Script; - newscript->Name = "mob_shadowsword_assassin"; - newscript->GetAI = &GetAI_mob_shadowsword_assassin; - newscript->RegisterSelf(); + ScriptedAI::MoveInLineOfSight(who); + } - newscript = new Script; - newscript->Name = "mob_shadowsword_commander"; - newscript->GetAI = &GetAI_mob_shadowsword_commander; + void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if(Enrage < diff) + { + AddSpellToCast(SPELL_ENRAGE, CAST_SELF); + Enrage = urand(10000, 12000); + } + else + Enrage -= diff; + + if(CataclysmBreath < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 20, true)) + { + ClearCastQueue(); + me->SetInFront(target); + AddSpellToCast(target, SPELL_CATACLYSM_BREATH, false, true); + } + CataclysmBreath = 8000; + } + else + CataclysmBreath -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_cataclysm_hound(Creature *_Creature) +{ + return new mob_cataclysm_houndAI(_Creature); +} + +/**************** +* Chaos Gazer - id 25595 + + Immunities: banish, enslave, turn, horror, confuse, stun, fear, horror, interrupt, silence + +*****************/ + +enum ChaosGazer +{ + SPELL_DRAIN_LIFE_1 = 46291, + SPELL_PETRIFY = 46288, + SPELL_TENTACLE_SWEEP = 46290 +}; + +struct mob_chaos_gazerAI : public ScriptedAI +{ + mob_chaos_gazerAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 DrainLifeCD; + uint32 Petrify; + uint32 TentacleSweep; + bool canDrainLife; + + void Reset() + { + DrainLifeCD = urand(10000, 12000); + Petrify = urand(3000, 7000); + TentacleSweep = Petrify + urand(1000, 1500); + canDrainLife = true; + } + + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if(HealthBelowPct(75.0f) && canDrainLife) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 22.0, true, 0, 16.0)) + { + ForceSpellCast(target, SPELL_DRAIN_LIFE_1, DONT_INTERRUPT, false, true); + DrainLifeCD = urand(10000, 12000); + } + else + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 16.0, true, 0, 8.0)) + { + ForceSpellCast(target, SPELL_DRAIN_LIFE_1, DONT_INTERRUPT, false, true); + DrainLifeCD = urand(10000, 12000); + } + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 8.0, true, me->getVictimGUID())) + { + ForceSpellCast(target, SPELL_DRAIN_LIFE_1, DONT_INTERRUPT, false, true); + DrainLifeCD = urand(10000, 12000); + } + else + DrainLifeCD = 1000; + canDrainLife = false; + } + + if(!canDrainLife) + { + if(DrainLifeCD <= diff) + canDrainLife = true; + else + DrainLifeCD -= diff; + } + + if(Petrify < diff) + { + AddSpellToCast(SPELL_PETRIFY, CAST_TANK); + Petrify = urand(9000, 12000); + } + else + Petrify -= diff; + + if(TentacleSweep < diff) + { + AddSpellToCast(SPELL_TENTACLE_SWEEP, CAST_TANK); + TentacleSweep = urand(7000, 12000); + } + else + TentacleSweep -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_chaos_gazer(Creature *_Creature) +{ + return new mob_chaos_gazerAI(_Creature); +} + + +/**************** +* Doomfire Destroyer - id 25592 + + Immunities: banish, enslave, turn, confuse, stun, fear, horror + +*****************/ + +enum DoomfireDestroyer +{ + SPELL_CREATE_DOMMFIRE_SHARD = 46306, + SPELL_IMMOLATION_AURA = 31722 +}; + +struct mob_doomfire_destroyerAI : public ScriptedAI +{ + mob_doomfire_destroyerAI(Creature *c) : ScriptedAI(c), summons(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 SummonTimer; + SummonList summons; + + void Reset() + { + DoCast(me, SPELL_IMMOLATION_AURA, true); + SummonTimer = 1000; + summons.DespawnAll(); + } + + void EnterEvadeMode() + { + summons.DespawnAll(); + ScriptedAI::EnterEvadeMode(); + } + + void JustSummoned(Creature *summon) + { + summons.Summon(summon); + } + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) + { + DoZoneInCombat(80.0f); + } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if(SummonTimer < diff) + { + AddSpellToCast(SPELL_CREATE_DOMMFIRE_SHARD, CAST_NULL); + SummonTimer = urand(5500, 7000); + } + else + SummonTimer -= diff; + + CastNextSpellIfAnyAndReady(); + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_doomfire_destroyer(Creature *_Creature) +{ + return new mob_doomfire_destroyerAI(_Creature); +} + +/**************** +* Doomfire Shard - id 25948 + + Immunities: banish, enslave, turn, confuse, stun, fear, horror + +*****************/ + +enum DoomfireShard +{ + SPELL_AVENGING_RAGE = 46305 +}; + +struct mob_doomfire_shardAI : public ScriptedAI +{ + mob_doomfire_shardAI(Creature *c) : ScriptedAI(c) + { + DestroyerGUID = 0; + } + + uint64 DestroyerGUID; + + void Reset() + { + DoCast(me, SPELL_IMMOLATION_AURA, true); + } + + void IsSummonedBy(Unit *pSummoner) + { + if (pSummoner) + { + DestroyerGUID = pSummoner->GetGUID(); + DoZoneInCombat(80.0f); + } + } + + void DamageTaken(Unit* pDone_by, uint32& damage) + { + if (damage > me->GetHealth()) + { + if (Unit* Destroyer = me->GetUnit(DestroyerGUID)) + { + if (Destroyer->isAlive()) + DoCast(Destroyer, SPELL_AVENGING_RAGE, true); + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_doomfire_shard(Creature *_Creature) +{ + return new mob_doomfire_shardAI(_Creature); +} + +/**************** +* Oblivion Mage - id 25597 + + Immunities: silence, interrupt, spell haste reduction, polymorph, stun, fear, horror + +*****************/ + +enum OblivionMage +{ + SPELL_FLAME_BUFFET = 46279, + SPELL_POLYMORPH = 46280, + SPELL_FIRE_CHANNELING = 46219, + + NPC_DOOMFIRE_DESTROYER = 25592 +}; + +struct mob_oblivion_mageAI : public ScriptedAI +{ + mob_oblivion_mageAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(20.0); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 Polymorph; + uint32 EvadeTimer; + bool channeling; + + void Reset() + { + SetAutocast(SPELL_FLAME_BUFFET, 2000, true); + Polymorph = 1000; + EvadeTimer = 10000; + channeling = false; + } + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) + { + DoZoneInCombat(80.0f); + if (me->IsNonMeleeSpellCast(false)) + me->InterruptNonMeleeSpells(false); + } + + void UpdateAI(const uint32 diff) + { + if (!me->isInCombat() && !channeling) + { + if(EvadeTimer <= diff) + { + if (Unit* Destroyer = FindCreature(NPC_DOOMFIRE_DESTROYER, 20, me)) + DoCast(me, SPELL_FIRE_CHANNELING); + channeling = true; + } + else + EvadeTimer -= diff; + } + + if(!UpdateVictim()) + return; + + if(!me->getVictim()->IsWithinDistInMap(me, 20) && !me->IsNonMeleeSpellCast(false)) + { + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 20.0, true)) + AttackStart(target, false); + } + + if(Polymorph < diff) + { + ClearCastQueue(); + AddSpellToCast(SPELL_POLYMORPH, CAST_RANDOM_WITHOUT_TANK, false, true); + Polymorph = urand(5000, 8000); + } + else + Polymorph -= diff; + + CastNextSpellIfAnyAndReady(diff); + } +}; + +CreatureAI* GetAI_mob_oblivion_mage(Creature *_Creature) +{ + return new mob_oblivion_mageAI(_Creature); +} + +/**************** +* Painbringer - id 25591 + + Immunities: banish, enslave, turn, horror, fear, disorient, root + +*****************/ + +enum Painbringer +{ + SPELL_BRING_PAIN_AURA = 46277 +}; + +struct mob_painbringerAI : public ScriptedAI +{ + mob_painbringerAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + + void Reset() + { + DoCast(me, SPELL_BRING_PAIN_AURA, true); + } + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_painbringer(Creature *_Creature) +{ + return new mob_painbringerAI(_Creature); +} + +/**************** +* Priestess of Torment - id 25509 + + Immunities: banish, enslave, turn, stun, fear, horror, confuse, root + +*****************/ + +enum PriestessOfTorment +{ + SPELL_BURN_MANA_AURA = 46267, + SPELL_WHIRLWIND = 46270, +}; + +struct mob_priestess_of_tormentAI : public ScriptedAI +{ + mob_priestess_of_tormentAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 Whirlwind; + uint32 MoveTimer; + bool moving; + + void Reset() + { + DoCast(me, SPELL_BURN_MANA_AURA, true); + Whirlwind = urand(2500, 4500); + MoveTimer = 1000; + moving = false; + } + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_EREDAR_TWINS_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) { DoZoneInCombat(80.0f); } + + void OnAuraRemove(Aura* Aur, bool stack) + { + if(Aur->GetId() == SPELL_WHIRLWIND) + { + moving = false; + AttackStart(me->getVictim()); + } + } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if (moving) + { + if(MoveTimer < diff) + { + float x, y, z = 0; + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 40.0f, true)) + { + target->GetGroundPointAroundUnit(x, y, z, 5.0, 3.14*RAND(0, 1/6, 2/6, 3/6, 4/6, 5/6, 1)); + me->GetMotionMaster()->Clear(false); + me->SetSpeed(MOVE_RUN, 1.5, true); + me->GetMotionMaster()->MovePoint(0, x, y, z); + } + MoveTimer = urand(1000, 2500); + } + else + MoveTimer -= diff; + } + + if(Whirlwind < diff) + { + DoCast(me, SPELL_WHIRLWIND); + moving = true; + Whirlwind = urand(13000, 16000); + } + else + Whirlwind -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_priestess_of_torment(Creature *_Creature) +{ + return new mob_priestess_of_tormentAI(_Creature); +} + +/* ============================ +* +* KIL'JAEDEN +* +* ============================*/ + +/* Content Data + * Shadowsword Guardian + * Hand of the Deceiver - at KJ script +*/ + +/**************** +* Shadowsword Guardian - id 25508 + + Immunities: TBD + +*****************/ + +enum ShadowswordGuardian +{ + SPELL_BEAR_DOWN = 46239, + SPELL_EARTHQUAKE = 46932 +}; + +struct mob_shadowsword_guardianAI : public ScriptedAI +{ + mob_shadowsword_guardianAI(Creature *c) : ScriptedAI(c) + { + me->SetAggroRange(AGGRO_RANGE); + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 BearDown; + + void Reset() + { + BearDown = urand(7000, 10000); + } + + void MoveInLineOfSight(Unit* who) + { + if (pInstance->GetData(DATA_MURU_EVENT) != DONE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit*) + { + if (pInstance->GetData(DATA_MURU_EVENT) != DONE) + { + EnterEvadeMode(); + return; + } + DoCast(me, SPELL_EARTHQUAKE); + DoZoneInCombat(80.0f); + } + + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if(BearDown < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 50.0f, true, me->getVictimGUID(), 7.0f)) + AddSpellToCast(target, SPELL_BEAR_DOWN, false, true); + BearDown = urand(7000, 14000); + } + else + BearDown -= diff; + + DoMeleeAttackIfReady(); + CastNextSpellIfAnyAndReady(); + } +}; + +CreatureAI* GetAI_mob_shadowsword_guardian(Creature *_Creature) +{ + return new mob_shadowsword_guardianAI(_Creature); +} + +/**************** +* Gauntlet Imp Trigger - id 25848 +* +*****************/ + +#define SPELL_SUMMON_VISUAL 46172 + +struct npc_gauntlet_imp_triggerAI : public Scripted_NoMovementAI +{ + npc_gauntlet_imp_triggerAI(Creature *c) : Scripted_NoMovementAI(c), summons(c) + { + me->SetAggroRange(2*AGGRO_RANGE); + pInstance = c->GetInstanceData(); + me->GetPosition(wLoc); + } + + ScriptedInstance* pInstance; + WorldLocation wLoc; + SummonList summons; + uint32 Deathbringer_timer; + uint32 Imp_timer; + + void Reset() + { + me->setActive(true); + Deathbringer_timer = 30000; + Imp_timer = 1000; + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + summons.DespawnAll(); + } + + void JustRespawned() + { + pInstance->SetData(DATA_TRASH_GAUNTLET_EVENT, NOT_STARTED); + if(me->HasAura(SPELL_SUMMON_VISUAL)) + me->RemoveAura(SPELL_SUMMON_VISUAL, 0); + summons.DespawnAll(); + } + + void JustSummoned(Creature *summon) + { + summons.Summon(summon); + } + + void EnterCombat(Unit* who) + { + return; + } + + void UpdateAI(const uint32 diff) + { + if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == IN_PROGRESS) + { + if(!me->HasAura(SPELL_SUMMON_VISUAL)) + DoCast(me, SPELL_SUMMON_VISUAL, true); + + if(Imp_timer < diff) + { + me->SummonCreature(MOB_VOLATILE_FIEND, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, wLoc.orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + Imp_timer = 12000; + } + else + Imp_timer -= diff; + + if(Deathbringer_timer < diff) + { + me->SummonCreature(MOB_SHADOWSWORD_DEATHBRINGER, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, wLoc.orientation, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); + Deathbringer_timer = 45000; + } + Deathbringer_timer -= diff; + } + + if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == FAIL) + JustRespawned(); + + if(pInstance->GetData(DATA_TRASH_GAUNTLET_EVENT) == DONE) + { + me->Kill(me, false); + JustRespawned(); + } + } +}; + +CreatureAI* GetAI_npc_gauntlet_imp_trigger(Creature *_Creature) +{ + return new npc_gauntlet_imp_triggerAI(_Creature); +} + +void AddSC_sunwell_plateau_trash() +{ + Script *newscript; + + // Kalecgos & Sathovarr & Brutallus & Felmyst + newscript = new Script; + newscript->Name = "mob_sunblade_arch_mage"; + newscript->GetAI = &GetAI_mob_sunblade_arch_mage; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_cabalist"; + newscript->GetAI = &GetAI_mob_sunblade_cabalist; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_dawn_priest"; + newscript->GetAI = &GetAI_mob_sunblade_dawn_priest; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_dusk_priest"; + newscript->GetAI = &GetAI_mob_sunblade_dusk_priest; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_protector"; + newscript->GetAI = &GetAI_mob_sunblade_protector; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_scout"; + newscript->GetAI = &GetAI_mob_sunblade_scout; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_slayer"; + newscript->GetAI = &GetAI_mob_sunblade_slayer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_sunblade_vindicator"; + newscript->GetAI = &GetAI_mob_sunblade_vindicator; + newscript->RegisterSelf(); + + // Eredar Twins + newscript = new Script; + newscript->Name = "mob_shadowsword_assassin"; + newscript->GetAI = &GetAI_mob_shadowsword_assassin; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_shadowsword_commander"; + newscript->GetAI = &GetAI_mob_shadowsword_commander; newscript->RegisterSelf(); newscript = new Script; @@ -1794,6 +2494,54 @@ void AddSC_sunwell_plateau_trash() newscript->GetAI = &GetAI_mob_volatile_fiend; newscript->RegisterSelf(); + // M'uru + newscript = new Script; + newscript->Name = "mob_apocalypse_guard"; + newscript->GetAI = &GetAI_mob_apocalypse_guard; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_cataclysm_hound"; + newscript->GetAI = &GetAI_mob_cataclysm_hound; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_chaos_gazer"; + newscript->GetAI = &GetAI_mob_chaos_gazer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_doomfire_destroyer"; + newscript->GetAI = &GetAI_mob_doomfire_destroyer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_doomfire_shard"; + newscript->GetAI = &GetAI_mob_doomfire_shard; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_oblivion_mage"; + newscript->GetAI = &GetAI_mob_oblivion_mage; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_painbringer"; + newscript->GetAI = &GetAI_mob_painbringer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_priestess_of_torment"; + newscript->GetAI = &GetAI_mob_priestess_of_torment; + newscript->RegisterSelf(); + + // Kil'jaeden + newscript = new Script; + newscript->Name = "mob_shadowsword_guardian"; + newscript->GetAI = &GetAI_mob_shadowsword_guardian; + newscript->RegisterSelf(); + + // others newscript = new Script; newscript->Name = "npc_gauntlet_imp_trigger"; newscript->GetAI = &GetAI_npc_gauntlet_imp_trigger; diff --git a/src/scripts/scripts/zone/swamp of sorrows/swamp_of_sorrows.cpp b/src/scripts/scripts/Eastern Kingdoms/swamp of sorrows/swamp_of_sorrows.cpp similarity index 84% rename from src/scripts/scripts/zone/swamp of sorrows/swamp_of_sorrows.cpp rename to src/scripts/scripts/Eastern Kingdoms/swamp of sorrows/swamp_of_sorrows.cpp index 515690f57..48ef23c0f 100644 --- a/src/scripts/scripts/zone/swamp of sorrows/swamp_of_sorrows.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/swamp of sorrows/swamp_of_sorrows.cpp @@ -1,8 +1,19 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp b/src/scripts/scripts/Eastern Kingdoms/tirisfal_glades/tirisfal_glades.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp rename to src/scripts/scripts/Eastern Kingdoms/tirisfal_glades/tirisfal_glades.cpp index 1f25cabb7..63131cf47 --- a/src/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/tirisfal_glades/tirisfal_glades.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/uldaman/boss_archaedas.cpp b/src/scripts/scripts/Eastern Kingdoms/uldaman/boss_archaedas.cpp old mode 100755 new mode 100644 similarity index 65% rename from src/scripts/scripts/zone/uldaman/boss_archaedas.cpp rename to src/scripts/scripts/Eastern Kingdoms/uldaman/boss_archaedas.cpp index 85c95fad1..96a6d893a --- a/src/scripts/scripts/zone/uldaman/boss_archaedas.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/uldaman/boss_archaedas.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006,2007 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2007 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_archaedas @@ -74,6 +77,7 @@ struct boss_archaedasAI : public ScriptedAI guardiansAwake = false; vaultWalkersAwake = false; + if (pInstance) pInstance->SetData (DATA_ANCIENT_DOOR, NOT_STARTED); if (pInstance) pInstance->SetData (DATA_MINIONS, NOT_STARTED); // respawn any dead minions m_creature->setFaction(35); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -92,14 +96,6 @@ struct boss_archaedasAI : public ScriptedAI } } - - void EnterCombat(Unit *who) - { - m_creature->setFaction (14); - m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag (UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE); - } - void SpellHit (Unit* caster, const SpellEntry *spell) { // Being woken up from the altar, start the awaken sequence @@ -127,7 +123,9 @@ struct boss_archaedasAI : public ScriptedAI return; // dont do anything until we are done } else if (wakingUp && Awaken_Timer <= 0) { wakingUp = false; - AttackStart(Unit::GetUnit(*m_creature, pInstance->GetData64(0))); + m_creature->setFaction (14); + m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag (UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE); return; // dont want to continue until we finish the AttackStart method } @@ -240,7 +238,6 @@ struct mob_archaedas_minionsAI : public ScriptedAI m_creature->RemoveAllAuras(); m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); m_creature->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - amIAwake = true; } void SpellHit (Unit* caster, const SpellEntry *spell) { @@ -266,7 +263,7 @@ struct mob_archaedas_minionsAI : public ScriptedAI } else if (wakingUp && Awaken_Timer <= 0) { wakingUp = false; amIAwake = true; - AttackStart(Unit::GetUnit(*m_creature, pInstance->GetData64(0))); // whoWokeArchaedasGUID + AttackStart(me->GetCreature(pInstance->GetData64(0))->getVictim()); return; // dont want to continue until we finish the AttackStart method } @@ -284,69 +281,6 @@ CreatureAI* GetAI_mob_archaedas_minions(Creature *_Creature) return new mob_archaedas_minionsAI (_Creature); } -/* ScriptData -SDName: go_altar_archaedas -SD%Complete: 100 -SDComment: Needs 3 people to activate the Archaedas script -SDCategory: Uldaman -EndScriptData */ - - -#define OBJECT_ALTAR_OF_ARCHAEDAS 133234 - -#define NUMBER_NEEDED_TO_ACTIVATE 3 - -#define SPELL_BOSS_OBJECT_VISUAL 11206 - -uint64 altarOfArchaedasCount[5]; -int32 altarOfArchaedasCounter=0; - - -bool GOUse_go_altar_of_archaedas(Player *player, GameObject* go) -{ - bool alreadyUsed; - // avoid crash - if(altarOfArchaedasCounter >= 4) - return false; - - go->AddUse (); - - alreadyUsed = false; - for (uint32 loop=0; loop<5; loop++) - { - if (altarOfArchaedasCount[loop] == player->GetGUID()) alreadyUsed = true; - } - if (!alreadyUsed) - altarOfArchaedasCount[altarOfArchaedasCounter++] = player->GetGUID(); - - player->CastSpell (player, SPELL_BOSS_OBJECT_VISUAL, false); - - if (altarOfArchaedasCounter < NUMBER_NEEDED_TO_ACTIVATE) { - return false; // not enough people yet - } - - // Check to make sure at least three people are still casting - uint32 count=0; - Unit *pTarget; - for (uint32 x=0; x<=5; x++) - { - pTarget = Unit::GetUnit(*player, altarOfArchaedasCount[x]); - if (!pTarget) continue; - if (pTarget->IsNonMeleeSpellCasted(true)) count++; - if (count >= NUMBER_NEEDED_TO_ACTIVATE) break; - } - - if (count < NUMBER_NEEDED_TO_ACTIVATE) { - return false; // not enough people - } - - ScriptedInstance* pInstance = (player->GetInstanceData()); - if (!pInstance) return false; - pInstance->SetData64(0,player->GetGUID()); // activate archaedas - - return false; -} - /* ScriptData SDName: mob_stonekeepers SD%Complete: 100 @@ -406,69 +340,6 @@ CreatureAI* GetAI_mob_stonekeepers(Creature *_Creature) return new mob_stonekeepersAI (_Creature); } -/* ScriptData -SDName: go_altar_of_the_keepers -SD%Complete: 100 -SDComment: Need 3 people to activate to open the altar. One by one the StoneKeepers will activate. After all four are dead than the door will open. -SDCategory: Uldaman -EndScriptData */ - - -#define SPELL_BOSS_OBJECT_VISUAL 11206 - -#define NUMBER_NEEDED_TO_ACTIVATE 3 - -static uint64 altarOfTheKeeperCount[5]; -static uint32 altarOfTheKeeperCounter=0; - -bool GOUse_go_altar_of_the_keepers(Player *player, GameObject* go) -{ - ScriptedInstance* pInstance = (player->GetInstanceData()); - if (!pInstance) return true; - - bool alreadyUsed; - - go->AddUse (); - - alreadyUsed = false; - for (uint32 loop=0; loop<5; ++loop) - { - if (altarOfTheKeeperCount[loop] == player->GetGUID()) - alreadyUsed = true; - } - if (!alreadyUsed && altarOfTheKeeperCounter < 5) - altarOfTheKeeperCount[altarOfTheKeeperCounter++] = player->GetGUID(); - player->CastSpell (player, SPELL_BOSS_OBJECT_VISUAL, false); - - if (altarOfTheKeeperCounter < NUMBER_NEEDED_TO_ACTIVATE) - { - //error_log ("not enough people yet, altarOfTheKeeperCounter = %d", altarOfTheKeeperCounter); - return false; // not enough people yet - } - - // Check to make sure at least three people are still casting - uint32 count=0; - Unit *pTarget; - for (uint32 x = 0; x < 5; ++x) - { - pTarget = Unit::GetUnit(*player, altarOfTheKeeperCount[x]); - //error_log ("number of people currently activating it: %d", x+1); - if (!pTarget) continue; - if (pTarget->IsNonMeleeSpellCasted(true)) count++; - if (count >= NUMBER_NEEDED_TO_ACTIVATE) break; - } - - if (count < NUMBER_NEEDED_TO_ACTIVATE) - { - // error_log ("still not enough people"); - return true; // not enough people - } - - //error_log ("activating stone keepers"); - pInstance->SetData(DATA_STONE_KEEPERS, IN_PROGRESS); // activate the Stone Keepers - return true; -} - void AddSC_boss_archaedas() { Script *newscript; @@ -477,21 +348,11 @@ void AddSC_boss_archaedas() newscript->GetAI = &GetAI_boss_archaedas; newscript->RegisterSelf(); - newscript = new Script; - newscript->Name="go_altar_of_archaedas"; - newscript->pGOUse = &GOUse_go_altar_of_archaedas; - newscript->RegisterSelf(); - newscript = new Script; newscript->Name="mob_archaedas_minions"; newscript->GetAI = &GetAI_mob_archaedas_minions; newscript->RegisterSelf(); - newscript = new Script; - newscript->Name="go_altar_of_the_keepers"; - newscript->pGOUse = &GOUse_go_altar_of_the_keepers; - newscript->RegisterSelf(); - newscript = new Script; newscript->Name="mob_stonekeepers"; newscript->GetAI = &GetAI_mob_stonekeepers; diff --git a/src/scripts/scripts/zone/uldaman/boss_ironaya.cpp b/src/scripts/scripts/Eastern Kingdoms/uldaman/boss_ironaya.cpp old mode 100755 new mode 100644 similarity index 83% rename from src/scripts/scripts/zone/uldaman/boss_ironaya.cpp rename to src/scripts/scripts/Eastern Kingdoms/uldaman/boss_ironaya.cpp index ec12cd173..b7b2fc67a --- a/src/scripts/scripts/zone/uldaman/boss_ironaya.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/uldaman/boss_ironaya.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -35,14 +38,14 @@ struct boss_ironayaAI : public ScriptedAI boss_ironayaAI(Creature *c) : ScriptedAI(c) {} uint32 Arcing_Timer; - bool hasCastedWstomp; - bool hasCastedKnockaway; + bool hasCastWstomp; + bool hasCastKnockaway; void Reset() { Arcing_Timer = 3000; - hasCastedKnockaway = false; - hasCastedWstomp = false; + hasCastKnockaway = false; + hasCastWstomp = false; } void EnterCombat(Unit *who) @@ -58,7 +61,7 @@ struct boss_ironayaAI : public ScriptedAI return; //If we are <50% hp do knockaway ONCE - if (!hasCastedKnockaway && m_creature->GetHealth()*2 < m_creature->GetMaxHealth()) + if (!hasCastKnockaway && m_creature->GetHealth()*2 < m_creature->GetMaxHealth()) { m_creature->CastSpell(m_creature->getVictim(),SPELL_KNOCKAWAY, true); @@ -72,7 +75,7 @@ struct boss_ironayaAI : public ScriptedAI m_creature->TauntApply(Target); //Shouldn't cast this agian - hasCastedKnockaway = true; + hasCastKnockaway = true; } //Arcing_Timer @@ -82,10 +85,10 @@ struct boss_ironayaAI : public ScriptedAI Arcing_Timer = 13000; }else Arcing_Timer -= diff; - if (!hasCastedWstomp && m_creature->GetHealth()*4 < m_creature->GetMaxHealth()) + if (!hasCastWstomp && m_creature->GetHealth()*4 < m_creature->GetMaxHealth()) { DoCast(m_creature,SPELL_WSTOMP); - hasCastedWstomp = true; + hasCastWstomp = true; } DoMeleeAttackIfReady(); diff --git a/src/scripts/scripts/zone/uldaman/def_uldaman.h b/src/scripts/scripts/Eastern Kingdoms/uldaman/def_uldaman.h old mode 100755 new mode 100644 similarity index 100% rename from src/scripts/scripts/zone/uldaman/def_uldaman.h rename to src/scripts/scripts/Eastern Kingdoms/uldaman/def_uldaman.h diff --git a/src/scripts/scripts/zone/uldaman/instance_uldaman.cpp b/src/scripts/scripts/Eastern Kingdoms/uldaman/instance_uldaman.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/zone/uldaman/instance_uldaman.cpp rename to src/scripts/scripts/Eastern Kingdoms/uldaman/instance_uldaman.cpp index e77aa5d16..be25c053d --- a/src/scripts/scripts/zone/uldaman/instance_uldaman.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/uldaman/instance_uldaman.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006,2007 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: instance_uldaman @@ -48,9 +51,9 @@ struct instance_uldaman : public ScriptedInstance { archaedasGUID = 0; ironayaGUID = 0; - whoWokeArchaedasGUID = 0; altarOfTheKeeperTempleDoor = 0; + altarOfArcheadas = 0; archaedasTempleDoor = 0; ancientVaultDoor = 0; ironayaSealDoor = 0; @@ -67,9 +70,9 @@ struct instance_uldaman : public ScriptedInstance uint64 archaedasGUID; uint64 ironayaGUID; - uint64 whoWokeArchaedasGUID; uint64 altarOfTheKeeperTempleDoor; + uint64 altarOfArcheadas; uint64 archaedasTempleDoor; uint64 ancientVaultDoor; uint64 ironayaSealDoor; @@ -95,41 +98,47 @@ struct instance_uldaman : public ScriptedInstance altarOfTheKeeperTempleDoor = go->GetGUID(); if (Encounters[0] == DONE) - HandleGameObject(0,true,go); + HandleGameObject(0, true, go); + break; + + case ALTAR_OF_ARCHAEDAS: // lock the door + altarOfArcheadas = go->GetGUID(); + if (Encounters[2] == DONE) + go->SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); break; case ARCHAEDAS_TEMPLE_DOOR: archaedasTempleDoor = go->GetGUID(); if (Encounters[0] == DONE) - HandleGameObject(0,true,go); + HandleGameObject(0, true, go); break; case ANCIENT_VAULT_DOOR: - go->SetUInt32Value(GAMEOBJECT_STATE,1); + go->SetUInt32Value(GAMEOBJECT_STATE, 1); go->SetUInt32Value(GAMEOBJECT_FLAGS, 33); ancientVaultDoor = go->GetGUID(); if (Encounters[1] == DONE) - HandleGameObject(0,true,go); + HandleGameObject(0, true, go); break; - case IRONAYA_SEAL_DOOR: + case IRONAYA_SEAL_DOOR: ironayaSealDoor = go->GetGUID(); if (Encounters[2] == DONE) - HandleGameObject(0,true,go); - break; + HandleGameObject(0, true, go); + break; - case KEYSTONE_GO: - keystoneGUID = go->GetGUID(); + case KEYSTONE_GO: + keystoneGUID = go->GetGUID(); if (Encounters[2] == DONE) { - HandleGameObject(0,true,go); + HandleGameObject(0, true, go); go->SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND); - } - break; + } + break; } } @@ -228,17 +237,13 @@ struct instance_uldaman : public ScriptedInstance } } - void ActivateArchaedas(uint64 target) + void ActivateArchaedas() { Creature *archaedas = instance->GetCreature(archaedasGUID); if(!archaedas) return; - if(Unit *victim = Unit::GetUnit(*archaedas, target)) - { - archaedas->CastSpell(archaedas, SPELL_ARCHAEDAS_AWAKEN,false); - whoWokeArchaedasGUID = target; - } + archaedas->CastSpell(archaedas, SPELL_ARCHAEDAS_AWAKEN,false); } void ActivateIronaya() @@ -321,13 +326,24 @@ struct instance_uldaman : public ScriptedInstance break; case DATA_ANCIENT_DOOR: + if(Encounters[1] == DONE) + return; + Encounters[1] = data; + if(data == NOT_STARTED) + { + instance->GetGameObject(altarOfArcheadas)->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } + if(data == IN_PROGRESS) + { + ActivateArchaedas(); + } if(data == DONE) //archeadas defeat - { - SetDoor (archaedasTempleDoor, true); //re open enter door - SetDoor (ancientVaultDoor, true); - } - break; + { + SetDoor (archaedasTempleDoor, true); //re open enter door + SetDoor (ancientVaultDoor, true); + } + break; case DATA_IRONAYA_DOOR: Encounters[2] = data; @@ -364,17 +380,6 @@ struct instance_uldaman : public ScriptedInstance SaveToDB(); } - void SetData64 (uint32 type, uint64 data) - { - // Archaedas - if (type==0 ) - { - ActivateArchaedas (data); - SetDoor (archaedasTempleDoor, false); //close when event is started - } - } - - void OnCreatureCreate (Creature *creature, uint32 creature_entry) { switch (creature_entry) { @@ -416,7 +421,7 @@ struct instance_uldaman : public ScriptedInstance uint64 GetData64 (uint32 identifier) { - if (identifier == 0) return whoWokeArchaedasGUID; + if (identifier == 0) return archaedasGUID; if (identifier == 1) return vaultWalker[0]; // VaultWalker1 if (identifier == 2) return vaultWalker[1]; // VaultWalker2 if (identifier == 3) return vaultWalker[2]; // VaultWalker3 diff --git a/src/scripts/scripts/zone/uldaman/uldaman.cpp b/src/scripts/scripts/Eastern Kingdoms/uldaman/uldaman.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/uldaman/uldaman.cpp rename to src/scripts/scripts/Eastern Kingdoms/uldaman/uldaman.cpp index f87a51440..93e0c5415 --- a/src/scripts/scripts/zone/uldaman/uldaman.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/uldaman/uldaman.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/undercity/undercity.cpp b/src/scripts/scripts/Eastern Kingdoms/undercity/undercity.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/undercity/undercity.cpp rename to src/scripts/scripts/Eastern Kingdoms/undercity/undercity.cpp index 8f825327c..b06832945 --- a/src/scripts/scripts/zone/undercity/undercity.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/undercity/undercity.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,7 +34,7 @@ EndContentData */ #include "precompiled.h" /*###### -## mob_rift_spawn - for mage q "Investigate the Alchemist Shop" +## mob_rift_spawn - for mage qs "Investigate the Alchemist Shop" & "Investigate the Blue Recluse" ######*/ #define RIFT_EMOTE_AGGRO "is angered and attacks!" @@ -117,7 +120,7 @@ struct mob_rift_spawnAI : public ScriptedAI { if(caster->GetTypeId() == TYPEID_PLAYER) casterGUID = caster->GetGUID(); - manifestation_timer = 1500; + manifestation_timer = 2500; } } @@ -131,16 +134,14 @@ struct mob_rift_spawnAI : public ScriptedAI { if(sucked) { - if(GameObject* container = GetClosestGameObjectWithEntry(me, GO_CONTAINMENT_COFFER, 5.0)) - { - container->Delete(); + Creature *trigger = me->SummonTrigger(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, 60000); if (trigger) { trigger->SetVisibility(VISIBILITY_OFF); trigger->CastSpell(trigger, SPELL_CREATE_FILLED_CONTAINMENT_COFFER, false); } - } + me->CastSpell(me, SPELL_RIFT_SPAWN_INVISIBILITY, true); me->Kill(me, false); return; @@ -191,16 +192,6 @@ struct mob_rift_spawnAI : public ScriptedAI manifestation_timer -= diff; } - // evade if too far from Mana Rift Disturbance - if(me->isInCombat() && me->GetMapId() == 0 && !me->IsWithinDist2d(1409, 353.5, 55.0)) - { - me->CombatStop(); - me->getThreatManager().clearReferences(); - me->RemoveAllAuras(); - me->SetHealth(me->GetMaxHealth()); - EscapeIntoVoid(Sucked); - } - if (!UpdateVictim()) return; diff --git a/src/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp b/src/scripts/scripts/Eastern Kingdoms/western_plaguelands/western_plaguelands.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp rename to src/scripts/scripts/Eastern Kingdoms/western_plaguelands/western_plaguelands.cpp index 047bbe0c2..afce0e34e --- a/src/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/western_plaguelands/western_plaguelands.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/westfall/westfall.cpp b/src/scripts/scripts/Eastern Kingdoms/westfall/westfall.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/westfall/westfall.cpp rename to src/scripts/scripts/Eastern Kingdoms/westfall/westfall.cpp index a46027c72..e462abde6 --- a/src/scripts/scripts/zone/westfall/westfall.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/westfall/westfall.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -336,7 +339,7 @@ bool QuestAccept_npc_defias_traitor(Player* player, Creature* creature, Quest co if (quest->GetQuestId() == QUEST_DEFIAS_BROTHERHOOD) { if (npc_escortAI* pEscortAI = CAST_AI(npc_defias_traitorAI, creature->AI())) - pEscortAI->Start(true, true, player->GetGUID(), quest); + pEscortAI->Start(true, true, player->GetGUID(), quest, true); DoScriptText(SAY_START, creature, player); } diff --git a/src/scripts/scripts/zone/wetlands/wetlands.cpp b/src/scripts/scripts/Eastern Kingdoms/wetlands/wetlands.cpp similarity index 87% rename from src/scripts/scripts/zone/wetlands/wetlands.cpp rename to src/scripts/scripts/Eastern Kingdoms/wetlands/wetlands.cpp index c1ac6de38..446b48783 100644 --- a/src/scripts/scripts/zone/wetlands/wetlands.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/wetlands/wetlands.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/zulaman/boss_akilzon.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_akilzon.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/zulaman/boss_akilzon.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_akilzon.cpp index ff088c90b..b1f3d147d --- a/src/scripts/scripts/zone/zulaman/boss_akilzon.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_akilzon.cpp @@ -1,18 +1,21 @@ -/* Copyright ?2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_Akilzon @@ -239,7 +242,7 @@ struct boss_akilzonAI : public ScriptedAI } // throw player to air and cast electrical storm on (should be handled by proper script effect targeting?) DoScriptText(EMOTE_STORM, m_creature, 0, true); - // temporary test, normally used in spell_linked_spell, should be casted before players flying + // temporary test, normally used in spell_linked_spell, should be cast before players flying target->CastSpell(target, 44007, true); m_creature->CastSpell(target, SPELL_ELECTRICAL_STORM, false); diff --git a/src/scripts/scripts/zone/zulaman/boss_halazzi.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_halazzi.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/zulaman/boss_halazzi.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_halazzi.cpp index ec1fa3963..157065b30 --- a/src/scripts/scripts/zone/zulaman/boss_halazzi.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_halazzi.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_Halazzi @@ -270,7 +273,7 @@ struct boss_halazziAI : public ScriptedAI { if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0,GetSpellMaxRange(SPELL_EARTHSHOCK), true)) { - if(target->IsNonMeleeSpellCasted(false)) + if(target->IsNonMeleeSpellCast(false)) AddSpellToCast(target,SPELL_EARTHSHOCK); else AddSpellToCast(target,SPELL_FLAMESHOCK); diff --git a/src/scripts/scripts/zone/zulaman/boss_hexlord.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_hexlord.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/zulaman/boss_hexlord.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_hexlord.cpp index 783f8fc07..d16e7253e --- a/src/scripts/scripts/zone/zulaman/boss_hexlord.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_hexlord.cpp @@ -1,18 +1,21 @@ -/* Copyright ?2006,2007 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2007 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Hex_Lord_Malacrass diff --git a/src/scripts/scripts/zone/zulaman/boss_janalai.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_janalai.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/zulaman/boss_janalai.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_janalai.cpp index 9236006c0..80ade0279 --- a/src/scripts/scripts/zone/zulaman/boss_janalai.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_janalai.cpp @@ -1,18 +1,21 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -*(at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Janalai @@ -318,7 +321,7 @@ struct boss_janalaiAI : public ScriptedAI { if(isFlameBreathing) { - if(!m_creature->IsNonMeleeSpellCasted(false)) + if(!m_creature->IsNonMeleeSpellCast(false)) { isFlameBreathing = false; }else @@ -412,7 +415,7 @@ struct boss_janalaiAI : public ScriptedAI for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (Player* i_pl = i->getSource()) - if(i_pl->isAlive()) + if(i_pl->isAlive() && !i_pl->IsInRange(m_creature, 0.0f, 20.0f)) DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); } //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far diff --git a/src/scripts/scripts/zone/zulaman/boss_nalorakk.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_nalorakk.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/zulaman/boss_nalorakk.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_nalorakk.cpp index e1b90d72c..9f1d28d57 --- a/src/scripts/scripts/zone/zulaman/boss_nalorakk.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_nalorakk.cpp @@ -1,18 +1,21 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Nalorakk @@ -332,6 +335,7 @@ struct boss_nalorakkAI : public ScriptedAI return; case 7: m_creature->SetOrientation(3.1415*0.5); + m_creature->SetHomePosition(NalorakkWay[7][0], NalorakkWay[7][1], NalorakkWay[7][2], m_creature->GetOrientation()); inMove = false; return; } diff --git a/src/scripts/scripts/zone/zulaman/boss_zuljin.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_zuljin.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/zulaman/boss_zuljin.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/boss_zuljin.cpp index 7fa688aa1..e5def817d --- a/src/scripts/scripts/zone/zulaman/boss_zuljin.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/boss_zuljin.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006,2007,2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_ZulJin @@ -105,7 +108,7 @@ static SpiritInfoStruct SpiritInfo[] = struct TransformStruct { - uint32 text; + int32 text; uint32 spell, unaura; }; @@ -248,7 +251,7 @@ struct boss_zuljinAI : public ScriptedAI void DoMeleeAttackIfReady() { - if( !m_creature->IsNonMeleeSpellCasted(false)) + if( !m_creature->IsNonMeleeSpellCast(false)) { if(m_creature->isAttackReady() && m_creature->IsWithinMeleeRange(m_creature->getVictim())) { diff --git a/src/scripts/scripts/zone/zulaman/def_zulaman.h b/src/scripts/scripts/Eastern Kingdoms/zulaman/def_zulaman.h old mode 100755 new mode 100644 similarity index 74% rename from src/scripts/scripts/zone/zulaman/def_zulaman.h rename to src/scripts/scripts/Eastern Kingdoms/zulaman/def_zulaman.h index a00aa1126..ed8ee0c1e --- a/src/scripts/scripts/zone/zulaman/def_zulaman.h +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/def_zulaman.h @@ -1,8 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ -#ifndef DEF_ZULAMAN_H -#define DEF_ZULAMAN_H +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_ZULAMAN_H +#define SC_DEF_ZULAMAN_H #define AKILZON "Akil'zon" #define HEXLORD "Hex Lord Malacrass" diff --git a/src/scripts/scripts/zone/zulaman/instance_zulaman.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/instance_zulaman.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/zulaman/instance_zulaman.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/instance_zulaman.cpp index 46613295d..3c943b777 --- a/src/scripts/scripts/zone/zulaman/instance_zulaman.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/instance_zulaman.cpp @@ -1,18 +1,21 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: instance_zulaman @@ -50,7 +53,7 @@ struct instance_zulaman : public ScriptedInstance uint64 HexLordEntranceGateGUID; uint64 HexLordExitGateGUID; uint64 ZulJinDoorGUID; - + uint64 HarrisonGUID; uint64 AkilzonGUID; @@ -72,7 +75,7 @@ struct instance_zulaman : public ScriptedInstance void Initialize() { - StrangeGongGUID = 0; + StrangeGongGUID = 0; MassiveGateGUID = 0; AkilzonDoorGUID = 0; @@ -80,7 +83,7 @@ struct instance_zulaman : public ScriptedInstance HalazziExitDoorGUID = 0; HexLordEntranceGateGUID= 0; HexLordExitGateGUID = 0; - ZulJinDoorGUID= 0; + ZulJinDoorGUID= 0; AkilzonGUID = 0; HarrisonGUID = 0; @@ -185,15 +188,7 @@ struct instance_zulaman : public ScriptedInstance default: break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void OnObjectCreate(GameObject *go) @@ -201,19 +196,19 @@ struct instance_zulaman : public ScriptedInstance switch(go->GetEntry()) { case 187359: StrangeGongGUID = go->GetGUID(); break; - case 186728: + case 186728: MassiveGateGUID = go->GetGUID(); if (Encounters[0] != NOT_STARTED) go->SetGoState(GO_STATE_ACTIVE); //opened else go->SetGoState(GO_STATE_READY); break; - case 186303: - HalazziExitDoorGUID = go->GetGUID(); + case 186303: + HalazziExitDoorGUID = go->GetGUID(); if(GetData(DATA_HALAZZIEVENT) == DONE) go->SetGoState(GO_STATE_ACTIVE); break; - case 186304: + case 186304: HalazziEntranceDoorGUID = go->GetGUID(); go->SetGoState(GO_STATE_ACTIVE); break; @@ -227,20 +222,20 @@ struct instance_zulaman : public ScriptedInstance AkilzonDoorGUID = go->GetGUID(); go->SetGoState(GO_STATE_ACTIVE); break; - case 186859: + case 186859: ZulJinDoorGUID = go->GetGUID(); go->SetGoState(GO_STATE_ACTIVE); break; - case 187021: - case 186648: - case 186672: + case 187021: + case 186648: + case 186672: case 186667: { uint8 i = GetHostageIndex(go->GetEntry()); RewardsGUID[i] = go->GetGUID(); - + if(Hostages[i] & HOSTAGE_CHEST_UNLOCKED) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); else if(Hostages[i] & HOSTAGE_CHEST_LOOTED) go->Delete(); break; @@ -368,7 +363,7 @@ struct instance_zulaman : public ScriptedInstance HandleGameObject(AkilzonDoorGUID, data != IN_PROGRESS); if (Encounters[2] != DONE) { - Encounters[2] = data; + Encounters[2] = data; if(data == DONE) { if(QuestMinute) @@ -410,7 +405,7 @@ struct instance_zulaman : public ScriptedInstance if(data == DONE) BossJustKilled(4); } - + if(data == NOT_STARTED) CheckInstanceStatus(); break; diff --git a/src/scripts/scripts/zone/zulaman/zulaman.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/zulaman/zulaman.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman.cpp index 2428b97c4..c54336f0a --- a/src/scripts/scripts/zone/zulaman/zulaman.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Zulaman @@ -121,7 +124,7 @@ CreatureAI* GetAI_npc_forest_frog(Creature *_Creature) #define GO_ASHLI_VASE 186671 #define SPELL_SMASH 18944 // most probably wrong spell, but has cool visual -#define SPELL_EXPLOSION 43418 // also not sure about this +#define SPELL_EXPLOSION 27745 // seems OK, but still not sure, original was 100% wrong original:" 43418 // also not sure about this" #define SPELL_ASHLI_FIREBALL 43525 #define YELL_ASHLI_KILL -1800518 @@ -186,8 +189,8 @@ struct npc_hostageAI : public ScriptedAI GameObject *target = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_CHEST_0 + i)); if(target) { - float x, y; - target->GetNearPoint2D(x, y, dist, angle); + float x, y, z; + target->GetNearPoint(x, y, z, 0.0f, dist, angle); me->GetMotionMaster()->MovePoint(1, x, y, me->GetPositionZ()); } EventStarted = true; diff --git a/src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman_trash.cpp b/src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman_trash.cpp new file mode 100644 index 000000000..f27ca4e74 --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/zulaman/zulaman_trash.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Zulaman's trash AI +SD%Complete: 0 +SDComment: Some more complicated trash behaviours than possible in EventAI +SDCategory: Zul'Aman +EndScriptData */ + +/* ContentData +EndContentData */ + +#include "precompiled.h" +#include "def_zulaman.h" + +void AddSC_zulaman_trash() +{/* + Script *newscript; + + newscript = new Script; + newscript->Name = ""; + newscript->GetAI = &GetAI_; + newscript->RegisterSelf();*/ +} \ No newline at end of file diff --git a/src/scripts/scripts/zone/zulgurub/boss_arlokk.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_arlokk.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/zulgurub/boss_arlokk.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_arlokk.cpp index 641605a36..a1f05e852 --- a/src/scripts/scripts/zone/zulgurub/boss_arlokk.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_arlokk.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_gahzranka.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_gahzranka.cpp index b5f723f4b..3268a863f --- a/src/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_gahzranka.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_grilek.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_grilek.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/zulgurub/boss_grilek.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_grilek.cpp index edf7ee930..3190a007e --- a/src/scripts/scripts/zone/zulgurub/boss_grilek.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_grilek.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_hakkar.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hakkar.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/zulgurub/boss_hakkar.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hakkar.cpp index 655b7a4c8..5f6a9e14c --- a/src/scripts/scripts/zone/zulgurub/boss_hakkar.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hakkar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hazzarah.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hazzarah.cpp index 4310a6366..b9c48f564 --- a/src/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_hazzarah.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_jeklik.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jeklik.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/zulgurub/boss_jeklik.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jeklik.cpp index e514173bc..cf8991b44 --- a/src/scripts/scripts/zone/zulgurub/boss_jeklik.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jeklik.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_jindo.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jindo.cpp old mode 100755 new mode 100644 similarity index 80% rename from src/scripts/scripts/zone/zulgurub/boss_jindo.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jindo.cpp index fcb3f57ad..c498a3ef5 --- a/src/scripts/scripts/zone/zulgurub/boss_jindo.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_jindo.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -27,17 +30,13 @@ EndScriptData */ #define SAY_AGGRO -1309014 #define SPELL_BRAINWASHTOTEM 24262 -#define SPELL_POWERFULLHEALINGWARD 24309 //We will not use this spell. We will summon a totem by script cause the spell totems will not cast. +#define SPELL_POWERFULLHEALINGWARD 24309 #define SPELL_HEX 24053 #define SPELL_DELUSIONSOFJINDO 24306 -#define SPELL_SHADEOFJINDO 24308 //We will not use this spell. We will summon a shade by script. - -//Healing Ward Spell -#define SPELL_HEAL 38588 //Totems are not working right. Right heal spell ID is 24311 but this spell is not casting... //Shade of Jindo Spell #define SPELL_SHADOWSHOCK 19460 -#define SPELL_INVISIBLE 24699 +#define SPELL_INVISIBLE 24307 struct boss_jindoAI : public ScriptedAI { @@ -96,8 +95,7 @@ struct boss_jindoAI : public ScriptedAI //HealingWard_Timer if (HealingWard_Timer < diff) { - //DoCast(m_creature, SPELL_POWERFULLHEALINGWARD); - HealingWard = m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000); + DoCast(m_creature, SPELL_POWERFULLHEALINGWARD); HealingWard_Timer = 14000 + rand()%6000; } else @@ -180,46 +178,6 @@ struct boss_jindoAI : public ScriptedAI } }; -//Healing Ward -struct mob_healing_wardAI : public ScriptedAI -{ - mob_healing_wardAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - } - - uint32 Heal_Timer; - - ScriptedInstance *pInstance; - - void Reset() - { - Heal_Timer = 2000; - } - - void EnterCombat(Unit *who) - { - } - - void UpdateAI (const uint32 diff) - { - //Heal_Timer - if(Heal_Timer < diff) - { - if(pInstance) - { - Unit *pJindo = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JINDO)); - if(pJindo && pJindo->isAlive()) - DoCast(pJindo, SPELL_HEAL); - } - Heal_Timer = 3000; - } - else - Heal_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; //Shade of Jindo struct mob_shade_of_jindoAI : public ScriptedAI @@ -264,11 +222,6 @@ CreatureAI* GetAI_boss_jindo(Creature *_Creature) return new boss_jindoAI (_Creature); } -CreatureAI* GetAI_mob_healing_ward(Creature *_Creature) -{ - return new mob_healing_wardAI (_Creature); -} - CreatureAI* GetAI_mob_shade_of_jindo(Creature *_Creature) { return new mob_shade_of_jindoAI (_Creature); @@ -283,11 +236,6 @@ void AddSC_boss_jindo() newscript->GetAI = &GetAI_boss_jindo; newscript->RegisterSelf(); - newscript = new Script; - newscript->Name="mob_healing_ward"; - newscript->GetAI = &GetAI_mob_healing_ward; - newscript->RegisterSelf(); - newscript = new Script; newscript->Name="mob_shade_of_jindo"; newscript->GetAI = &GetAI_mob_shade_of_jindo; diff --git a/src/scripts/scripts/zone/zulgurub/boss_mandokir.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_mandokir.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/zulgurub/boss_mandokir.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_mandokir.cpp index 845f1814c..049d5b66b --- a/src/scripts/scripts/zone/zulgurub/boss_mandokir.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_mandokir.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -227,7 +230,7 @@ struct boss_mandokirAI : public ScriptedAI { TargetInRange = 0; - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); for(; i != m_creature->getThreatManager().getThreatList().end(); ++i) { Unit* pUnit = Unit::GetUnit(*m_creature, (*i)->getUnitGuid()); diff --git a/src/scripts/scripts/zone/zulgurub/boss_marli.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_marli.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/zulgurub/boss_marli.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_marli.cpp index 99148a2e2..7a17625f3 --- a/src/scripts/scripts/zone/zulgurub/boss_marli.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_marli.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_renataki.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_renataki.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/zulgurub/boss_renataki.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_renataki.cpp index 64535deb4..fa8025edb --- a/src/scripts/scripts/zone/zulgurub/boss_renataki.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_renataki.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_thekal.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_thekal.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/zulgurub/boss_thekal.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_thekal.cpp index ed49e4a08..39368c206 --- a/src/scripts/scripts/zone/zulgurub/boss_thekal.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_thekal.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_venoxis.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_venoxis.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/zulgurub/boss_venoxis.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_venoxis.cpp index 125370af7..ed59ce55c --- a/src/scripts/scripts/zone/zulgurub/boss_venoxis.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_venoxis.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_wushoolay.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_wushoolay.cpp index 07f3e090e..742a9b298 --- a/src/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/boss_wushoolay.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Eastern Kingdoms/zulgurub/def_zulgurub.h b/src/scripts/scripts/Eastern Kingdoms/zulgurub/def_zulgurub.h new file mode 100644 index 000000000..cab18129f --- /dev/null +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/def_zulgurub.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_ZULGURUB_H +#define SC_DEF_ZULGURUB_H + +#define DATA_JEKLIKEVENT 1 +#define DATA_VENOXISEVENT 2 +#define DATA_MARLIEVENT 3 +#define DATA_THEKALEVENT 4 +#define DATA_ARLOKKEVENT 5 +#define DATA_HAKKAREVENT 6 +#define DATA_MANDOKIREVENT 7 +#define DATA_JINDOEVENT 8 +#define DATA_GAHZRANKAEVENT 9 +#define DATA_EDGEOFMADNESSEVENT 10 +#define DATA_JINDO 11 +#define DATA_LORKHAN 12 +#define DATA_THEKAL 13 +#define DATA_ZATH 14 +#define DATA_THEKALFAKEDEATH 15 +#define DATA_LORKHANISDEAD 16 +#define DATA_ZATHISDEAD 17 +#define DATA_OHGAN 18 + +#define GO_GONG_OF_BETHEKK 180526 +#endif + diff --git a/src/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp b/src/scripts/scripts/Eastern Kingdoms/zulgurub/instance_zulgurub.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp rename to src/scripts/scripts/Eastern Kingdoms/zulgurub/instance_zulgurub.cpp index 0469aac4e..0d46f31c6 --- a/src/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp +++ b/src/scripts/scripts/Eastern Kingdoms/zulgurub/instance_zulgurub.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -51,6 +54,13 @@ struct instance_zulgurub : public ScriptedInstance uint64 ThekalGUID; uint64 JindoGUID; uint64 OhganGUID; + uint64 GongGUID; + + void OnObjectCreate(GameObject* pGo) + { + if(pGo->GetEntry() == GO_GONG_OF_BETHEKK) + GongGUID = pGo->GetGUID(); + } uint32 GetEncounterForEntry(uint32 entry) { @@ -110,15 +120,7 @@ struct instance_zulgurub : public ScriptedInstance break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void Initialize() @@ -231,9 +233,23 @@ struct instance_zulgurub : public ScriptedInstance break; case DATA_ARLOKKEVENT: + { + if (data == IN_PROGRESS && encounters[4] != IN_PROGRESS) + if (GameObject *pGo = instance->GetGameObject(GongGUID)) + { + Creature *pArlokk = instance->GetCreatureById(14515); + + if (!pArlokk) + { + pGo->SetFlag(GAMEOBJECT_FLAGS,GO_FLAG_NOTSELECTABLE); + pGo->SummonCreature(14515,-11540.7,-1627.71,41.27,0.1,TEMPSUMMON_CORPSE_TIMED_DESPAWN,600000); + } + } + if (encounters[4] != DONE) encounters[4] = data; break; + } case DATA_HAKKAREVENT: if (encounters[5] != DONE) diff --git a/src/scripts/scripts/zone/ashenvale_forest/ashenvale.cpp b/src/scripts/scripts/Kalimdor/ashenvale_forest/ashenvale.cpp old mode 100755 new mode 100644 similarity index 86% rename from src/scripts/scripts/zone/ashenvale_forest/ashenvale.cpp rename to src/scripts/scripts/Kalimdor/ashenvale_forest/ashenvale.cpp index 14cd73dec..d23f670f9 --- a/src/scripts/scripts/zone/ashenvale_forest/ashenvale.cpp +++ b/src/scripts/scripts/Kalimdor/ashenvale_forest/ashenvale.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Ashenvale @@ -130,7 +133,7 @@ struct npc_torekAI : public npc_escortAI bool QuestAccept_npc_torek(Player* pPlayer, Creature* pCreature, Quest const* quest) { - if (quest->GetQuestId() == QUEST_TOREK_ASSULT) + if (pPlayer && quest->GetQuestId() == QUEST_TOREK_ASSULT) { //TODO: find companions, make them follow Torek, at any time (possibly done by mangos/database in future?) DoScriptText(SAY_READY, pCreature, pPlayer); @@ -536,7 +539,7 @@ bool GOUse_go_naga_brazier(Player* pPlayer, GameObject* pGo) bool ItemUse_item_Totemic_Beacon(Player *player, Item* _Item, SpellCastTargets const& targets) { float x,y,z; - player->GetClosePoint(x,y,z, 0.0f, 3.0f, frand(0, 2*M_PI)); + player->GetNearPoint(x,y,z, 0.0f, 3.0f, frand(0, 2*M_PI)); player->SummonCreature(NPC_EARTHEN_RING_GUIDE, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 120000); return false; } @@ -578,47 +581,50 @@ struct npc_Heretic_EmisaryAI : public ScriptedAI { if (!me->getVictim()) { - if (TalkTimer < diff && EventStarted) + if (EventStarted) { - Player * Player_; - Creature * Briatha = GetClosestCreatureWithEntry(me, NPC_ICECALLERBRIATHA, 20); - - if (Briatha && Briatha->isAlive()) + if (TalkTimer < diff) { - switch(Phase) + Player * Player_; + Creature * Briatha = GetClosestCreatureWithEntry(me, NPC_ICECALLERBRIATHA, 20); + + if (Briatha && Briatha->isAlive()) { - case 0: - Briatha->Say("These stones should be the last of them. Our coordination with Neptulon's forces will be impeccable.", LANG_UNIVERSAL, 0); - Phase++; - break; - case 1: - me->Say("Yess. The Tidehunter will be pleased at this development. The Firelord's hold will weaken.", LANG_UNIVERSAL, 0); - Phase++; - break; - case 2: - Briatha->Say("And your own preparations? Will the Frost Lord have a path to the portal?", LANG_UNIVERSAL, 0); - Phase++; - break; - case 3: - me->Say("Skar'this has informed us well. We have worked our way into the slave pens and await your cryomancerss.", LANG_UNIVERSAL, 0); - Phase++; - break; - case 4: - Briatha->Say("The ritual in Coilfang will bring Ahune through once he is fully prepared, and the resulting clash between Firelord and Frostlord will rend the foundations of this world. Our ultimate goals are in reach at last...", LANG_UNIVERSAL, 0); - Phase = 0; - if(Player_ = (Player*)(me->GetUnit(player))) - if(Player_->HasAura(46337, 0)) - Player_->AreaExploredOrEventHappens(11891); - EventStarted = false; - break; + switch(Phase) + { + case 0: + Briatha->Say("These stones should be the last of them. Our coordination with Neptulon's forces will be impeccable.", LANG_UNIVERSAL, 0); + Phase++; + break; + case 1: + me->Say("Yess. The Tidehunter will be pleased at this development. The Firelord's hold will weaken.", LANG_UNIVERSAL, 0); + Phase++; + break; + case 2: + Briatha->Say("And your own preparations? Will the Frost Lord have a path to the portal?", LANG_UNIVERSAL, 0); + Phase++; + break; + case 3: + me->Say("Skar'this has informed us well. We have worked our way into the slave pens and await your cryomancerss.", LANG_UNIVERSAL, 0); + Phase++; + break; + case 4: + Briatha->Say("The ritual in Coilfang will bring Ahune through once he is fully prepared, and the resulting clash between Firelord and Frostlord will rend the foundations of this world. Our ultimate goals are in reach at last...", LANG_UNIVERSAL, 0); + Phase = 0; + if(Player_ = (Player*)(me->GetUnit(player))) + if(Player_->HasAura(46337, 0)) + Player_->AreaExploredOrEventHappens(11891); + EventStarted = false; + break; + } + TalkTimer = 5000; } - TalkTimer = 5000; + else + EventStarted = false; } - else - EventStarted = false; - } else TalkTimer -= diff; + } return; } diff --git a/src/scripts/scripts/zone/azshara/azshara.cpp b/src/scripts/scripts/Kalimdor/azshara/azshara.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/azshara/azshara.cpp rename to src/scripts/scripts/Kalimdor/azshara/azshara.cpp index 5e7e0fe1b..047322a7c --- a/src/scripts/scripts/zone/azshara/azshara.cpp +++ b/src/scripts/scripts/Kalimdor/azshara/azshara.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -172,7 +175,7 @@ bool GossipSelect_npc_loramus_thalipedes(Player *player, Creature *_Creature, ui #define GOSSIP_GET_MOONSTONE "Hand over the Southfury moonstone and I'll let you go." //next message must be send to player when Rizzle jump into river, not implemented -#define MSG_ESCAPE_NOTICE "Rizzle Sprysprocket takes the Southfury moonstone and escapes into the river. Follow her!" +#define MSG_ESCAPE_NOTICE " Rizzle Sprysprocket takes the Southfury moonstone and escapes into the river. Follow her!" float WPs[58][4] = { @@ -278,6 +281,10 @@ struct mob_rizzle_sprysprocketAI : public ScriptedAI m_creature->RemoveCorpse(); } + void EnterEvadeMode() + { + } + void UpdateAI(const uint32 diff) { if(Must_Die) @@ -325,7 +332,7 @@ struct mob_rizzle_sprysprocketAI : public ScriptedAI if(Grenade_Timer < diff) { Player *player = (Player *)Unit::GetUnit((*m_creature), PlayerGUID); - if(player) + if(player && Reached == false) { DoScriptText(SAY_RIZZLE_GRENADE, m_creature, player); DoCast(player, SPELL_RIZZLE_FROST_GRENADE, true); @@ -335,7 +342,7 @@ struct mob_rizzle_sprysprocketAI : public ScriptedAI if(Check_Timer < diff) { - Player *player = (Player *)Unit::GetUnit((*m_creature), PlayerGUID); + Unit *player = m_creature->GetUnit(PlayerGUID); if(!player) { Despawn(); @@ -347,7 +354,6 @@ struct mob_rizzle_sprysprocketAI : public ScriptedAI DoScriptText(SAY_RIZZLE_FINAL, m_creature); m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 1); m_creature->setFaction(35); - m_creature->GetMotionMaster()->MovementExpired(); m_creature->RemoveAurasDueToSpell(SPELL_PERIODIC_DEPTH_CHARGE); Reached = true; } @@ -381,7 +387,7 @@ struct mob_rizzle_sprysprocketAI : public ScriptedAI void MovementInform(uint32 type, uint32 id) { - if (type != POINT_MOTION_TYPE) + if ((type != POINT_MOTION_TYPE) || Reached == true) return; if(id == 57) diff --git a/src/scripts/scripts/zone/azshara/boss_azuregos.cpp b/src/scripts/scripts/Kalimdor/azshara/boss_azuregos.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/azshara/boss_azuregos.cpp rename to src/scripts/scripts/Kalimdor/azshara/boss_azuregos.cpp index 2862ee66d..9a5fde18b --- a/src/scripts/scripts/zone/azshara/boss_azuregos.cpp +++ b/src/scripts/scripts/Kalimdor/azshara/boss_azuregos.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -71,8 +74,8 @@ struct boss_azuregosAI : public ScriptedAI if(Teleport_Timer < diff) { DoScriptText(SAY_TELEPORT, m_creature); - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) { Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); diff --git a/src/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp b/src/scripts/scripts/Kalimdor/azuremyst_isle/azuremyst_isle.cpp old mode 100755 new mode 100644 similarity index 78% rename from src/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp rename to src/scripts/scripts/Kalimdor/azuremyst_isle/azuremyst_isle.cpp index 8a8edd186..528a027f4 --- a/src/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp +++ b/src/scripts/scripts/Kalimdor/azuremyst_isle/azuremyst_isle.cpp @@ -1,4 +1,7 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 + /* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -77,18 +80,18 @@ struct npc_draenei_survivorAI : public ScriptedAI CanSayHelp = true; - m_creature->CastSpell(m_creature, SPELL_IRRIDATION, true); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SLEEP); + me->CastSpell(me, SPELL_IRRIDATION, true); + me->SetHealth(int(me->GetMaxHealth()*.1)); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SLEEP); } void EnterCombat(Unit *who) {} void MoveInLineOfSight(Unit *who) { - if (CanSayHelp && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsFriendlyTo(who) && m_creature->IsWithinDistInMap(who, 25.0f)) + if (CanSayHelp && who->GetTypeId() == TYPEID_PLAYER && me->IsFriendlyTo(who) && me->IsWithinDistInMap(who, 25.0f)) { - DoScriptText(RAND(HELP1, HELP2, HELP3, HELP4), m_creature); + DoScriptText(RAND(HELP1, HELP2, HELP3, HELP4), me); SayHelpTimer = 20000; CanSayHelp = false; @@ -99,9 +102,9 @@ struct npc_draenei_survivorAI : public ScriptedAI { if(Spell->Id == 28880) { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); - m_creature->CastSpell(m_creature, SPELL_STUNNED, true); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); + me->CastSpell(me, SPELL_STUNNED, true); pCaster = Caster->GetGUID(); @@ -115,20 +118,20 @@ struct npc_draenei_survivorAI : public ScriptedAI { if(SayThanksTimer <= diff) { - m_creature->RemoveAurasDueToSpell(SPELL_IRRIDATION); + me->RemoveAurasDueToSpell(SPELL_IRRIDATION); - if (Player *pPlayer = (Player*)Unit::GetUnit(*m_creature,pCaster)) + if (Player *pPlayer = (Player*)Unit::GetUnit(*me,pCaster)) { if (pPlayer->GetTypeId() != TYPEID_PLAYER) return; - DoScriptText(RAND(SAY_HEAL1, SAY_HEAL2, SAY_HEAL3, SAY_HEAL4), m_creature, pPlayer); + DoScriptText(RAND(SAY_HEAL1, SAY_HEAL2, SAY_HEAL3, SAY_HEAL4), me, pPlayer); - pPlayer->TalkedToCreature(m_creature->GetEntry(),m_creature->GetGUID()); + pPlayer->TalkedToCreature(me->GetEntry(),me->GetGUID()); } - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f); RunAwayTimer = 10000; SayThanksTimer = 0; @@ -143,14 +146,14 @@ struct npc_draenei_survivorAI : public ScriptedAI { if(RunAwayTimer <= diff) { - m_creature->RemoveAllAuras(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->setDeathState(JUST_DIED); - m_creature->SetHealth(0); - m_creature->CombatStop(); - m_creature->DeleteThreatList(); - m_creature->RemoveCorpse(); + me->RemoveAllAuras(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); + me->setDeathState(JUST_DIED); + me->SetHealth(0); + me->CombatStop(); + me->DeleteThreatList(); + me->RemoveCorpse(); } else RunAwayTimer -= diff; @@ -195,7 +198,7 @@ struct npc_sethir_the_ancientAI : public ScriptedAI void EnterCombat(Unit *who) { - DoScriptText(EMOTE_SOUND_DIE, m_creature); + DoScriptText(EMOTE_SOUND_DIE, me); } void SummonedCreatureDespawn(Creature*) @@ -205,13 +208,13 @@ struct npc_sethir_the_ancientAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { - if (!m_creature->isInCombat() && !pause_say && m_creature->IsWithinDistInMap(who, 30) && m_creature->IsHostileTo(who) && who->HasAuraType(SPELL_AURA_MOD_STEALTH)) + if (!me->isInCombat() && !pause_say && me->IsWithinDistInMap(who, 30) && me->IsHostileTo(who) && who->HasAuraType(SPELL_AURA_MOD_STEALTH)) { me->Say("I know you are there, rogue. Leave my home or join the others at the bottom of the World Tree!", LANG_UNIVERSAL, 0); pause_say = true; temp = 60000; } - //if (!m_creature->isInCombat() && m_creature->IsWithinDistInMap(who, 30) && m_creature->IsHostileTo(who)) AttackStart(who); + //if (!me->isInCombat() && me->IsWithinDistInMap(who, 30) && me->IsHostileTo(who)) AttackStart(who); ScriptedAI::MoveInLineOfSight(who); } @@ -237,8 +240,8 @@ struct npc_sethir_the_ancientAI : public ScriptedAI for (int i=1; i<=6; i++) { - Creature * tmpC = m_creature->SummonCreature(6911, pos.x, pos.y, pos.z, pos.o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 3000); - tmpC->AI()->AttackStart(m_creature->getVictim()); + Creature * tmpC = me->SummonCreature(6911, pos.x, pos.y, pos.z, pos.o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 3000); + tmpC->AI()->AttackStart(me->getVictim()); } Timer = 0; @@ -279,19 +282,19 @@ struct npc_engineer_spark_overgrindAI : public ScriptedAI { Dynamite_Timer = 8000; Emote_Timer = 120000 + rand()%30000; - m_creature->setFaction(875); + me->setFaction(875); } void EnterCombat(Unit *who) { } void UpdateAI(const uint32 diff) { - if( !m_creature->isInCombat() ) + if( !me->isInCombat() ) { if (Emote_Timer < diff) { - DoScriptText(SAY_TEXT, m_creature); - DoScriptText(SAY_EMOTE, m_creature); + DoScriptText(SAY_TEXT, me); + DoScriptText(SAY_EMOTE, me); Emote_Timer = 120000 + rand()%30000; } else @@ -303,7 +306,7 @@ struct npc_engineer_spark_overgrindAI : public ScriptedAI if (Dynamite_Timer < diff) { - DoCast(m_creature->getVictim(), SPELL_DYNAMITE); + DoCast(me->getVictim(), SPELL_DYNAMITE); Dynamite_Timer = 8000; } else @@ -349,10 +352,10 @@ struct npc_injured_draeneiAI : public ScriptedAI void Reset() { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.15)); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + me->SetHealth(int(me->GetMaxHealth()*.15)); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, RAND(PLAYER_STATE_SIT, PLAYER_STATE_SLEEP)); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, RAND(PLAYER_STATE_SIT, PLAYER_STATE_SLEEP)); } void EnterCombat(Unit *who) {} @@ -403,25 +406,25 @@ struct npc_magwinAI : public npc_escortAI switch(i) { case 0: - DoScriptText(SAY_START, m_creature, pPlayer); + DoScriptText(SAY_START, me, pPlayer); break; case 17: - DoScriptText(SAY_PROGRESS, m_creature, pPlayer); + DoScriptText(SAY_PROGRESS, me, pPlayer); break; case 28: - DoScriptText(SAY_END1, m_creature, pPlayer); + DoScriptText(SAY_END1, me, pPlayer); break; case 29: - DoScriptText(EMOTE_HUG, m_creature, pPlayer); - DoScriptText(SAY_END2, m_creature, pPlayer); - pPlayer->GroupEventHappens(QUEST_A_CRY_FOR_SAY_HELP,m_creature); + DoScriptText(EMOTE_HUG, me, pPlayer); + DoScriptText(SAY_END2, me, pPlayer); + pPlayer->GroupEventHappens(QUEST_A_CRY_FOR_SAY_HELP,me); break; } } void EnterCombat(Unit* who) { - DoScriptText(SAY_AGGRO, m_creature, who); + DoScriptText(SAY_AGGRO, me, who); } void Reset() { } @@ -554,7 +557,7 @@ struct npc_geezleAI : public ScriptedAI { Step = 1; EventStarted = true; - Creature* Spark = m_creature->SummonCreature(MOB_SPARK, SparkPos[0], SparkPos[1], SparkPos[2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000); + Creature* Spark = me->SummonCreature(MOB_SPARK, SparkPos[0], SparkPos[1], SparkPos[2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000); if(Spark) { SparkGUID = Spark->GetGUID(); @@ -562,13 +565,13 @@ struct npc_geezleAI : public ScriptedAI Spark->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); Spark->GetMotionMaster()->MovePoint(0, -5080.70, -11253.61, 0.56); } - m_creature->GetMotionMaster()->MovePoint(0, -5092.26, -11252, 0.71); + me->GetMotionMaster()->MovePoint(0, -5092.26, -11252, 0.71); SayTimer = 23000; } uint32 NextStep(uint32 Step) { - Unit* Spark = Unit::GetUnit((*m_creature), SparkGUID); + Unit* Spark = Unit::GetUnit((*me), SparkGUID); switch(Step) { @@ -578,21 +581,21 @@ struct npc_geezleAI : public ScriptedAI DoScriptText(EMOTE_SPARK, Spark); return 1000; case 2: - DoScriptText(GEEZLE_SAY_1, m_creature, Spark); + DoScriptText(GEEZLE_SAY_1, me, Spark); if(Spark) { - Spark->SetInFront(m_creature); - m_creature->SetInFront(Spark); + Spark->SetInFront(me); + me->SetInFront(Spark); } return 5000; case 3: DoScriptText(SPARK_SAY_2, Spark); return 7000; case 4: DoScriptText(SPARK_SAY_3, Spark); return 8000; - case 5: DoScriptText(GEEZLE_SAY_4, m_creature, Spark); return 8000; + case 5: DoScriptText(GEEZLE_SAY_4, me, Spark); return 8000; case 6: DoScriptText(SPARK_SAY_5, Spark); return 9000; case 7: DoScriptText(SPARK_SAY_6, Spark); return 8000; - case 8: DoScriptText(GEEZLE_SAY_7, m_creature, Spark); return 2000; + case 8: DoScriptText(GEEZLE_SAY_7, me, Spark); return 2000; case 9: - m_creature->GetMotionMaster()->MoveTargetedHome(); + me->GetMotionMaster()->MoveTargetedHome(); if(Spark) Spark->GetMotionMaster()->MovePoint(0, -5030.95, -11291.99, 7.97); return 20000; @@ -600,7 +603,7 @@ struct npc_geezleAI : public ScriptedAI if(Spark) Spark->DealDamage(Spark,Spark->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); //DespawnNagaFlag(false); - m_creature->SetVisibility(VISIBILITY_OFF); + me->SetVisibility(VISIBILITY_OFF); default: return 99999999; } } @@ -686,9 +689,9 @@ struct mob_nestlewood_owlkinAI : public ScriptedAI { if(ChannelTimer < diff && !Channeled && Hitted) { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - m_creature->SummonCreature(INOCULATED_OWLKIN, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 180000); + me->DealDamage(me, me->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->RemoveCorpse(); + me->SummonCreature(INOCULATED_OWLKIN, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 180000); Channeled = true; } else @@ -721,7 +724,7 @@ struct mob_siltfin_murlocAI : public ScriptedAI { if(((Player*)player)->GetQuestStatus(9595) == QUEST_STATUS_INCOMPLETE) { - Unit* summon = m_creature->SummonCreature(17612, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + Unit* summon = me->SummonCreature(17612, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); player->CastSpell(summon, 30790, false); } } @@ -865,6 +868,92 @@ bool go_bristlelimb_cage(Player* pPlayer, GameObject* pGo) return true; } +/*###### +## Quest: Matis the Cruel +######*/ + +#define NPC_MATIS 17664 +#define SAY_1 -1900255 +#define SAY_2 -1900256 + +struct npc_trackerAI : public ScriptedAI +{ + npc_trackerAI(Creature* creature) : ScriptedAI(creature) {} + + TimeTrackerSmall CheckTimer; + + void Reset() + { + CheckTimer.Reset(2000); + DoScriptText(SAY_1, me); + me->setFaction(1700); + if (Creature* Matis = GetClosestCreatureWithEntry(me, NPC_MATIS, 35.0f)) + me->AI()->AttackStart(Matis); + } + + void Credit() + { + Map* map = me->GetMap(); + Map::PlayerList const &PlayerList = map->GetPlayers(); + + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + { + if (Player* player = itr->getSource()) + { + if (me->IsWithinDistInMap(player, 35.0f) && (player->GetQuestStatus(9711) == QUEST_STATUS_INCOMPLETE)) + player->GroupEventHappens(9711, me); + } + } + } + + void EnterEvadeMode() + { + me->DeleteThreatList(); + me->CombatStop(true); + } + + void UpdateAI(const uint32 diff) + { + CheckTimer.Update(diff); + + if (CheckTimer.Passed()) + { + if (Creature* Matis = GetClosestCreatureWithEntry(me, NPC_MATIS, 35.0f)) + { + if ((Matis->GetHealth())*100 / Matis->GetMaxHealth() < 10) + { + me->AI()->EnterEvadeMode(); + Matis->setFaction(35); + Matis->CombatStop(); + Matis->DeleteThreatList(); + Matis->SetHealth(Matis->GetMaxHealth()); + DoScriptText(SAY_2, me); + Credit(); + Matis->ForcedDespawn(30000); + me->ForcedDespawn(35000); + } + } + else + { + if (Creature* Matis = GetClosestCreatureWithEntry(me, NPC_MATIS, 55.0f, false)) + Matis->setFaction(1701); + } + + CheckTimer.Reset(1000); + } + + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_tracker(Creature* creature) +{ + return new npc_trackerAI (creature); +} + void AddSC_azuremyst_isle() { Script *newscript; @@ -937,4 +1026,9 @@ void AddSC_azuremyst_isle() newscript->Name="go_bristlelimb_cage"; newscript->pGOUse = &go_bristlelimb_cage; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_tracker"; + newscript->GetAI = &GetAI_npc_tracker; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/barrens/the_barrens.cpp b/src/scripts/scripts/Kalimdor/barrens/the_barrens.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/barrens/the_barrens.cpp rename to src/scripts/scripts/Kalimdor/barrens/the_barrens.cpp index 12359a662..909f0f749 --- a/src/scripts/scripts/zone/barrens/the_barrens.cpp +++ b/src/scripts/scripts/Kalimdor/barrens/the_barrens.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -198,51 +200,41 @@ struct npc_taskmaster_fizzuleAI : public ScriptedAI { npc_taskmaster_fizzuleAI(Creature* c) : ScriptedAI(c) {} - bool IsFriend; uint32 Reset_Timer; uint32 FlareCount; void Reset() { - IsFriend = false; Reset_Timer = 120000; FlareCount = 0; m_creature->setFaction(FACTION_HOSTILE_F); m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); } - //This is a hack. Spellcast will make creature aggro but that is not - //supposed to happen (Trinity not implemented/not found way to detect this spell kind) - void DoUglyHack() - { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - } - void SpellHit(Unit *caster, const SpellEntry *spell) { - if( spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY ) + if (spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY) { - DoUglyHack(); - ++FlareCount; - if( FlareCount >= 2 ) - { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + + if (++FlareCount >= 2) m_creature->setFaction(FACTION_FRIENDLY_F); - IsFriend = true; - } } } void UpdateAI(const uint32 diff) { - if( IsFriend ) + if (me->getFaction() == FACTION_FRIENDLY_F) { - if( Reset_Timer < diff ) + if (Reset_Timer < diff) { EnterEvadeMode(); return; - } else Reset_Timer -= diff; + } + else + Reset_Timer -= diff; } if (!UpdateVictim()) diff --git a/src/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp b/src/scripts/scripts/Kalimdor/bloodmyst_isle/bloodmyst_isle.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp rename to src/scripts/scripts/Kalimdor/bloodmyst_isle/bloodmyst_isle.cpp index ade64ebe1..28a6cad4f --- a/src/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp +++ b/src/scripts/scripts/Kalimdor/bloodmyst_isle/bloodmyst_isle.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -201,7 +204,7 @@ bool GOUse_go_princess_stillpine_cage(Player* pPlayer, GameObject* pGO) if (pGO->GetGoType() == GAMEOBJECT_TYPE_DOOR) { DoScriptText(-1230010-urand(0, 2), Prisoner, pPlayer); - pPlayer->CastedCreatureOrGO(17682, Prisoner->GetGUID(), 31003); + pPlayer->CastCreatureOrGO(17682, Prisoner->GetGUID(), 31003); ((Creature*)Prisoner)->GetMotionMaster()->MoveFleeing(pPlayer,4000); CAST_AI(npc_princess_stillpineAI, ((Creature*)Prisoner)->AI())->FleeTimer = 4000; } diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp index 6d27467d3..a4374e1b2 --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_aeonus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp index fab8c4956..28d18c41d --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp index 4fb618fc7..770e3f6bd --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/boss_temporus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/dark_portal.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/dark_portal.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/caverns_of_time/dark_portal/dark_portal.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/dark_portal.cpp index 5f4ce8fd6..b81be4870 --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/dark_portal.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/dark_portal.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Dark_Portal @@ -397,7 +400,7 @@ struct npc_time_riftAI : public ScriptedAI else TimeRiftWave_Timer -= diff; } - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) return; debug_log("TSCR: npc_time_rift: not casting anylonger, i need to die."); diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/def_dark_portal.h b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/def_dark_portal.h new file mode 100644 index 000000000..89b49310d --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/def_dark_portal.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_DARKPORTAL_H +#define SC_DEF_DARKPORTAL_H + +#define TYPE_MEDIVH 1 +#define TYPE_RIFT 2 +#define TYPE_C_DEJA 3 +#define TYPE_TEMPORUS 4 + +#define DATA_MEDIVH 10 +#define DATA_PORTAL_COUNT 11 +#define DATA_SHIELD 12 + +#define WORLD_STATE_BM 2541 +#define WORLD_STATE_BM_SHIELD 2540 +#define WORLD_STATE_BM_RIFT 2784 + +#define QUEST_OPENING_PORTAL 10297 +#define QUEST_MASTER_TOUCH 9836 + +#define C_TIME_KEEPER 17918 + +#endif + diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp index 6fe628901..7510095ba --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/dark_portal/instance_dark_portal.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Dark_Portal diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_anetheron.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/boss_anetheron.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp index f3c589b75..abd61ea2b --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_anetheron.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_anetheron.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "def_hyjal.h" @@ -156,7 +173,7 @@ struct boss_anetheronAI : public hyjal_trashAI if(CheckTimer < diff) { DoZoneInCombat(); - if(!m_creature->IsNonMeleeSpellCasted(true)) + if(!m_creature->IsNonMeleeSpellCast(true)) { if(m_creature->GetSelection() != m_creature->getVictimGUID()) m_creature->SetSelection(m_creature->getVictimGUID()); diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp index 5c77492af..a18dd7c8f --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_archimonde.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_azgalor.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/boss_azgalor.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp index 95d27e77b..4b825e96e --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_azgalor.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_azgalor.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "def_hyjal.h" diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_kazrogal.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/boss_kazrogal.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp index 517ea3baf..05cb2cf72 --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_kazrogal.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_kazrogal.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "def_hyjal.h" diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_rage_winterchill.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/boss_rage_winterchill.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp index 15161d693..f428192d7 --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/boss_rage_winterchill.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/boss_rage_winterchill.cpp @@ -1,10 +1,27 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "def_hyjal.h" #include "hyjal_trash.h" #define SPELL_FROST_ARMOR 31256 -#define SPELL_DEATH_AND_DECAY 39658 +#define SPELL_DEATH_AND_DECAY 31258 #define SPELL_FROST_NOVA 31250 #define SPELL_ICEBOLT 31249 @@ -38,10 +55,6 @@ struct boss_rage_winterchillAI : public hyjal_trashAI pInstance = (c->GetInstanceData()); go = false; pos = 0; - - SpellEntry *decaySpell = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_DEATH_AND_DECAY); - if(decaySpell) - decaySpell->AttributesEx |= SPELL_ATTR_EX_CHANNELED_1; } uint32 FrostArmorTimer; diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/def_hyjal.h old mode 100755 new mode 100644 similarity index 53% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/def_hyjal.h index 0bb119b98..677e07f8d --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/def_hyjal.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_HYJAL_H -#define DEF_HYJAL_H +#ifndef SC_DEF_HYJAL_H +#define SC_DEF_HYJAL_H #define WORLD_STATE_WAVES 2842 #define WORLD_STATE_ENEMY 2453 diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal.cpp index ca93ab0fa..8db23d0c0 --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal.cpp @@ -1,4 +1,7 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -149,7 +152,7 @@ bool GossipHello_npc_thrall(Player *player, Creature *_Creature) uint32 AzgalorEvent = ai->GetInstanceData(DATA_AZGALOREVENT); if(KazrogalEvent == NOT_STARTED) player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BEGIN_HORDE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - else if(KazrogalEvent == DONE && AzgalorEvent == NOT_STARTED) + else if(KazrogalEvent == DONE && AzgalorEvent != DONE && AzgalorEvent != IN_PROGRESS) player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_AZGALOR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); else if(AzgalorEvent == DONE) player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.cpp index 565e94ed0..4ec383811 --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -941,7 +944,7 @@ void hyjalAI::UpdateAI(const uint32 diff) { if(SpellTimer[i] < diff) { - //if(m_creature->IsNonMeleeSpellCasted(false)) + //if(m_creature->IsNonMeleeSpellCast(false)) //m_creature->InterruptNonMeleeSpells(false); Unit* target = NULL; @@ -1073,7 +1076,7 @@ void hyjalAI::WaypointReached(uint32 i) (*itr)->GetMotionMaster()->Initialize(); float range = 10; if(m_creature->GetEntry() == THRALL)range = 20; - m_creature->GetNearPoint(m_creature, x, y, z, range, 0, m_creature->GetAngle((*itr))); + m_creature->GetNearPoint(x, y, z, range, 0, m_creature->GetAngle((*itr))); (*itr)->GetMotionMaster()->MovePoint(0, x+irand(-5,5), y+irand(-5,5), m_creature->GetPositionZ()); } } diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.h old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.h index 7952a40be..0f241a02a --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjalAI.h @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_HYJALAI_H #define SC_HYJALAI_H diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp index 2471aea4f..4bbef48cf --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" #include "def_hyjal.h" diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.h b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.h new file mode 100644 index 000000000..7a26f7882 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/hyjal_trash.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_HYJAL_TRASH_AI_H +#define SC_HYJAL_TRASH_AI_H + +#include "def_hyjal.h" +#include "escort_ai.h" + +#define MINRAIDDAMAGE 700000//minimal damage before trash can drop loot and reputation, resets if faction leader dies + +struct hyjal_trashAI : public npc_escortAI +{ + hyjal_trashAI(Creature *c); + + void UpdateAI(const uint32 diff); + + void JustDied(Unit* killer); + + void DamageTaken(Unit *done_by, uint32 &damage); + + public: + ScriptedInstance* pInstance; + bool IsEvent; + uint32 Delay; + uint32 LastOverronPos; + bool IsOverrun; + bool SetupOverrun; + uint32 OverrunType; + uint8 faction; + bool useFlyPath; + uint32 damageTaken; + float DummyTarget[3]; + + //private: +}; +#endif diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp index a6dcd0cb8..5c8b076ce --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/hyjal/instance_hyjal.cpp @@ -1,4 +1,7 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp new file mode 100644 index 000000000..0adff19b3 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Captain_Skarloc +SD%Complete: 99 +SDComment: +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" + +#define SAY_ENTER -1560000 +#define SAY_TAUNT1 -1560001 +#define SAY_TAUNT2 -1560002 +#define SAY_SLAY1 -1560003 +#define SAY_SLAY2 -1560004 +#define SAY_DEATH -1560005 + +#define SPELL_HOLY_LIGHT 29427 +#define SPELL_CLEANSE 29380 +#define SPELL_HAMMER_OF_JUSTICE 13005 +#define SPELL_HOLY_SHIELD 31904 +#define SPELL_DEVOTION_AURA 8258 +#define SPELL_CONSECRATION 38385 + +#define NPC_THRALL 17876 +#define C_WARDEN 17833 +#define C_VETERAN 17860 +#define SKARLOC_MOUNT 18798 +#define SKARLOC_MOUNT_MODEL 18223 + +struct boss_captain_skarlocAI : public ScriptedAI +{ + boss_captain_skarlocAI(Creature *creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + HeroicMode = me->GetMap()->IsHeroic(); + } + + ScriptedInstance *pInstance; + + bool HeroicMode; + bool Intro; + + uint8 Next; + uint32 IntroTimer; + uint32 Holy_Light_Timer; + uint32 Cleanse_Timer; + uint32 HammerOfJustice_Timer; + uint32 HolyShield_Timer; + uint32 DevotionAura_Timer; + uint32 Consecration_Timer; + uint64 Add1GUID; + uint64 Add2GUID; + uint64 ThrallinGUID; + + void Reset() + { + Intro = true; + Next = 0; + Add1GUID = 0; + Add2GUID = 0; + IntroTimer = 20000; + Holy_Light_Timer = 30000; + Cleanse_Timer = 10000; + HammerOfJustice_Timer = 60000; + HolyShield_Timer = 240000; + DevotionAura_Timer = 3000; + Consecration_Timer = 8000; + me->SetReactState(REACT_PASSIVE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->Mount(SKARLOC_MOUNT_MODEL); + SummonGuards(); + me->GetMotionMaster()->MovePoint(0, 2047.90f, 254.85f, 62.822f); + + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL))) + ThrallinGUID = Thrall->GetGUID(); + } + + void SummonGuards() + { + if (Creature *tAdd1 = DoSpawnCreature( C_WARDEN, -2, -2, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) + { + Add1GUID = tAdd1->GetGUID(); + tAdd1->SetReactState(REACT_PASSIVE); + tAdd1->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + tAdd1->GetMotionMaster()->MovePoint(0, 2044.12f, 253.47f, 62.748f); + } + + if (Creature *tAdd2 = DoSpawnCreature( C_VETERAN, 2, 2, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) + { + Add2GUID = tAdd2->GetGUID(); + tAdd2->SetReactState(REACT_PASSIVE); + tAdd2->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + tAdd2->GetMotionMaster()->MovePoint(0, 2049.22f, 258.16f, 62.754f); + } + } + + void MovementInform(uint32 type, uint32 id) + { + if (type == POINT_MOTION_TYPE) + { + switch (Next) + { + case 0: + me->Unmount(); + + if (Creature* Thrall = me->GetMap()->GetCreature(ThrallinGUID)) + Thrall->SummonCreature(SKARLOC_MOUNT,2047.90f, 254.85f, 62.822f, me->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 5000); + + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(0, 2056.80f, 240.81f, 63.538f); + + if (Creature* tAdd1 = me->GetCreature(Add1GUID)) + { + tAdd1->SetWalk(true); + tAdd1->GetMotionMaster()->MovePoint(0, 2052.94f, 239.37f, 63.219f); + } + + if (Creature* tAdd2 = me->GetCreature(Add2GUID)) + { + tAdd2->SetWalk(true); + tAdd2->GetMotionMaster()->MovePoint(0, 2058.66f, 243.99f, 63.59f); + } + + ++Next; + break; + case 1: + DoScriptText(SAY_ENTER, me); + ++Next; + break; + } + } + } + + void IntroEnd() + { + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetWalk(false); + + if (Creature* Thrall = me->GetMap()->GetCreature(ThrallinGUID)) + { + me->AI()->AttackStart(Thrall); + + if (Creature* tAdd1 = me->GetCreature(Add1GUID)) + { + tAdd1->SetReactState(REACT_AGGRESSIVE); + tAdd1->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + tAdd1->SetWalk(false); + tAdd1->AI()->AttackStart(Thrall); + } + + if (Creature* tAdd2 = me->GetCreature(Add2GUID)) + { + tAdd2->SetReactState(REACT_AGGRESSIVE); + tAdd2->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + tAdd2->SetWalk(false); + tAdd2->AI()->AttackStart(Thrall); + } + } + } + + void EnterCombat(Unit *who) + { + + DoScriptText(SAY_TAUNT1, me); + DoScriptText(SAY_TAUNT2, me); + } + + void KilledUnit(Unit *victim) + { + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); + } + + void EnterEvadeMode() + { + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (Creature* mount = tmpMap->GetCreature(tmpMap->GetCreatureGUID(SKARLOC_MOUNT))) + mount->ForcedDespawn(); + } + + void JustDied(Unit *victim) + { + DoScriptText(SAY_DEATH, me); + + if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS) + pInstance->SetData(TYPE_THRALL_PART1, DONE); + + if (pInstance->GetData(DATA_SKARLOC_DEATH) == DONE) + me->SetLootRecipient(NULL); + else + pInstance->SetData(DATA_SKARLOC_DEATH, DONE); + } + + void UpdateAI(const uint32 diff) + { + if (Intro) + { + if (IntroTimer < diff) + { + IntroEnd(); + Intro = false; + } + else + IntroTimer -= diff; + } + + //Return since we have no target + if (!UpdateVictim() ) + return; + + //Holy_Light + if (Holy_Light_Timer < diff) + { + DoCast(me, SPELL_HOLY_LIGHT); + Holy_Light_Timer = 30000; + } + else + Holy_Light_Timer -= diff; + + //Cleanse + if(Cleanse_Timer < diff) + { + DoCast(me, SPELL_CLEANSE); + Cleanse_Timer = 10000; + } + else + Cleanse_Timer -= diff; + + //Hammer of Justice + if (HammerOfJustice_Timer < diff) + { + DoCast(me->getVictim(), SPELL_HAMMER_OF_JUSTICE); + HammerOfJustice_Timer = 60000; + } + else + HammerOfJustice_Timer -= diff; + + //Holy Shield + if(HolyShield_Timer < diff) + { + DoCast(me, SPELL_HOLY_SHIELD); + HolyShield_Timer = 240000; + } + else + HolyShield_Timer -= diff; + + //Devotion_Aura + if (DevotionAura_Timer < diff) + { + DoCast(me, SPELL_DEVOTION_AURA); + DevotionAura_Timer = 60000; + } + else + DevotionAura_Timer -= diff; + + if(HeroicMode) + if(Consecration_Timer < diff) + { + DoCast(me, SPELL_CONSECRATION); + Consecration_Timer = 8000; + } + else + Consecration_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_captain_skarloc(Creature *creature) +{ + return new boss_captain_skarlocAI (creature); +} + +void AddSC_boss_captain_skarloc() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_captain_skarloc"; + newscript->GetAI = &GetAI_boss_captain_skarloc; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp new file mode 100644 index 000000000..bda125c5a --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp @@ -0,0 +1,408 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Epoch_Hunter +SD%Complete: 95 +SDComment: +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" + +#define SAY_AGGRO1 -1560016 +#define SAY_AGGRO2 -1560017 +#define SAY_SLAY1 -1560018 +#define SAY_SLAY2 -1560019 +#define SAY_BREATH1 -1560020 +#define SAY_BREATH2 -1560021 +#define SAY_DEATH -1560022 +#define SAY_INFINITE_AGGRO_1 -1560069 +#define SAY_INFINITE_AGGRO_2 -1560070 +#define SAY_INFINITE_AGGRO_3 -1560071 + +#define NPC_TARREN_MILL_GUARDSMAN 18092 +#define NPC_TARREN_MILL_PROTECTOR 18093 +#define NPC_TARREN_MILL_LOOKOUT 18094 +#define NPC_INFINITE_SLAYER 18170 +#define NPC_INFINITE_DEFILER 18171 +#define NPC_INFINITE_SABOTEUR 18172 +#define NPC_THRALL 17876 + +#define SPELL_SAND_BREATH 31914 +#define SPELL_IMPENDING_DEATH 31916 +#define SPELL_MAGIC_DISRUPTION_AURA 33834 +#define SPELL_WING_BUFFET HeroicMode ? 31475:38593 +#define SPELL_TRANSFORM 33133 // transform infinite defilers + +struct boss_epoch_hunterAI : public ScriptedAI +{ + boss_epoch_hunterAI(Creature *creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + HeroicMode = me->GetMap()->IsHeroic(); + } + + ScriptedInstance *pInstance; + + bool HeroicMode; + bool Intro; + bool Next; + + std::list attackers; + + uint8 Wave; + uint32 IntroTimer; + uint32 NextTimer; + uint32 SandBreath_Timer; + uint32 ImpendingDeath_Timer; + uint32 WingBuffet_Timer; + uint32 Mda_Timer; + uint64 ThrallGUID; + + void Reset() + { + Intro = true; + Next = true; + Wave = 0; + IntroTimer = 45000; + NextTimer = 51000; + SandBreath_Timer = 25000; + ImpendingDeath_Timer = 30000; + WingBuffet_Timer = 35000; + Mda_Timer = 40000; + attackers.clear(); + me->SetReactState(REACT_PASSIVE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL))) + ThrallGUID = Thrall->GetGUID(); + } + + void EnterCombat(Unit *who) + { + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2), me); + } + + void KilledUnit(Unit *victim) + { + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); + } + + void EnterEvadeMode() + { + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->ForcedDespawn(); + } + + void JustDied(Unit *victim) + { + DoScriptText(SAY_DEATH, me); + + if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS) + { + if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID)) + Thrall->AI()->DoAction(); + + pInstance->SetData(TYPE_THRALL_PART4, DONE); + } + + if (pInstance->GetData(DATA_EPOCH_DEATH) == DONE) + me->SetLootRecipient(NULL); + else + { + pInstance->SetData(DATA_EPOCH_DEATH, DONE); + pInstance->SetData(TYPE_THRALL_PART4, DONE); + } + + attackers.clear(); + } + + void JustSummoned(Creature* summoned) + { + attackers.push_back(summoned->GetGUID()); + summoned->SetReactState(REACT_PASSIVE); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void UpdateEntry() + { + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (!attackers.empty()) + { + for (std::list::iterator itr = attackers.begin(); itr != attackers.end(); ++itr) + { + if (Creature* attacker = tmpMap->GetCreature((*itr))) + { + attacker->CastSpell(attacker, SPELL_TRANSFORM, true); + + switch (attacker->GetEntry()) + { + case NPC_TARREN_MILL_GUARDSMAN: + attacker->UpdateEntry(NPC_INFINITE_SLAYER); + break; + case NPC_TARREN_MILL_PROTECTOR: + attacker->UpdateEntry(NPC_INFINITE_DEFILER); + + switch (Wave) + { + case 2: + DoScriptText(SAY_INFINITE_AGGRO_3, attacker); + break; + case 4: + DoScriptText(SAY_INFINITE_AGGRO_1, attacker); + break; + case 6: + DoScriptText(SAY_INFINITE_AGGRO_2, attacker); + break; + } + break; + case NPC_TARREN_MILL_LOOKOUT: + attacker->UpdateEntry(NPC_INFINITE_SABOTEUR); + break; + } + + attacker->SetReactState(REACT_AGGRESSIVE); + attacker->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID)) + attacker->AI()->AttackStart(Thrall); + } + } + } + } + + void NextWave() + { + ++Wave; + + switch (Wave) + { + case 1: + for (int i = 0; i < 3; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2639.87f, 696.65f, 55.803f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 1: + me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2635.31f, 697.35f, 56.024f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 2: + me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2644.64f, 697.09f, 55.860f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + } + } + break; + case 2: + UpdateEntry(); + Next = false; + break; + case 3: + for (int i = 0; i < 3; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2594.84f, 683.77f, 55.826f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 1: + me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2599.79f, 686.86f, 55.774f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 2: + me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2596.47f, 679.29f, 56.177f, 5.92f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + } + } + Next = true; + break; + case 4: + UpdateEntry(); + Next = false; + break; + case 5: + for (int i = 0; i < 4; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2639.87f, 696.65f, 55.803f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 1: + me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2635.31f, 697.35f, 56.024f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 2: + me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2644.64f, 697.09f, 55.860f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 3: + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2640.52f, 700.75f, 55.962f, 4.51f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + } + } + Next = true; + break; + case 6: + UpdateEntry(); + Next = false; + break; + case 7: + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->GetMotionMaster()->MovePoint(0, 2638.60f, 686.948f, 58.245f); + if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID)) + Thrall->AI()->AttackStart(me); + me->SetLevitate(false); + Intro = false; + break; + } + } + + void UpdateAI(const uint32 diff) + { + if (Intro) + { + if (IntroTimer < diff) + { + if (attackers.empty()) + NextWave(); + + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (!attackers.empty()) + { + bool alive = false; + for (std::list::iterator itr = attackers.begin(); itr != attackers.end(); ++itr) + { + if (Creature* attacker = tmpMap->GetCreature((*itr))) + { + if (attacker->isAlive()) + { + alive = true; + break; + } + } + } + + if (!alive) + { + NextWave(); + NextTimer = 5000; + } + } + + if (Creature* Thrall = tmpMap->GetCreature(ThrallGUID)) + { + if (!Thrall->isAlive()) + me->ForcedDespawn(); + } + + IntroTimer = 5000; + } + else + IntroTimer -= diff; + + if (Next) + { + if (NextTimer <= diff) + { + NextWave(); + } + else NextTimer -= diff; + } + } + + //Return since we have no target + if (!UpdateVictim() ) + return; + + //Sand Breath + if (SandBreath_Timer < diff) + { + if (me->IsNonMeleeSpellCast(false)) + me->InterruptNonMeleeSpells(false); + + DoCast(me->getVictim(),SPELL_SAND_BREATH); + + DoScriptText(RAND(SAY_BREATH1, SAY_BREATH2), me); + + SandBreath_Timer = 25000+rand()%5000; + } + else + SandBreath_Timer -= diff; + + if(ImpendingDeath_Timer < diff) + { + if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0 , GetSpellMaxRange(SPELL_IMPENDING_DEATH), true)) + DoCast(target,SPELL_IMPENDING_DEATH); + ImpendingDeath_Timer = 30000+rand()%5000; + } + else + ImpendingDeath_Timer -= diff; + + if(WingBuffet_Timer < diff) + { + DoCast(me,SPELL_WING_BUFFET); + WingBuffet_Timer = 25000+rand()%10000; + } + else + WingBuffet_Timer -= diff; + + if(Mda_Timer < diff) + { + DoCast(me,SPELL_MAGIC_DISRUPTION_AURA); + Mda_Timer = 15000; + } + else + Mda_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_epoch_hunter(Creature *creature) +{ + return new boss_epoch_hunterAI (creature); +} + +void AddSC_boss_epoch_hunter() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_epoch_hunter"; + newscript->GetAI = &GetAI_boss_epoch_hunter; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp old mode 100755 new mode 100644 similarity index 58% rename from src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp index 8962aa76d..e81bb2e52 --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_Luetenant_Drake -SD%Complete: 70 -SDComment: Missing proper code for patrolling area after being spawned. Script for GO (barrels) quest 10283 +SD%Complete: 99 +SDComment: SDCategory: Caverns of Time, Old Hillsbrad Foothills EndScriptData */ @@ -29,9 +32,9 @@ EndScriptData */ ## go_barrel_old_hillsbrad ######*/ -bool GOUse_go_barrel_old_hillsbrad(Player *player, GameObject* _GO) +bool GOUse_go_barrel_old_hillsbrad(Player *player, GameObject* go) { - ScriptedInstance* pInstance = (ScriptedInstance*)_GO->GetInstanceData(); + ScriptedInstance* pInstance = (ScriptedInstance*)go->GetInstanceData(); if (!pInstance) return false; @@ -41,6 +44,8 @@ bool GOUse_go_barrel_old_hillsbrad(Player *player, GameObject* _GO) pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS); + go->UseDoorOrButton(1800); + return false; } @@ -48,18 +53,17 @@ bool GOUse_go_barrel_old_hillsbrad(Player *player, GameObject* _GO) ## boss_lieutenant_drake ######*/ -#define SAY_ENTER -1560006 -#define SAY_AGGRO -1560007 -#define SAY_SLAY1 -1560008 -#define SAY_SLAY2 -1560009 -#define SAY_MORTAL -1560010 -#define SAY_SHOUT -1560011 -#define SAY_DEATH -1560012 +#define SAY_AGGRO -1560007 +#define SAY_SLAY1 -1560008 +#define SAY_SLAY2 -1560009 +#define SAY_MORTAL -1560010 +#define SAY_SHOUT -1560011 +#define SAY_DEATH -1560012 -#define SPELL_WHIRLWIND 31909 -#define SPELL_HAMSTRING 9080 -#define SPELL_MORTAL_STRIKE 31911 -#define SPELL_FRIGHTENING_SHOUT 33789 +#define SPELL_WHIRLWIND 31909 +#define SPELL_HAMSTRING 9080 +#define SPELL_MORTAL_STRIKE 31911 +#define SPELL_FRIGHTENING_SHOUT 33789 struct Location { @@ -87,21 +91,19 @@ static Location DrakeWP[]= {13, 2093.61, 139.441, 52.7616}, {14, 2086.29, 104.950, 52.9246}, {15, 2094.23, 81.2788, 52.6946}, - {16, 2108.70, 85.3075, 53.3294}, - {17, 2125.50, 88.9481, 54.7953}, - {18, 2128.20, 70.9763, 64.4221} + {16, 2108.70, 85.3075, 53.3294} }; struct boss_lieutenant_drakeAI : public ScriptedAI { - boss_lieutenant_drakeAI(Creature *c) : ScriptedAI(c) + boss_lieutenant_drakeAI(Creature *creature) : ScriptedAI(creature) { - pInstance = c->GetInstanceData(); + pInstance = creature->GetInstanceData(); } ScriptedInstance * pInstance; - bool CanPatrol; + bool WaypointReached; uint32 wpId; uint32 Whirlwind_Timer; @@ -111,68 +113,97 @@ struct boss_lieutenant_drakeAI : public ScriptedAI void Reset() { - CanPatrol = true; + WaypointReached = false; wpId = 0; - + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(DrakeWP[wpId].wpId, DrakeWP[wpId].x, DrakeWP[wpId].y, DrakeWP[wpId].z); Whirlwind_Timer = 20000; Fear_Timer = 30000; MortalStrike_Timer = 45000; ExplodingShout_Timer = 25000; } + void MovementInform(uint32 type, uint32 id) + { + if (type == POINT_MOTION_TYPE) + { + if (!me->isInCombat()) + { + ++wpId; + WaypointReached = true; + + if (wpId == 16) + wpId = 2; + } + } + } + void EnterCombat(Unit *who) { - DoScriptText(SAY_AGGRO, m_creature); + DoScriptText(SAY_AGGRO, me); + me->StopMoving(); + me->SetWalk(false); + } + + void EnterEvadeMode() + { + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX()-1.0f, me->GetPositionY()+1.0f, me->GetPositionZ()); } void KilledUnit(Unit *victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit *victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if (pInstance->GetData(DATA_DRAKE_DEATH) == DONE) - m_creature->SetLootRecipient(NULL); + me->SetLootRecipient(NULL); else pInstance->SetData(DATA_DRAKE_DEATH, DONE); + } void UpdateAI(const uint32 diff) { - //TODO: make this work - if (CanPatrol && wpId == 0) - { - m_creature->GetMotionMaster()->MovePoint(DrakeWP[0].wpId, DrakeWP[0].x, DrakeWP[0].y, DrakeWP[0].z); - wpId++; - } - //Return since we have no target if (!UpdateVictim()) + { + if (WaypointReached) + { + me->GetMotionMaster()->MovePoint(DrakeWP[wpId].wpId, DrakeWP[wpId].x, DrakeWP[wpId].y, DrakeWP[wpId].z); + WaypointReached = false; + } return; + } //Whirlwind if (Whirlwind_Timer < diff) { - DoCast(m_creature->getVictim(), SPELL_WHIRLWIND); + DoCast(me->getVictim(), SPELL_WHIRLWIND); Whirlwind_Timer = 20000+rand()%5000; }else Whirlwind_Timer -= diff; //Fear if (Fear_Timer < diff) { - DoScriptText(SAY_SHOUT, m_creature); - DoCast(m_creature->getVictim(), SPELL_FRIGHTENING_SHOUT); + DoScriptText(SAY_SHOUT, me); + DoCast(me->getVictim(), SPELL_FRIGHTENING_SHOUT); Fear_Timer = 30000+rand()%10000; }else Fear_Timer -= diff; //Mortal Strike if (MortalStrike_Timer < diff) { - DoScriptText(SAY_MORTAL, m_creature); - DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); + DoScriptText(SAY_MORTAL, me); + DoCast(me->getVictim(), SPELL_MORTAL_STRIKE); MortalStrike_Timer = 45000+rand()%5000; }else MortalStrike_Timer -= diff; @@ -180,9 +211,9 @@ struct boss_lieutenant_drakeAI : public ScriptedAI } }; -CreatureAI* GetAI_boss_lieutenant_drake(Creature *_Creature) +CreatureAI* GetAI_boss_lieutenant_drake(Creature *creature) { - return new boss_lieutenant_drakeAI (_Creature); + return new boss_lieutenant_drakeAI (creature); } void AddSC_boss_lieutenant_drake() diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h new file mode 100644 index 000000000..820a3ab35 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_OLD_HILLSBRAD_H +#define SC_DEF_OLD_HILLSBRAD_H + +#define TYPE_BARREL_DIVERSION 1 +#define TYPE_THRALL_EVENT 2 +#define TYPE_THRALL_PART1 3 +#define TYPE_THRALL_PART2 4 +#define TYPE_THRALL_PART3 5 +#define TYPE_THRALL_PART4 6 +#define DATA_THRALL 7 +#define DATA_TARETHA 8 +#define DATA_EPOCH 9 +#define DATA_SKARLOC_DEATH 10 +#define DATA_DRAKE_DEATH 11 +#define DATA_EPOCH_DEATH 12 +#define WORLD_STATE_OH 2436 + +#endif + diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp old mode 100755 new mode 100644 similarity index 55% rename from src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp rename to src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp index 64cadd4c1..9129ee8ab --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,45 +19,70 @@ /* ScriptData SDName: Instance_Old_Hillsbrad -SD%Complete: 75 -SDComment: If thrall escort fail, all parts will reset. In future, save sub-parts and continue from last known. +SD%Complete: 99 +SDComment: SDCategory: Caverns of Time, Old Hillsbrad Foothills EndScriptData */ #include "precompiled.h" #include "def_old_hillsbrad.h" -#define ENCOUNTERS 9 +#define ENCOUNTERS 9 -#define THRALL_ENTRY 17876 -#define TARETHA_ENTRY 18887 -#define EPOCH_ENTRY 18096 +#define THRALL_ENTRY 17876 +#define TARETHA_ENTRY 18887 +#define EPOCH_ENTRY 18096 +#define ORC_PRISONER_ENTRY 18598 +#define DRAKE_ENTRY 17848 -#define DRAKE_ENTRY 17848 +#define QUEST_ENTRY_DIVERSION 10283 +#define LODGE_QUEST_TRIGGER 20155 -#define QUEST_ENTRY_DIVERSION 10283 -#define LODGE_QUEST_TRIGGER 20155 +#define GO_ROARING_FLAME 182592 + +#define SAY_DRAKE_ENTER -1560006 + +static const float OrcLoc[][4] = +{ + {2104.51f, 91.96f, 53.14f, 0}, + {2192.58f, 238.44f, 52.44f, 0} +}; + +enum Summon +{ + NOT_SUMMONED = 0, + WAIT_FOR_SUMMON = 1, + SUMMONED = 2 +}; struct instance_old_hillsbrad : public ScriptedInstance { instance_old_hillsbrad(Map *map) : ScriptedInstance(map) {Initialize();}; uint32 Encounter[ENCOUNTERS]; - uint32 mBarrelCount; - uint32 mThrallEventCount; + uint32 BarrelCount; + uint32 ThrallEventCount; uint64 ThrallGUID; uint64 TarethaGUID; uint64 EpochGUID; + std::list RoaringFlamesList; + std::list LeftPrisonersList; + std::list RightPrisonersList; + + Summon summon; + void Initialize() { - mBarrelCount = 0; - mThrallEventCount = 0; + BarrelCount = 0; + ThrallEventCount = 0; ThrallGUID = 0; TarethaGUID = 0; EpochGUID = 0; + summon = NOT_SUMMONED; + for (uint8 i = 0; i < ENCOUNTERS; ++i) Encounter[i] = NOT_STARTED; } @@ -67,6 +95,15 @@ struct instance_old_hillsbrad : public ScriptedInstance return false; } + void OnPlayerEnter(Player* player) + { + if (player->isGameMaster()) + return; + + if (summon == NOT_SUMMONED) + summon = WAIT_FOR_SUMMON; + } + Player* GetPlayerInMap() { Map::PlayerList const& players = instance->GetPlayers(); @@ -94,10 +131,10 @@ struct instance_old_hillsbrad : public ScriptedInstance { if (Player* player = itr->getSource()) { - player->SendUpdateWorldState(WORLD_STATE_OH,mBarrelCount); + player->SendUpdateWorldState(WORLD_STATE_OH, BarrelCount); - if (mBarrelCount == 5) - player->KilledMonster(LODGE_QUEST_TRIGGER,0); + if (BarrelCount == 5) + player->KilledMonster(LODGE_QUEST_TRIGGER, 0); } } } @@ -118,9 +155,24 @@ struct instance_old_hillsbrad : public ScriptedInstance case EPOCH_ENTRY: EpochGUID = creature->GetGUID(); break; + case ORC_PRISONER_ENTRY: + if (creature->GetPositionZ() > 53.4f) + { + if (creature->GetPositionY() > 150.0f) + LeftPrisonersList.push_back(creature->GetGUID()); + else + RightPrisonersList.push_back(creature->GetGUID()); + } + break; } } + void OnObjectCreate(GameObject* go) + { + if (go->GetEntry() == GO_ROARING_FLAME) + RoaringFlamesList.push_back(go); + } + void SetData(uint32 type, uint32 data) { Player *player = GetPlayerInMap(); @@ -137,20 +189,50 @@ struct instance_old_hillsbrad : public ScriptedInstance { if (data == IN_PROGRESS) { - if (mBarrelCount >= 5) + if (BarrelCount >= 5) return; - ++mBarrelCount; + ++BarrelCount; UpdateOHWorldState(); - debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount); + debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u", BarrelCount); Encounter[0] = IN_PROGRESS; - if (mBarrelCount == 5) + if (BarrelCount == 5) { - player->SummonCreature(DRAKE_ENTRY,2128.43,71.01,64.42,1.74,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000); + if (Creature* drake = player->SummonCreature(DRAKE_ENTRY, 2128.43f, 71.01f, 64.42, 1.74f, TEMPSUMMON_DEAD_DESPAWN, 15000)) + DoScriptText(SAY_DRAKE_ENTER, drake, player); + Encounter[0] = DONE; + + for (std::list::iterator itr = RoaringFlamesList.begin(); itr != RoaringFlamesList.end(); ++itr) + { + // move the orcs outside the houses + float x, y, z; + for (std::list::iterator it = RightPrisonersList.begin(); it != RightPrisonersList.end(); ++it) + { + if (Creature* Orc = instance->GetCreature(*it)) + { + Orc->GetRandomPoint(OrcLoc[0][0], OrcLoc[0][1], OrcLoc[0][2], 10.0f, x, y, z); + Orc->SetWalk(false); + Orc->GetMotionMaster()->MovePoint(0, x, y, z); + } + } + + for (std::list::iterator il = LeftPrisonersList.begin(); il != LeftPrisonersList.end(); ++il) + { + if (Creature* Orc = instance->GetCreature(*il)) + { + Orc->GetRandomPoint(OrcLoc[1][0], OrcLoc[1][1], OrcLoc[1][2], 10.0f, x, y, z); + Orc->SetWalk(false); + Orc->GetMotionMaster()->MovePoint(0, x, y, z); + } + } + + (*itr)->SetRespawnTime(1800); + (*itr)->UpdateObjectVisibility(); + } } } break; @@ -159,46 +241,59 @@ struct instance_old_hillsbrad : public ScriptedInstance { if (data == FAIL) { - if (mThrallEventCount <= 20) + if (ThrallEventCount <= 20) { - mThrallEventCount++; + ThrallEventCount++; + debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times.", ThrallEventCount); + Encounter[1] = NOT_STARTED; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); - Encounter[2] = NOT_STARTED; - Encounter[3] = NOT_STARTED; - Encounter[4] = NOT_STARTED; - Encounter[5] = NOT_STARTED; + + if (Encounter[2] == IN_PROGRESS) + Encounter[2] = NOT_STARTED; + + if (Encounter[3] == IN_PROGRESS) + Encounter[3] = NOT_STARTED; + + if (Encounter[4] == IN_PROGRESS) + Encounter[4] = NOT_STARTED; + + if (Encounter[5] == IN_PROGRESS) + Encounter[5] = NOT_STARTED; } - else if (mThrallEventCount > 20) + else if (ThrallEventCount > 20) { - Encounter[1] = data; - Encounter[2] = data; - Encounter[3] = data; - Encounter[4] = data; - Encounter[5] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); + Encounter[0] = DONE; + Encounter[1] = DONE; + Encounter[2] = DONE; + Encounter[3] = DONE; + Encounter[4] = DONE; + Encounter[5] = DONE; + Encounter[6] = DONE; + Encounter[7] = DONE; + Encounter[8] = DONE; + debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. This is the end.", ThrallEventCount); } } else Encounter[1] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.",data); + debug_log("TSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.", data); break; } case TYPE_THRALL_PART1: Encounter[2] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.",data); + debug_log("TSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.", data); break; case TYPE_THRALL_PART2: Encounter[3] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.",data); + debug_log("TSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.", data); break; case TYPE_THRALL_PART3: Encounter[4] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.",data); + debug_log("TSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.", data); break; case TYPE_THRALL_PART4: Encounter[5] = data; - debug_log("TSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.",data); + debug_log("TSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.", data); break; case DATA_SKARLOC_DEATH: if (Encounter[6] != DONE) @@ -259,6 +354,34 @@ struct instance_old_hillsbrad : public ScriptedInstance return 0; } + void Update(uint32 diff) + { + if (summon == WAIT_FOR_SUMMON) + { + if (instance->GetPlayers().isEmpty()) + return; + + Player* player = instance->GetPlayers().begin()->getSource(); + + if (GetData(TYPE_THRALL_PART1) == NOT_STARTED) + player->SummonCreature(THRALL_ENTRY, 2231.51f, 119.84f, 82.297f, 4.15f,TEMPSUMMON_DEAD_DESPAWN,15000); + + if (GetData(TYPE_THRALL_PART1) == DONE && GetData(TYPE_THRALL_PART2) == NOT_STARTED) + { + player->SummonCreature(THRALL_ENTRY, 2063.40f, 229.512f, 64.488f, 2.18f,TEMPSUMMON_DEAD_DESPAWN,15000); + player->SummonCreature(18798, 2047.90f, 254.85f, 62.822f, 5.94f, TEMPSUMMON_DEAD_DESPAWN, 15000); + } + + if (GetData(TYPE_THRALL_PART2) == DONE && GetData(TYPE_THRALL_PART3) == NOT_STARTED) + player->SummonCreature(THRALL_ENTRY, 2486.91f, 626.357f, 58.076f, 4.66f,TEMPSUMMON_DEAD_DESPAWN,15000); + + if (GetData(TYPE_THRALL_PART3) == DONE && GetData(TYPE_THRALL_PART4) == NOT_STARTED) + player->SummonCreature(THRALL_ENTRY, 2660.48f, 659.409f, 61.937f, 5.83f,TEMPSUMMON_DEAD_DESPAWN,15000); + + summon = SUMMONED; + } + } + std::string GetSaveData() { OUT_SAVE_INST_DATA; diff --git a/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp new file mode 100644 index 000000000..b43c3c198 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp @@ -0,0 +1,1263 @@ + /* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Old_Hillsbrad +SD%Complete: 95 +SDComment: +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +/* ContentData +npc_brazen +npc_erozion +npc_thrall_old_hillsbrad +npc_taretha +erozion_image +EndContentData */ + +#include "precompiled.h" +#include "escort_ai.h" +#include "def_old_hillsbrad.h" + +#define QUEST_ENTRY_HILLSBRAD 10282 +#define QUEST_ENTRY_DIVERSION 10283 +#define QUEST_ENTRY_ESCAPE 10284 +#define QUEST_ENTRY_RETURN 10285 +#define ITEM_ENTRY_BOMBS 25853 + +/*###### +## npc_brazen +######*/ + +bool GossipHello_npc_brazen(Player *player, Creature *creature) +{ + player->ADD_GOSSIP_ITEM(0, "I am ready to go to Durnholde Keep.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(creature->GetNpcTextId(), creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_brazen(Player *player, Creature *creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + if (!player->HasItemCount(ITEM_ENTRY_BOMBS, 1)) + player->SEND_GOSSIP_MENU(9780, creature->GetGUID()); + else + { + player->CLOSE_GOSSIP_MENU(); + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 115; //from brazen + nodes[1] = 116; //end outside durnholde + player->ActivateTaxiPathTo(nodes); //TaxiPath 534 + } + } + return true; +} + +/*###### +## npc_erozion +######*/ + +bool GossipHello_npc_erozion(Player *player, Creature *creature) +{ + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + ScriptedInstance* pInstance = (creature->GetInstanceData()); + if ( pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS, 1)) + player->ADD_GOSSIP_ITEM( 0, "I need a pack of Incendiary Bombs.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + //if( !player->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && player->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE ) + //player->ADD_GOSSIP_ITEM( 0, "[PH] Teleport please, i'm tired.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + player->SEND_GOSSIP_MENU(9778, creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_erozion(Player *player, Creature *creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_ENTRY_BOMBS, 1); + if (msg == EQUIP_ERR_OK) + { + player->StoreNewItem(dest, ITEM_ENTRY_BOMBS, true); + } + player->SEND_GOSSIP_MENU(9515, creature->GetGUID()); + } + + /*if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + }*/ + + return true; +} + +/*###### +## npc_thrall_old_hillsbrad +######*/ + +enum Thrall +{ + //Thrall event texts + SAY_TH_START_EVENT_PART1 = -1560023, + SAY_ARMORER_CALL_GUARDS = -1560059, + SAY_TH_KILL_ARMORER = -1560050, + SAY_TH_ARMORY = -1560024, + SAY_TH_ARMORY_2 = -1560060, + SAY_AMBUSH_P1 = -1560073, + SAY_AMBUSH2_P1 = -1560074, + SAY_THRALL_END_P1 = -1560072, + SAY_TH_SKARLOC_MEET = -1560025, + SAY_TH_SKARLOC_TAUNT = -1560026, + SAY_TH_START_EVENT_PART2 = -1560027, + SAY_TH_MOUNTS_UP = -1560028, + EMOTE_TH_STARTLE_HORSE = -1560061, + EMOTE_TH_CALM_HORSE = -1560062, + SAY_TH_HEAD_TOWN = -1560063, + SAY_TH_CHURCH_ENTER = -1560064, + SAY_TH_CHURCH_END = -1560029, + SAY_TH_MEET_TARETHA = -1560030, + SAY_TH_EPOCH_WONDER = -1560031, + SAY_TH_EPOCH_KILL_TARETHA = -1560032, + SAY_TH_EVENT_COMPLETE = -1560033, + + SAY_TA_FREE = -1560048, + SAY_TA_ESCAPED = -1560049, + SAY_TR_GLAD_SAFE = -1560054, + SAY_TA_NEVER_MET = -1560055, + SAY_TR_THEN_WHO = -1560056, + SAY_WIPE_MEMORY = -1560051, + SAY_ABOUT_TARETHA = -1560052, + SAY_TA_FAREWELL = -1560053, + SAY_LOOKOUT_BARN_1 = -1560065, + SAY_PROTECTOR_BARN_2 = -1560066, + SAY_LOOKOUT_CHURCH = -1560067, + SAY_LOOKOUT_INN = -1560068, + + SAY_EPOCH_ENTER1 = -1560013, + SAY_EPOCH_ENTER2 = -1560014, + SAY_EPOCH_ENTER3 = -1560015, + + SAY_IMAGE_1 = -1560075, + SAY_IMAGE_2 = -1560076, + + SAY_TH_RANDOM_LOW_HP1 = -1560034, + SAY_TH_RANDOM_LOW_HP2 = -1560035, + + SAY_TH_RANDOM_DIE1 = -1560036, + SAY_TH_RANDOM_DIE2 = -1560037, + + SAY_TH_RANDOM_AGGRO1 = -1560038, + SAY_TH_RANDOM_AGGRO2 = -1560039, + SAY_TH_RANDOM_AGGRO3 = -1560040, + SAY_TH_RANDOM_AGGRO4 = -1560041, + + SAY_TH_RANDOM_KILL1 = -1560042, + SAY_TH_RANDOM_KILL2 = -1560043, + SAY_TH_RANDOM_KILL3 = -1560044, + + SAY_TH_LEAVE_COMBAT1 = -1560045, + SAY_TH_LEAVE_COMBAT2 = -1560046, + SAY_TH_LEAVE_COMBAT3 = -1560047, + + NPC_IMAGE_OF_ERONZION = 19438, + NPC_SKARLOC_MOUNT = 18798, + NPC_THRALL_QUEST_TRIGGER = 20156, + + NPC_WARDEN = 17833, + NPC_VETERAN = 17860, + NPC_MAGE = 18934, + NPC_SENTRY = 17819, + + NPC_CHURCH_GUARDSMAN = 23175, + NPC_CHURCH_PROTECTOR = 23179, + NPC_CHURCH_LOOKOUT = 23177, + + NPC_INN_GUARDSMAN = 23176, + NPC_INN_PROTECTOR = 23180, + NPC_INN_LOOKOUT = 23178, + + NPC_INFINITE_DEFILER = 18171, + NPC_INFINITE_SABOTEOR = 18172, + NPC_INFINITE_SLAYER = 18170, + + NPC_TARREN_MILL_GUARDSMAN = 18092, + NPC_TARREN_MILL_PROTECTOR = 18093, + NPC_TARREN_MILL_LOOKOUT = 18094, + + NPC_ARMORER = 18764, + NPC_SKARLOC = 17862, + NPC_EPOCH = 18096, + NPC_THRALL = 17876, + NPC_EROZION = 18723, + + SPELL_KNOCKOUT_ARMORER = 32890, + SPELL_STRIKE = 14516, + SPELL_SHIELD_BLOCK = 12169, + SPELL_SHADOW_SPIKE = 33125, + SPELL_TELEPORT = 7791, + SPELL_MEMORY_WIPE = 33336, + SPELL_MEMORY_WP_RESUME = 33337, + SPELL_SHADOW_PRISON = 33071, + + GO_PRISON_DOOR = 184393 +}; + +#define SPEED_WALK (0.5f) +#define SPEED_RUN (1.0f) +#define SPEED_MOUNT (1.6f) + +#define THRALL_WEAPON_MODEL 22106 +#define THRALL_WEAPON_INFO 218169346 +#define THRALL_SHIELD_MODEL 18662 +#define THRALL_SHIELD_INFO 234948100 +#define THRALL_MODEL_UNEQUIPPED 17292 +#define THRALL_MODEL_EQUIPPED 18165 +#define SKARLOC_MOUNT_MODEL 18223 + +//gossip items +#define GOSSIP_ITEM_START "We are ready to get you out of here, Thrall. Let's go!" +#define GOSSIP_ID_START 9568 +#define GOSSIP_ID_SKARLOC1 9614 //I'm glad Taretha is alive. We now must find a way to free her... +#define GOSSIP_ITEM_SKARLOC1 "Taretha cannot see you, Thrall." +#define GOSSIP_ID_SKARLOC2 9579 //What do you mean by this? Is Taretha in danger? +#define GOSSIP_ITEM_SKARLOC2 "The situation is rather complicated, Thrall. It would be best for you to head into the mountains now, before more of Blackmoore's men show up. We'll make sure Taretha is safe." +#define GOSSIP_ID_SKARLOC3 9580 +#define GOSSIP_ITEM_SKARLOC3 "Tarren Mill." +#define GOSSIP_ID_TARREN 9597 //tarren mill is beyond these trees +#define GOSSIP_ITEM_TARREN "We're ready, Thrall." +#define GOOSIP_ID_TARETHA 9614 +#define GOSSIP_ID_COMPLETE 9578 //Thank you friends, I owe my freedom to you. Where is Taretha? I hoped to see her + +struct npc_thrall_old_hillsbradAI : public npc_escortAI +{ + npc_thrall_old_hillsbradAI(Creature *creature) : npc_escortAI(creature) + { + pInstance = (creature->GetInstanceData()); + HadMount = false; + me->setActive(true); + } + + ScriptedInstance *pInstance; + + uint64 TarethaGUID; + uint64 MountGUID; + uint64 ArmorerGUID; + uint64 ImageGUID; + uint64 EpochGUID; + uint8 Part; + uint32 Steps; + uint32 StepsTimer; + uint32 StrikeTimer; + uint32 ShieldBlockTimer; + uint32 EmoteTimer; + + bool LowHp; + bool HadMount; + bool Event; + + void Reset() + { + LowHp = false; + Event = false; + + MountGUID = 0; + ArmorerGUID = 0; + ImageGUID = 0; + EpochGUID = 0; + TarethaGUID = pInstance->GetData64(DATA_TARETHA); + + Steps = 0; + StepsTimer = 0; + EmoteTimer = 0; + Part = 0; + StrikeTimer = urand(3000, 7000); + ShieldBlockTimer = urand(6000, 11000); + + if (HadMount) + DoMount(); + + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + { + DoUnmount(); + HadMount = false; + } + else + DoScriptText(RAND(SAY_TH_LEAVE_COMBAT1, SAY_TH_LEAVE_COMBAT2, SAY_TH_LEAVE_COMBAT3), me); + + if (pInstance && pInstance->GetData(TYPE_THRALL_PART1) == NOT_STARTED) + { + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 0); + me->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_UNEQUIPPED); + } + else + { + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038); + me->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_EQUIPPED); + } + } + + void WaypointReached(uint32 i) + { + switch (Part) + { + case 1: + switch (i) + { + case 0: + if (GameObject* door = FindGameObject(GO_PRISON_DOOR, INTERACTION_DISTANCE, me)) + door->UseDoorOrButton(6); + break; + case 7: + if (Creature* Armorer = me->SummonCreature(NPC_ARMORER, 2180.95f, 119.19f, 89.456f, 5.692f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 35000)) + DoScriptText(SAY_ARMORER_CALL_GUARDS, Armorer); + break; + case 8: + SetRun(false); + break; + case 9: + DoScriptText(SAY_TH_KILL_ARMORER, me); + DoCast(me, SPELL_KNOCKOUT_ARMORER); + if (Creature* Armorer = me->GetMap()->GetCreature(ArmorerGUID)) + Armorer->setDeathState(JUST_DIED); + break; + case 10: + DoScriptText(SAY_TH_ARMORY, me); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + break; + case 11: + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038); + me->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_EQUIPPED); + me->SetStandState(UNIT_STAND_STATE_STAND); + SetRun(); + break; + case 12: + if (Player* player = GetPlayerForEscort()) + me->SetFacingToObject(player); + DoScriptText(SAY_TH_ARMORY_2, me); + break; + case 17: + me->SummonCreature(NPC_MAGE, 2186.909f, 139.8108f, 88.21628f, 5.75f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_WARDEN, 2187.943f, 141.6124f, 88.21628f, 5.73f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2190.508f, 140.4597f, 88.21628f, 6.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2189.543f, 139.0996f, 88.23965f, 0.21f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 20: + me->SummonCreature(NPC_MAGE, 2149.463f, 104.9756f, 73.63239f, 1.71f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_SENTRY, 2147.642f, 105.0251f, 73.99422f, 1.52f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2149.212f, 107.2005f, 74.15676f, 1.71f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_WARDEN, 2147.328f, 106.7235f, 74.34447f, 1.69f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 23: + me->SummonCreature(NPC_MAGE, 2142.363f, 172.4260f, 66.30494f, 2.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_SENTRY, 2138.177f, 168.6046f, 66.30494f, 2.47f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_SENTRY, 2142.372f, 174.2907f, 66.30494f, 2.56f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2140.146f, 169.2364f, 66.30494f, 2.49f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 25: + me->SummonCreature(NPC_MAGE, 2107.938f, 192.0753f, 66.30494f, 2.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_MAGE, 2109.852f, 195.1403f, 66.30493f, 2.42f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2108.486f, 189.9346f, 66.30494f, 2.68f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_VETERAN, 2112.387f, 195.4947f, 66.30494f, 2.39f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 31: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_POINT); + EmoteTimer = 2000; + me->SetFacingTo(2.18f); + me->SummonCreature(NPC_SKARLOC, 2000.201f, 277.9190f, 66.4911f, 6.11f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + DoScriptText(SAY_TH_SKARLOC_MEET, me); + break; + case 33: + me->SetFacingTo(2.18f); + DoScriptText(SAY_THRALL_END_P1, me); + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + break; + } + break; + case 2: + switch (i) + { + case 1: + DoScriptText(SAY_TH_MOUNTS_UP, me); + DoMount(); + if (Creature* mount = me->GetCreature(me->GetMap()->GetCreatureGUID(NPC_SKARLOC_MOUNT))) + mount->ForcedDespawn(); + SetRun(); + break; + case 29: + me->SummonCreature(NPC_SKARLOC_MOUNT, 2488.64f, 625.77f, 58.26, 4.71f,TEMPSUMMON_TIMED_DESPAWN,10000); + DoUnmount(); + HadMount = false; + SetRun(false); + break; + case 30: + if (Creature* mount = me->GetMap()->GetCreature(MountGUID)) + me->SetFacingToObject(mount); + DoScriptText(EMOTE_TH_STARTLE_HORSE, me); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_EXCLAMATION); + EmoteTimer = 2000; + break; + case 31: + if (Creature* mount = me->GetMap()->GetCreature(MountGUID)) + { + mount->SetWalk(false); + mount->GetMotionMaster()->MovePoint(0, 2517.504f, 506.253f, 42.329f); + } + me->SetFacingTo(4.66f); + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + pInstance->SetData(TYPE_THRALL_PART2, DONE); + break; + } + break; + case 3: + switch (i) + { + case 3: + SetRun(false); + break; + case 6: + DoScriptText(EMOTE_TH_CALM_HORSE, me); + break; + case 9: + me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2510.16f, 693.98f, 55.50f, 2.84f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2510.02f, 697.72f, 55.51f, 3.38f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2507.83f, 693.76f, 55.50f, 3.14f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2508.22f, 698.00f, 55.50f, 3.14f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 13: + DoScriptText(SAY_TH_HEAD_TOWN, me); + SetRun(); + break; + case 24: + if (Player* player = GetPlayerForEscort()) + me->SetFacingToObject(player); + DoScriptText(SAY_TH_CHURCH_ENTER, me); + break; + case 25: + me->SummonCreature(NPC_CHURCH_PROTECTOR, 2627.88f, 657.63f, 55.98f, 4.28f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_CHURCH_LOOKOUT, 2627.27f, 655.17f, 56.03f, 4.50f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_CHURCH_LOOKOUT, 2629.21f, 654.81f, 56.04f, 4.38f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_CHURCH_GUARDSMAN, 2629.98f, 656.96f, 55.96f, 4.34f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 27: + DoScriptText(SAY_TH_CHURCH_END, me); + break; + case 35: + me->SummonCreature(NPC_INN_PROTECTOR, 2652.71f, 660.31f, 61.93f, 1.67f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_INN_LOOKOUT, 2648.96f, 662.59f, 61.93f, 0.79f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_INN_LOOKOUT, 2657.36f, 662.34f, 61.93f, 2.68f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->SummonCreature(NPC_INN_GUARDSMAN, 2656.39f, 659.77f, 61.93f, 2.61f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + break; + case 36: + SetRun(false); + break; + case 37: + if (Creature* Taretha = me->GetMap()->GetCreature(TarethaGUID)) + DoScriptText(SAY_TA_ESCAPED, Taretha, me); + break; + case 38: + pInstance->SetData(TYPE_THRALL_PART3,DONE); + DoScriptText(SAY_TH_MEET_TARETHA, me); + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + break; + } + break; + case 4: + switch (i) + { + case 0: + if (Creature* Epoch = me->SummonCreature(NPC_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_DEAD_DESPAWN,120000)) + DoScriptText(SAY_EPOCH_ENTER1, Epoch); + me->SetFacingTo(2.63f); + DoScriptText(SAY_TH_EPOCH_WONDER, me); + break; + case 1: + me->SetFacingTo(5.79f); + DoScriptText(SAY_TH_EPOCH_KILL_TARETHA, me); + if (Creature* Epoch = me->GetMap()->GetCreature(EpochGUID)) + DoScriptText(SAY_EPOCH_ENTER2, Epoch); + if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) + { + Creature* Taretha = (Unit::GetCreature(*me, TarethaGUID)); + Taretha->CastSpell(Taretha, SPELL_SHADOW_SPIKE, true); + Taretha->SetStandState(UNIT_STAND_STATE_DEAD); + } + break; + case 9: + if (Creature* Epoch = me->GetMap()->GetCreature(EpochGUID)) + { + DoScriptText(SAY_EPOCH_ENTER3, Epoch); + me->SetFacingToObject(Epoch); + } + SetEscortPaused(true); + break; + case 11: + if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) + { + Creature* Taretha = (Unit::GetCreature(*me, TarethaGUID)); + if (Player* pPlayer = GetPlayerForEscort()) + CAST_AI(npc_escortAI, (Taretha->AI()))->Start(false, true, pPlayer->GetGUID()); + } + Event = true; + me->SetFacingTo(5.79f); + SetEscortPaused(true); + break; + case 13: + Event = false; + pInstance->SetData(TYPE_THRALL_EVENT, DONE); + break; + } + break; + } + } + + void DoMount() + { + me->Mount(SKARLOC_MOUNT_MODEL); + me->SetSpeed(MOVE_RUN,SPEED_MOUNT); + } + + void DoUnmount() + { + me->Unmount(); + me->SetSpeed(MOVE_RUN,SPEED_RUN); + } + + void DoAction(const int32 action) + { + SetEscortPaused(false); + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if (spell->Id == SPELL_MEMORY_WP_RESUME) + me->RemoveAllAuras(); + } + + void EnterCombat(Unit* who) + { + DoScriptText(RAND(SAY_TH_RANDOM_AGGRO1, SAY_TH_RANDOM_AGGRO2, SAY_TH_RANDOM_AGGRO3, SAY_TH_RANDOM_AGGRO4), me); + + if (me->IsMounted()) + { + DoUnmount(); + HadMount = true; + } + } + + void QuestCredit() + { + Map* pMap = me->GetMap(); + Map::PlayerList const& players = pMap->GetPlayers(); + if (!players.isEmpty() && pMap->IsDungeon()) + { + for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if (Player* player = itr->getSource()) + player->KilledMonster(NPC_THRALL_QUEST_TRIGGER,me->GetGUID()); + } + } + } + + void JustSummoned(Creature* summoned) + { + switch (summoned->GetEntry()) + { + case NPC_ARMORER: + ArmorerGUID = summoned->GetGUID(); + summoned->SetReactState(REACT_PASSIVE); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + break; + case NPC_WARDEN: + DoScriptText(RAND(SAY_AMBUSH_P1, SAY_AMBUSH2_P1), summoned); + summoned->AI()->AttackStart(me); + break; + case NPC_SKARLOC_MOUNT: + MountGUID = summoned->GetGUID(); + break; + case NPC_EROZION: + ImageGUID = summoned->GetGUID(); + summoned->CastSpell(summoned, SPELL_TELEPORT, false); + break; + case NPC_CHURCH_PROTECTOR: + DoScriptText(SAY_LOOKOUT_CHURCH, summoned); + summoned->AI()->AttackStart(me); + break; + case NPC_INN_PROTECTOR: + DoScriptText(SAY_LOOKOUT_INN, summoned); + summoned->AI()->AttackStart(me); + break; + case NPC_TARREN_MILL_PROTECTOR: + DoScriptText(SAY_PROTECTOR_BARN_2, summoned); + break; + case NPC_TARREN_MILL_LOOKOUT: + DoScriptText(SAY_LOOKOUT_BARN_1, summoned); + break; + case NPC_EPOCH: + EpochGUID = summoned->GetGUID(); + summoned->SetLevitate(true); + break; + case NPC_TARREN_MILL_GUARDSMAN: + case NPC_SKARLOC: + break; + default: + summoned->AI()->AttackStart(me); + break; + } + } + + void KilledUnit(Unit *victim) + { + DoScriptText(RAND(SAY_TH_RANDOM_KILL1, SAY_TH_RANDOM_KILL2, SAY_TH_RANDOM_KILL3), me); + } + + void JustDied(Unit *slayer) + { + if (pInstance) + { + pInstance->SetData(TYPE_THRALL_EVENT,FAIL); + slayer->SummonCreature(NPC_IMAGE_OF_ERONZION, me->GetPositionX()+2, me->GetPositionY()+2, me->GetPositionZ(),me->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 10000); + } + + // Don't do a yell if he kills self (if player goes too far or at the end). + if (slayer == me) + return; + + DoScriptText(RAND(SAY_TH_RANDOM_DIE1, SAY_TH_RANDOM_DIE2), me); + } + + int32 NextStep(uint32 Steps) + { + if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) + { + Creature* Taretha = (Unit::GetCreature(*me, TarethaGUID)); + Creature* Image = me->GetMap()->GetCreature(ImageGUID); + + switch (Steps) + { + case 1: + return 15000; + case 2: + DoScriptText(SAY_TR_GLAD_SAFE, me); + return 10000; + case 3: + DoScriptText(SAY_TA_NEVER_MET, Taretha); + return 10000; + case 4: + DoScriptText(SAY_TR_THEN_WHO, me); + return 5000; + case 5: + me->SummonCreature(NPC_EROZION, 2648.47f, 684.43f, 55.713f, 3.86f, TEMPSUMMON_TIMED_DESPAWN, 300000); + return 5000; + case 6: + Image->CastSpell(Image, SPELL_MEMORY_WIPE, false); + return 5000; + case 7: + DoScriptText(SAY_WIPE_MEMORY, Image); + return 10000; + case 8: + DoScriptText(SAY_ABOUT_TARETHA, Image); + return 5000; + case 9: + Image->CastSpell(Image, SPELL_MEMORY_WP_RESUME, false); + DoScriptText(SAY_TH_EVENT_COMPLETE, me); + return 6000; + case 10: + Taretha->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); + DoScriptText(SAY_TA_FAREWELL, Taretha); + SetEscortPaused(false); + QuestCredit(); + return 3000; + case 11: + Taretha->SetWalk(true); + Taretha->GetMotionMaster()->MovePoint(0, 2639.96f, 703.66f, 56.056f); + Taretha->ForcedDespawn(11000); + default: + return 0; + } + } + return true; + } + + void StartEscort (Player* player, uint8 Parts) + { + Part = Parts; + + switch (Parts) + { + case 1: + AddWaypoint(0, 2230.91, 118.765, 82.2947, 2000), + AddWaypoint(1, 2230.33, 114.980, 82.2946, 0); + AddWaypoint(2, 2233.36, 111.057, 82.2996, 0); + AddWaypoint(3, 2231.17, 108.486, 82.6624, 0); + AddWaypoint(4, 2220.22, 114.605, 89.4264, 0); + AddWaypoint(5, 2215.23, 115.990, 89.4549, 0); + AddWaypoint(6, 2207.97, 105.351, 89.4549, 0); + AddWaypoint(7, 2202.53, 106.922, 89.4549, 0); + AddWaypoint(8, 2192.26, 112.618, 89.4549, 2000); + AddWaypoint(9, 2182.96, 117.850, 89.4548, 2000); + AddWaypoint(10, 2182.11, 120.328, 89.4548, 5000); + AddWaypoint(11, 2182.11, 120.329, 89.4548, 5000); + AddWaypoint(12, 2182.11, 120.330, 89.4548, 3000); + AddWaypoint(13, 2189.44, 113.922, 89.4549, 0); + AddWaypoint(14, 2195.63, 110.584, 89.4549, 0); + AddWaypoint(15, 2201.09, 115.115, 89.4549, 0); + AddWaypoint(16, 2204.34, 121.036, 89.4355, 0); + AddWaypoint(17, 2208.66, 129.127, 87.9560, 0); + AddWaypoint(18, 2193.09, 137.940, 88.2164, 0); + AddWaypoint(19, 2173.39, 149.064, 87.9227, 0); + AddWaypoint(20, 2164.25, 137.965, 85.0595, 0); + AddWaypoint(21, 2149.31, 125.645, 77.0858, 0); + AddWaypoint(22, 2142.78, 127.173, 75.5954, 0); + AddWaypoint(23, 2139.28, 133.952, 73.6386, 0); + AddWaypoint(24, 2139.54, 155.235, 67.1269, 0); + AddWaypoint(25, 2145.38, 167.551, 64.8974, 0); + AddWaypoint(26, 2134.28, 175.304, 67.9446, 0); + AddWaypoint(27, 2118.08, 187.387, 68.8141, 0); + AddWaypoint(28, 2105.88, 195.461, 65.1854, 0); + AddWaypoint(29, 2096.77, 196.939, 65.2117, 0); + AddWaypoint(30, 2083.90, 209.395, 64.8736, 0); + AddWaypoint(31, 2063.40, 229.509, 64.4883, 25000); + AddWaypoint(32, 2063.40, 229.510, 64.4883, 0); + AddWaypoint(33, 2063.40, 229.512, 64.4883, 0); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(true, true, player->GetGUID()); + break; + case 2: + AddWaypoint(0, 2046.70, 251.941, 62.7851, 4000); + AddWaypoint(1, 2046.70, 251.942, 62.7851, 3000); + AddWaypoint(2, 2011.77, 278.478, 65.3388, 0); + AddWaypoint(3, 2005.08, 289.676, 66.1179, 0); + AddWaypoint(4, 2033.11, 337.450, 66.0948, 0); + AddWaypoint(5, 2070.30, 416.208, 66.0893, 0); + AddWaypoint(6, 2086.76, 469.768, 65.9182, 0); + AddWaypoint(7, 2101.70, 497.955, 61.7881, 0); + AddWaypoint(8, 2133.39, 530.933, 55.3700, 0); + AddWaypoint(9, 2157.91, 559.635, 48.5157, 0); + AddWaypoint(10, 2167.34, 586.191, 42.4394, 0); + AddWaypoint(11, 2174.17, 637.643, 33.9002, 0); + AddWaypoint(12, 2179.31, 656.053, 34.723, 0); + AddWaypoint(13, 2183.65, 670.941, 34.0318, 0); + AddWaypoint(14, 2201.50, 668.616, 36.1236, 0); + AddWaypoint(15, 2221.56, 652.747, 36.6153, 0); + AddWaypoint(16, 2238.97, 640.125, 37.2214, 0); + AddWaypoint(17, 2251.17, 620.574, 40.1473, 0); + AddWaypoint(18, 2261.98, 595.303, 41.4117, 0); + AddWaypoint(19, 2278.67, 560.172, 38.9090, 0); + AddWaypoint(20, 2336.72, 528.327, 40.9369, 0); + AddWaypoint(21, 2381.04, 519.612, 37.7312, 0); + AddWaypoint(22, 2412.20, 515.425, 39.2068, 0); + AddWaypoint(23, 2452.39, 516.174, 42.9387, 0); + AddWaypoint(24, 2467.38, 539.389, 47.4992, 0); + AddWaypoint(25, 2470.70, 554.333, 46.6668, 0); + AddWaypoint(26, 2478.07, 575.321, 55.4549, 0); + AddWaypoint(27, 2480.00, 585.408, 56.6921, 0); + AddWaypoint(28, 2482.67, 608.817, 55.6643, 0); + AddWaypoint(29, 2485.62, 626.061, 58.0132, 2000); + AddWaypoint(30, 2486.91, 626.356, 58.0761, 2000); + AddWaypoint(31, 2486.91, 626.357, 58.0761, 0); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(true, false, player->GetGUID()); + break; + case 3: + AddWaypoint(0, 2488.58, 660.940, 57.3913, 0); + AddWaypoint(1, 2502.56, 686.059, 55.6252, 0); + AddWaypoint(2, 2502.08, 694.360, 55.5083, 0); + AddWaypoint(3, 2491.46, 694.321, 55.7163, 0); + AddWaypoint(4, 2491.10, 703.300, 55.7630, 0); + AddWaypoint(5, 2485.64, 702.992, 55.7917, 0); + AddWaypoint(6, 2479.63, 696.521, 55.7901, 0); + AddWaypoint(7, 2476.24, 696.204, 55.8093, 0); + AddWaypoint(8, 2475.39, 695.983, 55.8146, 0); + AddWaypoint(9, 2477.75, 694.473, 55.7945, 0); + AddWaypoint(10, 2481.27, 697.747, 55.7910, 0); + AddWaypoint(11, 2486.31, 703.131, 55.7861, 0); + AddWaypoint(12, 2490.76, 703.511, 55.7662, 0); + AddWaypoint(13, 2491.30, 694.792, 55.7195, 0); + AddWaypoint(14, 2502.08, 694.360, 55.5083, 0); + AddWaypoint(15, 2507.99, 679.298, 56.3760, 0); + AddWaypoint(16, 2524.79, 669.919, 54.9258, 0); + AddWaypoint(17, 2543.19, 665.289, 56.2957, 0); + AddWaypoint(18, 2566.49, 664.354, 54.5034, 0); + AddWaypoint(19, 2592.00, 664.611, 56.4394, 0); + AddWaypoint(20, 2616.14, 665.499, 55.1610, 0); + AddWaypoint(21, 2623.56, 666.965, 54.3983, 0); + AddWaypoint(22, 2629.99, 661.059, 54.2738, 0); + AddWaypoint(23, 2629.00, 656.982, 56.0651, 0); + AddWaypoint(24, 2620.84, 633.007, 56.0300, 3000); + AddWaypoint(25, 2621.62, 635.352, 56.0300, 0); + AddWaypoint(26, 2622.99, 639.178, 56.0300, 0); + AddWaypoint(27, 2628.73, 656.693, 56.0610, 0); + AddWaypoint(28, 2630.34, 661.135, 54.2738, 0); + AddWaypoint(29, 2635.38, 672.243, 54.4508, 0); + AddWaypoint(30, 2644.13, 668.158, 55.3797, 0); + AddWaypoint(31, 2646.82, 666.740, 56.9898, 0); + AddWaypoint(32, 2658.22, 665.432, 57.1725, 0); + AddWaypoint(33, 2661.88, 674.849, 57.1725, 0); + AddWaypoint(34, 2656.23, 677.208, 57.1725, 0); + AddWaypoint(35, 2652.28, 670.270, 61.9353, 0); + AddWaypoint(36, 2650.79, 664.290, 61.9302, 0); + AddWaypoint(37, 2660.48, 659.409, 61.9370, 5000); + AddWaypoint(38, 2660.48, 659.410, 61.9370, 0); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(true, true, player->GetGUID()); + break; + case 4: + AddWaypoint(0, 2660.48, 659.411, 61.9370, 5000); + AddWaypoint(1, 2660.48, 659.412, 61.9370, 2000); + AddWaypoint(2, 2652.32, 664.994, 61.9305, 0); + AddWaypoint(3, 2652.37, 670.561, 61.9368, 0); + AddWaypoint(4, 2656.05, 676.761, 57.1727, 0); + AddWaypoint(5, 2658.49, 677.166, 57.1727, 0); + AddWaypoint(6, 2659.28, 667.117, 57.1727, 0); + AddWaypoint(7, 2649.71, 665.387, 57.1727, 0); + AddWaypoint(8, 2634.79, 672.964, 54.4577, 0); + AddWaypoint(9, 2635.06, 673.892, 54.4713, 6000); + AddWaypoint(10, 2635.06, 673.893, 54.4713, 6000); + AddWaypoint(11, 2635.06, 673.890, 54.4713, 0); + AddWaypoint(12, 2634.30, 661.698, 54.4147, 0); + AddWaypoint(13, 2652.21, 644.396, 56.1906, 0); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(true, true, player->GetGUID()); + break; + } + return; + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if (StepsTimer <= diff) + { + if (Event) + StepsTimer = NextStep(++Steps); + } + else StepsTimer -= diff; + + if (HadMount && !me->isInCombat()) + DoMount(); + + if (EmoteTimer) + { + if (EmoteTimer <= diff) + { + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + EmoteTimer = 0; + } + else EmoteTimer -= diff; + } + + if (!UpdateVictim()) + return; + + if (StrikeTimer < diff) + { + DoCast(me->getVictim(), SPELL_STRIKE); + StrikeTimer = urand(4000, 7000); + } + else StrikeTimer -= diff; + + if (ShieldBlockTimer < diff) + { + DoCast(me, SPELL_SHIELD_BLOCK); + ShieldBlockTimer = urand(8000, 15000); + } + else ShieldBlockTimer -= diff; + + if (!LowHp && ((me->GetHealth()*100 / me->GetMaxHealth()) < 20)) + { + DoScriptText(RAND(SAY_TH_RANDOM_LOW_HP1, SAY_TH_RANDOM_LOW_HP2), me); + LowHp = true; + } + } +}; + +CreatureAI* GetAI_npc_thrall_old_hillsbrad(Creature* creature) +{ + return new npc_thrall_old_hillsbradAI(creature); +} + +bool GossipHello_npc_thrall_old_hillsbrad(Player *player, Creature *creature) +{ + if (creature->isQuestGiver()) + { + player->PrepareQuestMenu( creature->GetGUID() ); + player->SendPreparedQuest(creature->GetGUID()); + } + + ScriptedInstance* pInstance = (creature->GetInstanceData()); + if (pInstance) + { + if (pInstance->GetData(DATA_DRAKE_DEATH) == DONE && pInstance->GetData(TYPE_THRALL_PART1) == NOT_STARTED) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_START, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(GOSSIP_ID_START, creature->GetGUID()); + } + + if (pInstance->GetData(TYPE_THRALL_PART1) == DONE && pInstance->GetData(TYPE_THRALL_PART2) == NOT_STARTED) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_SKARLOC1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC1, creature->GetGUID()); + } + + if (pInstance->GetData(TYPE_THRALL_PART2) == DONE && pInstance->GetData(TYPE_THRALL_PART3) == NOT_STARTED) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TARREN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(GOSSIP_ID_TARREN, creature->GetGUID()); + } + + if (pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) + { + player->SEND_GOSSIP_MENU(GOOSIP_ID_TARETHA, creature->GetGUID()); + } + } + + return true; +} + +bool GossipSelect_npc_thrall_old_hillsbrad(Player *player, Creature *creature, uint32 sender, uint32 action) +{ + ScriptedInstance* pInstance = (creature->GetInstanceData()); + uint8 Parts = 0; + + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->CLOSE_GOSSIP_MENU(); + if (pInstance) + { + pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS); + pInstance->SetData(TYPE_THRALL_PART1, IN_PROGRESS); + } + + DoScriptText(SAY_TH_START_EVENT_PART1, creature); + Parts = 1; + CAST_AI(npc_thrall_old_hillsbradAI, creature->AI())->StartEscort(player, Parts); + break; + + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC2, creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+20: + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_SKARLOC3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+22); + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC3, creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+22: + player->CLOSE_GOSSIP_MENU(); + if (pInstance) + { + pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS); + pInstance->SetData(TYPE_THRALL_PART2,IN_PROGRESS); + } + + DoScriptText(SAY_TH_START_EVENT_PART2, creature); + Parts = 2; + CAST_AI(npc_thrall_old_hillsbradAI, creature->AI())->StartEscort(player, Parts); + break; + + case GOSSIP_ACTION_INFO_DEF+3: + player->CLOSE_GOSSIP_MENU(); + if (pInstance) + { + pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS); + pInstance->SetData(TYPE_THRALL_PART3,IN_PROGRESS); + } + Parts = 3; + CAST_AI(npc_thrall_old_hillsbradAI, creature->AI())->StartEscort(player, Parts); + break; + } + return true; +} + +/*###### +## npc_taretha +######*/ + +#define GOSSIP_ID_EPOCH1 9610 //Thank you for helping Thrall escape, friends. Now I only hope +#define GOSSIP_ITEM_EPOCH1 "Strange wizard?" +#define GOSSIP_ID_EPOCH2 9613 //Yes, friends. This man was no wizard of +#define GOSSIP_ITEM_EPOCH2 "We'll get you out. Taretha. Don't worry. I doubt the wizard would wander too far away." + +struct npc_tarethaAI : public npc_escortAI +{ + npc_tarethaAI(Creature *creature) : npc_escortAI(creature) + { + pInstance = (creature->GetInstanceData()); + } + + ScriptedInstance *pInstance; + + void WaypointReached(uint32 i) + { + switch (i) + { + case 0: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->RemoveAllAuras(); + break; + case 6: + DoScriptText(SAY_TA_FREE, me); + break; + case 7: + me->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); + break; + } + } + + void Reset() + { + DoCast(me, SPELL_SHADOW_PRISON, true); + } + + void EnterCombat(Unit* who) {} + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if (spell->Id == SPELL_MEMORY_WP_RESUME) + me->RemoveAllAuras(); + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + } +}; + +CreatureAI* GetAI_npc_taretha(Creature* creature) +{ + return new npc_tarethaAI(creature); +} + +bool GossipHello_npc_taretha(Player *player, Creature *creature) +{ + ScriptedInstance* pInstance = (creature->GetInstanceData()); + if (pInstance && pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_EPOCH1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH1, creature->GetGUID()); + } + + return true; +} + +bool GossipSelect_npc_taretha(Player *player, Creature *creature, uint32 sender, uint32 action) +{ + ScriptedInstance* pInstance = (creature->GetInstanceData()); + uint8 Parts = 4; + + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_EPOCH2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH2, creature->GetGUID()); + } + + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + + if (pInstance) + { + pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS); + pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS); + } + + Map* tmpMap = creature->GetMap(); + + if (!tmpMap) + return true; + + if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL))) + { + if(Thrall) + CAST_AI(npc_thrall_old_hillsbradAI, Thrall->AI())->StartEscort(player, Parts); + } + } + + return true; +} + +struct erozion_imageAI : public ScriptedAI +{ + erozion_imageAI(Creature *creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + } + + ScriptedInstance *pInstance; + + bool Intro; + + uint8 Next; + uint32 StepsTimer; + uint32 Steps; + + void Reset() + { + me->CastSpell(me, SPELL_TELEPORT, false); + Intro = true; + Steps = 0; + StepsTimer = 0; + } + + int32 NextStep(uint32 Steps) + { + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return true; + + if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL))) + { + switch (Steps) + { + case 1: + me->SetFacingToObject(Thrall); + return 2000; + case 2: + DoScriptText(SAY_IMAGE_1, me); + return 15000; + case 3: + if (pInstance) + { + if (pInstance->GetData(TYPE_THRALL_PART1) == NOT_STARTED) + me->SummonCreature(NPC_THRALL, 2231.51f, 119.84f, 82.297f, 4.15f,TEMPSUMMON_DEAD_DESPAWN,15000); + + if (pInstance->GetData(TYPE_THRALL_PART1) == DONE && pInstance->GetData(TYPE_THRALL_PART2) == NOT_STARTED) + { + me->SummonCreature(NPC_THRALL, 2063.40f, 229.512f, 64.488f, 2.18f,TEMPSUMMON_DEAD_DESPAWN,15000); + me->SummonCreature(NPC_SKARLOC_MOUNT,2047.90f, 254.85f, 62.822f, 5.94f, TEMPSUMMON_DEAD_DESPAWN, 15000); + } + + if (pInstance->GetData(TYPE_THRALL_PART2) == DONE && pInstance->GetData(TYPE_THRALL_PART3) == NOT_STARTED) + me->SummonCreature(NPC_THRALL, 2486.91f, 626.357f, 58.076f, 4.66f,TEMPSUMMON_DEAD_DESPAWN,15000); + + if (pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) + { + me->SummonCreature(NPC_THRALL, 2660.48f, 659.409f, 61.937f, 5.83f,TEMPSUMMON_DEAD_DESPAWN,15000); + if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) + { + if (Unit *Taretha = me->GetUnit(TarethaGUID)) + Taretha->SetStandState(UNIT_STAND_STATE_STAND); + } + } + } + return 5000; + case 4: + DoScriptText(SAY_IMAGE_2, me); + return 15000; + case 5: + me->CastSpell(me, SPELL_TELEPORT, false); + me->ForcedDespawn(1500); + default: + return 0; + } + } + return true; + } + + void UpdateAI(const uint32 diff) + { + if (StepsTimer <= diff) + { + if (Intro) + StepsTimer = NextStep(++Steps); + } + else StepsTimer -= diff; + } +}; + +CreatureAI* GetAI_erozion_image(Creature *creature) +{ + return new erozion_imageAI (creature); +} + +/*###### +## AddSC +######*/ + +void AddSC_old_hillsbrad() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_brazen"; + newscript->pGossipHello = &GossipHello_npc_brazen; + newscript->pGossipSelect = &GossipSelect_npc_brazen; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_erozion"; + newscript->pGossipHello = &GossipHello_npc_erozion; + newscript->pGossipSelect = &GossipSelect_npc_erozion; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_thrall_old_hillsbrad"; + newscript->pGossipHello = &GossipHello_npc_thrall_old_hillsbrad; + newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad; + newscript->GetAI = &GetAI_npc_thrall_old_hillsbrad; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_taretha"; + newscript->pGossipHello = &GossipHello_npc_taretha; + newscript->pGossipSelect = &GossipSelect_npc_taretha; + newscript->GetAI = &GetAI_npc_taretha; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="erozion_image"; + newscript->GetAI = &GetAI_erozion_image; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/darkshore/darkshore.cpp b/src/scripts/scripts/Kalimdor/darkshore/darkshore.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/darkshore/darkshore.cpp rename to src/scripts/scripts/Kalimdor/darkshore/darkshore.cpp index 5db085afc..14174d441 --- a/src/scripts/scripts/zone/darkshore/darkshore.cpp +++ b/src/scripts/scripts/Kalimdor/darkshore/darkshore.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Darkshore @@ -163,7 +166,7 @@ bool QuestAccept_npc_prospector_remtravel(Player* player, Creature* creature, Qu creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); DoScriptText(SAY_prospector_ACC, creature, player); - ((npc_escortAI*)creature->AI())->Start(true, true, player->GetGUID(), quest); + ((npc_escortAI*)creature->AI())->Start(true, false, player->GetGUID(), quest); } return true; } diff --git a/src/scripts/scripts/zone/desolace/desolace.cpp b/src/scripts/scripts/Kalimdor/desolace/desolace.cpp similarity index 94% rename from src/scripts/scripts/zone/desolace/desolace.cpp rename to src/scripts/scripts/Kalimdor/desolace/desolace.cpp index 4c0fc64be..6b931602b 100644 --- a/src/scripts/scripts/zone/desolace/desolace.cpp +++ b/src/scripts/scripts/Kalimdor/desolace/desolace.cpp @@ -1,8 +1,19 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -147,7 +158,7 @@ bool GossipHello_npc_aged_dying_ancient_kodo(Player* pPlayer, Creature* pCreatur if (pPlayer->HasAura(SPELL_KODO_KOMBO_PLAYER_BUFF, 0) && pCreature->HasAura(SPELL_KODO_KOMBO_DESPAWN_BUFF, 0)) { //the expected quest objective - pPlayer->CastedCreatureOrGO(pCreature->GetEntry(), pCreature->GetGUID(), SPELL_KODO_KOMBO_GOSSIP); + pPlayer->CastCreatureOrGO(pCreature->GetEntry(), pCreature->GetGUID(), SPELL_KODO_KOMBO_GOSSIP); pPlayer->RemoveAurasDueToSpell(SPELL_KODO_KOMBO_PLAYER_BUFF); pCreature->GetMotionMaster()->MoveIdle(); @@ -165,7 +176,7 @@ bool GOUse_go_iruxos(Player *pPlayer, GameObject* pGO) { if (pPlayer->GetQuestStatus(5381) == QUEST_STATUS_INCOMPLETE) { - Creature* Demon = pPlayer->SummonCreature(11876, pPlayer->GetPositionX()+frand(-2,2),pPlayer->GetPositionY()+frand(-2,2),pPlayer->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + Creature* Demon = pPlayer->SummonCreature(11876, pPlayer->GetPositionX()+frand(-2,2),pPlayer->GetPositionY()+frand(-2,2),pPlayer->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); if(Demon) { Demon->AI()->AttackStart(pPlayer); diff --git a/src/scripts/scripts/Kalimdor/dire_maul/dire_maul.cpp b/src/scripts/scripts/Kalimdor/dire_maul/dire_maul.cpp new file mode 100644 index 000000000..4485a1861 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/dire_maul/dire_maul.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Dire_Maul +SD%Complete: ? +SDComment: Quest support: 7481, 7482 +SDCategory: Dire_Maul +EndScriptData */ + +/* ContentData +go_kariel_remains +EndContentData */ + +#include "precompiled.h" + +#define QUEST_ELVEN_LEGENDS_HORDE 7481 +#define QUEST_ELVEN_LEGENDS_ALLY 7482 +bool GOUse_go_kariel_remains(Player *player, GameObject* _GO) +{ + player->AreaExploredOrEventHappens(QUEST_ELVEN_LEGENDS_ALLY); + player->AreaExploredOrEventHappens(QUEST_ELVEN_LEGENDS_HORDE); + return true; +} + +void AddSC_dire_maul() +{ + Script* newscript; + + newscript = new Script; + newscript->Name="go_kariel_remains"; + newscript->pGOUse = &GOUse_go_kariel_remains; + newscript->RegisterSelf(); +} \ No newline at end of file diff --git a/src/scripts/scripts/zone/durotar/durotar.cpp b/src/scripts/scripts/Kalimdor/durotar/durotar.cpp similarity index 81% rename from src/scripts/scripts/zone/durotar/durotar.cpp rename to src/scripts/scripts/Kalimdor/durotar/durotar.cpp index d9197a10e..1456d41d6 100644 --- a/src/scripts/scripts/zone/durotar/durotar.cpp +++ b/src/scripts/scripts/Kalimdor/durotar/durotar.cpp @@ -1,18 +1,20 @@ /* * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp b/src/scripts/scripts/Kalimdor/dustwallow_marsh/dustwallow_marsh.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp rename to src/scripts/scripts/Kalimdor/dustwallow_marsh/dustwallow_marsh.cpp index 1bb57cb93..979e8ac22 --- a/src/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp +++ b/src/scripts/scripts/Kalimdor/dustwallow_marsh/dustwallow_marsh.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -268,10 +271,6 @@ struct npc_theramore_combat_dummyAI : public Scripted_NoMovementAI { npc_theramore_combat_dummyAI(Creature *c) : Scripted_NoMovementAI(c) { - // niech ktoœ to przepisze na zapytanie plx - CreatureInfo *cInfo = (CreatureInfo *)m_creature->GetCreatureInfo(); - if (cInfo) - cInfo->flags_extra |= CREATURE_FLAG_EXTRA_NO_DAMAGE_TAKEN; } uint64 AttackerGUID; diff --git a/src/scripts/scripts/zone/felwood/felwood.cpp b/src/scripts/scripts/Kalimdor/felwood/felwood.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/felwood/felwood.cpp rename to src/scripts/scripts/Kalimdor/felwood/felwood.cpp index b7a4bc03c..06f4bdcc7 --- a/src/scripts/scripts/zone/felwood/felwood.cpp +++ b/src/scripts/scripts/Kalimdor/felwood/felwood.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Kalimdor/feralas/feralas.cpp b/src/scripts/scripts/Kalimdor/feralas/feralas.cpp new file mode 100644 index 000000000..f6e3099a7 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/feralas/feralas.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Feralas +SD%Complete: 100 +SDComment: Quest support: 3520, 2767. Special vendor Gregan Brewspewer +SDCategory: Feralas +EndScriptData */ + +#include "precompiled.h" +#include "escort_ai.h" + +/*###### +## npc_gregan_brewspewer +######*/ + +#define GOSSIP_HELLO "Buy somethin', will ya?" + +bool GossipHello_npc_gregan_brewspewer(Player* player, Creature* creature) +{ + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + + if (creature->isVendor() && player->GetQuestStatus(3909) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(2433, creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_gregan_brewspewer(Player* player, Creature* creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(2434, creature->GetGUID()); + } + if (action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST(creature->GetGUID()); + return true; +} + +/*###### +## npc_screecher_spirit +######*/ + +bool GossipHello_npc_screecher_spirit(Player* player, Creature* creature) +{ + player->SEND_GOSSIP_MENU(2039, creature->GetGUID()); + player->TalkedToCreature(creature->GetEntry(), creature->GetGUID()); + creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + return true; +} + +/*###### +## npc_oox22fe +######*/ + +enum oox22fe +{ + SAY_OOX_START = -1060000, + SAY_OOX_AGGRO1 = -1060001, + SAY_OOX_AGGRO2 = -1060002, + SAY_OOX_AMBUSH = -1060003, + SAY_OOX_END = -1060005, + + NPC_YETI = 7848, + NPC_GORILLA = 5260, + NPC_WOODPAW_REAVER = 5255, + NPC_WOODPAW_BRUTE = 5253, + NPC_WOODPAW_ALPHA = 5258, + NPC_WOODPAW_MYSTIC = 5254, + + QUEST_RESCUE_OOX22FE = 2767 +}; + +struct npc_oox22feAI : public npc_escortAI +{ + npc_oox22feAI(Creature* creature) : npc_escortAI(creature) {} + + void Reset() {} + + void EnterCombat(Unit* who) + { + switch (urand(0, 9)) + { + case 0: + DoScriptText(SAY_OOX_AGGRO1, me); + break; + case 1: + DoScriptText(SAY_OOX_AGGRO2, me); + break; + } + } + + void JustSummoned(Creature* summoned) + { + summoned->AI()->AttackStart(me); + } + + void WaypointReached(uint32 i) + { + switch (i) + { + case 11: + DoScriptText(SAY_OOX_AMBUSH, me); + break; + case 12: + me->SummonCreature(NPC_YETI, -4850.91f, 1595.67f, 72.99f, 2.85f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_YETI, -4851.76f, 1599.37f, 73.85f, 2.85f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_YETI, -4852.81f, 1592.63f, 72.28f, 2.85f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 23: + DoScriptText(SAY_OOX_AMBUSH, me); + break; + case 24: + me->SummonCreature(NPC_GORILLA, -4609.56f, 1991.80f, 57.24f, 3.74f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_GORILLA, -4613.00f, 1994.45f, 57.2f, 3.78f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_GORILLA, -4619.37f, 1998.11f, 57.72f, 3.84f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 31: + DoScriptText(SAY_OOX_AMBUSH, me); + break; + case 32: + me->SummonCreature(NPC_WOODPAW_REAVER, -4425.14f, 2075.87f, 47.77f, 3.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_WOODPAW_BRUTE , -4426.68f, 2077.98f, 47.57f, 3.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_WOODPAW_MYSTIC, -4428.33f, 2080.24f, 47.43f, 3.87f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + me->SummonCreature(NPC_WOODPAW_ALPHA , -4430.04f, 2075.54f, 46.83f, 3.81f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 40: + DoScriptText(SAY_OOX_END, me); + if (Player* player = GetPlayerForEscort()) + player->GroupEventHappens(QUEST_RESCUE_OOX22FE, me); + break; + } + } +}; + +CreatureAI* GetAI_npc_oox22fe(Creature* creature) +{ + return new npc_oox22feAI(creature); +} + +bool QuestAccept_npc_oox22fe(Player* player, Creature* creature, const Quest* quest) +{ + if (quest->GetQuestId() == QUEST_RESCUE_OOX22FE) + { + creature->SetStandState(UNIT_STAND_STATE_STAND); + DoScriptText(SAY_OOX_START, creature); + + if (npc_escortAI* EscortAI = CAST_AI(npc_oox22feAI, creature->AI())) + EscortAI->Start(true, true, player->GetGUID()); + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_feralas() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_gregan_brewspewer"; + newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer; + newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_screecher_spirit"; + newscript->pGossipHello = &GossipHello_npc_screecher_spirit; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_oox22fe"; + newscript->GetAI = &GetAI_npc_oox22fe; + newscript->pQuestAcceptNPC = &QuestAccept_npc_oox22fe; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp b/src/scripts/scripts/Kalimdor/maraudon/boss_celebras_the_cursed.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp rename to src/scripts/scripts/Kalimdor/maraudon/boss_celebras_the_cursed.cpp index d45a1197f..3fccf3292 --- a/src/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp +++ b/src/scripts/scripts/Kalimdor/maraudon/boss_celebras_the_cursed.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/maraudon/boss_landslide.cpp b/src/scripts/scripts/Kalimdor/maraudon/boss_landslide.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/maraudon/boss_landslide.cpp rename to src/scripts/scripts/Kalimdor/maraudon/boss_landslide.cpp index 56c4f6f9a..62fcae2a8 --- a/src/scripts/scripts/zone/maraudon/boss_landslide.cpp +++ b/src/scripts/scripts/Kalimdor/maraudon/boss_landslide.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/maraudon/boss_noxxion.cpp b/src/scripts/scripts/Kalimdor/maraudon/boss_noxxion.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/maraudon/boss_noxxion.cpp rename to src/scripts/scripts/Kalimdor/maraudon/boss_noxxion.cpp index 3d9f7226c..4368792f9 --- a/src/scripts/scripts/zone/maraudon/boss_noxxion.cpp +++ b/src/scripts/scripts/Kalimdor/maraudon/boss_noxxion.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp b/src/scripts/scripts/Kalimdor/maraudon/boss_princess_theradras.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp rename to src/scripts/scripts/Kalimdor/maraudon/boss_princess_theradras.cpp index 5f318aca2..683147fa5 --- a/src/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp +++ b/src/scripts/scripts/Kalimdor/maraudon/boss_princess_theradras.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Kalimdor/moonglade/moonglade.cpp b/src/scripts/scripts/Kalimdor/moonglade/moonglade.cpp new file mode 100644 index 000000000..125bd1026 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/moonglade/moonglade.cpp @@ -0,0 +1,1490 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Moonglade +SD%Complete: 100 +SDComment: Quest support: 30, 272, 5929, 5930, 10965. Special Flight Paths for Druid class, 8736. +SDCategory: Moonglade +EndScriptData */ + +/* ContentData +npc_bunthen_plainswind +npc_great_bear_spirit +npc_silva_filnaveth +npc_clintar_spirit +npc_clintar_dreamwalker +EndContentData */ + +#include "precompiled.h" +#include "escort_ai.h" + +/*###### +## npc_bunthen_plainswind +######*/ + +#define GOSSIP_BP1 "Do you know where I can find Half Pendant of Aquatic Endurance?" +#define GOSSIP_BP2 "I'd like to fly to Thunder Bluff." + +bool GossipHello_npc_bunthen_plainswind(Player *player, Creature *_Creature) +{ + if(player->getClass() != CLASS_DRUID) + player->SEND_GOSSIP_MENU(4916,_Creature->GetGUID()); + else if(player->GetTeam() != HORDE) + { + if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(4917,_Creature->GetGUID()); + } + else if(player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + player->SEND_GOSSIP_MENU(4918,_Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_bunthen_plainswind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + { + player->CLOSE_GOSSIP_MENU(); + if (player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) + { + std::vector nodes; + + nodes.resize(2); + nodes[0] = 63; // Nighthaven, Moonglade + nodes[1] = 22; // Thunder Bluff, Mulgore + player->ActivateTaxiPathTo(nodes); + } + break; + } + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_GOSSIP_MENU(5373,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(5376,_Creature->GetGUID()); + break; + } + return true; +} + +/*###### +## npc_great_bear_spirit +######*/ + +#define GOSSIP_BEAR1 "What do you represent, spirit?" +#define GOSSIP_BEAR2 "I seek to understand the importance of strength of the body." +#define GOSSIP_BEAR3 "I seek to understand the importance of strength of the heart." +#define GOSSIP_BEAR4 "I have heard your words, Great Bear Spirit, and I understand. I now seek your blessings to fully learn the way of the Claw." + +bool GossipHello_npc_great_bear_spirit(Player *player, Creature *_Creature) +{ + //ally or horde quest + if (player->GetQuestStatus(5929) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5930) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(4719, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(4718, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_great_bear_spirit(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(4721, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(4733, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(4734, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(4735, _Creature->GetGUID()); + if (player->GetQuestStatus(5929)==QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(5929); + if (player->GetQuestStatus(5930)==QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(5930); + break; + } + return true; +} + +/*###### +## npc_silva_filnaveth +######*/ + +#define GOSSIP_SF1 "Do you know where I can find Half Pendant of Aquatic Agility?" +#define GOSSIP_SF2 "I'd like to fly to Rut'theran Village." +bool GossipHello_npc_silva_filnaveth(Player *player, Creature *_Creature) +{ + if(player->getClass() != CLASS_DRUID) + player->SEND_GOSSIP_MENU(4913,_Creature->GetGUID()); + else if(player->GetTeam() != ALLIANCE) + { + if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(4915,_Creature->GetGUID()); + } + else if(player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + player->SEND_GOSSIP_MENU(4914,_Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_silva_filnaveth(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + { + player->CLOSE_GOSSIP_MENU(); + if (player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) + { + std::vector nodes; + + nodes.resize(2); + nodes[0] = 62; // Nighthaven, Moonglade + nodes[1] = 27; // Rut'theran Village, Teldrassil + player->ActivateTaxiPathTo(nodes); + } + break; + } + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_GOSSIP_MENU(5374,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(5375,_Creature->GetGUID()); + break; + } + return true; +} + +/*###### +## npc_clintar_spirit +######*/ + +float Clintar_spirit_WP[41][5] = +{ + //pos_x pos_y pos_z orien waitTime +{7465.28, -3115.46, 439.327, 0.83, 4000}, +{7476.49, -3101, 443.457, 0.89, 0}, +{7486.57, -3085.59, 439.478, 1.07, 0}, +{7472.19, -3085.06, 443.142, 3.07, 0}, +{7456.92, -3085.91, 438.862, 3.24, 0}, +{7446.68, -3083.43, 438.245, 2.40, 0}, +{7446.17, -3080.21, 439.826, 1.10, 6000}, +{7452.41, -3085.8, 438.984, 5.78, 0}, +{7469.11, -3084.94, 443.048, 6.25, 0}, +{7483.79, -3085.44, 439.607, 6.25, 0}, +{7491.14, -3090.96, 439.983, 5.44, 0}, +{7497.62, -3098.22, 436.854, 5.44, 0}, +{7498.72, -3113.41, 434.596, 4.84, 0}, +{7500.06, -3122.51, 434.749, 5.17, 0}, +{7504.96, -3131.53, 434.475, 4.74, 0}, +{7504.31, -3133.53, 435.693, 3.84, 6000}, +{7504.55, -3133.27, 435.476, 0.68, 15000}, +{7501.99, -3126.01, 434.93, 1.83, 0}, +{7490.76, -3114.97, 434.431, 2.51, 0}, +{7479.64, -3105.51, 431.123, 1.83, 0}, +{7474.63, -3086.59, 428.994, 1.83, 2000}, +{7472.96, -3074.18, 427.566, 1.57, 0}, +{7472.25, -3063, 428.268, 1.55, 0}, +{7473.46, -3054.22, 427.588, 0.36, 0}, +{7475.08, -3053.6, 428.653, 0.36, 6000}, +{7474.66, -3053.56, 428.433, 3.19, 4000}, +{7471.81, -3058.84, 427.073, 4.29, 0}, +{7472.16, -3064.91, 427.772, 4.95, 0}, +{7471.56, -3085.36, 428.924, 4.72, 0}, +{7473.56, -3093.48, 429.294, 5.04, 0}, +{7478.94, -3104.29, 430.638, 5.23, 0}, +{7484.46, -3109.61, 432.769, 5.79, 0}, +{7490.23, -3111.08, 434.431, 0.02, 0}, +{7496.29, -3108, 434.783, 1.15, 0}, +{7497.46, -3100.66, 436.191, 1.50, 0}, +{7495.64, -3093.39, 438.349, 2.10, 0}, +{7492.44, -3086.01, 440.267, 1.38, 0}, +{7498.26, -3076.44, 440.808, 0.71, 0}, +{7506.4, -3067.35, 443.64, 0.77, 0}, +{7518.37, -3057.42, 445.584, 0.74, 0}, +{7517.51, -3056.3, 444.568, 2.49, 4500} +}; + +#define ASPECT_RAVEN 22915 + +#define ASPECT_RAVEN_SUMMON_X 7472.96 +#define ASPECT_RAVEN_SUMMON_Y -3074.18 +#define ASPECT_RAVEN_SUMMON_Z 427.566 +#define CLINTAR_SPIRIT_SUMMON_X 7459.2275 +#define CLINTAR_SPIRIT_SUMMON_Y -3122.5632 +#define CLINTAR_SPIRIT_SUMMON_Z 438.9842 +#define CLINTAR_SPIRIT_SUMMON_O 0.8594 + +#define CLINTAR_SPIRIT_SAY_START -1000286 +#define CLINTAR_SPIRIT_SAY_UNDER_ATTACK_1 -1000287 +#define CLINTAR_SPIRIT_SAY_UNDER_ATTACK_2 -1000288 +#define CLINTAR_SPIRIT_SAY_GET_ONE -1000289 +#define CLINTAR_SPIRIT_SAY_GET_TWO -1000290 +#define CLINTAR_SPIRIT_SAY_GET_THREE -1000291 +#define CLINTAR_SPIRIT_SAY_GET_FINAL -1000292 + +struct npc_clintar_spiritAI : public npc_escortAI +{ +public: + npc_clintar_spiritAI(Creature *c) : npc_escortAI(c) {} + + uint32 Step; + uint32 CurrWP; + uint32 Event_Timer; + uint32 checkPlayer_Timer; + + uint64 PlayerGUID; + + bool Event_onWait; + + void Reset() + { + if(!PlayerGUID) + { + Step = 0; + CurrWP = 0; + Event_Timer = 0; + PlayerGUID = 0; + checkPlayer_Timer = 1000; + Event_onWait = false; + } + } + + void JustDied(Unit *killer) + { + if(!PlayerGUID) + return; + + Player* pPlayer = Unit::GetPlayer(PlayerGUID); + if (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE) + { + pPlayer->FailQuest(10965); + PlayerGUID = 0; + Reset(); + } + } + + void EnterEvadeMode() + { + Player* pPlayer = Unit::GetPlayer(PlayerGUID); + if (pPlayer && pPlayer->isInCombat() && pPlayer->getAttackerForHelper()) + { + AttackStart(pPlayer->getAttackerForHelper()); + return; + } + npc_escortAI::EnterEvadeMode(); + } + + void EnterCombat(Unit* who) + { + uint32 rnd = rand()%2; + switch(rnd) + { + case 0: DoScriptText(CLINTAR_SPIRIT_SAY_UNDER_ATTACK_1, m_creature, who); break; + case 1: DoScriptText(CLINTAR_SPIRIT_SAY_UNDER_ATTACK_2, m_creature, who); break; + } + } + + void StartEvent(Player* pPlayer) + { + if(!pPlayer) + return; + + if(pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE) + { + for(uint8 i = 0; i < 41; ++i) + { + AddWaypoint(i, Clintar_spirit_WP[i][0], Clintar_spirit_WP[i][1], Clintar_spirit_WP[i][2], (uint32)Clintar_spirit_WP[i][4]); + } + PlayerGUID = pPlayer->GetGUID(); + Start(true,false,PlayerGUID); + } + return; + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if(!PlayerGUID) + { + m_creature->setDeathState(JUST_DIED); + return; + } + + if (!m_creature->isInCombat() && !Event_onWait) + { + if (checkPlayer_Timer < diff) + { + Player* pPlayer = Unit::GetPlayer(PlayerGUID); + if (pPlayer && pPlayer->isInCombat() && pPlayer->getAttackerForHelper()) + AttackStart(pPlayer->getAttackerForHelper()); + + checkPlayer_Timer = 1000; + } + else + checkPlayer_Timer -= diff; + } + + if(Event_onWait && Event_Timer < diff) + { + Player* pPlayer = Unit::GetPlayer(PlayerGUID); + if (!pPlayer || (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_NONE)) + { + m_creature->setDeathState(JUST_DIED); + return; + } + + switch(CurrWP) + { + case 0: + switch(Step) + { + case 0: + m_creature->Say(CLINTAR_SPIRIT_SAY_START,0,PlayerGUID); + Event_Timer = 8000; + Step = 1; + break; + case 1: + Event_onWait = false; + break; + } + break; + case 6: + switch(Step) + { + case 0: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); + Event_Timer = 5000; + Step = 1; + break; + case 1: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + DoScriptText(CLINTAR_SPIRIT_SAY_GET_ONE, m_creature, pPlayer); + Event_onWait = false; + break; + } + break; + case 15: + switch(Step) + { + case 0: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); + Event_Timer = 5000; + Step = 1; + break; + case 1: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + Event_onWait = false; + break; + } + break; + case 16: + switch(Step) + { + case 0: + DoScriptText(CLINTAR_SPIRIT_SAY_GET_TWO, m_creature, pPlayer); + Event_Timer = 15000; + Step = 1; + break; + case 1: + Event_onWait = false; + break; + } + break; + case 20: + switch(Step) + { + case 0: + { + Creature *mob = m_creature->SummonCreature(ASPECT_RAVEN, ASPECT_RAVEN_SUMMON_X, ASPECT_RAVEN_SUMMON_Y, ASPECT_RAVEN_SUMMON_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000); + if(mob) + { + mob->AddThreat(m_creature,10000.0f); + mob->AI()->AttackStart(m_creature); + } + Event_Timer = 2000; + Step = 1; + break; + } + case 1: + Event_onWait = false; + break; + } + break; + case 24: + switch(Step) + { + case 0: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); + Event_Timer = 5000; + Step = 1; + break; + case 1: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + Event_onWait = false; + break; + } + break; + case 25: + switch(Step) + { + case 0: + DoScriptText(CLINTAR_SPIRIT_SAY_GET_THREE, m_creature, pPlayer); + Event_Timer = 4000; + Step = 1; + break; + case 1: + Event_onWait = false; + break; + } + break; + case 40: + switch(Step) + { + case 0: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 2); + DoScriptText(CLINTAR_SPIRIT_SAY_GET_FINAL, m_creature, pPlayer); + pPlayer->CompleteQuest(10965); + Event_Timer = 1500; + Step = 1; + break; + case 1: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + Event_Timer = 3000; + Step = 2; + break; + case 2: + pPlayer->TalkedToCreature(m_creature->GetEntry(), m_creature->GetGUID()); + PlayerGUID = 0; + Reset(); + m_creature->setDeathState(JUST_DIED); + break; + } + break; + default: + Event_onWait = false; + break; + } + + } else if(Event_onWait) Event_Timer -= diff; + } + + void WaypointReached(uint32 id) + { + CurrWP = id; + Event_Timer = 0; + Step = 0; + Event_onWait = true; + } +}; + +CreatureAI* GetAI_npc_clintar_spirit(Creature *_Creature) +{ + return new npc_clintar_spiritAI (_Creature); +} + +/*#### +# npc_clintar_dreamwalker +####*/ + +#define CLINTAR_SPIRIT 22916 + +bool QuestAccept_npc_clintar_dreamwalker(Player *player, Creature *creature, Quest const *quest ) +{ + if(quest->GetQuestId() == 10965) + { + Creature *clintar_spirit = creature->SummonCreature(CLINTAR_SPIRIT, CLINTAR_SPIRIT_SUMMON_X, CLINTAR_SPIRIT_SUMMON_Y, CLINTAR_SPIRIT_SUMMON_Z, CLINTAR_SPIRIT_SUMMON_O, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 100000); + if(clintar_spirit) + ((npc_clintar_spiritAI*)clintar_spirit->AI())->StartEvent(player); + } + return true; +} + +/* +## Quest: The Nightmare Manifests +## When we created this script. We tried to make it as much as possible blizzlike. +## But at the same time, we had some things replaced, for example, the coordinates +## of the Nightmares. The coordinates of the Nightmares had to do more clustered, because +## the current system scripting and muvemaps not allow to place Nightmares blizzlike. + ####*/ + +enum TheNightmareManifests +{ + REMULOS_SAY_1 = -1000672, + REMULOS_SAY_2 = -1000673, + REMULOS_SAY_3 = -1000674, + REMULOS_SAY_4 = -1000675, + REMULOS_SAY_5 = -1000676, + ERANIKUS_ZONE_EMOTE_ENTER = -1000677, + ERANIKUS_YELL_1 = -1000678, + REMULOS_YELL_1 = -1000679, + ERANIKUS_EMOTE_LAUGHT = -1000680, + ERANIKUS_YELL_2 = -1000681, + REMULOS_YELL_2 = -1000682, + ERANIKUS_YELL_3 = -1000683, + ERANIKUS_EMOTE_ROAR = -1000684, + REMULOS_SAY_6 = -1000685, + REMULOS_SAY_7 = -1000686, + ERANIKUS_YELL_4 = -1000687, + REMULOS_SAY_8 = -1000688, + ERANIKUS_YELL_5 = -1000689, + ERANIKUS_YELL_6 = -1000690, + ERANIKUS_YELL_7 = -1000691, + TYRANDE_YELL_1 = -1000692, + TYRANDE_SAY_1 = -1000693, + TYRANDE_YELL_2 = -1000694, + TYRANDE_YELL_3 = -1000695, + TYRANDE_SAY_2 = -1000696, + ERANIKUS_YELL_8 = -1000697, + ERANIKUS_YELL_9 = -1000698, + ERANIKUS_YELL_10 = -1000699, + ERANIKUS_ZONE_EMOTE_CONSUMED = -1000700, + TYRANDE_EMOTE_KNEE = -1000701, + TYRANDE_YELL_4 = -1000702, + ERANIKUS_SAY_1 = -1000703, + ERANIKUS_SAY_2 = -1000704, + ERANIKUS_SAY_3 = -1000705, + ERANIKUS_SAY_4 = -1000706, + REMULOS_SAY_9 = -1000707, + REMULOS_SAY_10 = -1000708, + + QUEST_NIGHTMARE_MANIFESTS = 8736, + + NPC_REMULOS = 11832, + NPC_ERANIKUS = 15491, + NPC_TYRANDE = 15633, + NPC_NIGHTMARE_PHANTASM = 15629, + NPC_MOONGLADE_WARDEN = 11822, + NPC_ERANIKUS_THE_REDEEMED = 15628, + NPC_PRIESTESS_OF_THE_MOON = 15634, + + NPC_NIGHTMARE_PHANTASMS_COUNT = 15, + NPC_MOONGLADE_WARDENS_COUNT = 10, + NPC_PRIESTESS_OF_THE_MOON_COUNT = 7, + + + SPELL_C0NJURE_DREAM_RIFT = 25813, + SPELL_STARFIRE = 21668, + SPELL_HEALING_TOUCH = 23381, + SPELL_REGROWTH = 20665, + SPELL_REJUVENATION = 20664, + SPELL_TRANQUILITY = 25817, + + SPELL_SPOTLIGHT = 35259, + ERANIKUS_SPELL_ACID_BREATH = 24839, + ERANIKUS_SPELL_NOXIUS_BREATH = 24818, + ERANIKUS_SPELL_SHADOW_BOLT_VOLLEY = 25586, + + POINT_COMBAT_START = 0xFFFFFF, + POINT_NIGHTRAVEN = 0xFFFFF0 +}; + +float PhantasmsSpawnpos[6][4] = +{ + {7865.17f, -2549.79f, 486.685f, 5.0f}, + {7889.45f, -2580.95f, 487.039f, 1.7f}, + {7916.65f, -2556.21f, 487.336f, 1.1f}, + {7926.25f, -2574.34f, 489.651f, 2.9f}, + {7855.32f, -2595.67f, 486.713f, 0.5f}, + {7890.27f, -2529.94f, 483.771f, 4.7f}, +}; + +struct Location +{ + float m_fX, m_fY, m_fZ, m_fO; +}; + +Location PristessHomePoint[] = +{ + {7883.12f, -2560.05f, 486.837f, 0.02f}, + {7882.61f, -2562.55f, 486.947f, 6.17f}, + {7882.21f, -2565.84f, 486.947f, 6.13f}, + {7882.12f, -2569.81f, 486.947f, 6.18f}, + {7878.62f, -2563.07f, 486.947f, 0.03f}, + {7878.14f, -2566.98f, 486.947f, 6.13f}, + {7880.23f, -2565.02f, 486.947f, 0.06f} +}; + +/*###### +## npc_remulos +######*/ + +struct npc_remulosAI : public npc_escortAI +{ + npc_remulosAI(Creature *c) : npc_escortAI(c) {} + + uint64 EranikusGUID; + uint32 uiPhase; + uint32 EventTimer; + uint32 FindVictimTimer; + uint32 StarfireTimer; + uint32 HealingTouchTimer; + uint32 RegrowthTimer; + uint32 RejuvenationTimer; + uint32 TranquilityTimer; + uint32 DeadPhantasmsCount; + bool PhantasmPhase; + bool EranikusPhase; + + std::list PhantasmsList; + std::list MoongladeWardenList; + + void Reset() + { + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + { + PhantasmPhase = false; + EranikusPhase = false; + EventTimer = 0; + uiPhase = 0; + FindVictimTimer = 2000; + DeadPhantasmsCount = 0; + StarfireTimer = urand(7000, 10000); + HealingTouchTimer = 4000; + RegrowthTimer = urand(5000, 10000); + RejuvenationTimer = urand(5000, 10000); + TranquilityTimer = urand(15000, 30000); + EranikusGUID = 0; + + PhantasmsList.clear(); + MoongladeWardenList.clear(); + } + } + + void JustSummoned(Creature* pSummoned) + { + if (pSummoned->GetEntry() == NPC_NIGHTMARE_PHANTASM) + { + PhantasmsList.push_back(pSummoned->GetGUID()); + pSummoned->GetMotionMaster()->MoveChase(me); + pSummoned->AI()->AttackStart(me); + } + + if (pSummoned->GetEntry() == NPC_MOONGLADE_WARDEN) + MoongladeWardenList.push_back(pSummoned->GetGUID()); + } + + void ClearSummonedCreatures() + { + if (!MoongladeWardenList.empty()) + { + for (std::list::iterator itr = MoongladeWardenList.begin(); itr != MoongladeWardenList.end(); ++itr) + { + if (Creature* pWarden = Unit::GetCreature(*me,*itr)) + pWarden->ForcedDespawn(); + } + } + MoongladeWardenList.clear(); + + if (!PhantasmsList.empty()) + { + for (std::list::iterator itr = PhantasmsList.begin(); itr != PhantasmsList.end(); ++itr) + { + if (Creature* pPhantasm = Unit::GetCreature(*me,*itr)) + pPhantasm->ForcedDespawn(); + } + } + PhantasmsList.clear(); + } + + void JustDied(Unit* /*killer*/) + { + ClearSummonedCreatures(); + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + pEranikus->ForcedDespawn(); + } + + void FindVictim(Creature* pCreature) + { + if (!pCreature->getVictim()) + { + if (PhantasmPhase) + { + if (Unit *pTarget = GetClosestCreatureWithEntry(pCreature, NPC_NIGHTMARE_PHANTASM, 50.0f)) + { + pCreature->GetMotionMaster()->MoveChase(pTarget); + pCreature->AI()->AttackStart(pTarget); + return; + } + } + + if (EranikusPhase) + { + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + pCreature->GetMotionMaster()->MoveChase(pEranikus); + pCreature->AI()->AttackStart(pEranikus); + return; + } + } + return; + } + } + + void CheckNightmare() + { + if (!PhantasmsList.empty()) + { + for (std::list::iterator itr = PhantasmsList.begin(); itr != PhantasmsList.end(); ++itr) + { + if (Creature *pPhantasm = Unit::GetCreature(*me,*itr)) + { + if (!pPhantasm->isAlive()) + { + PhantasmsList.erase(itr); + DeadPhantasmsCount++; + break; + } + } + } + } + if (DeadPhantasmsCount >=15) + { + PhantasmsList.clear(); + EventTimer = 10000; + uiPhase = 14; + } + } + + void WaypointReached(uint32 uiPointId) + { + Player* pPlayer = GetPlayerForEscort(); + + if (!pPlayer) + return; + + switch (uiPointId) + { + case 18: + SetEscortPaused(true); + DoScriptText(REMULOS_SAY_3, me, pPlayer); + EventTimer = 5000; + uiPhase = 2; + break; + case 23: + SetEscortPaused(true); + me->SetOrientation(0.044f); + me->SendHeartBeat(); + DoScriptText(REMULOS_SAY_7, me); + EventTimer = 7000; + uiPhase = 11; + break; + case 24: + SetEscortPaused(true); + break; + case 26: + SetEscortPaused(true); + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + me->SetOrientation(1.46); + me->SendHeartBeat(); + } + break; + } + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if (uiPhase) + { + if (EventTimer <= diff) + { + Player* pPlayer = GetPlayerForEscort(); + + if (!pPlayer) + return; + + switch (uiPhase) + { + case 1: + DoScriptText(REMULOS_SAY_2, me); + uiPhase = 0; + SetEscortPaused(false); + break; + case 2: + DoScriptText(REMULOS_SAY_4, me); + uiPhase = 3; + EventTimer = 10000; + break; + case 3: + DoScriptText(REMULOS_SAY_5, me); + DoCast(me, SPELL_C0NJURE_DREAM_RIFT); + uiPhase = 4; + EventTimer = 10000; + break; + case 4: + if (Creature* pEranikus = me->SummonCreature(NPC_ERANIKUS, 7867.44f, -2671.37f, 498.042f, 0.51f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000)) + { + //TODO: now must be server-wide emote + DoScriptText(ERANIKUS_ZONE_EMOTE_ENTER, pEranikus); + pEranikus->SetReactState(REACT_PASSIVE); + pEranikus->SetFlying(true); + pEranikus->AI()->IsSummonedBy(me); + pEranikus->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + EranikusGUID = pEranikus->GetGUID(); + } + else me->ForcedDespawn(); + uiPhase = 5; + EventTimer = 10000; + break; + case 5: + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + DoScriptText(ERANIKUS_YELL_1, pEranikus); + uiPhase = 6; + EventTimer = 10000; + break; + case 6: + DoScriptText(REMULOS_YELL_1, me); + uiPhase = 7; + EventTimer = 5000; + break; + case 7: + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + DoScriptText(ERANIKUS_EMOTE_LAUGHT, pEranikus); + DoScriptText(ERANIKUS_YELL_2, pEranikus); + } + uiPhase = 8; + EventTimer = 8000; + break; + case 8: + DoScriptText(REMULOS_YELL_2, me); + uiPhase = 9; + EventTimer = 9000; + break; + case 9: + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + DoScriptText(ERANIKUS_EMOTE_LAUGHT, pEranikus); + DoScriptText(ERANIKUS_YELL_3, pEranikus); + pEranikus->GetMotionMaster()->MovePoint(POINT_NIGHTRAVEN, 7926.28f, -2573.13f, 501.655f); + pEranikus->SetHomePosition(7926.28f, -2573.13f, 501.655f, 2.88f); + } + uiPhase = 10; + EventTimer = 5000; + break; + case 10: + DoScriptText(REMULOS_SAY_6, me, pPlayer); + SetEscortPaused(false); + uiPhase = 0; + break; + case 11: + SetEscortPaused(false); + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + DoScriptText(ERANIKUS_YELL_4, pEranikus); + DoScriptText(REMULOS_SAY_8, me); + } + + for (int i = 0; i < NPC_NIGHTMARE_PHANTASMS_COUNT; i++) + { + uint32 r = urand(0, 5); + float collision = (float)urand(4, 8); + me->SummonCreature(NPC_NIGHTMARE_PHANTASM, + PhantasmsSpawnpos[r][0]+collision, PhantasmsSpawnpos[r][1]+collision, + PhantasmsSpawnpos[r][2] + 2, PhantasmsSpawnpos[r][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + } + SetCanAttack(true); + PhantasmPhase = true; + me->SetSpeed(MOVE_RUN, 2.0f); + SetRun(true); + uiPhase = 12; + EventTimer = 5000; + break; + case 12: + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + DoScriptText(ERANIKUS_YELL_5, pEranikus); + for (int i = 0; i < NPC_MOONGLADE_WARDENS_COUNT; i++) + { + float collision = (float)urand(4, 8); + uint32 r = urand(0, 1) ? 1 : 0; + if (Creature* pWarden = me->SummonCreature(NPC_MOONGLADE_WARDEN, + PhantasmsSpawnpos[r][0]+collision, PhantasmsSpawnpos[r][1]+collision, + PhantasmsSpawnpos[r][2], PhantasmsSpawnpos[r][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) + FindVictim(pWarden); + } + uiPhase = 13; + EventTimer = 10000; + break; + case 13: + CheckNightmare(); + EventTimer = 500; + break; + case 14: + if (DeadPhantasmsCount >= NPC_NIGHTMARE_PHANTASMS_COUNT) + { + EranikusPhase = true; + PhantasmPhase = false; + SetCanAttack(false); + SetEscortPaused(false); + SetRun(false); + uiPhase = 15; + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + DoScriptText(ERANIKUS_YELL_6, pEranikus); + pEranikus->GetMotionMaster()->MovePoint(POINT_COMBAT_START, 7901.51f, -2565.71f, 488.046f); + pEranikus->SetHomePosition(7901.51f, -2565.71f, 488.046f, 3.17f); + } + } + EventTimer = 10000; + break; + case 15: + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + for (int i = 0; i < NPC_MOONGLADE_WARDENS_COUNT; i++) + me->SummonCreature(NPC_MOONGLADE_WARDEN, + pEranikus->GetPositionX(), pEranikus->GetPositionY(), + pEranikus->GetPositionZ(), 0.02, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + } + EventTimer = 60000; + break; + } + } + else EventTimer -= diff; + } + + if (GetTargetForHeal()) + { + if (RegrowthTimer <= diff) + { + DoCast(GetTargetForHeal(), SPELL_REGROWTH); + RegrowthTimer = urand(5000, 10000); + } else RegrowthTimer -= diff; + + if (RejuvenationTimer <= diff) + { + DoCast(GetTargetForHeal(), SPELL_REJUVENATION); + RejuvenationTimer = urand(5000, 10000); + } else RejuvenationTimer -= diff; + + if (TranquilityTimer <= diff) + { + DoCast(GetTargetForHeal(), SPELL_TRANQUILITY); + TranquilityTimer = urand(20000, 30000); + } else TranquilityTimer -= diff; + + if (HealingTouchTimer <= diff) + { + DoCast(GetTargetForHeal(), SPELL_HEALING_TOUCH); + HealingTouchTimer = 3500; + } else HealingTouchTimer -= diff; + } + + if (!UpdateVictim()) + { + if (FindVictimTimer <= diff) + { + FindVictim(me); + FindVictimTimer = 2000; + return; + } else FindVictimTimer -= diff; + return; + } + + if (StarfireTimer <= diff) + { + DoCast(me->getVictim(), SPELL_STARFIRE); + StarfireTimer = urand(7000, 10000); + } else StarfireTimer -= diff; + + DoMeleeAttackIfReady(); + } + + Unit* GetTargetForHeal() + { + if (HealthBelowPct(90)) + return me; + + if (PhantasmPhase) + { + if (Unit* pTarget = GetPlayerForEscort()) + if (pTarget->GetHealth()*100 < pTarget->GetMaxHealth()*90) + return pTarget; + return NULL; + } + + if (EranikusPhase) + { + if (Creature* pEranikus = Unit::GetCreature(*me, EranikusGUID)) + { + if (Unit* pTarget = pEranikus->getVictim()) + if (pTarget->GetHealth()*100 < pTarget->GetMaxHealth()*90) + return pTarget; + return NULL; + } + } + return NULL; + } + + void EventComplete() + { + if (Player* pPlayer = GetPlayerForEscort()) + pPlayer->GroupEventHappens(QUEST_NIGHTMARE_MANIFESTS, me); + } +}; + +CreatureAI* GetAI_npc_remulos(Creature* pCreature) +{ + return new npc_remulosAI(pCreature); +} + +bool QuestAccept_npc_remulos(Player* pPlayer, Creature* pCreature, const Quest* pQuest) +{ + if (pQuest->GetQuestId() == QUEST_NIGHTMARE_MANIFESTS) + { + DoScriptText(REMULOS_SAY_1, pCreature, pPlayer); + + if (npc_remulosAI* pEscortAI = CAST_AI(npc_remulosAI, pCreature->AI())) + { + pEscortAI->Start(true, false, pPlayer->GetGUID(), pQuest); + pEscortAI->SetEscortPaused(true); + pEscortAI->SetDespawnAtEnd(false); + pEscortAI->SetDespawnAtFar(false); + pEscortAI->uiPhase = 1; + pEscortAI->EventTimer = 10000; + } + } + return true; +} + +struct npc_eranikusAI : public ScriptedAI +{ +public: + npc_eranikusAI(Creature *c) : ScriptedAI(c) {} + + uint32 ShadowBoltTimer; + uint32 AcidBreathTimer; + uint32 NoxiusBreathTimer; + uint32 EventTimer; + uint32 FindVictimTimer; + uint32 uiPhase; + uint64 TyrandeGUID; + uint64 RemulosGUID; + bool CanAttack; + + std::list PriestessOfTheMoonList; + + void Reset() + { + ShadowBoltTimer = urand(5000, 12000); + AcidBreathTimer = urand(5000, 15000); + NoxiusBreathTimer = urand(10000, 20000); + EventTimer = 0; + FindVictimTimer = 2000; + uiPhase = 0; + TyrandeGUID = 0; + RemulosGUID = 0; + CanAttack = false; + + PriestessOfTheMoonList.clear(); + } + + void UpdateAI(const uint32 diff) + { + if (EventTimer <= diff) + { + switch (uiPhase) + { + case 0: + if (HealthBelowPct(80)) + { + DoScriptText(ERANIKUS_YELL_7, me); + if (Creature* pTyrande = me->SummonCreature(NPC_TYRANDE, 7927.01f, -2573.36f, 489.652f, 2.81f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000)) + { + TyrandeGUID = pTyrande->GetGUID(); + pTyrande->SetVisibility(VISIBILITY_OFF); + DoScriptText(TYRANDE_YELL_1, pTyrande); + } + uiPhase++; + } + EventTimer = 3000; + break; + case 1: + if (HealthBelowPct(70)) + { + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + DoScriptText(TYRANDE_YELL_2, pTyrande); + uiPhase++; + } + EventTimer = 3000; + break; + case 2: + if (HealthBelowPct(60)) + { + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + DoScriptText(TYRANDE_YELL_3, pTyrande); + uiPhase++; + } + EventTimer = 3000; + break; + case 3: + if (HealthBelowPct(40)) + { + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + DoScriptText(TYRANDE_SAY_2, pTyrande); + uiPhase++; + } + EventTimer = 3000; + break; + case 4: + if (HealthBelowPct(25)) + { + DoScriptText(ERANIKUS_YELL_8, me); + uiPhase++; + } + EventTimer = 3000; + break; + case 5: + if (HealthBelowPct(22)) + { + DoScriptText(ERANIKUS_YELL_9, me); + uiPhase++; + } + EventTimer = 3000; + break; + case 6: + if (HealthBelowPct(20)) + { + if (Creature* pRemulos = Unit::GetCreature(*me, RemulosGUID)) + { + CAST_AI(npc_remulosAI, pRemulos->AI())->EranikusPhase = false; + CAST_AI(npc_remulosAI, pRemulos->AI())->uiPhase = 0; + CAST_AI(npc_remulosAI, pRemulos->AI())->SetEscortPaused(false); + } + DoScriptText(ERANIKUS_YELL_10, me); + for (std::set::const_iterator itr = me->getAttackers().begin(); itr != me->getAttackers().end(); ++itr) + { + float collision = (float)urand(-8, 8); + uint32 r = urand(0, 1) ? 1 : 0; + if ((*itr)) + (*itr)->RemoveAllAuras(); + + if ((*itr)->GetEntry() == NPC_MOONGLADE_WARDEN) + { + if (Creature* pWarden = Unit::GetCreature(*me, (*itr)->GetGUID())) + { + pWarden->SetHomePosition(7877.72f + collision, -2581.84f + collision, 486.948f, 0.0f + collision); + pWarden->GetMotionMaster()->MoveTargetedHome(); + pWarden->SetStandState(UNIT_STAND_STATE_SIT); + } + } + } + CanAttack = false; + me->CombatStop(true); + me->setFaction(35); + me->DeleteThreatList(); + me->RemoveAllAuras(); + me->SetReactState(REACT_PASSIVE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + { + pTyrande->SetVisibility(VISIBILITY_ON); + pTyrande->SetHomePosition(7886.63f, -2565.8f, 486.965f, 6.16066f); + pTyrande->GetMotionMaster()->MoveTargetedHome(); + } + for (int i = 0; i < NPC_PRIESTESS_OF_THE_MOON_COUNT ; i++) + { + float collision = (float)urand(-4, 4); + uint32 r = urand(0, 1) ? 1 : 0; + if (Creature* pPristess = me->SummonCreature(NPC_PRIESTESS_OF_THE_MOON, 7927.01f + collision, -2573.36f + collision, 489.652f + collision, 2.81f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) + { + PriestessOfTheMoonList.push_back(pPristess->GetGUID()); + pPristess->SetHomePosition(PristessHomePoint[i].m_fX, PristessHomePoint[i].m_fY, + PristessHomePoint[i].m_fZ, PristessHomePoint[i].m_fO); + pPristess->GetMotionMaster()->MoveTargetedHome(); + } + } + EventTimer = 3000; + uiPhase++; + } else + EventTimer = 3000; + break; + case 7: + me->SetUInt64Value(UNIT_FIELD_TARGET, 0); + me->SetStandState(UNIT_STAND_STATE_DEAD); + DoTeleportTo(7901.51f, -2565.71f, 488.046f); + DoCast(me, SPELL_SPOTLIGHT, false); + //TODO: now must be server-wide emote + DoScriptText(ERANIKUS_ZONE_EMOTE_CONSUMED, me); + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + me->SetFacingToObject(pTyrande); + EventTimer = 3000; + uiPhase++; + break; + case 8: + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + { + pTyrande->SetFacingToObject(me); + DoScriptText(TYRANDE_EMOTE_KNEE, pTyrande); + pTyrande->SetStandState(UNIT_STAND_STATE_KNEEL); + DoScriptText(TYRANDE_YELL_4, pTyrande); + } + EventTimer = 3000; + uiPhase++; + break; + case 9: + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + { + pTyrande->SetStandState(UNIT_STAND_STATE_STAND); + me->SetFacingToObject(pTyrande); + } + if (Creature* pRemulos = Unit::GetCreature(*me, RemulosGUID)) + pRemulos->SetFacingToObject(me); + me->SetStandState(UNIT_STAND_STATE_STAND); + me->UpdateEntry(NPC_ERANIKUS_THE_REDEEMED); + me->SetDisplayId(6984); + DoScriptText(ERANIKUS_SAY_1, me); + EventTimer = 8000; + uiPhase++; + break; + case 10: + DoScriptText(ERANIKUS_SAY_2, me); + EventTimer = 5000; + uiPhase++; + break; + case 11: + DoScriptText(ERANIKUS_SAY_3, me); + EventTimer = 10000; + uiPhase++; + break; + case 12: + DoScriptText(ERANIKUS_SAY_4, me); + EventTimer = 8000; + uiPhase++; + break; + case 13: + if (Creature* pRemulos = Unit::GetCreature(*me, RemulosGUID)) + { + DoScriptText(REMULOS_SAY_9, pRemulos); + CAST_AI(npc_remulosAI, pRemulos->AI())->EventComplete(); + } + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + pTyrande->ForcedDespawn(); + if (!PriestessOfTheMoonList.empty()) + { + for (std::list::iterator itr = PriestessOfTheMoonList.begin(); itr != PriestessOfTheMoonList.end(); ++itr) + { + if (Creature* pPristess= Unit::GetCreature(*me,*itr)) + pPristess->ForcedDespawn(); + } + } + PriestessOfTheMoonList.clear(); + if (Creature* pRemulos = Unit::GetCreature(*me, RemulosGUID)) + { + DoScriptText(REMULOS_SAY_10, pRemulos); + CAST_AI(npc_remulosAI, pRemulos->AI())->ClearSummonedCreatures(); + pRemulos->ForcedDespawn(5000); + } + Reset(); + me->ForcedDespawn(); + break; + } + } else EventTimer -= diff; + + if (CanAttack) + { + if (!UpdateVictim()) + { + if (FindVictimTimer <= diff) + { + FindVictim(); + FindVictimTimer = 2000; + return; + } else FindVictimTimer -= diff; + return; + } + + if (ShadowBoltTimer <= diff) + { + DoCast(me->getVictim(), ERANIKUS_SPELL_SHADOW_BOLT_VOLLEY); + ShadowBoltTimer = urand(7000, 12000); + } else ShadowBoltTimer -= diff; + + if (AcidBreathTimer <= diff) + { + DoCast(me->getVictim(), ERANIKUS_SPELL_ACID_BREATH); + AcidBreathTimer = urand(5000, 15000); + } else AcidBreathTimer -= diff; + + if (NoxiusBreathTimer <= diff) + { + DoCast(me->getVictim(), ERANIKUS_SPELL_NOXIUS_BREATH); + NoxiusBreathTimer = urand(10000, 20000); + } else NoxiusBreathTimer -= diff; + + DoMeleeAttackIfReady(); + } + } + + void MovementInform(uint32 uiMotionType, uint32 uiPointId) + { + if (uiMotionType != POINT_MOTION_TYPE) + return; + + if (uiPointId == POINT_NIGHTRAVEN) + { + me->SetOrientation(2.88f); + me->SendHeartBeat(); + } + + if (uiPointId == POINT_COMBAT_START) + { + CanAttack = true; + me->SetFlying(false); + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + } + } + + void JustDied() + { + if (Creature* pTyrande = Unit::GetCreature(*me, TyrandeGUID)) + { + if (pTyrande->isAlive()) + pTyrande->ForcedDespawn(); + } + + if (!PriestessOfTheMoonList.empty()) + { + for (std::list::iterator itr = PriestessOfTheMoonList.begin(); itr != PriestessOfTheMoonList.end(); ++itr) + { + if (Creature* pPristess= Unit::GetCreature(*me,*itr)) + pPristess->ForcedDespawn(); + } + } + PriestessOfTheMoonList.clear(); + } + + void IsSummonedBy(Unit* pSummoner) + { + if (pSummoner->GetEntry() == NPC_REMULOS) + { + RemulosGUID = pSummoner->GetGUID(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveCharge(7867.44f, -2671.37f, 503.042f); + return; + } + } + + void FindVictim() + { + if (!me->getVictim()) + { + if (Unit *pTarget = me->SelectNearestTarget(20)) + { + me->GetMotionMaster()->MoveChase(pTarget); + AttackStart(pTarget); + return; + } + + if (Creature* pRemulos = Unit::GetCreature(*me, RemulosGUID)) + { + me->GetMotionMaster()->MoveChase(pRemulos); + AttackStart(pRemulos); + return; + } + } + } +}; + +CreatureAI* GetAI_npc_eranikus(Creature* pCreature) +{ + return new npc_eranikusAI(pCreature); +} + +/*#### +# +####*/ + +void AddSC_moonglade() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_bunthen_plainswind"; + newscript->pGossipHello = &GossipHello_npc_bunthen_plainswind; + newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_great_bear_spirit"; + newscript->pGossipHello = &GossipHello_npc_great_bear_spirit; + newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_silva_filnaveth"; + newscript->pGossipHello = &GossipHello_npc_silva_filnaveth; + newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_clintar_dreamwalker"; + newscript->pQuestAcceptNPC = &QuestAccept_npc_clintar_dreamwalker; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_clintar_spirit"; + newscript->GetAI = &GetAI_npc_clintar_spirit; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_remulos"; + newscript->GetAI = &GetAI_npc_remulos; + newscript->pQuestAcceptNPC = &QuestAccept_npc_remulos; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_eranikus"; + newscript->GetAI = &GetAI_npc_eranikus; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/mulgore/mulgore.cpp b/src/scripts/scripts/Kalimdor/mulgore/mulgore.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/mulgore/mulgore.cpp rename to src/scripts/scripts/Kalimdor/mulgore/mulgore.cpp index 5960f35c7..a0fb5c2fb --- a/src/scripts/scripts/zone/mulgore/mulgore.cpp +++ b/src/scripts/scripts/Kalimdor/mulgore/mulgore.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp b/src/scripts/scripts/Kalimdor/onyxias_lair/boss_onyxia.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp rename to src/scripts/scripts/Kalimdor/onyxias_lair/boss_onyxia.cpp index fc5ac7005..a4f5ea1a2 --- a/src/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp +++ b/src/scripts/scripts/Kalimdor/onyxias_lair/boss_onyxia.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -52,8 +55,9 @@ enum OnyxiaSpells }; -#define SPELL_ENGULFINGFLAMES 20019 -#define CREATURE_WHELP 11262 +#define SPELL_ENGULFINGFLAMES 20019 +#define CREATURE_WHELP 11262 +#define NPC_ONYXIAN_WARDER 12129 struct Position; enum SpawnDefinitions; @@ -88,6 +92,7 @@ struct boss_onyxiaAI : public ScriptedAI uint32 m_phaseMask; + uint32 m_rangeCheckTimer; uint32 m_flameBreathTimer; uint32 m_cleaveTimer; uint32 m_tailSweepTimer; @@ -107,14 +112,14 @@ struct boss_onyxiaAI : public ScriptedAI { if (m_creature->IsLevitating()) { - m_creature->SendMeleeAttackStart(m_creature->getVictim()); + m_creature->SendMeleeAttackStart(m_creature->getVictimGUID()); m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); m_creature->SetLevitate(false); DoStartMovement(m_creature->getVictim()); } else { - m_creature->SendMeleeAttackStop(m_creature->getVictim()); + m_creature->SendMeleeAttackStop(m_creature->getVictimGUID()); m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); m_creature->SetLevitate(true); } @@ -130,7 +135,7 @@ struct boss_onyxiaAI : public ScriptedAI if (!m_nextWay || m_nextWay == 6) return; - m_creature->SendMeleeAttackStop(m_creature->getVictim()); + m_creature->SendMeleeAttackStop(m_creature->getVictimGUID()); DoCast(m_creature->getVictim(), SPELL_FIREBALL); m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(), 100); } @@ -160,6 +165,7 @@ struct boss_onyxiaAI : public ScriptedAI void Reset() { + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); // Lie animation if (pInstance) pInstance->SetData(DATA_ONYXIA, NOT_STARTED); @@ -170,6 +176,7 @@ struct boss_onyxiaAI : public ScriptedAI m_nextWay = 0; m_nextMoveTimer = 0; + m_rangeCheckTimer = 3000; m_flameBreathTimer = 20000; m_cleaveTimer = 8000; m_tailSweepTimer = 5000; @@ -188,6 +195,16 @@ struct boss_onyxiaAI : public ScriptedAI m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); DoScriptText(SAY_AGGRO, m_creature); DoZoneInCombat(); + + std::list warders = FindAllCreaturesWithEntry(NPC_ONYXIAN_WARDER, 200.0f); + + for (std::list::iterator i = warders.begin(); i != warders.end(); ++i) + if (!(*i)->isAlive()) + { + (*i)->setDeathState(DEAD); + (*i)->Respawn(); + } + if (pInstance) pInstance->SetData(DATA_ONYXIA, IN_PROGRESS); } @@ -256,7 +273,7 @@ struct boss_onyxiaAI : public ScriptedAI m_nextWay = i + 1; m_nextMoveTimer = 2500; //DoTextEmote("Onyxia takes in a deep breath...", NULL, true);//DoScriptText(EMOTE_BREATH, m_creature); - m_creature->SendMeleeAttackStop(m_creature->getVictim()); + m_creature->SendMeleeAttackStop(m_creature->getVictimGUID()); DoCast(m_creature, SPELL_DEEPBREATH); m_creature->SetSpeed(MOVE_RUN, 2.5f); break; @@ -273,8 +290,25 @@ struct boss_onyxiaAI : public ScriptedAI if(!UpdateVictim()) return; + DoSpecialThings(diff, DO_EVADE_CHECK, 75.0f); + UpdatePhase(); + if (m_rangeCheckTimer < diff) + { + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (Player* plr = i->getSource()) + if (plr->isAlive() && !plr->isGameMaster() && !plr->IsWithinDistInMap(me, 100.0f)) + plr->TeleportTo(me->GetMapId(), me->GetPositionX(), me->GetPositionY(), + me->GetPositionZ(), plr->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT); + + m_rangeCheckTimer = 3000; + } + else + m_rangeCheckTimer -= diff; + if (m_phaseMask & PHASE_1) { if (m_flameBreathTimer < diff) diff --git a/src/scripts/scripts/Kalimdor/onyxias_lair/def_onyxia_lair.h b/src/scripts/scripts/Kalimdor/onyxias_lair/def_onyxia_lair.h new file mode 100644 index 000000000..f4c2f0ed5 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/onyxias_lair/def_onyxia_lair.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_ONYXIA_LAIR_H +#define SC_DEF_ONYXIA_LAIR_H + +struct cPosition +{ + float x; + float y; + float z; + float o; +}; + +enum SpawnDefinitions +{ + LEFT = 0, + RIGHT = 1, + MAX = 2, +}; + +static cPosition spawnEntrancePoints[MAX] = +{ + {-35.8699, -161.351, -91.1765}, + {-35.813, -268.307, -91.1498} +}; + +enum OnyxiaData +{ + DATA_ONYXIA = 1, + DATA_HATCH_EGGS = 2, + DATA_ERUPT = 3 +}; + +#endif diff --git a/src/scripts/scripts/zone/onyxias_lair/instance_onyxia_lair.cpp b/src/scripts/scripts/Kalimdor/onyxias_lair/instance_onyxia_lair.cpp similarity index 97% rename from src/scripts/scripts/zone/onyxias_lair/instance_onyxia_lair.cpp rename to src/scripts/scripts/Kalimdor/onyxias_lair/instance_onyxia_lair.cpp index b3131ffbe..9b0ada73d 100644 --- a/src/scripts/scripts/zone/onyxias_lair/instance_onyxia_lair.cpp +++ b/src/scripts/scripts/Kalimdor/onyxias_lair/instance_onyxia_lair.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/orgrimmar/orgrimmar.cpp b/src/scripts/scripts/Kalimdor/orgrimmar/orgrimmar.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/orgrimmar/orgrimmar.cpp rename to src/scripts/scripts/Kalimdor/orgrimmar/orgrimmar.cpp index 886202351..c224a7075 --- a/src/scripts/scripts/zone/orgrimmar/orgrimmar.cpp +++ b/src/scripts/scripts/Kalimdor/orgrimmar/orgrimmar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp b/src/scripts/scripts/Kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp similarity index 96% rename from src/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp rename to src/scripts/scripts/Kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp index d11f9975c..dce149270 100644 --- a/src/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp +++ b/src/scripts/scripts/Kalimdor/razorfen_downs/boss_amnennar_the_coldbringer.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2010 ScriptDev2 +/* + * Copyright (C) 2006-2010 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/razorfen_downs/instance_razorfen_downs.cpp b/src/scripts/scripts/Kalimdor/razorfen_downs/instance_razorfen_downs.cpp similarity index 83% rename from src/scripts/scripts/zone/razorfen_downs/instance_razorfen_downs.cpp rename to src/scripts/scripts/Kalimdor/razorfen_downs/instance_razorfen_downs.cpp index 63848f611..68dbc55f9 100644 --- a/src/scripts/scripts/zone/razorfen_downs/instance_razorfen_downs.cpp +++ b/src/scripts/scripts/Kalimdor/razorfen_downs/instance_razorfen_downs.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2010 Trinity + * Copyright (C) 2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +21,7 @@ #include "precompiled.h" #include "razorfen_downs.h" -#define MAX_ENCOUNTER 1 +#define MAX_ENCOUNTER 2 struct instance_razorfen_downs : public ScriptedInstance { @@ -30,7 +31,7 @@ struct instance_razorfen_downs : public ScriptedInstance }; uint64 uiGongGUID; - + std::list flamesGUID; uint32 m_auiEncounter[MAX_ENCOUNTER]; uint8 uiGongWaves; @@ -40,7 +41,7 @@ struct instance_razorfen_downs : public ScriptedInstance uiGongGUID = 0; uiGongWaves = 0; - + flamesGUID.clear(); memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); } @@ -51,7 +52,7 @@ struct instance_razorfen_downs : public ScriptedInstance std::ostringstream stream; stream << "T C "; - stream << m_auiEncounter[0] << " "; + stream << m_auiEncounter[0] << m_auiEncounter[1] << " "; stream << uiGongWaves; OUT_SAVE_INST_DATA_COMPLETE; @@ -70,20 +71,21 @@ struct instance_razorfen_downs : public ScriptedInstance OUT_LOAD_INST_DATA(in); char dataHead1, dataHead2; - uint16 data0, data1; + uint16 data0, data1, data2; std::istringstream loadStream(in); - loadStream >> dataHead1 >> dataHead2 >> data0 >> data1; + loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2; if (dataHead1 == 'T' && dataHead2 == 'C') { m_auiEncounter[0] = data0; + m_auiEncounter[1] = data1; for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) if (m_auiEncounter[i] == IN_PROGRESS) m_auiEncounter[i] = NOT_STARTED; - uiGongWaves = data1; + uiGongWaves = data2; } else OUT_LOAD_INST_DATA_FAIL; OUT_LOAD_INST_DATA_COMPLETE; @@ -98,11 +100,21 @@ struct instance_razorfen_downs : public ScriptedInstance if (m_auiEncounter[0] == DONE) pGo->SetFlag(GAMEOBJECT_FLAGS,GO_FLAG_NOTSELECTABLE); break; + case GO_IDOL_MOUTH: + case GO_IDOL_CUP: + case GO_IDOL_OVEN: + flamesGUID.push_back(pGo->GetGUID());break; default: break; } } + void OnCreatureCreate(Creature* c, uint32 id) + { + if (id == CREATURE_BELNISTRASZ && m_auiEncounter[1] == DONE) + c->ForcedDespawn(); + } + void SetData(uint32 uiType, uint32 uiData) { if (uiType == DATA_GONG_WAVES) @@ -167,13 +179,18 @@ struct instance_razorfen_downs : public ScriptedInstance } } - if (uiType == BOSS_TUTEN_KASH) + if (uiType == BOSS_TUTEN_KASH || uiType == DATA_BELNISTRASZ) { - m_auiEncounter[0] = uiData; + m_auiEncounter[uiType] = uiData; if (uiData == DONE) SaveToDB(); } + if (uiType == DATA_BELNISTRASZ) + { + for( std::list::iterator itr = flamesGUID.begin() ; itr != flamesGUID.end(); itr++) + instance->GetGameObject(*itr)->AddObjectToRemoveList(); + } } uint32 GetData(uint32 uiType) diff --git a/src/scripts/scripts/zone/razorfen_downs/razorfen_downs.cpp b/src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.cpp similarity index 52% rename from src/scripts/scripts/zone/razorfen_downs/razorfen_downs.cpp rename to src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.cpp index 7b35936fa..0b1819b6f 100644 --- a/src/scripts/scripts/zone/razorfen_downs/razorfen_downs.cpp +++ b/src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,29 +9,31 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData SDName: Razorfen_Downs -SD%Complete: 100 -SDComment: Support for Henry Stern(2 recipes) +SD%Complete: 70 +SDComment: TODO: npc_belnistrasz - combat AI/spells SDCategory: Razorfen Downs EndScriptData */ /* ContentData npc_henry_stern +npc_belnistrasz EndContentData */ //#include "ScriptedPch.h" #include "precompiled.h" #include "GossipDef.h" #include "razorfen_downs.h" +#include "escort_ai.h" /*### # npc_henry_stern @@ -180,6 +185,137 @@ CreatureAI* GetAI_npc_tomb_creature(Creature* pCreature) return new npc_tomb_creatureAI (pCreature); } +/*###### +## npc_belnistrasz +######*/ +enum belnistraszEnum +{ +QUEST_BELNISTRASZ = 3525, +BELNISTRASZ_SAY_START = -2100025, +BELNISTRASZ_SAY_AGGRO = -2100027,/* should be "You'll rue the day you crossed me, " no idea how to do that. + also mobs does not pull on him on the way to event */ +BELNISTRASZ_SAY_IDOL = -2100026, +BELNISTRASZ_YELL_3MIN = -2100028, +BELNISTRASZ_YELL_2MIN = -2100029, +BELNISTRASZ_YELL_1MIN = -2100030, +BELNISTRASZ_YELL_COMPLETE = -2100031, +BELNISTRASZ_SAY_PLAGUEMAW = -2100032, +OVEN_TARGET = 8662, +SPELL_BELNISTRASZ_VISUAL = 12774, +MOB_GEOMANCER = 7335, +MOB_BOAR = 7333, +MOB_WARRIOR = 7327, +BOSS_PLAGUEMAW = 7356, +GO_BELNISTRASZ_BRAZIER = 152097, +}; + +struct npc_belnistraszAI : public npc_escortAI +{ + npc_belnistraszAI(Creature *c) : npc_escortAI(c){} + + uint32 wavetimer; + uint8 waves; + bool onplace; + + void Reset() + { + SetDespawnAtEnd(false); + SetDespawnAtFar(false); + onplace = false; + wavetimer = 0; + waves = 0; + } + void WaypointReached(uint32 i) + { + if (i == 13) + { + DoScriptText(BELNISTRASZ_SAY_IDOL,m_creature); + Unit* bunny = FindCreature(OVEN_TARGET,50,m_creature); + if (bunny) + DoCast(bunny,SPELL_BELNISTRASZ_VISUAL); + onplace = true; + wavetimer = 10000; + SetCanAttack(false); + } + } + void EnterCombat(Unit* who) + { + if (!onplace) + DoScriptText(BELNISTRASZ_SAY_AGGRO,m_creature,who); + } + + void JustSummoned(Creature* summon) + { + summon->AI()->AttackStart(m_creature); + summon->AI()->DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!onplace || waves > 10) + { + npc_escortAI::UpdateAI(diff); + if (!me->getVictim() && waves > 10) + { + m_creature->SummonGameObject(GO_BELNISTRASZ_BRAZIER,2578,946,53.3,0,0,0,0,0,30000); + GetPlayerForEscort()->GroupEventHappens(QUEST_BELNISTRASZ,m_creature); + if(InstanceData* pInstance = me->GetInstanceData()) + pInstance->SetData(DATA_BELNISTRASZ,DONE); + me->ForcedDespawn(); + } + } + else if (wavetimer >= diff) + wavetimer -= diff; + else + { + waves ++; + switch (waves) + { + case 3: DoScriptText(BELNISTRASZ_YELL_3MIN,m_creature);break; + case 5: DoScriptText(BELNISTRASZ_YELL_2MIN,m_creature);break; + case 7: DoScriptText(BELNISTRASZ_YELL_1MIN,m_creature);break; + case 9: DoScriptText(BELNISTRASZ_YELL_COMPLETE,m_creature);break; + case 10: DoScriptText(BELNISTRASZ_SAY_PLAGUEMAW,m_creature);break; + default : break; + } + if (waves<9) + { + m_creature->SummonCreature(MOB_GEOMANCER,2565,961,51.7,5.48,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + m_creature->SummonCreature(MOB_BOAR,2568,961,51.7,5.48,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + m_creature->SummonCreature(MOB_WARRIOR,2585,960,52.3,3.86,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + m_creature->SummonCreature(MOB_BOAR,2585,950,52.3,3.86,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + wavetimer = 30000; + } + else if (waves == 9) + { + SetCanAttack(true); + m_creature->InterruptNonMeleeSpells(false,SPELL_BELNISTRASZ_VISUAL); + wavetimer = 5000; + } + else if (waves == 10) + { + m_creature->SummonCreature(BOSS_PLAGUEMAW,2585,956,52.3,3.86,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + } + } + } +}; + +bool QuestAccept_npc_belnistrasz(Player* pPlayer, Creature* pCreature, Quest const* quest) +{ + if (quest->GetQuestId() == QUEST_BELNISTRASZ) + if (npc_escortAI* pEscortAI = CAST_AI(npc_belnistraszAI, pCreature->AI())) + { + pEscortAI->Start(true, true, pPlayer->GetGUID()); + DoScriptText(BELNISTRASZ_SAY_START,pCreature,pPlayer); + } + return true; +} + +CreatureAI* GetAI_npc_belnistrasz(Creature* pCreature) +{ + return new npc_belnistraszAI(pCreature); +} + void AddSC_razorfen_downs() { Script* newscript; @@ -199,4 +335,10 @@ void AddSC_razorfen_downs() newscript->Name = "npc_tomb_creature"; newscript->GetAI = &GetAI_npc_tomb_creature; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_belnistrasz"; + newscript->GetAI = &GetAI_npc_belnistrasz; + newscript->pQuestAcceptNPC = &QuestAccept_npc_belnistrasz; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/razorfen_downs/razorfen_downs.h b/src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.h similarity index 63% rename from src/scripts/scripts/zone/razorfen_downs/razorfen_downs.h rename to src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.h index a67b4223c..9d60f4198 100644 --- a/src/scripts/scripts/zone/razorfen_downs/razorfen_downs.h +++ b/src/scripts/scripts/Kalimdor/razorfen_downs/razorfen_downs.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2010 Trinity + * Copyright (C) 2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,12 +17,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DEF_RAZORFEN_DOWNS_H -#define DEF_RAZORFEN_DOWNS_H +#ifndef SC_DEF_RAZORFEN_DOWNS_H +#define SC_DEF_RAZORFEN_DOWNS_H enum eData { BOSS_TUTEN_KASH, + DATA_BELNISTRASZ, DATA_GONG_WAVES }; @@ -32,14 +34,18 @@ enum eData64 enum eGameObject { - GO_GONG = 148917 + GO_GONG = 148917, + GO_IDOL_MOUTH = 151973, + GO_IDOL_OVEN = 151951, + GO_IDOL_CUP = 151952, }; enum eCreature { CREATURE_TOMB_FIEND = 7349, CREATURE_TOMB_REAVER = 7351, - CREATURE_TUTEN_KASH = 7355 + CREATURE_TUTEN_KASH = 7355, + CREATURE_BELNISTRASZ = 8516, }; #endif diff --git a/src/scripts/scripts/zone/razorfen_kraul/def_razorfen_kraul.h b/src/scripts/scripts/Kalimdor/razorfen_kraul/def_razorfen_kraul.h old mode 100755 new mode 100644 similarity index 63% rename from src/scripts/scripts/zone/razorfen_kraul/def_razorfen_kraul.h rename to src/scripts/scripts/Kalimdor/razorfen_kraul/def_razorfen_kraul.h index 96917fcd4..bc6c249e7 --- a/src/scripts/scripts/zone/razorfen_kraul/def_razorfen_kraul.h +++ b/src/scripts/scripts/Kalimdor/razorfen_kraul/def_razorfen_kraul.h @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DEF_RAZORFEN_KRAUL_H -#define DEF_RAZORFEN_KRAUL_H +#ifndef SC_DEF_RAZORFEN_KRAUL_H +#define SC_DEF_RAZORFEN_KRAUL_H #define TYPE_WARD_KEEPERS 1 #endif \ No newline at end of file diff --git a/src/scripts/scripts/zone/razorfen_kraul/instance_razorfen_kraul.cpp b/src/scripts/scripts/Kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/razorfen_kraul/instance_razorfen_kraul.cpp rename to src/scripts/scripts/Kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp index 30b787d4e..36dc9348a --- a/src/scripts/scripts/zone/razorfen_kraul/instance_razorfen_kraul.cpp +++ b/src/scripts/scripts/Kalimdor/razorfen_kraul/instance_razorfen_kraul.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/razorfen_kraul/razorfen_kraul.cpp b/src/scripts/scripts/Kalimdor/razorfen_kraul/razorfen_kraul.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/razorfen_kraul/razorfen_kraul.cpp rename to src/scripts/scripts/Kalimdor/razorfen_kraul/razorfen_kraul.cpp index a39718503..6018d8f88 --- a/src/scripts/scripts/zone/razorfen_kraul/razorfen_kraul.cpp +++ b/src/scripts/scripts/Kalimdor/razorfen_kraul/razorfen_kraul.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -125,7 +128,7 @@ struct npc_willixAI : public npc_escortAI bool QuestAccept_npc_willix(Player* player, Creature* creature, Quest const* quest) { - if (quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER) + if (player && quest->GetQuestId() == QUEST_WILLIX_THE_IMPORTER) { CAST_AI(npc_escortAI, (creature->AI()))->Start(true, false, player->GetGUID()); DoScriptText(SAY_READY, creature, player); @@ -165,7 +168,7 @@ struct npc_deaths_head_ward_keeperAI : public ScriptedAI if (QuillboarChanneling_Timer < diff) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); DoCast(m_creature, SPELL_QUILLBOAR_CHANNELING); QuillboarChanneling_Timer = 1100; diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp index 96c81c6b2..609e03dcd --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ayamiss.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -103,7 +106,7 @@ struct boss_ayamissAI : public ScriptedAI return; //If he is 70% start phase 2 - if (phase==1 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 70 && !m_creature->IsNonMeleeSpellCasted(false)) + if (phase==1 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 70 && !m_creature->IsNonMeleeSpellCast(false)) { phase=2; } diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_buru.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_buru.cpp index 46d489dcc..3b9732b7f --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_buru.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp index 2918f0df2..0060928da --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_kurinnaxx.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -85,7 +88,7 @@ struct boss_kurinnaxxAI : public ScriptedAI return; //If we are <30% cast enrage - if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) + if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCast(false)) { i=1; DoCast(m_creature->getVictim(),SPELL_ENRAGE); diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_moam.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_moam.cpp index 7aac09057..516f548e0 --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_moam.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp index 8d3a46830..d75ad3212 --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_ossirian.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp index a613031f0..601d94111 --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/boss_rajaxx.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/def_ruins_of_ahnqiraj.h b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/def_ruins_of_ahnqiraj.h similarity index 100% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/def_ruins_of_ahnqiraj.h rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/def_ruins_of_ahnqiraj.h diff --git a/src/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp rename to src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp index 438aa96b2..f29ed067a --- a/src/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp +++ b/src/scripts/scripts/Kalimdor/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + /* ScriptData SDName: Instance_Ruins_of_Ahnqiraj SD%Complete: 0 @@ -72,15 +90,7 @@ struct instance_ruins_of_ahnqiraj : public ScriptedInstance break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void OnObjectCreate(GameObject* go){} diff --git a/src/scripts/scripts/Kalimdor/silithus/silithus.cpp b/src/scripts/scripts/Kalimdor/silithus/silithus.cpp new file mode 100644 index 000000000..e2879bbc3 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/silithus/silithus.cpp @@ -0,0 +1,1508 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Silithus +SD%Complete: 100 +SDComment: Quest support: 7785, 8304, 8305, 8519. +SDCategory: Silithus +EndScriptData */ + +/* ContentData +npc_highlord_demitrian +npcs_rutgar_and_frankal +npc_cenarion_scout_jalia +npc_cenarion_scout_azenel +npc_cenarion_scout_landion +go_crystalline_tear +mob_qiraj_war_spawn +npc_anachronos_quest_trigger +npc_anachronos_the_ancient +EndContentData */ + +#include "precompiled.h" + +/*### +## npc_highlord_demitrian +###*/ + +#define GOSSIP_DEMITRIAN1 "What do you know of it?" +#define GOSSIP_DEMITRIAN2 "I am listening , Demitrian." +#define GOSSIP_DEMITRIAN3 "Continue, please." +#define GOSSIP_DEMITRIAN4 "A battle?" +#define GOSSIP_DEMITRIAN5 "" +#define GOSSIP_DEMITRIAN6 "Caught unaware? How?" +#define GOSSIP_DEMITRIAN7 "So what did Ragnaros do next?" + +bool GossipHello_npc_highlord_demitrian(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu(_Creature->GetGUID()); + + if (player->GetQuestStatus(7785) == QUEST_STATUS_NONE && + (player->HasItemCount(18563,1,false) || player->HasItemCount(18564,1,false))) + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(6812, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_highlord_demitrian(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(6842, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(6843, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(6844, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(6867, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(6868, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(6869, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->SEND_GOSSIP_MENU(6870, _Creature->GetGUID()); + + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 19016, 1); + if (msg == EQUIP_ERR_OK) + player->StoreNewItem(dest, 19016, true); + break; + } + return true; +} + +/*### +## npcs_rutgar_and_frankal +###*/ + +//gossip item text best guess +#define GOSSIP_ITEM1 "I seek information about Natalia" + +#define GOSSIP_ITEM2 "That sounds dangerous!" +#define GOSSIP_ITEM3 "What did you do?" +#define GOSSIP_ITEM4 "Who?" +#define GOSSIP_ITEM5 "Women do that. What did she demand?" +#define GOSSIP_ITEM6 "What do you mean?" +#define GOSSIP_ITEM7 "What happened next?" + +#define GOSSIP_ITEM11 "Yes, please continue" +#define GOSSIP_ITEM12 "What language?" +#define GOSSIP_ITEM13 "The Priestess attacked you?!" +#define GOSSIP_ITEM14 "I should ask the monkey about this" +#define GOSSIP_ITEM15 "Then what..." + +//trigger creatures to kill +#define TRIGGER_RUTGAR 15222 +#define TRIGGER_FRANKAL 15221 + +bool GossipHello_npcs_rutgar_and_frankal(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && + _Creature->GetEntry() == 15170 && + !player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && + _Creature->GetEntry() == 15171 && + player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); + + player->SEND_GOSSIP_MENU(7754, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npcs_rutgar_and_frankal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(7755, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(7756, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7757, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(7758, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(7759, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(7760, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + player->SEND_GOSSIP_MENU(7761, _Creature->GetGUID()); + //'kill' our trigger to update quest status + player->KilledMonster( TRIGGER_RUTGAR, _Creature->GetGUID() ); + break; + + case GOSSIP_ACTION_INFO_DEF + 9: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM11, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(7762, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM12, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(7763, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM13, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(7764, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM14, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(7765, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM15, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); + player->SEND_GOSSIP_MENU(7766, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 14: + player->SEND_GOSSIP_MENU(7767, _Creature->GetGUID()); + //'kill' our trigger to update quest status + player->KilledMonster( TRIGGER_FRANKAL, _Creature->GetGUID() ); + break; + } + return true; +} + +/*###### +## npc_cenarion_scout_jalia +######*/ + +#define GOSSIP_ITEM_JALIA "Create Hive'Ashi Scout Report." + +bool GossipHello_npc_cenarion_scout_jalia(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(8739) == QUEST_STATUS_INCOMPLETE ) + if(!player->HasItemCount(21161,1)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_JALIA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_cenarion_scout_jalia(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_SENDER_INFO ) + { + player->CastSpell( player, 25845, false); + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + +/*###### +## npc_cenarion_scout_azenel +######*/ + +#define GOSSIP_ITEM_AZENEL "Create Hive'Zora Scout Report." + +bool GossipHello_npc_cenarion_scout_azenel(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(8534) == QUEST_STATUS_INCOMPLETE ) + if(!player->HasItemCount(21158,1)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_AZENEL, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_cenarion_scout_azenel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_SENDER_INFO ) + { + player->CastSpell( player, 25843, false); + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + +/*###### +## npc_cenarion_scout_landion +######*/ + +#define GOSSIP_ITEM_LANDION "Create Hive'Regal Scout Report." + +bool GossipHello_npc_cenarion_scout_landion(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(8738) == QUEST_STATUS_INCOMPLETE ) + if(!player->HasItemCount(21160,1)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_LANDION, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_cenarion_scout_landion(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_SENDER_INFO ) + { + player->CastSpell( player, 25847, false); + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + + +/////// +/// Lesser Wind Stone +/////// + +#define GOSSIP_LESSER_WIND_STONE "I am no cultist, you monster! Come to me and face your destruction!" + +#define EARTHEN_TEMPLAR 15307 +#define CRIMSON_TEMPLAR 15209 +#define AZURE_TEMPLAR 15211 +#define HOARY_TEMPLAR 15212 + +bool GossipHello_go_lesser_wind_stone(Player *player, GameObject* _GO) +{ + if(player->HasEquiped(20406) && player->HasEquiped(20408) && player->HasEquiped(20407)) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_LESSER_WIND_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(_GO->GetGOInfo()->questgiver.gossipID, _GO->GetGUID()); + } + else + { + player->CastSpell(player, 24803, false); + } + + return true; +} + +void SendActionMenu_go_lesser_wind_stone(Player *player, GameObject* _GO, uint32 action) +{ + _GO->SetGoState(GO_STATE_ACTIVE); + _GO->SetRespawnTime(600); + player->CLOSE_GOSSIP_MENU(); + + switch(action) + { + case GOSSIP_ACTION_INFO_DEF: + player->CastSpell(player,24745,false); + player->SummonCreature(RAND(EARTHEN_TEMPLAR, CRIMSON_TEMPLAR, AZURE_TEMPLAR, HOARY_TEMPLAR), _GO->GetPositionX(),_GO->GetPositionY(),_GO->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); + player->DestroyItemCount(20406, 1, true, true); + player->DestroyItemCount(20407, 1, true, true); + player->DestroyItemCount(20408, 1, true, true); + break; + } +} + +bool GossipSelect_go_lesser_wind_stone(Player *player, GameObject* _GO, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_go_lesser_wind_stone(player, _GO, action); break; + } + return true; +} + + +/////// +/// Wind Stone +/////// + +#define GOSSIP_WIND_STONE "You will listen to this, ville duke! I am not your Twilight's Hammer lapdog! I am here to challenge you! Come! Come, and meet your death..." + +#define DUKE_OF_SHARDS 15208 +#define DUKE_OF_ZEPHYRS 15220 +#define DUKE_OF_FATHOMS 15207 +#define DUKE_OF_CYNDERS 15206 + +bool GossipHello_go_wind_stone(Player *player, GameObject* _GO) +{ + if(player->HasEquiped(20406) && player->HasEquiped(20408) && player->HasEquiped(20407) && player->HasEquiped(20422) && player->GetReputationRank(609) >= REP_FRIENDLY) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_WIND_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(_GO->GetGOInfo()->questgiver.gossipID, _GO->GetGUID()); + } + else + { + player->CastSpell(player, 24803, false); + } + + return true; +} + +void SendActionMenu_go_wind_stone(Player *player, GameObject* _GO, uint32 action) +{ + _GO->SetGoState(GO_STATE_ACTIVE); + _GO->SetRespawnTime(900); + player->CLOSE_GOSSIP_MENU(); + + switch(action) + { + case GOSSIP_ACTION_INFO_DEF: + player->CastSpell(player,24762,false); + player->SummonCreature(RAND(DUKE_OF_CYNDERS, DUKE_OF_FATHOMS, DUKE_OF_SHARDS, DUKE_OF_ZEPHYRS), _GO->GetPositionX(),_GO->GetPositionY(),_GO->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); + player->DestroyItemCount(20422, 1, true, true); + player->DestroyItemCount(20406, 1, true, true); + player->DestroyItemCount(20407, 1, true, true); + player->DestroyItemCount(20408, 1, true, true); + break; + } +} + +bool GossipSelect_go_wind_stone(Player *player, GameObject* _GO, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_go_wind_stone(player, _GO, action); break; + } + return true; +} + +/////// +/// Greater Wind Stone +/////// + +#define GOSSIP_GREATER_WIND_STONE "The day of judgement has come, fiend! I challenge you to battle!" + +#define BARON_KAZUM 15205 +#define HIGH_MARSHAL_WHIRLAXIS 15204 +#define LORD_SKWOL 15305 +#define PRINCE_SKALDRENOX 15203 + +bool GossipHello_go_greater_wind_stone(Player *player, GameObject* _GO) +{ + if(player->HasEquiped(20406) && player->HasEquiped(20408) && player->HasEquiped(20407) && player->HasEquiped(20422) && player->HasEquiped(20451) && player->GetReputationRank(609) >= REP_REVERED) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_GREATER_WIND_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(_GO->GetGOInfo()->questgiver.gossipID, _GO->GetGUID()); + } + else + { + player->CastSpell(player, 24803, false); + } + + return true; +} + +void SendActionMenu_go_greater_wind_stone(Player *player, GameObject* _GO, uint32 action) +{ + _GO->SetGoState(GO_STATE_ACTIVE); + _GO->SetRespawnTime(18000); + player->CLOSE_GOSSIP_MENU(); + + switch(action) + { + case GOSSIP_ACTION_INFO_DEF: + player->CastSpell(player,24785,false); + player->SummonCreature(RAND(BARON_KAZUM, HIGH_MARSHAL_WHIRLAXIS, LORD_SKWOL, PRINCE_SKALDRENOX),_GO->GetPositionX(),_GO->GetPositionY(),_GO->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); + player->DestroyItemCount(20406, 1, true, true); + player->DestroyItemCount(20407, 1, true, true); + player->DestroyItemCount(20408, 1, true, true); + player->DestroyItemCount(20422, 1, true, true); + player->DestroyItemCount(20451, 1, true, true); + break; + } +} + +bool GossipSelect_go_greater_wind_stone(Player *player, GameObject* _GO, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_go_greater_wind_stone(player, _GO, action); break; + } + return true; +} + +/*###### +## go_silithyst_mound (id 181597) +######*/ +#define GOSSIP_TAKE_BUFF "[PH] Take the Silithyst" +#define SPELL_SILITHYST 29519 + +bool GOUse_go_silithyst_mound(Player* pPlayer, GameObject* pGO) +{ + pPlayer->PlayerTalkClass->ClearMenus(); + pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_TAKE_BUFF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(pGO->GetGOInfo()->questgiver.gossipID, pGO->GetGUID()); + return true; +} + +bool GOGossipSelect_go_silithyst_mound(Player* pPlayer, GameObject* pGO, uint32 Sender, uint32 action) +{ + switch(action) + { + + case GOSSIP_ACTION_INFO_DEF+1: + if(!pPlayer->HasAura(SPELL_SILITHYST)) + pPlayer->CastSpell(pPlayer,SPELL_SILITHYST,false); + pGO->Delete(); + break; + } + + pPlayer->CLOSE_GOSSIP_MENU(); + return true; +} + +/*##### +# Quest: A Pawn on the Eternal Board +#####*/ + +/* ContentData +A Pawn on the Eternal Board - creatures, gameobjects and defines +mob_qiraj_war_spawn : Adds that are summoned in the Qiraj gates battle. +npc_anachronos_the_ancient : Creature that controls the event. +npc_anachronos_quest_trigger: controls the spawning of the BG War mobs. +go_crystalline_tear : GameObject that begins the event and hands out quest +TO DO: get correct spell IDs and timings for spells cast upon dragon transformations +TO DO: Dragons should use the HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF) after transformation,but for some unknown reason it doesnt work. +EndContentData */ + +enum eEternalBoard +{ + QUEST_A_PAWN_ON_THE_ETERNAL_BOARD = 8519, + + FACTION_HOSTILE = 14, + FACTION_FRIENDLY = 35, + + C_ANACHRONOS = 15381, + C_FANDRAL_STAGHELM = 15382, + C_ARYGOS = 15380, + C_MERITHRA = 15378, + C_CAELESTRASZ = 15379, + + ANACHRONOS_SAY_1 = -1000623, + ANACHRONOS_SAY_2 = -1000624, + ANACHRONOS_SAY_3 = -1000625, + ANACHRONOS_SAY_4 = -1000626, + ANACHRONOS_SAY_5 = -1000627, + ANACHRONOS_SAY_6 = -1000628, + ANACHRONOS_SAY_7 = -1000629, + ANACHRONOS_SAY_8 = -1000630, + ANACHRONOS_SAY_9 = -1000631, + ANACHRONOS_SAY_10 = -1000632, + ANACHRONOS_EMOTE_1 = -1000633, + ANACHRONOS_EMOTE_2 = -1000634, + ANACHRONOS_EMOTE_3 = -1000635, + + FANDRAL_SAY_1 = -1000636, + FANDRAL_SAY_2 = -1000637, + FANDRAL_SAY_3 = -1000638, + FANDRAL_SAY_4 = -1000639, + FANDRAL_SAY_5 = -1000640, + FANDRAL_SAY_6 = -1000641, + FANDRAL_EMOTE_1 = -1000642, + FANDRAL_EMOTE_2 = -1000643, + + CAELESTRASZ_SAY_1 = -1000644, + CAELESTRASZ_SAY_2 = -1000645, + CAELESTRASZ_YELL_1 = -1000646, + + ARYGOS_SAY_1 = -1000647, + ARYGOS_YELL_1 = -1000648, + ARYGOS_EMOTE_1 = -1000649, + + MERITHRA_SAY_1 = -1000650, + MERITHRA_SAY_2 = -1000651, + MERITHRA_YELL_1 = -1000652, + MERITHRA_EMOTE_1 = -1000653, + + GO_GATE_OF_AHN_QIRAJ = 176146, + GO_GLYPH_OF_AHN_QIRAJ = 176148, + GO_ROOTS_OF_AHN_QIRAJ = 176147, + + LONG_FORGOTTEN_MEMORIES = 8305, + EVENT_AREA_RADIUS = 65, + EVENT_COOLDOWN = 500000 //in ms. appear after event completed or failed (should be = Adds despawn time) + +}; + +struct QuestCinematic +{ + int32 TextId; + uint32 Creature, Timer; +}; + +// Creature 0 - Anachronos, 1 - Fandral, 2 - Arygos, 3 - Merithra, 4 - Caelestrasz +static QuestCinematic EventAnim[]= +{ + {ANACHRONOS_SAY_1, 0, 2000}, + {FANDRAL_SAY_1, 1, 4000}, + {MERITHRA_EMOTE_1, 3, 500}, + {MERITHRA_SAY_1, 3, 500}, + {ARYGOS_EMOTE_1, 2, 2000}, + {CAELESTRASZ_SAY_1, 4, 8000}, + {MERITHRA_SAY_2, 3, 6000}, + {NULL,3,2000}, + {MERITHRA_YELL_1, 3, 2500}, + {NULL, 3, 3000},//Morph + {NULL,3,4000},//EmoteLiftoff + {NULL, 3, 4000},// spell + {NULL, 3, 1250},//fly + {NULL, 3, 250},//remove flags + {ARYGOS_SAY_1, 2, 3000}, + {NULL,3,2000}, + {ARYGOS_YELL_1, 2, 3000}, + {NULL, 3, 3000},//Morph + {NULL,3,4000},//EmoteLiftoff + {NULL, 3, 4000},// spell + {NULL, 3, 1000},//fly + {NULL, 3, 1000},//remove flags + {CAELESTRASZ_SAY_2, 4, 5000}, + {NULL,3,3000}, + {CAELESTRASZ_YELL_1, 4, 3000}, + {NULL, 3, 3000},//Morph + {NULL,3,4000},//EmoteLiftoff + {NULL, 3, 2500},// spell + {ANACHRONOS_SAY_2, 0, 2000}, + {NULL, 3, 250},//fly + {NULL, 3, 25},//remove flags + {FANDRAL_SAY_2, 1, 3000}, + {ANACHRONOS_SAY_3, 0, 10000},//Both run through the armies + {NULL,3,2000},// Sands will stop + {NULL,3,8000},// Summon Gate + {ANACHRONOS_SAY_4, 0, 4000}, + {NULL, 0, 2000},//spell 1-> Arcane cosmetic (Mobs freeze) + {NULL, 0, 5000}, //Spell 2-> Arcane long cosmetic (barrier appears) (Barrier -> Glyphs) + {NULL, 0, 7000},//BarrieR + {NULL, 0, 4000},//Glyphs + {ANACHRONOS_SAY_5, 0, 2000}, + {NULL, 0, 4000},// Roots + {FANDRAL_SAY_3, 1, 3000},//Root Text + {FANDRAL_EMOTE_1, 1, 3000},//falls knee + {ANACHRONOS_SAY_6, 0, 3000}, + {ANACHRONOS_SAY_7, 0, 3000}, + {ANACHRONOS_SAY_8, 0, 8000}, + {ANACHRONOS_EMOTE_1, 0, 1000},//Give Scepter + {FANDRAL_SAY_4, 1, 3000}, + {FANDRAL_SAY_5, 1, 3000},//->Equip hammer~Scepter, throw it at door + {FANDRAL_EMOTE_2, 1, 3000},//Throw hammer at door. + {ANACHRONOS_SAY_9, 0, 3000}, + {FANDRAL_SAY_6, 1, 3000},//fandral goes away + {ANACHRONOS_EMOTE_2, 0, 3000}, + {ANACHRONOS_EMOTE_3, 0, 3000}, + {NULL, 0, 2000}, + {NULL, 0, 2000}, + {NULL, 0, 4000}, + {ANACHRONOS_SAY_10, 0, 3000}, + {NULL, 0, 2000}, + {NULL, 0, 3000}, + {NULL, 0, 15000}, + {NULL, 0, 5000}, + {NULL, 0, 3500}, + {NULL, 0, 5000}, + {NULL, 0, 3500}, + {NULL, 0, 5000}, + {NULL, 0, NULL} +}; + +struct Location +{ + float x, y, z, o; +}; + +//Cordinates for Spawns +static Location SpawnLocation[]= +{ + //Kaldorei Infantry + {-8085, 1528, 2.61f, 3.141592f}, + {-8080, 1526, 2.61f, 3.141592f}, + {-8085, 1524, 2.61f, 3.141592f}, + {-8080, 1522, 2.61f, 3.141592f}, + {-8085, 1520, 2.61f, 3.141592f}, + + {-8085, 1524, 2.61f, 3.141592f}, + {-8080, 1522, 2.61f, 3.141592f}, + {-8085, 1520, 2.61f, 3.141592f}, + {-8080, 1518, 2.61f, 3.141592f}, + {-8085, 1516, 2.61f, 3.141592f}, + + {-8085, 1518, 2.61f, 3.141592f}, + {-8080, 1516, 2.61f, 3.141592f}, + {-8080, 1520, 2.61f, 3.141592f}, + {-8080, 1424, 2.61f, 3.141592f}, + {-8085, 1422, 2.61f, 3.141592f}, + // 2 waves of warriors + {-8082, 1528, 2.61f, 3.141592f}, + {-8078, 1525, 2.61f, 3.141592f}, + {-8082, 1524, 2.61f, 3.141592f}, + {-8078, 1526, 2.61f, 3.141592f}, + {-8082, 1527, 2.61f, 3.141592f}, + + {-8082, 1524, 2.61f, 3.141592f}, + {-8078, 1522, 2.61f, 3.141592f}, + {-8082, 1520, 2.61f, 3.141592f}, + {-8078, 1518, 2.61f, 3.141592f}, + {-8082, 1516, 2.61f, 3.141592f}, + + {-8082, 1523, 2.61f, 3.141592f}, + {-8078, 1521, 2.61f, 3.141592f}, + {-8082, 1528, 2.61f, 3.141592f}, + {-8078, 1519, 2.61f, 3.141592f}, + {-8082, 1526, 2.61f, 3.141592f}, + + {-8082, 1524, 2.61f, 3.141592f}, + {-8078, 1522, 2.61f, 3.141592f}, + {-8082, 1520, 2.61f, 3.141592f}, + {-8078, 1518, 2.61f, 3.141592f}, + {-8082, 1516, 2.61f, 3.141592f}, + + //Anubisath Conqueror + {-8088, 1510, 2.61f, 0}, + {-8084, 1520, 2.61f, 0}, + {-8088, 1530, 2.61f, 0}, + + //Qiraj Wasp + {-8080, 1513, 2.61f, 0}, + {-8082, 1523, 2.61f, 0}, + {-8085, 1518, 2.61f, 0}, + {-8082, 1516, 2.61f, 0}, + {-8085, 1520, 2.61f, 0}, + {-8080, 1528, 2.61f, 0}, + + {-8082, 1513, 2.61f, 0}, + {-8079, 1523, 2.61f, 0}, + {-8080, 1531, 2.61f, 0}, + {-8079, 1516, 2.61f, 0}, + {-8082, 1520, 2.61f, 0}, + {-8080, 1518, 2.61f, 0}, + + //Qiraj Tank + {-8081, 1514, 2.61f, 0}, + {-8081, 1520, 2.61f, 0}, + {-8081, 1526, 2.61f, 0}, + {-8081, 1512, 2.61f, 0}, + {-8082, 1520, 2.61f, 0}, + {-8081, 1528, 2.61f, 0}, + + //Anubisath Conqueror + {-8082, 1513, 2.61f, 3.141592f}, + {-8082, 1520, 2.61f, 3.141592f}, + {-8082, 1527, 2.61f, 3.141592f}, +}; + +struct WaveData +{ + uint8 SpawnCount, UsedSpawnPoint; + uint32 CreatureId, SpawnTimer, YellTimer, DespTimer; + int32 WaveTextId; +}; + +static WaveData WavesInfo[] = +{ + {30, 0, 15423, 0, 0,24000, NULL}, //Kaldorei Soldier + {3, 35, 15424, 0, 0,24000, NULL}, //Anubisath Conqueror + {12, 38, 15414, 0, 0,24000, NULL}, //Qiraji Wasps + {6, 50, 15422, 0, 0,24000, NULL}, //Qiraji Tanks + {15, 15, 15423, 0, 0,24000, NULL} //Kaldorei Soldier + +}; + +struct SpawnSpells +{ + uint32 Timer1, Timer2, SpellId; +}; + +static SpawnSpells SpawnCast[]=// +{ + {100000, 2000, 33652}, // Stop Time + {38500, 300000, 28528}, // Poison Cloud + {58000, 300000, 35871}, // Frost Debuff (need correct spell) + {80950, 300000, 42075}, // Fire Explosion (need correct spell however this one looks cool) +}; +/*##### +# npc_anachronos_the_ancient +######*/ + +struct npc_anachronos_the_ancientAI : public ScriptedAI +{ + npc_anachronos_the_ancientAI(Creature* c) : ScriptedAI(c) {} + + uint32 AnimationTimer; + uint8 AnimationCount; + + uint64 AnachronosQuestTriggerGUID; + uint64 MerithraGUID; + uint64 ArygosGUID; + uint64 CaelestraszGUID; + uint64 FandralGUID; + uint64 PlayerGUID; + bool eventEnd; + + void Reset() + { + AnimationTimer = 1500; + AnimationCount = 0; + AnachronosQuestTriggerGUID = 0; + MerithraGUID = 0; + ArygosGUID = 0; + CaelestraszGUID = 0; + FandralGUID = 0; + PlayerGUID = 0; + eventEnd = false; + + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void HandleAnimation() + { + Player* plr = Unit::GetPlayer(PlayerGUID); + if (!plr) + return; + + Unit* Fandral = GetClosestCreatureWithEntry(plr, C_FANDRAL_STAGHELM, 100, me); + Unit* Arygos = GetClosestCreatureWithEntry(plr, C_ARYGOS, 100,me); + Unit* Caelestrasz = GetClosestCreatureWithEntry(plr, C_CAELESTRASZ, 100, me); + Unit* Merithra = GetClosestCreatureWithEntry(plr, C_MERITHRA, 100,me); + + if (!Fandral || !Arygos || !Caelestrasz || !Merithra) + return; + + Unit* mob; + AnimationTimer = EventAnim[AnimationCount].Timer; + if (eventEnd == false) + { + switch(AnimationCount) + { + case 0: + DoScriptText(ANACHRONOS_SAY_1, me , Fandral); + break; + case 1: + Fandral->SetUInt64Value(UNIT_FIELD_TARGET, me->GetGUID()); + DoScriptText(FANDRAL_SAY_1, Fandral,me); + break; + case 2: + Fandral->SetUInt64Value(UNIT_FIELD_TARGET,NULL); + DoScriptText(MERITHRA_EMOTE_1,Merithra); + break; + case 3: + DoScriptText(MERITHRA_SAY_1,Merithra); + break; + case 4: + DoScriptText(ARYGOS_EMOTE_1,Arygos); + break; + case 5: + Caelestrasz->SetUInt64Value(UNIT_FIELD_TARGET, Fandral->GetGUID()); + DoScriptText(CAELESTRASZ_SAY_1, Caelestrasz); + break; + case 6: + DoScriptText(MERITHRA_SAY_2, Merithra); + break; + case 7: + Caelestrasz->SetUInt64Value(UNIT_FIELD_TARGET, NULL); + Merithra->GetMotionMaster()->MoveCharge(-8065,1530,2.61f,10); + break; + case 8: + DoScriptText(MERITHRA_YELL_1,Merithra); + break; + case 9: + Merithra->CastSpell(Merithra,25105,true); + break; + case 10: + Merithra->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + Merithra->AddUnitMovementFlag(MOVEFLAG_LEVITATING); + Merithra->GetMotionMaster()->MoveCharge(-8065,1530,6.61f,3); + break; + case 11: + Merithra->CastSpell(Merithra,24818,false); + break; + case 12: + Merithra->GetMotionMaster()->MoveCharge(-8100,1530,50,42); + break; + case 13: + break; + case 14: + DoScriptText(ARYGOS_SAY_1,Arygos); + Merithra->SetVisibility(VISIBILITY_OFF); + break; + case 15: + Arygos->GetMotionMaster()->MoveCharge(-8065,1530,2.61f,10); + Merithra->GetMotionMaster()->MoveCharge(-8034.535f,1535.14f,2.61f,42); + break; + case 16: + DoScriptText(ARYGOS_YELL_1, Arygos); + break; + case 17: + Arygos->CastSpell(Arygos,25107,true); + break; + case 18: + Arygos->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + Arygos->AddUnitMovementFlag(MOVEFLAG_LEVITATING); + Arygos->GetMotionMaster()->MoveCharge(-8065,1530,6.61f,42); + break; + case 19: + Arygos->CastSpell(Arygos,44799,false); + break; + case 20: + Arygos->GetMotionMaster()->MoveCharge(-8095,1530,50,42); + break; + case 21: + break; + case 22: + DoScriptText(CAELESTRASZ_SAY_2,Caelestrasz, Fandral); + break; + case 23: + Caelestrasz->GetMotionMaster()->MoveCharge(-8065,1530,2.61f,10); + Arygos->SetVisibility(VISIBILITY_OFF); + Arygos->GetMotionMaster()->MoveCharge(-8034.535f,1535.14f,2.61f,10); + break; + case 24: + DoScriptText(CAELESTRASZ_YELL_1, Caelestrasz); + break; + case 25: + Caelestrasz->CastSpell(Caelestrasz,25106,true); + break; + case 26: + Caelestrasz->HandleEmoteCommand(254); + Caelestrasz->AddUnitMovementFlag(MOVEFLAG_LEVITATING); + Caelestrasz->GetMotionMaster()->MoveCharge(-8065,1530,7.61f,4); + break; + case 27: + Caelestrasz->CastSpell(Caelestrasz,43294,false); + break; + case 28: + DoScriptText(ANACHRONOS_SAY_2,me, Fandral); + break; + case 29: + Caelestrasz->GetMotionMaster()->MoveCharge(-8095,1530,50,42); + DoScriptText(FANDRAL_SAY_2, Fandral, me); + break; + case 30: + break; + case 31: + DoScriptText(ANACHRONOS_SAY_3, me, Fandral); + break; + case 32: + Caelestrasz->SetVisibility(VISIBILITY_OFF); + Caelestrasz->GetMotionMaster()->MoveCharge(-8034.535f,1535.14f,2.61f,42); + Fandral->GetMotionMaster()->MoveCharge(-8108,1529,2.77f,8); + me->GetMotionMaster()->MoveCharge(-8113,1525,2.77f,8); + break;//both run to the gate + case 33: + DoScriptText(ANACHRONOS_SAY_4, me); + Caelestrasz->GetMotionMaster()->MoveCharge(-8050,1473,65,15); + break; //Text: sands will stop + case 34: + DoCast(plr, 23017, true);//Arcane Channeling + break; + case 35: + me->CastSpell(-8088,1520.43f,2.67f,25158,true); + break; + case 36: + DoCast(plr, 25159, true); + break; + case 37: + me->SummonGameObject(GO_GATE_OF_AHN_QIRAJ,-8130,1525,17.5f,0,0,0,0,0,0); + break; + case 38: + DoCast(plr, 25166, true); + me->SummonGameObject(GO_GLYPH_OF_AHN_QIRAJ,-8130,1525,17.5f,0,0,0,0,0,0); + break; + case 39: + DoScriptText(ANACHRONOS_SAY_5, me, Fandral); + break; + case 40: + Fandral->CastSpell(me, 25167, true); + break; + case 41: + Fandral->SummonGameObject(GO_ROOTS_OF_AHN_QIRAJ,-8130,1525,17.5f,0,0,0,0,0,0); + DoScriptText(FANDRAL_SAY_3, Fandral); + break; + case 42: + me->CastStop(); + DoScriptText(FANDRAL_EMOTE_1, Fandral); + break; + case 43: + Fandral->CastStop(); + break; + case 44: + DoScriptText(ANACHRONOS_SAY_6, me); + break; + case 45: + DoScriptText(ANACHRONOS_SAY_7, me); + break; + case 46: + DoScriptText(ANACHRONOS_SAY_8, me); + me->GetMotionMaster()->MoveCharge(-8110,1527,2.77f,4); + break; + case 47: + DoScriptText(ANACHRONOS_EMOTE_1, me); + break; + case 48: + DoScriptText(FANDRAL_SAY_4,Fandral,me); + break; + case 49: + DoScriptText(FANDRAL_SAY_5,Fandral,me); + break; + case 50: + DoScriptText(FANDRAL_EMOTE_2,Fandral); + Fandral->CastSpell(-8127,1525,17.5f,33806,true); + break; + case 51: + { + uint32 loopbreaker = 0; + uint32 entries[4] = { 15423, 15424, 15414, 15422 }; + for (uint8 i = 0; i < 4; i++) + { + mob = GetClosestCreatureWithEntry(plr, entries[i],300,true); + loopbreaker = 0; + while (mob != NULL && loopbreaker < 67) + { + mob->RemoveFromWorld(); + mob = GetClosestCreatureWithEntry(plr, entries[i],300,true); + loopbreaker++; + } + mob = GetClosestCreatureWithEntry(plr, entries[i],300,false); + loopbreaker = 0; + while (mob != NULL && loopbreaker < 67) + { + mob->RemoveFromWorld(); + mob = GetClosestCreatureWithEntry(plr, entries[i],300,false); + loopbreaker++; + } + } + break; + } + case 52: + Fandral->GetMotionMaster()->MoveCharge(-8028.75f, 1538.795f, 2.61f,4); + DoScriptText(ANACHRONOS_SAY_9, me,Fandral); + break; + case 53: + DoScriptText(FANDRAL_SAY_6,Fandral); + break; + case 54: + DoScriptText(ANACHRONOS_EMOTE_2,me); + break; + case 55: + Fandral->SetVisibility(VISIBILITY_OFF); + break; + case 56: + DoScriptText(ANACHRONOS_EMOTE_3, me); + me->GetMotionMaster()->MoveCharge(-8116,1522,3.65f,4); + break; + case 57: + me->GetMotionMaster()->MoveCharge(-8116.7f,1527,3.7f,4); + break; + case 58: + me->GetMotionMaster()->MoveCharge(-8112.67f,1529.9f,2.86f,4); + break; + case 59: + me->GetMotionMaster()->MoveCharge(-8117.99f,1532.24f,3.94f,4); + break; + case 60: + if (plr) + DoScriptText(ANACHRONOS_SAY_10, me,plr); + me->GetMotionMaster()->MoveCharge(-8113.46f,1524.16f,2.89f,4); + break; + case 61: + me->GetMotionMaster()->MoveCharge(-8057.1f,1470.32f,2.61f,6); + if (plr->IsInRange(me,0,15)) + plr->GroupEventHappens(QUEST_A_PAWN_ON_THE_ETERNAL_BOARD ,me); + break; + case 62: + me->SetDisplayId(15500); + break; + case 63: + me->HandleEmoteCommand(254); + me->AddUnitMovementFlag(MOVEFLAG_LEVITATING); + break; + case 64: + me->GetMotionMaster()->MoveCharge(-8000,1400,150,9); + break; + case 65: + me->SetVisibility(VISIBILITY_OFF); + if (Creature* AnachronosQuestTrigger = (Unit::GetCreature(*me, AnachronosQuestTriggerGUID))) + { + DoScriptText(ARYGOS_YELL_1,me); + AnachronosQuestTrigger->AI()->EnterEvadeMode(); + eventEnd=true; + } + break; + } + } + ++AnimationCount; + } + + void UpdateAI(const uint32 diff) + { + if (AnimationTimer) + { + if (AnimationTimer <= diff) + HandleAnimation(); + else AnimationTimer -= diff; + } + if (AnimationCount < 65) + me->CombatStop(); + if (AnimationCount == 65 || eventEnd) + me->AI()->EnterEvadeMode(); + } +}; + +/*###### +# mob_qiraj_war_spawn +######*/ + +struct mob_qiraj_war_spawnAI : public ScriptedAI +{ + mob_qiraj_war_spawnAI(Creature* c) : ScriptedAI(c) {} + + uint64 MobGUID; + uint64 PlayerGUID; + uint32 SpellTimer1, SpellTimer2, SpellTimer3,SpellTimer4; + bool Timers; + bool hasTarget; + + void Reset() + { + MobGUID = 0; + PlayerGUID = 0; + Timers = false; + hasTarget = false; + } + + void EnterCombat(Unit* /*who*/) {} + void JustDied(Unit* /*slayer*/); + + void UpdateAI(const uint32 diff) + { + Unit *pTarget = NULL; + //Player* plr = me->GetPlayer(PlayerGUID); + + if (!Timers) + { + if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) //all but Kaldorei Soldiers + { + SpellTimer1 = SpawnCast[1].Timer1; + SpellTimer2 = SpawnCast[2].Timer1; + SpellTimer3 = SpawnCast[3].Timer1; + } + if (me->GetEntry() == 15423 || me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) + SpellTimer4 = SpawnCast[0].Timer1; + Timers = true; + } + if (me->GetEntry() == 15424 || me->GetEntry() == 15422|| me->GetEntry() == 15414) + { + if (SpellTimer1 <= diff) + { + DoCast(me, SpawnCast[1].SpellId); + DoCast(me, 24319); + SpellTimer1 = SpawnCast[1].Timer2; + } else SpellTimer1 -= diff; + if (SpellTimer2 <= diff) + { + DoCast(me, SpawnCast[2].SpellId); + SpellTimer2 = SpawnCast[2].Timer2; + } else SpellTimer2 -= diff; + if (SpellTimer3 <= diff) + { + DoCast(me, SpawnCast[3].SpellId); + SpellTimer3 = SpawnCast[3].Timer2; + } else SpellTimer3 -= diff; + } + if (me->GetEntry() == 15423 || me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) + { + if (SpellTimer4 <= diff) + { + me->RemoveAllAttackers(); + me->AttackStop(); + DoCast(me, 15533); + SpellTimer4 = SpawnCast[0].Timer2; + } else SpellTimer4 -= diff; + } + if (!hasTarget) + { + if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) + pTarget = GetClosestCreatureWithEntry(me, 15423,20,true); + if (me->GetEntry() == 15423) + { + uint8 tar = urand(0,2); + + if (tar == 0) + pTarget = GetClosestCreatureWithEntry(me, 15422,20,true); + else if (tar == 1) + pTarget = GetClosestCreatureWithEntry(me, 15424, 20, true); + else if (tar == 2) + pTarget = GetClosestCreatureWithEntry(me, 15414,20,true); + } + hasTarget = true; + if (pTarget) + me->AI()->AttackStart(pTarget); + } + if (!(GetClosestCreatureWithEntry(me, 15379, 60, true))) + DoCast(me, 33652); + + if (!UpdateVictim()) + { + hasTarget = false; + return; + } + + DoMeleeAttackIfReady(); + } +}; + +/*##### +# npc_anachronos_quest_trigger +#####*/ + +struct npc_anachronos_quest_triggerAI : public ScriptedAI +{ + npc_anachronos_quest_triggerAI(Creature* c) : ScriptedAI(c) {} + + uint64 PlayerGUID; + + uint32 WaveTimer; + uint32 AnnounceTimer; + + int8 LiveCount; + uint8 WaveCount; + + bool EventStarted; + bool Announced; + bool Failed; + + void Reset() + { + PlayerGUID = 0; + + WaveTimer = 2000; + AnnounceTimer = 1000; + LiveCount = 0; + WaveCount = 0; + + EventStarted = false; + Announced = false; + Failed = false; + + me->SetVisibility(VISIBILITY_OFF); + } + + void SummonNextWave() + { + //uint8 count = WavesInfo[WaveCount].SpawnCount; + uint8 locIndex = WavesInfo[WaveCount].UsedSpawnPoint; + //uint8 KaldoreiSoldierCount = 0; + //uint8 AnubisathConquerorCount = 0; + //uint8 QirajiWaspCount = 0; + for (uint8 i = 0; i < 67; ++i) + { + Creature* Spawn = NULL; + float X = SpawnLocation[locIndex + i].x; + float Y = SpawnLocation[locIndex + i].y; + float Z = SpawnLocation[locIndex + i].z; + float O = SpawnLocation[locIndex + i].o; + uint32 desptimer = WavesInfo[WaveCount].DespTimer; + Spawn = me->SummonCreature(WavesInfo[WaveCount].CreatureId, X, Y, Z, O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, desptimer); + + if (Spawn) + { + Spawn->LoadCreaturesAddon(); + if (Spawn->GetGUID() == 15423) + Spawn->SetDisplayId(15427+rand()%4); + if (i >= 30) WaveCount = 1; + if (i >= 33) WaveCount = 2; + if (i >= 45) WaveCount = 3; + if (i >= 51) WaveCount = 4; + + if (WaveCount < 5) //1-4 Wave + { + CAST_AI(mob_qiraj_war_spawnAI, Spawn->AI())->MobGUID = me->GetGUID(); + CAST_AI(mob_qiraj_war_spawnAI, Spawn->AI())->PlayerGUID = PlayerGUID; + } + } + } + WaveTimer = WavesInfo[WaveCount].SpawnTimer; + AnnounceTimer = WavesInfo[WaveCount].YellTimer; + } + + void CheckEventFail() + { + Player* pPlayer = Unit::GetPlayer(PlayerGUID); + + if (!pPlayer) + return; + + if (Group *EventGroup = pPlayer->GetGroup()) + { + Player* GroupMember; + + uint8 GroupMemberCount = 0; + uint8 DeadMemberCount = 0; + uint8 FailedMemberCount = 0; + + const Group::MemberSlotList members = EventGroup->GetMemberSlots(); + + for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr) + { + GroupMember = (Unit::GetPlayer(itr->guid)); + + if (!GroupMember) + continue; + + if (!GroupMember->IsWithinDistInMap(me, EVENT_AREA_RADIUS) && GroupMember->GetQuestStatus(QUEST_A_PAWN_ON_THE_ETERNAL_BOARD) == QUEST_STATUS_INCOMPLETE) + { + GroupMember->FailQuest(QUEST_A_PAWN_ON_THE_ETERNAL_BOARD); + GroupMember->SetQuestStatus(QUEST_A_PAWN_ON_THE_ETERNAL_BOARD, QUEST_STATUS_NONE); + ++FailedMemberCount; + } + ++GroupMemberCount; + + if (GroupMember->isDead()) + ++DeadMemberCount; + } + + if (GroupMemberCount == FailedMemberCount || !pPlayer->IsWithinDistInMap(me, EVENT_AREA_RADIUS)) + Failed = true; //only so event can restart + } + } + void LiveCounter() + { + --LiveCount; + if (!LiveCount) + Announced = false; + } + + void UpdateAI(const uint32 diff) + { + if (!PlayerGUID || !EventStarted) + return; + + if (WaveCount < 4) + { + if (!Announced && AnnounceTimer <= diff) + { + DoScriptText(WavesInfo[WaveCount].WaveTextId, me); + Announced = true; + } else AnnounceTimer -= diff; + + if (WaveTimer <= diff) + SummonNextWave(); + else WaveTimer -= diff; + } + CheckEventFail(); + if (WaveCount == 4 || Failed) + EnterEvadeMode(); + }; +}; + +void mob_qiraj_war_spawnAI::JustDied(Unit* /*slayer*/) +{ + me->RemoveCorpse(); + if (Creature* Mob = (Unit::GetCreature(*me, MobGUID))) + CAST_AI(npc_anachronos_quest_triggerAI, Mob->AI())->LiveCounter(); +}; + +/*##### +# go_crystalline_tear +######*/ + +bool Hello_go_crystalline_tear(Player* pPlayer, GameObject* pGO) +{ + if (pGO->GetGoType() == 2) + { + pPlayer->PrepareQuestMenu(pGO->GetGUID()); + pPlayer->SendPreparedQuest(pGO->GetGUID()); + } + + if (pPlayer->GetQuestStatus(LONG_FORGOTTEN_MEMORIES) != QUEST_STATUS_COMPLETE) + pPlayer->AreaExploredOrEventHappens(LONG_FORGOTTEN_MEMORIES); + return true; +} + +bool OnQuestAccept(Player* plr, GameObject* go, Quest const* quest) +{ + if (quest->GetQuestId() == QUEST_A_PAWN_ON_THE_ETERNAL_BOARD) + { + + if (Unit* Anachronos_Quest_Trigger = GetClosestCreatureWithEntry(go, 15454, 100, plr)) + { + + Unit *Merithra = Anachronos_Quest_Trigger->SummonCreature(15378,-8034.535f,1535.14f,2.61f,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000); + Unit *Caelestrasz = Anachronos_Quest_Trigger->SummonCreature(15379,-8032.767f, 1533.148f,2.61f, 1.5f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000); + Unit *Arygos = Anachronos_Quest_Trigger->SummonCreature(15380,-8034.52f, 1537.843f, 2.61f, 5.7f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000); + /* Unit *Fandral = */ Anachronos_Quest_Trigger->SummonCreature(15382,-8028.462f, 1535.843f, 2.61f, 3.141592f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000); + Creature *Anachronos = Anachronos_Quest_Trigger->SummonCreature(15381,-8028.75f, 1538.795f, 2.61f, 4,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,220000); + + if (Merithra) + { + Merithra->SetUInt32Value(UNIT_NPC_FLAGS, 0); + Merithra->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + Merithra->SetDisplayId(15420); + Merithra->setFaction(35); + } + + if (Caelestrasz) + { + Caelestrasz->SetUInt32Value(UNIT_NPC_FLAGS, 0); + Caelestrasz->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + Caelestrasz->SetDisplayId(15419); + Caelestrasz->setFaction(35); + } + + if (Arygos) + { + Arygos->SetUInt32Value(UNIT_NPC_FLAGS, 0); + Arygos->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + Arygos->SetDisplayId(15418); + Arygos->setFaction(35); + } + + if (Anachronos) + { + CAST_AI(/*npc_anachronos_the_ancient::*/npc_anachronos_the_ancientAI, Anachronos->AI())->PlayerGUID = plr->GetGUID(); + CAST_AI(/*npc_anachronos_quest_trigger::*/npc_anachronos_quest_triggerAI, CAST_CRE(Anachronos_Quest_Trigger)->AI())->Failed=false; + CAST_AI(/*npc_anachronos_quest_trigger::*/npc_anachronos_quest_triggerAI, CAST_CRE(Anachronos_Quest_Trigger)->AI())->PlayerGUID = plr->GetGUID(); + CAST_AI(/*npc_anachronos_quest_trigger::*/npc_anachronos_quest_triggerAI, CAST_CRE(Anachronos_Quest_Trigger)->AI())->EventStarted=true; + CAST_AI(/*npc_anachronos_quest_trigger::*/npc_anachronos_quest_triggerAI, CAST_CRE(Anachronos_Quest_Trigger)->AI())->Announced=true; + } + } + } + return true; +} + +CreatureAI* Getmob_qiraj_war_spawnAI(Creature* pCreature) +{ + return new mob_qiraj_war_spawnAI (pCreature); +} + +CreatureAI* Getnpc_anachronos_quest_triggerAI(Creature* pCreature) +{ + return new npc_anachronos_quest_triggerAI (pCreature); +} + +CreatureAI* Getnpc_anachronos_the_ancientAI(Creature* pCreature) +{ + return new npc_anachronos_the_ancientAI (pCreature); +} + +/*### +## +####*/ + +void AddSC_silithus() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_highlord_demitrian"; + newscript->pGossipHello = &GossipHello_npc_highlord_demitrian; + newscript->pGossipSelect = &GossipSelect_npc_highlord_demitrian; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npcs_rutgar_and_frankal"; + newscript->pGossipHello = &GossipHello_npcs_rutgar_and_frankal; + newscript->pGossipSelect = &GossipSelect_npcs_rutgar_and_frankal; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_cenarion_scout_jalia"; + newscript->pGossipHello = &GossipHello_npc_cenarion_scout_jalia; + newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_jalia; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_cenarion_scout_azenel"; + newscript->pGossipHello = &GossipHello_npc_cenarion_scout_azenel; + newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_azenel; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_cenarion_scout_landion"; + newscript->pGossipHello = &GossipHello_npc_cenarion_scout_landion; + newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_landion; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_lesser_wind_stone"; + newscript->pGOUse = &GossipHello_go_lesser_wind_stone; + newscript->pGossipSelectGO = &GossipSelect_go_lesser_wind_stone; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_wind_stone"; + newscript->pGOUse = &GossipHello_go_wind_stone; + newscript->pGossipSelectGO = &GossipSelect_go_wind_stone; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_greater_wind_stone"; + newscript->pGOUse = &GossipHello_go_greater_wind_stone; + newscript->pGossipSelectGO = &GossipSelect_go_greater_wind_stone; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_silithyst_mound"; + newscript->pGOUse = &GOUse_go_silithyst_mound; + newscript->pGossipSelectGO = &GOGossipSelect_go_silithyst_mound; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_crystalline_tear"; + newscript->pGOUse = &Hello_go_crystalline_tear; + newscript->pQuestAcceptGO = &OnQuestAccept; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_qiraj_war_spawn"; + newscript->GetAI = Getmob_qiraj_war_spawnAI; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_anachronos_quest_trigger"; + newscript->GetAI = Getnpc_anachronos_quest_triggerAI; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_anachronos_the_ancient"; + newscript->GetAI = Getnpc_anachronos_the_ancientAI; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp b/src/scripts/scripts/Kalimdor/stonetalon_mountains/stonetalon_mountains.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp rename to src/scripts/scripts/Kalimdor/stonetalon_mountains/stonetalon_mountains.cpp index d04205678..fe5bef7a6 --- a/src/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp +++ b/src/scripts/scripts/Kalimdor/stonetalon_mountains/stonetalon_mountains.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/tanaris/tanaris.cpp b/src/scripts/scripts/Kalimdor/tanaris/tanaris.cpp old mode 100755 new mode 100644 similarity index 70% rename from src/scripts/scripts/zone/tanaris/tanaris.cpp rename to src/scripts/scripts/Kalimdor/tanaris/tanaris.cpp index 28de64cef..653d69829 --- a/src/scripts/scripts/zone/tanaris/tanaris.cpp +++ b/src/scripts/scripts/Kalimdor/tanaris/tanaris.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -218,36 +220,7 @@ struct npc_custodian_of_timeAI : public npc_escortAI CreatureAI* GetAI_npc_custodian_of_time(Creature* pCreature) { - npc_custodian_of_timeAI* custodian_of_timeAI = new npc_custodian_of_timeAI(pCreature); - - custodian_of_timeAI->AddWaypoint(0, -8374.93,-4250.21, -204.38,5000); - custodian_of_timeAI->AddWaypoint(1, -8374.93,-4250.21, -204.38,16000); - custodian_of_timeAI->AddWaypoint(2, -8374.93,-4250.21, -204.38,10000); - custodian_of_timeAI->AddWaypoint(3, -8374.93,-4250.21, -204.38,2000); - custodian_of_timeAI->AddWaypoint(4, -8439.40,-4180.05, -209.25); - custodian_of_timeAI->AddWaypoint(5, -8437.82,-4120.84, -208.59,10000); - custodian_of_timeAI->AddWaypoint(6, -8437.82,-4120.84, -208.59,16000); - custodian_of_timeAI->AddWaypoint(7, -8437.82,-4120.84, -208.59,13000); - custodian_of_timeAI->AddWaypoint(8, -8437.82,-4120.84, -208.59,18000); - custodian_of_timeAI->AddWaypoint(9, -8437.82,-4120.84, -208.59,15000); - custodian_of_timeAI->AddWaypoint(10, -8437.82,-4120.84, -208.59,2000); - custodian_of_timeAI->AddWaypoint(11, -8467.26,-4198.63, -214.21); - custodian_of_timeAI->AddWaypoint(12, -8667.76,-4252.13, -209.56); - custodian_of_timeAI->AddWaypoint(13, -8703.71,-4234.58, -209.5,14000); - custodian_of_timeAI->AddWaypoint(14, -8703.71,-4234.58, -209.5,2000); - custodian_of_timeAI->AddWaypoint(15, -8642.81,-4304.37, -209.57); - custodian_of_timeAI->AddWaypoint(16, -8649.06,-4394.36, -208.46,6000); - custodian_of_timeAI->AddWaypoint(17, -8649.06,-4394.36, -208.46,18000); - custodian_of_timeAI->AddWaypoint(18, -8649.06,-4394.36, -208.46,2000); - custodian_of_timeAI->AddWaypoint(19, -8468.72,-4437.67, -215.45); - custodian_of_timeAI->AddWaypoint(20, -8427.54,-4426, -211.13); - custodian_of_timeAI->AddWaypoint(21, -8364.83,-4393.32, -205.91); - custodian_of_timeAI->AddWaypoint(22, -8304.54,-4357.2, -208.2,18000); - custodian_of_timeAI->AddWaypoint(23, -8304.54,-4357.2, -208.2,2000); - custodian_of_timeAI->AddWaypoint(24, -8375.42,-4250.41, -205.14,5000); - custodian_of_timeAI->AddWaypoint(25, -8375.42,-4250.41, -205.14,5000); - - return (CreatureAI*)custodian_of_timeAI; + return new npc_custodian_of_timeAI(pCreature); } /*###### @@ -393,6 +366,21 @@ struct npc_OOX17AI : public npc_escortAI { npc_OOX17AI(Creature *c) : npc_escortAI(c) {} + void Reset() {} + + void EnterCombat(Unit* /*who*/) + { + DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), me); + } + + void JustSummoned(Creature* summoned) + { + if (summoned->GetEntry() == SPAWN_SECOND_1) + DoScriptText(SAY_OOX17_AMBUSH_REPLY, summoned); + + summoned->AI()->AttackStart(me); + } + void WaypointReached(uint32 i) { Player* pPlayer = GetPlayerForEscort(); @@ -400,24 +388,57 @@ struct npc_OOX17AI : public npc_escortAI if (!pPlayer) return; - switch(i) { + switch(i) + { case 23: - me->SummonCreature(SPAWN_FIRST, -8350.96, -4445.79, 10.10, 6.20, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); - me->SummonCreature(SPAWN_FIRST, -8355.96, -4447.79, 10.10, 6.27, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); - me->SummonCreature(SPAWN_FIRST, -8353.96, -4442.79, 10.10, 6.08, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); DoScriptText(SAY_OOX_AMBUSH, me); break; - - case 56: - me->SummonCreature(SPAWN_SECOND_1, -7510.07, -4795.50, 9.35, 6.06, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); - me->SummonCreature(SPAWN_SECOND_2, -7515.07, -4797.50, 9.35, 6.22, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); - me->SummonCreature(SPAWN_SECOND_2, -7518.07, -4792.50, 9.35, 6.22, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + case 24: + for (uint8 i = 0; i < 3; ++i) + { + float x, y, z; + switch (i) + { + case 0: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 0.0f); + me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 1: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 2.0f); + me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 2: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 4.0f); + me->SummonCreature(SPAWN_FIRST, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + } + break; + case 57: DoScriptText(SAY_OOX_AMBUSH, me); - if (Unit* scoff = FindCreature(SPAWN_SECOND_2, 30, me)) - DoScriptText(SAY_OOX17_AMBUSH_REPLY, scoff); break; - - case 86: + case 58: + for (uint8 i = 0; i < 3; ++i) + { + float x, y, z; + switch (i) + { + case 0: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 0.0f); + me->SummonCreature(SPAWN_SECOND_1, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 1: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 2.0f); + me->SummonCreature(SPAWN_SECOND_2, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 2: + me->GetNearPoint(x, y, z, 0.0f, 15.0f, 4.0f); + me->SummonCreature(SPAWN_SECOND_2, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + } + break; + case 88: if (pPlayer) { DoScriptText(SAY_OOX_END, me); @@ -426,129 +447,24 @@ struct npc_OOX17AI : public npc_escortAI break; } } - - void Reset(){} - - void EnterCombat(Unit* /*who*/) - { - DoScriptText(RAND(SAY_OOX_AGGRO1,SAY_OOX_AGGRO2), me); - } - - void JustSummoned(Creature* summoned) - { - summoned->AI()->AttackStart(me); - } }; bool QuestAccept_npc_OOX17(Player* pPlayer, Creature* pCreature, Quest const* quest) { if (quest->GetQuestId() == Q_OOX17) { - pCreature->setFaction(113); - pCreature->SetHealth(pCreature->GetMaxHealth()); - pCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + pCreature->SetStandState(UNIT_STAND_STATE_STAND); DoScriptText(SAY_OOX_START, pCreature); if (npc_escortAI* pEscortAI = CAST_AI(npc_OOX17AI, pCreature->AI())) - pEscortAI->Start(true, false, pPlayer->GetGUID()); + pEscortAI->Start(true, true, pPlayer->GetGUID()); } return true; } CreatureAI* GetAI_npc_OOX17(Creature* pCreature) { - npc_OOX17AI* OOX17AI = new npc_OOX17AI(pCreature); - - OOX17AI->AddWaypoint(0, -8843.73, -4374.44, 43.71); - OOX17AI->AddWaypoint(1, -8834.68, -4373.88, 45.71); - OOX17AI->AddWaypoint(2, -8832.93, -4373.85, 45.67); - OOX17AI->AddWaypoint(3, -8829.21, -4373.72, 44.14); - OOX17AI->AddWaypoint(4, -8825.10, -4373.56, 41.44); - OOX17AI->AddWaypoint(5, -8818.88, -4372.75, 36.43); - OOX17AI->AddWaypoint(6, -8803.37, -4369.68, 30.06); - OOX17AI->AddWaypoint(7, -8786.68, -4366.18, 23.91); - OOX17AI->AddWaypoint(8, -8764.97, -4366.94, 25.23); - OOX17AI->AddWaypoint(9, -8745.49, -4363.16, 22.80); - OOX17AI->AddWaypoint(10, -8724.13, -4353.55, 20.72); - OOX17AI->AddWaypoint(11, -8706.77, -4346.14, 16.12); - OOX17AI->AddWaypoint(12, -8688.27, -4372.85, 13.64); - OOX17AI->AddWaypoint(13, -8668.76, -4380.38, 11.69); - OOX17AI->AddWaypoint(14, -8645.19, -4388.62, 12.56); - OOX17AI->AddWaypoint(15, -8614.73, -4398.60, 9.86); - OOX17AI->AddWaypoint(16, -8560.33, -4411.27, 13.17); - OOX17AI->AddWaypoint(17, -8536.45, -4416.49, 11.84); - OOX17AI->AddWaypoint(18, -8503.48, -4423.70, 13.59); - OOX17AI->AddWaypoint(19, -8471.91, -4430.60, 9.56); - OOX17AI->AddWaypoint(20, -8441.36, -4435.31, 9.40); - OOX17AI->AddWaypoint(21, -8403.41, -4441.16, 11.83); - OOX17AI->AddWaypoint(22, -8371.24, -4446.13, 9.47); - OOX17AI->AddWaypoint(23, -8353.96, -4448.79, 10.10); //Scorpid - OOX17AI->AddWaypoint(24, -8336.40, -4446.39, 8.98); - OOX17AI->AddWaypoint(25, -8303.78, -4441.96, 11.89); - OOX17AI->AddWaypoint(26, -8272.20, -4433.31, 9.60); - OOX17AI->AddWaypoint(27, -8224.76, -4419.39, 13.03); - OOX17AI->AddWaypoint(28, -8193.31, -4406.04, 10.17); - OOX17AI->AddWaypoint(29, -8155.65, -4397.74, 8.99); - OOX17AI->AddWaypoint(30, -8129.25, -4394.57, 10.92); - OOX17AI->AddWaypoint(31, -8104.86, -4399.03, 8.93); - OOX17AI->AddWaypoint(32, -8063.15, -4423.40, 10.07); - OOX17AI->AddWaypoint(33, -8032.15, -4443.47, 9.97); - OOX17AI->AddWaypoint(34, -8015.39, -4454.33, 9.39); - OOX17AI->AddWaypoint(35, -7981.64, -4482.44, 10.32); - OOX17AI->AddWaypoint(36, -7958.83, -4503.98, 9.69); - OOX17AI->AddWaypoint(37, -7932.45, -4528.91, 10.08); - OOX17AI->AddWaypoint(38, -7904.09, -4566.67, 12.59); - OOX17AI->AddWaypoint(39, -7883.33, -4593.91, 12.15); - OOX17AI->AddWaypoint(40, -7862.83, -4624.53, 10.21); - OOX17AI->AddWaypoint(41, -7840.79, -4654.26, 9.45); - OOX17AI->AddWaypoint(42, -7826.17, -4673.99, 10.61); - OOX17AI->AddWaypoint(43, -7807.86, -4698.69, 11.24); - OOX17AI->AddWaypoint(44, -7793.88, -4717.55, 10.48); - OOX17AI->AddWaypoint(45, -7778.68, -4738.05, 8.89); - OOX17AI->AddWaypoint(46, -7746.42, -4780.39, 9.84); - OOX17AI->AddWaypoint(47, -7724.11, -4772.75, 10.28); - OOX17AI->AddWaypoint(48, -7697.98, -4763.80, 9.52); - OOX17AI->AddWaypoint(49, -7665.33, -4752.62, 10.56); - OOX17AI->AddWaypoint(50, -7641.47, -4750.33, 8.94); - OOX17AI->AddWaypoint(51, -7620.08, -4753.96, 8.93); - OOX17AI->AddWaypoint(52, -7603.15, -4757.53, 9.06); - OOX17AI->AddWaypoint(53, -7579.43, -4767.07, 8.93); - OOX17AI->AddWaypoint(54, -7558.51, -4779.01, 9.64); - OOX17AI->AddWaypoint(55, -7536.40, -4789.32, 8.92); - OOX17AI->AddWaypoint(56, -7512.07, -4793.50, 9.35); //Wastewander - OOX17AI->AddWaypoint(57, -7490.79, -4788.80, 10.53); - OOX17AI->AddWaypoint(58, -7469.10, -4785.11, 10.42); - OOX17AI->AddWaypoint(59, -7453.18, -4782.41, 9.15); - OOX17AI->AddWaypoint(60, -7426.27, -4777.83, 9.54); - OOX17AI->AddWaypoint(61, -7393.84, -4770.19, 12.57); - OOX17AI->AddWaypoint(62, -7367.25, -4764.17, 11.92); - OOX17AI->AddWaypoint(63, -7341.00, -4752.11, 10.17); - OOX17AI->AddWaypoint(64, -7321.62, -4744.97, 11.58); - OOX17AI->AddWaypoint(65, -7302.35, -4744.35, 11.97); - OOX17AI->AddWaypoint(66, -7281.00, -4743.66, 11.21); - OOX17AI->AddWaypoint(67, -7258.33, -4742.93, 9.64); - OOX17AI->AddWaypoint(68, -7236.70, -4742.24, 10.16); - OOX17AI->AddWaypoint(69, -7217.52, -4743.87, 10.79); - OOX17AI->AddWaypoint(70, -7201.86, -4746.32, 9.58); - OOX17AI->AddWaypoint(71, -7182.01, -4749.41, 9.09); - OOX17AI->AddWaypoint(72, -7159.61, -4752.90, 9.52); - OOX17AI->AddWaypoint(73, -7139.58, -4756.02, 9.53); - OOX17AI->AddWaypoint(74, -7122.60, -4754.91, 9.66); - OOX17AI->AddWaypoint(75, -7101.06, -4753.87, 8.92); - OOX17AI->AddWaypoint(76, -7082.79, -4752.99, 9.97); - OOX17AI->AddWaypoint(77, -7061.81, -4751.98, 9.26); - OOX17AI->AddWaypoint(78, -7035.12, -4754.39, 9.19); - OOX17AI->AddWaypoint(79, -7013.90, -4758.64, 10.28); - OOX17AI->AddWaypoint(80, -7001.71, -4769.73, 10.59); - OOX17AI->AddWaypoint(81, -6984.95, -4788.61, 9.30); - OOX17AI->AddWaypoint(82, -6970.41, -4788.77, 9.42); - OOX17AI->AddWaypoint(83, -6957.16, -4788.92, 6.26); - OOX17AI->AddWaypoint(84, -6951.29, -4802.73, 4.45); - OOX17AI->AddWaypoint(85, -6944.81, -4816.58, 1.60); - OOX17AI->AddWaypoint(86, -6942.06, -4839.40, 0.66,5000); - - return (CreatureAI*)OOX17AI; + return new npc_OOX17AI(pCreature); } /*###### @@ -765,6 +681,7 @@ struct npc_anachronosAI : public ScriptedAI void Reset() { + me->SetVisibility(VISIBILITY_ON); checkTimer = 3000; } @@ -777,10 +694,10 @@ struct npc_anachronosAI : public ScriptedAI { if (HealthBelowPct(20)) { - m_creature->Yell("A terrible and costly mistake you have made. It is not my time, mortals.", LANG_UNIVERSAL, 0); - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DestroyForNearbyPlayers(); - m_creature->Kill(m_creature, false); + me->Yell("A terrible and costly mistake you have made. It is not my time, mortals.", LANG_UNIVERSAL, 0); + me->SetVisibility(VISIBILITY_OFF); + me->DestroyForNearbyPlayers(); + me->Kill(me, false); return; } diff --git a/src/scripts/scripts/zone/teldrassil/teldrassil.cpp b/src/scripts/scripts/Kalimdor/teldrassil/teldrassil.cpp similarity index 87% rename from src/scripts/scripts/zone/teldrassil/teldrassil.cpp rename to src/scripts/scripts/Kalimdor/teldrassil/teldrassil.cpp index cabd75dd5..8fe2e6585 100644 --- a/src/scripts/scripts/zone/teldrassil/teldrassil.cpp +++ b/src/scripts/scripts/Kalimdor/teldrassil/teldrassil.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp index ded6f50c0..f8b4a713a --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_bug_trio.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -27,7 +30,7 @@ EndScriptData */ #define SPELL_CLEAVE 26350 #define SPELL_TOXIC_VOLLEY 25812 #define SPELL_POISON_CLOUD 38718 //Only Spell with right dmg. -#define SPELL_ENRAGE 34624 //Changed cause 25790 is casted on gamers too. Same prob with old explosion of twin emperors. +#define SPELL_ENRAGE 34624 //Changed cause 25790 is cast on gamers too. Same prob with old explosion of twin emperors. #define SPELL_CHARGE 26561 #define SPELL_KNOCKBACK 26027 diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_cthun.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_cthun.cpp index 0b8150075..0221d4dec --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_cthun.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -625,7 +628,7 @@ struct cthunAI : public Scripted_NoMovementAI //Place all units in threat list on outside of stomach Stomach_Map.clear(); - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) { //Outside stomach diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp index b0fa2db9a..077a9edf7 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_fankriss.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp index f2eb8d22b..7672de236 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_huhuran.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_ouro.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_ouro.cpp index 46f24d3ef..618460b46 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_ouro.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_sartura.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_sartura.cpp index 0ab47d6a8..6930c1fac --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_sartura.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -152,7 +155,7 @@ struct boss_sarturaAI : public ScriptedAI //If she is 20% enrage if (!Enraged) { - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 20 && !m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 20 && !m_creature->IsNonMeleeSpellCast(false)) { DoCast(m_creature, SPELL_ENRAGE); Enraged = true; diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_skeram.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_skeram.cpp index b5f7883f9..857383431 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_skeram.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -142,7 +145,7 @@ struct boss_skeramAI : public ScriptedAI if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) { //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCast(false)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp index d79733cf3..2e62694f3 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_twinemperors.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -66,7 +69,7 @@ struct boss_twinemperorsAI : public ScriptedAI uint32 AfterTeleportTimer; bool DontYellWhenDead; uint32 Abuse_Bug_Timer, BugsTimer; - bool tspellcasted; + bool tspellCast; uint32 EnrageTimer; virtual bool IAmVeklor() = 0; @@ -83,7 +86,7 @@ struct boss_twinemperorsAI : public ScriptedAI Heal_Timer = 0; // first heal immediately when they get close together Teleport_Timer = TELEPORTTIME; AfterTeleport = false; - tspellcasted = false; + tspellCast = false; AfterTeleportTimer = 0; Abuse_Bug_Timer = 10000 + rand()%7000; BugsTimer = 2000; @@ -252,21 +255,21 @@ struct boss_twinemperorsAI : public ScriptedAI m_creature->addUnitState(UNIT_STAT_STUNNED); AfterTeleport = true; AfterTeleportTimer = 2000; - tspellcasted = false; + tspellCast = false; } bool TryActivateAfterTTelep(uint32 diff) { if (AfterTeleport) { - if (!tspellcasted) + if (!tspellCast) { m_creature->clearUnitState(UNIT_STAT_STUNNED); DoCast(m_creature, SPELL_TWIN_TELEPORT); m_creature->addUnitState(UNIT_STAT_STUNNED); } - tspellcasted = true; + tspellCast = true; if (AfterTeleportTimer < diff) { @@ -399,7 +402,7 @@ struct boss_twinemperorsAI : public ScriptedAI { if (EnrageTimer < diff) { - if (!m_creature->IsNonMeleeSpellCasted(true)) + if (!m_creature->IsNonMeleeSpellCast(true)) { DoCast(m_creature, SPELL_BERSERK); EnrageTimer = 60*60000; diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp old mode 100755 new mode 100644 similarity index 87% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp index 7a070a670..833fe9a33 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/boss_viscidus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h new file mode 100644 index 000000000..c5bc54826 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_TEMPLE_OF_AHNQIRAJ_H +#define SC_DEF_TEMPLE_OF_AHNQIRAJ_H + +#define DATA_THE_PROPHET_SKERAM 0 +#define DATA_BATTLEGUARD_SARTURA 1 +#define DATA_FANKRISS_THE_UNYIELDING 2 +#define DATA_PRINCESS_HUHURAN 3 +#define DATA_TWIN_EMPERORS 4 +#define DATA_C_THUN 5 +#define DATA_BUG_TRIO 6 +#define DATA_VISCIDUS 7 +#define DATA_OURO 8 + +#define DATA_SKERAM 9 +#define DATA_KRI 10 +#define DATA_VEM 11 +#define DATA_VEKLOR 12 +#define DATA_VEKNILASH 13 +#define DATA_BUG_TRIO_DEATH 14 + +#define DATA_CTHUN_PHASE 20 + +#endif + diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp index f18119396..1661ca422 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -104,15 +107,7 @@ struct instance_temple_of_ahnqiraj : public ScriptedInstance case 15275: VeknilashGUID = creature->GetGUID(); break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } bool IsEncounterInProgress() const diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp rename to src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp index 9eaf17104..8c72488c2 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp +++ b/src/scripts/scripts/Kalimdor/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -280,7 +283,7 @@ struct aqsentinelAI : public ScriptedAI Unit *GetHatedManaUser() { - std::list::iterator i; + std::list::iterator i; for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) { Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); diff --git a/src/scripts/scripts/zone/thousand_needles/thousand_needles.cpp b/src/scripts/scripts/Kalimdor/thousand_needles/thousand_needles.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/thousand_needles/thousand_needles.cpp rename to src/scripts/scripts/Kalimdor/thousand_needles/thousand_needles.cpp index 1dd24de10..7bc98db31 --- a/src/scripts/scripts/zone/thousand_needles/thousand_needles.cpp +++ b/src/scripts/scripts/Kalimdor/thousand_needles/thousand_needles.cpp @@ -1,19 +1,21 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp b/src/scripts/scripts/Kalimdor/thunder_bluff/thunder_bluff.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp rename to src/scripts/scripts/Kalimdor/thunder_bluff/thunder_bluff.cpp index a39d3c327..98335f509 --- a/src/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp +++ b/src/scripts/scripts/Kalimdor/thunder_bluff/thunder_bluff.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/ungoro_crater/ungoro_crater.cpp b/src/scripts/scripts/Kalimdor/ungoro_crater/ungoro_crater.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/ungoro_crater/ungoro_crater.cpp rename to src/scripts/scripts/Kalimdor/ungoro_crater/ungoro_crater.cpp index 6201210ca..d4f938ce4 --- a/src/scripts/scripts/zone/ungoro_crater/ungoro_crater.cpp +++ b/src/scripts/scripts/Kalimdor/ungoro_crater/ungoro_crater.cpp @@ -1,20 +1,23 @@ /* - * Copyright (C) 2008-2010 TrinityCore * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* ScriptData SDName: Ungoro Crater SD%Complete: 100 diff --git a/src/scripts/scripts/Kalimdor/wailing_caverns/def_wailing_caverns.h b/src/scripts/scripts/Kalimdor/wailing_caverns/def_wailing_caverns.h new file mode 100644 index 000000000..e71b5644a --- /dev/null +++ b/src/scripts/scripts/Kalimdor/wailing_caverns/def_wailing_caverns.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_WAILING_CAVERNS_H +#define SC_DEF_WAILING_CAVERNS_H + +enum eTypes +{ + TYPE_LORD_COBRAHN = 1, + TYPE_LORD_PYTHAS = 2, + TYPE_LADY_ANACONDRA = 3, + TYPE_LORD_SERPENTIS = 4, + TYPE_NARALEX_EVENT = 5, + TYPE_NARALEX_PART1 = 6, + TYPE_NARALEX_PART2 = 7, + TYPE_NARALEX_PART3 = 8, + TYPE_MUTANUS_THE_DEVOURER = 9, + TYPE_NARALEX_YELLED = 10, + + DATA_NARALEX = 3679, +}; + +#endif diff --git a/src/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp b/src/scripts/scripts/Kalimdor/wailing_caverns/instance_wailing_caverns.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp rename to src/scripts/scripts/Kalimdor/wailing_caverns/instance_wailing_caverns.cpp index ef32dbbb8..541f2b126 --- a/src/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp +++ b/src/scripts/scripts/Kalimdor/wailing_caverns/instance_wailing_caverns.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/wailing_caverns/wailing_caverns.cpp b/src/scripts/scripts/Kalimdor/wailing_caverns/wailing_caverns.cpp similarity index 88% rename from src/scripts/scripts/zone/wailing_caverns/wailing_caverns.cpp rename to src/scripts/scripts/Kalimdor/wailing_caverns/wailing_caverns.cpp index 5cd8b574a..92ce7c1fc 100644 --- a/src/scripts/scripts/zone/wailing_caverns/wailing_caverns.cpp +++ b/src/scripts/scripts/Kalimdor/wailing_caverns/wailing_caverns.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Wailing Caverns @@ -82,8 +85,8 @@ struct npc_disciple_of_naralexAI : public npc_escortAI eventTimer = 0; currentEvent = 0; eventProgress = 0; + Point = 0; me->setActive(true); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); } uint32 eventTimer; @@ -91,6 +94,7 @@ struct npc_disciple_of_naralexAI : public npc_escortAI uint32 eventProgress; uint32 sleepTimer; uint32 potionTimer; + uint32 Point; bool potCooldown; ScriptedInstance *pInstance; @@ -111,6 +115,7 @@ struct npc_disciple_of_naralexAI : public npc_escortAI pInstance->SetData(TYPE_NARALEX_PART1, DONE); break; case 11: + Point = i; eventProgress = 1; currentEvent = TYPE_NARALEX_PART2; pInstance->SetData(TYPE_NARALEX_PART2, IN_PROGRESS); @@ -119,6 +124,7 @@ struct npc_disciple_of_naralexAI : public npc_escortAI DoScriptText(SAY_BEYOND_THIS_CORRIDOR, me); break; case 24: + Point = i; eventProgress = 1; currentEvent = TYPE_NARALEX_PART3; pInstance->SetData(TYPE_NARALEX_PART3, IN_PROGRESS); @@ -138,6 +144,19 @@ struct npc_disciple_of_naralexAI : public npc_escortAI DoScriptText(SAY_ATTACKED, me, who); } + void EnterEvadeMode() + { + // Do not stop casting + if (Point == 11 || Point == 24) + { + m_creature->SetLootRecipient(NULL); + m_creature->DeleteThreatList(); + m_creature->CombatStop(false); + } + else + npc_escortAI::EnterEvadeMode(); + } + void JustDied(Unit * /*slayer*/) { if (pInstance) @@ -183,7 +202,6 @@ struct npc_disciple_of_naralexAI : public npc_escortAI ++eventProgress; DoScriptText(SAY_BANISH_THE_SPIRITS, me); DoCast(me, SPELL_SERPENTINE_CLEANSING); - //CAST_AI(npc_escortAI, me->AI())->SetCanDefend(false); eventTimer = 30000; me->SummonCreature(NPC_DEVIATE_VIPER, -61.5261, 273.676, -92.8442, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000); me->SummonCreature(NPC_DEVIATE_VIPER, -58.4658, 280.799, -92.8393, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000); @@ -192,7 +210,6 @@ struct npc_disciple_of_naralexAI : public npc_escortAI else if (eventProgress == 2) { - //CAST_AI(npc_escortAI, me->AI())->SetCanDefend(true); DoScriptText(SAY_CAVERNS_PURIFIED, me); pInstance->SetData(TYPE_NARALEX_PART2, DONE); if (me->HasAura(SPELL_SERPENTINE_CLEANSING, 0)) @@ -212,7 +229,6 @@ struct npc_disciple_of_naralexAI : public npc_escortAI { ++eventProgress; eventTimer = 15000; - //CAST_AI(npc_escortAI, me->AI())->SetCanDefend(false); if (Creature* naralex = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NARALEX))) DoCast(naralex, SPELL_NARALEXS_AWAKENING, true); DoScriptText(EMOTE_AWAKENING_RITUAL, me); @@ -224,9 +240,9 @@ struct npc_disciple_of_naralexAI : public npc_escortAI eventTimer = 15000; if (Creature* naralex = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NARALEX))) DoScriptText(EMOTE_TROUBLED_SLEEP, naralex); - me->SummonCreature(NPC_DEVIATE_MOCCASIN, 135.943, 199.701, -103.529, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_DEVIATE_MOCCASIN, 151.08, 221.13, -103.609, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_DEVIATE_MOCCASIN, 128.007, 227.428, -97.421, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_DEVIATE_MOCCASIN, 131.486, 218.504, -101.094, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_DEVIATE_MOCCASIN, 146.517, 233.378, -100.830, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_DEVIATE_MOCCASIN, 135.440, 253.692, -100.067, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); } else if (eventProgress == 4) @@ -235,13 +251,13 @@ struct npc_disciple_of_naralexAI : public npc_escortAI eventTimer = 30000; if (Creature* naralex = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NARALEX))) DoScriptText(EMOTE_WRITHE_IN_AGONY, naralex); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 133.413, 207.188, -102.469, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 142.857, 218.645, -102.905, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 105.102, 227.211, -102.752, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 153.372, 235.149, -102.826, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 149.524, 251.113, -102.558, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 136.208, 266.466, -102.977, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); - me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 126.167, 274.759, -102.962, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 131.486, 218.504, -101.094, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 146.517, 233.378, -100.830, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 135.440, 253.692, -100.067, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 144.752, 243.089, -100.219, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 127.191, 261.635, -99.542, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 117.289, 267.770, -99.667, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); + me->SummonCreature(NPC_NIGHTMARE_ECTOPLASM, 101.216, 260.543, -99.718, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000); } else if (eventProgress == 5) @@ -249,7 +265,7 @@ struct npc_disciple_of_naralexAI : public npc_escortAI ++eventProgress; if (Creature* naralex = pInstance->instance->GetCreature(pInstance->GetData64(DATA_NARALEX))) DoScriptText(EMOTE_HORRENDOUS_VISION, naralex); - me->SummonCreature(NPC_MUTANUS_THE_DEVOURER, 150.872, 262.905, -103.503, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300000); + me->SummonCreature(NPC_MUTANUS_THE_DEVOURER, 144.752, 243.089, -100.219, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300000); DoScriptText(SAY_MUTANUS_THE_DEVOURER, me); pInstance->SetData(TYPE_MUTANUS_THE_DEVOURER, IN_PROGRESS); } @@ -398,7 +414,6 @@ bool GossipSelect_npc_disciple_of_naralex(Player* pPlayer, Creature* pCreature, DoScriptText(SAY_MAKE_PREPARATIONS, pCreature); pCreature->setFaction(250); - pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); CAST_AI(npc_escortAI, (pCreature->AI()))->Start(false, false, pPlayer->GetGUID()); CAST_AI(npc_escortAI, (pCreature->AI()))->SetDespawnAtFar(false); diff --git a/src/scripts/scripts/zone/winterspring/winterspring.cpp b/src/scripts/scripts/Kalimdor/winterspring/winterspring.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/winterspring/winterspring.cpp rename to src/scripts/scripts/Kalimdor/winterspring/winterspring.cpp index b67a03103..c1583f390 --- a/src/scripts/scripts/zone/winterspring/winterspring.cpp +++ b/src/scripts/scripts/Kalimdor/winterspring/winterspring.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Kalimdor/zulfarrak/def_zul_farrak.h b/src/scripts/scripts/Kalimdor/zulfarrak/def_zul_farrak.h new file mode 100644 index 000000000..e614df518 --- /dev/null +++ b/src/scripts/scripts/Kalimdor/zulfarrak/def_zul_farrak.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_ZUL_FARRAK +#define SC_DEF_ZUL_FARRAK + +#define DATA_PYRAMID_BATTLE 1 +#define DATA_DOOR_EVENT 2 + +#define CAGES_BEGIN 141070 +#define CAGES_END 141074 +#define DOOR_ENTRY 146084 +#define CAPTIVES_BEGIN 7604 +#define CAPTIVES_END 7608 + +#endif \ No newline at end of file diff --git a/src/scripts/scripts/Kalimdor/zulfarrak/instance_zul_farrak.cpp b/src/scripts/scripts/Kalimdor/zulfarrak/instance_zul_farrak.cpp new file mode 100644 index 000000000..a9606f8ec --- /dev/null +++ b/src/scripts/scripts/Kalimdor/zulfarrak/instance_zul_farrak.cpp @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: instance_zul_farrak +SD%Complete: 70 +SDComment: basicaly pyramid event, TODO: make captives fight together against mobs and players; proper implementation of end door +SDCategory: Zul'Farrak +EndScriptData */ + +#include "precompiled.h" +#include "def_zul_farrak.h" + +#define ENCOUNTERS 2 + +float ZFWPs[10][3] = { +{1887.35,1263.67,41.48}, +{1890.87,1263.86,41.41}, +{1883.12,1263.76,41.59}, +{1890.72,1268.39,41.47}, +{1882.84,1267.99,41.73}, +{1885.85,1202.20,8.88}, +{1889.46,1204.23,8.88}, +{1887.41,1208.92,8.88}, +{1895.49,1204.23,8.88}, +{1876.23,1207.52,8.88}}; + +float spawns[26][4] ={ +{1902.83, 1223.41, 8.96, 3.95}, +{1894.64, 1206.29, 8.87, 2.22}, +{1874.45, 1204.44, 8.87, 0.88}, +{1874.18, 1221.24, 9.21, 0.84}, +{1879.02, 1223.06, 9.12, 5.91}, +{1882.07, 1225.70, 9.32, 5.69}, +{1886.97, 1225.86, 9.85, 5.79}, +{1892.28, 1225.49, 9.57, 5.63}, +{1894.72, 1221.91, 8.87, 2.34}, +{1890.08, 1218.68, 8.87, 1.59}, +{1883.50, 1218.25, 8.90, 0.67}, +{1886.93, 1221.40, 8.94, 1.60}, +{1883.76, 1222.30, 9.11, 6.26}, +{1889.82, 1222.51, 9.03, 0.97}, +{1898.23, 1217.97, 8.87, 3.42}, +{1877.40, 1216.41, 8.97, 0.37}, +{1893.07, 1215.26, 8.87, 3.08}, +{1878.57, 1214.16, 8.87, 3.12}, +{1889.94, 1212.21, 8.87, 1.59}, +{1883.74, 1212.35, 8.87, 1.59}, +{1877.00, 1207.27, 8.87, 3.80}, +{1873.63, 1204.65, 8.87, 0.61}, +{1896.46, 1205.62, 8.87, 5.72}, +{1899.63, 1202.52, 8.87, 2.46}, +{1889.23, 1207.72, 8.87, 1.47}, +{1879.77, 1207.96, 8.87, 1.55} +}; + +uint32 spawnentries[8] = {7789,7787,7787,8876,7788,8877,7275,7796}; + +struct instance_zul_farrak : public ScriptedInstance +{ + instance_zul_farrak(Map *map) : ScriptedInstance(map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + uint8 waves; + uint32 wavecounter; + uint64 captives[5]; + uint64 doorsGUID; + + void Initialize() + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + waves = 0; + wavecounter = 0; + for(uint8 i = 0; i < 5; i++) + captives[i] = 0; + doorsGUID = 0; + } + + void OnGameObjectCreate(GameObject *go, bool) + { + if (go->GetEntry() >= CAGES_BEGIN && go->GetEntry() <= CAGES_END ) + if (Encounter[0] > IN_PROGRESS) + go->SetGoState(GO_STATE_ACTIVE); + if (go->GetEntry() == DOOR_ENTRY && Encounter[1] == DONE) + { + go->SetGoState(GO_STATE_ACTIVE); + doorsGUID = go->GetGUID(); + } + } + + void OnCreatureCreate(Creature *c, bool) + { + if (c->GetEntry() >= CAPTIVES_BEGIN && c->GetEntry() <= CAPTIVES_END ) + { + if (Encounter[0] != NOT_STARTED) + c->ForcedDespawn(); + captives[c->GetEntry() - CAPTIVES_BEGIN] = c->GetGUID(); + } + } + + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + + std::ostringstream stream; + stream << Encounter[0] << " " << Encounter[1]; + + OUT_SAVE_INST_DATA_COMPLETE; + return stream.str(); + } + + void Load(const char* in) + { + if (!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + + std::istringstream loadStream(in); + loadStream >> Encounter[0] >> Encounter[1]; + + if (Encounter[0] == IN_PROGRESS) + Encounter[0] = NOT_STARTED; + + OUT_LOAD_INST_DATA_COMPLETE; + } + + void SetData(uint32 Data, uint32 Value) + { + if (Data == DATA_PYRAMID_BATTLE) + { + if (Value == IN_PROGRESS && Encounter[0] == NOT_STARTED) + Encounter[0] = Value; + else if (Value == SPECIAL) + --wavecounter; + } + else if (Data == DATA_DOOR_EVENT && Encounter[1] != DONE) + Encounter[1] = Value; + if (Data == DATA_DOOR_EVENT && Value == DONE) + if (GameObject * go = instance->GetGameObject(doorsGUID)) + go->SetGoState(GO_STATE_ACTIVE); + if (Value >= FAIL) + SaveToDB(); + + } + + uint32 GetData(uint32 Data) + { + if (Data == DATA_PYRAMID_BATTLE) + return Encounter[0]; + if (Data == DATA_DOOR_EVENT) + return Encounter[1]; + return 0; + } + + void Update(uint32 diff) + { + if (Encounter[0] == IN_PROGRESS && wavecounter == 0) + { + if (waves == 0) + for (uint8 i = 0; i < 5; i++) + if (Creature *c = GetCreature(captives[i])) + { + c->SetWalk(true); + c->GetMotionMaster()->MovePoint(0,ZFWPs[i][0],ZFWPs[i][1],ZFWPs[i][2]); + } + if (waves == 0 || waves == 1 || waves == 2) + for (uint8 j = 0; j < 4; j++) + for (uint8 i = 0; i < 6; i++) + if (Player * p = instance->GetPlayers().begin()->getSource()) + if (Creature* c = p->SummonCreature(spawnentries[i],spawns[j*6 + i][0],spawns[j*6 + i][1],spawns[j*6 + i][2],spawns[j*6 + i][3],TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000)) + wavecounter++; + if (waves == 3) + wavecounter = 15000; + if (waves >= 4) + Encounter[0] = DONE; + + if (waves == 2) + { + for (uint8 i = 0; i < 5; i++) + if (Creature *c = GetCreature(captives[i])) + { + c->GetMotionMaster()->MovePoint(1,ZFWPs[i+5][0],ZFWPs[i+5][1],ZFWPs[i+5][2]); + c->SetHomePosition(ZFWPs[i+5][0],ZFWPs[i+5][1],ZFWPs[i+5][2],0); + } + if (Player * p = instance->GetPlayers().begin()->getSource()) + { + if (Creature* c = p->SummonCreature(spawnentries[6],spawns[24][0],spawns[24][1],spawns[24][2],spawns[24][3],TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000)) + wavecounter++; + if (Creature* c = p->SummonCreature(spawnentries[7],spawns[25][0],spawns[25][1],spawns[25][2],spawns[25][3],TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000)) + wavecounter++; + } + } + + waves++; + } + + if (waves == 4) + { + if (wavecounter < diff) + wavecounter = 0; + else + wavecounter -= diff; + } + } +}; + +InstanceData* GetInstanceData_instance_zul_farrak(Map* map) +{ + return new instance_zul_farrak(map); +} + +void AddSC_instance_zul_farrak() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_zul_farrak"; + newscript->GetInstanceData = &GetInstanceData_instance_zul_farrak; + newscript->RegisterSelf(); +} \ No newline at end of file diff --git a/src/scripts/scripts/zone/zulfarrak/zulfarrak.cpp b/src/scripts/scripts/Kalimdor/zulfarrak/zulfarrak.cpp old mode 100755 new mode 100644 similarity index 66% rename from src/scripts/scripts/zone/zulfarrak/zulfarrak.cpp rename to src/scripts/scripts/Kalimdor/zulfarrak/zulfarrak.cpp index 26d3753cf..471a764a0 --- a/src/scripts/scripts/zone/zulfarrak/zulfarrak.cpp +++ b/src/scripts/scripts/Kalimdor/zulfarrak/zulfarrak.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Zulfarrak -SD%Complete: 50 -SDComment: Consider it temporary, no instance script made for this instance yet. +SD%Complete: 70 +SDComment: TODO: gossips ; make blastfuse blast the doors with spell SDCategory: Zul'Farrak EndScriptData */ @@ -27,6 +30,7 @@ npc_weegli_blastfuse EndContentData */ #include "precompiled.h" +#include "def_zul_farrak.h" /*###### ## npc_sergeant_bly @@ -42,12 +46,7 @@ EndContentData */ struct npc_sergeant_blyAI : public ScriptedAI { - npc_sergeant_blyAI(Creature *c) : ScriptedAI(c) - { - //pInstance = (c->GetInstanceData()); - } - - //ScriptedInstance* pInstance; + npc_sergeant_blyAI(Creature *c) : ScriptedAI(c) {} uint32 ShieldBash_Timer; uint32 Revenge_Timer; //this is wrong, spell should never be used unless m_creature->getVictim() dodge, parry or block attack. Trinity support required. @@ -58,22 +57,11 @@ struct npc_sergeant_blyAI : public ScriptedAI Revenge_Timer = 8000; m_creature->setFaction(FACTION_FRIENDLY); - - /*if( pInstance ) - pInstance->SetData(0, NOT_STARTED);*/ } - void EnterCombat(Unit *who) - { - /*if( pInstance ) - pInstance->SetData(0, IN_PROGRESS);*/ - } + void EnterCombat(Unit *who) {} - void JustDied(Unit *victim) - { - /*if( pInstance ) - pInstance->SetData(0, DONE);*/ - } + void JustDied(Unit *victim) {} void UpdateAI(const uint32 diff) { @@ -102,22 +90,25 @@ CreatureAI* GetAI_npc_sergeant_bly(Creature *_Creature) bool GossipHello_npc_sergeant_bly(Player *player, Creature *_Creature ) { - /*if( pInstance->GetData(0) == DONE ) - {*/ - player->ADD_GOSSIP_ITEM(1, GOSSIP_BLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + ScriptedInstance* pInstance = (ScriptedInstance*)_Creature->GetInstanceData(); + if(!pInstance) + return false; + if( pInstance->GetData(DATA_PYRAMID_BATTLE) == DONE ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_BLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); player->SEND_GOSSIP_MENU(1517, _Creature->GetGUID()); - /*} - else if( pInstance->GetData(0) == IN_PROGRESS ) + } + else if( pInstance->GetData(DATA_PYRAMID_BATTLE) == IN_PROGRESS ) player->SEND_GOSSIP_MENU(1516, _Creature->GetGUID()); else - player->SEND_GOSSIP_MENU(1515, _Creature->GetGUID());*/ + player->SEND_GOSSIP_MENU(1515, _Creature->GetGUID()); return true; } bool GossipSelect_npc_sergeant_bly(Player *player, Creature *_Creature, uint32 sender, uint32 action ) { - if( action == GOSSIP_ACTION_INFO_DEF+1 ) + if( action == GOSSIP_ACTION_INFO_DEF) { player->CLOSE_GOSSIP_MENU(); _Creature->setFaction(FACTION_HOSTILE); @@ -133,7 +124,7 @@ bool GossipSelect_npc_sergeant_bly(Player *player, Creature *_Creature, uint32 s #define SPELL_BOMB 8858 #define SPELL_GOBLIN_LAND_MINE 21688 #define SPELL_SHOOT 6660 -#define SPELL_WEEGLIS_BARREL 10772 +#define SPELL_WEEGLIS_BARREL 10772 // this one should open door #define GOSSIP_WEEGLI "[PH] Please blow up the door." @@ -141,27 +132,34 @@ struct npc_weegli_blastfuseAI : public ScriptedAI { npc_weegli_blastfuseAI(Creature *c) : ScriptedAI(c) { - //pInstance = (c->GetInstanceData()); + pInstance = (c->GetInstanceData()); } - //ScriptedInstance* pInstance; + ScriptedInstance* pInstance; - void Reset() - { - /*if( pInstance ) - pInstance->SetData(0, NOT_STARTED);*/ - } + void Reset() {} - void EnterCombat(Unit *who) + void EnterCombat(Unit *who) {} + + void MovementInform(uint32 motiontype ,uint32 wpid) { - /*if( pInstance ) - pInstance->SetData(0, IN_PROGRESS);*/ + if (motiontype != POINT_MOTION_TYPE) + return; + + if (wpid == 2) + { + // do things with blowing up the doors + m_creature->GetMotionMaster()->MovePoint(3,1876.11,1201.75,8.88); + } + if (wpid == 3 && pInstance) + pInstance->SetData(DATA_DOOR_EVENT,DONE); // after implementing spell remove it + } void JustDied(Unit *victim) { - /*if( pInstance ) - pInstance->SetData(0, DONE);*/ + if (pInstance) + pInstance->SetData(DATA_DOOR_EVENT,FAIL); } void UpdateAI(const uint32 diff) @@ -179,25 +177,33 @@ CreatureAI* GetAI_npc_weegli_blastfuse(Creature *_Creature) bool GossipHello_npc_weegli_blastfuse(Player *player, Creature *_Creature ) { - //event not implemented yet, this is only placeholder for future developement - /*if( pInstance->GetData(0) == DONE ) + ScriptedInstance* pInstance = (ScriptedInstance*)_Creature->GetInstanceData(); + if(!pInstance) + return false; + + if( pInstance->GetData(DATA_PYRAMID_BATTLE) == DONE ) { - player->ADD_GOSSIP_ITEM(1, GOSSIP_WEEGLI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(1514, _Creature->GetGUID());//if event can proceed to end + player->ADD_GOSSIP_ITEM(1, GOSSIP_WEEGLI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(1514, _Creature->GetGUID()); } - else if( pInstance->GetData(0) == IN_PROGRESS ) - player->SEND_GOSSIP_MENU(1513, _Creature->GetGUID());//if event are in progress - else*/ - player->SEND_GOSSIP_MENU(1511, _Creature->GetGUID()); //if event not started + else if( pInstance->GetData(DATA_PYRAMID_BATTLE) == IN_PROGRESS ) + player->SEND_GOSSIP_MENU(1513, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(1511, _Creature->GetGUID()); return true; } bool GossipSelect_npc_weegli_blastfuse(Player *player, Creature *_Creature, uint32 sender, uint32 action ) { - if( action == GOSSIP_ACTION_INFO_DEF+1 ) + ScriptedInstance* pInstance = (ScriptedInstance*)_Creature->GetInstanceData(); + if (!pInstance) + return false; + + if( action == GOSSIP_ACTION_INFO_DEF) { player->CLOSE_GOSSIP_MENU(); - //here we make him run to door, set the charge and run away off to nowhere + pInstance->SetData(DATA_DOOR_EVENT,DONE); + _Creature->GetMotionMaster()->MovePoint(2,1856.92,1146.26,15.15); } return true; } diff --git a/src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp b/src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp rename to src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp index d1c698ec9..505afb203 --- a/src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -229,7 +232,7 @@ struct boss_exarch_maladaarAI : public ScriptedAI if (!Avatar_summoned && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 25)) { - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); DoScriptText(SAY_SUMMON, m_creature); @@ -245,7 +248,7 @@ struct boss_exarch_maladaarAI : public ScriptedAI { if (target->GetTypeId() == TYPEID_PLAYER) { - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); uint32 i = urand(1,2); diff --git a/src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp b/src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp rename to src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp index 0f80ee7ee..9d322488c --- a/src/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/auchenai_crypts/boss_shirrak_the_dead_watcher.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp rename to src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp index 1f0c46f69..5ad647deb --- a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -193,7 +196,7 @@ struct boss_nexusprince_shaffarAI : public ScriptedAI if( FrostNova_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); DoCast(m_creature,SPELL_FROSTNOVA); @@ -223,7 +226,7 @@ struct boss_nexusprince_shaffarAI : public ScriptedAI { if( Blink_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); DoCast(m_creature,SPELL_BLINK); @@ -236,7 +239,7 @@ struct boss_nexusprince_shaffarAI : public ScriptedAI if( Beacon_Timer < diff) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); if( !urand(0,3) ) @@ -339,7 +342,7 @@ struct mob_ethereal_beaconAI : public ScriptedAI if( Apprentice_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); m_creature->CastSpell(m_creature,SPELL_ETHEREAL_APPRENTICE,true); diff --git a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_pandemonius.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp rename to src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_pandemonius.cpp index cb2f66830..c83f10bdb --- a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_pandemonius.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -113,7 +116,7 @@ struct boss_pandemoniusAI : public ScriptedAI { if( DarkShell_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); DoScriptText(EMOTE_DARK_SHELL, m_creature); diff --git a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_yor.cpp b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_yor.cpp similarity index 74% rename from src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_yor.cpp rename to src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_yor.cpp index 62c837af2..31551f486 100644 --- a/src/scripts/scripts/zone/aunchindoun/mana_tombs/boss_yor.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/boss_yor.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_mana_tombs.h" diff --git a/src/scripts/scripts/Outland/aunchindoun/mana_tombs/def_mana_tombs.h b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/def_mana_tombs.h new file mode 100644 index 000000000..a82da1051 --- /dev/null +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/def_mana_tombs.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_MANA_TOMBS_H +#define SC_DEF_MANA_TOMBS_H + +#define DATA_YOREVENT 1 +#define DATA_PANDEMONIUSEVENT 2 +#define DATA_NEXUSPRINCEEVENT 3 +#define DATA_SHAHEENEVENT 4 + +#endif diff --git a/src/scripts/scripts/zone/aunchindoun/mana_tombs/instance_mana_tombs.cpp b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/instance_mana_tombs.cpp similarity index 71% rename from src/scripts/scripts/zone/aunchindoun/mana_tombs/instance_mana_tombs.cpp rename to src/scripts/scripts/Outland/aunchindoun/mana_tombs/instance_mana_tombs.cpp index a8f9f6579..d066728cc 100644 --- a/src/scripts/scripts/zone/aunchindoun/mana_tombs/instance_mana_tombs.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/instance_mana_tombs.cpp @@ -1,7 +1,25 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_mana_tombs.h" -#define ENCOUNTERS 3 +#define ENCOUNTERS 4 struct instance_mana_tombs : public ScriptedInstance { @@ -50,6 +68,10 @@ struct instance_mana_tombs : public ScriptedInstance if(Encounter[2] != DONE) Encounter[2] = data; break; + case DATA_SHAHEENEVENT: + if(Encounter[3] != DONE) + Encounter[3] = data; + break; } if (data == DONE) @@ -64,6 +86,7 @@ struct instance_mana_tombs : public ScriptedInstance case DATA_YOREVENT: return Encounter[0]; case DATA_PANDEMONIUSEVENT: return Encounter[1]; case DATA_NEXUSPRINCEEVENT: return Encounter[2]; + case DATA_SHAHEENEVENT: return Encounter[3]; } return false; @@ -76,7 +99,8 @@ struct instance_mana_tombs : public ScriptedInstance std::ostringstream stream; stream << Encounter[0] << " " << Encounter[1] << " " - << Encounter[2]; + << Encounter[2] << " " + << Encounter[3]; OUT_SAVE_INST_DATA_COMPLETE; diff --git a/src/scripts/scripts/Outland/aunchindoun/mana_tombs/mana_tombs.cpp b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/mana_tombs.cpp new file mode 100644 index 000000000..71552c6a1 --- /dev/null +++ b/src/scripts/scripts/Outland/aunchindoun/mana_tombs/mana_tombs.cpp @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +HGName: mana_tombs +HG%Complete: 100 +HGComment: support the quest 10218. +HGCategory: Auchindoun, Mana Tombs +EndScriptData */ + +/* ContentData +npc_shaheen +go_transportercp +EndContentData */ + +#include "precompiled.h" +#include "def_mana_tombs.h" +#include "escort_ai.h" + +enum +{ + SAY_INTRO = -1900235, + SAY_STOP = -1900236, + SAY_START = -1900237, + SAY_1 = -1900238, + SAY_2 = -1900239, + SAY_3 = -1900240, + SAY_4 = -1900241, + SAY_5 = -1900242, + SAY_6 = -1900243, + SAY_7 = -1900244, + SAY_8 = -1900245, + SAY_9 = -1900246, + SAY_10 = -1900247, + SAY_11 = -1900248, + SAY_12 = -1900249, + SAY_13 = -1900250, + SAY_14 = -1900251, + SAY_END = -1900252, + + QUEST_HARD_WORK = 10218, + QUEST_SAFETY = 10216, + + NPC_SHAHEEN = 19671, + NPC_LABORER = 19672, + + NPC_THEURGIST = 18315, + NPC_SPELLBRINGER = 18312, + NPC_SORCERER = 18313, + NPC_RAIDER = 18311, + NPC_TERROR = 19307, + NPC_LEECH = 19306, + NPC_XIRAXIS = 19666, + + SPELL_BOLT = 38340 +}; + +struct Pos +{ + float x, y, z, o; +}; + +static Pos pos[]= +{ + {-364.60f, -60.08f, -0.96f, 0.0f}, + {-376.29f, -58.26f, -0.96f, 0.0f}, + {-385.13f, -69.05f, -0.96f, 0.0f}, + {-380.36f, -83.57f, -0.96f, 0.0f}, + {-369.68f, -85.28f, -0.96f, 0.0f}, + {-373.27f, -128.49f, -0.95f, 0.0f}, + {-373.25f, -198.86f, -0.95, 0.0f}, + {-233.20f, -173.49f, -0.95f, 0.0f}, + {-285.71f, -179.32f, -1.52, 0.0f}, + {-27.67f, -224.44f, 0.11, 3.0f}, + {-67.107f, -13.641f, -0.94, 0.0f}, + {-67.85f, -66.42f, -0.84, 0.0f} +}; + +struct npc_shaheenAI : public npc_escortAI +{ + npc_shaheenAI(Creature *creature) : npc_escortAI(creature) + { + pInstance = creature->GetInstanceData(); + } + + ScriptedInstance *pInstance; + + uint8 Part; + uint32 EventTimer; + uint8 EventStage; + uint64 XiraxisGUID; + + void Reset() + { + Part = 0; + EventTimer = 0; + EventStage = 0; + XiraxisGUID = 0; + } + + void AttackStart(Unit* who) + { + DoCast(me->getVictim(), SPELL_BOLT); + npc_escortAI::AttackStart(who); + } + + void JustSummoned(Creature* summoned) + { + switch (summoned->GetEntry()) + { + case NPC_TERROR: + break; + case NPC_XIRAXIS: + XiraxisGUID = summoned->GetGUID(); + summoned->SetReactState(REACT_PASSIVE); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + summoned->setFaction(1731); + summoned->GetMotionMaster()->MovePoint(0, pos[11].x, pos[11].y, pos[11].z); + break; + case NPC_LABORER: + summoned->GetMotionMaster()->MoveFleeing(summoned, 3000); + break; + default: + summoned->AI()->AttackStart(me); + break; + } + } + + void StartEscortPartOne (Player* player) + { + Part = 1; + AddWaypoint(0, -354.10, -67.69, -0.96, 0); + AddWaypoint(1, -354.93, -65.83, -0.96, 10000); + AddWaypoint(2, -355.44, -66.31, -0.96, 0); + AddWaypoint(3, -364.55, -72.08, -0.96, 1000); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(false, false, player->GetGUID()); + } + + void StartEscortPartTwo (Player* player) + { + Part = 2; + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + Start(true, false, player->GetGUID()); + } + + void WaypointReached(uint32 i) + { + switch (Part) + { + case 1: + switch(i) + { + case 1: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_WORK_NOSHEATHE); + break; + case 2: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + me->SummonCreature(NPC_LABORER, pos[0].x, pos[0].y, pos[0].z, pos[0].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + me->SummonCreature(NPC_LABORER, pos[1].x, pos[1].y, pos[1].z, pos[1].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + me->SummonCreature(NPC_LABORER, pos[2].x, pos[2].y, pos[2].z, pos[2].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + me->SummonCreature(NPC_LABORER, pos[3].x, pos[3].y, pos[3].z, pos[3].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + me->SummonCreature(NPC_LABORER, pos[4].x, pos[4].y, pos[4].z, pos[4].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + break; + case 3: + me->SetFacingTo(0.19f); + DoScriptText(SAY_STOP, me); + me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + break; + } + break; + case 2: + switch(i) + { + case 0: + DoScriptText(SAY_1, me); + break; + case 4: + DoScriptText(SAY_2, me); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_WORK_NOSHEATHE); + me->SummonCreature(NPC_THEURGIST, pos[5].x, pos[5].y, pos[5].z, pos[5].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_SPELLBRINGER, pos[5].x+(rand()%4), pos[5].y-(rand()%4), pos[5].z, pos[5].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_THEURGIST, pos[6].x, pos[6].y, pos[6].z, pos[6].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_SPELLBRINGER, pos[6].x+(rand()%4), pos[6].y-(rand()%4), pos[6].z, pos[6].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 5: + DoScriptText(SAY_3, me); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + break; + case 9: + DoScriptText(SAY_4, me); + me->SetFacingTo(5.19f); + break; + case 10: + DoScriptText(SAY_5, me); + me->SetFacingTo(0.76f); + break; + case 13: + DoScriptText(SAY_6, me); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_WORK_NOSHEATHE); + me->SummonCreature(NPC_SORCERER, pos[7].x, pos[7].y, pos[7].z, pos[7].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_RAIDER, pos[7].x+(rand()%4), pos[7].y-(rand()%4), pos[7].z, pos[7].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_SORCERER, pos[8].x, pos[8].y, pos[8].z, pos[8].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_RAIDER, pos[8].x+(rand()%4), pos[8].y-(rand()%4), pos[8].z, pos[8].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + break; + case 14: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + break; + case 19: + me->SummonCreature(NPC_TERROR, pos[9].x, pos[9].y, pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + break; + case 22: + DoScriptText(SAY_7, me); + EventTimer = 10000; + break; + case 24: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_WORK_NOSHEATHE); + break; + case 25: + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + DoScriptText(SAY_8, me); + break; + case 26: + DoScriptText(SAY_9, me); + break; + case 27: + DoScriptText(SAY_10, me); + break; + case 31: + EventTimer = 8000; + break; + case 32: + DoScriptText(SAY_14, me); + break; + case 33: + SetRun(); + DoScriptText(SAY_END, me); + if (Player* player = GetPlayerForEscort()) + player->GroupEventHappens(QUEST_HARD_WORK, me); + break; + } + break; + } + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if (EventTimer) + { + if (EventTimer <= diff) + { + switch (EventStage) + { + case 0: + me->SummonCreature(NPC_TERROR, pos[9].x, pos[9].y, pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y-(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y+(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y-(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y+(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y-(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + me->SummonCreature(NPC_LEECH, pos[9].x+(rand()%4), pos[9].y+(rand()%4), pos[9].z, pos[9].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + EventTimer = 0; + break; + case 1: + me->SummonCreature(NPC_XIRAXIS, pos[10].x, pos[10].y, pos[10].z, pos[10].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 300000); + EventTimer = 5000; + break; + case 2: + if (Creature* Xiraxis = (Unit::GetCreature(*me, XiraxisGUID))) + DoScriptText(SAY_11, Xiraxis); + EventTimer = 8000; + break; + case 3: + DoScriptText(SAY_12, me); + EventTimer = 8000; + break; + case 4: + if (Creature* Xiraxis = (Unit::GetCreature(*me, XiraxisGUID))) + { + DoScriptText(SAY_13, Xiraxis); + Xiraxis->SetReactState(REACT_AGGRESSIVE); + Xiraxis->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Xiraxis->setFaction(14); + Xiraxis->AI()->AttackStart(me); + } + EventTimer = 0; + break; + } + + ++EventStage; + } + else EventTimer -= diff; + } + + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_shaheen(Creature* creature) +{ + return new npc_shaheenAI(creature); +} + +bool QuestAccept_npc_shaheen(Player* player, Creature* creature, const Quest* quest) +{ + if (quest->GetQuestId() == QUEST_HARD_WORK) + { + if (npc_shaheenAI* escortAI = dynamic_cast(creature->AI())) + { + creature->setFaction(FACTION_ESCORT_N_NEUTRAL_PASSIVE); + DoScriptText(SAY_START, creature); + escortAI->StartEscortPartTwo(player); + } + } + + return true; +} + +/*###### +## go_transportercp +######*/ + +bool GOUse_go_transportercp(Player *player, GameObject* go) +{ + ScriptedInstance* pInstance = (ScriptedInstance*)go->GetInstanceData(); + + if (!pInstance) + return true; + + if (pInstance->GetData(DATA_SHAHEENEVENT) == DONE) + return true; + + if (!player->GetQuestRewardStatus(QUEST_HARD_WORK) && player->GetQuestRewardStatus(QUEST_SAFETY)) + { + pInstance->SetData(DATA_SHAHEENEVENT, DONE); + + if (Creature* shaheen = go->SummonCreature(NPC_SHAHEEN, -351.21f, -69.19f, -0.962f, 3.414f, TEMPSUMMON_CORPSE_DESPAWN, 10000)) + { + DoScriptText(SAY_INTRO, shaheen, player); + if (npc_shaheenAI* escortAI = dynamic_cast(shaheen->AI())) + escortAI->StartEscortPartOne(player); + } + } + return false; + + return true; +} + +void AddSC_mana_tombs() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_shaheen"; + newscript->GetAI = &GetAI_npc_shaheen; + newscript->pQuestAcceptNPC = &QuestAccept_npc_shaheen; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_transportercp"; + newscript->pGOUse = &GOUse_go_transportercp; + newscript->RegisterSelf(); +} \ No newline at end of file diff --git a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_anzu.cpp b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_anzu.cpp similarity index 89% rename from src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_anzu.cpp rename to src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_anzu.cpp index b2af677ec..ad24d0c74 100644 --- a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_anzu.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_anzu.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_sethekk_halls.h" diff --git a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp rename to src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp index f5c218084..2ad6564b5 --- a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -35,6 +38,9 @@ EndScriptData */ #define SAY_DEATH -1556006 +#define SAY_LAKKA -1900253 +#define NPC_LAKKA 18956 + #define SPELL_FROST_SHOCK 21401 //37865 #define SPELL_FLAME_SHOCK 34354 #define SPELL_SHADOW_SHOCK 30138 @@ -42,10 +48,8 @@ EndScriptData */ #define SPELL_CHAIN_LIGHTNING 15659 //15305 -#define SPELL_SUMMON_SYTH_FIRE 33537 // Spawns 19203 -#define SPELL_SUMMON_SYTH_ARCANE 33538 // Spawns 19205 -#define SPELL_SUMMON_SYTH_FROST 33539 // Spawns 19204 -#define SPELL_SUMMON_SYTH_SHADOW 33540 // Spawns 19206 +#define NPC_ELEMENTAL 19203 +#define NUM_ELEMENTALS 4 #define SPELL_FLAME_BUFFET (HeroicMode?38141:33526) #define SPELL_ARCANE_BUFFET (HeroicMode?38138:33527) @@ -54,8 +58,7 @@ EndScriptData */ struct boss_darkweaver_sythAI : public ScriptedAI { - boss_darkweaver_sythAI(Creature *c) : ScriptedAI(c) - + boss_darkweaver_sythAI(Creature *c) : ScriptedAI(c), summons(c) { HeroicMode = m_creature->GetMap()->IsHeroic(); pInstance = c->GetInstanceData(); @@ -63,6 +66,8 @@ struct boss_darkweaver_sythAI : public ScriptedAI ScriptedInstance *pInstance; + SummonList summons; + uint32 flameshock_timer; uint32 arcaneshock_timer; uint32 frostshock_timer; @@ -76,6 +81,8 @@ struct boss_darkweaver_sythAI : public ScriptedAI void Reset() { + summons.DespawnAll(); + flameshock_timer = 2000; arcaneshock_timer = 4000; frostshock_timer = 6000; @@ -99,8 +106,13 @@ struct boss_darkweaver_sythAI : public ScriptedAI void JustDied(Unit* Killer) { + summons.DespawnAll(); + DoScriptText(SAY_DEATH, m_creature); + if (Creature* lakka = GetClosestCreatureWithEntry(me, NPC_LAKKA, 25.0f)) + DoScriptText(SAY_LAKKA, lakka); + if(pInstance) pInstance->SetData(DATA_DARKWEAVEREVENT, DONE); } @@ -117,19 +129,26 @@ struct boss_darkweaver_sythAI : public ScriptedAI { if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0, 60, true)) summoned->AI()->AttackStart(target); + + summons.Summon(summoned); } void SythSummoning() { DoScriptText(SAY_SUMMON, m_creature); - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_SUMMON_SYTH_ARCANE,true); //front - DoCast(m_creature,SPELL_SUMMON_SYTH_FIRE,true); //back - DoCast(m_creature,SPELL_SUMMON_SYTH_FROST,true); //left - DoCast(m_creature,SPELL_SUMMON_SYTH_SHADOW,true); //right + float px, py, pz; + + for (int id = NUM_ELEMENTALS; id--; ) + { + me->GetNearPoint(px, py, pz, 0.0f, 8.0f, 0.5f * id * M_PI); + + if (Creature *elemental = me->SummonCreature(NPC_ELEMENTAL + id, px, py, pz, me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0)) + summons.Summon(elemental); + } } void UpdateAI(const uint32 diff) diff --git a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp rename to src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp index 75e9b3ff4..21f9ca49e --- a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -154,11 +157,11 @@ struct boss_talon_king_ikissAI : public ScriptedAI if (Sheep_Timer < diff) { - //second top aggro target in normal, random target in heroic correct? Unit *target = NULL; - target = HeroicMode ? SelectUnit(SELECT_TARGET_RANDOM,0, 60, true) : SelectUnit(SELECT_TARGET_TOPAGGRO,1, 60, true, m_creature->getVictimGUID()); + target = SelectUnit(SELECT_TARGET_RANDOM,0, 60, true, m_creature->getVictimGUID()); + //surely not tank (2.2.0 patchnotes), but not sure if it should be random or second aggro if (target) - DoCast(target,HeroicMode ? H_SPELL_POLYMORPH : SPELL_POLYMORPH); + DoCast(target,HeroicMode ? H_SPELL_POLYMORPH : SPELL_POLYMORPH); //don't see any difference between them Sheep_Timer = 15000+rand()%2500; } else @@ -188,7 +191,7 @@ struct boss_talon_king_ikissAI : public ScriptedAI if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0, 60, true)) { - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(false); //Spell doesn't work, but we use for visual effect at least diff --git a/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/def_sethekk_halls.h b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/def_sethekk_halls.h new file mode 100644 index 000000000..410f70b44 --- /dev/null +++ b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/def_sethekk_halls.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SETHEKK_HALLS_H +#define SC_DEF_SETHEKK_HALLS_H + +#define DATA_IKISSEVENT 1 +#define DATA_ANZUEVENT 2 +#define DATA_DARKWEAVEREVENT 3 +#define DATA_LAKKA 4 +#endif + diff --git a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp old mode 100755 new mode 100644 similarity index 58% rename from src/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp rename to src/scripts/scripts/Outland/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp index 4e767895a..2090be2b9 --- a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,17 +19,27 @@ /* ScriptData SDName: Instance - Sethekk Halls -SD%Complete: 50 +SD%Complete: 98 SDComment: Instance Data for Sethekk Halls instance SDCategory: Auchindoun, Sethekk Halls EndScriptData */ #include "precompiled.h" #include "def_sethekk_halls.h" +#include "escort_ai.h" -#define ENCOUNTERS 3 +#define ENCOUNTERS 4 #define IKISS_DOOR 177203 +#define NPC_LAKKA 18956 +#define QUEST_BROTHER 10097 + +enum LakkaStatus +{ + LAKKA_NOT_SUMMONED = 0, + LAKKA_WAIT_FOR_SUMMON = 1, + LAKKA_SUMMONED = 2 +}; struct instance_sethekk_halls : public ScriptedInstance { @@ -34,11 +47,14 @@ struct instance_sethekk_halls : public ScriptedInstance uint32 Encounter[ENCOUNTERS]; + LakkaStatus Lakka; + uint64 IkissDoorGUID; void Initialize() { IkissDoorGUID = 0; + Lakka = LAKKA_NOT_SUMMONED; for(uint8 i = 0; i < ENCOUNTERS; i++) Encounter[i] = NOT_STARTED; @@ -52,6 +68,15 @@ struct instance_sethekk_halls : public ScriptedInstance return false; } + void OnPlayerEnter(Player* player) + { + if (player->isGameMaster()) + return; + + if (player->GetQuestStatus(QUEST_BROTHER) == QUEST_STATUS_INCOMPLETE && Lakka == LAKKA_NOT_SUMMONED && !player->GetMap()->IsHeroic()) + Lakka = LAKKA_WAIT_FOR_SUMMON; + } + void OnCreatureCreate(Creature *creature, uint32 entry) { switch(entry) @@ -78,6 +103,25 @@ struct instance_sethekk_halls : public ScriptedInstance } } + void QuestCredit() + { + Map::PlayerList const& players = instance->GetPlayers(); + + if (!players.isEmpty()) + { + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if (Player* player = itr->getSource()) + { + if (player->GetQuestStatus(QUEST_BROTHER) == QUEST_STATUS_INCOMPLETE) + player->KilledMonster(NPC_LAKKA, NULL); + } + } + } + else + debug_log("TSCR: Instance Sethek Halls: PlayerList is empty!"); + } + void SetData(uint32 type, uint32 data) { switch(type) @@ -96,6 +140,12 @@ struct instance_sethekk_halls : public ScriptedInstance if(Encounter[2] != DONE) Encounter[2] = data; break; + case DATA_LAKKA: + if (data == DONE) + QuestCredit(); + else + Encounter[3] = data; + break; } if (data == DONE) @@ -109,7 +159,7 @@ struct instance_sethekk_halls : public ScriptedInstance case DATA_IKISSEVENT: return Encounter[0]; case DATA_ANZUEVENT: return Encounter[1]; case DATA_DARKWEAVEREVENT: return Encounter[2]; - + case DATA_LAKKA: return Encounter[3]; } return false; } @@ -121,7 +171,8 @@ struct instance_sethekk_halls : public ScriptedInstance std::ostringstream stream; stream << Encounter[0] << " " << Encounter[1] << " " - << Encounter[2]; + << Encounter[2] << " " + << Encounter[3]; OUT_SAVE_INST_DATA_COMPLETE; @@ -139,7 +190,7 @@ struct instance_sethekk_halls : public ScriptedInstance OUT_LOAD_INST_DATA(in); std::istringstream loadStream(in); - loadStream >> Encounter[0] >> Encounter[1] >> Encounter[2]; + loadStream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3]; for(uint8 i = 0; i < ENCOUNTERS; ++i) if (Encounter[i] == IN_PROGRESS) @@ -148,6 +199,19 @@ struct instance_sethekk_halls : public ScriptedInstance OUT_LOAD_INST_DATA_COMPLETE; } + void Update(uint32 diff) + { + if (Lakka == LAKKA_WAIT_FOR_SUMMON) + { + if (instance->GetPlayers().isEmpty()) + return; + + Player* player = instance->GetPlayers().begin()->getSource(); + player->SummonCreature(NPC_LAKKA, -158.226f, 158.690f, 0.0f, 1.21f, TEMPSUMMON_DEAD_DESPAWN, 10000); + Lakka = LAKKA_SUMMONED; + } + } + }; InstanceData* GetInstanceData_instance_sethekk_halls(Map* map) @@ -155,26 +219,51 @@ InstanceData* GetInstanceData_instance_sethekk_halls(Map* map) return new instance_sethekk_halls(map); } -#define GOSSIP_FREE "Free me, hero." -#define Q_BAB 10097 +/*##### +## npc_lakka +#####*/ + +struct npc_lakkaAI : public npc_escortAI +{ + npc_lakkaAI(Creature *creature) : npc_escortAI(creature) {} + + void Reset() {} + + void WaypointReached(uint32 i) {} +}; + +CreatureAI* GetAI_npc_lakka(Creature* pCreature) +{ + return new npc_lakkaAI(pCreature); +} + +#define GOSSIP_FREE "I'll have you out of here in just a moment." +#define SAY_FREE -1900254 +#define GO_SETHEKK_CAGE 183051 -bool GossipHello_npc_lakka(Player *player, Creature *_Creature) +bool GossipHello_npc_lakka(Player *player, Creature *creature) { - if(player->GetQuestStatus(Q_BAB) == QUEST_STATUS_INCOMPLETE) + if(player->GetQuestStatus(QUEST_BROTHER) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_FREE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(68, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(9636, creature->GetGUID()); return true; } -bool GossipSelect_npc_lakka(Player *player, Creature *_Creature, uint32 sender, uint32 action) +bool GossipSelect_npc_lakka(Player* player, Creature* creature, uint32 sender, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF+1) { player->CLOSE_GOSSIP_MENU(); - player->GroupEventHappens(Q_BAB, _Creature); - player->DealDamage(_Creature, _Creature->GetMaxHealth()); - _Creature->RemoveCorpse(); + if (GameObject* cage = FindGameObject(GO_SETHEKK_CAGE, INTERACTION_DISTANCE, creature)) + cage->UseDoorOrButton(5); + + ScriptedInstance* Instance = (creature->GetInstanceData()); + if (Instance) + Instance->SetData(DATA_LAKKA, DONE); + + DoScriptText(SAY_FREE, creature, player); + ((npc_lakkaAI*)creature->AI())->Start(false, false, player->GetGUID()); } return true; @@ -190,6 +279,7 @@ void AddSC_instance_sethekk_halls() newscript = new Script; newscript->Name = "npc_lakka"; + newscript->GetAI = &GetAI_npc_lakka; newscript->pGossipHello = &GossipHello_npc_lakka; newscript->pGossipSelect = &GossipSelect_npc_lakka; newscript->RegisterSelf(); diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp old mode 100755 new mode 100644 similarity index 81% rename from src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp rename to src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp index 6165390f6..ed74b9fc5 --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -50,7 +53,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI boss_ambassador_hellmawAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance* pInstance; @@ -80,7 +83,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI { if (pInstance->GetData(TYPE_HELLMAW) == NOT_STARTED) { - DoCast(m_creature,SPELL_BANISH, true); + DoCast(me,SPELL_BANISH, true); IsBanished = true; } } @@ -88,10 +91,10 @@ struct boss_ambassador_hellmawAI : public ScriptedAI void DoIntro() { - DoScriptText(SAY_INTRO, m_creature); + DoScriptText(SAY_INTRO, me); - if (m_creature->HasAura(SPELL_BANISH,0)) - m_creature->RemoveAurasDueToSpell(SPELL_BANISH); + if (me->HasAura(SPELL_BANISH,0)) + me->RemoveAurasDueToSpell(SPELL_BANISH); IsBanished = false; Intro = true; @@ -103,20 +106,23 @@ struct boss_ambassador_hellmawAI : public ScriptedAI void EnterCombat(Unit *who) { if(IsBanished) + { EnterEvadeMode(); + return; + } - m_creature->GetMotionMaster()->Clear(); - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), m_creature); + me->GetMotionMaster()->Clear(); + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); } void KilledUnit(Unit *victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit *victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if (pInstance) pInstance->SetData(TYPE_HELLMAW, DONE); @@ -131,7 +137,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI { if(Banish_Timer < diff) { - DoCast(m_creature,SPELL_BANISH, true); + DoCast(me,SPELL_BANISH, true); Banish_Timer = 40000; } else @@ -153,16 +159,16 @@ struct boss_ambassador_hellmawAI : public ScriptedAI EventCheck_Timer -= diff; } - if (!m_creature->isInCombat() && !IsBanished && !OnPath_Delay) + if (!me->isInCombat() && !IsBanished && !OnPath_Delay) { - m_creature->GetMotionMaster()->MovePath(PATH_PATROL, false); + me->GetMotionMaster()->MovePath(PATH_PATROL, false); OnPath_Delay = 55000; patrol = false; } - if (!m_creature->isInCombat() && !patrol && OnPath_Delay < diff) + if (!me->isInCombat() && !patrol && OnPath_Delay < diff) { - m_creature->GetMotionMaster()->MovePath(PATH_FINAL, true); + me->GetMotionMaster()->MovePath(PATH_FINAL, true); patrol = true; } else @@ -173,7 +179,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI if (CorrosiveAcid_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_CORROSIVE_ACID); + DoCast(me->getVictim(),SPELL_CORROSIVE_ACID); CorrosiveAcid_Timer = 25000; } else @@ -181,7 +187,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI if (Fear_Timer < diff) { - DoCast(m_creature,SPELL_FEAR); + DoCast(me,SPELL_FEAR); Fear_Timer = 25000; } else @@ -191,7 +197,7 @@ struct boss_ambassador_hellmawAI : public ScriptedAI { if (Enrage_Timer < diff) { - DoCast(m_creature,SPELL_ENRAGE); + DoCast(me,SPELL_ENRAGE); Enrage_Timer = 5*MINUTE*1000; } else diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp old mode 100755 new mode 100644 similarity index 93% rename from src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp rename to src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp index 3c6331946..3009cf47d --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -91,12 +94,12 @@ struct boss_blackheart_the_inciterAI : public ScriptedAI void KilledUnit(Unit *victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit *victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if( pInstance ) pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, DONE); @@ -122,13 +125,13 @@ struct boss_blackheart_the_inciterAI : public ScriptedAI for(std::list::iterator i = TrashList.begin(); i != TrashList.end(); ++i) { (*i)->setActive(true); - (*i)->AI()->AttackStart(m_creature->getVictim()); + (*i)->AI()->AttackStart(me->getVictim()); } } void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), m_creature); + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); TrashAggro(); @@ -163,9 +166,9 @@ struct boss_blackheart_the_inciterAI : public ScriptedAI if(InciteChaos_Timer < diff) { - DoCast(m_creature, SPELL_INCITE_CHAOS); + DoCast(me, SPELL_INCITE_CHAOS); - Map *map = m_creature->GetMap(); + Map *map = me->GetMap(); Map::PlayerList const &PlayerList = map->GetPlayers(); if(PlayerList.isEmpty()) @@ -202,7 +205,7 @@ struct boss_blackheart_the_inciterAI : public ScriptedAI //Knockback_Timer if (Knockback_Timer < diff) { - DoCast(m_creature, SPELL_WAR_STOMP); + DoCast(me, SPELL_WAR_STOMP); Knockback_Timer = 20000; } else diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp old mode 100755 new mode 100644 similarity index 75% rename from src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp rename to src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp index a35f67e2f..ad7881063 --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -70,7 +73,7 @@ struct mob_voidtravelerAI : public ScriptedAI { mob_voidtravelerAI(Creature *c) : ScriptedAI(c) { - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } bool HeroicMode; @@ -83,7 +86,7 @@ struct mob_voidtravelerAI : public ScriptedAI VorpilGUID = 0; move = 0; sacrificed = false; - m_creature->setActive(true); + me->setActive(true); } void EnterCombat(Unit *who){} @@ -91,35 +94,35 @@ struct mob_voidtravelerAI : public ScriptedAI void UpdateAI(const uint32 diff) { /* - if(Unit *Vorpil = Unit::GetUnit(*m_creature, VorpilGUID)) + if(Unit *Vorpil = Unit::GetUnit(*me, VorpilGUID)) { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->DealDamage(me, me->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } */ if(move < diff) { - Unit *Vorpil = Unit::GetUnit(*m_creature, VorpilGUID); + Unit *Vorpil = Unit::GetUnit(*me, VorpilGUID); if(!Vorpil) return; if(sacrificed) { Vorpil->CastSpell(Vorpil, HeroicMode?H_SPELL_EMPOWERING_SHADOWS:SPELL_EMPOWERING_SHADOWS, true); - DoCast(m_creature, SPELL_SHADOW_NOVA, true); - //m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->setDeathState(JUST_DIED); - m_creature->RemoveCorpse(); + DoCast(me, SPELL_SHADOW_NOVA, true); + //me->DealDamage(me, me->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->setDeathState(JUST_DIED); + me->RemoveCorpse(); return; } - m_creature->GetMotionMaster()->MoveFollow(Vorpil,0,0); - m_creature->SetSpeed(MOVE_RUN, 0.3f, true); + me->GetMotionMaster()->MoveFollow(Vorpil,0,0); + me->SetSpeed(MOVE_RUN, 0.3f, true); - if(m_creature->IsWithinDistInMap(Vorpil, 3)) + if(me->IsWithinDistInMap(Vorpil, 3)) { - DoCast(m_creature, SPELL_SACRIFICE, false); + DoCast(me, SPELL_SACRIFICE, false); sacrificed = true; move = 500; return; @@ -127,7 +130,7 @@ struct mob_voidtravelerAI : public ScriptedAI if(!Vorpil->isInCombat() || Vorpil->isDead()) { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->DealDamage(me, me->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } move = 1000; @@ -146,7 +149,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI boss_grandmaster_vorpilAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); Intro = false; } @@ -181,7 +184,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI for (int i = 0;i<5;i++) { Creature *Portal = NULL; - Portal = m_creature->SummonCreature(MOB_VOID_PORTAL,VoidPortalCoords[i][0],VoidPortalCoords[i][1],VoidPortalCoords[i][2],0,TEMPSUMMON_CORPSE_DESPAWN,3000000); + Portal = me->SummonCreature(MOB_VOID_PORTAL,VoidPortalCoords[i][0],VoidPortalCoords[i][1],VoidPortalCoords[i][2],0,TEMPSUMMON_CORPSE_DESPAWN,3000000); if(Portal) { PortalsGuid[i] = Portal->GetGUID(); @@ -199,7 +202,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI { for (int i = 0;i < 5; i ++) { - Unit *Portal = Unit::GetUnit((*m_creature), PortalsGuid[i]); + Unit *Portal = Unit::GetUnit((*me), PortalsGuid[i]); if (Portal && Portal->isAlive()) Portal->DealDamage(Portal, Portal->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); PortalsGuid[i] = 0; @@ -211,10 +214,10 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI void spawnVoidTraveler() { int pos = rand()%5; - m_creature->SummonCreature(MOB_VOID_TRAVELER,VoidPortalCoords[pos][0],VoidPortalCoords[pos][1],VoidPortalCoords[pos][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,5000); + me->SummonCreature(MOB_VOID_TRAVELER,VoidPortalCoords[pos][0],VoidPortalCoords[pos][1],VoidPortalCoords[pos][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,5000); if(!HelpYell) { - DoScriptText(SAY_HELP, m_creature); + DoScriptText(SAY_HELP, me); HelpYell = true; } } @@ -222,17 +225,17 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI void JustSummoned(Creature *summoned) { if (summoned && summoned->GetEntry() == MOB_VOID_TRAVELER) - ((mob_voidtravelerAI*)summoned->AI())->VorpilGUID = m_creature->GetGUID(); + ((mob_voidtravelerAI*)summoned->AI())->VorpilGUID = me->GetGUID(); } void KilledUnit(Unit *victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit *victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); destroyPortals(); if(pInstance) @@ -241,7 +244,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), m_creature); + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); summonPortals(); @@ -251,11 +254,11 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { - if(who && !m_creature->getVictim() && m_creature->canStartAttack(who)) + if(who && !me->getVictim() && me->canStartAttack(who)) AttackStart(who); - if (!Intro && who && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who)) + if (!Intro && who && me->IsWithinLOSInMap(who)&& me->IsWithinDistInMap(who, 100) && me->IsHostileTo(who)) { - DoScriptText(SAY_INTRO, m_creature); + DoScriptText(SAY_INTRO, me); Intro = true; } } @@ -267,7 +270,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI if (ShadowBoltVolley_Timer < diff) { - DoCast(m_creature,SPELL_SHADOWBOLT_VOLLEY); + DoCast(me,SPELL_SHADOWBOLT_VOLLEY); ShadowBoltVolley_Timer = 15000; } else @@ -287,17 +290,17 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI if ( DrawShadows_Timer < diff) { - Map *map = m_creature->GetMap(); + Map *map = me->GetMap(); Map::PlayerList const &PlayerList = map->GetPlayers(); for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if (Player* i_pl = i->getSource()) if (i_pl->isAlive() && !i_pl->HasAura(SPELL_BANISH,0) && !i_pl->isGameMaster()) - i_pl->TeleportTo(m_creature->GetMapId(), VorpilPosition[0],VorpilPosition[1],VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT); + i_pl->TeleportTo(me->GetMapId(), VorpilPosition[0],VorpilPosition[1],VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT); - m_creature->Relocate(VorpilPosition[0],VorpilPosition[1],VorpilPosition[2]); - DoCast(m_creature,SPELL_DRAW_SHADOWS,true); + me->Relocate(VorpilPosition[0],VorpilPosition[1],VorpilPosition[2]); + DoCast(me,SPELL_DRAW_SHADOWS,true); - DoCast(m_creature,HeroicMode?H_SPELL_RAIN_OF_FIRE:SPELL_RAIN_OF_FIRE); + DoCast(me,HeroicMode?H_SPELL_RAIN_OF_FIRE:SPELL_RAIN_OF_FIRE); ShadowBoltVolley_Timer = 6000; DrawShadows_Timer = 30000; @@ -310,7 +313,7 @@ struct boss_grandmaster_vorpilAI : public ScriptedAI spawnVoidTraveler(); summonTraveler_Timer = 10000; //enrage at 20% - if((m_creature->GetHealth()*5) < m_creature->GetMaxHealth()) + if((me->GetHealth()*5) < me->GetMaxHealth()) summonTraveler_Timer = 5000; } else diff --git a/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_murmur.cpp b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_murmur.cpp new file mode 100644 index 000000000..0a102c62a --- /dev/null +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/boss_murmur.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Murmur +SD%Complete: 90 +SDComment: TODO: add fight event when player enter in the room +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" + +#define EMOTE_SONIC_BOOM -1555036 + +#define SPELL_SONIC_BOOM_CAST (HeroicMode?38796:33923) +#define SPELL_SONIC_BOOM (HeroicMode?38795:33666) +#define SPELL_RESONANCE 33657 +#define SPELL_MURMURS_TOUCH (HeroicMode?38794:33711) +#define SPELL_MAGNETIC_PULL 33689 +#define SPELL_SONIC_SHOCK 38797 +#define SPELL_THUNDERING_STORM 39365 + +struct boss_murmurAI : public Scripted_NoMovementAI +{ + boss_murmurAI(Creature *c) : Scripted_NoMovementAI(c) + { + HeroicMode = me->GetMap()->IsHeroic(); + } + + uint32 SonicBoom_Timer; + uint32 MurmursTouch_Timer; + uint32 Resonance_Timer; + uint32 MagneticPull_Timer; + uint32 SonicShock_Timer; + uint32 ThunderingStorm_Timer; + bool HeroicMode; + + void Reset() + { + SonicBoom_Timer = (HeroicMode ? 40000 : 50000); + MurmursTouch_Timer = (HeroicMode ? 28000 : 31000); + Resonance_Timer = 5000; + MagneticPull_Timer = 45000; + ThunderingStorm_Timer = 5000; + SonicShock_Timer = 5000; + + //database should have `RegenHealth`=0 to prevent regen + uint32 hp = (me->GetMaxHealth()*40)/100; + if (hp) + me->SetHealth(hp); + + me->ResetPlayerDamageReq(); + } + + void EnterCombat(Unit *who) { } + + // Murmurs Touch heroic, maybe spell exist ? + void SpellHitTarget(Unit *target, const SpellEntry *spell) + { + if (target && target->isAlive() && spell && spell->Id == 38794) + { + std::list& m_threatlist = me->getThreatManager().getThreatList(); + for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + { + if (Unit* targets = Unit::GetUnit((*me),(*i)->getUnitGuid())) + { + if (targets->isAlive() && target->GetGUID() != (*i)->getUnitGuid()) + target->CastSpell(targets, SPELL_MAGNETIC_PULL, true); + } + } + } + + return; + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target or casting + if (!UpdateVictim() || me->IsNonMeleeSpellCast(false)) + return; + + // Murmur's Touch + if (MurmursTouch_Timer < diff) + { + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) + AddSpellToCast(target, SPELL_MURMURS_TOUCH); + + MurmursTouch_Timer = (HeroicMode ? 30000 : 20000); + } + else + MurmursTouch_Timer -= diff; + + // Resonance + if (Resonance_Timer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_NEAREST, 0, 100, true); + + if (target && !me->IsWithinMeleeRange(target)) + AddSpellToCast(me, SPELL_RESONANCE); + + Resonance_Timer = 5000; + } + else + Resonance_Timer -= diff; + + if (HeroicMode) + { + // Thundering Storm cast to all which are too far away + if (ThunderingStorm_Timer < diff) + { + std::list& m_threatlist = me->getThreatManager().getThreatList(); + for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + { + if (Unit* target = Unit::GetUnit((*me),(*i)->getUnitGuid())) + { + if (target->isAlive() && !target->IsWithinDistInMap(me, 12.0f)) + ForceSpellCast(target, SPELL_THUNDERING_STORM, DONT_INTERRUPT); + } + } + + ThunderingStorm_Timer = 7500; + } + else + ThunderingStorm_Timer -= diff; + + // Sonic Shock cast to tank if someone is too far away + if (SonicShock_Timer < diff) + { + std::list& m_threatlist = me->getThreatManager().getThreatList(); + for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + { + if (Unit* target = Unit::GetUnit((*me),(*i)->getUnitGuid())) + { + if (target->isAlive() && !target->IsWithinDistInMap(me, 12.0f)) + { + AddSpellToCast(SPELL_SONIC_SHOCK, CAST_TANK); + break; + } + } + } + + SonicShock_Timer = 2000; + } + else + SonicShock_Timer -= diff; + } + + if (!HeroicMode) + { + // Magnetic Pull normal only + if (MagneticPull_Timer < diff) + { + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) + ForceSpellCast(target, SPELL_MAGNETIC_PULL); + + MagneticPull_Timer = 40000; + } + else + MagneticPull_Timer -= diff; + } + + // Sonic Boom + if (SonicBoom_Timer < diff) + { + ForceSpellCast(me, SPELL_SONIC_BOOM, DONT_INTERRUPT, true); + ForceSpellCastWithScriptText(me, SPELL_SONIC_BOOM_CAST, EMOTE_SONIC_BOOM); + SonicBoom_Timer = (HeroicMode ? 30000 : 40000); + Resonance_Timer = 5000; + ThunderingStorm_Timer = 5000; + SonicShock_Timer = 5000; + } + else + SonicBoom_Timer -= diff; + + CastNextSpellIfAnyAndReady(); + + // Select nearest most aggro target if top aggro too far + if (!me->isAttackReady()) + return; + + if (!me->IsWithinMeleeRange(me->getVictim())) + { + std::list& m_threatlist = me->getThreatManager().getThreatList(); + for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + { + if (Unit* target = Unit::GetUnit((*me),(*i)->getUnitGuid())) + { + if (target->isAlive() && me->IsWithinMeleeRange(target)) + { + me->TauntApply(target); + break; + } + } + } + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_murmur(Creature *_Creature) +{ + return new boss_murmurAI (_Creature); +} + +void AddSC_boss_murmur() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_murmur"; + newscript->GetAI = &GetAI_boss_murmur; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h new file mode 100644 index 000000000..fa36961d5 --- /dev/null +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SHADOW_LABYRINTH_H +#define SC_DEF_SHADOW_LABYRINTH_H + +#define TYPE_HELLMAW 1 +#define TYPE_RITUALIST 2 +#define DATA_BLACKHEARTTHEINCITEREVENT 3 +#define DATA_GRANDMASTERVORPILEVENT 4 +#define DATA_MURMUREVENT 5 +#define DATA_GRANDMASTERVORPIL 6 +#endif + diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp old mode 100755 new mode 100644 similarity index 83% rename from src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp rename to src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp index 5e095d62d..03a1ec764 --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp +++ b/src/scripts/scripts/Outland/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -246,6 +249,57 @@ InstanceData* GetInstanceData_instance_shadow_labyrinth(Map* map) return new instance_shadow_labyrinth(map); } +/*###### +## npc_tortured_skeleton +######*/ + +struct npc_tortured_skeletonAI : public ScriptedAI +{ + npc_tortured_skeletonAI(Creature* creature) : ScriptedAI(creature) {} + + void Reset() + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetStandState(UNIT_STAND_STATE_DEAD); + } + + void EnterCombat(Unit* who) + { + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetStandState(UNIT_STAND_STATE_STAND); + } + + void EnterEvadeMode() + { + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(); + + if (!me->isAlive()) + return; + + me->GetMotionMaster()->MoveTargetedHome(); + } + + void JustReachedHome() + { + Reset(); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_tortured_skeleton(Creature* creature) +{ + return new npc_tortured_skeletonAI (creature); +} + void AddSC_instance_shadow_labyrinth() { Script *newscript; @@ -253,5 +307,10 @@ void AddSC_instance_shadow_labyrinth() newscript->Name = "instance_shadow_labyrinth"; newscript->GetInstanceData = &GetInstanceData_instance_shadow_labyrinth; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_tortured_skeleton"; + newscript->GetAI = &GetAI_npc_tortured_skeleton; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/black_temple/black_temple.cpp b/src/scripts/scripts/Outland/black_temple/black_temple.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/black_temple/black_temple.cpp rename to src/scripts/scripts/Outland/black_temple/black_temple.cpp index de4e7a75b..e54d1d953 --- a/src/scripts/scripts/zone/black_temple/black_temple.cpp +++ b/src/scripts/scripts/Outland/black_temple/black_temple.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/black_temple/black_temple_trash.cpp b/src/scripts/scripts/Outland/black_temple/black_temple_trash.cpp similarity index 99% rename from src/scripts/scripts/zone/black_temple/black_temple_trash.cpp rename to src/scripts/scripts/Outland/black_temple/black_temple_trash.cpp index 84bd36dce..0c2669dda 100644 --- a/src/scripts/scripts/zone/black_temple/black_temple_trash.cpp +++ b/src/scripts/scripts/Outland/black_temple/black_temple_trash.cpp @@ -1,8 +1,19 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -86,7 +97,7 @@ struct mob_aqueous_lordAI : public ScriptedAI { if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) { - target->GetClosePoint(temp.coord_x, temp.coord_y, temp.coord_z, 15.0); + target->GetNearPoint(temp.coord_x, temp.coord_y, temp.coord_z, 15.0); Creature* Spawn = me->SummonCreature(NPC_AQUEOUS_SPAWN, temp.coord_x, temp.coord_y, temp.coord_z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); Spawn->AI()->AttackStart(target); } @@ -832,12 +843,12 @@ struct mob_bonechewer_taskmasterAI : public ScriptedAI mob_bonechewer_taskmasterAI(Creature *c) : ScriptedAI(c) { me->SetAggroRange(AGGRO_RANGE); } uint32 disgruntledTimer; - bool disgruntledCasted; + bool disgruntledCast; void Reset() { disgruntledTimer = 20000; - disgruntledCasted = false; + disgruntledCast = false; } void EnterCombat(Unit *who) @@ -846,7 +857,7 @@ struct mob_bonechewer_taskmasterAI : public ScriptedAI if (urand(0, 100) < 25) { me->CastSpell(me, SPELL_BONECHEWER_DISGRUNTLED, false); - disgruntledCasted = true; + disgruntledCast = true; } } @@ -860,12 +871,12 @@ struct mob_bonechewer_taskmasterAI : public ScriptedAI if(!UpdateVictim()) return; - if (!disgruntledCasted) + if (!disgruntledCast) { if (disgruntledTimer < diff || me->GetHealth()*100/me->GetMaxHealth() < 75) { me->CastSpell(me, SPELL_BONECHEWER_DISGRUNTLED, false); - disgruntledCasted = true; + disgruntledCast = true; } else disgruntledTimer -= diff; @@ -1013,7 +1024,7 @@ struct mob_dragonmaw_skystalkerAI : public ScriptedAI { me->SetLevitate(false); - if (!me->IsNonMeleeSpellCasted(false)) + if (!me->IsNonMeleeSpellCast(false)) { DoResetThreat(); victim = GetNewTarget(); @@ -1125,7 +1136,7 @@ struct mob_dragonmaw_windreaverAI : public ScriptedAI if (me->IsWithinDistInMap(victim, 10)) { me->SetLevitate(false); - if (!me->IsNonMeleeSpellCasted(false)) + if (!me->IsNonMeleeSpellCast(false)) { DoResetThreat(); victim = GetNewTarget(); @@ -1829,7 +1840,7 @@ struct mob_ashtongue_primalistAI : public ScriptedAI AddSpellToCast(me->getVictim(), SPELL_SWEEPING_WING_CLIP); float x, y, z; - me->GetClosePoint(x,y,z,0.0f, urand(10,15), frand(0.0f, 2*M_PI)); + me->GetNearPoint(x,y,z,0.0f, urand(10,15), frand(0.0f, 2*M_PI)); me->GetMotionMaster()->MovePoint(1, x,y,z); SweepingWingClip = 37000; } @@ -4422,7 +4433,7 @@ struct mob_pristess_of_dementiaAI: public ScriptedAI { if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200.0f, true)) { - target->GetClosePoint(x, y, z, 5.0f); + target->GetNearPoint(x, y, z, 5.0f); me->SummonCreature(NPC_IMAGE_OF_DEMENTIA, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 15000); } } @@ -4847,7 +4858,7 @@ struct mob_spellbound_attendentAI: public ScriptedAI if(!UpdateVictim()) return; - if(me->getVictim() && me->getVictim()->IsNonMeleeSpellCasted(false) && !cooldown) + if(me->getVictim() && me->getVictim()->IsNonMeleeSpellCast(false) && !cooldown) { ForceSpellCast(me->getVictim(), SPELL_KICK, INTERRUPT_AND_CAST_INSTANTLY); cooldown = true; diff --git a/src/scripts/scripts/zone/black_temple/boss_bloodboil.cpp b/src/scripts/scripts/Outland/black_temple/boss_bloodboil.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/black_temple/boss_bloodboil.cpp rename to src/scripts/scripts/Outland/black_temple/boss_bloodboil.cpp index 46bc9bdb7..20c51b13a --- a/src/scripts/scripts/zone/black_temple/boss_bloodboil.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_bloodboil.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/scripts/scripts/Outland/black_temple/boss_illidan.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/black_temple/boss_illidan.cpp rename to src/scripts/scripts/Outland/black_temple/boss_illidan.cpp index cb177df53..b9d27b951 --- a/src/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_illidan.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_illidan_stormrage @@ -102,7 +105,7 @@ enum IllidanSpell SPELL_ILLIDAN_ENRAGE = 40683, // Phase 2 spells - SPELL_ILLIDAN_THROW_GLAIVE = 39635, + SPELL_ILLIDAN_THROW_GLAIVE = 39849, SPELL_ILLIDAN_GLAIVE_RETURN = 39873, SPELL_ILLIDAN_FIREBALL = 40598, SPELL_ILLIDAN_DARK_BARRAGE = 40585, @@ -163,12 +166,13 @@ enum IllidanEvent // Phase: Maiev summon EVENT_ILLIDAN_SUMMON_MAIEV = 28, - EVENT_ILLIDAN_CAGE_TRAP = 29, + EVENT_ILLIDAN_INPRISON_RAID = 29, + EVENT_ILLIDAN_CAGE_TRAP = 30, - EVENT_ILLIDAN_KILL = 30, - EVENT_ILLIDAN_DEATH_SPEECH = 31, + EVENT_ILLIDAN_KILL = 31, + EVENT_ILLIDAN_DEATH_SPEECH = 32, - EVENT_ILLIDAN_FLAME_DEATH = 32, + EVENT_ILLIDAN_FLAME_DEATH = 33, EVENT_ILLIDAN_RANDOM_YELL }; @@ -213,10 +217,7 @@ class GlaiveTargetRespawner void operator()(Creature* u) const { if (u->GetEntry() == GLAIVE_TARGET) - { - u->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); u->Respawn(); - } } void operator()(GameObject* u) const { } void operator()(WorldObject*) const {} @@ -387,7 +388,7 @@ struct boss_illidan_stormrageAI : public BossAI me->AttackStop(); me->SetReactState(REACT_PASSIVE); - ForceSpellCastWithScriptText(SPELL_ILLIDAN_INPRISON_RAID, CAST_SELF, YELL_ILLIDAN_INPRISON_RAID); + events.ScheduleEvent(EVENT_ILLIDAN_INPRISON_RAID, 500, m_phase); events.ScheduleEvent(EVENT_ILLIDAN_SUMMON_MAIEV, 6000, m_phase); break; } @@ -526,10 +527,10 @@ struct boss_illidan_stormrageAI : public BossAI if (Creature *pGlaive = GetClosestCreatureWithEntry(pTrigger, GLAIVE_TARGET, 70.0f, true)) { WorldLocation final; - pTrigger->GetClosePoint(final.coord_x, final.coord_y, final.coord_z, 80.0f, false, pTrigger->GetAngle(pGlaive)); + pTrigger->GetNearPoint(final.coord_x, final.coord_y, final.coord_z, 80.0f, false, pTrigger->GetAngle(pGlaive)); final.coord_z = 354.519f; pTrigger->SetSpeed(MOVE_RUN, 1.0f); - pTrigger->GetMotionMaster()->MovePoint(0, final.coord_x, final.coord_y, final.coord_z, UNIT_ACTION_CONTROLLED); + pTrigger->GetMotionMaster()->MovePoint(0, final.coord_x, final.coord_y, final.coord_z, true, UNIT_ACTION_CONTROLLED); pTrigger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -564,15 +565,14 @@ struct boss_illidan_stormrageAI : public BossAI { me->SetLevitate(false); me->HandleEmoteCommand(EMOTE_ONESHOT_LAND); - - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->SetReactState(REACT_AGGRESSIVE); ChangePhase(PHASE_THREE); break; } case EVENT_ILLIDAN_RETURN_GLAIVE: { - // implement SPELL_ILLIDAN_GLAIVE_RETURN visual + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + summons.Cast(BLADE_OF_AZZINOTH, SPELL_ILLIDAN_GLAIVE_RETURN, me); summons.DespawnEntry(BLADE_OF_AZZINOTH); events.ScheduleEvent(EVENT_ILLIDAN_LAND, 1000, m_phase); break; @@ -732,6 +732,11 @@ struct boss_illidan_stormrageAI : public BossAI { switch (eventId) { + case EVENT_ILLIDAN_INPRISON_RAID: + { + ForceSpellCastWithScriptText(SPELL_ILLIDAN_INPRISON_RAID, CAST_SELF, YELL_ILLIDAN_INPRISON_RAID, INTERRUPT_AND_CAST_INSTANTLY, true); + break; + } case EVENT_ILLIDAN_SUMMON_MAIEV: { ForceSpellCast(me, SPELL_ILLIDAN_SUMMON_MAIEV); @@ -928,10 +933,10 @@ struct boss_illidan_stormrageAI : public BossAI if (!UpdateVictim()) return; + DoSpecialThings(diff, DO_EVERYTHING, 200.0f, 2.5f); + if (m_combatTimer < diff) { - DoSpecialThings(diff, DO_EVERYTHING, 200.0f, 2.5f); - if (Creature *pAkama = instance->GetCreature(instance->GetData64(DATA_AKAMA))) DoModifyThreatPercent(pAkama, -101); @@ -1257,7 +1262,7 @@ struct boss_illidan_akamaAI : public BossAI if (Creature *pIllidan = instance->GetCreature(instance->GetData64(DATA_ILLIDANSTORMRAGE))) { float x,y,z; - pIllidan->GetClosePoint(x, y, z, 0.0f, 8.0f, -pIllidan->GetAngle(CENTER_X, CENTER_Y)); + pIllidan->GetNearPoint(x, y, z, 0.0f, 8.0f, -pIllidan->GetAngle(CENTER_X, CENTER_Y)); me->Relocate(x, y, z); me->SendHeartBeat(); @@ -1331,6 +1336,7 @@ struct boss_illidan_akamaAI : public BossAI me->SetSelection(pIllidan->GetGUID()); pIllidan->SetSelection(me->GetGUID()); pIllidan->RemoveAurasDueToSpell(SPELL_ILLIDAN_KNEEL_INTRO); + me->SetFacingToObject(pIllidan); DoScriptText(SAY_ILLIDAN_NO1, pIllidan); } @@ -1479,7 +1485,7 @@ struct boss_illidan_maievAI : public BossAI if (Creature *pIllidan = instance->GetCreature(instance->GetData64(DATA_ILLIDANSTORMRAGE))) { float x, y, z; - pIllidan->GetClosePoint(x, y, z, 0.0f, 45.0f, -pIllidan->GetAngle(CENTER_X, CENTER_Y)); + pIllidan->GetNearPoint(x, y, z, 0.0f, 45.0f, -pIllidan->GetAngle(CENTER_X, CENTER_Y)); z = 354.519; me->Relocate(x, y, z); @@ -1509,7 +1515,7 @@ struct boss_illidan_maievAI : public BossAI me->GetMotionMaster()->Clear(false); float x, y, z; - me->GetClosePoint(x, y, z, 0.0f, 25.0f, frand(0, 2*M_PI)); + me->GetNearPoint(x, y, z, 0.0f, 25.0f, frand(0, 2*M_PI)); z = 354.519; me->Relocate(x, y, z); @@ -1530,7 +1536,7 @@ struct boss_illidan_maievAI : public BossAI if (Creature *pIllidan = instance->GetCreature(instance->GetData64(DATA_ILLIDANSTORMRAGE))) { float x, y, z; - pIllidan->GetClosePoint(x, y, z, 0.0f, 7.0f, pIllidan->GetOrientation()); + pIllidan->GetNearPoint(x, y, z, 0.0f, 7.0f, pIllidan->GetOrientation()); z = 354.519; me->Relocate(x, y, z); diff --git a/src/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp b/src/scripts/scripts/Outland/black_temple/boss_mother_shahraz.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp rename to src/scripts/scripts/Outland/black_temple/boss_mother_shahraz.cpp index e4d6a1913..b9625b5d8 --- a/src/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_mother_shahraz.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -219,7 +222,10 @@ struct boss_shahrazAI : public ScriptedAI if (m_checkTimer < diff) { if(me->GetDistance(wLoc.coord_x, wLoc.coord_y, wLoc.coord_z) > 110) + { EnterEvadeMode(); + return; + } DoZoneInCombat(); me->SetSpeed(MOVE_RUN, 3.0); diff --git a/src/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp b/src/scripts/scripts/Outland/black_temple/boss_reliquary_of_souls.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp rename to src/scripts/scripts/Outland/black_temple/boss_reliquary_of_souls.cpp index 59aa5cba0..20d097f34 --- a/src/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_reliquary_of_souls.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Reliquary_of_Souls @@ -255,11 +258,11 @@ struct boss_reliquary_of_soulsAI : public Scripted_NoMovementAI bool FindPlayers() { - std::list& m_threatlist = me->getThreatManager().getThreatList(); + std::list& m_threatlist = me->getThreatManager().getThreatList(); if(m_threatlist.empty()) return false; - for(std::list::iterator itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) + for(std::list::iterator itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) { Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); if(pUnit && pUnit->isAlive() && pUnit->isInCombat() && me->canAttack(pUnit) && pUnit->IsWithinDistInMap(me, 100.0f)) @@ -292,6 +295,7 @@ struct boss_reliquary_of_soulsAI : public Scripted_NoMovementAI if(Creature *Essence = Unit::GetCreature(*me, EssenceGUID)) { Essence->Kill(Essence, false); + Essence->SetLootRecipient(NULL); Essence->RemoveCorpse(); } } @@ -690,7 +694,7 @@ struct boss_essence_of_desireAI : public ScriptedAI { if(spell->Effect[i] == SPELL_EFFECT_INTERRUPT_CAST) { - SpellEntry const *temp = me->m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellInfo(); + SpellEntry const *temp = me->m_currentSpells[CURRENT_GENERIC_SPELL]->GetSpellEntry(); if(temp->Id == SPELL_SOUL_SHOCK || temp->Id == SPELL_DEADEN) { me->InterruptSpell(CURRENT_GENERIC_SPELL, false); diff --git a/src/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/scripts/scripts/Outland/black_temple/boss_shade_of_akama.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp rename to src/scripts/scripts/Outland/black_temple/boss_shade_of_akama.cpp index 7757b10cf..562ac030f --- a/src/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_shade_of_akama.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -660,7 +663,7 @@ struct mob_ashtongue_sorcererAI : public ScriptedAI if (m_checkTimer < diff) { - if (!me->IsNonMeleeSpellCasted(true, false, true)) // that shouldn't happen + if (!me->IsNonMeleeSpellCast(true, false, true)) // that shouldn't happen { if (Unit *pShade = me->GetUnit(*me, m_shadeGUID)) { @@ -830,7 +833,7 @@ struct boss_shade_of_akamaAI : public ScriptedAI m_sorcerers.push_back(pSorcerer->GetGUID()); WorldLocation sLoc; - me->GetClosePoint(sLoc.coord_x, sLoc.coord_y, sLoc.coord_z, 0, 10.0f, frand(4.30, 5.31)); + me->GetNearPoint(sLoc.coord_x, sLoc.coord_y, sLoc.coord_z, 0, 10.0f, frand(4.30, 5.31)); pSorcerer->GetMotionMaster()->MovePoint(0, sLoc.coord_x, sLoc.coord_y, sLoc.coord_z); } m_sorcTimer = 30000; @@ -1302,6 +1305,7 @@ struct npc_akamaAI : public Scripted_NoMovementAI if (Creature *pShade = me->GetCreature(*me, ShadeGUID)) { + me->InterruptNonMeleeSpells(false); AttackStart(pShade); return me->getVictim(); } diff --git a/src/scripts/scripts/zone/black_temple/boss_supremus.cpp b/src/scripts/scripts/Outland/black_temple/boss_supremus.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/black_temple/boss_supremus.cpp rename to src/scripts/scripts/Outland/black_temple/boss_supremus.cpp index ff00a0a36..f007bb716 --- a/src/scripts/scripts/zone/black_temple/boss_supremus.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_supremus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -172,8 +175,8 @@ struct boss_supremusAI : public ScriptedAI uint32 health = 0; Unit* target = NULL; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) { Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); @@ -255,7 +258,7 @@ struct boss_supremusAI : public ScriptedAI if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true, m_creature->getVictimGUID())) { DoResetThreat(); - m_creature->getThreatManager().setCurrentVictim((HostilReference*)target); + m_creature->getThreatManager().setCurrentVictim((HostileReference*)target); m_creature->AI()->AttackStart(target); m_creature->AddThreat(target, 5000000.0f); DoScriptText(EMOTE_NEW_TARGET, m_creature, 0, true); diff --git a/src/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp b/src/scripts/scripts/Outland/black_temple/boss_teron_gorefiend.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp rename to src/scripts/scripts/Outland/black_temple/boss_teron_gorefiend.cpp index f933fba27..feff5e126 --- a/src/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_teron_gorefiend.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -381,6 +384,10 @@ struct boss_teron_gorefiendAI : public ScriptedAI if(pInstance) pInstance->SetData(EVENT_TERONGOREFIEND, DONE); + const Map::PlayerList& players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) + i->getSource()->RemoveAurasDueToSpell(SPELL_SHADOW_OF_DEATH); + DoScriptText(SAY_DEATH, m_creature); } @@ -425,8 +432,8 @@ struct boss_teron_gorefiendAI : public ScriptedAI { if(!Blossom) return; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); for(i = m_threatlist.begin(); i != m_threatlist.end(); i++) { Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); diff --git a/src/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp b/src/scripts/scripts/Outland/black_temple/boss_warlord_najentus.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp rename to src/scripts/scripts/Outland/black_temple/boss_warlord_najentus.cpp index 98a6d04f0..2cd85812f --- a/src/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp +++ b/src/scripts/scripts/Outland/black_temple/boss_warlord_najentus.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/black_temple/def_black_temple.h b/src/scripts/scripts/Outland/black_temple/def_black_temple.h old mode 100755 new mode 100644 similarity index 62% rename from src/scripts/scripts/zone/black_temple/def_black_temple.h rename to src/scripts/scripts/Outland/black_temple/def_black_temple.h index 6126aabf3..e4da76bf8 --- a/src/scripts/scripts/zone/black_temple/def_black_temple.h +++ b/src/scripts/scripts/Outland/black_temple/def_black_temple.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_BLACK_TEMPLE_H -#define DEF_BLACK_TEMPLE_H +#ifndef SC_DEF_BLACK_TEMPLE_H +#define SC_DEF_BLACK_TEMPLE_H #define DATA_AKAMA 1 #define DATA_AKAMA_SHADE 2 diff --git a/src/scripts/scripts/zone/black_temple/illidari_council.cpp b/src/scripts/scripts/Outland/black_temple/illidari_council.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/black_temple/illidari_council.cpp rename to src/scripts/scripts/Outland/black_temple/illidari_council.cpp index e4a736864..eff5feafc --- a/src/scripts/scripts/zone/black_temple/illidari_council.cpp +++ b/src/scripts/scripts/Outland/black_temple/illidari_council.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -587,14 +590,22 @@ struct boss_high_nethermancer_zerevorAI : public illidari_council_baseAI EnterEvadeMode(); return; } - - if (me->GetDistance2d(me->getVictim()) <= 40.0f) - me->GetMotionMaster()->MoveIdle(); + + if (me->GetDistance(me->getVictim()) <= 40.0f) + { + me->SetFacingToObject(me->getVictim()); // he is getting stuck sometimes + me->StopMoving(); + + } + else - me->GetMotionMaster()->MoveChase(me->getVictim(), 40); + DoStartMovement(me->getVictim()); + //me->GetMotionMaster()->MoveChase(me->getVictim(), 40.0f); // It's not working. Simply. + + // On front stairs, do not let boss to go into textures; - //CheckStairsPos(); + CheckStairsPos(); uint32 damage = 0; SharedRule(damage); @@ -646,8 +657,8 @@ struct boss_high_nethermancer_zerevorAI : public illidari_council_baseAI if (m_aexpTimer < diff) { - std::list& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) + std::list& m_threatlist = me->getThreatManager().getThreatList(); + for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) { if (Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid())) { diff --git a/src/scripts/scripts/zone/black_temple/instance_black_temple.cpp b/src/scripts/scripts/Outland/black_temple/instance_black_temple.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/black_temple/instance_black_temple.cpp rename to src/scripts/scripts/Outland/black_temple/instance_black_temple.cpp index a7a753493..ca1c1a05d --- a/src/scripts/scripts/zone/black_temple/instance_black_temple.cpp +++ b/src/scripts/scripts/Outland/black_temple/instance_black_temple.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Black_Temple diff --git a/src/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp b/src/scripts/scripts/Outland/blades_edge_mountains/blades_edge_mountains.cpp old mode 100755 new mode 100644 similarity index 63% rename from src/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp rename to src/scripts/scripts/Outland/blades_edge_mountains/blades_edge_mountains.cpp index c8a011330..f0f488cde --- a/src/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp +++ b/src/scripts/scripts/Outland/blades_edge_mountains/blades_edge_mountains.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,13 +19,12 @@ /* ScriptData SDName: Blades_Edge_Mountains -SD%Complete: 90 -SDComment: Quest support: 10503, 10504, 10556, 10609, 10682, 10980. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete) +SD%Complete: 98 +SDComment: Quest support: 10503, 10504, 10556, 10609, 10682, 10980, 10518, 10859, 10674, 11058 ,11080, 11059, 10675, 10867, 10557, 10710, 10711, 10712, 10821, 10911, 10723, 10802, 11000, 11026, 11051. Assault on Bash'ir Landing!. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete) SDCategory: Blade's Edge Mountains EndScriptData */ /* ContentData -mobs_bladespire_ogre mobs_nether_drake npc_daranelle npc_overseer_nuaar @@ -30,9 +32,26 @@ npc_saikkal_the_elder npc_skyguard_handler_irena npc_bloodmaul_brutebane npc_ogre_brute +npc_vim_bunny npc_aether_ray npc_wildlord_antelarion npc_kolphis_darkscale +npc_prophecy_trigger +go_thunderspike +go_apexis_relic +go_simon_cluster +npc_simon_bunny +npc_orb_attracter +npc_razaan_event +npc_razaani_raide +npc_rally_zapnabber +npc_anger_camp +go_obeliks +npc_cannon_target +npc_gargrom +npc_soulgrinder +npc_bashir_landing +npc_banishing_crystal EndContentData */ #include "precompiled.h" @@ -41,11 +60,11 @@ EndContentData */ ## mobs_nether_drake ######*/ -#define SAY_NIHIL_1 -1000396 -#define SAY_NIHIL_2 -1000397 -#define SAY_NIHIL_3 -1000398 -#define SAY_NIHIL_4 -1000399 -#define SAY_NIHIL_INTERRUPT -1000400 +#define SAY_NIHIL_1 -1000396 +#define SAY_NIHIL_2 -1000397 +#define SAY_NIHIL_3 -1000398 +#define SAY_NIHIL_4 -1000399 +#define SAY_NIHIL_INTERRUPT -1000400 #define ENTRY_WHELP 20021 #define ENTRY_PROTO 21821 @@ -61,7 +80,7 @@ EndContentData */ struct mobs_nether_drakeAI : public ScriptedAI { - mobs_nether_drakeAI(Creature *c) : ScriptedAI(c) {} + mobs_nether_drakeAI(Creature* creature) : ScriptedAI(creature) {} bool IsNihil; uint32 NihilSpeech_Timer; @@ -76,9 +95,9 @@ struct mobs_nether_drakeAI : public ScriptedAI NihilSpeech_Timer = 2000; IsNihil = false; - if( m_creature->GetEntry() == ENTRY_NIHIL ) + if (me->GetEntry() == ENTRY_NIHIL) { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); IsNihil = true; } @@ -89,13 +108,13 @@ struct mobs_nether_drakeAI : public ScriptedAI IntangiblePresence_Timer = 15000; } - void SpellHit(Unit *caster, const SpellEntry *spell) + void SpellHit(Unit* caster, const SpellEntry* spell) { - if( spell->Id == SPELL_T_PHASE_MODULATOR && caster->GetTypeId() == TYPEID_PLAYER ) + if (spell->Id == SPELL_T_PHASE_MODULATOR && caster->GetTypeId() == TYPEID_PLAYER) { uint32 cEntry = 0; - switch( m_creature->GetEntry() ) + switch (me->GetEntry()) { case ENTRY_WHELP: cEntry = RAND(ENTRY_PROTO, ENTRY_ADOLE, ENTRY_MATUR, ENTRY_NIHIL); @@ -110,25 +129,25 @@ struct mobs_nether_drakeAI : public ScriptedAI cEntry = RAND(ENTRY_PROTO, ENTRY_ADOLE, ENTRY_NIHIL); break; case ENTRY_NIHIL: - if( NihilSpeech_Phase ) + if (NihilSpeech_Phase) { - DoScriptText(SAY_NIHIL_INTERRUPT, m_creature); + DoScriptText(SAY_NIHIL_INTERRUPT, me); IsNihil = false; cEntry = RAND(ENTRY_PROTO, ENTRY_ADOLE, ENTRY_MATUR); } break; } - if( cEntry ) + if (cEntry) { - m_creature->UpdateEntry(cEntry); + me->UpdateEntry(cEntry); - if( cEntry == ENTRY_NIHIL ) + if (cEntry == ENTRY_NIHIL) { - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(true); + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); Reset(); } } @@ -137,35 +156,35 @@ struct mobs_nether_drakeAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if( IsNihil ) + if (IsNihil) { - if( NihilSpeech_Phase ) + if (NihilSpeech_Phase) { - if(NihilSpeech_Timer <= diff) + if (NihilSpeech_Timer <= diff) { - switch( NihilSpeech_Phase ) + switch (NihilSpeech_Phase) { case 1: - DoScriptText(SAY_NIHIL_1, m_creature); + DoScriptText(SAY_NIHIL_1, me); ++NihilSpeech_Phase; break; case 2: - DoScriptText(SAY_NIHIL_2, m_creature); + DoScriptText(SAY_NIHIL_2, me); ++NihilSpeech_Phase; break; case 3: - DoScriptText(SAY_NIHIL_3, m_creature); + DoScriptText(SAY_NIHIL_3, me); ++NihilSpeech_Phase; break; case 4: - DoScriptText(SAY_NIHIL_4, m_creature); + DoScriptText(SAY_NIHIL_4, me); ++NihilSpeech_Phase; break; case 5: - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetLevitate(true); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetLevitate(true); //then take off to random location. creature is initially summoned, so don't bother do anything else. - m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+100, m_creature->GetPositionY(), m_creature->GetPositionZ()+100); + me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+100, me->GetPositionY(), me->GetPositionZ()+100); NihilSpeech_Phase = 0; break; } @@ -177,30 +196,30 @@ struct mobs_nether_drakeAI : public ScriptedAI return; //anything below here is not interesting for Nihil, so skip it } - if( !UpdateVictim() ) + if (!UpdateVictim()) return; - if( IntangiblePresence_Timer <= diff ) + if (IntangiblePresence_Timer <= diff) { - DoCast(m_creature->getVictim(),SPELL_INTANGIBLE_PRESENCE); + DoCast(me->getVictim(),SPELL_INTANGIBLE_PRESENCE); IntangiblePresence_Timer = 15000+rand()%15000; } else IntangiblePresence_Timer -= diff; - if( ManaBurn_Timer <= diff ) + if (ManaBurn_Timer <= diff) { - Unit* target = m_creature->getVictim(); - if( target && target->getPowerType() == POWER_MANA ) + Unit* target = me->getVictim(); + if (target && target->getPowerType() == POWER_MANA) DoCast(target,SPELL_MANA_BURN); ManaBurn_Timer = 8000+rand()%8000; } else ManaBurn_Timer -= diff; - if( ArcaneBlast_Timer <= diff ) + if (ArcaneBlast_Timer <= diff) { - DoCast(m_creature->getVictim(),SPELL_ARCANE_BLAST); + DoCast(me->getVictim(),SPELL_ARCANE_BLAST); ArcaneBlast_Timer = 2500+rand()%5000; } else @@ -209,9 +228,9 @@ struct mobs_nether_drakeAI : public ScriptedAI DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_mobs_nether_drake(Creature *_Creature) +CreatureAI* GetAI_mobs_nether_drake(Creature* creature) { - return new mobs_nether_drakeAI (_Creature); + return new mobs_nether_drakeAI (creature); } /*###### @@ -222,21 +241,21 @@ CreatureAI* GetAI_mobs_nether_drake(Creature *_Creature) struct npc_daranelleAI : public ScriptedAI { - npc_daranelleAI(Creature *c) : ScriptedAI(c) {} + npc_daranelleAI(Creature* creature) : ScriptedAI(creature) {} void Reset() { } - void MoveInLineOfSight(Unit *who) + void MoveInLineOfSight(Unit* who) { if (who->GetTypeId() == TYPEID_PLAYER) { - if(who->HasAura(36904,0)) + if (who->HasAura(36904,0)) { - DoScriptText(SAY_DARANELLE, m_creature, who); + DoScriptText(SAY_DARANELLE, me, who); //TODO: Move the below to updateAI and run if this statement == true - ((Player*)who)->KilledMonster(21511, m_creature->GetGUID()); + ((Player*)who)->KilledMonster(21511, me->GetGUID()); ((Player*)who)->RemoveAurasDueToSpell(36904); } } @@ -245,9 +264,9 @@ struct npc_daranelleAI : public ScriptedAI } }; -CreatureAI* GetAI_npc_daranelle(Creature *_Creature) +CreatureAI* GetAI_npc_daranelle(Creature* creature) { - return new npc_daranelleAI (_Creature); + return new npc_daranelleAI (creature); } /*###### @@ -256,21 +275,21 @@ CreatureAI* GetAI_npc_daranelle(Creature *_Creature) #define GOSSIP_HON "Overseer, I am here to negotiate on behalf of the Cenarion Expedition." -bool GossipHello_npc_overseer_nuaar(Player *player, Creature *_Creature) +bool GossipHello_npc_overseer_nuaar(Player* player, Creature* creature) { if (player->GetQuestStatus(10682) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_HON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, GOSSIP_HON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(10532, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(10532, creature->GetGUID()); return true; } -bool GossipSelect_npc_overseer_nuaar(Player *player, Creature *_Creature, uint32 sender, uint32 action) +bool GossipSelect_npc_overseer_nuaar(Player* player, Creature* creature, uint32 sender, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF+1) { - player->SEND_GOSSIP_MENU(10533, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(10533, creature->GetGUID()); player->AreaExploredOrEventHappens(10682); } return true; @@ -283,27 +302,27 @@ bool GossipSelect_npc_overseer_nuaar(Player *player, Creature *_Creature, uint32 #define GOSSIP_HSTE "Yes... yes, it's me." #define GOSSIP_SSTE "Yes elder. Tell me more of the book." -bool GossipHello_npc_saikkal_the_elder(Player *player, Creature *_Creature) +bool GossipHello_npc_saikkal_the_elder(Player* player, Creature* creature) { if (player->GetQuestStatus(10980) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_HSTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, GOSSIP_HSTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(10794, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(10794, creature->GetGUID()); return true; } -bool GossipSelect_npc_saikkal_the_elder(Player *player, Creature *_Creature, uint32 sender, uint32 action) +bool GossipSelect_npc_saikkal_the_elder(Player* player, Creature* creature, uint32 sender, uint32 action) { switch (action) { case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_SSTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(10795, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_SSTE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(10795, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+2: - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - player->SEND_GOSSIP_MENU(10796, _Creature->GetGUID()); + player->TalkedToCreature(creature->GetEntry(), creature->GetGUID()); + player->SEND_GOSSIP_MENU(10796, creature->GetGUID()); break; } return true; @@ -315,20 +334,20 @@ bool GossipSelect_npc_saikkal_the_elder(Player *player, Creature *_Creature, uin #define GOSSIP_SKYGUARD "Fly me to Skettis please" -bool GossipHello_npc_skyguard_handler_irena(Player *player, Creature *_Creature ) +bool GossipHello_npc_skyguard_handler_irena(Player* player, Creature* creature) { - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); if (player->GetReputationMgr().GetRank(1031) >= REP_HONORED) - player->ADD_GOSSIP_ITEM( 2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(creature->GetNpcTextId(), creature->GetGUID()); return true; } -bool GossipSelect_npc_skyguard_handler_irena(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_skyguard_handler_irena(Player* player, Creature* creature, uint32 sender, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF+1) { @@ -357,16 +376,16 @@ enum eBloodmaul struct npc_bloodmaul_brutebaneAI : public ScriptedAI { - npc_bloodmaul_brutebaneAI(Creature *c) : ScriptedAI(c){} + npc_bloodmaul_brutebaneAI(Creature* creature) : ScriptedAI(creature){} - void IsSummonedBy(Unit *pOwner) + void IsSummonedBy(Unit* pOwner) { if (Creature* pOgre = GetClosestCreatureWithEntry(me, NPC_OGRE_BRUTE, 50.0f)) { pOgre->SetReactState(REACT_DEFENSIVE); - pOgre->GetMotionMaster()->MovePoint(1, m_creature->GetPositionX()-1, m_creature->GetPositionY()+1, m_creature->GetPositionZ()); + pOgre->GetMotionMaster()->MovePoint(1, me->GetPositionX()-1, me->GetPositionY()+1, me->GetPositionZ()); - if (Player *plOwner = pOwner->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Player* plOwner = pOwner->GetCharmerOrOwnerPlayerOrPlayerItself()) plOwner->KilledMonster(NPC_QUEST_CREDIT, pOgre->GetGUID()); } } @@ -374,9 +393,9 @@ struct npc_bloodmaul_brutebaneAI : public ScriptedAI void UpdateAI(const uint32 uiDiff){} }; -CreatureAI* GetAI_npc_bloodmaul_brutebane(Creature* pCreature) +CreatureAI* GetAI_npc_bloodmaul_brutebane(Creature* creature) { - return new npc_bloodmaul_brutebaneAI (pCreature); + return new npc_bloodmaul_brutebaneAI (creature); } /*###### @@ -385,7 +404,7 @@ CreatureAI* GetAI_npc_bloodmaul_brutebane(Creature* pCreature) struct npc_ogre_bruteAI : public ScriptedAI { - npc_ogre_bruteAI(Creature *c) : ScriptedAI(c){} + npc_ogre_bruteAI(Creature* creature) : ScriptedAI(creature){} void MovementInform(uint32 type, uint32 id) { @@ -413,9 +432,9 @@ struct npc_ogre_bruteAI : public ScriptedAI } }; -CreatureAI* GetAI_npc_ogre_brute(Creature* pCreature) +CreatureAI* GetAI_npc_ogre_brute(Creature* creature) { - return new npc_ogre_bruteAI(pCreature); + return new npc_ogre_bruteAI(creature); } /*###### @@ -429,7 +448,7 @@ CreatureAI* GetAI_npc_ogre_brute(Creature* pCreature) struct npc_vim_bunnyAI : public ScriptedAI { - npc_vim_bunnyAI(Creature *c) : ScriptedAI(c){} + npc_vim_bunnyAI(Creature* creature) : ScriptedAI(creature){} uint32 CheckTimer; @@ -440,21 +459,21 @@ struct npc_vim_bunnyAI : public ScriptedAI bool GetPlayer() { - Player *pPlayer = NULL; - Hellground::AnyPlayerInObjectRangeCheck p_check(m_creature, 3.0f); + Player* pPlayer = NULL; + Hellground::AnyPlayerInObjectRangeCheck p_check(me, 3.0f); Hellground::ObjectSearcher searcher(pPlayer, p_check); - Cell::VisitAllObjects(m_creature, searcher, 3.0f); + Cell::VisitAllObjects(me, searcher, 3.0f); return pPlayer; } void UpdateAI(const uint32 diff) { - if(CheckTimer < diff) + if (CheckTimer < diff) { - if(me->GetDistance2d(3279.80f, 4639.76f) < 5.0) + if (me->GetDistance2d(3279.80f, 4639.76f) < 5.0) { - if(GetClosestCreatureWithEntry(me, MAIN_SPAWN, 80.0f)) + if (GetClosestCreatureWithEntry(me, MAIN_SPAWN, 80.0f)) { CheckTimer = 20000; return; @@ -462,7 +481,7 @@ struct npc_vim_bunnyAI : public ScriptedAI // WE NEED HERE TO BE SURE THAT SPAWN IS VALID ! std::list triggers = FindAllCreaturesWithEntry(PENTAGRAM_TRIGGER, 50.0); - if(triggers.size() >= 5) + if (triggers.size() >= 5) { DoSpawnCreature(MAIN_SPAWN,0,0,0,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000); CheckTimer = 20000; @@ -472,9 +491,9 @@ struct npc_vim_bunnyAI : public ScriptedAI } else { - if(GetPlayer()) + if (GetPlayer()) { - Unit *temp = DoSpawnCreature(PENTAGRAM_TRIGGER,0,0,2.0,0, TEMPSUMMON_TIMED_DESPAWN, 15000); + Unit* temp = DoSpawnCreature(PENTAGRAM_TRIGGER,0,0,2.0,0, TEMPSUMMON_TIMED_DESPAWN, 15000); temp->CastSpell(temp, SPELL_PENTAGRAM, false); CheckTimer = 16000; return; @@ -487,9 +506,9 @@ struct npc_vim_bunnyAI : public ScriptedAI } }; -CreatureAI* GetAI_npc_vim_bunny(Creature *_Creature) +CreatureAI* GetAI_npc_vim_bunny(Creature* creature) { - return new npc_vim_bunnyAI (_Creature); + return new npc_vim_bunnyAI (creature); } /*###### @@ -503,8 +522,7 @@ CreatureAI* GetAI_npc_vim_bunny(Creature *_Creature) struct mob_aetherrayAI : public ScriptedAI { - - mob_aetherrayAI(Creature *c) : ScriptedAI(c) {} + mob_aetherrayAI(Creature* creature) : ScriptedAI(creature) {} bool Weak; uint64 PlayerGUID; @@ -514,15 +532,15 @@ struct mob_aetherrayAI : public ScriptedAI Weak = false; } - void EnterCombat(Unit *who) + void EnterCombat(Unit* who) { - if(Player *player = who->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Player* player = who->GetCharmerOrOwnerPlayerOrPlayerItself()) PlayerGUID = player->GetGUID(); } void JustSummoned(Creature* summoned) { - summoned->GetMotionMaster()->MoveFollow(Unit::GetPlayer(PlayerGUID), PET_FOLLOW_DIST, m_creature->GetFollowAngle()); + summoned->GetMotionMaster()->MoveFollow(Unit::GetPlayer(PlayerGUID), PET_FOLLOW_DIST, me->GetFollowAngle()); } void UpdateAI(const uint32 diff) @@ -531,24 +549,24 @@ struct mob_aetherrayAI : public ScriptedAI if (!UpdateVictim()) return; - if(PlayerGUID) // start: support for quest 11066 and 11065 + if (PlayerGUID) // start: support for quest 11066 and 11065 { Player* target = Unit::GetPlayer(PlayerGUID); - if(target && !Weak && m_creature->GetHealth() < (m_creature->GetMaxHealth() / 100 * 40) + if (target && !Weak && me->GetHealth() < (me->GetMaxHealth() / 100 *40) && (target->GetQuestStatus(11066) == QUEST_STATUS_INCOMPLETE || target->GetQuestStatus(11065) == QUEST_STATUS_INCOMPLETE)) { me->MonsterTextEmote(EMOTE_WEAK, 0, false); Weak = true; } - if(Weak && m_creature->HasAura(40856, 0)) + if (Weak && me->HasAura(40856, 0)) { me->CastSpell(target, SPELL_SUMMON_WRANGLED, false); - target->KilledMonster(23343, m_creature->GetGUID()); - m_creature->AttackStop(); // delete the normal mob - m_creature->DealDamage(m_creature, m_creature->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); + target->KilledMonster(23343, me->GetGUID()); + me->AttackStop(); // delete the normal mob + me->DealDamage(me, me->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->RemoveCorpse(); } } @@ -558,9 +576,9 @@ struct mob_aetherrayAI : public ScriptedAI }; -CreatureAI* GetAI_mob_aetherray(Creature *_Creature) +CreatureAI* GetAI_mob_aetherray(Creature* creature) { - return new mob_aetherrayAI (_Creature); + return new mob_aetherrayAI (creature); } /*#### @@ -568,29 +586,43 @@ CreatureAI* GetAI_mob_aetherray(Creature *_Creature) ####*/ #define GOSSIP_ITEM_WILDLORD "Restore Felsworn Gas Mask." +#define GOSSIP_ITEM2_WILDLORD "Restore Druid Signal" -bool GossipHello_npc_wildlord_antelarion(Player *player, Creature *_Creature) +bool GossipHello_npc_wildlord_antelarion(Player* player, Creature* creature) { - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if(player->GetQuestStatus(10819) || player->GetQuestStatus(10820) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(31366,1)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_WILDLORD, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + if (creature->isQuestGiver()) + { + player->PrepareQuestMenu(creature->GetGUID()); + + if (player->GetQuestStatus(10819) || player->GetQuestStatus(10820) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(31366,1)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_WILDLORD, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO); + + if (player->GetQuestStatus(10910) || player->GetQuestStatus(10910) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(31763,1)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM2_WILDLORD, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO+1); + + player->SEND_GOSSIP_MENU(creature->GetNpcTextId(), creature->GetGUID()); + } return true; } -bool GossipSelect_npc_wildlord_antelarion(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_wildlord_antelarion(Player* player, Creature* creature, uint32 sender, uint32 action) { - if( action == GOSSIP_SENDER_INFO ) + uint32 entry = 0; + if (action == GOSSIP_SENDER_INFO) + entry = 31366; + else if (action == GOSSIP_SENDER_INFO +1) + entry = 31763; + + if (entry != 0) { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 31366, 1); - if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, 31366, true); - player->SendNewItem(item,1,true,false,true); - } - player->CLOSE_GOSSIP_MENU(); + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, entry, 1); + if (msg == EQUIP_ERR_OK) + { + Item* item = player->StoreNewItem(dest, entry, true); + player->SendNewItem(item,1,true,false,true); + } + player->CLOSE_GOSSIP_MENU(); } return true; } @@ -605,42 +637,43 @@ bool GossipSelect_npc_wildlord_antelarion(Player *player, Creature *_Creature, u #define GOSSIP_ITEM_KOLPHIS4 "Impressive. When do we attack?" #define GOSSIP_ITEM_KOLPHIS5 "Absolutely!" -bool GossipHello_npc_kolphis_darkscale(Player *player, Creature *_Creature) +bool GossipHello_npc_kolphis_darkscale(Player* player, Creature* creature) { - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if(player->GetQuestStatus(10722) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KOLPHIS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1 ); - player->SEND_GOSSIP_MENU(25019, _Creature->GetGUID()); -return true; + if (creature->isQuestGiver()) + player->PrepareQuestMenu(creature->GetGUID()); + if (player->GetQuestStatus(10722) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KOLPHIS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(25019, creature->GetGUID()); + + return true; } -bool GossipSelect_npc_kolphis_darkscale(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_kolphis_darkscale(Player* player, Creature* creature, uint32 sender, uint32 action) { switch (action) { case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KOLPHIS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(25020, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KOLPHIS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(25020, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KOLPHIS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(25021, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KOLPHIS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(25021, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KOLPHIS4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(25022, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KOLPHIS4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(25022, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KOLPHIS5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(25023, _Creature->GetGUID()); + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_KOLPHIS5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(25023, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: player->CompleteQuest(10722); - player->SEND_GOSSIP_MENU(25024, _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(25024, creature->GetGUID()); break; } -return true; + return true; } /*######### @@ -649,18 +682,18 @@ return true; struct npc_prophecy_triggerAI : public ScriptedAI { - npc_prophecy_triggerAI(Creature *c) : ScriptedAI(c) + npc_prophecy_triggerAI(Creature* creature) : ScriptedAI(creature) { me->SetReactState(REACT_AGGRESSIVE); } - void MoveInLineOfSight(Unit *pWho) + void MoveInLineOfSight(Unit* pWho) { - if (Player *plWho = pWho->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (Player* plWho = pWho->GetCharmerOrOwnerPlayerOrPlayerItself()) { if (plWho->GetQuestStatus(10607) == QUEST_STATUS_INCOMPLETE && plWho->HasAura(37466,0) && plWho->GetDistance(me) < 20.0f) { - switch(me->GetEntry()) + switch (me->GetEntry()) { case 22798: me->Whisper("From the darkest night shall rise again the raven, shall take flight in the shadows, shall reveal the nature of its kind. Prepare yourself for its coming, for the faithful shall be elevated to take flight with the raven, the rest be forgotten to walk upon the ground, clipped wings and shame.", plWho->GetGUID()); @@ -683,9 +716,9 @@ struct npc_prophecy_triggerAI : public ScriptedAI } }; -CreatureAI* GetAI_npc_prophecy_trigger(Creature *_Creature) +CreatureAI* GetAI_npc_prophecy_trigger(Creature* creature) { - return new npc_prophecy_triggerAI(_Creature); + return new npc_prophecy_triggerAI(creature); } /*######### @@ -696,12 +729,12 @@ CreatureAI* GetAI_npc_prophecy_trigger(Creature *_Creature) #define Q_THE_THUNDERSPIKE 10526 #define GOR_GRIMGUT_ENTRY 21319 -bool GOUse_go_thunderspike(Player *player, GameObject* _GO) +bool GOUse_go_thunderspike(Player* player, GameObject* go) { if (player->GetQuestStatus(Q_THE_THUNDERSPIKE) == QUEST_STATUS_INCOMPLETE) { // to prevent spawn spam :) - if (Creature *pGor = GetClosestCreatureWithEntry(player, GOR_GRIMGUT_ENTRY, 50.0f)) + if (Creature* pGor = GetClosestCreatureWithEntry(player, GOR_GRIMGUT_ENTRY, 50.0f)) { if (!pGor->getVictim() && pGor->isAlive()) pGor->AI()->AttackStart(player); @@ -1052,7 +1085,7 @@ struct npc_simon_bunnyAI : public ScriptedAI /* Called when AI is playing the sequence for player. We cast the visual spell and then remove the - casted color from the casting sequence. + cast color from the casting sequence. */ void PlayNextColor() { @@ -1312,7 +1345,7 @@ struct AttractOrbs { if (Player* player = itr->getSource()) { - if(totem->IsWithinDistInMap(player, 15.0f) && (player->GetQuestStatus(10674) || player->GetQuestStatus(10859) == QUEST_STATUS_INCOMPLETE)) + if (totem->IsWithinDistInMap(player, 15.0f) && (player->GetQuestStatus(10674) || player->GetQuestStatus(10859) == QUEST_STATUS_INCOMPLETE)) player->KilledMonster(NPC_QUEST_CREDIT2, totem->GetGUID()); } } @@ -1321,7 +1354,7 @@ struct AttractOrbs struct npc_orb_attracterAI : public Scripted_NoMovementAI { - npc_orb_attracterAI(Creature *c) : Scripted_NoMovementAI(c) {} + npc_orb_attracterAI(Creature* creature) : Scripted_NoMovementAI(creature) {} TimeTrackerSmall attractTimer; @@ -1330,7 +1363,7 @@ struct npc_orb_attracterAI : public Scripted_NoMovementAI me->SetReactState(REACT_PASSIVE); attractTimer.Reset(1500); me->ForcedDespawn(10000); - } + } void UpdateAI(const uint32 diff) { @@ -1476,7 +1509,7 @@ struct npc_razaani_raiderAI : public ScriptedAI if (!tmpMap) return; - if (Creature * eorb = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_EORB))) + if (Creature* eorb = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_EORB))) { summoned->SetLevitate(true); summoned->GetMotionMaster()->MovePoint(0, eorb->GetPositionX(), eorb->GetPositionY(), eorb->GetPositionZ()); @@ -1485,7 +1518,7 @@ struct npc_razaani_raiderAI : public ScriptedAI void JustDied(Unit* who) { - if (PlayerGUID != NULL) + if (PlayerGUID != 0) { me->SummonCreature(NPC_DEADSOUL, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()+3, me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 20000); @@ -1494,7 +1527,7 @@ struct npc_razaani_raiderAI : public ScriptedAI if (!tmpMap) return; - if (Creature * eorb = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_EORB))) + if (Creature* eorb = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_EORB))) CAST_AI(npc_razaan_eventAI, eorb->AI())->HeyYa(); } } @@ -1601,7 +1634,7 @@ struct npc_rally_zapnabberAI : public ScriptedAI player->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN); - switch(flights) + switch (flights) { case 1: DoTeleportPlayer(player, Port[0], Port[1], Port[2], 5.1f); @@ -1624,7 +1657,7 @@ struct npc_rally_zapnabberAI : public ScriptedAI if (!tmpMap) return; - if (Creature * channeler = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_CHANNELER))) + if (Creature* channeler = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_CHANNELER))) channeler->CastSpell(channeler, SPELL_CANNON_CHANNEL, true); Flight = true; @@ -1637,7 +1670,7 @@ struct npc_rally_zapnabberAI : public ScriptedAI { if (Player* player = me->GetPlayer(playerGUID)) { - switch(flights) + switch (flights) { case 1: player->GetUnitStateMgr().DropAction(UNIT_ACTION_STUN); @@ -1679,11 +1712,11 @@ struct npc_rally_zapnabberAI : public ScriptedAI if (!tmpMap) return; - if (Creature * target = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_CH_TARGET))) + if (Creature* target = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_CH_TARGET))) { ++Count; - switch(Count) + switch (Count) { case 1: target->CastSpell(target, SPELL_STATE1, true); @@ -1751,12 +1784,12 @@ bool GossipHello_npc_rally_zapnabber(Player* player, Creature* creature) return true; } -bool GossipSelect_npc_rally_zapnabber(Player* player, Creature* creature, uint32 sender, uint32 action ) +bool GossipSelect_npc_rally_zapnabber(Player* player, Creature* creature, uint32 sender, uint32 action) { uint8 flight; flight = 0; - switch(action) + switch (action) { case GOSSIP_ACTION_INFO_DEF + 1: flight = 1; @@ -1858,7 +1891,7 @@ CreatureAI* GetAI_npc_anger_camp(Creature* creature) return new npc_anger_campAI (creature); } -bool GOUse_go_obeliks(Player *player, GameObject* go) +bool GOUse_go_obeliks(Player* player, GameObject* go) { if (player->GetQuestStatus(QUEST_FIRED) == QUEST_STATUS_INCOMPLETE) { @@ -2003,13 +2036,733 @@ CreatureAI* GetAI_npc_cannon_target(Creature* creature) return new npc_cannon_targetAI (creature); } +/*###### +## npc_gargrom +######*/ + +#define GO_TEMP 185232 + +struct Pos +{ + float x, y, z; +}; + +static Pos sum[]= +{ + {3610.64f, 7180.36f, 139.98f}, + {3611.35f, 7179.39f, 140.10f} +}; + +struct npc_gargromAI : public ScriptedAI +{ + npc_gargromAI(Creature* creature) : ScriptedAI(creature) {} + + void Reset() + { + me->SetWalk(true); + me->GetMotionMaster()->MovePoint(0, sum[0].x, sum[0].y, sum[0].z); + } + + void MovementInform(uint32 type, uint32 id) + { + if (type == POINT_MOTION_TYPE) + { + me->setDeathState(JUST_DIED); + me->SummonGameObject(GO_TEMP, sum[1].x, sum[1].y, sum[1].z, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 25); + me->SummonGameObject(GO_TEMP, sum[1].x-(rand()%4), sum[1].y-(rand()%4), sum[1].z, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 25); + } + } +}; + +CreatureAI* GetAI_npc_gargrom(Creature* creature) +{ + return new npc_gargromAI (creature); +} + +/*###### +## npc_soulgrinder +######*/ + +enum +{ + SPELL_VRITUAL = 39918, + SPELL_GTRANSFORM = 39916, + SPELL_RBEAM = 39920, + SPELL_SHADOWFORMONE = 39943, + SPELL_SHADOWFORMTWO = 39944, + SPELL_SHADOWFORMTHREE = 39946, + SPELL_SHADOWFORMFOUR = 39947, + + NPC_SOULGRINGER = 23019, + NPC_SSPIRIT = 22912, + NPC_BRITUAL = 23037, + NPC_SCULLOC = 22910, + + QUEST_SOULGRINGER = 11000 +}; + +struct Ev +{ + float x, y, z, o; +}; + +static Ev ent[]= +{ + {3493.81f, 5530.01f, 19.57f, 0.80f}, + {3466.89f, 5566.49f, 20.24f, 0.30f}, + {3486.58f, 5551.74f, 7.51f, 0.65f}, + {3515.08f, 5527.14f, 20.17f, 1.20f}, + {3470.48f, 5583.96f, 20.68f, 6.20f} +}; + +struct npc_soulgrinderAI : public ScriptedAI +{ + npc_soulgrinderAI(Creature* creature) : ScriptedAI(creature), summons(me) {} + + bool DoSpawns; + + SummonList summons; + uint32 SpawnTimer; + uint32 BeamTimer; + uint8 Count; + uint64 PlayerGUID; + uint64 SkullocGUID; + + void Reset() + { + if (Creature* bm = GetClosestCreatureWithEntry(me, NPC_SOULGRINGER, 10.0f)) + { + if (me->GetGUID() != bm->GetGUID()) + me->ForcedDespawn(); + } + + DoSpawns = true; + SpawnTimer = 5000; + BeamTimer = 35000; + Count = 0; + PlayerGUID = 0; + SkullocGUID = 0; + DoCast(me, SPELL_VRITUAL, true); + INeedTarget(); + } + + void INeedTarget() + { + Map* map = me->GetMap(); + Map::PlayerList const &PlayerList = map->GetPlayers(); + + for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + { + if (Player* player = itr->getSource()) + { + if (me->IsWithinDistInMap(player, 10.0f) && player->GetQuestStatus(QUEST_SOULGRINGER) == QUEST_STATUS_INCOMPLETE) + PlayerGUID = player->GetGUID(); + } + } + } + + void DoSpawn() + { + float fx, fy, fz; + + me->GetNearPoint(fx, fy, fz, 0.0f, 20.0f, 0.0f); + me->SummonCreature(NPC_SSPIRIT, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + me->GetNearPoint(fx, fy, fz, 0.0f, 20.0f, 4.6f); + me->SummonCreature(NPC_SSPIRIT, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + + if (roll_chance_i(60)) + { + me->GetNearPoint(fx, fy, fz, 0.0f, 20.0f, 1.5f); + me->SummonCreature(NPC_SSPIRIT, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + } + + if (roll_chance_i(50)) + { + me->GetNearPoint(fx, fy, fz, 0.0f, 20.0f, 3.1f); + me->SummonCreature(NPC_SSPIRIT, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + } + } + + void JustSummoned(Creature* summoned) + { + summons.Summon(summoned); + + if (summoned->GetEntry() == NPC_SSPIRIT) + { + summoned->CastSpell(summoned , SPELL_GTRANSFORM, true); + + if (Unit* target = me->GetPlayer(PlayerGUID)) + summoned->AI()->AttackStart(target); + } + + if (summoned->GetEntry() == NPC_BRITUAL) + { + summoned->CastSpell(me, SPELL_RBEAM, true); + } + else + { + if (summoned->GetEntry() == NPC_SCULLOC) + SkullocGUID = summoned->GetGUID(); + } + } + + void Beam() + { + ++Count; + + switch (Count) + { + case 1: + DoCast(me, SPELL_SHADOWFORMONE, true); + me->SummonCreature(NPC_BRITUAL, ent[0].x, ent[0].y, ent[0].z, ent[0].o, TEMPSUMMON_DEAD_DESPAWN, 5000); + break; + case 2: + DoCast(me, SPELL_SHADOWFORMTWO, true); + me->SummonCreature(NPC_BRITUAL, ent[1].x, ent[1].y, ent[1].z, ent[1].o, TEMPSUMMON_DEAD_DESPAWN, 5000); + me->SummonCreature(NPC_SCULLOC, ent[2].x, ent[2].y, ent[2].z, ent[2].o, TEMPSUMMON_DEAD_DESPAWN, 5000); + break; + case 3: + DoCast(me, SPELL_SHADOWFORMTHREE, true); + me->SummonCreature(NPC_BRITUAL, ent[3].x, ent[3].y, ent[3].z, ent[3].o, TEMPSUMMON_DEAD_DESPAWN, 5000); + break; + case 4: + DoCast(me, SPELL_SHADOWFORMFOUR, true); + me->SummonCreature(NPC_BRITUAL, ent[4].x, ent[4].y, ent[4].z, ent[4].o, TEMPSUMMON_DEAD_DESPAWN, 5000); + break; + case 5: + DoSpawns = false; + summons.DespawnEntry(NPC_BRITUAL); + + if (Creature* Skulloc = me->GetCreature(SkullocGUID)) + Skulloc->CastSpell(me, SPELL_RBEAM, true); + break; + case 6: + summons.DespawnEntry(NPC_SSPIRIT); + + if (Creature* Skulloc = me->GetCreature(SkullocGUID)) + Skulloc->SetVisibility(VISIBILITY_OFF); + + summons.DespawnEntry(NPC_SCULLOC); + + if (Creature* Skulloc = me->SummonCreature(NPC_SCULLOC, ent[2].x, ent[2].y, ent[2].z, ent[2].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) + { + Skulloc->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + if (Unit* target = me->GetPlayer(PlayerGUID)) + Skulloc->AI()->AttackStart(target); + } + me->ForcedDespawn(); + break; + } + + } + + void UpdateAI(const uint32 diff) + { + if (DoSpawns) + { + if (SpawnTimer <= diff) + { + DoSpawn(); + + SpawnTimer = 20000; + } + else SpawnTimer -= diff; + } + + if (BeamTimer <= diff) + { + Beam(); + + if (Count == 5) + BeamTimer = 5000; + else BeamTimer = 80000; + } + else BeamTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_soulgrinder(Creature* creature) +{ + return new npc_soulgrinderAI (creature); +} + +/*###### +## Assault on Bash'ir Landing! +######*/ + +enum +{ + YELL_AETHER_1 = -1900226, + YELL_AETHER_2 = -1900227, + YELL_AETHER_3 = -1900230, + YELL_AETHER_4 = -1900232, + YELL_ASSISTANT = -1900228, + YELL_ADEPT = -1900229, + YELL_MASTER = -1900231, + + NPC_SSLAVE = 23246, + NPC_FFIEND = 23249, + NPC_SUBPRIMAL = 23247, + NPC_CONTROLLER = 23368, + NPC_HARBRINGER = 23390, + NPC_INQUISITOR = 23414, + NPC_RECKONER = 23332, + NPC_GCOLLECTOR = 23333, + NPC_DISRUPTORT = 23250, + NPC_AETHER = 23241, + NPC_ASSISTANT = 23243, + NPC_ADEPT = 23244, + NPC_MASTER = 23245, + NPC_SRANGER = 23242, + NPC_LIEUTENANT = 23430 +}; + +struct Assault +{ + float x, y, z, o; +}; + +static Assault AssaultPos[]= +{ + { 4014.87f, 5891.27f, 267.870f, 0.608f }, + { 4018.21f, 5888.22f, 267.870f, 1.271f }, + { 4013.54f, 5895.92f, 267.870f, 6.138f }, + { 2529.85f, 7323.99f, 375.353, 5.834f }, + { 3063.00f, 6708.12f, 585.281, 5.834f }, +}; + +static Assault AssaultPosone[]= +{ + { 3975.04f, 5860.19f, 266.310, 0.674f }, + { 3974.83f, 5871.05f, 265.135, 0.674f }, + { 3966.80f, 5874.23f, 265.294, 0.674f }, + { 3969.07f, 5884.81f, 266.298, 0.674f }, + { 3981.83f, 5856.02f, 266.298, 0.674f }, + { 3981.12f, 5845.82f, 266.712, 0.674f }, + { 3989.52f, 5845.91f, 266.793, 0.674f }, + { 3968.80f, 5856.74f, 266.725, 0.674f } +}; + +static Assault AssaultPostwo[]= +{ + { 4005.12f, 5894.48f, 267.348, 4.926f }, + { 4014.66f, 5880.12f, 267.871, 2.499f }, + { 4011.16f, 5888.21f, 267.826, 3.779f } +}; + +struct npc_bashir_landingAI : public ScriptedAI +{ + npc_bashir_landingAI(Creature* creature) : ScriptedAI(creature), summons(me) {} + + bool Assault; + bool CanStart; + bool Next; + + SummonList summons; + std::list attackers; + + uint32 CheckTimer; + uint32 SpawnTimer; + uint32 StartSpawnTimer; + uint32 EndTimer; + uint8 Wave; + uint64 AetherGUID; + uint64 CollectorGUID; + + void Reset() + { + CanStart = true; + Assault = false; + Next = true; + CheckTimer = 3000; + SpawnTimer = 60000; + StartSpawnTimer = 240000; + EndTimer = 1500000; + attackers.clear(); + Wave = 0; + AetherGUID = 0; + CollectorGUID = 0; + SpawnDefenders(); + } + + void SpawnDefenders() + { + for (int i = 0; i < 4; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_AETHER, AssaultPos[i].x, AssaultPos[i].y, AssaultPos[i].z, AssaultPos[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 1: + me->SummonCreature(NPC_SRANGER, AssaultPos[i].x, AssaultPos[i].y, AssaultPos[i].z, AssaultPos[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 2: + me->SummonCreature(NPC_SRANGER, AssaultPos[i].x, AssaultPos[i].y, AssaultPos[i].z, AssaultPos[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 3: + me->SummonCreature(NPC_LIEUTENANT, AssaultPos[i].x, AssaultPos[i].y, AssaultPos[i].z, AssaultPos[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + } + } + } + + void JustSummoned(Creature* summoned) + { + summons.Summon(summoned); + + if (summoned->GetEntry() == NPC_SRANGER) + summoned->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USESTANDING); + + if (summoned->GetEntry() == NPC_SUBPRIMAL || + summoned->GetEntry() == NPC_CONTROLLER || + summoned->GetEntry() == NPC_HARBRINGER || + summoned->GetEntry() == NPC_INQUISITOR || + summoned->GetEntry() == NPC_RECKONER) + { + attackers.push_back(summoned->GetGUID()); + summoned->GetMotionMaster()->MoveFleeing(summoned, 3000); + } + + if (summoned->GetEntry() == NPC_SSLAVE || + summoned->GetEntry() == NPC_FFIEND) + { + attackers.push_back(summoned->GetGUID()); + summoned->GetMotionMaster()->MoveFleeing(summoned, 3000); + + if (Creature* Aether = me->GetCreature(AetherGUID)) + summoned->AI()->AttackStart(Aether); + } + + if (summoned->GetEntry() == NPC_GCOLLECTOR) + { + attackers.push_back(summoned->GetGUID()); + CollectorGUID = summoned->GetGUID(); + summoned->SetReactState(REACT_PASSIVE); + } + + if (summoned->GetEntry() == NPC_DISRUPTORT) + { + attackers.push_back(summoned->GetGUID()); + if (Creature* Aether = me->GetCreature(AetherGUID)) + Aether->AI()->AttackStart(summoned); + } + + if (summoned->GetEntry() == NPC_AETHER) + { + AetherGUID = summoned->GetGUID(); + DoScriptText(YELL_AETHER_1, summoned); + summoned->SetReactState(REACT_AGGRESSIVE); + summoned->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USESTANDING); + } + + if (summoned->GetEntry() == NPC_ASSISTANT) + DoScriptText(YELL_ASSISTANT, summoned); + + if (summoned->GetEntry() == NPC_ADEPT) + DoScriptText(YELL_ADEPT, summoned); + + if (summoned->GetEntry() == NPC_MASTER) + { + DoScriptText(YELL_MASTER, summoned); + if (Creature* Aether = me->GetCreature(AetherGUID)) + DoScriptText(YELL_AETHER_4, Aether); + } + + if (summoned->GetEntry() == NPC_LIEUTENANT) + { + summoned->Mount(21152); + summoned->SetLevitate(true); + summoned->SetSpeed(MOVE_FLIGHT, 1.00f); + summoned->GetMotionMaster()->MovePoint(0, AssaultPos[4].x, AssaultPos[4].y, AssaultPos[4].z); + summoned->ForcedDespawn(40000); + } + } + + void NextWave() + { + ++Wave; + + switch (Wave) + { + case 1: //1.1 + for (int i = 0; i < 7; i++) + me->SummonCreature(NPC_SSLAVE, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 2: //1.2 + for (int i = 0; i < 7; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_FFIEND, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + me->SummonCreature(NPC_SSLAVE, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + } + } + Next = false; + break; + case 3: //2.1 + me->SummonCreature(NPC_ASSISTANT, AssaultPostwo[0].x, AssaultPostwo[0].y, AssaultPostwo[0].z, AssaultPostwo[0].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + + for (int i = 0; i < 7; i++) + me->SummonCreature(NPC_SUBPRIMAL, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + + for (int i = 0; i < 7; i++) + me->SummonCreature(NPC_SSLAVE, AssaultPosone[i].x+(rand()%6), AssaultPosone[i].y+(rand()%6), AssaultPosone[i].z, AssaultPos[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + + Next = true; + break; + case 4: //2.2 + if (Creature* Aether = me->GetCreature(AetherGUID)) + DoScriptText(YELL_AETHER_2, Aether); + + for (int i = 0; i < 7; i++) + { + switch (i) + { + case 0: + case 3: + case 6: + me->SummonCreature(NPC_DISRUPTORT, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 1: + case 2: + case 4: + case 5: + me->SummonCreature(NPC_SUBPRIMAL, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + } + } + Next = false; + break; + case 5: //3.1 + me->SummonCreature(NPC_ADEPT, AssaultPostwo[1].x, AssaultPostwo[1].y, AssaultPostwo[1].z, AssaultPostwo[1].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + + for (int i = 0; i < 7; i++) + { + switch (i) + { + case 0: + me->SummonCreature(NPC_CONTROLLER, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 3: + case 6: + me->SummonCreature(NPC_HARBRINGER, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 1: + case 4: + me->SummonCreature(NPC_INQUISITOR, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 2: + case 5: + me->SummonCreature(NPC_RECKONER, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + } + } + Next = true; + break; + case 6: //3.2 + if (Creature* Aether = me->GetCreature(AetherGUID)) + DoScriptText(YELL_AETHER_3, Aether); + + for (int i = 0; i < 8; i++) + { + switch (i) + { + case 1: + case 4: + me->SummonCreature(NPC_INQUISITOR, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 2: + case 5: + me->SummonCreature(NPC_RECKONER, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 0: + case 3: + case 6: + me->SummonCreature(NPC_HARBRINGER, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + case 7: + me->SummonCreature(NPC_GCOLLECTOR, AssaultPosone[i].x, AssaultPosone[i].y, AssaultPosone[i].z, AssaultPosone[i].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + break; + } + } + break; + case 7: + if (Creature* Aether = me->GetCreature(AetherGUID)) + { + if (Creature* Collector = me->GetCreature(CollectorGUID)) + { + Collector->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Collector->SetReactState(REACT_AGGRESSIVE); + Collector->AI()->AttackStart(Aether); + } + } + Next = false; + break; + case 8: + me->SummonCreature(NPC_MASTER, AssaultPostwo[2].x, AssaultPostwo[2].y, AssaultPostwo[2].z, AssaultPostwo[2].o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1500000); + Assault = true; + break; + } + } + + void EventFail() + { + summons.DespawnAll(); + attackers.clear(); + Assault = true; + } + + void UpdateAI(const uint32 diff) + { + if (!Assault) + { + if (CheckTimer <= diff) + { + Map* tmpMap = me->GetMap(); + + if (!tmpMap) + return; + + if (!attackers.empty()) + { + bool alive = false; + for (std::list::iterator itr = attackers.begin(); itr != attackers.end(); ++itr) + { + if (Creature* attacker = tmpMap->GetCreature((*itr))) + { + if (attacker->isAlive()) + { + alive = true; + break; + } + } + } + + if (!alive) + { + NextWave(); + SpawnTimer = 180000; + } + } + + CheckTimer = 3000; + + if (Creature* Aether = me->GetCreature(AetherGUID)) + { + if (Aether->isAlive()) + return; + else EventFail(); + } + } + else CheckTimer -= diff; + + if (Next) + { + if (SpawnTimer <= diff) + { + NextWave(); + SpawnTimer = 180000; + } + else SpawnTimer -= diff; + } + } + + if (CanStart) + { + if (StartSpawnTimer <= diff) + { + NextWave(); + CanStart = false; + } + else StartSpawnTimer -= diff; + } + + if (EndTimer <= diff) + { + EventFail(); + } + else EndTimer -= diff; + } +}; + +CreatureAI* GetAI_npc_bashir_landing(Creature* creature) +{ + return new npc_bashir_landingAI (creature); +} + +/*###### +## npc_banishing_crystal +######*/ + +enum +{ + SPELL_MASTER = 40828, + SPELL_BANISHMENT = 40857, + + NPC_BCREDIT = 23327 +}; + +struct npc_banishing_crystalAI : public ScriptedAI +{ + npc_banishing_crystalAI(Creature* creature) : ScriptedAI(creature) {} + + uint64 PlayerGUID; + + void Reset() + { + PlayerGUID = 0; + DoCast(me, SPELL_BANISHMENT); + GetPlayer(); + } + + void GetPlayer() + { + Map* map = me->GetMap(); + Map::PlayerList const &PlayerList = map->GetPlayers(); + + for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + { + if (Player* player = itr->getSource()) + { + if (me->IsWithinDistInMap(player, 30.0f) && (player->GetQuestStatus(11026) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11051) == QUEST_STATUS_INCOMPLETE)) + PlayerGUID = player->GetGUID(); + } + } + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if (spell->Id == SPELL_MASTER) + { + if (Player* player = me->GetPlayer(PlayerGUID)) + player->KilledMonster(NPC_BCREDIT, me->GetGUID()); + } + } +}; + +CreatureAI* GetAI_npc_banishing_crystal(Creature* creature) +{ + return new npc_banishing_crystalAI (creature); +} + /*###### ## AddSC ######*/ void AddSC_blades_edge_mountains() { - Script *newscript; + Script* newscript; newscript = new Script; newscript->Name="mobs_nether_drake"; @@ -2133,4 +2886,24 @@ void AddSC_blades_edge_mountains() newscript->Name="npc_cannon_target"; newscript->GetAI = &GetAI_npc_cannon_target; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_gargrom"; + newscript->GetAI = &GetAI_npc_gargrom; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_soulgrinder"; + newscript->GetAI = &GetAI_npc_soulgrinder; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_bashir_landing"; + newscript->GetAI = &GetAI_npc_bashir_landing; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_banishing_crystal"; + newscript->GetAI = &GetAI_npc_banishing_crystal; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp index 2530161be..41b576b14 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp index 23f7cce3c..828bd1ea2 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp index dde2e9558..70fc1e9f4 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -23,7 +26,7 @@ EndScriptData */ #include "precompiled.h" #include "def_serpent_shrine.h" -#include "../../../creature/simple_ai.h" +#include "../../../special/simple_ai.h" #include "Spell.h" #define SAY_INTRO -1548042 @@ -288,7 +291,7 @@ struct boss_lady_vashjAI : public ScriptedAI Intro = true; DoScriptText(SAY_INTRO, me); } - if (!CanAttack) + if (!CanAttack || me->isDead()) return; if (!who || me->getVictim()) @@ -488,8 +491,8 @@ struct boss_lady_vashjAI : public ScriptedAI { bool InMeleeRange = false; Unit *target; - std::list t_list = me->getThreatManager().getThreatList(); - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + std::list t_list = me->getThreatManager().getThreatList(); + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); //if in melee range @@ -1113,11 +1116,11 @@ struct mob_shield_generator_channelAI : public ScriptedAI ScriptedInstance *instance; uint32 Check_Timer; - bool Casted; + bool Cast; void Reset() { Check_Timer = 0; - Casted = false; + Cast = false; me->SetUInt32Value(UNIT_FIELD_DISPLAYID , 11686); //invisible me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -1140,10 +1143,10 @@ struct mob_shield_generator_channelAI : public ScriptedAI if(Vashj && Vashj->isAlive()) { //start visual channel - if (!Casted || !Vashj->HasAura(SPELL_MAGIC_BARRIER,0)) + if (!Cast || !Vashj->HasAura(SPELL_MAGIC_BARRIER,0)) { me->CastSpell(Vashj,SPELL_MAGIC_BARRIER,true); - Casted = true; + Cast = true; } } Check_Timer = 1000; diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp index 28369df1c..74a7accda --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -187,6 +190,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI uint32 InnderDemon_Count; uint64 Demon; uint64 SpellBinderGUID[3]; + uint64 actualtarget; void Reset() { @@ -219,7 +223,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_NORMAL); } - void CheckChannelers(bool DoEvade = true) + void CheckChannelers() { for(uint8 i = 0; i < 3; i++) { @@ -243,7 +247,6 @@ struct boss_leotheras_the_blindAI : public ScriptedAI Creature* binder = m_creature->SummonCreature(MOB_SPELLBINDER,nx,ny,z,o,TEMPSUMMON_DEAD_DESPAWN,0); if (binder) SpellBinderGUID[i] = binder->GetGUID(); - } } void MoveInLineOfSight(Unit *who) @@ -400,6 +403,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI //Return since we have no target if (!UpdateVictim() || m_creature->HasAura(AURA_BANISH, 0)) { + if(BanishTimer < diff) { CheckBanish(); //no need to check every update tick @@ -444,11 +448,16 @@ struct boss_leotheras_the_blindAI : public ScriptedAI else Whirlwind_Timer = 15000; - NeedThreatReset = false; - DoResetThreat(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - m_creature->SetReactState(REACT_AGGRESSIVE); + actualtarget = m_creature->getVictimGUID(); + if (actualtarget) + { + NeedThreatReset = false; + DoResetThreat(); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(m_creature->GetUnit(actualtarget)); + DoZoneInCombat(); + m_creature->SetReactState(REACT_AGGRESSIVE); + } } //Enrage_Timer ( 10 min ) @@ -527,10 +536,10 @@ struct boss_leotheras_the_blindAI : public ScriptedAI //Summon Inner Demon if(InnerDemons_Timer < diff) { - std::list& ThreatList = m_creature->getThreatManager().getThreatList(); + std::list& ThreatList = m_creature->getThreatManager().getThreatList(); std::vector TargetList; - for(std::list::iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + for(std::list::iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { Unit *tempTarget = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true); if(tempTarget && !tempTarget->HasAura(SPELL_CONSUMING_MADNESS,0) && tempTarget->GetGUID() != m_creature->getVictimGUID() && std::find(TargetList.begin(), TargetList.end(), tempTarget) == TargetList.end() && TargetList.size() < 5) @@ -599,6 +608,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI if(Copy) { Demon = Copy->GetGUID(); + Copy->SetMeleeDamageSchool(SPELL_SCHOOL_FIRE); if (m_creature->getVictim()) Copy->AI()->AttackStart(m_creature->getVictim()); } @@ -660,10 +670,6 @@ struct boss_leotheras_the_blind_demonformAI : public ScriptedAI //Return since we have no target if (!UpdateVictim() ) return; - - if(m_creature->getVictim()->HasAura(30300,0)) - DoResetThreat(); - if (checkTimer <= diff) { checkTimer = 2000; @@ -695,9 +701,8 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI { mob_greyheart_spellbinderAI(Creature *c) : ScriptedAI(c) { - pInstance = ((ScriptedInstance *)c->GetInstanceData());; + pInstance = ((ScriptedInstance *)c->GetInstanceData()); leotherasGUID = 0; - AddedBanish = false; } ScriptedInstance *pInstance; @@ -707,8 +712,6 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI uint32 Mindblast_Timer; uint32 Earthshock_Timer; - bool AddedBanish; - void Reset() { Mindblast_Timer = 3000 + rand()%5000; @@ -716,10 +719,15 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI if(pInstance) { + if (pInstance->GetData(DATA_LEOTHERASTHEBLINDEVENT) != NOT_STARTED) + { + m_creature->Kill(m_creature,false); + return; + } pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0); Creature *leotheras = (Creature *)Unit::GetUnit(*m_creature, leotherasGUID); if(leotheras && leotheras->isAlive()) - ((boss_leotheras_the_blindAI*)leotheras->AI())->CheckChannelers(false); + ((boss_leotheras_the_blindAI*)leotheras->AI())->CheckChannelers(); } } @@ -732,8 +740,7 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI void JustRespawned() { - AddedBanish = false; - Reset(); + EnterEvadeMode(); } void CastChanneling() @@ -772,7 +779,7 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI if(pInstance && !pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER)) { - EnterEvadeMode(); + Reset(); return; } diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp index 677892be2..1e554c447 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,7 +19,7 @@ #include "precompiled.h" #include "def_serpent_shrine.h" -#include "../../../creature/simple_ai.h" +#include "../../../special/simple_ai.h" #include "Spell.h" #define EMOTE_SPOUT "takes a deep breath." @@ -46,7 +49,7 @@ enum lurkerSpells SPELL_SPOUT_BREATH = 37431, SPELL_SPOUT_EFFECT = 37433, SPELL_GEYSER = 37478, - SPELL_WHIRL = 37363, + SPELL_WHIRL = 37660, SPELL_WATERBOLT = 37138, SPELL_SUBMERGE = 37550, }; diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp index d4593ebc0..8675405d4 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Morogrim_Tidewalker @@ -186,7 +189,7 @@ struct boss_morogrim_tidewalkerAI : public ScriptedAI int i = 0; for (std::list::const_iterator itr = tmpList.begin(); itr != tmpList.end(); ++itr) - (*itr)->CastSpell(*itr, wateryGraves[i++], true); + me->CastSpell(*itr, wateryGraves[i++], true); DoScriptText(RAND(SAY_SUMMON_BUBL1, SAY_SUMMON_BUBL2), m_creature); DoScriptText(EMOTE_WATERY_GRAVE, m_creature); diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h old mode 100755 new mode 100644 similarity index 50% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h index 69a6efb5d..dc6ab47f0 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h @@ -1,9 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef DEF_SERPENT_SHRINE_H -#define DEF_SERPENT_SHRINE_H +#ifndef SC_DEF_SERPENT_SHRINE_H +#define SC_DEF_SERPENT_SHRINE_H enum LurkerEventState { @@ -43,6 +58,7 @@ enum WaterEventState #define DATA_WATER 23 #define DATA_SHARKKIS_PET 24 -#define WATER_Z -19.9f +#define WATER_Z -21.57f +#define VASHJ_WATER_Z 20.27f #endif diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp index 89a381f5f..9e88c760b --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -28,8 +31,7 @@ EndScriptData */ #define SPELL_SCALDINGWATER 37284 #define MOB_COILFANG_FRENZY 21508 -#define TRASHMOB_COILFANG_PRIESTESS 21220 //6*2 -#define TRASHMOB_COILFANG_SHATTERER 21301 //6*3 +#define TRASHMOB_GRAYHEART_TECHICIAN 21263 /* Serpentshrine cavern encounters: @@ -78,6 +80,7 @@ struct instance_serpentshrine_cavern : public ScriptedInstance uint32 PlayerInWaterTimer; uint32 Water; uint32 trashCheckTimer; + uint32 ScaldingWaterDelayer; bool ShieldGeneratorDeactivated[4]; uint32 Encounters[ENCOUNTERS]; @@ -114,6 +117,7 @@ struct instance_serpentshrine_cavern : public ScriptedInstance PlayerInWaterTimer = 0; DoSpawnFrenzy = false; trashCheckTimer = 10000; + ScaldingWaterDelayer = 500; for(uint8 i = 0; i < ENCOUNTERS; i++) Encounters[i] = NOT_STARTED; @@ -227,15 +231,7 @@ struct instance_serpentshrine_cavern : public ScriptedInstance break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void SetData64(uint32 type, uint64 data) @@ -406,15 +402,18 @@ struct instance_serpentshrine_cavern : public ScriptedInstance { if (Encounters[2] == NOT_STARTED) // check and change water state only if lurker event is not started { - uint64 tmpPriestessGuid = instance->GetCreatureGUID(TRASHMOB_COILFANG_PRIESTESS, GET_ALIVE_CREATURE_GUID); - uint64 tmpShattererGuid = instance->GetCreatureGUID(TRASHMOB_COILFANG_SHATTERER, GET_ALIVE_CREATURE_GUID); - if (!tmpPriestessGuid && !tmpShattererGuid) + uint64 tmpTechnicianGuid = instance->GetCreatureGUID(TRASHMOB_GRAYHEART_TECHICIAN, GET_ALIVE_CREATURE_GUID); + if (!tmpTechnicianGuid) Water = WATERSTATE_SCALDING; else Water = WATERSTATE_FRENZY; } - - trashCheckTimer = 10000; + else if (Encounters[2] == DONE) + { + Water = WATERSTATE_NONE; + } + + trashCheckTimer = 5000; } else trashCheckTimer -= diff; @@ -437,22 +436,33 @@ struct instance_serpentshrine_cavern : public ScriptedInstance if (Water == WATERSTATE_SCALDING) { if (!pPlayer->HasAura(SPELL_SCALDINGWATER)) - pPlayer->CastSpell(pPlayer, SPELL_SCALDINGWATER, true); + { + if (ScaldingWaterDelayer < diff) // this timer (delayer) prevents multiple application of this buff when player jumps in water (sometimes >3k damage) + { + pPlayer->CastSpell(pPlayer, SPELL_SCALDINGWATER, true); + ScaldingWaterDelayer = 500; + break; + } + else + ScaldingWaterDelayer -= diff; + break; + } } else if (Water == WATERSTATE_FRENZY) { //spawn frenzy - if (DoSpawnFrenzy) + if (DoSpawnFrenzy && !pPlayer->isGameMaster()) { - if (Creature* frenzy = pPlayer->SummonCreature(MOB_COILFANG_FRENZY,pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ(),pPlayer->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000)) - { - frenzy->AddUnitMovementFlag(MOVEFLAG_SWIMMING); - frenzy->SetLevitate(true); - frenzy->AI()->AttackStart(pPlayer); - } + if (Creature* frenzy = pPlayer->SummonCreature(MOB_COILFANG_FRENZY,pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ(),pPlayer->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000)) + frenzy->AI()->AttackStart(pPlayer); + DoSpawnFrenzy = false; } } + else if (Water == WATERSTATE_NONE) + { + break; + } } } } @@ -470,7 +480,7 @@ struct instance_serpentshrine_cavern : public ScriptedInstance if (PlayerInWaterTimer) WaterCheckTimer = 1; else - WaterCheckTimer = 500; //remove stress from core + WaterCheckTimer = 1000; //remove stress from core } else WaterCheckTimer -= diff; diff --git a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp similarity index 90% rename from src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp index cceb0a95d..e29d71698 100644 --- a/src/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/serpent_shrine/serpent_shrine_trash.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "precompiled.h" #include "def_serpent_shrine.h" @@ -16,7 +34,7 @@ struct mob_vashjir_honor_guardAI : public ScriptedAI uint32 Knockback_Timer; uint32 Execute_Timer; uint32 Cleave_Timer; - bool Frenzy_Casted; + bool Frenzy_Cast; uint32 Talk_Timer; uint32 Check_Timer; @@ -29,7 +47,7 @@ struct mob_vashjir_honor_guardAI : public ScriptedAI Knockback_Timer = urand(10000, 30000); Execute_Timer = 0; Cleave_Timer = urand(3000, 6000); - Frenzy_Casted = false; + Frenzy_Cast = false; Talk_Timer = 10000; Check_Timer = 1000; } @@ -77,10 +95,10 @@ struct mob_vashjir_honor_guardAI : public ScriptedAI else Cleave_Timer -= diff; - if(!Frenzy_Casted && HealthBelowPct(50)) + if(!Frenzy_Cast && HealthBelowPct(50)) { AddSpellToCast(SPELL_FRENZY, CAST_SELF); - Frenzy_Casted = true; + Frenzy_Cast = true; } CastNextSpellIfAnyAndReady(); @@ -383,51 +401,6 @@ CreatureAI* GetAI_mob_serpentshrine_parasite(Creature *_Creature) } -struct mob_coilfang_frenzyAI : public ScriptedAI -{ - mob_coilfang_frenzyAI(Creature *c) : ScriptedAI(c) {} - - void Reset() - { - - } - - void EnterEvadeMode() - { - float x, y, z; - me->GetPosition(x, y, z); - me->SetHomePosition(x, y, z, me->GetOrientation()); - ScriptedAI::EnterEvadeMode(); - } - - void UpdateAI(const uint32 diff) - { - float x, y, z; - me->GetPosition(x, y, z); - - if(z > WATER_Z) - me->Relocate(x, y, WATER_Z, me->GetOrientation()); - - if(!UpdateVictim()) - return; - - Unit *victim = me->getVictim(); - - victim->GetPosition(x, y, z); - if(z - 5 > WATER_Z) - { - EnterEvadeMode(); - return; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_coilfang_frenzy(Creature *_Creature) -{ - return new mob_coilfang_frenzyAI(_Creature); -} void AddSC_serpent_shrine_trash() { @@ -447,10 +420,4 @@ void AddSC_serpent_shrine_trash() newscript->Name = "mob_serpentshrine_parasite"; newscript->GetAI = &GetAI_mob_serpentshrine_parasite; newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name = "mob_coilfang_frenzy"; - newscript->GetAI = &GetAI_mob_coilfang_frenzy; - newscript->RegisterSelf(); - } diff --git a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp similarity index 93% rename from src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp index 192741f95..4ea190749 100644 --- a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_lord_ahune.cpp @@ -1,11 +1,20 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -*/ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Lord Ahune diff --git a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp similarity index 87% rename from src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp index 30653e3d9..5995d2617 100644 --- a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/boss_mennu_the_betrayer.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include "precompiled.h" @@ -108,7 +125,10 @@ struct boss_mennu_the_betrayerAI : public ScriptedAI if(LightningBolt_Timer < diff) { - AddSpellToCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT); + if (HeroicMode) + AddCustomSpellToCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT,142,0,0); + else + AddCustomSpellToCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT,175,0,0); LightningBolt_Timer = 10000; } else diff --git a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/instance_slave_pens.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/instance_slave_pens.cpp similarity index 81% rename from src/scripts/scripts/zone/coilfang_resevoir/slave_pens/instance_slave_pens.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/instance_slave_pens.cpp index ec9902887..5f205e25b 100644 --- a/src/scripts/scripts/zone/coilfang_resevoir/slave_pens/instance_slave_pens.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/instance_slave_pens.cpp @@ -1,11 +1,20 @@ -/* Copyright (C) 2008 - 2010 HelgroundDev -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -*/ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Instance_Slave_Pens diff --git a/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/slave_pens_trash.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/slave_pens_trash.cpp new file mode 100644 index 000000000..b94e9fada --- /dev/null +++ b/src/scripts/scripts/Outland/coilfang_resevoir/slave_pens/slave_pens_trash.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "precompiled.h" + +#define SPELL_HAMSTRING 9080 +#define SPELL_HEAD_CRACK 16172 +#define YELL_AGGRO -678 +#define YELL_OOC1 -679 +#define YELL_OOC2 -680 +#define YELL_OOC3 -681 +#define YELL_OOC4 -683 +#define YELL_OOC5 -684 +#define YELL_OOC6 -685 + + +struct mob_coilfang_slavehandlerAI : public ScriptedAI +{ + mob_coilfang_slavehandlerAI(Creature *c) : ScriptedAI(c) {} + + uint32 hamstringtimer; + uint32 headcracktimer; + uint32 yelltimer; + + void Reset() + { + hamstringtimer = urand(5800,6200); + headcracktimer = 11100; + yelltimer = urand(60000,120000); + } + + void JustDied(Unit* ) + { + StartRun(); + } + + void StartRun() + { + std::list alist= FindAllCreaturesWithEntry(17963, 100); + std::list blist= FindAllCreaturesWithEntry(17964, 100); + for(std::list::iterator itr = blist.begin(); itr != blist.end(); itr++) + alist.push_front(*itr); + for(std::list::iterator itr = alist.begin(); itr != alist.end(); itr++) + { + if ((*itr)->GetFormation() == me->GetFormation()) + { + if ((*itr)->isAlive()) + { + (*itr)->RemoveAllAuras(); + (*itr)->DeleteThreatList(); + (*itr)->CombatStop(); + + if (me->GetPositionY() > -150.0f) + (*itr)->GetMotionMaster()->MovePoint(1, 115.0f, -98.0f, -1.5f); + else + (*itr)->GetMotionMaster()->MovePoint(2, -102.0f, -121.0f, -2.1f); + + (*itr)->ForcedDespawn(7000); + } + } + } + } + + void EnterCombat(Unit* attacker) + { + me->Yell(YELL_AGGRO,0,0); + } + + void UpdateAI(const uint32 diff) + { + if(!me->isInCombat()) + if(yelltimer < diff) + { + me->Yell(RAND(YELL_OOC1,YELL_OOC2,YELL_OOC3,YELL_OOC4,YELL_OOC5,YELL_OOC6),0,0); + yelltimer = urand(60000,120000); + } + else + yelltimer -=diff; + + if(!UpdateVictim()) + return; + + if(hamstringtimer < diff) + { + AddSpellToCast(SPELL_HAMSTRING); + hamstringtimer = 9000; + } + else + hamstringtimer -= diff; + + if(headcracktimer < diff) + { + AddSpellToCast(SPELL_HEAD_CRACK,CAST_RANDOM); + headcracktimer = urand(20000,25000); + } + else + headcracktimer -= diff; + + DoMeleeAttackIfReady(); + CastNextSpellIfAnyAndReady(diff); + } +}; + +CreatureAI* GetAI_mob_coilfang_slavehandler(Creature *_creature) +{ + return new mob_coilfang_slavehandlerAI (_creature); +} + +// SV +#define SPELL_DISARM 6713 +#define SPELL_GEYSER 10987 +#define SPELL_FRENZY 8269 + +struct npc_coilfang_slavemasterAI : public ScriptedAI +{ + npc_coilfang_slavemasterAI(Creature *c) : ScriptedAI(c) {} + + uint32 hamstringtimer; + uint32 headcracktimer; + uint32 yelltimer; + + bool frenzy; + + void Reset() + { + hamstringtimer = urand(5800,6200); + headcracktimer = 11100; + yelltimer = urand(60000,120000); + frenzy = false; + } + + void JustDied(Unit* ) + { + StartRun(); + } + + void StartRun() + { + std::list alist= FindAllCreaturesWithEntry(17799, 100); + for(std::list::iterator itr = alist.begin(); itr != alist.end(); itr++) + { + if ((*itr)->GetFormation() == me->GetFormation()) + { + if ((*itr)->isAlive()) + { + (*itr)->RemoveAllAuras(); + (*itr)->DeleteThreatList(); + (*itr)->CombatStop(); + (*itr)->GetMotionMaster()->MovePoint(1, -149.0f, -295.0f, -7.6f); + (*itr)->ForcedDespawn(7000); + } + } + } + } + + void EnterCombat(Unit* attacker) + { + me->Yell(YELL_AGGRO,0,0); + } + + void UpdateAI(const uint32 diff) + { + if(!me->isInCombat()) + if(yelltimer < diff) + { + me->Yell(RAND(YELL_OOC1,YELL_OOC2,YELL_OOC3,YELL_OOC4,YELL_OOC5,YELL_OOC6),0,0); + yelltimer = urand(60000,120000); + } + else + yelltimer -=diff; + + if(!UpdateVictim()) + return; + + if(hamstringtimer < diff) + { + AddSpellToCast(SPELL_DISARM); + hamstringtimer = 9000; + } + else + hamstringtimer -= diff; + + if(headcracktimer < diff) + { + AddSpellToCast(SPELL_GEYSER); + headcracktimer = urand(20000,25000); + } + else + headcracktimer -= diff; + + if (HealthBelowPct(20.0f) && !frenzy) + { + ForceSpellCast(me, SPELL_FRENZY, INTERRUPT_AND_CAST_INSTANTLY); + frenzy = true; + } + + DoMeleeAttackIfReady(); + CastNextSpellIfAnyAndReady(diff); + } +}; + +CreatureAI* GetAI_npc_coilfang_slavemaster(Creature *_creature) +{ + return new npc_coilfang_slavemasterAI (_creature); +} + + +void AddSC_slave_pens_trash() +{ + Script *newscript; + newscript = new Script; + newscript->Name="mob_coilfang_slavehandler"; + newscript->GetAI = &GetAI_mob_coilfang_slavehandler; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_coilfang_slavemaster"; + newscript->GetAI = &GetAI_npc_coilfang_slavemaster; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp old mode 100755 new mode 100644 similarity index 91% rename from src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp index a94acc05e..bb4e5aa9c --- a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,7 +19,7 @@ /* ScriptData SDName: Boss_Hydromancer_Thespia -SD%Complete: 80 +SD%Complete: 90 SDComment: Needs additional adjustments (when instance script is adjusted) SDCategory: Coilfang Resevoir, The Steamvault EndScriptData */ @@ -46,7 +49,7 @@ struct boss_thespiaAI : public ScriptedAI boss_thespiaAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; @@ -70,13 +73,13 @@ struct boss_thespiaAI : public ScriptedAI (*it)->GetMotionMaster()->MoveTargetedHome(); } - if (pInstance && m_creature->isAlive()) + if (pInstance && me->isAlive()) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEAD, m_creature); + DoScriptText(SAY_DEAD, me); if (pInstance) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, DONE); @@ -84,16 +87,16 @@ struct boss_thespiaAI : public ScriptedAI void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), m_creature); + DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); } void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); + DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), me); std::list water_elementals = FindAllCreaturesWithEntry(17917, 100); for(std::list::iterator it = water_elementals.begin(); it != water_elementals.end(); it++) - (*it)->SetInCombatWith(who); + (*it)->AI()->AttackStart(who); if (pInstance) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, IN_PROGRESS); @@ -152,7 +155,7 @@ struct mob_coilfang_waterelementalAI : public ScriptedAI void Reset() { - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); WaterBoltVolley_Timer = 3000+rand()%3000; } @@ -165,7 +168,7 @@ struct mob_coilfang_waterelementalAI : public ScriptedAI if (WaterBoltVolley_Timer < diff) { - DoCast(m_creature, HeroicMode ? H_SPELL_WATER_BOLT_VOLLEY : SPELL_WATER_BOLT_VOLLEY); + DoCast(me, HeroicMode ? H_SPELL_WATER_BOLT_VOLLEY : SPELL_WATER_BOLT_VOLLEY); WaterBoltVolley_Timer = 7000+rand()%5000; }else WaterBoltVolley_Timer -= diff; diff --git a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp old mode 100755 new mode 100644 similarity index 64% rename from src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp index dfb9dfe57..3ad9dc6a8 --- a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_Mekgineer_Steamrigger -SD%Complete: 60 -SDComment: Mechanics' interrrupt heal doesn't work very well, also a proper movement needs to be implemented -> summon further away and move towards target to repair. +SD%Complete: 90 +SDComment: SDCategory: Coilfang Resevoir, The Steamvault EndScriptData */ @@ -42,16 +45,26 @@ EndContentData */ #define SPELL_SUPER_SHRINK_RAY 31485 #define SPELL_SAW_BLADE 31486 #define SPELL_ELECTRIFIED_NET 35107 -#define H_SPELL_ENRAGE 1 //corrent enrage spell not known +#define H_SPELL_ENRAGE 41924 #define ENTRY_STREAMRIGGER_MECHANIC 17951 +struct SumonPos +{ + float x, y, z; +}; + +static SumonPos Pos[]= +{ + {-339.99f, -118.05f, -7.827f} +}; + struct boss_mekgineer_steamriggerAI : public ScriptedAI { boss_mekgineer_steamriggerAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; @@ -60,6 +73,7 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI uint32 Shrink_Timer; uint32 Saw_Blade_Timer; uint32 Electrified_Net_Timer; + uint32 Berserk_timer; bool Summon75; bool Summon50; bool Summon25; @@ -69,18 +83,19 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI Shrink_Timer = 20000; Saw_Blade_Timer = 15000; Electrified_Net_Timer = 10000; + Berserk_timer = 300000; Summon75 = false; Summon50 = false; Summon25 = false; - if (pInstance && m_creature->isAlive()) + if (pInstance && me->isAlive()) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, NOT_STARTED); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if (pInstance) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, DONE); @@ -88,30 +103,30 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), m_creature); + DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); } void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); + DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), me); if (pInstance) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, IN_PROGRESS); } - //no known summon spells exist void SummonMechanichs() { - DoScriptText(SAY_MECHANICS, m_creature); + DoScriptText(SAY_MECHANICS, me); + + me->SummonCreature(ENTRY_STREAMRIGGER_MECHANIC, Pos[0].x,Pos[0].y ,Pos[0].z , 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + me->SummonCreature(ENTRY_STREAMRIGGER_MECHANIC, Pos[0].x,Pos[0].y ,Pos[0].z , 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + me->SummonCreature(ENTRY_STREAMRIGGER_MECHANIC, Pos[0].x,Pos[0].y ,Pos[0].z , 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + if (roll_chance_i(30)) + me->SummonCreature(ENTRY_STREAMRIGGER_MECHANIC, Pos[0].x,Pos[0].y ,Pos[0].z , 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - if (rand()%2) - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,-7,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - if (rand()%2) - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,7,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + if (roll_chance_i(10)) + me->SummonCreature(ENTRY_STREAMRIGGER_MECHANIC, Pos[0].x,Pos[0].y ,Pos[0].z , 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); } void UpdateAI(const uint32 diff) @@ -121,30 +136,38 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI if (Shrink_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_SUPER_SHRINK_RAY); + DoCast(me->getVictim(),SPELL_SUPER_SHRINK_RAY); Shrink_Timer = 20000; }else Shrink_Timer -= diff; if (Saw_Blade_Timer < diff) { - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, m_creature->getVictimGUID())) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) DoCast(target,SPELL_SAW_BLADE); else - DoCast(m_creature->getVictim(),SPELL_SAW_BLADE); + DoCast(me->getVictim(),SPELL_SAW_BLADE); Saw_Blade_Timer = 15000; } else Saw_Blade_Timer -= diff; if (Electrified_Net_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_ELECTRIFIED_NET); + DoCast(me->getVictim(),SPELL_ELECTRIFIED_NET); Electrified_Net_Timer = 10000; } else Electrified_Net_Timer -= diff; + if (Berserk_timer < diff) + { + if (HeroicMode) + DoCast(me, H_SPELL_ENRAGE); + + Berserk_timer = 300000+rand()%10000; + }else Berserk_timer -=diff; + if (!Summon75) { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 75) + if ((me->GetHealth()*100 / me->GetMaxHealth()) < 75) { SummonMechanichs(); Summon75 = true; @@ -153,7 +176,7 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI if (!Summon50) { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + if ((me->GetHealth()*100 / me->GetMaxHealth()) < 50) { SummonMechanichs(); Summon50 = true; @@ -162,7 +185,7 @@ struct boss_mekgineer_steamriggerAI : public ScriptedAI if (!Summon25) { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) + if ((me->GetHealth()*100 / me->GetMaxHealth()) < 25) { SummonMechanichs(); Summon25 = true; @@ -179,18 +202,16 @@ CreatureAI* GetAI_boss_mekgineer_steamrigger(Creature *_Creature) } #define SPELL_DISPEL_MAGIC 17201 -#define SPELL_REPAIR 31532 -#define H_SPELL_REPAIR 37936 +#define SPELL_REPAIR (HeroicMode ? 37936 : 31532) -#define MAX_REPAIR_RANGE (13.0f) //we should be at least at this range for repair -#define MIN_REPAIR_RANGE (7.0f) //we can stop movement at this range to repair but not required +#define MAX_REPAIR_RANGE (13.0f) struct mob_steamrigger_mechanicAI : public ScriptedAI { mob_steamrigger_mechanicAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance* pInstance; @@ -200,7 +221,13 @@ struct mob_steamrigger_mechanicAI : public ScriptedAI void Reset() { - Repair_Timer = irand(500, 2500); + Repair_Timer = irand(1500, 2500); + + if (Unit* Mekgineer = Unit::GetUnit((*me), pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER))) + { + float angle = RAND(0.0f, 1.5f, 3.1f, 4.6f); + me->GetMotionMaster()->MoveFollow(Mekgineer, 7.0f, angle); + } } void MoveInLineOfSight(Unit* who) @@ -209,7 +236,14 @@ struct mob_steamrigger_mechanicAI : public ScriptedAI return; } - void EnterCombat(Unit *who) { } + void EnterCombat(Unit *who) {} + void AttackStart(Unit* who) + { + if (pInstance && pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == IN_PROGRESS) + return; + + ScriptedAI::AttackStart(who); + } void UpdateAI(const uint32 diff) { @@ -217,20 +251,16 @@ struct mob_steamrigger_mechanicAI : public ScriptedAI { if (pInstance && pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER) && pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == IN_PROGRESS) { - if (Unit* pMekgineer = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER))) + if (Unit* Mekgineer = Unit::GetUnit((*me), pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER))) { - if (m_creature->IsWithinDistInMap(pMekgineer, MAX_REPAIR_RANGE)) + if (me->IsWithinDistInMap(Mekgineer, MAX_REPAIR_RANGE)) { - DoCast(pMekgineer,HeroicMode ? H_SPELL_REPAIR : SPELL_REPAIR); - Repair_Timer = irand(1500, 3000);; - } - else - { - //m_creature->GetMotionMaster()->MovementExpired(); - //m_creature->GetMotionMaster()->MoveFollow(pMekgineer,0,0); + DoCast(Mekgineer, SPELL_REPAIR); + + Repair_Timer = irand(1500, 3000); } } - }else Repair_Timer = irand(1500, 3000);; + }else Repair_Timer = irand(1500, 3000); }else Repair_Timer -= diff; if (!UpdateVictim()) diff --git a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp old mode 100755 new mode 100644 similarity index 60% rename from src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp index 26f77e11a..c3e877dfa --- a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_Warlord_Kalithres -SD%Complete: 65 -SDComment: Contains workarounds regarding warlord's rage spells not acting as expected. Both scripts here require review and fine tuning. +SD%Complete: 95 +SDComment: SDCategory: Coilfang Resevoir, The Steamvault EndScriptData */ @@ -35,61 +38,10 @@ EndScriptData */ #define SPELL_SPELL_REFLECTION 31534 #define SPELL_IMPALE 39061 -#define SPELL_WARLORDS_RAGE 37081 +//#define SPELL_WARLORDS_RAGE 37081 #define SPELL_WARLORDS_RAGE_NAGA 31543 - #define SPELL_WARLORDS_RAGE_PROC 36453 -struct mob_naga_distillerAI : public Scripted_NoMovementAI -{ - mob_naga_distillerAI(Creature *c) : Scripted_NoMovementAI(c) - { - pInstance = (c->GetInstanceData()); - } - - ScriptedInstance *pInstance; - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - //hack, due to really weird spell behaviour :( - if (pInstance) - { - if (pInstance->GetData(TYPE_DISTILLER) == IN_PROGRESS) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } - } - - void EnterCombat(Unit *who) { } - - void StartRageGen(Unit *caster) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - DoCast(caster,SPELL_WARLORDS_RAGE_NAGA,true); - - if (pInstance) - pInstance->SetData(TYPE_DISTILLER,IN_PROGRESS); - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if (m_creature->GetHealth() <= damage) - if (pInstance) - pInstance->SetData(TYPE_DISTILLER,DONE); - } - - void UpdateAI(const uint32 diff) - { - } -}; - struct boss_warlord_kalithreshAI : public ScriptedAI { boss_warlord_kalithreshAI(Creature *c) : ScriptedAI(c) @@ -104,8 +56,6 @@ struct boss_warlord_kalithreshAI : public ScriptedAI uint32 Impale_Timer; uint32 Rage_Timer; uint64 CurrentDistiller; - bool CanRage; - uint32 checkTimer; WorldLocation pos; @@ -117,9 +67,7 @@ struct boss_warlord_kalithreshAI : public ScriptedAI Reflection_Timer = 10000; Impale_Timer = 7000+rand()%7000; Rage_Timer = 45000; - CanRage = false; CurrentDistiller = 0; - checkTimer = 3000; std::list naga_distillers = FindAllCreaturesWithEntry(17954, 100); @@ -136,36 +84,63 @@ struct boss_warlord_kalithreshAI : public ScriptedAI void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), m_creature); - m_creature->SetHealth(m_creature->GetMaxHealth()); + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); + me->SetHealth(me->GetMaxHealth()); if (pInstance) pInstance->SetData(TYPE_WARLORD_KALITHRESH, IN_PROGRESS); } void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } - void SpellHit(Unit *caster, const SpellEntry *spell) + void OnAuraRemove(Aura* aur, bool) { - //hack :( - if (spell->Id == SPELL_WARLORDS_RAGE_PROC) + if (aur->GetId() == SPELL_WARLORDS_RAGE_NAGA) { - if(CurrentDistiller) - if(Unit *distiler = me->GetUnit(CurrentDistiller)) + if (CurrentDistiller) + { + if (Unit* distiller = me->GetUnit(CurrentDistiller)) { - distiler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - distiler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - distiler->SetHealth(distiler->GetMaxHealth()); - CurrentDistiller = 0; + if (distiller && distiller->isAlive()) + { + distiller->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + distiller->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + distiller->SetHealth(distiller->GetMaxHealth()); + CurrentDistiller = 0; + DoCast(me, SPELL_WARLORDS_RAGE_PROC, true); + } + else return; } + } + } + + //if (aur->GetId() == SPELL_WARLORDS_RAGE) + // return; + } + + void MovementInform(uint32 type, uint32 id) + { + if (type != POINT_MOTION_TYPE || !id) + return; + + if (CurrentDistiller) + { + if (Unit* distiller = me->GetUnit(CurrentDistiller)) + { + me->SetFacingToObject(distiller); + DoScriptText(SAY_REGEN, me); + distiller->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + distiller->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + distiller->CastSpell(me, SPELL_WARLORDS_RAGE_NAGA, true); + } } } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if (pInstance) pInstance->SetData(TYPE_WARLORD_KALITHRESH, DONE); @@ -184,7 +159,7 @@ struct boss_warlord_kalithreshAI : public ScriptedAI if (checkTimer < diff) { - if (!m_creature->IsWithinDistInMap(&pos, 105.0f)) + if (!me->IsWithinDistInMap(&pos, 105.0f)) { EnterEvadeMode(); return; @@ -197,24 +172,22 @@ struct boss_warlord_kalithreshAI : public ScriptedAI if (Rage_Timer < diff) { Creature* distiller = GetClosestCreatureWithEntry(me, 17954, 100); + if (distiller) { + float x, y, z; + distiller->GetNearPoint(x, y, z, INTERACTION_DISTANCE); + me->GetMotionMaster()->MovePoint(1, x, y, z); CurrentDistiller = distiller->GetGUID(); - DoScriptText(SAY_REGEN, m_creature); - DoCast(m_creature,SPELL_WARLORDS_RAGE, true); - ((mob_naga_distillerAI*)distiller->AI())->StartRageGen(m_creature); } + Rage_Timer = 15000+rand()%15000; }else Rage_Timer -= diff; - - if (pInstance && m_creature->HasAura(37081, 0) && pInstance->GetData(TYPE_DISTILLER) == DONE) - m_creature->RemoveAurasDueToSpell(37081); - //Reflection_Timer if (Reflection_Timer < diff) { - AddSpellToCast(m_creature, SPELL_SPELL_REFLECTION); + AddSpellToCast(me, SPELL_SPELL_REFLECTION); Reflection_Timer = 15000+rand()%10000; }else Reflection_Timer -= diff; @@ -232,11 +205,6 @@ struct boss_warlord_kalithreshAI : public ScriptedAI } }; -CreatureAI* GetAI_mob_naga_distiller(Creature *_Creature) -{ - return new mob_naga_distillerAI (_Creature); -} - CreatureAI* GetAI_boss_warlord_kalithresh(Creature *_Creature) { return new boss_warlord_kalithreshAI (_Creature); @@ -246,11 +214,6 @@ void AddSC_boss_warlord_kalithresh() { Script *newscript; - newscript = new Script; - newscript->Name="mob_naga_distiller"; - newscript->GetAI = &GetAI_mob_naga_distiller; - newscript->RegisterSelf(); - newscript = new Script; newscript->Name="boss_warlord_kalithresh"; newscript->GetAI = &GetAI_boss_warlord_kalithresh; diff --git a/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/def_steam_vault.h b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/def_steam_vault.h new file mode 100644 index 000000000..1b91b8a63 --- /dev/null +++ b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/def_steam_vault.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_STEAM_VAULT_H +#define SC_DEF_STEAM_VAULT_H + +#define TYPE_HYDROMANCER_THESPIA 1 +#define TYPE_MEKGINEER_STEAMRIGGER 2 +#define TYPE_WARLORD_KALITHRESH 3 + +#define DATA_MEKGINEERSTEAMRIGGER 5 +#define DATA_KALITRESH 6 +#define DATA_THESPIA 7 + +#define DATA_MAIN_CHAMBERS_DOOR 8 + +#endif + diff --git a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp index d26355d7f..346bc2b1f --- a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/steam_vault/instance_steam_vault.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -24,7 +27,7 @@ EndScriptData */ #include "precompiled.h" #include "def_steam_vault.h" -#define ENCOUNTERS 4 +#define ENCOUNTERS 3 #define MAIN_CHAMBERS_DOOR 183049 #define ACCESS_PANEL_HYDRO 184125 @@ -157,9 +160,6 @@ struct instance_steam_vault : public ScriptedInstance Encounter[2] = data; break; - case TYPE_DISTILLER: - Encounter[3] = data; - break; } if(data == DONE || data == SPECIAL) @@ -176,8 +176,6 @@ struct instance_steam_vault : public ScriptedInstance return Encounter[1]; case TYPE_WARLORD_KALITHRESH: return Encounter[2]; - case TYPE_DISTILLER: - return Encounter[3]; } return 0; } @@ -205,8 +203,7 @@ struct instance_steam_vault : public ScriptedInstance std::ostringstream stream; stream << Encounter[0] << " "; stream << Encounter[1] << " "; - stream << Encounter[2] << " "; - stream << Encounter[3]; + stream << Encounter[2]; OUT_SAVE_INST_DATA_COMPLETE; @@ -222,7 +219,7 @@ struct instance_steam_vault : public ScriptedInstance } OUT_LOAD_INST_DATA(in); std::istringstream stream(in); - stream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3]; + stream >> Encounter[0] >> Encounter[1] >> Encounter[2]; for(uint8 i = 0; i < ENCOUNTERS-1; ++i) if(Encounter[i] == IN_PROGRESS) Encounter[i] = NOT_STARTED; diff --git a/src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_hungarfen.cpp old mode 100755 new mode 100644 similarity index 80% rename from src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_hungarfen.cpp index 39ea8eed6..878ac4126 --- a/src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_hungarfen.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -30,7 +33,7 @@ struct boss_hungarfenAI : public ScriptedAI { boss_hungarfenAI(Creature *c) : ScriptedAI(c) { - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } bool HeroicMode; @@ -54,11 +57,11 @@ struct boss_hungarfenAI : public ScriptedAI if (!UpdateVictim()) return; - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20 ) + if( (me->GetHealth()*100) / me->GetMaxHealth() <= 20 ) { if( !Root ) { - DoCast(m_creature,SPELL_FOUL_SPORES); + DoCast(me,SPELL_FOUL_SPORES); Root = true; } } @@ -66,9 +69,9 @@ struct boss_hungarfenAI : public ScriptedAI if( Mushroom_Timer < diff ) { if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - m_creature->SummonCreature(17990, target->GetPositionX()+(rand()%8), target->GetPositionY()+(rand()%8), target->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); + me->SummonCreature(17990, target->GetPositionX()+(rand()%8), target->GetPositionY()+(rand()%8), target->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); else - m_creature->SummonCreature(17990, m_creature->GetPositionX()+(rand()%8), m_creature->GetPositionY()+(rand()%8), m_creature->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); + me->SummonCreature(17990, me->GetPositionX()+(rand()%8), me->GetPositionY()+(rand()%8), me->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); Mushroom_Timer = 10000; }else Mushroom_Timer -= diff; @@ -106,8 +109,8 @@ struct mob_underbog_mushroomAI : public ScriptedAI Grow_Timer = 0; Shrink_Timer = 20000; - DoCast(m_creature,SPELL_PUTRID_MUSHROOM,true); - DoCast(m_creature,SPELL_SPORE_CLOUD,true); + DoCast(me,SPELL_PUTRID_MUSHROOM,true); + DoCast(me,SPELL_SPORE_CLOUD,true); } void MoveInLineOfSight(Unit *who) { return; } @@ -121,13 +124,13 @@ struct mob_underbog_mushroomAI : public ScriptedAI if( Grow_Timer <= diff ) { - DoCast(m_creature,SPELL_GROW); + DoCast(me,SPELL_GROW); Grow_Timer = 3000; }else Grow_Timer -= diff; if( Shrink_Timer <= diff ) { - m_creature->RemoveAurasDueToSpell(SPELL_GROW); + me->RemoveAurasDueToSpell(SPELL_GROW); Stop = true; }else Shrink_Timer -= diff; } diff --git a/src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_the_black_stalker.cpp b/src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_the_black_stalker.cpp rename to src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp index 1934eea61..97e4423f3 --- a/src/scripts/scripts/zone/coilfang_resevoir/underbog/boss_the_black_stalker.cpp +++ b/src/scripts/scripts/Outland/coilfang_resevoir/underbog/boss_the_black_stalker.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -37,7 +40,7 @@ struct boss_the_black_stalkerAI : public ScriptedAI { boss_the_black_stalkerAI(Creature *c) : ScriptedAI(c) { - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); c->GetPosition(wLoc); } @@ -72,18 +75,18 @@ struct boss_the_black_stalkerAI : public ScriptedAI if(summon && summon->GetEntry() == ENTRY_SPORE_STRIDER) { Striders.push_back(summon->GetGUID()); - if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, m_creature->getVictimGUID())) + if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) summon->AI()->AttackStart(target); else - if(m_creature->getVictim()) - summon->AI()->AttackStart(m_creature->getVictim()); + if(me->getVictim()) + summon->AI()->AttackStart(me->getVictim()); } } void JustDied(Unit *who) { for(std::list::iterator i = Striders.begin(); i != Striders.end(); ++i) - if(Creature *strider = Unit::GetCreature(*m_creature, *i)) + if(Creature *strider = Unit::GetCreature(*me, *i)) { strider->SetLootRecipient(NULL); strider->DealDamage(strider,strider->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); @@ -99,7 +102,7 @@ struct boss_the_black_stalkerAI : public ScriptedAI // Evade if too far if(check_Timer < diff) { - if(!m_creature->IsWithinDistInMap(&wLoc, 60)) + if(!me->IsWithinDistInMap(&wLoc, 60)) { EnterEvadeMode(); return; @@ -110,7 +113,7 @@ struct boss_the_black_stalkerAI : public ScriptedAI // Spore Striders if(HeroicMode && SporeStriders_Timer < diff) { - DoCast(m_creature,SPELL_SUMMON_SPORE_STRIDER); + DoCast(me,SPELL_SUMMON_SPORE_STRIDER); SporeStriders_Timer = 10000+rand()%5000; }else SporeStriders_Timer -= diff; @@ -119,7 +122,7 @@ struct boss_the_black_stalkerAI : public ScriptedAI { if(LevitatedTarget_Timer < diff) { - if(Unit* target = (Unit*)Unit::GetUnit(*m_creature, LevitatedTarget)) + if(Unit* target = (Unit*)Unit::GetUnit(*me, LevitatedTarget)) { if(!target->HasAura(SPELL_LEVITATE,0)) { @@ -144,7 +147,7 @@ struct boss_the_black_stalkerAI : public ScriptedAI } if(Levitate_Timer < diff) { - if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, m_creature->getVictimGUID())) + if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) { DoCast(target, SPELL_LEVITATE); LevitatedTarget = target->GetGUID(); diff --git a/src/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp b/src/scripts/scripts/Outland/gruuls_lair/boss_gruul.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp rename to src/scripts/scripts/Outland/gruuls_lair/boss_gruul.cpp index fabccd705..6ea492a62 --- a/src/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp +++ b/src/scripts/scripts/Outland/gruuls_lair/boss_gruul.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp b/src/scripts/scripts/Outland/gruuls_lair/boss_high_king_maulgar.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp rename to src/scripts/scripts/Outland/gruuls_lair/boss_high_king_maulgar.cpp index 48b4ed8ee..d6177b1f5 --- a/src/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp +++ b/src/scripts/scripts/Outland/gruuls_lair/boss_high_king_maulgar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Outland/gruuls_lair/def_gruuls_lair.h b/src/scripts/scripts/Outland/gruuls_lair/def_gruuls_lair.h new file mode 100644 index 000000000..ea776462e --- /dev/null +++ b/src/scripts/scripts/Outland/gruuls_lair/def_gruuls_lair.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_GRUULS_LAIR_H +#define SC_DEF_GRUULS_LAIR_H + +#define DATA_BLINDEYETHESEER 1 +#define DATA_GRUULEVENT 2 +#define DATA_KIGGLERTHECRAZED 3 +#define DATA_KROSHFIREHAND 4 +#define DATA_MAULGAREVENT 5 +#define DATA_MAULGAREVENT_TANK 6 +#define DATA_OLMTHESUMMONER 7 +#define DATA_MAULGARDOOR 8 +#define DATA_GRUULDOOR 9 +#define DATA_MAULGAR 10 +#endif + diff --git a/src/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp b/src/scripts/scripts/Outland/gruuls_lair/instance_gruuls_lair.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp rename to src/scripts/scripts/Outland/gruuls_lair/instance_gruuls_lair.cpp index c28818f74..bc10d69d6 --- a/src/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp +++ b/src/scripts/scripts/Outland/gruuls_lair/instance_gruuls_lair.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_broggok.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_broggok.cpp index 058dec401..50dbebad0 --- a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_broggok.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -53,17 +56,12 @@ static CellPosition CellLocation[]= { 501.118f, 84.228f, 9.657f, 3.188f } }; -/* static float CellPrisoner[] -{ - { }, - { }, - { }, - { }, -}; */ - struct boss_broggokAI : public ScriptedAI { - boss_broggokAI(Creature *c) : ScriptedAI(c), summons(c) { pInstance = c->GetInstanceData(); } + boss_broggokAI(Creature *c) : ScriptedAI(c), summons(c) + { + pInstance = c->GetInstanceData(); + } uint32 AcidSpray_Timer; uint32 PoisonSpawn_Timer; @@ -87,7 +85,9 @@ struct boss_broggokAI : public ScriptedAI summons.DespawnAll(); prisoners.clear(); - pInstance->SetData(DATA_BROGGOKEVENT, NOT_STARTED); + if (pInstance) + pInstance->SetData(DATA_BROGGOKEVENT, NOT_STARTED); + me->SetReactState(REACT_PASSIVE); phase = EVENT_NULL; @@ -120,12 +120,15 @@ struct boss_broggokAI : public ScriptedAI void EnterCombat(Unit *who) { DoScriptText(SAY_AGGRO, m_creature); + phase = EVENT_FIGHT; } void JustDied(Unit *pKiller) { - pInstance->SetData(DATA_BROGGOKEVENT, DONE); + if (pInstance) + pInstance->SetData(DATA_BROGGOKEVENT, DONE); + summons.DespawnAll(); prisoners.clear(); } @@ -135,7 +138,8 @@ struct boss_broggokAI : public ScriptedAI switch (param) { case EVENT_1_CAGE: - pInstance->SetData(DATA_BROGGOKEVENT, IN_PROGRESS); + if (pInstance) + pInstance->SetData(DATA_BROGGOKEVENT, IN_PROGRESS); case EVENT_2_CAGE: case EVENT_3_CAGE: case EVENT_4_CAGE: @@ -250,6 +254,7 @@ bool GOUse_go_broggok_lever(Player* pPlayer, GameObject* pGo) if (Creature *pBoss = GetClosestCreatureWithEntry(pPlayer, 17380, 200.0f)) pBoss->AI()->DoAction(EVENT_1_CAGE); } + pGo->UseDoorOrButton(5); return true; } diff --git a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp old mode 100755 new mode 100644 similarity index 88% rename from src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp index 797c6f3c9..a1a18a5c8 --- a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -69,7 +72,7 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI { boss_kelidan_the_breakerAI(Creature *c) : ScriptedAI(c) { - pInstance = (c->GetInstanceData()); + pInstance = c->GetInstanceData(); for(int i=0; i<5; ++i) Channelers[i] = 0; } @@ -94,13 +97,19 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI check_Timer = 0; Firenova = false; addYell = false; - SummonChannelers(); + + if (pInstance) + pInstance->SetData(DATA_KELIDANEVENT, NOT_STARTED); } void EnterCombat(Unit *who) { DoScriptText(SAY_WAKE, m_creature); - if (m_creature->IsNonMeleeSpellCasted(false)) + + if (pInstance) + pInstance->SetData(DATA_KELIDANEVENT, IN_PROGRESS); + + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); DoStartMovement(who); } @@ -173,8 +182,21 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI void JustDied(Unit* Killer) { DoScriptText(SAY_DIE, m_creature); - if(pInstance) - pInstance->SetData(DATA_KELIDANEVENT, DONE); + + if(pInstance) + pInstance->SetData(DATA_KELIDANEVENT, DONE); + } + + void MovementInform(uint32 type, uint32 id) + { + if (type != POINT_MOTION_TYPE) + return; + + if (id == 1) + { + SummonChannelers(); + DoCast(m_creature,SPELL_EVOCATION); + } } void UpdateAI(const uint32 diff) @@ -183,8 +205,12 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI { if(check_Timer < diff) { - if (!m_creature->IsNonMeleeSpellCasted(false)) - DoCast(m_creature,SPELL_EVOCATION); + if (!m_creature->IsNonMeleeSpellCast(false)) + { + float x, y, z; + me->GetRespawnCoord(x, y, z); + me->GetMotionMaster()->MovePoint(1, x, y, z); + } check_Timer = 5000; } @@ -198,7 +224,7 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI { if (Firenova_Timer < diff) { - AddSpellToCast(m_creature,SPELL_FIRE_NOVA); + ForceSpellCast(me, SPELL_FIRE_NOVA, INTERRUPT_AND_CAST_INSTANTLY); Firenova = false; ShadowVolley_Timer = 2000; } @@ -226,7 +252,7 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI if (BurningNova_Timer < diff) { - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); DoScriptText(SAY_NOVA, m_creature); @@ -247,7 +273,7 @@ struct boss_kelidan_the_breakerAI : public ScriptedAI } BurningNova_Timer = urand(20000, 28000); - Firenova_Timer= 6500; + Firenova_Timer= 5000; Firenova = true; } else @@ -290,7 +316,7 @@ struct mob_shadowmoon_channelerAI : public ScriptedAI ShadowBolt_Timer = urand(1000, 2000); MarkOfShadow_Timer = urand(5000, 7000); check_Timer = 0; - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); } @@ -299,7 +325,7 @@ struct mob_shadowmoon_channelerAI : public ScriptedAI if(Creature *Kelidan = (Creature *)FindCreature(ENTRY_KELIDAN, 100, m_creature)) ((boss_kelidan_the_breakerAI*)Kelidan->AI())->ChannelerEngaged(who); - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(true); DoStartMovement(who); @@ -317,7 +343,7 @@ struct mob_shadowmoon_channelerAI : public ScriptedAI { if(check_Timer < diff) { - if (!m_creature->IsNonMeleeSpellCasted(false)) + if (!m_creature->IsNonMeleeSpellCast(false)) if(Creature *Kelidan = (Creature *)FindCreature(ENTRY_KELIDAN, 100, m_creature)) { uint64 channeler = ((boss_kelidan_the_breakerAI*)Kelidan->AI())->GetChanneled(m_creature); diff --git a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp old mode 100755 new mode 100644 similarity index 84% rename from src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp index da75dd364..5c50701ec --- a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/boss_the_maker.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_The_Maker -SD%Complete: 80 -SDComment: Mind control no support +SD%Complete: 85 +SDComment: SDCategory: Hellfire Citadel, Blood Furnace EndScriptData */ @@ -38,7 +41,10 @@ EndScriptData */ struct boss_the_makerAI : public ScriptedAI { - boss_the_makerAI(Creature *c) : ScriptedAI(c){ pInstance = c->GetInstanceData(); } + boss_the_makerAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } uint32 AcidSpray_Timer; uint32 ExplodingBreaker_Timer; @@ -53,11 +59,17 @@ struct boss_the_makerAI : public ScriptedAI ExplodingBreaker_Timer = 6000; Domination_Timer = 20000; Knockdown_Timer = 10000; + + if (pInstance) + pInstance->SetData(DATA_MAKEREVENT, NOT_STARTED); } void EnterCombat(Unit *who) { DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); + + if (pInstance) + pInstance->SetData(DATA_MAKEREVENT, IN_PROGRESS); } void KilledUnit(Unit* victim) @@ -68,7 +80,9 @@ struct boss_the_makerAI : public ScriptedAI void JustDied(Unit* Killer) { DoScriptText(SAY_DIE, m_creature); - pInstance->SetData(DATA_MAKEREVENT, DONE); + + if (pInstance) + pInstance->SetData(DATA_MAKEREVENT, DONE); } void UpdateAI(const uint32 diff) @@ -79,7 +93,7 @@ struct boss_the_makerAI : public ScriptedAI if (AcidSpray_Timer < diff) { AddSpellToCast(me->getVictim(), SPELL_ACID_SPRAY); - AcidSpray_Timer = 15000+rand()%8000; + AcidSpray_Timer = 35000+rand()%8000; // not the correct spell. why spam ? } else AcidSpray_Timer -=diff; diff --git a/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/def_blood_furnace.h b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/def_blood_furnace.h new file mode 100644 index 000000000..4cf15e994 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/def_blood_furnace.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_BLOOD_FURNACE_H +#define SC_DEF_BLOOD_FURNACE_H + +#define DATA_KELIDANEVENT 1 +#define DATA_BROGGOKEVENT 2 +#define DATA_MAKEREVENT 3 + +#endif diff --git a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp old mode 100755 new mode 100644 similarity index 51% rename from src/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp index fb50e518a..0f79bdc09 --- a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,7 +19,7 @@ /* ScriptData SDName: Instance_Blood_Furnace -SD%Complete: 85 +SD%Complete: 95 SDComment: SDCategory: Hellfire Citadel, Blood Furnace EndScriptData */ @@ -24,59 +27,86 @@ EndScriptData */ #include "precompiled.h" #include "def_blood_furnace.h" -#define ENTRY_SEWER1 181823 -#define ENTRY_SEWER2 181766 +#define ENCOUNTERS 3 + +enum Doors +{ + NOT_OPENED = 0, + WAIT_FOR_OPEN = 1, + OPENED = 2 +}; struct instance_blood_furnace : public ScriptedInstance { instance_blood_furnace(Map *map) : ScriptedInstance(map) {Initialize();}; + uint32 Encounter[ENCOUNTERS]; uint64 Sewer1GUID; uint64 Sewer2GUID; - - uint32 BroggokEncounter; - uint32 MakerEncounter; - - uint64 BroggokDoor; - uint64 MakerDoorGUID; + uint64 BroggokDoor1GUID; + uint64 BroggokDoor2GUID; + uint64 MakerDoor1GUID; + uint64 MakerDoor2GUID; + uint64 MakerGUID; + uint64 BroggokGUID; + uint64 KelidanGUID; uint64 CellDoor[4]; + Doors door; + void Initialize() { Sewer1GUID = 0; Sewer2GUID = 0; - MakerDoorGUID = 0; - BroggokEncounter = NOT_STARTED; - MakerEncounter = NOT_STARTED; + MakerDoor1GUID = 0; + MakerDoor2GUID = 0; + BroggokDoor1GUID = 0; + BroggokDoor2GUID = 0; + MakerGUID = 0; + BroggokGUID = 0; + KelidanGUID = 0; for(int i = 0; i < 4; i++) CellDoor[i] = 0; - BroggokDoor = 0; + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + + door = NOT_OPENED; + } + + void OnPlayerEnter(Player* player) + { + if (door == NOT_OPENED) + door = WAIT_FOR_OPEN; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature->GetEntry()) + { + case 17381: MakerGUID = creature->GetGUID(); break; + case 17380: BroggokGUID = creature->GetGUID(); break; + case 17377: KelidanGUID = creature->GetGUID(); break; + } } void OnObjectCreate(GameObject *go) { switch (go->GetEntry()) { - case ENTRY_SEWER1: Sewer1GUID = go->GetGUID(); break; - case ENTRY_SEWER2: Sewer2GUID = go->GetGUID(); break; - case 181819: - BroggokDoor = go->GetGUID(); - if (BroggokEncounter == DONE) - HandleGameObject(BroggokDoor, 0); - break; + case 181811: MakerDoor1GUID = go->GetGUID(); break; + case 181812: MakerDoor2GUID = go->GetGUID(); break; case 181821: CellDoor[0] = go->GetGUID(); break; case 181820: CellDoor[1] = go->GetGUID(); break; case 181818: CellDoor[2] = go->GetGUID(); break; case 181817: CellDoor[3] = go->GetGUID(); break; - case 181812: - MakerDoorGUID = go->GetGUID(); - if (MakerEncounter == DONE) - HandleGameObject(MakerDoorGUID,0); - break; + case 181822: BroggokDoor1GUID = go->GetGUID(); break; + case 181819: BroggokDoor2GUID = go->GetGUID(); break; + case 181823: Sewer1GUID = go->GetGUID(); break; + case 181766: Sewer2GUID = go->GetGUID(); break; } } @@ -107,7 +137,7 @@ struct instance_blood_furnace : public ScriptedInstance return; } - if (GameObject *go = GameObject::GetGameObject(*player,guid)) + if (GameObject *go = GameObject::GetGameObject(*player, guid)) go->SetGoState(GOState(state)); } @@ -115,36 +145,50 @@ struct instance_blood_furnace : public ScriptedInstance { switch (type) { - case DATA_KELIDANEVENT: + case DATA_MAKEREVENT: if (data == DONE) - { - HandleGameObject(Sewer1GUID,0); - HandleGameObject(Sewer2GUID,0); - } + HandleGameObject(MakerDoor2GUID, 0); + + if (Encounter[0] != DONE) + Encounter[0] = data; break; case DATA_BROGGOKEVENT: if (data == DONE) - HandleGameObject(BroggokDoor, 0); + HandleGameObject(BroggokDoor2GUID, 0); - BroggokEncounter = data; + if (Encounter[1] != DONE) + Encounter[1] = data; break; - case DATA_MAKEREVENT: + case DATA_KELIDANEVENT: if (data == DONE) - HandleGameObject(MakerDoorGUID,0); + { + HandleGameObject(Sewer1GUID, 0); + HandleGameObject(Sewer2GUID, 0); + } - MakerEncounter = data; + if (Encounter[2] != DONE) + Encounter[2] = data; break; if (data == DONE) + { SaveToDB(); + OUT_SAVE_INST_DATA_COMPLETE; + } } } uint32 GetData(uint32 type) { - if (type == DATA_BROGGOKEVENT) - return BroggokEncounter; - + switch (type) + { + case DATA_MAKEREVENT: + return Encounter[0]; + case DATA_BROGGOKEVENT: + return Encounter[1]; + case DATA_KELIDANEVENT: + return Encounter[2]; + } return 0; } @@ -158,19 +202,53 @@ struct instance_blood_furnace : public ScriptedInstance case 4: return CellDoor[type-1]; case 5: - return BroggokDoor; + return BroggokDoor2GUID; default: return 0; } } + void Update(uint32 diff) + { + if (door == WAIT_FOR_OPEN) + { + if (Creature* Maker = instance->GetCreature(MakerGUID)) + { + HandleGameObject(MakerDoor1GUID, 0); + + if (Maker && !Maker->isAlive()) + HandleGameObject(MakerDoor2GUID, 0); + } + + if (Creature* Broggok = instance->GetCreature(BroggokGUID)) + { + HandleGameObject(BroggokDoor1GUID, 0); + + if (Broggok && !Broggok->isAlive()) + HandleGameObject(BroggokDoor2GUID, 0); + } + + if (Creature* Kelidan = instance->GetCreature(KelidanGUID)) + { + if (Kelidan && !Kelidan->isAlive()) + { + HandleGameObject(Sewer1GUID, 0); + HandleGameObject(Sewer2GUID, 0); + } + } + + door = OPENED; + } + } + std::string GetSaveData() { OUT_SAVE_INST_DATA; std::ostringstream stream; - stream << MakerEncounter << " "; - stream << BroggokEncounter; + stream << Encounter[0] << " "; + stream << Encounter[1] << " "; + stream << Encounter[2] ; OUT_SAVE_INST_DATA_COMPLETE; @@ -184,15 +262,15 @@ struct instance_blood_furnace : public ScriptedInstance OUT_LOAD_INST_DATA_FAIL; return; } + OUT_LOAD_INST_DATA(in); - std::istringstream stream(in); - stream >> MakerEncounter >> BroggokEncounter; - if (MakerEncounter == DONE) - HandleGameObject(MakerDoorGUID,0); + std::istringstream stream(in); + stream >> Encounter[0] >> Encounter[1] >> Encounter[2]; - if (BroggokEncounter == DONE) - HandleGameObject(BroggokDoor, 0); + for (uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounter[i] == IN_PROGRESS) + Encounter[i] = NOT_STARTED; OUT_LOAD_INST_DATA_COMPLETE; } diff --git a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp old mode 100755 new mode 100644 similarity index 60% rename from src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp index 8d1c5bb7d..9338b3d09 --- a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp @@ -1,4 +1,8 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,12 +20,13 @@ /* ScriptData SDName: Boss_Omar_The_Unscarred -SD%Complete: 90 -SDComment: Temporary solution for orbital/shadow whip-ability. Needs more core support before making it more proper. +SD%Complete: 98 +SDComment: SDCategory: Hellfire Citadel, Hellfire Ramparts EndScriptData */ #include "precompiled.h" +#include "hellfire_ramparts.h" #define SAY_AGGRO_1 -1543009 #define SAY_AGGRO_2 -1543010 @@ -34,47 +39,52 @@ EndScriptData */ #define SPELL_ORBITAL_STRIKE 30637 #define SPELL_SHADOW_WHIP 30638 -#define SPELL_TREACHEROUS_AURA 30695 -#define H_SPELL_BANE_OF_TREACHERY 37566 +#define SPELL_BANE_OF_AURA_TREACHERY (HeroicMode ? 37566 : 30695) #define SPELL_DEMONIC_SHIELD 31901 -#define SPELL_SHADOW_BOLT 30686 -#define H_SPELL_SHADOW_BOLT 39297 +#define SPELL_SHADOW_BOLT (HeroicMode ? 39297 : 30686) #define SPELL_SUMMON_FIENDISH_HOUND 30707 struct boss_omor_the_unscarredAI : public ScriptedAI { boss_omor_the_unscarredAI(Creature *c) : ScriptedAI(c) { + pInstance = (c->GetInstanceData()); } + ScriptedInstance* pInstance; + uint32 OrbitalStrike_Timer; uint32 ShadowWhip_Timer; uint32 Aura_Timer; uint32 DemonicShield_Timer; uint32 Shadowbolt_Timer; uint32 Summon_Timer; - uint32 SummonedCount; uint64 playerGUID; bool CanPullBack; void Reset() { - DoScriptText(SAY_WIPE, m_creature); + DoScriptText(SAY_WIPE, me); - OrbitalStrike_Timer = 25000; + OrbitalStrike_Timer = 22000; ShadowWhip_Timer = 2000; - Aura_Timer = 10000; + Aura_Timer = 18000; DemonicShield_Timer = 1000; - Shadowbolt_Timer = 2000; - Summon_Timer = 10000; - SummonedCount = 0; + Shadowbolt_Timer = 1; + Summon_Timer = 20000; playerGUID = 0; CanPullBack = false; + + if (pInstance) + pInstance->SetData(DATA_OMOR, NOT_STARTED); } void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); + DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), me); + + if (pInstance) + pInstance->SetData(DATA_OMOR, IN_PROGRESS); } void KilledUnit(Unit* victim) @@ -82,22 +92,23 @@ struct boss_omor_the_unscarredAI : public ScriptedAI if (rand()%2) return; - DoScriptText(SAY_KILL_1, m_creature); + DoScriptText(SAY_KILL_1, me); } void JustSummoned(Creature* summoned) { - DoScriptText(SAY_SUMMON, m_creature); + DoScriptText(SAY_SUMMON, me); if (Unit* random = SelectUnit(SELECT_TARGET_RANDOM,0)) summoned->AI()->AttackStart(random); - - ++SummonedCount; } void JustDied(Unit* Killer) { - DoScriptText(SAY_DIE, m_creature); + DoScriptText(SAY_DIE, me); + + if (pInstance) + pInstance->SetData(DATA_OMOR, DONE); } void UpdateAI(const uint32 diff) @@ -105,65 +116,65 @@ struct boss_omor_the_unscarredAI : public ScriptedAI if (!UpdateVictim()) return; - //only two may be wrong, perhaps increase timer and spawn periodically instead. - if (SummonedCount < 2) + if (Summon_Timer < diff) { - if (Summon_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_SUMMON_FIENDISH_HOUND); - Summon_Timer = 15000+rand()%15000; - } - else - Summon_Timer -= diff; + AddSpellToCast(me, SPELL_SUMMON_FIENDISH_HOUND); + Summon_Timer = 18000; } + else + Summon_Timer -= diff; if (CanPullBack) { if (ShadowWhip_Timer < diff) { - if (Unit* temp = Unit::GetUnit(*m_creature,playerGUID)) + if (Unit* temp = Unit::GetUnit(*me,playerGUID)) { - //if unit dosen't have this flag, then no pulling back (script will attempt cast, even if orbital strike was resisted) if (temp->HasUnitMovementFlag(MOVEFLAG_FALLINGFAR)) { - m_creature->InterruptNonMeleeSpells(false); - DoCast(temp,SPELL_SHADOW_WHIP); + me->InterruptNonMeleeSpells(false); + DoCast(temp, SPELL_SHADOW_WHIP); + } + else + { + if (!temp->HasUnitMovementFlag(MOVEFLAG_FALLINGFAR)) + { + playerGUID = 0; + CanPullBack = false; + } } } - playerGUID = 0; - ShadowWhip_Timer = 2000; - CanPullBack = false; + ShadowWhip_Timer = 2200; } else ShadowWhip_Timer -= diff; } else if (OrbitalStrike_Timer < diff) { - Unit* temp = NULL; - if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) - temp = m_creature->getVictim(); - else - temp = SelectUnit(SELECT_TARGET_RANDOM,0); + Unit *temp = SelectUnit(SELECT_TARGET_NEAREST, 0, 100, true); - if (temp && temp->GetTypeId() == TYPEID_PLAYER) + if (temp && temp->GetTypeId() == TYPEID_PLAYER && me->IsWithinMeleeRange(temp)) { - DoCast(temp,SPELL_ORBITAL_STRIKE); - OrbitalStrike_Timer = 14000+rand()%2000; + me->InterruptNonMeleeSpells(false); + DoCast(temp, SPELL_ORBITAL_STRIKE); + OrbitalStrike_Timer = 22000; playerGUID = temp->GetGUID(); if (playerGUID) + { CanPullBack = true; + ShadowWhip_Timer = 3000; + } } } else OrbitalStrike_Timer -= diff; - if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) + if ((me->GetHealth()*100) / me->GetMaxHealth() < 20) { if (DemonicShield_Timer < diff) { - DoCast(m_creature,SPELL_DEMONIC_SHIELD); + AddSpellToCast(me, SPELL_DEMONIC_SHIELD); DemonicShield_Timer = 15000; } else @@ -172,12 +183,12 @@ struct boss_omor_the_unscarredAI : public ScriptedAI if (Aura_Timer < diff) { - DoScriptText(SAY_CURSE, m_creature); + DoScriptText(SAY_CURSE, me); if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0)) { - DoCast(target, HeroicMode ? H_SPELL_BANE_OF_TREACHERY : SPELL_TREACHEROUS_AURA); - Aura_Timer = 8000+rand()%8000; + AddSpellToCast(target, SPELL_BANE_OF_AURA_TREACHERY); + Aura_Timer = 18000; } } else @@ -187,16 +198,17 @@ struct boss_omor_the_unscarredAI : public ScriptedAI { if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0)) { - if (target) - target = m_creature->getVictim(); - - DoCast(target, HeroicMode ? H_SPELL_SHADOW_BOLT : SPELL_SHADOW_BOLT); - Shadowbolt_Timer = 4000+rand()%2500; + if(!me->IsWithinMeleeRange(target)) + { + AddSpellToCast(target, SPELL_SHADOW_BOLT); + Shadowbolt_Timer = 3000; + } } } else Shadowbolt_Timer -= diff; + CastNextSpellIfAnyAndReady(); DoMeleeAttackIfReady(); } }; diff --git a/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp new file mode 100644 index 000000000..de774d1a0 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp @@ -0,0 +1,560 @@ +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +Name: Boss_Vazruden_the_Herald +%Complete: 95 +Comment: +Category: Hellfire Citadel, Hellfire Ramparts +EndScriptData */ + +#include "precompiled.h" +#include "hellfire_ramparts.h" + +#define SAY_INTRO -1543017 +#define SAY_AGGRO1 -1543018 +#define SAY_AGGRO2 -1543019 +#define SAY_AGGRO3 -1543020 +#define SAY_TAUNT -1543021 +#define SAY_KILL1 -1543022 +#define SAY_KILL2 -1543023 +#define SAY_DEATH -1543024 +#define EMOTE_DESCEND -1543025 +#define POINT_ID_CENTER 11 +#define POINT_ID_FLYING 12 +#define POINT_ID_COMBAT 13 +#define SPELL_FIREBALL (HeroicMode?36920:34653) +#define SPELL_CONE_OF_FIRE (HeroicMode?36921:30926) +#define SPELL_SUMMON_LIQUID_FIRE (HeroicMode?30928:23971) +#define SPELL_BELLOW_ROAR 39427 +#define SPELL_REVENGE (HeroicMode?40392:19130) +#define SPELL_BLAZE (HeroicMode?32492:30927) +#define SPELL_KIDNEY_SHOT 30621 +#define SPELL_FIRE_NOVA_VISUAL 19823 +#define SPELL_SUMMON_VAZRUDEN 30717 +#define ENTRY_HELLFIRE_SENTRY 17517 +#define ENTRY_VAZRUDEN_HERALD 17307 +#define ENTRY_VAZRUDEN 17537 +#define ENTRY_NAZAN 17536 +#define ENTRY_LIQUID_FIRE 22515 +#define ENTRY_REINFORCED_FEL_IRON_CHEST (HeroicMode?185169:185168) + +#define PATH_ENTRY 2081 + +const float CenterPos[3] = { -1399.401f, 1736.365f, 87.008f}; +const float CombatPos[3] = { -1413.848f, 1754.019f, 83.146f}; + +struct boss_vazruden_the_heraldAI : public ScriptedAI +{ + boss_vazruden_the_heraldAI(Creature* creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + HeroicMode = me->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + + bool HeroicMode; + bool SentryDown; + bool IsEventInProgress; + bool IsDescending; + uint8 phase; + uint32 MovementTimer; + uint32 FireballTimer; + uint32 ConeOfFireTimer; + uint32 BellowingRoarTimer; + uint32 checktimer; + uint32 FlyTimer; + uint64 PlayerGUID; + uint64 VazrudenGUID; + uint64 VictimGUID; + + void Reset() + { + if (me->GetEntry() != ENTRY_VAZRUDEN_HERALD) + me->UpdateEntry(ENTRY_VAZRUDEN_HERALD); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + MovementTimer = 0; + phase = 0; + SentryDown = false; + IsEventInProgress = false; + IsDescending = false; + PlayerGUID = 0; + VazrudenGUID = 0; + VictimGUID = 0; + checktimer = 0; + FireballTimer = 0; + ConeOfFireTimer = 1200+rand()%3000; + BellowingRoarTimer = 1800+rand()%3000; + FlyTimer = 45000+rand()%3000; + me->SetLevitate(true); + me->SetSpeed(MOVE_FLIGHT, 1.0f); + me->GetMotionMaster()->MovePath(PATH_ENTRY, true); + + if (Creature* Vazruden = GetClosestCreatureWithEntry(me, ENTRY_VAZRUDEN, 100.0f, false)) + { + Vazruden->SetLootRecipient(NULL); + Vazruden->RemoveCorpse(); + } + } + + void AttackStart(Unit* who) + { + if (pInstance && pInstance->GetData(DATA_NAZAN) != IN_PROGRESS) + return; + + ScriptedAI::AttackStart(who); + } + + void MovementInform(uint32 type, uint32 id) + { + if (!pInstance) + return; + + if (type == POINT_MOTION_TYPE) + { + switch (id) + { + case POINT_ID_CENTER: + DoSplit(); + break; + case POINT_ID_COMBAT: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + pInstance->SetData(DATA_NAZAN, IN_PROGRESS); + me->SetLevitate(false); + me->SetWalk(true); + me->GetMotionMaster()->Clear(); + + if (Unit *victim = SelectUnit(SELECT_TARGET_NEAREST,0)) + me->AI()->AttackStart(victim); + + FireballTimer = 5200+rand()%4000; + phase = 2; + break; + case POINT_ID_FLYING: + if (IsEventInProgress) + FireballTimer = 1; + break; + } + } + } + + void DoStart() + { + if (MovementTimer || IsEventInProgress) + return; + + if (pInstance) + { + me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); + DoMoveToCenter(); + IsEventInProgress = true; + } + + phase = 1; + } + + void DoMoveToCenter() + { + DoScriptText(SAY_INTRO, me); + me->GetMotionMaster()->MovePoint(POINT_ID_CENTER, CenterPos[0], CenterPos[1], CenterPos[2]); + } + + void DoSplit() + { + me->UpdateEntry(ENTRY_NAZAN); + DoCast(me, SPELL_SUMMON_VAZRUDEN); + MovementTimer = 2000; + checktimer = 10000; + me->SetSpeed(MOVE_FLIGHT, 2.0f); + me->GetMotionMaster()->MoveIdle(); + } + + void DoMoveToAir() + { + float x, y, z, o; + me->GetHomePosition(x, y, z, o); + me->GetMotionMaster()->MovePoint(POINT_ID_FLYING, x, y, z); + } + + void DoMoveToCombat() + { + if (IsDescending || !pInstance || pInstance->GetData(DATA_NAZAN) == IN_PROGRESS) + return; + + IsDescending = true; + me->GetMotionMaster()->MovePoint(POINT_ID_COMBAT, CombatPos[0], CombatPos[1], CombatPos[2]); + DoScriptText(EMOTE_DESCEND, me); + } + + void SpellHitTarget(Unit* target, const SpellEntry* entry) + { + + } + + void JustSummoned(Creature* summoned) + { + switch (summoned->GetEntry()) + { + case ENTRY_VAZRUDEN: + if (Player* pPlayer = Unit::GetPlayer(PlayerGUID)) + summoned->AI()->AttackStart(pPlayer); + + VazrudenGUID = summoned->GetGUID(); + break; + case ENTRY_LIQUID_FIRE: + summoned->SetLevel(me->getLevel()); + summoned->setFaction(me->getFaction()); + break; + } + } + + void DoDescend() + { + if (IsDescending) + return; + + DoMoveToCombat(); + } + + void SentryDownBy(Unit* who) + { + if (SentryDown) + { + PlayerGUID = who->GetGUID(); + DoStart(); + SentryDown = false; + } + else + SentryDown = true; + } + + void SelectVictim(Unit* victim) + { + VictimGUID = victim->GetGUID(); + } + + void JustDied(Unit* killer) + { + if (pInstance) + pInstance->SetData(DATA_NAZAN, DONE); + } + + void JustReachedHome() + { + if (pInstance) + pInstance->SetData(DATA_NAZAN, FAIL); + } + + void UpdateAI(const uint32 diff) + { + + + switch (phase) + { + case 0: + return; + break; + case 1: // flight + if (MovementTimer) + { + if (MovementTimer <= diff) + { + DoMoveToAir(); + MovementTimer = 0; + } + else + MovementTimer -= diff; + } + + if (VazrudenGUID && FireballTimer) + { + if (FireballTimer <= diff) + { + if (Creature* Vazruden = me->GetMap()->GetCreature(VazrudenGUID)) + { + Vazruden->AI()->DoAction(); + + if (Unit* victim = Unit::GetUnit(*me, VictimGUID)) + { + DoCast(victim, SPELL_FIREBALL); + FireballTimer = 4000+rand()%3000; + } + } + } + else + FireballTimer -= diff; + } + + if (FlyTimer <= diff) + { + DoDescend(); + } + else + FlyTimer -= diff; + + if ((me->GetHealth())*100 / me->GetMaxHealth() < 20) + DoMoveToCombat(); + + if (checktimer < diff && me->isAlive()) + { + if (Creature* Vazruden = me->GetMap()->GetCreature(VazrudenGUID)) + { + if (Vazruden && Vazruden->getVictim() || me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) + return; + else + EnterEvadeMode(); + } + + checktimer = 2000; + + } + else + checktimer -= diff; + break; + case 2: // In Combat + if (FireballTimer <= diff) + { + if (Unit *victim = SelectUnit(SELECT_TARGET_RANDOM,0)) + { + DoCast(victim, SPELL_FIREBALL); + FireballTimer = 7000+rand()%3000; + } + } + else + FireballTimer -= diff; + + if (ConeOfFireTimer <= diff) + { + DoCast(me->getVictim(), SPELL_CONE_OF_FIRE); + ConeOfFireTimer = 8300+rand()%3000; + } + else + ConeOfFireTimer -= diff; + + if (HeroicMode) + { + if (BellowingRoarTimer <= diff) + { + DoCast(me, SPELL_BELLOW_ROAR); + BellowingRoarTimer = 35000+rand()%4000; + } + else + BellowingRoarTimer -= diff; + } + + DoMeleeAttackIfReady(); + + if (checktimer <= diff) + { + if (!me->getVictim()) + { + if (Unit *victim = SelectUnit(SELECT_TARGET_NEAREST,0)) + me->AI()->AttackStart(victim); + else + EnterEvadeMode(); + } + + checktimer = 2000; + + } + else + checktimer -= diff; + break; + } + } +}; + +struct boss_vazrudenAI : public ScriptedAI +{ + boss_vazrudenAI(Creature* creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + HeroicMode = me->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + + bool HeroicMode; + bool HealthBelow; + + uint32 RevengeTimer; + uint64 VazHeraldGUID; + + void Reset() + { + HealthBelow = false; + RevengeTimer = 4000+rand()%3000; + VazHeraldGUID = 0; + } + + void EnterCombat(Unit *who) + { + DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); + } + + void JustDied(Unit* killer) + { + DoScriptText(SAY_DEATH, me); + + if (pInstance) + { + if (uint64 VazHeraldGUID = pInstance->GetData64(DATA_VAZHERALD)) + { + Creature* Nazan = (Unit::GetCreature(*me, VazHeraldGUID)); + CAST_AI(boss_vazruden_the_heraldAI, Nazan->AI())->DoDescend(); + } + } + } + + void JustReachedHome() + { + me->SetVisibility(VISIBILITY_OFF); + me->ForcedDespawn(); + } + + void KilledUnit(Unit* pVictim) + { + DoScriptText(RAND(SAY_KILL1, SAY_KILL2), me); + } + + void DamageTaken(Unit* dealer, uint32& damage) + { + if (!HealthBelow && pInstance && (me->GetHealth()*100 - damage) / me->GetMaxHealth() < 30) + { + if (uint64 VazHeraldGUID = pInstance->GetData64(DATA_VAZHERALD)) + { + Creature* Nazan = (Unit::GetCreature(*me, VazHeraldGUID)); + CAST_AI(boss_vazruden_the_heraldAI, Nazan->AI())->DoDescend(); + } + + HealthBelow = true; + } + } + + void DoAction(const int32 action) + { + if (Unit *victim = SelectUnit(SELECT_TARGET_RANDOM,0)) + { + if (uint64 VazHeraldGUID = pInstance->GetData64(DATA_VAZHERALD)) + { + Creature* Nazan = (Unit::GetCreature(*me, VazHeraldGUID)); + CAST_AI(boss_vazruden_the_heraldAI, Nazan->AI())->SelectVictim(victim); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (RevengeTimer < diff) + { + DoCast(me->getVictim(), SPELL_REVENGE); + RevengeTimer = 10000+rand()%3000; + } + else + RevengeTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct mob_hellfire_sentryAI : public ScriptedAI +{ + mob_hellfire_sentryAI(Creature *creature) : ScriptedAI(creature) + { + pInstance = (creature->GetInstanceData()); + } + + ScriptedInstance* pInstance; + + uint32 KidneyShot_Timer; + uint64 VazHeraldGUID; + + void Reset() + { + KidneyShot_Timer = 3000+rand()%4000; + VazHeraldGUID = 0; + } + + void JustDied(Unit* who) + { + if (uint64 VazHeraldGUID = pInstance->GetData64(DATA_VAZHERALD)) + { + Creature* Nazan = (Unit::GetCreature(*me, VazHeraldGUID)); + CAST_AI(boss_vazruden_the_heraldAI, Nazan->AI())->SentryDownBy(who); + } + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (KidneyShot_Timer <= diff) + { + if (Unit *victim = me->getVictim()) + DoCast(victim, SPELL_KIDNEY_SHOT); + + KidneyShot_Timer = 18000+rand()%3000; + } + else + KidneyShot_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_vazruden_the_herald(Creature *creature) +{ + return new boss_vazruden_the_heraldAI (creature); +} + +CreatureAI* GetAI_boss_vazruden(Creature *creature) +{ + return new boss_vazrudenAI (creature); +} + +CreatureAI* GetAI_mob_hellfire_sentry(Creature *creature) +{ + return new mob_hellfire_sentryAI (creature); +} + +void AddSC_boss_vazruden_the_herald() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_vazruden_the_herald"; + newscript->GetAI = &GetAI_boss_vazruden_the_herald; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="boss_vazruden"; + newscript->GetAI = &GetAI_boss_vazruden; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_hellfire_sentry"; + newscript->GetAI = &GetAI_mob_hellfire_sentry; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp old mode 100755 new mode 100644 similarity index 68% rename from src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp index 65a3f93d6..6b6a04238 --- a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -22,6 +25,7 @@ SDCategory: Hellfire Citadel, Hellfire Ramparts EndScriptData */ #include "precompiled.h" +#include "hellfire_ramparts.h" #define SAY_TAUNT -1543000 #define SAY_HEAL -1543001 @@ -42,9 +46,12 @@ struct boss_watchkeeper_gargolmarAI : public ScriptedAI { boss_watchkeeper_gargolmarAI(Creature *c) : ScriptedAI(c) { - HeroicMode = m_creature->GetMap()->IsHeroic(); + pInstance = (c->GetInstanceData()); + HeroicMode = me->GetMap()->IsHeroic(); } + ScriptedInstance* pInstance; + bool HeroicMode; uint32 Surge_Timer; @@ -62,29 +69,35 @@ struct boss_watchkeeper_gargolmarAI : public ScriptedAI HasTaunted = false; YelledForHeal = false; + + if (pInstance) + pInstance->SetData(DATA_GARGOLMAR, NOT_STARTED); } void EnterCombat(Unit *who) { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); + DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), me); + + if (pInstance) + pInstance->SetData(DATA_GARGOLMAR, IN_PROGRESS); } void MoveInLineOfSight(Unit* who) { - if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessiblePlacefor(m_creature) ) + if (!me->getVictim() && who->isTargetableForAttack() && ( me->IsHostileTo( who )) && who->isInAccessiblePlacefor(me) ) { - if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return; - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + float attackRadius = me->GetAttackDistance(who); + if (me->IsWithinDistInMap(who, attackRadius) && me->IsWithinLOSInMap(who)) { //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); AttackStart(who); } - else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) + else if (!HasTaunted && me->IsWithinDistInMap(who, 60.0f)) { - DoScriptText(SAY_TAUNT, m_creature); + DoScriptText(SAY_TAUNT, me); HasTaunted = true; } } @@ -92,12 +105,20 @@ struct boss_watchkeeper_gargolmarAI : public ScriptedAI void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), m_creature); + DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DIE, m_creature); + DoScriptText(SAY_DIE, me); + + std::list helpers = FindAllCreaturesWithEntry(17309, 100); + for(std::list::iterator i = helpers.begin(); i != helpers.end(); i++) + { + (*i)->ForcedDespawn(500); + } + if (pInstance) + pInstance->SetData(DATA_GARGOLMAR, DONE); } void UpdateAI(const uint32 diff) @@ -107,13 +128,13 @@ struct boss_watchkeeper_gargolmarAI : public ScriptedAI if (MortalWound_Timer < diff) { - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_MORTAL_WOUND : SPELL_MORTAL_WOUND); + DoCast(me->getVictim(),HeroicMode ? H_SPELL_MORTAL_WOUND : SPELL_MORTAL_WOUND); MortalWound_Timer = 5000+rand()%8000; }else MortalWound_Timer -= diff; if (Surge_Timer < diff) { - DoScriptText(SAY_SURGE, m_creature); + DoScriptText(SAY_SURGE, me); if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0,GetSpellMaxRange(SPELL_SURGE), true)) DoCast(target,SPELL_SURGE); @@ -121,20 +142,20 @@ struct boss_watchkeeper_gargolmarAI : public ScriptedAI Surge_Timer = 5000+rand()%8000; }else Surge_Timer -= diff; - if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) + if ((me->GetHealth()*100) / me->GetMaxHealth() < 20) { if (Retaliation_Timer < diff) { - DoCast(m_creature,SPELL_RETALIATION); + DoCast(me,SPELL_RETALIATION); Retaliation_Timer = 30000; }else Retaliation_Timer -= diff; } if (!YelledForHeal) { - if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 40) + if ((me->GetHealth()*100) / me->GetMaxHealth() < 40) { - DoScriptText(SAY_HEAL, m_creature); + DoScriptText(SAY_HEAL, me); YelledForHeal = true; } } diff --git a/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/hellfire_ramparts.h b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/hellfire_ramparts.h new file mode 100644 index 000000000..84e2e6b56 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/hellfire_ramparts.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2006-2013 ScriptDev2 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef DEF_RAMPARTS_H +#define DEF_RAMPARTS_H + +#define DATA_GARGOLMAR 1 +#define DATA_OMOR 2 +#define DATA_NAZAN 3 +#define DATA_VAZHERALD 4 + +#endif \ No newline at end of file diff --git a/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp new file mode 100644 index 000000000..7d60af1b9 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2006-2013 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Hellfire_Ramparts +SD%Complete: 95 +SDComment: +SDCategory: Hellfire Ramparts +EndScriptData */ + +#include "precompiled.h" +#include "hellfire_ramparts.h" + +#define ENCOUNTERS 3 +#define ENTRY_VAZRUDEN_HERALD 17307 +#define ENTRY_NAZAN 17536 +#define ENTRY_HELLFIRE_SENTRY 17517 +#define ENTRY_REINFORCED_FEL_IRON_CHEST_H 185169 +#define ENTRY_REINFORCED_FEL_IRON_CHEST 185168 + +const float VazrudenMiddle[3] = {-1406.5, 1746.5, 81.2}; + +struct instance_ramparts : public ScriptedInstance +{ + instance_ramparts(Map *map) : ScriptedInstance(map){Initialize();} + + uint32 Encounter[ENCOUNTERS]; + std::string str_data; + std::list SentryList; + uint64 VazHeraldGUID; + + void Initialize() + { + for (uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + + VazHeraldGUID = 0; + } + + bool IsEncounterInProgress() const + { + for (uint8 i = 0; i < ENCOUNTERS; i++) + if (Encounter[i] == IN_PROGRESS) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch (creature_entry) + { + case ENTRY_VAZRUDEN_HERALD: + VazHeraldGUID = creature->GetGUID(); + break; + case ENTRY_HELLFIRE_SENTRY: + SentryList.push_back(creature->GetGUID()); + break; + } + } + + Player* GetPlayerInMap() + { + Map::PlayerList const& players = instance->GetPlayers(); + + if (!players.isEmpty()) + { + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if (Player* plr = itr->getSource()) + return plr; + } + } + + debug_log("OSCR: Instance Hellfire Ramparts: GetPlayerInMap, but PlayerList is empty!"); + return NULL; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_GARGOLMAR: + if (Encounter[0] != DONE) + Encounter[0] = data; + break; + case DATA_OMOR: + if (Encounter[1] != DONE) + Encounter[1] = data; + break; + case DATA_NAZAN: + if (data == FAIL) + { + for (std::list::iterator it = SentryList.begin(); it != SentryList.end(); ++it) + { + if (Creature* sentry = instance->GetCreature(*it)) + { + if (sentry->isDead()) + sentry->Respawn(); + } + } + Encounter[2] = NOT_STARTED; + } + + if (data == DONE) + { + Player *player = GetPlayerInMap(); + + if (instance->IsHeroic()) + player->SummonGameObject(ENTRY_REINFORCED_FEL_IRON_CHEST_H,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],0,0,0,0,0,0); + else + player->SummonGameObject(ENTRY_REINFORCED_FEL_IRON_CHEST,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],0,0,0,0,0,0); + } + + if (Encounter[2] != DONE) + Encounter[2] = data; + break; + } + + if (data == DONE) + { + SaveToDB(); + OUT_SAVE_INST_DATA_COMPLETE; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_GARGOLMAR: return Encounter[0]; + case DATA_OMOR: return Encounter[1]; + case DATA_NAZAN: return Encounter[2]; + } + return false; + } + + uint64 GetData64(uint32 data) + { + switch (data) + { + case DATA_VAZHERALD: + return VazHeraldGUID; + } + return 0; + } + + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + std::ostringstream saveStream; + + saveStream << Encounter[0] << " " << Encounter[1] << " " << Encounter[2]; + + char* out = new char[saveStream.str().length() + 1]; + strcpy(out, saveStream.str().c_str()); + if (out) + { + OUT_SAVE_INST_DATA_COMPLETE; + return out; + } + + return str_data.c_str(); + } + + void Load(const char* in) + { + if (!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + + std::istringstream loadStream(in); + loadStream >> Encounter[0] >> Encounter[1] >> Encounter[2]; + + for (uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounter[i] == IN_PROGRESS) + Encounter[i] = NOT_STARTED; + + OUT_LOAD_INST_DATA_COMPLETE; + } +}; +InstanceData* GetInstanceData_instance_ramparts(Map* pMap) +{ + return new instance_ramparts(pMap); +} + +void AddSC_instance_ramparts() +{ + Script* pNewScript; + pNewScript = new Script; + pNewScript->Name = "instance_ramparts"; + pNewScript->GetInstanceData = &GetInstanceData_instance_ramparts; + pNewScript->RegisterSelf(); +} \ No newline at end of file diff --git a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp old mode 100755 new mode 100644 similarity index 94% rename from src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp index 8a754f737..5635c88b6 --- a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp @@ -1,18 +1,21 @@ -/* Copyright(C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -*(at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright(C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Magtheridon diff --git a/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h new file mode 100644 index 000000000..a83447a3f --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_MAGTHERIDONS_LAIR_H +#define SC_DEF_MAGTHERIDONS_LAIR_H + +#define DATA_MAGTHERIDON_EVENT 1 +#define DATA_MAGTHERIDON 2 +#define DATA_DOOR_GUID 3 +#define DATA_COLLAPSE 5 +#endif + diff --git a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp index 949c448f5..f5c7ae5be --- a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData diff --git a/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp new file mode 100644 index 000000000..5b6799038 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shattered_Halls +SD%Complete: 99 +SDComment: +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +/* ContentData +boss_blood_guard_porung +EndContentData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +#define SPELL_CLEAVE 15496 + +struct SumonPos +{ + float x, y, z; +}; + +static SumonPos Pos[]= +{ + {502.24f, 339.12f, 2.105f}, + {503.24f, 292.17f, 1.937f} +}; + + +struct boss_blood_guard_porungAI : public ScriptedAI +{ + boss_blood_guard_porungAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance* pInstance; + uint32 Cleave_Timer; + uint64 playerGUID; + uint8 wave; + bool waveone; + bool wavetwo; + + + void Reset() + { + Cleave_Timer = 10000; + playerGUID = 0; + waveone = false; + wavetwo = false; + wave = 0; + + if (pInstance) + pInstance->SetData(TYPE_PORUNG, NOT_STARTED); + } + + void MoveInLineOfSight(Unit* who) + { + if (who->GetTypeId() == TYPEID_PLAYER && !((Player*)who)->isGameMaster()) + { + if (who->IsWithinDistInMap(me, 126.0f) && !waveone) + { + playerGUID = who->GetGUID(); + DoSummon(); + ++wave; + waveone = true; + } + + if (who->IsWithinDistInMap(me, 76.0f) && !wavetwo) + { + playerGUID = who->GetGUID(); + DoSummon(); + wavetwo = true; + } + } + + ScriptedAI::MoveInLineOfSight(who); + } + + void DoSummon() + { + for (uint8 i = 0; i < 4; ++i) + { + me->SummonCreature(17462, Pos[wave].x, Pos[wave].y, Pos[wave].z, me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + } + } + + void JustSummoned(Creature* summoned) + { + if (Player* player = Unit::GetPlayer(playerGUID)) + summoned->AI()->AttackStart(player); + } + + void JustDied(Unit* Killer) + { + if (pInstance) + pInstance->SetData(TYPE_PORUNG, DONE); + } + + void EnterCombat(Unit *who) + { + if (pInstance) + pInstance->SetData(TYPE_PORUNG, IN_PROGRESS); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (Cleave_Timer < diff) + { + DoCast(me->getVictim(), SPELL_CLEAVE, false); + Cleave_Timer = 7500 + rand()%5000; + } + else + Cleave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_blood_guard_porung(Creature *_Creature) +{ + return new boss_blood_guard_porungAI (_Creature); +} + +struct npc_blood_guardAI : public ScriptedAI +{ + npc_blood_guardAI(Creature *c) : ScriptedAI(c) {} + + uint64 playerGUID; + uint8 wave; + bool waveone; + bool wavetwo; + + void Reset() + { + playerGUID = 0; + waveone = false; + wavetwo = false; + wave = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (who->GetTypeId() == TYPEID_PLAYER && !((Player*)who)->isGameMaster()) + { + if (who->IsWithinDistInMap(me, 126.0f) && !waveone) + { + playerGUID = who->GetGUID(); + DoSummon(); + ++wave; + waveone = true; + } + + if (who->IsWithinDistInMap(me, 76.0f) && !wavetwo) + { + playerGUID = who->GetGUID(); + DoSummon(); + wavetwo = true; + } + } + + ScriptedAI::MoveInLineOfSight(who); + } + + void DoSummon() + { + for (uint8 i = 0; i < 4; ++i) + { + me->SummonCreature(17462, Pos[wave].x, Pos[wave].y, Pos[wave].z, me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + } + } + + void JustSummoned(Creature* summoned) + { + if (Player* player = Unit::GetPlayer(playerGUID)) + summoned->AI()->AttackStart(player); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_blood_guard(Creature *_Creature) +{ + return new npc_blood_guardAI (_Creature); +} + +void AddSC_boss_blood_guard_porung() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_blood_guard_porung"; + newscript->GetAI = &GetAI_boss_blood_guard_porung; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_blood_guard"; + newscript->GetAI = &GetAI_npc_blood_guard; + newscript->RegisterSelf(); +} diff --git a/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp new file mode 100644 index 000000000..0352f7763 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_nethekurse.cpp @@ -0,0 +1,445 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grand_Warlock_Nethekurse +SD%Complete: 95 +SDComment: +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +/* ContentData +boss_grand_warlock_nethekurse +mob_fel_orc_convert +EndContentData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +struct Say +{ + int32 id; +}; + +static Say PeonAttacked[]= +{ + {-1540001}, + {-1540002}, + {-1540003}, + {-1540004}, +}; +static Say PeonDies[]= +{ + {-1540005}, + {-1540006}, + {-1540007}, + {-1540008}, +}; + +#define SAY_INTRO -1540000 +#define SAY_TAUNT_1 -1540009 +#define SAY_TAUNT_2 -1540010 +#define SAY_TAUNT_3 -1540011 +#define SAY_AGGRO_1 -1540012 +#define SAY_AGGRO_2 -1540013 +#define SAY_AGGRO_3 -1540014 +#define SAY_SLAY_1 -1540015 +#define SAY_SLAY_2 -1540016 +#define SAY_DIE -1540017 + +#define SPELL_DEATH_COIL 30500 +#define SPELL_DARK_SPIN 30502 +#define SPELL_SHADOW_FISSURE 30496 +#define SPELL_SHADOW_SEAR 30735 +#define SPELL_SHADOW_BOLT 30505 +#define SPELL_DARK_CLEAVE 30508 +#define SPELL_SHADOW_CLEAVE 30495 +#define H_SPELL_SHADOW_SLAM 35953 + +#define SPELL_HEMORRHAGE 30478 +#define SPELL_CONSUMPTION 30497 + +struct boss_grand_warlock_nethekurseAI : public ScriptedAI +{ + boss_grand_warlock_nethekurseAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + HeroicMode = me->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + bool IntroOnce; + bool IsIntroEvent; + bool IsMainEvent; + bool SpinOnce; + bool Phase; + + uint32 PeonEngagedCount; + uint32 PeonKilledCount; + + uint32 IntroEvent_Timer; + uint32 DeathCoil_Timer; + uint32 ShadowFissure_Timer; + uint32 Cleave_Timer; + uint32 ShadowBolt_Timer; + uint32 DarkCleave_Timer; + + void Reset() + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + IsIntroEvent = false; + IntroOnce = false; + IsMainEvent = false; + SpinOnce = false; + Phase = false; + + PeonEngagedCount = 0; + PeonKilledCount = 0; + + IntroEvent_Timer = 20000; + DeathCoil_Timer = 20000; + ShadowFissure_Timer = 8000; + Cleave_Timer = 17000; + ShadowBolt_Timer = 1000; + DarkCleave_Timer = 1000; + + if (pInstance) + pInstance->SetData(TYPE_NETHEKURSE, NOT_STARTED); + } + + void DoYellForPeonEnterCombat() + { + if (PeonEngagedCount >= 4) + return; + + DoScriptText(PeonAttacked[PeonEngagedCount].id, me); + ++PeonEngagedCount; + } + + void DoYellForPeonDeath() + { + if (PeonKilledCount >= 4) + return; + + DoScriptText(PeonDies[PeonKilledCount].id, me); + ++PeonKilledCount; + + if (PeonKilledCount == 4) + { + IsIntroEvent = false; + IsMainEvent = true; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } + + void PeonsAreDead() + { + DoScriptText(RAND(SAY_TAUNT_1, SAY_TAUNT_2, SAY_TAUNT_3), me); + + IsIntroEvent = false; + PeonEngagedCount = 4; + PeonKilledCount = 4; + IsMainEvent = true; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void AttackStart(Unit* who) + { + if (IsIntroEvent || !IsMainEvent) + return; + + ScriptedAI::AttackStart(who); + } + + void MoveInLineOfSight(Unit *who) + { + if (!IntroOnce && me->IsWithinDistInMap(who, 40.0f)) + { + if (who->GetTypeId() != TYPEID_PLAYER || ((Player*)who)->isGameMaster()) + return; + + DoScriptText(SAY_INTRO, me); + IntroOnce = true; + IsIntroEvent = true; + + if (pInstance) + { + pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); + pInstance->SetData(TYPE_NETHEKURSE, SPECIAL); + } + } + + if (IsIntroEvent || !IsMainEvent) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void EnterCombat(Unit* who) + { + DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), me); + } + + void JustSummoned(Creature *summoned) + { + summoned->setFaction(14); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + summoned->CastSpell(summoned,SPELL_CONSUMPTION,false,0,0,me->GetGUID()); + } + + void KilledUnit(Unit* victim) + { + DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); + } + + void EnterEvadeMode() + { + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->GetUnitStateMgr().InitDefaults(true); + + if (!me->isAlive()) + return; + + if (pInstance) + { + pInstance->SetData(TYPE_NETHEKURSE, FAIL); + + float x, y, z; + me->GetRespawnCoord(x, y, z); + me->GetMotionMaster()->MovePoint(1, x, y, z); + } + else + me->GetMotionMaster()->MoveTargetedHome(); + } + + void JustDied(Unit* killer) + { + DoScriptText(SAY_DIE, me); + + if (!pInstance) + return; + + pInstance->SetData(TYPE_NETHEKURSE,DONE); + } + + void MovementInform(uint32 type, uint32 id) + { + if (type != POINT_MOTION_TYPE) + return; + + if(id == 1) + { + Reset(); + me->SetFacingTo(4.4f); + me->CastSpell(me, SPELL_SHADOW_SEAR, true); + } + } + + void UpdateAI(const uint32 diff) + { + if (IsIntroEvent) + { + if (!pInstance) + return; + + if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS) + { + if (IntroEvent_Timer <= diff) + { + PeonsAreDead(); + } else IntroEvent_Timer -= diff; + } + } + + if (!UpdateVictim()) + return; + + if (!IsMainEvent) + return; + + if (Phase) + { + if (!SpinOnce) + { + me->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN); + DoCast(me, SPELL_DARK_SPIN); + SpinOnce = true; + } + + if (ShadowBolt_Timer <= diff) + { + if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,0)) + DoCast(pTarget,SPELL_SHADOW_BOLT); + ShadowBolt_Timer = 1000; + } else ShadowBolt_Timer -= diff; + + if (DarkCleave_Timer <= diff) + { + DoCast(me->getVictim(),SPELL_DARK_CLEAVE); + DarkCleave_Timer = 1000; + } else DarkCleave_Timer -= diff; + } + else + { + if (ShadowFissure_Timer <= diff) + { + if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,0)) + DoCast(pTarget,SPELL_SHADOW_FISSURE); + ShadowFissure_Timer = 7500+rand()%7500; + } else ShadowFissure_Timer -= diff; + + if (DeathCoil_Timer <= diff) + { + if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,0)) + DoCast(pTarget,SPELL_DEATH_COIL); + DeathCoil_Timer = 15000+rand()%5000; + } else DeathCoil_Timer -= diff; + + if (Cleave_Timer <= diff) + { + DoCast(me->getVictim(),(HeroicMode ? H_SPELL_SHADOW_SLAM : SPELL_SHADOW_CLEAVE)); + Cleave_Timer = 20000+rand()%2500; + } else Cleave_Timer -= diff; + + if ((me->GetHealth()*100) / me->GetMaxHealth() <= 20) + Phase = true; + + DoMeleeAttackIfReady(); + } + } +}; + +struct mob_fel_orc_convertAI : public ScriptedAI +{ + mob_fel_orc_convertAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + } + + ScriptedInstance* pInstance; + uint32 Hemorrhage_Timer; + uint32 Kill_Timer; + + void Reset() + { + me->SetNoCallAssistance(true); + Hemorrhage_Timer = 3000; + Kill_Timer = 0; + } + + void MoveInLineOfSight(Unit* who) + { + return; + } + + void EnterCombat(Unit* who) + { + if (pInstance) + { + if (pInstance->GetData64(DATA_NETHEKURSE)) + { + Creature *pKurse = Unit::GetCreature(*me,pInstance->GetData64(DATA_NETHEKURSE)); + if (pKurse) + ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonEnterCombat(); + } + + if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS) + return; + else pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); + } + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if (spell->Id == SPELL_SHADOW_SEAR) + { + if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS) + Kill_Timer = 20000; + } + } + + void JustDied(Unit* killer) + { + if (pInstance) + { + if (pInstance->GetData64(DATA_NETHEKURSE)) + { + Creature *pKurse = Unit::GetCreature(*me,pInstance->GetData64(DATA_NETHEKURSE)); + if (pKurse) + ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonDeath(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (Kill_Timer) + { + if (Kill_Timer <= diff) + { + me->DealDamage(me, me->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Kill_Timer = 0; + } else Kill_Timer -= diff; + } + + if (!UpdateVictim()) + return; + + if (Hemorrhage_Timer <= diff) + { + DoCast(me->getVictim(),SPELL_HEMORRHAGE); + Hemorrhage_Timer = 15000; + } else Hemorrhage_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_grand_warlock_nethekurse(Creature* creature) +{ + return new boss_grand_warlock_nethekurseAI (creature); +} + +CreatureAI* GetAI_mob_fel_orc_convert(Creature* creature) +{ + return new mob_fel_orc_convertAI (creature); +} + +void AddSC_boss_grand_warlock_nethekurse() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_grand_warlock_nethekurse"; + newscript->GetAI = &GetAI_boss_grand_warlock_nethekurse; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "mob_fel_orc_convert"; + newscript->GetAI = &GetAI_mob_fel_orc_convert; + newscript->RegisterSelf(); + +} + diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp old mode 100755 new mode 100644 similarity index 86% rename from src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp index f9887c499..c497a6497 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp @@ -1,4 +1,8 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +20,8 @@ /* ScriptData SDName: Boss_Warbringer_Omrogg -SD%Complete: 85 -SDComment: Heroic enabled. Spell timing may need additional tweaks +SD%Complete: 95 +SDComment:Spell timing may need additional tweaks SDCategory: Hellfire Citadel, Shattered Halls EndScriptData */ @@ -117,7 +121,7 @@ struct mob_omrogg_headsAI : public ScriptedAI if (Death_Timer < diff) { - DoScriptText(YELL_DIE_R, m_creature); + DoScriptText(YELL_DIE_R, me); DeathYell = false; } else @@ -130,7 +134,7 @@ struct boss_warbringer_omroggAI : public ScriptedAI boss_warbringer_omroggAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance* pInstance; @@ -174,15 +178,15 @@ struct boss_warbringer_omroggAI : public ScriptedAI ResetThreat_Timer = 30000; if (pInstance) - pInstance->SetData(TYPE_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid. + pInstance->SetData(TYPE_WARBRINGER, NOT_STARTED); } void DoYellForThreat() { if (LeftHead && RightHead) { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); + Unit *Left = Unit::GetUnit(*me,LeftHead); + Unit *Right = Unit::GetUnit(*me,RightHead); if (!Left || !Right) return; @@ -203,7 +207,7 @@ struct boss_warbringer_omroggAI : public ScriptedAI DoSpawnCreature(ENTRY_LEFT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); DoSpawnCreature(ENTRY_RIGHT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); - if (Unit *Left = Unit::GetUnit(*m_creature,LeftHead)) + if (Unit *Left = Unit::GetUnit(*me,LeftHead)) { iaggro = rand()%3; @@ -214,7 +218,7 @@ struct boss_warbringer_omroggAI : public ScriptedAI } if (pInstance) - pInstance->SetData(TYPE_OMROGG, IN_PROGRESS); + pInstance->SetData(TYPE_WARBRINGER, IN_PROGRESS); } void JustSummoned(Creature *summoned) @@ -234,8 +238,8 @@ struct boss_warbringer_omroggAI : public ScriptedAI { if (LeftHead && RightHead) { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); + Unit *Left = Unit::GetUnit(*me,LeftHead); + Unit *Right = Unit::GetUnit(*me,RightHead); if (!Left || !Right) return; @@ -263,8 +267,8 @@ struct boss_warbringer_omroggAI : public ScriptedAI { if (LeftHead && RightHead) { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); + Unit *Left = Unit::GetUnit(*me,LeftHead); + Unit *Right = Unit::GetUnit(*me,RightHead); if (!Left || !Right) return; @@ -275,7 +279,7 @@ struct boss_warbringer_omroggAI : public ScriptedAI } if (pInstance) - pInstance->SetData(TYPE_OMROGG, DONE); + pInstance->SetData(TYPE_WARBRINGER, DONE); } void UpdateAI(const uint32 diff) @@ -287,8 +291,8 @@ struct boss_warbringer_omroggAI : public ScriptedAI if (!LeftHead || !RightHead) return; - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); + Unit *Left = Unit::GetUnit(*me,LeftHead); + Unit *Right = Unit::GetUnit(*me,RightHead); if (!Left || !Right) return; @@ -330,7 +334,7 @@ struct boss_warbringer_omroggAI : public ScriptedAI if (BlastCount && BlastWave_Timer <= diff) { - DoCast(m_creature,SPELL_BLAST_WAVE); + DoCast(me,SPELL_BLAST_WAVE); BlastWave_Timer = 5000; ++BlastCount; @@ -340,8 +344,8 @@ struct boss_warbringer_omroggAI : public ScriptedAI if (BurningMaul_Timer < diff) { - DoScriptText(EMOTE_ENRAGE, m_creature); - DoCast(m_creature,HeroicMode ? H_SPELL_BURNING_MAUL : SPELL_BURNING_MAUL); + DoScriptText(EMOTE_ENRAGE, me); + DoCast(me,HeroicMode ? H_SPELL_BURNING_MAUL : SPELL_BURNING_MAUL); BurningMaul_Timer = 40000; BlastWave_Timer = 16000; BlastCount = 1; @@ -353,20 +357,20 @@ struct boss_warbringer_omroggAI : public ScriptedAI { DoYellForThreat(); DoResetThreat(); - m_creature->AddThreat(target, 0.0f); + me->AddThreat(target, 0.0f); } ResetThreat_Timer = 35000+rand()%10000; }else ResetThreat_Timer -= diff; if (Fear_Timer < diff) { - DoCast(m_creature,SPELL_FEAR); + DoCast(me,SPELL_FEAR); Fear_Timer = 15000+rand()%25000; }else Fear_Timer -= diff; if (ThunderClap_Timer < diff) { - DoCast(m_creature,SPELL_THUNDERCLAP); + DoCast(me,SPELL_THUNDERCLAP); ThunderClap_Timer = 25000+rand()%15000; }else ThunderClap_Timer -= diff; diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp old mode 100755 new mode 100644 similarity index 51% rename from src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp rename to src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp index f00f3b57b..0c4dcaac9 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/boss_warchief_kargath_bladefist.cpp @@ -1,5 +1,36 @@ -/* Copyright (C) 2008 - 2009 BroodWyrm */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shattered_Halls +SD%Complete: 95 +SDComment: +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +/* ContentData +boss_warchief_kargath_bladefist +EndContentData */ + #include "precompiled.h" +#include "def_shattered_halls.h" #define SPELL_BLADE_DANCE 30739 #define H_SPELL_CHARGE 25821 @@ -15,25 +46,19 @@ float AssassEntrance[3] = {275.136,-84.29,2.3}; // y +-8 float AssassExit[3] = {184.233,-84.29,2.3}; // y +-8 float AddsEntrance[3] = {306.036,-84.29,1.93}; -#define SOUND_AGGRO1 10323 -#define SAY_AGGRO1 "Ours is the true Horde! The only Horde!" -#define SOUND_AGGRO2 10324 -#define SAY_AGGRO2 "I'll carve the meat from your bones!" -#define SOUND_AGGRO3 10325 -#define SAY_AGGRO3 "I am called Bladefist for a reason, as you will see!" -#define SOUND_SLAY1 10326 -#define SAY_SLAY1 "For the real Horde!" -#define SOUND_SLAY2 10327 -#define SAY_SLAY2 "I am the only Warchief!" -#define SOUND_DEATH 10328 -#define SAY_DEATH "The true Horde... will.. prevail.." +#define SAY_AGGRO1 -1540042 +#define SAY_AGGRO2 -1540043 +#define SAY_AGGRO3 -1540044 +#define SAY_SLAY1 -1540045 +#define SAY_SLAY2 -1540046 +#define SAY_DEATH -1540047 struct boss_warchief_kargath_bladefistAI : public ScriptedAI { boss_warchief_kargath_bladefistAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance* pInstance; @@ -45,6 +70,7 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI uint32 Charge_timer; uint32 Blade_Dance_Timer; uint32 Summon_Assistant_Timer; + uint32 Assistant_Timer; uint32 resetcheck_timer; uint32 Wait_Timer; @@ -52,6 +78,7 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI uint32 summoned; bool InBlade; + bool Assistant; uint32 target_num; @@ -59,36 +86,39 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI { removeAdds(); - m_creature->SetSpeed(MOVE_RUN,2); - m_creature->SetWalk(false); + me->SetSpeed(MOVE_RUN,2); + me->SetWalk(false); - summoned = 2; + summoned = 1; InBlade = false; Wait_Timer = 0; + Assistant = false; Charge_timer = 0; Blade_Dance_Timer = 30000; - Summon_Assistant_Timer = 15000; + Summon_Assistant_Timer = (HeroicMode ? 20000 : 30000); + Assistant_Timer = 120000; Assassins_Timer = 5000; resetcheck_timer = 5000; + + if (pInstance) + pInstance->SetData(TYPE_KARGATH, NOT_STARTED); } void EnterCombat(Unit *who) { - switch (rand()%3) + DoScriptText(RAND(SAY_AGGRO1,SAY_AGGRO2,SAY_AGGRO3), me); + + if (pInstance) { - case 0: - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - break; - case 2: - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - break; + pInstance->SetData(TYPE_KARGATH, IN_PROGRESS); + + if (pInstance->GetData(TYPE_WARBRINGER) != DONE) + { + Creature *War = Unit::GetCreature(*me, pInstance->GetData64(DATA_WARBRINGER)); + if (War && War->isAlive()) + War->AI()->AttackStart(who); + } } } @@ -110,27 +140,19 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI void KilledUnit(Unit *victim) { - if(victim->GetTypeId() == TYPEID_PLAYER) + if (victim->GetTypeId() == TYPEID_PLAYER) { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - break; - } + DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), me); } } void JustDied(Unit* Killer) { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoScriptText(SAY_DEATH, me); removeAdds(); + + if (pInstance) + pInstance->SetData(TYPE_KARGATH, DONE); } void MovementInform(uint32 type, uint32 id) @@ -146,7 +168,7 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI if(target_num > 0) // to prevent loops { Wait_Timer = 1; - DoCast(m_creature,SPELL_BLADE_DANCE,true); + DoCast(me,SPELL_BLADE_DANCE, true); target_num--; } } @@ -154,25 +176,25 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI void removeAdds() { - for(std::vector::iterator itr = adds.begin(); itr!= adds.end(); ++itr) + for (std::vector::iterator itr = adds.begin(); itr!= adds.end(); ++itr) { - Unit* temp = Unit::GetUnit((*m_creature),*itr); + Unit* temp = Unit::GetUnit((*me), *itr); if(temp && temp->isAlive()) { (*temp).GetMotionMaster()->Clear(true); - m_creature->DealDamage(temp,temp->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->DealDamage(temp,temp->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); ((Creature*)temp)->RemoveCorpse(); } } adds.clear(); - for(std::vector::iterator itr = assassins.begin(); itr!= assassins.end(); ++itr) + for (std::vector::iterator itr = assassins.begin(); itr!= assassins.end(); ++itr) { - Unit* temp = Unit::GetUnit((*m_creature),*itr); + Unit* temp = Unit::GetUnit((*me), *itr); if(temp && temp->isAlive()) { (*temp).GetMotionMaster()->Clear(true); - m_creature->DealDamage(temp,temp->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + me->DealDamage(temp,temp->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); ((Creature*)temp)->RemoveCorpse(); } } @@ -180,20 +202,20 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI } void SpawnAssassin() { - m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassEntrance[0],AssassEntrance[1]+8, AssassEntrance[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); - m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassEntrance[0],AssassEntrance[1]-8, AssassEntrance[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); - m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]+8, AssassExit[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); - m_creature->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]-8, AssassExit[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + me->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassEntrance[0],AssassEntrance[1]+8, AssassEntrance[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + me->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassEntrance[0],AssassEntrance[1]-8, AssassEntrance[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + me->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]+8, AssassExit[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + me->SummonCreature(MOB_SHATTERED_ASSASSIN,AssassExit[0],AssassExit[1]-8, AssassExit[2], 0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); } void UpdateAI(const uint32 diff) { - if (!UpdateVictim() ) + if (!UpdateVictim()) return; - if(Assassins_Timer) + if (Assassins_Timer) { - if(Assassins_Timer < diff) + if (Assassins_Timer < diff) { SpawnAssassin(); Assassins_Timer = 0; @@ -202,20 +224,31 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI Assassins_Timer -= diff; } - if(InBlade) + if (Assistant_Timer) + { + if (Assistant_Timer < diff) + { + Assistant = true; + Assistant_Timer = 0; + } + else + Assistant_Timer -= diff; + } + + if (InBlade) { - if(Wait_Timer) - if(Wait_Timer < diff) + if (Wait_Timer) + if (Wait_Timer < diff) { - if(target_num <= 0) + if (target_num <= 0) { // stop bladedance InBlade = false; - m_creature->SetSpeed(MOVE_RUN,2); - (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); + me->SetSpeed(MOVE_RUN,2); + (*me).GetMotionMaster()->MoveChase(me->getVictim()); Blade_Dance_Timer = 30000; Wait_Timer = 0; - if(HeroicMode) + if (HeroicMode) Charge_timer = 5000; } else @@ -226,7 +259,7 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI randy = (rand()%40); x = 210+ randx ; y = -60- randy ; - (*m_creature).GetMotionMaster()->MovePoint(1,x,y,m_creature->GetPositionZ()); + (*me).GetMotionMaster()->MovePoint(1,x,y,me->GetPositionZ()); Wait_Timer = 0; } } @@ -235,24 +268,24 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI } else { - if(Blade_Dance_Timer) + if (Blade_Dance_Timer) { - if(Blade_Dance_Timer < diff) + if (Blade_Dance_Timer < diff) { target_num = TARGET_NUM; Wait_Timer = 1; InBlade = true; Blade_Dance_Timer = 0; - m_creature->SetSpeed(MOVE_RUN,4); + me->SetSpeed(MOVE_RUN,4); return; } else Blade_Dance_Timer -= diff; } - if(Charge_timer) + if (Charge_timer) { - if(Charge_timer < diff) + if (Charge_timer < diff) { DoCast(SelectUnit(SELECT_TARGET_RANDOM,0), H_SPELL_CHARGE); Charge_timer = 0; @@ -266,11 +299,16 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI Unit* target = NULL; Creature* Summoned; - for(int i = 0; i < summoned; i++) - Summoned = m_creature->SummonCreature(RAND(MOB_HEARTHEN_GUARD, MOB_SHARPSHOOTER_GUARD, MOB_REAVER_GUARD), AddsEntrance[0], AddsEntrance[1], AddsEntrance[2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + for (int i = 0; i < summoned; i++) + Summoned = me->SummonCreature(RAND(MOB_HEARTHEN_GUARD, MOB_SHARPSHOOTER_GUARD, MOB_REAVER_GUARD), AddsEntrance[0], AddsEntrance[1], AddsEntrance[2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + + if (Assistant) + { + if (rand()%100 < 2) + summoned++; + } - if(rand()%100 < 20) summoned++; - Summon_Assistant_Timer = 15000 + (rand()%5000) ; + Summon_Assistant_Timer = (HeroicMode ? 15000 : 20000); } else Summon_Assistant_Timer -= diff; @@ -278,11 +316,11 @@ struct boss_warchief_kargath_bladefistAI : public ScriptedAI DoMeleeAttackIfReady(); } - if(resetcheck_timer < diff) + if (resetcheck_timer < diff) { uint32 tempx,tempy; - tempx = m_creature->GetPositionX(); - tempy = m_creature->GetPositionY(); + tempx = me->GetPositionX(); + tempy = me->GetPositionY(); if ( tempx > 255 || tempx < 205) { diff --git a/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/def_shattered_halls.h b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/def_shattered_halls.h new file mode 100644 index 000000000..110d6e509 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/def_shattered_halls.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_SHATTERED_H +#define SC_DEF_SHATTERED_H + +#define TYPE_NETHEKURSE 1 +#define DATA_NETHEKURSE 2 +#define TYPE_PORUNG 3 +#define TYPE_WARBRINGER 4 +#define DATA_WARBRINGER 5 +#define TYPE_KARGATH 6 + +#define TYPE_EXECUTION 7 +#define TYPE_EXECUTION_DONE 8 +#endif + diff --git a/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp new file mode 100644 index 000000000..5d459f340 --- /dev/null +++ b/src/scripts/scripts/Outland/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp @@ -0,0 +1,503 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2013 TrinityCore + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shattered_Halls +SD%Complete: 99 +SDComment: +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +#define ENCOUNTERS 6 + +#define DOOR_NETHEKURSE1 182539 +#define DOOR_NETHEKURSE2 182540 +#define NPC_FEL_ORC 17083 +#define NPC_NETHEKURSE 16807 +#define NPC_WARBRINGER 16809 +#define NPC_KARGATH 16808 +#define SPELL_SHADOW_SEAR 30735 + +enum +{ + NPC_EXECUTIONER = 17301, + NPC_SOLDIER_ALLIANCE_1 = 17288, + NPC_SOLDIER_ALLIANCE_2 = 17289, + NPC_SOLDIER_ALLIANCE_3 = 17292, + NPC_OFFICER_ALLIANCE = 17290, + + NPC_SOLDIER_HORDE_1 = 17294, + NPC_SOLDIER_HORDE_2 = 17295, + NPC_SOLDIER_HORDE_3 = 17297, + NPC_OFFICER_HORDE = 17296, + + SPELL_KARGATH_EXECUTIONER_1 = 39288, + SPELL_KARGATH_EXECUTIONER_2 = 39289, + SPELL_KARGATH_EXECUTIONER_3 = 39290, + + //SAY_KARGATH_EXECUTE_ALLY = ?, + //SAY_KARGATH_EXECUTE_HORDE = ? +}; + +struct SpawnLocation +{ + uint32 AllianceEntry, HordeEntry; + float fX, fY, fZ, fO; +}; + +const float afExecutionerLoc[4] = {151.443f, -84.439f, 1.938f, 6.283f}; + +static SpawnLocation aSoldiersLocs[]= +{ + {0, NPC_SOLDIER_HORDE_1, 119.609f, 256.127f, -45.254f, 5.133f}, + {NPC_SOLDIER_ALLIANCE_1, 0, 131.106f, 254.520f, -45.236f, 3.951f}, + {NPC_SOLDIER_ALLIANCE_3, NPC_SOLDIER_HORDE_3, 151.040f, -91.558f, 1.936f, 1.559f}, + {NPC_SOLDIER_ALLIANCE_2, NPC_SOLDIER_HORDE_2, 150.669f, -77.015f, 1.933f, 4.705f}, + {NPC_OFFICER_ALLIANCE, NPC_OFFICER_HORDE, 138.241f, -84.198f, 1.907f, 0.055f} +}; + +enum Summon +{ + NOT_SUMMONED = 0, + WAIT_FOR_SUMMON = 1, + SUMMONED = 2 +}; + +struct instance_shattered_halls : public ScriptedInstance +{ + instance_shattered_halls(Map *map) : ScriptedInstance(map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + std::list OrcGUID; + uint64 nethekurseGUID; + uint64 warbringerGUID; + uint64 nethekurseDoor1GUID; + uint64 nethekurseDoor2GUID; + uint64 kargathGUID; + uint64 executionerGUID; + uint64 officeraGUID; + uint64 officerhGUID; + uint64 soldiera2GUID; + uint64 soldiera3GUID; + uint64 soldierh2GUID; + uint64 soldierh3GUID; + + uint32 ExecutionTimer; + uint32 Team; + uint8 ExecutionStage; + + Summon summon; + + void Initialize() + { + nethekurseGUID = 0; + warbringerGUID = 0; + nethekurseDoor1GUID = 0; + nethekurseDoor2GUID = 0; + kargathGUID = 0; + executionerGUID = 0; + officeraGUID = 0; + officerhGUID = 0; + soldiera2GUID = 0; + soldiera3GUID = 0; + soldierh2GUID = 0; + soldierh3GUID = 0; + + Team = 0; + ExecutionStage =0; + ExecutionTimer = 55*MINUTE*IN_MILISECONDS; + + summon = NOT_SUMMONED; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + } + + void OnPlayerEnter(Player* player) + { + if (!instance->IsHeroic()) + return; + + if (summon == NOT_SUMMONED) + summon = WAIT_FOR_SUMMON; + } + + bool IsEncounterInProgress() const + { + for (uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounter[i] == IN_PROGRESS) + return true; + return false; + } + + Player* GetPlayerInMap() + { + Map::PlayerList const& players = instance->GetPlayers(); + + if (!players.isEmpty()) + { + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if (Player* plr = itr->getSource()) + return plr; + } + } + + debug_log("TSCR: Instance Shattered Halls: GetPlayerInMap, but PlayerList is empty!"); + return NULL; + } + + void OnObjectCreate(GameObject *go) + { + switch (go->GetEntry()) + { + case DOOR_NETHEKURSE1: + nethekurseDoor1GUID = go->GetGUID(); + if(GetData(TYPE_NETHEKURSE) == DONE) + HandleGameObject(nethekurseDoor1GUID, 0); + break; + case DOOR_NETHEKURSE2: + nethekurseDoor2GUID = go->GetGUID(); + if(GetData(TYPE_NETHEKURSE) == DONE) + HandleGameObject(nethekurseDoor2GUID, 0); + break; + } + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch (creature_entry) + { + case NPC_NETHEKURSE: nethekurseGUID = creature->GetGUID(); break; + case NPC_WARBRINGER: warbringerGUID = creature->GetGUID(); break; + case NPC_KARGATH: kargathGUID = creature->GetGUID(); break; + case NPC_EXECUTIONER: executionerGUID = creature->GetGUID(); break; + case NPC_SOLDIER_ALLIANCE_2: soldiera2GUID = creature->GetGUID(); break; + case NPC_SOLDIER_ALLIANCE_3: soldiera3GUID = creature->GetGUID(); break; + case NPC_OFFICER_ALLIANCE: officeraGUID = creature->GetGUID(); break; + case NPC_SOLDIER_HORDE_2: soldierh2GUID = creature->GetGUID(); break; + case NPC_SOLDIER_HORDE_3: soldierh3GUID = creature->GetGUID(); break; + case NPC_OFFICER_HORDE: officerhGUID = creature->GetGUID(); break; + case NPC_FEL_ORC: OrcGUID.push_back(creature->GetGUID()); break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch( type ) + { + case TYPE_NETHEKURSE: + if (data == FAIL) + { + for (std::list::iterator itr = OrcGUID.begin(); itr != OrcGUID.end(); ++itr) + { + if (Creature* Orc = instance->GetCreature(*itr)) + { + if (!Orc->isAlive()) + { + Orc->ForcedDespawn(); + Orc->Respawn(); + } + } + } + } + if (data == SPECIAL) + { + for (std::list::iterator itr = OrcGUID.begin(); itr != OrcGUID.end(); ++itr) + { + if (Creature* Orc = instance->GetCreature(*itr)) + { + if (Orc->isAlive()) + { + if (Creature* neth = instance->GetCreature(nethekurseGUID)) + neth->CastSpell(Orc, SPELL_SHADOW_SEAR, true); + + } + } + } + } + if (data == DONE) + { + HandleGameObject(nethekurseDoor1GUID, 0); + HandleGameObject(nethekurseDoor2GUID, 0); + } + + if (Encounter[0] != DONE) + Encounter[0] = data; + break; + case TYPE_WARBRINGER: + if (Encounter[1] != DONE) + Encounter[1] = data; + break; + case TYPE_PORUNG: + if (Encounter[2] != DONE) + Encounter[2] = data; + break; + case TYPE_KARGATH: + if (data == DONE) + { + if (Creature* Executioner = instance->GetCreature(executionerGUID)) + Executioner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + } + else + Encounter[3] = data; + break; + case TYPE_EXECUTION: + if (data == DONE && !instance->GetCreature(executionerGUID)) + { + if (Player* player = GetPlayerInMap()) + { + for (uint8 i = 2; i < 5; ++i) + player->SummonCreature(Team == ALLIANCE ? aSoldiersLocs[i].AllianceEntry : aSoldiersLocs[i].HordeEntry, aSoldiersLocs[i].fX, aSoldiersLocs[i].fY, aSoldiersLocs[i].fZ, aSoldiersLocs[i].fO, TEMPSUMMON_DEAD_DESPAWN, 0); + + if (Creature* Executioner = player->SummonCreature(NPC_EXECUTIONER, afExecutionerLoc[0], afExecutionerLoc[1], afExecutionerLoc[2], afExecutionerLoc[3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 80*MINUTE*IN_MILISECONDS)) + Executioner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + + DoCastGroupDebuff(SPELL_KARGATH_EXECUTIONER_1); + ExecutionTimer = 55*MINUTE*IN_MILISECONDS; + } + } + else + Encounter[4] = data; + break; + case TYPE_EXECUTION_DONE: + if (data == DONE) + { + if (Creature* Officer = instance->GetCreature(Team == ALLIANCE ? officeraGUID : officerhGUID)) + Officer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER); + } + else + Encounter[5] = data; + break; + } + + if (data == DONE) + { + SaveToDB(); + OUT_SAVE_INST_DATA_COMPLETE; + } + } + + uint32 GetData(uint32 type) + { + switch (type) + { + case TYPE_NETHEKURSE: + return Encounter[0]; + case TYPE_WARBRINGER: + return Encounter[1]; + case TYPE_PORUNG: + return Encounter[2]; + case TYPE_KARGATH: + return Encounter[3]; + case TYPE_EXECUTION: + return Encounter[4]; + case TYPE_EXECUTION_DONE: + return Encounter[5]; + } + return 0; + } + + uint64 GetData64(uint32 data) + { + switch (data) + { + case DATA_NETHEKURSE: + return nethekurseGUID; + case DATA_WARBRINGER: + return warbringerGUID; + } + return 0; + } + + void OnCreatureDeath(Creature* pCreature) + { + if (pCreature->GetEntry() == NPC_EXECUTIONER) + SetData(TYPE_EXECUTION_DONE, DONE); + } + + void DoCastGroupDebuff(uint32 SpellId) + { + Map::PlayerList const& lPlayers = instance->GetPlayers(); + + if (lPlayers.isEmpty()) + return; + + for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr) + { + Player* player = itr->getSource(); + if (player && !player->HasAura(SpellId, 0)) + player->CastSpell(player, SpellId, true); + } + } + + void HandleGameObject(uint64 guid, uint32 state) + { + Player *player = GetPlayerInMap(); + + if (!player || !guid) + return; + + if (GameObject *go = GameObject::GetGameObject(*player,guid)) + go->SetGoState(GOState(state)); + } + + void Update(uint32 diff) + { + if (ExecutionTimer) + { + if (ExecutionTimer <= diff) + { + switch(ExecutionStage) + { + case 0: + if (Creature* Soldier = instance->GetCreature(Team == ALLIANCE ? officeraGUID : officerhGUID)) + Soldier->DealDamage(Soldier, Soldier->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + //DoScriptText(Team == ALLIANCE ? SAY_KARGATH_EXECUTE_ALLY : SAY_KARGATH_EXECUTE_HORDE, instance->GetCreature(kargathGUID)); + + DoCastGroupDebuff(SPELL_KARGATH_EXECUTIONER_2); + ExecutionTimer = 10*MINUTE*IN_MILISECONDS; + break; + case 1: + if (Creature* Soldier = instance->GetCreature(Team == ALLIANCE ? soldiera2GUID : soldierh2GUID)) + Soldier->DealDamage(Soldier, Soldier->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + DoCastGroupDebuff(SPELL_KARGATH_EXECUTIONER_3); + ExecutionTimer = 15*MINUTE*IN_MILISECONDS; + break; + case 2: + if (Creature* Soldier = instance->GetCreature(Team == ALLIANCE ? soldiera3GUID : soldierh3GUID)) + Soldier->DealDamage(Soldier, Soldier->GetHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + SetData(TYPE_EXECUTION_DONE, FAIL); + ExecutionTimer = 0; + break; + } + ++ExecutionStage; + } + else ExecutionTimer -= diff; + } + + if (summon == WAIT_FOR_SUMMON) + { + if (instance->GetPlayers().isEmpty() || Team) + return; + + Player* player = instance->GetPlayers().begin()->getSource(); + Team = player->GetTeam(); + + if (Team == ALLIANCE) + player->SummonCreature(aSoldiersLocs[1].AllianceEntry, aSoldiersLocs[1].fX, aSoldiersLocs[1].fY, aSoldiersLocs[1].fZ, aSoldiersLocs[1].fO, TEMPSUMMON_DEAD_DESPAWN, 0); + else + player->SummonCreature(aSoldiersLocs[0].HordeEntry, aSoldiersLocs[0].fX, aSoldiersLocs[0].fY, aSoldiersLocs[0].fZ, aSoldiersLocs[0].fO, TEMPSUMMON_DEAD_DESPAWN, 0); + + summon = SUMMONED; + } + } + + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + + std::ostringstream stream; + stream << Encounter[0] << " "; + stream << Encounter[1] << " "; + stream << Encounter[2] << " "; + stream << Encounter[3] << " "; + stream << Encounter[4] << " "; + stream << Encounter[5] ; + + OUT_SAVE_INST_DATA_COMPLETE; + + return stream.str(); + } + + void Load(const char* in) + { + if(!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + + std::istringstream stream(in); + stream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3] >> Encounter[4] >> Encounter[5]; + + for (uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounter[i] == IN_PROGRESS) + Encounter[i] = NOT_STARTED; + + if (Encounter[0] == DONE) + { + HandleGameObject(nethekurseDoor1GUID, 0); + HandleGameObject(nethekurseDoor2GUID, 0); + } + + OUT_LOAD_INST_DATA_COMPLETE; + } +}; + +InstanceData* GetInstanceData_instance_shattered_halls(Map* map) +{ + return new instance_shattered_halls(map); +} + +bool AreaTrigger_at_shattered_halls(Player* player, AreaTriggerEntry const* /*pAt*/) +{ + if (player->isGameMaster() || player->isDead()) + return false; + + instance_shattered_halls* pInstance = (instance_shattered_halls*)player->GetInstanceData(); + + if (!pInstance) + return false; + + if (!pInstance->instance->IsHeroic()) + return false; + + if (pInstance->GetData(TYPE_KARGATH) == DONE || pInstance->GetData(TYPE_WARBRINGER) == DONE) + return false; + + if (pInstance->GetData(TYPE_EXECUTION) == NOT_STARTED) + pInstance->SetData(TYPE_EXECUTION, DONE); + + return true; +} + +void AddSC_instance_shattered_halls() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_shattered_halls"; + newscript->GetInstanceData = &GetInstanceData_instance_shattered_halls; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "at_shattered_halls"; + newscript->pAreaTrigger = &AreaTrigger_at_shattered_halls; + newscript->RegisterSelf(); +} + diff --git a/src/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp b/src/scripts/scripts/Outland/hellfire_peninsula/boss_doomlord_kazzak.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp rename to src/scripts/scripts/Outland/hellfire_peninsula/boss_doomlord_kazzak.cpp index d7d5e4a54..1713b7a79 --- a/src/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp +++ b/src/scripts/scripts/Outland/hellfire_peninsula/boss_doomlord_kazzak.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp b/src/scripts/scripts/Outland/hellfire_peninsula/hellfire_peninsula.cpp old mode 100755 new mode 100644 similarity index 80% rename from src/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp rename to src/scripts/scripts/Outland/hellfire_peninsula/hellfire_peninsula.cpp index 6fb684b6a..6abcb736d --- a/src/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp +++ b/src/scripts/scripts/Outland/hellfire_peninsula/hellfire_peninsula.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -402,7 +405,7 @@ struct npc_demoniac_scryerAI : public ScriptedAI std::list PlayersWithQuestList; void Reset() - { + { IfIsComplete = false; SpawnDemonTimer = 15000; SpawnOrcTimer = 30000; @@ -425,7 +428,7 @@ struct npc_demoniac_scryerAI : public ScriptedAI if(player->GetQuestStatus(QUEST_DEMONIAC) == QUEST_STATUS_INCOMPLETE) PlayersWithQuestList.push_back(player->GetGUID()); } - } + } void AttackedBy(Unit* pEnemy) {} void AttackStart(Unit* pEnemy) {} @@ -445,7 +448,7 @@ struct npc_demoniac_scryerAI : public ScriptedAI } float fX, fY, fZ; - me->GetNearPoint(me, fX, fY, fZ, 0.0f, 5.0f, fAngle); + me->GetNearPoint(fX, fY, fZ, 0.0f, 5.0f, fAngle); uint32 m_Time = TIME_TOTAL - (SpawnButtressTimer * ButtressCount); me->SummonCreature(NPC_BUTTRESS, fX, fY, fZ, me->GetAngle(fX, fY), TEMPSUMMON_TIMED_DESPAWN, m_Time); @@ -914,7 +917,7 @@ struct npc_felblood_initiateAI : public ScriptedAI void EnterCombat(Unit* who) { - if(me->IsNonMeleeSpellCasted(false)) + if(me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); } @@ -933,7 +936,7 @@ struct npc_felblood_initiateAI : public ScriptedAI { if(OOCTimer < diff) { - if(!me->IsNonMeleeSpellCasted(false)) + if(!me->IsNonMeleeSpellCast(false)) HandleOffCombatEffects(); if(roll_chance_i(3)) me->Yell(YellSiphon[urand(0,3)], 0, 0); @@ -1005,15 +1008,42 @@ CreatureAI* GetAI_npc_felblood_initiate(Creature *creature) #define GOSSIP_ICE_STONE "Place your hands on stone" -#define NPC_GLACIAL_TEMPLAR 26216 +enum +{ + NPC_FROSTWAVE_LIEUTENANT = 26116, + NPC_HAILSTONE_LIEUTENANT = 26178, + NPC_CHILLWIND_LIEUTENANT = 26204, + NPC_FRIGID_LIEUTENANT = 26214, + NPC_GLACIAL_LIEUTENANT = 26215, + NPC_GLACIAL_TEMPLAR = 26216, +}; + +uint32 GetIceStoneQuestID(uint32 zone) +{ + switch (zone) + { + case 33: return 11948; // Stranglethorn Vale + case 51: return 11952; // Searing Gorge + case 331: return 11917; // Ashenvale + case 405: return 11947; // Desolace + case 1377: return 11953; // Silithus + case 3483: return 11954; // Hellfire Peninsula + default: return 0; + } +} -bool GossipHello_go_ice_stone(Player *player, GameObject* go) +bool GossipHello_go_ice_stone(Player *player, GameObject *go) { - if( player->GetQuestStatus(11954) == QUEST_STATUS_INCOMPLETE ) + if (uint32 quest = GetIceStoneQuestID(player->GetZoneId())) { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ICE_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->PlayerTalkClass->ClearMenus(); + + if (player->GetQuestStatus(quest) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ICE_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(go->GetGOInfo()->questgiver.gossipID, go->GetGUID()); } - player->SEND_GOSSIP_MENU(go->GetGOInfo()->questgiver.gossipID, go->GetGUID()); + return true; } @@ -1023,23 +1053,35 @@ void SendActionMenu_go_ice_stone(Player *player, GameObject* go, uint32 action) go->SetRespawnTime(300); player->CLOSE_GOSSIP_MENU(); - float x,y,z; - player->GetClosePoint(x,y,z, 0.0f, 2.0f, frand(0, M_PI)); - - switch(action) + if (action == GOSSIP_ACTION_INFO_DEF) { - case GOSSIP_ACTION_INFO_DEF: - player->SummonCreature(NPC_GLACIAL_TEMPLAR, x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); - break; + uint32 npcId; + + switch (player->GetZoneId()) + { + case 33: npcId = NPC_CHILLWIND_LIEUTENANT; break; // Stranglethorn Vale + case 51: npcId = NPC_FRIGID_LIEUTENANT; break; // Searing Gorge + case 331: npcId = NPC_FROSTWAVE_LIEUTENANT; break; // Ashenvale + case 405: npcId = NPC_HAILSTONE_LIEUTENANT; break; // Desolace + case 1377: npcId = NPC_GLACIAL_LIEUTENANT; break; // Silithus + case 3483: npcId = NPC_GLACIAL_TEMPLAR; break; // Hellfire Peninsula + default: return; + } + + if (GetClosestCreatureWithEntry(player, npcId, 20.0f)) + return; + + float x,y,z; + player->GetNearPoint(x,y,z, 0.0f, 2.0f, frand(0, M_PI)); + player->SummonCreature(npcId, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); } } -bool GossipSelect_go_ice_stone(Player *player, GameObject* go, uint32 sender, uint32 action ) +bool GossipSelect_go_ice_stone(Player *player, GameObject *go, uint32 sender, uint32 action) { - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_go_ice_stone(player, go, action); break; - } + if (sender == GOSSIP_SENDER_MAIN) + SendActionMenu_go_ice_stone(player, go, action); + return true; } @@ -1251,12 +1293,14 @@ struct npc_anchorite_baradaAI : public ScriptedAI uint32 StepsTimer; uint32 Steps; + uint64 PlayerGUID; void Reset() { Exorcim = false; StepsTimer = 0; Steps = 0; + PlayerGUID = 0; } void AttackedBy(Unit* who) {} @@ -1269,95 +1313,103 @@ struct npc_anchorite_baradaAI : public ScriptedAI uint32 NextStep(uint32 Steps) { - Creature* Colonel = GetClosestCreatureWithEntry(me, NPC_COLONEL_JULES, 15); - - switch(Steps) + if (Creature* Colonel = GetClosestCreatureWithEntry(me, NPC_COLONEL_JULES, 15)) { - case 1:me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - me->SetStandState(UNIT_STAND_STATE_STAND);return 2000; - case 2:DoScriptText(SAY_BARADA1, me,0);return 5000; - case 3:DoScriptText(SAY_BARADA2, me,0);return 3000; - case 4:DoScriptText(SAY_COLONEL1, Colonel, 0);return 3000; - case 5:me->SetWalk(true);;return 3000; - case 6:me->GetMotionMaster()->MovePoint(0, P[7].x, P[7].y, P[7].z);return 2000; - case 7:me->GetMotionMaster()->MovePoint(0, P[8].x, P[8].y, P[8].z);return 2100; - case 8:me->SetFacingToObject(Colonel);return 2000; - case 9:me->CastSpell(me, SPELL_EXORCIM , false);return 10000; - case 10:DoScriptText(SAY_BARADA3, me,0); return 10000; - case 11:DoScriptText(SAY_COLONEL2, Colonel, 0);return 8000; - case 12:me->RemoveAllAuras(); - case 13:me->CastSpell(me, SPELL_EXORCIM2 , false); - case 14:Colonel->CastSpell(Colonel, SPELL_COLONEL1, false); - case 15:Colonel->SetSpeed(MOVE_FLIGHT, 0.15f); - Colonel->SetLevitate(true); - Colonel->GetMotionMaster()->MovePoint(0, P[1].x, P[1].y, P[1].z); - Colonel->CastSpell(Colonel, SPELL_COLONEL3, false);return 14000; - case 16:DoScriptText(SAY_COLONEL3, Colonel, 0); - DoSpawnDarkness(); - DoSpawnDarkness();return 14000; - case 17:DoScriptText(SAY_BARADA4, me, 0); - DoSpawnDarkness(); - DoSpawnDarkness();return 14000; - case 18:DoScriptText(SAY_COLONEL4, Colonel, 0); - DoSpawnDarkness();return 14000; - case 19:DoScriptText(SAY_BARADA5, me, 0); return 14000; - case 20:Colonel->CastSpell(Colonel, SPELL_COLONEL4, false); - Colonel->CastSpell(Colonel, SPELL_COLONEL2, false); - DoSpawnDarkness();return 1500; - case 21:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 7000; - case 22:DoScriptText(SAY_COLONEL5, Colonel, 0);return 1000; - case 23:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z); - DoSpawnDarkness();return 5000; - case 24:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z); - Colonel->CastSpell(me,SPELL_COLONEL5, false);return 3500; - case 25:DoScriptText(SAY_BARADA6, me, 0); - case 26:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); - DoSpawnDarkness();return 2000; - case 27:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[4].z);return 4000; - case 28:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z); - DoScriptText(SAY_COLONEL6, Colonel, 0); - DoSpawnDarkness();return 4000; - case 29:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z);return 4000; - case 30:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 4000; - case 31: DoScriptText(SAY_BARADA7, me, 0); return 0; - case 32:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z); - DoSpawnDarkness();return 4000; - case 33:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 4000; - case 34:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); - DoScriptText(SAY_COLONEL7, Colonel, 0); - DoSpawnDarkness();return 4000; - case 35:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 4000; - case 36:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); - DoSpawnDarkness();return 4000; - case 37:DoScriptText(SAY_BARADA6, me, 0); - case 38:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 2500; - case 39:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z);return 4000; - case 40:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); - DoScriptText(SAY_COLONEL8, Colonel, 0);return 4000; - case 41:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z);return 4000; - case 42:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 4000; - case 43:DoScriptText(SAY_BARADA6, me, 0); return 1000; - case 44:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z);return 4000; - case 45:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); - Colonel->CastSpell(Colonel, SPELL_COLONEL8, false);return 4000; - case 46:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); - Colonel->CastSpell(Colonel, SPELL_COLONEL7, false);return 4000; - case 47:Colonel->GetMotionMaster()->MovePoint(0, P[6].x, P[6].y, P[6].z);return 5000; - case 48:DoScriptText(SAY_BARADA8, me, 0); return 1000; - case 49:Colonel->GetMotionMaster()->MovePoint(0, P[0].x, P[0].y, P[0].z);return 3000; - case 50:Colonel->RemoveAllAuras(); - case 51:me->RemoveAllAuras();return 2000; - case 52:me->SetWalk(true);return 2000; - case 53:me->GetMotionMaster()->MovePoint(0, P[9].x, P[9].y, P[9].z);return 2200; - case 54:me->GetMotionMaster()->MovePoint(0, P[10].x, P[10].y, P[10].z);return 7000; - case 55:me->SetStandState(UNIT_STAND_STATE_KNEEL); - me->CombatStop();return 3000; - case 56:Colonel->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);return 20000; - case 57:me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - Colonel->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - case 58:Reset(); - default: return 0; + switch(Steps) + { + case 1:me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + me->SetStandState(UNIT_STAND_STATE_STAND);return 2000; + case 2:DoScriptText(SAY_BARADA1, me,0);return 5000; + case 3:DoScriptText(SAY_BARADA2, me,0);return 3000; + case 4:DoScriptText(SAY_COLONEL1, Colonel, 0);return 3000; + case 5:me->SetWalk(true);;return 3000; + case 6:me->GetMotionMaster()->MovePoint(0, P[7].x, P[7].y, P[7].z);return 2000; + case 7:me->GetMotionMaster()->MovePoint(0, P[8].x, P[8].y, P[8].z);return 2100; + case 8:me->SetFacingToObject(Colonel);return 2000; + case 9:me->CastSpell(me, SPELL_EXORCIM , false);return 10000; + case 10:DoScriptText(SAY_BARADA3, me,0); return 10000; + case 11:DoScriptText(SAY_COLONEL2, Colonel, 0);return 8000; + case 12:me->RemoveAllAuras(); + case 13:me->CastSpell(me, SPELL_EXORCIM2 , false); + case 14:Colonel->CastSpell(Colonel, SPELL_COLONEL1, false); + case 15:Colonel->SetSpeed(MOVE_FLIGHT, 0.15f); + Colonel->SetLevitate(true); + Colonel->GetMotionMaster()->MovePoint(0, P[1].x, P[1].y, P[1].z); + Colonel->CastSpell(Colonel, SPELL_COLONEL3, false);return 14000; + case 16:DoScriptText(SAY_COLONEL3, Colonel, 0); + DoSpawnDarkness(); + DoSpawnDarkness();return 14000; + case 17:DoScriptText(SAY_BARADA4, me, 0); + DoSpawnDarkness(); + DoSpawnDarkness();return 14000; + case 18:DoScriptText(SAY_COLONEL4, Colonel, 0); + DoSpawnDarkness();return 14000; + case 19:DoScriptText(SAY_BARADA5, me, 0); return 14000; + case 20:Colonel->CastSpell(Colonel, SPELL_COLONEL4, false); + Colonel->CastSpell(Colonel, SPELL_COLONEL2, false); + DoSpawnDarkness();return 1500; + case 21:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 7000; + case 22:DoScriptText(SAY_COLONEL5, Colonel, 0);return 1000; + case 23:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z); + DoSpawnDarkness();return 5000; + case 24:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z); + Colonel->CastSpell(me,SPELL_COLONEL5, false);return 3500; + case 25:DoScriptText(SAY_BARADA6, me, 0); + case 26:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); + DoSpawnDarkness();return 2000; + case 27:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[4].z);return 4000; + case 28:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z); + DoScriptText(SAY_COLONEL6, Colonel, 0); + DoSpawnDarkness();return 4000; + case 29:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z);return 4000; + case 30:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 4000; + case 31: DoScriptText(SAY_BARADA7, me, 0); return 0; + case 32:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z); + DoSpawnDarkness();return 4000; + case 33:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 4000; + case 34:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); + DoScriptText(SAY_COLONEL7, Colonel, 0); + DoSpawnDarkness();return 4000; + case 35:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z);return 4000; + case 36:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); + DoSpawnDarkness();return 4000; + case 37:DoScriptText(SAY_BARADA6, me, 0); + case 38:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 2500; + case 39:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z);return 4000; + case 40:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); + DoScriptText(SAY_COLONEL8, Colonel, 0);return 4000; + case 41:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z);return 4000; + case 42:Colonel->GetMotionMaster()->MovePoint(0, P[2].x, P[2].y, P[2].z);return 4000; + case 43:DoScriptText(SAY_BARADA6, me, 0); return 1000; + case 44:Colonel->GetMotionMaster()->MovePoint(0, P[3].x, P[3].y, P[3].z);return 4000; + case 45:Colonel->GetMotionMaster()->MovePoint(0, P[4].x, P[4].y, P[4].z); + Colonel->CastSpell(Colonel, SPELL_COLONEL8, false);return 4000; + case 46:Colonel->GetMotionMaster()->MovePoint(0, P[5].x, P[5].y, P[5].z); + Colonel->CastSpell(Colonel, SPELL_COLONEL7, false);return 4000; + case 47:Colonel->GetMotionMaster()->MovePoint(0, P[6].x, P[6].y, P[6].z);return 5000; + case 48:DoScriptText(SAY_BARADA8, me, 0); return 1000; + case 49:Colonel->GetMotionMaster()->MovePoint(0, P[0].x, P[0].y, P[0].z);return 3000; + case 50:Colonel->RemoveAllAuras(); + case 51:me->RemoveAllAuras();return 2000; + case 52:me->SetWalk(true);return 2000; + case 53:me->GetMotionMaster()->MovePoint(0, P[9].x, P[9].y, P[9].z);return 2200; + case 54:me->GetMotionMaster()->MovePoint(0, P[10].x, P[10].y, P[10].z);return 7000; + case 55:me->SetStandState(UNIT_STAND_STATE_KNEEL); + me->CombatStop();return 3000; + case 56:Colonel->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);return 20000; + case 57:me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + Colonel->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + case 58: + { + if (Player* plr = Unit::GetPlayer(PlayerGUID)) + if (plr->IsInRange(me,0,15)) + plr->GroupEventHappens(QUEST_THE_EXORCIM ,me); + Reset(); + } + default: return 0; + } } + return 0; } void JustDied(Unit* who) @@ -1397,6 +1449,7 @@ bool GossipSelect_npc_anchorite_barada(Player* player, Creature* creature, uint3 { if (action == GOSSIP_ACTION_INFO_DEF+1) { + ((npc_anchorite_baradaAI*)creature->AI())->PlayerGUID = player->GetGUID(); ((npc_anchorite_baradaAI*)creature->AI())->Exorcim = true; player->CLOSE_GOSSIP_MENU(); } @@ -1430,7 +1483,7 @@ static Move M[]= struct npc_darkness_releasedAI : public ScriptedAI { npc_darkness_releasedAI(Creature* creature) : ScriptedAI(creature) - { + { ChTimer = 5000; AtTimer = 10000; DoCast(me, SPELL_AURA_ME); @@ -1849,13 +1902,13 @@ struct npc_pathaleon_imageAI : public ScriptedAI uint32 Steps; void Reset() - { + { SumTimer = 5000; StepsTimer = 0; Steps = 0; Event = true; SummonTrigger = false; - } + } void DoSpawnGoliathon() { @@ -2016,7 +2069,7 @@ struct npc_vieraAI : public npc_escortAI void JustSummoned(Creature* summoned) { - summoned->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, summoned->GetFollowAngle()); + summoned->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, summoned->GetFollowAngle()); } void SpellHit(Unit* caster, const SpellEntry* spell) @@ -2024,16 +2077,16 @@ struct npc_vieraAI : public npc_escortAI if(spell->Id == 30077) { DoScriptText(SAY_VIERA2, me, 0); - SetEscortPaused(false); + SetEscortPaused(false); } } void UpdateEscortAI(const uint32 diff) { if (EndsTimer <= diff) - { + { SetEscortPaused(false); - } + } else EndsTimer -= diff; } }; @@ -2114,6 +2167,190 @@ CreatureAI* GetAI_npc_deranged_helboar(Creature* creature) return new npc_deranged_helboarAI(creature); } +/*### +# Quest 10792 "Zeth'Gor Must Burn!" (Horde) - Visual Effect +####*/ + +enum Quest10792 +{ + SPELL_FIRE = 35724, + GO_FIRE = 183816 +}; +struct npc_east_hovelAI : public ScriptedAI +{ + npc_east_hovelAI(Creature* creature) : ScriptedAI(creature) {} + + bool Summon; + uint32 ResetTimer; + void Reset() + { + Summon = true; + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(spell->Id == SPELL_FIRE) + { + if(Summon) + { + me->SummonGameObject(GO_FIRE, -934.393005, 1934.01001, 82.031601, 3.35103, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -927.877991, 1927.44995, 81.048897, 5.25344, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -935.54303, 1921.160034, 82.4132, 2.67035, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -944.015015, 1928.160034, 82.105499, 5.98648, 0, 0, 0, 0, 15); + ResetTimer = 15000; + Summon = false; + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!Summon) + { + if (ResetTimer <= diff) + { + Summon = true; + } + else ResetTimer -= diff; + } + } +}; +CreatureAI* GetAI_npc_east_hovel(Creature* creature) +{ + return new npc_east_hovelAI(creature); +} + +struct npc_west_hovelAI : public ScriptedAI +{ + npc_west_hovelAI(Creature* creature) : ScriptedAI(creature) {} + + bool Summon; + uint32 ResetTimer; + void Reset() + { + Summon = true; + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(spell->Id == SPELL_FIRE) + { + if(Summon) + { + me->SummonGameObject(GO_FIRE, -1145.410034, 2064.830078, 80.782600, 5.044, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1156.839966, 2060.870117, 79.176399, 3.83972, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1152.719971, 2073.5, 80.622902, 2.00713, 0, 0, 0, 0, 15); + ResetTimer = 15000; + Summon = false; + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!Summon) + { + if (ResetTimer <= diff) + { + Summon = true; + } + else ResetTimer -= diff; + } + } +}; +CreatureAI* GetAI_npc_west_hovel(Creature* creature) +{ + return new npc_west_hovelAI(creature); +} + +struct npc_stableAI : public ScriptedAI +{ + npc_stableAI(Creature* creature) : ScriptedAI(creature) {} + + bool Summon; + uint32 ResetTimer; + void Reset() + { + Summon = true; + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(spell->Id == SPELL_FIRE) + { + if(Summon) + { + me->SummonGameObject(GO_FIRE, -1067.280029, 1998.949951, 76.286301, 5.86431, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1052.189941, 2012.099976, 80.946198, 5.95157, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1043.439941, 2002.140015, 76.030502, 2.00713, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1052.26001, 1996.339966, 79.377502, 0.628319, 0, 0, 0, 0, 15); + ResetTimer = 15000; + Summon = false; + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!Summon) + { + if (ResetTimer <= diff) + { + Summon = true; + } + else ResetTimer -= diff; + } + } +}; +CreatureAI* GetAI_npc_stable(Creature* creature) +{ + return new npc_stableAI(creature); +} + +struct npc_barracksAI : public ScriptedAI +{ + npc_barracksAI(Creature* creature) : ScriptedAI(creature) {} + + bool Summon; + uint32 ResetTimer; + void Reset() + { + Summon = true; + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(spell->Id == SPELL_FIRE) + { + if(Summon) + { + me->SummonGameObject(GO_FIRE, -1176.709961, 1972.189941, 107.182999, 5.18363, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1120.219971, 1929.890015, 92.360901, 0.89011, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1137.099976, 1951.25, 94.115898, 2.32129, 0, 0, 0, 0, 15); + me->SummonGameObject(GO_FIRE, -1152.890015, 1961.48999, 92.9795, 0.994838, 0, 0, 0, 0, 15); + ResetTimer = 15000; + Summon = false; + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!Summon) + { + if (ResetTimer <= diff) + { + Summon = true; + } + else ResetTimer -= diff; + } + } +}; +CreatureAI* GetAI_npc_barracks(Creature* creature) +{ + return new npc_barracksAI(creature); +} + void AddSC_hellfire_peninsula() { Script *newscript; @@ -2247,4 +2484,24 @@ void AddSC_hellfire_peninsula() newscript->Name = "npc_deranged_helboar"; newscript->GetAI = &GetAI_npc_deranged_helboar; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_east_hovel"; + newscript->GetAI = &GetAI_npc_east_hovel; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_west_hovel"; + newscript->GetAI = &GetAI_npc_west_hovel; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_stable"; + newscript->GetAI = &GetAI_npc_stable; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_barracks"; + newscript->GetAI = &GetAI_npc_barracks; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/nagrand/nagrand.cpp b/src/scripts/scripts/Outland/nagrand/nagrand.cpp old mode 100755 new mode 100644 similarity index 92% rename from src/scripts/scripts/zone/nagrand/nagrand.cpp rename to src/scripts/scripts/Outland/nagrand/nagrand.cpp index 526326503..c73e1d67e --- a/src/scripts/scripts/zone/nagrand/nagrand.cpp +++ b/src/scripts/scripts/Outland/nagrand/nagrand.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -695,7 +698,7 @@ struct npc_corki_capitiveAI : public ScriptedAI void Reset() { - PlayerGUID = NULL; + PlayerGUID = 0; me->SetWalk(false); } @@ -707,7 +710,7 @@ struct npc_corki_capitiveAI : public ScriptedAI { return; } - else PlayerGUID = NULL; + else PlayerGUID = 0; switch (urand(0,4)) { @@ -1083,15 +1086,12 @@ struct npc_maghar_prisonerAI : public ScriptedAI { npc_maghar_prisonerAI(Creature *creature) : ScriptedAI(creature) {} - uint32 DieTimer; uint64 PlayerGUID; void Reset() { - DieTimer = 0; PlayerGUID = 0; me->SetWalk(false); - me->SetVisibility(VISIBILITY_ON); //??? } void MoveInLineOfSight(Unit* who) @@ -1102,7 +1102,7 @@ struct npc_maghar_prisonerAI : public ScriptedAI { return; } - else PlayerGUID = NULL; + else PlayerGUID = 0; switch (urand(0,3)) { @@ -1213,21 +1213,7 @@ struct npc_maghar_prisonerAI : public ScriptedAI { if (MotionType == POINT_MOTION_TYPE) { - //me->ForcedDespawn(); - me->SetVisibility(VISIBILITY_OFF); //??? - me->GetMotionMaster()->MoveTargetedHome(); //??? - } - } - - void UpdateAI(const uint32 diff) - { - if(DieTimer) - { - if(DieTimer <= diff) - { - me->ForcedDespawn(); - } - else DieTimer -= diff; + me->ForcedDespawn(); } } }; @@ -1268,10 +1254,9 @@ bool go_maghar_prison(Player* player, GameObject* go) if (npc_maghar_prisonerAI* scriptedAI = CAST_AI(npc_maghar_prisonerAI, Prisoner->AI())) { scriptedAI->StartRun(player); - scriptedAI->DieTimer = 20000; } - return false; + return false; } } return true; @@ -1338,14 +1323,14 @@ struct npc_warmaul_pyreAI : public ScriptedAI { Event = false; PlayerGUID = 0; - StepsTimer =0; + StepsTimer = 0; Steps = 0; CorpseCount = 0; MoveCount = 1; me->SetVisibility(VISIBILITY_OFF); } - void EnterCombat(Unit *who){} + void EnterCombat(Unit *who) {} void DoSpawn() { @@ -1353,7 +1338,7 @@ struct npc_warmaul_pyreAI : public ScriptedAI me->SummonCreature(NPC_SABOTEUR, Z[1].x, Z[1].y, Z[1].z, 3.8f, TEMPSUMMON_CORPSE_DESPAWN, 60000); } - void DoSummon() + void DoSummon() { ++CorpseCount; @@ -1391,17 +1376,12 @@ struct npc_warmaul_pyreAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { - if (who->GetTypeId() == TYPEID_PLAYER) - { - if (((Player*)who)->GetQuestStatus(9932) == QUEST_STATUS_INCOMPLETE) + if (Player* plr = who->ToPlayer()) + if (plr->GetQuestStatus(9932) == QUEST_STATUS_INCOMPLETE && me->IsWithinDistInMap(plr, 3.0f)) { - if (me->IsWithinDistInMap(((Player *)who), 3.0f)) - { - PlayerGUID = who->GetObjectGuid(); - Event = true; // this is not the best way to start the event :) - } + PlayerGUID = who->GetObjectGuid(); + Event = true; // this is not the best way to start the event :) } - } } void Started() @@ -1415,21 +1395,21 @@ struct npc_warmaul_pyreAI : public ScriptedAI Creature* GetSaboteur(uint8 ListNum) { - if (!SaboteurList.empty()) - { - uint8 Num = 1; + if (SaboteurList.empty()) + return NULL; - for (std::list::iterator itr = SaboteurList.begin(); itr != SaboteurList.end(); ++itr) - { - if (ListNum && ListNum != Num) - { - ++Num; - continue; - } + uint8 Num = 1; - if ((*itr)->isAlive() && (*itr)->IsWithinDistInMap(me, 25.0f)) - return (*itr); + for (std::list::iterator itr = SaboteurList.begin(); itr != SaboteurList.end(); ++itr) + { + if (ListNum && ListNum != Num) + { + ++Num; + continue; } + + if ((*itr)->isAlive() && (*itr)->IsWithinDistInMap(me, 25.0f)) + return (*itr); } return NULL; @@ -1437,80 +1417,128 @@ struct npc_warmaul_pyreAI : public ScriptedAI uint32 NextStep(uint32 Steps) { - switch(Steps) + switch (Steps) { - case 1:DoSpawn(); + case 1: + DoSpawn(); return 4000; - case 2:Started(); + + case 2: + Started(); return 2900; - case 3:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR1, Saboteur); + + case 3: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR1, Saboteur); return 5000; - case 4:if (Creature* Saboteur = GetSaboteur(1)) - DoScriptText(SAY_SABOTEUR2, Saboteur); + + case 4: + if (Creature* Saboteur = GetSaboteur(1)) + DoScriptText(SAY_SABOTEUR2, Saboteur); return 5000; - case 5:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR3, Saboteur); + + case 5: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR3, Saboteur); return 5000; - case 6:if (Creature* Saboteur = GetSaboteur(1)) - DoScriptText(SAY_SABOTEUR4, Saboteur); + + case 6: + if (Creature* Saboteur = GetSaboteur(1)) + DoScriptText(SAY_SABOTEUR4, Saboteur); return 4000; - case 7:Move(); + + case 7: + Move(); return 6000; - case 8:DoSummon(); + + case 8: + DoSummon(); return 2000; - case 9:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR5, Saboteur); + + case 9: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR5, Saboteur); return 2000; - case 10:Move(); + + case 10: + Move(); return 7000; - case 11:DoSummon(); + + case 11: + DoSummon(); return 2000; - case 12:if (Creature* Saboteur = GetSaboteur(1)) - DoScriptText(SAY_SABOTEUR6, Saboteur); + + case 12: + if (Creature* Saboteur = GetSaboteur(1)) + DoScriptText(SAY_SABOTEUR6, Saboteur); return 2000; - case 13:Move(); + + case 13: + Move(); return 7000; - case 14:DoSummon(); + + case 14: + DoSummon(); return 2000; - case 15:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR7, Saboteur); + + case 15: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR7, Saboteur); return 3000; - case 16:if (Creature* Saboteur = GetSaboteur(1)) - DoScriptText(SAY_SABOTEUR7, Saboteur); + + case 16: + if (Creature* Saboteur = GetSaboteur(1)) + DoScriptText(SAY_SABOTEUR7, Saboteur); return 2000; - case 17:Move(); + + case 17: + Move(); return 7000; - case 18:DoSummon(); + + case 18: + DoSummon(); return 2000; - case 19:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR8, Saboteur); + + case 19: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR8, Saboteur); return 3000; - case 21:if (Creature* Saboteur = GetSaboteur(1)) - DoScriptText(SAY_SABOTEUR9, Saboteur); + + case 21: + if (Creature* Saboteur = GetSaboteur(1)) + DoScriptText(SAY_SABOTEUR9, Saboteur); return 2000; - case 22:Move(); + + case 22: + Move(); return 7000; - case 23:DoSummon(); + + case 23: + DoSummon(); return 2000; - case 24:if (Creature* Saboteur = GetSaboteur(2)) - DoScriptText(SAY_SABOTEUR10, Saboteur); + + case 24: + if (Creature* Saboteur = GetSaboteur(2)) + DoScriptText(SAY_SABOTEUR10, Saboteur); return 2000; - case 25:Move(); + + case 25: + Move(); return 7000; - case 26:if (Player* player = me->GetPlayer(PlayerGUID)) - { - float Radius = 15.0f; - if (me->IsWithinDistInMap(player, Radius)) - ((Player*)player)->KilledMonster(18395, me->GetObjectGuid()); - } + + case 26: + if (Player* player = me->GetPlayer(PlayerGUID)) + if (me->IsWithinDistInMap(player, 15.0f)) + ((Player*) player)->KilledMonster(18395, me->GetObjectGuid()); return 2000; - case 27:for (std::list::iterator itr = SaboteurList.begin(); itr != SaboteurList.end(); ++itr) - { - (*itr)->ForcedDespawn(); - } - Reset(); - default: return 0; + + case 27: + for (std::list::iterator itr = SaboteurList.begin(); itr != SaboteurList.end(); ++itr) + (*itr)->ForcedDespawn(); + Reset(); + + default: + return 0; } } @@ -1522,7 +1550,8 @@ struct npc_warmaul_pyreAI : public ScriptedAI if (Event) StepsTimer = NextStep(++Steps); } - else StepsTimer -= diff; + else + StepsTimer -= diff; } }; diff --git a/src/scripts/scripts/zone/netherstorm/netherstorm.cpp b/src/scripts/scripts/Outland/netherstorm/netherstorm.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/netherstorm/netherstorm.cpp rename to src/scripts/scripts/Outland/netherstorm/netherstorm.cpp index 44e2eecbb..471640fac --- a/src/scripts/scripts/zone/netherstorm/netherstorm.cpp +++ b/src/scripts/scripts/Outland/netherstorm/netherstorm.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -244,20 +247,24 @@ struct npc_manaforge_control_consoleAI : public ScriptedAI void UpdateAI(const uint32 diff) { + if (!someplayer) + return; + if( Event_Timer < diff ) { switch(Phase) { case 1: - if (someplayer) { - Unit* u = Unit::GetUnit((*me), someplayer); - if (u && u->GetTypeId() == TYPEID_PLAYER) DoScriptText(EMOTE_START, me, u); - } + Unit* u = me->GetUnit(someplayer); + if (u && u->GetTypeId() == TYPEID_PLAYER) + DoScriptText(EMOTE_START, me, u); + Event_Timer = 60000; Wave = true; ++Phase; break; + } case 2: DoScriptText(EMOTE_60, me); Event_Timer = 30000; @@ -277,20 +284,17 @@ struct npc_manaforge_control_consoleAI : public ScriptedAI break; case 5: DoScriptText(EMOTE_COMPLETE, me); - if (someplayer) - { - Player* player = Unit::GetPlayer(someplayer); - if (player) - player->KilledMonster(me->GetEntry(),me->GetGUID()); + Player* player = Unit::GetPlayer(someplayer); + if (player) + player->KilledMonster(me->GetEntry(),me->GetGUID()); + DoCast(me,SPELL_DISABLE_VISUAL); - DoCast(me,SPELL_DISABLE_VISUAL); - } if (goConsole) { if (GameObject* go = GameObject::GetGameObject((*me),goConsole)) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } - ++Phase; + someplayer = 0; break; } } else Event_Timer -= diff; @@ -332,27 +336,28 @@ bool GOUse_go_manaforge_control_console(Player* player, GameObject* go) case 3726: //b'naar if ((player->GetQuestStatus(10299) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10329) == QUEST_STATUS_INCOMPLETE) && player->HasItemCount(29366,1)) - manaforge = player->SummonCreature(ENTRY_BNAAR_C_CONSOLE,2918.95,4189.98,161.88,0.34,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + manaforge = go->GetMap()->GetCreatureById(ENTRY_BNAAR_C_CONSOLE); break; case 3730: //coruu if ((player->GetQuestStatus(10321) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10330) == QUEST_STATUS_INCOMPLETE) && player->HasItemCount(29396,1)) - manaforge = player->SummonCreature(ENTRY_CORUU_C_CONSOLE,2426.77,2750.38,133.24,2.14,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + manaforge = go->GetMap()->GetCreatureById(ENTRY_CORUU_C_CONSOLE); break; case 3734: //duro if ((player->GetQuestStatus(10322) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10338) == QUEST_STATUS_INCOMPLETE) && player->HasItemCount(29397,1)) - manaforge = player->SummonCreature(ENTRY_DURO_C_CONSOLE,2976.48,2183.29,163.20,1.85,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + manaforge = go->GetMap()->GetCreatureById(ENTRY_DURO_C_CONSOLE); break; case 3722: //ara if ((player->GetQuestStatus(10323) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10365) == QUEST_STATUS_INCOMPLETE) && player->HasItemCount(29411,1)) - manaforge = player->SummonCreature(ENTRY_ARA_C_CONSOLE,4013.71,4028.76,192.10,1.25,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + manaforge = go->GetMap()->GetCreatureById(ENTRY_ARA_C_CONSOLE); break; } if (manaforge) { + manaforge->AI()->Reset(); ((npc_manaforge_control_consoleAI*)manaforge->AI())->someplayer = player->GetGUID(); ((npc_manaforge_control_consoleAI*)manaforge->AI())->goConsole = go->GetGUID(); go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); @@ -1121,7 +1126,6 @@ bool GOUse_go_ethereum_prison(Player* player, GameObject* go) break; } - go->SetLootState(GO_READY); go->UseDoorOrButton(5*MINUTE*IN_MILISECONDS); return true; @@ -1214,8 +1218,16 @@ CreatureAI* GetAI_mob_epextraction(Creature* creature) return new mob_epextractionAI (creature); } -#define BOOM_BOT_TARGET 20392 -#define BOOM_BOT 19692 +/*###### +## npc_dr_boom +######*/ + +enum +{ + THROW_DYNAMITE = 35276, + BOOM_BOT = 19692, + BOOM_BOT_TARGET = 20392 +}; struct mob_dr_boomAI : public ScriptedAI { @@ -1252,7 +1264,7 @@ struct mob_dr_boomAI : public ScriptedAI else Reset(); - SummonTimer = 3000; + SummonTimer = 2000; } else SummonTimer -= diff; @@ -1260,15 +1272,15 @@ struct mob_dr_boomAI : public ScriptedAI if (!UpdateVictim()) return; - if (!me->IsWithinDistInMap(me->getVictim(), 30.0f)) + if (!me->IsWithinDistInMap(me->getVictim(), 23.0f)) { EnterEvadeMode(); return; } - if (me->isAttackReady()) + if (me->isAttackReady() && me->IsWithinDistInMap(me->getVictim(), 12.2f)) { - DoCast(me->getVictim(), 35276, true); + DoCast(me->getVictim(), THROW_DYNAMITE, true); me->resetAttackTimer(); } } @@ -1279,22 +1291,33 @@ CreatureAI* GetAI_mob_dr_boom(Creature* creature) return new mob_dr_boomAI (creature); } +/*###### +## mob_boom_bot +######*/ + +#define SPELL_BOOM 35132 + struct mob_boom_botAI : public ScriptedAI { mob_boom_botAI(Creature* creature) : ScriptedAI(creature) {} - void Reset() {} + void Reset() + { + me->SetWalk(true); + } void EnterCombat(Unit* who) { return; } + void AttackedBy(Unit* who) { return; } + void AttackStart(Unit* who) { return; } void MovementInform(uint32 type, uint32 id) { if (type != POINT_MOTION_TYPE) return; - DoCast(me, 35132, true); //proper Boom spell - me->Kill(me, false); - me->RemoveCorpse(); + DoCast(me, SPELL_BOOM, true); + me->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN); + me->ForcedDespawn(2000); } void MoveInLineOfSight(Unit* who) @@ -1302,21 +1325,13 @@ struct mob_boom_botAI : public ScriptedAI if (!who->isCharmedOwnedByPlayerOrPlayer()) return; - if (me->IsWithinDistInMap(who, 6.0f, false)) + if (me->IsWithinDistInMap(who, 1.0f, false)) { - DoCast(me, 35132, true); //proper Boom spell - me->Kill(me, false); - me->RemoveCorpse(); + DoCast(me, SPELL_BOOM, true); + me->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN); + me->ForcedDespawn(2000); } } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); - } }; CreatureAI* GetAI_mob_boom_bot(Creature* creature) @@ -1500,7 +1515,7 @@ struct npc_scrapped_reaverAI : public ScriptedAI float angle = RAND(2.3f, 3.4f, 4.8f); float x, y, z; - me->GetNearPoint(me, x, y, z, 0.0f, 35.0f, angle); + me->GetNearPoint( x, y, z, 0.0f, 35.0f, angle); me->SummonCreature(NPC_ZAXXIS, x, y, z+2, me->GetAngle(x, y), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 7000); } @@ -1910,7 +1925,7 @@ struct npc_captured_vanguardAI : public npc_escortAI if (!me->getVictim()) return; - + if (GlaiveTimer < diff) { DoCast(me->getVictim(), SPELL_GLAIVE); @@ -2483,7 +2498,7 @@ bool GossipHello_npc_saeed(Player* player, Creature* creature) if (((npc_saeedAI*)creature->AI())->HasEscortState(STATE_ESCORT_PAUSED)) player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_GO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); player->SEND_GOSSIP_MENU(creature->GetNpcTextId(), creature->GetGUID()); - + return true; } @@ -2566,7 +2581,7 @@ struct npc_dimensiusAI : public ScriptedAI } float fx, fy, fz; - me->GetNearPoint(me, fx, fy, fz, 0.0f, 20.0f, fangle); + me->GetNearPoint( fx, fy, fz, 0.0f, 20.0f, fangle); me->SummonCreature(NPC_SPAWN, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_DEAD_DESPAWN, 5000); } @@ -2727,7 +2742,7 @@ struct npc_king_salhadaarAI : public ScriptedAI uint32 Count; uint32 FluxTimer; uint32 StasisTimer; - + void Reset() { @@ -2766,7 +2781,7 @@ struct npc_king_salhadaarAI : public ScriptedAI //DoScriptText(YELL_INTRO, me); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->setFaction(FACTION_HOSTILE); + me->setFaction(FACTION_HOSTILE); me->RemoveAllAuras(); DoCast(me, SPELL_OVERSPARK); } @@ -2891,7 +2906,7 @@ CreatureAI* GetAI_npc_energy_ball(Creature* creature) # npc_trader_marid ######*/ -#define GOSSIP_ITEM_GO "I am prepared to offer a deal!" +#define GOSSIP_ITEM_GO1 "I am prepared to offer a deal!" enum { @@ -2917,9 +2932,9 @@ struct npc_trader_maridAI : public npc_escortAI void EnterCombat(Unit* who) { float fx, fy, fz; - me->GetNearPoint(me, fx, fy, fz, 0.0f, 4.0f, 0.0f); + me->GetNearPoint( fx, fy, fz, 0.0f, 4.0f, 0.0f); me->SummonCreature(NPC_BODYGUARD, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - me->GetNearPoint(me, fx, fy, fz, 0.0f, 4.0f, M_PI); + me->GetNearPoint( fx, fy, fz, 0.0f, 4.0f, M_PI); me->SummonCreature(NPC_BODYGUARD, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); } @@ -2964,7 +2979,7 @@ bool GossipHello_npc_trader_marid(Player* player, Creature* creature) { if( player->GetQuestStatus(QUEST_TROUBLE) == QUEST_STATUS_INCOMPLETE) { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_GO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_GO1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); player->SEND_GOSSIP_MENU(creature->GetNpcTextId(), creature->GetGUID()); } else @@ -3022,9 +3037,9 @@ struct npc_doctor_vomisaAI : public ScriptedAI CheckTimer = 5000; float fx, fy, fz; - me->GetNearPoint(me, fx, fy, fz, 0.0f, 5.0f, 4.7f); + me->GetNearPoint( fx, fy, fz, 0.0f, 5.0f, 4.7f); me->SummonCreature(NPC_X6000, fx, fy, fz, me->GetAngle(fx, fy), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 61000); - me->GetNearPoint(me, fx, fy, fz, 0.0f, 56.0f, 4.7f); + me->GetNearPoint( fx, fy, fz, 0.0f, 56.0f, 4.7f); me->SummonCreature(NPC_NEGATRON, fx, fy, fz, 2.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 50000); } } diff --git a/src/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp b/src/scripts/scripts/Outland/shadowmoon_valley/boss_doomwalker.cpp old mode 100755 new mode 100644 similarity index 84% rename from src/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp rename to src/scripts/scripts/Outland/shadowmoon_valley/boss_doomwalker.cpp index ec2981d9b..51ab12ea8 --- a/src/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp +++ b/src/scripts/scripts/Outland/shadowmoon_valley/boss_doomwalker.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Doomwalker diff --git a/src/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp b/src/scripts/scripts/Outland/shadowmoon_valley/shadowmoon_valley.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp rename to src/scripts/scripts/Outland/shadowmoon_valley/shadowmoon_valley.cpp index 9021b5672..f1863a9e2 --- a/src/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp +++ b/src/scripts/scripts/Outland/shadowmoon_valley/shadowmoon_valley.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -130,7 +133,9 @@ struct mob_azalothAI : public ScriptedAI } else cripple_timer-=diff; - +/* This spell has been disabled due to HUGE spam in logs: +2013-11-10 09:41:01 ERROR: SPELL: no destination for spell ID 38741 +x 20 0000 000 times... or more //spell rain of fire if (rain_timerGetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) - return; - - ScriptedAI::MoveInLineOfSight(who); + switch(i) + { + case 0: + if (GameObject* go = GetClosestGameObjectWithEntry(me, GO_FLAYER_CARCASS, INTERACTION_DISTANCE)) + me->SetFacingToObject(go); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACKUNARMED); + break; + case 1: + DoCast(me, SPELL_JUST_EATEN); + me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + DoScriptText(SAY_JUST_EATEN, m_creature); + if (GameObject* go = GetClosestGameObjectWithEntry(me, GO_FLAYER_CARCASS, INTERACTION_DISTANCE)) + go->Delete(); + if (Player* player = GetPlayerForEscort()) + player->KilledMonster(22131, m_creature->GetGUID()); + me->GetUnitStateMgr().PushAction(UNIT_ACTION_DOWAYPOINTS); + break; + } } - void SpellHit(Unit* caster, const SpellEntry* spell) + void OnAuraRemove(Aura* aur, bool) { - if(!caster) - return; - - if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_PLACE_CARCASS && !m_creature->HasAura(SPELL_JUST_EATEN, 0) && !PlayerGUID) - { - float PlayerX, PlayerY, PlayerZ; - caster->GetClosePoint(PlayerX, PlayerY, PlayerZ, m_creature->GetObjectSize()); - m_creature->SetLevitate(true); - m_creature->GetMotionMaster()->MovePoint(1, PlayerX, PlayerY, PlayerZ); - PlayerGUID = caster->GetGUID(); - } + if(aur->GetId() == SPELL_JUST_EATEN) + me->setFaction(1824); } - void MovementInform(uint32 type, uint32 id) + void SpellHit(Unit* caster, const SpellEntry* spell) { - if(type != POINT_MOTION_TYPE) + if(!caster) return; - if(id == 1) + if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_PLACE_CARCASS && !me->HasAura(SPELL_JUST_EATEN, 0)) { - IsEating = true; - EatTimer = 5000; - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACKUNARMED); - m_creature->SetLevitate(false); + if (caster->ToPlayer()->GetQuestStatus(10804) == QUEST_STATUS_INCOMPLETE) + { + float x, y, z; + caster->GetNearPoint(x, y, z, me->GetObjectSize()); + AddWaypoint(0, x, y, z, 15000); + AddWaypoint(1, x+0.1f, y-0.1f, z, 1000); + me->GetRespawnCoord(x, y, z); + AddWaypoint(2, x, y, z, 5000); + ((npc_escortAI*)(me->AI()))->SetClearWaypoints(true); + ((npc_escortAI*)(me->AI()))->SetDespawnAtEnd(false); + ((npc_escortAI*)(me->AI()))->SetDespawnAtFar(false); + me->setFaction(35); + me->GetUnitStateMgr().DropAction(UNIT_ACTION_DOWAYPOINTS); + Start(false, true, caster->GetGUID()); + } } } - void UpdateAI(const uint32 diff) + void UpdateEscortAI(const uint32 diff) { - if(IsEating) - if(EatTimer < diff) - { - IsEating = false; - DoCast(m_creature, SPELL_JUST_EATEN); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); - DoScriptText(SAY_JUST_EATEN, m_creature); - if(PlayerGUID) - { - Player* plr = Unit::GetPlayer(PlayerGUID); - if(plr && plr->GetQuestStatus(10804) == QUEST_STATUS_INCOMPLETE) - { - plr->KilledMonster(22131, m_creature->GetGUID()); - Evade = true; - PlayerGUID = 0; - } - } - }else EatTimer -= diff; - - if(Evade) - if(ResetTimer < diff) - { - EnterEvadeMode(); - return; - }else ResetTimer -= diff; - - if(!UpdateVictim()) + if (!UpdateVictim()) return; - if(CastTimer < diff) + if (CastTimer < diff) { - DoCast(m_creature->getVictim(), SPELL_NETHER_BREATH); + DoCast(me->getVictim(), SPELL_NETHER_BREATH); CastTimer = 5000; - }else CastTimer -= diff; + } + else CastTimer -= diff; DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_mob_mature_netherwing_drake(Creature *_creature) +CreatureAI* GetAI_mob_mature_netherwing_drake(Creature* creature) { - return new mob_mature_netherwing_drakeAI(_creature); + return new mob_mature_netherwing_drakeAI(creature); } /*### @@ -334,7 +316,7 @@ struct mob_enslaved_netherwing_drakeAI : public ScriptedAI AttackStart(Dragonmaw); } - HostilReference* ref = m_creature->getThreatManager().getOnlineContainer().getReferenceByTarget(caster); + HostileReference* ref = m_creature->getThreatManager().getOnlineContainer().getReferenceByTarget(caster); if(ref) ref->removeReference(); } @@ -442,7 +424,7 @@ struct mob_dragonmaw_peonAI : public ScriptedAI Tapped = true; float x, y, z; - caster->GetClosePoint(x, y, z, m_creature->GetObjectSize()); + caster->GetNearPoint(x, y, z, m_creature->GetObjectSize()); m_creature->SetWalk(false); m_creature->GetMotionMaster()->MovePoint(1, x, y, z); @@ -1770,6 +1752,7 @@ bool GOQuestAccept_GO_crystal_prison(Player* plr, GameObject* go, Quest const* q if(Illidan && !(((npc_lord_illidan_stormrageAI*)((Creature*)Illidan)->AI())->EventStarted)) { + ((npc_lord_illidan_stormrageAI*)((Creature*)Illidan)->AI())->Reset(); ((npc_lord_illidan_stormrageAI*)((Creature*)Illidan)->AI())->PlayerGUID = plr->GetGUID(); ((npc_lord_illidan_stormrageAI*)((Creature*)Illidan)->AI())->LiveCount = 0; ((npc_lord_illidan_stormrageAI*)((Creature*)Illidan)->AI())->EventStarted=true; @@ -2132,7 +2115,7 @@ struct npc_AkamaAI : public ScriptedAI { target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); target->SetHealth(target->GetMaxHealth()); - target->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN); + target->GetUnitStateMgr().DropAction(UNIT_ACTION_STUN); } } m_creature->Say(SAY_DIALOG_AKAMA_5, LANG_UNIVERSAL, 0); @@ -2503,7 +2486,6 @@ struct mob_shadowlord_deathwailAI : public ScriptedAI uint64 HeartGUID; bool landed; - bool flying; bool felfire; void Reset() @@ -2520,44 +2502,22 @@ struct mob_shadowlord_deathwailAI : public ScriptedAI Fear_Timer = 20000; Deathcoil_Timer = 8000; - Unit* trigger = FindCreature(22096, 100, m_creature); - if(trigger) - { - if(trigger->isAlive()) - { - m_creature->GetMotionMaster()->Initialize(); - m_creature->SetLevitate(true); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->GetMotionMaster()->MovePath(DEATHWAIL_FLYPATH, true); - landed = false; - flying = false; - } - else - { - me->SetWalk(true); - m_creature->SetSpeed(MOVE_RUN, 1.4); - m_creature->GetMotionMaster()->MovePoint(1, -3247, 284, 138.1); - } - } - } - - void EnterCombat(Unit *who) - { - if(!flying) - return; - } + m_creature->GetMotionMaster()->Initialize(); + m_creature->SetLevitate(true); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + //m_creature->GetMotionMaster()->MovePath(DEATHWAIL_FLYPATH, true); + //this waypoints are to far away from home and npc resets during travel + m_creature->GetMotionMaster()->MovePoint(0, -3247, 284, 187); + landed = false; - void MoveInLineOfSight(Unit *who) - { - if(!flying) - return; + Unit* trigger = FindCreature(22096, 100, m_creature); + if (trigger && !trigger->isAlive()) + ((Creature*)trigger)->Respawn(); } void AttackStart(Unit* who) { - if(!flying) - return; - else if (m_creature->Attack(who, true)) + if (m_creature->Attack(who, true)) { m_creature->AddThreat(who, 0.0f); m_creature->SetInCombatWith(who); @@ -2579,9 +2539,10 @@ struct mob_shadowlord_deathwailAI : public ScriptedAI m_creature->GetMotionMaster()->Initialize(); m_creature->SetLevitate(true); m_creature->GetMotionMaster()->MovePoint(1, -3247, 284, 138.1); + m_creature->SetHomePosition( -3247, 284, 138.1, 0); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoZoneInCombat(50); landed = true; - flying = true; felfire = false; } if(!m_creature->isInCombat() && landed && trigger && trigger->isAlive()) @@ -2602,47 +2563,48 @@ struct mob_shadowlord_deathwailAI : public ScriptedAI else Check_Timer -= diff; - if(flying && UpdateVictim()) + if(!landed || !UpdateVictim()) + return; + + if(Shadowbolt_Timer < diff) { - if(Shadowbolt_Timer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_SHADOWBOLT); - Shadowbolt_Timer = 12000+rand()%6000; - } - else - Shadowbolt_Timer -= diff; + AddSpellToCast(m_creature->getVictim(), SPELL_SHADOWBOLT); + Shadowbolt_Timer = 12000+rand()%6000; + } + else + Shadowbolt_Timer -= diff; - if(ShadowboltVoley_Timer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_SHADOWBOLT); - ShadowboltVoley_Timer = 25000+rand()%15000; - } - else - ShadowboltVoley_Timer -= diff; + if(ShadowboltVoley_Timer < diff) + { + AddSpellToCast(m_creature->getVictim(), SPELL_SHADOWBOLT); + ShadowboltVoley_Timer = 25000+rand()%15000; + } + else + ShadowboltVoley_Timer -= diff; - if(Fear_Timer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 30.0, true)) - AddSpellToCast(target, SPELL_FEAR); - Fear_Timer = 10000+rand()%20000; - } - else - Fear_Timer -= diff; + if(Fear_Timer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 30.0, true)) + AddSpellToCast(target, SPELL_FEAR); + Fear_Timer = 10000+rand()%20000; + } + else + Fear_Timer -= diff; - if(Deathcoil_Timer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 30.0, true, m_creature->getVictimGUID())) - AddSpellToCast(target, SPELL_DEATHCOIL); - else - AddSpellToCast(m_creature->getVictim(), SPELL_DEATHCOIL); - Deathcoil_Timer = 15000+rand()%30000; - } + if(Deathcoil_Timer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 30.0, true, m_creature->getVictimGUID())) + AddSpellToCast(target, SPELL_DEATHCOIL); else - Deathcoil_Timer -= diff; + AddSpellToCast(m_creature->getVictim(), SPELL_DEATHCOIL); + Deathcoil_Timer = 15000+rand()%30000; } - + else + Deathcoil_Timer -= diff; + CastNextSpellIfAnyAndReady(); DoMeleeAttackIfReady(); + } }; diff --git a/src/scripts/scripts/zone/shattrath/shattrath_city.cpp b/src/scripts/scripts/Outland/shattrath/shattrath_city.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/shattrath/shattrath_city.cpp rename to src/scripts/scripts/Outland/shattrath/shattrath_city.cpp index 016a1ff1f..8076e7b1d --- a/src/scripts/scripts/zone/shattrath/shattrath_city.cpp +++ b/src/scripts/scripts/Outland/shattrath/shattrath_city.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -413,7 +416,7 @@ struct npc_kservantAI : public npc_escortAI } break; } - case 24: + case 24: { switch(TalkCount) { diff --git a/src/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp b/src/scripts/scripts/Outland/tempest_keep/arcatraz/arcatraz.cpp old mode 100755 new mode 100644 similarity index 51% rename from src/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp rename to src/scripts/scripts/Outland/tempest_keep/arcatraz/arcatraz.cpp index 6897cc0a4..c1e2ee565 --- a/src/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/arcatraz/arcatraz.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Arcatraz -SD%Complete: 60 -SDComment: Warden Mellichar, event controller for Skyriss event. Millhouse Manastorm. TODO: make better combatAI for Millhouse. +SD%Complete: 90 +SDComment: SDCategory: Tempest Keep, The Arcatraz EndScriptData */ @@ -86,6 +89,8 @@ struct npc_millhouse_manastormAI : public ScriptedAI Pyroblast_Timer = 1000; Fireball_Timer = 2500; + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + if( pInstance ) { if( pInstance->GetData(TYPE_WARDEN_2) == DONE ) @@ -93,34 +98,30 @@ struct npc_millhouse_manastormAI : public ScriptedAI if( pInstance->GetData(TYPE_HARBINGERSKYRISS) == DONE ) { - DoScriptText(SAY_COMPLETE, m_creature); + DoScriptText(SAY_COMPLETE, me); + me->ForcedDespawn(20000); } } } - void AttackStart(Unit* who) + void MovementInform(uint32 type, uint32 id) { - if (m_creature->Attack(who, true)) - { - m_creature->AddThreat(who, 0.0f); + if (type != POINT_MOTION_TYPE) + return; - //TODO: Make it so he moves when target out of range - DoStartNoMovement(who); - } - } - - void EnterCombat(Unit *who) - { + me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 4.8f); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + me->SetReactState(REACT_AGGRESSIVE); } void KilledUnit(Unit *victim) { - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), m_creature); + DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me); } void JustDied(Unit *victim) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); /*for questId 10886 (heroic mode only) if( pInstance && pInstance->GetData(TYPE_HARBINGERSKYRISS) != DONE ) @@ -138,35 +139,35 @@ struct npc_millhouse_manastormAI : public ScriptedAI switch( Phase ) { case 1: - DoScriptText(SAY_INTRO_1, m_creature); + DoScriptText(SAY_INTRO_1, me); EventProgress_Timer = 18000; break; case 2: - DoScriptText(SAY_INTRO_2, m_creature); + DoScriptText(SAY_INTRO_2, me); EventProgress_Timer = 18000; break; case 3: - DoScriptText(SAY_WATER, m_creature); - DoCast(m_creature,SPELL_CONJURE_WATER); + if( pInstance ) + pInstance->SetData(TYPE_WARDEN_2,DONE); EventProgress_Timer = 7000; break; case 4: - DoScriptText(SAY_BUFFS, m_creature); - DoCast(m_creature,SPELL_ICE_ARMOR); - EventProgress_Timer = 7000; + DoScriptText(SAY_WATER, me); + DoCast(me,SPELL_CONJURE_WATER); + EventProgress_Timer = 10000; break; case 5: - DoScriptText(SAY_DRINK, m_creature); - DoCast(m_creature,SPELL_ARCANE_INTELLECT); - EventProgress_Timer = 7000; + DoScriptText(SAY_BUFFS, me); + DoCast(me,SPELL_ICE_ARMOR); + EventProgress_Timer = 10000; break; case 6: - DoScriptText(SAY_READY, m_creature); - EventProgress_Timer = 6000; + DoScriptText(SAY_DRINK, me); + DoCast(me,SPELL_ARCANE_INTELLECT); + EventProgress_Timer = 7000; break; case 7: - if( pInstance ) - pInstance->SetData(TYPE_WARDEN_2,DONE); + DoScriptText(SAY_READY, me); Init = true; break; } @@ -178,30 +179,30 @@ struct npc_millhouse_manastormAI : public ScriptedAI if( !UpdateVictim() ) return; - if( !LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) ) + if( !LowHp && ((me->GetHealth()*100 / me->GetMaxHealth()) < 20) ) { - DoScriptText(SAY_LOWHP, m_creature); + DoScriptText(SAY_LOWHP, me); LowHp = true; } if( Pyroblast_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( me->IsNonMeleeSpellCast(false) ) return; - DoScriptText(SAY_PYRO, m_creature); + DoScriptText(SAY_PYRO, me); - DoCast(m_creature->getVictim(),SPELL_PYROBLAST); + DoCast(me->getVictim(),SPELL_PYROBLAST); Pyroblast_Timer = 40000; }else Pyroblast_Timer -=diff; if( Fireball_Timer < diff ) { - DoCast(m_creature->getVictim(),SPELL_FIREBALL); + DoCast(me->getVictim(),SPELL_FIREBALL); Fireball_Timer = 4000; }else Fireball_Timer -=diff; - DoMeleeAttackIfReady(); + //DoMeleeAttackIfReady(); } }; @@ -245,6 +246,8 @@ CreatureAI* GetAI_npc_millhouse_manastorm(Creature *_Creature) #define SPELL_TARGET_OMEGA 36852 #define SPELL_BUBBLE_VISUAL 36849 +#define SPELL_ETHEREAL_TELEPORT 34427 + struct npc_warden_mellicharAI : public ScriptedAI { npc_warden_mellicharAI(Creature *c) : ScriptedAI(c) @@ -268,43 +271,46 @@ struct npc_warden_mellicharAI : public ScriptedAI EventProgress_Timer = 22000; Phase = 1; - m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature,SPELL_TARGET_OMEGA); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(me,SPELL_TARGET_OMEGA); - if( pInstance ) + if( pInstance && !(pInstance->GetData(TYPE_HARBINGERSKYRISS) == DONE)) pInstance->SetData(TYPE_HARBINGERSKYRISS,NOT_STARTED); + if(Unit* millhouse = (Unit*)FindCreature(ENTRY_MILLHOUSE, 100, me)) + millhouse->ToCreature()->ForcedDespawn(0); } - void AttackStart(Unit* who) { } + void AttackStart(Unit* who) {} void MoveInLineOfSight(Unit *who) { if( IsRunning ) return; - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessiblePlacefor(m_creature) ) + if( !me->getVictim() && who->isTargetableForAttack() && ( me->IsHostileTo( who )) && who->isInAccessiblePlacefor(me) ) { - if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return; if (who->GetTypeId() != TYPEID_PLAYER) return; - float attackRadius = m_creature->GetAttackDistance(who)/10; - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + float attackRadius = me->GetAttackDistance(who)/10; + if( me->IsWithinDistInMap(who, attackRadius) && me->IsWithinLOSInMap(who) ) EnterCombat(who); } } void EnterCombat(Unit *who) { - DoScriptText(YELL_INTRO1, m_creature); - DoCast(m_creature,SPELL_BUBBLE_VISUAL); + if (!IsRunning) + { + DoScriptText(YELL_INTRO1, me); + DoCast(me,SPELL_BUBBLE_VISUAL); + } if( pInstance ) { - pInstance->SetData(TYPE_HARBINGERSKYRISS,IN_PROGRESS); - if (GameObject* Sphere = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_SPHERE_SHIELD))) - Sphere->SetGoState(GO_STATE_READY); + pInstance->HandleGameObject(pInstance->GetData64(DATA_SPHERE_SHIELD),false); IsRunning = true; } } @@ -319,14 +325,10 @@ struct npc_warden_mellicharAI : public ScriptedAI return true; if( Phase == 5 && pInstance->GetData(TYPE_WARDEN_2) == DONE ) return true; - if( Phase == 4 ) + if( Phase == 4 || Phase == 1 || Phase == 2) return true; if( Phase == 3 && pInstance->GetData(TYPE_WARDEN_1) == DONE ) return true; - if( Phase == 2 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) - return true; - if( Phase == 1 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) - return true; return false; } return false; @@ -336,31 +338,30 @@ struct npc_warden_mellicharAI : public ScriptedAI { if( pInstance ) { - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveSpellsCausingAura(SPELL_AURA_DUMMY); + me->InterruptNonMeleeSpells(true); + me->RemoveSpellsCausingAura(SPELL_AURA_DUMMY); switch( Phase ) { case 2: - DoCast(m_creature,SPELL_TARGET_ALPHA); - pInstance->SetData(TYPE_WARDEN_1,IN_PROGRESS); - if (GameObject *Sphere = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_SPHERE_SHIELD))) - Sphere->SetGoState(GO_STATE_READY); + DoCast(me,SPELL_TARGET_ALPHA); + pInstance->HandleGameObject(pInstance->GetData64(DATA_POD_A),true); break; case 3: - DoCast(m_creature,SPELL_TARGET_BETA); - pInstance->SetData(TYPE_WARDEN_2,IN_PROGRESS); + DoCast(me,SPELL_TARGET_BETA); + pInstance->HandleGameObject(pInstance->GetData64(DATA_POD_B),true); break; case 5: - DoCast(m_creature,SPELL_TARGET_DELTA); - pInstance->SetData(TYPE_WARDEN_3,IN_PROGRESS); + DoCast(me,SPELL_TARGET_DELTA); + pInstance->HandleGameObject(pInstance->GetData64(DATA_POD_D),true); break; case 6: - DoCast(m_creature,SPELL_TARGET_GAMMA); - pInstance->SetData(TYPE_WARDEN_4,IN_PROGRESS); + DoCast(me,SPELL_TARGET_GAMMA); + pInstance->HandleGameObject(pInstance->GetData64(DATA_POD_G),true); break; case 7: - pInstance->SetData(TYPE_WARDEN_5,IN_PROGRESS); + pInstance->HandleGameObject(pInstance->GetData64(DATA_POD_O),true); + pInstance->SetData(TYPE_HARBINGERSKYRISS,IN_PROGRESS); break; } CanSpawn = true; @@ -384,28 +385,42 @@ struct npc_warden_mellicharAI : public ScriptedAI { //continue beam omega pod, unless we are about to summon skyriss if( Phase != 7 ) - DoCast(m_creature,SPELL_TARGET_OMEGA); + DoCast(me,SPELL_TARGET_OMEGA); switch( Phase ) { case 2: - m_creature->SummonCreature(RAND(ENTRY_TRICKSTER, ENTRY_PH_HUNTER), 478.326, -148.505, 42.56, 3.19, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + if (Creature* temp = me->SummonCreature(RAND(ENTRY_TRICKSTER, ENTRY_PH_HUNTER), 478.326, -148.505, 42.56, 3.19, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); break; case 3: - m_creature->SummonCreature(ENTRY_MILLHOUSE,413.292,-148.378,42.56,6.27,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + if (Creature* temp = me->SummonCreature(ENTRY_MILLHOUSE,413.292,-148.378,42.56,6.27,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000)) + { + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); + temp->SetReactState(REACT_PASSIVE); + } break; case 4: - DoScriptText(YELL_RELEASE2B, m_creature); + DoScriptText(YELL_RELEASE2B, me); break; case 5: - m_creature->SummonCreature(RAND(ENTRY_AKKIRIS, ENTRY_SULFURON), 420.179, -174.396, 42.58, 0.02, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + if (Creature* temp = me->SummonCreature(RAND(ENTRY_AKKIRIS, ENTRY_SULFURON), 420.179, -174.396, 42.58, 0.02, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); break; case 6: - m_creature->SummonCreature(RAND(ENTRY_TW_DRAK,ENTRY_BL_DRAK), 471.795, -174.58, 42.58, 3.06, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); + if (Creature* temp = me->SummonCreature(RAND(ENTRY_TW_DRAK,ENTRY_BL_DRAK), 471.795, -174.58, 42.58, 3.06, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000)) + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); + + if (Creature* millhouse = GetClosestCreatureWithEntry(me, ENTRY_MILLHOUSE, 100)) + { + millhouse->SetWalk(true); + millhouse->GetMotionMaster()->MovePoint(0, 445.55f, -157.658f, 43.06f); + } break; case 7: - m_creature->SummonCreature(ENTRY_SKYRISS,445.763,-191.639,44.64,1.60,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoScriptText(YELL_WELCOME, m_creature); + if (Creature* temp = me->SummonCreature(ENTRY_SKYRISS,445.763,-191.639,44.64,1.60,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000)) + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); + DoScriptText(YELL_WELCOME, me); break; } CanSpawn = false; @@ -416,17 +431,17 @@ struct npc_warden_mellicharAI : public ScriptedAI switch( Phase ) { case 1: - DoScriptText(YELL_INTRO2, m_creature); + DoScriptText(YELL_INTRO2, me); EventProgress_Timer = 10000; ++Phase; break; case 2: - DoScriptText(YELL_RELEASE1, m_creature); + DoScriptText(YELL_RELEASE1, me); DoPrepareForPhase(); EventProgress_Timer = 7000; break; case 3: - DoScriptText(YELL_RELEASE2A, m_creature); + DoScriptText(YELL_RELEASE2A, me); DoPrepareForPhase(); EventProgress_Timer = 10000; break; @@ -435,12 +450,12 @@ struct npc_warden_mellicharAI : public ScriptedAI EventProgress_Timer = 15000; break; case 5: - DoScriptText(YELL_RELEASE3, m_creature); + DoScriptText(YELL_RELEASE3, me); DoPrepareForPhase(); EventProgress_Timer = 15000; break; case 6: - DoScriptText(YELL_RELEASE4, m_creature); + DoScriptText(YELL_RELEASE4, me); DoPrepareForPhase(); EventProgress_Timer = 15000; break; @@ -453,33 +468,174 @@ struct npc_warden_mellicharAI : public ScriptedAI } else EventProgress_Timer -= diff; } }; + CreatureAI* GetAI_npc_warden_mellichar(Creature *_Creature) { return new npc_warden_mellicharAI (_Creature); } -/*##### -# mob_zerekethvoidzone (this script probably not needed in future -> `creature_template_addon`.`auras`='36120 0') -#####*/ +/*###### +## npc_felfire_wave +######*/ + +#define SPELL_FELFIRE 35769 -#define SPELL_VOID_ZONE_DAMAGE 36120 +struct npc_felfire_waveAI : public ScriptedAI +{ + npc_felfire_waveAI(Creature* c) : ScriptedAI(c) {} + + uint32 Burn; + + void IsSummonedBy(Unit *summoner) + { + Burn = 0; + float x, y, z; + me->SetSpeed(MOVE_RUN, 1.1); + me->GetNearPoint(x, y, z, 0, 20, summoner->GetAngle(me)); + me->UpdateAllowedPositionZ(x, y, z); + me->GetMotionMaster()->MovePoint(1, x, y, z); + } + + void AttackStart(Unit* who) {} + + void MovementInform(uint32 type, uint32 id) + { + if (type != POINT_MOTION_TYPE || id != 1) + return; + + me->ForcedDespawn(5000); + } + + void UpdateAI(const uint32 diff) + { + if(Burn < diff) + { + DoCast(me, SPELL_FELFIRE, true); + Burn = 450; + } + else + Burn -= diff; + } +}; -struct mob_zerekethvoidzoneAI : public Scripted_NoMovementAI +CreatureAI* GetAI_npc_felfire_wave(Creature* _Creature) { - mob_zerekethvoidzoneAI(Creature *c) : Scripted_NoMovementAI(c) {} + return new npc_felfire_waveAI(_Creature); +} + +#define SPELL_AURA (HeroicMode ? 38828 : 36716) +#define SPELL_EXPLODE (HeroicMode ? 38830 : 36719) + +struct npc_arcatraz_sentinelAI : public ScriptedAI +{ + npc_arcatraz_sentinelAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + HeroicMode = me->GetMap()->IsHeroic(); + } + + uint32 ThreatWipe_Timer; + uint32 Suicide_Timer; + + ScriptedInstance *pInstance; + bool HeroicMode; void Reset() { - m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); - m_creature->setFaction(16); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_DEAD); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->CastSpell(me, SPELL_AURA, true); - DoCast(m_creature,SPELL_VOID_ZONE_DAMAGE); + ThreatWipe_Timer = urand(5000, 10000); + Suicide_Timer = 0; + } + + void EnterCombat(Unit *who) + { + me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); + me->SetHealth(me->GetMaxHealth() * 40 / 100); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (!Suicide_Timer) + { + if (ThreatWipe_Timer < diff) + { + DoResetThreat(); + ThreatWipe_Timer = urand(10000, 15000); + } + else + ThreatWipe_Timer -= diff; + + if (me->GetHealth()*100/me->GetMaxHealth() <= 12) + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->RemoveAllAuras(); + me->CastSpell(me, SPELL_EXPLODE, true); + + Suicide_Timer = 10000; + } + } + else + { + if (Suicide_Timer < diff) + me->Kill(me, false); + else + Suicide_Timer -= diff; + } + + DoMeleeAttackIfReady(); } }; -CreatureAI* GetAI_mob_zerekethvoidzoneAI(Creature *_Creature) + +CreatureAI* GetAI_npc_arcatraz_sentinel(Creature *_Creature) { - return new mob_zerekethvoidzoneAI (_Creature); + return new npc_arcatraz_sentinelAI (_Creature); +} + +#define SPELL_SUMMON 36593 + +struct npc_warder_corpseAI : public ScriptedAI +{ + npc_warder_corpseAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()); + } + + ScriptedInstance *pInstance; + + bool summon; + + void Reset() + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); + me->SetUInt32Value(UNIT_FIELD_BYTES_1, 7); + summon = false; + } + + void EnterCombat(Unit *who) {} + void AttackStart(Unit* who) {} + + void MoveInLineOfSight(Unit* who) + { + if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinMeleeRange(who) && !summon) //no GM support they fail last days :P + { + DoCast(me, SPELL_SUMMON, true); + summon = true; + } + } +}; + +CreatureAI* GetAI_npc_warder_corpse(Creature *_Creature) +{ + return new npc_warder_corpseAI (_Creature); } void AddSC_arcatraz() @@ -497,8 +653,18 @@ void AddSC_arcatraz() newscript->RegisterSelf(); newscript = new Script; - newscript->Name="mob_zerekethvoidzone"; - newscript->GetAI = &GetAI_mob_zerekethvoidzoneAI; + newscript->Name="npc_felfire_wave"; + newscript->GetAI = &GetAI_npc_felfire_wave; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="arcatraz_sentinel"; + newscript->GetAI = &GetAI_npc_arcatraz_sentinel; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="warder_corpse"; + newscript->GetAI = &GetAI_npc_warder_corpse; newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp b/src/scripts/scripts/Outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp old mode 100755 new mode 100644 similarity index 65% rename from src/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp rename to src/scripts/scripts/Outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp index c5602c63f..d2dfea368 --- a/src/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_Harbinger_Skyriss -SD%Complete: 45 -SDComment: CombatAI not fully implemented. Timers will need adjustments. Need more docs on how event fully work. Reset all event and force start over if fail at one point? +SD%Complete: 90 +SDComment: CombatAI not fully implemented. Timers will need adjustments. SDCategory: Tempest Keep, The Arcatraz EndScriptData */ @@ -40,6 +43,8 @@ EndContentData */ #define SAY_IMAGE -1552008 #define SAY_DEATH -1552009 +#define ENTRY_MILLHOUSE 20977 + #define SPELL_FEAR 39415 #define SPELL_MIND_REND 36924 @@ -58,10 +63,10 @@ EndContentData */ struct boss_harbinger_skyrissAI : public ScriptedAI { - boss_harbinger_skyrissAI(Creature *c) : ScriptedAI(c) + boss_harbinger_skyrissAI(Creature *c) : ScriptedAI(c), summons(me) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); Intro = false; } @@ -72,18 +77,18 @@ struct boss_harbinger_skyrissAI : public ScriptedAI bool IsImage33; bool IsImage66; + SummonList summons; uint32 Intro_Phase; uint32 Intro_Timer; uint32 MindRend_Timer; uint32 Fear_Timer; uint32 Domination_Timer; uint32 ManaBurn_Timer; - uint32 checkTimer; void Reset() { if(!Intro) - m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2); + me->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2); IsImage33 = false; IsImage66 = false; @@ -109,20 +114,20 @@ struct boss_harbinger_skyrissAI : public ScriptedAI void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if(pInstance) pInstance->SetData(TYPE_HARBINGERSKYRISS,DONE); if(pInstance && HeroicMode) { - if(Unit* millhouse = (Unit*)FindCreature(NPC_MILLHOUSE, 100, m_creature)) + if(Unit* millhouse = (Unit*)FindCreature(NPC_MILLHOUSE, 100, me)) { if(millhouse->isAlive()) { MapRefManager::const_iterator player = pInstance->instance->GetPlayers().begin(); if(player != pInstance->instance->GetPlayers().end()) - player->getSource()->GroupEventHappens(QUEST_10886, m_creature); + player->getSource()->GroupEventHappens(QUEST_10886, me); } } @@ -133,11 +138,14 @@ struct boss_harbinger_skyrissAI : public ScriptedAI { if(!summon) return; + + summons.Summon(summon); + if(IsImage66) summon->SetHealth((summon->GetMaxHealth()*33)/100); else summon->SetHealth((summon->GetMaxHealth()*66)/100); - if(m_creature->getVictim()) + if(me->getVictim()) if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0)) summon->AI()->AttackStart(target); } @@ -148,20 +156,55 @@ struct boss_harbinger_skyrissAI : public ScriptedAI if( victim->GetEntry() == 21436 ) return; - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), m_creature); + DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me); } void DoSplit(uint32 val) { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(false); + if( me->IsNonMeleeSpellCast(false) ) + me->InterruptNonMeleeSpells(false); - DoScriptText(SAY_IMAGE, m_creature); + DoScriptText(SAY_IMAGE, me); if( val == 66 ) - DoCast(m_creature, SPELL_66_ILLUSION); + DoCast(me, SPELL_66_ILLUSION); else - DoCast(m_creature, SPELL_33_ILLUSION); + DoCast(me, SPELL_33_ILLUSION); + } + + void EnterEvadeMode() + { + if (!me->isAlive()) + return; + + //domination? + bool alive = false; + Player* pl; + InstanceMap::PlayerList const &playerliste = ((InstanceMap*)me->GetMap())->GetPlayers(); + InstanceMap::PlayerList::const_iterator it; + + Map::PlayerList const &PlayerList = ((InstanceMap*)me->GetMap())->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + pl = i->getSource(); + + if (pl && pl->isAlive()) + { + alive = true; + break; + } + } + + if (!alive) + { + pInstance->SetData(TYPE_HARBINGERSKYRISS, FAIL); + summons.DespawnAll(); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->ForcedDespawn(); + return; + } } void UpdateAI(const uint32 diff) @@ -176,26 +219,26 @@ struct boss_harbinger_skyrissAI : public ScriptedAI switch( Intro_Phase ) { case 1: - DoScriptText(SAY_INTRO, m_creature); - if (GameObject* Sphere = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_SPHERE_SHIELD))) - Sphere->SetGoState(GO_STATE_ACTIVE); + DoScriptText(SAY_INTRO, me); + pInstance->HandleGameObject(pInstance->GetData64(DATA_SPHERE_SHIELD),true); ++Intro_Phase; Intro_Timer = 25000; break; case 2: - DoScriptText(SAY_AGGRO, m_creature); - if( Unit *mellic = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_MELLICHAR)) ) + DoScriptText(SAY_AGGRO, me); + if( Unit *mellic = Unit::GetUnit(*me,pInstance->GetData64(DATA_MELLICHAR)) ) { //should have a better way to do this. possibly spell exist. mellic->SetHealth(0); mellic->setDeathState(JUST_DIED); - pInstance->SetData(TYPE_SHIELD_OPEN,IN_PROGRESS); } ++Intro_Phase; Intro_Timer = 3000; break; case 3: - m_creature->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2); + me->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2); + if(Creature* millhouse = GetClosestCreatureWithEntry(me, ENTRY_MILLHOUSE, 100)) + millhouse->AI()->AttackStart(me); Intro = true; break; } @@ -205,43 +248,12 @@ struct boss_harbinger_skyrissAI : public ScriptedAI if( !UpdateVictim() ) return; - if (checkTimer < diff) - { - bool alive = false; - Player* pl; - InstanceMap::PlayerList const &playerliste = ((InstanceMap*)m_creature->GetMap())->GetPlayers(); - InstanceMap::PlayerList::const_iterator it; - - Map::PlayerList const &PlayerList = ((InstanceMap*)m_creature->GetMap())->GetPlayers(); - for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - pl = i->getSource(); - - if (pl && pl->isAlive()) - { - alive = true; - break; - } - } - - if (!alive) - { - me->Kill(me->getVictim(), false); - EnterEvadeMode(); - return; - } - - checkTimer = 3000; - } - else - checkTimer -= diff; - - if( !IsImage66 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 66) ) + if( !IsImage66 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 66) ) { DoSplit(66); IsImage66 = true; } - if( !IsImage33 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 33) ) + if( !IsImage33 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 33) ) { DoSplit(33); IsImage33 = true; @@ -249,40 +261,40 @@ struct boss_harbinger_skyrissAI : public ScriptedAI if( MindRend_Timer < diff ) { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_MIND_REND), true, m_creature->getVictimGUID()) ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_MIND_REND), true, me->getVictimGUID())) DoCast(target,HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); else - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); + DoCast(me->getVictim(),HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); MindRend_Timer = 8000; }else MindRend_Timer -=diff; if( Fear_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( me->IsNonMeleeSpellCast(false) ) return; - DoScriptText(RAND(SAY_FEAR_1, SAY_FEAR_2), m_creature); + DoScriptText(RAND(SAY_FEAR_1, SAY_FEAR_2), me); - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_FEAR), true, m_creature->getVictimGUID()) ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_FEAR), true, me->getVictimGUID()) ) DoCast(target,SPELL_FEAR); else - DoCast(m_creature->getVictim(),SPELL_FEAR); + DoCast(me->getVictim(),SPELL_FEAR); Fear_Timer = 25000; }else Fear_Timer -=diff; if( Domination_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( me->IsNonMeleeSpellCast(false) ) return; - DoScriptText(RAND(SAY_MIND_1, SAY_MIND_2), m_creature); + DoScriptText(RAND(SAY_MIND_1, SAY_MIND_2), me); - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_DOMINATION), true, m_creature->getVictimGUID()) ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_DOMINATION), true, me->getVictimGUID()) ) DoCast(target,HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); else - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); + DoCast(me->getVictim(),HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); Domination_Timer = 16000+rand()%16000; }else Domination_Timer -=diff; @@ -291,10 +303,10 @@ struct boss_harbinger_skyrissAI : public ScriptedAI { if( ManaBurn_Timer < diff ) { - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( me->IsNonMeleeSpellCast(false) ) return; - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(H_SPELL_MANA_BURN), true, m_creature->getVictimGUID()) ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(H_SPELL_MANA_BURN), true, me->getVictimGUID()) ) DoCast(target,H_SPELL_MANA_BURN); ManaBurn_Timer = 16000+rand()%16000; @@ -318,15 +330,36 @@ struct boss_harbinger_skyriss_illusionAI : public ScriptedAI boss_harbinger_skyriss_illusionAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } + uint32 MindRend_Timer; + ScriptedInstance *pInstance; bool HeroicMode; - void Reset() { } + void Reset() + { + MindRend_Timer = 5000; + } - void EnterCombat(Unit *who) { } + void UpdateAI(const uint32 diff) + { + if(!UpdateVictim()) + return; + + if( MindRend_Timer < diff ) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1, GetSpellMaxRange(SPELL_MIND_REND_IMAGE), true, me->getVictimGUID())) + DoCast(target,HeroicMode ? H_SPELL_MIND_REND_IMAGE : SPELL_MIND_REND_IMAGE); + else + DoCast(me->getVictim(),HeroicMode ? H_SPELL_MIND_REND_IMAGE : SPELL_MIND_REND_IMAGE); + + MindRend_Timer = 15000+rand()%6000; + }else MindRend_Timer -=diff; + + DoMeleeAttackIfReady(); + } }; CreatureAI* GetAI_boss_harbinger_skyriss_illusion(Creature *_Creature) diff --git a/src/scripts/scripts/Outland/tempest_keep/arcatraz/def_arcatraz.h b/src/scripts/scripts/Outland/tempest_keep/arcatraz/def_arcatraz.h new file mode 100644 index 000000000..b000c01d1 --- /dev/null +++ b/src/scripts/scripts/Outland/tempest_keep/arcatraz/def_arcatraz.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_ARCATRAZ_H +#define SC_DEF_ARCATRAZ_H + +#define TYPE_ZEREKETH 1 +#define TYPE_DALLIAH 2 +#define TYPE_SOCCOTHRATES 3 +#define TYPE_HARBINGERSKYRISS 4 +#define TYPE_WARDEN_1 5 +#define TYPE_WARDEN_2 6 +#define TYPE_WARDEN_3 7 +#define TYPE_WARDEN_4 8 +#define DATA_MELLICHAR 9 +#define DATA_SPHERE_SHIELD 10 +#define DATA_POD_A 11 +#define DATA_POD_B 12 +#define DATA_POD_D 13 +#define DATA_POD_G 14 +#define DATA_POD_O 15 +#endif + diff --git a/src/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp b/src/scripts/scripts/Outland/tempest_keep/arcatraz/instance_arcatraz.cpp old mode 100755 new mode 100644 similarity index 77% rename from src/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp rename to src/scripts/scripts/Outland/tempest_keep/arcatraz/instance_arcatraz.cpp index b5086b28b..957422dc8 --- a/src/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/arcatraz/instance_arcatraz.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -24,7 +27,7 @@ EndScriptData */ #include "precompiled.h" #include "def_arcatraz.h" -#define ENCOUNTERS 9 +#define ENCOUNTERS 8 #define CONTAINMENT_CORE_SECURITY_FIELD_ALPHA 184318 //door opened when Wrath-Scryer Soccothrates dies #define CONTAINMENT_CORE_SECURITY_FIELD_BETA 184319 //door opened when Dalliah the Doomsayer dies @@ -33,7 +36,6 @@ EndScriptData */ #define POD_DELTA 183964 //pod third boss wave #define POD_GAMMA 183962 //pod fourth boss wave #define POD_OMEGA 183965 //pod fifth boss wave -#define WARDENS_SHIELD 184802 // warden shield #define SEAL_SPHERE 184802 //shield 'protecting' mellichar #define MELLICHAR 20904 //skyriss will kill this unit @@ -54,12 +56,11 @@ struct instance_arcatraz : public ScriptedInstance uint64 Containment_Core_Security_Field_Alpha; uint64 Containment_Core_Security_Field_Beta; - GameObject *Pod_Alpha; - GameObject *Pod_Gamma; - GameObject *Pod_Beta; - GameObject *Pod_Delta; - GameObject *Pod_Omega; - GameObject *Wardens_Shield; + uint64 Pod_Alpha; + uint64 Pod_Gamma; + uint64 Pod_Beta; + uint64 Pod_Delta; + uint64 Pod_Omega; uint64 GoSphereGUID; uint64 MellicharGUID; @@ -68,12 +69,11 @@ struct instance_arcatraz : public ScriptedInstance { Containment_Core_Security_Field_Alpha = 0; Containment_Core_Security_Field_Beta = 0; - Pod_Alpha = NULL; - Pod_Beta = NULL; - Pod_Delta = NULL; - Pod_Gamma = NULL; - Pod_Omega = NULL; - Wardens_Shield = NULL; + Pod_Alpha = 0; + Pod_Beta = 0; + Pod_Delta = 0; + Pod_Gamma = 0; + Pod_Omega = 0; GoSphereGUID = 0; MellicharGUID = 0; @@ -106,12 +106,11 @@ struct instance_arcatraz : public ScriptedInstance HandleGameObject(0, true, go); break; case SEAL_SPHERE: GoSphereGUID = go->GetGUID(); break; - case POD_ALPHA: Pod_Alpha = go; break; - case POD_BETA: Pod_Beta = go; break; - case POD_DELTA: Pod_Delta = go; break; - case POD_GAMMA: Pod_Gamma = go; break; - case POD_OMEGA: Pod_Omega = go; break; - //case WARDENS_SHIELD: Wardens_Shield = go; break; + case POD_ALPHA: Pod_Alpha = go->GetGUID(); break; + case POD_BETA: Pod_Beta = go->GetGUID(); break; + case POD_DELTA: Pod_Delta = go->GetGUID(); break; + case POD_GAMMA: Pod_Gamma = go->GetGUID(); break; + case POD_OMEGA: Pod_Omega = go->GetGUID(); break; } } @@ -148,51 +147,33 @@ struct instance_arcatraz : public ScriptedInstance Encounter[5] = NOT_STARTED; Encounter[6] = NOT_STARTED; Encounter[7] = NOT_STARTED; - Encounter[8] = NOT_STARTED; + HandleGameObject(Pod_Alpha,false); + HandleGameObject(Pod_Beta,false); + HandleGameObject(Pod_Gamma,false); + HandleGameObject(Pod_Delta,false); + HandleGameObject(Pod_Omega,false); + HandleGameObject(GoSphereGUID,true); + if (GetCreature(MellicharGUID) && GetCreature(MellicharGUID)->isDead()) + GetCreature(MellicharGUID)->Respawn(); } Encounter[3] = data; break; - case TYPE_WARDEN_1: - if (data == IN_PROGRESS) - if (Pod_Alpha) - Pod_Alpha->UseDoorOrButton(); + case TYPE_WARDEN_1:; Encounter[4] = data; break; - case TYPE_WARDEN_2: - if ( data == IN_PROGRESS ) - if (Pod_Beta) - Pod_Beta->UseDoorOrButton(); + case TYPE_WARDEN_2:; Encounter[5] = data; break; case TYPE_WARDEN_3: - if (data == IN_PROGRESS) - if (Pod_Delta) - Pod_Delta->UseDoorOrButton(); Encounter[6] = data; break; case TYPE_WARDEN_4: - if (data == IN_PROGRESS) - if (Pod_Gamma) - Pod_Gamma->UseDoorOrButton(); Encounter[7] = data; break; - - case TYPE_WARDEN_5: - if (data == IN_PROGRESS) - if (Pod_Omega) - Pod_Omega->UseDoorOrButton(); - Encounter[8] = data; - break; - - case TYPE_SHIELD_OPEN: - if (data == IN_PROGRESS) - if (Wardens_Shield) - Wardens_Shield->UseDoorOrButton(); - break; } if(data == DONE) @@ -211,8 +192,7 @@ struct instance_arcatraz : public ScriptedInstance stream << Encounter[4] << " "; stream << Encounter[5] << " "; stream << Encounter[6] << " "; - stream << Encounter[7] << " "; - stream << Encounter[8]; + stream << Encounter[7]; OUT_SAVE_INST_DATA_COMPLETE; @@ -229,7 +209,7 @@ struct instance_arcatraz : public ScriptedInstance OUT_LOAD_INST_DATA(in); std::istringstream stream(in); stream >> Encounter[0] >> Encounter[1] >> Encounter[2] >> Encounter[3] >> Encounter[4] >> Encounter[5] >> Encounter[6] - >> Encounter[7] >> Encounter[8]; + >> Encounter[7]; for(uint8 i = 0; i < ENCOUNTERS; ++i) if(Encounter[i] == IN_PROGRESS) Encounter[i] = NOT_STARTED; @@ -259,8 +239,6 @@ struct instance_arcatraz : public ScriptedInstance return Encounter[6]; case TYPE_WARDEN_4: return Encounter[7]; - case TYPE_WARDEN_5: - return Encounter[8]; } return 0; } @@ -273,6 +251,16 @@ struct instance_arcatraz : public ScriptedInstance return MellicharGUID; case DATA_SPHERE_SHIELD: return GoSphereGUID; + case DATA_POD_A: + return Pod_Alpha; + case DATA_POD_B: + return Pod_Beta; + case DATA_POD_D: + return Pod_Delta; + case DATA_POD_G: + return Pod_Gamma; + case DATA_POD_O: + return Pod_Omega; } return 0; } diff --git a/src/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp rename to src/scripts/scripts/Outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp index 0f838d542..f4196ddca --- a/src/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_high_botanist_freywinn.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -94,7 +97,7 @@ struct boss_high_botanist_freywinnAI : public ScriptedAI { DoScriptText(RAND(SAY_TREE_1, SAY_TREE_2), m_creature); - if( m_creature->IsNonMeleeSpellCasted(false) ) + if( m_creature->IsNonMeleeSpellCast(false) ) m_creature->InterruptNonMeleeSpells(true); m_creature->RemoveAllAuras(); diff --git a/src/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_laj.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp rename to src/scripts/scripts/Outland/tempest_keep/botanica/boss_laj.cpp index 29cb153ec..9b737dfe3 --- a/src/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_laj.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_warp_splinter.cpp old mode 100755 new mode 100644 similarity index 87% rename from src/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp rename to src/scripts/scripts/Outland/tempest_keep/botanica/boss_warp_splinter.cpp index f08c527c8..3de9e0bd2 --- a/src/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/botanica/boss_warp_splinter.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Warp_Splinter diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_alar.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/boss_alar.cpp index 37f619ca8..bcafab186 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_alar.cpp @@ -1,18 +1,21 @@ -/* Copyright(C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -*(at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: boss_alar diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_astromancer.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/boss_astromancer.cpp index fb055863a..0927c9dec --- a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_astromancer.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -138,14 +141,6 @@ struct boss_high_astromancer_solarianAI : public ScriptedAI Summons.DespawnAll(); } - void StartEvent() - { - DoScriptText(SAY_AGGRO, m_creature); - - if(pInstance) - pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS); - } - void KilledUnit(Unit *victim) { DoScriptText(RAND(SAY_KILL1, SAY_KILL2, SAY_KILL3), m_creature); @@ -163,7 +158,11 @@ struct boss_high_astromancer_solarianAI : public ScriptedAI void EnterCombat(Unit *who) { - StartEvent(); + DoScriptText(SAY_AGGRO, m_creature); + DoZoneInCombat(); + + if(pInstance) + pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS); } void SummonMinion(uint32 entry, float x, float y, float z) diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_kaelthas.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/boss_kaelthas.cpp index 3d7090387..4414f6177 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_kaelthas.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -355,7 +358,7 @@ struct boss_kaelthasAI : public ScriptedAI uint32 Phase; uint32 PhaseSubphase; //generic uint32 Phase_Timer; //generic timer - uint32 PyrosCasted; + uint32 PyrosCast; uint32 Check_Timer2; uint32 Anim_Timer; uint32 Step; @@ -413,7 +416,7 @@ struct boss_kaelthasAI : public ScriptedAI MindControl_Timer = 10000; Phoenix_Timer =50000; ShockPyroChain_Timer = 60000; - PyrosCasted = 0; + PyrosCast = 0; Pyro_Timer = 0; ShockBarrier_Timer = 60000; GravityLapse_Timer = 16000; @@ -422,7 +425,7 @@ struct boss_kaelthasAI : public ScriptedAI Kick_Timer = 3000; Check_Timer = 4000; Check_Timer2 = 3000; - PyrosCasted = 0; + PyrosCast = 0; Phase = 0; Anim_Timer = 0; Step = 1; @@ -1082,6 +1085,8 @@ struct boss_kaelthasAI : public ScriptedAI Arcane_Timer2 -= diff; } + DoSpecialThings(diff, DO_SPEED_UPDATE); + //Phase 4 specific spells if(Phase == 4) { @@ -1093,9 +1098,9 @@ struct boss_kaelthasAI : public ScriptedAI // arcane disruption, shock, pyroblasts chain if(ShockPyroChain_Timer < diff) { - if(PyrosCasted == 0) + if(PyrosCast == 0) { - if(m_creature->IsNonMeleeSpellCasted(false)) + if(m_creature->IsNonMeleeSpellCast(false)) { m_creature->InterruptNonMeleeSpells(true); } @@ -1111,21 +1116,21 @@ struct boss_kaelthasAI : public ScriptedAI if(Pyro_Timer < diff) { - if(PyrosCasted < 3) + if(PyrosCast < 3) { m_creature->StopMoving(); m_creature->CastSpell(m_creature->getVictim(), SPELL_PYROBLAST, false); - ++PyrosCasted; + ++PyrosCast; Pyro_Timer = 4000; } } else Pyro_Timer -= diff; - if(PyrosCasted >= 3) + if(PyrosCast >= 3) { ChainPyros = false; - PyrosCasted = 0; + PyrosCast = 0; ShockPyroChain_Timer = 48000; Pyro_Timer = 0; } @@ -1153,7 +1158,7 @@ struct boss_kaelthasAI : public ScriptedAI //GravityLapse_Timer if(GravityLapse_Timer < diff) { - std::list::iterator iter = m_creature->getThreatManager().getThreatList().begin(); + std::list::iterator iter = m_creature->getThreatManager().getThreatList().begin(); uint32 glapse_teleport_id = 35966; float X, Y, Z; @@ -1590,8 +1595,8 @@ struct boss_grand_astromancer_capernianAI : public advisorbase_ai if(ArcaneExplosion_Timer < diff) { bool InMeleeRange = false; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) { Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); //if in melee range diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_void_reaver.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/boss_void_reaver.cpp index 4093225de..60ad933e1 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/boss_void_reaver.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/Outland/tempest_keep/the_eye/def_the_eye.h b/src/scripts/scripts/Outland/tempest_keep/the_eye/def_the_eye.h new file mode 100644 index 000000000..b9c630621 --- /dev/null +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/def_the_eye.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_THE_EYE_H +#define SC_DEF_THE_EYE_H + +#define DATA_ALAREVENT 1 +#define DATA_ASTROMANCER 2 +#define DATA_GRANDASTROMANCERCAPERNIAN 3 +#define DATA_HIGHASTROMANCERSOLARIANEVENT 4 +#define DATA_KAELTHAS 5 +#define DATA_KAELTHASEVENT 6 +#define DATA_LORDSANGUINAR 7 +#define DATA_MASTERENGINEERTELONICUS 8 +#define DATA_THALADREDTHEDARKENER 10 +#define DATA_VOIDREAVEREVENT 11 +#define DATA_ALAR 12 +#define DATA_EXPLODE 13 + +#endif + diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/instance_the_eye.cpp old mode 100755 new mode 100644 similarity index 79% rename from src/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/instance_the_eye.cpp index 1fdfa3c11..58229d5b6 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/instance_the_eye.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData @@ -46,6 +49,8 @@ struct instance_the_eye : public ScriptedInstance std::set ExplodeObjectGUID; uint64 Astromancer; uint64 Alar; + std::list AstromancerTrash; + std::list VoidTrash; uint32 Encounters[ENCOUNTERS]; @@ -60,6 +65,8 @@ struct instance_the_eye : public ScriptedInstance ExplodeObjectGUID.clear(); Astromancer = 0; Alar = 0; + AstromancerTrash.clear(); + VoidTrash.clear(); for(uint8 i = 0; i < ENCOUNTERS; ++i) Encounters[i] = NOT_STARTED; @@ -116,17 +123,24 @@ struct instance_the_eye : public ScriptedInstance case 19514: Alar = creature->GetGUID(); break; + case 20031: + case 20036: + case 20043: + case 20044: + case 20045: + if (creature->GetDistance(433,-373,18)<150) + AstromancerTrash.push_front(creature->GetGUID()); + break; + case 20040: + case 20041: + case 20042: + case 20052: + if (creature->GetDistance(425,404,15)<150) + VoidTrash.push_front(creature->GetGUID()); + break; } - const CreatureData *tmp = creature->GetLinkedRespawnCreatureData(); - if (!tmp) - return; - - if (GetEncounterForEntry(tmp->id) && creature->isAlive() && GetData(GetEncounterForEntry(tmp->id)) == DONE) - { - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - } + HandleInitCreatureState(creature); } void OnObjectCreate(GameObject *go) @@ -168,12 +182,30 @@ struct instance_the_eye : public ScriptedInstance Encounters[0] = data; break; case DATA_HIGHASTROMANCERSOLARIANEVENT: - if(Encounters[1] != DONE) + if(Encounters[1] != DONE) + { Encounters[1] = data; + if (data == IN_PROGRESS && !AstromancerTrash.empty()) + for(std::list::iterator i = AstromancerTrash.begin(); i != AstromancerTrash.end(); ++i) + { + Creature* trashmob = GetCreature(*i); + if (trashmob && trashmob->isAlive()) + trashmob->AI()->DoZoneInCombat(); + } + } break; case DATA_VOIDREAVEREVENT: if(Encounters[2] != DONE) + { Encounters[2] = data; + if (data == IN_PROGRESS && !VoidTrash.empty()) + for(std::list::iterator i = VoidTrash.begin(); i != VoidTrash.end(); ++i) + { + Creature* trashmob = GetCreature(*i); + if (trashmob && trashmob->isAlive()) + trashmob->AI()->DoZoneInCombat(); + } + } break; case DATA_KAELTHASEVENT: if(data == NOT_STARTED || data == DONE) diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp b/src/scripts/scripts/Outland/tempest_keep/the_eye/the_eye.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_eye/the_eye.cpp index d4992762f..e26522334 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_eye/the_eye.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp index 9798dc42d..dce2e88df --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +19,8 @@ /* ScriptData SDName: Boss_Gatewatcher_Gyrokill -SD%Complete: 0 -SDComment: Place Holder +SD%Complete: 90 +SDComment: SDCategory: Tempest Keep, The Mechanar EndScriptData */ @@ -42,7 +45,7 @@ struct boss_gatewatcher_gyro_killAI : public ScriptedAI boss_gatewatcher_gyro_killAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; @@ -68,17 +71,17 @@ struct boss_gatewatcher_gyro_killAI : public ScriptedAI if(pInstance) pInstance->SetData(DATA_GYROKILL_EVENT, IN_PROGRESS); - DoScriptText(SAY_AGGRO, m_creature); + DoScriptText(SAY_AGGRO, me); } void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); if (!pInstance) return; @@ -96,15 +99,15 @@ struct boss_gatewatcher_gyro_killAI : public ScriptedAI //Shadow Power if(Shadow_Power_Timer < diff) { - DoCast(m_creature,HeroicMode ? H_SPELL_SHADOW_POWER : SPELL_SHADOW_POWER); + DoCast(me,HeroicMode ? H_SPELL_SHADOW_POWER : SPELL_SHADOW_POWER); Shadow_Power_Timer = 20000 + rand()%8000; }else Shadow_Power_Timer -= diff; //Saw Blade if(Saw_Blade_Timer < diff) { - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_SAW_BLADE : SPELL_SAW_BLADE); - DoScriptText(RAND(SAY_SAW_ATTACK1, SAY_SAW_ATTACK2), m_creature); + DoCast(me->getVictim(),HeroicMode ? H_SPELL_SAW_BLADE : SPELL_SAW_BLADE); + DoScriptText(RAND(SAY_SAW_ATTACK1, SAY_SAW_ATTACK2), me); Saw_Blade_Timer = 30000; }else Saw_Blade_Timer -= diff; @@ -112,7 +115,7 @@ struct boss_gatewatcher_gyro_killAI : public ScriptedAI //Stream of Machine Fluid if(Stream_of_Machine_Fluid_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); + DoCast(me->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); Stream_of_Machine_Fluid_Timer = 35000 + rand()%15000; }else Stream_of_Machine_Fluid_Timer -= diff; diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp old mode 100755 new mode 100644 similarity index 68% rename from src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp index 7a9acb364..38b7b9aa0 --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Gatewatcher_Ironhand @@ -32,7 +35,7 @@ EndScriptData */ #define SAY_DEATH_1 -1554011 #define EMOTE_HAMMER -1554012 -// Spells to be casted +// Spells to be cast #define SPELL_SHADOW_POWER 35322 #define H_SPELL_SHADOW_POWER 39193 #define SPELL_HAMMER_PUNCH 35326 @@ -46,7 +49,7 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI boss_gatewatcher_iron_handAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; @@ -72,7 +75,7 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI if(pInstance) pInstance->SetData(DATA_IRONHAND_EVENT, IN_PROGRESS); - DoScriptText(SAY_AGGRO_1, m_creature); + DoScriptText(SAY_AGGRO_1, me); } void KilledUnit(Unit* victim) @@ -80,12 +83,12 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI if (rand()%2) return; - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), m_creature); + DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH_1, m_creature); + DoScriptText(SAY_DEATH_1, me); if (!pInstance) return; @@ -103,7 +106,7 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI //Shadow Power if(Shadow_Power_Timer < diff) { - DoCast(m_creature,HeroicMode ? H_SPELL_SHADOW_POWER : SPELL_SHADOW_POWER); + DoCast(me,HeroicMode ? H_SPELL_SHADOW_POWER : SPELL_SHADOW_POWER); Shadow_Power_Timer = 20000 + rand()%8000; }else Shadow_Power_Timer -= diff; @@ -111,14 +114,14 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI if(Jackhammer_Timer < diff) { //TODO: expect cast this about 5 times in a row (?), announce it by emote only once - DoScriptText(EMOTE_HAMMER, m_creature); - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_JACKHAMMER : SPELL_JACKHAMMER); + DoScriptText(EMOTE_HAMMER, me); + DoCast(me->getVictim(),HeroicMode ? H_SPELL_JACKHAMMER : SPELL_JACKHAMMER); - //chance to yell, but not same time as emote (after spell in fact casted) + //chance to yell, but not same time as emote (after spell in fact cast) if (rand()%2) return; - DoScriptText(RAND(SAY_HAMMER_1, SAY_HAMMER_2), m_creature); + DoScriptText(RAND(SAY_HAMMER_1, SAY_HAMMER_2), me); Jackhammer_Timer = 30000; }else Jackhammer_Timer -= diff; @@ -126,7 +129,7 @@ struct boss_gatewatcher_iron_handAI : public ScriptedAI //Stream of Machine Fluid if(Stream_of_Machine_Fluid_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); + DoCast(me->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); Stream_of_Machine_Fluid_Timer = 35000 + rand()%15000; }else Stream_of_Machine_Fluid_Timer -= diff; diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp old mode 100755 new mode 100644 similarity index 52% rename from src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp index 678148394..95ce302e1 --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp @@ -1,23 +1,26 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss_Nethermancer_Sepethrea -SD%Complete: 90 -SDComment: Need adjustments to initial summons +SD%Complete: 99 +SDComment: Check melee dmg and immunities SDCategory: Tempest Keep, The Mechanar EndScriptData */ @@ -25,7 +28,7 @@ EndScriptData */ #include "def_mechanar.h" #define SAY_AGGRO -1554013 -#define SAY_SUMMON -1554014 +#define SAY_SUMMON -1554014 // using this when resummoning adds, used on timer here to prevent double yell #define SAY_DRAGONS_BREATH_1 -1554015 #define SAY_DRAGONS_BREATH_2 -1554016 #define SAY_SLAY1 -1554017 @@ -35,18 +38,17 @@ EndScriptData */ #define SPELL_SUMMON_RAGIN_FLAMES 35275 #define H_SPELL_SUMMON_RAGIN_FLAMES 39084 -#define SPELL_FROST_ATTACK 35263 +#define SPELL_FROST_ATTACK 45195 #define SPELL_ARCANE_BLAST 35314 #define SPELL_DRAGONS_BREATH 35250 -#define SPELL_KNOCKBACK 37317 -#define SPELL_SOLARBURN 35267 +//#define SPELL_SOLARBURN 35267 // its an NPC ability, not this boss struct boss_nethermancer_sepethreaAI : public ScriptedAI { boss_nethermancer_sepethreaAI(Creature *c) : ScriptedAI(c), summons(me) { pInstance = c->GetInstanceData(); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; @@ -55,17 +57,15 @@ struct boss_nethermancer_sepethreaAI : public ScriptedAI uint32 arcane_blast_Timer; uint32 dragons_breath_Timer; - uint32 knockback_Timer; - uint32 solarburn_Timer; + uint32 yell_timer; SummonList summons; void Reset() { arcane_blast_Timer = urand(12000, 18000); - dragons_breath_Timer = urand(18000, 22000); - knockback_Timer = urand(22000, 28000); - solarburn_Timer = 30000; + dragons_breath_Timer = urand(22000, 28000); + yell_timer = 5000; pInstance->SetData(DATA_NETHERMANCER_EVENT, NOT_STARTED); @@ -76,19 +76,20 @@ struct boss_nethermancer_sepethreaAI : public ScriptedAI { pInstance->SetData(DATA_NETHERMANCER_EVENT, IN_PROGRESS); - DoScriptText(SAY_AGGRO, m_creature); - AddSpellToCastWithScriptText(HeroicMode ? H_SPELL_SUMMON_RAGIN_FLAMES : SPELL_SUMMON_RAGIN_FLAMES, CAST_SELF, SAY_SUMMON); + DoScriptText(SAY_AGGRO, me); + AddSpellToCast(HeroicMode ? H_SPELL_SUMMON_RAGIN_FLAMES : SPELL_SUMMON_RAGIN_FLAMES, CAST_SELF); } void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); + DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); pInstance->SetData(DATA_NETHERMANCER_EVENT, DONE); + pInstance->SetData(DATA_BRIDGE_EVENT, DONE); summons.DespawnAll(); } @@ -98,10 +99,11 @@ struct boss_nethermancer_sepethreaAI : public ScriptedAI summons.Summon(summoned); } - void DamageMade(Unit * target, uint32 & damage, bool direct) + void DamageMade(Unit* target, uint32 & , bool direct, uint8 school_mask) { - if (direct) - m_creature->CastSpell(target, SPELL_FROST_ATTACK, true); + if (direct && !me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)) + if(roll_chance_i(40)) + me->CastSpell(target, SPELL_FROST_ATTACK, true); } void UpdateAI(const uint32 diff) @@ -110,11 +112,12 @@ struct boss_nethermancer_sepethreaAI : public ScriptedAI if (!UpdateVictim() ) return; - //Arcane Blast + //Arcane Blast with knockback, reducing threat by 50% if (arcane_blast_Timer < diff) { AddSpellToCast(SPELL_ARCANE_BLAST, CAST_TANK); - arcane_blast_Timer = urand(12500, 17500); + arcane_blast_Timer = urand(25000, 35000); + me->getThreatManager().modifyThreatPercent(me->getVictim(), -50.0f); } else arcane_blast_Timer -= diff; @@ -123,28 +126,21 @@ struct boss_nethermancer_sepethreaAI : public ScriptedAI if (dragons_breath_Timer < diff) { AddSpellToCastWithScriptText(SPELL_DRAGONS_BREATH, CAST_TANK, RAND(SAY_DRAGONS_BREATH_1, SAY_DRAGONS_BREATH_2, 0, 0)); - dragons_breath_Timer = urand(12000 ,22000); + dragons_breath_Timer = urand(30000, 35000); } else dragons_breath_Timer -= diff; - //Knockback - if (knockback_Timer < diff) + if(yell_timer) { - AddSpellToCast(SPELL_KNOCKBACK, CAST_TANK); - knockback_Timer = urand(15000, 25000); + if (yell_timer <= diff) + { + DoScriptText(SAY_SUMMON, me); + yell_timer = 0; + } + else + yell_timer -= diff; } - else - knockback_Timer -= diff; - - //Solarburn - if (solarburn_Timer < diff) - { - AddSpellToCast(SPELL_SOLARBURN, CAST_RANDOM); - solarburn_Timer = 30000; - } - else - solarburn_Timer -= diff; CastNextSpellIfAnyAndReady(); DoMeleeAttackIfReady(); @@ -156,8 +152,7 @@ CreatureAI* GetAI_boss_nethermancer_sepethrea(Creature *_Creature) return new boss_nethermancer_sepethreaAI (_Creature); } -#define SPELL_INFERNO 35268 -#define H_SPELL_INFERNO 39346 +#define SPELL_INFERNO 39346 #define SPELL_FIRE_TAIL 35278 struct mob_ragin_flamesAI : public ScriptedAI @@ -165,34 +160,35 @@ struct mob_ragin_flamesAI : public ScriptedAI mob_ragin_flamesAI(Creature *c) : ScriptedAI(c) { pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); + HeroicMode = me->GetMap()->IsHeroic(); } ScriptedInstance *pInstance; bool HeroicMode; - + bool canMelee; uint32 infernoTimer; uint64 currentTarget; void Reset() { - infernoTimer = 10000; + infernoTimer = urand(8000,13000); + canMelee = true; - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); - m_creature->SetSpeed(MOVE_RUN, HeroicMode ? 0.7f : 0.5f); + me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); + me->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); + me->SetSpeed(MOVE_RUN, HeroicMode ? 0.8f : 0.5f); - SetAutocast(SPELL_FIRE_TAIL, 500, false, CAST_SELF); + SetAutocast(SPELL_FIRE_TAIL, HeroicMode ? 700 : 1200, true, CAST_SELF); } void ChangeTarget() { - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0, 5000, true)) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 500, true, me->getVictimGUID())) { Unit * prevTarUnit = me->GetMap()->GetUnit(currentTarget); if (prevTarUnit) - m_creature->AddThreat(prevTarUnit, -5000000.0f); + me->AddThreat(prevTarUnit, -5000000.0f); currentTarget = target->GetGUID(); me->AI()->AttackStart(target); @@ -204,7 +200,25 @@ struct mob_ragin_flamesAI : public ScriptedAI { DoZoneInCombat(); ChangeTarget(); - StartAutocast(); + } + + void OnAuraApply(Aura* aur, Unit* caster, bool stackApply) + { + if (aur->GetId() == SPELL_INFERNO) + { + StopAutocast(); + canMelee = false; + } + } + + void OnAuraRemove(Aura* aur, bool stackApply) + { + if (aur->GetId() == SPELL_INFERNO) + { + StartAutocast(); + ChangeTarget(); + canMelee = true; + } } void UpdateAI(const uint32 diff) @@ -212,20 +226,19 @@ struct mob_ragin_flamesAI : public ScriptedAI if (!UpdateVictim()) return; - DoSpecialThings(diff, DO_COMBAT_N_SPEED, 200.0f, HeroicMode ? 0.7f : 0.5f); + DoSpecialThings(diff, DO_COMBAT_N_SPEED, 200.0f, HeroicMode ? 0.8f : 0.5f); if (infernoTimer < diff) { - AddSpellToCast(HeroicMode ? H_SPELL_INFERNO : SPELL_INFERNO, CAST_SELF); - ChangeTarget(); - - infernoTimer = 10000; + AddSpellToCast(SPELL_INFERNO, CAST_SELF); + infernoTimer = urand(16000,21000); } else infernoTimer -= diff; - CastNextSpellIfAnyAndReady(); - DoMeleeAttackIfReady(); + CastNextSpellIfAnyAndReady(diff); + if(canMelee) + DoMeleeAttackIfReady(); } }; diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp old mode 100755 new mode 100644 similarity index 71% rename from src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp index 16be26e1a..3916687d7 --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp @@ -1,27 +1,31 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Boss Pathaleon the Calculator -SD%Complete: 50 -SDComment: Event missing. Script for himself 99% blizzlike. +SD%Complete: 95 +SDComment: SDCategory: Tempest Keep, The Mechanar EndScriptData */ #include "precompiled.h" +#include "def_mechanar.h" #define SAY_AGGRO -1554020 #define SAY_DOMINATION_1 -1554021 @@ -32,7 +36,7 @@ EndScriptData */ #define SAY_SLAY_2 -1554026 #define SAY_DEATH -1554027 -// Spells to be casted +// Spells to be cast #define SPELL_MANA_TAP 36021 #define SPELL_ARCANE_TORRENT 36022 #define SPELL_DOMINATION 35280 @@ -50,12 +54,15 @@ EndScriptData */ struct boss_pathaleon_the_calculatorAI : public ScriptedAI { - boss_pathaleon_the_calculatorAI(Creature *c) : ScriptedAI(c), summons(m_creature) + boss_pathaleon_the_calculatorAI(Creature *c) : ScriptedAI(c), summons(me) { - HeroicMode = m_creature->GetMap()->IsHeroic(); - m_creature->GetPosition(wLoc); + pInstance = c->GetInstanceData(); + HeroicMode = me->GetMap()->IsHeroic(); + me->GetPosition(wLoc); } + ScriptedInstance *pInstance; + uint32 Summon_Timer; SummonList summons; uint32 ManaTap_Timer; @@ -81,20 +88,26 @@ struct boss_pathaleon_the_calculatorAI : public ScriptedAI Counter = 0; summons.DespawnAll(); + + if (pInstance && pInstance->GetData(DATA_BRIDGE_EVENT) != DONE) + { + me->SetVisibility(VISIBILITY_OFF); + me->SetReactState(REACT_PASSIVE); + } } void EnterCombat(Unit *who) { - DoScriptText(SAY_AGGRO, m_creature); + DoScriptText(SAY_AGGRO, me); } void KilledUnit(Unit* victim) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), m_creature); + DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); } void JustDied(Unit* Killer) { - DoScriptText(SAY_DEATH, m_creature); + DoScriptText(SAY_DEATH, me); summons.DespawnAll(); } @@ -113,17 +126,17 @@ struct boss_pathaleon_the_calculatorAI : public ScriptedAI for(int i = 0; i < 3;i++) { Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - Creature* Wraith = m_creature->SummonCreature(21062,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + Creature* Wraith = me->SummonCreature(21062,me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); if (target && Wraith) Wraith->AI()->AttackStart(target); } - DoScriptText(SAY_SUMMON, m_creature); + DoScriptText(SAY_SUMMON, me); Summon_Timer = 30000 + rand()%15000; }else Summon_Timer -= diff; if(Check_Timer < diff) { - if(!m_creature->IsWithinDistInMap(&wLoc, 30.0f)) + if(!me->IsWithinDistInMap(&wLoc, 30.0f)) EnterEvadeMode(); else DoZoneInCombat(); @@ -134,21 +147,21 @@ struct boss_pathaleon_the_calculatorAI : public ScriptedAI if(ManaTap_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_MANA_TAP); + DoCast(me->getVictim(),SPELL_MANA_TAP); ManaTap_Timer = 14000 + rand()%8000; }else ManaTap_Timer -= diff; if(ArcaneTorrent_Timer < diff) { - DoCast(m_creature->getVictim(),SPELL_ARCANE_TORRENT); + DoCast(me->getVictim(),SPELL_ARCANE_TORRENT); ArcaneTorrent_Timer = 12000 + rand()%6000; }else ArcaneTorrent_Timer -= diff; if(Domination_Timer < diff) { - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, m_creature->getVictimGUID())) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) { - DoScriptText(RAND(SAY_DOMINATION_1, SAY_DOMINATION_2), m_creature); + DoScriptText(RAND(SAY_DOMINATION_1, SAY_DOMINATION_2), me); DoCast(target,SPELL_DOMINATION); } @@ -160,15 +173,15 @@ struct boss_pathaleon_the_calculatorAI : public ScriptedAI { if(ArcaneExplosion_Timer < diff) { - DoCast(m_creature->getVictim(),H_SPELL_ARCANE_EXPLOSION); + DoCast(me->getVictim(),H_SPELL_ARCANE_EXPLOSION); ArcaneExplosion_Timer = 10000 + rand()%4000; }else ArcaneExplosion_Timer -= diff; } - if (!Enraged && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21) + if (!Enraged && me->GetHealth()*100 / me->GetMaxHealth() < 21) { - DoCast(m_creature, SPELL_FRENZY); - DoScriptText(SAY_ENRAGE, m_creature); + DoCast(me, SPELL_FRENZY); + DoScriptText(SAY_ENRAGE, me); Enraged = true; } @@ -212,10 +225,10 @@ struct mob_nether_wraithAI : public ScriptedAI if(ArcaneMissiles_Timer < diff) { - if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, m_creature->getVictimGUID())) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 200, true, me->getVictimGUID())) DoCast(target,SPELL_ARCANE_MISSILES); else - DoCast(m_creature->getVictim(),SPELL_ARCANE_MISSILES); + DoCast(me->getVictim(),SPELL_ARCANE_MISSILES); ArcaneMissiles_Timer = 5000 + rand()%5000; }else ArcaneMissiles_Timer -=diff; @@ -224,7 +237,7 @@ struct mob_nether_wraithAI : public ScriptedAI { if(Detonation_Timer < diff) { - DoCast(m_creature,SPELL_DETONATION); + DoCast(me,SPELL_DETONATION); Detonation = true; }else Detonation_Timer -= diff; } @@ -233,8 +246,8 @@ struct mob_nether_wraithAI : public ScriptedAI { if (Die_Timer < diff) { - m_creature->setDeathState(JUST_DIED); - m_creature->RemoveCorpse(); + me->setDeathState(JUST_DIED); + me->RemoveCorpse(); }else Die_Timer -= diff; } diff --git a/src/scripts/scripts/Outland/tempest_keep/the_mechanar/def_mechanar.h b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/def_mechanar.h new file mode 100644 index 000000000..4c7ee06f3 --- /dev/null +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/def_mechanar.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_DEF_MECHANAR_H +#define SC_DEF_MECHANAR_H + +#define DATA_NETHERMANCER_EVENT 1 +#define DATA_IRONHAND_EVENT 2 +#define DATA_GYROKILL_EVENT 3 +#define DATA_CACHE_OF_LEGION_EVENT 4 +#define DATA_MECHANO_LORD_EVENT 5 +#define DATA_BRIDGE_EVENT 6 + +#define GET_CHARGE_ID(p) ( (p)->HasAura(39088, 0) ? (1) : ( (p)->HasAura(39091, 0) ? (-1) : (0) )) + +#endif + diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/instance_mechanar.cpp old mode 100755 new mode 100644 similarity index 56% rename from src/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp rename to src/scripts/scripts/Outland/tempest_keep/the_mechanar/instance_mechanar.cpp index 852c7fbe2..36a46df7f --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp +++ b/src/scripts/scripts/Outland/tempest_keep/the_mechanar/instance_mechanar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -6,17 +9,17 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* ScriptData SDName: Instance_Mechanar -SD%Complete: 100 +SD%Complete: 99 SDComment: SDCategory: Mechanar EndScriptData */ @@ -24,7 +27,7 @@ EndScriptData */ #include "precompiled.h" #include "def_mechanar.h" -#define ENCOUNTERS 5 +#define ENCOUNTERS 6 #define GO_MOARGDOOR1 184632 #define GO_MOARGDOOR2 184322 @@ -32,6 +35,64 @@ EndScriptData */ #define NPC_IRONHAND 19710 #define NPC_GYROKILL 19218 +#define NPC_PATHALEON 19220 + +#define NPC_ASTROMAGE 19168 +#define NPC_PHYSICIAN 20990 +#define NPC_CENTURION 19510 +#define NPC_ENGINEER 20988 +#define NPC_NETHERBINDER 20059 +#define NPC_FORGE_DESTROYER 19735 + +#define MAX_BRIDGE_LOCATIONS 6 +#define MAX_BRIDGE_TRASH 4 + +#define SPELL_ETHEREAL_TELEPORT 34427 + +#define SAY_PATHALEON_INTRO -1554028 + + +struct SpawnLocation +{ + uint32 m_uiSpawnEntry; + float x, y, z, o; +}; + +static const SpawnLocation BridgeEventLocs[MAX_BRIDGE_LOCATIONS][4] = +{ + { + {NPC_ASTROMAGE, 243.9323f, -24.53621f, 26.3284f, 0}, + {NPC_ASTROMAGE, 240.5847f, -21.25438f, 26.3284f, 0}, + {NPC_PHYSICIAN, 238.4178f, -25.92982f, 26.3284f, 0}, + {NPC_CENTURION, 237.1122f, -19.14261f, 26.3284f, 0}, + }, + { + {NPC_FORGE_DESTROYER, 199.945f, -22.85885f, 24.95783f, 0}, + {0, 0, 0, 0, 0}, + }, + { + {NPC_ENGINEER, 179.8642f, -25.84609f, 24.8745f, 0}, + {NPC_ENGINEER, 181.9983f, -17.56084f, 24.8745f, 0}, + {NPC_PHYSICIAN, 183.4078f, -22.46612f, 24.8745f, 0}, + {0, 0, 0, 0, 0}, + }, + { + {NPC_ENGINEER, 141.0496f, 37.86048f, 24.87399f, 4.65f}, + {NPC_ASTROMAGE, 137.6626f, 34.89631f, 24.8742f, 4.65f}, + {NPC_PHYSICIAN, 135.3587f, 38.03816f, 24.87417f, 4.65f}, + {0, 0, 0, 0, 0}, + }, + { + {NPC_FORGE_DESTROYER, 137.8275f, 53.18128f, 24.95783f, 4.65f}, + {0, 0, 0, 0, 0}, + }, + { + {NPC_PHYSICIAN, 134.3062f, 109.1506f, 26.45663f, 4.65f}, + {NPC_ASTROMAGE, 135.3307f, 99.96439f, 26.45663f, 4.65f}, + {NPC_NETHERBINDER, 141.3976f, 102.7863f, 26.45663f, 4.65f}, + {NPC_ENGINEER, 140.8281f, 112.0363f, 26.45663f, 4.65f}, + }, +}; struct instance_mechanar : public ScriptedInstance { @@ -42,11 +103,48 @@ struct instance_mechanar : public ScriptedInstance uint64 MoargDoor1; uint64 MoargDoor2; uint64 NethermancerDoor; + uint64 PathaleonGUID; uint32 CheckTimer; bool CleanupCharges; + uint32 BridgeEventTimer; + uint32 EventTimer; + uint8 BridgeEventPhase; + + std::list BridgeTrashGuidList; + + void Initialize() + { + for(uint8 i = 0; i < ENCOUNTERS; ++i) + Encounters[i] = NOT_STARTED; + + Heroic = instance->IsHeroic(); + MoargDoor1 = 0; + MoargDoor2 = 0; + NethermancerDoor = 0; + PathaleonGUID = 0; + CheckTimer = 3000; + CleanupCharges = false; + BridgeEventTimer = 0; + BridgeEventPhase = 0; + EventTimer = 0; + BridgeTrashGuidList.clear(); + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) + return true; + + return false; + } void OnCreatureCreate (Creature *creature, uint32 creature_entry) { + switch (creature->GetEntry()) + { + case NPC_PATHALEON: PathaleonGUID = creature->GetGUID(); break; + } } void OnObjectCreate(GameObject* go) @@ -70,28 +168,6 @@ struct instance_mechanar : public ScriptedInstance } } - void Initialize() - { - for(uint8 i = 0; i < ENCOUNTERS; ++i) - Encounters[i] = NOT_STARTED; - - Heroic = instance->IsHeroic(); - MoargDoor1 = 0; - MoargDoor2 = 0; - NethermancerDoor = 0; - CheckTimer = 3000; - CleanupCharges = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) - return true; - - return false; - } - uint32 GetData(uint32 type) { switch(type) @@ -101,6 +177,7 @@ struct instance_mechanar : public ScriptedInstance case DATA_GYROKILL_EVENT: return Encounters[2]; case DATA_CACHE_OF_LEGION_EVENT: return Encounters[3]; case DATA_MECHANO_LORD_EVENT: return Encounters[4]; + case DATA_BRIDGE_EVENT: return Encounters[5]; } return false; @@ -116,6 +193,9 @@ struct instance_mechanar : public ScriptedInstance switch(type) { case DATA_NETHERMANCER_EVENT: + if (data == DONE) + BridgeEventTimer = 10000; + if(Encounters[0] != DONE) { Encounters[0] = data; @@ -151,11 +231,70 @@ struct instance_mechanar : public ScriptedInstance if(data == DONE) CleanupCharges = true; break; + case DATA_BRIDGE_EVENT: + if(Encounters[5] != DONE) + Encounters[5] = data; + break; } if(data == DONE) SaveToDB(); } + void DoSpawnBridgeWave() + { + if (BridgeEventPhase > MAX_BRIDGE_LOCATIONS) + return; + if (Player* player = instance->GetPlayers().begin()->getSource()) + { + switch (BridgeEventPhase) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + for (uint8 i = 0; i < MAX_BRIDGE_TRASH; ++i) + { + if (BridgeEventLocs[BridgeEventPhase][i].m_uiSpawnEntry == 0) + break; + + if (Creature* temp = player->SummonCreature(BridgeEventLocs[BridgeEventPhase][i].m_uiSpawnEntry, BridgeEventLocs[BridgeEventPhase][i].x, BridgeEventLocs[BridgeEventPhase][i].y, BridgeEventLocs[BridgeEventPhase][i].z, BridgeEventLocs[BridgeEventPhase][i].o, TEMPSUMMON_DEAD_DESPAWN, 0)) + { + BridgeTrashGuidList.push_back(temp->GetGUID()); + temp->CastSpell(temp, SPELL_ETHEREAL_TELEPORT, false); + + switch (BridgeEventPhase) + { + case 1: + case 2: + case 3: + case 4: + case 5: + if (player->isAlive()) + temp->AI()->AttackStart(player); + break; + } + } + } + break; + case 6: + if (Creature* Pathaleon = instance->GetCreature(PathaleonGUID)) + { + Pathaleon->SetVisibility(VISIBILITY_ON); + Pathaleon->SetReactState(REACT_AGGRESSIVE); + Pathaleon->CastSpell(Pathaleon, SPELL_ETHEREAL_TELEPORT, false); + DoScriptText(SAY_PATHALEON_INTRO, Pathaleon, player); + BridgeEventTimer = 0; + EventTimer = 0; + } + break; + } + ++BridgeEventPhase; + } + + } + void Update(uint32 diff) { if(Heroic && GetData(DATA_MECHANO_LORD_EVENT) == IN_PROGRESS) @@ -208,6 +347,56 @@ struct instance_mechanar : public ScriptedInstance CleanupCharges = false; } + if (BridgeEventTimer) + { + if (BridgeEventTimer <= diff) + { + DoSpawnBridgeWave(); + BridgeEventTimer = 0; + EventTimer = 2000; + + if (GetData(DATA_BRIDGE_EVENT) != DONE) + SetData(DATA_BRIDGE_EVENT, DONE); + } + else + BridgeEventTimer -= diff; + } + + if (EventTimer) + { + if (EventTimer <= diff) + { + bool alive = false; + for (std::list::iterator itr = BridgeTrashGuidList.begin(); itr != BridgeTrashGuidList.end(); ++itr) + { + if (Creature *tmp = instance->GetCreature(*itr)) + { + if (tmp->isAlive()) + { + alive = true; + break; + } + } + } + + EventTimer = 2000; + + if (!alive) + { + if (BridgeEventPhase == 3) + { + BridgeEventTimer = 10000; + EventTimer = 0; + return; + } + else + DoSpawnBridgeWave(); + } + + } + else + EventTimer -= diff; + } } std::string GetSaveData() @@ -217,7 +406,10 @@ struct instance_mechanar : public ScriptedInstance std::ostringstream stream; stream << Encounters[0] << " "; stream << Encounters[1] << " "; - stream << Encounters[2]; + stream << Encounters[2] << " "; + stream << Encounters[3] << " "; + stream << Encounters[4] << " "; + stream << Encounters[5]; OUT_SAVE_INST_DATA_COMPLETE; @@ -232,11 +424,14 @@ struct instance_mechanar : public ScriptedInstance return; } OUT_LOAD_INST_DATA(in); + std::istringstream stream(in); - stream >> Encounters[0] >> Encounters[1] >> Encounters[2]; + stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] >> Encounters[4] >> Encounters[5]; + for(uint8 i = 0; i < ENCOUNTERS; ++i) if(Encounters[i] == IN_PROGRESS) Encounters[i] = NOT_STARTED; + OUT_LOAD_INST_DATA_COMPLETE; } }; diff --git a/src/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp b/src/scripts/scripts/Outland/terokkar_forest/terokkar_forest.cpp old mode 100755 new mode 100644 similarity index 97% rename from src/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp rename to src/scripts/scripts/Outland/terokkar_forest/terokkar_forest.cpp index c415077df..06f4091ac --- a/src/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp +++ b/src/scripts/scripts/Outland/terokkar_forest/terokkar_forest.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -494,7 +497,7 @@ bool GossipHello_go_skull_pile(Player *player, GameObject* go) void SendActionMenu_go_skull_pile(Player *player, GameObject* go, uint32 action) { - // GO should be despawned by spell casted below, but it's not working :( + // GO should be despawned by spell cast below, but it's not working :( if(player->HasItemCount(32620, 10)) { go->SetGoState(GO_STATE_ACTIVE); @@ -594,8 +597,12 @@ float skyguardWPStart[3][2] = { { -3807, 3496 } }; -float skyguardWPMiddle[3] = { - -3785, 3507, 315 +#define SKYGUARD_WP_MIDDLE_MAX 4 +float skyguardWPMiddle[4][3] = { + {-3785, 3507, 315}, + {-3798, 3500, 316}, + {-3798, 3515, 308}, + {-3786, 3515, 314} }; float skyguardWPs[6][2] = { @@ -766,8 +773,10 @@ struct mob_terokkAI : public ScriptedAI if(SkyguardFlare_Timer < diff) { - if(Creature *skyguard = Creature::GetCreature(*me, SkyguardGUIDs[skyguardTurn++])) - skyguard->GetMotionMaster()->MovePoint(SKYGUARD_WP_MIDDLE, skyguardWPMiddle[0], skyguardWPMiddle[1], skyguardWPMiddle[2]); + if(Creature *skyguard = Creature::GetCreature(*me, SkyguardGUIDs[skyguardTurn++])){ + uint32 i = rand() % SKYGUARD_WP_MIDDLE_MAX; + skyguard->GetMotionMaster()->MovePoint(SKYGUARD_WP_MIDDLE, skyguardWPMiddle[i][0], skyguardWPMiddle[i][1], skyguardWPMiddle[i][2]); + } skyguardTurn %= 3; SkyguardFlare_Timer = 20000; } @@ -796,8 +805,8 @@ struct npc_skyguard_aceAI : public ScriptedAI uint64 TargetGUID; uint32 TargetLifetime; - uint32 AncientFlame_Timer; - uint32 Move_Timer; + int32 AncientFlame_Timer; + int32 Move_Timer; int NextWP; void Reset() @@ -847,7 +856,7 @@ struct npc_skyguard_aceAI : public ScriptedAI creature->GetPosition(x, y, z); z = groundAltitiude; creature->Relocate(x, y, z); - creature->CastSpell(creature, SPELL_SKYGUARD_FLARE_TARGET, true); + creature->CastSpell(creature, SPELL_SKYGUARD_FLARE_TARGET, false); TargetGUID = creature->GetGUID(); TargetLifetime = 20500; AncientFlame_Timer = 5500; @@ -876,11 +885,14 @@ struct npc_skyguard_aceAI : public ScriptedAI { if(Move_Timer < diff) { - me->GetMotionMaster()->MovePoint(NextWP, skyguardWPs[NextWP][0], skyguardWPs[NextWP][1], skyguardAltitude); + if (me->GetMotionMaster()->empty()) + me->GetMotionMaster()->MovePoint(NextWP, skyguardWPs[NextWP][0], skyguardWPs[NextWP][1], skyguardAltitude); Move_Timer = -1; } - else + else{ Move_Timer -= diff; + Move_Timer = Move_Timer < 0 ? 0 : Move_Timer; + } } if(AncientFlame_Timer >= 0) @@ -1762,10 +1774,10 @@ struct npc_razorthorn_ravagerAI : public ScriptedAI me->GetMotionMaster()->MoveFollow(me->GetCharmer(),PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); if(GameObject* go = FindGameObject(GAMEOBJECT_RAZORTHORN_DIRT_MOUND, 15, me)) { - if(me->GetCharmer()->GetTypeId() == TYPEID_PLAYER) + if(me->GetCharmer() && me->GetCharmer()->GetTypeId() == TYPEID_PLAYER) { MoundList.push_front(go->GetGUID()); - //go->DestroyForPlayer(((Player*)me->GetCharmer())); + go->DestroyForPlayer(((Player*)me->GetCharmer())); checked = false; } } @@ -1844,7 +1856,7 @@ struct quest_the_vengeful_harbringerAI : public ScriptedAI if (Creature * Boss = Portal_Trigger->SummonCreature(21638, Portal_Trigger->GetPositionX(), Portal_Trigger->GetPositionY(), Portal_Trigger->GetPositionZ(), Portal_Trigger->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 180000)) { - Event_Trigger_B->GetClosePoint(x, y, z, 5.0f); + Event_Trigger_B->GetNearPoint(x, y, z, 5.0f); Boss->GetMotionMaster()->MovePoint(1,x,y,z); } } @@ -1870,7 +1882,7 @@ struct quest_the_vengeful_harbringerAI : public ScriptedAI if (!Trash1 || !Trash2 || !Trash3) return; - Event_Trigger_B->GetClosePoint(x, y, z, 5.0f); + Event_Trigger_B->GetNearPoint(x, y, z, 5.0f); Trash1->GetMotionMaster()->MovePoint(1, x, y, z); Trash2->GetMotionMaster()->MovePoint(1, x +5.0f, y, z); @@ -2311,26 +2323,20 @@ static WP W[]= { {-2464.39f, 5398.43f, 2.12f}, {-2485.65f, 5382.77f, 0.11f}, - {-2464.22f, 5402.19f, 2.16f}, {-2542.65f, 5482.23f, 8.25f}, {-2520.57f, 5447.79f, 0.12f}, - {-2545.31f, 5484.29f, 8.34f}, {-2582.34f, 5425.01f, 26.85f}, {-2561.75f, 5439.09f, 27.16f}, - {-2579.22f, 5430.93f, 28.04f}, {-2528.63f, 5387.37f, 27.65f}, - {-2550.72f, 5404.97f, 20.00f}, - {-2526.76f, 5384.53f, 28.09f} + {-2550.72f, 5404.97f, 20.00f} }; struct npc_captive_childAI : public npc_escortAI { npc_captive_childAI(Creature* creature) : npc_escortAI(creature) { Reset(); } - void Reset() - { - me->SetVisibility(VISIBILITY_ON); //??? - } + void Reset() {} + //if you add more children .add GUID here. uint32 WaypointID() { @@ -2370,25 +2376,21 @@ struct npc_captive_childAI : public npc_escortAI case 1: AddWaypoint(0, W[0].x+(rand()%4), W[0].y-(rand()%4), W[0].z, 3000); AddWaypoint(1, W[1].x, W[1].y, W[1].z); - AddWaypoint(2, W[2].x, W[2].y, W[2].z); Start(false, true, player->GetGUID()); break; case 2: - AddWaypoint(0, W[3].x+(rand()%4), W[3].y-(rand()%4), W[3].z, 3000); - AddWaypoint(1, W[4].x, W[4].y, W[4].z); - AddWaypoint(2, W[5].x, W[5].y, W[5].z); + AddWaypoint(0, W[2].x+(rand()%4), W[2].y-(rand()%4), W[2].z, 3000); + AddWaypoint(1, W[3].x, W[3].y, W[3].z); Start(false, true, player->GetGUID()); break; case 3: - AddWaypoint(0, W[6].x+(rand()%4), W[6].y-(rand()%4), W[6].z, 3000); - AddWaypoint(1, W[7].x, W[7].y, W[7].z); - AddWaypoint(2, W[8].x, W[8].y, W[8].z); + AddWaypoint(0, W[4].x+(rand()%4), W[4].y-(rand()%4), W[4].z, 3000); + AddWaypoint(1, W[5].x, W[5].y, W[5].z); Start(false, true, player->GetGUID()); break; case 4: - AddWaypoint(0, W[9].x+(rand()%4), W[9].y-(rand()%4), W[9].z, 3000); - AddWaypoint(1, W[10].x, W[10].y, W[10].z); - AddWaypoint(2, W[11].x, W[11].y, W[11].z); + AddWaypoint(0, W[6].x+(rand()%4), W[6].y-(rand()%4), W[6].z, 3000); + AddWaypoint(1, W[7].x, W[7].y, W[7].z); Start(false, true, player->GetGUID()); break; } @@ -2420,9 +2422,6 @@ struct npc_captive_childAI : public npc_escortAI } break; case 1: - me->SetVisibility(VISIBILITY_OFF); //??? strange bug and we need wp2(home). - break; - case 2: me->ForcedDespawn(); break; } diff --git a/src/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp b/src/scripts/scripts/Outland/zangarmarsh/zangarmarsh.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp rename to src/scripts/scripts/Outland/zangarmarsh/zangarmarsh.cpp index 25b2ebf39..d61d7a458 --- a/src/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp +++ b/src/scripts/scripts/Outland/zangarmarsh/zangarmarsh.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/boss/boss_emeriss.cpp b/src/scripts/scripts/boss/boss_emeriss.cpp index 6c955390f..8f97c9a1b 100755 --- a/src/scripts/scripts/boss/boss_emeriss.cpp +++ b/src/scripts/scripts/boss/boss_emeriss.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/boss/boss_hogger.cpp b/src/scripts/scripts/boss/boss_hogger.cpp new file mode 100644 index 000000000..5857b7457 --- /dev/null +++ b/src/scripts/scripts/boss/boss_hogger.cpp @@ -0,0 +1,46 @@ + +#include "precompiled.h" + +#define START_SAY_1 -5 +#define START_SAY_2 -6 + +#define SPELL_HEAD_BUTT 6730 +#define SPELL_RUSHING_CHARGE 6268 +#define SPELL_PIERCE_ARMOR 6016 + +struct boss_hoggerAI : public ScriptedAI +{ + boss_hoggerAI(Creature *c) : ScriptedAI(c) {} + + void EnterCombat(Unit* who) + { + m_creature->Yell(RAND(START_SAY_1,START_SAY_2),0,0); + } + + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + if (!m_creature->IsWithinMeleeRange(m_creature->getVictim()) && !m_creature->HasAura(SPELL_RUSHING_CHARGE)) + DoCast(m_creature,SPELL_RUSHING_CHARGE); + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_hogger(Creature *_Creature) +{ + return new boss_hoggerAI (_Creature); +} + +void AddSC_boss_hogger() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_hogger_the"; + newscript->GetAI = &GetAI_boss_hogger; + newscript->RegisterSelf(); + +} \ No newline at end of file diff --git a/src/scripts/scripts/boss/boss_lethon.cpp b/src/scripts/scripts/boss/boss_lethon.cpp index 721009ac6..d7595e65c 100755 --- a/src/scripts/scripts/boss/boss_lethon.cpp +++ b/src/scripts/scripts/boss/boss_lethon.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/boss/boss_taerar.cpp b/src/scripts/scripts/boss/boss_taerar.cpp index 3910d319c..f4a601816 100755 --- a/src/scripts/scripts/boss/boss_taerar.cpp +++ b/src/scripts/scripts/boss/boss_taerar.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/boss/boss_ysondre.cpp b/src/scripts/scripts/boss/boss_ysondre.cpp index ab004615f..c727f5208 100755 --- a/src/scripts/scripts/boss/boss_ysondre.cpp +++ b/src/scripts/scripts/boss/boss_ysondre.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/guard/guard_ai.h b/src/scripts/scripts/guard/guard_ai.h deleted file mode 100755 index 228a9fcdc..000000000 --- a/src/scripts/scripts/guard/guard_ai.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_GUARDAI_H -#define SC_GUARDAI_H - -#define GENERIC_CREATURE_COOLDOWN 5000 - -struct guardAI : public ScriptedAI -{ - guardAI(Creature *c) : ScriptedAI(c) {} - - uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) - uint32 BuffTimer; //This variable keeps track of buffs - - void Reset(); - - void EnterCombat(Unit *who); - - void JustDied(Unit *Killer); - - void UpdateAI(const uint32 diff); -}; -#endif - diff --git a/src/scripts/scripts/areatrigger/areatrigger_scripts.cpp b/src/scripts/scripts/special/areatrigger_scripts.cpp old mode 100755 new mode 100644 similarity index 86% rename from src/scripts/scripts/areatrigger/areatrigger_scripts.cpp rename to src/scripts/scripts/special/areatrigger_scripts.cpp index a0115e6a9..35b1c70be --- a/src/scripts/scripts/areatrigger/areatrigger_scripts.cpp +++ b/src/scripts/scripts/special/areatrigger_scripts.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -118,6 +121,18 @@ bool AreaTrigger_at_nats_landing(Player* player, AreaTriggerEntry const* trigger return false; } +/*##### +## at_eredar_twins +#####*/ + +bool AreaTrigger_at_eredar_twins(Player* player, AreaTriggerEntry const* trigger) +{ + Unit* Alythess = FindCreature(25166, 50, player); + if(Alythess) + Alythess->ToCreature()->AI()->SetData(1, 1); // just to trigger intro event + return false; +} + void AddSC_areatrigger_scripts() { Script *newscript; @@ -137,5 +152,9 @@ void AddSC_areatrigger_scripts() newscript->pAreaTrigger = &AreaTrigger_at_nats_landing; newscript->RegisterSelf(); + newscript = new Script; + newscript->Name = "at_eredar_twins"; + newscript->pAreaTrigger = &AreaTrigger_at_eredar_twins; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/custom/custom_example.cpp b/src/scripts/scripts/special/custom_example.cpp old mode 100755 new mode 100644 similarity index 98% rename from src/scripts/scripts/custom/custom_example.cpp rename to src/scripts/scripts/special/custom_example.cpp index 286c023b9..7f2654fad --- a/src/scripts/scripts/custom/custom_example.cpp +++ b/src/scripts/scripts/special/custom_example.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/custom/custom_gossip_codebox.cpp b/src/scripts/scripts/special/custom_gossip_codebox.cpp old mode 100755 new mode 100644 similarity index 95% rename from src/scripts/scripts/custom/custom_gossip_codebox.cpp rename to src/scripts/scripts/special/custom_gossip_codebox.cpp index 2e5d5516a..369aefeea --- a/src/scripts/scripts/custom/custom_gossip_codebox.cpp +++ b/src/scripts/scripts/special/custom_gossip_codebox.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/go/go_scripts.cpp b/src/scripts/scripts/special/go_scripts.cpp old mode 100755 new mode 100644 similarity index 53% rename from src/scripts/scripts/go/go_scripts.cpp rename to src/scripts/scripts/special/go_scripts.cpp index 6f4b15f4c..d2e960ef5 --- a/src/scripts/scripts/go/go_scripts.cpp +++ b/src/scripts/scripts/special/go_scripts.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +20,7 @@ /* ScriptData SDName: GO_Scripts SD%Complete: 100 -SDComment: Quest support: 4285,4287,4288(crystal pylons), 4296. Field_Repair_Bot->Teaches spell 22704. Barov_journal->Teaches spell 26089 +SDComment: Quest support: 4285,4287,4288(crystal pylons), 4296. Field_Repair_Bot->Teaches spell 22704. Barov_journal->Teaches spell 26089, 8620 SDCategory: Game Objects EndScriptData */ @@ -42,6 +45,7 @@ go_field_repair_bot_74A go_teleporter go_hive_pod go_ethereum_transponder_zeta +go_draconic_for_dummies EndContentData */ #include "precompiled.h" @@ -220,12 +224,11 @@ bool GOUse_go_sacred_fire_of_life(Player* pPlayer, GameObject* pGO) ## go_crystalforge ######*/ -#define GOSSIP_ITEM_BEAST_1 "[PH] Create 1 x Flask of Beast" -#define GOSSIP_ITEM_BEAST_5 "[PH] Create 5 x Flask of Beast" - -#define GOSSIP_ITEM_SORCERER_1 "[PH] Create 1 x Flask of Sorcerer" -#define GOSSIP_ITEM_SORCERER_5 "[PH] Create 5 x Flask of Sorcerer" - +#define ITEM_APEXIS_SHARD 32569 +#define GOSSIP_ITEM_BEAST_1 "Purchase 1 Unstable Flask of the Beast for the cost of 10 Apexis Shards" +#define GOSSIP_ITEM_BEAST_5 "Purchase 5 Unstable Flask of the Beast for the cost of 50 Apexis Shards" +#define GOSSIP_ITEM_SORCERER_1 "Purchase 1 Unstable Flask of the Sorcerer for the cost of 10 Apexis Shards" +#define GOSSIP_ITEM_SORCERER_5 "Purchase 5 Unstable Flask of the Sorcerer for the cost of 50 Apexis Shards" enum FELFORGE { @@ -262,17 +265,23 @@ bool GOGossipSelect_go_crystalforge(Player* pPlayer, GameObject* pGO, uint32 Sen switch(action) { case GOSSIP_ACTION_INFO_DEF+1: - pPlayer->CastSpell(pPlayer,(pGO->GetEntry() == 185919) + if (pPlayer->HasItemCount(ITEM_APEXIS_SHARD, 10)) + { + pPlayer->CastSpell(pPlayer,(pGO->GetEntry() == 185919) ? uint32(SPELL_CREATE_1_FLASK_OF_BEAST) : uint32(SPELL_CREATE_1_FLASK_OF_SORCERER) , false); - break; + } + break; case GOSSIP_ACTION_INFO_DEF+2: - pPlayer->CastSpell(pPlayer,(pGO->GetEntry() == 185919) + if (pPlayer->HasItemCount(ITEM_APEXIS_SHARD, 50)) + { + pPlayer->CastSpell(pPlayer,(pGO->GetEntry() == 185919) ? uint32(SPELL_CREATE_5_FLASK_OF_BEAST) : uint32(SPELL_CREATE_5_FLASK_OF_SORCERER), false); - break; + } + break; } pPlayer->CLOSE_GOSSIP_MENU(); @@ -446,7 +455,7 @@ bool GOUse_go_ethereum_transponder_zeta(Player* pPlayer, GameObject* pGO) { pGO->UseDoorOrButton(60); pPlayer->SummonCreature(NPC_AMEER, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+1, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 60000); - + return true; } @@ -460,99 +469,364 @@ bool GOUse_go_ethereal_teleport_pad(Player* pPlayer, GameObject* pGO) { pGO->UseDoorOrButton(60); pPlayer->SummonCreature(NPC_MARID, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+1, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 60000); - + + return true; +} + +/*###### +## go_fel_crystal_prism +######*/ + +#define GOSSIP_ITEM_1 "Insert 35 Apexis Shards!" + +enum +{ + NPC_BRAXXUS = 23353, + NPC_INCINERATOR = 23354, + NPC_GALVANOTH = 22281, + NPC_ZARCSIN = 23355, + + ITEM_APEX_SHARD = 32569 +}; + +bool GOUse_go_fel_crystal_prism(Player* pPlayer, GameObject* pGO) +{ + if (pPlayer->HasItemCount(ITEM_APEX_SHARD, 35) && pPlayer->GetQuestStatus(11079) == QUEST_STATUS_INCOMPLETE) + pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + pPlayer->SEND_GOSSIP_MENU(pGO->GetGOInfo()->questgiver.gossipID, pGO->GetGUID()); return true; } +bool GOGossipSelect_go_fel_crystal_prism(Player* pPlayer, GameObject* pGO, uint32 Sender, uint32 action) +{ + switch (urand(0,3)) + { + case 0: + pGO->SummonCreature(NPC_BRAXXUS, pGO->GetPositionX()+(rand()%4), pGO->GetPositionY()-(rand()%4), pGO->GetPositionZ()-(rand()%4), pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 1: + pGO->SummonCreature(NPC_INCINERATOR, pGO->GetPositionX()+(rand()%4), pGO->GetPositionY()-(rand()%4), pGO->GetPositionZ()-(rand()%4), pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 2: + pGO->SummonCreature(NPC_GALVANOTH, pGO->GetPositionX()+(rand()%4), pGO->GetPositionY()-(rand()%4), pGO->GetPositionZ()-(rand()%4), pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 3: + pGO->SummonCreature(NPC_ZARCSIN, pGO->GetPositionX()+(rand()%4), pGO->GetPositionY()-(rand()%4), pGO->GetPositionZ()-(rand()%4), pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + + pPlayer->DestroyItemCount(ITEM_APEX_SHARD, 35, true); + pPlayer->CLOSE_GOSSIP_MENU(); + return true; +} + +/*###### +## go_rule_skies +######*/ + +enum +{ + NPC_RIVENDARK = 23061, + NPC_OBSIDIA = 23282, + NPC_FURYWING = 23261, + NPC_INSIDION = 23281 +}; + +bool GOUse_go_rule_skies(Player* pPlayer, GameObject* pGO) +{ + if (pPlayer->HasItemCount(32569, 35)) + { + pPlayer->DestroyItemCount(32569, 35, true); + switch(pGO->GetEntry()) + { + case 185936: + pGO->SummonCreature(NPC_RIVENDARK, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+10.0f, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 185932: + pGO->SummonCreature(NPC_OBSIDIA, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+10.0f, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 185937: + pGO->SummonCreature(NPC_FURYWING, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+10.0f, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + case 185938: + pGO->SummonCreature(NPC_INSIDION, pGO->GetPositionX(), pGO->GetPositionY(), pGO->GetPositionZ()+10.0f, pGO->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + break; + } + pGO->SetLootState(GO_JUST_DEACTIVATED); + } + pPlayer->CLOSE_GOSSIP_MENU(); + return true; +} + +/*###### +## go_draconic_for_dummies +######*/ + +#define GOSSIP_BOOK_HELLO "" +#define QUEST_THE_ONLY_PRESCRIPTION 8620 +#define GOB_DRACONIC_BOOK_STORMWIND 180665 +#define GOB_DRACONIC_BOOK_UNDERCITY 180666 +#define GOB_DRACONIC_BOOK_BLACKWING_LAIR 180667 +#define ITEM_DRACONIC_BOOK_STORMWIND 21107 +#define ITEM_DRACONIC_BOOK_UNDERCITY 21106 +#define ITEM_DRACONIC_BOOK_BLACKWING_LAIR 21109 + +bool GOUse_go_draconic_for_dummies(Player* pPlayer, GameObject* pGO) +{ + if (pPlayer->GetQuestStatus(QUEST_THE_ONLY_PRESCRIPTION) == QUEST_STATUS_INCOMPLETE) + { + switch (pGO->GetEntry()) + { + case GOB_DRACONIC_BOOK_STORMWIND: + if (!pPlayer->HasItemCount(ITEM_DRACONIC_BOOK_STORMWIND,1)) + break; + else + return true; + case GOB_DRACONIC_BOOK_UNDERCITY: + if (!pPlayer->HasItemCount(ITEM_DRACONIC_BOOK_UNDERCITY,1)) + break; + else + return true; + case GOB_DRACONIC_BOOK_BLACKWING_LAIR: + if (!pPlayer->HasItemCount(ITEM_DRACONIC_BOOK_BLACKWING_LAIR,1)) + break; + else + return true; + default: + return true; + } + pPlayer->ADD_GOSSIP_ITEM(NULL, GOSSIP_BOOK_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(50010, pGO->GetGUID()); + } + return true; +} + +bool GOGossipSelect_go_draconic_for_dummies(Player* pPlayer, GameObject* pGO, uint32 Sender, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + { + uint32 ItemId; + switch (pGO->GetEntry()) + { + case GOB_DRACONIC_BOOK_STORMWIND: + ItemId = ITEM_DRACONIC_BOOK_STORMWIND; + break; + case GOB_DRACONIC_BOOK_UNDERCITY: + ItemId = ITEM_DRACONIC_BOOK_UNDERCITY; + break; + case GOB_DRACONIC_BOOK_BLACKWING_LAIR: + ItemId = ITEM_DRACONIC_BOOK_BLACKWING_LAIR; + break; + default: + return true; + } + ItemPosCountVec dest; + uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ItemId, 1); + if (msg == EQUIP_ERR_OK) + { + Item* item = pPlayer->StoreNewItem(dest, ItemId, true); + pPlayer->SendNewItem(item,1,true,false,true); + } + break; + } + } + pPlayer->CLOSE_GOSSIP_MENU(); + return true; +} + +const char* ImpInABottleQuotes[] = +{ + "Hey! You try telling the future when someone's shaking up your house!", + "I don't think so, boss.", + "The answer's yes in here, don't see why it'd be different out there!", + "I suppose.", + "It's as sure as the warts on my backside", + "Yes, unless I have anything to do with it", + "Jump three times and dance for ten minutes and it will definitely happen!", + "My sources say \"no\". Before the torture, that is.", + "Definitely.", + "I can't see why not, although, I can't see a lot of things right now.", + "Yes, it will rain. That's not what you asked? Too bad!", + "My fortune telling powers are immeasureable - your chances are though: NO CHANCE", + "The odds are 32.33 [repeating of course] percent change of success.", + "Didn't you already ask that once? Yes already!", + "Avoid taking unnecessary gambles. Your lucky numbers are two, two and a half, and eleven-teen.", + "When Blackrock Freezes over", + "Survey says: BZZZZT!", + "Imp in a ball is ignoring you.", + "Hey! You try arranging furniture with some jerk shaking your house", + "Yes, but if anyone else asks... it wasn't me who told you", + "Hahahahahah, you're kidding right?", + "Sure but you're not going to like it.", + "I don't have to be a fortune-telling imp to know the answer to that one - No!", + "Yes, now stop pestering me", + "Yes! I mean no! I mean... which answer will get me out of here?", + "When dwarves fly. Oh they do? Then yes.", + "Want to trade places?", + "You remember that time you tried to drill that hole in your head?", + "What happens in the twisting nether, stays in the twisting nether.", + "Yes, yes, a thousand times, yes already!", + "Not unless you're some kind of super-person. And don't kid yourself, you're not.", + "NO - and don't try shaking me again for a better answer!", + "Yes, but I hoped I would never have to answer that", + "Word on the peninsula is YES!", + "Oh, that's one for sure.", + "Do you ask this question to everything that's trapped in a ball?", + "I ask myself that question everyday.", + "Da King! Chort ready to serve.", + "Are you making fun of me?", + "It's like my mother always said: \"Razxx khaj jhashxx xashjx.\"", + "It pains me to say this, but \"Yes\".", + "This was NOT in my contract!", + "It's times like these that I wish I had a cooldown.", + "Are you my pal, Danny?", + "Wouldn't you like to know?", + "That's about as likely as me getting a date with a succubuss.", + "Yes, it will rain. That's not what you asked? Too bad!", + "Please... is Kil'jaeden red?", + "You should be asking \"Is that rogue behind me going to kill me?\"", + "Yes, is my answer..........NOT!", + "Yeah, sure. You just keep thinking that.", + "XRA RAHKI MAZIZRA!", + "What kind of imp do you think I am?", + "Three Words - \"ab - so - lutely\"!", + "Looks good for you...and bad for me.", + "You need Arcane Intellect, because that answer is obvious! NO!", + "Ruk!", + "It won't matter, you'll be dead by tomorrow.", + "I can make that happen. Just sign below the dotted line...", + "The outlook is very bad for YOU that is! Haha, take it!", + "I've consulted my fellow imps, and we think YES, except for that one imp." +}; + +bool GOUse_go_imp_in_a_bottle(Player* player, GameObject* go) +{ + if (go == nullptr || player == nullptr || !go->IsInWorld() || !player->IsInWorld()) + return false; + + go->Whisper(ImpInABottleQuotes[urand(0, (sizeof(ImpInABottleQuotes)/sizeof(char*)) -1)], player->GetGUID()); + return true; +}; + +bool GOUse_go_personal_mole_machine(Player* player, GameObject* go) +{ + if (go == nullptr || player == nullptr || !go->IsInWorld() || !player->IsInWorld()) + return false; + + Unit* owner = go->GetOwner(); + if (!owner || !owner->IsInWorld()) + return false; + + if (player->IsInRaidWith(owner)) + { + WorldLocation location(230, 446.82f, 21.14f, -70.65f, 5.28f); + player->TeleportTo(location); + } + return true; +}; + void AddSC_go_scripts() { Script *newscript; newscript = new Script; newscript->Name="go_northern_crystal_pylon"; - newscript->pGOUse = &GOUse_go_northern_crystal_pylon; + newscript->pGOUse = &GOUse_go_northern_crystal_pylon; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_imp_in_a_bottle"; + newscript->pGOUse = &GOUse_go_imp_in_a_bottle; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="go_personal_mole_machine"; + newscript->pGOUse = &GOUse_go_personal_mole_machine; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_eastern_crystal_pylon"; - newscript->pGOUse = &GOUse_go_eastern_crystal_pylon; + newscript->pGOUse = &GOUse_go_eastern_crystal_pylon; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_western_crystal_pylon"; - newscript->pGOUse = &GOUse_go_western_crystal_pylon; + newscript->pGOUse = &GOUse_go_western_crystal_pylon; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_barov_journal"; - newscript->pGOUse = &GOUse_go_barov_journal; + newscript->pGOUse = &GOUse_go_barov_journal; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_field_repair_bot_74A"; - newscript->pGOUse = &GOUse_go_field_repair_bot_74A; + newscript->pGOUse = &GOUse_go_field_repair_bot_74A; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_orb_of_command"; - newscript->pGOUse = &GOUse_go_orb_of_command; + newscript->pGOUse = &GOUse_go_orb_of_command; newscript->pGossipSelectGO = &GOGossipSelect_go_orb_of_command; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_tablet_of_madness"; - newscript->pGOUse = &GOUse_go_tablet_of_madness; + newscript->pGOUse = &GOUse_go_tablet_of_madness; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_tablet_of_the_seven"; - newscript->pGOUse = &GOUse_go_tablet_of_the_seven; + newscript->pGOUse = &GOUse_go_tablet_of_the_seven; newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_jump_a_tron"; - newscript->pGOUse = &GOUse_go_jump_a_tron; + newscript->pGOUse = &GOUse_go_jump_a_tron; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_sacred_fire_of_life"; - newscript->pGOUse = &GOUse_go_sacred_fire_of_life; + newscript->pGOUse = &GOUse_go_sacred_fire_of_life; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_crystalforge"; - newscript->pGOUse = &GOUse_go_crystalforge; + newscript->pGOUse = &GOUse_go_crystalforge; newscript->pGossipSelectGO = &GOGossipSelect_go_crystalforge; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_matrix_punchograph"; - newscript->pGOUse = &GOUse_go_matrix_punchograph; + newscript->pGOUse = &GOUse_go_matrix_punchograph; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_cat_figurine"; - newscript->pGOUse = &GOUse_go_cat_figurine; + newscript->pGOUse = &GOUse_go_cat_figurine; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_blood_filled_orb"; - newscript->pGOUse = &GOUse_go_blood_filled_orb; + newscript->pGOUse = &GOUse_go_blood_filled_orb; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_ethereum_stasis"; - newscript->pGOUse = &GOUse_go_ethereum_stasis; + newscript->pGOUse = &GOUse_go_ethereum_stasis; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_resonite_cask"; - newscript->pGOUse = &GOUse_go_resonite_cask; + newscript->pGOUse = &GOUse_go_resonite_cask; newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_darkmoon_cannon"; - newscript->pGOUse = &GOUse_go_darkmoon_cannon; + newscript->pGOUse = &GOUse_go_darkmoon_cannon; newscript->RegisterSelf(); newscript = new Script; @@ -574,5 +848,22 @@ void AddSC_go_scripts() newscript->Name = "go_ethereal_teleport_pad"; newscript->pGOUse = &GOUse_go_ethereal_teleport_pad; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_fel_crystal_prism"; + newscript->pGOUse = &GOUse_go_fel_crystal_prism; + newscript->pGossipSelectGO = &GOGossipSelect_go_fel_crystal_prism; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_rule_skies"; + newscript->pGOUse = &GOUse_go_rule_skies; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "go_draconic_for_dummies"; + newscript->pGOUse = &GOUse_go_draconic_for_dummies; + newscript->pGossipSelectGO = &GOGossipSelect_go_draconic_for_dummies; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/guard/guard_ai.cpp b/src/scripts/scripts/special/guard_ai.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/guard/guard_ai.cpp rename to src/scripts/scripts/special/guard_ai.cpp index 129271428..4990a22e6 --- a/src/scripts/scripts/guard/guard_ai.cpp +++ b/src/scripts/scripts/special/guard_ai.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -99,7 +102,7 @@ void guardAI::UpdateAI(const uint32 diff) return; // Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCast(false)) { //If we are within range melee the target if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) @@ -133,7 +136,7 @@ void guardAI::UpdateAI(const uint32 diff) else { //Only run this code if we arn't already casting - if (!m_creature->IsNonMeleeSpellCasted(false)) + if (!m_creature->IsNonMeleeSpellCast(false)) { bool Healing = false; SpellEntry const *info = NULL; diff --git a/src/scripts/scripts/special/guard_ai.h b/src/scripts/scripts/special/guard_ai.h new file mode 100644 index 000000000..f256ff064 --- /dev/null +++ b/src/scripts/scripts/special/guard_ai.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SC_GUARDAI_H +#define SC_GUARDAI_H + +#define GENERIC_CREATURE_COOLDOWN 5000 + +struct guardAI : public ScriptedAI +{ + guardAI(Creature *c) : ScriptedAI(c) {} + + uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) + uint32 BuffTimer; //This variable keeps track of buffs + + void Reset(); + + void EnterCombat(Unit *who); + + void JustDied(Unit *Killer); + + void UpdateAI(const uint32 diff); +}; +#endif + diff --git a/src/scripts/scripts/guard/guards.cpp b/src/scripts/scripts/special/guards.cpp old mode 100755 new mode 100644 similarity index 99% rename from src/scripts/scripts/guard/guards.cpp rename to src/scripts/scripts/special/guards.cpp index ec9ae26f1..8517ab322 --- a/src/scripts/scripts/guard/guards.cpp +++ b/src/scripts/scripts/special/guards.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/item/item_scripts.cpp b/src/scripts/scripts/special/item_scripts.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/scripts/scripts/item/item_scripts.cpp rename to src/scripts/scripts/special/item_scripts.cpp index 801c017dc..2d5233b9a --- a/src/scripts/scripts/item/item_scripts.cpp +++ b/src/scripts/scripts/special/item_scripts.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -120,7 +123,7 @@ bool ItemUse_item_blackwhelp_net(Player *player, Item* _Item, SpellCastTargets c #####*/ //This is just a hack and should be removed from here. -//Creature/Item are in fact created before spell are sucessfully casted, without any checks at all to ensure proper/expected behavior. +//Creature/Item are in fact created before spell are sucessfully cast, without any checks at all to ensure proper/expected behavior. bool ItemUse_item_draenei_fishing_net(Player *player, Item* _Item, SpellCastTargets const& targets) { if( player->GetQuestStatus(9452) == QUEST_STATUS_INCOMPLETE ) @@ -311,32 +314,6 @@ bool ItemUse_item_tame_beast_rods(Player *player, Item* _Item, SpellCastTargets return true; } -/*##### -# item_yehkinyas_bramble -#####*/ - -bool ItemUse_item_yehkinyas_bramble(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if (player->GetQuestStatus(3520) == QUEST_STATUS_INCOMPLETE) - { - Unit * unit_target = targets.getUnitTarget(); - if( unit_target && - unit_target->GetTypeId()==TYPEID_UNIT && - unit_target->isDead() && - // cast only on corpse 5307 or 5308 - (unit_target->GetEntry()==5307 || unit_target->GetEntry()==5308) ) - { - ((Creature*)unit_target)->RemoveCorpse(); // remove corpse for cancelling second use - return false; // all ok - } - } - WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message - data << uint32(10699); // itemId - data << uint8(SPELL_FAILED_BAD_TARGETS); // reason - player->GetSession()->SendPacket(&data); // send message: Bad target - player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell - return true; -} /*##### # item_specific_target #####*/ @@ -355,7 +332,6 @@ bool ItemUse_item_specific_target(Player *player, Item* _Item, SpellCastTargets uint32 iEntry = _Item->GetEntry(); uint32 cEntry[MAX_TARGETS] = { 0, 0, 0, 0 }; - bool removeCorpse = false; uint8 targetState = T_ALIVE & T_DEAD; @@ -371,20 +347,21 @@ bool ItemUse_item_specific_target(Player *player, Item* _Item, SpellCastTargets case 32321: cEntry[0] = 22979; break; // Sparrowhawk Net case 32825: cEntry[0] = 22357; break; // Soul Cannon case 34255: cEntry[0] = 24922; break; // Razorthorn Flayer Gland - case 25552: cEntry[0] = 17148; cEntry[1] = 17147; cEntry[2] = 17146; targetState = T_DEAD; removeCorpse = true; break; // Warmaul Ogre Banner - case 22473: cEntry[0] = 15941; cEntry[1] = 15945; break; // Disciplinary Rod - case 34368: cEntry[0] = 24972; targetState = T_DEAD; break; // Attuned Crystal Cores - case 29513: cEntry[0] = 19354; break; // Staff of the Dreghood Elders - case 32680: cEntry[0] = 23311; targetState = T_ALIVE; break; // Booterang case 30251: cEntry[0] = 20058; break; // Rina's Diminution Powder case 23417: cEntry[0] = 16975; break; // Sanctified Crystal case 32698: cEntry[0] = 22181; break; // Wrangling Rope - case 34257: cEntry[0] = 24918; targetState = T_ALIVE; break; // Fel Siphon - case 28547: cEntry[0] = 17157; cEntry[1] = 18865; break; - case 12284: cEntry[0] = 7047; cEntry[1] = 7048; cEntry[2] = 7049; break; // Draco-Incarcinatrix 900 - case 23337: cEntry[0] = 16880; targetState = T_ALIVE; break; // Cenarion Antidote - case 29818: cEntry[0] = 20774; targetState = T_ALIVE; break; // Energy Field Modulator - case 13289: cEntry[0] = 10384; cEntry[1] = 10385; targetState = T_ALIVE; break; // Egan's Blaster + case 29513: cEntry[0] = 19354; break; // Staff of the Dreghood Elders + case 22473: cEntry[0] = 15941; cEntry[1] = 15945; break; // Disciplinary Rod + case 34368: cEntry[0] = 24972; targetState = T_DEAD; break; // Attuned Crystal Cores + case 32680: cEntry[0] = 23311; targetState = T_ALIVE; break; // Booterang + case 34257: cEntry[0] = 24918; targetState = T_ALIVE; break; // Fel Siphon + case 28547: cEntry[0] = 18881; cEntry[1] = 18865; break; // Elemental power extractor + case 12284: cEntry[0] = 7047; cEntry[1] = 7048; cEntry[2] = 7049; break; // Draco-Incarcinatrix 900 + case 23337: cEntry[0] = 16880; targetState = T_ALIVE; break; // Cenarion Antidote + case 29818: cEntry[0] = 20774; targetState = T_ALIVE; break; // Energy Field Modulator + case 13289: cEntry[0] = 10384; cEntry[1] = 10385; targetState = T_ALIVE; break; // Egan's Blaster + case 10699: cEntry[0] = 5307; cEntry[1] = 5308; targetState = T_DEAD; break; // Yehkinyas Bramble + case 25552: cEntry[0] = 17148; cEntry[1] = 17147; cEntry[2] = 17146; targetState = T_DEAD; break; // Warmaul Ogre Banner } if(uTarget && uTarget->GetTypeId() == TYPEID_UNIT) @@ -421,9 +398,9 @@ bool ItemUse_item_specific_target(Player *player, Item* _Item, SpellCastTargets } case T_DEAD: { - if(!uTarget->isAlive()) + if(uTarget->getDeathState() == CORPSE) return false; - else + else if (uTarget->getDeathState() != DEAD) { WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message data << uint32(_Item->GetEntry()); // itemId @@ -432,6 +409,7 @@ bool ItemUse_item_specific_target(Player *player, Item* _Item, SpellCastTargets player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); return true; } + // if deathstate == dead corpse should be invisible and untargettable, so invalid target } } } @@ -542,17 +520,11 @@ void AddSC_item_scripts() newscript->pItemUse = &ItemUse_item_muiseks_vessel; newscript->RegisterSelf(); - newscript = new Script; newscript->Name="item_tame_beast_rods"; newscript->pItemUse = &ItemUse_item_tame_beast_rods; newscript->RegisterSelf(); - newscript = new Script; - newscript->Name="item_yehkinyas_bramble"; - newscript->pItemUse = &ItemUse_item_yehkinyas_bramble; - newscript->RegisterSelf(); - newscript = new Script; newscript->Name="item_specific_target"; newscript->pItemUse = &ItemUse_item_specific_target; diff --git a/src/scripts/scripts/item/item_test.cpp b/src/scripts/scripts/special/item_test.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/item/item_test.cpp rename to src/scripts/scripts/special/item_test.cpp index 8fce0b714..a3dabe9ff --- a/src/scripts/scripts/item/item_test.cpp +++ b/src/scripts/scripts/special/item_test.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/src/scripts/scripts/creature/mob_generic_creature.cpp b/src/scripts/scripts/special/mob_generic_creature.cpp old mode 100755 new mode 100644 similarity index 85% rename from src/scripts/scripts/creature/mob_generic_creature.cpp rename to src/scripts/scripts/special/mob_generic_creature.cpp index a19325b17..b20fb1437 --- a/src/scripts/scripts/creature/mob_generic_creature.cpp +++ b/src/scripts/scripts/special/mob_generic_creature.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: Generic_Creature @@ -87,7 +90,7 @@ struct generic_creatureAI : public ScriptedAI if( m_creature->IsWithinMeleeRange(m_creature->getVictim())) { //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCast(false)) { bool Healing = false; SpellEntry const *info = NULL; @@ -118,7 +121,7 @@ struct generic_creatureAI : public ScriptedAI else { //Only run this code if we arn't already casting - if (!m_creature->IsNonMeleeSpellCasted(false)) + if (!m_creature->IsNonMeleeSpellCast(false)) { bool Healing = false; SpellEntry const *info = NULL; diff --git a/src/scripts/scripts/npc/npc_innkeeper.cpp b/src/scripts/scripts/special/npc_innkeeper.cpp old mode 100755 new mode 100644 similarity index 96% rename from src/scripts/scripts/npc/npc_innkeeper.cpp rename to src/scripts/scripts/special/npc_innkeeper.cpp index 27d910881..7f6821b15 --- a/src/scripts/scripts/npc/npc_innkeeper.cpp +++ b/src/scripts/scripts/special/npc_innkeeper.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -120,7 +123,7 @@ bool GossipSelect_npc_innkeeper(Player *player, Creature *_Creature, uint32 send } player->CastSpell(player, trickspell, true); } - return true; // prevent Trinity core handling + return true; // prevent core handling } //Trininty Gossip core handling dont work... else if (action == GOSSIP_OPTION_VENDOR) diff --git a/src/scripts/scripts/npc/npc_professions.cpp b/src/scripts/scripts/special/npc_professions.cpp old mode 100755 new mode 100644 similarity index 90% rename from src/scripts/scripts/npc/npc_professions.cpp rename to src/scripts/scripts/special/npc_professions.cpp index 9df6339a9..00df82b91 --- a/src/scripts/scripts/npc/npc_professions.cpp +++ b/src/scripts/scripts/special/npc_professions.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -104,7 +107,12 @@ there is no difference here (except that default text is chosen with `gameobject #define BOX_UNLEARN_TAILOR_SPEC "Do you really want to unlearn your tailoring specialty and lose all associated recipes? \n Cost: " #define GOSSIP_LEARN_GOBLIN "I am absolutely certain that i want to learn Goblin engineering" +#define GOSSIP_UNLEARN_GOBLIN "I wish to unlearn my Goblin Engineering specialization!" #define GOSSIP_LEARN_GNOMISH "I am absolutely certain that i want to learn Gnomish engineering" +#define GOSSIP_UNLEARN_GNOMISH "I wish to unlearn my Gnomish Engineering specialization!" + +#define BOX_UNLEARN_GOBLIN_SPEC "Do you really want to unlearn your Goblin Engineering specialization and lose all asociated recipes?" +#define BOX_UNLEARN_GNOMISH_SPEC "Do you really want to unlearn your Gnomish Engineering specialization and lose all asociated recipes?" /*### # spells defines @@ -1220,18 +1228,123 @@ bool GossipSelect_npc_prof_tailor(Player *player, Creature *_Creature, uint32 se # start menues for GO (engineering and leatherworking) ###*/ -/*bool GOUse_go_soothsaying_for_dummies(Player *player, GameObject* _GO) +bool HasLeatherSpec(Player* player) +{ + return (player->HasSpell(S_ELEMENTAL) || player->HasSpell(S_DRAGON) || player->HasSpell(S_TRIBAL)); +} + +bool HasEngineerSpec(Player* player) { - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0,GOSSIP_LEARN_DRAGON, GOSSIP_SENDER_INFO, GOSSIP_ACTION_INFO_DEF, "", 0); + return (player->HasSpell(S_GNOMISH) || player->HasSpell(S_GOBLIN)); +} - player->SEND_GOSSIP_MENU(5584, _GO->GetGUID()); +bool GossipHello_go_soothsaying_for_dummies(Player *player, GameObject* go) +{ + if (player->HasSkill(SKILL_LEATHERWORKING) && player->GetBaseSkillValue(SKILL_LEATHERWORKING) >= 225 && player->getLevel() > 39) + { + if (!HasLeatherSpec(player)) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_DRAGON, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELEMENTAL, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRIBAL, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(8326, go->GetGUID()); + return true; + } + } + if (player->HasSkill(SKILL_ENGINERING) && player->GetBaseSkillValue(SKILL_ENGINERING) >= 200 && player->getLevel() > 39) + { + if (player->GetQuestRewardStatus(3643) || player->GetQuestRewardStatus(3641) || player->GetQuestRewardStatus(3639)) + { + if (!HasEngineerSpec(player)) + { + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_GNOMISH, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+4); + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_GOBLIN, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(30000, go->GetGUID()); + return true; + } + if (player->HasSpell(S_GNOMISH)) + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_GNOMISH, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+6, BOX_UNLEARN_GNOMISH_SPEC, DoHighUnlearnCost(player), false); + if (player->HasSpell(S_GOBLIN)) + player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_GOBLIN, GOSSIP_SENDER_CHECK, GOSSIP_ACTION_INFO_DEF+7, BOX_UNLEARN_GNOMISH_SPEC, DoHighUnlearnCost(player), false); + } + } + player->SEND_GOSSIP_MENU(30000, go->GetGUID()); return true; -}*/ +} -/*### -# -###*/ +void SendActionMenu_go_soothsaying_for_dummies(Player *player, GameObject* go, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + if(!player->HasSpell(S_DRAGON)) + player->CastSpell(player, S_LEARN_DRAGON, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+2: + if (!player->HasSpell(S_ELEMENTAL)) + player->CastSpell(player, S_LEARN_ELEMENTAL, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+3: + if (!player->HasSpell(S_TRIBAL)) + player->CastSpell(player, S_LEARN_TRIBAL, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+4: + if (!player->HasSpell(S_GNOMISH)) + player->CastSpell(player, S_LEARN_GNOMISH, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+5: + if (!player->HasSpell(S_GOBLIN)) + player->CastSpell(player, S_LEARN_GOBLIN, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+6: + if(EquippedOk(player,20219)) // Gnomish Engineer + { + if(player->GetMoney() >= DoLowUnlearnCost(player)) + { + player->removeSpell(20219); + ProfessionUnlearnSpells(player, 20219); + player->ModifyMoney(-DoLowUnlearnCost(player)); + } + else + player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, NULL, 0, 0); + } + else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF+7: + if(EquippedOk(player,20222)) // Gnomish Engineer + { + if(player->GetMoney() >= DoLowUnlearnCost(player)) + { + player->removeSpell(20222); + ProfessionUnlearnSpells(player, 20222); + player->ModifyMoney(-DoLowUnlearnCost(player)); + } + else + player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, NULL, 0, 0); + } + else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + } +} + +bool GossipSelect_go_soothsaying_for_dummies(Player *player, GameObject* go, uint32 sender, uint32 action) +{ + switch(sender) + { + case GOSSIP_SENDER_CHECK: SendActionMenu_go_soothsaying_for_dummies(player, go, action); break; + } + return true; +} void AddSC_npc_professions() { @@ -1261,10 +1374,10 @@ void AddSC_npc_professions() newscript->pGossipSelect = &GossipSelect_npc_prof_tailor; newscript->RegisterSelf(); - /*newscript = new Script; + newscript = new Script; newscript->Name="go_soothsaying_for_dummies"; - newscript->pGOUse = &GOUse_go_soothsaying_for_dummies; - //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies; - newscript->RegisterSelf();*/ + newscript->pGOUse = &GossipHello_go_soothsaying_for_dummies; + newscript->pGossipSelectGO = &GossipSelect_go_soothsaying_for_dummies; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/npc/npcs_special.cpp b/src/scripts/scripts/special/npcs_special.cpp old mode 100755 new mode 100644 similarity index 78% rename from src/scripts/scripts/npc/npcs_special.cpp rename to src/scripts/scripts/special/npcs_special.cpp index fe4d12405..90b39f34a --- a/src/scripts/scripts/npc/npcs_special.cpp +++ b/src/scripts/scripts/special/npcs_special.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -38,12 +41,14 @@ npc_mojo 100% AI for companion Mojo (summoned by item: 339 npc_master_omarion 100% Master Craftsman Omarion, patterns menu npc_lorekeeper_lydros 100% Dialogue (story) + add A Dull and Flat Elven Blade npc_crashin_thrashin_robot 100% AI for Crashin' Thrashin' Robot from engineering +npc_gnomish_flame_turret EndContentData */ #include "precompiled.h" #include "BattleGround.h" #include "Totem.h" #include "PetAI.h" +#include "Language.h" #include #include @@ -652,7 +657,7 @@ CreatureAI* GetAI_npc_doctor(Creature *_Creature) ######*/ #define SPELL_DEATHTOUCH 5 -#define SAY_AGGRO "This area is closed!" +#define SAY_AGGRO "This area is closed!" struct npc_guardianAI : public ScriptedAI { @@ -665,7 +670,7 @@ struct npc_guardianAI : public ScriptedAI void EnterCombat(Unit *who) { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); } void UpdateAI(const uint32 diff) @@ -675,7 +680,7 @@ struct npc_guardianAI : public ScriptedAI if (me->isAttackReady()) { - me->CastSpell(me->getVictim(),SPELL_DEATHTOUCH, true); + me->CastSpell(me->getVictim(), SPELL_DEATHTOUCH, true); me->resetAttackTimer(); } } @@ -1015,16 +1020,13 @@ CreatureAI* GetAI_npc_tonk_mine(Creature *_Creature) bool ReceiveEmote_npc_winter_reveler( Player *player, Creature *_Creature, uint32 emote ) { - if (player->HasSpellCooldown(26218)) - return false; - - if (emote == TEXTEMOTE_KISS) + if ((!player->HasAura(26218))&&(emote == TEXTEMOTE_KISS)) { - //_Creature->CastSpell(_Creature, 26218, false); - player->CastSpell(player, 26218, false); - player->AddSpellCooldown(26218, 0, time(NULL) + 3600); + _Creature->CastSpell(player, 26218, false); + return true; } - return true; + + return false; } /*#### @@ -1055,7 +1057,7 @@ struct npc_snake_trap_serpentsAI : public ScriptedAI Timer checkTimer; - void Reset() + void EnterCombat(Unit*) { if (roll_chance_f(66.0f)) { @@ -1074,7 +1076,7 @@ struct npc_snake_trap_serpentsAI : public ScriptedAI if (ScriptedAI::UpdateVictim()) return true; - if (Unit* target = me->SelectNearbyTarget(15.0f)) + if (Unit* target = me->SelectNearestTarget(5.0f)) AttackStart(target); return me->getVictim(); @@ -1645,67 +1647,210 @@ bool GossipSelect_npc_ring_specialist(Player* player, Creature* _Creature, uint3 return true; } -/*######## -# npc_elemental_guardian -#########*/ +/*###### +# npc_fire_elemental_guardian +######*/ +#define SPELL_FIRENOVA 12470 // wrong, spell disabled in code +#define SPELL_FIRESHIELD 13376 // this spell is not an aura, it's instant cast aoe +#define SPELL_FIREBLAST 8413 // we won't find the proper one fireblast, so we use the one with the best matching stats -struct npc_elemental_guardianAI : public ScriptedAI +struct npc_fire_elemental_guardianAI : public ScriptedAI { - npc_elemental_guardianAI(Creature *c) : ScriptedAI(c) { c->SetReactState(REACT_PASSIVE); } + npc_fire_elemental_guardianAI(Creature* c) : ScriptedAI(c){} - uint32 m_checkTimer; + uint32 FireNova_Timer; + uint32 FireBlast_Timer; + uint32 FireShield_Timer; void Reset() { - m_checkTimer = 2000; +// FireNova_Timer = 5000 + rand() % 15000; // 5-20 sec cd + FireBlast_Timer = 10000 +rand() % 5000; // 10-15 sec cd + FireShield_Timer = 2000; // 1 tick/ 2sec + me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + me->SetReactState(REACT_DEFENSIVE); + me->SetAggroRange(0); + me->CombatStopWithPets(); + me->ClearInCombat(); + me->AttackStop(); } - void MoveInLineOfSight(Unit *pWho) {} - void UpdateAI(const uint32 diff) { - if (m_checkTimer < diff) - { - Creature *pTotem = me->GetCreature(me->GetOwnerGUID()); - if (!me->getVictim() && pTotem) - { - if (!me->hasUnitState(UNIT_STAT_FOLLOW)) - me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); - - if (Unit *pTemp = pTotem->SelectNearestTarget(30.0f)) - AttackStart(pTemp); - } - - if (pTotem) - { - if (!pTotem->isAlive()) + Creature *pTotem = me->GetCreature(me->GetOwnerGUID()); + Unit *victim = pTotem->SelectNearestTarget(5.0f); + Unit *attacker = pTotem->getAttackerForHelper(); + + if (pTotem) + { + if (!pTotem->isAlive()) + { + me->ForcedDespawn(); + return; + } + if (!me->IsWithinDistInMap(pTotem, 30.0f) || (!victim || !attacker)) + { + if (!me->getVictim()|| !me->IsWithinDistInMap(pTotem, 30.0f)) + if (!me->hasUnitState(UNIT_STAT_FOLLOW)) { - me->ForcedDespawn(); - return; + victim = NULL; + attacker = NULL; + me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); + Reset(); + return; } + } + if (me->getVictim() && me->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() && + (pTotem->isInSanctuary() || me->isInSanctuary() || me->getVictim()->isInSanctuary())) + { + victim = NULL; + attacker = NULL; + me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); + Reset(); + return; + } + + if ((victim || attacker)) + { + if (attacker) + { + me->SetInCombatWith(attacker); + AttackStart(attacker); + } + else + { + me->SetInCombatWith(victim); + AttackStart(victim); + } + if (me->hasUnitState(UNIT_STAT_CASTING)) + return; - if (!me->IsWithinDistInMap(pTotem, 30.0f)) - { - EnterEvadeMode(); - me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); - } - } - else - me->ForcedDespawn(); + if (FireShield_Timer <= diff) + { + DoCast(me->getVictim(), SPELL_FIRESHIELD); + FireShield_Timer = 2000; + } + else + FireShield_Timer -= diff; - m_checkTimer = 2000; - } - else - m_checkTimer -= diff; - DoMeleeAttackIfReady(); + + if (FireBlast_Timer <= diff) + { + DoCast(me->getVictim(), SPELL_FIREBLAST); + FireBlast_Timer = 10000 + rand() % 5000; // 10-15 sec cd + } + else + FireBlast_Timer -= diff; + + +/* + if (FireNova_Timer <= diff) + { + DoCast(me->getVictim(), SPELL_FIRENOVA); + FireNova_Timer = 5000 + rand() % 15000; // 5-20 sec cd + } + else + FireNova_Timer -= diff; +*/ + + DoMeleeAttackIfReady(); + } + } } }; -CreatureAI* GetAI_npc_elemental_guardian(Creature* pCreature) +CreatureAI *GetAI_npc_fire_elemental_guardian(Creature* c) { - return new npc_elemental_guardianAI(pCreature); -} + return new npc_fire_elemental_guardianAI(c); +}; + +/*###### +# npc_earth_elemental_guardian +######*/ +#define SPELL_ANGEREDEARTH 36213 + +struct npc_earth_elemental_guardianAI : public ScriptedAI +{ + npc_earth_elemental_guardianAI(Creature* c) : ScriptedAI(c) {} + + uint32 AngeredEarth_Timer; + + void Reset() + { + AngeredEarth_Timer = 1000; + me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); + me->SetReactState(REACT_DEFENSIVE); + me->SetAggroRange(0); + me->CombatStopWithPets(); + me->ClearInCombat(); + me->AttackStop(); + } + + void UpdateAI(const uint32 diff) + { + Creature *pTotem = me->GetCreature(me->GetOwnerGUID()); + Unit *victim = pTotem->SelectNearestTarget(5.0f); + Unit *attacker = pTotem->getAttackerForHelper(); + + if (pTotem) + { + if (!pTotem->isAlive()) + { + me->ForcedDespawn(); + return; + } + + if (!me->IsWithinDistInMap(pTotem, 30.0f) || (!victim || !attacker)) + { + if (!me->getVictim() || !me->IsWithinDistInMap(pTotem, 30.0f)) + if (!me->hasUnitState(UNIT_STAT_FOLLOW)) + { + victim = NULL; + attacker = NULL; + me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); + Reset(); + return; + } + } + + if (me->getVictim() && me->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() && + (pTotem->isInSanctuary() || me->isInSanctuary() || me->getVictim()->isInSanctuary())) + { + Reset(); + victim = NULL; + attacker = NULL; + me->GetMotionMaster()->MoveFollow(pTotem, 2.0f, M_PI); + return; + } + + + if ((victim || attacker)) + { + + if (attacker) + AttackStart(attacker); + else + AttackStart(victim); + + if (AngeredEarth_Timer <= diff) + { + DoCast(me->getVictim(), SPELL_ANGEREDEARTH); + AngeredEarth_Timer = 5000 + rand() % 15000; // 5-20 sec cd + } + else + AngeredEarth_Timer -= diff; + + DoMeleeAttackIfReady(); + } + } + } +}; + +CreatureAI *GetAI_npc_earth_elemental_guardian(Creature* c) +{ + return new npc_earth_elemental_guardianAI(c); +}; /*######## # npc_master_omarion @@ -2023,7 +2168,7 @@ struct npc_crashin_trashin_robotAI : public ScriptedAI Creature * tmp = *(itr); - tmp->GetNearPoint(tmp, x, y, z, 0, 5.0f, frand(0.0f, M_PI*2)); + tmp->GetNearPoint(x, y, z, 0, 5.0f, frand(0.0f, M_PI*2)); me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MovePoint(0, x, y, z); } @@ -2271,7 +2416,7 @@ struct trigger_barkerAI : public ScriptedAI if (me->IsWithinDistInMap(who, 10.0f) && who->HasAura(43883, 0)) { - ((Player*)who)->CastedCreatureOrGO(me->GetEntry(), me->GetGUID(), 0); + ((Player*)who)->CastCreatureOrGO(me->GetEntry(), me->GetGUID(), 0); } } }; @@ -2379,6 +2524,7 @@ enum MiniPetsInfo NPC_WILLY = 23231, SPELL_WILLY_SLEEP = 40663, + SPELL_WILLY_TRIGGER = 40619, NPC_DRAGON_KITE = 25110, SPELL_DRAGON_KITE_LIGHTNING = 45197, @@ -2447,7 +2593,7 @@ struct npc_small_pet_handlerAI : public ScriptedAI { me->HandleEmoteCommand(EMOTE_ONESHOT_NONE); - if (me->IsNonMeleeSpellCasted(false)) + if (me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); m_bIsIdle = false; @@ -2484,7 +2630,7 @@ struct npc_small_pet_handlerAI : public ScriptedAI else { me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); - if (me->IsNonMeleeSpellCasted(false)) + if (me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); m_uiActionTimer = urand(10000, 30000); @@ -2509,6 +2655,11 @@ struct npc_small_pet_handlerAI : public ScriptedAI AddSpellToCast(me->GetOwner(), SPELL_DRAGON_KITE_STRING); break; } + case NPC_WILLY: + { + AddSpellToCast(me,SPELL_WILLY_TRIGGER); + break; + } default: break; } @@ -2591,56 +2742,34 @@ bool GossipSelect_npc_combatstop(Player* player, Creature* _Creature, uint32 sen return true; } -struct npc_resurrectAI : public ScriptedAI +struct npc_resurrectAI : public Scripted_NoMovementAI { - npc_resurrectAI(Creature* c) : ScriptedAI(c) {} + npc_resurrectAI(Creature* c) : Scripted_NoMovementAI(c) {} TimeTrackerSmall timer; - void Reset() + void Reset() override { - me->setDeathState(DEAD); - - me->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, me->GetGUID()); - // aura - me->SetUInt32Value(UNIT_FIELD_AURA, SPELL_SPIRIT_HEAL_CHANNEL); - me->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 0x00000009); - me->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x0000003C); - me->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0x000000FF); - // casting visual effect - me->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL); - // correct cast speed - me->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); - + me->SetReactState(REACT_PASSIVE); timer.Reset(2000); } - void AttackStart(Unit* who) {} - void EnterCombat(Unit *who) {} + void MoveInLineOfSight(Unit *who) override {} + void AttackStart(Unit* who) override {} + void EnterCombat(Unit *who) override {} - struct PlayerRemove - { - PlayerRemove(Creature* c) : me(c) {} - - Creature* me; - bool operator()(Player* plr) - { - return plr->isAlive() || me->IsHostileTo(plr); - } - }; - - void UpdateAI(const uint32 uiDiff) + void UpdateAI(const uint32 uiDiff) override { timer.Update(uiDiff); if (timer.Passed()) { std::list players; - Hellground::AnyPlayerInObjectRangeCheck check(me, 15.0f); + Hellground::AnyPlayerInObjectRangeCheck check(me, 15.0f, false); Hellground::ObjectListSearcher searcher(players, check); Cell::VisitAllObjects(me, searcher, 15.0f); - players.remove_if(PlayerRemove(me)); + players.remove_if([this](Player* plr) -> bool { return me->IsHostileTo(plr); }); while (!players.empty()) { @@ -2661,6 +2790,485 @@ CreatureAI* GetAI_npc_resurrect(Creature* pCreature) return new npc_resurrectAI(pCreature); } +enum TargetDummySpells +{ + TARGET_DUMMY_PASSIVE = 4044, + TARGET_DUMMY_SPAWN_EFFECT = 4507, + + ADVANCED_TARGET_DUMMY_PASSIVE = 4048, + ADVANCED_TARGET_DUMMY_SPAWN_EFFECT = 4092, + + MASTER_TARGET_DUMMY_PASSIVE = 19809, +}; + +enum TargetDummyEntry +{ + TARGET_DUMMY = 2673, + ADV_TARGET_DUMMY = 2674, + MASTER_TARGET_DUMMY = 12426 +}; + +struct npc_target_dummyAI : public Scripted_NoMovementAI +{ + npc_target_dummyAI(Creature* c) : Scripted_NoMovementAI(c) {} + + void Reset() override + { + me->SetReactState(REACT_PASSIVE); + + ClearCastQueue(); + + TargetDummySpells spawneffect; + TargetDummySpells passive; + + switch (me->GetEntry()) + { + case TARGET_DUMMY: + { + spawneffect = TARGET_DUMMY_SPAWN_EFFECT; + passive = TARGET_DUMMY_PASSIVE; + break; + } + case ADV_TARGET_DUMMY: + { + spawneffect = ADVANCED_TARGET_DUMMY_SPAWN_EFFECT; + passive = ADVANCED_TARGET_DUMMY_PASSIVE; + break; + } + case MASTER_TARGET_DUMMY: + { + spawneffect = ADVANCED_TARGET_DUMMY_SPAWN_EFFECT; + passive = MASTER_TARGET_DUMMY_PASSIVE; + break; + } + } + + AddSpellToCast(passive, CAST_SELF); + AddSpellToCast(spawneffect, CAST_SELF); + } + + void AttackStart(Unit* who) override {} + void EnterCombat(Unit *who) override {} + void MoveInLineOfSight(Unit* who) override {} + + void UpdateAI(const uint32 diff) override + { + CastNextSpellIfAnyAndReady(); + } +}; + +CreatureAI* GetAI_npc_target_dummy(Creature* pCreature) +{ + return new npc_target_dummyAI(pCreature); +} + +enum ExplosiveSheepExplosion +{ + EXPLOSIVE_SHEEP_EXPLOSION = 4050, + HIGH_EXPLOSIVE_SHEEP_EXPLOSION = 44279, +}; + +enum ExplosiveSheepEntry +{ + EXPLOSIVE_SHEEP = 2675, + HIGH_EXPLOSIVE_SHEEP = 24715 +}; + +struct npc_explosive_sheepAI : public ScriptedAI +{ + npc_explosive_sheepAI(Creature* c) : ScriptedAI(c) {} + + TimeTrackerSmall explosionTimer; + + void JustRespawned() override + { + explosionTimer.Reset(10000); + } + + void Reset() override + { + me->SetReactState(REACT_PASSIVE); + + ClearCastQueue(); + } + + void AttackStart(Unit* who) override {} + void EnterCombat(Unit *who) override {} + void MoveInLineOfSight(Unit* who) override {} + + void UpdateAI(const uint32 diff) override + { + explosionTimer.Update(diff); + if (explosionTimer.Passed()) + { + ForceSpellCast(me->GetEntry() == EXPLOSIVE_SHEEP ? EXPLOSIVE_SHEEP_EXPLOSION : HIGH_EXPLOSIVE_SHEEP_EXPLOSION, CAST_SELF, INTERRUPT_AND_CAST, true); + me->ForcedDespawn(); + return; + } + + if (me->getVictim() == nullptr) + { + if (Unit* target = me->SelectNearestTarget()) + ScriptedAI::AttackStart(target); + } + else + { + if (me->IsWithinDistInMap(me->getVictim(), 2.0f)) + { + ForceSpellCast(me->GetEntry() == EXPLOSIVE_SHEEP ? EXPLOSIVE_SHEEP_EXPLOSION : HIGH_EXPLOSIVE_SHEEP_EXPLOSION, CAST_SELF, INTERRUPT_AND_CAST, true); + me->ForcedDespawn(); + return; + } + } + + CastNextSpellIfAnyAndReady(); + } +}; + +CreatureAI* GetAI_npc_explosive_sheep(Creature* pCreature) +{ + return new npc_explosive_sheepAI(pCreature); +} + +/*###### +## Meridith the Mermaiden +######*/ + +#define GOSSIP_HELLO "Thank you for your help" +#define LOVE_SONG_QUEST_ID 8599 +#define SIREN_SONG 25678 + +bool GossipHello_npc_meridith_the_mermaiden(Player *player, Creature *creature) +{ + if( player->GetQuestStatus(LOVE_SONG_QUEST_ID) == QUEST_STATUS_COMPLETE ) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + } + player->PlayerTalkClass->SendGossipMenu(7916,creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_meridith_the_mermaiden(Player *player, Creature * creature, uint32 sender, uint32 action ) +{ + if(action == GOSSIP_ACTION_INFO_DEF+1) + { + creature->Say("Farewell!", LANG_UNIVERSAL, 0); + creature->CastSpell(player, SIREN_SONG, false); + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + +// npc_gnomish_flame_turret +#define SPELL_GNOMISH_FLAME_TURRET 43050 + +struct npc_gnomish_flame_turret : public Scripted_NoMovementAI +{ + npc_gnomish_flame_turret(Creature* c) : Scripted_NoMovementAI(c) + { + me->SetAggroRange(10.0f); // radius of spell + } + Timer CheckTimer; + + void Reset() + { + SetAutocast(SPELL_GNOMISH_FLAME_TURRET, 1000); + StartAutocast(); + me->SetReactState(REACT_AGGRESSIVE); + CheckTimer.Reset(2000); + } + + bool UpdateVictim() + { + if (ScriptedAI::UpdateVictim()) + return true; + + if (Unit* target = me->SelectNearestTarget(10.0f)) + AttackStart(target); + + return me->getVictim(); + } + + void UpdateAI(const uint32 diff) + { + CheckTimer.Update(diff); + if (CheckTimer.Passed()) + { + Unit* owner = me->GetOwner(); + if (!owner || !owner->IsInMap(me)) + { + me->ForcedDespawn(); + return; + } + CheckTimer.Reset(2000); + } + + if (!UpdateVictim()) + return; + + CastNextSpellIfAnyAndReady(diff); + } +}; + +CreatureAI* GetAI_npc_gnomish_flame_turret(Creature *_Creature) +{ + return new npc_gnomish_flame_turret(_Creature); +} + +/*###### + # dummy park control + ######*/ +#define DUMMY_PARK_ON "Start dummy park event" +#define DUMMY_PARK_OFF "Stop dummy park event" +#define DUMMY_PARK_OBJECTS 16 +#define DUMMY_PARK_NPCS 8 + +float dummyparkstorage[3] = {-1899, 5607, -33}; + +float dummyparkobjectlocs[DUMMY_PARK_OBJECTS][3] = { + {-1945.59, 5559.70, -12.428}, + {-1917.56, 5571.52, -12.428}, + {-1937.18, 5542.79, -12.428}, + {-1940.55, 5554.45, -12.427}, + {-1915.94, 5564.6, -12.427}, + {-1909.43, 5556.58, -12.428}, + {-1934.38, 5539.64, -12.428}, + {-1932.02, 5536.95, -12.427}, + {-1932.02, 5536.95, -11.184}, + {-1908.28, 5552.2, -12.426}, + {-1907.54, 5548.75, -12.428}, + {-1907.54, 5548.75, -11.185}, + {-1930.43, 5535.41, -12.428}, + {-1907.17, 5546.7, -12.426}, + {-1933.35, 5570.6, -12.427}, + {-1933.36, 5570.6, -12.427} +}; + +uint32 dummyparkobjects[DUMMY_PARK_OBJECTS][2] ={ + {13228578,184380}, + {13228592,184381}, + {13231451,173223}, + {13228737,173223}, + {13228733,173223}, + {13231535,173223}, + {13229544,187225}, + {13231413,183992}, + {13231420,186738}, + {13229522,187225}, + {13231299,183992}, + {13231325,186738}, + {13266292,173223}, + {13266474,173223}, + {13266692,183319}, + {13246219,180423} +}; + +float dummyparknpclocs[DUMMY_PARK_NPCS][3] ={ + {-1919.98, 5551.57, -12.426}, + {-1926.75, 5548.27, -12.426}, + {-1928.70, 5560.42, -12.428}, + {-1913.47, 5560.28, -12.428}, + {-1933.36, 5570.6, -12.427}, + {-1938.83, 5548.67, -12.427}, + {-1922.58, 5565.43, -12.427}, + {-1936.90, 5560.12, -12.427} +}; + +uint32 dummyparknpcs[DUMMY_PARK_NPCS][2] ={ + {29312,66700}, + {29337,66701}, + {29437,66702}, + {29461,66703}, + {133929,66704}, + {60062,66709}, + {126618,66712}, + {126714,66713} +}; + +bool GossipHello_npc_dummy_park(Player *player, Creature *creature) +{ + if (player->isGameMaster()) + { + player->ADD_GOSSIP_ITEM(0, DUMMY_PARK_ON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, DUMMY_PARK_OFF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_dummy_park(Player *player, Creature *creature, uint32 sender, uint32 action) +{ + if (player->isGameMaster()) + { + if(action == GOSSIP_ACTION_INFO_DEF+1) + { + creature->Whisper("Preparing dummy park!",player->GetGUID()); + GameObject* gob; + for (uint8 i = 0 ; i < DUMMY_PARK_OBJECTS ; i++) + { + gob = NULL; + gob = player->GetMap()->GetGameObject(MAKE_NEW_GUID(dummyparkobjects[i][0], dummyparkobjects[i][1], HIGHGUID_GAMEOBJECT)); + if (gob) + { + Map* map = gob->GetMap(); + gob->Relocate(dummyparkobjectlocs[i][0], dummyparkobjectlocs[i][1], dummyparkobjectlocs[i][2], gob->GetOrientation()); + gob->SetFloatValue(GAMEOBJECT_POS_X, dummyparkobjectlocs[i][0]); + gob->SetFloatValue(GAMEOBJECT_POS_Y, dummyparkobjectlocs[i][1]); + gob->SetFloatValue(GAMEOBJECT_POS_Z, dummyparkobjectlocs[i][2]); + gob->SaveToDB(); + gob->Refresh(); + } + } + Creature* mCreature; + for (uint8 i = 0 ; i < DUMMY_PARK_NPCS ; i++) + { + + mCreature = NULL; + mCreature = player->GetMap()->GetCreature(MAKE_NEW_GUID(dummyparknpcs[i][0],dummyparknpcs[i][1],HIGHGUID_UNIT)); + if (mCreature) + { + Map* map = mCreature->GetMap(); + mCreature->SetHomePosition(dummyparknpclocs[i][0], dummyparknpclocs[i][1], dummyparknpclocs[i][2], mCreature->GetOrientation()); + map->CreatureRelocation(mCreature,dummyparknpclocs[i][0], dummyparknpclocs[i][1], dummyparknpclocs[i][2], mCreature->GetOrientation()); + } + GameDataDatabase.PExecuteLog("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", + dummyparknpclocs[i][0], dummyparknpclocs[i][1], dummyparknpclocs[i][2], dummyparknpcs[i][0]); + } + } + else if(action == GOSSIP_ACTION_INFO_DEF+2) + { + creature->Whisper("Removing dummy park!",player->GetGUID()); + GameObject* gob; + for (uint8 i = 0 ; i < DUMMY_PARK_OBJECTS ; i++) + { + gob = NULL; + gob = player->GetMap()->GetGameObject(MAKE_NEW_GUID(dummyparkobjects[i][0], dummyparkobjects[i][1], HIGHGUID_GAMEOBJECT)); + if (gob) + { + Map* map = gob->GetMap(); + gob->Relocate(dummyparkstorage[0], dummyparkstorage[1], dummyparkstorage[2], gob->GetOrientation()); + gob->SetFloatValue(GAMEOBJECT_POS_X, dummyparkstorage[0]); + gob->SetFloatValue(GAMEOBJECT_POS_Y, dummyparkstorage[1]); + gob->SetFloatValue(GAMEOBJECT_POS_Z, dummyparkstorage[2]); + gob->SaveToDB(); + gob->Refresh(); + } + } + Creature* mCreature; + for (uint8 i = 0 ; i < DUMMY_PARK_NPCS ; i++) + { + mCreature = NULL; + mCreature = player->GetMap()->GetCreature(MAKE_NEW_GUID(dummyparknpcs[i][0],dummyparknpcs[i][1],HIGHGUID_UNIT)); + if (mCreature) + { + Map* map = mCreature->GetMap(); + mCreature->SetHomePosition(dummyparknpclocs[i][0], dummyparknpclocs[i][1], dummyparknpclocs[i][2], mCreature->GetOrientation()); + map->CreatureRelocation(mCreature,dummyparkstorage[0], dummyparkstorage[1], dummyparkstorage[2], mCreature->GetOrientation()); + } + GameDataDatabase.PExecuteLog("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", + dummyparkstorage[0], dummyparkstorage[1], dummyparkstorage[2], dummyparknpcs[i][0]); + } + } + } + return true; +} + +struct npc_nearly_dead_combat_dummyAI : public Scripted_NoMovementAI +{ + npc_nearly_dead_combat_dummyAI(Creature *c) : Scripted_NoMovementAI(c) + { + } + + uint64 AttackerGUID; + uint32 Check_Timer; + + void Reset() + { + m_creature->SetHealth(m_creature->GetMaxHealth()/11); + m_creature->SetNoCallAssistance(true); + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_STUN, true); + AttackerGUID = 0; + Check_Timer = 0; + } + + void EnterCombat(Unit* who) + { + AttackerGUID = ((Player*)who)->GetGUID(); + m_creature->GetUnitStateMgr().PushAction(UNIT_ACTION_STUN, UNIT_ACTION_PRIORITY_END); + } + + void DamageTaken(Unit *attacker, uint32 &damage) + { + } + + void UpdateAI(const uint32 diff) + { + Player* attacker = Player::GetPlayer(AttackerGUID); + + if (!UpdateVictim()) + return; + + if (attacker && Check_Timer < diff) + { + if(m_creature->GetDistance2d(attacker) > 12.0f) + EnterEvadeMode(); + + Check_Timer = 3000; + } + else + Check_Timer -= diff; + } +}; + +CreatureAI* GetAI_npc_nearly_dead_combat_dummy(Creature *_Creature) +{ + return new npc_nearly_dead_combat_dummyAI(_Creature); +} + +struct npc_instakill_guardianAI : public Scripted_NoMovementAI +{ + npc_instakill_guardianAI(Creature *c) : Scripted_NoMovementAI(c) + { + me->SetReactState(REACT_PASSIVE); + } + + float distance; + + void Reset() + { + distance = 0.1f * m_creature->GetRespawnDelay(); + } + + void MoveInLineOfSight(Unit* who) + { + Player* player = who->GetCharmerOrOwnerPlayerOrPlayerItself(); + if (!player || player->isGameMaster() || !me->isAlive()) + return; + + WorldLocation loc; + player->GetPosition(loc); + if( m_creature->GetExactDist(&loc) < distance) + { + sWorld.SendGMText(LANG_INSTA_KILL_GUARDIAN, + player->GetName(),player->GetGUIDLow(), + float(player->GetPositionX()),float(player->GetPositionY()),float(player->GetPositionZ()),player->GetMapId()); + sLog.outLog(LOG_CHEAT,"Player %s (%u) killed by instakill guardian, position X: %f Y: %f Z: %f Map: %u", + player->GetName(),player->GetGUIDLow(), + float(player->GetPositionX()),float(player->GetPositionY()),float(player->GetPositionZ()),player->GetMapId()); + who->Kill(player); + } + } + + void UpdateAI(const uint32 diff) + { + } +}; + +CreatureAI* GetAI_npc_instakill_guardian(Creature *_Creature) +{ + return new npc_instakill_guardianAI(_Creature); +} + void AddSC_npcs_special() { Script *newscript; @@ -2762,8 +3370,13 @@ void AddSC_npcs_special() newscript->RegisterSelf(); newscript = new Script; - newscript->Name = "npc_elemental_guardian"; - newscript->GetAI = &GetAI_npc_elemental_guardian; + newscript->Name = "npc_fire_elemental_guardian"; + newscript->GetAI = &GetAI_npc_fire_elemental_guardian; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_earth_elemental_guardian"; + newscript->GetAI = &GetAI_npc_earth_elemental_guardian; newscript->RegisterSelf(); newscript = new Script; @@ -2840,4 +3453,41 @@ void AddSC_npcs_special() newscript->Name = "npc_resurrect"; newscript->GetAI = &GetAI_npc_resurrect; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_target_dummy"; + newscript->GetAI = &GetAI_npc_target_dummy; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_explosive_sheep"; + newscript->GetAI = &GetAI_npc_explosive_sheep; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_meridith_the_mermaiden"; + newscript->pGossipHello = &GossipHello_npc_meridith_the_mermaiden; + newscript->pGossipSelect = &GossipSelect_npc_meridith_the_mermaiden; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_gnomish_flame_turret"; + newscript->GetAI = &GetAI_npc_gnomish_flame_turret; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_dummy_park_controller"; + newscript->pGossipHello = &GossipHello_npc_dummy_park; + newscript->pGossipSelect = &GossipSelect_npc_dummy_park; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_nearly_dead_combat_dummy"; + newscript->GetAI = &GetAI_npc_nearly_dead_combat_dummy; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="npc_instakill_guardian"; + newscript->GetAI = &GetAI_npc_instakill_guardian; + newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/creature/simple_ai.cpp b/src/scripts/scripts/special/simple_ai.cpp old mode 100755 new mode 100644 similarity index 89% rename from src/scripts/scripts/creature/simple_ai.cpp rename to src/scripts/scripts/special/simple_ai.cpp index 4f38a90c2..666f88070 --- a/src/scripts/scripts/creature/simple_ai.cpp +++ b/src/scripts/scripts/special/simple_ai.cpp @@ -1,18 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* ScriptData SDName: SimpleAI @@ -233,7 +236,7 @@ void SimpleAI::UpdateAI(const uint32 diff) continue; //Check Current spell - if (!(Spell[i].InterruptPreviousCast && m_creature->IsNonMeleeSpellCasted(false))) + if (!(Spell[i].InterruptPreviousCast && m_creature->IsNonMeleeSpellCast(false))) { Unit* target = NULL; @@ -259,7 +262,7 @@ void SimpleAI::UpdateAI(const uint32 diff) //Target is ok, cast a spell on it and then do our random yell if (target) { - if (m_creature->IsNonMeleeSpellCasted(false)) + if (m_creature->IsNonMeleeSpellCast(false)) m_creature->InterruptNonMeleeSpells(false); DoCast(target, Spell[i].Spell_Id); diff --git a/src/scripts/scripts/creature/simple_ai.h b/src/scripts/scripts/special/simple_ai.h old mode 100755 new mode 100644 similarity index 70% rename from src/scripts/scripts/creature/simple_ai.h rename to src/scripts/scripts/special/simple_ai.h index d1b60e402..2a050574c --- a/src/scripts/scripts/creature/simple_ai.h +++ b/src/scripts/scripts/special/simple_ai.h @@ -1,6 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef SC_SIMPLEAI_H #define SC_SIMPLEAI_H diff --git a/src/scripts/scripts/spells/spell_scripts.cpp b/src/scripts/scripts/special/spell_scripts.cpp similarity index 74% rename from src/scripts/scripts/spells/spell_scripts.cpp rename to src/scripts/scripts/special/spell_scripts.cpp index 436c32bfe..c66f8a5cf 100644 --- a/src/scripts/scripts/spells/spell_scripts.cpp +++ b/src/scripts/scripts/special/spell_scripts.cpp @@ -1,4 +1,7 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* + * Copyright (C) 2006-2008 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -130,31 +133,48 @@ bool Spell_arcane_torrent(Unit* caster, std::list &, SpellCastTargets con return true; } -bool Spell_throw_glaive(Unit* pCaster, std::list &unitList, SpellCastTargets const& targets, SpellEntry const *pSpell, uint32 effect_index) +bool Spell_strong_fetish(Unit *caster, Unit* pUnit, Item* pItem, GameObject* pGameObject, SpellEntry const *pSpell, uint32 effectIndex) { - if (effect_index != 0) + if (caster->GetTypeId() != TYPEID_PLAYER) return true; - if (unitList.empty()) - return true; - - Unit* target = NULL; - for (std::list::iterator it = unitList.begin(); it != unitList.end(); ++it) + if (Player* player = caster->ToPlayer()) { - if (!(*it)->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER)) + if (player->GetQuestStatus(10544) == QUEST_STATUS_INCOMPLETE) { - target = *it; - break; + switch (player->GetAreaId()) + { + case 3773: + player->SummonCreature(21446, player->GetPositionX()+(rand()%4), player->GetPositionY()+(rand()%4), player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + return true; + break; + case 3776: + player->SummonCreature(21452, player->GetPositionX()+(rand()%4), player->GetPositionY()+(rand()%4), player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + return true; + break; + } } + return false; } - unitList.clear(); + return true; +} + +bool Spell_coax_marmot(Unit *caster, Unit* pUnit, Item* pItem, GameObject* pGameObject, SpellEntry const *pSpell, uint32 effectIndex) +{ + if (caster->GetTypeId() != TYPEID_PLAYER) + return true; - if (target) + if (Player* player = caster->ToPlayer()) { - target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); - unitList.push_back(target); + if (player->GetQuestStatus(10720) == QUEST_STATUS_INCOMPLETE) + { + if (Creature* marmot = GetClosestCreatureWithEntry(player, 22189, 15.0f)) + player->CastSpell(marmot, 530, true); // not the correct spell, workaround + } + return false; } + return true; } @@ -183,7 +203,12 @@ void AddSC_spell_scripts() newscript->RegisterSelf(); newscript = new Script; - newscript->Name = "spell_throw_glaive"; - newscript->pSpellTargetMap = &Spell_throw_glaive; + newscript->Name = "strong_fetish"; + newscript->pSpellHandleEffect = &Spell_strong_fetish; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "coax_marmot"; + newscript->pSpellHandleEffect = &Spell_coax_marmot; newscript->RegisterSelf(); } diff --git a/src/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp b/src/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp deleted file mode 100755 index cf787c569..000000000 --- a/src/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Alterac_Mountains -SD%Complete: 100 -SDComment: Quest support: 6681 -SDCategory: Alterac Mountains -EndScriptData */ - -/* ContentData -npc_ravenholdt -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_ravenholdt -######*/ - -struct npc_ravenholdtAI : public ScriptedAI -{ - npc_ravenholdtAI(Creature *c) : ScriptedAI(c) {} - - void Reset() { } - - void MoveInLineOfSight(Unit *who) - { - if( who->GetTypeId() == TYPEID_PLAYER ) - if( ((Player*)who)->GetQuestStatus(6681) == QUEST_STATUS_INCOMPLETE ) - ((Player*)who)->KilledMonster(m_creature->GetEntry(),m_creature->GetGUID() ); - } -}; - -CreatureAI* GetAI_npc_ravenholdt(Creature *_Creature) -{ - return new npc_ravenholdtAI (_Creature); -} - -void AddSC_alterac_mountains() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_ravenholdt"; - newscript->GetAI = &GetAI_npc_ravenholdt; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/alterac_valley/boss_drekthar.cpp b/src/scripts/scripts/zone/alterac_valley/boss_drekthar.cpp deleted file mode 100755 index fea108fb0..000000000 --- a/src/scripts/scripts/zone/alterac_valley/boss_drekthar.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_DrekThar -SD%Complete: 50% -SDComment: Some spells listed on wowwiki but doesn't exist on wowhead -EndScriptData */ - -#include "precompiled.h" - -#define YELL_AGGRO -2100000 - -#define YELL_EVADE -2100001 -#define YELL_RESPAWN -2100002 - -#define YELL_RANDOM1 -2100003 -#define YELL_RANDOM2 -2100004 -#define YELL_RANDOM3 -2100005 -#define YELL_RANDOM4 -2100006 -#define YELL_RANDOM5 -2100007 - - -#define SPELL_WHIRLWIND 15589 -#define SPELL_WHIRLWIND2 13736 -#define SPELL_KNOCKDOWN 19128 -#define SPELL_FRENZY 8269 -#define SPELL_SWEEPING_STRIKES 18765 // not sure -#define SPELL_CLEAVE 20677 // not sure -#define SPELL_WINDFURY 35886 // not sure -#define SPELL_STORMPIKE 51876 // not sure - - -struct boss_drektharAI : public ScriptedAI -{ - boss_drektharAI(Creature *c) : ScriptedAI(c) - { - m_creature->GetPosition(wLoc); - } - - uint32 WhirlwindTimer; - uint32 Whirlwind2Timer; - uint32 KnockdownTimer; - uint32 FrenzyTimer; - uint32 YellTimer; - uint32 CheckTimer; - WorldLocation wLoc; - - void Reset() - { - WhirlwindTimer = urand(0, 10000); - Whirlwind2Timer = urand(0, 15000); - KnockdownTimer = 12000; - FrenzyTimer = 6000; - YellTimer = urand(20000, 30000); //20 to 30 seconds - CheckTimer = 2000; - } - - void EnterCombat(Unit *who) - { - DoScriptText(YELL_AGGRO, m_creature); - } - - void JustRespawned() - { - Reset(); - DoScriptText(YELL_RESPAWN, m_creature); - } - - void KilledUnit(Unit* victim){} - - void JustDied(Unit* Killer){} - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if(CheckTimer < diff) - { - if(!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) - EnterEvadeMode(); - - CheckTimer = 2000; - } - else - CheckTimer -= diff; - - if (WhirlwindTimer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_WHIRLWIND); - WhirlwindTimer = urand(8000, 18000); - } - else - WhirlwindTimer -= diff; - - if (Whirlwind2Timer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_WHIRLWIND2); - Whirlwind2Timer = urand(7000, 25000); - } - else - Whirlwind2Timer -= diff; - - if (KnockdownTimer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_KNOCKDOWN); - KnockdownTimer = urand(10000, 15000); - } - else - KnockdownTimer -= diff; - - if (FrenzyTimer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_FRENZY); - FrenzyTimer = urand(20000, 25000); - } - else - FrenzyTimer -= diff; - - if (YellTimer < diff) - { - DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5), m_creature); - YellTimer = urand(20000, 30000); //20 to 30 seconds - } - else - YellTimer -= diff; - - CastNextSpellIfAnyAndReady(); - DoMeleeAttackIfReady(); - } -}; - - -CreatureAI* GetAI_boss_drekthar(Creature *_Creature) -{ - return new boss_drektharAI (_Creature); -} - -void AddSC_boss_drekthar() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "boss_drekthar"; - newscript->GetAI = &GetAI_boss_drekthar; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/alterac_valley/boss_vanndar.cpp b/src/scripts/scripts/zone/alterac_valley/boss_vanndar.cpp deleted file mode 100755 index 7b86d12aa..000000000 --- a/src/scripts/scripts/zone/alterac_valley/boss_vanndar.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Vanndar -SD%Complete: -SDComment: Some spells listed on wowwiki but doesn't exist on wowhead -EndScriptData */ - -#include "precompiled.h" - -#define YELL_AGGRO -2100008 - -#define YELL_EVADE -2100009 -#define YELL_RESPAWN1 -2100010 -#define YELL_RESPAWN2 -2100011 - -#define YELL_RANDOM1 -2100012 -#define YELL_RANDOM2 -2100013 -#define YELL_RANDOM3 -2100014 -#define YELL_RANDOM4 -2100015 -#define YELL_RANDOM5 -2100016 -#define YELL_RANDOM6 -2100017 -#define YELL_RANDOM7 -2100018 - - -#define SPELL_AVATAR 19135 -#define SPELL_THUNDERCLAP 15588 -#define SPELL_STORMBOLT 20685 // not sure - - -struct boss_vanndarAI : public ScriptedAI -{ - boss_vanndarAI(Creature *c) : ScriptedAI(c) - { - m_creature->GetPosition(wLoc); - } - - uint32 AvatarTimer; - uint32 ThunderclapTimer; - uint32 StormboltTimer; - uint32 YellTimer; - uint32 CheckTimer; - WorldLocation wLoc; - - void Reset() - { - AvatarTimer = 3000; - ThunderclapTimer = 4000; - StormboltTimer = 6000; - YellTimer = urand(20000, 30000); //20 to 30 seconds - CheckTimer = 2000; - } - - void EnterCombat(Unit *who) - { - DoScriptText(YELL_AGGRO, m_creature); - } - - void JustRespawned() - { - Reset(); - DoScriptText(RAND(YELL_RESPAWN1, YELL_RESPAWN2), m_creature); - } - - void KilledUnit(Unit* victim){} - - void JustDied(Unit* Killer){} - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (CheckTimer < diff) - { - if (!m_creature->IsWithinDistInMap(&wLoc, 20.0f)) - EnterEvadeMode(); - - CheckTimer = 2000; - } - else - CheckTimer -= diff; - - if (AvatarTimer < diff) - { - ForceSpellCast(m_creature->getVictim(), SPELL_AVATAR); - AvatarTimer = urand(15000, 20000); - } - else - AvatarTimer -= diff; - - if (ThunderclapTimer < diff) - { - AddSpellToCast(m_creature->getVictim(), SPELL_THUNDERCLAP); - ThunderclapTimer = urand(5000, 15000); - } - else - ThunderclapTimer -= diff; - - if (StormboltTimer < diff) - { - Unit * victim = SelectUnit(SELECT_TARGET_RANDOM, 1, 30.0f, true); - if (victim) - AddSpellToCast(victim, SPELL_STORMBOLT); - StormboltTimer = urand(10000, 25000); - } - else - StormboltTimer -= diff; - - if (YellTimer < diff) - { - DoScriptText(RAND(YELL_RANDOM1, YELL_RANDOM2, YELL_RANDOM3, YELL_RANDOM4, YELL_RANDOM5, YELL_RANDOM6, YELL_RANDOM7), m_creature); - YellTimer = urand(20000, 30000); //20 to 30 seconds - } - else - YellTimer -= diff; - - CastNextSpellIfAnyAndReady(); - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_vanndar(Creature *_Creature) -{ - return new boss_vanndarAI (_Creature); -} - -void AddSC_boss_vanndar() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "boss_vanndar"; - newscript->GetAI = &GetAI_boss_vanndar; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/aunchindoun/mana_tombs/def_mana_tombs.h b/src/scripts/scripts/zone/aunchindoun/mana_tombs/def_mana_tombs.h deleted file mode 100644 index 73a87b960..000000000 --- a/src/scripts/scripts/zone/aunchindoun/mana_tombs/def_mana_tombs.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef DEF_MANA_TOMBS_H -#define DEF_MANA_TOMBS_H - -#define DATA_YOREVENT 1 -#define DATA_PANDEMONIUSEVENT 2 -#define DATA_NEXUSPRINCEEVENT 3 - -#endif diff --git a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h b/src/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h deleted file mode 100755 index 20b844fad..000000000 --- a/src/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SETHEKK_HALLS_H -#define DEF_SETHEKK_HALLS_H - -#define DATA_IKISSEVENT 1 -#define DATA_ANZUEVENT 2 -#define DATA_DARKWEAVEREVENT 3 -#endif - diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp b/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp deleted file mode 100755 index 8008b5b5d..000000000 --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Murmur -SD%Complete: 90 -SDComment: Timers may be incorrect -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" - -#define EMOTE_SONIC_BOOM -1555036 - -#define SPELL_SONIC_BOOM_CAST (HeroicMode?38796:33923) -#define SPELL_SONIC_BOOM_EFFECT (HeroicMode?38795:33666) -#define SPELL_RESONANCE 33657 -#define SPELL_MURMURS_TOUCH (HeroicMode?38794:33711) -#define SPELL_MAGNETIC_PULL 33689 -#define SPELL_SONIC_SHOCK 38797 -#define SPELL_THUNDERING_STORM 39365 - -struct boss_murmurAI : public Scripted_NoMovementAI -{ - boss_murmurAI(Creature *c) : Scripted_NoMovementAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - uint32 SonicBoom_Timer; - uint32 MurmursTouch_Timer; - uint32 Resonance_Timer; - uint32 MagneticPull_Timer; - uint32 SonicShock_Timer; - uint32 ThunderingStorm_Timer; - bool HeroicMode; - - void Reset() - { - SonicBoom_Timer = 30000; - MurmursTouch_Timer = 20000; - Resonance_Timer = 10000; - MagneticPull_Timer = 20000; - ThunderingStorm_Timer = 15000; - SonicShock_Timer = 10000; - - //database should have `RegenHealth`=0 to prevent regen - uint32 hp = (m_creature->GetMaxHealth()*40)/100; - if (hp) - m_creature->SetHealth(hp); - - m_creature->ResetPlayerDamageReq(); - } - - void EnterCombat(Unit *who) { } - - // Sonic Boom instant damage (needs core fix instead of this) - void SpellHitTarget(Unit *target, const SpellEntry *spell) - { - if(target && target->isAlive() && spell && spell->Id == SPELL_SONIC_BOOM_EFFECT) - m_creature->DealDamage(target, (target->GetHealth()*90)/100, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NATURE, spell); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target or casting - if (!UpdateVictim() || m_creature->IsNonMeleeSpellCasted(false)) - return; - - // Murmur's Touch - if (MurmursTouch_Timer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 80, true)) - AddSpellToCast(target, SPELL_MURMURS_TOUCH); - - MurmursTouch_Timer = 30000; - } - else - MurmursTouch_Timer -= diff; - - // Resonance - if(Resonance_Timer < diff) - { - if(!m_creature->hasUnitState(UNIT_STAT_CASTING)) - { - Unit *target = SelectUnit(SELECT_TARGET_NEAREST, 0, 100, true); - - if(target && !m_creature->IsWithinMeleeRange(target)) - AddSpellToCast(m_creature, SPELL_RESONANCE); - - Resonance_Timer = 5000; - } - else - Resonance_Timer = 2000; - } - else - Resonance_Timer -= diff; - - if(HeroicMode) - { - // Thundering Storm - if(ThunderingStorm_Timer < diff) - { - ForceSpellCast(SPELL_THUNDERING_STORM, CAST_NULL, DONT_INTERRUPT); - - ThunderingStorm_Timer = 5000; - } - else - ThunderingStorm_Timer -= diff; - - // Sonic Shock - if(SonicShock_Timer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, false)) - AddSpellToCast(target, SPELL_SONIC_SHOCK); - - SonicShock_Timer = urand(10000, 20000); - } - else - SonicShock_Timer -= diff; - } - - // Magnetic Pull - if (MagneticPull_Timer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) - { - ForceSpellCast(target, SPELL_MAGNETIC_PULL); - MagneticPull_Timer = urand (20000, 35000); - } - else - MagneticPull_Timer = 500; - } - else - MagneticPull_Timer -= diff; - - // Sonic Boom - if(SonicBoom_Timer < diff) - { - ForceSpellCast(m_creature, SPELL_SONIC_BOOM_EFFECT, DONT_INTERRUPT, true); - ForceSpellCastWithScriptText(m_creature, SPELL_SONIC_BOOM_CAST, EMOTE_SONIC_BOOM); - SonicBoom_Timer = 30000; - Resonance_Timer = 1500; - } - else - SonicBoom_Timer -= diff; - - CastNextSpellIfAnyAndReady(); - - // Select nearest most aggro target if top aggro too far - if(!m_creature->isAttackReady()) - return; - - if(!m_creature->IsWithinMeleeRange(m_creature->getVictim())) - { - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - for(std::list::iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) - { - if(Unit* target = Unit::GetUnit((*m_creature),(*i)->getUnitGuid())) - { - if(target->isAlive() && m_creature->IsWithinMeleeRange(target)) - { - m_creature->TauntApply(target); - break; - } - } - } - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_murmur(Creature *_Creature) -{ - return new boss_murmurAI (_Creature); -} - -void AddSC_boss_murmur() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_murmur"; - newscript->GetAI = &GetAI_boss_murmur; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h b/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h deleted file mode 100755 index 9f60fff71..000000000 --- a/src/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHADOW_LABYRINTH_H -#define DEF_SHADOW_LABYRINTH_H - -#define TYPE_HELLMAW 1 -#define TYPE_RITUALIST 2 -#define DATA_BLACKHEARTTHEINCITEREVENT 3 -#define DATA_GRANDMASTERVORPILEVENT 4 -#define DATA_MURMUREVENT 5 -#define DATA_GRANDMASTERVORPIL 6 -#endif - diff --git a/src/scripts/scripts/zone/blackrock_depths/def_blackrock_depths.h b/src/scripts/scripts/zone/blackrock_depths/def_blackrock_depths.h deleted file mode 100755 index 6dc5cd828..000000000 --- a/src/scripts/scripts/zone/blackrock_depths/def_blackrock_depths.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_BRD_H -#define DEF_BRD_H - -#define TYPE_RING_OF_LAW 1 -#define TYPE_VAULT 2 -#define TYPE_BAR 3 -#define TYPE_TOMB_OF_SEVEN 4 -#define TYPE_LYCEUM 5 -#define TYPE_IRON_HALL 6 -#define TYPE_THELDREN 7 - -#define DATA_EMPEROR 10 -#define DATA_PHALANX 11 - -#define DATA_ARENA1 12 -#define DATA_ARENA2 13 -#define DATA_ARENA3 14 -#define DATA_ARENA4 15 - -#define DATA_GO_BAR_KEG 16 -#define DATA_GO_BAR_KEG_TRAP 17 -#define DATA_GO_BAR_DOOR 18 - -#define DATA_QUEST_JAIL_BREAK 19 -#define DATA_DUGHAL 20 - -#define DATA_SUPPLY_ROOM 21 -#define DATA_SHILL 22 -#define DATA_JAZ 23 -#define DATA_TOBIAS 24 -#define DATA_CREST 25 - -#define Q_STARTER 26 - -#endif \ No newline at end of file diff --git a/src/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp b/src/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp deleted file mode 100755 index 5b8332dd3..000000000 --- a/src/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Pyroguard_Emberseer -SD%Complete: 100 -SDComment: Event to activate Emberseer NYI -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIRENOVA 23462 -#define SPELL_FLAMEBUFFET 23341 -#define SPELL_PYROBLAST 17274 - -struct boss_pyroguard_emberseerAI : public ScriptedAI -{ - boss_pyroguard_emberseerAI(Creature *c) : ScriptedAI(c) {} - - uint32 FireNova_Timer; - uint32 FlameBuffet_Timer; - uint32 PyroBlast_Timer; - - void Reset() - { - FireNova_Timer = 6000; - FlameBuffet_Timer = 3000; - PyroBlast_Timer = 14000; - } - - void EnterCombat(Unit *who) - { - } - - void JustDied(Unit* killer) - { - if(GameObject* door = FindGameObject(175153, 100, killer)) - { - door->Use(killer); - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!UpdateVictim() ) - return; - - //FireNova_Timer - if (FireNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIRENOVA); - FireNova_Timer = 6000; - }else FireNova_Timer -= diff; - - //FlameBuffet_Timer - if (FlameBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBUFFET); - FlameBuffet_Timer = 14000; - }else FlameBuffet_Timer -= diff; - - //PyroBlast_Timer - if (PyroBlast_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_PYROBLAST); - PyroBlast_Timer = 15000; - }else PyroBlast_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_pyroguard_emberseer(Creature *_Creature) -{ - return new boss_pyroguard_emberseerAI (_Creature); -} - -void AddSC_boss_pyroguard_emberseer() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_pyroguard_emberseer"; - newscript->GetAI = &GetAI_boss_pyroguard_emberseer; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/caverns_of_time/dark_portal/def_dark_portal.h b/src/scripts/scripts/zone/caverns_of_time/dark_portal/def_dark_portal.h deleted file mode 100755 index f9e2e8605..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/dark_portal/def_dark_portal.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_DARKPORTAL_H -#define DEF_DARKPORTAL_H - -#define TYPE_MEDIVH 1 -#define TYPE_RIFT 2 -#define TYPE_C_DEJA 3 -#define TYPE_TEMPORUS 4 - -#define DATA_MEDIVH 10 -#define DATA_PORTAL_COUNT 11 -#define DATA_SHIELD 12 - -#define WORLD_STATE_BM 2541 -#define WORLD_STATE_BM_SHIELD 2540 -#define WORLD_STATE_BM_RIFT 2784 - -#define QUEST_OPENING_PORTAL 10297 -#define QUEST_MASTER_TOUCH 9836 - -#define C_TIME_KEEPER 17918 - -#endif - diff --git a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.h b/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.h deleted file mode 100755 index c18868b06..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/hyjal/hyjal_trash.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef SC_HYJAL_TRASH_AI_H -#define SC_HYJAL_TRASH_AI_H - -#include "def_hyjal.h" -#include "escort_ai.h" - -#define MINRAIDDAMAGE 700000//minimal damage before trash can drop loot and reputation, resets if faction leader dies - -struct hyjal_trashAI : public npc_escortAI -{ - hyjal_trashAI(Creature *c); - - void UpdateAI(const uint32 diff); - - void JustDied(Unit* killer); - - void DamageTaken(Unit *done_by, uint32 &damage); - - public: - ScriptedInstance* pInstance; - bool IsEvent; - uint32 Delay; - uint32 LastOverronPos; - bool IsOverrun; - bool SetupOverrun; - uint32 OverrunType; - uint8 faction; - bool useFlyPath; - uint32 damageTaken; - float DummyTarget[3]; - - //private: -}; -#endif diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp b/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp deleted file mode 100755 index 4a63ebfb4..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Captain_Skarloc -SD%Complete: 75 -SDComment: Missing adds, missing waypoints to move up to Thrall once spawned + speech before enter combat. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" - -#define SAY_ENTER -1560000 -#define SAY_TAUNT1 -1560001 -#define SAY_TAUNT2 -1560002 -#define SAY_SLAY1 -1560003 -#define SAY_SLAY2 -1560004 -#define SAY_DEATH -1560005 - -#define SPELL_HOLY_LIGHT 29427 -#define SPELL_CLEANSE 29380 -#define SPELL_HAMMER_OF_JUSTICE 13005 -#define SPELL_HOLY_SHIELD 31904 -#define SPELL_DEVOTION_AURA 8258 -#define SPELL_CONSECRATION 38385 - -#define C_WARDEN 17833 -#define C_VETERAN 17860 - -struct boss_captain_skarlocAI : public ScriptedAI -{ - boss_captain_skarlocAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - ScriptedInstance *pInstance; - - bool HeroicMode; - - uint32 Holy_Light_Timer; - uint32 Cleanse_Timer; - uint32 HammerOfJustice_Timer; - uint32 HolyShield_Timer; - uint32 DevotionAura_Timer; - uint32 Consecration_Timer; - - void Reset() - { - Holy_Light_Timer = 30000; - Cleanse_Timer = 10000; - HammerOfJustice_Timer = 60000; - HolyShield_Timer = 240000; - DevotionAura_Timer = 3000; - Consecration_Timer = 8000; - } - - void EnterCombat(Unit *who) - { - if(Creature *tAdd1 = DoSpawnCreature( C_WARDEN, 2, 2, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000)) - tAdd1->AI()->AttackStart(who); - - if(Creature *tAdd2 = DoSpawnCreature( C_VETERAN, -2, -2, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000)) - tAdd2->AI()->AttackStart(who); - - //This is not correct. Should taunt Thrall before engage in combat - DoScriptText(SAY_TAUNT1, m_creature); - DoScriptText(SAY_TAUNT2, m_creature); - } - - void KilledUnit(Unit *victim) - { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); - } - - void JustDied(Unit *victim) - { - DoScriptText(SAY_DEATH, m_creature); - - if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS) - pInstance->SetData(TYPE_THRALL_PART1, DONE); - - if (pInstance->GetData(DATA_SKARLOC_DEATH) == DONE) - m_creature->SetLootRecipient(NULL); - else - pInstance->SetData(DATA_SKARLOC_DEATH, DONE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!UpdateVictim() ) - return; - - //Holy_Light - if (Holy_Light_Timer < diff) - { - DoCast(m_creature, SPELL_HOLY_LIGHT); - Holy_Light_Timer = 30000; - } - else - Holy_Light_Timer -= diff; - - //Cleanse - if(Cleanse_Timer < diff) - { - DoCast(m_creature, SPELL_CLEANSE); - Cleanse_Timer = 10000; - } - else - Cleanse_Timer -= diff; - - //Hammer of Justice - if (HammerOfJustice_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HAMMER_OF_JUSTICE); - HammerOfJustice_Timer = 60000; - } - else - HammerOfJustice_Timer -= diff; - - //Holy Shield - if(HolyShield_Timer < diff) - { - DoCast(m_creature, SPELL_HOLY_SHIELD); - HolyShield_Timer = 240000; - } - else - HolyShield_Timer -= diff; - - //Devotion_Aura - if (DevotionAura_Timer < diff) - { - DoCast(m_creature, SPELL_DEVOTION_AURA); - DevotionAura_Timer = 60000; - } - else - DevotionAura_Timer -= diff; - - if(HeroicMode) - if(Consecration_Timer < diff) - { - DoCast(m_creature, SPELL_CONSECRATION); - Consecration_Timer = 8000; - } - else - Consecration_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_captain_skarloc(Creature *_Creature) -{ - return new boss_captain_skarlocAI (_Creature); -} - -void AddSC_boss_captain_skarloc() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_captain_skarloc"; - newscript->GetAI = &GetAI_boss_captain_skarloc; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp b/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp deleted file mode 100755 index 9e1f2c1ad..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Epoch_Hunter -SD%Complete: 60 -SDComment: Missing spawns pre-event, missing speech to be coordinated with rest of escort event. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" - -#define SAY_ENTER1 -1560013 -#define SAY_ENTER2 -1560014 -#define SAY_ENTER3 -1560015 -#define SAY_AGGRO1 -1560016 -#define SAY_AGGRO2 -1560017 -#define SAY_SLAY1 -1560018 -#define SAY_SLAY2 -1560019 -#define SAY_BREATH1 -1560020 -#define SAY_BREATH2 -1560021 -#define SAY_DEATH -1560022 - -#define SPELL_SAND_BREATH 31914 -#define SPELL_IMPENDING_DEATH 31916 -#define SPELL_MAGIC_DISRUPTION_AURA 33834 -#define SPELL_WING_BUFFET HeroicMode ? 31475:38593 - -struct boss_epoch_hunterAI : public ScriptedAI -{ - boss_epoch_hunterAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - ScriptedInstance *pInstance; - - bool HeroicMode; - - uint32 SandBreath_Timer; - uint32 ImpendingDeath_Timer; - uint32 WingBuffet_Timer; - uint32 Mda_Timer; - - void Reset() - { - SandBreath_Timer = 25000; - ImpendingDeath_Timer = 30000; - WingBuffet_Timer = 35000; - Mda_Timer = 40000; - } - - void EnterCombat(Unit *who) - { - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2), m_creature); - } - - void KilledUnit(Unit *victim) - { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), m_creature); - } - - void JustDied(Unit *victim) - { - DoScriptText(SAY_DEATH, m_creature); - - if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS) - pInstance->SetData(TYPE_THRALL_PART4, DONE); - - if (pInstance->GetData(DATA_EPOCH_DEATH) == DONE) - m_creature->SetLootRecipient(NULL); - else - pInstance->SetData(DATA_EPOCH_DEATH, DONE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!UpdateVictim() ) - return; - - //Sand Breath - if (SandBreath_Timer < diff) - { - if (m_creature->IsNonMeleeSpellCasted(false)) - m_creature->InterruptNonMeleeSpells(false); - - DoCast(m_creature->getVictim(),SPELL_SAND_BREATH); - - DoScriptText(RAND(SAY_BREATH1, SAY_BREATH2), m_creature); - - SandBreath_Timer = 25000+rand()%5000; - } - else - SandBreath_Timer -= diff; - - if(ImpendingDeath_Timer < diff) - { - if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0 , GetSpellMaxRange(SPELL_IMPENDING_DEATH), true)) - DoCast(target,SPELL_IMPENDING_DEATH); - ImpendingDeath_Timer = 30000+rand()%5000; - } - else - ImpendingDeath_Timer -= diff; - - if(WingBuffet_Timer < diff) - { - DoCast(m_creature,SPELL_WING_BUFFET); - WingBuffet_Timer = 25000+rand()%10000; - } - else - WingBuffet_Timer -= diff; - - if(Mda_Timer < diff) - { - DoCast(m_creature,SPELL_MAGIC_DISRUPTION_AURA); - Mda_Timer = 15000; - } - else - Mda_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_epoch_hunter(Creature *_Creature) -{ - return new boss_epoch_hunterAI (_Creature); -} - -void AddSC_boss_epoch_hunter() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_epoch_hunter"; - newscript->GetAI = &GetAI_boss_epoch_hunter; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h b/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h deleted file mode 100755 index 455bcbc5a..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_OLD_HILLSBRAD_H -#define DEF_OLD_HILLSBRAD_H - -#define TYPE_BARREL_DIVERSION 1 -#define TYPE_THRALL_EVENT 2 -#define TYPE_THRALL_PART1 3 -#define TYPE_THRALL_PART2 4 -#define TYPE_THRALL_PART3 5 -#define TYPE_THRALL_PART4 6 -#define DATA_THRALL 7 -#define DATA_TARETHA 8 -#define DATA_EPOCH 9 -#define DATA_SKARLOC_DEATH 10 -#define DATA_DRAKE_DEATH 11 -#define DATA_EPOCH_DEATH 12 -#define WORLD_STATE_OH 2436 - -#endif - diff --git a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp deleted file mode 100755 index 2cede95a5..000000000 --- a/src/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp +++ /dev/null @@ -1,875 +0,0 @@ - /* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Old_Hillsbrad -SD%Complete: 40 -SDComment: Quest support: 10283, 10284. All friendly NPC's. Thrall waypoints fairly complete, missing many details, but possible to complete escort. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -/* ContentData -npc_brazen -npc_erozion -npc_thrall_old_hillsbrad -npc_taretha -EndContentData */ - -#include "precompiled.h" -#include "escort_ai.h" -#include "def_old_hillsbrad.h" - -#define QUEST_ENTRY_HILLSBRAD 10282 -#define QUEST_ENTRY_DIVERSION 10283 -#define QUEST_ENTRY_ESCAPE 10284 -#define QUEST_ENTRY_RETURN 10285 -#define ITEM_ENTRY_BOMBS 25853 - -/*###### -## npc_brazen -######*/ - -bool GossipHello_npc_brazen(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM(0, "I am ready to go to Durnholde Keep.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_brazen(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - if( !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) - player->SEND_GOSSIP_MENU(9780, _Creature->GetGUID()); - else - { - player->CLOSE_GOSSIP_MENU(); - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 115; //from brazen - nodes[1] = 116; //end outside durnholde - player->ActivateTaxiPathTo(nodes); //TaxiPath 534 - } - } - return true; -} - -/*###### -## npc_erozion -######*/ - -bool GossipHello_npc_erozion(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); - if( pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) - player->ADD_GOSSIP_ITEM( 0, "I need a pack of Incendiary Bombs.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - if( !player->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && player->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE ) - player->ADD_GOSSIP_ITEM( 0, "[PH] Teleport please, i'm tired.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->SEND_GOSSIP_MENU(9778, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_erozion(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_ENTRY_BOMBS, 1); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem(dest, ITEM_ENTRY_BOMBS, true); - } - player->SEND_GOSSIP_MENU(9515, _Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_INFO_DEF+2 ) - { - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -/*###### -## npc_thrall_old_hillsbrad -######*/ - -//Thrall texts -#define SAY_TH_START_EVENT_PART1 -1560023 -#define SAY_TH_ARMORY -1560024 -#define SAY_TH_SKARLOC_MEET -1560025 -#define SAY_TH_SKARLOC_TAUNT -1560026 -#define SAY_TH_START_EVENT_PART2 -1560027 -#define SAY_TH_MOUNTS_UP -1560028 -#define SAY_TH_CHURCH_END -1560029 -#define SAY_TH_MEET_TARETHA -1560030 -#define SAY_TH_EPOCH_WONDER -1560031 -#define SAY_TH_EPOCH_KILL_TARETHA -1560032 -#define SAY_TH_EVENT_COMPLETE -1560033 - -#define SAY_TH_RANDOM_LOW_HP1 -1560034 -#define SAY_TH_RANDOM_LOW_HP2 -1560035 - -#define SAY_TH_RANDOM_DIE1 -1560036 -#define SAY_TH_RANDOM_DIE2 -1560037 - -#define SAY_TH_RANDOM_AGGRO1 -1560038 -#define SAY_TH_RANDOM_AGGRO2 -1560039 -#define SAY_TH_RANDOM_AGGRO3 -1560040 -#define SAY_TH_RANDOM_AGGRO4 -1560041 - -#define SAY_TH_RANDOM_KILL1 -1560042 -#define SAY_TH_RANDOM_KILL2 -1560043 -#define SAY_TH_RANDOM_KILL3 -1560044 - -#define SAY_TH_LEAVE_COMBAT1 -1560045 -#define SAY_TH_LEAVE_COMBAT2 -1560046 -#define SAY_TH_LEAVE_COMBAT3 -1560047 - -//Taretha texts -#define SAY_TA_FREE -1560048 -#define SAY_TA_ESCAPED -1560049 - -//Misc for Thrall -#define SPELL_STRIKE 14516 -#define SPELL_SHIELD_BLOCK 12169 -#define SPELL_SUMMON_EROZION_IMAGE 33954 //if thrall dies during escort? - -#define SPEED_WALK (0.5f) -#define SPEED_RUN (1.0f) -#define SPEED_MOUNT (1.6f) - -#define THRALL_WEAPON_MODEL 22106 -#define THRALL_WEAPON_INFO 218169346 -#define THRALL_SHIELD_MODEL 18662 -#define THRALL_SHIELD_INFO 234948100 -#define THRALL_MODEL_UNEQUIPPED 17292 -#define THRALL_MODEL_EQUIPPED 18165 - -//Misc creature entries -#define ENTRY_ARMORER 18764 -#define ENTRY_SCARLOC 17862 - -#define MOB_ENTRY_RIFLE 17820 -#define MOB_ENTRY_WARDEN 17833 -#define MOB_ENTRY_VETERAN 17860 -#define MOB_ENTRY_WATCHMAN 17814 -#define MOB_ENTRY_SENTRY 17815 - -#define MOB_ENTRY_BARN_GUARDSMAN 18092 -#define MOB_ENTRY_BARN_PROTECTOR 18093 -#define MOB_ENTRY_BARN_LOOKOUT 18094 - -#define MOB_ENTRY_CHURCH_GUARDSMAN 23175 -#define MOB_ENTRY_CHURCH_PROTECTOR 23179 -#define MOB_ENTRY_CHURCH_LOOKOUT 23177 - -#define MOB_ENTRY_INN_GUARDSMAN 23176 -#define MOB_ENTRY_INN_PROTECTOR 23180 -#define MOB_ENTRY_INN_LOOKOUT 23178 - -#define SKARLOC_MOUNT 18798 -#define SKARLOC_MOUNT_MODEL 18223 -#define EROZION_ENTRY 18723 -#define ENTRY_EPOCH 18096 - -//gossip items -#define GOSSIP_ID_START 9568 -#define GOSSIP_ID_SKARLOC1 9614 //I'm glad Taretha is alive. We now must find a way to free her... -#define GOSSIP_ITEM_SKARLOC1 "Taretha cannot see you, Thrall." -#define GOSSIP_ID_SKARLOC2 9579 //What do you mean by this? Is Taretha in danger? -#define GOSSIP_ITEM_SKARLOC2 "The situation is rather complicated, Thrall. It would be best for you to head into the mountains now, before more of Blackmoore's men show up. We'll make sure Taretha is safe." -#define GOSSIP_ID_SKARLOC3 9580 - -#define GOSSIP_ID_TARREN 9597 //tarren mill is beyond these trees -#define GOSSIP_ITEM_TARREN "We're ready, Thrall." - -#define GOSSIP_ID_COMPLETE 9578 //Thank you friends, I owe my freedom to you. Where is Taretha? I hoped to see her - -struct npc_thrall_old_hillsbradAI : public npc_escortAI -{ - npc_thrall_old_hillsbradAI(Creature *c) : npc_escortAI(c) - { - pInstance = (c->GetInstanceData()); - HadMount = false; - m_creature->setActive(true); - } - - ScriptedInstance *pInstance; - - uint64 TarethaGUID; - uint32 WaitTimer; - - bool LowHp; - bool HadMount; - - void WaypointReached(uint32 i) - { - switch (i) - { - case 8: - SetRun(false); - m_creature->SummonCreature(18764, 2181.87, 112.46, 89.45, 0.26, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - break; - case 9: - DoScriptText(SAY_TH_ARMORY, m_creature); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038); - break; - case 10: - m_creature->SetDisplayId(THRALL_MODEL_EQUIPPED); - break; - case 11: - SetRun(); - break; - case 15: - m_creature->SummonCreature(MOB_ENTRY_RIFLE,2200.28,137.37,87.93,5.07,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_WARDEN,2197.44,131.83,87.93,0.78,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2203.62,135.40,87.93,3.70,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2200.75,130.13,87.93,1.48,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 21: - m_creature->SummonCreature(MOB_ENTRY_RIFLE,2135.80,154.01,67.45,4.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_WARDEN,2144.36,151.87,67.74,4.46,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2142.12,154.41,67.12,4.56,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2138.08,155.38,67.24,4.60,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 25: - m_creature->SummonCreature(MOB_ENTRY_RIFLE,2102.98,192.17,65.24,6.02,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_WARDEN,2108.48,198.75,65.18,5.15,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2106.11,197.29,65.18,5.63,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_VETERAN,2104.18,194.82,65.18,5.75,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 29: - DoScriptText(SAY_TH_SKARLOC_MEET, m_creature); - m_creature->SummonCreature(17862,2036.48,271.22,63.43,5.27,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000); - //temporary,skarloc should rather be triggered to walk up to thrall - break; - case 30: - SetEscortPaused(true); - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - SetRun(false); - break; - case 31: - DoScriptText(SAY_TH_MOUNTS_UP, m_creature); - DoMount(); - SetRun(); - break; - case 37: - //possibly regular patrollers? If so, remove this and let database handle them - m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2124.26,522.16,56.87,3.99,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2121.69,525.37,57.11,4.01,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_SENTRY,2124.65,524.55,56.63,3.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 59: - m_creature->SummonCreature(SKARLOC_MOUNT,2488.64,625.77,58.26,4.71,TEMPSUMMON_TIMED_DESPAWN,10000); - DoUnmount(); - HadMount = false; - SetRun(false); - break; - case 60: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - //make horsie run off - SetEscortPaused(true); - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - pInstance->SetData(TYPE_THRALL_PART2, DONE); - SetRun(); - break; - case 64: - SetRun(false); - break; - case 68: - m_creature->SummonCreature(MOB_ENTRY_BARN_PROTECTOR,2500.22,692.60,55.50,2.84,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_LOOKOUT,2500.13,696.55,55.51,3.38,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.55,693.64,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.94,695.81,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 71: - SetRun(); - break; - case 81: - SetRun(false); - break; - case 83: - m_creature->SummonCreature(MOB_ENTRY_CHURCH_PROTECTOR,2627.33,646.82,56.03,4.28,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - m_creature->SummonCreature(MOB_ENTRY_CHURCH_LOOKOUT,2624.14,648.03,56.03,4.50,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2625.32,649.60,56.03,4.38,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2627.22,649.00,56.03,4.34,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - break; - case 84: - DoScriptText(SAY_TH_CHURCH_END, m_creature); - SetRun(); - break; - case 91: - SetRun(false); - break; - case 93: - m_creature->SummonCreature(MOB_ENTRY_INN_PROTECTOR,2652.71,660.31,61.93,1.67,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_INN_LOOKOUT,2648.96,662.59,61.93,0.79,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2657.36,662.34,61.93,2.68,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2656.39,659.77,61.93,2.61,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 94: - if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) - if (Unit* Taretha = Unit::GetUnit((*m_creature), TarethaGUID)) - DoScriptText(SAY_TA_ESCAPED, Taretha, m_creature); - break; - case 95: - DoScriptText(SAY_TH_MEET_TARETHA, m_creature); - pInstance->SetData(TYPE_THRALL_PART3,DONE); - SetEscortPaused(true); - break; - case 96: - DoScriptText(SAY_TH_EPOCH_WONDER, m_creature); - break; - case 97: - DoScriptText(SAY_TH_EPOCH_KILL_TARETHA, m_creature); - SetRun(); - break; - case 98: - //trigger epoch Yell("Thrall! Come outside and face your fate! ....") - //from here, thrall should not never be allowed to move to point 106 which he currently does. - break; - - case 106: - { - //trigger taretha to run down outside - if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA)) - { - if (Creature* Taretha = (Unit::GetCreature(*m_creature, TarethaGUID))) - { - if (Player* pPlayer = GetPlayerForEscort()) - CAST_AI(npc_escortAI, (Taretha->AI()))->Start(false, true, pPlayer->GetGUID()); - } - } - - //kill credit Creature for quest - Map* pMap = m_creature->GetMap(); - Map::PlayerList const& players = pMap->GetPlayers(); - if (!players.isEmpty() && pMap->IsDungeon()) - { - for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - if (Player* pPlayer = itr->getSource()) - pPlayer->KilledMonster(20156,m_creature->GetGUID()); - } - } - - //alot will happen here, thrall and taretha talk, erozion appear at spot to explain - m_creature->SummonCreature(EROZION_ENTRY,2646.47,680.416,55.38,4.16,TEMPSUMMON_TIMED_DESPAWN,120000); - } - break; - case 108: - //last waypoint, just set Thrall invisible, respawn is turned off - m_creature->SetVisibility(VISIBILITY_OFF); - break; - } - } - - void Reset() - { - LowHp = false; - - if (HadMount) - DoMount(); - - if (!HasEscortState(STATE_ESCORT_ESCORTING)) - { - DoUnmount(); - HadMount = false; - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 0); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_UNEQUIPPED); - } - else - DoScriptText(RAND(SAY_TH_LEAVE_COMBAT1, SAY_TH_LEAVE_COMBAT2, SAY_TH_LEAVE_COMBAT3), m_creature); - } - - void StartWP() - { - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - SetEscortPaused(false); - } - - void DoMount() - { - m_creature->Mount(SKARLOC_MOUNT_MODEL); - m_creature->SetSpeed(MOVE_RUN,SPEED_MOUNT); - } - - void DoUnmount() - { - m_creature->Unmount(); - m_creature->SetSpeed(MOVE_RUN,SPEED_RUN); - } - - void EnterCombat(Unit* who) - { - DoScriptText(RAND(SAY_TH_RANDOM_AGGRO1, SAY_TH_RANDOM_AGGRO2, SAY_TH_RANDOM_AGGRO3, SAY_TH_RANDOM_AGGRO4), m_creature); - - if (m_creature->IsMounted()) - { - DoUnmount(); - HadMount = true; - } - - WaitTimer = 4000; - } - - void JustSummoned(Creature* summoned) - { - switch (summoned->GetEntry()) - { - //TODO: make Scarloc start into event instead, and not start attack directly - case MOB_ENTRY_BARN_GUARDSMAN: - case MOB_ENTRY_BARN_PROTECTOR: - case MOB_ENTRY_BARN_LOOKOUT: - case SKARLOC_MOUNT: - case EROZION_ENTRY: - break; - default: - summoned->AI()->AttackStart(m_creature); - break; - } - } - - void KilledUnit(Unit *victim) - { - DoScriptText(RAND(SAY_TH_RANDOM_KILL1, SAY_TH_RANDOM_KILL2, SAY_TH_RANDOM_KILL3), m_creature); - } - - void JustDied(Unit *slayer) - { - if (pInstance) - pInstance->SetData(TYPE_THRALL_EVENT,FAIL); - - // Don't do a yell if he kills self (if player goes too far or at the end). - if (slayer == m_creature) - return; - - DoScriptText(RAND(SAY_TH_RANDOM_DIE1, SAY_TH_RANDOM_DIE2), m_creature); - } - - void UpdateAI(const uint32 diff) - { - if (!me->isInCombat()) - { - if (WaitTimer > diff) - { - WaitTimer -= diff; - return; - } - else - WaitTimer = 0; - } - - npc_escortAI::UpdateAI(diff); - - if (!UpdateVictim()) - return; - - //TODO: add his abilities'n-crap here - if (!LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20)) - { - DoScriptText(RAND(SAY_TH_RANDOM_LOW_HP1, SAY_TH_RANDOM_LOW_HP2), m_creature); - LowHp = true; - } - } -}; - -CreatureAI* GetAI_npc_thrall_old_hillsbrad(Creature *_Creature) -{ - npc_thrall_old_hillsbradAI* thrall_walkAI = new npc_thrall_old_hillsbradAI(_Creature); - - thrall_walkAI->AddWaypoint(0, 2230.91, 118.765, 82.2947,5000); - thrall_walkAI->AddWaypoint(1, 2230.33, 114.980, 82.2946); - thrall_walkAI->AddWaypoint(2, 2233.36, 111.057, 82.2996); - thrall_walkAI->AddWaypoint(3, 2231.17, 108.486, 82.6624); - thrall_walkAI->AddWaypoint(4, 2220.22, 114.605, 89.4264); - thrall_walkAI->AddWaypoint(5, 2215.23, 115.990, 89.4549); - thrall_walkAI->AddWaypoint(6, 2210.00, 106.849, 89.4549); - thrall_walkAI->AddWaypoint(7, 2205.66, 105.234, 89.4549); - //spawn armorer - thrall_walkAI->AddWaypoint(8, 2192.26, 112.618, 89.4549); - - //get weapon - thrall_walkAI->AddWaypoint(9, 2181.28, 118.612, 89.4549,8000); - //get armor - thrall_walkAI->AddWaypoint(10, 2181.62, 120.385, 89.4549,5000); - - thrall_walkAI->AddWaypoint(11, 2189.44, 113.922, 89.4549); - thrall_walkAI->AddWaypoint(12, 2195.63, 110.584, 89.4549); - thrall_walkAI->AddWaypoint(13, 2201.09, 115.115, 89.4549); - thrall_walkAI->AddWaypoint(14, 2204.34, 121.036, 89.4355); - //first ambush - thrall_walkAI->AddWaypoint(15, 2208.66, 129.127, 87.9560); - thrall_walkAI->AddWaypoint(16, 2193.09, 137.940, 88.2164); - thrall_walkAI->AddWaypoint(17, 2173.39, 149.064, 87.9227); - thrall_walkAI->AddWaypoint(18, 2164.25, 137.965, 85.0595); - thrall_walkAI->AddWaypoint(19, 2149.31, 125.645, 77.0858); - thrall_walkAI->AddWaypoint(20, 2142.78, 127.173, 75.5954); - //second ambush - thrall_walkAI->AddWaypoint(21, 2139.28, 133.952, 73.6386); - thrall_walkAI->AddWaypoint(22, 2139.54, 155.235, 67.1269); - thrall_walkAI->AddWaypoint(23, 2145.38, 167.551, 64.8974); - thrall_walkAI->AddWaypoint(24, 2134.28, 175.304, 67.9446); - thrall_walkAI->AddWaypoint(25, 2118.08, 187.387, 68.8141); - //third ambush - thrall_walkAI->AddWaypoint(26, 2105.88, 195.461, 65.1854); - thrall_walkAI->AddWaypoint(27, 2096.77, 196.939, 65.2117); - thrall_walkAI->AddWaypoint(28, 2083.90, 209.395, 64.8736); - //in front of keeps gate, meeting scarloc - thrall_walkAI->AddWaypoint(29, 2067.84, 224.376, 64.8022,30000); - - //ref point after skarloc fight - thrall_walkAI->AddWaypoint(30, 2055.40, 242.90, 63.3418); - - //mount up! - thrall_walkAI->AddWaypoint(31, 2039.20, 266.460, 63.0182,10000); - thrall_walkAI->AddWaypoint(32, 2011.77, 278.478, 65.3388); - thrall_walkAI->AddWaypoint(33, 2005.08, 289.676, 66.1179); - thrall_walkAI->AddWaypoint(34, 2033.11, 337.450, 66.0948); - thrall_walkAI->AddWaypoint(35, 2070.30, 416.208, 66.0893); - thrall_walkAI->AddWaypoint(36, 2086.76, 469.768, 65.9182); - //possible road ambush - thrall_walkAI->AddWaypoint(37, 2101.70, 497.955, 61.7881); - - thrall_walkAI->AddWaypoint(38, 2133.39, 530.933, 55.3700,5000); - thrall_walkAI->AddWaypoint(39, 2157.91, 559.635, 48.5157); - thrall_walkAI->AddWaypoint(40, 2167.34, 586.191, 42.4394); - thrall_walkAI->AddWaypoint(41, 2174.17, 637.643, 33.9002); - thrall_walkAI->AddWaypoint(42, 2179.31, 656.053, 34.723); - thrall_walkAI->AddWaypoint(43, 2183.65, 670.941, 34.0318); - thrall_walkAI->AddWaypoint(44, 2201.50, 668.616, 36.1236); - thrall_walkAI->AddWaypoint(45, 2221.56, 652.747, 36.6153); - thrall_walkAI->AddWaypoint(46, 2238.97, 640.125, 37.2214); - thrall_walkAI->AddWaypoint(47, 2251.17, 620.574, 40.1473); - thrall_walkAI->AddWaypoint(48, 2261.98, 595.303, 41.4117); - thrall_walkAI->AddWaypoint(49, 2278.67, 560.172, 38.9090); - thrall_walkAI->AddWaypoint(50, 2336.72, 528.327, 40.9369); - thrall_walkAI->AddWaypoint(51, 2381.04, 519.612, 37.7312); - thrall_walkAI->AddWaypoint(52, 2412.20, 515.425, 39.2068); - thrall_walkAI->AddWaypoint(53, 2452.39, 516.174, 42.9387); - thrall_walkAI->AddWaypoint(54, 2467.38, 539.389, 47.4992); - thrall_walkAI->AddWaypoint(55, 2470.70, 554.333, 46.6668); - thrall_walkAI->AddWaypoint(56, 2478.07, 575.321, 55.4549); - thrall_walkAI->AddWaypoint(57, 2480.00, 585.408, 56.6921); - thrall_walkAI->AddWaypoint(58, 2482.67, 608.817, 55.6643); - //demount - thrall_walkAI->AddWaypoint(59, 2485.62, 626.061, 58.0132,2000); - //scare the shit out of horse, so it'll run off - thrall_walkAI->AddWaypoint(60, 2486.91, 626.356, 58.0761); - - thrall_walkAI->AddWaypoint(61, 2488.58, 660.940, 57.3913); - thrall_walkAI->AddWaypoint(62, 2502.56, 686.059, 55.6252); - thrall_walkAI->AddWaypoint(63, 2502.08, 694.360, 55.5083); - thrall_walkAI->AddWaypoint(64, 2491.46, 694.321, 55.7163); - thrall_walkAI->AddWaypoint(65, 2491.10, 703.300, 55.7630); - thrall_walkAI->AddWaypoint(66, 2485.64, 702.992, 55.7917); - - thrall_walkAI->AddWaypoint(67, 2479.10, 695.291, 55.7901,10000); - //spawn mobs - thrall_walkAI->AddWaypoint(68, 2476.75, 693.689, 55.7960); - thrall_walkAI->AddWaypoint(69, 2475.39, 695.983, 55.8146); - thrall_walkAI->AddWaypoint(70, 2477.75, 694.473, 55.7945); - //meet mobs in doorway - thrall_walkAI->AddWaypoint(71, 2481.27, 697.747, 55.7910); - - thrall_walkAI->AddWaypoint(72, 2486.31, 703.131, 55.7861,5000); - thrall_walkAI->AddWaypoint(73, 2490.76, 703.511, 55.7662); - thrall_walkAI->AddWaypoint(74, 2491.30, 694.792, 55.7195); - thrall_walkAI->AddWaypoint(75, 2518.69, 693.876, 55.1383); - thrall_walkAI->AddWaypoint(76, 2531.33, 681.914, 55.1383); - thrall_walkAI->AddWaypoint(77, 2568.25, 682.654, 55.1778); - thrall_walkAI->AddWaypoint(78, 2589.61, 689.981, 55.1421); - thrall_walkAI->AddWaypoint(79, 2634.74, 679.833, 54.6613); - thrall_walkAI->AddWaypoint(80, 2630.41, 661.464, 54.2761); - thrall_walkAI->AddWaypoint(81, 2629.00, 656.982, 56.0651); - //stop in church - thrall_walkAI->AddWaypoint(82, 2620.84, 633.007, 56.0300,3000); - //summon - thrall_walkAI->AddWaypoint(83, 2622.99, 639.178, 56.0300); - - thrall_walkAI->AddWaypoint(84, 2628.73, 656.693, 56.0610,5000); - thrall_walkAI->AddWaypoint(85, 2630.34, 661.135, 54.2738); - thrall_walkAI->AddWaypoint(86, 2635.38, 672.243, 54.4508); - thrall_walkAI->AddWaypoint(87, 2644.13, 668.158, 55.3797); - thrall_walkAI->AddWaypoint(88, 2646.82, 666.740, 56.9898); - thrall_walkAI->AddWaypoint(89, 2658.22, 665.432, 57.1725); - thrall_walkAI->AddWaypoint(90, 2661.88, 674.849, 57.1725); - thrall_walkAI->AddWaypoint(91, 2656.23, 677.208, 57.1725); - - thrall_walkAI->AddWaypoint(92, 2652.28, 670.270, 61.9353); - //summon inn - thrall_walkAI->AddWaypoint(93, 2650.79, 664.290, 61.9302); - thrall_walkAI->AddWaypoint(94, 2658.19, 660.454, 61.9320,5000); - //speak with Taretha - thrall_walkAI->AddWaypoint(95, 2660.57, 659.173, 61.9370); - - //epoch calls - thrall_walkAI->AddWaypoint(96, 2658.19, 660.454, 61.9320,5000); - //taretha "dies" - thrall_walkAI->AddWaypoint(97, 2659.84, 659.482, 61.9361,5000); - - thrall_walkAI->AddWaypoint(98, 2654.28, 662.722, 61.9313); - thrall_walkAI->AddWaypoint(99, 2652.37, 670.561, 61.9368); - thrall_walkAI->AddWaypoint(100, 2656.05, 676.761, 57.1727); - thrall_walkAI->AddWaypoint(101, 2658.49, 677.166, 57.1727); - thrall_walkAI->AddWaypoint(102, 2659.28, 667.117, 57.1727); - thrall_walkAI->AddWaypoint(103, 2649.71, 665.387, 57.1727); - //he's outside inn here - thrall_walkAI->AddWaypoint(104, 2634.79, 672.964, 54.4577); - - //getting ready here, must start attack before 30secs up - thrall_walkAI->AddWaypoint(105, 2635.06, 673.892, 54.4713,30000); - - //ref point, will move here when all dead and meet Taretha - thrall_walkAI->AddWaypoint(106, 2634.79, 672.964, 54.4577,60000); - - //run off - thrall_walkAI->AddWaypoint(107, 2631.72, 665.629, 54.2923); - thrall_walkAI->AddWaypoint(108, 2647.40, 640.530, 55.7634); - - return (CreatureAI*)thrall_walkAI; -} - -bool GossipHello_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - { - player->PrepareQuestMenu( _Creature->GetGUID() ); - player->SendPreparedQuest(_Creature->GetGUID()); - } - - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); - if (pInstance) - { - if (pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE && !pInstance->GetData(TYPE_THRALL_EVENT)) - { - player->ADD_GOSSIP_ITEM( 0, "[PH] Start walking.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_ID_START, _Creature->GetGUID()); - } - - if (pInstance->GetData(TYPE_THRALL_PART1) == DONE && !pInstance->GetData(TYPE_THRALL_PART2)) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC1, _Creature->GetGUID()); - } - - if (pInstance->GetData(TYPE_THRALL_PART2) == DONE && !pInstance->GetData(TYPE_THRALL_PART3)) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_TARREN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(GOSSIP_ID_TARREN, _Creature->GetGUID()); - } - } - - return true; -} - -bool GossipSelect_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - if (pInstance) - { - pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS); - pInstance->SetData(TYPE_THRALL_PART1, IN_PROGRESS); - } - - ((npc_escortAI*)(_Creature->AI()))->SetMaxPlayerDistance(100.0f);//not really needed, because it will not despawn if player is too far - ((npc_escortAI*)(_Creature->AI()))->SetDespawnAtEnd(false); - ((npc_escortAI*)(_Creature->AI()))->SetDespawnAtFar(false); - DoScriptText(SAY_TH_START_EVENT_PART1, _Creature); - ((npc_escortAI*)(_Creature->AI()))->Start(true, true, player->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC2, _Creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+20: - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC3, _Creature->GetGUID()); - _Creature->SummonCreature(SKARLOC_MOUNT,2038.81,270.26,63.20,5.41,TEMPSUMMON_TIMED_DESPAWN,12000); - if (pInstance) - pInstance->SetData(TYPE_THRALL_PART2,IN_PROGRESS); - - DoScriptText(SAY_TH_START_EVENT_PART2, _Creature); - - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); - break; - - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - if (pInstance) - pInstance->SetData(TYPE_THRALL_PART3,IN_PROGRESS); - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); - break; - } - return true; -} - -/*###### -## npc_taretha -######*/ - -#define GOSSIP_ID_EPOCH1 9610 //Thank you for helping Thrall escape, friends. Now I only hope -#define GOSSIP_ITEM_EPOCH1 "Strange wizard?" -#define GOSSIP_ID_EPOCH2 9613 //Yes, friends. This man was no wizard of -#define GOSSIP_ITEM_EPOCH2 "We'll get you out. Taretha. Don't worry. I doubt the wizard would wander too far away." - -struct npc_tarethaAI : public npc_escortAI -{ - npc_tarethaAI(Creature *c) : npc_escortAI(c) - { - pInstance = (c->GetInstanceData()); - } - - ScriptedInstance *pInstance; - - void WaypointReached(uint32 i) - { - switch (i) - { - case 6: - DoScriptText(SAY_TA_FREE, m_creature); - break; - case 7: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); - break; - } - } - - void Reset() {} - void EnterCombat(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); - } -}; -CreatureAI* GetAI_npc_taretha(Creature *_Creature) -{ - npc_tarethaAI* taretha_walkAI = new npc_tarethaAI(_Creature); - - taretha_walkAI->AddWaypoint(0, 2650.06, 665.473, 61.9305); - taretha_walkAI->AddWaypoint(1, 2652.44, 670.761, 61.9370); - taretha_walkAI->AddWaypoint(2, 2655.96, 676.913, 57.1725); - taretha_walkAI->AddWaypoint(3, 2659.40, 677.317, 57.1725); - taretha_walkAI->AddWaypoint(4, 2651.75, 664.482, 57.1725); - taretha_walkAI->AddWaypoint(5, 2647.49, 666.595, 57.0824); - taretha_walkAI->AddWaypoint(6, 2644.37, 668.167, 55.4182); - taretha_walkAI->AddWaypoint(7, 2640.96, 669.890, 54.7567,60000); - - return (CreatureAI*)taretha_walkAI; -} - -bool GossipHello_npc_taretha(Player *player, Creature *_Creature) -{ - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); - if (pInstance && pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH1, _Creature->GetGUID()); - } - - return true; -} - -bool GossipSelect_npc_taretha(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - ScriptedInstance* pInstance = (_Creature->GetInstanceData()); - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH2, _Creature->GetGUID()); - } - - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - player->CLOSE_GOSSIP_MENU(); - - if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS) - { - if (pInstance) - pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS); - if (pInstance->GetData64(DATA_EPOCH) == 0) - _Creature->SummonCreature(ENTRY_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); - - if (uint64 ThrallGUID = pInstance->GetData64(DATA_THRALL)) - { - Creature* Thrall = (Unit::GetCreature((*_Creature), ThrallGUID)); - if(Thrall) - ((npc_thrall_old_hillsbradAI*)Thrall->AI())->StartWP(); - } - } - } - - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_old_hillsbrad() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_brazen"; - newscript->pGossipHello = &GossipHello_npc_brazen; - newscript->pGossipSelect = &GossipSelect_npc_brazen; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_erozion"; - newscript->pGossipHello = &GossipHello_npc_erozion; - newscript->pGossipSelect = &GossipSelect_npc_erozion; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_thrall_old_hillsbrad"; - newscript->pGossipHello = &GossipHello_npc_thrall_old_hillsbrad; - newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad; - newscript->GetAI = &GetAI_npc_thrall_old_hillsbrad; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_taretha"; - newscript->pGossipHello = &GossipHello_npc_taretha; - newscript->pGossipSelect = &GossipSelect_npc_taretha; - newscript->GetAI = &GetAI_npc_taretha; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h b/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h deleted file mode 100755 index 2cf24cd82..000000000 --- a/src/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_STEAM_VAULT_H -#define DEF_STEAM_VAULT_H - -#define TYPE_HYDROMANCER_THESPIA 1 -#define TYPE_MEKGINEER_STEAMRIGGER 2 -#define TYPE_WARLORD_KALITHRESH 3 -#define TYPE_DISTILLER 4 - -#define DATA_MEKGINEERSTEAMRIGGER 5 -#define DATA_KALITRESH 6 -#define DATA_THESPIA 7 - -#define DATA_MAIN_CHAMBERS_DOOR 8 - -#endif - diff --git a/src/scripts/scripts/zone/deadmines/def_deadmines.h b/src/scripts/scripts/zone/deadmines/def_deadmines.h deleted file mode 100755 index 9b535a9fd..000000000 --- a/src/scripts/scripts/zone/deadmines/def_deadmines.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef DEF_DEADMINES_H -#define DEF_DEADMINES_H - -#include "precompiled.h" - -#define CANNON_NOT_USED 1 -#define CANNON_GUNPOWDER_USED 2 -#define CANNON_BLAST_INITIATED 3 -#define PIRATES_ATTACK 4 -#define EVENT_DONE 5 - -#define EVENT_STATE 1 -#endif - diff --git a/src/scripts/scripts/zone/feralas/feralas.cpp b/src/scripts/scripts/zone/feralas/feralas.cpp deleted file mode 100755 index f3822bcdb..000000000 --- a/src/scripts/scripts/zone/feralas/feralas.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Feralas -SD%Complete: 100 -SDComment: Quest support: 3520. Special vendor Gregan Brewspewer -SDCategory: Feralas -EndScriptData */ - -#include "precompiled.h" - -/*###### -## npc_gregan_brewspewer -######*/ - -#define GOSSIP_HELLO "Buy somethin', will ya?" - -bool GossipHello_npc_gregan_brewspewer(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isVendor() && player->GetQuestStatus(3909) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(0, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(2433,_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_gregan_brewspewer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(2434,_Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - return true; -} - -/*###### -## npc_screecher_spirit -######*/ - -bool GossipHello_npc_screecher_spirit(Player *player, Creature *_Creature) -{ - player->SEND_GOSSIP_MENU(2039, _Creature->GetGUID() ); - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_feralas() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_gregan_brewspewer"; - newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer; - newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_screecher_spirit"; - newscript->pGossipHello = &GossipHello_npc_screecher_spirit; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h b/src/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h deleted file mode 100755 index 145e573f0..000000000 --- a/src/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_GRUULS_LAIR_H -#define DEF_GRUULS_LAIR_H - -#define DATA_BLINDEYETHESEER 1 -#define DATA_GRUULEVENT 2 -#define DATA_KIGGLERTHECRAZED 3 -#define DATA_KROSHFIREHAND 4 -#define DATA_MAULGAREVENT 5 -#define DATA_MAULGAREVENT_TANK 6 -#define DATA_OLMTHESUMMONER 7 -#define DATA_MAULGARDOOR 8 -#define DATA_GRUULDOOR 9 -#define DATA_MAULGAR 10 -#endif - diff --git a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h b/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h deleted file mode 100755 index 9b684f504..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_BLOOD_FURNACE_H -#define DEF_BLOOD_FURNACE_H - -#define DATA_KELIDANEVENT 1 -#define DATA_BROGGOKEVENT 2 -#define DATA_MAKEREVENT 3 - -#endif diff --git a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp b/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp deleted file mode 100755 index eee04267f..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -Name: Boss_Vazruden_the_Herald -%Complete: 90 -Comment: -Category: Hellfire Citadel, Hellfire Ramparts -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIREBALL (HeroicMode?36920:34653) -#define SPELL_CONE_OF_FIRE (HeroicMode?36921:30926) -#define SPELL_SUMMON_LIQUID_FIRE (HeroicMode?30928:23971) -#define SPELL_BELLOWING_ROAR 39427 -#define SPELL_REVENGE (HeroicMode?40392:19130) -#define SPELL_KIDNEY_SHOT 30621 -#define SPELL_FIRE_NOVA_VISUAL 19823 - -#define ENTRY_HELLFIRE_SENTRY 17517 -#define ENTRY_VAZRUDEN_HERALD 17307 -#define ENTRY_VAZRUDEN 17537 -#define ENTRY_NAZAN 17536 -#define ENTRY_LIQUID_FIRE 22515 -#define ENTRY_REINFORCED_FEL_IRON_CHEST (HeroicMode?185169:185168) - -#define SAY_INTRO -1543017 -#define SAY_WIPE -1543018 -#define SAY_AGGRO_1 -1543019 -#define SAY_AGGRO_2 -1543020 -#define SAY_AGGRO_3 -1543021 -#define SAY_KILL_1 -1543022 -#define SAY_KILL_2 -1543023 -#define SAY_DIE -1543024 -#define EMOTE -1543025 - -#define PATH_ENTRY 2081 - -const float VazrudenMiddle[3] = {-1406.5, 1746.5, 81.2}; -const float VazrudenRing[2][3] = -{ - {-1430, 1705, 112}, - {-1377, 1760, 112} -}; - -struct boss_nazanAI : public ScriptedAI -{ - boss_nazanAI(Creature *c) : ScriptedAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - VazrudenGUID = 0; - flight = true; - } - - uint32 Fireball_Timer; - uint32 ConeOfFire_Timer; - uint32 BellowingRoar_Timer; - uint32 Fly_Timer; - uint32 Turn_Timer; - uint32 UnsummonCheck; - bool flight; - uint64 VazrudenGUID; - bool HeroicMode; - SpellEntry *liquid_fire; - - void Reset() - { - Fireball_Timer = 4000; - Fly_Timer = 45000; - Turn_Timer = 0; - UnsummonCheck = 5000; - } - - void JustSummoned(Creature *summoned) - { - if(summoned && summoned->GetEntry() == ENTRY_LIQUID_FIRE) - { - summoned->SetLevel(m_creature->getLevel()); - summoned->setFaction(m_creature->getFaction()); - summoned->CastSpell(summoned,SPELL_SUMMON_LIQUID_FIRE,true); - summoned->CastSpell(summoned,SPELL_FIRE_NOVA_VISUAL,true); - } - } - - void SpellHitTarget(Unit* target, const SpellEntry* entry) - { - if(target && entry->Id == SPELL_FIREBALL) - m_creature->SummonCreature(ENTRY_LIQUID_FIRE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),target->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,30000); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - { - if(UnsummonCheck < diff && m_creature->isAlive()) - { - m_creature->SetLootRecipient(NULL); - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - }else UnsummonCheck -= diff; - return; - } - - if(Fireball_Timer < diff) - { - if(Unit *victim = SelectUnit(SELECT_TARGET_RANDOM,0)) - DoCast(victim, SPELL_FIREBALL,true); - Fireball_Timer = 4000+rand()%3000; - }else Fireball_Timer -= diff; - - if(flight) // phase 1 - the flight - { - Creature *Vazruden = Unit::GetCreature(*m_creature,VazrudenGUID); - if(Fly_Timer < diff || !(Vazruden && Vazruden->isAlive() && (Vazruden->GetHealth()*5 > Vazruden->GetMaxHealth()))) - { - flight = false; - BellowingRoar_Timer = 6000; - ConeOfFire_Timer = 12000; - m_creature->SetLevitate(false); - m_creature->SetWalk(true); - m_creature->GetMotionMaster()->Clear(); - if(Unit *victim = SelectUnit(SELECT_TARGET_NEAREST,0)) - m_creature->AI()->AttackStart(victim); - DoStartMovement(m_creature->getVictim()); - DoScriptText(EMOTE, m_creature); - return; - }else Fly_Timer -= diff; - - if(Turn_Timer < diff) - { - uint32 waypoint = (Fly_Timer/10000)%2; - if(m_creature->GetDistance(VazrudenRing[waypoint][0],VazrudenRing[waypoint][1],VazrudenRing[waypoint][2]) > 5) - m_creature->GetMotionMaster()->MovePoint(0,VazrudenRing[waypoint][0],VazrudenRing[waypoint][1],VazrudenRing[waypoint][2]); - Turn_Timer = 10000; - }else Turn_Timer -= diff; - } - else // phase 2 - land fight - { - if(ConeOfFire_Timer < diff) - { - DoCast(m_creature, SPELL_CONE_OF_FIRE); - ConeOfFire_Timer = 12000; - Fireball_Timer = 4000; - }else ConeOfFire_Timer -= diff; - - if(HeroicMode && BellowingRoar_Timer < diff) - { - DoCast(m_creature, SPELL_BELLOWING_ROAR); - BellowingRoar_Timer = 45000; - }else BellowingRoar_Timer -= diff; - - DoMeleeAttackIfReady(); - } - } -}; - -struct boss_vazrudenAI : public ScriptedAI -{ - boss_vazrudenAI(Creature *c) : ScriptedAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - uint32 Revenge_Timer; - bool HeroicMode; - bool WipeSaid; - uint32 UnsummonCheck; - - void Reset() - { - Revenge_Timer = 4000; - UnsummonCheck = 2000; - WipeSaid = false; - } - - void EnterCombat(Unit *who) - { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); - } - - void KilledUnit(Unit* who) - { - if(who && who->GetEntry()!=ENTRY_VAZRUDEN) - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), m_creature); - } - - void JustDied(Unit* who) - { - if(who && who != m_creature) - DoScriptText(SAY_DIE, m_creature); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - { - if(UnsummonCheck < diff && m_creature->isAlive()) - { - if(!WipeSaid) - { - DoScriptText(SAY_WIPE, m_creature); - WipeSaid = true; - } - m_creature->SetLootRecipient(NULL); - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - }else UnsummonCheck -= diff; - return; - } - - if(Revenge_Timer < diff) - { - if(Unit *victim = m_creature->getVictim()) - DoCast(victim, SPELL_REVENGE); - Revenge_Timer = 5000; - }else Revenge_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct boss_vazruden_the_heraldAI : public ScriptedAI -{ - boss_vazruden_the_heraldAI(Creature *c) : ScriptedAI(c) - { - summoned = false; - sentryDown = false; - NazanGUID = 0; - VazrudenGUID = 0; - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - uint32 phase; - uint32 waypoint; - uint32 check; - bool sentryDown; - uint64 NazanGUID; - uint64 VazrudenGUID; - bool summoned; - bool HeroicMode; - - void Reset() - { - phase = 0; - waypoint = 0; - check = 0; - UnsummonAdds(); - m_creature->GetMotionMaster()->MovePath(PATH_ENTRY, true); - } - - void UnsummonAdds() - { - if(summoned) - { - Creature *Nazan = Unit::GetCreature(*m_creature, NazanGUID); - Creature *Vazruden = Unit::GetCreature(*m_creature, VazrudenGUID); - if(Nazan || (Nazan = (Creature *)FindCreature(ENTRY_NAZAN, 5000, m_creature))) - { - Nazan->SetLootRecipient(NULL); - Nazan->SetVisibility(VISIBILITY_OFF); - Nazan->DealDamage(Nazan, Nazan->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - Nazan->RemoveCorpse(); - NazanGUID = 0; - } - if(Vazruden || (Vazruden = (Creature *)FindCreature(ENTRY_VAZRUDEN, 5000, m_creature))) - { - Vazruden->SetLootRecipient(NULL); - Vazruden->SetVisibility(VISIBILITY_OFF); - Vazruden->DealDamage(Vazruden, Vazruden->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - Vazruden->RemoveCorpse(); - VazrudenGUID = 0; - } - summoned = false; - m_creature->clearUnitState(UNIT_STAT_ROOT); - m_creature->SetVisibility(VISIBILITY_ON); - } - } - - void SummonAdds() - { - if(!summoned) - { - Creature* Vazruden = m_creature->SummonCreature(ENTRY_VAZRUDEN,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,6000000); - if(Vazruden) - VazrudenGUID = Vazruden->GetGUID(); - Creature* Nazan = m_creature->SummonCreature(ENTRY_NAZAN,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,6000000); - if(Nazan) - NazanGUID = Nazan->GetGUID(); - summoned = true; - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->addUnitState(UNIT_STAT_ROOT); - } - } - - void EnterCombat(Unit *who) - { - if(phase==0) - { - phase = 1; - check = 0; - DoScriptText(SAY_INTRO, m_creature); - } - } - - void JustSummoned(Creature *summoned) - { - if(!summoned) return; - Unit *victim = m_creature->getVictim(); - if(summoned->GetEntry() == ENTRY_NAZAN) - { - ((boss_nazanAI *)summoned->AI())->VazrudenGUID = VazrudenGUID; - summoned->SetLevitate(true); - summoned->SetSpeed(MOVE_FLIGHT, 2.5); - if(victim) - ((ScriptedAI*)summoned->AI())->AttackStart(victim,false); - } - else if(victim) - summoned->AI()->AttackStart(victim); - } - - void SentryDownBy(Unit* killer) - { - if(sentryDown) - { - AttackStart(killer, false); - sentryDown = false; - } - else - sentryDown = true; - } - - void UpdateAI(const uint32 diff) - { - switch(phase) - { - case 0: // circle around the platform - return; - break; - case 1: // go to the middle and begin the fight - if(check < diff) - { - if(m_creature->GetDistance(VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2])>5) - { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MovePoint(0,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2]); - check = 1000; - } - else - { - SummonAdds(); - phase = 2; - return; - } - }else check -= diff; - break; - default: // adds do the job now - if(check < diff) - { - Creature *Nazan = Unit::GetCreature(*m_creature, NazanGUID); - Creature *Vazruden = Unit::GetCreature(*m_creature, VazrudenGUID); - if(Nazan && Nazan->isAlive() || Vazruden && Vazruden->isAlive()) - { - if(Nazan && Nazan->getVictim() || Vazruden && Vazruden->getVictim()) - return; - else - { - UnsummonAdds(); - EnterEvadeMode(); - return; - } - }else - { - m_creature->SummonGameObject(ENTRY_REINFORCED_FEL_IRON_CHEST,VazrudenMiddle[0],VazrudenMiddle[1],VazrudenMiddle[2],0,0,0,0,0,0); - m_creature->SetLootRecipient(NULL); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - check = 2000; - }else check -= diff; - break; - } - } -}; - -struct mob_hellfire_sentryAI : public ScriptedAI -{ - mob_hellfire_sentryAI(Creature *c) : ScriptedAI(c) {} - - uint32 KidneyShot_Timer; - - void Reset() - { - KidneyShot_Timer = 3000+rand()%4000; - } - - void JustDied(Unit* who) - { - if(Creature *herald = (Creature *)FindCreature(ENTRY_VAZRUDEN_HERALD,150, m_creature)) - ((boss_vazruden_the_heraldAI *)herald->AI())->SentryDownBy(who); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if(KidneyShot_Timer < diff) - { - if(Unit *victim = m_creature->getVictim()) - DoCast(victim, SPELL_KIDNEY_SHOT); - KidneyShot_Timer = 20000; - }else KidneyShot_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_vazruden_the_herald(Creature *_Creature) -{ - return new boss_vazruden_the_heraldAI (_Creature); -} - -CreatureAI* GetAI_boss_vazruden(Creature *_Creature) -{ - return new boss_vazrudenAI (_Creature); -} - - -CreatureAI* GetAI_boss_nazan(Creature *_Creature) -{ - return new boss_nazanAI (_Creature); -} - -CreatureAI* GetAI_mob_hellfire_sentry(Creature *_Creature) -{ - return new mob_hellfire_sentryAI (_Creature); -} - -void AddSC_boss_vazruden_the_herald() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_vazruden_the_herald"; - newscript->GetAI = &GetAI_boss_vazruden_the_herald; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="boss_vazruden"; - newscript->GetAI = &GetAI_boss_vazruden; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="boss_nazan"; - newscript->GetAI = &GetAI_boss_nazan; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="mob_hellfire_sentry"; - newscript->GetAI = &GetAI_mob_hellfire_sentry; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h b/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h deleted file mode 100755 index 9bff56a22..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_MAGTHERIDONS_LAIR_H -#define DEF_MAGTHERIDONS_LAIR_H - -#define DATA_MAGTHERIDON_EVENT 1 -#define DATA_MAGTHERIDON 2 -#define DATA_DOOR_GUID 3 -#define DATA_COLLAPSE 5 -#endif - diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp b/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp deleted file mode 100644 index 0ec04bae8..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_blood_guard_porung.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "precompiled.h" -#include "def_shattered_halls.h" - -#define SPELL_CLEAVE 15496 - -struct boss_blood_guard_porungAI : public ScriptedAI -{ - boss_blood_guard_porungAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - } - - ScriptedInstance* pInstance; - uint32 Cleave_Timer; - - void Reset() - { - Cleave_Timer = 10000; - - if (pInstance) - pInstance->SetData(TYPE_PORUNG, NOT_STARTED); - } - - void JustDied(Unit* Killer) - { - if (pInstance) - pInstance->SetData(TYPE_PORUNG, DONE); - } - - void EnterCombat(Unit *who) - { - if (pInstance) - pInstance->SetData(TYPE_PORUNG, IN_PROGRESS); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CLEAVE, false); - Cleave_Timer = 7500 + rand()%5000; - } - else - Cleave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_blood_guard_porung(Creature *_Creature) -{ - return new boss_blood_guard_porungAI (_Creature); -} - -void AddSC_boss_blood_guard_porung() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_blood_guard_porung"; - newscript->GetAI = &GetAI_boss_blood_guard_porung; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp deleted file mode 100755 index 61fce361e..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grand_Warlock_Nethekurse -SD%Complete: 75 -SDComment: encounter not fully completed. missing part where boss kill minions. -SDCategory: Hellfire Citadel, Shattered Halls -EndScriptData */ - -/* ContentData -boss_grand_warlock_nethekurse -mob_fel_orc_convert -mob_lesser_shadow_fissure -EndContentData */ - -#include "precompiled.h" -#include "def_shattered_halls.h" - -struct Say -{ - int32 id; -}; - -static Say PeonAttacked[]= -{ - {-1540001}, - {-1540002}, - {-1540003}, - {-1540004}, -}; -static Say PeonDies[]= -{ - {-1540005}, - {-1540006}, - {-1540007}, - {-1540008}, -}; - -#define SAY_INTRO -1540000 -#define SAY_TAUNT_1 -1540009 -#define SAY_TAUNT_2 -1540010 -#define SAY_TAUNT_3 -1540011 -#define SAY_AGGRO_1 -1540012 -#define SAY_AGGRO_2 -1540013 -#define SAY_AGGRO_3 -1540014 -#define SAY_SLAY_1 -1540015 -#define SAY_SLAY_2 -1540016 -#define SAY_DIE -1540017 - -#define SPELL_DEATH_COIL 30500 -#define SPELL_DARK_SPIN 30502 // core bug spell attack caster :D -#define SPELL_SHADOW_FISSURE 30496 // Summon the ShadowFissure NPC - -#define SPELL_SHADOW_CLEAVE 30495 -#define H_SPELL_SHADOW_SLAM 35953 - -#define SPELL_HEMORRHAGE 30478 - -#define SPELL_CONSUMPTION 30497 -#define SPELL_TEMPORARY_VISUAL 39312 // this is wrong, a temporary solution. spell consumption already has the purple visual, but doesn't display as it should - -struct boss_grand_warlock_nethekurseAI : public ScriptedAI -{ - boss_grand_warlock_nethekurseAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - } - - ScriptedInstance* pInstance; - bool HeroicMode; - - bool IntroOnce; - bool IsIntroEvent; - bool IsMainEvent; - bool SpinOnce; - //bool HasTaunted; - bool Phase; - - uint32 PeonEngagedCount; - uint32 PeonKilledCount; - - uint32 IntroEvent_Timer; - uint32 DeathCoil_Timer; - uint32 ShadowFissure_Timer; - uint32 Cleave_Timer; - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - IsIntroEvent = false; - IntroOnce = false; - IsMainEvent = false; - //HasTaunted = false; - SpinOnce = false; - Phase = false; - - PeonEngagedCount = 0; - PeonKilledCount = 0; - - IntroEvent_Timer = 90000; //how long before getting bored and kills his minions? - DeathCoil_Timer = 20000; - ShadowFissure_Timer = 8000; - Cleave_Timer = 5000; - } - - void DoYellForPeonAggro() - { - if (PeonEngagedCount >= 4) - return; - - DoScriptText(PeonAttacked[PeonEngagedCount].id, m_creature); - ++PeonEngagedCount; - } - - void DoYellForPeonDeath() - { - if (PeonKilledCount >= 4) - return; - - DoScriptText(PeonDies[PeonKilledCount].id, m_creature); - ++PeonKilledCount; - - if (PeonKilledCount == 4) - { - IsIntroEvent = false; - IsMainEvent = true; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } - - void DoTauntPeons() - { - DoScriptText(RAND(SAY_TAUNT_1, SAY_TAUNT_2, SAY_TAUNT_3), m_creature); - - //TODO: kill the peons first - IsIntroEvent = false; - PeonEngagedCount = 4; - PeonKilledCount = 4; - IsMainEvent = true; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void AttackStart(Unit* who) - { - if (IsIntroEvent || !IsMainEvent) - return; - - if (m_creature->Attack(who, true)) - { - if (Phase) - DoStartNoMovement(who); - else - DoStartMovement(who); - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!IntroOnce && m_creature->IsWithinDistInMap(who, 50.0f)) - { - if (who->GetTypeId() != TYPEID_PLAYER) - return; - - DoScriptText(SAY_INTRO, m_creature); - IntroOnce = true; - IsIntroEvent = true; - - if (pInstance) - pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); - } - - if (IsIntroEvent || !IsMainEvent) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void EnterCombat(Unit *who) - { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2, SAY_AGGRO_3), m_creature); - } - - void JustSummoned(Creature *summoned) - { - summoned->setFaction(16); - summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - summoned->CastSpell(summoned,SPELL_TEMPORARY_VISUAL,true); - summoned->CastSpell(summoned,SPELL_CONSUMPTION,false,0,0,m_creature->GetGUID()); - } - - void KilledUnit(Unit* victim) - { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), m_creature); - } - - void JustDied(Unit* Killer) - { - DoScriptText(SAY_DIE, m_creature); - - if (!pInstance) - return; - - pInstance->SetData(TYPE_NETHEKURSE,DONE); - - if (pInstance->GetData64(DATA_NETHEKURSE_DOOR)) - { - if (GameObject *Door = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_NETHEKURSE_DOOR))) - Door->SetGoState(GO_STATE_ACTIVE); - } - } - - void UpdateAI(const uint32 diff) - { - if (IsIntroEvent) - { - if (!pInstance) - return; - - if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS) - { - if (IntroEvent_Timer < diff) - { - DoTauntPeons(); - }else IntroEvent_Timer -= diff; - } - } - - if (!UpdateVictim() ) - return; - - if (!IsMainEvent) - return; - - if (Phase) - { - if (!SpinOnce) - { - DoCast(m_creature->getVictim(),SPELL_DARK_SPIN); - SpinOnce = true; - } - - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),(HeroicMode ? H_SPELL_SHADOW_SLAM : SPELL_SHADOW_CLEAVE)); - Cleave_Timer = 6000+rand()%2500; - }else Cleave_Timer -= diff; - } - else - { - if (ShadowFissure_Timer < diff) - { - if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0)) - DoCast(target,SPELL_SHADOW_FISSURE); - ShadowFissure_Timer = 7500+rand()%7500; - }else ShadowFissure_Timer -= diff; - - if (DeathCoil_Timer < diff) - { - if (Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0)) - DoCast(target,SPELL_DEATH_COIL); - DeathCoil_Timer = 15000+rand()%5000; - }else DeathCoil_Timer -= diff; - - if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20) - Phase = true; - - DoMeleeAttackIfReady(); - } - } -}; - -struct mob_fel_orc_convertAI : public ScriptedAI -{ - mob_fel_orc_convertAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()); - } - - ScriptedInstance* pInstance; - uint32 Hemorrhage_Timer; - - void Reset() - { - m_creature->SetNoCallAssistance(true); //we don't want any assistance (WE R HEROZ!) - Hemorrhage_Timer = 3000; - } - - void MoveInLineOfSight(Unit *who) - { - return; - } - - void EnterCombat(Unit* who) - { - if (pInstance) - { - if (pInstance->GetData64(DATA_NETHEKURSE)) - { - Creature *pKurse = Unit::GetCreature(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); - if (pKurse && m_creature->IsWithinDistInMap(pKurse, 45.0f)) - { - ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonAggro(); - - if (pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS) - return; - else - pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); - } - } - } - } - - void JustDied(Unit* Killer) - { - if (pInstance) - { - if (pInstance->GetData(TYPE_NETHEKURSE) != IN_PROGRESS) - return; - - if (pInstance->GetData64(DATA_NETHEKURSE)) - { - Creature *pKurse = Unit::GetCreature(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); - if (pKurse) - ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonDeath(); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (Hemorrhage_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HEMORRHAGE); - Hemorrhage_Timer = 15000; - }else Hemorrhage_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_grand_warlock_nethekurse(Creature *_Creature) -{ - return new boss_grand_warlock_nethekurseAI (_Creature); -} - -CreatureAI* GetAI_mob_fel_orc_convert(Creature *_Creature) -{ - return new mob_fel_orc_convertAI (_Creature); -} - -void AddSC_boss_grand_warlock_nethekurse() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_grand_warlock_nethekurse"; - newscript->GetAI = &GetAI_boss_grand_warlock_nethekurse; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="mob_fel_orc_convert"; - newscript->GetAI = &GetAI_mob_fel_orc_convert; - newscript->RegisterSelf(); - -} - diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h b/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h deleted file mode 100755 index 17cf63222..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHATTERED_H -#define DEF_SHATTERED_H - -#define TYPE_NETHEKURSE 1 -#define DATA_NETHEKURSE 2 -#define DATA_NETHEKURSE_DOOR 3 - -#define TYPE_OMROGG 4 -#define TYPE_PORUNG 5 -#endif - diff --git a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp b/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp deleted file mode 100755 index bffa16f3d..000000000 --- a/src/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Shattered_Halls -SD%Complete: 50 -SDComment: currently missing info about door. instance not complete -SDCategory: Hellfire Citadel, Shattered Halls -EndScriptData */ - -#include "precompiled.h" -#include "def_shattered_halls.h" - -#define ENCOUNTERS 3 - -#define DOOR_NETHEKURSE 1 - -struct instance_shattered_halls : public ScriptedInstance -{ - instance_shattered_halls(Map *map) : ScriptedInstance(map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - uint64 nethekurseGUID; - uint64 nethekurseDoorGUID; - - void Initialize() - { - nethekurseGUID = 0; - nethekurseDoorGUID = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = NOT_STARTED; - } - - void OnObjectCreate(GameObject *go) - { - switch( go->GetEntry() ) - { - case DOOR_NETHEKURSE: nethekurseDoorGUID = go->GetGUID(); break; - } - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch( creature_entry ) - { - case 16807: nethekurseGUID = creature->GetGUID(); break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch( type ) - { - case TYPE_NETHEKURSE: - Encounter[0] = data; - break; - case TYPE_OMROGG: - Encounter[1] = data; - break; - case TYPE_PORUNG: - Encounter[2] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch( type ) - { - case TYPE_NETHEKURSE: - return Encounter[0]; - case TYPE_OMROGG: - return Encounter[1]; - case TYPE_PORUNG: - return Encounter[2]; - } - return 0; - } - - uint64 GetData64(uint32 data) - { - switch(data) - { - case DATA_NETHEKURSE: - return nethekurseGUID; - case DATA_NETHEKURSE_DOOR: - return nethekurseDoorGUID; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_shattered_halls(Map* map) -{ - return new instance_shattered_halls(map); -} - -void AddSC_instance_shattered_halls() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_shattered_halls"; - newscript->GetInstanceData = &GetInstanceData_instance_shattered_halls; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/moonglade/moonglade.cpp b/src/scripts/scripts/zone/moonglade/moonglade.cpp deleted file mode 100755 index 6f65873fa..000000000 --- a/src/scripts/scripts/zone/moonglade/moonglade.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Moonglade -SD%Complete: 100 -SDComment: Quest support: 30, 272, 5929, 5930, 10965. Special Flight Paths for Druid class. -SDCategory: Moonglade -EndScriptData */ - -/* ContentData -npc_bunthen_plainswind -npc_great_bear_spirit -npc_silva_filnaveth -npc_clintar_spirit -npc_clintar_dreamwalker -EndContentData */ - -#include "precompiled.h" -#include "escort_ai.h" - -/*###### -## npc_bunthen_plainswind -######*/ - -#define GOSSIP_BP1 "Do you know where I can find Half Pendant of Aquatic Endurance?" -#define GOSSIP_BP2 "I'd like to fly to Thunder Bluff." - -bool GossipHello_npc_bunthen_plainswind(Player *player, Creature *_Creature) -{ - if(player->getClass() != CLASS_DRUID) - player->SEND_GOSSIP_MENU(4916,_Creature->GetGUID()); - else if(player->GetTeam() != HORDE) - { - if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(4917,_Creature->GetGUID()); - } - else if(player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - player->SEND_GOSSIP_MENU(4918,_Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_bunthen_plainswind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - { - player->CLOSE_GOSSIP_MENU(); - if (player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) - { - std::vector nodes; - - nodes.resize(2); - nodes[0] = 63; // Nighthaven, Moonglade - nodes[1] = 22; // Thunder Bluff, Mulgore - player->ActivateTaxiPathTo(nodes); - } - break; - } - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_GOSSIP_MENU(5373,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(5376,_Creature->GetGUID()); - break; - } - return true; -} - -/*###### -## npc_great_bear_spirit -######*/ - -#define GOSSIP_BEAR1 "What do you represent, spirit?" -#define GOSSIP_BEAR2 "I seek to understand the importance of strength of the body." -#define GOSSIP_BEAR3 "I seek to understand the importance of strength of the heart." -#define GOSSIP_BEAR4 "I have heard your words, Great Bear Spirit, and I understand. I now seek your blessings to fully learn the way of the Claw." - -bool GossipHello_npc_great_bear_spirit(Player *player, Creature *_Creature) -{ - //ally or horde quest - if (player->GetQuestStatus(5929) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5930) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(4719, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(4718, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_great_bear_spirit(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(4721, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(4733, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(4734, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(4735, _Creature->GetGUID()); - if (player->GetQuestStatus(5929)==QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(5929); - if (player->GetQuestStatus(5930)==QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(5930); - break; - } - return true; -} - -/*###### -## npc_silva_filnaveth -######*/ - -#define GOSSIP_SF1 "Do you know where I can find Half Pendant of Aquatic Agility?" -#define GOSSIP_SF2 "I'd like to fly to Rut'theran Village." -bool GossipHello_npc_silva_filnaveth(Player *player, Creature *_Creature) -{ - if(player->getClass() != CLASS_DRUID) - player->SEND_GOSSIP_MENU(4913,_Creature->GetGUID()); - else if(player->GetTeam() != ALLIANCE) - { - if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(4915,_Creature->GetGUID()); - } - else if(player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_SF1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - player->SEND_GOSSIP_MENU(4914,_Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_silva_filnaveth(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - { - player->CLOSE_GOSSIP_MENU(); - if (player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) - { - std::vector nodes; - - nodes.resize(2); - nodes[0] = 62; // Nighthaven, Moonglade - nodes[1] = 27; // Rut'theran Village, Teldrassil - player->ActivateTaxiPathTo(nodes); - } - break; - } - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_GOSSIP_MENU(5374,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(5375,_Creature->GetGUID()); - break; - } - return true; -} - -/*###### -## npc_clintar_spirit -######*/ - -float Clintar_spirit_WP[41][5] = -{ - //pos_x pos_y pos_z orien waitTime -{7465.28, -3115.46, 439.327, 0.83, 4000}, -{7476.49, -3101, 443.457, 0.89, 0}, -{7486.57, -3085.59, 439.478, 1.07, 0}, -{7472.19, -3085.06, 443.142, 3.07, 0}, -{7456.92, -3085.91, 438.862, 3.24, 0}, -{7446.68, -3083.43, 438.245, 2.40, 0}, -{7446.17, -3080.21, 439.826, 1.10, 6000}, -{7452.41, -3085.8, 438.984, 5.78, 0}, -{7469.11, -3084.94, 443.048, 6.25, 0}, -{7483.79, -3085.44, 439.607, 6.25, 0}, -{7491.14, -3090.96, 439.983, 5.44, 0}, -{7497.62, -3098.22, 436.854, 5.44, 0}, -{7498.72, -3113.41, 434.596, 4.84, 0}, -{7500.06, -3122.51, 434.749, 5.17, 0}, -{7504.96, -3131.53, 434.475, 4.74, 0}, -{7504.31, -3133.53, 435.693, 3.84, 6000}, -{7504.55, -3133.27, 435.476, 0.68, 15000}, -{7501.99, -3126.01, 434.93, 1.83, 0}, -{7490.76, -3114.97, 434.431, 2.51, 0}, -{7479.64, -3105.51, 431.123, 1.83, 0}, -{7474.63, -3086.59, 428.994, 1.83, 2000}, -{7472.96, -3074.18, 427.566, 1.57, 0}, -{7472.25, -3063, 428.268, 1.55, 0}, -{7473.46, -3054.22, 427.588, 0.36, 0}, -{7475.08, -3053.6, 428.653, 0.36, 6000}, -{7474.66, -3053.56, 428.433, 3.19, 4000}, -{7471.81, -3058.84, 427.073, 4.29, 0}, -{7472.16, -3064.91, 427.772, 4.95, 0}, -{7471.56, -3085.36, 428.924, 4.72, 0}, -{7473.56, -3093.48, 429.294, 5.04, 0}, -{7478.94, -3104.29, 430.638, 5.23, 0}, -{7484.46, -3109.61, 432.769, 5.79, 0}, -{7490.23, -3111.08, 434.431, 0.02, 0}, -{7496.29, -3108, 434.783, 1.15, 0}, -{7497.46, -3100.66, 436.191, 1.50, 0}, -{7495.64, -3093.39, 438.349, 2.10, 0}, -{7492.44, -3086.01, 440.267, 1.38, 0}, -{7498.26, -3076.44, 440.808, 0.71, 0}, -{7506.4, -3067.35, 443.64, 0.77, 0}, -{7518.37, -3057.42, 445.584, 0.74, 0}, -{7517.51, -3056.3, 444.568, 2.49, 4500} -}; - -#define ASPECT_RAVEN 22915 - -#define ASPECT_RAVEN_SUMMON_X 7472.96 -#define ASPECT_RAVEN_SUMMON_Y -3074.18 -#define ASPECT_RAVEN_SUMMON_Z 427.566 -#define CLINTAR_SPIRIT_SUMMON_X 7459.2275 -#define CLINTAR_SPIRIT_SUMMON_Y -3122.5632 -#define CLINTAR_SPIRIT_SUMMON_Z 438.9842 -#define CLINTAR_SPIRIT_SUMMON_O 0.8594 - -#define CLINTAR_SPIRIT_SAY_START -1000286 -#define CLINTAR_SPIRIT_SAY_UNDER_ATTACK_1 -1000287 -#define CLINTAR_SPIRIT_SAY_UNDER_ATTACK_2 -1000288 -#define CLINTAR_SPIRIT_SAY_GET_ONE -1000289 -#define CLINTAR_SPIRIT_SAY_GET_TWO -1000290 -#define CLINTAR_SPIRIT_SAY_GET_THREE -1000291 -#define CLINTAR_SPIRIT_SAY_GET_FINAL -1000292 - -struct npc_clintar_spiritAI : public npc_escortAI -{ -public: - npc_clintar_spiritAI(Creature *c) : npc_escortAI(c) {} - - uint32 Step; - uint32 CurrWP; - uint32 Event_Timer; - uint32 checkPlayer_Timer; - - uint64 PlayerGUID; - - bool Event_onWait; - - void Reset() - { - if(!PlayerGUID) - { - Step = 0; - CurrWP = 0; - Event_Timer = 0; - PlayerGUID = 0; - checkPlayer_Timer = 1000; - Event_onWait = false; - } - } - - void JustDied(Unit *killer) - { - if(!PlayerGUID) - return; - - Player* pPlayer = Unit::GetPlayer(PlayerGUID); - if (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE) - { - pPlayer->FailQuest(10965); - PlayerGUID = 0; - Reset(); - } - } - - void EnterEvadeMode() - { - Player* pPlayer = Unit::GetPlayer(PlayerGUID); - if (pPlayer && pPlayer->isInCombat() && pPlayer->getAttackerForHelper()) - { - AttackStart(pPlayer->getAttackerForHelper()); - return; - } - npc_escortAI::EnterEvadeMode(); - } - - void EnterCombat(Unit* who) - { - uint32 rnd = rand()%2; - switch(rnd) - { - case 0: DoScriptText(CLINTAR_SPIRIT_SAY_UNDER_ATTACK_1, m_creature, who); break; - case 1: DoScriptText(CLINTAR_SPIRIT_SAY_UNDER_ATTACK_2, m_creature, who); break; - } - } - - void StartEvent(Player* pPlayer) - { - if(!pPlayer) - return; - - if(pPlayer->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE) - { - for(uint8 i = 0; i < 41; ++i) - { - AddWaypoint(i, Clintar_spirit_WP[i][0], Clintar_spirit_WP[i][1], Clintar_spirit_WP[i][2], (uint32)Clintar_spirit_WP[i][4]); - } - PlayerGUID = pPlayer->GetGUID(); - Start(true,false,PlayerGUID); - } - return; - } - - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); - - if(!PlayerGUID) - { - m_creature->setDeathState(JUST_DIED); - return; - } - - if (!m_creature->isInCombat() && !Event_onWait) - { - if (checkPlayer_Timer < diff) - { - Player* pPlayer = Unit::GetPlayer(PlayerGUID); - if (pPlayer && pPlayer->isInCombat() && pPlayer->getAttackerForHelper()) - AttackStart(pPlayer->getAttackerForHelper()); - - checkPlayer_Timer = 1000; - } - else - checkPlayer_Timer -= diff; - } - - if(Event_onWait && Event_Timer < diff) - { - Player* pPlayer = Unit::GetPlayer(PlayerGUID); - if (!pPlayer || (pPlayer && pPlayer->GetQuestStatus(10965) == QUEST_STATUS_NONE)) - { - m_creature->setDeathState(JUST_DIED); - return; - } - - switch(CurrWP) - { - case 0: - switch(Step) - { - case 0: - m_creature->Say(CLINTAR_SPIRIT_SAY_START,0,PlayerGUID); - Event_Timer = 8000; - Step = 1; - break; - case 1: - Event_onWait = false; - break; - } - break; - case 6: - switch(Step) - { - case 0: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); - Event_Timer = 5000; - Step = 1; - break; - case 1: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - DoScriptText(CLINTAR_SPIRIT_SAY_GET_ONE, m_creature, pPlayer); - Event_onWait = false; - break; - } - break; - case 15: - switch(Step) - { - case 0: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); - Event_Timer = 5000; - Step = 1; - break; - case 1: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - Event_onWait = false; - break; - } - break; - case 16: - switch(Step) - { - case 0: - DoScriptText(CLINTAR_SPIRIT_SAY_GET_TWO, m_creature, pPlayer); - Event_Timer = 15000; - Step = 1; - break; - case 1: - Event_onWait = false; - break; - } - break; - case 20: - switch(Step) - { - case 0: - { - Creature *mob = m_creature->SummonCreature(ASPECT_RAVEN, ASPECT_RAVEN_SUMMON_X, ASPECT_RAVEN_SUMMON_Y, ASPECT_RAVEN_SUMMON_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000); - if(mob) - { - mob->AddThreat(m_creature,10000.0f); - mob->AI()->AttackStart(m_creature); - } - Event_Timer = 2000; - Step = 1; - break; - } - case 1: - Event_onWait = false; - break; - } - break; - case 24: - switch(Step) - { - case 0: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 133); - Event_Timer = 5000; - Step = 1; - break; - case 1: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - Event_onWait = false; - break; - } - break; - case 25: - switch(Step) - { - case 0: - DoScriptText(CLINTAR_SPIRIT_SAY_GET_THREE, m_creature, pPlayer); - Event_Timer = 4000; - Step = 1; - break; - case 1: - Event_onWait = false; - break; - } - break; - case 40: - switch(Step) - { - case 0: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 2); - DoScriptText(CLINTAR_SPIRIT_SAY_GET_FINAL, m_creature, pPlayer); - pPlayer->CompleteQuest(10965); - Event_Timer = 1500; - Step = 1; - break; - case 1: - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - Event_Timer = 3000; - Step = 2; - break; - case 2: - pPlayer->TalkedToCreature(m_creature->GetEntry(), m_creature->GetGUID()); - PlayerGUID = 0; - Reset(); - m_creature->setDeathState(JUST_DIED); - break; - } - break; - default: - Event_onWait = false; - break; - } - - } else if(Event_onWait) Event_Timer -= diff; - } - - void WaypointReached(uint32 id) - { - CurrWP = id; - Event_Timer = 0; - Step = 0; - Event_onWait = true; - } -}; - -CreatureAI* GetAI_npc_clintar_spirit(Creature *_Creature) -{ - return new npc_clintar_spiritAI (_Creature); -} - -/*#### -# npc_clintar_dreamwalker -####*/ - -#define CLINTAR_SPIRIT 22916 - -bool QuestAccept_npc_clintar_dreamwalker(Player *player, Creature *creature, Quest const *quest ) -{ - if(quest->GetQuestId() == 10965) - { - Creature *clintar_spirit = creature->SummonCreature(CLINTAR_SPIRIT, CLINTAR_SPIRIT_SUMMON_X, CLINTAR_SPIRIT_SUMMON_Y, CLINTAR_SPIRIT_SUMMON_Z, CLINTAR_SPIRIT_SUMMON_O, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 100000); - if(clintar_spirit) - ((npc_clintar_spiritAI*)clintar_spirit->AI())->StartEvent(player); - } - return true; -} - -/*#### -# -####*/ - -void AddSC_moonglade() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_bunthen_plainswind"; - newscript->pGossipHello = &GossipHello_npc_bunthen_plainswind; - newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_great_bear_spirit"; - newscript->pGossipHello = &GossipHello_npc_great_bear_spirit; - newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_silva_filnaveth"; - newscript->pGossipHello = &GossipHello_npc_silva_filnaveth; - newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_clintar_dreamwalker"; - newscript->pQuestAcceptNPC = &QuestAccept_npc_clintar_dreamwalker; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_clintar_spirit"; - newscript->GetAI = &GetAI_npc_clintar_spirit; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/onyxias_lair/def_onyxia_lair.h b/src/scripts/scripts/zone/onyxias_lair/def_onyxia_lair.h deleted file mode 100644 index b5e92444f..000000000 --- a/src/scripts/scripts/zone/onyxias_lair/def_onyxia_lair.h +++ /dev/null @@ -1,28 +0,0 @@ - -struct cPosition -{ - float x; - float y; - float z; - float o; -}; - -enum SpawnDefinitions -{ - LEFT = 0, - RIGHT = 1, - MAX = 2, -}; - -static cPosition spawnEntrancePoints[MAX] = -{ - {-35.8699, -161.351, -91.1765}, - {-35.813, -268.307, -91.1498} -}; - -enum OnyxiaData -{ - DATA_ONYXIA = 1, - DATA_HATCH_EGGS = 2, - DATA_ERUPT = 3 -}; diff --git a/src/scripts/scripts/zone/scarlet_monastery/def_scarlet_monastery.h b/src/scripts/scripts/zone/scarlet_monastery/def_scarlet_monastery.h deleted file mode 100755 index b8ab82212..000000000 --- a/src/scripts/scripts/zone/scarlet_monastery/def_scarlet_monastery.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SCARLET_M -#define DEF_SCARLET_M - -#define TYPE_MOGRAINE_AND_WHITE_EVENT 1 -#define DATA_MOGRAINE 2 -#define DATA_WHITEMANE 3 -#define DATA_DOOR_WHITEMANE 4 - -#define DATA_HORSEMAN_EVENT 5 -#define GAMEOBJECT_PUMPKIN_SHRINE 6 -#endif - diff --git a/src/scripts/scripts/zone/scholomance/def_scholomance.h b/src/scripts/scripts/zone/scholomance/def_scholomance.h deleted file mode 100755 index 0216a48fc..000000000 --- a/src/scripts/scripts/zone/scholomance/def_scholomance.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SCHOLOMANCE_H -#define DEF_SCHOLOMANCE_H - -#define DATA_CANSPAWNGANDLING 1 -#define DATA_DOCTORTHEOLENKRASTINOV_DEATH 2 -#define DATA_INSTRUCTORMALICIA_DEATH 3 -#define DATA_LADYILLUCIABAROV_DEATH 4 -#define DATA_LORDALEXEIBAROV_DEATH 5 -#define DATA_LOREKEEPERPOLKELT_DEATH 6 -#define DATA_THERAVENIAN_DEATH 7 -#endif - diff --git a/src/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h b/src/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h deleted file mode 100755 index 1612bfd59..000000000 --- a/src/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHADOWFANG_H -#define DEF_SHADOWFANG_H - -#define TYPE_FREE_NPC 1 -#define TYPE_RETHILGORE 2 -#define TYPE_FENRUS 3 -#define TYPE_NANDOS 4 -#endif - diff --git a/src/scripts/scripts/zone/silithus/silithus.cpp b/src/scripts/scripts/zone/silithus/silithus.cpp deleted file mode 100755 index e2088a370..000000000 --- a/src/scripts/scripts/zone/silithus/silithus.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Silithus -SD%Complete: 100 -SDComment: Quest support: 7785, 8304. -SDCategory: Silithus -EndScriptData */ - -/* ContentData -npc_highlord_demitrian -npcs_rutgar_and_frankal -npc_cenarion_scout_jalia -npc_cenarion_scout_azenel -npc_cenarion_scout_landion -EndContentData */ - -#include "precompiled.h" - -/*### -## npc_highlord_demitrian -###*/ - -#define GOSSIP_DEMITRIAN1 "What do you know of it?" -#define GOSSIP_DEMITRIAN2 "I am listening , Demitrian." -#define GOSSIP_DEMITRIAN3 "Continue, please." -#define GOSSIP_DEMITRIAN4 "A battle?" -#define GOSSIP_DEMITRIAN5 "" -#define GOSSIP_DEMITRIAN6 "Caught unaware? How?" -#define GOSSIP_DEMITRIAN7 "So what did Ragnaros do next?" - -bool GossipHello_npc_highlord_demitrian(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu(_Creature->GetGUID()); - - if (player->GetQuestStatus(7785) == QUEST_STATUS_NONE && - (player->HasItemCount(18563,1,false) || player->HasItemCount(18564,1,false))) - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(6812, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_highlord_demitrian(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(6842, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(6843, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(6844, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(6867, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(6868, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, GOSSIP_DEMITRIAN7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(6869, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->SEND_GOSSIP_MENU(6870, _Creature->GetGUID()); - - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 19016, 1); - if (msg == EQUIP_ERR_OK) - player->StoreNewItem(dest, 19016, true); - break; - } - return true; -} - -/*### -## npcs_rutgar_and_frankal -###*/ - -//gossip item text best guess -#define GOSSIP_ITEM1 "I seek information about Natalia" - -#define GOSSIP_ITEM2 "That sounds dangerous!" -#define GOSSIP_ITEM3 "What did you do?" -#define GOSSIP_ITEM4 "Who?" -#define GOSSIP_ITEM5 "Women do that. What did she demand?" -#define GOSSIP_ITEM6 "What do you mean?" -#define GOSSIP_ITEM7 "What happened next?" - -#define GOSSIP_ITEM11 "Yes, please continue" -#define GOSSIP_ITEM12 "What language?" -#define GOSSIP_ITEM13 "The Priestess attacked you?!" -#define GOSSIP_ITEM14 "I should ask the monkey about this" -#define GOSSIP_ITEM15 "Then what..." - -//trigger creatures to kill -#define TRIGGER_RUTGAR 15222 -#define TRIGGER_FRANKAL 15221 - -bool GossipHello_npcs_rutgar_and_frankal(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && - _Creature->GetEntry() == 15170 && - !player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && - _Creature->GetEntry() == 15171 && - player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); - - player->SEND_GOSSIP_MENU(7754, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npcs_rutgar_and_frankal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(7755, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(7756, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7757, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(7758, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(7759, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(7760, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - player->SEND_GOSSIP_MENU(7761, _Creature->GetGUID()); - //'kill' our trigger to update quest status - player->KilledMonster( TRIGGER_RUTGAR, _Creature->GetGUID() ); - break; - - case GOSSIP_ACTION_INFO_DEF + 9: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM11, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(7762, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM12, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(7763, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM13, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(7764, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM14, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(7765, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM15, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); - player->SEND_GOSSIP_MENU(7766, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 14: - player->SEND_GOSSIP_MENU(7767, _Creature->GetGUID()); - //'kill' our trigger to update quest status - player->KilledMonster( TRIGGER_FRANKAL, _Creature->GetGUID() ); - break; - } - return true; -} - -/*###### -## npc_cenarion_scout_jalia -######*/ - -#define GOSSIP_ITEM_JALIA "Create Hive'Ashi Scout Report." - -bool GossipHello_npc_cenarion_scout_jalia(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(8739) == QUEST_STATUS_INCOMPLETE ) - if(!player->HasItemCount(21161,1)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_JALIA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_cenarion_scout_jalia(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_SENDER_INFO ) - { - player->CastSpell( player, 25845, false); - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -/*###### -## npc_cenarion_scout_azenel -######*/ - -#define GOSSIP_ITEM_AZENEL "Create Hive'Zora Scout Report." - -bool GossipHello_npc_cenarion_scout_azenel(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(8534) == QUEST_STATUS_INCOMPLETE ) - if(!player->HasItemCount(21158,1)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_AZENEL, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_cenarion_scout_azenel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_SENDER_INFO ) - { - player->CastSpell( player, 25843, false); - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -/*###### -## npc_cenarion_scout_landion -######*/ - -#define GOSSIP_ITEM_LANDION "Create Hive'Regal Scout Report." - -bool GossipHello_npc_cenarion_scout_landion(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(8738) == QUEST_STATUS_INCOMPLETE ) - if(!player->HasItemCount(21160,1)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_LANDION, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_cenarion_scout_landion(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_SENDER_INFO ) - { - player->CastSpell( player, 25847, false); - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -/////// -/// Wind Stone -/////// - -#define GOSSIP_WIND_STONE "You will listen to this, ville duke! I am not your Twilight's Hammer lapdog! I am here to challenge you! Come! Come, and meet your death..." - -#define DUKE_OF_SHARDS 15208 -#define DUKE_OF_ZEPHYRS 15220 -#define DUKE_OF_FATHOMS 15207 -#define DUKE_OF_CYNDERS 15206 - -bool GossipHello_go_wind_stone(Player *player, GameObject* _GO) -{ - if(player->HasEquiped(20406) && player->HasEquiped(20408) && player->HasEquiped(20407) && player->HasEquiped(20422)) - { - player->ADD_GOSSIP_ITEM(0, GOSSIP_WIND_STONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - } - - player->SEND_GOSSIP_MENU(_GO->GetGOInfo()->questgiver.gossipID, _GO->GetGUID()); - return true; -} - -void SendActionMenu_go_wind_stone(Player *player, GameObject* _GO, uint32 action) -{ - _GO->SetGoState(GO_STATE_ACTIVE); - _GO->SetRespawnTime(600); - player->CLOSE_GOSSIP_MENU(); - - float x,y,z; - player->GetClosePoint(x,y,z, 0.0f, 2.0f, frand(0, M_PI)); - - switch(action) - { - case GOSSIP_ACTION_INFO_DEF: - player->CastSpell(player,24762,false); - player->SummonCreature(RAND(DUKE_OF_CYNDERS, DUKE_OF_FATHOMS, DUKE_OF_SHARDS, DUKE_OF_ZEPHYRS), x,y,z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 600000); - player->DestroyItemCount(20422, 1, true, true); - break; - } -} - -bool GossipSelect_go_wind_stone(Player *player, GameObject* _GO, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_go_wind_stone(player, _GO, action); break; - } - return true; -} - -/*###### -## go_silithyst_mound (id 181597) -######*/ -#define GOSSIP_TAKE_BUFF "[PH] Take the Silithyst" -#define SPELL_SILITHYST 29519 - -bool GOUse_go_silithyst_mound(Player* pPlayer, GameObject* pGO) -{ - pPlayer->PlayerTalkClass->ClearMenus(); - pPlayer->ADD_GOSSIP_ITEM(0, GOSSIP_TAKE_BUFF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - pPlayer->SEND_GOSSIP_MENU(pGO->GetGOInfo()->questgiver.gossipID, pGO->GetGUID()); - return true; -} - -bool GOGossipSelect_go_silithyst_mound(Player* pPlayer, GameObject* pGO, uint32 Sender, uint32 action) -{ - switch(action) - { - - case GOSSIP_ACTION_INFO_DEF+1: - if(!pPlayer->HasAura(SPELL_SILITHYST)) - pPlayer->CastSpell(pPlayer,SPELL_SILITHYST,false); - pGO->Delete(); - break; - } - - pPlayer->CLOSE_GOSSIP_MENU(); - return true; -} - -/*### -## -####*/ - -void AddSC_silithus() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "npc_highlord_demitrian"; - newscript->pGossipHello = &GossipHello_npc_highlord_demitrian; - newscript->pGossipSelect = &GossipSelect_npc_highlord_demitrian; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npcs_rutgar_and_frankal"; - newscript->pGossipHello = &GossipHello_npcs_rutgar_and_frankal; - newscript->pGossipSelect = &GossipSelect_npcs_rutgar_and_frankal; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_cenarion_scout_jalia"; - newscript->pGossipHello = &GossipHello_npc_cenarion_scout_jalia; - newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_jalia; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_cenarion_scout_azenel"; - newscript->pGossipHello = &GossipHello_npc_cenarion_scout_azenel; - newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_azenel; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_cenarion_scout_landion"; - newscript->pGossipHello = &GossipHello_npc_cenarion_scout_landion; - newscript->pGossipSelect = &GossipSelect_npc_cenarion_scout_landion; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="go_wind_stone"; - newscript->pGOUse = &GossipHello_go_wind_stone; - newscript->pGossipSelectGO = &GossipSelect_go_wind_stone; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name = "go_silithyst_mound"; - newscript->pGOUse = &GOUse_go_silithyst_mound; - newscript->pGossipSelectGO = &GOGossipSelect_go_silithyst_mound; - newscript->RegisterSelf(); -} - diff --git a/src/scripts/scripts/zone/stratholme/def_stratholme.h b/src/scripts/scripts/zone/stratholme/def_stratholme.h deleted file mode 100755 index 79dd277c9..000000000 --- a/src/scripts/scripts/zone/stratholme/def_stratholme.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_STRATHOLME_H -#define DEF_STRATHOLME_H - -#define TYPE_BARON_RUN 1 -#define TYPE_BARONESS 2 -#define TYPE_NERUB 3 -#define TYPE_PALLID 4 -#define TYPE_RAMSTEIN 5 -#define TYPE_BARON 6 - -#define DATA_BARON 10 -#define DATA_YSIDA_TRIGGER 11 - -#define TYPE_SH_QUEST 20 -#define TYPE_SH_CATHELA 21 -#define TYPE_SH_GREGOR 22 -#define TYPE_SH_NEMAS 23 -#define TYPE_SH_VICAR 24 -#define TYPE_SH_AELMAR 25 - -#define QUEST_DEAD_MAN_PLEA 8945 -#define SPELL_BARON_ULTIMATUM 27861 -#endif - diff --git a/src/scripts/scripts/zone/sunwell_plateau/boss_muru.cpp b/src/scripts/scripts/zone/sunwell_plateau/boss_muru.cpp deleted file mode 100755 index edf4b20e2..000000000 --- a/src/scripts/scripts/zone/sunwell_plateau/boss_muru.cpp +++ /dev/null @@ -1,754 +0,0 @@ -/* Copyright (C) 2009 Trinity -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: Boss_Muru -SD%Complete: 80 -SDComment: all sounds, black hole effect triggers to often (46228) -*/ - -#include "precompiled.h" -#include "def_sunwell_plateau.h" - -// Muru & Entropius's spells -enum Spells -{ - SPELL_ENRAGE = 26662, - - // Muru's spells - SPELL_NEGATIVE_ENERGY = 46009, //(this trigger 46008) - SPELL_DARKNESS = 45999, - SPELL_OPEN_ALL_PORTALS = 46177, - SPELL_OPEN_PORTAL = 45977, - SPELL_OPEN_PORTAL_2 = 45976, - SPELL_SUMMON_BERSERKER = 46037, - SPELL_SUMNON_FURY_MAGE = 46038, - SPELL_SUMMON_VOID_SENTINEL = 45988, - SPELL_SUMMON_ENTROPIUS = 46217, - - // Entropius's spells - SPELL_DARKNESS_E = 46269, - SPELL_BLACKHOLE = 46282, - SPELL_NEGATIVE_ENERGY_E = 46284, - SPELL_ENTROPIUS_SPAWN = 46223, - - // Shadowsword Berserker's spells - SPELL_FLURRY = 46160, - SPELL_DUAL_WIELD = 29651, - - // Shadowsword Fury Mage's spells - SPELL_FEL_FIREBALL = 46101, - SPELL_SPELL_FURY = 46102, - - // Void Sentinel's spells - SPELL_SHADOW_PULSE = 46087, - SPELL_VOID_BLAST = 46161, - - // Void Spawn's spells - SPELL_SHADOW_BOLT_VOLLEY = 46082, - - //Dark Fiend Spells - SPELL_DARKFIEND_AOE = 45944, - SPELL_DARKFIEND_VISUAL = 45936, - SPELL_DARKFIEND_SKIN = 45934, - - //Black Hole Spells - SPELL_BLACKHOLE_SPAWN = 46242, - SPELL_BLACKHOLE_GROW = 46228 -}; - -enum Creatures -{ - CREATURE_DARKNESS = 25879, - CREATURE_DARK_FIENDS = 25744, - CREATURE_BERSERKER = 25798, - CREATURE_FURY_MAGE = 25799, - CREATURE_VOID_SENTINEL = 25772, - CREATURE_VOID_SPAWN = 25824, - CREATURE_BLACK_HOLE = 25855, - BOSS_MURU = 25741, - BOSS_ENTROPIUS = 25840 -}; - -enum BossTimers -{ - TIMER_DARKNESS = 0, - TIMER_HUMANOIDES = 1, - TIMER_PHASE = 2, - TIMER_SENTINEL = 3 -}; - -float DarkFiends[8][4] = -{ - {1819.9, 609.80, 69.74, 1.94}, - {1829.39, 617.89, 69.73, 2.61}, - {1801.98, 633.62, 69.74, 5.71}, - {1830.88, 629.99, 69.73, 3.52}, - {1800.38, 621.41, 69.74, 0.22}, - {1808.3 , 612.45, 69.73, 1.02}, - {1823.9 , 639.69, 69.74, 4.12}, - {1811.85, 640.46, 69.73, 4.97} -}; - -float Humanoides[6][5] = -{ - {CREATURE_FURY_MAGE, 1780.16, 666.83, 71.19, 5.21}, - {CREATURE_FURY_MAGE, 1847.93, 600.30, 71.30, 2.57}, - {CREATURE_BERSERKER, 1779.97, 660.64, 71.19, 5.28}, - {CREATURE_BERSERKER, 1786.2 , 661.01, 71.19, 4.51}, - {CREATURE_BERSERKER, 1845.17, 602.63, 71.28, 2.43}, - {CREATURE_BERSERKER, 1842.91, 599.93, 71.23, 2.44} -}; - -uint32 EnrageTimer = 600000; -struct boss_entropiusAI : public ScriptedAI -{ - boss_entropiusAI(Creature *c) : ScriptedAI(c), Summons(m_creature) - { - pInstance = c->GetInstanceData(); - Combat = false; - } - - ScriptedInstance* pInstance; - SummonList Summons; - - bool Combat; - uint32 BlackHoleSummonTimer; - - uint32 checkTimer; - - void Reset() - { - if (!Combat) - { - BlackHoleSummonTimer = 15000; - DoCastAOE(SPELL_NEGATIVE_ENERGY_E, false); - } - else - { - pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED); - - Summons.DespawnAll(); - } - - checkTimer = 3000; - } - - void EnterCombat(Unit *who) - { - DoCastAOE(SPELL_NEGATIVE_ENERGY_E, true); - DoCast(m_creature, SPELL_ENTROPIUS_SPAWN, false); - } - - void JustSummoned(Creature* summoned) - { - switch (summoned->GetEntry()) - { - case CREATURE_DARK_FIENDS: - summoned->CastSpell(summoned,SPELL_DARKFIEND_VISUAL,false); - break; - case CREATURE_DARKNESS: - summoned->addUnitState(UNIT_STAT_STUNNED); - float x,y,z,o; - summoned->GetHomePosition(x,y,z,o); - m_creature->SummonCreature(CREATURE_DARK_FIENDS, x,y,z,o, TEMPSUMMON_CORPSE_DESPAWN, 0); - break; - } - - summoned->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM,0, 50, true)); - Summons.Summon(summoned); - } - - void KilledUnit(Unit* victim) - { - - } - - void JustDied(Unit* killer) - { - pInstance->SetData(DATA_MURU_EVENT, DONE); - Summons.DespawnAll(); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (checkTimer < diff) - { - DoZoneInCombat(); - checkTimer = 3000; - } - else - checkTimer -= diff; - - if (!Combat) - Combat = true; - - if (EnrageTimer < diff) - { - DoCast(m_creature, SPELL_ENRAGE, false); - EnrageTimer = 60000; - } - else - EnrageTimer -= diff; - - if (BlackHoleSummonTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true); - if (target) - { - DoCast(target, SPELL_DARKNESS_E, false); - target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true); - if (target) - { - target->CastSpell(target, SPELL_BLACKHOLE, false); - BlackHoleSummonTimer = 15000; - } - } - } - else - BlackHoleSummonTimer -= diff; - - DoMeleeAttackIfReady(); - } - -}; - -CreatureAI* GetAI_boss_entropius(Creature *_Creature) -{ - return new boss_entropiusAI (_Creature); -} - -struct boss_muruAI : public Scripted_NoMovementAI -{ - boss_muruAI(Creature *c) : Scripted_NoMovementAI(c), Summons(m_creature) - { - pInstance = c->GetInstanceData(); - } - - ScriptedInstance* pInstance; - SummonList Summons; - - uint8 Phase; - uint32 Timer[4]; - - uint32 checkTimer; - - bool DarkFiend; - - void Reset() - { - DarkFiend = false; - Phase = 1; - - EnrageTimer = 600000; - Timer[TIMER_DARKNESS] = 45000; - Timer[TIMER_HUMANOIDES] = 10000; - Timer[TIMER_PHASE] = 2000; - Timer[TIMER_SENTINEL] = 31500; - Summons.DespawnAll(); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_ON); - - checkTimer = 3000; - - pInstance->SetData(DATA_MURU_EVENT, NOT_STARTED); - } - - void EnterCombat(Unit *who) - { - //pInstance->SetData(DATA_MURU_EVENT, IN_PROGRESS); - DoCastAOE(SPELL_NEGATIVE_ENERGY,false); - } - - void KilledUnit(Unit* victim){} - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if (damage > m_creature->GetHealth() && Phase == 1) - { - damage = 0; - Phase = 2; - m_creature->RemoveAllAuras(); - DoCast(m_creature, SPELL_OPEN_ALL_PORTALS, false); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - if (Phase > 1 && Phase < 4) - damage = 0; - } - - void JustSummoned(Creature* summoned) - { - switch (summoned->GetEntry()) - { - case BOSS_ENTROPIUS: - m_creature->SetVisibility(VISIBILITY_OFF); - break; - case CREATURE_DARK_FIENDS: - summoned->CastSpell(summoned,SPELL_DARKFIEND_VISUAL,false); - break; - default: - break; - } - - summoned->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM,0, 50, true)); - Summons.Summon(summoned); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (checkTimer < diff) - { - DoZoneInCombat(); - checkTimer = 3000; - } - else - checkTimer -= diff; - - if (Phase == 3) - { - if (Timer[TIMER_PHASE] GetData(DATA_MURU_EVENT)) - { - case NOT_STARTED: - Reset(); - break; - case DONE: - Phase = 4; - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DestroyForNearbyPlayers(); - m_creature->Kill(m_creature, false); - m_creature->RemoveCorpse(); - break; - default: - break; - } - - Timer[TIMER_PHASE] = 3000; - } - else - Timer[TIMER_PHASE] -= diff; - - return; - } - - if (EnrageTimer < diff) - { - DoCast(m_creature, SPELL_ENRAGE, false); - EnrageTimer = 60000; - } - else - EnrageTimer -= diff; - - for (uint8 i = 0; i < 4; ++i) - { - if (Timer[i] < diff) - { - switch (i) - { - case TIMER_DARKNESS: - if (!DarkFiend) - { - DoCastAOE(SPELL_DARKNESS, false); - Timer[TIMER_DARKNESS] = 3000; - DarkFiend = true; - } - else - { - DarkFiend = false; - for (uint8 i = 0; i < 8; ++i) - m_creature->SummonCreature(CREATURE_DARK_FIENDS,DarkFiends[i][0],DarkFiends[i][1],DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0); - - Timer[TIMER_DARKNESS] = 42000; - } - - break; - - case TIMER_HUMANOIDES: - for (uint8 i = 0; i < 6; ++i) - m_creature->SummonCreature(Humanoides[i][0],Humanoides[i][1],Humanoides[i][2],Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0); - - Timer[TIMER_HUMANOIDES] = 60000; - break; - - case TIMER_PHASE: - m_creature->RemoveAllAuras(); - DoCast(m_creature, SPELL_SUMMON_ENTROPIUS, false); - Timer[TIMER_PHASE] = 3000; - Phase = 3; - return; - - case TIMER_SENTINEL: - DoCastAOE(SPELL_OPEN_PORTAL_2, false); - Timer[TIMER_SENTINEL] = 30000; - break; - } - - break; - } - } - - //Timer - for (uint8 i = 0; i < 4; ++i) - { - if (i != TIMER_PHASE) - Timer[i] -= diff; - else - if (Phase == 2) - Timer[i] -= diff; - } - } -}; - -CreatureAI* GetAI_boss_muru(Creature *_Creature) -{ - return new boss_muruAI (_Creature); -} - -struct npc_muru_portalAI : public Scripted_NoMovementAI -{ - npc_muru_portalAI(Creature *c) : Scripted_NoMovementAI(c), Summons(m_creature) - { - pInstance = c->GetInstanceData(); - } - - ScriptedInstance* pInstance; - SummonList Summons; - Creature* Muru; - bool SummonSentinel; - bool InAction; - uint32 SummonTimer; - - void Reset() - { - m_creature->addUnitState(UNIT_STAT_STUNNED); - SummonTimer = 5000; - InAction = false; - SummonSentinel = false; - Summons.DespawnAll(); - } - - void EnterCombat(Unit *who) {} - - void JustSummoned(Creature* summoned) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_PLAYER_GUID)); - if (target) - summoned->AI()->AttackStart(target); - - Summons.Summon(summoned); - } - - void SpellHit(Unit* caster, const SpellEntry* Spell) - { - float x,y,z,o; - m_creature->GetHomePosition(x,y,z,o); - DoTeleportTo(x,y,z); - InAction = true; - - switch (Spell->Id) - { - case SPELL_OPEN_ALL_PORTALS: - DoCastAOE(SPELL_OPEN_PORTAL, false); - break; - case SPELL_OPEN_PORTAL_2: - DoCastAOE(SPELL_OPEN_PORTAL, false); - SummonSentinel = true; - break; - } - } - - void UpdateAI(const uint32 diff) - { - if (!SummonSentinel) - { - if(InAction && pInstance->GetData(DATA_MURU_EVENT) == NOT_STARTED) - Reset(); - - return; - } - - if (SummonTimer < diff) - { - DoCastAOE(SPELL_SUMMON_VOID_SENTINEL, false); - SummonTimer = 5000; - SummonSentinel = false; - } - else - SummonTimer -= diff; - } -}; - -CreatureAI* GetAI_npc_muru_portal(Creature *_Creature) -{ - return new npc_muru_portalAI (_Creature); -} - -struct npc_dark_fiendAI : public ScriptedAI -{ - npc_dark_fiendAI(Creature *c) : ScriptedAI(c) - { - pInstance = c->GetInstanceData(); - } - - ScriptedInstance* pInstance; - bool InAction; - uint32 WaitTimer; - - void Reset() - { - WaitTimer = 2000; - InAction = false; - m_creature->addUnitState(UNIT_STAT_STUNNED); - } - - void EnterCombat(Unit *who) {} - - void SpellHit(Unit* caster, const SpellEntry* Spell) - { - for (uint8 i = 0; i < 3; ++i) - { - if (Spell->Effect[i] == 38) - { - m_creature->Kill(m_creature, false); - m_creature->RemoveCorpse(); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (WaitTimer < diff) - { - if (!InAction) - { - m_creature->clearUnitState(UNIT_STAT_STUNNED); - DoCastAOE(SPELL_DARKFIEND_SKIN, false); - - if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0, 100, true)) - AttackStart(target); - - InAction = true; - WaitTimer = 500; - } - else - { - if (m_creature->IsWithinDistInMap(m_creature->getVictim(), 5)) - { - DoCastAOE(SPELL_DARKFIEND_AOE, false); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - } - - WaitTimer = 500; - } - } - else - WaitTimer -= diff; - } - -}; - -CreatureAI* GetAI_npc_dark_fiend(Creature *_Creature) -{ - return new npc_dark_fiendAI (_Creature); -} - -struct npc_void_sentinelAI : public ScriptedAI -{ - npc_void_sentinelAI(Creature *c) : ScriptedAI(c) - { - pInstance = c->GetInstanceData(); - } - - ScriptedInstance* pInstance; - - uint32 PulseTimer; - uint32 VoidBlastTimer; - - - void Reset() - { - PulseTimer = 3000; - VoidBlastTimer = 45000; //is this a correct timer? - float x,y,z,o; - m_creature->GetHomePosition(x,y,z,o); - DoTeleportTo(x,y,71); - }; - - void EnterCombat(Unit *who) {} - - void JustDied(Unit* killer) - { - for (uint8 i = 0; i < 8; ++i) - m_creature->SummonCreature(CREATURE_VOID_SPAWN, m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(), rand()%6, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000); - } - - void UpdateAI(const uint32 diff) - { - if (!UpdateVictim()) - return; - - if (PulseTimer < diff) - { - DoCastAOE(SPELL_SHADOW_PULSE, true); - PulseTimer = 3000; - } - else - PulseTimer -= diff; - - if (VoidBlastTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_VOID_BLAST, false); - VoidBlastTimer = 45000; - } - else - VoidBlastTimer -= diff; - - DoMeleeAttackIfReady(); - } - -}; - -CreatureAI* GetAI_npc_void_sentinel(Creature *_Creature) -{ - return new npc_void_sentinelAI (_Creature); -} - -struct npc_blackholeAI : public ScriptedAI -{ - npc_blackholeAI(Creature *c) : ScriptedAI(c) - { - pInstance = c->GetInstanceData(); - } - - ScriptedInstance* pInstance; - - uint32 DespawnTimer; - uint32 SpellTimer; - uint8 Phase; - uint8 NeedForAHack; - - void Reset() - { - DespawnTimer = 15000; - SpellTimer = 5000; - Phase = 0; - m_creature->addUnitState(UNIT_STAT_STUNNED); - DoCastAOE(SPELL_BLACKHOLE_SPAWN, true); - } - - void EnterCombat(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if (SpellTimer < diff) - { - Unit* Victim = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_PLAYER_GUID)); - switch (NeedForAHack) - { - case 0: - m_creature->clearUnitState(UNIT_STAT_STUNNED); - DoCastAOE(SPELL_BLACKHOLE_GROW, false); - if (Victim) - AttackStart(Victim); - - SpellTimer = 700; - NeedForAHack = 2; - break; - case 1: - m_creature->AddAura(SPELL_BLACKHOLE_GROW, m_creature); - NeedForAHack = 2; - SpellTimer = 600; - break; - case 2: - SpellTimer = 400; - NeedForAHack = 3; - m_creature->RemoveAura(SPELL_BLACKHOLE_GROW, 1); - break; - case 3: - SpellTimer = 400+rand()%500; - NeedForAHack = 1; - Unit* Temp = m_creature->getVictim(); - if (Temp && Temp->GetPositionZ() > 73 && Victim) - AttackStart(Victim); - - break; - } - } - else - SpellTimer -= diff; - - if (DespawnTimer < diff) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DestroyForNearbyPlayers(); - m_creature->Kill(m_creature, false); - m_creature->RemoveCorpse(); - } - else - DespawnTimer -= diff; - } -}; - -CreatureAI* GetAI_npc_blackhole(Creature *_Creature) -{ - return new npc_blackholeAI (_Creature); -} - -void AddSC_boss_muru() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_muru"; - newscript->GetAI = &GetAI_boss_muru; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="boss_entropius"; - newscript->GetAI = &GetAI_boss_entropius; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_muru_portal"; - newscript->GetAI = &GetAI_npc_muru_portal; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_dark_fiend"; - newscript->GetAI = &GetAI_npc_dark_fiend; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_void_sentinel"; - newscript->GetAI = &GetAI_npc_void_sentinel; - newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="npc_blackhole"; - newscript->GetAI = &GetAI_npc_blackhole; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau.cpp b/src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau.cpp deleted file mode 100755 index aa7ebeac1..000000000 --- a/src/scripts/scripts/zone/sunwell_plateau/sunwell_plateau.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2009 Trinity - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Sunwell_Plateau -SD%Complete: 0 -SDComment: Placeholder, Epilogue after Kil'jaeden, Captain Selana Gossips -EndScriptData */ - -/* ContentData -npc_prophet_velen -npc_captain_selana -EndContentData */ - -#include "precompiled.h" -#include "def_sunwell_plateau.h" - -/*###### -## npc_prophet_velen -######*/ - -enum ProphetSpeeches -{ - PROPHET_SAY1 = -1580099, - PROPHET_SAY2 = -1580100, - PROPHET_SAY3 = -1580101, - PROPHET_SAY4 = -1580102, - PROPHET_SAY5 = -1580103, - PROPHET_SAY6 = -1580104, - PROPHET_SAY7 = -1580105, - PROPHET_SAY8 = -1580106 -}; - -enum LiadrinnSpeeches -{ - LIADRIN_SAY1 = -1580107, - LIADRIN_SAY2 = -1580108, - LIADRIN_SAY3 = -1580109 -}; - - -/*###### -## npc_captain_selana -######*/ - -#define CS_GOSSIP1 "Give me a situation report, Captain." -#define CS_GOSSIP2 "What went wrong?" -#define CS_GOSSIP3 "Why did they stop?" -#define CS_GOSSIP4 "Your insight is appreciated." - -bool GossipHello_npc_captain_selana(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(12588, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_captain_selana(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(12589, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(12590, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, CS_GOSSIP4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(12591, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->SEND_GOSSIP_MENU(12592, _Creature->GetGUID()); - break; - } - return true; -} - -void AddSC_sunwell_plateau() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_captain_selana"; - newscript->pGossipHello = &GossipHello_npc_captain_selana; - newscript->pGossipSelect = &GossipSelect_npc_captain_selana; - newscript->RegisterSelf(); -} diff --git a/src/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h b/src/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h deleted file mode 100755 index 76f8d5753..000000000 --- a/src/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_ARCATRAZ_H -#define DEF_ARCATRAZ_H - -#define TYPE_ZEREKETH 1 -#define TYPE_DALLIAH 2 -#define TYPE_SOCCOTHRATES 3 -#define TYPE_HARBINGERSKYRISS 4 -#define TYPE_WARDEN_1 5 -#define TYPE_WARDEN_2 6 -#define TYPE_WARDEN_3 7 -#define TYPE_WARDEN_4 8 -#define TYPE_WARDEN_5 9 -#define DATA_MELLICHAR 10 -#define TYPE_SHIELD_OPEN 11 -#define DATA_SPHERE_SHIELD 12 -#endif - diff --git a/src/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h b/src/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h deleted file mode 100755 index 6fbf1a3b8..000000000 --- a/src/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_THE_EYE_H -#define DEF_THE_EYE_H - -#define DATA_ALAREVENT 1 -#define DATA_ASTROMANCER 2 -#define DATA_GRANDASTROMANCERCAPERNIAN 3 -#define DATA_HIGHASTROMANCERSOLARIANEVENT 4 -#define DATA_KAELTHAS 5 -#define DATA_KAELTHASEVENT 6 -#define DATA_LORDSANGUINAR 7 -#define DATA_MASTERENGINEERTELONICUS 8 -#define DATA_THALADREDTHEDARKENER 10 -#define DATA_VOIDREAVEREVENT 11 -#define DATA_ALAR 12 -#define DATA_EXPLODE 13 - -#endif - diff --git a/src/scripts/scripts/zone/tempest_keep/the_mechanar/def_mechanar.h b/src/scripts/scripts/zone/tempest_keep/the_mechanar/def_mechanar.h deleted file mode 100755 index f993aff66..000000000 --- a/src/scripts/scripts/zone/tempest_keep/the_mechanar/def_mechanar.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef DEF_MECHANAR_H -#define DEF_MECHANAR_H - -#define DATA_NETHERMANCER_EVENT 1 -#define DATA_IRONHAND_EVENT 2 -#define DATA_GYROKILL_EVENT 3 -#define DATA_CACHE_OF_LEGION_EVENT 4 -#define DATA_MECHANO_LORD_EVENT 5 - -#define GET_CHARGE_ID(p) ( (p)->HasAura(39088, 0) ? (1) : ( (p)->HasAura(39091, 0) ? (-1) : (0) )) - -#endif - diff --git a/src/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h b/src/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h deleted file mode 100755 index 1312bed0d..000000000 --- a/src/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_TEMPLE_OF_AHNQIRAJ_H -#define DEF_TEMPLE_OF_AHNQIRAJ_H - -#define DATA_THE_PROPHET_SKERAM 0 -#define DATA_BATTLEGUARD_SARTURA 1 -#define DATA_FANKRISS_THE_UNYIELDING 2 -#define DATA_PRINCESS_HUHURAN 3 -#define DATA_TWIN_EMPERORS 4 -#define DATA_C_THUN 5 -#define DATA_BUG_TRIO 6 -#define DATA_VISCIDUS 7 -#define DATA_OURO 8 - -#define DATA_SKERAM 9 -#define DATA_KRI 10 -#define DATA_VEM 11 -#define DATA_VEKLOR 12 -#define DATA_VEKNILASH 13 -#define DATA_BUG_TRIO_DEATH 14 - -#define DATA_CTHUN_PHASE 20 - -#endif - diff --git a/src/scripts/scripts/zone/wailing_caverns/def_wailing_caverns.h b/src/scripts/scripts/zone/wailing_caverns/def_wailing_caverns.h deleted file mode 100644 index 6ef1a673c..000000000 --- a/src/scripts/scripts/zone/wailing_caverns/def_wailing_caverns.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_WAILING_CAVERNS_H -#define DEF_WAILING_CAVERNS_H - -enum eTypes -{ - TYPE_LORD_COBRAHN = 1, - TYPE_LORD_PYTHAS = 2, - TYPE_LADY_ANACONDRA = 3, - TYPE_LORD_SERPENTIS = 4, - TYPE_NARALEX_EVENT = 5, - TYPE_NARALEX_PART1 = 6, - TYPE_NARALEX_PART2 = 7, - TYPE_NARALEX_PART3 = 8, - TYPE_MUTANUS_THE_DEVOURER = 9, - TYPE_NARALEX_YELLED = 10, - - DATA_NARALEX = 3679, -}; - -#endif diff --git a/src/scripts/scripts/zone/zulaman/zulaman_trash.cpp b/src/scripts/scripts/zone/zulaman/zulaman_trash.cpp deleted file mode 100644 index d7565d2d7..000000000 --- a/src/scripts/scripts/zone/zulaman/zulaman_trash.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2008 - 2010 HellgroundDev -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -*/ - -/* ScriptData -SDName: Zulaman's trash AI -SD%Complete: 0 -SDComment: Some more complicated trash behaviours than possible in EventAI -SDCategory: Zul'Aman -EndScriptData */ - -/* ContentData -EndContentData */ - -#include "precompiled.h" -#include "def_zulaman.h" - -void AddSC_zulaman_trash() -{/* - Script *newscript; - - newscript = new Script; - newscript->Name = ""; - newscript->GetAI = &GetAI_; - newscript->RegisterSelf();*/ -} \ No newline at end of file diff --git a/src/scripts/scripts/zone/zulgurub/def_zulgurub.h b/src/scripts/scripts/zone/zulgurub/def_zulgurub.h deleted file mode 100755 index 510698bf4..000000000 --- a/src/scripts/scripts/zone/zulgurub/def_zulgurub.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_ZULGURUB_H -#define DEF_ZULGURUB_H - -#define DATA_JEKLIKEVENT 1 -#define DATA_VENOXISEVENT 2 -#define DATA_MARLIEVENT 3 -#define DATA_THEKALEVENT 4 -#define DATA_ARLOKKEVENT 5 -#define DATA_HAKKAREVENT 6 -#define DATA_MANDOKIREVENT 7 -#define DATA_JINDOEVENT 8 -#define DATA_GAHZRANKAEVENT 9 -#define DATA_EDGEOFMADNESSEVENT 10 -#define DATA_JINDO 11 -#define DATA_LORKHAN 12 -#define DATA_THEKAL 13 -#define DATA_ZATH 14 -#define DATA_THEKALFAKEDEATH 15 -#define DATA_LORKHANISDEAD 16 -#define DATA_ZATHISDEAD 17 -#define DATA_OHGAN 18 - -#endif - diff --git a/src/scripts/system/ScriptLoader.cpp b/src/scripts/system/ScriptLoader.cpp index 7aa14eae2..677d6caab 100644 --- a/src/scripts/system/ScriptLoader.cpp +++ b/src/scripts/system/ScriptLoader.cpp @@ -1,6 +1,20 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "precompiled.h" @@ -72,6 +86,7 @@ extern void AddSC_boss_nexusprince_shaffar(); extern void AddSC_boss_pandemonius(); extern void AddSC_boss_yor(); extern void AddSC_instance_mana_tombs(); +extern void AddSC_mana_tombs(); //--Sekketh Halls extern void AddSC_boss_darkweaver_syth(); @@ -144,6 +159,7 @@ extern void AddSC_boss_quatermasterzigris(); extern void AddSC_boss_pyroguard_emberseer(); extern void AddSC_boss_gyth(); extern void AddSC_boss_rend_blackhand(); +extern void AddSC_instance_blackrock_spire(); //Blackwing lair extern void AddSC_boss_razorgore(); @@ -210,6 +226,7 @@ extern void AddSC_serpent_shrine_trash(); extern void AddSC_boss_lord_ahune(); extern void AddSC_boss_mennu_the_betrayer(); extern void AddSC_instance_slave_pens(); +extern void AddSC_slave_pens_trash(); //--Steam Vault extern void AddSC_boss_hydromancer_thespia(); @@ -231,6 +248,7 @@ extern void AddSC_instance_deadmines(); //Desolace extern void AddSC_desolace(); //Dire Maul +extern void AddSC_dire_maul(); //Dun Morogh extern void AddSC_dun_morogh(); @@ -286,6 +304,7 @@ extern void AddSC_boss_warchief_kargath_bladefist(); extern void AddSC_instance_shattered_halls(); //--Ramparts +extern void AddSC_instance_ramparts(); extern void AddSC_boss_watchkeeper_gargolmar(); extern void AddSC_boss_omor_the_unscarred(); extern void AddSC_boss_vazruden_the_herald(); @@ -570,6 +589,7 @@ extern void AddSC_ungoro_crater(); //Upper blackrock spire //Wailing caverns extern void AddSC_wailing_caverns(); +extern void AddSC_instance_wailing_caverns(); //Western plaguelands extern void AddSC_western_plaguelands(); @@ -587,6 +607,7 @@ extern void AddSC_zangarmarsh(); //Zul'Farrak extern void AddSC_zulfarrak(); +extern void AddSC_instance_zul_farrak(); //Zul'Gurub extern void AddSC_boss_jeklik(); @@ -687,6 +708,7 @@ void AddScripts() AddSC_boss_pandemonius(); AddSC_boss_yor(); AddSC_instance_mana_tombs(); + AddSC_mana_tombs(); //--Sekketh Halls AddSC_boss_darkweaver_syth(); @@ -756,7 +778,8 @@ void AddScripts() AddSC_boss_pyroguard_emberseer(); AddSC_boss_gyth(); AddSC_boss_rend_blackhand(); - + AddSC_instance_blackrock_spire(); + //Blackwing lair AddSC_boss_razorgore(); AddSC_boss_vael(); @@ -822,6 +845,7 @@ void AddScripts() AddSC_boss_lord_ahune(); AddSC_boss_mennu_the_betrayer(); AddSC_instance_slave_pens(); + AddSC_slave_pens_trash(); //--Steam Vault AddSC_boss_hydromancer_thespia(); @@ -843,6 +867,7 @@ void AddScripts() //Desolace AddSC_desolace(); //Dire Maul + AddSC_dire_maul(); //Dun Morogh AddSC_dun_morogh(); @@ -898,6 +923,7 @@ void AddScripts() AddSC_instance_shattered_halls(); //--Ramparts + AddSC_instance_ramparts(); AddSC_boss_watchkeeper_gargolmar(); AddSC_boss_omor_the_unscarred(); AddSC_boss_vazruden_the_herald(); @@ -1183,6 +1209,7 @@ void AddScripts() //Upper blackrock spire //Wailing caverns AddSC_wailing_caverns(); + AddSC_instance_wailing_caverns(); //Western plaguelands AddSC_western_plaguelands(); @@ -1200,6 +1227,7 @@ void AddScripts() //Zul'Farrak AddSC_zulfarrak(); + AddSC_instance_zul_farrak(); //Zul'Gurub AddSC_boss_jeklik(); diff --git a/src/scripts/system/ScriptLoader.h b/src/scripts/system/ScriptLoader.h index 920b0a7d2..c74b64315 100644 --- a/src/scripts/system/ScriptLoader.h +++ b/src/scripts/system/ScriptLoader.h @@ -1,6 +1,20 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information +/* + * Copyright (C) 2006-2009 ScriptDev2 + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef SC_SCRIPTLOADER_H diff --git a/src/scripts/system/system.cpp b/src/scripts/system/system.cpp index f2eb5e7c9..4ddda7fab 100644 --- a/src/scripts/system/system.cpp +++ b/src/scripts/system/system.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2008-2009 Trinity - * - * Thanks to the original authors: MaNGOS + * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2009 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Auth/AuthCrypt.cpp b/src/shared/Auth/AuthCrypt.cpp index 8fca93b7f..d458c5bcd 100755 --- a/src/shared/Auth/AuthCrypt.cpp +++ b/src/shared/Auth/AuthCrypt.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Auth/AuthCrypt.h b/src/shared/Auth/AuthCrypt.h index 020f8bcdc..df537c0a5 100755 --- a/src/shared/Auth/AuthCrypt.h +++ b/src/shared/Auth/AuthCrypt.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUTHCRYPT_H -#define _AUTHCRYPT_H +#ifndef HELLGROUND_AUTHCRYPT_H +#define HELLGROUND_AUTHCRYPT_H #include #include diff --git a/src/shared/Auth/BigNumber.cpp b/src/shared/Auth/BigNumber.cpp index 11bfad5dd..bbd55f46f 100755 --- a/src/shared/Auth/BigNumber.cpp +++ b/src/shared/Auth/BigNumber.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Auth/BigNumber.h b/src/shared/Auth/BigNumber.h index d0c78488a..30a8be2ec 100755 --- a/src/shared/Auth/BigNumber.h +++ b/src/shared/Auth/BigNumber.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUTH_BIGNUMBER_H -#define _AUTH_BIGNUMBER_H +#ifndef HELLGROUND_AUTH_BIGNUMBER_H +#define HELLGROUND_AUTH_BIGNUMBER_H #include "Common.h" #include "ByteBuffer.h" diff --git a/src/shared/Auth/CMakeLists.txt b/src/shared/Auth/CMakeLists.txt index da55dd989..e911e7b7a 100755 --- a/src/shared/Auth/CMakeLists.txt +++ b/src/shared/Auth/CMakeLists.txt @@ -1,20 +1,20 @@ - -########### next target ############### - -SET(trinityauth_STAT_SRCS - AuthCrypt.cpp - AuthCrypt.h - BigNumber.cpp - BigNumber.h - Hmac.cpp - Hmac.h - SARC4.cpp - SARC4.h - Sha1.cpp - Sha1.h - md5.c - md5.h - WardenKeyGeneration.h -) - -add_library(trinityauth STATIC ${trinityauth_STAT_SRCS}) + +########### next target ############### + +SET(hellgroundauth_STAT_SRCS + AuthCrypt.cpp + AuthCrypt.h + BigNumber.cpp + BigNumber.h + Hmac.cpp + Hmac.h + SARC4.cpp + SARC4.h + Sha1.cpp + Sha1.h + md5.c + md5.h + WardenKeyGeneration.h +) + +add_library(hellgroundauth STATIC ${hellgroundauth_STAT_SRCS}) diff --git a/src/shared/Auth/Hmac.cpp b/src/shared/Auth/Hmac.cpp index bd1d1ae6e..d4e3e46f2 100755 --- a/src/shared/Auth/Hmac.cpp +++ b/src/shared/Auth/Hmac.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,6 +56,12 @@ void HmacHash::UpdateData(const std::string &str) UpdateData((uint8 const*)str.c_str(), str.length()); } +void HmacHash::UpdateData(const uint8* data, size_t len) +{ + HMAC_Update(&m_ctx, data, len); +} + + void HmacHash::Initialize() { HMAC_Init_ex(&m_ctx, &m_key, SEED_KEY_SIZE, EVP_sha1(), NULL); diff --git a/src/shared/Auth/Hmac.h b/src/shared/Auth/Hmac.h index 63247b0c6..a64aa0b49 100755 --- a/src/shared/Auth/Hmac.h +++ b/src/shared/Auth/Hmac.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUTH_HMAC_H -#define _AUTH_HMAC_H +#ifndef HELLGROUND_AUTH_HMAC_H +#define HELLGROUND_AUTH_HMAC_H #include "Common.h" #include @@ -37,6 +37,7 @@ class HmacHash ~HmacHash(); void UpdateBigNumber(BigNumber *bn); void UpdateData(const uint8 *data, int length); + void UpdateData(const uint8* data, size_t len); void UpdateData(const std::string &str); void Initialize(); void Finalize(); diff --git a/src/shared/Auth/SARC4.cpp b/src/shared/Auth/SARC4.cpp index 59ab31d2d..8fd586d81 100644 --- a/src/shared/Auth/SARC4.cpp +++ b/src/shared/Auth/SARC4.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Auth/SARC4.h" diff --git a/src/shared/Auth/SARC4.h b/src/shared/Auth/SARC4.h index 95ea9c1d0..689fa462e 100644 --- a/src/shared/Auth/SARC4.h +++ b/src/shared/Auth/SARC4.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUTH_SARC4_H -#define _AUTH_SARC4_H +#ifndef HELLGROUND_AUTH_SARC4_H +#define HELLGROUND_AUTH_SARC4_H #include "Common.h" #include diff --git a/src/shared/Auth/Sha1.cpp b/src/shared/Auth/Sha1.cpp index 90334543b..edd85db4d 100755 --- a/src/shared/Auth/Sha1.cpp +++ b/src/shared/Auth/Sha1.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Auth/Sha1.h b/src/shared/Auth/Sha1.h index 6794d3bd1..8c6442eaf 100755 --- a/src/shared/Auth/Sha1.h +++ b/src/shared/Auth/Sha1.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _AUTH_SHA1_H -#define _AUTH_SHA1_H +#ifndef HELLGROUND_AUTH_SHA1_H +#define HELLGROUND_AUTH_SHA1_H #include "Common.h" #include diff --git a/src/shared/Auth/WardenKeyGeneration.h b/src/shared/Auth/WardenKeyGeneration.h index 37c3fff13..1aa4dc98e 100644 --- a/src/shared/Auth/WardenKeyGeneration.h +++ b/src/shared/Auth/WardenKeyGeneration.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,18 +9,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Sha1.h" -#ifndef _WARDEN_KEY_GENERATION_H -#define _WARDEN_KEY_GENERATION_H +#ifndef HELLGROUND_WARDEN_KEY_GENERATION_H +#define HELLGROUND_WARDEN_KEY_GENERATION_H class SHA1Randx { public: diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 0bfa7cb00..fe7ee72a7 100755 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _BYTEBUFFER_H -#define _BYTEBUFFER_H +#ifndef HELLGROUND_BYTEBUFFER_H +#define HELLGROUND_BYTEBUFFER_H #include "Common.h" #include "Log.h" diff --git a/src/shared/Common.cpp b/src/shared/Common.cpp index a31c88fdb..2803bcfbb 100755 --- a/src/shared/Common.cpp +++ b/src/shared/Common.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Common.h b/src/shared/Common.h index ecec9f10c..395162b2a 100755 --- a/src/shared/Common.h +++ b/src/shared/Common.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_COMMON_H -#define TRINITYCORE_COMMON_H +#ifndef HELLGROUND_COMMON_H +#define HELLGROUND_COMMON_H // config.h needs to be included 1st // TODO this thingy looks like hack ,but its not, need to @@ -27,7 +27,7 @@ #ifdef HAVE_CONFIG_H // Remove Some things that we will define // This is in case including another config.h -// before trinity config.h +// before config.h #ifdef PACKAGE #undef PACKAGE #endif //PACKAGE @@ -172,25 +172,27 @@ enum TimeConstants enum AccountPermissionMasks { - PERM_PLAYER = 0x000001, - PERM_DEVELOPER = 0x000002, + PERM_PLAYER = 0x000001, // 1 + PERM_DEVELOPER = 0x000002, // 2 + PERM_HEAD_DEVELOPER = 0x000100, // 256 - PERM_GM_TRIAL = 0x000100, - PERM_GM_HELPER = 0x000200, + PERM_GM_TRIAL = 0x000200, // 512 + PERM_GM_HELPER = 0x000400, // 1024 - PERM_GM_HEAD = 0x000800, + PERM_GM_HEAD = 0x000800, // 2048 - PERM_ADM_NORM = 0x001000, - PERM_ADM_HEAD = 0x002000, + PERM_ADM_NORM = 0x001000, // 4096 + PERM_ADM_HEAD = 0x002000, // 8192 - PERM_CONSOLE = 0x800000, + PERM_CONSOLE = 0x800000, // 8388608 - PERM_GMT = PERM_GM_TRIAL | PERM_GM_HELPER | PERM_GM_HEAD, - PERM_ADM = PERM_GMT | PERM_ADM_NORM | PERM_ADM_HEAD, + PERM_GMT = PERM_GM_TRIAL | PERM_GM_HELPER | PERM_GM_HEAD | PERM_ADM_NORM | PERM_ADM_HEAD, + PERM_ADM = PERM_ADM_NORM | PERM_ADM_HEAD, PERM_HIGH_GMT = PERM_ADM | PERM_GM_HEAD, - PERM_GMT_DEV = PERM_GMT | PERM_DEVELOPER, - PERM_HIGH_DEV = PERM_HIGH_GMT | PERM_DEVELOPER, - PERM_ALL = PERM_PLAYER | PERM_GMT_DEV | PERM_ADM + PERM_GMT_HDEV = PERM_GMT | PERM_HEAD_DEVELOPER, + PERM_GMT_DEV = PERM_GMT | PERM_DEVELOPER | PERM_HEAD_DEVELOPER, + PERM_HIGH_DEV = PERM_HIGH_GMT | PERM_DEVELOPER | PERM_HEAD_DEVELOPER, + PERM_ALL = PERM_PLAYER | PERM_GMT_DEV }; enum AccountStates @@ -203,14 +205,16 @@ enum AccountStates enum PunishmentTypes { PUNISHMENT_MUTE = 1, - PUNISHMENT_BAN = 2 + PUNISHMENT_BAN = 2, + PUNISHMENT_TROLLMUTE= 3 }; enum ClientOSVersion { - CLIENT_OS_UNKNOWN = 0, - CLIENT_OS_WIN = 1, - CLIENT_OS_OSX = 2 + CLIENT_OS_UNKNOWN = 0, // unknown system client + CLIENT_OS_WIN = 1, // Windows client + CLIENT_OS_OSX = 2, // OSX client + CLIENT_OS_CHAT = 3, // WoW Chat client }; // Used in mangosd/realmd diff --git a/src/shared/Config/CMakeLists.txt b/src/shared/Config/CMakeLists.txt index eda452735..e32277d03 100755 --- a/src/shared/Config/CMakeLists.txt +++ b/src/shared/Config/CMakeLists.txt @@ -1,10 +1,10 @@ - -########### next target ############### - -SET(trinityconfig_STAT_SRCS - Config.cpp - Config.h -) - -add_library(trinityconfig STATIC ${trinityconfig_STAT_SRCS}) - + +########### next target ############### + +SET(hellgroundconfig_STAT_SRCS + Config.cpp + Config.h +) + +add_library(hellgroundconfig STATIC ${hellgroundconfig_STAT_SRCS}) + diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp index a86f4b8ba..c6fabd2d3 100755 --- a/src/shared/Config/Config.cpp +++ b/src/shared/Config/Config.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Config.h" diff --git a/src/shared/Config/Config.h b/src/shared/Config/Config.h index f9d017ec7..69311c9b0 100755 --- a/src/shared/Config/Config.h +++ b/src/shared/Config/Config.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef HELLGROUND_CONFIG_H +#define HELLGROUND_CONFIG_H #include "ace/Singleton.h" #include "ace/Null_Mutex.h" diff --git a/src/shared/Database/CMakeLists.txt b/src/shared/Database/CMakeLists.txt index d12c26fb2..d72f80024 100755 --- a/src/shared/Database/CMakeLists.txt +++ b/src/shared/Database/CMakeLists.txt @@ -1,28 +1,28 @@ -SET(trinitydatabase_STAT_SRCS - Database.cpp - Database.h - DatabaseEnv.h - DatabaseImpl.h - Field.cpp - Field.h - QueryResult.cpp - QueryResult.h - QueryResult.cpp - QueryResultMysql.cpp - QueryResultMysql.h - DatabaseMysql.h - DatabaseMysql.cpp - SQLStorage.cpp - SQLStorage.h - SQLStorageImpl.h - SqlPreparedStatement.cpp - SqlPreparedStatement.h - SqlDelayThread.cpp - SqlDelayThread.h - SqlOperations.cpp - SqlOperations.h - dbcfile.cpp - dbcfile.h -) - -add_library(trinitydatabase STATIC ${trinitydatabase_STAT_SRCS}) +SET(hellgrounddatabase_STAT_SRCS + Database.cpp + Database.h + DatabaseEnv.h + DatabaseImpl.h + Field.cpp + Field.h + QueryResult.cpp + QueryResult.h + QueryResult.cpp + QueryResultMysql.cpp + QueryResultMysql.h + DatabaseMysql.h + DatabaseMysql.cpp + SQLStorage.cpp + SQLStorage.h + SQLStorageImpl.h + SqlPreparedStatement.cpp + SqlPreparedStatement.h + SqlDelayThread.cpp + SqlDelayThread.h + SqlOperations.cpp + SqlOperations.h + dbcfile.cpp + dbcfile.h +) + +add_library(hellgrounddatabase STATIC ${hellgrounddatabase_STAT_SRCS}) diff --git a/src/shared/Database/DBCFileLoader.cpp b/src/shared/Database/DBCFileLoader.cpp index 69f73c637..179c54298 100644 --- a/src/shared/Database/DBCFileLoader.cpp +++ b/src/shared/Database/DBCFileLoader.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include diff --git a/src/shared/Database/DBCFileLoader.h b/src/shared/Database/DBCFileLoader.h index 133df11ea..f2c3de414 100644 --- a/src/shared/Database/DBCFileLoader.h +++ b/src/shared/Database/DBCFileLoader.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,16 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBC_FILE_LOADER_H -#define DBC_FILE_LOADER_H +#ifndef HELLGROUND_DBC_FILE_LOADER_H +#define HELLGROUND_DBC_FILE_LOADER_H #include "Platform/Define.h" #include "Utilities/ByteConverter.h" diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h index 81f93656a..262eb4837 100644 --- a/src/shared/Database/DBCStore.h +++ b/src/shared/Database/DBCStore.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCSTORE_H -#define DBCSTORE_H +#ifndef HELLGROUND_DBCSTORE_H +#define HELLGROUND_DBCSTORE_H #include "DBCFileLoader.h" diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index 6839fef93..655131631 100755 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DatabaseEnv.h" @@ -87,6 +88,7 @@ bool SqlConnection::ExecuteStmt(int nIndex, const SqlStmtParameters& id ) //get prepared statement object SqlPreparedStatement * pStmt = GetStmt(nIndex); + ASSERT(pStmt); //it will be better for server to crash than to keep working with database problems //bind parameters pStmt->bind(id); //execute statement @@ -248,13 +250,15 @@ void Database::Ping() { SqlConnection::Lock guard(m_pAsyncConn); - guard->Query(sql); + if (guard->Query(sql) == QueryResultAutoPtr(nullptr)) + abort(); } for (int i = 0; i < m_nQueryConnPoolSize; ++i) { SqlConnection::Lock guard(m_pQueryConnections[i]); - guard->Query(sql); + if (guard->Query(sql) == QueryResultAutoPtr(nullptr)) + abort(); } } diff --git a/src/shared/Database/Database.h b/src/shared/Database/Database.h index 25bd2b71b..6f1840d96 100755 --- a/src/shared/Database/Database.h +++ b/src/shared/Database/Database.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DATABASE_H -#define DATABASE_H +#ifndef HELLGROUND_DATABASE_H +#define HELLGROUND_DATABASE_H #include "Threading.h" #include "Utilities/UnorderedMap.h" diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h index 04d238cb5..de439aa9d 100755 --- a/src/shared/Database/DatabaseEnv.h +++ b/src/shared/Database/DatabaseEnv.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DATABASEENV_H -#define DATABASEENV_H +#ifndef HELLGROUND_DATABASEENV_H +#define HELLGROUND_DATABASEENV_H #include "Common.h" #include "Log.h" @@ -28,6 +29,7 @@ #include "Database/Database.h" #include "Database/DatabaseMysql.h" typedef DatabaseMysql DatabaseType; + #define _LIKE_ "LIKE" #define _TABLE_SIM_ "`" #define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )" diff --git a/src/shared/Database/DatabaseImpl.h b/src/shared/Database/DatabaseImpl.h index 9661327bf..84fd91294 100755 --- a/src/shared/Database/DatabaseImpl.h +++ b/src/shared/Database/DatabaseImpl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,14 +9,17 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef HELLGROUND_DATABASEIMPL_H +#define HELLGROUND_DATABASEIMPL_H + #include "Database/Database.h" #include "Database/SqlOperations.h" @@ -184,3 +188,5 @@ Database::DelayQueryHolder(Class *object, void (Class::*method)(QueryResultAutoP #undef ASYNC_QUERY_BODY #undef ASYNC_PQUERY_BODY #undef ASYNC_DELAYHOLDER_BODY + +#endif diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 6b8ef7518..08e09c0ed 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DO_POSTGRESQL @@ -164,16 +165,6 @@ bool MySQLConnection::Initialize(const char *infoString) Execute("SET NAMES `utf8`"); Execute("SET CHARACTER SET `utf8`"); - #if MYSQL_VERSION_ID >= 50003 - my_bool my_true = (my_bool)1; - if (mysql_options(mMysql, MYSQL_OPT_RECONNECT, &my_true)) - sLog.outDetail("Failed to turn on MYSQL_OPT_RECONNECT."); - else - sLog.outDetail("Successfully turned on MYSQL_OPT_RECONNECT."); - #else - #warning "Your mySQL client lib version does not support reconnecting after a timeout.\nIf this causes you any trouble we advice you to upgrade your mySQL client libs to at least mySQL 5.0.13 to resolve this problem." - #endif - return true; } else diff --git a/src/shared/Database/DatabaseMysql.h b/src/shared/Database/DatabaseMysql.h index 7d588f737..f0e0d1df5 100644 --- a/src/shared/Database/DatabaseMysql.h +++ b/src/shared/Database/DatabaseMysql.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,18 +9,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DO_POSTGRESQL -#ifndef _DATABASEMYSQL_H -#define _DATABASEMYSQL_H +#ifndef HELLGROUND_DATABASEMYSQL_H +#define HELLGROUND_DATABASEMYSQL_H //#include "Common.h" #include "Database.h" diff --git a/src/shared/Database/Field.cpp b/src/shared/Database/Field.cpp index 7f3f8b274..93b03be22 100755 --- a/src/shared/Database/Field.cpp +++ b/src/shared/Database/Field.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //#include "DatabaseEnv.h" diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index 3480cf3c3..83fbba0ea 100755 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef FIELD_H -#define FIELD_H +#ifndef HELLGROUND_FIELD_H +#define HELLGROUND_FIELD_H #include "Common.h" diff --git a/src/shared/Database/QueryResult.cpp b/src/shared/Database/QueryResult.cpp index 30f386a19..8cccecdf5 100644 --- a/src/shared/Database/QueryResult.cpp +++ b/src/shared/Database/QueryResult.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2010 Trinity + * Copyright (C) 2008-2010 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Database/QueryResult.h b/src/shared/Database/QueryResult.h index fa2da217c..5bb575e79 100755 --- a/src/shared/Database/QueryResult.h +++ b/src/shared/Database/QueryResult.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef QUERYRESULT_H -#define QUERYRESULT_H +#ifndef HELLGROUND_QUERYRESULT_H +#define HELLGROUND_QUERYRESULT_H #undef ACE_HAS_STANDARD_CPP_LIBRARY #include diff --git a/src/shared/Database/QueryResultMysql.cpp b/src/shared/Database/QueryResultMysql.cpp index f4cc31d2e..2b9e6cd76 100644 --- a/src/shared/Database/QueryResultMysql.cpp +++ b/src/shared/Database/QueryResultMysql.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DatabaseEnv.h" diff --git a/src/shared/Database/QueryResultMysql.h b/src/shared/Database/QueryResultMysql.h index 367f0591d..22865c5b4 100644 --- a/src/shared/Database/QueryResultMysql.h +++ b/src/shared/Database/QueryResultMysql.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,15 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef QUERYRESULTMYSQL_H -#define QUERYRESULTMYSQL_H + +#ifndef HELLGROUND_QUERYRESULTMYSQL_H +#define HELLGROUND_QUERYRESULTMYSQL_H #include "Common.h" diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index a1647ecb0..76fcad173 100755 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SQLStorage.h" @@ -21,8 +22,8 @@ extern DatabaseType GameDataDatabase; -const char CreatureInfosrcfmt[]="iiiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiisiilliiis"; -const char CreatureInfodstfmt[]="iiiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiisiilliiii"; +const char CreatureInfosrcfmt[]="iiiiiiisssiiiiiiifiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiisiilliiis"; +const char CreatureInfodstfmt[]="iiiiiiisssiiiiiiifiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiisiilliiii"; const char CreatureDataAddonInfofmt[]="iiiiiiiis"; const char CreatureModelfmt[]="iffbi"; const char CreatureInfoAddonInfofmt[]="iiiiiiiis"; diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 34110287d..178f5b06e 100755 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SQLSTORAGE_H -#define SQLSTORAGE_H +#ifndef HELLGROUND_SQLSTORAGE_H +#define HELLGROUND_SQLSTORAGE_H #include "Common.h" #include "Database/DatabaseEnv.h" diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h index cee5a84c8..d355d42b8 100755 --- a/src/shared/Database/SQLStorageImpl.h +++ b/src/shared/Database/SQLStorageImpl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SQLSTORAGE_IMPL_H -#define SQLSTORAGE_IMPL_H +#ifndef HELLGROUND_SQLSTORAGE_IMPL_H +#define HELLGROUND_SQLSTORAGE_IMPL_H #include "ProgressBar.h" #include "Log.h" diff --git a/src/shared/Database/SqlDelayThread.cpp b/src/shared/Database/SqlDelayThread.cpp index 01c2b3e43..6f97e6d9d 100755 --- a/src/shared/Database/SqlDelayThread.cpp +++ b/src/shared/Database/SqlDelayThread.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Database/SqlDelayThread.h" diff --git a/src/shared/Database/SqlDelayThread.h b/src/shared/Database/SqlDelayThread.h index f6fcb5a67..77591b740 100755 --- a/src/shared/Database/SqlDelayThread.h +++ b/src/shared/Database/SqlDelayThread.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __SQLDELAYTHREAD_H -#define __SQLDELAYTHREAD_H +#ifndef HELLGROUND_SQLDELAYTHREAD_H +#define HELLGROUND_SQLDELAYTHREAD_H #include "ace/Thread_Mutex.h" #include "LockedQueue.h" diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index 3158c0df8..75b54e253 100755 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SqlOperations.h" diff --git a/src/shared/Database/SqlOperations.h b/src/shared/Database/SqlOperations.h index 517d4a416..cf092e05b 100755 --- a/src/shared/Database/SqlOperations.h +++ b/src/shared/Database/SqlOperations.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __SQLOPERATIONS_H -#define __SQLOPERATIONS_H +#ifndef HELLGROUND_SQLOPERATIONS_H +#define HELLGROUND_SQLOPERATIONS_H #include "Common.h" diff --git a/src/shared/Database/SqlPreparedStatement.cpp b/src/shared/Database/SqlPreparedStatement.cpp index c34e3d7c8..d720c4f07 100644 --- a/src/shared/Database/SqlPreparedStatement.cpp +++ b/src/shared/Database/SqlPreparedStatement.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DatabaseEnv.h" diff --git a/src/shared/Database/SqlPreparedStatement.h b/src/shared/Database/SqlPreparedStatement.h index 1e13bfed6..4410f0c3a 100644 --- a/src/shared/Database/SqlPreparedStatement.h +++ b/src/shared/Database/SqlPreparedStatement.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2011 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SQLPREPAREDSTATEMENTS_H -#define SQLPREPAREDSTATEMENTS_H +#ifndef HELLGROUND_SQLPREPAREDSTATEMENTS_H +#define HELLGROUND_SQLPREPAREDSTATEMENTS_H #include "Common.h" #include diff --git a/src/shared/DelayExecutor.cpp b/src/shared/DelayExecutor.cpp index df6f8ed7d..d6f4c1f7b 100755 --- a/src/shared/DelayExecutor.cpp +++ b/src/shared/DelayExecutor.cpp @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include #include #include diff --git a/src/shared/DelayExecutor.h b/src/shared/DelayExecutor.h index e1b655a30..f308be1dd 100755 --- a/src/shared/DelayExecutor.h +++ b/src/shared/DelayExecutor.h @@ -1,5 +1,23 @@ -#ifndef _M_DELAY_EXECUTOR_H -#define _M_DELAY_EXECUTOR_H +/* + * Copyright (C) 2008-2014 Hellground + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef HELLGROUND_DELAY_EXECUTOR_H +#define HELLGROUND_DELAY_EXECUTOR_H #include #include diff --git a/src/shared/LockedVector.h b/src/shared/LockedVector.h index 41df32f13..5ec7c91aa 100644 --- a/src/shared/LockedVector.h +++ b/src/shared/LockedVector.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2012 /dev/rsa for MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,19 +9,19 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* based on LockedQueue class from MaNGOS */ /* written for use instead not locked std::list && std::vector */ -#ifndef LOCKEDVECTOR_H -#define LOCKEDVECTOR_H +#ifndef HELLGROUND_LOCKEDVECTOR_H +#define HELLGROUND_LOCKEDVECTOR_H #include #include diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp old mode 100755 new mode 100644 index af084345e..836a52709 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,16 +26,6 @@ #include "Config/Config.h" #include "Util.h" -enum LogType -{ - LogNormal = 0, - LogDetails, - LogDebug, - LogError -}; - -const int LogType_count = int(LogError) +1; - const char* logToStr[LOG_MAX_FILES][3] = { // file name conf mode timestamp conf name { "GMLogFile", "a", "GmLogTimestamp" }, // LOG_GM @@ -54,10 +44,13 @@ const char* logToStr[LOG_MAX_FILES][3] = { "DiffLogFile", "a", NULL }, // LOG_DIFF { "SessionDiffLogFile", "a", NULL }, // LOG_SESSION_DIFF { "CrashLogFile", "a", NULL }, // LOG_CRASH - { "DBDiffFile", "a", NULL } // LOG_DB_DIFF + { "DBDiffFile", "a", NULL }, // LOG_DB_DIFF + { "ExpLogFile", "a", NULL }, // LOG_EXP + { "TradeLogFile", "a", NULL }, // LOG_TRADE + { "RaceChangeLogFile", "a", NULL } // LOG_RACE_CHANGE }; -Log::Log() : m_colored(false), m_includeTime(false), m_gmlog_per_account(false) +Log::Log() : m_includeTime(false), m_gmlog_per_account(false) { for (uint8 i = LOG_DEFAULT; i < LOG_MAX_FILES; i++) logFile[i] = NULL; @@ -65,131 +58,6 @@ Log::Log() : m_colored(false), m_includeTime(false), m_gmlog_per_account(false) Initialize(); } -void Log::InitColors(const std::string& str) -{ - if(str.empty()) - { - m_colored = false; - return; - } - - int color[4]; - - std::istringstream ss(str); - - for(int i = 0; i < LogType_count; ++i) - { - ss >> color[i]; - - if(!ss) - return; - - if(color[i] < 0 || color[i] >= Color_count) - return; - } - - for(int i = 0; i < LogType_count; ++i) - m_colors[i] = Color(color[i]); - - m_colored = true; -} - -void Log::SetColor(bool stdout_stream, Color color) -{ - #if PLATFORM == PLATFORM_WINDOWS - - static WORD WinColorFG[Color_count] = - { - 0, // BLACK - FOREGROUND_RED, // RED - FOREGROUND_GREEN, // GREEN - FOREGROUND_RED | FOREGROUND_GREEN, // BROWN - FOREGROUND_BLUE, // BLUE - FOREGROUND_RED | FOREGROUND_BLUE,// MAGENTA - FOREGROUND_GREEN | FOREGROUND_BLUE, // CYAN - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,// WHITE - // YELLOW - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY, - // RED_BOLD - FOREGROUND_RED | FOREGROUND_INTENSITY, - // GREEN_BOLD - FOREGROUND_GREEN | FOREGROUND_INTENSITY, - FOREGROUND_BLUE | FOREGROUND_INTENSITY, // BLUE_BOLD - // MAGENTA_BOLD - FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY, - // CYAN_BOLD - FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, - // WHITE_BOLD - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY - }; - - HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE ); - SetConsoleTextAttribute(hConsole, WinColorFG[color]); - #else - - enum ANSITextAttr - { - TA_NORMAL=0, - TA_BOLD=1, - TA_BLINK=5, - TA_REVERSE=7 - }; - - enum ANSIFgTextAttr - { - FG_BLACK=30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, - FG_MAGENTA, FG_CYAN, FG_WHITE, FG_YELLOW - }; - - enum ANSIBgTextAttr - { - BG_BLACK=40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, - BG_MAGENTA, BG_CYAN, BG_WHITE - }; - - static uint8 UnixColorFG[Color_count] = - { - FG_BLACK, // BLACK - FG_RED, // RED - FG_GREEN, // GREEN - FG_BROWN, // BROWN - FG_BLUE, // BLUE - FG_MAGENTA, // MAGENTA - FG_CYAN, // CYAN - FG_WHITE, // WHITE - FG_YELLOW, // YELLOW - FG_RED, // LRED - FG_GREEN, // LGREEN - FG_BLUE, // LBLUE - FG_MAGENTA, // LMAGENTA - FG_CYAN, // LCYAN - FG_WHITE // LWHITE - }; - - fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color 0) - { - if (m_colored) - SetColor(true,m_colors[LogDetails]); - - if (m_includeTime) - outTime(); - - if (m_colored) - ResetColor(true); - } - if (logFile[LOG_DEFAULT] && m_logFileLevel > 0) { va_list ap; @@ -471,19 +304,6 @@ void Log::outDetail(const char * str, ...) if (!str) return; - if (m_logLevel > 1) - { - - if (m_colored) - SetColor(true,m_colors[LogDetails]); - - if (m_includeTime) - outTime(); - - if (m_colored) - ResetColor(true); - } - if (logFile[LOG_DEFAULT] && m_logFileLevel > 1) { va_list ap; @@ -501,15 +321,6 @@ void Log::outDebugInLine(const char * str, ...) if (!str) return; - if (m_logLevel > 2) - { - if (m_colored) - SetColor(true,m_colors[LogDebug]); - - if (m_colored) - ResetColor(true); - } - if(logFile[LOG_DEFAULT] && m_logFileLevel > 2) { va_list ap; @@ -524,18 +335,6 @@ void Log::outDebug(const char * str, ...) if(!str) return; - if (m_logLevel > 2) - { - if (m_colored) - SetColor(true,m_colors[LogDebug]); - - if (m_includeTime) - outTime(); - - if (m_colored) - ResetColor(true); - } - if (logFile[LOG_DEFAULT] && m_logFileLevel > 2) { outTimestamp(logFile[LOG_DEFAULT]); @@ -555,18 +354,6 @@ void Log::outCommand(uint32 account, const char * str, ...) if (!str) return; - if (m_logLevel > 1) - { - if (m_colored) - SetColor(true,m_colors[LogDetails]); - - if (m_includeTime) - outTime(); - - if (m_colored) - ResetColor(true); - } - if (logFile[LOG_DEFAULT] && m_logFileLevel > 1) { va_list ap; diff --git a/src/shared/Log.h b/src/shared/Log.h old mode 100755 new mode 100644 index 2c951ad58..5c3e75c37 --- a/src/shared/Log.h +++ b/src/shared/Log.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,16 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_LOG_H -#define TRINITYCORE_LOG_H +#ifndef HELLGROUND_LOG_H +#define HELLGROUND_LOG_H #include "ace/Singleton.h" #include "ace/Thread_Mutex.h" - #include "Common.h" -class Config; - // bitmask enum LogFilters { @@ -36,25 +33,6 @@ enum LogFilters LOG_FILTER_VISIBILITY_CHANGES = 4 }; -enum Color -{ - BLACK, - RED, - GREEN, - BROWN, - BLUE, - MAGENTA, - CYAN, - GREY, - YELLOW, - LRED, - LGREEN, - LBLUE, - LMAGENTA, - LCYAN, - WHITE -}; - enum LogNames { LOG_GM = 0, @@ -74,12 +52,13 @@ enum LogNames LOG_SESSION_DIFF = 14, LOG_CRASH = 15, LOG_DB_DIFF = 16, + LOG_EXP = 17, + LOG_TRADE = 18, + LOG_RACE_CHANGE = 19, LOG_MAX_FILES }; -const int Color_count = int(WHITE)+1; - class Log { friend class ACE_Singleton; @@ -98,7 +77,6 @@ class Log public: void Initialize(); - void InitColors(const std::string& init_str); void outTitle(const char * str); void outCommand(uint32 account, const char * str, ...) ATTR_PRINTF(3,4); // any log level @@ -117,18 +95,16 @@ class Log void outWhisp(uint32 account, const char * str, ...) ATTR_PRINTF(3, 4); void outPacket(uint32 glow, const char * str, ...) ATTR_PRINTF(3, 4); - void SetLogLevel(char * Level); void SetLogFileLevel(char * Level); - void SetColor(bool stdout_stream, Color color); - void ResetColor(bool stdout_stream); void outTime(); static bool outTimestamp(FILE* file); static std::string GetTimestampStr(); uint32 getLogFilter() const { return m_logFilter; } - bool IsOutDebug() const { return m_logLevel > 2 || (m_logFileLevel > 2 && logFile[LOG_DEFAULT]); } - bool IsOutCharDump() const { return m_charLog_Dump; } + bool IsOutDebug() const { return (m_logFileLevel > 2 && logFile[LOG_DEFAULT]); } bool IsIncludeTime() const { return m_includeTime; } + bool IsLogEnabled(LogNames log) const { return logFile[log] != NULL; } + private: FILE* openLogFile(LogNames log); FILE* openGmlogPerAccount(uint32 account); @@ -139,25 +115,18 @@ class Log FILE* openWhisplogPerAccount(uint32 account); // log/console control - uint32 m_logLevel; uint32 m_logFileLevel; - bool m_colored; bool m_includeTime; - Color m_colors[4]; uint32 m_logFilter; // cache values for after initilization use (like gm log per account case) std::string m_logsDir; std::string m_logsTimestamp; - // char log control - bool m_charLog_Dump; - // gm log control bool m_gmlog_per_account; std::string m_gmlog_filename_format; - std::string m_whisplog_filename_format; }; diff --git a/src/shared/ProgressBar.cpp b/src/shared/ProgressBar.cpp index 1496886ca..1f44bfe41 100755 --- a/src/shared/ProgressBar.cpp +++ b/src/shared/ProgressBar.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ProgressBar.h" diff --git a/src/shared/ProgressBar.h b/src/shared/ProgressBar.h index 67da8e92a..3ca83bf8f 100755 --- a/src/shared/ProgressBar.h +++ b/src/shared/ProgressBar.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -10,15 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TRINITYCORE_PROGRESSBAR_H -#define TRINITYCORE_PROGRESSBAR_H + +#ifndef HELLGROUND_PROGRESSBAR_H +#define HELLGROUND_PROGRESSBAR_H #include #include "Platform/Define.h" diff --git a/src/shared/ServiceWin32.cpp b/src/shared/ServiceWin32.cpp index 4a07a99ad..570785c4e 100755 --- a/src/shared/ServiceWin32.cpp +++ b/src/shared/ServiceWin32.cpp @@ -1,12 +1,12 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * Copyright (C) 2008 Trinity - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef WIN32 diff --git a/src/shared/ServiceWin32.h b/src/shared/ServiceWin32.h index d046acdce..bf436db28 100755 --- a/src/shared/ServiceWin32.h +++ b/src/shared/ServiceWin32.h @@ -1,12 +1,12 @@ /* - * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * - * Copyright (C) 2008 Trinity - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef WIN32 diff --git a/src/shared/SystemConfig.h b/src/shared/SystemConfig.h index 34fe36a46..bf3e9ffe0 100755 --- a/src/shared/SystemConfig.h +++ b/src/shared/SystemConfig.h @@ -1,8 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity - * + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +27,7 @@ #include "revision.h" -#define _PACKAGENAME "TrinityCore " +#define _PACKAGENAME "HellgroundCore " #define _CODENAME "YUME" #if HELLGROUND_ENDIAN == HELLGROUND_BIGENDIAN @@ -49,19 +48,19 @@ # define SYSCONFDIR "" #endif -#define _HELLGROUND_CORE_CONFIG SYSCONFDIR "trinitycore.conf" -#define _HELLGROUND_REALM_CONFIG SYSCONFDIR "trinityrealm.conf" +#define _HELLGROUND_CORE_CONFIG SYSCONFDIR "hellgroundcore.conf" +#define _HELLGROUND_REALM_CONFIG SYSCONFDIR "hellgroundrealm.conf" // Format is YYYYMMDDRR where RR is the change in the conf file // for that day. #ifndef _HELLGROUND_CORE_CONFVER -# define _HELLGROUND_CORE_CONFVER 2012070901 +# define _HELLGROUND_CORE_CONFVER 2014022101 #endif //_HELLGROUND_CORE_CONFVER // Format is YYYYMMDDRR where RR is the change in the conf file // for that day. #ifndef _REALMDCONFVERSION -# define _REALMDCONFVERSION 2011092901 +# define _REALMDCONFVERSION 2014021201 #endif #endif diff --git a/src/shared/Threading.cpp b/src/shared/Threading.cpp index 4356e4d6c..b276b7893 100755 --- a/src/shared/Threading.cpp +++ b/src/shared/Threading.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Threading.h" diff --git a/src/shared/Threading.h b/src/shared/Threading.h index 858dd5f3a..ad35b0306 100755 --- a/src/shared/Threading.h +++ b/src/shared/Threading.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,16 +9,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef THREADING_H -#define THREADING_H +#ifndef HELLGROUND_THREADING_H +#define HELLGROUND_THREADING_H #include #include diff --git a/src/shared/Timer.h b/src/shared/Timer.h index 9f0170dca..fe671e9c6 100755 --- a/src/shared/Timer.h +++ b/src/shared/Timer.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 1425e2f67..e8394e6fd 100755 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -220,7 +220,7 @@ std::string TimeToTimestampStr(time_t t) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) char buf[20]; - snprintf(buf,20,"%04d-%02d-%02d_%02d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + snprintf(buf,20,"%04d-%02d-%02d %02d:%02d:%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); return std::string(buf); } diff --git a/src/shared/Util.h b/src/shared/Util.h index 560ad2c0e..451995eda 100755 --- a/src/shared/Util.h +++ b/src/shared/Util.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS - * - * Copyright (C) 2008 Trinity + * Copyright (C) 2005-2008 MaNGOS + * Copyright (C) 2008 TrinityCore + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _UTIL_H -#define _UTIL_H +#ifndef HELLGROUND_UTIL_H +#define HELLGROUND_UTIL_H #include "Common.h" diff --git a/src/shared/WheatyExceptionReport.h b/src/shared/WheatyExceptionReport.h index 228d260e5..36aa77535 100755 --- a/src/shared/WheatyExceptionReport.h +++ b/src/shared/WheatyExceptionReport.h @@ -1,3 +1,8 @@ +//========================================== +// Matt Pietrek +// MSDN Magazine, 2002 +// FILE: WheatyExceptionReport.h +//========================================== #ifndef _WHEATYEXCEPTIONREPORT_ #define _WHEATYEXCEPTIONREPORT_ diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp index ce4f7417a..79ca779fd 100755 --- a/src/tools/genrevision/genrevision.cpp +++ b/src/tools/genrevision/genrevision.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 MaNGOS + * Copyright (C) 2008-2014 Hellground * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -8,12 +9,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -22,7 +23,7 @@ #include #include -#pragma warning(disable:4996) //sprintf is unsave warnings +#pragma warning(disable:4996) //sprintf is unsafe warnings struct RawData { @@ -319,15 +320,17 @@ bool extractDataFromHG(std::string path, bool use_url, RawData& data) { bool res = false; - res = extractDataFromHG(path+".hg/cache/branchheads",path,use_url,data); + res = extractDataFromHG(path+".hg/cache/branchheads-served",path,use_url,data); if (!res) - res = extractDataFromHG(path+"_hg/cache/branchheads",path,use_url,data); + res = extractDataFromHG(path+".hg/cache/branchheads-base",path,use_url,data); if (!res) - res = extractDataFromHG(path+".hg/branchheads.cache",path,use_url,data); + res = extractDataFromHG(path+"_hg/cache/branchheads-base",path,use_url,data); if (!res) res = extractDataFromHG(path+".hg/cache/branchheads",path,use_url,data); if (!res) res = extractDataFromHG(path+"_hg/cache/branchheads",path,use_url,data); + if (!res) + res = extractDataFromHG(path+".hg/branchheads.cache",path,use_url,data); if (!res) res = extractDataFromHG(path+"_hg/branchheads.cache",path,use_url,data); if (!res) diff --git a/win/HellGround VC100.sln b/win/HellGround VC100.sln index c50d94d2d..ab8dde6ff 100644 --- a/win/HellGround VC100.sln +++ b/win/HellGround VC100.sln @@ -1,5 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game", "VC100\game.vcxproj", "{1DC6C4DA-A028-41F3-877D-D5400C594F88}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "VC100\shared.vcxproj", "{90297C34-F231-4DF4-848E-A74BCC0E40ED}" @@ -8,89 +8,193 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "VC100\zlib.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "framework", "VC100\framework.vcxproj", "{BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrinityCore", "VC100\TrinityCore.vcxproj", "{A3A04E47-43A2-4C08-90B3-029CEF558594}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HellgroundCore", "VC100\HellgroundCore.vcxproj", "{A3A04E47-43A2-4C08-90B3-029CEF558594}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrinityRealm", "VC100\TrinityRealm.vcxproj", "{563E9905-3657-460C-AE63-0AC39D162E23}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HellgroundRealm", "VC100\HellgroundRealm.vcxproj", "{563E9905-3657-460C-AE63-0AC39D162E23}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrinityScripts", "VC100\TrinityScripts.vcxproj", "{4295C8A9-79B7-4354-8064-F05FB9CA0C96}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HellgroundScripts", "VC100\HellgroundScripts.vcxproj", "{4295C8A9-79B7-4354-8064-F05FB9CA0C96}" ProjectSection(ProjectDependencies) = postProject {A3A04E47-43A2-4C08-90B3-029CEF558594} = {A3A04E47-43A2-4C08-90B3-029CEF558594} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrevision", "VC100\genrevision.vcxproj", "{803F488E-4C5A-4866-8D5C-1E6C03C007C2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Detour", "..\dep\recastnavigation\Detour\win\VC100\Detour.vcxproj", "{72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lualib", "VC100\lualib.vcxproj", "{EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_PCH|Win32 = Debug_PCH|Win32 + Debug_PCH|x64 = Debug_PCH|x64 Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release_PCH|Win32 = Release_PCH|Win32 + Release_PCH|x64 = Release_PCH|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug|Win32.ActiveCfg = Debug|Win32 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug|Win32.Build.0 = Debug|Win32 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug|x64.ActiveCfg = Debug|x64 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Debug|x64.Build.0 = Debug|x64 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release_PCH|x64.Build.0 = Release_PCH|x64 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release|Win32.ActiveCfg = Release|Win32 {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release|Win32.Build.0 = Release|Win32 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release|x64.ActiveCfg = Release|x64 + {1DC6C4DA-A028-41F3-877D-D5400C594F88}.Release|x64.Build.0 = Release|x64 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug|Win32.ActiveCfg = Debug|Win32 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug|Win32.Build.0 = Debug|Win32 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug|x64.ActiveCfg = Debug|x64 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Debug|x64.Build.0 = Debug|x64 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release_PCH|x64.Build.0 = Release_PCH|x64 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release|Win32.ActiveCfg = Release|Win32 {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release|Win32.Build.0 = Release|Win32 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release|x64.ActiveCfg = Release|x64 + {90297C34-F231-4DF4-848E-A74BCC0E40ED}.Release|x64.Build.0 = Release|x64 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.ActiveCfg = Debug|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.Build.0 = Debug|x64 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release_PCH|x64.Build.0 = Release_PCH|x64 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32 {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.ActiveCfg = Release|x64 + {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.Build.0 = Release|x64 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug|Win32.ActiveCfg = Debug|Win32 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug|Win32.Build.0 = Debug|Win32 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug|x64.ActiveCfg = Debug|x64 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Debug|x64.Build.0 = Debug|x64 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release_PCH|x64.Build.0 = Release_PCH|x64 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release|Win32.ActiveCfg = Release|Win32 {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release|Win32.Build.0 = Release|Win32 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release|x64.ActiveCfg = Release|x64 + {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}.Release|x64.Build.0 = Release|x64 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug|Win32.ActiveCfg = Debug|Win32 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug|Win32.Build.0 = Debug|Win32 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug|x64.ActiveCfg = Debug|x64 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Debug|x64.Build.0 = Debug|x64 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release_PCH|x64.Build.0 = Release_PCH|x64 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release|Win32.ActiveCfg = Release|Win32 {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release|Win32.Build.0 = Release|Win32 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release|x64.ActiveCfg = Release|x64 + {A3A04E47-43A2-4C08-90B3-029CEF558594}.Release|x64.Build.0 = Release|x64 {563E9905-3657-460C-AE63-0AC39D162E23}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {563E9905-3657-460C-AE63-0AC39D162E23}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {563E9905-3657-460C-AE63-0AC39D162E23}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {563E9905-3657-460C-AE63-0AC39D162E23}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {563E9905-3657-460C-AE63-0AC39D162E23}.Debug|Win32.ActiveCfg = Debug|Win32 {563E9905-3657-460C-AE63-0AC39D162E23}.Debug|Win32.Build.0 = Debug|Win32 + {563E9905-3657-460C-AE63-0AC39D162E23}.Debug|x64.ActiveCfg = Debug|x64 + {563E9905-3657-460C-AE63-0AC39D162E23}.Debug|x64.Build.0 = Debug|x64 {563E9905-3657-460C-AE63-0AC39D162E23}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {563E9905-3657-460C-AE63-0AC39D162E23}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {563E9905-3657-460C-AE63-0AC39D162E23}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {563E9905-3657-460C-AE63-0AC39D162E23}.Release_PCH|x64.Build.0 = Release_PCH|x64 {563E9905-3657-460C-AE63-0AC39D162E23}.Release|Win32.ActiveCfg = Release|Win32 {563E9905-3657-460C-AE63-0AC39D162E23}.Release|Win32.Build.0 = Release|Win32 + {563E9905-3657-460C-AE63-0AC39D162E23}.Release|x64.ActiveCfg = Release|x64 + {563E9905-3657-460C-AE63-0AC39D162E23}.Release|x64.Build.0 = Release|x64 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug|Win32.ActiveCfg = Debug|Win32 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug|Win32.Build.0 = Debug|Win32 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug|x64.ActiveCfg = Debug|x64 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Debug|x64.Build.0 = Debug|x64 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release_PCH|x64.Build.0 = Release_PCH|x64 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release|Win32.ActiveCfg = Release|Win32 {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release|Win32.Build.0 = Release|Win32 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release|x64.ActiveCfg = Release|x64 + {4295C8A9-79B7-4354-8064-F05FB9CA0C96}.Release|x64.Build.0 = Release|x64 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug_PCH|Win32.ActiveCfg = Debug_PCH|Win32 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug_PCH|Win32.Build.0 = Debug_PCH|Win32 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug_PCH|x64.ActiveCfg = Debug_PCH|x64 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug_PCH|x64.Build.0 = Debug_PCH|x64 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|Win32.ActiveCfg = Debug|Win32 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|Win32.Build.0 = Debug|Win32 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|x64.ActiveCfg = Debug|x64 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|x64.Build.0 = Debug|x64 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release_PCH|Win32.ActiveCfg = Release_PCH|Win32 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release_PCH|Win32.Build.0 = Release_PCH|Win32 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release_PCH|x64.ActiveCfg = Release_PCH|x64 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release_PCH|x64.Build.0 = Release_PCH|x64 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|Win32.ActiveCfg = Release|Win32 {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|Win32.Build.0 = Release|Win32 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|x64.ActiveCfg = Release|x64 + {803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|x64.Build.0 = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug_PCH|Win32.ActiveCfg = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug_PCH|Win32.Build.0 = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug_PCH|x64.ActiveCfg = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug_PCH|x64.Build.0 = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.ActiveCfg = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|Win32.Build.0 = Debug|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.ActiveCfg = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Debug|x64.Build.0 = Debug|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release_PCH|Win32.ActiveCfg = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release_PCH|Win32.Build.0 = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release_PCH|x64.ActiveCfg = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release_PCH|x64.Build.0 = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.ActiveCfg = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|Win32.Build.0 = Release|Win32 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.ActiveCfg = Release|x64 + {72BDF975-4D4A-42C7-B2C4-F9ED90A2ABB6}.Release|x64.Build.0 = Release|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug_PCH|Win32.ActiveCfg = Debug|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug_PCH|Win32.Build.0 = Debug|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug_PCH|x64.ActiveCfg = Debug|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug_PCH|x64.Build.0 = Debug|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug|Win32.Build.0 = Debug|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug|x64.ActiveCfg = Debug|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Debug|x64.Build.0 = Debug|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release_PCH|Win32.ActiveCfg = Release|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release_PCH|Win32.Build.0 = Release|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release_PCH|x64.ActiveCfg = Release|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release_PCH|x64.Build.0 = Release|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release|Win32.ActiveCfg = Release|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release|Win32.Build.0 = Release|Win32 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release|x64.ActiveCfg = Release|x64 + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/win/VC100/TrinityCore.vcxproj b/win/VC100/HellgroundCore.vcxproj similarity index 78% rename from win/VC100/TrinityCore.vcxproj rename to win/VC100/HellgroundCore.vcxproj index 9fc0ba601..663365414 100644 --- a/win/VC100/TrinityCore.vcxproj +++ b/win/VC100/HellgroundCore.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -36,48 +36,57 @@ {A3A04E47-43A2-4C08-90B3-029CEF558594} - trinitycore + hellgroundcore + HellgroundCore Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 @@ -129,17 +138,17 @@ $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ true - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ false false false - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ true AllRules.ruleset @@ -168,7 +177,7 @@ - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) @@ -196,7 +205,7 @@ /MACHINE:I386 %(AdditionalOptions) - Detour.lib;ACE.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) + ACE.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) $(TargetPath) true $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) @@ -217,12 +226,12 @@ copy ..\..\dep\lib\precompiled\Release\*.dll ..\..\bin\$(Platform)_$(Configuration)\ if exist $(TargetPath) move $(TargetPath) $(OutDir).. -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) @@ -250,7 +259,7 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu /MACHINE:I386 %(AdditionalOptions) - Detour.lib;ACE.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) + ACE.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) $(TargetPath) true $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) @@ -271,12 +280,12 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu copy ..\..\dep\lib\precompiled\Release\*.dll ..\..\bin\$(Platform)_$(Configuration) if exist $(TargetPath) move $(TargetPath) $(OutDir).. -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) @@ -305,7 +314,7 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu /MACHINE:I386 %(AdditionalOptions) - Detour.lib;ACEd.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) + ACEd.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) $(TargetPath) true $(OutDir);..\..\dep\lib\precompiled\Debug;%(AdditionalLibraryDirectories) @@ -326,12 +335,12 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu copy ..\..\dep\lib\precompiled\Debug\*.dll ..\..\bin\$(Platform)_$(Configuration)\lib\ if exist $(TargetPath) move $(TargetPath) $(OutDir).. -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\HellgroundCore.conf.dist - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) @@ -357,7 +366,7 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu /MACHINE:I386 %(AdditionalOptions) - Detour.lib;ACEd.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) + ACEd.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) $(TargetPath) @@ -378,28 +387,28 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu copy ..\..\dep\lib\precompiled\Debug\*.dll ..\..\bin\$(Platform)_$(Configuration)\lib\ if exist $(TargetPath) move $(TargetPath) $(OutDir).. -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\HellgroundCore.conf.dist X64 - .\trinitycore_$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore_$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) OnlyExplicitInline - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\trinitycore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\hellgroundcore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) VERSION=0.12.0-SVN;WIN32;NDEBUG;_CONSOLE;ENABLE_CLI;%(PreprocessorDefinitions) true MultiThreadedDLL true NotSet true - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.pch - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.pch + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -411,22 +420,22 @@ copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configu libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;framework.lib;msvcrt.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\framework__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.map Console - $(OutDir)TrinityCore.lib + $(OutDir)HellgroundCore.lib MachineX64 copy ..\..\dep\lib\$(Platform)_$(Configuration)\*.dll ..\..\bin\$(Platform)_$(Configuration) -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) @@ -434,22 +443,22 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) X64 - .\trinitycore_$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore_$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) OnlyExplicitInline - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\trinitycore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\hellgroundcore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) VERSION=0.12.0-SVN;WIN32;NDEBUG;_CONSOLE;ENABLE_CLI;%(PreprocessorDefinitions) true MultiThreadedDLL true NotSet true - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.pch - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.pch + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -461,22 +470,22 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;framework.lib;msvcrt.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\framework__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.map Console - $(OutDir)TrinityCore.lib + $(OutDir)HellgroundCore.lib MachineX64 copy ..\..\dep\lib\$(Platform)_$(Configuration)\*.dll ..\..\bin\$(Platform)_$(Configuration) -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) @@ -484,22 +493,22 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) X64 - .\trinitycore_$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore_$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) OnlyExplicitInline - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\trinitycore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\hellgroundcore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) VERSION=0.12.0-SVN;WIN32;NDEBUG;_CONSOLE;ENABLE_CLI;%(PreprocessorDefinitions) true MultiThreadedDLL true NotSet true - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.pch - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.pch + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -511,22 +520,22 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;framework.lib;msvcrt.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\framework__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.map Console - $(OutDir)TrinityCore.lib + $(OutDir)HellgroundCore.lib MachineX64 copy ..\..\dep\lib\$(Platform)_$(Configuration)\*.dll ..\..\bin\$(Platform)_$(Configuration) -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) @@ -534,21 +543,21 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) X64 - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.tlb + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.tlb /MP %(AdditionalOptions) Disabled - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\trinitycore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - VERSION=0.12.0-SVN;WIN32;_DEBUG;TRINITY_DEBUG;_CONSOLE;ENABLE_CLI;%(PreprocessorDefinitions) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\game;..\..\src\hellgroundcore;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + VERSION=0.12.0-SVN;WIN32;_DEBUG;HELLGROUND_DEBUG;_CONSOLE;ENABLE_CLI;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL true - .\trinitycore__$(Platform)_$(Configuration)\trinitycore.pch - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ - .\trinitycore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\hellgroundcore.pch + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ + .\hellgroundcore__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -560,49 +569,52 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;framework.lib;msvcrtd.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\framework__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.map Console false - $(OutDir)TrinityCore.lib + $(OutDir)HellgroundCore.lib MachineX64 copy ..\..\dep\lib\$(Platform)_$(Configuration)\*.dll ..\..\bin\$(Platform)_$(Configuration) -copy ..\..\src\trinitycore\trinitycore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityCore.conf.dist +copy ..\..\src\hellgroundcore\hellgroundcore.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundCore.conf.dist copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) - + - - - + + + - + - - - + + + - + - + + + {72bdf975-4d4a-42c7-b2c4-f9ed90a2abb6} + {bf6f5d0e-33a5-4e23-9e7d-dd481b7b5b9e} @@ -614,7 +626,7 @@ copy ..\..\README.* ..\..\bin\$(Platform)_$(Configuration) {90297c34-f231-4df4-848e-a74bcc0e40ed} false - + {563e9905-3657-460c-ae63-0ac39d162e23} false diff --git a/win/VC100/HellgroundCore.vcxproj.filters b/win/VC100/HellgroundCore.vcxproj.filters new file mode 100644 index 000000000..e71b2073b --- /dev/null +++ b/win/VC100/HellgroundCore.vcxproj.filters @@ -0,0 +1,31 @@ + + + + + {c9298846-540e-4c6c-bf08-9881b7c593db} + + + + + doc + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/win/VC100/TrinityRealm.vcxproj b/win/VC100/HellgroundRealm.vcxproj similarity index 83% rename from win/VC100/TrinityRealm.vcxproj rename to win/VC100/HellgroundRealm.vcxproj index 2b1893169..3848e3329 100644 --- a/win/VC100/TrinityRealm.vcxproj +++ b/win/VC100/HellgroundRealm.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -37,47 +37,56 @@ {563E9905-3657-460C-AE63-0AC39D162E23} realmd + HellgroundRealm Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 Application false MultiByte + v120 @@ -129,17 +138,17 @@ $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ true - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ false false false - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ true AllRules.ruleset @@ -212,7 +221,7 @@ $(OutDir)$(TargetName).lib - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist if exist $(TargetPath) move $(TargetPath) $(OutDir).. @@ -263,7 +272,7 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. $(OutDir)$(TargetName).lib - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist if exist $(TargetPath) move $(TargetPath) $(OutDir).. @@ -314,7 +323,7 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. $(OutDir)$(TargetName).lib - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\HellgroundRealm.conf.dist if exist $(TargetPath) move $(TargetPath) $(OutDir).. @@ -362,7 +371,7 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. $(OutDir)$(TargetName).lib - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\lib\HellgroundRealm.conf.dist if exist $(TargetPath) move $(TargetPath) $(OutDir).. @@ -381,10 +390,10 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. true NotSet true - .\trinityrealm__$(Platform)_$(Configuration)\realmd.pch - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\realmd.pch + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -396,18 +405,18 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. zthread.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\zthread__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.map Console MachineX64 - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist @@ -425,10 +434,10 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. true NotSet true - .\trinityrealm__$(Platform)_$(Configuration)\realmd.pch - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\realmd.pch + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -440,18 +449,18 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. zthread.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\zthread__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.map Console MachineX64 - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist @@ -469,10 +478,10 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. true NotSet true - .\trinityrealm__$(Platform)_$(Configuration)\realmd.pch - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\realmd.pch + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -484,18 +493,18 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. zthread.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\zthread__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.map Console MachineX64 - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist @@ -507,15 +516,15 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. /MP %(AdditionalOptions) Disabled ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\realmd;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - VERSION=0.12.0-SVN;WIN32;_DEBUG;TRINITY_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + VERSION=0.12.0-SVN;WIN32;_DEBUG;HELLGROUND_DEBUG;_CONSOLE;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL true - .\trinityrealm__$(Platform)_$(Configuration)\realmd.pch - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ - .\trinityrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\realmd.pch + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ + .\hellgroundrealm__$(Platform)_$(Configuration)\ Level3 true ProgramDatabase @@ -527,39 +536,41 @@ if exist $(TargetPath) move $(TargetPath) $(OutDir).. zthread.lib;libmySQL.lib;libeay32.lib;ws2_32.lib;winmm.lib;odbc32.lib;odbccp32.lib;advapi32.lib;dbghelp.lib;%(AdditionalDependencies) - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.exe + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.exe true ..\..\dep\lib\$(Platform)_$(Configuration);..\..\dep\ACE_wrappers\lib;.\zthread__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.pdb + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.pdb true - ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.map + ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.map Console false MachineX64 - copy ..\..\src\trinityrealm\trinityrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\TrinityRealm.conf.dist + copy ..\..\src\hellgroundrealm\hellgroundrealm.conf.dist ..\..\bin\$(Platform)_$(Configuration)\HellgroundRealm.conf.dist - - - - - + + + + + + - - - - - + + + + + + - + diff --git a/win/VC100/HellgroundScripts.vcxproj b/win/VC100/HellgroundScripts.vcxproj new file mode 100644 index 000000000..1ea599c5b --- /dev/null +++ b/win/VC100/HellgroundScripts.vcxproj @@ -0,0 +1,930 @@ + + + + + Debug_PCH + Win32 + + + Debug_PCH + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release_PCH + Win32 + + + Release_PCH + x64 + + + Release + Win32 + + + Release + x64 + + + + HellgroundScripts + {4295C8A9-79B7-4354-8064-F05FB9CA0C96} + ScriptDev2 + Win32Proj + + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + DynamicLibrary + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ + $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ + true + $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ + $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ + $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ + $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ + $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ + $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ + false + false + false + ..\..\bin\$(Platform)_$(Configuration)\ + .\ScriptDev2__$(Platform)_$(Configuration)\ + true + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + ..\..\bin\$(Platform)_$(Configuration)\ + .\ScriptDev2__$(Platform)_$(Configuration)\ + .\ScriptDev2__$(Platform)_$(Configuration)\ + .\ScriptDev2__$(Platform)_$(Configuration)\ + false + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + hellgroundscript + hellgroundscript + hellgroundscript + hellgroundscript + + + + + + + + /MP -Zm124 %(AdditionalOptions) + Disabled + ..\..\dep\include\;..\..\src\scripts\scripts\special;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + precompiled.h + Level3 + EditAndContinue + + + hellgroundcore.lib;libmySQL.lib;ACEd.lib;%(AdditionalDependencies) + $(TargetPath) + $(OutDir);..\..\dep\lib\precompiled\Debug;%(AdditionalLibraryDirectories) + true + $(OutDir)$(TargetName).pdb + Windows + false + + + $(OutDir)$(TargetName).lib + MachineX86 + true + $(OutDir)$(TargetName).map + + + if exist $(TargetPath) move $(TargetPath) $(OutDir).. + + + + + + + + + /MP -Zm113 %(AdditionalOptions) + ..\..\dep\include\;..\..\src\scripts\scripts\special;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) + false + MultiThreadedDLL + StreamingSIMDExtensions + Fast + Use + precompiled.h + Level3 + ProgramDatabase + Disabled + OnlyExplicitInline + + + hellgroundcore.lib;libmySQL.lib;ACE.lib;%(AdditionalDependencies) + $(TargetPath) + $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) + false + Windows + true + true + false + + + $(OutDir)$(TargetName).lib + MachineX86 + $(OutDir)$(TargetName).pdb + false + $(OutDir)$(TargetName).map + + + if exist $(TargetPath) move $(TargetPath) $(OutDir).. + + + + + + + + + /MP -Zm113 %(AdditionalOptions) + ..\..\dep\include\;..\..\src\scripts\scripts\special;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) + false + MultiThreadedDLL + StreamingSIMDExtensions + Fast + Use + precompiled.h + Level3 + ProgramDatabase + Disabled + OnlyExplicitInline + true + + + hellgroundcore.lib;libmySQL.lib;ACE.lib;%(AdditionalDependencies) + $(TargetPath) + $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) + Windows + true + true + false + + + $(OutDir)$(TargetName).lib + MachineX86 + true + $(OutDir)$(TargetName).pdb + true + $(OutDir)$(TargetName).map + + + if exist $(TargetPath) move $(TargetPath) $(OutDir).. + + + + + + + + + /MP -Zm124 %(AdditionalOptions) + ..\..\dep\include\;..\..\src\scripts\scripts\special;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + StreamingSIMDExtensions + Fast + Use + precompiled.h + Level3 + ProgramDatabase + Disabled + Default + EnableFastChecks + + + hellgroundcore.lib;libmySQL.lib;ACEd.lib;%(AdditionalDependencies) + $(TargetPath) + $(OutDir);..\..\dep\lib\precompiled\Debug;%(AdditionalLibraryDirectories) + Windows + true + true + false + + + $(OutDir)$(TargetName).lib + MachineX86 + true + $(OutDir)$(TargetName).pdb + true + $(OutDir)$(TargetName).map + + + if exist $(TargetPath) move $(TargetPath) $(OutDir).. + + + + + + + + + X64 + + + Disabled + ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;MANGOS_DEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + precompiled.h + Level3 + ProgramDatabase + + + hellgroundcore.lib;ACEd.lib;%(AdditionalDependencies) + $(OutDir)hellgroundscript.dll + ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\hellgroundcore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + true + $(OutDir)MaNGOSScript.pdb + Windows + false + + + $(OutDir)hellgroundscript.lib + MachineX64 + + + + + + + + + X64 + + + /MP %(AdditionalOptions) + ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) + false + MultiThreadedDLL + Use + precompiled.h + Level3 + ProgramDatabase + + + hellgroundcore.lib;ACE.lib;%(AdditionalDependencies) + $(OutDir)hellgroundscript.dll + ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\hellgroundcore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + false + Windows + true + true + false + + + $(OutDir)hellgroundscript.lib + MachineX64 + + + + + + + + + X64 + + + /MP %(AdditionalOptions) + ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) + false + MultiThreadedDLL + Use + precompiled.h + Level3 + ProgramDatabase + + + hellgroundcore.lib;ACE.lib;%(AdditionalDependencies) + $(OutDir)hellgroundscript.dll + ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\hellgroundcore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + false + Windows + true + true + false + + + $(OutDir)hellgroundscript.lib + MachineX64 + + + + + + + + + X64 + + + /MP %(AdditionalOptions) + ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) + false + MultiThreadedDLL + Use + precompiled.h + Level3 + ProgramDatabase + + + hellgroundcore.lib;ACE.lib;%(AdditionalDependencies) + $(OutDir)hellgroundscript.dll + ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\hellgroundcore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) + false + Windows + true + true + false + + + $(OutDir)hellgroundscript.lib + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {90297c34-f231-4df4-848e-a74bcc0e40ed} + + + {a3a04e47-43a2-4c08-90b3-029cef558594} + + + + + + \ No newline at end of file diff --git a/win/VC100/HellgroundScripts.vcxproj.filters b/win/VC100/HellgroundScripts.vcxproj.filters new file mode 100644 index 000000000..267eaad36 --- /dev/null +++ b/win/VC100/HellgroundScripts.vcxproj.filters @@ -0,0 +1,1715 @@ + + + + + {bdce62a4-b084-42e8-8248-f0aadc4bc0ad} + + + {8291aeef-e65d-4fb6-915a-b742d3378fb0} + + + {c9e1ec2b-62d5-4e32-93c7-9e7211682e80} + + + {8d2b5f11-d110-4fdf-8d4b-1cc831f4d1ee} + + + {a349ac5c-9a3e-4f18-8d75-4aa90a80d778} + + + {e6761d98-9e4e-487f-adac-a48d5403ffdb} + + + {8290c881-4ad9-4851-a989-6d15115a090f} + + + {fb65a864-c699-4d95-954c-554718f69e3b} + + + {6d333590-04c7-4836-85c2-72287223b658} + + + {f4c517c6-c2d2-421c-8a11-b829f6c1575d} + + + {d2f76663-d459-46f0-95cf-953d3e3b8f84} + + + {6482406e-94df-40c4-8adc-4215c41910c8} + + + {93fb41ff-2f56-49bf-8b65-72eb245bf5c5} + + + {cc3b84c9-fb8e-4c7b-863d-2e9271c4c6bf} + + + {8064c517-d276-4c34-9fdb-5640f1bef87c} + + + {117f2fa5-de75-4105-9a20-e5d0907f138c} + + + {c707cb15-d2fb-460a-8cd2-835f0c62cbec} + + + {f0322b6e-1c2e-4915-8ed9-918a9fb0ef71} + + + {8030e199-bbd2-4e63-a3ed-3c14b395252d} + + + {683660a0-8880-41ac-a91f-52b6bbf2e6a7} + + + {420513ed-e626-4598-9fcf-d43fc68200f2} + + + {252f987c-313e-4022-84c2-ea183bdd1152} + + + {104c4cae-b840-4bc2-a274-78b3ed6e1c4e} + + + {15832be0-3507-4459-a2b2-44f82b1d19f8} + + + {8791a214-5405-43d3-b27d-009375a4eaf5} + + + {2477b44d-b9e9-4b1f-ae75-83d17df39c18} + + + {88150fe2-8954-4943-a48a-780644c5c6a6} + + + {d4e9bd8b-2d59-47fb-bb8b-44909a56c972} + + + {ab156596-733a-4016-b276-ea604a36f34a} + + + {2a660590-e42a-4cf5-bdf9-6974c03f3206} + + + {7d5d35ab-50ab-4ccd-9492-890cdb156f83} + + + {4dba8fe9-eb23-4f9c-b7f3-31f439f77d5f} + + + {58a0785b-c8fa-4c25-a63d-3d995deff6d8} + + + {f8fc28d5-8a6d-46e9-aafb-3521e8b3c218} + + + {1bd70d1b-1560-4344-9f46-c77d6fb735fa} + + + {4286e9c2-ed4a-462a-8771-5fe54d52d85f} + + + {1fb1cd34-1fe4-420e-8fc5-c273054ac2cf} + + + {1d8a223d-7486-4b1c-9c8d-7053214843af} + + + {17ff95c5-2165-4b05-9472-3c5370152a14} + + + {229ac029-50e6-4c53-a941-5b6b8720e9bc} + + + {6cb0ab12-5160-46e6-8645-68242e583182} + + + {b2e1354a-413b-4372-a689-8afb68b0f4ff} + + + {4ee50d8b-706a-4353-ade0-1a5ec630774a} + + + {21a5399e-94c7-43fb-8d08-c1f83d839e5e} + + + {f23a1edb-bc70-4c34-9ace-76e67944be2f} + + + {582511bf-2e74-481d-8706-ca10e1c4fe6e} + + + {1796363d-7dc1-4f3d-aa41-226f7072e764} + + + {8480df4e-134f-4310-8808-0a11837df562} + + + {45bc1015-705a-4fd4-8411-87975f1dd87f} + + + {36ede908-4c16-49c2-bafb-b549e509deec} + + + {42c2de4e-fad7-4f5d-bfc6-3d921d5a4dd7} + + + {f2e90fce-3bb8-4dcd-b0b8-9c10d854d5cb} + + + {34a68648-d4e1-45a7-88f0-0583c10e5c52} + + + {a12f8943-6924-42a6-8c82-d603e2461b03} + + + {294af0de-427e-4d22-b26e-f813776bda94} + + + {579e7cca-2c52-4475-a774-8816bbef96c7} + + + {e7c3a726-b4aa-4206-ab04-7652feb7b5c7} + + + {8175f2a2-5946-498e-a920-658e70b85bcf} + + + {a5ec3f98-9ff0-4fd0-8030-72d692632ee0} + + + {779d02d0-b1a6-46f2-8ffe-44f62646c81b} + + + {a36ba48a-5a93-4cc7-bf6f-86b10157369c} + + + {68dc9f67-12ed-4bbd-9b0b-c390c33b25a0} + + + {c4c64f2e-df23-4901-8b12-5775de049781} + + + {e6b96048-146f-4dc0-be6f-db2aba0cc2a3} + + + {b19dbf1c-1f40-44ce-bf9d-b85af9c0c39a} + + + {476d48fb-1ea2-4b75-a305-4a0a3e655a06} + + + {550e94ec-a7ba-4ee7-b1e5-9be00f5b34c4} + + + {66c1644b-b910-485d-874a-92ea30370930} + + + {c699e294-8dc9-4a14-afaa-a6268288e997} + + + {85c2ffcc-a94a-4f4b-be5f-fcdfb6156295} + + + {8bfc661a-5388-4fa9-ae04-6f8d01871fdd} + + + {7ce7c2b8-7c13-4dca-b72f-1a1beef82922} + + + {517e6c2d-8369-42ee-9f1d-3b8818a5204c} + + + {d389dd62-d12c-4cf8-bcf3-ceb09c0cdf5b} + + + {0a62681c-813e-4562-b667-3c623c04ebd2} + + + {2e95dcac-277e-4431-b3d7-192b0d0fe539} + + + {a7936352-0199-4739-b53a-fa50cbccf50f} + + + {a6984a6e-797a-43af-a330-f17c30cd432f} + + + {b3d2dabc-1aa2-426a-84d3-67a8ce35329f} + + + {c8c3c8c5-04ca-4b50-b20a-3f072d0ead95} + + + {d1ccae14-22bb-46dd-bef9-64fc3aa93b00} + + + {b312f48e-b7b9-4bc4-af44-76f157b25ec0} + + + {2cef6d6e-8c3e-4c9e-be83-f540280d35c4} + + + {c6b0d1b7-a8ce-4762-86c8-5c624deed0c7} + + + {fe60c02b-f792-4755-b6ca-a2fb3fab6a5e} + + + {3821806f-7cf7-40ba-a03f-7f2ab8cca923} + + + {71da00c7-3674-4ea9-bcc1-a77ae4cdb52a} + + + {1d36f0b7-f55d-476a-b51b-9fbf49ec2bd1} + + + {c8c5f86c-7fab-4e6e-afce-7bcac4dd61d1} + + + {0b55834d-cf32-467d-8b39-0ce5e4207d65} + + + {dbb35332-9dd6-4767-aa3b-e417a1524e58} + + + {37a93f89-0a9b-4eff-8cab-2dd7c994ea09} + + + {42b3571d-4216-4c77-a9c2-6ce6acb4469a} + + + {821a5cef-b456-416f-9667-479c75a23db6} + + + {3e41a39d-6883-4d32-ade6-7427a37e85d8} + + + {8c8d33cb-f7a1-4edb-949a-d3f028031fff} + + + {6ed26bbd-b18e-49d2-8b6f-9e814dcf37af} + + + {25e71dfd-275b-41e7-9bd7-98a3774a4c97} + + + {ae423b58-cc88-442c-bf6a-0c5b460208ff} + + + {4e7648fc-6bba-4d2d-b14b-3c1d57810954} + + + {04c08655-e9f9-40df-97a5-7749f69239ad} + + + {fb036523-dd02-492a-9514-b9bbd3c1079d} + + + {e21d62f9-1e24-4288-83b2-c05e78a6c01c} + + + {436b03d5-81a8-4551-bc61-04dda100d108} + + + {a9170084-1919-4c4d-aa94-88400c15424e} + + + {2400aadc-6771-4a0d-9f15-8b9b3148dd88} + + + {6c091a19-8462-4a51-afe7-a6aac6bc7b04} + + + {6337c580-7867-4c6e-a961-78df207f9044} + + + {f97fd9ef-1118-482b-9640-b174731dfe29} + + + {933884b1-5e5c-459a-9bce-bc3e476011ea} + + + {60a033ca-8311-4402-9332-8dd658d781a9} + + + {c01b2050-20fc-47e0-be12-30a324fe3b06} + + + {c31dd55b-9dd8-4364-b535-8d5a08eb6ceb} + + + {aed4464e-69d8-4248-91f5-ce6f6035e7cb} + + + {02cc5cb7-1eb7-4c67-b92f-1634b2b2d86a} + + + {d98c4035-5824-4907-a814-028d2415da0a} + + + {32bc8fb4-7d8b-46fc-8ab2-3f5be02e7267} + + + {a0da2eb2-6fe6-4efd-aab6-4109d179e710} + + + {7bac0f6d-b236-496c-bda2-e487bb1e4d2e} + + + {ed07c189-fb23-4151-859c-c0cfa9e978bf} + + + {bab9eac4-4f5f-401b-921a-4a1ddd3bbe07} + + + {ce5e9434-5125-4e0a-9c66-cbcc3e2f5968} + + + {7bd80ffd-2656-42db-bd90-1459d7972fb4} + + + {29db419c-6238-4cda-a65a-ca9abdb73845} + + + {1687a90d-aead-4aeb-afca-1bf87011a0c0} + + + {a6ccc2c0-babf-4dbf-a814-caf21207fdcc} + + + + + Scripts\boss + + + Scripts\boss + + + Scripts\boss + + + Scripts\boss + + + Scripts\Eastern Kingdoms\Alterac Mountains + + + Scripts\Kalimdor\Ashenvale Forest + + + Scripts\Eastern Kingdoms\Alterac Valley + + + Scripts\Eastern Kingdoms\Alterac Valley + + + Scripts\Eastern Kingdoms\Alterac Valley + + + Scripts\Eastern Kingdoms\Alterac Valley + + + Scripts\Kalimdor\Azshara + + + Scripts\Kalimdor\Azshara + + + Scripts\Kalimdor\Barrens + + + Scripts\Eastern Kingdoms\Arathi Highlands + + + Scripts\Eastern Kingdoms\Deadmines + + + Scripts\Kalimdor\Desolace + + + Scripts\Eastern Kingdoms\Dun Morogh + + + Scripts\Kalimdor\Durotar + + + Scripts\Eastern Kingdoms\Duskwood + + + Scripts\Kalimdor\Dustwallow Marsh + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Eastern Kingdoms\Blackwing Lair + + + Scripts\Kalimdor\Bloodmyst Isle + + + Scripts\Outland\Gruul%27s Lair + + + Scripts\Outland\Gruul%27s Lair + + + Scripts\Outland\Gruul%27s Lair + + + Scripts\Eastern Kingdoms\Burning Steppes + + + Scripts\Kalimdor\Darkshore + + + Scripts\Eastern Kingdoms\Eastern Plaguelands + + + Scripts\Kalimdor\Moonglade + + + Scripts\Kalimdor\Razorfen Kraul + + + Scripts\Kalimdor\Razorfen Kraul + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Kalimdor\Ruins of Ahn%27Qiraj + + + Scripts\Eastern Kingdoms\Swamp of Sorrows + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Searing Gorge + + + Scripts\Eastern Kingdoms\Elwynn Forest + + + Scripts\Kalimdor\Felwood + + + Scripts\Kalimdor\Feralas + + + Scripts\Kalimdor\Maraudon + + + Scripts\Kalimdor\Maraudon + + + Scripts\Kalimdor\Maraudon + + + Scripts\Kalimdor\Maraudon + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Kalimdor\Mulgore + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Eastern Kingdoms\Naxxramas + + + Scripts\Kalimdor\Onyxia%27s Lair + + + Scripts\Kalimdor\Onyxia%27s Lair + + + Scripts\Kalimdor\Razorfen Downs + + + Scripts\Kalimdor\Razorfen Downs + + + Scripts\Kalimdor\Razorfen Downs + + + Scripts\Eastern Kingdoms\Shadowfang Keep + + + Scripts\Eastern Kingdoms\Shadowfang Keep + + + Scripts\Kalimdor\Stonetalon Mountains + + + Scripts\Eastern Kingdoms\Stranglethorn Vale + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Kalimdor\Tanaris + + + Scripts\Kalimdor\Teldrassil + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Thousand Needles + + + Scripts\Kalimdor\Silithus + + + Scripts\Eastern Kingdoms\Silverpine Forest + + + Scripts\Eastern Kingdoms\Tirisfal Glades + + + Scripts\Kalimdor\Wailing Caverns + + + Scripts\Kalimdor\Wailing Caverns + + + Scripts\Eastern Kingdoms\Western Plaguelands + + + Scripts\Eastern Kingdoms\Westfall + + + Scripts\Eastern Kingdoms\Wetlands + + + Scripts\Kalimdor\Winterspring + + + Scripts\Kalimdor\Zul%27Farrak + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Eastern Kingdoms\Uldaman + + + Scripts\Eastern Kingdoms\Uldaman + + + Scripts\Eastern Kingdoms\Uldaman + + + Scripts\Eastern Kingdoms\Uldaman + + + Scripts\Kalimdor\Un%27Goro Crater + + + Scripts\Outland\Aunchindoun\Auchenai Crypts + + + Scripts\Outland\Aunchindoun\Auchenai Crypts + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Scripts\Outland\Aunchindoun\Sethekk Halls + + + Scripts\Outland\Aunchindoun\Sethekk Halls + + + Scripts\Outland\Aunchindoun\Sethekk Halls + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Kalimdor\Azuremyst Isle + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Black Temple + + + Scripts\Eastern Kingdoms\Eversong Woods + + + Scripts\Eastern Kingdoms\Ghostlands + + + Scripts\Outland\Blade%27s Edge Mountains + + + Scripts\Eastern Kingdoms\Blasted Lands + + + Scripts\Eastern Kingdoms\Blasted Lands + + + Scripts\Outland\Hellfire Citadel\Blood Furnace + + + Scripts\Outland\Hellfire Citadel\Blood Furnace + + + Scripts\Outland\Hellfire Citadel\Blood Furnace + + + Scripts\Outland\Hellfire Citadel\Blood Furnace + + + Scripts\Outland\Hellfire Citadel\Magtheridon%27s lair + + + Scripts\Outland\Hellfire Citadel\Magtheridon%27s lair + + + Scripts\Outland\Hellfire Citadel\Hellfire Ramparts + + + Scripts\Outland\Hellfire Citadel\Hellfire Ramparts + + + Scripts\Outland\Hellfire Citadel\Hellfire Ramparts + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Outland\Hellfire Peninsula + + + Scripts\Outland\Hellfire Peninsula + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Outland\Nagrand + + + Scripts\Outland\Netherstorm + + + Scripts\Outland\Shadowmoon Valley + + + Scripts\Outland\Shadowmoon Valley + + + Scripts\Outland\Tempest Keep\Arcatraz + + + Scripts\Outland\Tempest Keep\Arcatraz + + + Scripts\Outland\Tempest Keep\Arcatraz + + + Scripts\Outland\Tempest Keep\Botanica + + + Scripts\Outland\Tempest Keep\Botanica + + + Scripts\Outland\Tempest Keep\Botanica + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Terokkar Forest + + + Scripts\Outland\Zangarmarsh + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Eastern Kingdoms\Stormwind City + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Slave Pens + + + Scripts\Outland\Coilfang Resevoir\Slave Pens + + + Scripts\Outland\Coilfang Resevoir\Slave Pens + + + Scripts\Outland\Coilfang Resevoir\Steam Vault + + + Scripts\Outland\Coilfang Resevoir\Steam Vault + + + Scripts\Outland\Coilfang Resevoir\Steam Vault + + + Scripts\Outland\Coilfang Resevoir\Steam Vault + + + Scripts\Outland\Coilfang Resevoir\Underbog + + + Scripts\Outland\Coilfang Resevoir\Underbog + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Eastern Kingdoms\Silvermoon City + + + Scripts\Eastern Kingdoms\Iron Forge + + + Scripts\Kalimdor\Orgrimmar + + + Scripts\Outland\Shattrath City + + + Scripts\Kalimdor\Thunder Bluff + + + Scripts\Eastern Kingdoms\Undercity + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Isle of Quel%27Danas + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Loch Modan + + + Scripts\Eastern Kingdoms\Hinterlands + + + Include + + + Include + + + System + + + System + + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Outland\Aunchindoun\Sethekk Halls + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Include + + + Include + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Scripts\Kalimdor\Zul%27Farrak + + + Scripts\Outland\Coilfang Resevoir\Slave Pens + + + Scripts\Outland\Hellfire Citadel\Hellfire Ramparts + + + Scripts\Kalimdor\Dire Maul + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\special + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Eastern Kingdoms\Molten Core + + + + + Scripts\Eastern Kingdoms\Deadmines + + + Scripts\Outland\Gruul%27s Lair + + + Scripts\Kalimdor\Razorfen Kraul + + + Scripts\Eastern Kingdoms\Scarlet Monastery + + + Scripts\Eastern Kingdoms\Scholomance + + + Scripts\Eastern Kingdoms\Molten Core + + + Scripts\Kalimdor\Onyxia%27s Lair + + + Scripts\Kalimdor\Razorfen Downs + + + Scripts\Eastern Kingdoms\Shadowfang Keep + + + Scripts\Eastern Kingdoms\Stratholme + + + Scripts\Kalimdor\Temple of Ahn%27Qiraj + + + Scripts\Kalimdor\Wailing Caverns + + + Scripts\Eastern Kingdoms\Zul%27Gurub + + + Scripts\Outland\Aunchindoun\Sethekk Halls + + + Scripts\Outland\Aunchindoun\Shadow Labyrinth + + + Scripts\Outland\Black Temple + + + Scripts\Outland\Hellfire Citadel\Blood Furnace + + + Scripts\Outland\Hellfire Citadel\Magtheridon%27s lair + + + Scripts\Outland\Hellfire Citadel\Shattered Halls + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Outland\Tempest Keep\Arcatraz + + + Scripts\Outland\Tempest Keep\The Eye + + + Scripts\Outland\Tempest Keep\The Mechanar + + + Scripts\Outland\Coilfang Resevoir\Serpent Shrine Cavern + + + Scripts\Outland\Coilfang Resevoir\Steam Vault + + + Scripts\Kalimdor\Caverns of Time\The Dark Portal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Battle for Mt. Hyjal + + + Scripts\Kalimdor\Caverns of Time\Old Hillsbrad + + + Scripts\Eastern Kingdoms\Zul%27Aman + + + Scripts\Eastern Kingdoms\Magister%27s Terrace + + + Scripts\Eastern Kingdoms\Sunwell Plateau + + + Scripts\Eastern Kingdoms\Blackrock Depths + + + Include + + + Include + + + Include + + + Include + + + System + + + + Scripts\Eastern Kingdoms\Karazhan + + + Scripts\Outland\Aunchindoun\Mana Tombs + + + Include + + + Scripts\Eastern Kingdoms\Blackrock Spire + + + Scripts\Kalimdor\Zul%27Farrak + + + Scripts\special + + + Scripts\special + + + Scripts\Eastern Kingdoms\Molten Core + + + + + + \ No newline at end of file diff --git a/win/VC100/TrinityCore.vcxproj.filters b/win/VC100/TrinityCore.vcxproj.filters deleted file mode 100644 index 3f3f3f1d9..000000000 --- a/win/VC100/TrinityCore.vcxproj.filters +++ /dev/null @@ -1,31 +0,0 @@ - - - - - {c9298846-540e-4c6c-bf08-9881b7c593db} - - - - - doc - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/win/VC100/TrinityScripts.vcxproj b/win/VC100/TrinityScripts.vcxproj deleted file mode 100644 index deb3ff7a4..000000000 --- a/win/VC100/TrinityScripts.vcxproj +++ /dev/null @@ -1,914 +0,0 @@ - - - - - Debug_PCH - Win32 - - - Debug_PCH - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release_PCH - Win32 - - - Release_PCH - x64 - - - Release - Win32 - - - Release - x64 - - - - TrinityScripts - {4295C8A9-79B7-4354-8064-F05FB9CA0C96} - ScriptDev2 - Win32Proj - - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ - $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ - true - $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ - $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ - $(SolutionDir)..\bin\$(Platform)_$(Configuration)\lib\ - $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ - $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ - $(ProjectDir)$(Platform)_$(Configuration)\$(ProjectName)\ - false - false - false - ..\..\bin\$(Platform)_$(Configuration)\ - .\ScriptDev2__$(Platform)_$(Configuration)\ - true - ..\..\bin\$(Platform)_$(Configuration)\ - ..\..\bin\$(Platform)_$(Configuration)\ - ..\..\bin\$(Platform)_$(Configuration)\ - .\ScriptDev2__$(Platform)_$(Configuration)\ - .\ScriptDev2__$(Platform)_$(Configuration)\ - .\ScriptDev2__$(Platform)_$(Configuration)\ - false - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - AllRules.ruleset - AllRules.ruleset - - - - - - - AllRules.ruleset - AllRules.ruleset - AllRules.ruleset - - - - - - - trinityscript - trinityscript - trinityscript - trinityscript - - - - - - - - /MP -Zm124 %(AdditionalOptions) - Disabled - ..\..\dep\include\;..\..\src\scripts\scripts\npc;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\src\scripts\scripts\npc\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - precompiled.h - Level3 - EditAndContinue - - - trinitycore.lib;libmySQL.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - $(OutDir);..\..\dep\lib\precompiled\Debug;%(AdditionalLibraryDirectories) - true - $(OutDir)$(TargetName).pdb - Windows - false - - - $(OutDir)$(TargetName).lib - MachineX86 - true - $(OutDir)$(TargetName).map - - - if exist $(TargetPath) move $(TargetPath) $(OutDir).. - - - - - - - - - /MP -Zm113 %(AdditionalOptions) - ..\..\dep\include\;..\..\src\scripts\scripts\npc;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\src\scripts\scripts\npc\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) - false - MultiThreadedDLL - StreamingSIMDExtensions - Fast - Use - precompiled.h - Level3 - ProgramDatabase - Disabled - OnlyExplicitInline - - - trinitycore.lib;libmySQL.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) - false - Windows - true - true - false - - - $(OutDir)$(TargetName).lib - MachineX86 - $(OutDir)$(TargetName).pdb - false - $(OutDir)$(TargetName).map - - - if exist $(TargetPath) move $(TargetPath) $(OutDir).. - - - - - - - - - /MP -Zm113 %(AdditionalOptions) - ..\..\dep\include\;..\..\src\scripts\scripts\npc;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\src\scripts\scripts\npc\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) - false - MultiThreadedDLL - StreamingSIMDExtensions - Fast - Use - precompiled.h - Level3 - ProgramDatabase - Disabled - OnlyExplicitInline - true - - - trinitycore.lib;libmySQL.lib;ACE.lib;%(AdditionalDependencies) - $(TargetPath) - $(OutDir);..\..\dep\lib\precompiled\Release;%(AdditionalLibraryDirectories) - Windows - true - true - false - - - $(OutDir)$(TargetName).lib - MachineX86 - true - $(OutDir)$(TargetName).pdb - true - $(OutDir)$(TargetName).map - - - if exist $(TargetPath) move $(TargetPath) $(OutDir).. - - - - - - - - - /MP -Zm124 %(AdditionalOptions) - ..\..\dep\include\;..\..\src\scripts\scripts\npc;..\..\src\shared\;..\..\src\shared\Database;..\..\src\framework\;..\..\src\game\;..\..\src\scripts\include\;..\..\src\scripts\scripts\npc\;..\..\dep\ACE_wrappers;..\..\src\scripts\system;..\..\src\game\movemap;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;THIS_IS_SCRIPT_DLL;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - StreamingSIMDExtensions - Fast - Use - precompiled.h - Level3 - ProgramDatabase - Disabled - Default - EnableFastChecks - - - trinitycore.lib;libmySQL.lib;ACEd.lib;%(AdditionalDependencies) - $(TargetPath) - $(OutDir);..\..\dep\lib\precompiled\Debug;%(AdditionalLibraryDirectories) - Windows - true - true - false - - - $(OutDir)$(TargetName).lib - MachineX86 - true - $(OutDir)$(TargetName).pdb - true - $(OutDir)$(TargetName).map - - - if exist $(TargetPath) move $(TargetPath) $(OutDir).. - - - - - - - - - X64 - - - Disabled - ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;MANGOS_DEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - precompiled.h - Level3 - ProgramDatabase - - - trinitycore.lib;ACEd.lib;%(AdditionalDependencies) - $(OutDir)trinityscript.dll - ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\trinitycore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - true - $(OutDir)MaNGOSScript.pdb - Windows - false - - - $(OutDir)trinityscript.lib - MachineX64 - - - - - - - - - X64 - - - /MP %(AdditionalOptions) - ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) - false - MultiThreadedDLL - Use - precompiled.h - Level3 - ProgramDatabase - - - trinitycore.lib;ACE.lib;%(AdditionalDependencies) - $(OutDir)trinityscript.dll - ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\trinitycore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - false - Windows - true - true - false - - - $(OutDir)trinityscript.lib - MachineX64 - - - - - - - - - X64 - - - /MP %(AdditionalOptions) - ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) - false - MultiThreadedDLL - Use - precompiled.h - Level3 - ProgramDatabase - - - trinitycore.lib;ACE.lib;%(AdditionalDependencies) - $(OutDir)trinityscript.dll - ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\trinitycore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - false - Windows - true - true - false - - - $(OutDir)trinityscript.lib - MachineX64 - - - - - - - - - X64 - - - /MP %(AdditionalOptions) - ..\..\dep\include\;..\..\..\shared\;..\..\..\framework\;..\..\..\game\;..\include\;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPT;%(PreprocessorDefinitions) - false - MultiThreadedDLL - Use - precompiled.h - Level3 - ProgramDatabase - - - trinitycore.lib;ACE.lib;%(AdditionalDependencies) - $(OutDir)trinityscript.dll - ..\..\dep\ACE_wrappers\lib;..\..\dep\lib\$(Platform)_$(Configuration);..\..\win\VC90\zthread__$(Platform)_$(Configuration);..\..\win\VC90\trinitycore__$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - false - Windows - true - true - false - - - $(OutDir)trinityscript.lib - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {90297c34-f231-4df4-848e-a74bcc0e40ed} - - - {a3a04e47-43a2-4c08-90b3-029cef558594} - - - - - - \ No newline at end of file diff --git a/win/VC100/TrinityScripts.vcxproj.filters b/win/VC100/TrinityScripts.vcxproj.filters deleted file mode 100644 index e6d4a2566..000000000 --- a/win/VC100/TrinityScripts.vcxproj.filters +++ /dev/null @@ -1,1670 +0,0 @@ - - - - - {bdce62a4-b084-42e8-8248-f0aadc4bc0ad} - - - {8291aeef-e65d-4fb6-915a-b742d3378fb0} - - - {4c68549f-a53c-490f-be1f-250a35655312} - - - {8235419d-15a1-4d8f-ab50-017a84ad9a85} - - - {d31f4491-ffb2-4a87-8d78-db3ac8559b99} - - - {63252f50-9425-4105-8a1e-5db528d535e6} - - - {68a38bdc-a36d-4260-bdd3-8ec824974d13} - - - {834b6ee4-d375-4c82-8cc1-85600a8442c7} - - - {58128758-d72d-42cf-8c63-9fe65eb5d27f} - - - {ee0444f2-dcd5-4694-8598-285ec59a044f} - - - {6d333590-04c7-4836-85c2-72287223b658} - - - {a12f8943-6924-42a6-8c82-d603e2461b03} - - - {f4c517c6-c2d2-421c-8a11-b829f6c1575d} - - - {294af0de-427e-4d22-b26e-f813776bda94} - - - {8064c517-d276-4c34-9fdb-5640f1bef87c} - - - {e7c3a726-b4aa-4206-ab04-7652feb7b5c7} - - - {8175f2a2-5946-498e-a920-658e70b85bcf} - - - {d2f76663-d459-46f0-95cf-953d3e3b8f84} - - - {c707cb15-d2fb-460a-8cd2-835f0c62cbec} - - - {f0322b6e-1c2e-4915-8ed9-918a9fb0ef71} - - - {550e94ec-a7ba-4ee7-b1e5-9be00f5b34c4} - - - {66c1644b-b910-485d-874a-92ea30370930} - - - {8030e199-bbd2-4e63-a3ed-3c14b395252d} - - - {c699e294-8dc9-4a14-afaa-a6268288e997} - - - {683660a0-8880-41ac-a91f-52b6bbf2e6a7} - - - {85c2ffcc-a94a-4f4b-be5f-fcdfb6156295} - - - {cc3b84c9-fb8e-4c7b-863d-2e9271c4c6bf} - - - {a5ec3f98-9ff0-4fd0-8030-72d692632ee0} - - - {6c091a19-8462-4a51-afe7-a6aac6bc7b04} - - - {779d02d0-b1a6-46f2-8ffe-44f62646c81b} - - - {b19dbf1c-1f40-44ce-bf9d-b85af9c0c39a} - - - {420513ed-e626-4598-9fcf-d43fc68200f2} - - - {0a62681c-813e-4562-b667-3c623c04ebd2} - - - {d1ccae14-22bb-46dd-bef9-64fc3aa93b00} - - - {4286e9c2-ed4a-462a-8771-5fe54d52d85f} - - - {b312f48e-b7b9-4bc4-af44-76f157b25ec0} - - - {582511bf-2e74-481d-8706-ca10e1c4fe6e} - - - {1bd70d1b-1560-4344-9f46-c77d6fb735fa} - - - {1fb1cd34-1fe4-420e-8fc5-c273054ac2cf} - - - {1d8a223d-7486-4b1c-9c8d-7053214843af} - - - {252f987c-313e-4022-84c2-ea183bdd1152} - - - {7ce7c2b8-7c13-4dca-b72f-1a1beef82922} - - - {517e6c2d-8369-42ee-9f1d-3b8818a5204c} - - - {8791a214-5405-43d3-b27d-009375a4eaf5} - - - {2477b44d-b9e9-4b1f-ae75-83d17df39c18} - - - {d389dd62-d12c-4cf8-bcf3-ceb09c0cdf5b} - - - {58a0785b-c8fa-4c25-a63d-3d995deff6d8} - - - {2e95dcac-277e-4431-b3d7-192b0d0fe539} - - - {f8fc28d5-8a6d-46e9-aafb-3521e8b3c218} - - - {a7936352-0199-4739-b53a-fa50cbccf50f} - - - {b3d2dabc-1aa2-426a-84d3-67a8ce35329f} - - - {c8c3c8c5-04ca-4b50-b20a-3f072d0ead95} - - - {1687a90d-aead-4aeb-afca-1bf87011a0c0} - - - {71da00c7-3674-4ea9-bcc1-a77ae4cdb52a} - - - {b2e1354a-413b-4372-a689-8afb68b0f4ff} - - - {4ee50d8b-706a-4353-ade0-1a5ec630774a} - - - {f23a1edb-bc70-4c34-9ace-76e67944be2f} - - - {c6b0d1b7-a8ce-4762-86c8-5c624deed0c7} - - - {fe60c02b-f792-4755-b6ca-a2fb3fab6a5e} - - - {3821806f-7cf7-40ba-a03f-7f2ab8cca923} - - - {1d36f0b7-f55d-476a-b51b-9fbf49ec2bd1} - - - {2cef6d6e-8c3e-4c9e-be83-f540280d35c4} - - - {17ff95c5-2165-4b05-9472-3c5370152a14} - - - {229ac029-50e6-4c53-a941-5b6b8720e9bc} - - - {1796363d-7dc1-4f3d-aa41-226f7072e764} - - - {37a93f89-0a9b-4eff-8cab-2dd7c994ea09} - - - {45bc1015-705a-4fd4-8411-87975f1dd87f} - - - {36ede908-4c16-49c2-bafb-b549e509deec} - - - {42c2de4e-fad7-4f5d-bfc6-3d921d5a4dd7} - - - {42b3571d-4216-4c77-a9c2-6ce6acb4469a} - - - {821a5cef-b456-416f-9667-479c75a23db6} - - - {34a68648-d4e1-45a7-88f0-0583c10e5c52} - - - {0b55834d-cf32-467d-8b39-0ce5e4207d65} - - - {dbb35332-9dd6-4767-aa3b-e417a1524e58} - - - {3e41a39d-6883-4d32-ade6-7427a37e85d8} - - - {8c8d33cb-f7a1-4edb-949a-d3f028031fff} - - - {6ed26bbd-b18e-49d2-8b6f-9e814dcf37af} - - - {25e71dfd-275b-41e7-9bd7-98a3774a4c97} - - - {ae423b58-cc88-442c-bf6a-0c5b460208ff} - - - {579e7cca-2c52-4475-a774-8816bbef96c7} - - - {4e7648fc-6bba-4d2d-b14b-3c1d57810954} - - - {104c4cae-b840-4bc2-a274-78b3ed6e1c4e} - - - {15832be0-3507-4459-a2b2-44f82b1d19f8} - - - {04c08655-e9f9-40df-97a5-7749f69239ad} - - - {117f2fa5-de75-4105-9a20-e5d0907f138c} - - - {6337c580-7867-4c6e-a961-78df207f9044} - - - {f97fd9ef-1118-482b-9640-b174731dfe29} - - - {933884b1-5e5c-459a-9bce-bc3e476011ea} - - - {60a033ca-8311-4402-9332-8dd658d781a9} - - - {c01b2050-20fc-47e0-be12-30a324fe3b06} - - - {c31dd55b-9dd8-4364-b535-8d5a08eb6ceb} - - - {2a660590-e42a-4cf5-bdf9-6974c03f3206} - - - {aed4464e-69d8-4248-91f5-ce6f6035e7cb} - - - {02cc5cb7-1eb7-4c67-b92f-1634b2b2d86a} - - - {d98c4035-5824-4907-a814-028d2415da0a} - - - {a0da2eb2-6fe6-4efd-aab6-4109d179e710} - - - {7bac0f6d-b236-496c-bda2-e487bb1e4d2e} - - - {ed07c189-fb23-4151-859c-c0cfa9e978bf} - - - {bab9eac4-4f5f-401b-921a-4a1ddd3bbe07} - - - {ce5e9434-5125-4e0a-9c66-cbcc3e2f5968} - - - {7bd80ffd-2656-42db-bd90-1459d7972fb4} - - - {29db419c-6238-4cda-a65a-ca9abdb73845} - - - {93fb41ff-2f56-49bf-8b65-72eb245bf5c5} - - - {6cb0ab12-5160-46e6-8645-68242e583182} - - - {fb036523-dd02-492a-9514-b9bbd3c1079d} - - - {e21d62f9-1e24-4288-83b2-c05e78a6c01c} - - - {436b03d5-81a8-4551-bc61-04dda100d108} - - - {a9170084-1919-4c4d-aa94-88400c15424e} - - - {2400aadc-6771-4a0d-9f15-8b9b3148dd88} - - - {a36ba48a-5a93-4cc7-bf6f-86b10157369c} - - - {68dc9f67-12ed-4bbd-9b0b-c390c33b25a0} - - - {c4c64f2e-df23-4901-8b12-5775de049781} - - - {e6b96048-146f-4dc0-be6f-db2aba0cc2a3} - - - {a6ccc2c0-babf-4dbf-a814-caf21207fdcc} - - - {476d48fb-1ea2-4b75-a305-4a0a3e655a06} - - - {8bfc661a-5388-4fa9-ae04-6f8d01871fdd} - - - {89a055ed-8643-4655-994c-0adee1a4b6fc} - - - {d4e9bd8b-2d59-47fb-bb8b-44909a56c972} - - - {a6984a6e-797a-43af-a330-f17c30cd432f} - - - {32bc8fb4-7d8b-46fc-8ab2-3f5be02e7267} - - - {c8c5f86c-7fab-4e6e-afce-7bcac4dd61d1} - - - {8480df4e-134f-4310-8808-0a11837df562} - - - {f2e90fce-3bb8-4dcd-b0b8-9c10d854d5cb} - - - {ab156596-733a-4016-b276-ea604a36f34a} - - - {4dba8fe9-eb23-4f9c-b7f3-31f439f77d5f} - - - {21a5399e-94c7-43fb-8d08-c1f83d839e5e} - - - {6482406e-94df-40c4-8adc-4215c41910c8} - - - {7d5d35ab-50ab-4ccd-9492-890cdb156f83} - - - {88150fe2-8954-4943-a48a-780644c5c6a6} - - - {c9e1ec2b-62d5-4e32-93c7-9e7211682e80} - - - {8d2b5f11-d110-4fdf-8d4b-1cc831f4d1ee} - - - {482e753a-9af0-4b4c-9801-70933d6afb14} - - - - - Scripts\boss - - - Scripts\boss - - - Scripts\boss - - - Scripts\boss - - - Scripts\creature - - - Scripts\creature - - - Scripts\guard - - - Scripts\guard - - - Scripts\npc - - - Scripts\npc - - - Scripts\npc - - - Scripts\custom - - - Scripts\custom - - - Scripts\areatrigger - - - Scripts\go - - - Scripts\item - - - Scripts\item - - - Scripts\zone\Alterac Mountains - - - Scripts\zone\Ashenvale Forest - - - Scripts\zone\Alterac Valley - - - Scripts\zone\Alterac Valley - - - Scripts\zone\Alterac Valley - - - Scripts\zone\Alterac Valley - - - Scripts\zone\Azshara - - - Scripts\zone\Azshara - - - Scripts\zone\Barrens - - - Scripts\zone\Arathi Highlands - - - Scripts\zone\Deadmines - - - Scripts\zone\Desolace - - - Scripts\zone\Dun Morogh - - - Scripts\zone\Durotar - - - Scripts\zone\Duskwood - - - Scripts\zone\Dustwallow Marsh - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Blackwing Lair - - - Scripts\zone\Bloodmyst Isle - - - Scripts\zone\Gruul%27s Lair - - - Scripts\zone\Gruul%27s Lair - - - Scripts\zone\Gruul%27s Lair - - - Scripts\zone\Burning Steppes - - - Scripts\zone\Darkshore - - - Scripts\zone\Eastern Plaguelands - - - Scripts\zone\Moonglade - - - Scripts\zone\Razorfen Kraul - - - Scripts\zone\Razorfen Kraul - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Ruins of Ahn%27Qiraj - - - Scripts\zone\Swamp of Sorrows - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Scholomance - - - Scripts\zone\Searing Gorge - - - Scripts\zone\Elwynn Forest - - - Scripts\zone\Felwood - - - Scripts\zone\Feralas - - - Scripts\zone\Maraudon - - - Scripts\zone\Maraudon - - - Scripts\zone\Maraudon - - - Scripts\zone\Maraudon - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Molten Core - - - Scripts\zone\Mulgore - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Naxxramas - - - Scripts\zone\Onyxia%27s Lair - - - Scripts\zone\Onyxia%27s Lair - - - Scripts\zone\Razorfen Downs - - - Scripts\zone\Razorfen Downs - - - Scripts\zone\Razorfen Downs - - - Scripts\zone\Shadowfang Keep - - - Scripts\zone\Shadowfang Keep - - - Scripts\zone\Stonetalon Mountains - - - Scripts\zone\Stranglethorn Vale - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Stratholme - - - Scripts\zone\Tanaris - - - Scripts\zone\Teldrassil - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Thousand Needles - - - Scripts\zone\Silithus - - - Scripts\zone\Silverpine Forest - - - Scripts\zone\Tirisfal Glades - - - Scripts\zone\Wailing Caverns - - - Scripts\zone\Wailing Caverns - - - Scripts\zone\Western Plaguelands - - - Scripts\zone\Westfall - - - Scripts\zone\Wetlands - - - Scripts\zone\Winterspring - - - Scripts\zone\Zul%27Farrak - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Uldaman - - - Scripts\zone\Uldaman - - - Scripts\zone\Uldaman - - - Scripts\zone\Uldaman - - - Scripts\zone\Un%27Goro Crater - - - Scripts\zone\Aunchindoun\Auchenai Crypts - - - Scripts\zone\Aunchindoun\Auchenai Crypts - - - Scripts\zone\Aunchindoun\Mana Tombs - - - Scripts\zone\Aunchindoun\Mana Tombs - - - Scripts\zone\Aunchindoun\Mana Tombs - - - Scripts\zone\Aunchindoun\Sethekk Halls - - - Scripts\zone\Aunchindoun\Sethekk Halls - - - Scripts\zone\Aunchindoun\Sethekk Halls - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Azuremyst Isle - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Black Temple - - - Scripts\zone\Eversong Woods - - - Scripts\zone\Ghostlands - - - Scripts\zone\Blade%27s Edge Mountains - - - Scripts\zone\Blasted Lands - - - Scripts\zone\Blasted Lands - - - Scripts\zone\Hellfire Citadel\Blood Furnace - - - Scripts\zone\Hellfire Citadel\Blood Furnace - - - Scripts\zone\Hellfire Citadel\Blood Furnace - - - Scripts\zone\Hellfire Citadel\Blood Furnace - - - Scripts\zone\Hellfire Citadel\Magtheridon%27s lair - - - Scripts\zone\Hellfire Citadel\Magtheridon%27s lair - - - Scripts\zone\Hellfire Citadel\Hellfire Ramparts - - - Scripts\zone\Hellfire Citadel\Hellfire Ramparts - - - Scripts\zone\Hellfire Citadel\Hellfire Ramparts - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Hellfire Peninsula - - - Scripts\zone\Hellfire Peninsula - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Karazhan - - - Scripts\zone\Nagrand - - - Scripts\zone\Netherstorm - - - Scripts\zone\Shadowmoon Valley - - - Scripts\zone\Shadowmoon Valley - - - Scripts\zone\Tempest Keep\Arcatraz - - - Scripts\zone\Tempest Keep\Arcatraz - - - Scripts\zone\Tempest Keep\Arcatraz - - - Scripts\zone\Tempest Keep\Botanica - - - Scripts\zone\Tempest Keep\Botanica - - - Scripts\zone\Tempest Keep\Botanica - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Terokkar Forest - - - Scripts\zone\Zangarmarsh - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Blackrock Spire - - - Scripts\zone\Stormwind City - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Slave Pens - - - Scripts\zone\Coilfang Resevoir\Slave Pens - - - Scripts\zone\Coilfang Resevoir\Slave Pens - - - Scripts\zone\Coilfang Resevoir\Steam Vault - - - Scripts\zone\Coilfang Resevoir\Steam Vault - - - Scripts\zone\Coilfang Resevoir\Steam Vault - - - Scripts\zone\Coilfang Resevoir\Steam Vault - - - Scripts\zone\Coilfang Resevoir\Underbog - - - Scripts\zone\Coilfang Resevoir\Underbog - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Silvermoon City - - - Scripts\zone\Iron Forge - - - Scripts\zone\Orgrimmar - - - Scripts\zone\Shattrath City - - - Scripts\zone\Thunder Bluff - - - Scripts\zone\Undercity - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Isle of Quel%27Danas - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Loch Modan - - - Scripts\zone\Hinterlands - - - Include - - - Include - - - System - - - System - - - - Scripts\zone\Karazhan - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Aunchindoun\Sethekk Halls - - - Scripts\zone\Aunchindoun\Mana Tombs - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Blackrock Depths - - - Scripts\zone\Blackrock Depths - - - Include - - - Include - - - Scripts\spells - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Karazhan - - - - - Scripts\creature - - - Scripts\guard - - - Scripts\zone\Deadmines - - - Scripts\zone\Gruul%27s Lair - - - Scripts\zone\Razorfen Kraul - - - Scripts\zone\Scarlet Monastery - - - Scripts\zone\Scholomance - - - Scripts\zone\Molten Core - - - Scripts\zone\Onyxia%27s Lair - - - Scripts\zone\Razorfen Downs - - - Scripts\zone\Shadowfang Keep - - - Scripts\zone\Stratholme - - - Scripts\zone\Temple of Ahn%27Qiraj - - - Scripts\zone\Wailing Caverns - - - Scripts\zone\Zul%27Gurub - - - Scripts\zone\Aunchindoun\Sethekk Halls - - - Scripts\zone\Aunchindoun\Shadow Labyrinth - - - Scripts\zone\Black Temple - - - Scripts\zone\Hellfire Citadel\Blood Furnace - - - Scripts\zone\Hellfire Citadel\Magtheridon%27s lair - - - Scripts\zone\Hellfire Citadel\Shattered Halls - - - Scripts\zone\Karazhan - - - Scripts\zone\Tempest Keep\Arcatraz - - - Scripts\zone\Tempest Keep\The Eye - - - Scripts\zone\Tempest Keep\The Mechanar - - - Scripts\zone\Coilfang Resevoir\Serpent Shrine Cavern - - - Scripts\zone\Coilfang Resevoir\Steam Vault - - - Scripts\zone\Caverns of Time\The Dark Portal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Battle for Mt. Hyjal - - - Scripts\zone\Caverns of Time\Old Hillsbrad - - - Scripts\zone\Zul%27Aman - - - Scripts\zone\Magister%27s Terrace - - - Scripts\zone\Sunwell Plateau - - - Scripts\zone\Blackrock Depths - - - Include - - - Include - - - Include - - - Include - - - System - - - - Scripts\zone\Karazhan - - - Scripts\zone\Aunchindoun\Mana Tombs - - - Include - - - - - - \ No newline at end of file diff --git a/win/VC100/framework.vcxproj b/win/VC100/framework.vcxproj index 9e4756b3a..1b543a117 100644 --- a/win/VC100/framework.vcxproj +++ b/win/VC100/framework.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -44,41 +44,49 @@ StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 StaticLibrary MultiByte false + v120 @@ -279,7 +287,7 @@ /Zl /MP %(AdditionalOptions) Disabled ..\..\src\framework;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;TRINITY_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;HELLGROUND_DEBUG;_LIB;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL diff --git a/win/VC100/game.vcxproj b/win/VC100/game.vcxproj index 9ad4e7caa..7978e8adf 100644 --- a/win/VC100/game.vcxproj +++ b/win/VC100/game.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -43,41 +43,49 @@ StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 @@ -162,7 +170,7 @@ /MP %(AdditionalOptions) Disabled - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;..\..\dep\lualib;..\src\game\luaengine;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) false false @@ -198,7 +206,7 @@ OnlyExplicitInline - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;..\..\dep\lualib;..\src\game\luaengine;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -236,7 +244,7 @@ OnlyExplicitInline - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;..\..\dep\lualib;..\src\game\luaengine;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true MultiThreadedDLL @@ -276,7 +284,7 @@ Default - ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;%(AdditionalIncludeDirectories) + ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\Database;..\..\src\game\movemap;..\..\src\game\vmap;..\..\dep\ACE_wrappers;..\..\src\game\;..\..\dep\g3dlite\include;..\..\dep\lualib;..\src\game\luaengine;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true MultiThreadedDebugDLL @@ -322,7 +330,7 @@ /MP /openmp %(AdditionalOptions) Disabled ..\..\dep\include;..\..\src\framework;..\..\src\shared;..\..\src\shared\vmap;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;TRINITY_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;HELLGROUND_DEBUG;_LIB;%(PreprocessorDefinitions) false false EnableFastChecks @@ -471,6 +479,10 @@ + + + + @@ -500,6 +512,7 @@ + @@ -525,7 +538,6 @@ - @@ -537,7 +549,7 @@ - + @@ -644,10 +656,33 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -679,6 +714,7 @@ + @@ -713,7 +749,6 @@ - @@ -723,7 +758,7 @@ - + @@ -805,6 +840,14 @@ + + {ee2d5a7d-2e9b-43f0-a016-66c46d01ac6b} + true + true + false + true + false + {90297c34-f231-4df4-848e-a74bcc0e40ed} false diff --git a/win/VC100/game.vcxproj.filters b/win/VC100/game.vcxproj.filters index 630389a8e..ad3d8fd84 100644 --- a/win/VC100/game.vcxproj.filters +++ b/win/VC100/game.vcxproj.filters @@ -67,6 +67,9 @@ {a57f8b6e-9cc3-40b0-8a37-cb2b721813dd} + + {ad85c0ec-51eb-4bf8-895e-3683faecc9ff} + @@ -150,9 +153,6 @@ Server - - Server - Server @@ -186,7 +186,7 @@ References - + References @@ -567,6 +567,21 @@ Maps/Grids + + Warden + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + Managers + @@ -668,9 +683,6 @@ Server - - Server - Server @@ -698,7 +710,7 @@ References - + References @@ -1076,5 +1088,77 @@ Maps/Grids + + Warden + + + Movement + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + LuaEngine + + + Managers + \ No newline at end of file diff --git a/win/VC100/genrevision.vcxproj b/win/VC100/genrevision.vcxproj index 32c4bf22b..c173101b5 100644 --- a/win/VC100/genrevision.vcxproj +++ b/win/VC100/genrevision.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -44,39 +44,47 @@ Application Unicode true + v120 Application Unicode true + v120 Application Unicode true + v120 Application Unicode + v120 Application Unicode true + v120 Application Unicode true + v120 Application Unicode true + v120 Application Unicode + v120 diff --git a/win/VC100/lualib.vcxproj b/win/VC100/lualib.vcxproj new file mode 100644 index 000000000..51eefce2a --- /dev/null +++ b/win/VC100/lualib.vcxproj @@ -0,0 +1,205 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {EE2D5A7D-2E9B-43F0-A016-66C46D01AC6B} + lualib + + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + + + + + + + + + + + + + + + + + .\lualib__$(Platform)_$(Configuration)\ + .\lualib__$(Platform)_$(Configuration)\ + lualib + .lib + + + .\lualib__$(Platform)_$(Configuration)\ + .\lualib__$(Platform)_$(Configuration)\ + lualib + .lib + + + .\lualib__$(Platform)_$(Configuration)\ + .\lualib__$(Platform)_$(Configuration)\ + lualib + .lib + + + .\lualib__$(Platform)_$(Configuration)\ + .\lualib__$(Platform)_$(Configuration)\ + lualib + .lib + + + + Level3 + Disabled + false + + + true + + + + + Level3 + Disabled + false + + + true + + + + + Level3 + MaxSpeed + true + true + false + false + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + false + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/win/VC100/lualib.vcxproj.filters b/win/VC100/lualib.vcxproj.filters new file mode 100644 index 000000000..9ab366173 --- /dev/null +++ b/win/VC100/lualib.vcxproj.filters @@ -0,0 +1,188 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/win/VC100/shared.vcxproj b/win/VC100/shared.vcxproj index 89d972f15..5dba654bf 100644 --- a/win/VC100/shared.vcxproj +++ b/win/VC100/shared.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -43,41 +43,49 @@ StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 StaticLibrary false MultiByte + v120 @@ -448,7 +456,7 @@ /MP /openmp %(AdditionalOptions) Disabled ..\..\dep\include;..\..\dep\include\g3dlite;..\..\src\framework;..\..\src\shared;..\..\dep\ACE_wrappers;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;TRINITY_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + WIN32;_DEBUG;HELLGROUND_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL true @@ -537,8 +545,8 @@ $(SolutionDir)../.hg/branch.cache;%(AdditionalInputs) revision.h;%(Outputs) Getting Version... :) - cd %(RootDir)%(Directory) -"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." + cd %(RootDir)%(Directory) +"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." $(SolutionDir)../.hg/branch.cache;%(AdditionalInputs) revision.h;%(Outputs) @@ -560,14 +568,14 @@ Getting Version... :) Getting Version... :) Getting Version... :) - cd %(RootDir)%(Directory) -"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." + cd %(RootDir)%(Directory) +"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." - cd %(RootDir)%(Directory) -"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." + cd %(RootDir)%(Directory) +"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." - cd %(RootDir)%(Directory) -"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." + cd %(RootDir)%(Directory) +"$(ProjectDir)$(Platform)_$(Configuration)\genrevision\genrevision.exe" "..\.." $(SolutionDir)../.hg/branch.cache;%(AdditionalInputs) $(SolutionDir)../.hg/branch.cache;%(AdditionalInputs) diff --git a/win/VC100/zlib.vcxproj b/win/VC100/zlib.vcxproj index 6cccbd2c2..aaadb29a1 100644 --- a/win/VC100/zlib.vcxproj +++ b/win/VC100/zlib.vcxproj @@ -1,5 +1,5 @@  - + Debug_PCH @@ -41,34 +41,42 @@ StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120 StaticLibrary MultiByte + v120