Added the OnEntityAddEffect hook.
This commit is contained in:
parent
9e8361976b
commit
fa1d85feca
|
@ -57,6 +57,7 @@ public:
|
||||||
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
|
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
|
||||||
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
|
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
|
||||||
|
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) = 0;
|
||||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
|
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
|
||||||
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||||
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||||
|
|
|
@ -420,6 +420,26 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CriticalSection);
|
||||||
|
bool res = false;
|
||||||
|
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
|
||||||
|
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||||
|
{
|
||||||
|
m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier, cLuaState::Return, res);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
|
bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CriticalSection);
|
cCSLock Lock(m_CriticalSection);
|
||||||
|
@ -1507,6 +1527,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
|
||||||
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
|
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
|
||||||
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
|
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
|
||||||
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
|
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
|
||||||
|
case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect";
|
||||||
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
|
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
|
||||||
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
|
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
|
||||||
case cPluginManager::HOOK_KILLING: return "OnKilling";
|
case cPluginManager::HOOK_KILLING: return "OnKilling";
|
||||||
|
|
|
@ -80,6 +80,7 @@ public:
|
||||||
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
|
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
|
||||||
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
|
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
|
||||||
|
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) override;
|
||||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
|
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
|
||||||
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
||||||
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
||||||
|
|
|
@ -448,6 +448,27 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
|
||||||
|
{
|
||||||
|
HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT);
|
||||||
|
if (Plugins == m_Hooks.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
|
||||||
|
{
|
||||||
|
if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
|
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
|
||||||
{
|
{
|
||||||
FIND_HOOK(HOOK_EXECUTE_COMMAND);
|
FIND_HOOK(HOOK_EXECUTE_COMMAND);
|
||||||
|
|
|
@ -73,6 +73,7 @@ public: // tolua_export
|
||||||
HOOK_CRAFTING_NO_RECIPE,
|
HOOK_CRAFTING_NO_RECIPE,
|
||||||
HOOK_DISCONNECT,
|
HOOK_DISCONNECT,
|
||||||
HOOK_PLAYER_ANIMATION,
|
HOOK_PLAYER_ANIMATION,
|
||||||
|
HOOK_ENTITY_ADD_EFFECT,
|
||||||
HOOK_EXECUTE_COMMAND,
|
HOOK_EXECUTE_COMMAND,
|
||||||
HOOK_EXPLODED,
|
HOOK_EXPLODED,
|
||||||
HOOK_EXPLODING,
|
HOOK_EXPLODING,
|
||||||
|
@ -173,6 +174,7 @@ public: // tolua_export
|
||||||
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
|
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
|
||||||
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||||
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
|
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
|
||||||
|
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier);
|
||||||
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
|
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
|
||||||
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
||||||
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "Pawn.h"
|
#include "Pawn.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
|
#include "../Bindings/PluginManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +73,14 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat
|
||||||
|
|
||||||
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
|
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
|
||||||
{
|
{
|
||||||
|
// Check if the plugins allow the addition:
|
||||||
|
if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier()))
|
||||||
|
{
|
||||||
|
// A plugin disallows the addition, bail out.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No need to add empty effects:
|
||||||
if (a_EffectType == cEntityEffect::effNoEffect)
|
if (a_EffectType == cEntityEffect::effNoEffect)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
/** Applies an entity effect
|
/** Applies an entity effect
|
||||||
|
Checks with plugins if they allow the addition.
|
||||||
@param a_EffectType The entity effect to apply
|
@param a_EffectType The entity effect to apply
|
||||||
@param a_EffectDurationTicks The duration of the effect
|
@param a_EffectDurationTicks The duration of the effect
|
||||||
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
|
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
|
||||||
|
@ -35,6 +36,7 @@ public:
|
||||||
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
|
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
|
||||||
|
|
||||||
/** Applies an entity effect
|
/** Applies an entity effect
|
||||||
|
Checks with plugins if they allow the addition.
|
||||||
@param a_EffectType The entity effect to apply
|
@param a_EffectType The entity effect to apply
|
||||||
@param a_Effect The parameters of the effect
|
@param a_Effect The parameters of the effect
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user