(L, 2);
player->GiveLevel(level);
return 0;
}
int GetChatTag(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetChatTag());
return 1;
}
/**
* Returns an item in given bag on given slot.
*
*
* Possible and most commonly used combinations:
*
* bag = 255
* slots 0-18 equipment
* slots 19-22 equipped bag slots
* slots 23-38 backpack
* slots 39-66 bank main slots
* slots 67-74 bank bag slots
* slots 86-117 keyring
*
* bag = 19-22
* slots 0-35 for equipped bags
*
* bag = 67-74
* slots 0-35 for bank bags
*
*
* @param uint8 bag : the bag the [Item] is in, you can get this with [Item:GetBagSlot]
* @param uint8 slot : the slot the [Item] is in within the bag, you can get this with [Item:GetSlot]
* @return [Item] item : [Item] or nil
*/
int GetItemByPos(lua_State* L, Player* player)
{
uint8 bag = Eluna::CHECKVAL(L, 2);
uint8 slot = Eluna::CHECKVAL(L, 3);
Eluna::Push(L, player->GetItemByPos(bag, slot));
return 1;
}
int GetGossipTextId(lua_State* L, Player* player)
{
WorldObject* obj = Eluna::CHECKOBJ(L, 2);
Eluna::Push(L, player->GetGossipTextId(obj));
return 1;
}
int GetSelection(lua_State* L, Player* player)
{
#ifndef TRINITY
Eluna::Push(L, player->GetMap()->GetUnit(player->GetSelectionGuid()));
#else
Eluna::Push(L, player->GetSelectedUnit());
#endif
return 1;
}
int GetGMRank(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetSecurity());
return 1;
}
int GetCoinage(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetMoney());
return 1;
}
int GetGuildId(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetGuildId());
return 1;
}
int GetTeam(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetTeamId());
return 1;
}
int GetItemCount(lua_State* L, Player* player)
{
int id = Eluna::CHECKVAL(L, 2);
bool checkinBank = Eluna::CHECKVAL(L, 3, false);
Eluna::Push(L, player->GetItemCount(id, checkinBank));
return 1;
}
int GetLifetimeKills(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
return 1;
}
int GetPlayerIP(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetRemoteAddress());
return 1;
}
int GetLevelPlayedTime(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetLevelPlayedTime());
return 1;
}
int GetTotalPlayedTime(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetTotalPlayedTime());
return 1;
}
int GetGuild(lua_State* L, Player* player)
{
Eluna::Push(L, eGuildMgr->GetGuildById(player->GetGuildId()));
return 1;
}
int GetGroup(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetGroup());
return 1;
}
int GetAccountId(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetAccountId());
return 1;
}
int GetAccountName(lua_State* L, Player* player)
{
std::string accName;
if (eAccountMgr->GetName(player->GetSession()->GetAccountId(), accName))
Eluna::Push(L, accName);
return 1;
}
int GetCorpse(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetCorpse());
return 1;
}
int GetDbLocaleIndex(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetSessionDbLocaleIndex());
return 1;
}
int GetDbcLocale(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetSessionDbcLocale());
return 1;
}
/*int GetRecruiterId(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSession()->GetRecruiterId());
return 1;
}*/
/*int GetSelectedPlayer(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSelectedPlayer());
return 1;
}*/
/*int GetSelectedUnit(lua_State* L, Player* player)
{
Eluna::Push(L, player->GetSelectedUnit());
return 1;
}*/
/*int GetNearbyGameObject(lua_State* L, Player* player)
{
Eluna::Push(L, ChatHandler(player->GetSession()).GetNearbyGameObject());
return 1;
}*/
/* SETTERS */
int SetPlayerLock(lua_State* L, Player* player)
{
bool apply = Eluna::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 SetAtLoginFlag(lua_State* L, Player* player)
{
uint32 flag = Eluna::CHECKVAL(L, 2);
player->SetAtLoginFlag((AtLoginFlags)flag);
return 0;
}
int SetSheath(lua_State* L, Player* player)
{
uint32 sheathed = Eluna::CHECKVAL(L, 2);
if (sheathed >= MAX_SHEATH_STATE)
return 0;
player->SetSheath((SheathState)sheathed);
return 0;
}
int SetRestTime(lua_State* L, Player* player)
{
uint32 value = Eluna::CHECKVAL(L, 2);
player->SetRestTime(value);
return 0;
}
int SetDrunkValue(lua_State* L, Player* player)
{
uint8 newDrunkValue = Eluna::CHECKVAL(L, 2);
player->SetDrunkValue(newDrunkValue);
return 0;
}
int SetFactionForRace(lua_State* L, Player* player)
{
uint8 race = Eluna::CHECKVAL(L, 2);
player->setFactionForRace(race);
return 0;
}
int SetSkill(lua_State* L, Player* player)
{
uint16 id = Eluna::CHECKVAL(L, 2);
uint16 step = Eluna::CHECKVAL(L, 3);
uint16 currVal = Eluna::CHECKVAL(L, 4);
uint16 maxVal = Eluna::CHECKVAL(L, 5);
player->SetSkill(id, step, currVal, maxVal);
return 0;
}
int SetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods
{
uint8 rank = Eluna::CHECKVAL(L, 2);
if (!player->GetGuildId())
return 0;
player->SetRank(rank);
return 0;
}
int SetFreeTalentPoints(lua_State* L, Player* player)
{
uint32 points = Eluna::CHECKVAL(L, 2);
player->SetFreeTalentPoints(points);
#if (!defined(TBC) && !defined(CLASSIC))
player->SendTalentsInfoData(false);
#endif
return 0;
}
int SetReputation(lua_State* L, Player* player)
{
uint32 faction = Eluna::CHECKVAL(L, 2);
int32 value = Eluna::CHECKVAL(L, 3);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
player->GetReputationMgr().SetReputation(factionEntry, value);
return 0;
}
int SetQuestStatus(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
uint32 status = Eluna::CHECKVAL(L, 3);
if (status >= MAX_QUEST_STATUS)
return 0;
player->SetQuestStatus(entry, (QuestStatus)status);
return 0;
}
int SetRestType(lua_State* L, Player* player)
{
int type = Eluna::CHECKVAL(L, 2);
player->SetRestType((RestType)type);
return 0;
}
int SetRestBonus(lua_State* L, Player* player)
{
float bonus = Eluna::CHECKVAL(L, 2);
player->SetRestBonus(bonus);
return 0;
}
int SetAcceptWhispers(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetAcceptWhispers(on);
return 0;
}
int SetPvPDeath(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetPvPDeath(on);
return 0;
}
int SetGMVisible(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetGMVisible(on);
return 0;
}
int SetTaxiCheat(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetTaxiCheater(on);
return 0;
}
int SetGMChat(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetGMChat(on);
return 0;
}
int SetGameMaster(lua_State* L, Player* player)
{
bool on = Eluna::CHECKVAL(L, 2, true);
player->SetGameMaster(on);
return 0;
}
int SetGender(lua_State* L, Player* player)
{
uint32 _gender = Eluna::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);
player->InitDisplayIds();
return 0;
}
#ifndef CATA
#ifndef CLASSIC
int SetArenaPoints(lua_State* L, Player* player)
{
uint32 arenaP = Eluna::CHECKVAL(L, 2);
player->SetArenaPoints(arenaP);
return 0;
}
int SetHonorPoints(lua_State* L, Player* player)
{
uint32 honorP = Eluna::CHECKVAL(L, 2);
player->SetHonorPoints(honorP);
return 0;
}
#endif
#endif
#ifdef CLASSIC
int SetHonorStoredKills(lua_State* L, Player* player)
{
uint32 kills = Eluna::CHECKVAL(L, 2);
bool honorable = Eluna::CHECKVAL(L, 3, true);
player->SetHonorStoredKills(kills, honorable);
return 0;
}
int SetRankPoints(lua_State* L, Player* player)
{
float rankPoints = Eluna::CHECKVAL(L, 2);
player->SetRankPoints(rankPoints);
return 0;
}
int SetHonorLastWeekStandingPos(lua_State* L, Player* player)
{
int32 standingPos = Eluna::CHECKVAL(L, 2);
player->SetHonorLastWeekStandingPos(standingPos);
return 0;
}
#endif
int SetLifetimeKills(lua_State* L, Player* player)
{
uint32 val = Eluna::CHECKVAL(L, 2);
player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, val);
return 0;
}
int SetCoinage(lua_State* L, Player* player)
{
uint32 amt = Eluna::CHECKVAL(L, 2);
player->SetMoney(amt);
return 0;
}
int SetBindPoint(lua_State* L, Player* player)
{
float x = Eluna::CHECKVAL(L, 2);
float y = Eluna::CHECKVAL(L, 3);
float z = Eluna::CHECKVAL(L, 4);
uint32 mapId = Eluna::CHECKVAL(L, 5);
uint32 areaId = Eluna::CHECKVAL(L, 6);
WorldLocation loc(mapId, x, y, z);
#ifndef TRINITY
player->SetHomebindToLocation(loc, areaId);
#else
player->SetHomebind(loc, areaId);
#endif
return 0;
}
#ifndef CLASSIC
int SetKnownTitle(lua_State* L, Player* player)
{
uint32 id = Eluna::CHECKVAL(L, 2);
CharTitlesEntry const* t = sCharTitlesStore.LookupEntry(id);
if (t)
player->SetTitle(t, false);
return 0;
}
#endif
#ifndef TRINITY
int SetFFA(lua_State* L, Player* player)
{
bool apply = Eluna::CHECKVAL(L, 2, true);
player->SetFFAPvP(apply);
return 0;
}
#endif
/*int SetMovement(lua_State* L, Player* player)
{
int32 pType = Eluna::CHECKVAL(L, 2);
player->SetMovement((PlayerMovementType)pType);
return 0;
}*/
/* OTHER */
#if (!defined(TBC) && !defined(CLASSIC))
int ResetPetTalents(lua_State* /*L*/, Player* player)
{
#ifndef TRINITY
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)
{
#ifndef TRINITY
player->GetAchievementMgr().Reset();
#else
player->ResetAchievements();
#endif
return 0;
}
#endif
int SendShowMailBox(lua_State* L, Player* player)
{
uint64 guid = Eluna::CHECKVAL(L, 2, player->GET_GUID());
#if (defined(CLASSIC) || defined(TBC))
WorldPacket data(CMSG_GET_MAIL_LIST, 8);
data << uint64(guid);
player->GetSession()->HandleGetMailList(data);
#else
player->GetSession()->SendShowMailBox(ObjectGuid(guid));
#endif
return 0;
}
#ifndef CATA
#ifndef CLASSIC
int ModifyArenaPoints(lua_State* L, Player* player)
{
int32 amount = Eluna::CHECKVAL(L, 2);
player->ModifyArenaPoints(amount);
return 0;
}
int ModifyHonorPoints(lua_State* L, Player* player)
{
int32 amount = Eluna::CHECKVAL(L, 2);
player->ModifyHonorPoints(amount);
return 0;
}
#endif
#endif
int SaveToDB(lua_State* /*L*/, Player* player)
{
player->SaveToDB();
return 0;
}
int SummonPlayer(lua_State* L, Player* player)
{
Player* target = Eluna::CHECKOBJ(L, 2);
uint32 map = Eluna::CHECKVAL(L, 3);
float x = Eluna::CHECKVAL(L, 4);
float y = Eluna::CHECKVAL(L, 5);
float z = Eluna::CHECKVAL(L, 6);
float zoneId = Eluna::CHECKVAL(L, 7);
uint32 delay = Eluna::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_MILLISECONDS : MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS);
target->GetSession()->SendPacket(&data);
return 0;
}
int Mute(lua_State* L, Player* player)
{
uint32 muteseconds = Eluna::CHECKVAL(L, 2);
/*const char* reason = luaL_checkstring(L, 2);*/ // Mangos does not have a reason field in database.
uint64 muteTime = time(NULL) + muteseconds;
player->GetSession()->m_muteTime = muteTime;
LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'", muteTime, player->GetSession()->GetAccountId());
return 0;
}
int CreateCorpse(lua_State* /*L*/, Player* player)
{
player->CreateCorpse();
return 0;
}
int RewardQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
Quest const* quest = eObjectMgr->GetQuestTemplate(entry);
if (quest)
player->RewardQuest(quest, 0, player);
return 0;
}
int SendAuctionMenu(lua_State* L, Player* player)
{
Unit* unit = Eluna::CHECKOBJ(L, 2);
#ifndef TRINITY
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
#else
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
#endif
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 = Eluna::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 = Eluna::CHECKOBJ(L, 2);
player->GetSession()->SendTabardVendorActivate(obj->GET_GUID());
return 0;
}
int SendShowBank(lua_State* L, Player* player)
{
WorldObject* obj = Eluna::CHECKOBJ(L, 2);
player->GetSession()->SendShowBank(obj->GET_GUID());
return 0;
}
int SendListInventory(lua_State* L, Player* player)
{
WorldObject* obj = Eluna::CHECKOBJ(L, 2);
player->GetSession()->SendListInventory(obj->GET_GUID());
return 0;
}
int SendTrainerList(lua_State* L, Player* player)
{
WorldObject* obj = Eluna::CHECKOBJ(L, 2);
player->GetSession()->SendTrainerList(obj->GET_GUID());
return 0;
}
int SendGuildInvite(lua_State* L, Player* player)
{
Player* plr = Eluna::CHECKOBJ(L, 2);
#ifndef TRINITY
player->GetSession()->SendGuildInvite(plr);
#else
if (Guild* guild = player->GetGuild())
guild->HandleInviteMember(player->GetSession(), plr->GetName());
#endif
return 0;
}
int LogoutPlayer(lua_State* L, Player* player)
{
bool save = Eluna::CHECKVAL(L, 2, true);
player->GetSession()->LogoutPlayer(save);
return 0;
}
int RemoveFromBattlegroundRaid(lua_State* /*L*/, Player* player)
{
#ifndef TRINITY
player->RemoveFromBattleGroundRaid();
#else
player->RemoveFromBattlegroundOrBattlefieldRaid();
#endif
return 0;
}
int UnbindInstance(lua_State* L, Player* player)
{
uint32 map = Eluna::CHECKVAL(L, 2);
#ifndef CLASSIC
uint32 difficulty = Eluna::CHECKVAL(L, 3);
if (difficulty < MAX_DIFFICULTY)
player->UnbindInstance(map, (Difficulty)difficulty);
#else
player->UnbindInstance(map);
#endif
return 0;
}
int LeaveBattleground(lua_State* L, Player* player)
{
bool teleToEntryPoint = Eluna::CHECKVAL(L, 2, true);
player->LeaveBattleground(teleToEntryPoint);
return 0;
}
int DurabilityRepair(lua_State* L, Player* player)
{
uint16 position = Eluna::CHECKVAL(L, 2);
bool cost = Eluna::CHECKVAL(L, 3, true);
float discountMod = Eluna::CHECKVAL(L, 4);
bool guildBank = Eluna::CHECKVAL(L, 5, false);
#ifdef CLASSIC
Eluna::Push(L, player->DurabilityRepair(position, cost, discountMod));
#else
Eluna::Push(L, player->DurabilityRepair(position, cost, discountMod, guildBank));
#endif
return 1;
}
int DurabilityRepairAll(lua_State* L, Player* player)
{
bool cost = Eluna::CHECKVAL(L, 2, true);
float discountMod = Eluna::CHECKVAL(L, 3);
bool guildBank = Eluna::CHECKVAL(L, 4, false);
#ifdef CLASSIC
Eluna::Push(L, player->DurabilityRepairAll(cost, discountMod));
#else
Eluna::Push(L, player->DurabilityRepairAll(cost, discountMod, guildBank));
#endif
return 1;
}
int DurabilityPointLossForEquipSlot(lua_State* L, Player* player)
{
int32 slot = Eluna::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 = Eluna::CHECKVAL(L, 2);
bool inventory = Eluna::CHECKVAL(L, 3, true);
player->DurabilityPointsLossAll(points, inventory);
return 0;
}
int DurabilityPointsLoss(lua_State* L, Player* player)
{
Item* item = Eluna::CHECKOBJ- (L, 2);
int32 points = Eluna::CHECKVAL(L, 3);
player->DurabilityPointsLoss(item, points);
return 0;
}
int DurabilityLoss(lua_State* L, Player* player)
{
Item* item = Eluna::CHECKOBJ
- (L, 2);
double percent = Eluna::CHECKVAL(L, 3);
player->DurabilityLoss(item, percent);
return 0;
}
int DurabilityLossAll(lua_State* L, Player* player)
{
double percent = Eluna::CHECKVAL(L, 2);
bool inventory = Eluna::CHECKVAL(L, 3, true);
player->DurabilityLossAll(percent, inventory);
return 0;
}
int KillPlayer(lua_State* /*L*/, Player* player)
{
player->KillPlayer();
return 0;
}
int RemoveFromGroup(lua_State* /*L*/, Player* player)
{
if (!player->GetGroup())
return 0;
player->RemoveFromGroup();
return 0;
}
int ResetTalentsCost(lua_State* L, Player* player)
{
#ifdef CATA
Eluna::Push(L, player->GetNextResetTalentsCost());
#else
#ifdef TRINITY
Eluna::Push(L, player->ResetTalentsCost());
#else
Eluna::Push(L, player->resetTalentsCost());
#endif
#endif
return 1;
}
int ResetTalents(lua_State* L, Player* player)
{
bool no_cost = Eluna::CHECKVAL(L, 2, true);
#ifdef CATA
player->ResetTalents(no_cost);
#else
#ifdef TRINITY
player->ResetTalents(no_cost);
#else
player->resetTalents(no_cost);
#endif
#endif
#if (!defined(TBC) && !defined(CLASSIC))
player->SendTalentsInfoData(false);
#endif
return 0;
}
int RemoveSpell(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
bool disabled = Eluna::CHECKVAL(L, 3, false);
bool learn_low_rank = Eluna::CHECKVAL(L, 4, true);
#ifdef TRINITY
player->RemoveSpell(entry, disabled, learn_low_rank);
#else
player->removeSpell(entry, disabled, learn_low_rank);
#endif
return 0;
}
int ClearComboPoints(lua_State* /*L*/, Player* player)
{
player->ClearComboPoints();
return 0;
}
int AddComboPoints(lua_State* L, Player* player)
{
Unit* target = Eluna::CHECKOBJ(L, 2);
int8 count = Eluna::CHECKVAL(L, 3);
player->AddComboPoints(target, count);
return 0;
}
int TalkedToCreature(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
Creature* creature = Eluna::CHECKOBJ(L, 3);
player->TalkedToCreature(entry, creature->GET_GUID());
return 0;
}
int KilledMonsterCredit(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->KilledMonsterCredit(entry, player->GET_GUID());
return 0;
}
int GroupEventHappens(lua_State* L, Player* player)
{
uint32 questId = Eluna::CHECKVAL(L, 2);
WorldObject* obj = Eluna::CHECKOBJ(L, 3);
player->GroupEventHappens(questId, obj);
return 0;
}
int AreaExploredOrEventHappens(lua_State* L, Player* player)
{
uint32 questId = Eluna::CHECKVAL(L, 2);
player->AreaExploredOrEventHappens(questId);
return 0;
}
int FailQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->FailQuest(entry);
return 0;
}
int IncompleteQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->IncompleteQuest(entry);
return 0;
}
int CompleteQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->CompleteQuest(entry);
return 0;
}
int Whisper(lua_State* L, Player* player)
{
std::string text = Eluna::CHECKVAL(L, 2);
uint32 lang = Eluna::CHECKVAL(L, 3);
#ifdef TRINITY
Player* receiver = Eluna::CHECKOBJ(L, 4);
#else
uint64 guid = Eluna::CHECKVAL(L, 4);
#endif
#ifdef TRINITY
player->Whisper(text, (Language)lang, receiver);
#else
player->Whisper(text, lang, ObjectGuid(guid));
#endif
return 0;
}
int TextEmote(lua_State* L, Player* player)
{
std::string text = Eluna::CHECKVAL(L, 2);
player->TextEmote(text);
return 0;
}
int Yell(lua_State* L, Player* player)
{
std::string text = Eluna::CHECKVAL(L, 2);
uint32 lang = Eluna::CHECKVAL(L, 3);
#ifdef TRINITY
player->Yell(text, (Language)lang);
#else
player->Yell(text, lang);
#endif
return 0;
}
int Say(lua_State* L, Player* player)
{
std::string text = Eluna::CHECKVAL(L, 2);
uint32 lang = Eluna::CHECKVAL(L, 3);
#ifdef TRINITY
player->Say(text, (Language)lang);
#else
player->Say(text, lang);
#endif
return 0;
}
int GiveXP(lua_State* L, Player* player)
{
uint32 xp = Eluna::CHECKVAL(L, 2);
Unit* victim = Eluna::CHECKOBJ(L, 3, false);
player->GiveXP(xp, victim);
return 0;
}
int ToggleDND(lua_State* /*L*/, Player* player)
{
player->ToggleDND();
return 0;
}
int ToggleAFK(lua_State* /*L*/, Player* player)
{
player->ToggleAFK();
return 0;
}
int EquipItem(lua_State* L, Player* player)
{
uint16 dest = 0;
Item* item = Eluna::CHECKOBJ
- (L, 2, false);
uint32 slot = Eluna::CHECKVAL(L, 3);
if (slot >= INVENTORY_SLOT_BAG_END)
return 1;
if (!item)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
item = Item::CreateItem(entry, 1, player);
if (!item)
return 1;
InventoryResult result = player->CanEquipItem(slot, dest, item, false);
if (result != EQUIP_ERR_OK)
{
delete item;
return 1;
}
player->ItemAddedQuestCheck(entry, 1);
#if (!defined(TBC) && !defined(CLASSIC))
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, entry, 1);
#endif
}
else
{
InventoryResult result = player->CanEquipItem(slot, dest, item, false);
if (result != EQUIP_ERR_OK)
return 1;
player->RemoveItem(item->GetBagSlot(), item->GetSlot(), true);
}
Eluna::Push(L, player->EquipItem(dest, item, true));
return 1;
}
int CanEquipItem(lua_State* L, Player* player)
{
Item* item = Eluna::CHECKOBJ
- (L, 2, false);
uint32 slot = Eluna::CHECKVAL(L, 3);
if (slot >= EQUIPMENT_SLOT_END)
{
Eluna::Push(L, false);
return 1;
}
if (!item)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
uint16 dest;
InventoryResult msg = player->CanEquipNewItem(slot, dest, entry, false);
if (msg != EQUIP_ERR_OK)
{
Eluna::Push(L, false);
return 1;
}
}
else
{
uint16 dest;
InventoryResult msg = player->CanEquipItem(slot, dest, item, false);
if (msg != EQUIP_ERR_OK)
{
Eluna::Push(L, false);
return 1;
}
}
Eluna::Push(L, true);
return 1;
}
#ifndef CLASSIC
int UnsetKnownTitle(lua_State* L, Player* player)
{
uint32 id = Eluna::CHECKVAL(L, 2);
CharTitlesEntry const* t = sCharTitlesStore.LookupEntry(id);
if (t)
player->SetTitle(t, true);
return 0;
}
#endif
int AdvanceSkillsToMax(lua_State* /*L*/, Player* player)
{
player->UpdateSkillsToMaxSkillsForLevel();
return 0;
}
int AdvanceAllSkills(lua_State* L, Player* player)
{
uint32 step = Eluna::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_ENGINEERING, SKILL_LEATHERWORKING, SKILL_LOCKPICKING, SKILL_SKINNING, SKILL_TAILORING,
#ifndef CLASSIC
SKILL_JEWELCRAFTING,
#endif
#if (!defined(TBC) && !defined(CLASSIC))
SKILL_INSCRIPTION,
#endif
};
static const uint32 skillsSize = sizeof(skillsArray) / sizeof(*skillsArray);
for (uint32 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 = Eluna::CHECKVAL(L, 2);
uint32 _step = Eluna::CHECKVAL(L, 3);
if (_skillId && _step)
{
if (player->HasSkill(_skillId))
player->UpdateSkill(_skillId, _step);
}
return 0;
}
int Teleport(lua_State* L, Player* player)
{
uint32 mapId = Eluna::CHECKVAL(L, 2);
float x = Eluna::CHECKVAL(L, 3);
float y = Eluna::CHECKVAL(L, 4);
float z = Eluna::CHECKVAL(L, 5);
float o = Eluna::CHECKVAL(L, 6);
#ifndef TRINITY
if (player->IsTaxiFlying())
#else
if (player->IsInFlight())
#endif
{
player->GetMotionMaster()->MovementExpired();
player->m_taxi.ClearTaxiDestinations();
}
Eluna::Push(L, player->TeleportTo(mapId, x, y, z, o));
return 1;
}
int AddLifetimeKills(lua_State* L, Player* player)
{
uint32 val = Eluna::CHECKVAL(L, 2);
uint32 currentKills = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS);
player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val);
return 0;
}
int AddItem(lua_State* L, Player* player)
{
uint32 itemId = Eluna::CHECKVAL(L, 2);
uint32 itemCount = Eluna::CHECKVAL(L, 3);
#ifndef TRINITY
Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount));
#else
uint32 noSpaceForCount = 0;
ItemPosCountVec dest;
InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, itemCount, &noSpaceForCount);
if (msg != EQUIP_ERR_OK)
itemCount -= noSpaceForCount;
if (itemCount == 0 || dest.empty())
return 1;
Item* item = player->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
if (item)
player->SendNewItem(item, itemCount, true, false);
Eluna::Push(L, item);
#endif
return 1;
}
int RemoveItem(lua_State* L, Player* player)
{
Item* item = Eluna::CHECKOBJ
- (L, 2, false);
uint32 itemCount = Eluna::CHECKVAL(L, 3);
if (!item)
{
uint32 itemId = Eluna::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 = Eluna::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 = Eluna::CHECKVAL(L, 2);
bool update = Eluna::CHECKVAL(L, 3, true);
player->RemoveSpellCooldown(spellId, update);
return 0;
}
int ResetTypeCooldowns(lua_State* L, Player* player)
{
uint32 category = Eluna::CHECKVAL(L, 2);
bool update = Eluna::CHECKVAL(L, 3, true);
player->RemoveSpellCategoryCooldown(category, update);
return 0;
}
int ResetAllCooldowns(lua_State* /*L*/, Player* player)
{
player->RemoveAllSpellCooldown();
return 0;
}
int SendClearCooldowns(lua_State* L, Player* player)
{
uint32 spellId = Eluna::CHECKVAL(L, 2);
Unit* target = Eluna::CHECKOBJ(L, 3);
player->SendClearCooldown(spellId, target);
return 0;
}
int SendBroadcastMessage(lua_State* L, Player* player)
{
const char* message = Eluna::CHECKVAL(L, 2);
if (std::string(message).length() > 0)
ChatHandler(player->GetSession()).SendSysMessage(message);
return 0;
}
int SendAreaTriggerMessage(lua_State* L, Player* player)
{
std::string msg = Eluna::CHECKVAL(L, 2);
if (msg.length() > 0)
player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str());
return 0;
}
int SendNotification(lua_State* L, Player* player)
{
std::string msg = Eluna::CHECKVAL(L, 2);
if (msg.length() > 0)
player->GetSession()->SendNotification("%s", msg.c_str());
return 0;
}
int SendPacket(lua_State* L, Player* player)
{
WorldPacket* data = Eluna::CHECKOBJ(L, 2);
bool selfOnly = Eluna::CHECKVAL(L, 3, true);
if (selfOnly)
player->GetSession()->SendPacket(data);
else
player->SendMessageToSet(data, true);
return 0;
}
int SendAddonMessage(lua_State* L, Player* player)
{
std::string prefix = Eluna::CHECKVAL(L, 2);
std::string message = Eluna::CHECKVAL(L, 3);
uint8 channel = Eluna::CHECKVAL(L, 4);
Player* receiver = Eluna::CHECKOBJ(L, 5);
std::string fullmsg = prefix + "\t" + message;
WorldPacket data(SMSG_MESSAGECHAT, 100);
data << uint8(channel);
data << int32(LANG_ADDON);
data << uint64(player->GET_GUID());
#ifndef CLASSIC
data << uint32(0);
data << uint64(receiver->GET_GUID());
#endif
data << uint32(fullmsg.length() + 1);
data << fullmsg;
data << uint8(0);
receiver->GetSession()->SendPacket(&data);
return 0;
}
int SendVendorWindow(lua_State* L, Player* player)
{
Unit* sendTo = Eluna::CHECKOBJ(L, 2);
player->GetSession()->SendListInventory(sendTo->GET_GUID());
return 0;
}
int KickPlayer(lua_State* /*L*/, Player* player)
{
player->GetSession()->KickPlayer();
return 0;
}
int ModifyMoney(lua_State* L, Player* player)
{
int32 amt = Eluna::CHECKVAL(L, 2);
player->ModifyMoney(amt);
return 1;
}
int LearnSpell(lua_State* L, Player* player)
{
uint32 id = Eluna::CHECKVAL(L, 2);
#ifdef TRINITY
player->LearnSpell(id, false);
#else
player->learnSpell(id, false);
#endif
return 0;
}
int ResurrectPlayer(lua_State* L, Player* player)
{
float percent = Eluna::CHECKVAL(L, 2, 100.0f);
bool sickness = Eluna::CHECKVAL(L, 3, false);
player->ResurrectPlayer(percent, sickness);
player->SpawnCorpseBones();
return 0;
}
int GossipMenuAddItem(lua_State* L, Player* player)
{
uint32 _icon = Eluna::CHECKVAL(L, 2);
const char* msg = Eluna::CHECKVAL(L, 3);
uint32 _sender = Eluna::CHECKVAL(L, 4);
uint32 _intid = Eluna::CHECKVAL(L, 5);
bool _code = Eluna::CHECKVAL(L, 6, false);
const char* _promptMsg = Eluna::CHECKVAL(L, 7, "");
uint32 _money = Eluna::CHECKVAL(L, 8, 0);
#ifndef TRINITY
#ifndef CLASSIC
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _money, _code);
#else
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _code);
#endif
#else
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code);
#endif
return 0;
}
int GossipComplete(lua_State* /*L*/, Player* player)
{
#ifndef TRINITY
player->PlayerTalkClass->CloseGossip();
#else
player->PlayerTalkClass->SendCloseGossip();
#endif
return 0;
}
int GossipSendMenu(lua_State* L, Player* player)
{
uint32 _npcText = Eluna::CHECKVAL(L, 2);
WorldObject* sender = Eluna::CHECKOBJ(L, 3);
if (sender->GetTypeId() == TYPEID_PLAYER)
{
uint32 menu_id = Eluna::CHECKVAL(L, 4);
player->PlayerTalkClass->GetGossipMenu().SetMenuId(menu_id);
}
player->PlayerTalkClass->SendGossipMenu(_npcText, sender->GET_GUID());
return 0;
}
int GossipClearMenu(lua_State* /*L*/, Player* player)
{
player->PlayerTalkClass->ClearMenus();
return 0;
}
int PlaySoundToPlayer(lua_State* L, Player* player)
{
uint32 soundId = Eluna::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 = Eluna::CHECKVAL(L, 2);
if (pathId >= sTaxiPathNodesByPath.size())
return 0;
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathId];
if (path.size() < 2)
return 0;
std::vector nodes;
nodes.resize(2);
nodes[0] = path[0].index;
nodes[1] = path[path.size() - 1].index;
player->ActivateTaxiPathTo(nodes);
return 0;
}
int GossipSendPOI(lua_State* L, Player* player)
{
float x = Eluna::CHECKVAL(L, 2);
float y = Eluna::CHECKVAL(L, 3);
uint32 icon = Eluna::CHECKVAL(L, 4);
uint32 flags = Eluna::CHECKVAL(L, 5);
uint32 data = Eluna::CHECKVAL(L, 6);
std::string iconText = Eluna::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 = Eluna::CHECKOBJ(L, 2);
if (source->GetTypeId() == TYPEID_UNIT)
{
if (source->GetUInt32Value(UNIT_NPC_FLAGS) & UNIT_NPC_FLAG_QUESTGIVER)
player->PrepareQuestMenu(source->GET_GUID());
}
else if (source->GetTypeId() == TYPEID_GAMEOBJECT)
{
if (source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
player->PrepareQuestMenu(source->GET_GUID());
}
return 0;
}
int SendQuestTemplate(lua_State* L, Player* player)
{
uint32 questId = Eluna::CHECKVAL(L, 2);
bool activeAccept = Eluna::CHECKVAL(L, 3, true);
Quest const* quest = eObjectMgr->GetQuestTemplate(questId);
if (!quest)
return 0;
player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activeAccept);
return 0;
}
int SpawnBones(lua_State* /*L*/, Player* player)
{
player->SpawnCorpseBones();
return 0;
}
int RemovedInsignia(lua_State* L, Player* player)
{
Player* looter = Eluna::CHECKOBJ(L, 2);
player->RemovedInsignia(looter);
return 0;
}
/*int BindToInstance(lua_State* L, Player* player)
{
player->BindToInstance();
return 0;
}*/
/*int AddTalent(lua_State* L, Player* player)
{
uint32 spellId = Eluna::CHECKVAL(L, 2);
uint8 spec = Eluna::CHECKVAL(L, 3);
bool learning = Eluna::CHECKVAL(L, 4, true);
if (spec >= MAX_TALENT_SPECS)
Eluna::Push(L, false);
else
Eluna::Push(L, player->AddTalent(spellId, spec, learning));
return 1;
}*/
/*int GainSpellComboPoints(lua_State* L, Player* player)
{
int8 count = Eluna::CHECKVAL(L, 2);
player->GainSpellComboPoints(count);
return 0;
}*/
/*int KillGOCredit(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
uint64 guid = Eluna::CHECKVAL(L, 3);
player->KillCreditGO(entry, guid);
return 0;
}*/
/*int KilledPlayerCredit(lua_State* L, Player* player)
{
player->KilledPlayerCredit();
return 0;
}*/
/*int RemoveRewardedQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->RemoveRewardedQuest(entry);
return 0;
}*/
/*int RemoveActiveQuest(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
player->RemoveActiveQuest(entry);
return 0;
}*/
/*int SummonPet(lua_State* L, Player* player)
{
uint32 entry = Eluna::CHECKVAL(L, 2);
float x = Eluna::CHECKVAL(L, 3);
float y = Eluna::CHECKVAL(L, 4);
float z = Eluna::CHECKVAL(L, 5);
float o = Eluna::CHECKVAL(L, 6);
uint32 petType = Eluna::CHECKVAL(L, 7);
uint32 despwtime = Eluna::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 = Eluna::CHECKVAL(L, 2, PET_SAVE_AS_DELETED);
bool returnreagent = Eluna::CHECKVAL(L, 2, false);
if (!player->GetPet())
return 0;
player->RemovePet(player->GetPet(), (PetSaveMode)mode, returnreagent);
return 0;
}*/
};
#endif