Spell functions

class SpellFunctions

Public Static Functions

static void ClearSpellbookChanges(unsigned short pid) noexcept

Clear the last recorded spellbook changes for a player.

This is used to initialize the sending of new PlayerSpellbook packets.

Parameters

pid – The player ID whose spellbook changes should be used.

Returns

void

static void ClearSpellsActiveChanges(unsigned short pid) noexcept

Clear the last recorded spells active changes for a player.

This is used to initialize the sending of new PlayerSpellsActive packets.

Parameters

pid – The player ID whose spells active changes should be used.

Returns

void

static void ClearCooldownChanges(unsigned short pid) noexcept

Clear the last recorded cooldown changes for a player.

This is used to initialize the sending of new PlayerCooldown packets.

Parameters

pid – The player ID whose cooldown changes should be used.

Returns

void

static unsigned int GetSpellbookChangesSize(unsigned short pid) noexcept

Get the number of indexes in a player’s latest spellbook changes.

Parameters

pid – The player ID whose spellbook changes should be used.

Returns

The number of indexes.

static unsigned int GetSpellbookChangesAction(unsigned short pid) noexcept

Get the action type used in a player’s latest spellbook changes.

Parameters

pid – The player ID whose spellbook changes should be used.

Returns

The action type (0 for SET, 1 for ADD, 2 for REMOVE).

static unsigned int GetSpellsActiveChangesSize(unsigned short pid) noexcept

Get the number of indexes in a player’s latest spells active changes.

Parameters

pid – The player ID whose spells active changes should be used.

Returns

The number of indexes for spells active changes.

static unsigned int GetSpellsActiveChangesAction(unsigned short pid) noexcept

Get the action type used in a player’s latest spells active changes.

Parameters

pid – The player ID whose spells active changes should be used.

Returns

The action type (0 for SET, 1 for ADD, 2 for REMOVE).

static unsigned int GetCooldownChangesSize(unsigned short pid) noexcept

Get the number of indexes in a player’s latest cooldown changes.

Parameters

pid – The player ID whose cooldown changes should be used.

Returns

The number of indexes.

static void SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept

Set the action type in a player’s spellbook changes.

Parameters
  • pid – The player ID whose spellbook changes should be used.

  • action – The action (0 for SET, 1 for ADD, 2 for REMOVE).

Returns

void

static void SetSpellsActiveChangesAction(unsigned short pid, unsigned char action) noexcept

Set the action type in a player’s spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • action – The action (0 for SET, 1 for ADD, 2 for REMOVE).

Returns

void

static void AddSpell(unsigned short pid, const char *spellId) noexcept

Add a new spell to the spellbook changes for a player.

Parameters
  • pid – The player ID whose spellbook changes should be used.

  • spellId – The spellId of the spell.

Returns

void

static void AddSpellActive(unsigned short pid, const char *spellId, const char *displayName, bool stackingState) noexcept

Add a new active spell to the spells active changes for a player, using the temporary effect values stored so far.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellId – The spellId of the spell.

  • displayName – The displayName of the spell.

  • stackingState – Whether the spell should stack with other instances of itself.

Returns

void

static void AddSpellActiveEffect(unsigned short pid, int effectId, double magnitude, double duration, double timeLeft, int arg) noexcept

Add a new effect to the next active spell that will be added to a player.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • effectId – The id of the effect.

  • magnitude – The magnitude of the effect.

  • duration – The duration of the effect.

  • timeLeft – The timeLeft for the effect.

  • arg – The arg of the effect when applicable, e.g. the skill used for Fortify Skill or the attribute used for Fortify Attribute.

Returns

void

static void AddCooldownSpell(unsigned short pid, const char *spellId, unsigned int startDay, double startHour) noexcept

Add a new cooldown spell to the cooldown changes for a player.

Parameters
  • pid – The player ID whose cooldown changes should be used.

  • spellId – The spellId of the spell.

  • startDay – The day on which the cooldown starts.

  • startHour – The hour at which the cooldown starts.

Returns

void

static const char *GetSpellId(unsigned short pid, unsigned int index) noexcept

Get the spell id at a certain index in a player’s latest spellbook changes.

Parameters
  • pid – The player ID whose spellbook changes should be used.

  • index – The index of the spell.

Returns

The spell id.

static const char *GetSpellsActiveId(unsigned short pid, unsigned int index) noexcept

