AddAgroDmg() public method

public AddAgroDmg ( int playerid, int dmg ) : void
playerid int
dmg int
return void
Example #1
0
        void ActionNormalAttack()
        {
            try
            {
                float x = 0, y = 0;

                bool[] aRound = null;

                if (Character.Action.Object != null)
                {
                    //Set target object as object
                    obj TargetInformation = Character.Action.Object as obj;
                    //If our target object is a monster
                    #region Attacking a monster
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.MONSTER)
                    {
                        //If state is dead
                        if (TargetInformation.State == 4)
                        {
                            //Set normal attack bool to false
                            Character.Action.nAttack = false;
                            //Stop attack timer
                            StopAttackTimer();
                        }

                        if (TargetInformation.Agro == null)
                        {
                            TargetInformation.Agro = new List <_agro>();
                        }
                        x = (float)TargetInformation.x;
                        y = (float)TargetInformation.y;

                        if (!TargetInformation.Attacking)
                        {
                            TargetInformation.AddAgroDmg(Character.Information.UniqueID, 1);
                        }
                        if (TargetInformation.Die || TargetInformation.GetDie)
                        {
                            StopAttackTimer();
                            return;
                        }
                    }
                    #endregion
                    //If attacking a player
                    #region Attacking a player
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.PLAYER)
                    {
                        if (!Character.Information.PvP)
                        {
                            Character.Action.nAttack = false;
                            StopAttackTimer();
                            return;
                        }

                        Systems sys = Character.Action.Object as Systems;
                        if (sys.Character.State.LastState == 4)
                        {
                            StopAttackTimer();
                            return;
                        }

                        if (!(Character.Information.PvP && sys.Character.Information.PvP))
                        {
                            StopAttackTimer();
                            return;
                        }
                        if (!Character.InGame)
                        {
                            StopAttackTimer();
                            return;
                        }
                        x      = sys.Character.Position.x;
                        y      = sys.Character.Position.y;
                        aRound = sys.Character.aRound;
                    }
                    #endregion

                    double distance = Formule.gamedistance(Character.Position.x,
                                                           Character.Position.y,
                                                           x,
                                                           y);

                    if (Character.Information.Item.wID == 0)
                    {
                        distance -= 0.5;
                    }
                    else
                    {
                        distance -= Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                    }

                    if (distance > 0)
                    {
                        float farkx = x;
                        float farky = y;

                        if (Character.Information.Item.wID == 0)
                        {
                            Character.Position.wX = farkx - Character.Position.x - 0;
                            Character.Position.wY = farky - Character.Position.y - 0;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }
                        else
                        {
                            Character.Position.wX = farkx - Character.Position.x - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.wY = farky - Character.Position.y - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }

                        Send(Packet.Movement(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID,
                                                                                  (float)Formule.packetx((float)farkx, Character.Position.xSec),
                                                                                  (float)Character.Position.z,
                                                                                  (float)Formule.packety((float)farky, Character.Position.ySec),
                                                                                  Character.Position.xSec,
                                                                                  Character.Position.ySec)));

                        Character.Position.Time         = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        Character.Position.RecordedTime = Character.Position.Time;

                        Character.Position.packetxSec = Character.Position.xSec;
                        Character.Position.packetySec = Character.Position.ySec;

                        Character.Position.packetX = (ushort)Formule.packetx((float)farkx, Character.Position.xSec);
                        Character.Position.packetY = (ushort)Formule.packety((float)farky, Character.Position.ySec);

                        Character.Position.Walking = true;

                        StartMovementTimer((int)(Character.Position.Time * 0.1));

                        return;
                    }
                }
                ActionAttack();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Normal Attack Error : {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Example #2
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Spawn & Kill
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void GM_ZOE(int model, byte count)
 {
     try
     {
         for (int x = 0; x < count; x++)
         {
             // spawn
             obj o = new obj();
             o.ID = model;
             o.Type = 3;
             o.Ids = new Global.ID(Global.ID.IDS.Object);
             o.UniqueID = o.Ids.GetUniqueID;
             o.x = Character.Position.x;
             o.z = Character.Position.z;
             o.y = Character.Position.y;
             o.oX = o.x;
             o.oY = o.y;
             o.xSec = Character.Position.xSec;
             o.ySec = Character.Position.ySec;
             o.AutoMovement = false;
             o.HP = Data.ObjectBase[model].HP;
             o.Agresif = Data.ObjectBase[model].Agresif;
             if (Data.ObjectBase[model].Type == 4) o.LocalType = 4;
             else if (Data.ObjectBase[model].Type == 1) o.LocalType = 1;
             else if (Data.ObjectBase[model].Type == 2) o.LocalType = 2;
             o.AutoSpawn = false;
             o.Kat = 1;
             o.SpeedWalk = Data.ObjectBase[o.ID].SpeedWalk;
             o.SpeedRun = Data.ObjectBase[o.ID].SpeedRun;
             o.SpeedZerk = Data.ObjectBase[o.ID].SpeedZerk;
             Systems.aRound(ref o.oX, ref o.oY, 5);
             Systems.Objects.Add(o);
             o.SpawnMe();
             o.AddAgroDmg(Character.Information.UniqueID, o.HP);
             if (o.ID == 1954 || o.ID == 1982 || o.ID == 2002 || o.ID == 3810 || o.ID == 3875 || o.ID == 5871 || o.ID == 14538 || o.ID == 14839 || o.ID == 3877)
                 Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
             // kill
             obj o2 = GetObject(o.UniqueID);
             o2.HP = 0;
             o2.GetDie = true;
             o2.SetExperience();
             o2.MonsterDrop();
             o2.StartDeadTimer(100);
             if (o2.ID == 1954 || o2.ID == 1982 || o2.ID == 2002 || o2.ID == 3810 || o2.ID == 3875 || o2.ID == 5871 || o2.ID == 14538)
                 Systems.SendAll(Packet.Unique_Data(6, (int)o2.ID, Character.Information.Name));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("[ZOE] Error : " + ex.Message);
         Systems.Debugger.Write(ex);
     }
 }