Beispiel #1
0
        public Equip(DroppedEquip pBase, ZoneCharacter pNewOwner, sbyte pSlot)
        {
            DatabaseEquip dbeq = new DatabaseEquip();
            dbeq.IncDex = pBase.Dex;
            dbeq.IncStr = pBase.Str;
            dbeq.IncEnd = pBase.End;
            dbeq.IncInt = pBase.Int;
            dbeq.IncSpr = pBase.Spr;
            dbeq.Upgrades = pBase.Upgrades;
            dbeq.EquipID = pBase.ItemID;
            dbeq.Slot = pSlot;
            dbeq.Character = pNewOwner.character;

            Program.Entity.AddToDatabaseEquips(dbeq);
            equip = dbeq;
            ItemID = (ushort)dbeq.EquipID;
            pNewOwner.InventoryItems.Add(pSlot, this);
            pNewOwner.Save();
        }
Beispiel #2
0
 public Equip(DatabaseEquip eqp)
 {
     equip = eqp;
     ItemID = (ushort)eqp.EquipID;
 }
Beispiel #3
0
        public WorldCharacter CreateCharacter(string name, byte slot, byte hair, byte color, byte face, Job job, bool ismale)
        {
            if (Characters.ContainsKey(slot) || slot > 5)
                return null;
            //TODO: check if hair etc are actual beginner ones! (premium hack)

            BaseStatsEntry stats = DataProvider.Instance.JobBasestats[job];
            if (stats == null)
            {
                Log.WriteLine(LogLevel.Warn, "Houston, we have a problem! Jobstats not found for job {0}", job.ToString());
                return null;
            }

            Character newchar = new Character();
            newchar.AccountID = this.AccountID;
            newchar.CharLevel = 1;
            newchar.Name = name;
            newchar.Face = face;
            newchar.Hair = hair;
            newchar.HairColor = color;
            newchar.Job = (byte)job;
            newchar.Male = ismale;
            newchar.Slot = slot;
            newchar.XPos = 7636;
            newchar.YPos = 4610;
            newchar.HP = (short)stats.MaxHP;
            newchar.SP = (short)stats.MaxSP;
            newchar.HPStones = (short)stats.MaxHPStones;
            newchar.SPStones = (short)stats.MaxSPStones;
            Program.Entity.AddToCharacters(newchar);
            int charID = newchar.ID;
            ushort begineqp = GetBeginnerEquip(job);
            if (begineqp > 0)
            {
                DatabaseEquip eqp = new DatabaseEquip();
                eqp.EquipID = begineqp;
                eqp.Slot = (short)((job == Job.Archer) ? -10 : -12);
                newchar.Equips.Add(eqp);
            }
            Program.Entity.SaveChanges();
            WorldCharacter tadaa = new WorldCharacter(newchar, (job == Job.Archer) ? (byte)12 : (byte)10, begineqp);
            Characters.Add(slot, tadaa);
            return tadaa;
        }
Beispiel #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DatabaseEquips EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDatabaseEquips(DatabaseEquip databaseEquip)
 {
     base.AddObject("DatabaseEquips", databaseEquip);
 }
Beispiel #5
0
 /// <summary>
 /// Create a new DatabaseEquip object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="owner">Initial value of the Owner property.</param>
 /// <param name="slot">Initial value of the Slot property.</param>
 /// <param name="equipID">Initial value of the EquipID property.</param>
 /// <param name="upgrades">Initial value of the Upgrades property.</param>
 /// <param name="incStr">Initial value of the IncStr property.</param>
 /// <param name="incEnd">Initial value of the IncEnd property.</param>
 /// <param name="incDex">Initial value of the IncDex property.</param>
 /// <param name="incInt">Initial value of the IncInt property.</param>
 /// <param name="incSpr">Initial value of the IncSpr property.</param>
 public static DatabaseEquip CreateDatabaseEquip(global::System.Int32 id, global::System.Int32 owner, global::System.Int16 slot, global::System.Int32 equipID, global::System.Byte upgrades, global::System.Byte incStr, global::System.Byte incEnd, global::System.Byte incDex, global::System.Byte incInt, global::System.Byte incSpr)
 {
     DatabaseEquip databaseEquip = new DatabaseEquip();
     databaseEquip.ID = id;
     databaseEquip.Owner = owner;
     databaseEquip.Slot = slot;
     databaseEquip.EquipID = equipID;
     databaseEquip.Upgrades = upgrades;
     databaseEquip.IncStr = incStr;
     databaseEquip.IncEnd = incEnd;
     databaseEquip.IncDex = incDex;
     databaseEquip.IncInt = incInt;
     databaseEquip.IncSpr = incSpr;
     return databaseEquip;
 }
Beispiel #6
0
 public InventoryStatus GiveItem(ushort id, byte amount = 1)
 {
     ItemInfo info;
     if (DataProvider.Instance.ItemsByID.TryGetValue(id, out info))
     {
         if (info.Slot == FiestaLib.ItemSlot.Normal)
         {
             foreach (var i in InventoryItems.Values)
             {
                 if (i.ItemID == id && i.Amount < i.Info.MaxLot)
                 {
                     // We found the same item and it can stack more!
                     byte left = (byte)(i.Info.MaxLot - i.Amount);
                     if (left > amount)
                     {
                         i.Amount += left;
                         amount -= left;
                     }
                     else
                     {
                         i.Amount += amount;
                         amount = 0;
                     }
                     Handler12.ModifyInventorySlot(this, 0x24, (byte)i.Slot, (byte)i.Slot, i);
                     if (amount == 0)
                     {
                         break;
                     }
                 }
             }
             // If we have still some stuff left, go ahead and create new stacks!
             if (amount > 0)
             {
                 while (amount > 0)
                 {
                     sbyte invslot;
                     if (GetFreeInventorySlot(out invslot))
                     {
                         DatabaseItem item = new DatabaseItem();
                         item.Amount = amount;
                         item.Character = character;
                         item.ObjectID = info.ItemID;
                         item.Slot = invslot;
                         Program.Entity.AddToDatabaseItems(item);
                         Item nitem = new Item(item);
                         InventoryItems.Add(invslot, nitem);
                         Handler12.ModifyInventorySlot(this, 0x24, (byte)invslot, (byte)invslot, nitem);
                         amount -= info.MaxLot;
                     }
                     else return InventoryStatus.FULL;
                 }
             }
             Save();
             return InventoryStatus.ADDED;
         }
         else
         {
             sbyte invslot;
             if (GetFreeInventorySlot(out invslot))
             {
                 DatabaseEquip equip = new DatabaseEquip();
                 equip.Character = character;
                 equip.EquipID = info.ItemID;
                 equip.Slot = invslot;
                 Program.Entity.AddToDatabaseEquips(equip);
                 Equip nequip = new Equip(equip);
                 InventoryItems.Add(invslot, nequip);
                 Save();
                 Handler12.ModifyInventorySlot(this, 0x24, (byte)invslot, (byte)invslot, nequip);
                 return InventoryStatus.ADDED;
             }
             else return InventoryStatus.FULL;
         }
     }
     else return InventoryStatus.NOT_FOUND;
 }