Exemple #1
0
        private void ListTargetInfo()
        {
            string cp        = "0/0";
            string hp        = "0/0";
            string mp        = "0/0";
            uint   target_id = Globals.gamedata.my_char.TargetID;

            switch (Globals.gamedata.my_char.CurrentTargetType)
            {
            case TargetType.SELF:
                hp = Globals.gamedata.my_char.Cur_HP.ToString() + "/" + Globals.gamedata.my_char.Max_HP.ToString();
                mp = Globals.gamedata.my_char.Cur_MP.ToString() + "/" + Globals.gamedata.my_char.Max_MP.ToString();
                cp = Globals.gamedata.my_char.Cur_CP.ToString() + "/" + Globals.gamedata.my_char.Max_CP.ToString();
                break;

            case TargetType.MYPET:
                hp = Globals.gamedata.my_pet.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet.Max_HP.ToString();
                mp = Globals.gamedata.my_pet.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet.Max_MP.ToString();
                cp = Globals.gamedata.my_pet.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet.Max_CP.ToString();
                break;

            case TargetType.MYPET1:
                hp = Globals.gamedata.my_pet1.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet1.Max_HP.ToString();
                mp = Globals.gamedata.my_pet1.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet1.Max_MP.ToString();
                cp = Globals.gamedata.my_pet1.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet1.Max_CP.ToString();
                break;

            case TargetType.MYPET2:
                hp = Globals.gamedata.my_pet2.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet2.Max_HP.ToString();
                mp = Globals.gamedata.my_pet2.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet2.Max_MP.ToString();
                cp = Globals.gamedata.my_pet2.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet2.Max_CP.ToString();
                break;

            case TargetType.MYPET3:
                hp = Globals.gamedata.my_pet3.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet3.Max_HP.ToString();
                mp = Globals.gamedata.my_pet3.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet3.Max_MP.ToString();
                cp = Globals.gamedata.my_pet3.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet3.Max_CP.ToString();
                break;

            case TargetType.PLAYER:
                Globals.PlayerLock.EnterReadLock();
                try
                {
                    CharInfo player = Util.GetChar(target_id);

                    if (player != null)
                    {
                        /*if (Globals.gamedata.Chron >= Chronicle.CT2_4 && Globals.gamedata.Official_Server)
                         * {
                         *  /*
                         *  hp = ("HP: " + player.Cur_HP / 100000).ToString() + "%";
                         *  mp = ("MP: " + player.Cur_MP / 100000).ToString() + "%";
                         *  cp = ("CP: " + player.Cur_CP / 100000).ToString() + "%";
                         *  hp = ("HP: " + (player.Cur_HP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture));
                         *  mp = ("CP: " + (player.Cur_MP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture));
                         *  cp = ("MP: " + (player.Cur_CP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture));
                         *
                         * }
                         * else
                         * {*/
                        hp = player.Cur_HP.ToString() + "/" + player.Max_HP.ToString();
                        mp = player.Cur_MP.ToString() + "/" + player.Max_MP.ToString();
                        cp = player.Cur_CP.ToString() + "/" + player.Max_CP.ToString();
                        //}
                    }
                }    //unlock
                finally
                {
                    Globals.PlayerLock.ExitReadLock();
                }
                break;

            case TargetType.NPC:
                Globals.NPCLock.EnterReadLock();
                try
                {
                    NPCInfo npc = Util.GetNPC(target_id);

                    if (npc != null)
                    {
                        hp = npc.Cur_HP.ToString() + "/" + npc.Max_HP.ToString();
                        mp = npc.Cur_MP.ToString() + "/" + npc.Max_MP.ToString();
                        cp = npc.Cur_CP.ToString() + "/" + npc.Max_CP.ToString();

                        label_targetinfo.Text = "Target Info: " + Environment.NewLine
                                                + "ID : " + npc.ID.ToString() + Environment.NewLine
                                                + "NPCID: " + npc.NPCID.ToString() + Environment.NewLine
                                                + "Attackable: " + npc.isAttackable.ToString() + Environment.NewLine
                                                + "X: " + npc.X.ToString() + Environment.NewLine
                                                + "Y: " + npc.Y.ToString() + Environment.NewLine
                                                + "Z: " + npc.Z.ToString() + Environment.NewLine
                                                + "Heading: " + npc.Heading.ToString() + Environment.NewLine
                                                + "MAtk Speed: " + npc.MatkSpeed.ToString() + Environment.NewLine
                                                + "PAtk Speed: " + npc.PatkSpeed.ToString() + Environment.NewLine
                                                + "Run Speed: " + npc.RunSpeed.ToString() + Environment.NewLine
                                                + "Walk Speed: " + npc.WalkSpeed.ToString() + Environment.NewLine
                                                + "Move Speed Mult: " + npc.MoveSpeedMult.ToString() + Environment.NewLine
                                                + "Atk Speed Mult: " + npc.AttackSpeedMult.ToString() + Environment.NewLine
                                                + "Collision Rad: " + npc.CollisionRadius.ToString() + Environment.NewLine
                                                + "Collision Height: " + npc.CollisionHeight.ToString() + Environment.NewLine
                                                + "RHand: " + npc.RHand.ToString() + Environment.NewLine
                                                + "LHand: " + npc.LHand.ToString() + Environment.NewLine
                                                + "LRHand: " + npc.LRHand.ToString() + Environment.NewLine
                                                + "NameShows: " + npc.NameShows.ToString() + Environment.NewLine
                                                + "IsRunning: " + npc.isRunning.ToString() + Environment.NewLine
                                                + "IsInCombat: " + npc.isInCombat.ToString() + Environment.NewLine
                                                + "IsAlikeDead: " + npc.isAlikeDead.ToString() + Environment.NewLine
                                                + "IsInvisible: " + npc.isInvisible.ToString() + Environment.NewLine
                                                + "IsSitting: " + npc.isSitting.ToString();
                    }
                }    //unlock
                finally
                {
                    Globals.NPCLock.ExitReadLock();
                }
                break;
            }
        }
Exemple #2
0
 public static void StaticObjectInfo(ByteBuffer buffe)
 {
     NPCInfo npc_inf = new NPCInfo();
     npc_inf.LoadStaticObject(buffe);
     AddInfo.Add_NPCInfo(npc_inf);
 }
Exemple #3
0
        static public void GetLoc(uint id, ref int x, ref int y, ref int z)
        {
            //is self?
            if (Globals.gamedata.my_char.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_char.X);
                y = Util.Float_Int32(Globals.gamedata.my_char.Y);
                z = Util.Float_Int32(Globals.gamedata.my_char.Z);
                return;
            }

            //is my pet?
            if (Globals.gamedata.my_pet.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet.Z);
                return;
            }
            if (Globals.gamedata.my_pet1.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet1.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet1.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet1.Z);
                return;
            }
            if (Globals.gamedata.my_pet2.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet2.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet2.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet2.Z);
                return;
            }
            if (Globals.gamedata.my_pet3.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet3.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet3.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet3.Z);
                return;
            }

            //is in the list of chars?
            Globals.PlayerLock.EnterReadLock();
            try
            {
                CharInfo player = Util.GetChar(id);

                if (player != null)
                {
                    x = Util.Float_Int32(player.X);
                    y = Util.Float_Int32(player.Y);
                    z = Util.Float_Int32(player.Z);
                    return;
                }
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            //is it a party member?
            Globals.PartyLock.EnterReadLock();
            try
            {
                PartyMember pmem = Util.GetCharParty(id);

                if (pmem != null)
                {
                    x = pmem.X;
                    y = pmem.Y;
                    z = pmem.Z;
                    return;
                }
            }
            finally
            {
                Globals.PartyLock.ExitReadLock();
            }

            Globals.NPCLock.EnterReadLock();
            try
            {
                NPCInfo npc = Util.GetNPC(id);

                if (npc != null)
                {
                    x = Util.Float_Int32(npc.X);
                    y = Util.Float_Int32(npc.Y);
                    z = Util.Float_Int32(npc.Z);
                    return;
                }
            }
            finally
            {
                Globals.NPCLock.ExitReadLock();
            }
        }
