示例#1
0
        internal static void Create(string charName, CharacterCreate charCreateStruct)
        {
            // TODO: old emu does some in depth validation of race/class combinations and ability scores.  Will add later if necessary

            using (EmuDataContext dbCtx = new EmuDataContext())
            {
                DataLoadOptions dlo = new DataLoadOptions();
                dlo.LoadWith<StartingItem>(si => si.Item);
                dbCtx.LoadOptions = dlo;

                Character toon = dbCtx.Characters.SingleOrDefault(c => c.Name == charName);
                toon.Race = (short)charCreateStruct.Race;
                toon.Class = (byte)charCreateStruct.Class;
                toon.Gender = (byte)charCreateStruct.Gender;
                toon.Deity = (int)charCreateStruct.Deity;
                toon.STR = (short)charCreateStruct.STR;
                toon.STA = (short)charCreateStruct.STA;
                toon.AGI = (short)charCreateStruct.AGI;
                toon.DEX = (short)charCreateStruct.DEX;
                toon.WIS = (short)charCreateStruct.WIS;
                toon.INT = (short)charCreateStruct.INT;
                toon.CHA = (short)charCreateStruct.CHA;
                toon.Face = (byte)charCreateStruct.Face;
                toon.EyeColor1 = (byte)charCreateStruct.EyeColor1;
                toon.EyeColor2 = (byte)charCreateStruct.EyeColor2;
                toon.HairStyle = (byte)charCreateStruct.HairStyle;
                toon.HairColor = (byte)charCreateStruct.HairColor;
                toon.Beard = (byte)charCreateStruct.Beard;
                toon.BeardColor = (byte)charCreateStruct.BeardColor;
                toon.LastSeenDate = DateTime.Now;
                toon.CharLevel = 1;
                toon.PracticePoints = 5;
                toon.HP = 1000;     // just here for dev, later will be set elsewhere
                toon.HungerLevel = 6000;
                toon.ThirstLevel = 6000;
                toon.Platinum = (uint)EQEmulator.Servers.WorldServer.ServerConfig.StartingPlat;
                toon.Gold = (uint)EQEmulator.Servers.WorldServer.ServerConfig.StartingGold;

                SetRacialStartingAbilities(ref toon);   // Sets languages and skills that are racially determined
                SetClassStartingAbilities(ref toon);    // Sets skills determined by class

                // Get the character's start zone
                StartZone startZone = dbCtx.StartZones.SingleOrDefault(sz => sz.PlayerChoice == charCreateStruct.StartZone
                    && sz.PlayerClass == charCreateStruct.Class && sz.PlayerDeity == charCreateStruct.Deity && sz.PlayerRace == charCreateStruct.Race);
                CharacterBind cb = new CharacterBind();
                toon.X = toon.Y = toon.Z = 0.0F;
                cb.X = cb.Y = cb.Z = 0.0F;
                toon.Heading = 0.0F;

                if (startZone != null)  // TODO: should heading for zone and bind be set to some default setting?
                {
                    // Found a start zone in the db... load up the bind info from that
                    toon.ZoneID = startZone.ZoneID;
                    toon.ZoneName = startZone.Zone.ShortName;
                    toon.X = startZone.X;
                    toon.Y = startZone.Y;
                    toon.Z = startZone.Z;

                    if (startZone.BindZoneID != null)
                    {
                        cb.ZoneID = startZone.BindZoneID.Value;
                        cb.X = startZone.BindX.Value;
                        cb.Y = startZone.BindY.Value;
                        cb.Z = startZone.BindZ.Value;
                    }
                    else
                        cb.ZoneID = startZone.ZoneID;
                }
                else
                    SetDefaultStartZone(charCreateStruct.StartZone, ref toon, ref cb);

                Zone zone = null;

                // Load safe points for start zone coords if necessary
                if (toon.X == 0.0F && toon.Y == 0.0F && toon.Z == 0.0F)
                {
                    zone = dbCtx.Zones.SingleOrDefault(z => z.ZoneID == toon.ZoneID);
                    toon.X = zone.SafeX;
                    toon.Y = zone.SafeY;
                    toon.Z = zone.SafeZ;
                }

                // Load safe points for start bind coords if necessary
                if (cb.X == 0.0F && cb.Y == 0.0F && cb.Z == 0.0F)
                {
                    zone = dbCtx.Zones.SingleOrDefault(z => z.ZoneID == cb.ZoneID);
                    if (zone != null)
                    {
                        cb.X = zone.SafeX;
                        cb.Y = zone.SafeY;
                        cb.Z = zone.SafeZ;
                    }
                    else
                        _log.ErrorFormat("Unable to load safe points for bind zone {0}", cb.ZoneID);
                }

                cb.Heading = toon.Heading.Value;
                toon.CharacterBinds.Add(cb);

                // Get starting items
                var startingItems = from si in dbCtx.StartingItems
                                    where (si.Race == toon.Race.Value || si.Race == 0) && (si.Class == toon.Class.Value || si.Class == 0)
                                    && (si.DeityID == (toon.Deity ?? 0) || si.DeityID == 0) && (si.ZoneID == toon.ZoneID.Value || si.ZoneID == 0)
                                    select si;

                int siSlotId = 22;    // for initial items with unspecified slots, just dump them to the personal inv slots
                foreach (StartingItem si in startingItems) {
                    InventoryItem ii = new InventoryItem {
                        ItemID = si.ItemID,
                        Charges = si.ItemCharges,
                        Color = si.Item.Color ?? 0,
                        SlotID = si.Slot
                    };

                    if (ii.SlotID < 0) {  // for unspecified inventory slots, find an open slot
                        ii.SlotID = siSlotId;
                        siSlotId++;
                    }

                    toon.InventoryItems.Add(ii);
                }

                dbCtx.SubmitChanges();
            }
        }
