Spells added to a class disappear after I do other things

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

Spells added to a class disappear after I do other things

Postby psychoninja911 » Tue Jan 23, 2018 3:21 am

:D
Hey guys!
Basically, I have a code snippet in an NPC that fires off this for me when I pick a spell or spec I want to add to a class. These are old spell lines. No unique spells.
They all appear just as they should, but if I level, relog, zone, or try to train - they all get removed.
Code: Select all
if (text.ToLower() == "click")
{
player.Out.SendMessage("Should have other spell line now!", DOL.GS.PacketHandler.eChatType.CT_Staff, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow);
player.AddSpecialization(SkillBase.GetSpecialization(Specs.Stormcalling));
player.AddSpellLine(SkillBase.GetSpellLine("Stormcalling"));
player.AddSpecialization(SkillBase.GetSpecialization(Specs.Darkness));
player.AddSpellLine(SkillBase.GetSpellLine("Darkness"));
player.AddSpecialization(SkillBase.GetSpecialization(Specs.Augmentation));
player.AddSpellLine(SkillBase.GetSpellLine("Augmentation"));
player.Out.SendUpdatePlayer();
player.Out.SendUpdatePoints();
player.Out.SendUpdatePlayerSkills();
player.SaveIntoDatabase();
player.UpdatePlayerStatus();
}
That's what it kinda looks like. Those are just test specs...
I seriously watch them disappear like this:
Image
psychoninja911
DOL Novice
 
Posts: 51
Joined: Fri Oct 07, 2011 6:46 pm

Re: Spells added to a class disappear after I do other thing

Postby Dinberg » Tue Jan 23, 2018 9:37 am

What triggers the removal? It looks like interacting with the trainer in some way, like training one of the skills?
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Re: Spells added to a class disappear after I do other thing

Postby psychoninja911 » Tue Jan 23, 2018 5:52 pm

What triggers the removal? It looks like interacting with the trainer in some way, like training one of the skills?
I'm not 100% sure.

I did some more tests. BEFORE the spells disappear, I can use them! They all work. Darkness, Stormcalling, whatever.
So. Relogging and trainer must have the same thing that removes stuff you can't use.
Also let me add!:
I did NOT set anything up in classxspecialization that allows me to naturally have this. Otherwise, if I do, I think the spell appears there all the time. I want the players to journey off into the wild, and learn how to make this spell... but without their hard work disappearing :D


