From d9ff37d78df1ef34d5a3d73d5f781debf3839e76 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sun, 14 Sep 2014 00:32:25 +0300 Subject: [PATCH] Eluna: Add cod and money to sendmail, add missing spawn types for mangos and tc for SpawnCreature --- CreatureMethods.h | 25 +++++++++++++++++++++++++ GlobalMethods.h | 14 ++++++++++++++ LuaFunctions.cpp | 3 ++- WorldObjectMethods.h | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/CreatureMethods.h b/CreatureMethods.h index 6430178..e90e62d 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -605,6 +605,31 @@ namespace LuaCreature return 4; } + /** + * Sets the position the [Creature] returns to when evading from combat + * or respawning. + * + * @param float x + * @param float y + * @param float z + * @param float o + */ + int SetHomePosition(lua_State* L, Creature* creature) + { + float x = Eluna::CHECKVAL(L, 2); + float y = Eluna::CHECKVAL(L, 3); + float z = Eluna::CHECKVAL(L, 4); + float o = Eluna::CHECKVAL(L, 5); + +#ifndef TRINITY + creature->SetRespawnCoord(x, y, z, o); +#else + creature->SetHomePosition(x, y, z, o); +#endif + + return 0; + } + /** * Returns a target from the [Creature]'s threat list based on the * supplied arguments. diff --git a/GlobalMethods.h b/GlobalMethods.h index 087e837..d15b831 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -1230,11 +1230,25 @@ namespace LuaGlobalFunctions uint32 senderGUIDLow = Eluna::CHECKVAL(L, ++i, 0); uint32 stationary = Eluna::CHECKVAL(L, ++i, MAIL_STATIONERY_DEFAULT); uint32 delay = Eluna::CHECKVAL(L, ++i, 0); + uint32 money = Eluna::CHECKVAL(L, ++i, 0); + uint32 cod = Eluna::CHECKVAL(L, ++i, 0); int argAmount = lua_gettop(L); MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary); MailDraft draft(subject, text); +#ifdef TRINITY + if (cod) + draft.AddCOD(cod); + if (money) + draft.AddMoney(money); +#else + if (cod) + draft.SetCOD(cod); + if (money) + draft.SetMoney(money); +#endif + #ifdef TRINITY SQLTransaction trans = CharacterDatabase.BeginTransaction(); #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 293f90a..ae2927d 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -106,7 +106,7 @@ void RegisterGlobals(lua_State* L) 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), whoBanned(string)]) - Banmode: 0 account, 1 character, 2 IP lua_register(L, "SaveAllPlayers", &LuaGlobalFunctions::SaveAllPlayers); // SaveAllPlayers() - Saves all players - lua_register(L, "SendMail", &LuaGlobalFunctions::SendMail); // SendMail(subject, text, receiverLowGUID[, senderLowGUID, stationary, delay, itemEntry, itemAmount, itemEntry2, itemAmount2...]) - Sends a mail to player with lowguid. use nil to use default values on optional arguments. UNDOCUMENTED + lua_register(L, "SendMail", &LuaGlobalFunctions::SendMail); // SendMail(subject, text, receiverLowGUID[, senderLowGUID, stationary, delay, money, cod, itemEntry, itemAmount, itemEntry2, itemAmount2...]) - Sends a mail to player with lowguid. use nil to use default values on optional arguments. UNDOCUMENTED lua_register(L, "AddTaxiPath", &LuaGlobalFunctions::AddTaxiPath); // AddTaxiPath(pathTable, mountA, mountH[, price, pathId]) - Adds a new taxi path. Returns the path's ID. Will replace an existing path if pathId provided and already used. mountIDs are NPC entries. path table structure: T = {{map, x, y, z[, actionFlag, delay, arrivalEvId, departEvId]}, {...}, ...} 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. @@ -753,6 +753,7 @@ ElunaRegister CreatureMethods[] = { "SetNPCFlags", &LuaCreature::SetNPCFlags }, { "SetDeathState", &LuaCreature::SetDeathState }, { "SetWalk", &LuaCreature::SetWalk }, + { "SetHomePosition", &LuaCreature::SetHomePosition }, // Booleans { "IsWorldBoss", &LuaCreature::IsWorldBoss }, diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index 94c91d1..99a3e5e 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -613,6 +613,13 @@ namespace LuaWorldObject case 3: type = TEMPSUMMON_TIMED_DESPAWN; break; + case 4: +#ifdef TRINITY + type = TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT; +#else + type = TEMPSUMMON_TIMED_OOC_DESPAWN; +#endif + break; case 5: type = TEMPSUMMON_CORPSE_DESPAWN; break; @@ -625,6 +632,14 @@ namespace LuaWorldObject case 8: type = TEMPSUMMON_MANUAL_DESPAWN; break; +#ifndef TRINITY + case 9: + type = TEMPSUMMON_TIMED_OOC_OR_CORPSE_DESPAWN; + break; + case 10: + type = TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN; + break; +#endif default: return luaL_argerror(L, 7, "valid SpawnType expected"); }