Beispiel #1
0
        public int CalculateTotal(EmbeddedData data, DbChar character, DbClassStats stats, out bool firstBorn)
        {
            double f = 0;

            foreach (var i in bonusDat)
            {
                if (i.Item3(this, character, character.Fame))
                {
                    f += i.Item4(character.Fame);
                }
            }

            //Well Equiped
            var bonus = character.Items.Take(4).Where(x => x != -1).Sum(x => data.Items[(ushort)x].FameBonus) / 100.0;

            f += character.Fame * bonus;

            //First born
            if (character.Fame + bonus > stats.AllKeys.Select(x => stats[ushort.Parse(x)].BestFame).Max())
            {
                bonus    += (int)(character.Fame * 0.1);
                firstBorn = true;
            }
            else
            {
                firstBorn = false;
            }

            return(character.Fame + (int)bonus);
        }
Beispiel #2
0
        public int CalculateTotal(EmbeddedData data, DbChar character, bool firstBorn)
        {
            double f = 0;

            foreach (var i in bonusDat)
            {
                if (i.Item3(this, character, character.Fame))
                {
                    f += i.Item4(character.Fame);
                }
            }

            //Well Equiped
            var bonus = character.Items.Take(4).Where(x => x != -1).Sum(x => data.Items[(ushort)x].FameBonus) / 100.0;

            f += character.Fame * bonus;

            //First born
            if (firstBorn)
            {
                bonus += (int)(character.Fame * 0.1);
            }

            return(character.Fame + (int)bonus);
        }
Beispiel #3
0
        public void Death(EmbeddedData dat, DbAccount acc, DbChar character, FameStats stats, string killer)
        {
            character.Dead = true;
            SaveCharacter(acc, character, acc.LockToken != null);
            bool firstBorn;
            var  finalFame = stats.CalculateTotal(dat, character,
                                                  new DbClassStats(acc), out firstBorn);

            var death = new DbDeath(acc, character.CharId);

            death.ObjectType = character.ObjectType;
            death.Level      = character.Level;
            death.TotalFame  = finalFame;
            death.Killer     = killer;
            death.FirstBorn  = firstBorn;
            death.DeathTime  = DateTime.Now;
            death.Flush();

            var idBuff = BitConverter.GetBytes(character.CharId);

            Sets.Remove(0, $"alive.{acc.AccountId}", idBuff);
            Lists.AddFirst(0, $"dead.{acc.AccountId}", idBuff);

            UpdateFame(acc, finalFame);

            var entry = new DbLegendEntry()
            {
                AccId     = int.Parse(acc.AccountId),
                ChrId     = character.CharId,
                TotalFame = finalFame
            };

            DbLegend.Insert(this, death.DeathTime, entry);
        }
Beispiel #4
0
 internal AutoAssign(EmbeddedData dat)
     : base("autoId")
 {
     this.dat     = dat;
     nextSignedId = GetValue <int>("nextSigned", "50000"); //0xC350
     nextFullId   = GetValue <int>("nextFull", "58000");   //0xE290
 }
Beispiel #5
0
        public void Init(EmbeddedData data)
        {
            ObjectDesc field = null;

            foreach (var i in data.ObjectDescs.Where(_ => _.Value.Player || _.Value.Class == "Player"))
            {
                field = i.Value;
                SetValue(field.ObjectType.ToString(), JsonConvert.SerializeObject(new DbClassAvailabilityEntry()
                {
                    Id         = field.ObjectId,
                    Restricted = field.ObjectType == 782 ? "unrestricted" : "restricted"
                }));
            }
        }
Beispiel #6
0
        public CreateStatus CreateCharacter(EmbeddedData dat, DbAccount acc, ushort type, int skin, out DbChar character)
        {
            var @class = dat.ObjectTypeToElement[type];

            if (Sets.GetLength(0, "alive." + acc.AccountId).Exec() >= acc.MaxCharSlot)
            {
                character = null;
                return(CreateStatus.ReachCharLimit);
            }

            int newId = (int)Hashes.Increment(0, acc.Key, "nextCharId").Exec();

            character = new DbChar(acc, newId)
            {
                ObjectType  = type,
                Level       = 1,
                Experience  = 0,
                Fame        = 0,
                HasBackpack = false,
                Items       = @class.Element("Equipment").Value.Replace("0xa22", "-1").CommaToArray <int>(),
                Stats       = new int[] {
                    int.Parse(@class.Element("MaxHitPoints").Value),
                    int.Parse(@class.Element("MaxMagicPoints").Value),
                    int.Parse(@class.Element("Attack").Value),
                    int.Parse(@class.Element("Defense").Value),
                    int.Parse(@class.Element("Speed").Value),
                    int.Parse(@class.Element("Dexterity").Value),
                    int.Parse(@class.Element("HpRegen").Value),
                    int.Parse(@class.Element("MpRegen").Value),
                },
                HP         = int.Parse(@class.Element("MaxHitPoints").Value),
                MP         = int.Parse(@class.Element("MaxMagicPoints").Value),
                Tex1       = 0,
                Tex2       = 0,
                Skin       = skin,
                Pet        = -1,
                FameStats  = new byte[0],
                CreateTime = DateTime.Now,
                LastSeen   = DateTime.Now
            };
            character.Flush();
            Sets.Add(0, "alive." + acc.AccountId, BitConverter.GetBytes(newId));
            return(CreateStatus.OK);
        }
Beispiel #7
0
        public void ChangeClassAvailability(DbAccount acc, EmbeddedData data, ushort type)
        {
            int price;

            if (acc.Credits < (price = data.ObjectDescs[type].UnlockCost))
            {
                return;
            }

            Hashes.Set(0, $"classAvailability.{acc.AccountId}", type.ToString(),
                       JsonConvert.SerializeObject(new DbClassAvailabilityEntry()
            {
                Id         = data.ObjectTypeToId[type],
                Restricted = "unrestricted"
            }));
            UpdateCredit(acc, -price);
            acc.Flush();
            acc.Reload();
        }
Beispiel #8
0
        public IEnumerable <Tuple <string, string, double> > GetBonuses(EmbeddedData data, DbChar character, bool firstBorn)
        {
            foreach (var i in bonusDat)
            {
                if (i.Item3(this, character, character.Fame))
                {
                    yield return(Tuple.Create(i.Item1, i.Item2, i.Item4(character.Fame)));
                }
            }

            //Well Equiped
            var bonus = character.Items.Take(4).Where(x => x != -1).Sum(x => data.Items[(ushort)x].FameBonus) / 100.0;

            if (bonus > 0)
            {
                yield return(Tuple.Create("Well Equipped", "Bonus for equipment", character.Fame * bonus));
            }

            //First born
            if (firstBorn)
            {
                yield return(Tuple.Create("First Born", "Best fame of any of your previous incarnations", character.Fame * 0.1));
            }
        }