Here's my fightertrainer.cs:
/*
* 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;
using DOL.Database;
using DOL.GS.PacketHandler;
using DOL.Language;

namespace DOL.GS.Trainer
{
/// <summary>
/// Fighter Trainer
/// </summary>
[NPCGuildScript("Fighter Trainer", eRealm.Albion)] // this attribute instructs DOL to use this script for all "Fighter Trainer" NPC's in Albion (multiple guilds are possible for one script)
public class FighterTrainer : GameTrainer
{
public override eCharacterClass TrainedClass
{
get { return eCharacterClass.Fighter; }
}

/// <summary>
/// The practice weapon template ID
/// </summary>
public const string PRACTICE_WEAPON_ID = "practice_sword";
/// <summary>
/// The practice shield template ID
/// </summary>
public const string PRACTICE_SHIELD_ID = "small_training_shield";

public FighterTrainer() : base(eChampionTrainerType.Fighter)
{
}

/// <summary>
/// Interact with trainer
/// </summary>
/// <param name="player"></param>
/// <returns></returns>
public override bool Interact(GamePlayer player)
{
if (!base.Interact(player)) return false;

// check if class matches
if (player.CharacterClass.ID == (int)TrainedClass)
{
// player can be promoted
if (player.Level>=5)
{
player.Out.SendMessage(this.Name + " says, \"You must now seek your training elsewhere. Which path would you like to follow? [Armsman], [Paladin], or [Mercenary]?\"", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
}
else
{
OfferTraining(player);
}

// ask for basic equipment if player doesnt own it
if (player.Inventory.GetFirstItemByID(PRACTICE_WEAPON_ID, eInventorySlot.MinEquipable, eInventorySlot.LastBackpack) == null)
{
player.Out.SendMessage(this.Name + " says, \"Do you require a [practice weapon]?\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
if (player.Inventory.GetFirstItemByID(PRACTICE_SHIELD_ID, eInventorySlot.MinEquipable, eInventorySlot.LastBackpack) == null)
{
player.Out.SendMessage(this.Name + " says, \"Do you require a [training shield]?\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
}
else
{
CheckChampionTraining(player);
}
return true;
}

/// <summary>
/// Talk to trainer
/// </summary>
/// <param name="source"></param>
/// <param name="text"></param>
/// <returns></returns>
public override bool WhisperReceive(GameLiving source, string text)
{
if (!base.WhisperReceive(source, text)) return false;
GamePlayer player = source as GamePlayer;

switch (text) {
case "Armsman":
if(player.Race == (int)eRace.Avalonian || player.Race == (int)eRace.Briton || player.Race == (int)eRace.HalfOgre || player.Race == (int)eRace.Highlander || player.Race == (int)eRace.Inconnu || player.Race == (int)eRace.Saracen || player.Race == (int)eRace.AlbionMinotaur)
{
player.Out.SendMessage(this.Name + " says, \"Ah! An Armsmen is it? Good solid fighters they are! Their fighting prowess is a great asset to Albion. To become an armsman you must enlist with the Defenders of Albion.\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
else{
player.Out.SendMessage(this.Name + " says, \"The path of an Armsman is not available to your race. Please choose another.\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
return true;
case "Mercenary":
if(player.Race == (int)eRace.Avalonian || player.Race == (int)eRace.Briton || player.Race == (int)eRace.HalfOgre || player.Race == (int)eRace.Highlander || player.Race == (int)eRace.Inconnu || player.Race == (int)eRace.Saracen || player.Race == (int)eRace.AlbionMinotaur)
{
player.Out.SendMessage(this.Name + " says, \"You wish to become a Mercenary do you? Roguish fighters in nature, solid warriors in battle, their ability to quickly evade enemy attacks has made them a valuable asset to the Guild of Shadows.\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
else{
player.Out.SendMessage(this.Name + " says, \"The path of a Mercenary is not available to your race. Please choose another.\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
return true;
case "Paladin":
if(player.Race == (int) eRace.Avalonian || player.Race == (int) eRace.Briton || player.Race == (int) eRace.Highlander || player.Race == (int) eRace.Saracen){
player.Out.SendMessage(this.Name + " says, \"You wish to be a defender of the faith I take it? Many a Paladin has led our fighters into battle with victory not far behind. Their never-ending sacrifice proves that the Church of Albion will remain for many centuries!\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
else{
player.Out.SendMessage(this.Name + " says, \"The path of a Paladin is not available to your race. Please choose another.\"",eChatType.CT_Say,eChatLoc.CL_PopupWindow);
}
return true;
case "practice weapon":
if (player.Inventory.GetFirstItemByID(PRACTICE_WEAPON_ID, eInventorySlot.Min_Inv, eInventorySlot.Max_Inv) == null)
{
player.ReceiveItem(this,PRACTICE_WEAPON_ID);
}
return true;
case "training shield":
if (player.Inventory.GetFirstItemByID(PRACTICE_SHIELD_ID, eInventorySlot.Min_Inv, eInventorySlot.Max_Inv) == null)
{
player.ReceiveItem(this, PRACTICE_SHIELD_ID);
}
return true;
}
return true;
}
}
}
But the same thing happens when I relog too?
psychoninja911
DOL Novice
 
Posts: 51
Joined: Fri Oct 07, 2011 6:46 pm

Re: Spells added to a class disappear after I do other thing

Postby Dinberg » Tue Jan 23, 2018 7:32 pm

I'm guessing that the problem could be this:

GamePlayer.cs, LoadClassSpecializations(bool sendMessages) https://github.com/Dawn-of-Light/DOLSha ... ePlayer.cs
Code: Select all
/// <summary>
/// Load this player Classes Specialization.
/// </summary>
public virtual void LoadClassSpecializations(bool sendMessages)
{
// Get this Attached Class Specialization from SkillBase.
IDictionary<Specialization, int> careers = SkillBase.GetSpecializationCareer(CharacterClass.ID);

// Remove All Trainable Specialization or "Career Spec" that aren't managed by This Data Career anymore
var speclist = GetSpecList();
var careerslist = careers.Keys.Select(k => k.KeyName.ToLower());
foreach (var spec in speclist.Where(sp => sp.Trainable || !sp.AllowSave))
{
if (!careerslist.Contains(spec.KeyName.ToLower()))
RemoveSpecialization(spec.KeyName);
}
This method seems to strip all specializations from the player if they aren't included in the Database definition of the class! It is called by 'GamePlayer.LoadSkillsFromCharacter' (which explains the loss at log in) and 'GamePlayer.RefreshSpecDependentSkills' (which probably explains the loss when you interact with the trainer.

You might be able to just remove this and get your intended functionality. Good luck!
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Re: Spells added to a class disappear after I do other thing

Postby psychoninja911 » Tue Jan 23, 2018 7:43 pm

I'm guessing that the problem could be this:

GamePlayer.cs, LoadClassSpecializations(bool sendMessages) https://github.com/Dawn-of-Light/DOLSha ... ePlayer.cs
Code: Select all
/// <summary>
/// Load this player Classes Specialization.
/// </summary>
public virtual void LoadClassSpecializations(bool sendMessages)
{
// Get this Attached Class Specialization from SkillBase.
IDictionary<Specialization, int> careers = SkillBase.GetSpecializationCareer(CharacterClass.ID);

// Remove All Trainable Specialization or "Career Spec" that aren't managed by This Data Career anymore
var speclist = GetSpecList();
var careerslist = careers.Keys.Select(k => k.KeyName.ToLower());
foreach (var spec in speclist.Where(sp => sp.Trainable || !sp.AllowSave))
{
if (!careerslist.Contains(spec.KeyName.ToLower()))
RemoveSpecialization(spec.KeyName);
}
This method seems to strip all specializations from the player if they aren't included in the Database definition of the class! It is called by 'GamePlayer.LoadSkillsFromCharacter' (which explains the loss at log in) and 'GamePlayer.RefreshSpecDependentSkills' (which probably explains the loss when you interact with the trainer.

You might be able to just remove this and get your intended functionality. Good luck!

Dang! You are amazing! I'm going to test this right away!

Thank you so much Dinberg! I really really appreciate it sir!

Edit:
Look what I found Dinberg:
Code: Select all
// Remove All Trainable Specialization or "Career Spec" that aren't managed by This Data Career anymore
var speclist = GetSpecList();
var careerslist = careers.Keys.Select(k => k.KeyName.ToLower());
foreach (var spec in speclist.Where(sp => sp.Trainable || !sp.AllowSave))
{
if (!careerslist.Contains(spec.KeyName.ToLower()))
RemoveSpecialization(spec.KeyName);
}
psychoninja911
DOL Novice
 
Posts: 51
Joined: Fri Oct 07, 2011 6:46 pm

Re: Spells added to a class disappear after I do other thing

Postby psychoninja911 » Tue Jan 23, 2018 8:02 pm

WORKED!!!!!

Thank you so much! I'll pass this help on as much as I can.
I really appreciate it!

Edit: That fixed it for logging in and out, AND for speccing. I have no idea why or how that little snippet applies to both.
psychoninja911
DOL Novice
 
Posts: 51
Joined: Fri Oct 07, 2011 6:46 pm

Re: Spells added to a class disappear after I do other thing

Postby Dinberg » Tue Jan 23, 2018 11:47 pm

No problem, glad to be of help.

If you read above again, you'll see why it applies to both. Follow the code execution through - though I appreciate that can be nasty, DOL does look like spaghetti these days!
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Re: Spells added to a class disappear after I do other thing

Postby psychoninja911 » Wed Jan 24, 2018 10:27 pm

Hmm... Is this the correct context for adding an ability skill? Like, guard, or blunt weapons, or studded armor?
player.AddAbility(SkillBase.GetAbility("Combat Awareness"));

I also found this online, however it it doesn't recognize weapon_axes, or any abilities, as being part of Abilities class.
player.addability(skillbase.getability(abilities.weapon_axes));
or
player.addability(skillbase.getability(Abilities.Studded));

For example, the studded one would give me an error that says:
'Dictionary<string, Ability>' does not contain a definition for 'Studded' and no xtension method 'Studded' accepting a first argument of type 'Dictionary<string, Ability>' could be found (are you missing a using directive or assembly reference?)

But that appears to be the method everyone else is using.
With the method I made:
player.AddAbility(SkillBase.GetAbility("Combat Awareness"));
It says the skill is added, but I never see it appear in that tab.
psychoninja911
DOL Novice
 
Posts: 51
Joined: Fri Oct 07, 2011 6:46 pm

Re: Spells added to a class disappear after I do other thing

Postby Shadexx » Fri Feb 02, 2018 5:11 am

Hi there,

I can only give advice for an older REV as I am not using the current one, but back then, you had to add new abilities into the "SkillConstants.cs" file. In addition to that, one has to create a DB entry in the "ability" table. For complete new abilities though, you will have to write a new .CS file or to use an existing one which you would kind of edit to your matches.

PS: I am happy that DOL is still alive and people are still willed to help. :)
User avatar
Shadexx
DOL Experienced
 
Posts: 156
Joined: Mon Nov 09, 2009 9:58 am
Location: Germany

Re: Spells added to a class disappear after I do other thing

Postby Dinberg » Fri Feb 02, 2018 9:17 am

I think psychoninja was able to solve this in the end. If so, could you post the solution? Cheers
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest