Esempio n. 1
0
        public void Buff(MobStatus buff, short value, MobSkill skill)
        {
            using (Packet outPacket = new Packet(MapleServerOperationCode.ApplyMonsterStatus))
            {
                outPacket.WriteInt(this.ObjectID);
                outPacket.WriteInt((int)buff);
                outPacket.WriteShort(value);
                outPacket.WriteShort(skill.MapleID);
                outPacket.WriteShort(skill.Level);
                outPacket.WriteShort();
                outPacket.WriteShort(0); // Delay
                outPacket.WriteByte(1);

                this.Map.Broadcast(outPacket);
            }

            Delay.Execute(skill.Duration * 1000, () =>
            {
                using (Packet outPacket = new Packet(MapleServerOperationCode.CancelMonsterStatus))
                {
                    outPacket.WriteInt(this.ObjectID);
                    outPacket.WriteInt((int)buff);
                    outPacket.WriteShort(value);
                    outPacket.WriteByte(1);

                    this.Map.Broadcast(outPacket);
                }

                this.Buffs.Remove(buff);
            });
        }
Esempio n. 2
0
        public Buff(CharacterBuffs parent, dynamic buffDatum)
        {
            this.Parent           = parent;
            this.MapleID          = buffDatum.MapleID;
            this.SkillLevel       = buffDatum.SkillLevel;
            this.Type             = buffDatum.Type;
            this.Value            = buffDatum.Value;
            this.End              = buffDatum.End;
            this.PrimaryStatups   = new Dictionary <PrimaryBuffStat, short>();
            this.SecondaryStatups = new Dictionary <SecondaryBuffStat, short>();

            if (this.Type == 1)
            {
                this.CalculateStatups(ChannelData.CachedSkills[this.MapleID][this.SkillLevel]);
            }

            Delay.Execute((this.End - DateTime.Now).TotalMilliseconds, () => this.Parent.Remove(this));
        }
Esempio n. 3
0
        public Buff(CharacterBuffs parent, Skill skill, int value)
        {
            this.Parent           = parent;
            this.MapleID          = skill.MapleID;
            this.SkillLevel       = skill.CurrentLevel;
            this.Type             = 1;
            this.Value            = value;
            this.End              = DateTime.Now.AddSeconds(skill.BuffTime);
            this.PrimaryStatups   = new Dictionary <PrimaryBuffStat, short>();
            this.SecondaryStatups = new Dictionary <SecondaryBuffStat, short>();

            this.CalculateStatups(skill);

            Delay.Execute((this.End - DateTime.Now).TotalMilliseconds, () => { if (this.Parent.Contains(this))
                                                                               {
                                                                                   this.Parent.Remove(this);
                                                                               }
                          });
        }
Esempio n. 4
0
        public Buff(CharacterBuffs parent, Skill skill, int value)
        {
            Parent           = parent;
            MapleID          = skill.MapleID;
            SkillLevel       = skill.CurrentLevel;
            Type             = 1;
            Value            = value;
            End              = DateTime.Now.AddSeconds(skill.BuffTime);
            PrimaryStatups   = new Dictionary <CharacterConstants.PrimaryBuffStat, short>();
            SecondaryStatups = new Dictionary <CharacterConstants.SecondaryBuffStat, short>();

            CalculateStatups(skill);

            Delay.Execute(() =>
            {
                if (Parent.Contains(this))
                {
                    Parent.RemoveBuff(this);
                }
            }, (int)(End - DateTime.Now).TotalMilliseconds);
        }
Esempio n. 5
0
        protected override void RemoveItem(int index)
        {
            lock (this)
            {
                Reactor item = base.Items[index];

                if (DataProvider.IsInitialized)
                {
                    using (Packet oPacket = item.GetDestroyPacket())
                    {
                        this.Map.Broadcast(oPacket);
                    }
                }

                base.RemoveItem(index);

                if (item.SpawnPoint != null)
                {
                    Delay.Execute(() => item.SpawnPoint.Spawn(), (item.SpawnPoint.RespawnTime <= 0 ? 30 : item.SpawnPoint.RespawnTime) * 100);
                }
            }
        }
