SirHack'nSmash
Recruit
I am encountering a null reference exception while attempting a simple test to add experience to the player's skills. The exception occurs when AddSkillXp() is called and since this is part of the game's native code I don't know how to investigate further. Does anyone know why the code below fails and can anyone provide any information at all on how to mod experience and character development using only custom DLLs or XMLs, without altering native game files?
(The code is implemented in a custom MissionBehaviour class.)
C#:
public override void OnMissileHit(Agent attacker, Agent victim, bool isCanceled)
{
if (attacker != null && attacker.IsHero)
{
//Boost crossbow xp for every missile hit.
SkillObject xSkill = new SkillObject("Crossbow");
CharacterObject xChar = (CharacterObject)attacker.Character;
xChar.HeroObject.AddSkillXp(xSkill, 10000f);
InformationManager.DisplayMessage(new InformationMessage("Crossbow XP gained."));
}
}
(The code is implemented in a custom MissionBehaviour class.)