Skip to content

Commit

Permalink
Move CharacterClass to DB (#444)
Browse files Browse the repository at this point in the history
Refactor CharacterClass
Remove ICharacterClass and all its implementations
Save default CharacterClasses into DB if they do not exist yet
Fix pet window to no longer close when releasing subpet while having no main pet
Change Necromancer spells only using power when pet starts casting them
  • Loading branch information
NetDwarf authored Feb 9, 2023
2 parents c583fa0 + b455deb commit a50d077
Show file tree
Hide file tree
Showing 115 changed files with 2,151 additions and 5,485 deletions.
285 changes: 209 additions & 76 deletions DOLDatabase/Tables/DBCharacterClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,80 +20,213 @@

namespace DOL.Database
{
[DataTable(TableName = "CharacterClass")]
public class DBCharacterClass : DataObject
{
private int id;
private int specPointMultiplier;
private int baseHP;
private int baseWeaponSkill;
private string autoTrainableSkills;
private string eligibleRaces;

[PrimaryKey]
public int ID
{
get => id;
set
{
Dirty = true;
id = value;
}
}

[DataElement]
public int SpecPointMultiplier
{
get { return specPointMultiplier; }
set
{
Dirty = true;
specPointMultiplier = value;
}
}

[DataElement]
public int BaseHP
{
get { return baseHP; }
set
{
Dirty = true;
baseHP = value;
}
}

[DataElement]
public int BaseWeaponSkill
{
get { return baseWeaponSkill; }
set
{
Dirty = true;
baseWeaponSkill = value;
}
}

[DataElement]
public string AutoTrainSkills
{
get { return autoTrainableSkills; }
set
{
Dirty = true;
autoTrainableSkills = value;
}
}

[DataElement]
public string EligibleRaces
{
get { return eligibleRaces; }
set
{
Dirty = true;
eligibleRaces = value;
}
}
}
[DataTable(TableName = "CharacterClass")]
public class DBCharacterClass : DataObject
{
private byte id;
private byte baseClassID;
private byte specPointMultiplier;
private short baseHP;
private short baseWeaponSkill;
private string autoTrainableSkills = "";
private string eligibleRaces = "";
private byte classType;
private string name;
private string femaleName = "";
private string professionTranslationID;
private byte primaryStat;
private byte secondaryStat;
private byte tertiaryStat;
private byte manaStat;
private bool canUseLeftHandedWeapon;
private byte maxPulsingSpells;

[PrimaryKey]
public byte ID
{
get => id;
set
{
Dirty = true;
id = value;
}
}

[DataElement]
public byte BaseClassID
{
get => baseClassID;
set
{
Dirty = true;
baseClassID = value;
}
}

[DataElement]
public byte ClassType
{
get => classType;
set
{
Dirty = true;
classType = value;
}
}

[DataElement]
public string Name
{
get => name;
set
{
Dirty = true;
name = value;
}
}

[DataElement]
public string FemaleName
{
get => femaleName;
set
{
Dirty = true;
femaleName = value;
}
}

[DataElement]
public byte SpecPointMultiplier
{
get => specPointMultiplier;
set
{
Dirty = true;
specPointMultiplier = value;
}
}

[DataElement]
public string AutoTrainSkills
{
get => autoTrainableSkills;
set
{
Dirty = true;
autoTrainableSkills = value;
}
}


[DataElement]
public byte PrimaryStat
{
get => primaryStat;
set
{
Dirty = true;
primaryStat = value;
}
}

[DataElement]
public byte SecondaryStat
{
get => secondaryStat;
set
{
Dirty = true;
secondaryStat = value;
}
}

[DataElement]
public byte TertiaryStat
{
get => tertiaryStat;
set
{
Dirty = true;
tertiaryStat = value;
}
}

[DataElement]
public byte ManaStat
{
get => manaStat;
set
{
Dirty = true;
manaStat = value;
}
}

[DataElement]
public short BaseHP
{
get => baseHP;
set
{
Dirty = true;
baseHP = value;
}
}

[DataElement]
public short BaseWeaponSkill
{
get => baseWeaponSkill;
set
{
Dirty = true;
baseWeaponSkill = value;
}
}

[DataElement]
public string EligibleRaces
{
get => eligibleRaces;
set
{
Dirty = true;
eligibleRaces = value;
}
}

[DataElement]
public bool CanUseLeftHandedWeapon
{
get => canUseLeftHandedWeapon;
set
{
Dirty = true;
canUseLeftHandedWeapon = value;
}
}

[DataElement]
public string ProfessionTranslationID
{
get => professionTranslationID;
set
{
Dirty = true;
professionTranslationID = value;
}
}

//No DataElement on purpose
public byte MaxPulsingSpells
{
get => maxPulsingSpells;
set
{
Dirty = true;
maxPulsingSpells = value;
}
}
}
}
2 changes: 2 additions & 0 deletions GameServer/ai/brain/Necromancer/NecromancerPetBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public override void Notify(DOL.Events.DOLEvent e, object sender, EventArgs args
// This message is for spells from the spell queue only, so suppress
// it for insta cast buffs coming from the pet itself.

var spellHandler = ScriptMgr.CreateSpellHandler(Owner, spellArgs.Spell, spellLine);
Owner.Mana -= spellHandler.PowerCost(target);
if (spellLine.Name != (Body as NecromancerPet).PetInstaSpellLine)
{
Owner.Notify(GameLivingEvent.CastStarting, Body, new CastingEventArgs(Body.CurrentSpellHandler));
Expand Down
2 changes: 1 addition & 1 deletion GameServer/commands/gmcommands/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ public void SetClass(GamePlayer target, int classID)

//reset before, and after changing the class.
target.Reset();
target.SetCharacterClass(classID);
target.SetCharacterClass(CharacterClass.GetClass(classID));
target.Reset();

//this is just for additional updates
Expand Down
58 changes: 41 additions & 17 deletions GameServer/effects/Necromancer/NecromancerShadeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,60 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;
using System.Collections.Generic;
using DOL.AI.Brain;

namespace DOL.GS.Effects
{
/// <summary>
/// Necromancer shade effect (grants immunity to all forms of
/// attack).
/// </summary>
/// <author>Aredhel</author>
public class NecromancerShadeEffect : ShadeEffect
{
/// <summary>
/// Creates a new shade effect.
/// </summary>
public NecromancerShadeEffect() { }
public override void Start(GameLiving living)
{
base.Start(living);

if (player.ControlledBrain != null && player.ControlledBrain.Body != null)
{
GameNPC pet = player.ControlledBrain.Body;
List<GameObject> attackerList;
lock (player.Attackers)
attackerList = new List<GameObject>(player.Attackers);

foreach (GameObject obj in attackerList)
{
if (obj is GameNPC)
{
GameNPC npc = (GameNPC)obj;
if (npc.TargetObject == player && npc.AttackState)
{
IOldAggressiveBrain brain = npc.Brain as IOldAggressiveBrain;
if (brain != null)
{
npc.AddAttacker(pet);
npc.StopAttack();
brain.AddToAggroList(pet, (int)(brain.GetAggroAmountForLiving(player) + 1));
}
}
}
}
}
}

public override void Cancel(bool playerCanceled)
{
if (player.ControlledBrain != null)
{
(player.ControlledBrain as ControlledNpcBrain).Stop();
}
base.Cancel(playerCanceled);
}

protected int m_timeRemaining = -1;

/// <summary>
/// Remaining time of the effect in seconds.
/// </summary>
public override int RemainingTime
{
get { return (m_timeRemaining < 0) ? 0 : m_timeRemaining * 1000; }
}

/// <summary>
/// Set timer when pet is out of range.
/// </summary>
/// <param name="seconds"></param>
public void SetTetherTimer(int seconds)
{
m_timeRemaining = seconds;
Expand Down
Loading

0 comments on commit a50d077

Please sign in to comment.