Implemented buff level restrictions

Higher level buffs can't be cast on lower level toons.
The formula was based on information found here: http://samanna.net/eq.general/buffs.shtml
This behavior is controlled by the rule Spells:BuffLevelRestrictions which defaults to true.
This commit is contained in:
Michael Cook 2013-10-21 19:13:55 -04:00
parent 56ba87577b
commit a06fe1d02e
6 changed files with 49 additions and 0 deletions

View File

@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 10/21/2013 ==
demonstar55: Changed GetMinLevel return 0 for more cases that EQ uses for some reason ...
demonstar55: Added buff level restrictions, set the Spells:BuffLevelRestrictions to false to have the old behavior.
== 10/18/2013 ==
Uleat: Expanded the 'Bag Type' enumeration to include all known values. Also, set in place additional 'Bag Type' to 'Skill Type' conversions. Some of these will need to be verified before activation.

View File

@ -294,6 +294,7 @@ RULE_INT ( Spells, DeathSaveCharismaMod, 3) //Determines how much charisma effec
RULE_INT ( Spells, DivineInterventionHeal, 8000) //Divine intervention heal amount.
RULE_BOOL ( Spells, AdditiveBonusValues, false) //Allow certain bonuses to be calculated by adding together the value from each item, instead of taking the highest value. (ie Add together all Cleave Effects)
RULE_BOOL ( Spells, UseCHAScribeHack, false) //ScribeSpells and TrainDiscs quest functions will ignore entries where field 12 is CHA. What's the best way to do this?
RULE_BOOL ( Spells, BuffLevelRestrictions, true) //Buffs will not land on low level toons like live
RULE_CATEGORY_END()
RULE_CATEGORY( Combat )

View File

@ -50,6 +50,7 @@
#define ITEM_OUT_OF_CHARGES 182 //Item is out of charges.
#define TARGET_NO_MANA 191 //Your target has no mana to affect
#define TARGET_GROUP_MEMBER 196 //You must first target a group member.
#define SPELL_TOO_POWERFUL 197 //Your spell is too powerful for your intended target.
#define INSUFFICIENT_MANA 199 //Insufficient Mana to cast this spell!
#define SAC_TOO_LOW 203 //This being is not a worthy sacrifice.
#define SAC_TOO_HIGH 204 //This being is too powerful to be a sacrifice.

View File

@ -482,6 +482,7 @@ public:
int32 GetDotFocus(uint16 spell_id, int32 value);
int32 GetActDoTDamage(uint16 spell_id, int32 value);
virtual bool CheckFizzle(uint16 spell_id);
virtual bool CheckSpellLevelRestriction(uint16 spell_id);
virtual int GetCurrentBuffSlots() const;
virtual int GetCurrentSongSlots() const;
virtual int GetCurrentDiscSlots() const { return 1; }

View File

@ -191,6 +191,7 @@ public:
virtual bool DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_center,
CastAction_type &CastAction);
virtual bool CheckFizzle(uint16 spell_id);
virtual bool CheckSpellLevelRestriction(uint16 spell_id);
virtual bool IsImmuneToSpell(uint16 spell_id, Mob *caster);
virtual float GetAOERange(uint16 spell_id);
void InterruptSpell(uint16 spellid = SPELL_UNKNOWN);

View File

@ -2709,6 +2709,41 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2,
return 0;
}
// Check Spell Level Restrictions
// returns true if they meet the restrictions, false otherwise
// derived from http://samanna.net/eq.general/buffs.shtml
// spells 1-50: no restrictons
// 51-65: SpellLevel/2+15
// 66+L Group Spells 62, Single Target 61
bool Mob::CheckSpellLevelRestriction(uint16 spell_id)
{
return true;
}
bool Client::CheckSpellLevelRestriction(uint16 spell_id)
{
int SpellLevel = GetMinLevel(spell_id);
// Only check for beneficial buffs, if it's a bard song, only if it's short duration
if(IsBuffSpell(spell_id) && IsBeneficialSpell(spell_id) &&
!(IsBardSong(spell_id) && !IsShortDurationBuff(spell_id)))
{
if(SpellLevel > 65)
{
if(IsGroupSpell(spell_id) && GetLevel() < 62)
return false;
else if(GetLevel() < 61)
return false;
}
else if(SpellLevel > 50) // 51-65
{
if(GetLevel() < (SpellLevel/2+15))
return false;
}
}
return true;
}
// returns the slot the buff was added to, -1 if it wasn't added due to
// stacking problems, and -2 if this is not a buff
@ -3479,6 +3514,15 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r
else if (IsBeneficialSpell(spell_id) && !IsSummonPCSpell(spell_id))
entity_list.AddHealAggro(spelltar, this, CheckHealAggroAmount(spell_id, (spelltar->GetMaxHP() - spelltar->GetHP())));
// make sure spelltar is high enough level for the buff
if(RuleB(Spells, BuffLevelRestrictions) && !spelltar->CheckSpellLevelRestriction(spell_id))
{
mlog(SPELLS__BUFFS, "Spell %d failed: recipient did not meet the level restrictions", spell_id);
if(!IsBardSong(spell_id))
Message_StringID(MT_SpellFailure, SPELL_TOO_POWERFUL);
return false;
}
// cause the effects to the target
if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness))
{