Esempio n. 1
0
 public int GetCooldown(string ID, string type, string key)
 {
     if (!Cooldowns.ContainsKey(ID) || !Cooldowns[ID].ContainsKey(type) || !Cooldowns[ID][type].ContainsKey(key))
     {
         return(0);
     }
     return(Cooldowns[ID][type][key]);
 }
Esempio n. 2
0
 public bool TryCooldown(string key, int value)
 {
     if (!Cooldowns.ContainsKey(key) || Cooldowns[key] <= 0)
     {
         Cooldowns.SetOrAdd(key, value);
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
        public CooldownManager(List <Spell> spells)
        {
            Cooldowns = new();

            if (spells != null)
            {
                foreach (Spell spell in spells)
                {
                    if (!Cooldowns.ContainsKey(spell.Name))
                    {
                        Cooldowns.Add(spell.Name, DateTime.UtcNow);
                    }
                }
            }
        }
Esempio n. 4
0
 public void AddCooldown(string ID, string type, string key, int time = 0)
 {
     if (!Cooldowns.ContainsKey(ID))
     {
         Cooldowns.Add(ID, new Dictionary <string, Dictionary <string, int> >());
     }
     if (!Cooldowns[ID].ContainsKey(type))
     {
         Cooldowns[ID].Add(type, new Dictionary <string, int>());
     }
     if (!Cooldowns[ID][type].ContainsKey(key))
     {
         Cooldowns[ID][type].Add(key, time);
     }
     Core.Instance.SvManager.StartCoroutine(StartCooldown(ID, type, key));
 }
Esempio n. 5
0
        public bool UseBuffSpell(StrikingDummy target, Spells spell, bool verbose = false)
        {
            if (GcdDuration <= 0)
            {
                throw new Exception($"Warning! Using off-gcd ability { spell } when GCD is available! Remaining cooldown on { spell }: { Cooldowns[spell]}");
            }

            if (Cooldowns.ContainsKey(spell) || QueuedEffects.ContainsKey(Skills.StatusEffects.AnimationLocked))
            {
                return(false);
            }

            SpellLibrary.QueueEffect(this, spell, target, verbose);
            Cooldowns.Add(spell, SpellLibrary.SpellCooldowns(spell));
            return(true);
        }
Esempio n. 6
0
        public void Move(PacketReader packet)
        {
            var moveAction       = packet.ReadShort();
            var skillByte        = packet.ReadByte();
            var skillId          = packet.ReadByte();
            var projectileTarget = packet.ReadPoint();

            var movements = new Movements(packet);

            Position = movements.Position;
            Foothold = movements.Foothold;
            Stance   = movements.Stance;

            // TODO - Load the mob skill
            MobSkill skill = null;

            if (skill != null)
            {
                if (Health * 100 / MaxHealth > skill.CachedReference.PercentageLimitHp ||
                    Cooldowns.ContainsKey(skill) &&
                    Cooldowns[skill].AddSeconds(skill.CachedReference.Cooldown) >= DateTime.UtcNow ||
                    (MobSkillName)skill.MapleId == MobSkillName.Summon && Map.Mobs.Count >= 100)
                {
                    skill = null;
                }
            }

            skill?.Cast(this);

            using var pwControl = new PacketWriter(ServerOperationCode.MobControlResponse);
            pwControl.WriteInt(ObjectId);
            pwControl.WriteShort(moveAction);
            pwControl.WriteBool(skill != null); // use skills
            pwControl.WriteShort((short)Mana);
            pwControl.WriteShort(0);            // skill id, skill level
            Controller?.Send(pwControl);

            using var pwMove = new PacketWriter(ServerOperationCode.MobMove);
            pwMove.WriteInt(ObjectId);
            pwMove.WriteBool(skill != null); // use skills
            pwMove.WriteInt(skillId);
            pwMove.WriteByte(0);
            pwMove.WriteBytes(movements.ToByteArray());
            Map.Send(pwMove, Controller);
        }
Esempio n. 7
0
        public double UseDamageSpell(StrikingDummy target, Spells spell, bool verbose = false)
        {
            if (GcdDuration <= 0 && spell != Spells.PrePullSuiton)
            {
                var remainingCd = Cooldowns.ContainsKey(spell) ? Cooldowns[spell] : 0;
                throw new Exception($"Warning! Using off-gcd ability { spell } when GCD is available! Remaining cooldown on { spell }: { remainingCd }");
            }

            if (Cooldowns.ContainsKey(spell) || QueuedEffects.ContainsKey(Skills.StatusEffects.AnimationLocked))
            {
                return(0);
            }

            if (spell == Spells.FumaShuriken ||
                spell == Spells.Raiton ||
                spell == Spells.Suiton)
            {
                if (Cooldowns.ContainsKey(Spells.FumaShuriken) ||
                    Cooldowns.ContainsKey(Spells.Raiton) ||
                    Cooldowns.ContainsKey(Spells.Suiton))
                {
                    return(0);
                }
            }

            if (spell == Spells.TrickAttack)
            {
                if (!StatusEffects.ContainsKey(Skills.StatusEffects.Suiton))
                {
                    throw new Exception($"Warning! Cannot use TA without Suiton active!");
                }
                if (verbose)
                {
                    Console.WriteLine("Suiton removed after TA cast!");
                }
                StatusEffects.Remove(Skills.StatusEffects.Suiton);
            }

            var potency    = SpellLibrary.SpellPotencies(spell);
            var multiplier = CalculateMultiplier(target, SpellLibrary.SpellDamageType(spell));
            var damage     = FormulaLibrary.WeaponSkills(potency, Weapon.WeaponDamage, GetDexterity(), Det, multiplier);

            var guaranteeCrit = false;

            if (spell == Spells.FumaShuriken ||
                spell == Spells.Raiton ||
                spell == Spells.Suiton)
            {
                if (StatusEffects.ContainsKey(Skills.StatusEffects.Kassatsu))
                {
                    guaranteeCrit = true;
                    StatusEffects.Remove(Skills.StatusEffects.Kassatsu);
                }
            }

            if (guaranteeCrit)
            {
                damage *= FormulaLibrary.CritDmg(Crt);
            }
            else
            {
                damage = (damage * CalculateCritChance() * FormulaLibrary.CritDmg(Crt)) +
                         (damage * (1 - CalculateCritChance()));
            }

            SpellLibrary.QueueEffect(this, spell, target, verbose);

            if (spell == Spells.FumaShuriken)
            {
                Cooldowns.Add(spell, 500 + SpellLibrary.SpellCooldowns(spell));
            }
            else if (spell == Spells.Raiton)
            {
                Cooldowns.Add(spell, 1000 + SpellLibrary.SpellCooldowns(spell));
            }
            else if (spell == Spells.Suiton)
            {
                Cooldowns.Add(spell, 1500 + SpellLibrary.SpellCooldowns(spell));
            }
            else if (spell == Spells.PrePullSuiton)
            {
                Cooldowns.Add(Spells.Suiton, SpellLibrary.SpellCooldowns(Spells.Suiton));
            }
            else
            {
                Cooldowns.Add(spell, SpellLibrary.SpellCooldowns(spell));
            }

            return(damage);
        }
Esempio n. 8
0
        public void Move(Packet inPacket)
        {
            short moveAction      = inPacket.ReadShort();
            bool  cheatResult     = (inPacket.ReadByte() & 0xF) != 0;
            byte  centerSplit     = inPacket.ReadByte();
            int   illegalVelocity = inPacket.ReadInt();

            inPacket.Skip(8);
            inPacket.ReadByte();
            inPacket.ReadInt();

            Movements movements = Movements.Decode(inPacket);

            Position = movements.Position;
            Foothold = movements.Foothold;
            Stance   = movements.Stance;

            byte     skillID    = 0;
            byte     skillLevel = 0;
            MobSkill skill      = null;

            if (skill != null)
            {
                if (Health * 100 / MaxHealth > skill.PercentageLimitHP ||
                    (Cooldowns.ContainsKey(skill) && Cooldowns[skill].AddSeconds(skill.Cooldown) >= DateTime.Now) ||
                    ((MobConstants.MobSkillName)skill.MapleID) == MobConstants.MobSkillName.Summon && Map.Mobs.Count >= 100)
                {
                    skill = null;
                }
            }

            if (skill != null)
            {
                skill.Cast(this);
            }

            using (Packet oPacket = new Packet(ServerOperationCode.MobCtrlAck))
            {
                oPacket
                .WriteInt(ObjectID)
                .WriteShort(moveAction)     //moveActionID
                .WriteBool(cheatResult)     //UseSkills??
                .WriteShort((short)Mana)
                .WriteByte(skillID)
                .WriteByte(skillLevel);

                Controller.Client.Send(oPacket);
            }

            using (Packet oPacket = new Packet(ServerOperationCode.MobMove))
            {
                oPacket
                .WriteInt(ObjectID)
                .WriteBool(false)
                .WriteBool(cheatResult)     //UseSkills??
                .WriteByte(centerSplit)
                .WriteInt(illegalVelocity)
                .WriteBytes(movements.ToByteArray());

                Map.Broadcast(oPacket, Controller);
            }
        }