示例#2
0
 private static void SetDefaultStartZone(uint startZoneId, ref Character toon, ref CharacterBind cb)
 {
     switch (startZoneId)
     {
         case 0:
             toon.ZoneID = 24;   // erudnext
             cb.ZoneID = 38;     // tox
             break;
         case 1:
             toon.ZoneID = 2;   // north qeynos
             cb.ZoneID = 2;     // north qeynos
             break;
         case 2:
             toon.ZoneID = 29;   // halas
             cb.ZoneID = 30;     // everfrost
             break;
         case 3:
             toon.ZoneID = 19;   // rivervale
             cb.ZoneID = 20;     // kithicor
             break;
         case 4:
             toon.ZoneID = 9;   // freeportw
             cb.ZoneID = 9;     // freeportw
             break;
         case 5:
             toon.ZoneID = 40;   // neriaka
             cb.ZoneID = 25;     // nektulos
             break;
         case 6:
             toon.ZoneID = 52;   // gukta
             cb.ZoneID = 46;     // innothule
             break;
         case 7:
             toon.ZoneID = 49;   // oggok
             cb.ZoneID = 47;     // feerrott
             break;
         case 8:
             toon.ZoneID = 60;   // kaladima
             cb.ZoneID = 68;     // butcher
             break;
         case 9:
             toon.ZoneID = 54;   // gfaydark
             cb.ZoneID = 54;     // gfaydark
             break;
         case 10:
             toon.ZoneID = 61;   // felwithea
             cb.ZoneID = 54;     // gfaydark
             break;
         case 11:
             toon.ZoneID = 55;   // akanon
             cb.ZoneID = 56;     // steamfont
             break;
         case 12:
             toon.ZoneID = 82;   // cabwest
             cb.ZoneID = 78;     // fieldofbone
             break;
         case 13:
             toon.ZoneID = 155;   // sharvahl
             cb.ZoneID = 155;     // sharvahl
             break;
         default:
             throw new ArgumentException("Invalid start zone: must be between 0 - 13", "startZoneId");
     }
 }
		private void detach_CharacterBinds(CharacterBind entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		private void attach_CharacterBinds(CharacterBind entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
 partial void DeleteCharacterBind(CharacterBind instance);
 partial void UpdateCharacterBind(CharacterBind instance);
 partial void InsertCharacterBind(CharacterBind instance);