Esempio n. 1
0
        public bool Attack(Object obj, object args)
        {
            CombatInterface_Npc cb = CbtInterface as CombatInterface_Npc;

            if (cb == null)
            {
                Log.Error("Pet", "Missing CombatInterface in Attack()");
                return(false);
            }

            Unit attacker = obj as Unit;

            if (attacker == null)
            {
                Log.Error("Pet", "Object is NULL in Attack()");
                return(false);
            }

            if (AIMode != 3 && cb.CurrentTarget == null)
            {
                AiInterface.ProcessCombatStart(attacker);
            }

            return(false);
        }
        protected override void SetDeath(Unit killer)
        {
            if (Spawn.DoorId == 0)
            {
                if (Spawn.AllowVfxUpdate == 1)
                {
                    UpdateVfxState(1);
                }
                else
                {
                    IsActive = false;
                }
            }
            else
            {
                OpenDoor(false);
            }

            // I'm ashamed by the way I fixed it...
            if (Name != "Keep Door" && Entry != 100 && Respawn == 1)
            {
                SetRespawnTimer();
            }

            if (this.IsAttackable == 1 && this.Spawn.Proto.CreatureId != 0)
            {
                SpawnNPCFromGO();
            }

            base.SetDeath(killer);

            AiInterface.ProcessCombatEnd();
        }
Esempio n. 3
0
        protected override void SetDeath(Unit killer)
        {
            Health = 0;

            States.Add((byte)CreatureState.Dead);

            PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECT_DEATH, 12);

            Out.WriteUInt16(Oid);
            Out.WriteByte(1);
            Out.WriteByte(0);
            Out.WriteUInt16(killer.IsPet() ? killer.GetPet().Owner.Oid : killer.Oid);
            Out.Fill(0, 6);
            DispatchPacket(Out, true);

            AbtInterface.Cancel(true);
            ScrInterface.OnDie(this);


            BuffInterface.RemoveBuffsOnDeath();

            EvtInterface.Notify(EventName.OnDie, this, killer);

            Pet    pet      = killer as Pet;
            Player credited = (pet != null) ? pet.Owner : (killer as Player);

            if (credited != null)
            {
                HandleDeathRewards(credited);
            }

            AiInterface.ProcessCombatEnd();

            SetRespawnTimer();

            EvtInterface.RemoveEventNotify(EventName.OnReceiveDamage, OnReceiveDamage);

            if (!FlagGuard.Info.KeepLord)
            {
                _keep.OnKeepNpcAttacked(0);
                return;
            }

            /*Log.Info(_keep.Info.Name, (_keep.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction") + " keep lord slain by " + killer.Name + " of " + (killer.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction"));*/

            if (_keep.Realm == killer.Realm)
            {
                /*if (FlagGuard.Info.KeepLord)
                 *  Log.Info(_keep.Info.Name, (_keep.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction") + " keep lord respawned.");*/
                _logger.Debug($"Kill request from own realm {killer.Name} {_keep.Realm}");
                FlagGuard.Creature = new KeepCreature(Spawn, FlagGuard, _keep);
                Region.AddObject(FlagGuard.Creature, Spawn.ZoneId);
                Destroy();
            }
            else
            {
                _keep.OnLordKilled();
            }
        }
Esempio n. 4
0
        public override void Update(long msTick)
        {
            base.Update(msTick);

            if (WaypointGUID > 0 && AiInterface != null && AiInterface.Waypoints != null && AiInterface.Waypoints.Count > 0)
            {
                AiInterface.Update(msTick);
            }
        }
Esempio n. 5
0
        public override void OnLoad()
        {
            base.OnLoad();

            var brain = new BossBrain(this);

            brain.Abilities = CreatureService.BossSpawnAbilities.Where(x => x.BossSpawnId == this.BossId).ToList();
            AiInterface.SetBrain(brain);

            //AiInterface.SetBrain(new BossBrain(this));
        }
Esempio n. 6
0
        public override void Dispose()
        {
            ItmInterface.Stop();
            CbtInterface.Stop();
            StsInterface.Stop();
            QtsInterface.Stop();
            MvtInterface.Stop();
            AbtInterface.Stop();
            EvtInterface.Stop();
            AiInterface.Stop();

            base.Dispose();
        }
Esempio n. 7
0
        public override void OnLoad()
        {
            SpawnPoint.X = X;
            SpawnPoint.Y = Y;
            SpawnPoint.Z = Z;
            SpawnHeading = Heading;
            if (EvtInterface == null)
            {
                EvtInterface = new EventInterface(this);
            }

            AiInterface.Load();
            base.OnLoad();
        }