Exemple #4
0
		public static void Add_NPCInfo(NPCInfo npc_inf)
		{
            Globals.NPCLock.EnterWriteLock();
            try
            {
                if (Globals.gamedata.nearby_npcs.ContainsKey(npc_inf.ID))
                {
                    //already in the array
                    //Globals.gamedata.nearby_npcs[npc_inf.ID] = npc_inf;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).X = npc_inf.X;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).Y = npc_inf.Y;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).Z = npc_inf.Z;
                    //((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).isInvisible = npc_inf.isInvisible;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).isAlikeDead = npc_inf.isAlikeDead;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).isInCombat = npc_inf.isInCombat;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).isSitting = npc_inf.isSitting;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).isRunning = npc_inf.isRunning;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).ExtendedEffects = npc_inf.ExtendedEffects;
                    ((NPCInfo)Globals.gamedata.nearby_npcs[npc_inf.ID]).AbnormalEffects = npc_inf.AbnormalEffects;
                    if (npc_inf.TargetID == Globals.gamedata.my_char.ID)
                    {
                        Globals.l2net_home.Add_Debug("Got aggro? " + npc_inf.Name);
                    }
                    else
                    {
                       // Globals.l2net_home.Add_Debug("npc:" + npc_inf.Name + " targetid:" + npc_inf.TargetID);
                    }
                }
                else
                {
                    Globals.gamedata.nearby_npcs.Add(npc_inf.ID, npc_inf);
                }
            }
            catch
            {
                //oh well
            }
            finally
            {
                Globals.NPCLock.ExitWriteLock();
            }

            Globals.l2net_home.timer_npcs.Start();
		}
Exemple #5
0
        public static void ExNPCInfo(ByteBuffer buffe)
        {
            try
            {
                NPCInfo npc_inf = new NPCInfo();
                npc_inf.LoadEX(buffe);
                AddInfo.Add_NPCInfo(npc_inf);
            }
            catch (Exception e)
            {
                Globals.l2net_home.Add_Text("FE:6601 packet error caught! " + e.Message, Globals.Red, TextType.ALL);
            }

        }