Get the spell id at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The spell id.

static const char *GetSpellsActiveDisplayName(unsigned short pid, unsigned int index) noexcept

Get the spell display name at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The spell display name.

static bool GetSpellsActiveStackingState(unsigned short pid, unsigned int index) noexcept

Get the spell stacking state at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The spell stacking state.

static unsigned int GetSpellsActiveEffectCount(unsigned short pid, unsigned int index) noexcept

Get the number of effects at an index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The number of effects.

static unsigned int GetSpellsActiveEffectId(unsigned short pid, unsigned int spellIndex, unsigned int effectIndex) noexcept

Get the id for an effect index at a spell index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellIndex – The index of the spell.

  • effectIndex – The index of the effect.

Returns

The id of the effect.

static int GetSpellsActiveEffectArg(unsigned short pid, unsigned int spellIndex, unsigned int effectIndex) noexcept

Get the arg for an effect index at a spell index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellIndex – The index of the spell.

  • effectIndex – The index of the effect.

Returns

The arg of the effect.

static double GetSpellsActiveEffectMagnitude(unsigned short pid, unsigned int spellIndex, unsigned int effectIndex) noexcept

Get the magnitude for an effect index at a spell index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellIndex – The index of the spell.

  • effectIndex – The index of the effect.

Returns

The magnitude of the effect.

static double GetSpellsActiveEffectDuration(unsigned short pid, unsigned int spellIndex, unsigned int effectIndex) noexcept

Get the duration for an effect index at a spell index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellIndex – The index of the spell.

  • effectIndex – The index of the effect.

Returns

The duration of the effect.

static double GetSpellsActiveEffectTimeLeft(unsigned short pid, unsigned int spellIndex, unsigned int effectIndex) noexcept

Get the time left for an effect index at a spell index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • spellIndex – The index of the spell.

  • effectIndex – The index of the effect.

Returns

The time left for the effect.

static bool DoesSpellsActiveHavePlayerCaster(unsigned short pid, unsigned int index) noexcept

Check whether the spell at a certain index in a player’s latest spells active changes has a player as its caster.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

Whether a player is the caster of the spell.

static int GetSpellsActiveCasterPid(unsigned short pid, unsigned int index) noexcept

Get the player ID of the caster of the spell at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The player ID of the caster.

static const char *GetSpellsActiveCasterRefId(unsigned short pid, unsigned int index) noexcept

Get the refId of the actor caster of the spell at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The refId of the caster.

static unsigned int GetSpellsActiveCasterRefNum(unsigned short pid, unsigned int index) noexcept

Get the refNum of the actor caster of the spell at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The refNum of the caster.

static unsigned int GetSpellsActiveCasterMpNum(unsigned short pid, unsigned int index) noexcept

Get the mpNum of the actor caster of the spell at a certain index in a player’s latest spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • index – The index of the spell.

Returns

The mpNum of the caster.

static const char *GetCooldownSpellId(unsigned short pid, unsigned int index) noexcept

Get the spell id at a certain index in a player’s latest cooldown changes.

Parameters
  • pid – The player ID whose cooldown changes should be used.

  • index – The index of the cooldown spell.

Returns

The spell id.

static unsigned int GetCooldownStartDay(unsigned short pid, unsigned int index) noexcept

Get the starting day of the cooldown at a certain index in a player’s latest cooldown changes.

Parameters
  • pid – The player ID whose cooldown changes should be used.

  • index – The index of the cooldown spell.

Returns

The starting day of the cooldown.

static double GetCooldownStartHour(unsigned short pid, unsigned int index) noexcept

Get the starting hour of the cooldown at a certain index in a player’s latest cooldown changes.

Parameters
  • pid – The player ID whose cooldown changes should be used.

  • index – The index of the cooldown spell.

Returns

The starting hour of the cooldown.

static void SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a PlayerSpellbook packet with a player’s recorded spellbook changes.

Parameters
  • pid – The player ID whose spellbook changes should be used.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendSpellsActiveChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a PlayerSpellsActive packet with a player’s recorded spells active changes.

Parameters
  • pid – The player ID whose spells active changes should be used.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendCooldownChanges(unsigned short pid) noexcept

Send a PlayerCooldowns packet with a player’s recorded cooldown changes.

Parameters

pid – The player ID whose cooldown changes should be used.

Returns

void