mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Truncating history
This commit is contained in:
127
AuraMethods.h
Normal file
127
AuraMethods.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md 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)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetCasterGuid());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetCasterGUID());
|
||||
#endif
|
||||
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 GetOwner(lua_State* L, Aura* aura)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, aura->GetTarget());
|
||||
#else
|
||||
sEluna->Push(L, aura->GetOwner());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SetDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetAuraDuration(duration);
|
||||
#else
|
||||
aura->SetDuration(duration);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetMaxDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetAuraMaxDuration(duration);
|
||||
#else
|
||||
aura->SetMaxDuration(duration);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetStackAmount(lua_State* L, Aura* aura)
|
||||
{
|
||||
int amount = sEluna->CHECKVAL<int>(L, 2);
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->SetStackAmount(amount);
|
||||
#else
|
||||
aura->SetStackAmount(amount);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Remove(lua_State* L, Aura* aura)
|
||||
{
|
||||
int duration = sEluna->CHECKVAL<int>(L, 2);
|
||||
#ifdef MANGOS
|
||||
aura->GetHolder()->RemoveAura(aura->GetEffIndex());
|
||||
#else
|
||||
aura->Remove();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
134
CMakeLists.txt
Normal file
134
CMakeLists.txt
Normal file
@@ -0,0 +1,134 @@
|
||||
#
|
||||
# Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
# This program is free software licensed under GPL version 3
|
||||
# Please see the included DOCS/LICENSE.md for more information
|
||||
#
|
||||
|
||||
if ( USE_COREPCH )
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
file(GLOB sources_localdir *.cpp *.h)
|
||||
|
||||
set(LuaEngine_STAT_SRCS
|
||||
${LuaEngine_STAT_SRCS}
|
||||
${sources_localdir}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
|
||||
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast
|
||||
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
|
||||
${CMAKE_SOURCE_DIR}/dep/SFMT
|
||||
${CMAKE_SOURCE_DIR}/dep/mersennetwister
|
||||
${CMAKE_SOURCE_DIR}/dep/zlib
|
||||
${CMAKE_SOURCE_DIR}/dep/lualib
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography/Authentication
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/DataStores
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Debugging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/CountedReference
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Policies
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision/Management
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision/Models
|
||||
${CMAKE_SOURCE_DIR}/src/server/collision/Maps
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Accounts
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Achievements
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Addons
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Handlers
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/EventAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Calendar
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Chat
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Chat/Channels
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Conditions
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Combat
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/DataStores
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/DungeonFinding
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/AreaTrigger
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Corpse
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Creature
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/DynamicObject
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item/Container
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/GameObject
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object/Updates
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Pet
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Player
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Transport
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Unit
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Vehicle
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Events
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Globals
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Grids
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Grids/Cells
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Grids/Notifiers
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Groups
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Guilds
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Instances
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/LookingForGroup
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Loot
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Mails
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Maps
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/Spline
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Opcodes
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/OutdoorPvP
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Pools
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/PrecompiledHeaders
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Quests
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Reputation
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Scripting
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Server
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Server/Protocol
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Server/Protocol/Handlers
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Skills
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Spells
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Spells/Auras
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Texts
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Tickets
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Tools
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Weather
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/World
|
||||
${CMAKE_SOURCE_DIR}/src/server/scripts/PrecompiledHeaders
|
||||
${ACE_INCLUDE_DIR}
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
add_library(LuaEngine STATIC
|
||||
${LuaEngine_STAT_SRCS}
|
||||
${game_STAT_SRCS}
|
||||
${game_STAT_PCH_SRC}
|
||||
)
|
||||
|
||||
target_link_libraries(LuaEngine
|
||||
game
|
||||
)
|
||||
|
||||
add_dependencies(LuaEngine game)
|
||||
58
CorpseMethods.h
Normal file
58
CorpseMethods.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef CORPSEMETHODS_H
|
||||
#define CORPSEMETHODS_H
|
||||
|
||||
namespace LuaCorpse
|
||||
{
|
||||
// GetOwnerGUID()
|
||||
int GetOwnerGUID(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, corpse->GetOwnerGuid());
|
||||
#else
|
||||
sEluna->Push(L, corpse->GetOwnerGUID());
|
||||
#endif
|
||||
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
|
||||
679
CreatureMethods.h
Normal file
679
CreatureMethods.h
Normal file
@@ -0,0 +1,679 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef CREATUREMETHODS_H
|
||||
#define CREATUREMETHODS_H
|
||||
|
||||
namespace LuaCreature
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsReputationGainDisabled(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsReputationGainDisabled());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsRegeneratingHealth(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsRegeneratingHealth());
|
||||
#else
|
||||
sEluna->Push(L, creature->isRegeneratingHealth());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasInvolvedQuest(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 quest_id = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasInvolvedQuest(quest_id));
|
||||
#else
|
||||
sEluna->Push(L, creature->hasInvolvedQuest(quest_id));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsTargetAcceptable(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->isTargetableForAttack(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanAssistTo(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* u = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
Unit* enemy = sEluna->CHECKOBJ<Unit>(L, 3);
|
||||
bool checkfaction = sEluna->CHECKVAL<bool>(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 IsTappedBy(lua_State* L, Creature* creature)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->isTappedBy(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasLootRecipient(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasLootRecipient());
|
||||
#else
|
||||
sEluna->Push(L, creature->hasLootRecipient());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasReactState(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 state = sEluna->CHECKVAL<int32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->GetCharmInfo()->HasReactState((ReactStates)state));
|
||||
#else
|
||||
sEluna->Push(L, creature->HasReactState((ReactStates)state));
|
||||
#endif
|
||||
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 IsInEvadeMode(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsInEvadeMode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsElite(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsElite());
|
||||
#else
|
||||
sEluna->Push(L, creature->isElite());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsGuard(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsGuard());
|
||||
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 IsWorldBoss(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->IsWorldBoss());
|
||||
#else
|
||||
sEluna->Push(L, creature->isWorldBoss());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasCategoryCooldown(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spell = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasCategoryCooldown(spell));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasSpell(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 id = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasSpell(id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasQuest(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 questId = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->HasQuest(questId));
|
||||
#else
|
||||
sEluna->Push(L, creature->hasQuest(questId));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasSpellCooldown(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spellId = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasSpellCooldown(spellId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanFly(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->CanFly());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int IsTrigger(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsTrigger());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int IsDamageEnoughForLootingAndReward(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->IsDamageEnoughForLootingAndReward());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int CanStartAttack(lua_State* L, Creature* creature) // TODO: Implement core side
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
bool force = sEluna->CHECKVAL<bool>(L, 3, true);
|
||||
|
||||
sEluna->Push(L, creature->CanStartAttack(target, force));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int HasLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->HasLootMode(lootMode));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* GETTERS */
|
||||
int GetRespawnDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetRespawnDelay());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRespawnRadius(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetRespawnRadius());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDefaultMovementType(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetDefaultMovementType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAggroRange(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetAttackDistance(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAttackDistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetAttackDistance(target));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLootRecipientGroup(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->GetGroupLootRecipient());
|
||||
#else
|
||||
sEluna->Push(L, creature->GetLootRecipientGroup());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLootRecipient(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetLootRecipient());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetReactState(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->GetCharmInfo()->GetReactState());
|
||||
#else
|
||||
sEluna->Push(L, creature->GetReactState());
|
||||
#endif
|
||||
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 GetCreatureSpellCooldownDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 spell = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
sEluna->Push(L, creature->GetCreatureSpellCooldownDelay(spell));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCorpseDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetCorpseDelay());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetHomePosition(lua_State* L, Creature* creature)
|
||||
{
|
||||
float x, y, z, o;
|
||||
#ifdef MANGOS
|
||||
creature->GetRespawnCoord(x, y, z, &o);
|
||||
#else
|
||||
creature->GetHomePosition(x, y, z, o);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, x);
|
||||
sEluna->Push(L, y);
|
||||
sEluna->Push(L, z);
|
||||
sEluna->Push(L, o);
|
||||
return 4;
|
||||
}
|
||||
|
||||
int GetAITarget(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 targetType = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
bool playerOnly = sEluna->CHECKVAL<bool>(L, 3, false);
|
||||
uint32 position = sEluna->CHECKVAL<uint32>(L, 4, 0);
|
||||
float dist = sEluna->CHECKVAL<float>(L, 5, 0.0f);
|
||||
int32 aura = sEluna->CHECKVAL<int32>(L, 6, 0);
|
||||
|
||||
ThreatList const& threatlist = creature->getThreatManager().getThreatList();
|
||||
if (position >= threatlist.size())
|
||||
{
|
||||
sEluna->Push(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::list<Unit*> targetList;
|
||||
for (ThreatList::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<Unit*>::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<Unit*>::reverse_iterator ritr = targetList.rbegin();
|
||||
std::advance(ritr, position);
|
||||
sEluna->Push(L, *ritr);
|
||||
return 1;
|
||||
}
|
||||
case SELECT_TARGET_RANDOM:
|
||||
{
|
||||
std::list<Unit*>::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;
|
||||
|
||||
ThreatList const& threatList = creature->getThreatManager().getThreatList();
|
||||
ThreatList::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 GetNPCFlags(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetUInt32Value(UNIT_NPC_FLAGS));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CATA
|
||||
int GetShieldBlockValue(lua_State* L, Creature* creature)
|
||||
{
|
||||
sEluna->Push(L, creature->GetShieldBlockValue());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
sEluna->Push(L, creature->GetLootMode());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* SETTERS */
|
||||
int SetNPCFlags(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 flags = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
creature->SetUInt32Value(UNIT_NPC_FLAGS, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetDeathState(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 state = sEluna->CHECKVAL<int32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->SetDeathState((DeathState)state);
|
||||
#else
|
||||
creature->setDeathState((DeathState)state);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetWalk(lua_State* L, Creature* creature) // TODO: Move same to Player ?
|
||||
{
|
||||
bool enable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetWalk(enable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetReactState(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 state = sEluna->CHECKVAL<int32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->GetCharmInfo()->SetReactState((ReactStates)state);
|
||||
#else
|
||||
creature->SetReactState((ReactStates)state);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetDisableReputationGain(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool disable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetDisableReputationGain(disable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetInCombatWithZone(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->SetInCombatWithZone();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetRespawnRadius(lua_State* L, Creature* creature)
|
||||
{
|
||||
float dist = sEluna->CHECKVAL<float>(L, 2);
|
||||
|
||||
creature->SetRespawnRadius(dist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetRespawnDelay(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
creature->SetRespawnDelay(delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetDefaultMovementType(lua_State* L, Creature* creature)
|
||||
{
|
||||
int32 type = sEluna->CHECKVAL<int32>(L, 2);
|
||||
|
||||
creature->SetDefaultMovementType((MovementGeneratorType)type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetNoSearchAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool val = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetNoSearchAssistance(val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetNoCallAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool val = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
creature->SetNoCallAssistance(val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetHover(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool enable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->SetLevitate(enable);
|
||||
#else
|
||||
creature->SetHover(enable);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
|
||||
creature->SetLootMode(lootMode);
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
/*int SetDisableGravity(lua_State* L, Creature* creature)
|
||||
{
|
||||
bool disable = sEluna->CHECKVAL<bool>(L, 2, true);
|
||||
bool packetOnly = sEluna->CHECKVAL<bool>(L, 3, false);
|
||||
|
||||
sEluna->Push(L, creature->SetDisableGravity(disable, packetOnly));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* OTHER */
|
||||
int DespawnOrUnsummon(lua_State* L, Creature* creature)
|
||||
{
|
||||
uint32 msTimeToDespawn = sEluna->CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
#ifdef MANGOS
|
||||
creature->ForcedDespawn(msTimeToDespawn);
|
||||
#else
|
||||
creature->DespawnOrUnsummon(msTimeToDespawn);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Respawn(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->Respawn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RemoveCorpse(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->RemoveCorpse();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MoveWaypoint(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
creature->GetMotionMaster()->MoveWaypoint();
|
||||
#else
|
||||
creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CallAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->CallAssistance();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CallForHelp(lua_State* L, Creature* creature)
|
||||
{
|
||||
float radius = sEluna->CHECKVAL<float>(L, 2);
|
||||
|
||||
creature->CallForHelp(radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FleeToGetAssistance(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->DoFleeToGetAssistance();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AttackStart(lua_State* L, Creature* creature)
|
||||
{
|
||||
Unit* target = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
|
||||
creature->AI()->AttackStart(target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SaveToDB(lua_State* L, Creature* creature)
|
||||
{
|
||||
creature->SaveToDB();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SelectVictim(lua_State* L, Creature* creature)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, creature->SelectHostileTarget());
|
||||
#else
|
||||
sEluna->Push(L, creature->SelectVictim());
|
||||
#endif
|
||||
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<uint16>(L, 2);
|
||||
|
||||
creature->RemoveLootMode(lootMode);
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
/*int AddLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features
|
||||
{
|
||||
uint16 lootMode = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
|
||||
creature->AddLootMode(lootMode);
|
||||
return 0;
|
||||
}*/
|
||||
};
|
||||
#endif
|
||||
207
GameObjectMethods.h
Normal file
207
GameObjectMethods.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GAMEOBJECTMETHODS_H
|
||||
#define GAMEOBJECTMETHODS_H
|
||||
|
||||
namespace LuaGameObject
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int HasQuest(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 questId = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, go->HasQuest(questId));
|
||||
#else
|
||||
sEluna->Push(L, go->hasQuest(questId));
|
||||
#endif
|
||||
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 IsActive(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
sEluna->Push(L, false);
|
||||
else
|
||||
sEluna->Push(L, go->isActiveObject());
|
||||
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;
|
||||
}*/
|
||||
|
||||
/* GETTERS */
|
||||
int GetDisplayId(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
sEluna->Push(L, go->GetDisplayId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGoState(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
sEluna->Push(L, go->GetGoState());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLootState(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
sEluna->Push(L, go->getLootState());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetGoState(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
uint32 state = sEluna->CHECKVAL<uint32>(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 SetLootState(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
uint32 state = sEluna->CHECKVAL<uint32>(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;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
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<bool>(L, 2, false);
|
||||
if (del)
|
||||
go->DeleteFromDB();
|
||||
go->RemoveFromWorld();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RegisterEvent(lua_State* L, GameObject* go)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
uint32 repeats = sEluna->CHECKVAL<uint32>(L, 4);
|
||||
|
||||
lua_settop(L, 2);
|
||||
int functionRef = lua_ref(L, true);
|
||||
functionRef = sEluna->m_EventMgr.AddEvent(&go->m_Events, functionRef, delay, repeats, go);
|
||||
if (functionRef)
|
||||
sEluna->Push(L, functionRef);
|
||||
else
|
||||
sEluna->Push(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RemoveEventById(lua_State* L, GameObject* go)
|
||||
{
|
||||
int eventId = sEluna->CHECKVAL<int>(L, 2);
|
||||
sEluna->m_EventMgr.RemoveEvent(&go->m_Events, eventId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RemoveEvents(lua_State* L, GameObject* go)
|
||||
{
|
||||
sEluna->m_EventMgr.RemoveEvents(&go->m_Events);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UseDoorOrButton(lua_State* L, GameObject* go)
|
||||
{
|
||||
if (!go || !go->IsInWorld())
|
||||
return 0;
|
||||
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
go->UseDoorOrButton(delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Despawn(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 delay = sEluna->CHECKVAL<uint32>(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<uint32>(L, 2, 1);
|
||||
if (!delay)
|
||||
delay = 1;
|
||||
|
||||
go->SetSpawnedByDefault(true);
|
||||
go->SetRespawnTime(delay);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
1167
GlobalMethods.h
Normal file
1167
GlobalMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
227
GroupMethods.h
Normal file
227
GroupMethods.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GROUPMETHODS_H
|
||||
#define GROUPMETHODS_H
|
||||
|
||||
namespace LuaGroup
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsLeader(lua_State* L, Group* group)
|
||||
{
|
||||
uint64 guid = sEluna->CHECKVAL<uint64>(L, 2);
|
||||
sEluna->Push(L, group->IsLeader(GUID_TYPE(guid)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsFull(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->IsFull());
|
||||
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 IsMember(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
sEluna->Push(L, group->IsMember(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsAssistant(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->IsAssistant(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SameSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player1 = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
Player* player2 = sEluna->CHECKOBJ<Player>(L, 3);
|
||||
sEluna->Push(L, group->SameSubGroup(player1, player2));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int HasFreeSlotSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
uint8 subGroup = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
sEluna->Push(L, group->HasFreeSlotSubGroup(subGroup));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddInvite(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->AddInvite(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int isLFGGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
sEluna->Push(L, group->isLFGGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int isBFGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
sEluna->Push(L, group->isBFGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* GETTERS */
|
||||
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)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->GetLeaderGuid());
|
||||
#else
|
||||
sEluna->Push(L, group->GetLeaderGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLeader(lua_State* L, Group* group)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGuid()));
|
||||
#else
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(group->GetLeaderGUID()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetGUID(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->GET_GUID());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMemberGUID(lua_State* L, Group* group)
|
||||
{
|
||||
const char* name = sEluna->CHECKVAL<const char*>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->GetMemberGuid(name));
|
||||
#else
|
||||
sEluna->Push(L, group->GetMemberGUID(name));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMembersCount(lua_State* L, Group* group)
|
||||
{
|
||||
sEluna->Push(L, group->GetMembersCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetMemberGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, group->GetMemberGroup(player->GET_GUID()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int ChangeLeader(lua_State* L, Group* group)
|
||||
{
|
||||
Player* leader = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
group->ChangeLeader(leader->GET_GUID());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SendPacket(packet, sendToPlayersInBattleground[, ignoreguid])
|
||||
int SendPacket(lua_State* L, Group* group)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
bool ignorePlayersInBg = sEluna->CHECKVAL<bool>(L, 3);
|
||||
uint64 ignore = sEluna->CHECKVAL<uint64>(L, 4);
|
||||
|
||||
group->BroadcastPacket(data, ignorePlayersInBg, -1, (GUID_TYPE)ignore);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RemoveMember(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint32 method = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), method));
|
||||
#else
|
||||
sEluna->Push(L, group->RemoveMember(player->GET_GUID(), (RemoveMethod)method));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Disband(lua_State* L, Group* group)
|
||||
{
|
||||
group->Disband();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConvertToRaid(lua_State* L, Group* group)
|
||||
{
|
||||
group->ConvertToRaid();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ChangeMembersGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 groupID = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
|
||||
group->ChangeMembersGroup(player->GET_GUID(), groupID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*int ConvertToLFG(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
group->ConvertToLFG();
|
||||
return 0;
|
||||
}*/
|
||||
};
|
||||
#endif
|
||||
205
GuildMethods.h
Normal file
205
GuildMethods.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GUILDMETHODS_H
|
||||
#define GUILDMETHODS_H
|
||||
|
||||
namespace LuaGuild
|
||||
{
|
||||
/* GETTERS */
|
||||
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)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGuid()));
|
||||
#else
|
||||
sEluna->Push(L, sObjectAccessor->FindPlayer(guild->GetLeaderGUID()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetLeaderGUID(lua_State* L, Guild* guild)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, guild->GetLeaderGuid());
|
||||
#else
|
||||
sEluna->Push(L, guild->GetLeaderGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
#ifndef CATA
|
||||
int SetLeader(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->SetLeader(player->GET_GUID());
|
||||
#else
|
||||
guild->HandleSetLeader(player->GetSession(), player->GetName());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int SetBankTabText(lua_State* L, Guild* guild)
|
||||
{
|
||||
uint8 tabId = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
const char* text = sEluna->CHECKVAL<const char*>(L, 3);
|
||||
#ifdef MANGOS
|
||||
guild->SetGuildBankTabText(tabId, text);
|
||||
#else
|
||||
guild->SetBankTabText(tabId, text);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
// SendPacketToGuild(packet)
|
||||
int SendPacket(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
|
||||
guild->BroadcastPacket(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SendPacketToRankedInGuild(packet, rankId)
|
||||
int SendPacketToRanked(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
uint8 ranked = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
|
||||
guild->BroadcastPacketToRank(data, ranked);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Disband(lua_State* L, Guild* guild)
|
||||
{
|
||||
guild->Disband();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddMember(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 rankId = sEluna->CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
|
||||
|
||||
guild->AddMember(player->GET_GUID(), rankId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DeleteMember(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
bool isDisbanding = sEluna->CHECKVAL<bool>(L, 3, false);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->DelMember(player->GET_GUID(), isDisbanding);
|
||||
#else
|
||||
guild->DeleteMember(player->GET_GUID(), isDisbanding);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ChangeMemberRank(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint8 newRank = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
|
||||
guild->ChangeMemberRank(player->GET_GUID(), newRank);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Move to Player methods
|
||||
int WithdrawBankMoney(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
uint32 money = sEluna->CHECKVAL<uint32>(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<Player>(L, 2);
|
||||
uint32 money = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
|
||||
#ifdef MANGOS
|
||||
guild->SetBankMoney(guild->GetGuildBankMoney() + money);
|
||||
#else
|
||||
guild->HandleMemberDepositMoney(player->GetSession(), money);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
2093
HookMgr.cpp
Normal file
2093
HookMgr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
467
HookMgr.h
Normal file
467
HookMgr.h
Normal file
@@ -0,0 +1,467 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef LUAHOOKS_H
|
||||
#define LUAHOOKS_H
|
||||
|
||||
#include "Includes.h"
|
||||
|
||||
// Base
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
// enums
|
||||
#ifdef MANGOS
|
||||
#include "Player.h"
|
||||
#else
|
||||
#include "GameObjectAI.h"
|
||||
#endif
|
||||
#include "Group.h"
|
||||
#include "Item.h"
|
||||
#include "Weather.h"
|
||||
|
||||
#ifdef MANGOS
|
||||
#define ScriptedAI ReactorAI
|
||||
#define SpellEffIndex SpellEffectIndex
|
||||
#define ItemTemplate ItemPrototype
|
||||
#define GetTemplate GetProto
|
||||
//#include "Common.h"
|
||||
//#include "Policies/Singleton.h"
|
||||
//#include "ObjectGuid.h"
|
||||
//#include "ace/Atomic_Op.h"
|
||||
//
|
||||
//enums
|
||||
//#include "DBCEnums.h"
|
||||
//#include "Includes.h"
|
||||
#endif
|
||||
|
||||
struct AreaTriggerEntry;
|
||||
#ifdef MANGOS
|
||||
class ScriptedAI;
|
||||
#else
|
||||
struct ScriptedAI;
|
||||
#endif
|
||||
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);
|
||||
|
||||
#ifndef MANGOS
|
||||
GameObjectAI* GetAI(GameObject* gameObject);
|
||||
#endif
|
||||
|
||||
/* 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, SpellEffIndex 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, ItemTemplate const* pProto);
|
||||
void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, std::string code);
|
||||
|
||||
/* Creature */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex 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, SpellEffIndex 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, Difficulty 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);
|
||||
|
||||
#ifndef MANGOS
|
||||
/* Vehicle */
|
||||
void OnInstall(Vehicle* vehicle);
|
||||
void OnUninstall(Vehicle* vehicle);
|
||||
void OnReset(Vehicle* vehicle);
|
||||
void OnInstallAccessory(Vehicle* vehicle, Creature* accessory);
|
||||
void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId);
|
||||
void OnRemovePassenger(Vehicle* vehicle, Unit* passenger);
|
||||
#endif
|
||||
|
||||
/* 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);
|
||||
};
|
||||
#ifdef MANGOS
|
||||
#define sHookMgr (&MaNGOS::Singleton<HookMgr>::Instance())
|
||||
#else
|
||||
#define sHookMgr ACE_Singleton<HookMgr, ACE_Null_Mutex>::instance()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
498
ItemMethods.h
Normal file
498
ItemMethods.h
Normal file
@@ -0,0 +1,498 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ITEMMETHODS_H
|
||||
#define ITEMMETHODS_H
|
||||
|
||||
namespace LuaItem
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsSoulBound(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsSoulBound());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef TBC
|
||||
int IsBoundAccountWide(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBoundAccountWide());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
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<Player>(L, 2);
|
||||
|
||||
sEluna->Push(L, item->IsBindedNotWith(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsLocked(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsLocked());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsBag(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsCurrencyToken(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsCurrencyToken());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsNotEmptyBag(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsNotEmptyBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsBroken(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsBroken());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CanBeTraded(lua_State* L, Item* item)
|
||||
{
|
||||
#ifdef TBC
|
||||
sEluna->Push(L, item->CanBeTraded());
|
||||
#else
|
||||
bool mail = sEluna->CHECKVAL<bool>(L, 2, false);
|
||||
sEluna->Push(L, item->CanBeTraded(mail));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsInTrade(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsInTrade());
|
||||
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<uint32>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, item->HasQuest(quest));
|
||||
#else
|
||||
sEluna->Push(L, item->hasQuest(quest));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsPotion(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsPotion());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CATA
|
||||
int IsWeaponVellum(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsWeaponVellum());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsArmorVellum(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsArmorVellum());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int IsConjuredConsumable(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->IsConjuredConsumable());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
|
||||
{
|
||||
/*sEluna->Push(L, item->IsRefundExpired());
|
||||
return 1;*/
|
||||
return 0; // Temp till supported
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetItemLink(lua_State* L, Item* item)
|
||||
{
|
||||
// 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<int>(L, 2, DEFAULT_LOCALE);
|
||||
if (loc_idx < 0 || loc_idx >= MAX_LOCALES)
|
||||
return luaL_argerror(L, 2, "valid LocaleConstant expected");
|
||||
|
||||
const ItemTemplate* temp = item->GetTemplate();
|
||||
std::string name = temp->Name1;
|
||||
if (ItemLocale const* il = sObjectMgr->GetItemLocale(temp->ItemId))
|
||||
ObjectMgr::GetLocaleString(il->Name, loc_idx, name);
|
||||
|
||||
if (int32 itemRandPropId = item->GetItemRandomPropertyId())
|
||||
{
|
||||
#ifdef CATA
|
||||
char* suffix = NULL;
|
||||
#else
|
||||
char* const* suffix = NULL;
|
||||
#endif
|
||||
if (itemRandPropId < 0)
|
||||
{
|
||||
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
}
|
||||
if (suffix)
|
||||
{
|
||||
//std::string test(suffix[(name != temp->Name1) ? loc_idx : DEFAULT_LOCALE]);
|
||||
//if (!test.empty())
|
||||
//{
|
||||
name += ' ';
|
||||
name += suffix[(name != temp->Name1) ? loc_idx : DEFAULT_LOCALE];
|
||||
/*}*/
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << 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)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, item->GetOwnerGuid());
|
||||
#else
|
||||
sEluna->Push(L, item->GetOwnerGUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetOwner());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 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<uint32>(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<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSpellTrigger(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 index = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
sEluna->Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Class);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSubClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->SubClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetName(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Name1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDisplayId(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->DisplayInfoID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetQuality(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->Quality);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBuyCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->BuyCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBuyPrice(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->BuyPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetSellPrice(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->SellPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInventoryType(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->InventoryType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAllowableClass(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->AllowableClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetAllowableRace(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->AllowableRace);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetItemLevel(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->ItemLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRequiredLevel(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RequiredLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WOTLK
|
||||
int GetStatsCount(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->StatsCount);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int GetRandomProperty(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RandomProperty);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRandomSuffix(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->RandomSuffix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetItemSet(lua_State* L, Item* item)
|
||||
{
|
||||
sEluna->Push(L, item->GetTemplate()->ItemSet);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetBagSize(lua_State* L, Item* item)
|
||||
{
|
||||
if (Bag* bag = item->ToBag())
|
||||
sEluna->Push(L, bag->GetBagSize());
|
||||
else
|
||||
sEluna->Push(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
#ifdef MANGOS
|
||||
item->SetOwnerGuid(player->GET_GUID());
|
||||
#else
|
||||
item->SetOwnerGUID(player->GET_GUID());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetBinding(lua_State* L, Item* item)
|
||||
{
|
||||
bool soulbound = sEluna->CHECKVAL<bool>(L, 2);
|
||||
|
||||
item->SetBinding(soulbound);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetCount(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 count = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
item->SetCount(count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetEnchantment(lua_State* L, Item* item)
|
||||
{
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 enchant = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
if (!sSpellItemEnchantmentStore.LookupEntry(enchant))
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(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;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int ClearEnchantment(lua_State* L, Item* item)
|
||||
{
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
sEluna->Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)sEluna->CHECKVAL<uint32>(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 SaveToDB(lua_State* L, Item* item)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
item->SaveToDB();
|
||||
#else
|
||||
SQLTransaction trans = SQLTransaction(NULL);
|
||||
item->SaveToDB(trans);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
895
LuaEngine.cpp
Normal file
895
LuaEngine.cpp
Normal file
@@ -0,0 +1,895 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#include "LuaEngine.h"
|
||||
|
||||
#ifdef MANGOS
|
||||
INSTANTIATE_SINGLETON_1(Eluna);
|
||||
#endif
|
||||
|
||||
#if PLATFORM == PLATFORM_UNIX
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
extern void RegisterFunctions(lua_State* L);
|
||||
extern void AddElunaScripts();
|
||||
|
||||
// Start or restart eluna. Returns true if started
|
||||
bool StartEluna()
|
||||
{
|
||||
#ifndef ELUNA
|
||||
#ifndef MANGOS
|
||||
{
|
||||
TC_LOG_ERROR("eluna", "[Eluna]: LuaEngine is Disabled. (If you want to use it please enable in cmake)");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ELUNA_GUARD();
|
||||
bool restart = false;
|
||||
if (sEluna->L)
|
||||
{
|
||||
restart = true;
|
||||
sHookMgr->OnEngineRestart();
|
||||
TC_LOG_INFO("eluna", "[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();
|
||||
|
||||
#ifdef MANGOS
|
||||
// Check config file for eluna is enabled or disabled
|
||||
if (!sWorld->getConfig(CONFIG_BOOL_ELUNA_ENABLED))
|
||||
{
|
||||
TC_LOG_ERROR("eluna", "[Eluna]: LuaEngine is Disabled. (If you want to use it please set config in 'mangosd.conf')");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
sEluna->L = luaL_newstate();
|
||||
TC_LOG_INFO("eluna", "[Eluna]: Lua Engine loaded.");
|
||||
|
||||
LoadedScripts loadedScripts;
|
||||
sEluna->LoadDirectory("lua_scripts", &loadedScripts);
|
||||
luaL_openlibs(sEluna->L);
|
||||
RegisterFunctions(sEluna->L);
|
||||
|
||||
// Randomize math.random()
|
||||
// The macro fails on TC for unknown reason
|
||||
// luaL_dostring(sEluna->L, "math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )");
|
||||
if (!luaL_loadstring(sEluna->L, "math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )"))
|
||||
lua_pcall(sEluna->L, 0, LUA_MULTRET, 0);
|
||||
|
||||
uint32 count = 0;
|
||||
char filename[200];
|
||||
for (std::set<std::string>::const_iterator itr = loadedScripts.begin(); itr != loadedScripts.end(); ++itr)
|
||||
{
|
||||
strcpy(filename, itr->c_str());
|
||||
if (luaL_loadfile(sEluna->L, filename) != 0)
|
||||
{
|
||||
TC_LOG_ERROR("eluna", "[Eluna]: Error loading file `%s`.", itr->c_str());
|
||||
sEluna->report(sEluna->L);
|
||||
}
|
||||
else
|
||||
{
|
||||
int err = lua_pcall(sEluna->L, 0, 0, 0);
|
||||
if (err != 0 && err == LUA_ERRRUN)
|
||||
{
|
||||
TC_LOG_ERROR("eluna", "[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<Creature>::ReadGuard g(HashMapHolder<Creature>::GetLock());
|
||||
HashMapHolder<Creature>::MapType& m = HashMapHolder<Creature>::GetContainer();
|
||||
for (HashMapHolder<Creature>::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<GameObject>::ReadGuard g(HashMapHolder<GameObject>::GetLock());
|
||||
HashMapHolder<GameObject>::MapType& m = HashMapHolder<GameObject>::GetContainer();
|
||||
for (HashMapHolder<GameObject>::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();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
TC_LOG_INFO("eluna", "[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)
|
||||
{
|
||||
TC_LOG_ERROR("eluna", "[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."))
|
||||
{
|
||||
TC_LOG_DEBUG("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;
|
||||
TC_LOG_ERROR("eluna", "[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);
|
||||
TC_LOG_ERROR("eluna", "%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_pcall(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, TempSummon 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<Unit>::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<WorldObject>::push(L, obj);
|
||||
}
|
||||
}
|
||||
void Eluna::Push(lua_State* L, Object 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<Object>::push(L, obj);
|
||||
}
|
||||
}
|
||||
template<> bool Eluna::CHECKVAL<bool>(lua_State* L, int narg)
|
||||
{
|
||||
return lua_isnumber(L, narg) ? luaL_optnumber(L, narg, 1) ? true : false : lua_toboolean(L, narg);
|
||||
}
|
||||
template<> bool Eluna::CHECKVAL<bool>(lua_State* L, int narg, bool def)
|
||||
{
|
||||
return lua_isnone(L, narg) ? def : lua_isnumber(L, narg) ? luaL_optnumber(L, narg, 1) ? true : false : lua_toboolean(L, narg);
|
||||
}
|
||||
template<> float Eluna::CHECKVAL<float>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checknumber(L, narg);
|
||||
}
|
||||
template<> float Eluna::CHECKVAL<float>(lua_State* L, int narg, float def)
|
||||
{
|
||||
return luaL_optnumber(L, narg, def);
|
||||
}
|
||||
template<> double Eluna::CHECKVAL<double>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checknumber(L, narg);
|
||||
}
|
||||
template<> double Eluna::CHECKVAL<double>(lua_State* L, int narg, double def)
|
||||
{
|
||||
return luaL_optnumber(L, narg, def);
|
||||
}
|
||||
template<> int8 Eluna::CHECKVAL<int8>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkint(L, narg);
|
||||
}
|
||||
template<> int8 Eluna::CHECKVAL<int8>(lua_State* L, int narg, int8 def)
|
||||
{
|
||||
return luaL_optint(L, narg, def);
|
||||
}
|
||||
template<> uint8 Eluna::CHECKVAL<uint8>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkunsigned(L, narg);
|
||||
}
|
||||
template<> uint8 Eluna::CHECKVAL<uint8>(lua_State* L, int narg, uint8 def)
|
||||
{
|
||||
return luaL_optunsigned(L, narg, def);
|
||||
}
|
||||
template<> int16 Eluna::CHECKVAL<int16>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkint(L, narg);
|
||||
}
|
||||
template<> int16 Eluna::CHECKVAL<int16>(lua_State* L, int narg, int16 def)
|
||||
{
|
||||
return luaL_optint(L, narg, def);
|
||||
}
|
||||
template<> uint16 Eluna::CHECKVAL<uint16>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkunsigned(L, narg);
|
||||
}
|
||||
template<> uint16 Eluna::CHECKVAL<uint16>(lua_State* L, int narg, uint16 def)
|
||||
{
|
||||
return luaL_optunsigned(L, narg, def);
|
||||
}
|
||||
template<> uint32 Eluna::CHECKVAL<uint32>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkunsigned(L, narg);
|
||||
}
|
||||
template<> uint32 Eluna::CHECKVAL<uint32>(lua_State* L, int narg, uint32 def)
|
||||
{
|
||||
return luaL_optunsigned(L, narg, def);
|
||||
}
|
||||
template<> int32 Eluna::CHECKVAL<int32>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checklong(L, narg);
|
||||
}
|
||||
template<> int32 Eluna::CHECKVAL<int32>(lua_State* L, int narg, int32 def)
|
||||
{
|
||||
return luaL_optlong(L, narg, def);
|
||||
}
|
||||
template<> const char* Eluna::CHECKVAL<const char*>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkstring(L, narg);
|
||||
}
|
||||
template<> const char* Eluna::CHECKVAL<const char*>(lua_State* L, int narg, const char* def)
|
||||
{
|
||||
return luaL_optstring(L, narg, def);
|
||||
}
|
||||
template<> std::string Eluna::CHECKVAL<std::string>(lua_State* L, int narg)
|
||||
{
|
||||
return luaL_checkstring(L, narg);
|
||||
}
|
||||
template<> std::string Eluna::CHECKVAL<std::string>(lua_State* L, int narg, std::string def)
|
||||
{
|
||||
return luaL_optstring(L, narg, def.c_str());
|
||||
}
|
||||
template<> uint64 Eluna::CHECKVAL<uint64>(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<uint64>(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<int64>(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<int64>(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<T>::tname);\
|
||||
errmsg += " expected";\
|
||||
luaL_argerror(L, narg, errmsg.c_str());\
|
||||
}\
|
||||
return NULL;\
|
||||
}\
|
||||
return O->F();\
|
||||
}
|
||||
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error)
|
||||
{
|
||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
||||
TEST_OBJ(Unit, obj, error, ToUnit);
|
||||
}
|
||||
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error)
|
||||
{
|
||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
||||
TEST_OBJ(Player, obj, error, ToPlayer);
|
||||
}
|
||||
template<> Creature* Eluna::CHECKOBJ<Creature>(lua_State* L, int narg, bool error)
|
||||
{
|
||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
||||
TEST_OBJ(Creature, obj, error, ToCreature);
|
||||
}
|
||||
template<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error)
|
||||
{
|
||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
||||
TEST_OBJ(GameObject, obj, error, ToGameObject);
|
||||
}
|
||||
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error)
|
||||
{
|
||||
WorldObject* obj = CHECKOBJ<WorldObject>(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_VEHICLE:
|
||||
if (evt < VEHICLE_EVENT_COUNT)
|
||||
{
|
||||
VehicleEventBindings.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->GetGameObjectTemplate(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->GetGameObjectTemplate(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->GetItemTemplate(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->GetItemTemplate(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<int>(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();
|
||||
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<uint32> nodes;
|
||||
nodes.resize(2);
|
||||
nodes[0] = path[0].index;
|
||||
nodes[1] = path[path.size() - 1].index;
|
||||
|
||||
player->ActivateTaxiPathTo(nodes);
|
||||
}
|
||||
|
||||
uint32 LuaTaxiMgr::AddPath(std::list<TaxiPathNodeEntry> nodes, uint32 mountA, uint32 mountH, uint32 price, uint32 pathId)
|
||||
{
|
||||
if (nodes.size() < 2)
|
||||
return 0;
|
||||
if (!pathId)
|
||||
pathId = sTaxiPathNodesByPath.size();
|
||||
if (sTaxiPathNodesByPath.size() <= pathId)
|
||||
sTaxiPathNodesByPath.resize(pathId + 1);
|
||||
sTaxiPathNodesByPath[pathId].clear();
|
||||
sTaxiPathNodesByPath[pathId].resize(nodes.size());
|
||||
uint32 startNode = nodeId;
|
||||
uint32 index = 0;
|
||||
for (std::list<TaxiPathNodeEntry>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
|
||||
{
|
||||
TaxiPathNodeEntry entry = *it;
|
||||
entry.path = pathId;
|
||||
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
|
||||
nodeEntry->ID = index;
|
||||
nodeEntry->map_id = entry.mapid;
|
||||
nodeEntry->MountCreatureID[0] = mountH;
|
||||
nodeEntry->MountCreatureID[1] = mountA;
|
||||
nodeEntry->x = entry.x;
|
||||
nodeEntry->y = entry.y;
|
||||
nodeEntry->z = entry.z;
|
||||
sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
|
||||
entry.index = nodeId++;
|
||||
sTaxiPathNodesByPath[pathId].set(index++, TaxiPathNodePtr(new TaxiPathNodeEntry(entry)));
|
||||
}
|
||||
if (startNode >= nodeId)
|
||||
return 0;
|
||||
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
|
||||
return pathId;
|
||||
}
|
||||
689
LuaEngine.h
Normal file
689
LuaEngine.h
Normal file
@@ -0,0 +1,689 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef __ELUNA__H
|
||||
#define __ELUNA__H
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
};
|
||||
|
||||
#include "Includes.h"
|
||||
#include "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 "GuildMgr.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 "revision.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"
|
||||
#ifdef MANGOS
|
||||
#include "ReactorAI.h"
|
||||
#include "revision_nr.h"
|
||||
#else
|
||||
#include "ScriptedCreature.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "WeatherMgr.h"
|
||||
#endif
|
||||
#ifndef TBC
|
||||
#include "Vehicle.h"
|
||||
#endif
|
||||
|
||||
typedef std::set<std::string> LoadedScripts;
|
||||
|
||||
#define ELUNA_GUARD() \
|
||||
ACE_Guard< ACE_Thread_Mutex > ELUNA_GUARD_OBJECT (sEluna->lock);
|
||||
|
||||
#ifdef MANGOS
|
||||
#undef sWorld
|
||||
#undef sMapMgr
|
||||
#undef sGuildMgr
|
||||
#undef sObjectMgr
|
||||
#undef sAccountMgr
|
||||
#undef sObjectAccessor
|
||||
#define sWorld (&MaNGOS::Singleton<World>::Instance())
|
||||
#define sMapMgr (&MapManager::Instance())
|
||||
#define sGuildMgr (&MaNGOS::Singleton<GuildMgr>::Instance())
|
||||
#define sObjectMgr (&MaNGOS::Singleton<ObjectMgr>::Instance())
|
||||
#define sAccountMgr (&MaNGOS::Singleton<AccountMgr>::Instance())
|
||||
#define sObjectAccessor (&ObjectAccessor::Instance())
|
||||
#define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l)
|
||||
#define GUID_TYPE ObjectGuid
|
||||
#define GET_GUID GetObjectGuid
|
||||
#define GetGameObjectTemplate GetGameObjectInfo
|
||||
#define GetItemTemplate GetItemPrototype
|
||||
#define TC_LOG_INFO(L, ...) sLog.outString(__VA_ARGS__);
|
||||
#define TC_LOG_ERROR(L, ...) sLog.outErrorEluna(__VA_ARGS__);
|
||||
#define TC_LOG_DEBUG(L, ...) sLog.outDebug(__VA_ARGS__);
|
||||
#define CORE_VERSION REVISION_NR
|
||||
#define CORE_NAME "MaNGOS"
|
||||
#define SERVER_MSG_STRING SERVER_MSG_CUSTOM
|
||||
#define MAX_LOCALES MAX_LOCALE
|
||||
#define OVERRIDE override
|
||||
#define DIALOG_STATUS_SCRIPTED_NO_STATUS DIALOG_STATUS_UNDEFINED
|
||||
#define TempSummon TemporarySummon
|
||||
#define PLAYER_FIELD_LIFETIME_HONORABLE_KILLS PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
|
||||
#define MAX_TALENT_SPECS MAX_TALENT_SPEC_COUNT
|
||||
#define Vehicle VehicleInfo
|
||||
#define GUID_ENPART(guid) ObjectGuid(guid).GetEntry()
|
||||
#define GUID_LOPART(guid) ObjectGuid(guid).GetCounter()
|
||||
#define GUID_HIPART(guid) ObjectGuid(guid).GetHigh()
|
||||
enum SelectAggroTarget
|
||||
{
|
||||
SELECT_TARGET_RANDOM = 0, // Just selects a random target
|
||||
SELECT_TARGET_TOPAGGRO, // Selects targes from top aggro to bottom
|
||||
SELECT_TARGET_BOTTOMAGGRO, // Selects targets from bottom aggro to top
|
||||
SELECT_TARGET_NEAREST,
|
||||
SELECT_TARGET_FARTHEST
|
||||
};
|
||||
#ifdef TBC
|
||||
#define SPELL_AURA_MOD_KILL_XP_PCT SPELL_AURA_MOD_XP_PCT
|
||||
#endif
|
||||
#else
|
||||
#define GUID_TYPE uint64
|
||||
#define GET_GUID GetGUID
|
||||
#define CORE_VERSION _DATE
|
||||
#define CORE_NAME "TrinityCore"
|
||||
#define REGEN_TIME_FULL
|
||||
#define ThreatList ThreatContainer::StorageType
|
||||
#ifdef CATA
|
||||
#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct ElunaRegister
|
||||
{
|
||||
const char* name;
|
||||
int(*mfunc)(lua_State*, T*);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
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/<core>
|
||||
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<typename C>
|
||||
static void SetMethods(lua_State* L, ElunaRegister<C>* 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<T**>(lua_touserdata(L, narg));
|
||||
if (!ptrHold)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
std::string errmsg(ElunaTemplate<Unit>::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<T>* l = static_cast<ElunaRegister<T>*>(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<LuaEvent*> EventSet;
|
||||
typedef std::map<EventProcessor*, EventSet> EventMap;
|
||||
// typedef UNORDERED_MAP<uint64, EventProcessor> 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<int> ElunaBindingMap;
|
||||
typedef std::map<int, ElunaBindingMap> 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<int, int> ElunaBindingMap;
|
||||
typedef std::map<uint32, ElunaBindingMap> 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<typename T> void Push(lua_State* L, T const* ptr)
|
||||
{
|
||||
ElunaTemplate<T>::push(L, ptr);
|
||||
}
|
||||
void Push(lua_State* L, Object const* obj);
|
||||
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, TempSummon const* summon);
|
||||
|
||||
// Checks
|
||||
template<typename T> T CHECKVAL(lua_State* L, int narg);
|
||||
template<typename T> T CHECKVAL(lua_State* L, int narg, T def);
|
||||
template<typename T> T* CHECKOBJ(lua_State* L, int narg, bool error = true)
|
||||
{
|
||||
return ElunaTemplate<T>::check(L, narg, error);
|
||||
}
|
||||
|
||||
struct ObjectGUIDCheck
|
||||
{
|
||||
ObjectGUIDCheck(GUID_TYPE guid) : _guid(guid) { }
|
||||
bool operator()(WorldObject* object)
|
||||
{
|
||||
return object->GET_GUID() == _guid;
|
||||
}
|
||||
|
||||
GUID_TYPE _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->GET_GUID() == u->GET_GUID())
|
||||
return false;
|
||||
if (!i_obj->IsWithinDistInMap(u, i_range))
|
||||
return false;
|
||||
if (Unit* unit = u->ToUnit())
|
||||
{
|
||||
#ifdef MANGOS
|
||||
if (!unit->isAlive())
|
||||
return false;
|
||||
#else
|
||||
if (!unit->IsAlive())
|
||||
return false;
|
||||
#endif
|
||||
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<Unit>(lua_State* L, int narg, bool error);
|
||||
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error);
|
||||
template<> Creature* Eluna::CHECKOBJ<Creature>(lua_State* L, int narg, bool error);
|
||||
template<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error);
|
||||
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error);
|
||||
|
||||
#ifdef MANGOS
|
||||
#define sEluna (&MaNGOS::Singleton<Eluna>::Instance())
|
||||
#else
|
||||
#define sEluna ACE_Singleton<Eluna, ACE_Null_Mutex>::instance()
|
||||
#endif
|
||||
|
||||
class LuaTaxiMgr
|
||||
{
|
||||
private:
|
||||
static uint32 nodeId;
|
||||
public:
|
||||
static void StartTaxi(Player* player, uint32 pathid);
|
||||
static uint32 AddPath(std::list<TaxiPathNodeEntry> nodes, uint32 mountA, uint32 mountH, uint32 price = 0, uint32 pathId = 0);
|
||||
};
|
||||
#endif
|
||||
1215
LuaFunctions.cpp
Normal file
1215
LuaFunctions.cpp
Normal file
File diff suppressed because it is too large
Load Diff
114
MapMethods.h
Normal file
114
MapMethods.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef MAPMETHODS_H
|
||||
#define MAPMETHODS_H
|
||||
|
||||
namespace LuaMap
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsArena(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->IsBattleArena());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsBattleground(lua_State* L, Map* map)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, map->IsBattleGround());
|
||||
#else
|
||||
sEluna->Push(L, map->IsBattleground());
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
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<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
#ifdef TBC
|
||||
float z = map->GetHeight(x, y, MAX_HEIGHT);
|
||||
#else
|
||||
uint32 phasemask = sEluna->CHECKVAL<uint32>(L, 4, 1);
|
||||
float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
|
||||
#endif
|
||||
if (z == INVALID_HEIGHT)
|
||||
return 0;
|
||||
sEluna->Push(L, z);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDifficulty(lua_State* L, Map* map)
|
||||
{
|
||||
sEluna->Push(L, map->GetDifficulty());
|
||||
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<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
float z = sEluna->CHECKVAL<float>(L, 4);
|
||||
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, map->GetTerrain()->GetAreaId(x, y, z));
|
||||
#else
|
||||
sEluna->Push(L, map->GetAreaId(x, y, z));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
214
ObjectMethods.h
Normal file
214
ObjectMethods.h
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef OBJECTMETHODS_H
|
||||
#define OBJECTMETHODS_H
|
||||
|
||||
namespace LuaObject
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int HasFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
|
||||
sEluna->Push(L, obj->HasFlag(index, flag));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int IsInWorld(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->IsInWorld());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetUInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
sEluna->Push(L, obj->GetFloatValue(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
sEluna->Push(L, obj->GetByteValue(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
sEluna->Push(L, obj->GetUInt16Value(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetObjectScale());
|
||||
return 1;
|
||||
}
|
||||
|
||||
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->GET_GUID());
|
||||
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;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->SetFlag(index, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
int32 value = sEluna->CHECKVAL<int32>(L, 3);
|
||||
obj->SetInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
obj->SetUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
float value = sEluna->CHECKVAL<float>(L, 3);
|
||||
|
||||
obj->SetFloatValue(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
uint8 value = sEluna->CHECKVAL<uint8>(L, 4);
|
||||
obj->SetByteValue(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
uint16 value = sEluna->CHECKVAL<uint16>(L, 4);
|
||||
obj->SetUInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = sEluna->CHECKVAL<uint8>(L, 3);
|
||||
int16 value = sEluna->CHECKVAL<int16>(L, 4);
|
||||
obj->SetInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
float size = sEluna->CHECKVAL<float>(L, 2);
|
||||
|
||||
obj->SetObjectScale(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int RemoveFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->RemoveFlag(index, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UpdateUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = sEluna->CHECKVAL<uint32>(L, 3);
|
||||
obj->UpdateUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ToCorpse(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToCorpse());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ToGameObject(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToGameObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ToUnit(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToUnit());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ToCreature(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToCreature());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ToPlayer(lua_State* L, Object* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->ToPlayer());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
2328
PlayerMethods.h
Normal file
2328
PlayerMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
188
QueryMethods.h
Normal file
188
QueryMethods.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef QUERYMETHODS_H
|
||||
#define QUERYMETHODS_H
|
||||
|
||||
#ifdef MANGOS
|
||||
#define RESULT result
|
||||
#else
|
||||
#define RESULT (*result)
|
||||
#endif
|
||||
namespace LuaQuery
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsNull(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(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;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
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 GetBool(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(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<uint32>(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<uint32>(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<uint32>(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<uint32>(L, 2);
|
||||
if (!result || col >= RESULT->GetFieldCount())
|
||||
sEluna->Push(L, 0);
|
||||
else
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetUInt64());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt8(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
if (!result || col >= RESULT->GetFieldCount())
|
||||
sEluna->Push(L, 0);
|
||||
else
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetInt8());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetInt16(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(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<uint32>(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<uint32>(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<uint32>(L, 2);
|
||||
if (!result || col >= RESULT->GetFieldCount())
|
||||
sEluna->Push(L, 0.0f);
|
||||
else
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetFloat());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDouble(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
if (!result || col >= RESULT->GetFieldCount())
|
||||
sEluna->Push(L, 0.0);
|
||||
else
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetDouble());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetString(lua_State* L, QueryResult* result)
|
||||
{
|
||||
uint32 col = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
if (!result || col >= RESULT->GetFieldCount())
|
||||
sEluna->Push(L, "");
|
||||
else
|
||||
sEluna->Push(L, RESULT->Fetch()[col].GetString());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int NextRow(lua_State* L, QueryResult* result)
|
||||
{
|
||||
if (!result)
|
||||
sEluna->Push(L, false);
|
||||
else
|
||||
sEluna->Push(L, RESULT->NextRow());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#undef RESULT
|
||||
|
||||
#endif
|
||||
103
QuestMethods.h
Normal file
103
QuestMethods.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef QUESTMETHODS_H
|
||||
#define QUESTMETHODS_H
|
||||
|
||||
namespace LuaQuest
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int HasFlag(lua_State* L, Quest* quest)
|
||||
{
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, quest->HasQuestFlag((QuestFlags)flag));
|
||||
#else
|
||||
sEluna->Push(L, quest->HasFlag(flag));
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
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 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)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, quest->GetQuestFlags());
|
||||
#else
|
||||
sEluna->Push(L, quest->GetFlags());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetType(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int GetMaxLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
sEluna->Push(L, quest->GetMaxLevel());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/* SETTERS */
|
||||
int SetFlag(lua_State* L, Quest* quest)
|
||||
{
|
||||
uint32 flag = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
quest->SetSpecialFlag((QuestSpecialFlags)flag);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
36
README.md
Normal file
36
README.md
Normal file
@@ -0,0 +1,36 @@
|
||||

|
||||
|
||||
## About
|
||||
|
||||
Eluna is a Lua Engine for World of Warcraft emulators. Eluna is supporting MaNGOS and TrinityCore.
|
||||
We want to be the major Lua source for World of Warcraft emulation.<br />
|
||||
Follow us on our [Twitter](https://twitter.com/EmuDevs) page to view the latest news about EmuDevs and what's going on with Eluna.
|
||||
|
||||
If you're having trouble, post in Eluna's support here: [Eluna Support Forum](http://emudevs.com/forumdisplay.php/84-Support)<br />
|
||||
If you need help regarding methods, hooks and other wiki related documentation, go to [Eluna's Wiki](http://wiki.emudevs.com/doku.php?id=eluna).
|
||||
|
||||
## Source
|
||||
|
||||
[](https://travis-ci.org/ElunaLuaEngine/Eluna-TC-Wotlk) [Eluna TrinityCore WOTLK](https://github.com/ElunaLuaEngine/Eluna-TC-Wotlk)<br />
|
||||
[](https://travis-ci.org/ElunaLuaEngine/Eluna-TC-Cata) [Eluna TrinityCore Cataclysm](https://github.com/ElunaLuaEngine/Eluna-TC-Cata)
|
||||
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreClassic) [Eluna cMaNGOS Classic](https://github.com/eluna-dev-mangos/ElunaCoreClassic)<br />
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreTbc) [Eluna cMaNGOS TBC](https://github.com/eluna-dev-mangos/ElunaCoreTbc)<br />
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreWotlk) [Eluna cMaNGOS WotLK](https://github.com/eluna-dev-mangos/ElunaCoreWotlk)
|
||||
|
||||
## Links
|
||||
|
||||
* [Installation & Updating](/docs/INSTALL.md)
|
||||
* [Eluna Wiki](http://wiki.emudevs.com/doku.php?id=eluna)
|
||||
* [Eluna Scripts](https://github.com/ElunaLuaEngine/Scripts)
|
||||
* [Eluna Support Forum](http://emudevs.com)
|
||||
* [cMaNGOS](http://cmangos.net/)
|
||||
* [TrinityCore](http://www.trinitycore.org/)
|
||||
* [License](/docs/LICENSE.md)
|
||||
|
||||
## Team
|
||||
|
||||
* Tommy (Easelm)
|
||||
* Foereaper
|
||||
* Rochet2
|
||||
* Salja
|
||||
131
SpellMethods.h
Normal file
131
SpellMethods.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef SPELLMETHODS_H
|
||||
#define SPELLMETHODS_H
|
||||
|
||||
namespace LuaSpell
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->IsAutoRepeat());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
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->m_spellInfo->Id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPowerCost(lua_State* L, Spell* spell)
|
||||
{
|
||||
sEluna->Push(L, spell->GetPowerCost());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDuration(lua_State* L, Spell* spell)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, GetSpellDuration(spell->m_spellInfo));
|
||||
#else
|
||||
sEluna->Push(L, spell->GetSpellInfo()->GetDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetTargetDest(lua_State* L, Spell* spell)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
|
||||
return 0;
|
||||
float x, y, z;
|
||||
spell->m_targets.getDestination(x, y, z);
|
||||
#else
|
||||
if (!spell->m_targets.HasDst())
|
||||
return 0;
|
||||
float x, y, z;
|
||||
spell->m_targets.GetDstPos()->GetPosition(x, y, z);
|
||||
#endif
|
||||
sEluna->Push(L, x);
|
||||
sEluna->Push(L, y);
|
||||
sEluna->Push(L, z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
int GetTarget(lua_State* L, Spell* spell)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
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->GetCaster()->GetMap()->GetCorpse(spell->m_targets.getCorpseTargetGuid()))
|
||||
sEluna->Push(sEluna->L, target);
|
||||
else if (Unit* target = spell->m_targets.getUnitTarget())
|
||||
sEluna->Push(sEluna->L, target);
|
||||
else
|
||||
sEluna->Push(sEluna->L);
|
||||
#else
|
||||
if (GameObject* target = spell->m_targets.GetGOTarget())
|
||||
sEluna->Push(L, target);
|
||||
else if (Item* target = spell->m_targets.GetItemTarget())
|
||||
sEluna->Push(L, target);
|
||||
else if (Corpse* target = spell->m_targets.GetCorpseTarget())
|
||||
sEluna->Push(L, target);
|
||||
else if (Unit* target = spell->m_targets.GetUnitTarget())
|
||||
sEluna->Push(L, target);
|
||||
else if (WorldObject* target = spell->m_targets.GetObjectTarget())
|
||||
sEluna->Push(L, target);
|
||||
else
|
||||
sEluna->Push(L);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool repeat = sEluna->CHECKVAL<bool>(L, 2);
|
||||
spell->SetAutoRepeat(repeat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int Cast(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool skipCheck = sEluna->CHECKVAL<bool>(L, 2);
|
||||
spell->cast(skipCheck);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cancel(lua_State* L, Spell* spell)
|
||||
{
|
||||
spell->cancel();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Finish(lua_State* L, Spell* spell)
|
||||
{
|
||||
spell->finish();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
1710
UnitMethods.h
Normal file
1710
UnitMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
80
VehicleMethods.h
Normal file
80
VehicleMethods.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef TBC
|
||||
#ifndef VEHICLEMETHODS_H
|
||||
#define VEHICLEMETHODS_H
|
||||
|
||||
namespace LuaVehicle
|
||||
{
|
||||
/* BOOLEAN */
|
||||
int IsOnBoard(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->HasOnBoard(passenger));
|
||||
#else
|
||||
sEluna->Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* GETTERS */
|
||||
int GetOwner(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->GetOwner());
|
||||
#else
|
||||
sEluna->Push(L, vehicle->GetBase());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetEntry(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, vehicle->GetVehicleEntry()->m_ID);
|
||||
#else
|
||||
sEluna->Push(L, vehicle->GetVehicleInfo()->m_ID);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
int8 seatId = sEluna->CHECKVAL<int8>(L, 2);
|
||||
sEluna->Push(L, vehicle->GetPassenger(seatId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int AddPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
int8 seatId = sEluna->CHECKVAL<int8>(L, 3);
|
||||
#ifdef MANGOS
|
||||
if (vehicle->CanBoard(passenger))
|
||||
vehicle->Board(passenger, seatId);
|
||||
#else
|
||||
vehicle->AddPassenger(passenger, seatId);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RemovePassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = sEluna->CHECKOBJ<Unit>(L, 2);
|
||||
#ifdef MANGOS
|
||||
vehicle->UnBoard(passenger, false);
|
||||
#else
|
||||
vehicle->RemovePassenger(passenger);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
51
WeatherMethods.h
Normal file
51
WeatherMethods.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef WEATHERMETHODS_H
|
||||
#define WEATHERMETHODS_H
|
||||
|
||||
namespace LuaWeather
|
||||
{
|
||||
/* GETTERS */
|
||||
int GetZoneId(lua_State* L, Weather* weather)
|
||||
{
|
||||
sEluna->Push(L, weather->GetZone());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* SETTERS */
|
||||
int SetWeather(lua_State* L, Weather* weather)
|
||||
{
|
||||
uint32 weatherType = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float grade = sEluna->CHECKVAL<float>(L, 3);
|
||||
|
||||
weather->SetWeather((WeatherType)weatherType, grade);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SendWeatherUpdateToPlayer(lua_State* L, Weather* weather)
|
||||
{
|
||||
Player* player = sEluna->CHECKOBJ<Player>(L, 2);
|
||||
|
||||
weather->SendWeatherUpdateToPlayer(player);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
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
|
||||
432
WorldObjectMethods.h
Normal file
432
WorldObjectMethods.h
Normal file
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef WORLDOBJECTMETHODS_H
|
||||
#define WORLDOBJECTMETHODS_H
|
||||
|
||||
namespace LuaWorldObject
|
||||
{
|
||||
/* GETTERS */
|
||||
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;
|
||||
}
|
||||
|
||||
#ifndef TBC
|
||||
int GetPhaseMask(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
sEluna->Push(L, obj->GetPhaseMask());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
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<float>(L, 2, SIZE_OF_GRIDS);
|
||||
|
||||
Unit* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_PLAYER);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::UnitLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(target, checker);
|
||||
Cell::VisitWorldObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::UnitLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNearestGameObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
GameObject* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_GAMEOBJECT, entry);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::GameObjectLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(target, checker);
|
||||
Cell::VisitGridObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::GameObjectLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetNearestCreature(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
Creature* target = NULL;
|
||||
Eluna::WorldObjectInRangeCheck checker(true, obj, range, TYPEMASK_UNIT, entry);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::CreatureLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(target, checker);
|
||||
Cell::VisitGridObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::CreatureLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetPlayersInRange(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float range = sEluna->CHECKVAL<float>(L, 2, SIZE_OF_GRIDS);
|
||||
|
||||
std::list<Player*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_PLAYER);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::PlayerListSearcher<Eluna::WorldObjectInRangeCheck> searcher(list, checker);
|
||||
Cell::VisitWorldObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::PlayerListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
for (std::list<Player*>::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<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
std::list<Creature*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_UNIT, entry);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::CreatureListSearcher<Eluna::WorldObjectInRangeCheck> searcher(list, checker);
|
||||
Cell::VisitGridObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::CreatureListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
for (std::list<Creature*>::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<float>(L, 2, SIZE_OF_GRIDS);
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
std::list<GameObject*> list;
|
||||
Eluna::WorldObjectInRangeCheck checker(false, obj, range, TYPEMASK_GAMEOBJECT, entry);
|
||||
#ifdef MANGOS
|
||||
MaNGOS::GameObjectListSearcher<Eluna::WorldObjectInRangeCheck> searcher(list, checker);
|
||||
Cell::VisitGridObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::GameObjectListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
for (std::list<GameObject*>::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<bool>(L, 2, true);
|
||||
float range = sEluna->CHECKVAL<float>(L, 3, SIZE_OF_GRIDS);
|
||||
uint16 type = sEluna->CHECKVAL<uint16>(L, 4, 0); // TypeMask
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 5, 0);
|
||||
uint32 hostile = sEluna->CHECKVAL<uint32>(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;
|
||||
#ifdef MANGOS
|
||||
MaNGOS::WorldObjectLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(target, checker);
|
||||
Cell::VisitAllObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::WorldObjectLastSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, target, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
sEluna->Push(L, target);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::list<WorldObject*> list;
|
||||
#ifdef MANGOS
|
||||
MaNGOS::WorldObjectListSearcher<Eluna::WorldObjectInRangeCheck> searcher(list, checker);
|
||||
Cell::VisitAllObjects(obj, searcher, range);
|
||||
#else
|
||||
Trinity::WorldObjectListSearcher<Eluna::WorldObjectInRangeCheck> searcher(obj, list, checker);
|
||||
obj->VisitNearbyObject(range, searcher);
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
for (std::list<WorldObject*>::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<uint64>(L, 2);
|
||||
|
||||
#ifdef MANGOS
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER: sEluna->Push(L, obj->GetMap()->GetPlayer(GUID_TYPE(guid))); break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT: sEluna->Push(L, obj->GetMap()->GetGameObject(GUID_TYPE(guid))); break;
|
||||
#ifndef TBC
|
||||
case HIGHGUID_VEHICLE:
|
||||
#endif
|
||||
case HIGHGUID_UNIT:
|
||||
case HIGHGUID_PET: sEluna->Push(L, obj->GetMap()->GetAnyTypeCreature(GUID_TYPE(guid))); break;
|
||||
default: return 0;
|
||||
}
|
||||
#else
|
||||
switch (GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER: sEluna->Push(L, sObjectAccessor->GetPlayer(*obj, GUID_TYPE(guid))); break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT: sEluna->Push(L, sObjectAccessor->GetGameObject(*obj, GUID_TYPE(guid))); break;
|
||||
case HIGHGUID_VEHICLE:
|
||||
case HIGHGUID_UNIT: sEluna->Push(L, sObjectAccessor->GetCreature(*obj, GUID_TYPE(guid))); break;
|
||||
case HIGHGUID_PET: sEluna->Push(L, sObjectAccessor->GetPet(*obj, GUID_TYPE(guid))); break;
|
||||
default: return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetDistance(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
WorldObject* target = sEluna->CHECKOBJ<WorldObject>(L, 2, false);
|
||||
if (target && target->IsInWorld())
|
||||
sEluna->Push(L, obj->GetDistance(target));
|
||||
else
|
||||
{
|
||||
float X = sEluna->CHECKVAL<float>(L, 2);
|
||||
float Y = sEluna->CHECKVAL<float>(L, 3);
|
||||
float Z = sEluna->CHECKVAL<float>(L, 4);
|
||||
sEluna->Push(L, obj->GetDistance(X, Y, Z));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetRelativePoint(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
float dist = sEluna->CHECKVAL<float>(L, 2);
|
||||
float rad = sEluna->CHECKVAL<float>(L, 3);
|
||||
|
||||
float x, y, z;
|
||||
obj->GetClosePoint(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<WorldObject>(L, 2, false);
|
||||
|
||||
if (target && target->IsInWorld())
|
||||
sEluna->Push(L, obj->GetAngle(target));
|
||||
else
|
||||
{
|
||||
float x = sEluna->CHECKVAL<float>(L, 2);
|
||||
float y = sEluna->CHECKVAL<float>(L, 3);
|
||||
sEluna->Push(L, obj->GetAngle(x, y));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
int SendPacket(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
WorldPacket* data = sEluna->CHECKOBJ<WorldPacket>(L, 2);
|
||||
obj->SendMessageToSet(data, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SummonGameObject(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float x = sEluna->CHECKVAL<float>(L, 3);
|
||||
float y = sEluna->CHECKVAL<float>(L, 4);
|
||||
float z = sEluna->CHECKVAL<float>(L, 5);
|
||||
float o = sEluna->CHECKVAL<float>(L, 6);
|
||||
uint32 respawnDelay = sEluna->CHECKVAL<uint32>(L, 7, 30);
|
||||
#ifdef MANGOS
|
||||
sEluna->Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay));
|
||||
#else
|
||||
sEluna->Push(L, obj->SummonGameObject(entry, x, y, z, o, 0, 0, 0, 0, respawnDelay));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SpawnCreature(lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 entry = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
float x = sEluna->CHECKVAL<float>(L, 3);
|
||||
float y = sEluna->CHECKVAL<float>(L, 4);
|
||||
float z = sEluna->CHECKVAL<float>(L, 5);
|
||||
float o = sEluna->CHECKVAL<float>(L, 6);
|
||||
uint32 spawnType = sEluna->CHECKVAL<uint32>(L, 7, 8);
|
||||
uint32 despawnTimer = sEluna->CHECKVAL<uint32>(L, 8, 0);
|
||||
|
||||
TempSummonType 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
|
||||
207
WorldPacketMethods.h
Normal file
207
WorldPacketMethods.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2014 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md 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<uint32>(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<uint64>(L, 2);
|
||||
(*packet) << guid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteString(string)
|
||||
int WriteString(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
std::string _val = sEluna->CHECKVAL<std::string>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteBye(byte)
|
||||
int WriteByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int8 byte = sEluna->CHECKVAL<int8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteUByte(byte)
|
||||
int WriteUByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint8 byte = sEluna->CHECKVAL<uint8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteUShort(short)
|
||||
int WriteUShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint16 _ushort = sEluna->CHECKVAL<uint16>(L, 2);
|
||||
(*packet) << _ushort;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteShort(short)
|
||||
int WriteShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int16 _short = sEluna->CHECKVAL<int16>(L, 2);
|
||||
(*packet) << _short;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteLong(long)
|
||||
int WriteLong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int32 _long = sEluna->CHECKVAL<int32>(L, 2);
|
||||
(*packet) << _long;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteULong(long)
|
||||
int WriteULong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 _ulong = sEluna->CHECKVAL<uint32>(L, 2);
|
||||
(*packet) << _ulong;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteFloat(float)
|
||||
int WriteFloat(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
float _val = sEluna->CHECKVAL<float>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// WriteDouble(double)
|
||||
int WriteDouble(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
double _val = sEluna->CHECKVAL<double>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
33
docs/INSTALL.md
Normal file
33
docs/INSTALL.md
Normal file
@@ -0,0 +1,33 @@
|
||||
#Installation
|
||||
Get the core:<br/>
|
||||
[](https://travis-ci.org/ElunaLuaEngine/Eluna-TC-Wotlk) [Eluna TrinityCore WOTLK](https://github.com/ElunaLuaEngine/Eluna-TC-Wotlk)<br />
|
||||
[](https://travis-ci.org/ElunaLuaEngine/Eluna-TC-Cata) [Eluna TrinityCore Cataclysm](https://github.com/ElunaLuaEngine/Eluna-TC-Cata)
|
||||
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreClassic) [Eluna cMaNGOS Classic](https://github.com/eluna-dev-mangos/ElunaCoreClassic)<br />
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreTbc) [Eluna cMaNGOS TBC](https://github.com/eluna-dev-mangos/ElunaCoreTbc)<br />
|
||||
[](https://travis-ci.org/eluna-dev-mangos/ElunaCoreWotlk) [Eluna cMaNGOS WotLK](https://github.com/eluna-dev-mangos/ElunaCoreWotlk)
|
||||
|
||||
On **TrinityCore** navigate to `\src\`<br />
|
||||
On **MaNGOS** navigate to `\src\game\`<br />
|
||||
|
||||
Open `git bash` in `LuaEngine` folder and do
|
||||
1. `git init`
|
||||
2. `git remote add origin https://github.com/ElunaLuaEngine/Eluna`
|
||||
3. `git pull origin master`
|
||||
|
||||
Compile the core normally (use cmake on TC)
|
||||
|
||||
#Updating
|
||||
When updating you should take up the `commit hashes` you are on, just in case.
|
||||
You can get it from git with `git log` for example.
|
||||
Use this when git is open in the source folder as well as in LuaEngine folder.
|
||||
You should take note what are the newest SQL updates in `sql/updates/*` folders.
|
||||
|
||||
Use `git pull` in core source and in LuaEngine folder to get the newest source changes and Eluna from github.
|
||||
Try compiling and if you encounter errors, report to [support](https://github.com/ElunaLuaEngine/Eluna#links) or [issues](https://github.com/ElunaLuaEngine/Eluna/issues).
|
||||
You can revert back to the old sources by using `git reset --hard 000000`, where 000000 is the `commit hash`.
|
||||
|
||||
If the compiling was successful, you should update your database if needed.
|
||||
You can do this by running all **new** SQL files in `sql/updates/*`.
|
||||
You need to see your notes from before pulling the updates or you can use the old commit hash to see on github what were the last files you ran.
|
||||
An easy way is to just look at the created/modified date on the files.
|
||||
220
docs/LICENSE.md
Normal file
220
docs/LICENSE.md
Normal file
@@ -0,0 +1,220 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
0. Definitions.
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU 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 <http://www.gnu.org/licenses/>.
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
Reference in New Issue
Block a user