Exemple #6
0
        private static void AnimateStuff()
        {
            bool  found = false;
            float vx, vy, vz;
            float vxx;
            float movespeed;
            float time;

            ////////////////////////////////Animate self
            try
            {
                if (Globals.gamedata.my_char.Moving == true)
                {
                    if (Globals.gamedata.OOG && (DateTime.Now - Globals.gamedata.my_char.lastVerifyTime).Milliseconds > 1000)
                    {
                        //send the verify pos packet
                        ServerPackets.Send_Verify();
                    }
                    if (Globals.gamedata.my_char.MoveTarget != 0)
                    {
                        found = false;
                        //need to set the dest
                        switch (Globals.gamedata.my_char.MoveTargetType)
                        {
                        case TargetType.ERROR:
                        case TargetType.NONE:
                            //shouldn't get this ever
                            //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - char: " + Globals.gamedata.my_char.Name + ":" + Globals.gamedata.my_char.ID.ToString() + "--: " + Globals.gamedata.my_char.MoveTarget.ToString());
                            break;

                        case TargetType.SELF:
                            //shouldn't get this ever...
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_char.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_char.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_char.Z;
                            found = true;
                            break;

                        case TargetType.MYPET:
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet.Z;
                            found = true;
                            break;

                        case TargetType.MYPET1:
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet1.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet1.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet1.Z;
                            found = true;
                            break;

                        case TargetType.MYPET2:
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet2.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet2.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet2.Z;
                            found = true;
                            break;

                        case TargetType.MYPET3:
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet3.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet3.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet3.Z;
                            found = true;
                            break;

                        case TargetType.PLAYER:
                            CharInfo player_target = null;

                            Globals.PlayerLock.EnterReadLock();
                            try
                            {
                                player_target = Util.GetChar(Globals.gamedata.my_char.MoveTarget);
                            }
                            finally
                            {
                                Globals.PlayerLock.ExitReadLock();
                            }

                            if (player_target != null)
                            {
                                Globals.gamedata.my_char.Dest_X = player_target.X;
                                Globals.gamedata.my_char.Dest_Y = player_target.Y;
                                Globals.gamedata.my_char.Dest_Z = player_target.Z;
                                found = true;
                            }
                            break;

                        case TargetType.NPC:
                            NPCInfo npc_target = null;

                            Globals.NPCLock.EnterReadLock();
                            try
                            {
                                npc_target = Util.GetNPC(Globals.gamedata.my_char.MoveTarget);
                            }
                            finally
                            {
                                Globals.NPCLock.ExitReadLock();
                            }

                            if (npc_target != null)
                            {
                                Globals.gamedata.my_char.Dest_X = npc_target.X;
                                Globals.gamedata.my_char.Dest_Y = npc_target.Y;
                                Globals.gamedata.my_char.Dest_Z = npc_target.Z;
                                found = true;
                            }
                            break;

                        case TargetType.ITEM:
                            ItemInfo item_target = null;

                            Globals.ItemLock.EnterReadLock();
                            try
                            {
                                item_target = Util.GetItem(Globals.gamedata.my_char.MoveTarget);
                            }
                            finally
                            {
                                Globals.ItemLock.ExitReadLock();
                            }

                            if (item_target != null)
                            {
                                Globals.gamedata.my_char.Dest_X = item_target.X;
                                Globals.gamedata.my_char.Dest_Y = item_target.Y;
                                Globals.gamedata.my_char.Dest_Z = item_target.Z;
                                found = true;
                            }
                            break;
                        }

                        if (!found)
                        {
                            Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_char.X;
                            Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_char.Y;
                            Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_char.Z;
                        }
                    }

                    //move me towards my target
                    vx = Globals.gamedata.my_char.Dest_X - Globals.gamedata.my_char.X;
                    vy = Globals.gamedata.my_char.Dest_Y - Globals.gamedata.my_char.Y;
                    vz = Globals.gamedata.my_char.Dest_Z - Globals.gamedata.my_char.Z;

                    //movespeed = ((float)my_char.RunSpeed)*ch.MoveSpeedMult;
                    movespeed = Globals.gamedata.my_char.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult;

                    time = Convert.ToSingle((DateTime.Now - Globals.gamedata.my_char.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND;

                    vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz));
                    if (vxx != 0)
                    {
                        vxx = Util.Float_Cap(movespeed * time / vxx);
                    }

                    vx *= vxx;
                    vy *= vxx;
                    vz *= vxx;

                    Globals.gamedata.my_char.X           += vx;
                    Globals.gamedata.my_char.Y           += vy;
                    Globals.gamedata.my_char.Z           += vz;
                    Globals.gamedata.my_char.lastMoveTime = DateTime.Now;

                    if ((Globals.gamedata.my_char.MoveTarget == 0) && (Math.Sqrt(Math.Pow(Globals.gamedata.my_char.X - Globals.gamedata.my_char.Dest_X, 2) + Math.Pow(Globals.gamedata.my_char.Y - Globals.gamedata.my_char.Dest_Y, 2) + Math.Pow(Globals.gamedata.my_char.Z - Globals.gamedata.my_char.Dest_Z, 2)) < Globals.THRESHOLD))
                    {
                        Globals.gamedata.my_char.Moving = false;
                    }
                }
            }
            catch
            {
                Globals.l2net_home.Add_Error("crash: Animate self");
            }

            ///////////////////////Animate Pet
            if (Globals.gamedata.my_pet.ID != 0)
            {
                try
                {
                    if (Globals.gamedata.my_pet.Moving == true)
                    {
                        if (Globals.gamedata.my_pet.MoveTarget != 0)
                        {
                            found = false;
                            //need to set the dest
                            switch (Globals.gamedata.my_pet.MoveTargetType)
                            {
                            case TargetType.ERROR:
                            case TargetType.NONE:
                                //shouldn't get this ever
                                //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - pet: " + Globals.gamedata.my_pet.Name + ":" + Globals.gamedata.my_pet.ID.ToString() + "--: " + Globals.gamedata.my_pet.MoveTarget.ToString());
                                break;

                            case TargetType.SELF:
                                Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_char.X;
                                Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_char.Y;
                                Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_char.Z;
                                found = true;
                                break;

                            case TargetType.MYPET:
                                //shouldn't get this ever...
                                Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_pet.X;
                                Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_pet.Y;
                                Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_pet.Z;
                                found = true;
                                break;

                            case TargetType.MYPET1:
                                //shouldn't get this ever...
                                Globals.gamedata.my_pet1.Dest_X = Globals.gamedata.my_pet1.X;
                                Globals.gamedata.my_pet1.Dest_Y = Globals.gamedata.my_pet1.Y;
                                Globals.gamedata.my_pet1.Dest_Z = Globals.gamedata.my_pet1.Z;
                                found = true;
                                break;

                            case TargetType.MYPET2:
                                //shouldn't get this ever...
                                Globals.gamedata.my_pet2.Dest_X = Globals.gamedata.my_pet2.X;
                                Globals.gamedata.my_pet2.Dest_Y = Globals.gamedata.my_pet2.Y;
                                Globals.gamedata.my_pet2.Dest_Z = Globals.gamedata.my_pet2.Z;
                                found = true;
                                break;

                            case TargetType.MYPET3:
                                //shouldn't get this ever...
                                Globals.gamedata.my_pet3.Dest_X = Globals.gamedata.my_pet3.X;
                                Globals.gamedata.my_pet3.Dest_Y = Globals.gamedata.my_pet3.Y;
                                Globals.gamedata.my_pet3.Dest_Z = Globals.gamedata.my_pet3.Z;
                                found = true;
                                break;

                            case TargetType.PLAYER:
                                CharInfo player_target = null;

                                Globals.PlayerLock.EnterReadLock();
                                try
                                {
                                    player_target = Util.GetChar(Globals.gamedata.my_pet.MoveTarget);
                                }
                                finally
                                {
                                    Globals.PlayerLock.ExitReadLock();
                                }

                                if (player_target != null)
                                {
                                    Globals.gamedata.my_pet.Dest_X = player_target.X;
                                    Globals.gamedata.my_pet.Dest_Y = player_target.Y;
                                    Globals.gamedata.my_pet.Dest_Z = player_target.Z;
                                    found = true;
                                }
                                break;

                            case TargetType.NPC:
                                NPCInfo npc_target = null;

                                Globals.NPCLock.EnterReadLock();
                                try
                                {
                                    npc_target = Util.GetNPC(Globals.gamedata.my_pet.MoveTarget);
                                }
                                finally
                                {
                                    Globals.NPCLock.ExitReadLock();
                                }

                                if (npc_target != null)
                                {
                                    Globals.gamedata.my_pet.Dest_X = npc_target.X;
                                    Globals.gamedata.my_pet.Dest_Y = npc_target.Y;
                                    Globals.gamedata.my_pet.Dest_Z = npc_target.Z;
                                    found = true;
                                }
                                break;

                            case TargetType.ITEM:
                                ItemInfo item_target = null;

                                Globals.ItemLock.EnterReadLock();
                                try
                                {
                                    item_target = Util.GetItem(Globals.gamedata.my_pet.MoveTarget);
                                }
                                finally
                                {
                                    Globals.ItemLock.ExitReadLock();
                                }

                                if (item_target != null)
                                {
                                    Globals.gamedata.my_pet.Dest_X = item_target.X;
                                    Globals.gamedata.my_pet.Dest_Y = item_target.Y;
                                    Globals.gamedata.my_pet.Dest_Z = item_target.Z;
                                    found = true;
                                }
                                break;
                            }

                            if (!found)
                            {
                                Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_pet.X;
                                Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_pet.Y;
                                Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_pet.Z;
                            }
                        }

                        //move me towards my target
                        vx = Globals.gamedata.my_pet.Dest_X - Globals.gamedata.my_pet.X;
                        vy = Globals.gamedata.my_pet.Dest_Y - Globals.gamedata.my_pet.Y;
                        vz = Globals.gamedata.my_pet.Dest_Z - Globals.gamedata.my_pet.Z;

                        //movespeed = ((float)my_char.RunSpeed)*ch.MoveSpeedMult;
                        movespeed = Globals.gamedata.my_pet.RunSpeed * Globals.gamedata.my_pet.MoveSpeedMult;

                        time = Convert.ToSingle((DateTime.Now - Globals.gamedata.my_pet.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND;

                        vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz));
                        if (vxx != 0)
                        {
                            vxx = Util.Float_Cap(movespeed * time / vxx);
                        }

                        vx *= vxx;
                        vy *= vxx;
                        vz *= vxx;

                        Globals.gamedata.my_pet.X           += vx;
                        Globals.gamedata.my_pet.Y           += vy;
                        Globals.gamedata.my_pet.Z           += vz;
                        Globals.gamedata.my_pet.lastMoveTime = DateTime.Now;

                        if ((Globals.gamedata.my_pet.MoveTarget == 0) && (Math.Sqrt(Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_pet.Dest_X, 2) + Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_pet.Dest_Y, 2) + Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_pet.Dest_Z, 2)) < Globals.THRESHOLD))
                        {
                            Globals.gamedata.my_pet.Moving = false;
                        }
                    }
                }
                catch
                {
                    Globals.l2net_home.Add_Error("crash: Animate pet");
                }
            }

            ///////////////////////Animate other chars
            Globals.PlayerLock.EnterReadLock();
            try
            {
                foreach (CharInfo player in Globals.gamedata.nearby_chars.Values)
                {
                    if (player.Moving)
                    {
                        if (player.MoveTarget != 0)
                        {
                            found = false;
                            //need to set the dest
                            switch (player.MoveTargetType)
                            {
                            case TargetType.ERROR:
                            case TargetType.NONE:
                                //shouldn't get this ever...
                                //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - pc: " + player.Name + ":" + player.ID.ToString() + "--: " + player.MoveTarget.ToString());
                                break;

                            case TargetType.SELF:
                                player.Dest_X = Globals.gamedata.my_char.X;
                                player.Dest_Y = Globals.gamedata.my_char.Y;
                                player.Dest_Z = Globals.gamedata.my_char.Z;
                                found         = true;
                                break;

                            case TargetType.MYPET:
                                player.Dest_X = Globals.gamedata.my_pet.X;
                                player.Dest_Y = Globals.gamedata.my_pet.Y;
                                player.Dest_Z = Globals.gamedata.my_pet.Z;
                                found         = true;
                                break;

                            case TargetType.MYPET1:
                                player.Dest_X = Globals.gamedata.my_pet1.X;
                                player.Dest_Y = Globals.gamedata.my_pet1.Y;
                                player.Dest_Z = Globals.gamedata.my_pet1.Z;
                                found         = true;
                                break;

                            case TargetType.MYPET2:
                                player.Dest_X = Globals.gamedata.my_pet2.X;
                                player.Dest_Y = Globals.gamedata.my_pet2.Y;
                                player.Dest_Z = Globals.gamedata.my_pet2.Z;
                                found         = true;
                                break;

                            case TargetType.MYPET3:
                                player.Dest_X = Globals.gamedata.my_pet3.X;
                                player.Dest_Y = Globals.gamedata.my_pet3.Y;
                                player.Dest_Z = Globals.gamedata.my_pet3.Z;
                                found         = true;
                                break;

                            case TargetType.PLAYER:
                                CharInfo player_target = null;

                                //no need to lock... we already have a writer lock
                                player_target = Util.GetChar(Globals.gamedata.my_char.MoveTarget);

                                if (player_target != null)
                                {
                                    player.Dest_X = player_target.X;
                                    player.Dest_Y = player_target.Y;
                                    player.Dest_Z = player_target.Z;
                                    found         = true;
                                }
                                break;

                            case TargetType.NPC:
                                NPCInfo npc_target = null;

                                Globals.NPCLock.EnterReadLock();
                                try
                                {
                                    npc_target = Util.GetNPC(player.MoveTarget);
                                }
                                finally
                                {
                                    Globals.NPCLock.ExitReadLock();
                                }

                                if (npc_target != null)
                                {
                                    player.Dest_X = npc_target.X;
                                    player.Dest_Y = npc_target.Y;
                                    player.Dest_Z = npc_target.Z;
                                    found         = true;
                                }
                                break;

                            case TargetType.ITEM:
                                ItemInfo item_target = null;

                                Globals.ItemLock.EnterReadLock();
                                try
                                {
                                    item_target = Util.GetItem(player.MoveTarget);
                                }    //unlock
                                finally
                                {
                                    Globals.ItemLock.ExitReadLock();
                                }

                                if (item_target != null)
                                {
                                    player.Dest_X = item_target.X;
                                    player.Dest_Y = item_target.Y;
                                    player.Dest_Z = item_target.Z;
                                    found         = true;
                                }
                                break;
                            }

                            if (!found)
                            {
                                player.Dest_X = player.X;
                                player.Dest_Y = player.Y;
                                player.Dest_Z = player.Z;
                            }
                        }

                        vx = player.Dest_X - player.X;
                        vy = player.Dest_Y - player.Y;
                        vz = player.Dest_Z - player.Z;

                        if (player.isRunning != 0)
                        {
                            movespeed = player.RunSpeed * player.MoveSpeedMult;
                        }
                        else
                        {
                            movespeed = player.WalkSpeed * player.MoveSpeedMult;
                        }

                        time = Convert.ToSingle((DateTime.Now - player.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND;

                        vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz));
                        if (vxx != 0)
                        {
                            vxx = Util.Float_Cap(movespeed * time / vxx);
                        }

                        vx *= vxx;
                        vy *= vxx;
                        vz *= vxx;

                        player.X           += Util.Float_Int32(vx);
                        player.Y           += Util.Float_Int32(vy);
                        player.Z           += Util.Float_Int32(vz);
                        player.lastMoveTime = DateTime.Now;

                        if ((player.MoveTarget == 0) && (Math.Sqrt(Math.Pow(player.X - player.Dest_X, 2) + Math.Pow(player.Y - player.Dest_Y, 2) + Math.Pow(player.Z - player.Dest_Z, 2)) < Globals.THRESHOLD))
                        {
                            player.Moving = false;
                        }
                    }
                }
            }//unlock
            catch
            {
                Globals.l2net_home.Add_Error("crash: Animate other players");
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            //animate npcs
            Globals.NPCLock.EnterReadLock();
            try
            {
                foreach (NPCInfo npc in Globals.gamedata.nearby_npcs.Values)
                {
                    if (npc.Moving)
                    {
                        if (npc.MoveTarget != 0)
                        {
                            found = false;
                            //need to set the dest
                            switch (npc.MoveTargetType)
                            {
                            case TargetType.ERROR:
                            case TargetType.NONE:
                                //shouldn't get this ever...
                                //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - npc: " + npc.Name + ":" + npc.ID.ToString() + "--: " + npc.MoveTarget.ToString());
                                break;

                            case TargetType.SELF:
                                npc.Dest_X = Globals.gamedata.my_char.X;
                                npc.Dest_Y = Globals.gamedata.my_char.Y;
                                npc.Dest_Z = Globals.gamedata.my_char.Z;
                                found      = true;
                                break;

                            case TargetType.MYPET:
                                npc.Dest_X = Globals.gamedata.my_pet.X;
                                npc.Dest_Y = Globals.gamedata.my_pet.Y;
                                npc.Dest_Z = Globals.gamedata.my_pet.Z;
                                found      = true;
                                break;

                            case TargetType.MYPET1:
                                npc.Dest_X = Globals.gamedata.my_pet1.X;
                                npc.Dest_Y = Globals.gamedata.my_pet1.Y;
                                npc.Dest_Z = Globals.gamedata.my_pet1.Z;
                                found      = true;
                                break;

                            case TargetType.MYPET2:
                                npc.Dest_X = Globals.gamedata.my_pet2.X;
                                npc.Dest_Y = Globals.gamedata.my_pet2.Y;
                                npc.Dest_Z = Globals.gamedata.my_pet2.Z;
                                found      = true;
                                break;

                            case TargetType.MYPET3:
                                npc.Dest_X = Globals.gamedata.my_pet3.X;
                                npc.Dest_Y = Globals.gamedata.my_pet3.Y;
                                npc.Dest_Z = Globals.gamedata.my_pet3.Z;
                                found      = true;
                                break;

                            case TargetType.PLAYER:
                                CharInfo player_target = null;

                                Globals.PlayerLock.EnterReadLock();
                                try
                                {
                                    player_target = Util.GetChar(npc.MoveTarget);
                                }
                                finally
                                {
                                    Globals.PlayerLock.ExitReadLock();
                                }

                                if (player_target != null)
                                {
                                    npc.Dest_X = player_target.X;
                                    npc.Dest_Y = player_target.Y;
                                    npc.Dest_Z = player_target.Z;
                                    found      = true;
                                }
                                break;

                            case TargetType.NPC:
                                NPCInfo npc_target = null;

                                //no need to lock... we already have a writer lock
                                npc_target = Util.GetNPC(npc.MoveTarget);

                                if (npc_target != null)
                                {
                                    npc.Dest_X = npc_target.X;
                                    npc.Dest_Y = npc_target.Y;
                                    npc.Dest_Z = npc_target.Z;
                                    found      = true;
                                }
                                break;

                            case TargetType.ITEM:
                                ItemInfo item_target = null;

                                Globals.ItemLock.EnterReadLock();
                                try
                                {
                                    item_target = Util.GetItem(npc.MoveTarget);
                                }
                                finally
                                {
                                    Globals.ItemLock.ExitReadLock();
                                }

                                if (item_target != null)
                                {
                                    npc.Dest_X = item_target.X;
                                    npc.Dest_Y = item_target.Y;
                                    npc.Dest_Z = item_target.Z;
                                    found      = true;
                                }
                                break;
                            }//end of switch

                            if (!found)
                            {
                                npc.Dest_X = npc.X;
                                npc.Dest_Y = npc.Y;
                                npc.Dest_Z = npc.Z;
                            }
                        }

                        vx = npc.Dest_X - npc.X;
                        vy = npc.Dest_Y - npc.Y;
                        vz = npc.Dest_Z - npc.Z;

                        if (npc.isRunning != 0)
                        {
                            movespeed = npc.RunSpeed * npc.MoveSpeedMult;
                        }
                        else
                        {
                            movespeed = npc.WalkSpeed * npc.MoveSpeedMult;
                        }

                        time = Convert.ToSingle((DateTime.Now - npc.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND;

                        vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz));
                        if (vxx != 0)
                        {
                            vxx = Util.Float_Cap(movespeed * time / vxx);
                        }

                        vx *= vxx;
                        vy *= vxx;
                        vz *= vxx;

                        npc.X           += Util.Float_Int32(vx);
                        npc.Y           += Util.Float_Int32(vy);
                        npc.Z           += Util.Float_Int32(vz);
                        npc.lastMoveTime = DateTime.Now;

                        if ((npc.MoveTarget == 0) && (Math.Sqrt(Math.Pow(npc.X - npc.Dest_X, 2) + Math.Pow(npc.Y - npc.Dest_Y, 2) + Math.Pow(npc.Z - npc.Dest_Z, 2)) < Globals.THRESHOLD))
                        {
                            npc.Moving = false;
                        }
                    }
                }
            }//unlock
            catch
            {
                Globals.l2net_home.Add_Error("crash: Animate npcs");
            }
            finally
            {
                Globals.NPCLock.ExitReadLock();
            }
        }//end of AnimateStuff
