[API] Apply spells with custom buff durations and adjust existing spell buff durations. (#1997)

* working

* Update spell_effects.cpp

* updates

* disable_buff_overwrite

* revert

* update

* working

* update

* updates

* Update spells.cpp

* getbuffstat done

* Update perl_mob.cpp

* [API] Apply spells with custom buff durations and adjust existing spell buff durations.

* [API] Apply spells with custom buff durations and adjust existing spell buff durations.

* [API] Apply spells with custom buff durations and adjust existing spell buff durations.

* [API] Apply spells with custom buff durations and adjust existing spell buff durations.

* https://github.com/EQEmu/Server/pull/1997

Lua added, thanks kinglykrab
This commit is contained in:
KayenEQ
2022-02-15 08:58:10 -05:00
committed by GitHub
parent 5fd62d82db
commit 615f4a5304
7 changed files with 258 additions and 17 deletions
+5 -9
View File
@@ -3200,9 +3200,8 @@ bool Mob::HasDiscBuff()
// stacking problems, and -2 if this is not a buff
// if caster is null, the buff will be added with the caster level being
// the level of the mob
int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_override)
int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_override, bool disable_buff_overrwrite)
{
int buffslot, ret, caster_level, emptyslot = -1;
bool will_overwrite = false;
std::vector<int> overwrite_slots;
@@ -3223,7 +3222,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid
LogSpells("Buff [{}] failed to add because its duration came back as 0", spell_id);
return -2; // no duration? this isn't a buff
}
LogSpells("Trying to add buff [{}] cast by [{}] (cast level [{}]) with duration [{}]",
spell_id, caster?caster->GetName():"UNKNOWN", caster_level, duration);
@@ -3297,7 +3296,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid
// at this point we know that this buff will stick, but we have
// to remove some other buffs already worn if will_overwrite is true
if (will_overwrite) {
if (will_overwrite && !disable_buff_overrwrite) {
std::vector<int>::iterator cur, end;
cur = overwrite_slots.begin();
end = overwrite_slots.end();
@@ -3314,9 +3313,6 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid
}
}
// now add buff at emptyslot
assert(buffs[emptyslot].spellid == SPELL_UNKNOWN); // sanity check
buffs[emptyslot].spellid = spell_id;
buffs[emptyslot].casterlevel = caster_level;
if (caster && !caster->IsAura()) // maybe some other things we don't want to ...
@@ -3446,7 +3442,7 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite)
// break stuff
//
bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, int reflect_effectiveness, bool use_resist_adjust, int16 resist_adjust,
bool isproc, int level_override, int32 duration_override)
bool isproc, int level_override, int32 duration_override, bool disable_buff_overrwrite)
{
// well we can't cast a spell on target without a target
if(!spelltar)
@@ -3994,7 +3990,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, int reflect_effectivenes
}
// cause the effects to the target
if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness, level_override, reflect_effectiveness, duration_override))
if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness, level_override, reflect_effectiveness, duration_override, disable_buff_overrwrite))
{
// if SpellEffect returned false there's a problem applying the
// spell. It's most likely a buff that can't stack.