Experience not working properly?

07/25/2012 18:58 ProperCodes#1
Code:
namespace Source.Structures.Instances
{
    class Experience
    {
        public static void ProcessLeveling(GameClient Attacker, IBaseEntity Opponent, GuildMonster GuildMob, uint Damage, ushort SpellID)
        {
            #region TG
            if (GuildMob != null)
            {
                if (Attacker.Entity.MapID.ID == 1039)
                {
                    if (SpellID == 0)
                        ConquerSpell.CalculateProfExp(Attacker, Damage);
                    if (SpellID != 0)
                        ConquerSpell.CalculateSpellExp(Attacker, SpellID, Damage);

                    CalculateExp(Attacker, GuildMob.Level, Damage);
                    return;
                }
            }
            #endregion
            #region Monsters
            else if (Attacker.Entity.EntityFlag == EntityFlag.Player && Opponent.EntityFlag == EntityFlag.Monster)
            {
                Monster Monster = (Monster)Opponent.Owner;
                if (Monster.IsGuard) return;

                if (SpellID == 0)
                    ConquerSpell.CalculateProfExp(Attacker, Damage);
                if (SpellID != 0)
                    ConquerSpell.CalculateSpellExp(Attacker, SpellID, Damage);
                if (Attacker.Team.Active)
                    ConquerTeam.CalculateExp(Attacker, (byte)(Opponent.Owner as Entity).Level); //Problem

                    CalculateExp(Attacker, (Opponent.Owner as Monster).Entity.Level, Damage);
            }
            #endregion
        }
        public static void CalculateExp(GameClient Attacker, int OpponentLv, uint Damage)
        {
            if (Attacker.Entity.Level < 130)
            {
                double AddedExp = 0;
                if (OpponentLv + 4 < Attacker.Entity.Level) AddedExp = 0.1;
                if (OpponentLv + 4 >= Attacker.Entity.Level) AddedExp = 1;
                if (OpponentLv >= Attacker.Entity.Level) AddedExp = 1.1;
                if (OpponentLv - 4 > Attacker.Entity.Level) AddedExp = 1.3;

                Damage = Convert.ToUInt32(Damage * AddedExp);
                Damage *= (uint)DataStructures.ExperienceRate;

                if (Attacker.ExperienceMultiply > 0)
                    Damage *= Attacker.ExperienceMultiply;
                if (Attacker.Entity.MapID == 1039)
                    Damage = (uint)Math.Round((double)Damage * 0.1); // * tgModifier

                Attacker.Experience += (int)Damage;

                uint Needed = Database.LoadLevelExp((byte)Attacker.Entity.Level);
                if ((int)(Attacker.Experience - Needed) >= 0)
                {
                    //Attacker.Experience -= (int)Needed;
                    Attacker.Experience = 0;
                    StatusChange.Level(Attacker, (byte)(Attacker.Entity.Level + 1), true);
                }
                Attacker.Send(new StatTypePacket(Attacker.Entity.UID, (uint)Attacker.Experience, StatIDs.Experience).Serialize());
            }
        }
    }
}
I am having troubles getting the experience to work properly maybe because of this? I am not sure, but when I kill a monster none of the experience is adding to the bar. Every time I try to fix it, it because worse and even more errors show. If someone can help it would be beyond great! Yes, I am trying to learn how to code so excuse the sloppy work.
07/25/2012 20:29 _DreadNought_#2
Are you level 130+?

Is monster null?

Check:)
07/25/2012 20:49 ProperCodes#3
I am level 1 and how do I check if monster is null? (Stupid question)
07/25/2012 20:54 _DreadNought_#4
Learn breakpointing, That will more than likely solve your current problem of figuring out what the problem was in the first place.
07/25/2012 21:25 shadowman123#5
Well show us the Error .. and you should call these once each attack bet Player -> monster btw i like the way u coded it