Exemple #7
0
		public static void Set_Target_HP()
		{
			string cp = "0/0";
			string hp = "0/0";
			string mp = "0/0";

            uint target_id = Globals.gamedata.my_char.TargetID;

            switch (Globals.gamedata.my_char.CurrentTargetType)
			{

				case TargetType.SELF:
                    hp = Globals.gamedata.my_char.Cur_HP.ToString() + "/" + Globals.gamedata.my_char.Max_HP.ToString();
                    mp = Globals.gamedata.my_char.Cur_MP.ToString() + "/" + Globals.gamedata.my_char.Max_MP.ToString();
                    cp = Globals.gamedata.my_char.Cur_CP.ToString() + "/" + Globals.gamedata.my_char.Max_CP.ToString();
                    break;
                case TargetType.MYPET:
                    hp = Globals.gamedata.my_pet.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet.Max_HP.ToString();
                    mp = Globals.gamedata.my_pet.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet.Max_MP.ToString();
                    cp = Globals.gamedata.my_pet.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet.Max_CP.ToString();
                    break;
                case TargetType.MYPET1:
                    hp = Globals.gamedata.my_pet1.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet1.Max_HP.ToString();
                    mp = Globals.gamedata.my_pet1.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet1.Max_MP.ToString();
                    cp = Globals.gamedata.my_pet1.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet1.Max_CP.ToString();
                    break;
                case TargetType.MYPET2:
                    hp = Globals.gamedata.my_pet2.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet2.Max_HP.ToString();
                    mp = Globals.gamedata.my_pet2.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet2.Max_MP.ToString();
                    cp = Globals.gamedata.my_pet2.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet2.Max_CP.ToString();
                    break;
                case TargetType.MYPET3:
                    hp = Globals.gamedata.my_pet3.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet3.Max_HP.ToString();
                    mp = Globals.gamedata.my_pet3.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet3.Max_MP.ToString();
                    cp = Globals.gamedata.my_pet3.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet3.Max_CP.ToString();
                    break;
				case TargetType.PLAYER:
                    Globals.PlayerLock.EnterReadLock();
					try
					{
                        CharInfo player = Util.GetChar(target_id);

                        if (player != null)
                        {
                            /*if (Globals.gamedata.Chron >= Chronicle.CT2_4 && Globals.gamedata.Official_Server)
                            {
                                /*
                                hp = ("HP: " + player.Cur_HP / 100000).ToString() + "%";
                                mp = ("MP: " + player.Cur_MP / 100000).ToString() + "%";
                                cp = ("CP: " + player.Cur_CP / 100000).ToString() + "%";
                                hp = ("HP: " + (player.Cur_HP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture));
                                mp = ("CP: " + (player.Cur_MP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture));
                                cp = ("MP: " + (player.Cur_CP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture)); 

                            }
                            else
                            {*/
                                hp = player.Cur_HP.ToString() + "/" + player.Max_HP.ToString();
                                mp = player.Cur_MP.ToString() + "/" + player.Max_MP.ToString();
                                cp = player.Cur_CP.ToString() + "/" + player.Max_CP.ToString();
                            //}
                        }
					}//unlock
					finally
					{
                        Globals.PlayerLock.ExitReadLock();
					}
					break;
				case TargetType.NPC:
                    Globals.NPCLock.EnterReadLock();
					try
					{
                        NPCInfo npc = Util.GetNPC(target_id);

                        if (npc != null)
                        {
                            hp = npc.Cur_HP.ToString() + "/" + npc.Max_HP.ToString();
                            mp = npc.Cur_MP.ToString() + "/" + npc.Max_MP.ToString();
                            cp = npc.Cur_CP.ToString() + "/" + npc.Max_CP.ToString();
                        }
					}//unlock
					finally
					{
                        Globals.NPCLock.ExitReadLock();
					}
					break;
			}

			Globals.l2net_home.Set_Target_CP(cp);
			Globals.l2net_home.Set_Target_HP(hp);
			Globals.l2net_home.Set_Target_MP(mp);
			//Globals.l2net_home.panel_target.Refresh();

            if (Globals.l2net_home.menuItem_cmd_overlay.Checked && Globals.overlaywindow != null)
			{
                Globals.overlaywindow.Set_Target_CP(cp);
                Globals.overlaywindow.Set_Target_HP(hp);
                Globals.overlaywindow.Set_Target_MP(mp);
				//L2NET.overlaywindow.Refresh();
			}
		}