Esempio n. 6
0
        public Buff(CharacterBuffs parent, Datum datum)
        {
            Parent           = parent;
            MapleID          = (int)datum["MapleID"];
            SkillLevel       = (byte)datum["SkillLevel"];
            Type             = (byte)datum["Type"];
            Value            = (int)datum["Value"];
            End              = (DateTime)datum["End"];
            PrimaryStatups   = new Dictionary <CharacterConstants.PrimaryBuffStat, short>();
            SecondaryStatups = new Dictionary <CharacterConstants.SecondaryBuffStat, short>();

            if (Type == 1)
            {
                CalculateStatups(DataProvider.Skills[MapleID][SkillLevel]);
            }

            Delay.Execute(() =>
            {
                if (Parent.Contains(this))
                {
                    Parent.RemoveBuff(this);
                }
            }, (int)(End - DateTime.Now).TotalMilliseconds);
        }
Esempio n. 7
0
        public void Buff(MobStatus buff, short value, MobSkill skill)
        {
            using (Packet oPacket = new Packet(ServerOperationCode.MobStatSet))
            {
                oPacket
                .WriteInt(this.ObjectID)
                .WriteLong()
                .WriteInt()
                .WriteInt((int)buff)
                .WriteShort(value)
                .WriteShort(skill.MapleID)
                .WriteShort(skill.Level)
                .WriteShort(-1)
                .WriteShort(0)     // Delay
                .WriteInt();

                this.Map.Broadcast(oPacket);
            }

            Delay.Execute(() =>
            {
                using (Packet Packet = new Packet(ServerOperationCode.MobStatReset))
                {
                    Packet
                    .WriteInt(this.ObjectID)
                    .WriteLong()
                    .WriteInt()
                    .WriteInt((int)buff)
                    .WriteInt();

                    this.Map.Broadcast(Packet);
                }

                this.Buffs.Remove(buff);
            }, skill.Duration * 1000);
        }
Esempio n. 8
0
        public Buff(CharacterBuffs parent, Datum datum)
        {
            this.Parent           = parent;
            this.MapleID          = (int)datum["MapleID"];
            this.SkillLevel       = (byte)datum["SkillLevel"];
            this.Type             = (byte)datum["Type"];
            this.Value            = (int)datum["Value"];
            this.End              = (DateTime)datum["End"];
            this.PrimaryStatups   = new Dictionary <PrimaryBuffStat, short>();
            this.SecondaryStatups = new Dictionary <SecondaryBuffStat, short>();

            if (this.Type == 1)
            {
                this.CalculateStatups(DataProvider.Skills[this.MapleID][this.SkillLevel]);
            }

            Delay.Execute(() =>
            {
                if (this.Parent.Contains(this))
                {
                    this.Parent.Remove(this);
                }
            }, (int)(this.End - DateTime.Now).TotalMilliseconds);
        }
Esempio n. 9
0
        public void Buff(MobConstants.MobStatus buff, short value, Skill skill)
        {
            using (Packet oPacket = new Packet(ServerOperationCode.MobStatSet))
            {
                oPacket
                .WriteInt(ObjectID)
                .WriteLong()
                .WriteInt()
                .WriteInt((int)buff)
                .WriteShort(value)
                .WriteShort((short)skill.MapleID)
                .WriteShort(skill.CurrentLevel)
                .WriteShort(-1)
                .WriteShort(0)     // Delay
                .WriteInt();

                Map.Broadcast(oPacket);
            }

            Delay.Execute(() =>
            {
                using (Packet Packet = new Packet(ServerOperationCode.MobStatReset))
                {
                    Packet
                    .WriteInt(ObjectID)
                    .WriteLong()
                    .WriteInt()
                    .WriteInt((int)buff)
                    .WriteInt();

                    Map.Broadcast(Packet);
                }

                Buffs.Remove(buff);
            }, skill.BuffTime * 1000);
        }
