[Server] Add script functions that get casters of actors' active spells

pull/593/head
David Cernat 3 years ago
parent 61a61d627e
commit a59a37dd66

@ -280,6 +280,36 @@ double ActorFunctions::GetActorSpellsActiveEffectTimeLeft(unsigned int actorInde
return readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).params.mEffects.at(effectIndex).mTimeLeft;
}
bool ActorFunctions::DoesActorSpellsActiveHavePlayerCaster(unsigned int actorIndex, unsigned int spellIndex) noexcept
{
return readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).caster.isPlayer;
}
int ActorFunctions::GetActorSpellsActiveCasterPid(unsigned int actorIndex, unsigned int spellIndex) noexcept
{
Player* caster = Players::getPlayer(readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).caster.guid);
if (caster != nullptr)
return caster->getId();
return -1;
}
const char* ActorFunctions::GetActorSpellsActiveCasterRefId(unsigned int actorIndex, unsigned int spellIndex) noexcept
{
return readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).caster.refId.c_str();
}
unsigned int ActorFunctions::GetActorSpellsActiveCasterRefNum(unsigned int actorIndex, unsigned int spellIndex) noexcept
{
return readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).caster.refNum;
}
unsigned int ActorFunctions::GetActorSpellsActiveCasterMpNum(unsigned int actorIndex, unsigned int spellIndex) noexcept
{
return readActorList->baseActors.at(actorIndex).spellsActiveChanges.activeSpells.at(spellIndex).caster.mpNum;
}
bool ActorFunctions::DoesActorHavePosition(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).hasPositionData;

@ -60,6 +60,12 @@
{"GetActorSpellsActiveEffectDuration", ActorFunctions::GetActorSpellsActiveEffectDuration},\
{"GetActorSpellsActiveEffectTimeLeft", ActorFunctions::GetActorSpellsActiveEffectTimeLeft},\
\
{"DoesActorSpellsActiveHavePlayerCaster", ActorFunctions::DoesActorSpellsActiveHavePlayerCaster},\
{"GetActorSpellsActiveCasterPid", ActorFunctions::GetActorSpellsActiveCasterPid},\
{"GetActorSpellsActiveCasterRefId", ActorFunctions::GetActorSpellsActiveCasterRefId},\
{"GetActorSpellsActiveCasterRefNum", ActorFunctions::GetActorSpellsActiveCasterRefNum},\
{"GetActorSpellsActiveCasterMpNum", ActorFunctions::GetActorSpellsActiveCasterMpNum},\
\
{"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\
{"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\
\
@ -533,6 +539,52 @@ public:
*/
static double GetActorSpellsActiveEffectTimeLeft(unsigned int actorIndex, unsigned int spellIndex, unsigned int effectIndex) noexcept;
/**
* \brief Check whether the spell at a certain index in an actor's latest spells active changes has a player
* as its caster.
*
* \param actorIndex The index of the actor.
* \param spellIndex The index of the spell.
* \return Whether a player is the caster of the spell.
*/
static bool DoesActorSpellsActiveHavePlayerCaster(unsigned int actorIndex, unsigned int spellIndex) noexcept;
/**
* \brief Get the player ID of the caster of the spell at a certain index in an actor's latest spells active changes.
*
* \param actorIndex The index of the actor.
* \param spellIndex The index of the spell.
* \return The player ID of the caster.
*/
static int GetActorSpellsActiveCasterPid(unsigned int actorIndex, unsigned int spellIndex) noexcept;
/**
* \brief Get the refId of the actor caster of the spell at a certain index in an actor's latest spells active changes.
*
* \param actorIndex The index of the actor.
* \param spellIndex The index of the spell.
* \return The refId of the caster.
*/
static const char* GetActorSpellsActiveCasterRefId(unsigned int actorIndex, unsigned int spellIndex) noexcept;
/**
* \brief Get the refNum of the actor caster of the spell at a certain index in an actor's latest spells active changes.
*
* \param actorIndex The index of the actor.
* \param spellIndex The index of the spell.
* \return The refNum of the caster.
*/
static unsigned int GetActorSpellsActiveCasterRefNum(unsigned int actorIndex, unsigned int spellIndex) noexcept;
/**
* \brief Get the mpNum of the actor caster of the spell at a certain index in an actor's latest spells active changes.
*
* \param actorIndex The index of the actor.
* \param spellIndex The index of the spell.
* \return The mpNum of the caster.
*/
static unsigned int GetActorSpellsActiveCasterMpNum(unsigned int actorIndex, unsigned int spellIndex) noexcept;
/**
* \brief Check whether there is any positional data for the actor at a certain index in
* the read actor list.

Loading…
Cancel
Save