Esempio n. 1
0
        public override void OnLoad()
        {
            InteractType = GenerateInteractType(Spawn.Title);

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

            ItmInterface.Load(WorldMgr.GetCreatureItems(Spawn.Entry));
            Level = (byte)RandomMgr.Next((int)Spawn.Proto.MinLevel, (int)Spawn.Proto.MaxLevel);
            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 * 2);


            // 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));
            Region.UpdateRange(this);

            base.OnLoad();
        }
Esempio n. 2
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;
        }
Esempio n. 3
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;
            }


            if (Spawn.Level != 0)
            {
                if (Spawn.Level > 2)
                {
                    Level = (byte)RandomMgr.Next((int)Spawn.Level - 1, Spawn.Level + 1);
                }
                else
                {
                    Level = (byte)RandomMgr.Next((int)Spawn.Level, Spawn.Level + 1);
                }
            }
            else
            {
                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);
             * int HeightMap = ClientFileMgr.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();

            /*AiInterface.Waypoints = WorldMgr.GetNpcWaypoints(Spawn.Guid);
             *
             * 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)
             *  {
             *      if (AiInterface.Waypoints.Count <= 4)
             *      {
             *          int i = 0;
             *          if (AiInterface.Waypoints.Count != 0)
             *              i = AiInterface.Waypoints.Count - 1;
             *          for (; i < 3; ++i)
             *          {
             *              AiInterface.AddWaypoint(new Waypoint());
             *          }
             *      }
             *      foreach (Waypoint Wp in AiInterface.Waypoints)
             *      {
             *          AiInterface.RandomizeWaypoint(Wp);
             *      }
             *  }
             * }*/
            IsActive = true;

            if (InteractType == GameData.InteractType.INTERACTTYPE_TRAINER)
            {
                States.Add(1);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_BANKER)
            {
                States.Add(11);                                                 // 11
            }
            if (InteractType == GameData.InteractType.INTERACTTYPE_GUILD_VAULT) // added
            {
                States.Add(0);                                                  // dont know what states are yet ?
            }
            if (InteractType == GameData.InteractType.INTERACTTYPE_AUCTIONEER)
            {
                States.Add(12);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_GUILD_REGISTRAR)
            {
                States.Add(14);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_FLIGHT_MASTER)
            {
                States.Add(15);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_DYEMERCHANT)
            {
                States.Add(26);
            }
        }