Esempio n. 8
0
        public Pet(ushort petId, Creature_spawn spawn, Player owner, byte aiMode, bool isStationary, bool isCombative) : base(spawn)
        {
            PetId        = petId;
            Owner        = owner;
            IsStationary = isStationary;
            if (!isStationary)
            {
                FollowMode = 2;
            }
            AIMode         = aiMode;
            _ownerUILinked = isCombative;

            if (!isCombative)
            {
                IsInvulnerable = true;
            }

            else
            {
                SpeedMult = 1.2f;
            }

            switch (aiMode)
            {
            case 3: AiInterface.SetBrain(new PassiveBrain(this)); break;

            case 4: AiInterface.SetBrain(new GuardBrain(this)); break;

            case 5: AiInterface.SetBrain(new AggressiveBrain(this)); break;
            }
            Realm   = owner.Realm;
            Faction = (byte)(owner.Realm == Realms.REALMS_REALM_DESTRUCTION ? 8 : 6);

            Owner.SendStats();

            Health = 1;

            EvtInterface.AddEvent(SendPetInitial, 500, 1);
        }
Esempio n. 9
0
        protected override void SetDeath(Unit killer)
        {
            Health = 0;

            States.Add((byte)CreatureState.Dead); // Death State

            PacketOut Out = new PacketOut((byte)Opcodes.F_OBJECT_DEATH, 12);

            Out.WriteUInt16(Oid);
            Out.WriteByte(1);
            Out.WriteByte(0);
            Out.WriteUInt16(killer.IsPet() ? killer.GetPet().Owner.Oid : killer.Oid);
            Out.Fill(0, 6);
            DispatchPacket(Out, true);

            AbtInterface.Cancel(true);
            ScrInterface.OnDie(this);

            BuffInterface.RemoveBuffsOnDeath();

            EvtInterface.Notify(EventName.OnDie, this, killer);

            AiInterface.ProcessCombatEnd();

            EvtInterface.AddEvent(RezUnit, 10000, 1); // Clear the object in 10 seconds.

            if (_ownerUILinked)
            {
                SendPetRemove(true);

                IPetCareerInterface petInterface = Owner.CrrInterface as IPetCareerInterface;

                petInterface?.Notify_PetDown();

                _ownerUILinked = false;
            }
        }
Esempio n. 10
0
        public override void Update()
        {
            long Tick = TCPManager.GetTimeStampMS();

            UpdateHealth(Tick);
            UpdateActionPoints(Tick);
            EvtInterface.Update(Tick);

            CbtInterface.Update(Tick);
            ItmInterface.Update(Tick);
            StsInterface.Update(Tick);
            QtsInterface.Update(Tick);
            MvtInterface.Update(Tick);
            AbtInterface.Update(Tick);
            AiInterface.Update(Tick);

            if (NextSend < Tick)
            {
                NextSend = Tick + STATE_INTERVAL;
                SendState(null);
            }

            base.Update();
        }
        public override void OnLoad()
        {
            base.OnLoad();

            AiInterface.SetBrain(new InstanceBossBrain(this));
        }
Esempio n. 12
0
        public override void OnLoad()
        {
            InteractType = Spawn.Proto.InteractType;

            SetFaction(Spawn.Faction != 0 ? Spawn.Faction : Spawn.Proto.Faction);

            ItmInterface.Load(CreatureService.GetCreatureItems(Spawn.Entry));
            if (Spawn.Proto.MinLevel > Spawn.Proto.MaxLevel)
            {
                Spawn.Proto.MinLevel = Spawn.Proto.MaxLevel;
            }

            if (Spawn.Proto.MaxLevel <= Spawn.Proto.MinLevel)
            {
                Spawn.Proto.MaxLevel = Spawn.Proto.MinLevel;
            }

            if (Spawn.Proto.MaxLevel == 0)
            {
                Spawn.Proto.MaxLevel = 1;
            }
            if (Spawn.Proto.MinLevel == 0)
            {
                Spawn.Proto.MinLevel = 1;
            }

            if (Spawn.Level != 0)
            {
                if (Spawn.Level > 2)
                {
                    Level = (byte)StaticRandom.Instance.Next(Spawn.Level - 1, Spawn.Level + 1);
                }
                else
                {
                    Level = (byte)StaticRandom.Instance.Next(Spawn.Level, Spawn.Level + 1);
                }
            }
            else
            {
                Level = (byte)StaticRandom.Instance.Next(Spawn.Proto.MinLevel, Spawn.Proto.MaxLevel + 1);
            }

            SetCreatureStats();

            Health = TotalHealth;

            X = Zone.CalculPin((uint)Spawn.WorldX, true);
            Y = Zone.CalculPin((uint)Spawn.WorldY, false);
            Z = (ushort)Spawn.WorldZ;

            // TODO : Bad Height Formula

            /*int HeightMap = HeightMapMgr.GetHeight(Zone.ZoneId, X, Y);
             * if (Z < HeightMap)
             * {
             *  Log.Error("Creature", "["+Spawn.Entry+"] Invalid Height : Min=" + HeightMap + ",Z=" + Z);
             *  return;
             * }*/

            Heading         = (ushort)Spawn.WorldO;
            WorldPosition.X = Spawn.WorldX;
            WorldPosition.Y = Spawn.WorldY;
            WorldPosition.Z = Spawn.WorldZ;

            SetOffset((ushort)(Spawn.WorldX >> 12), (ushort)(Spawn.WorldY >> 12));
            ScrInterface.AddScript(Spawn.Proto.ScriptName);

            SaveSpawnData();
            LoadInterfaces();

            AiInterface.SetBrain(new DummyBrain(this));

            States.Add(0x12);
            States.Add((byte)CreatureState.UnkOmnipresent);

            Speed = 350;
            StsInterface.Speed = 350;
            MvtInterface.SetBaseSpeed(Speed);
            MvtInterface.FollowReacquisitionInterval = 100;

            IsActive = true;
        }