Esempio n. 10
0
        protected override void RemoveItem(int index) // NOTE: Equivalent of mob death.
        {
            Mob item = base.Items[index];

            int       mostDamage = 0;
            Character owner      = null;

            foreach (KeyValuePair <Character, uint> attacker in item.Attackers)
            {
                if (attacker.Key.Map == this.Map)
                {
                    if (attacker.Value > mostDamage)
                    {
                        owner = attacker.Key;
                    }
                    //TODO: more conditioning, exps buffs, exps debuffs
                    attacker.Key.Experience += (int)Math.Min(item.Experience, (attacker.Value * item.Experience) / item.MaxHealth) * WvsGame.ExperienceRate;
                    int    expGained         = (int)item.Experience * WvsGame.ExperienceRate;
                    Packet ExpGainOnMobDeath = Experience.GetShowExpGainPacket(true, expGained, false, 0, 0);
                    owner.Client.Send(ExpGainOnMobDeath);
                }
            }

            item.Attackers.Clear();

            if (item.CanDrop)
            {
                List <Drop> drops = new List <Drop>();

                foreach (Loot loopLoot in item.Loots)
                {
                    if ((Application.Random.Next(1000000) / WvsGame.DropRate) <= loopLoot.Chance)
                    {
                        if (loopLoot.IsMeso)
                        {
                            drops.Add(new Meso((short)(Application.Random.Next(loopLoot.MinimumQuantity, loopLoot.MaximumQuantity) * WvsGame.MesoRate))
                            {
                                Dropper = item,
                                Owner   = owner
                            });
                        }
                        else
                        {
                            drops.Add(new Item(loopLoot.MapleID, (short)Application.Random.Next(loopLoot.MinimumQuantity, loopLoot.MaximumQuantity))
                            {
                                Dropper = item,
                                Owner   = owner
                            });
                        }
                    }
                }

                foreach (Drop loopDrop in drops)
                {
                    // TODO: Space out drops.

                    this.Map.Drops.Add(loopDrop);
                }
            }

            if (owner != null)
            {
                foreach (KeyValuePair <ushort, Dictionary <int, short> > loopStarted in owner.Quests.Started)
                {
                    if (loopStarted.Value.ContainsKey(item.MapleID))
                    {
                        if (loopStarted.Value[item.MapleID] < DataProvider.Quests[loopStarted.Key].PostRequiredKills[item.MapleID])
                        {
                            loopStarted.Value[item.MapleID]++;

                            using (Packet oPacket = new Packet(ServerOperationCode.Message))
                            {
                                oPacket
                                .WriteByte((byte)MessageType.QuestRecord)
                                .WriteUShort(loopStarted.Key)
                                .WriteByte(1);

                                string kills = string.Empty;

                                foreach (int kill in loopStarted.Value.Values)
                                {
                                    kills += kill.ToString().PadLeft(3, '0');
                                }

                                oPacket
                                .WriteString(kills)
                                .WriteInt()
                                .WriteInt();

                                owner.Client.Send(oPacket);

                                if (owner.Quests.CanComplete(loopStarted.Key, true))
                                {
                                    owner.Quests.NotifyComplete(loopStarted.Key);
                                }
                            }
                        }
                    }
                }
            }

            if (DataProvider.IsInitialized)
            {
                item.Controller.ControlledMobs.Remove(item);

                using (Packet oPacket = item.GetDestroyPacket())
                {
                    this.Map.Broadcast(oPacket);
                }
            }

            base.RemoveItem(index);

            if (item.SpawnPoint != null)
            {
                Delay.Execute(() => item.SpawnPoint.Spawn(), 3 * 1000); // TODO: Actual respawn time.
            }

            foreach (int summonID in item.DeathSummons)
            {
                this.Map.Mobs.Add(new Mob(summonID)
                {
                    Position = item.Position // TODO: Set owner as well.
                });
            }
        }
Esempio n. 11
0
 public void Register(Action method, int delay)
 {
     Delay.Execute(delay, () => {
         method();
     });
 }
