Esempio n. 1
0
        public override void Convert(byte[] rawData)
        {
            uint       uint32    = DBCRecordConverter.GetUInt32(rawData, 1);
            RaceId     race      = (RaceId)((int)uint32 & (int)byte.MaxValue);
            ClassId    clssId    = (ClassId)((uint32 & 65280U) >> 8);
            GenderType gender    = (GenderType)((uint32 & 16711680U) >> 16);
            Archetype  archetype = ArchetypeMgr.GetArchetype(race, clssId);

            if (archetype == null)
            {
                return;
            }
            List <ItemStack> initialItems = archetype.GetInitialItems(gender);

            for (int field = 2; field <= 25; ++field)
            {
                int itemId = DBCRecordConverter.GetInt32(rawData, field);
                if (itemId > 0)
                {
                    ItemTemplate template = ItemMgr.GetTemplate((Asda2ItemId)itemId);
                    if (template == null)
                    {
                        LogManager.GetCurrentClassLogger()
                        .Warn("Missing initial Item in DB: " + (object)itemId + " (" + (object)(uint)itemId +
                              ")");
                    }
                    else if (template.IsStackable)
                    {
                        int index = initialItems.FindIndex((Predicate <ItemStack>)(stack =>
                                                                                   (long)stack.Template.Id == (long)itemId));
                        if (index > -1)
                        {
                            initialItems[index] = new ItemStack()
                            {
                                Template = template,
                                Amount   = initialItems[index].Amount + 1
                            }
                        }
                        ;
                        else
                        {
                            initialItems.Add(new ItemStack()
                            {
                                Template = template,
                                Amount   = template.IsAmmo ? template.MaxAmount : 1
                            });
                        }
                    }
                    else
                    {
                        initialItems.Add(new ItemStack()
                        {
                            Template = template,
                            Amount   = 1
                        });
                    }
                }
            }
        }
Esempio n. 2
0
 public ClassSelectionMenu(BaseClass clss, ArchetypeSelectionHandler handler, uint textId)
     : base(textId)
 {
     Class = clss;
     foreach (Archetype archetype in ArchetypeMgr.Archetypes[(int)clss.Id])
     {
         if (archetype != null)
         {
             Archetype arche = archetype;
             AddItem(new GossipMenuItem(archetype.ToString(),
                                        convo => handler(convo, arche)));
         }
     }
 }
Esempio n. 3
0
		public TestCharacter(TestAccount acc, CharacterRecord record, Archetype archetype, bool isNew)
		{
			Create(acc, PrepareRecord(acc, record, archetype, isNew), CreateClient(acc));
			record.ExploredZones = new byte[UpdateFieldMgr.ExplorationZoneFieldSize * 4];
			acc.Characters.Add(record);
			acc.Character = this;

			BaseHealth = 1000;
			Health = 1000;
			Assert.AreEqual(1000, BaseHealth);
			Asser.GreaterOrEqual(MaxHealth, BaseHealth);
			Assert.AreEqual(1000, Health);
			Assert.IsFalse(string.IsNullOrEmpty(Name));

			SpecProfiles = new[] { WCell.RealmServer.Talents.SpecProfile.NewSpecProfile(this, 0) };
		}
Esempio n. 4
0
		public static CharacterRecord PrepareRecord(TestAccount acc, CharacterRecord record, Archetype archetype, bool isNew)
		{
			var race = archetype.Race;

			record.Name = "TestChar" + record.EntityLowId;
			record.AccountId = acc.AccountId;
			record.Created = DateTime.Now;
			record.New = isNew;
			record.TotalPlayTime = 0;
			record.LevelPlayTime = 0;
			record.TutorialFlags = new byte[32];
			record.SetupNewRecord(archetype);

			record.CreateAndFlush();

			return record;
		}
Esempio n. 5
0
        public void FinalizeDataHolder()
        {
            int num = Level > 0 ? Level : 1;

            if (num > RealmServerConfiguration.MaxCharacterLevel)
            {
                return;
            }
            Archetype archetype = ArchetypeMgr.GetArchetype(Race, Class);

            if (archetype == null)
            {
                return;
            }
            if (Level == 1)
            {
                archetype.FirstLevelStats = this;
            }
            archetype.LevelStats[num - 1] = this;
        }
