Skip to content

Commit

Permalink
Fix Ethereal Bond
Browse files Browse the repository at this point in the history
* Due to an old Atlas bug, it was applied to the base mana pool as a percentage using the level instead of the value, then again in `MaxManaCalculator` but as a flat bonus using the value. Most likely caused by a confusion between old (power pool%) and new (flat power) Ethereal Bonds..
* Changed its type to `eProperty.PowerPool`, since we’re using the old one.
* Whether it should be applied on base power pool or total power pool is unclear. This makes a difference for Theurgist pets for example. For now, It will be applied to the total power pool.
* Made it additive with ToA power pool% bonus, since it now works the same way.
* Replacing it with the newer version will require changing it’s type back to `eProperty.MaxMana`.
* Removed debug messages.
  • Loading branch information
bm01 committed Jul 27, 2024
1 parent 8dc6b2b commit 5d41d2c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 174 deletions.
38 changes: 7 additions & 31 deletions GameServer/gameobjects/GamePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2719,14 +2719,11 @@ public override byte HealthPercentGroupWindow
/// <summary>
/// Calculate max mana for this player based on level and mana stat level
/// </summary>
/// <param name="level"></param>
/// <param name="manaStat"></param>
/// <returns></returns>
public virtual int CalculateMaxMana(int level, int manaStat)
{
int maxpower = 0;
int maxPower = 0;

//Special handling for Vampiirs:
// Special handling for Vampiirs:
/* There is no stat that affects the Vampiir's power pool or the damage done by its power based spells.
* The Vampiir is not a focus based class like, say, an Enchanter.
* The Vampiir is a lot more cut and dried than the typical casting class.
Expand All @@ -2743,37 +2740,16 @@ public virtual int CalculateMaxMana(int level, int manaStat)
* Strength ALSO affects the size of the power pool for a Vampiir sort of.
* Your INNATE strength (the number of attribute points your character has for strength) has no effect at all.
* Extra points added through ITEMS, however, does increase the size of your power pool.

*/
if (CharacterClass.ManaStat != eStat.UNDEFINED || CharacterClass.ID == (int)eCharacterClass.Vampiir)
{
maxpower = Math.Max(5, (level * 5) + (manaStat - 50));
}
else if (CharacterClass.ManaStat == eStat.UNDEFINED && Champion && ChampionLevel > 0)
{
maxpower = 100; // This is a guess, need feedback
}

#region Calculation : AtlasOF_EtheralBond
// --- [START] --- AtlasOF_EtherealBond --------------------------------------------------------
AtlasOF_EtherealBondAbility raEtherealBond = GetAbility<AtlasOF_EtherealBondAbility>();
if (raEtherealBond != null)
{
if (raEtherealBond.Level > 0)
{
maxpower += (maxpower * raEtherealBond.Level) / 100;
}
}
// --- [ END ] --- AtlasOF_EtherealBond --------------------------------------------------------
#endregion

if (maxpower < 0)
maxpower = 0;
if (CharacterClass.ManaStat is not eStat.UNDEFINED || (eCharacterClass) CharacterClass.ID is eCharacterClass.Vampiir)
maxPower = Math.Max(5, level * 5 + (manaStat - 50));
else if (Champion && ChampionLevel > 0)
maxPower = 100; // This is a guess, need feedback.

return maxpower;
return Math.Max(0, maxPower);
}


/// <summary>
/// Gets/sets the object mana
/// </summary>
Expand Down
144 changes: 55 additions & 89 deletions GameServer/propertycalc/MaxManaCalculator.cs
Original file line number Diff line number Diff line change
@@ -1,100 +1,66 @@
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;