Exemple #8
0
        static public int Distance(uint id)
        {
            //this function will lock based on what we are checking distance to
            TargetType type = GetType(id);

            switch (type)
            {
            case TargetType.ERROR:
            case TargetType.NONE:
                return(System.Int32.MaxValue);

            case TargetType.SELF:
                return(0);

            case TargetType.MYPET:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET1:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet1.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet1.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet1.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET2:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet2.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet2.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet2.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET3:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet3.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet3.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet3.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.PLAYER:
                Globals.PlayerLock.EnterReadLock();
                try
                {
                    CharInfo player = GetChar(id);

                    if (player != null)
                    {
                        return((int)System.Math.Sqrt(
                                   System.Math.Pow(player.X - Globals.gamedata.my_char.X, 2) +
                                   System.Math.Pow(player.Y - Globals.gamedata.my_char.Y, 2) +
                                   System.Math.Pow(player.Z - Globals.gamedata.my_char.Z, 2)));
                    }
                }    //unlock
                finally
                {
                    Globals.PlayerLock.ExitReadLock();
                }
                break;

            case TargetType.NPC:
                Globals.NPCLock.EnterReadLock();
                try
                {
                    NPCInfo npc = GetNPC(id);

                    if (npc != null)
                    {
                        return((int)System.Math.Sqrt(
                                   System.Math.Pow(npc.X - Globals.gamedata.my_char.X, 2) +
                                   System.Math.Pow(npc.Y - Globals.gamedata.my_char.Y, 2) +
                                   System.Math.Pow(npc.Z - Globals.gamedata.my_char.Z, 2)));
                    }
                }    //unlock
                finally
                {
                    Globals.NPCLock.ExitReadLock();
                }
                break;

            case TargetType.ITEM:
                Globals.ItemLock.EnterReadLock();
                try
                {
                    ItemInfo item = GetItem(id);

                    if (item != null)
                    {
                        return((int)System.Math.Sqrt(
                                   System.Math.Pow(item.X - Globals.gamedata.my_char.X, 2) +
                                   System.Math.Pow(item.Y - Globals.gamedata.my_char.Y, 2) +
                                   System.Math.Pow(item.Z - Globals.gamedata.my_char.Z, 2)));
                    }
                }    //unlock
                finally
                {
                    Globals.ItemLock.ExitReadLock();
                }
                break;
            }

            return(System.Int32.MaxValue);
        }
        private bool MeetsConditions(NPCInfo npc)
        {

            if (BotOptions.Target_Pathfinding == 1)
            {
                if (!Globals.gamedata.pathManager.runASTAR(npc.X, npc.Y))
                {
#if DEBUG
                    Globals.l2net_home.Add_Debug("Couldn't target mob because we could not find a path to it =)");
#endif
                    return false;
                }
            }
            if (
                ((BotOptions.Target_ATTACKABLE == 2) || (BotOptions.Target_ATTACKABLE == 0 && npc.isAttackable != 0) || (BotOptions.Target_ATTACKABLE == 1 && npc.isAttackable == 0)) &&
                ((BotOptions.Target_ALIVE == 2) || (BotOptions.Target_ALIVE == 0 && npc.isAlikeDead == 0) || (BotOptions.Target_ALIVE == 1 && npc.isAlikeDead != 0)) &&
                ((BotOptions.Target_INBOX == 2) || (BotOptions.Target_INBOX == 0 && Globals.gamedata.Paths.IsPointInside(Util.Float_Int32(npc.X), Util.Float_Int32(npc.Y))) || (BotOptions.Target_INBOX == 1 && !Globals.gamedata.Paths.IsPointInside(Util.Float_Int32(npc.X), Util.Float_Int32(npc.Y)))) &&
                ((BotOptions.Target_COMBAT == 2) || (BotOptions.Target_COMBAT == 0 && npc.CheckCombat() == false) || (BotOptions.Target_COMBAT == 1 && npc.CheckCombat() == true)) &&
                (Math.Abs(Globals.gamedata.my_char.Z - npc.Z) <= BotOptions.Target_ZRANGE)
                )
            {
                return true;
            }

            return false;
        }
Exemple #10
0
        static public int Distance(uint id, TargetType type)
        {
            //no locks needed... since the calling function has the locks in it
            switch (type)
            {
            case TargetType.ERROR:
            case TargetType.NONE:
                return(System.Int32.MaxValue);

            case TargetType.SELF:
                return(0);

            case TargetType.MYPET:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET1:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet1.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet1.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet1.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET2:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet2.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet2.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet2.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.MYPET3:
                return((int)System.Math.Sqrt(
                           System.Math.Pow(Globals.gamedata.my_pet3.X - Globals.gamedata.my_char.X, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet3.Y - Globals.gamedata.my_char.Y, 2) +
                           System.Math.Pow(Globals.gamedata.my_pet3.Z - Globals.gamedata.my_char.Z, 2)));

            case TargetType.PLAYER:
                CharInfo player = GetChar(id);

                if (player != null)
                {
                    return((int)System.Math.Sqrt(
                               System.Math.Pow(player.X - Globals.gamedata.my_char.X, 2) +
                               System.Math.Pow(player.Y - Globals.gamedata.my_char.Y, 2) +
                               System.Math.Pow(player.Z - Globals.gamedata.my_char.Z, 2)));
                }
                break;

            case TargetType.NPC:
                NPCInfo npc = GetNPC(id);

                if (npc != null)
                {
                    return((int)System.Math.Sqrt(
                               System.Math.Pow(npc.X - Globals.gamedata.my_char.X, 2) +
                               System.Math.Pow(npc.Y - Globals.gamedata.my_char.Y, 2) +
                               System.Math.Pow(npc.Z - Globals.gamedata.my_char.Z, 2)));
                }
                break;

            case TargetType.ITEM:
                ItemInfo item = GetItem(id);

                if (item != null)
                {
                    return((int)System.Math.Sqrt(
                               System.Math.Pow(item.X - Globals.gamedata.my_char.X, 2) +
                               System.Math.Pow(item.Y - Globals.gamedata.my_char.Y, 2) +
                               System.Math.Pow(item.Z - Globals.gamedata.my_char.Z, 2)));
                }
                break;
            }

            return(System.Int32.MaxValue);
        }