Esempio n. 6
0
        public void FinalizeDataHolder()
        {
            Race  = ArchetypeMgr.GetRace(RaceId);
            Class = ArchetypeMgr.GetClass(ClassId);

            if (Class == null || Race == null)
            {
                //throw new ContentException("Could not load Archetype \"{0}\" - Invalid Class or race.", this);
            }

            var races = ArchetypeMgr.Archetypes[(uint)ClassId];

            if (races == null)
            {
                ArchetypeMgr.Archetypes[(uint)ClassId] = races = new Archetype[WCellConstants.RaceTypeLength];
            }

            StartLocation = new WorldZoneLocation(StartMapId, StartPosition, StartZoneId);
            if (StartLocation.Map == null)
            {
                LogManager.GetCurrentClassLogger().Warn("Failed to initialize Archetype \"" + this + "\" - StartMap does not exist: " + StartMapId);
                //ArrayUtil.Set(ref RaceClassMgr.BaseRaces, (uint)Id, null);
            }
            else
            {
                /*if (StartLocation.ZoneTemplate == null)
                 * {
                 *      LogManager.GetCurrentClassLogger().Warn("Failed to initialize Archetype \"" + this +
                 *                                                               "\" - StartZone \"" + StartZoneId + "\" does not exist in StartMap \"" +
                 *                                                               StartMapId + "\"");
                 *      //ArrayUtil.Set(ref RaceClassMgr.BaseRaces, (uint)Id, null);
                 * }
                 * else
                 * {*/
                races[(uint)RaceId] = this;
                //}
            }

            //get levelstats
        }
Esempio n. 7
0
		public TestCharacter(CharacterRecord record, Archetype archetype, bool isNew)
			: this(Setup.AccountPool.CreateAccount(), record, archetype, isNew)
		{
		}
Esempio n. 8
0
		public TestCharacter(Archetype archetype, bool isNew)
			: this(Setup.AccountPool.CreateAccount(), Setup.CreateCharRecord(), archetype, isNew)
		{
		}
Esempio n. 9
0
		public void SetupNewRecord(Archetype archetype)
		{
			Race = archetype.Race.Id;
			Class = archetype.Class.Id;
			Level = archetype.Class.ActualStartLevel;
			PositionX = archetype.StartPosition.X;
			PositionY = archetype.StartPosition.Y;
			PositionZ = archetype.StartPosition.Z;
			Orientation = archetype.StartOrientation;
			MapId = archetype.StartMapId;
			Zone = archetype.StartZoneId;
			TotalPlayTime = 0;
			LevelPlayTime = 0;
			TutorialFlags = new byte[32];
			WatchedFaction = -1;

			DisplayId = archetype.Race.GetDisplayId(Gender);
		}
Esempio n. 10
0
		public static TestCharacter CreateChar(bool isNew, Archetype archetype)
		{
			if (isNew)
			{
				Setup.EnsureBasicSetup();
			}
			else
			{
				// load items from DB -> Items need to be initialized
				Setup.EnsureItemsLoaded();
			}
			var chr = new TestCharacter(archetype, isNew);
			//chr.Load(); TODO: Fix this!
			return chr;
		}
Esempio n. 11
0
		public void FinalizeDataHolder()
		{
			Race = ArchetypeMgr.GetRace(RaceId);
			Class = ArchetypeMgr.GetClass(ClassId);

			if (Class == null || Race == null)
			{
				throw new ContentException("Could not load Archetype \"{0}\" - Invalid Class or race.", this);
			}

			var races = ArchetypeMgr.Archetypes[(uint)ClassId];
			if (races == null)
			{
				ArchetypeMgr.Archetypes[(uint)ClassId] = races = new Archetype[WCellDef.RaceTypeLength];
			}

			StartLocation = new WorldZoneLocation(StartMapId, StartPosition, StartZoneId);
			if (StartLocation.Map == null)
			{
				LogManager.GetCurrentClassLogger().Warn("Failed to initialize Archetype \"" + this + "\" - StartMap does not exist: " + StartMapId);
				//ArrayUtil.Set(ref RaceClassMgr.BaseRaces, (uint)Id, null);
			}
			else
			{
				if (StartLocation.ZoneTemplate == null)
				{
					LogManager.GetCurrentClassLogger().Warn("Failed to initialize Archetype \"" + this +
												 "\" - StartZone \"" + StartZoneId + "\" does not exist in StartMap \"" +
												 StartMapId + "\"");
					//ArrayUtil.Set(ref RaceClassMgr.BaseRaces, (uint)Id, null);
				}
				else
				{
					races[(uint)RaceId] = this;
				}
			}

			//get levelstats
		}
Esempio n. 12
0
 static ArchetypeMgr()
 {
     for (var c = 0; c < Archetypes.Length; c++)
     {
         Archetypes[c] = new Archetype[WCellConstants.RaceTypeLength];
     }
 }