Esempio n. 12
0
        public void ControlMonster(Client gc, int j)
        {
            if (this.IsControling == true)
            {
                return;
            }

            var chr = gc.Character;

            this.IsControling = true;

            Delay tmr = null;

            tmr = new Delay(1000, true, () =>
            {
                if (this.GetMapCharactersTotal() < 1)
                {
                    tmr.Cancel();
                    this.IsControling = false;
                    return;
                }

                for (int i = 0; i < j; i++)
                {
                    if (this.Monster[i].State == 3 || this.Monster[i].State == 7 || this.Monster[i].State == 9 ||
                        this.Monster[i].MoveType == 3)
                    {
                        continue;
                    }

                    int Direction = this.Monster[i].Direction;

                    Monster Monster = UpdatePosition(this.Monster[i], (int)(40 * this.Monster[i].Speed));

                    foreach (Character All in this.Characters)
                    {
                        if (this.Monster[i].State != 9 && Direction != Monster.Direction && All.MapX == this.MapX &&
                            All.MapY == this.MapY)
                        {
                            MonsterPacket.spawnMonster(All.Client, this.Monster[i], 0, 0, 0, 0);
                        }
                    }
                }
            });
            tmr.Execute();

            Delay tmr2 = null;

            tmr2 = new Delay(20000, true, () =>
            {
                if (this.GetMapCharactersTotal() < 1)
                {
                    tmr2.Cancel();
                    this.IsControling = false;
                    return;
                }

                for (int i = 0; i < j; i++)
                {
                    if (this.Monster[i].IsAlive == false)
                    {
                        this.Monster[i].HP      = MobFactory.MonsterMaxHP(this.Monster[i].Level);
                        this.Monster[i].IsAlive = true;
                        this.Monster[i].State   = (this.Monster[i].MoveType == 0 ? (byte)0 : (byte)1);
                        foreach (Character All in this.Characters)
                        {
                            if (All.MapX == this.MapX && All.MapY == this.MapY)
                            {
                                MonsterPacket.regenrMonster(All.Client, this.Monster[i]);
                                MonsterPacket.spawnMonster(All.Client, this.Monster[i], 0, 0, 0, 0);
                            }
                        }
                    }
                }
            });
            tmr2.Execute();
        }
Esempio n. 13
0
 public void LateUpdate()
 {
     d.Execute();
 }
Esempio n. 14
0
        protected override void RemoveItem(int index) // NOTE: Equivalent of reactor death.
        {
            lock (this)
            {
                Reactor item = this.GetAtIndex(index);
                item.Act(item.LastAttacker);

                List <Drop> drops = new List <Drop>();

                foreach (Loot loopLoot in item.Loots)
                {
                    if (item.LastAttacker != null)
                    {
                        if (Application.Random.Next(251) / ChannelServer.DropRate >= loopLoot.Chance) //TODO: is this the right formula?
                        {
                            if (loopLoot.QuestID == -1 || item.LastAttacker.Quests.Started.ContainsKey((ushort)loopLoot.QuestID))
                            {
                                drops.Add(new Item(loopLoot.MapleID)
                                {
                                    Dropper = item,
                                    Owner   = item.LastAttacker
                                });
                            }
                        }
                    }
                }

                foreach (Loot loopLoot in item.MesoLoots)
                {
                    if (Application.Random.Next(101) <= loopLoot.Chance)
                    {
                        drops.Add(new Meso(Application.Random.Next(loopLoot.MinimumQuantity, loopLoot.MaximumQuantity + 1) * ChannelServer.MesoRate)
                        {
                            Dropper = item,
                            Owner   = item.LastAttacker
                        });
                    }
                }

                item.MesoLoots.Clear();

                Point dropPosition = new Point(item.Position.X, item.Position.Y);
                dropPosition.X -= (short)(12 * drops.Count);

                foreach (Drop loopDrop in drops)
                {
                    loopDrop.Position   = new Point(dropPosition.X, dropPosition.Y);
                    loopDrop.Position.Y = loopDrop.Owner.Position.Y; // the position of the reactor is wierd
                    dropPosition.X     += 25;

                    this.Map.Drops.Add(loopDrop);
                }

                if (ChannelData.IsInitialized)
                {
                    using (Packet destroy = item.GetDestroyPacket())
                    {
                        item.Map.Broadcast(destroy);
                    }
                }

                base.RemoveItem(index);

                if (item.SpawnPoint != null)
                {
                    Delay.Execute((item.SpawnPoint.RespawnTime <= 0 ? 30 : item.SpawnPoint.RespawnTime) * 100, () => item.SpawnPoint.Spawn(this.Map));
                }
            }
        }
