mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-22 20:10:16 -04:00
Merge pull request #30 from DreamWeave-MP/you-did-this-to-me
Feat(scripting): Add script function to set player who cast a spell effect on another
This commit is contained in:
commit
f32e46331e
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
|
Player* storedPlayerCaster;
|
||||||
std::vector<ESM::ActiveEffect> storedActiveEffects;
|
std::vector<ESM::ActiveEffect> storedActiveEffects;
|
||||||
|
|
||||||
void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexcept
|
void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexcept
|
||||||
@ -112,8 +113,15 @@ void SpellFunctions::AddSpellActive(unsigned short pid, const char* spellId, con
|
|||||||
spell.params.mDisplayName = displayName;
|
spell.params.mDisplayName = displayName;
|
||||||
spell.params.mEffects = storedActiveEffects;
|
spell.params.mEffects = storedActiveEffects;
|
||||||
|
|
||||||
|
if (storedPlayerCaster != nullptr)
|
||||||
|
{
|
||||||
|
spell.caster.isPlayer = true;
|
||||||
|
spell.caster.guid = storedPlayerCaster->guid;
|
||||||
|
}
|
||||||
|
|
||||||
player->spellsActiveChanges.activeSpells.push_back(spell);
|
player->spellsActiveChanges.activeSpells.push_back(spell);
|
||||||
|
|
||||||
|
storedPlayerCaster = nullptr;
|
||||||
storedActiveEffects.clear();
|
storedActiveEffects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +356,11 @@ double SpellFunctions::GetCooldownStartHour(unsigned short pid, unsigned int ind
|
|||||||
return player->cooldownChanges.at(index).startTimestampHour;
|
return player->cooldownChanges.at(index).startTimestampHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpellFunctions::SetSpellsActiveCasterPid(unsigned short casterPid) noexcept
|
||||||
|
{
|
||||||
|
storedPlayerCaster = Players::getPlayer(casterPid);
|
||||||
|
}
|
||||||
|
|
||||||
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
{"GetCooldownStartDay", SpellFunctions::GetCooldownStartDay},\
|
{"GetCooldownStartDay", SpellFunctions::GetCooldownStartDay},\
|
||||||
{"GetCooldownStartHour", SpellFunctions::GetCooldownStartHour},\
|
{"GetCooldownStartHour", SpellFunctions::GetCooldownStartHour},\
|
||||||
\
|
\
|
||||||
|
{"SetSpellsActiveCasterPid", SpellFunctions::SetSpellsActiveCasterPid},\
|
||||||
|
\
|
||||||
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges},\
|
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges},\
|
||||||
{"SendSpellsActiveChanges", SpellFunctions::SendSpellsActiveChanges},\
|
{"SendSpellsActiveChanges", SpellFunctions::SendSpellsActiveChanges},\
|
||||||
{"SendCooldownChanges", SpellFunctions::SendCooldownChanges},\
|
{"SendCooldownChanges", SpellFunctions::SendCooldownChanges},\
|
||||||
@ -353,6 +355,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
static double GetCooldownStartHour(unsigned short pid, unsigned int index) noexcept;
|
static double GetCooldownStartHour(unsigned short pid, unsigned int index) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set a player ID as the caster of the next active spell that will be added to a player.
|
||||||
|
*
|
||||||
|
* \param casterPid The player ID of the caster.
|
||||||
|
*/
|
||||||
|
static void SetSpellsActiveCasterPid(unsigned short casterPid) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes.
|
* \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user