Eluna: Add cod and money to sendmail, add missing spawn types for mangos and tc for SpawnCreature

This commit is contained in:
Rochet2
2014-09-14 00:32:25 +03:00
parent 9add43bf2a
commit d9ff37d78d
4 changed files with 56 additions and 1 deletions

View File

@@ -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<float>(L, 2);
float y = Eluna::CHECKVAL<float>(L, 3);
float z = Eluna::CHECKVAL<float>(L, 4);
float o = Eluna::CHECKVAL<float>(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.

View File

@@ -1230,11 +1230,25 @@ namespace LuaGlobalFunctions
uint32 senderGUIDLow = Eluna::CHECKVAL<uint32>(L, ++i, 0);
uint32 stationary = Eluna::CHECKVAL<uint32>(L, ++i, MAIL_STATIONERY_DEFAULT);
uint32 delay = Eluna::CHECKVAL<uint32>(L, ++i, 0);
uint32 money = Eluna::CHECKVAL<uint32>(L, ++i, 0);
uint32 cod = Eluna::CHECKVAL<uint32>(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

View File

@@ -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<Creature> CreatureMethods[] =
{ "SetNPCFlags", &LuaCreature::SetNPCFlags },
{ "SetDeathState", &LuaCreature::SetDeathState },
{ "SetWalk", &LuaCreature::SetWalk },
{ "SetHomePosition", &LuaCreature::SetHomePosition },
// Booleans
{ "IsWorldBoss", &LuaCreature::IsWorldBoss },

View File

@@ -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");
}