Esempio n. 15
0
        protected override void RemoveItem(int index) // NOTE: Equivalent of mob death.
        {
            lock (this)
            {
                Mob item = this.GetAtIndex(index);

                int       mostDamage = 0;
                Character owner      = null;

                foreach (KeyValuePair <Character, uint> attacker in item.Attackers)
                {
                    if (attacker.Key.IsAlive && attacker.Key.Client.IsAlive && attacker.Key.Map == this.Map)
                    {
                        if (attacker.Value > mostDamage)
                        {
                            owner = attacker.Key;
                        }

                        attacker.Key.GainExperience((int)Math.Min(item.Experience, (attacker.Value * item.Experience) / item.MaxHP));
                    }
                }

                item.Attackers.Clear();

                if (item.CanDrop)
                {
                    List <Drop> drops = new List <Drop>();

                    foreach (Loot loopLoot in item.Loots)
                    {
                        if ((Application.Random.Next(1000000) / ChannelServer.DropRate) <= loopLoot.Chance)
                        {
                            drops.Add(new Item(loopLoot.MapleID, (short)Application.Random.Next(loopLoot.MinimumQuantity, loopLoot.MaximumQuantity))
                            {
                                Dropper = item,
                                Owner   = owner
                            });
                        }
                    }

                    Point dropPosition = new Point(item.Position.X, item.Position.Y);
                    dropPosition.X -= (short)(12 * drops.Count);

                    foreach (Drop loopDrop in drops)
                    {
                        loopDrop.Position = new Point(dropPosition.X, dropPosition.Y);
                        dropPosition.X   += 25;

                        this.Map.Drops.Add(loopDrop);
                    }
                }

                if (owner != null)
                {
                    foreach (KeyValuePair <ushort, Dictionary <int, short> > loopStartedQuest in owner.Quests.Started)
                    {
                        if (loopStartedQuest.Value.ContainsKey(item.MapleID))
                        {
                            if (loopStartedQuest.Value[item.MapleID] < ChannelData.Quests[loopStartedQuest.Key].PostRequiredKills[item.MapleID])
                            {
                                loopStartedQuest.Value[item.MapleID]++;

                                using (Packet outPacket = new Packet(MapleServerOperationCode.ShowLog))
                                {
                                    outPacket.WriteByte(1);
                                    outPacket.WriteUShort(loopStartedQuest.Key);
                                    outPacket.WriteByte(1);

                                    string kills = string.Empty;

                                    foreach (int kill in loopStartedQuest.Value.Values)
                                    {
                                        kills += kill.ToString().PadLeft(3, '0');
                                    }

                                    outPacket.WriteString(kills);
                                    outPacket.WriteInt();
                                    outPacket.WriteInt();

                                    owner.Client.Send(outPacket);
                                }

                                if (owner.Quests.CanComplete(loopStartedQuest.Key, true))
                                {
                                    owner.Quests.NotifyComplete(loopStartedQuest.Key);
                                }
                            }
                        }
                    }
                }

                if (ChannelData.IsInitialized)
                {
                    item.Controller.ControlledMobs.Remove(item);

                    using (Packet destroy = item.GetDestroyPacket())
                    {
                        item.Map.Broadcast(destroy);
                    }
                }

                base.RemoveItem(index);

                if (item.SpawnPoint != null && item.CanRespawn)
                {
                    Delay.Execute(3 * 1000, () => item.SpawnPoint.Spawn(this.Map));
                }

                foreach (int summonId in item.DeathSummons)
                {
                    this.Map.Mobs.Add(new Mob(summonId)
                    {
                        Position = item.Position
                    });
                }
            }
        }
