Skip to content

Commit

Permalink
[Eluna] Updated Eluna to latest revision. Thanks to @PargeLenis for h…
Browse files Browse the repository at this point in the history
…elping fix
  • Loading branch information
billy1arm committed Nov 16, 2023
1 parent 226b1c5 commit 1960d6e
Show file tree
Hide file tree
Showing 110 changed files with 53,971 additions and 1,823 deletions.
12 changes: 10 additions & 2 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ source_group("World\\Handlers" FILES ${SRC_GRP_WORLD_HANDLERS})

# Build the Eluna library if enabled
if(SCRIPT_LIB_ELUNA)
file(GLOB SRC_GRP_ELUNA ${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.cpp ${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.h)
file(GLOB SRC_GRP_ELUNA
${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/*.h
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos/*.cpp
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos/*.h
)
source_group("Eluna" FILES ${SRC_GRP_ELUNA})
endif()

Expand Down Expand Up @@ -255,7 +260,10 @@ target_include_directories(game
Warden
Warden/Modules
WorldHandlers
$<$<BOOL:${SCRIPT_LIB_ELUNA}>:${CMAKE_SOURCE_DIR}/src/modules/Eluna>
$<$<BOOL:${SCRIPT_LIB_ELUNA}>:
${CMAKE_SOURCE_DIR}/src/modules/Eluna
${CMAKE_SOURCE_DIR}/src/modules/Eluna/Mangos
>
$<$<BOOL:${PLAYERBOTS}>:
${CMAKE_SOURCE_DIR}/src/modules/Bots
${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Eluna/BindingMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class hash_helper
{
return std::hash<typename std::underlying_type<T>::type>()(t);
}

template <typename T, typename std::enable_if<!std::is_enum<T>::value>::type* = nullptr>
static inline result_type hash(T const & t)
{
Expand Down
80 changes: 0 additions & 80 deletions src/modules/Eluna/CMakeLists.txt

This file was deleted.

206 changes: 206 additions & 0 deletions src/modules/Eluna/CMangos/AuraMethods.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*
* Copyright (C) 2010 - 2016 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

/***
* The persistent effect of a [Spell] that remains on a [Unit] after the [Spell]
* has been cast.
*
* As an example, if you cast a damage-over-time spell on a target, an [Aura] is
* put on the target that deals damage continuously.
*
* [Aura]s on your player are displayed in-game as a series of icons to the left
* of the mini-map.
*
* Inherits all methods from: none
*/
namespace LuaAura
{
/**
* Returns the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return [Unit] caster
*/
int GetCaster(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetCaster());
return 1;
}

/**
* Returns the GUID of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return string caster_guid : the GUID of the Unit as a decimal string
*/
int GetCasterGUID(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetCasterGuid());
return 1;
}

/**
* Returns the level of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
*
* @return uint32 caster_level
*/
int GetCasterLevel(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetCaster()->GetLevel());
return 1;
}

/**
* Returns the amount of time left until the [Aura] expires.
*
* @return int32 duration : amount of time left in milliseconds
*/
int GetDuration(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetAuraDuration());
return 1;
}

/**
* Returns the ID of the [Spell] that caused this [Aura] to be applied.
*
* @return uint32 aura_id
*/
int GetAuraId(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetId());
return 1;
}

/**
* Returns the amount of time this [Aura] lasts when applied.
*
* To determine how much time has passed since this Aura was applied,
* subtract the result of [Aura]:GetDuration from the result of this method.
*
* @return int32 max_duration : the maximum duration of the Aura, in milliseconds
*/
int GetMaxDuration(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetAuraMaxDuration());
return 1;
}

/**
* Returns the number of times the [Aura] has "stacked".
*
* This is the same as the number displayed on the [Aura]'s icon in-game.
*
* @return uint32 stack_amount
*/
int GetStackAmount(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetStackAmount());
return 1;
}

/**
* Returns the [Unit] that the [Aura] has been applied to.
*
* @return [Unit] owner
*/
int GetOwner(lua_State* L, Aura* aura)
{
Eluna::Push(L, aura->GetTarget());
return 1;
}

/**
* Change the amount of time before the [Aura] expires.
*
* @param int32 duration : the new duration of the Aura, in milliseconds
*/
int SetDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
aura->GetHolder()->SetAuraDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
return 0;
}

/**
* Change the maximum amount of time before the [Aura] expires.
*
* This does not affect the current duration of the [Aura], but if the [Aura]
* is reset to the maximum duration, it will instead change to `duration`.
*
* @param int32 duration : the new maximum duration of the Aura, in milliseconds
*/
int SetMaxDuration(lua_State* L, Aura* aura)
{
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
aura->GetHolder()->SetAuraMaxDuration(duration);
#if (defined(TBC) || defined(CLASSIC))
aura->GetHolder()->UpdateAuraDuration();
#else
aura->GetHolder()->SendAuraUpdate(false);
#endif
return 0;
}

/**
* Change the amount of times the [Aura] has "stacked" on the [Unit].
*
* If `amount` is greater than or equal to the current number of stacks,
* then the [Aura] has its duration reset to the maximum duration.
*
* @param uint32 amount
*/
int SetStackAmount(lua_State* L, Aura* aura)
{
uint8 amount = Eluna::CHECKVAL<uint8>(L, 2);
#ifndef CATA
aura->GetHolder()->SetStackAmount(amount, aura->GetTarget());
#else
aura->GetHolder()->SetStackAmount(amount);
#endif
return 0;
}

/**
* Remove this [Aura] from the [Unit] it is applied to.
*/
int Remove(lua_State* L, Aura* aura)
{
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
return 0;
}

ElunaRegister<Aura> AuraMethods[] =
{
// Getters
{ "GetCaster", &LuaAura::GetCaster },
{ "GetCasterGUID", &LuaAura::GetCasterGUID },
{ "GetCasterLevel", &LuaAura::GetCasterLevel },
{ "GetDuration", &LuaAura::GetDuration },
{ "GetMaxDuration", &LuaAura::GetMaxDuration },
{ "GetAuraId", &LuaAura::GetAuraId },
{ "GetStackAmount", &LuaAura::GetStackAmount },
{ "GetOwner", &LuaAura::GetOwner },

// Setters
{ "SetDuration", &LuaAura::SetDuration },
{ "SetMaxDuration", &LuaAura::SetMaxDuration },
{ "SetStackAmount", &LuaAura::SetStackAmount },

// Other
{ "Remove", &LuaAura::Remove },

{ NULL, NULL }
};
};
#endif
Loading

0 comments on commit 1960d6e

Please sign in to comment.