namespace DOL.GS.PropertyCalc
{
/// <summary>
/// The Power Pool calculator
///
/// BuffBonusCategory1 unused
/// BuffBonusCategory2 unused
/// BuffBonusCategory3 unused
/// BuffBonusCategory4 unused
/// BuffBonusMultCategory1 unused
/// </summary>
[PropertyCalculator(eProperty.MaxMana)]
public class MaxManaCalculator : PropertyCalculator
{
public MaxManaCalculator() {}
/// <summary>
/// The Power Pool calculator
///
/// BuffBonusCategory1 unused
/// BuffBonusCategory2 unused
/// BuffBonusCategory3 unused
/// BuffBonusCategory4 unused
/// BuffBonusMultCategory1 unused
/// </summary>
[PropertyCalculator(eProperty.MaxMana)]
public class MaxManaCalculator : PropertyCalculator
{
public MaxManaCalculator() {}

public override int CalcValue(GameLiving living, eProperty property)
{
if (living is GamePlayer)
{
GamePlayer player = living as GamePlayer;
eStat manaStat = player.CharacterClass.ManaStat;
public override int CalcValue(GameLiving living, eProperty property)
{
if (living is not GamePlayer player)
return 0;

if (player.CharacterClass.ManaStat == eStat.UNDEFINED)
{
//Special handling for Vampiirs:
/* There is no stat that affects the Vampiir's power pool or the damage done by its power based spells.
* The Vampiir is not a focus based class like, say, an Enchanter.
* The Vampiir is a lot more cut and dried than the typical casting class.
* EDIT, 12/13/04 - I was told today that this answer is not entirely accurate.
* While there is no stat that affects the damage dealt (in the way that intelligence or piety affects how much damage a more traditional caster can do),
* the Vampiir's power pool capacity is intended to be increased as the Vampiir's strength increases.
*
* This means that strength ONLY affects a Vampiir's mana pool
*/
if (player.CharacterClass.ID == (int)eCharacterClass.Vampiir)
{
manaStat = eStat.STR;
}
else if (player.Champion && player.ChampionLevel > 0)
{
return player.CalculateMaxMana(player.Level, 0);
}
else
{
return 0;
}
}
eStat manaStat;

int manaBase = player.CalculateMaxMana(player.Level, player.GetModified((eProperty)manaStat));
int itemBonus = living.ItemBonus[(int)property];
int poolBonus = living.ItemBonus[(int)eProperty.PowerPool];
int abilityBonus = living.AbilityBonus[(int)property];
if (player.CharacterClass.ManaStat is not eStat.UNDEFINED)
manaStat = player.CharacterClass.ManaStat;
else
{
// Special handling for Vampiirs:
/* There is no stat that affects the Vampiir's power pool or the damage done by its power based spells.
* The Vampiir is not a focus based class like, say, an Enchanter.
* The Vampiir is a lot more cut and dried than the typical casting class.
* EDIT, 12/13/04 - I was told today that this answer is not entirely accurate.
* While there is no stat that affects the damage dealt (in the way that intelligence or piety affects how much damage a more traditional caster can do),
* the Vampiir's power pool capacity is intended to be increased as the Vampiir's strength increases.
*
* This means that strength ONLY affects a Vampiir's mana pool
*/
if ((eCharacterClass) player.CharacterClass.ID is eCharacterClass.Vampiir)
manaStat = eStat.STR;
else if (player.Champion && player.ChampionLevel > 0)
return player.CalculateMaxMana(player.Level, 0);
else
return 0;
}

int itemCap = player.Level / 2 + 1;
int poolCap = player.Level / 2;
itemCap = itemCap + Math.Min(player.ItemBonus[(int)eProperty.PowerPoolCapBonus], itemCap);
poolCap = poolCap + Math.Min(player.ItemBonus[(int)eProperty.PowerPoolCapBonus], player.Level);
int flatItemBonusCap = player.Level / 2 + 1;
int poolItemBonusCap = player.Level / 2 + Math.Min(player.ItemBonus[(int) eProperty.PowerPoolCapBonus], player.Level);

int manaBase = player.CalculateMaxMana(player.Level, player.GetModified((eProperty) manaStat));
int flatItemBonus = Math.Min(flatItemBonusCap, living.ItemBonus[(int) property]);
int poolItemBonus = Math.Min(poolItemBonusCap, living.ItemBonus[(int) eProperty.PowerPool]);
int flatAbilityBonus = living.AbilityBonus[(int) property];
int poolAbilityBonus = living.AbilityBonus[(int) eProperty.PowerPool];

if (itemBonus > itemCap) {
itemBonus = itemCap;
}
if (poolBonus > poolCap)
poolBonus = poolCap;

//Q: What exactly does the power pool % increase do?Does it increase the amount of power my cleric
//can generate (like having higher piety)? Or, like the dex cap increase, do I have to put spellcraft points into power to make it worth anything?
//A: I’m better off quoting Balance Boy directly here: ” Power pool is affected by
//your acuity stat, +power bonus, the Ethereal Bond Realm ability, and your level.
//The resulting power pool is adjusted by your power pool % increase bonus.
return (int)(manaBase + itemBonus + abilityBonus + (manaBase + itemBonus + abilityBonus) * poolBonus * 0.01);
}
else
{
return 1000000; // default
}
}
}
// Q: What exactly does the power pool % increase do? Does it increase the amount of power my cleric can generate (like having higher piety)?
// Or, like the dex cap increase, do I have to put spellcraft points into power to make it worth anything?
// A: I'm better off quoting Balance Boy directly here: "Power pool is affected by your acuity stat, +power bonus,
// the Ethereal Bond Realm ability, and your level. The resulting power pool is adjusted by your power pool % increase bonus.
double result = manaBase + flatItemBonus + flatAbilityBonus;
result *= 1 + (poolItemBonus + poolAbilityBonus) * 0.01;
return (int) result;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using DOL.Database;
using DOL.GS.Effects;
using DOL.GS.PacketHandler;
using DOL.Language;
using log4net;

namespace DOL.GS.RealmAbilities
{
Expand All @@ -17,60 +10,23 @@ public class AtlasOF_EtherealBondAbility : RAPropertyEnhancer
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

public AtlasOF_EtherealBondAbility(DbAbility dba, int level) : base(dba, level, eProperty.MaxMana) { }
public AtlasOF_EtherealBondAbility(DbAbility dba, int level) : base(dba, level, eProperty.PowerPool) { }

protected override string ValueUnit { get { return "%"; } }
protected override string ValueUnit => "%";

public override bool CheckRequirement(GamePlayer player) { return AtlasRAHelpers.GetSerenityLevel(player) >= 2; }

public override int GetAmountForLevel(int level) { return AtlasRAHelpers.GetPropertyEnhancer3AmountForLevel(level); }

public override int CostForUpgrade(int level) { return AtlasRAHelpers.GetCommonUpgradeCostFor5LevelsRA(level); }

public override void Activate(GameLiving living, bool sendUpdates)
public override bool CheckRequirement(GamePlayer player)
{
log.Warn("inside Activate");
log.WarnFormat("1 - inside Activate Current maxmana is {0}", living.MaxMana);
base.Activate(living, sendUpdates);
log.WarnFormat("2 - inside Activate Current maxmana is {0}", living.MaxMana);

/*
// Ethereal Bond : Increases maximum power by 3% per level of this ability.
// Pre-Requisits : Serenity lvl 2
AtlasOF_SerenityAbility raSerenity = living.GetAbility<AtlasOF_SerenityAbility>();
if (raSerenity != null)
{
log.WarnFormat("Serenity level is {0}", raSerenity.Level);
if (raSerenity.Level < 2)
{
log.WarnFormat("Serenity level is {0} and pre-requisite needs Serenity to be at least lvl 2 so we CANNOT activate RA ability", raSerenity.Level);
return;
}
else
{
log.WarnFormat("Current MaxMana is {0}", living.MaxMana);
AtlasOF_RAMaxManaEnhancer raMana = AtlasOF_RAMaxManaEnhancer(le)
log.WarnFormat("Current MaxMana is {0}", living.MaxMana);
}
}
else
{
log.WarnFormat("The player {0} does not have Serenity Ability and its a pre-requisite to Ethereal Bond", living.Name);
base.Deactivate(living, sendUpdates);
}
*/
return AtlasRAHelpers.GetSerenityLevel(player) >= 2;
}

public override void OnLevelChange(int oldLevel, int newLevel = 0)
public override int GetAmountForLevel(int level)
{
log.WarnFormat("1 - inside OnLevelChange, oldLevel {0}, newLevel {1}, Current maxmana is {2}", oldLevel, newLevel, base.m_activeLiving.MaxMana);
base.OnLevelChange(oldLevel, newLevel);
log.WarnFormat("1 - inside OnLevelChange, oldLevel {0}, newLevel {1}, Current maxmana is {2}", oldLevel, newLevel, base.m_activeLiving.MaxMana);
return AtlasRAHelpers.GetPropertyEnhancer3AmountForLevel(level);
}

public override int CostForUpgrade(int level)
{
return AtlasRAHelpers.GetCommonUpgradeCostFor5LevelsRA(level);
}
}
}

0 comments on commit 5d41d2c

Please sign in to comment.