Esempio n. 16
0
        public static void Char_Fury_Req(InPacket lea, Client c)
        {
            int Type = lea.ReadInt();

            var chr = c.Character;

            if (Type == 0 || chr.IsFuring == true || chr.Fury != chr.MaxFury)
            {
                return;
            }

            Map Map = MapFactory.GetMap(chr.MapX, chr.MapY);

            if (Type == 1)
            {
                short UpgradeAttack  = (short)(chr.Attack * 0.2);
                short UpgradeMagic   = (short)(chr.Magic * 0.2);
                short UpgradeDefense = (short)(chr.Defense * 0.2);

                chr.IsFuring    = true;
                chr.FuryAttack  = UpgradeAttack;
                chr.FuryMagic   = UpgradeMagic;
                chr.FuryDefense = UpgradeDefense;

                chr.MaxAttack += UpgradeAttack;
                chr.Attack    += UpgradeAttack;
                chr.MaxMagic  += UpgradeMagic;
                chr.Magic     += UpgradeMagic;
                chr.Defense   += UpgradeDefense;

                StatusPacket.getStatusInfo(c);
                foreach (Character All in Map.Characters)
                {
                    StatusPacket.Fury(All.Client, chr, Type);
                }

                chr.Fury       = 0;
                chr.FuringType = 1;

                Delay tmr = null;
                tmr = new Delay(30000, false, () =>
                {
                    chr.IsFuring   = false;
                    chr.MaxAttack -= UpgradeAttack;
                    chr.Attack    -= UpgradeAttack;
                    chr.MaxMagic  -= UpgradeMagic;
                    chr.Magic     -= UpgradeMagic;
                    chr.Defense   -= UpgradeDefense;
                    StatusPacket.getStatusInfo(c);
                    foreach (Character All in Map.Characters)
                    {
                        StatusPacket.Fury(All.Client, chr, 0);
                    }
                });
                tmr.Execute();
            }
            else if (Type == 2)
            {
                Skill Skill = chr.Skills[2, 0];

                if (Skill == null)
                {
                    return;
                }

                int Time = 1;

                switch (Skill.SkillLevel)
                {
                case 1:
                    Time = 30000;
                    break;

                case 2:
                    Time = 32000;
                    break;

                case 3:
                    Time = 34000;
                    break;

                case 4:
                    Time = 36000;
                    break;

                case 5:
                    Time = 38000;
                    break;

                case 6:
                    Time = 40000;
                    break;

                case 7:
                    Time = 42000;
                    break;

                case 8:
                    Time = 44000;
                    break;

                case 9:
                    Time = 46000;
                    break;

                case 10:
                    Time = 48000;
                    break;

                case 11:
                    Time = 50000;
                    break;

                case 12:
                    Time = 52000;
                    break;

                case 13:
                    Time = 53000;
                    break;

                case 14:
                    Time = 54000;
                    break;

                case 15:
                    Time = 55000;
                    break;

                case 16:
                    Time = 56000;
                    break;

                case 17:
                    Time = 57000;
                    break;

                case 18:
                    Time = 58000;
                    break;

                case 19:
                    Time = 59000;
                    break;

                case 20:
                    Time = 60000;
                    break;
                }

                short UpgradeAttack  = (short)(chr.Attack * 0.2 * Skill.SkillLevel);
                short UpgradeMagic   = (short)(chr.Magic * 0.2 * Skill.SkillLevel);
                short UpgradeDefense = (short)(chr.Defense * 0.2 * Skill.SkillLevel);

                chr.IsFuring    = true;
                chr.FuryAttack  = UpgradeAttack;
                chr.FuryMagic   = UpgradeMagic;
                chr.FuryDefense = UpgradeDefense;

                chr.MaxAttack += UpgradeAttack;
                chr.Attack    += UpgradeAttack;
                chr.MaxMagic  += UpgradeMagic;
                chr.Magic     += UpgradeMagic;
                chr.Defense   += UpgradeDefense;

                StatusPacket.getStatusInfo(c);
                foreach (Character All in Map.Characters)
                {
                    StatusPacket.Fury(All.Client, chr, Type);
                }

                chr.Fury       = 0;
                chr.FuringType = 2;

                Delay tmr = null;
                tmr = new Delay(Time, false, () =>
                {
                    chr.IsFuring   = false;
                    chr.MaxAttack -= UpgradeAttack;
                    chr.Attack    -= UpgradeAttack;
                    chr.MaxMagic  -= UpgradeMagic;
                    chr.Magic     -= UpgradeMagic;
                    chr.Defense   -= UpgradeDefense;
                    StatusPacket.getStatusInfo(c);
                    foreach (Character All in Map.Characters)
                    {
                        StatusPacket.Fury(All.Client, chr, 0);
                    }
                });
                tmr.Execute();
            }
        }