Exemple #11
0
        public static long TARGET_INT(string req)
        {
            switch (Globals.gamedata.my_char.CurrentTargetType)
            {
            case TargetType.ERROR:
            case TargetType.NONE:
                break;

            case TargetType.SELF:
                switch (req)
                {
                case "KARMA":
                    return((long)Globals.gamedata.my_char.Karma);

                case "TARGETID":
                    return((long)Globals.gamedata.my_char.TargetID);

                case "ID":
                    return((long)Globals.gamedata.my_char.ID);

                case "TYPEID":
                    return((long)0);

                case "X":
                    return((long)Globals.gamedata.my_char.X);

                case "Y":
                    return((long)Globals.gamedata.my_char.Y);

                case "Z":
                    return((long)Globals.gamedata.my_char.Z);

                case "DESTX":
                    return((long)Globals.gamedata.my_char.Dest_X);

                case "DESTY":
                    return((long)Globals.gamedata.my_char.Dest_Y);

                case "DESTZ":
                    return((long)Globals.gamedata.my_char.Dest_Z);

                case "IS_MOVING":
                    return(Globals.gamedata.my_char.Moving ? 1L : 0L);

                case "MAX_HP":
                    return((long)Globals.gamedata.my_char.Max_HP);

                case "MAX_MP":
                    return((long)Globals.gamedata.my_char.Max_MP);

                case "MAX_CP":
                    return((long)Globals.gamedata.my_char.Max_CP);

                case "CUR_HP":
                    return((long)Globals.gamedata.my_char.Cur_HP);

                case "CUR_MP":
                    return((long)Globals.gamedata.my_char.Cur_MP);

                case "CUR_CP":
                    return((long)Globals.gamedata.my_char.Cur_CP);

                case "PER_HP":
                    return((long)(100.0 * (Globals.gamedata.my_char.Cur_HP / Globals.gamedata.my_char.Max_HP)));

                case "PER_MP":
                    return((long)(100.0 * (Globals.gamedata.my_char.Cur_MP / Globals.gamedata.my_char.Max_MP)));

                case "PER_CP":
                    return((long)(100.0 * (Globals.gamedata.my_char.Cur_CP / Globals.gamedata.my_char.Max_CP)));

                case "RUN_SPEED":
                    return((long)(Globals.gamedata.my_char.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                case "WALK_SPEED":
                    return((long)(Globals.gamedata.my_char.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                case "ATTACK_SPEED":
                    return((long)Globals.gamedata.my_char.AttackSpeedMult);

                case "CAST_SPEED":
                    return((long)Globals.gamedata.my_char.MatkSpeed);

                case "EVAL":
                    return((long)Globals.gamedata.my_char.RecAmount);

                case "RUNNING":
                    return((long)Globals.gamedata.my_char.isRunning);

                case "SITTING":
                    return((long)Globals.gamedata.my_char.isSitting);

                case "LOOKS_DEAD":
                    return((long)Globals.gamedata.my_char.isAlikeDead);

                default:
                    ScriptEngine.Script_Error("invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.MYPET:
                switch (req)
                {
                case "KARMA":
                    return((long)Globals.gamedata.my_pet.Karma);

                case "TARGETID":
                    return((long)Globals.gamedata.my_pet.TargetID);

                case "ID":
                    return((long)Globals.gamedata.my_pet.ID);

                case "TYPEID":
                    return((long)Globals.gamedata.my_pet.NPCID);

                case "X":
                    return((long)Globals.gamedata.my_pet.X);

                case "Y":
                    return((long)Globals.gamedata.my_pet.Y);

                case "Z":
                    return((long)Globals.gamedata.my_pet.Z);

                case "DESTX":
                    return((long)Globals.gamedata.my_pet.Dest_X);

                case "DESTY":
                    return((long)Globals.gamedata.my_pet.Dest_Y);

                case "DESTZ":
                    return((long)Globals.gamedata.my_pet.Dest_Z);

                case "IS_MOVING":
                    return(Globals.gamedata.my_pet.Moving ? 1L : 0L);

                case "MAX_HP":
                    return((long)Globals.gamedata.my_pet.Max_HP);

                case "MAX_MP":
                    return((long)Globals.gamedata.my_pet.Max_MP);

                case "MAX_CP":
                    return((long)Globals.gamedata.my_pet.Max_CP);

                case "CUR_HP":
                    return((long)Globals.gamedata.my_pet.Cur_HP);

                case "CUR_MP":
                    return((long)Globals.gamedata.my_pet.Cur_MP);

                case "CUR_CP":
                    return((long)Globals.gamedata.my_pet.Cur_CP);

                case "PER_HP":
                    return((long)(100.0 * (Globals.gamedata.my_pet.Cur_HP / Globals.gamedata.my_pet.Max_HP)));

                case "PER_MP":
                    return((long)(100.0 * (Globals.gamedata.my_pet.Cur_MP / Globals.gamedata.my_pet.Max_MP)));

                case "PER_CP":
                    return((long)(100.0 * (Globals.gamedata.my_pet.Cur_CP / Globals.gamedata.my_pet.Max_CP)));

                case "RUN_SPEED":
                    return((long)(Globals.gamedata.my_pet.RunSpeed * Globals.gamedata.my_pet.MoveSpeedMult));

                case "WALK_SPEED":
                    return((long)(Globals.gamedata.my_pet.WalkSpeed * Globals.gamedata.my_pet.MoveSpeedMult));

                case "ATTACK_SPEED":
                    return((long)Globals.gamedata.my_pet.AttackSpeedMult);

                case "CAST_SPEED":
                    return((long)Globals.gamedata.my_pet.MatkSpeed);

                case "EVAL":
                    return((long)0);

                case "RUNNING":
                    return((long)Globals.gamedata.my_pet.isRunning);

                case "SITTING":
                    return((long)0);

                case "LOOKS_DEAD":
                    return((long)Globals.gamedata.my_pet.isAlikeDead);

                default:
                    ScriptEngine.Script_Error("invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.MYPET1:
                switch (req)
                {
                case "KARMA":
                    return((long)Globals.gamedata.my_pet1.Karma);

                case "TARGETID":
                    return((long)Globals.gamedata.my_pet1.TargetID);

                case "ID":
                    return((long)Globals.gamedata.my_pet1.ID);

                case "TYPEID":
                    return((long)Globals.gamedata.my_pet1.NPCID);

                case "X":
                    return((long)Globals.gamedata.my_pet1.X);

                case "Y":
                    return((long)Globals.gamedata.my_pet1.Y);

                case "Z":
                    return((long)Globals.gamedata.my_pet1.Z);

                case "DESTX":
                    return((long)Globals.gamedata.my_pet1.Dest_X);

                case "DESTY":
                    return((long)Globals.gamedata.my_pet1.Dest_Y);

                case "DESTZ":
                    return((long)Globals.gamedata.my_pet1.Dest_Z);

                case "IS_MOVING":
                    return(Globals.gamedata.my_pet1.Moving ? 1L : 0L);

                case "MAX_HP":
                    return((long)Globals.gamedata.my_pet1.Max_HP);

                case "MAX_MP":
                    return((long)Globals.gamedata.my_pet1.Max_MP);

                case "MAX_CP":
                    return((long)Globals.gamedata.my_pet1.Max_CP);

                case "CUR_HP":
                    return((long)Globals.gamedata.my_pet1.Cur_HP);

                case "CUR_MP":
                    return((long)Globals.gamedata.my_pet1.Cur_MP);

                case "CUR_CP":
                    return((long)Globals.gamedata.my_pet1.Cur_CP);

                case "PER_HP":
                    return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_HP / Globals.gamedata.my_pet1.Max_HP)));

                case "PER_MP":
                    return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_MP / Globals.gamedata.my_pet1.Max_MP)));

                case "PER_CP":
                    return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_CP / Globals.gamedata.my_pet1.Max_CP)));

                case "RUN_SPEED":
                    return((long)(Globals.gamedata.my_pet1.RunSpeed * Globals.gamedata.my_pet1.MoveSpeedMult));

                case "WALK_SPEED":
                    return((long)(Globals.gamedata.my_pet1.WalkSpeed * Globals.gamedata.my_pet1.MoveSpeedMult));

                case "ATTACK_SPEED":
                    return((long)Globals.gamedata.my_pet1.AttackSpeedMult);

                case "CAST_SPEED":
                    return((long)Globals.gamedata.my_pet1.MatkSpeed);

                case "EVAL":
                    return((long)0);

                case "RUNNING":
                    return((long)Globals.gamedata.my_pet1.isRunning);

                case "SITTING":
                    return((long)0);

                case "LOOKS_DEAD":
                    return((long)Globals.gamedata.my_pet1.isAlikeDead);

                default:
                    ScriptEngine.Script_Error("invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.MYPET2:
                switch (req)
                {
                case "KARMA":
                    return((long)Globals.gamedata.my_pet2.Karma);

                case "TARGETID":
                    return((long)Globals.gamedata.my_pet2.TargetID);

                case "ID":
                    return((long)Globals.gamedata.my_pet2.ID);

                case "TYPEID":
                    return((long)Globals.gamedata.my_pet2.NPCID);

                case "X":
                    return((long)Globals.gamedata.my_pet2.X);

                case "Y":
                    return((long)Globals.gamedata.my_pet2.Y);

                case "Z":
                    return((long)Globals.gamedata.my_pet2.Z);

                case "DESTX":
                    return((long)Globals.gamedata.my_pet2.Dest_X);

                case "DESTY":
                    return((long)Globals.gamedata.my_pet2.Dest_Y);

                case "DESTZ":
                    return((long)Globals.gamedata.my_pet2.Dest_Z);

                case "IS_MOVING":
                    return(Globals.gamedata.my_pet2.Moving ? 1L : 0L);

                case "MAX_HP":
                    return((long)Globals.gamedata.my_pet2.Max_HP);

                case "MAX_MP":
                    return((long)Globals.gamedata.my_pet2.Max_MP);

                case "MAX_CP":
                    return((long)Globals.gamedata.my_pet2.Max_CP);

                case "CUR_HP":
                    return((long)Globals.gamedata.my_pet2.Cur_HP);

                case "CUR_MP":
                    return((long)Globals.gamedata.my_pet2.Cur_MP);

                case "CUR_CP":
                    return((long)Globals.gamedata.my_pet2.Cur_CP);

                case "PER_HP":
                    return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_HP / Globals.gamedata.my_pet2.Max_HP)));

                case "PER_MP":
                    return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_MP / Globals.gamedata.my_pet2.Max_MP)));

                case "PER_CP":
                    return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_CP / Globals.gamedata.my_pet2.Max_CP)));

                case "RUN_SPEED":
                    return((long)(Globals.gamedata.my_pet2.RunSpeed * Globals.gamedata.my_pet2.MoveSpeedMult));

                case "WALK_SPEED":
                    return((long)(Globals.gamedata.my_pet2.WalkSpeed * Globals.gamedata.my_pet2.MoveSpeedMult));

                case "ATTACK_SPEED":
                    return((long)Globals.gamedata.my_pet2.AttackSpeedMult);

                case "CAST_SPEED":
                    return((long)Globals.gamedata.my_pet2.MatkSpeed);

                case "EVAL":
                    return((long)0);

                case "RUNNING":
                    return((long)Globals.gamedata.my_pet2.isRunning);

                case "SITTING":
                    return((long)0);

                case "LOOKS_DEAD":
                    return((long)Globals.gamedata.my_pet2.isAlikeDead);

                default:
                    ScriptEngine.Script_Error("invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.MYPET3:
                switch (req)
                {
                case "KARMA":
                    return((long)Globals.gamedata.my_pet3.Karma);

                case "TARGETID":
                    return((long)Globals.gamedata.my_pet3.TargetID);

                case "ID":
                    return((long)Globals.gamedata.my_pet3.ID);

                case "TYPEID":
                    return((long)Globals.gamedata.my_pet3.NPCID);

                case "X":
                    return((long)Globals.gamedata.my_pet3.X);

                case "Y":
                    return((long)Globals.gamedata.my_pet3.Y);

                case "Z":
                    return((long)Globals.gamedata.my_pet3.Z);

                case "DESTX":
                    return((long)Globals.gamedata.my_pet3.Dest_X);

                case "DESTY":
                    return((long)Globals.gamedata.my_pet3.Dest_Y);

                case "DESTZ":
                    return((long)Globals.gamedata.my_pet3.Dest_Z);

                case "IS_MOVING":
                    return(Globals.gamedata.my_pet3.Moving ? 1L : 0L);

                case "MAX_HP":
                    return((long)Globals.gamedata.my_pet3.Max_HP);

                case "MAX_MP":
                    return((long)Globals.gamedata.my_pet3.Max_MP);

                case "MAX_CP":
                    return((long)Globals.gamedata.my_pet3.Max_CP);

                case "CUR_HP":
                    return((long)Globals.gamedata.my_pet3.Cur_HP);

                case "CUR_MP":
                    return((long)Globals.gamedata.my_pet3.Cur_MP);

                case "CUR_CP":
                    return((long)Globals.gamedata.my_pet3.Cur_CP);

                case "PER_HP":
                    return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_HP / Globals.gamedata.my_pet3.Max_HP)));

                case "PER_MP":
                    return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_MP / Globals.gamedata.my_pet3.Max_MP)));

                case "PER_CP":
                    return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_CP / Globals.gamedata.my_pet3.Max_CP)));

                case "RUN_SPEED":
                    return((long)(Globals.gamedata.my_pet3.RunSpeed * Globals.gamedata.my_pet3.MoveSpeedMult));

                case "WALK_SPEED":
                    return((long)(Globals.gamedata.my_pet3.WalkSpeed * Globals.gamedata.my_pet3.MoveSpeedMult));

                case "ATTACK_SPEED":
                    return((long)Globals.gamedata.my_pet3.AttackSpeedMult);

                case "CAST_SPEED":
                    return((long)Globals.gamedata.my_pet3.MatkSpeed);

                case "EVAL":
                    return((long)0);

                case "RUNNING":
                    return((long)Globals.gamedata.my_pet3.isRunning);

                case "SITTING":
                    return((long)0);

                case "LOOKS_DEAD":
                    return((long)Globals.gamedata.my_pet3.isAlikeDead);

                default:
                    ScriptEngine.Script_Error("invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.PLAYER:
                Globals.PlayerLock.EnterReadLock();
                try
                {
                    CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID);

                    if (player != null)
                    {
                        switch (req)
                        {
                        case "KARMA":
                            return((long)player.Karma);

                        case "TARGETID":
                            return((long)player.TargetID);

                        case "ID":
                            return((long)player.ID);

                        case "TYPEID":
                            return((long)0);

                        case "X":
                            return((long)player.X);

                        case "Y":
                            return((long)player.Y);

                        case "Z":
                            return((long)player.Z);

                        case "DESTX":
                            return((long)player.Dest_X);

                        case "DESTY":
                            return((long)player.Dest_Y);

                        case "DESTZ":
                            return((long)player.Dest_Z);

                        case "IS_MOVING":
                            return(player.Moving ? 1L : 0L);

                        case "MAX_HP":
                            return((long)player.Max_HP);

                        case "MAX_MP":
                            return((long)player.Max_MP);

                        case "MAX_CP":
                            return((long)player.Max_CP);

                        case "CUR_HP":
                            return((long)player.Cur_HP);

                        case "CUR_MP":
                            return((long)player.Cur_MP);

                        case "CUR_CP":
                            return((long)player.Cur_CP);

                        case "PER_HP":
                            return((long)(100.0 * (player.Cur_HP / player.Max_HP)));

                        case "PER_MP":
                            return((long)(100.0 * (player.Cur_MP / player.Max_MP)));

                        case "PER_CP":
                            return((long)(100.0 * (player.Cur_CP / player.Max_CP)));

                        case "RUN_SPEED":
                            return((long)(player.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                        case "WALK_SPEED":
                            return((long)(player.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                        case "ATTACK_SPEED":
                            return((long)player.AttackSpeedMult);

                        case "CAST_SPEED":
                            return((long)player.MatkSpeed);

                        case "EVAL":
                            return((long)player.RecAmount);

                        case "RUNNING":
                            return((long)player.isRunning);

                        case "SITTING":
                            return((long)player.isSitting);

                        case "LOOKS_DEAD":
                            return((long)player.isAlikeDead);

                        default:
                            ScriptEngine.Script_Error("invalid target data(player) request");
                            break;
                        }
                    }
                }    //unlock
                finally
                {
                    Globals.PlayerLock.ExitReadLock();
                }
                break;

            case TargetType.NPC:
                Globals.NPCLock.EnterReadLock();
                try
                {
                    NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID);

                    if (npc != null)
                    {
                        switch (req)
                        {
                        case "KARMA":
                            return((long)npc.Karma);

                        case "TARGETID":
                            return((long)npc.TargetID);

                        case "ID":
                            return((long)npc.ID);

                        case "TYPEID":
                            return((long)npc.NPCID);

                        case "X":
                            return((long)npc.X);

                        case "Y":
                            return((long)npc.Y);

                        case "Z":
                            return((long)npc.Z);

                        case "DESTX":
                            return((long)npc.Dest_X);

                        case "DESTY":
                            return((long)npc.Dest_Y);

                        case "DESTZ":
                            return((long)npc.Dest_Z);

                        case "IS_MOVING":
                            return(npc.Moving ? 1L : 0L);

                        case "MAX_HP":
                            return((long)npc.Max_HP);

                        case "MAX_MP":
                            return((long)npc.Max_MP);

                        case "MAX_CP":
                            return((long)npc.Max_CP);

                        case "CUR_HP":
                            return((long)npc.Cur_HP);

                        case "CUR_MP":
                            return((long)npc.Cur_MP);

                        case "CUR_CP":
                            return((long)npc.Cur_CP);

                        case "PER_HP":
                            return((long)(100.0 * (npc.Cur_HP / npc.Max_HP)));

                        case "PER_MP":
                            return((long)(100.0 * (npc.Cur_MP / npc.Max_MP)));

                        case "PER_CP":
                            return((long)(100.0 * (npc.Cur_CP / npc.Max_CP)));

                        case "RUN_SPEED":
                            return((long)(npc.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                        case "WALK_SPEED":
                            return((long)(npc.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult));

                        case "ATTACK_SPEED":
                            return((long)npc.AttackSpeedMult);

                        case "CAST_SPEED":
                            return((long)npc.MatkSpeed);

                        case "SPOILED":
                            if (Globals.gamedata.my_char.TargetSpoiled)
                            {
                                return((long)(1));
                            }
                            else
                            {
                                return((long)(0));
                            }

                        case "RUNNING":
                            return((long)npc.isRunning);

                        case "SITTING":
                            return((long)npc.isSitting);

                        case "LOOKS_DEAD":
                            return((long)npc.isAlikeDead);

                        default:
                            ScriptEngine.Script_Error("invalid target data(npc) request");
                            break;
                        }
                    }
                }    //unlock
                finally
                {
                    Globals.NPCLock.ExitReadLock();
                }
                break;
            }


            return((long)0);
        }
Exemple #12
0
        public static string TARGET_STRING(string req)
        {
            switch (Globals.gamedata.my_char.CurrentTargetType)
            {
            case TargetType.ERROR:
            case TargetType.NONE:
                break;

            case TargetType.SELF:
                switch (req)
                {
                case "NAME":
                    return(Globals.gamedata.my_char.Name);

                case "TITLE":
                    return(Globals.gamedata.my_char.Title);

                case "CLAN":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName);

                case "ALLY":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName);

                default:
                    ScriptEngine.Script_Error("invalid invalid target data(self) request");
                    break;
                }
                break;

            case TargetType.MYPET:
                switch (req)
                {
                case "NAME":
                    return(Globals.gamedata.my_pet.Name);

                case "TITLE":
                    return(Globals.gamedata.my_pet.Title);

                case "CLAN":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName);

                case "ALLY":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName);

                default:
                    ScriptEngine.Script_Error("invalid invalid target data(my pet) request");
                    break;
                }
                break;

            case TargetType.MYPET1:
                switch (req)
                {
                case "NAME":
                    return(Globals.gamedata.my_pet1.Name);

                case "TITLE":
                    return(Globals.gamedata.my_pet1.Title);

                case "CLAN":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName);

                case "ALLY":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName);

                default:
                    ScriptEngine.Script_Error("invalid invalid target data(my pet) request");
                    break;
                }
                break;

            case TargetType.MYPET2:
                switch (req)
                {
                case "NAME":
                    return(Globals.gamedata.my_pet2.Name);

                case "TITLE":
                    return(Globals.gamedata.my_pet2.Title);

                case "CLAN":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName);

                case "ALLY":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName);

                default:
                    ScriptEngine.Script_Error("invalid invalid target data(my pet) request");
                    break;
                }
                break;

            case TargetType.MYPET3:
                switch (req)
                {
                case "NAME":
                    return(Globals.gamedata.my_pet3.Name);

                case "TITLE":
                    return(Globals.gamedata.my_pet3.Title);

                case "CLAN":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName);

                case "ALLY":
                    return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName);

                default:
                    ScriptEngine.Script_Error("invalid invalid target data(my pet) request");
                    break;
                }
                break;

            case TargetType.PLAYER:
                Globals.PlayerLock.EnterReadLock();
                try
                {
                    CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID);

                    if (player != null)
                    {
                        switch (req)
                        {
                        case "NAME":
                            return(player.Name);

                        case "TITLE":
                            return(player.Title);

                        case "CLAN":
                            return(((Clan_Info)Globals.clanlist[player.ClanID]).ClanName);

                        case "ALLY":
                            return(((Clan_Info)Globals.clanlist[player.ClanID]).AllyName);

                        default:
                            ScriptEngine.Script_Error("invalid invalid target data(player) request");
                            break;
                        }
                    }
                }    //unlock
                finally
                {
                    Globals.PlayerLock.ExitReadLock();
                }
                break;

            case TargetType.NPC:
                Globals.NPCLock.EnterReadLock();
                try
                {
                    NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID);

                    if (npc != null)
                    {
                        switch (req)
                        {
                        case "NAME":
                            return(Util.GetNPCName(npc.NPCID));

                        case "TITLE":
                            return(npc.Title);

                        default:
                            ScriptEngine.Script_Error("invalid target data(npc) request");
                            break;
                        }
                    }
                }    //unlock
                finally
                {
                    Globals.NPCLock.ExitReadLock();
                }
                break;
            }

            return("");
        }