Esempio n. 13
0
        public override void OnLoad()
        {
            InteractType = GenerateInteractType(Spawn.Title != 0 ? Spawn.Title : Spawn.Proto.Title);

            SetFaction(Spawn.Faction != 0 ? Spawn.Faction : Spawn.Proto.Faction);

            ItmInterface.Load(WorldMgr.GetCreatureItems(Spawn.Entry));
            if (Spawn.Proto.MinLevel > Spawn.Proto.MaxLevel)
            {
                Spawn.Proto.MinLevel = Spawn.Proto.MaxLevel;
            }

            if (Spawn.Proto.MaxLevel <= Spawn.Proto.MinLevel)
            {
                Spawn.Proto.MaxLevel = Spawn.Proto.MinLevel;
            }

            if (Spawn.Proto.MaxLevel == 0)
            {
                Spawn.Proto.MaxLevel = 1;
            }
            if (Spawn.Proto.MinLevel == 0)
            {
                Spawn.Proto.MinLevel = 1;
            }

            Level = (byte)RandomMgr.Next((int)Spawn.Proto.MinLevel, (int)Spawn.Proto.MaxLevel + 1);
            StsInterface.SetBaseStat((byte)GameData.Stats.STATS_WOUNDS, GenerateWounds(Level, Rank));
            StsInterface.ApplyStats();
            Health = TotalHealth;

            X = Zone.CalculPin((uint)(Spawn.WorldX), true);
            Y = Zone.CalculPin((uint)(Spawn.WorldY), false);
            Z = (ushort)(Spawn.WorldZ);

            /*
             * if (Zone.ZoneId == 161)
             * {
             *  Z += 16384;
             *  X += 16384;
             *  Y += 16384;
             * }
             */
            // TODO : Bad Height Formula

            /*int HeightMap = HeightMapMgr.GetHeight(Zone.ZoneId, X, Y);
             * if (Z < HeightMap)
             * {
             *  Log.Error("Creature", "["+Spawn.Entry+"] Invalid Height : Min=" + HeightMap + ",Z=" + Z);
             *  return;
             * }*/

            Heading         = (ushort)Spawn.WorldO;
            WorldPosition.X = Spawn.WorldX;
            WorldPosition.Y = Spawn.WorldY;
            WorldPosition.Z = Spawn.WorldZ;

            SetOffset((ushort)(Spawn.WorldX >> 12), (ushort)(Spawn.WorldY >> 12));
            ScrInterface.AddScript(Spawn.Proto.ScriptName);
            base.OnLoad();

            if (Spawn.Title == 0 && Spawn.Icone == 0 && Spawn.Proto.Title == 0 && Spawn.Icone == 0 && Spawn.Emote == 0 && Spawn.Proto.FinishingQuests == null && Spawn.Proto.StartingQuests == null)
            {
                if (Faction <= 1 || Faction == 128 || Faction == 129)
                {
                    SFastRandom Random = new SFastRandom(X ^ Y ^ Z);

                    for (int i = 0; i < 3; ++i)
                    {
                        Waypoint Wp = new Waypoint();
                        Wp.X           = (ushort)(X + Random.randomInt(50) + Random.randomInt(100) + Random.randomInt(150));
                        Wp.Y           = (ushort)(Y + Random.randomInt(50) + Random.randomInt(100) + Random.randomInt(150));
                        Wp.Z           = (ushort)Z;
                        Wp.Speed       = 10;
                        Wp.WaitAtEndMS = (uint)(5000 + Random.randomIntAbs(10) * 1000);
                        AiInterface.AddWaypoint(Wp);
                    }
                }
            }

            IsActive = true;
        }