What am I missing?

03/18/2021 07:22 denominator#1
Code:
case 6001:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);
                                            MsgMagicEffect suse = new MsgMagicEffect(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= spell.Distance)
                                            {
                                                foreach (Interfaces.IMapObject _obj in attacker.Owner.Screen.Objects)
                                                {
                                                    if (_obj.MapObjType == MapObjectType.Player || _obj.MapObjType == MapObjectType.Monster)
                                                    {
                                                        attacked = _obj as Player;
                                                        if (attacked.MapObjType == MapObjectType.Monster)
                                                            if (attacked.Name == "TeratoDragon")//SnowBanshee
                                                                continue;
                                                        if (attacked.Name == "SnowBanshee")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "ThrillingSpook")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "SwordMaster")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "LavaBeast")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "Guard1")//SnowBanshee
                                                            continue;
                                                        if (spell.ID == 6001)
                                                        {
                                                            MsgMagicCoat.Process(attacker.Owner, attacked, spell.ID);
                                                        }
                                                        if (Constants.NoVeneno.Contains(attacked.Name))
                                                            continue;
                                                        if (Kernel.GetDistance(X, Y, attacked.X, attacked.Y) <= spell.Range)
                                                        {
                                                            if (CanAttack(attacker, attacked, spell, attack.InteractType == MsgInteract.Melee))
                                                            {
                                                                uint damage = Calculate.Percent(attacked, spell.PowerPercent);
                                                                int potDifference = attacker.BattlePower - attacked.BattlePower;
                                                                int rate = (int)spell.Percent + potDifference - 20;
                                                                if (Kernel.Rate(rate))
                                                                {
                                                                    attacked.Hitpoints -= damage;
                                                                    attacked.ToxicFogStamp = Time32.Now;
                                                                    attacked.ToxicFogLeft = 20;
                                                                    attacked.ToxicFogPercent = spell.PowerPercent;                                                                    
                                                                    attacked.AddFlag((ulong)MsgUpdate.Flags.Poisoned, attacked.ToxicFogLeft, true);                                                                    
                                                                    suse.AddTarget(attacked.UID, damage, null);                                                                   
                                                                }
                                                                else
                                                                {
                                                                    //attacked.Hitpoints -= damage;
                                                                    suse.AddTarget(attacked.UID, 0, null);
                                                                    suse.Targets[attacked.UID].Hit = false;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                            attacker.Owner.SendScreen(suse, true);
                                        }
                                        break;
                                    }
It damages on impact but doesn't continue to damage like it should, originally it didn't even damage but I managed to figure out why.
03/19/2021 13:09 Latyos#2
First of all, this piece of code is terrible. You are processing 6 strcmp for every valid target. At least replace them with monsterID checks, jesus.

And you have a mistake here

Code:
attacked = _obj as Player;
                                                        if (attacked.MapObjType == MapObjectType.Monster)
                                                            if (attacked.Name == "TeratoDragon")//SnowBanshee
                                                                continue;
                                                        if (attacked.Name == "SnowBanshee")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "ThrillingSpook")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "SwordMaster")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "LavaBeast")//SnowBanshee
                                                            continue;
                                                        if (attacked.Name == "Guard1")//SnowBanshee
                                                            continue;
I think you are checking if "attacked" is a monster to check for names but since you are not using curly brackets, it only check for if monster for TeratoDragon and checks for other's no matter what. So technically, I could create a character named "SwordMaster" and I'd be immune to "ToxicFog" :kekw:

To be honest, everything about this piece of code is wrong. But the reason why ToxicFog deals initial damage but doesn't deal more damage is because you are just putting this target flag for "Poisoned" but you are most probably missing logic to process that flag.
03/19/2021 13:26 denominator#3
The code was already in the source. Same as pirate skills that weren't working but I managed to get them working. Thank you for replying :)

I'm assuming this is the logic

Code:
 #region ToxicFog
                if (client.Player.ToxicFogLeft > 0)
                {
                    if (Now >= client.Player.ToxicFogStamp.AddSeconds(2))
                    {
                        float Percent = client.Player.ToxicFogPercent;
                        Percent = Percent / 100 * (client.Player.Detoxication / 100F);
                        //Remove this line if you want it normal
                        Percent = Math.Min(0.1F, client.Player.ToxicFogPercent);
                        client.Player.ToxicFogLeft--;
                        if (client.Player.ToxicFogLeft == 0)
                        {
                            client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Poisoned);
                            return;
                        }
                        client.Player.ToxicFogStamp = Now;
                        if (client.Player.Hitpoints > 1)
                        {
                            uint damage = Game.Attacking.Calculate.Percent(client.Player, Percent);
                            client.Player.Hitpoints -= damage;
                            Network.GamePackets.MsgMagicEffect suse = new Network.GamePackets.MsgMagicEffect(true);
                            suse.Attacker = client.Player.UID;
                            suse.SpellID = 10010;
                            suse.AddTarget(client.Player.UID, damage, null);
                            client.SendScreen(suse, true);
                            if (client != null)
                                client.UpdateQualifier(damage, true);
                        }
                    }
                }
                else
                {
                    if (client.Player.ContainsFlag((ulong)MsgUpdate.Flags.Poisoned))
                        client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Poisoned);
                }
                #endregion