Exemple #13
0
        private void button_attack_Click(object sender, EventArgs e)
        {
            switch (Globals.gamedata.my_char.CurrentTargetType)
            {
            case TargetType.ERROR:
            case TargetType.NONE:
                break;

            case TargetType.SELF:
                break;

            case TargetType.MYPET:
                ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet.X), Util.Float_Int32(Globals.gamedata.my_pet.Y), Util.Float_Int32(Globals.gamedata.my_pet.Z), false);
                break;

            case TargetType.MYPET1:
                ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet1.X), Util.Float_Int32(Globals.gamedata.my_pet1.Y), Util.Float_Int32(Globals.gamedata.my_pet1.Z), false);
                break;

            case TargetType.MYPET2:
                ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet2.X), Util.Float_Int32(Globals.gamedata.my_pet2.Y), Util.Float_Int32(Globals.gamedata.my_pet2.Z), false);
                break;

            case TargetType.MYPET3:
                ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet3.X), Util.Float_Int32(Globals.gamedata.my_pet3.Y), Util.Float_Int32(Globals.gamedata.my_pet3.Z), false);
                break;

            case TargetType.PLAYER:
                Globals.PlayerLock.EnterReadLock();
                try
                {
                    CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID);

                    if (player != null)
                    {
                        ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(player.X), Util.Float_Int32(player.Y), Util.Float_Int32(player.Z), false);
                    }
                }
                finally
                {
                    Globals.PlayerLock.ExitReadLock();
                }
                break;

            case TargetType.NPC:
                Globals.NPCLock.EnterReadLock();
                try
                {
                    NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID);

                    if (npc != null)
                    {
                        ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(npc.X), Util.Float_Int32(npc.Y), Util.Float_Int32(npc.Z), false);
                    }
                }
                finally
                {
                    Globals.NPCLock.ExitReadLock();
                }
                break;
            }
        }
