[Help]The gate and pole wont die!

02/19/2012 18:33 JobvdH#1
Hello all,

I finished coding guildwar and guilds on CoEmu.
But when my guildwar is started the gates and the pole won't "Die"
Can someone help me with this?

Heres my code:
Code:
		public static void doTNpc(ClientSocket CSocket, Struct.TerrainNPC AttackedTNpc, int Damage, int AType)
		{
			if(AttackedTNpc.UID >= 6700)
			{
                if (AType != 21)
                    ConquerPacket.ToLocal(ConquerPacket.Attack(CSocket.Client.ID, AttackedTNpc.UID, AttackedTNpc.X, AttackedTNpc.Y, Damage, AType), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
                if (AType == 25)
                    ConquerPacket.ToLocal(ConquerPacket.Status(CSocket, 2, AttackedTNpc.CurrentHP, (Struct.StatusTypes)0), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
                if (AttackedTNpc.UID == 6701)
                {
                    if (AttackedTNpc.CurrentHP <= 0)
                    {
                        Handler.OpenGate((Struct.TerrainNPC)Nano.TerrainNpcs[6701]);
                    }
                }
                else if (AttackedTNpc.UID == 6702)
                {
                    if (AttackedTNpc.CurrentHP <= 0)
                    {
                        Handler.OpenGate((Struct.TerrainNPC)Nano.TerrainNpcs[6702]);
                    }
                }
                else if (AttackedTNpc.UID == 6700)
                {
                    if (AttackedTNpc.CurrentHP <= 0)
                    {
                        AttackedTNpc.CurrentHP = 0;
                        Handler.RestartWar(CSocket, AttackedTNpc);
                    }
                    else
                    {
                        if (Struct.GuildWars.Scores.Contains(CSocket.Client.Guild.Name))
                            Struct.GuildWars.Scores[CSocket.Client.Guild.Name] = (int)Struct.GuildWars.Scores[CSocket.Client.Guild.Name] + Damage;
                        else
                            Struct.GuildWars.Scores.Add(CSocket.Client.Guild.Name, Damage);
                    }
                }
			}
			else
			{
				GiveExp(CSocket, AttackedTNpc, Damage);
				if(AType != 21)
					ConquerPacket.ToLocal(ConquerPacket.Attack(CSocket.Client.ID, AttackedTNpc.UID, AttackedTNpc.X, AttackedTNpc.Y, Damage, AType), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
			}
		}
Thanks in advance,
JobvdH!
02/20/2012 19:01 JobvdH#2
Bump
02/21/2012 00:33 pro4never#3
All anyone can say is breakpoint, see where the issue is and then fix the problem.

Does it ever call the open gate or restart war method? What about inside that method, where does it fail?
02/21/2012 09:43 JobvdH#4
Well I tried putting the OpenGate method on a command and it works fine, but when I attack the gate it will remain closed.

#Edit:
Heres my OpenGate void:
Code:
        public static void OpenGate(Struct.TerrainNPC TNpc)
        {
            if (TNpc.UID == 6701)
            {
                TNpc.CurrentHP = 0;
                TNpc.Type = 1704177;
                ConquerPacket.ToLocal(ConquerPacket.TerrainNPC(TNpc.UID, TNpc.MaximumHP, TNpc.CurrentHP, TNpc.X, TNpc.Y - 2, TNpc.Type, "ii", 1), TNpc.X, TNpc.Y - 2, TNpc.Map, 0, 0);
            }
            else if (TNpc.UID == 6702)
            {
                TNpc.CurrentHP = 0;
                TNpc.Type = 1704213;
                ConquerPacket.ToLocal(ConquerPacket.TerrainNPC(TNpc.UID, TNpc.MaximumHP, TNpc.CurrentHP, TNpc.X, TNpc.Y - 4, TNpc.Type, "ii", 1), TNpc.X, TNpc.Y - 4, TNpc.Map, 0, 0);
            }
        }
02/21/2012 11:00 pro4never#5
As I said.. breakpoint and see where the issue lies. Aka basic introductory debugging anyone who wants to program should be comfortable with doing regularly.
02/21/2012 11:30 JobvdH#6
Nothing is wrong with the brake points, that went wrong with making a copy.
I found out that if passes the else if (AttackedTNpc.UID == 6702) but at the HP check. It just doesn't check it or the check is wrong.

Code:
                else if (AttackedTNpc.UID == 6702) //Left gate
                {
                    if (Nano.TerrainNpcs[6702].CurrentHP <= 0)
                    {
                        Handler.OpenGate((Struct.TerrainNPC)Nano.TerrainNpcs[6702]);
                    }
                }
#EDIT:
I've already got it fixed, thanks for the support!

#Request Close!