This is in my Thread.cs whilst the original code/post is in Handle.cs

Code:
public enum Flags : ulong
        {
            FlashingName = 0,
            Poisoned = 1,
03/19/2021 13:44 Latyos#4
Quote:
Originally Posted by denominator View Post
The code was already in the source. Same as pirate skills that weren't working but I managed to get them working. Thank you for replying :)

I'm assuming this is the logic

Code:
 #region ToxicFog
                if (client.Player.ToxicFogLeft > 0)
                {
                    if (Now >= client.Player.ToxicFogStamp.AddSeconds(2))
                    {
                        float Percent = client.Player.ToxicFogPercent;
                        Percent = Percent / 100 * (client.Player.Detoxication / 100F);
                        //Remove this line if you want it normal
                        Percent = Math.Min(0.1F, client.Player.ToxicFogPercent);
                        client.Player.ToxicFogLeft--;
                        if (client.Player.ToxicFogLeft == 0)
                        {
                            client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Poisoned);
                            return;
                        }
                        client.Player.ToxicFogStamp = Now;
                        if (client.Player.Hitpoints > 1)
                        {
                            uint damage = Game.Attacking.Calculate.Percent(client.Player, Percent);
                            client.Player.Hitpoints -= damage;
                            Network.GamePackets.MsgMagicEffect suse = new Network.GamePackets.MsgMagicEffect(true);
                            suse.Attacker = client.Player.UID;
                            suse.SpellID = 10010;
                            suse.AddTarget(client.Player.UID, damage, null);
                            client.SendScreen(suse, true);
                            if (client != null)
                                client.UpdateQualifier(damage, true);
                        }
                    }
                }
                else
                {
                    if (client.Player.ContainsFlag((ulong)MsgUpdate.Flags.Poisoned))
                        client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Poisoned);
                }
                #endregion


If that source is filled with that kind of code, I think you better drop it before you put much work in it. If I could find such an exploit in less than 100 LoC, I don't even want to imagine rest of the source.

Seems like it
03/19/2021 14:03 denominator#5
It's a COServer source, also it's for personal use :)

Better logic? Regardless it still doesn't work lmao
Code:
if (client.Player.ToxicFogLeft > 0)
                {
                    if (Now >= client.Player.ToxicFogStamp.AddSeconds(2))
                    {
                        float Percent = client.Player.ToxicFogPercent;
                        if (client.Player.Detoxication != 0)
                        {
                            float immu = 1 - client.Player.Detoxication / 100F;
                            Percent = Percent * immu;
                        }
                        client.Player.ToxicFogLeft--;
                        if (client.Player.ToxicFogLeft == 0)
                        {
                            client.Player.RemoveFlag((ulong)(MsgUpdate.Flags.Poisoned));
                            return;
                        }
                        client.Player.ToxicFogStamp = Now;
                        if (client.Player.Hitpoints > 1)
                        {
                            uint damage = Game.Attacking.Calculate.Percent(client.Player, Percent);
                            if (client.Player.ContainsFlag((ulong)(Network.GamePackets.MsgUpdate.Flags.AzureShield)))
                            {

                                if (damage > client.Player.AzureShieldDefence)
                                {
                                    damage -= client.Player.AzureShieldDefence;
                                    Game.Attacking.Calculate.CreateAzureDmg(client.Player.AzureShieldDefence, client.Player, client.Player);
                                    client.Player.RemoveFlag((ulong)(Network.GamePackets.MsgUpdate.Flags.AzureShield));
                                }
                                else
                                {
                                    Game.Attacking.Calculate.CreateAzureDmg((uint)damage, client.Player, client.Player);
                                    client.Player.AzureShieldDefence -= (ushort)damage;
                                    client.Player.AzureShieldPacket();
                                    damage = 1;
                                }
                            }
                            else
                                client.Player.Hitpoints -= damage;

                            Network.GamePackets.MsgMagicEffect suse = new Network.GamePackets.MsgMagicEffect(true);
                            suse.Attacker = client.Player.UID;
                            suse.SpellID = 10010;
                            suse.AddTarget(client.Player.UID, damage, null);
                            client.SendScreen(suse, true);
                            if (client != null)
                                client.UpdateQualifier(damage, true);

                        }
                    }
                }
                else
                {
                    if (client.Player.ContainsFlag((ulong)MsgUpdate.Flags.Poisoned))
                        client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Poisoned);
                }
Doh if only I had tested it pvp instead of just pvm fml, it works I guess I have overworked my brain over the past few days, therefore my question should have been why isn't it attacking monsters