Exemple #14
0
        public void Copy(NPCInfo copy)
        {
            NPCID = copy.NPCID;
            isAttackable = copy.isAttackable;
            X = copy.X;
            Y = copy.Y;
            Z = copy.Z;
            Heading = copy.Heading;
            MatkSpeed = copy.MatkSpeed;
            PatkSpeed = copy.PatkSpeed;

            RunSpeed = copy.RunSpeed;
            WalkSpeed = copy.WalkSpeed;
            SwimRunSpeed = copy.SwimRunSpeed;
            SwimWalkSpeed = copy.SwimWalkSpeed;
            flRunSpeed = copy.flRunSpeed;
            flWalkSpeed = copy.flWalkSpeed;
            FlyRunSpeed = copy.FlyRunSpeed;
            FlyWalkSpeed = copy.FlyWalkSpeed;

            MoveSpeedMult = copy.MoveSpeedMult;
            AttackSpeedMult = copy.AttackSpeedMult;
            CollisionRadius = copy.CollisionRadius;
            CollisionHeight = copy.CollisionHeight;

            RHand = copy.RHand;
            LRHand = copy.LRHand;
            LHand = copy.LHand;
            NameShows = copy.NameShows;

            isRunning = copy.isRunning;
            isInCombat = copy.isInCombat;
            isAlikeDead = copy.isAlikeDead;
            isInvisible = copy.isInvisible;

            Name = copy.Name;
            Title = copy.Title;

            Karma = copy.Karma;
            PvPFlag = copy.PvPFlag;
            SummonedNameColor = copy.SummonedNameColor;

            AbnormalEffects = copy.AbnormalEffects;
            ExtendedEffects = copy.ExtendedEffects;
            my_buffs = copy.my_buffs;
        }