[HELP] Speedgun Weapon Skill Error

09/04/2008 22:13 taguro#1
After careful testing, I've determined the what causes the error to occur. I just haven't the slightest clue how to fix it.

Action that causes the error:
Quote:
Attempting to attack with Spear while using Skill Speedgun
Problem (in-game):
Quote:
When the player uses spear, the attack is fine. When the add the skill SpeedGun, they can no longer attack the monster, and the server throws the error below:
Error:
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
   at COServer_Project.Character.WeaponSkill() in C:Conquer BeyondCOBeyond SourceCharacter.cs:line 2849
   at COServer_Project.Character.Attack() in C:Conquer BeyondCOBeyond SourceCharacter.cs:line 3250
Character.cs Statement 1:
Code:
                else if (WepType == 560 && !Use)
                {
                    if (TargetUID != 0)
                        if (Skills.Contains((short)1260))
                        {
                            byte SkillLvl = (byte)Skills[(short)1260];
                            byte Chance = (byte)DataBase.SkillAttributes[(int)1260][(int)SkillLvl][5];
                            if (Other.ChanceSuccess(Chance))
                            {
                                UseSkill(1260, 0, 0, TargetUID);
                                Use = true;
                            }
                        }
                }
Line 2849:
Code:
                        if (Skills.Contains((short)1260))
Character.cs Statement 2:
Code:
   public void Attack()
        {
            LastAttack = DateTime.Now;
            if (!Alive)
            {
                MobTarget = null;
                SkillLoopingTarget = 0;
                TGTarget = null;
                PTarget = null;
                return;
            }
            Ready = false;
            try
            {
                if (AtkType == 25 || AtkType == 2)
                {
                    if (!WeaponSkill())
                    {
                        if (MobTarget != null)
                        {
                            if (MobTarget.Alive)
                                if (MobTarget.Map == LocMap)
                                    if (MyMath.PointDistance(LocX, LocY, MobTarget.PosX, MobTarget.PosY) < 6 || AtkType == 25)
                                    {
                                        if (!SMOn && !AccuracyOn)
                                        {
                                            if (!Other.ChanceSuccess(RealAgi / 2 + Math.Abs((110 - Level) / 2)))
                                            {
                                                MissAttack(MobTarget);
                                                return;
                                            }
                                        }
                                        else if (SMOn)
                                        {
                                            if (!Other.ChanceSuccess(RealAgi + Math.Abs((110 - Level) / 2)))
                                            {
                                                MissAttack(MobTarget);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            if (!Other.ChanceSuccess(RealAgi * 1.2 + Math.Abs((110 - Level) / 2)))
                                            {
                                                MissAttack(MobTarget);
                                                return;
                                            }
                                        }
Line 3250:
Code:
                    if (!WeaponSkill())
This is the only weapon skill I've had any errors with. All others were tested and proved working.
09/04/2008 22:28 Zanzibar#2
Replace the first thing with this

Code:
else if (WepType == 560 && !Use)
                {
                    if (Skills.Contains((short)1260))
                    {
                        byte SkillLvl = (byte)Skills[(short)1260];
                        byte Chance = (byte)DataBase.SkillAttributes[(int)1260][(int)SkillLvl][5];
                        if (Other.ChanceSuccess(Chance))
                        {
                            UseSkill(1260, 0, 0, 0);
                            Use = true;
                        }
                    }
                }
09/04/2008 22:57 taguro#3
Quote:
Originally Posted by Zanzibar View Post
Replace the first thing with this

Code:
else if (WepType == 560 && !Use)
                {
                    if (Skills.Contains((short)1260))
                    {
                        byte SkillLvl = (byte)Skills[(short)1260];
                        byte Chance = (byte)DataBase.SkillAttributes[(int)1260][(int)SkillLvl][5];
                        if (Other.ChanceSuccess(Chance))
                        {
                            UseSkill(1260, 0, 0, 0);
                            Use = true;
                        }
                    }
                }
Thanks for the reply, unfortunately, this didn't fix the error.
09/04/2008 23:01 InfamousNoone#4
the "Skills" variable is null.
09/04/2008 23:05 taguro#5
Quote:
Originally Posted by InfamousNoone View Post
the "Skills" variable is null.
I thought about that, but if that was it, then why do all the other weapon skills work. I used the same code for all of them.
09/05/2008 01:39 tao4229#6
Quote:
Originally Posted by taguro View Post
I thought about that, but if that was it, then why do all the other weapon skills work. I used the same code for all of them.
You don't understand, the variable IS null. Otherwise you wouldn't be getting that error. I will look at it in a minute... Are you sure that 1260 is the speedgun ID?
09/05/2008 09:40 ~*NewDuuDe*~#7
Quote:
Originally Posted by tao4229 View Post
You don't understand, the variable IS null. Otherwise you wouldn't be getting that error. I will look at it in a minute... Are you sure that 1260 is the speedgun ID?
Yep 1260 is the speedgun id
i have a list of pretty much all
if u go a bit down in tht guide ull see all skills well allmost all
[Only registered and activated users can see links. Click Here To Register...]
09/05/2008 12:48 YukiXian#8
U have to code it too in the DataBase.cs!
09/05/2008 15:36 taguro#9
Quote:
Originally Posted by YukiXian View Post
U have to code it too in the DataBase.cs!
lol, i know it has to be coded in the database.cs.... and it is. here is my issue, the coding is the exact same for EVERY 2-handed weapon skill. all other skills work besides this ONE. Any more ideas?
09/06/2008 04:52 taguro#10
NVM error solved: Thanks for all your posts and replies.
09/06/2008 05:31 tao4229#11
Quote:
Originally Posted by taguro View Post
NVM error solved: Thanks for all your posts and replies.
Just out of curiosity, what was the problem, and how did you solve it?(Just incase I run into this later =o)
09/06/2008 08:30 taguro#12
Quote:
Originally Posted by tao4229 View Post
Just out of curiosity, what was the problem, and how did you solve it?(Just incase I run into this later =o)
When I was writing the Database.cs file, I was quickly copying and pasting the codes I was using for the other weapon skills. I just forgot to change the last code to 1260(the skill id for the spear.)

Quote:
U have to code it too in the DataBase.cs!
Thanks goes to YukiXian for pointing out the Database.cs and to Kinshi who help me out the most with this error.
09/06/2008 16:14 tao4229#13
Quote:
Originally Posted by taguro View Post
When I was writing the Database.cs file, I was quickly copying and pasting the codes I was using for the other weapon skills. I just forgot to change the last code to 1260(the skill id for the spear.)


Thanks goes to YukiXian for pointing out the Database.cs and to Kinshi who help me out the most with this error.
Ahh, I see.

I could totally see myself doing that D=
09/06/2008 21:53 ~Yuki~#14
Quote:
Originally Posted by tao4229 View Post
Ahh, I see.

I could totally see myself doing that D=
Lol... everyone makes mistakes some BIG ones some LIL ones... Who cares^^