الموضوع: مشكلة في الوتر
عرض مشاركة واحدة
قديم 2020-04-05, 03:35 AM
المشاركة 7
ElSaher
.:: مشرف اقسام كونكر ::.
  • غير متواجد
افتراضي رد: مشكلة في الوتر
جرب

كود:
using system;
using mr_panda.network.gamepackets;
using system.runtime.interopservices;
using mr_panda.interfaces;
using system.collections.generic;
using mr_panda;

namespace 
mr_panda.game.attacking
{
    public class 
calculate
    
{
        public static 
uint percent(entity attacked, float percent)
        {
            return (
uint)(attacked.hitpoints * percent);
        }
        public static 
uint percent(sobnpcspawn attacked, float percent)
        {
            return (
uint)(attacked.hitpoints * percent);
        }
        public static 
uint percent(int target, float percent)
        {
            return (
uint)(target * percent);
        }
        public static 
bool ratestatus(byte value)
        {
            return (
kernel.random.next() % 100) < value;
        }
        public static 
bool getrefinery()
        {
            return 
ratestatus(30);
            
//byte val = (byte)myrandom.next(1, 200);
            //return (byte)myrandom.next(1, val) > 90;
        
}
        public static 
ulong calculateexpbonus(ushort level, ushort monsterlevel, ulong experience)
        {
            
int leveldiff = (2 + level - monsterlevel);
            if (
leveldiff < -5)
                
experience = (ulong)(experience * 1.3);
            else if (
leveldiff < -1)
                
experience = (ulong)(experience * 1.2);
            else if (
leveldiff == 4)
                
experience = (ulong)(experience * 0.8);
            else if (
leveldiff == 5)
                
experience = (ulong)(experience * 0.3);
            else if (
leveldiff > 5)
                
experience = (ulong)(experience * 0.1);
            return 
experience;
        }

        
internal static uint calculatebossdamage(entity attacker, entity attacked, ushort spellid)
        {
            
int damage = 0;
            
damage = mymath.getdamagemonster2entity(attacker, attacked, spellid, 0);
            
attack a = new attack(true);
            
checkdamage(attacker, attacked, ref damage, ref a, true);
            return (
uint)damage;
        }

        
internal static uint magic(entity attacker, entity attacked, database.spellinformation spell, ref attack attack, byte p = 0)
        {
            
int damage = 0;

            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, spell.id, spell.level, ref attack);
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, spell.id, spell.level, ref attack);

            
checkdamage(attacker, attacked, ref damage, ref attack, true);
            return (
uint)damage;
        }

        
internal static uint melee(entity attacker, sobnpcspawn attackedsobnpc, ref attack attack)
        {
            return (
uint)mymath.getdamageentity2environment(attacker, attackedsobnpc, (byte)attack.melee, ref attack);
        }

        
internal static uint melee(entity attacker, entity attacked, database.spellinformation spell, ref attack attack, byte p = 0)
        {
            
int damage = 0;
            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, spell.id, spell.level, ref attack);
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, spell.id, spell.level, ref attack);

            
checkdamage(attacker, attacked, ref damage, ref attack, false);
            return (
uint)damage;
        }

        
internal static uint monsterdamage(entity attacker, entity attacked, ref attack attack, bool p)
        {
            
int damage = 0;
            
damage = mymath.getdamagemonster2entity(attacker, attacked, !p ? Attack.melee : Attack.magic);
            
attack a = new attack(true);
            
checkdamage(attacker, attacked, ref damage, ref a, p);
            return (
uint)damage;
        }

        
internal static uint monsterdamage(entity attacker, entity attacked, ushort spellid)
        {
            
int damage = 0;
            
damage = mymath.getdamagemonster2entity(attacker, attacked, spellid, 0);
            
attack a = new attack(true);
            
checkdamage(attacker, attacked, ref damage, ref a, false);
            return (
uint)damage;
        }

        
internal static uint ranged(entity attacker, entity attacked, ref attack attack, byte p = 0)
        {
            
int damage = 0;

            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, attack.ranged, ref attack) / 24;
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, attack.ranged, ref attack) / 24;

            
checkdamage(attacker, attacked, ref damage, ref attack, false);
            return (
uint)damage;
        }

        
internal static uint melee(entity attacker, entity attacked, ref attack attack, byte p = 0)
        {
            
int damage = 0;

            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, attack.melee, ref attack);
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, attack.melee, ref attack);

            
checkdamage(attacker, attacked, ref damage, ref attack, false);
            return (
uint)damage;
        }

        
internal static uint magic(entity attacker, entity attacked, ref attack attack, byte p = 0)
        {
            
int damage = 0;

            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, attack.magic, ref attack);
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, attack.magic, ref attack);

            
checkdamage(attacker, attacked, ref damage, ref attack, false);
            return (
uint)damage;
        }

        
internal static uint ranged(entity attacker, sobnpcspawn attackedsob, ref attack attack)
        {
            return (
uint)mymath.getdamageentity2environment(attacker, attackedsob, attack.ranged, ref attack) / 24;
        }

        
internal static uint magic(entity attacker, sobnpcspawn attackedsob, database.spellinformation spell, ref attack attack)
        {
            return (
uint)mymath.getdamageentity2environment(attacker, attackedsob, spell.id, spell.level, ref attack);
        }

        
internal static uint ranged(entity attacker, entity attacked, database.spellinformation spell, ref attack attack, byte p = 0)
        {
            
int damage = 0;
            if (
attacked.entityflag == entityflag.monster)
                
damage = mymath.getdamageentity2monster(attacker, attacked, spell.id, spell.level, ref attack);
            else
                
damage = mymath.getdamageentity2entity(attacker, attacked, spell.id, spell.level, ref attack);

            
checkdamage(attacker, attacked, ref damage, ref attack, false);
            return (
uint)damage;
        }
        public static 
int calculateskillcstrike(entity attackerclient, entity attackedclient, int damage)
        {
            if (
attackerclient.skillcstrike == attackedclient.immunity)
                return 
damage;
            if (
attackerclient.skillcstrike > attackedclient.immunity)
            {
                
int power = (int)(attackerclient.skillcstrike - attackedclient.immunity);
                
damage = (int)((double)damage * 1.100);
            }
            return 
damage;
        }
        public static 
int calculatecriticalstrike(entity attackerclient, entity attackedclient, int damage)
        {
            if (
attackerclient.criticalstrike == attackedclient.immunity)
                return 
damage;

            if (
attackerclient.criticalstrike > attackedclient.immunity)
            {
                
damage = (int)((double)damage * 1.100);
            }
            return 
damage;
        }
        public static 
int calculatebreaktrough(entity attackerclient, entity attackedclient, int damage)
        {
            if ((
attackerclient.breaktrough == attackedclient.counteraction) || attackerclient.class >= 130 && attackerclient.class <= 135)
                return 
damage;
            if (
attackerclient.breaktrough > attackedclient.counteraction)
            {
                
int power = (int)(attackerclient.breaktrough - attackedclient.counteraction);
                
damage = (int)((double)damage * 0.900);
            }
            return 
damage;
        }
        private static 
void autorespone(entity attacker, entity attacked, ref int damage)
        {
            try
            {
                if (
attacker.entityflag == entityflag.entity)
                {
                    if (
attacker.owner.spells.containskey(11120))
                    {
                        var 
s = attacker.owner.spells[11120];
                        var 
spell = database.spelltable.spellinformations[s.id][s.level];
                        if (
spell != null)
                        {
                            if (
kernel.rate(spell.percent))
                            {
                                var 
ent = attacked as entity;
                                if (!
ent.isblackspotted)
                                {
                                    
ent.isblackspotted = true;
                                    
ent.blackspotstamp = time32.now;
                                    
ent.blackspotstepsecs = spell.duration;
                                    
kernel.blackspoted.tryadd(ent.uid, ent);
                                    
blackspotpacket bsp = new blackspotpacket();
                                    foreach (var 
h in program.gamepool)
                                    {
                                        
h.send(bsp.toarray(true, ent.uid));
                                    }
                                }
                            }
                        }
                    }
                }
                if (
attacked.entityflag == entityflag.entity)
                {
                    if (
attacked.owner.spells.containskey(11130) && attacked.owner.player.iseagleeyeshooted)
                    {
                        var 
s = attacked.owner.spells[11130];
                        var 
spell = database.spelltable.spellinformations[s.id][s.level];
                        if (
spell != null)
                        {
                            if (
kernel.rate(spell.percent))
                            {
                                
attacked.owner.player.iseagleeyeshooted = false;
                                
spelluse ssuse = new spelluse(true);
                                
ssuse.attacker = attacked.uid;
                                
ssuse.spellid = spell.id;
                                
ssuse.spelllevel = spell.level;
                                
ssuse.addtarget(attacked.owner.player, new spelluse.damageclass().damage = 11030, null);
                                if (
attacked.entityflag == entityflag.entity)
                                {
                                    
attacked.owner.sendscreen(ssuse, true);
                                }
                            }
                        }
                    }
                    if (
attacked.counterkillswitch && kernel.rate(30) && !attacker.containsflag((ulong)update.flags.fly) && time32.now > attacked.counterkillstamp.addseconds(15))
                    {
                        
attacked.counterkillstamp = time32.now;
                        
network.gamepackets.attack attack = new mr_panda.network.gamepackets.attack(true);
                        
attack.effect1 = attack.attackeffects1.none;
                        
uint damage = melee(attacked, attacker, ref attack);
                        
damage = damage / 3;
                        
attack.attacked = attacker.uid;
                        
attack.attacker = attacked.uid;
                        
attack.attacktype = network.gamepackets.attack.scapegoat;
                        
attack.damage = 0;
                        
attack.responsedamage = damage;
                        
attack.x = attacked.x;
                        
attack.y = attacked.y;

                        if (
attacker.hitpoints <= damage)
                        {
                            if (
attacker.entityflag == entityflag.entity)
                            {
                                
attacked.owner.updatequalifier(damage);
                                
attacker.owner.sendscreen(attack, true);
                                
attacked.attackpacket = null;
                            }
                            else
                            {
                                
attacker.monsterinfo.sendscreen(attack);
                            }
                            
attacker.die(attacked);
                        }
                        else
                        {
                            
attacker.hitpoints -= damage;
                            if (
attacker.entityflag == entityflag.entity)
                            {
                                
attacked.owner.updatequalifier(damage);
                                
attacker.owner.sendscreen(attack, true);
                            }
                            else
                            {
                                
attacker.monsterinfo.sendscreen(attack);
                            }
                        }
                        
damage = 0;
                    }
                    else if (
attacked.owner.spells.containskey(3060) && kernel.rate(15))
                    {
                        
uint damage = (uint)(damage / 10);
                        if (
damage <= 0)
                            
damage = 1;
                        if (
damage > 10000) damage = 10000;
                        
network.gamepackets.attack attack = new mr_panda.network.gamepackets.attack(true);
                        
attack.attacked = attacker.uid;
                        
attack.attacker = attacked.uid;
                        
attack.attacktype = network.gamepackets.attack.reflect;
                        
attack.damage = damage;
                        
attack.responsedamage = damage;
                        
attack.x = attacked.x;
                        
attack.y = attacked.y;

                        if (
attacker.hitpoints <= damage)
                        {
                            if (
attacker.entityflag == entityflag.entity)
                            {
                                
attacked.owner.updatequalifier(damage);
                                
attacker.owner.sendscreen(attack, true);
                                
attacked.attackpacket = null;
                            }
                            else
                            {
                                
attacker.monsterinfo.sendscreen(attack);
                            }
                            
attacker.die(attacked);
                        }
                        else
                        {
                            
attacker.hitpoints -= damage;
                            if (
attacker.entityflag == entityflag.entity)
                            {
                                
attacked.owner.updatequalifier(damage);
                                
attacker.owner.sendscreen(attack, true);
                            }
                            else
                            {
                                
attacker.monsterinfo.sendscreen(attack);
                            }
                        }
                        
damage = 0;
                    }
                }
            }
            catch (
exception e) { program.saveexception(e); }
        }
        public static 
void checkdamage(entity attacker, entity attacked, ref int damage, ref attack packet, bool magic = false)
        {
            if (
attacked.entityflag == entityflag.monster)
            {
                if (!
attacker.assassin() && !attacker.ischaser1())
                {
                    if (
attacked.monsterinfo.boss || attacked.boss == 1)
                    {
                        if (
magic)
                            
damage = (int)damage * 10;
                        else
                            
damage = (int)damage * 4;
                        return;
                    }
                }
            }
            if (
attacker.entityflag == entityflag.entity)
            {
                
blesseffect.effect(attacker);
                
//gemeffect.effect(attacker);
            
}
            
calculate.autorespone(attacker, attacked, ref damage);
            if (
attacked.containsflag2(network.gamepackets.update.flags2.azureshield))
            {

                if (
damage > attacked.azureshielddefence)
                {
                    
damage -= attacked.azureshielddefence;
                    
createazuredmg(attacked.azureshielddefence, attacker, attacked);
                    
attacked.removeflag2(network.gamepackets.update.flags2.azureshield);
                }
                else
                {
                    
createazuredmg((uint)damage, attacker, attacked);
                    
attacked.azureshielddefence -= (ushort)damage;
                    
attacked.azureshieldpacket();
                    
damage = 1;
                }
            }
            
#region nobility damage
            
if (attacked.entityflag == entityflag.entity && (attacker.battlepower < attacked.battlepower))
            {
                if (
attacked.owner.challenge == null)
                {
                    if (
attacker.entityflag == entityflag.monster) return;
                    
int sub = attacked.battlepower - attacker.battlepower;
                    
//sub *= 2000;//##samak battlepower
                    
if (sub > 41)
                    {
                        if (
attacker.entityflag == entityflag.monster) return;
                        
damage = 1;
                    }
                    else
                    {
//samak
                        
if (attacker.entityflag == entityflag.monster) return;
                        
damage = (int32)math.floor((float)damage * (.75 - (sub * 0.01)));
                    }
                }
            }
            if (
attacked.entityflag == entityflag.entity && (attacker.battlepower > attacked.battlepower))
            {
                if (
attacked.owner.challenge == null)
                {
                    if (
attacker.entityflag == entityflag.monster) return;
                    
int dmg = attacked.battlepower - attacker.battlepower;
                    if (
dmg > 50)
                    {
                        if (
attacker.entityflag == entityflag.monster) return;
                        
damage = damage * 2;
                    }
                    else
                        if (
attacker.entityflag == entityflag.monster) return;
                    
damage = (int32)math.floor((float)damage * (1.10 - (dmg * 0.01)));
                }
            }
            
#endregion
            #region nobility damage
            #region king
            
if (attacker.nobilityrank == conquerstructures.nobilityrank.king)
            {
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.king)
                {
                    
damage = (int)((double)damage * 1.08);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.prince)
                {
                    
damage = (int)((double)damage * 1.18);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.duke)
                {
                    
damage = (int)((double)damage * 1.19);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.earl)
                {
                    
damage = (int)((double)damage * 1.20);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.baron)
                {
                    
damage = (int)((double)damage * 1.21);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.knight)
                {
                    
damage = (int)((double)damage * 1.22);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.serf)
                {
                    
damage = (int)((double)damage * 1.23);
                }
            }
            
#endregion king
            #region prince
            
if (attacker.nobilityrank == conquerstructures.nobilityrank.prince)
            {
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.king)
                {
                    
damage = (int)((double)damage * 1.03);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.prince)
                {
                    
damage = (int)((double)damage * 1.07);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.duke)
                {
                    
damage = (int)((double)damage * 1.19);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.earl)
                {
                    
damage = (int)((double)damage * 1.20);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.baron)
                {
                    
damage = (int)((double)damage * 1.21);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.knight)
                {
                    
damage = (int)((double)damage * 1.22);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.serf)
                {
                    
damage = (int)((double)damage * 1.23);
                }
            }
            
#endregion prince
            #region duke
            
if (attacker.nobilityrank == conquerstructures.nobilityrank.duke)
            {
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.king)
                {
                    
damage = (int)((double)damage * 1.02);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.prince)
                {
                    
damage = (int)((double)damage * 0.99);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.duke)
                {
                    
damage = (int)((double)damage * 1.08);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.earl)
                {
                    
damage = (int)((double)damage * 1.19);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.baron)
                {
                    
damage = (int)((double)damage * 1.20);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.knight)
                {
                    
damage = (int)((double)damage * 1.21);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.serf)
                {
                    
damage = (int)((double)damage * 1.22);
                }
            }
            
#endregion duke
            #region earl
            
if (attacker.nobilityrank == conquerstructures.nobilityrank.earl)
            {
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.king)
                {
                    
damage = (int)((double)damage * 0.91);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.prince)
                {
                    
damage = (int)((double)damage * 0.95);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.duke)
                {
                    
damage = (int)((double)damage * 1);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.earl)
                {
                    
damage = (int)((double)damage * 1.05);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.baron)
                {
                    
damage = (int)((double)damage * 1.19);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.knight)
                {
                    
damage = (int)((double)damage * 1.20);
                }
                if (
attacked.nobilityrank == conquerstructures.nobilityrank.serf)
                {
                    
damage = (int)((double)damage * 1.21);
                }
            }
            
#endregion earl
            #endregion
            #region dragonswing
            
if (kernel.rate(20))//bas kada
            
{
                if (
attacked.containsflag3(update.flags3.dragonswing))
                {
                    
_string str = new _string(true);
                    
str.uid = attacked.uid;
                    
str.textscount = 1;
                    
str.type = _string.effect;
                    
str.texts.add("poisonmiss");
                    if (
attacked.entityflag == entityflag.entity)
                        
attacked.owner.sendscreen(str, true);
                    
damage = 0;
                }
            }
            
#endregion

if (attacked.class <= 135 && attacked.class >=130)
                
damage *= 2;

            if (
attacked.containsflag(network.gamepackets.update.flags.shurikenvortex))
                
damage = 1;
            if (
constants.damage1map.contains(attacked.mapid))
                
damage = 1;
            if (
attacked.messipoints == 1)
                
damage = 1;
            if (
attacker.messipoints == 2)
                
damage = 1000000;
            if (
attacked.messipoints == 2)
                
damage = 1;
            if (
attacker.messipoints == 3)
                
damage = 100000;
        }
        public static 
void createazuredmg(uint dmg, entity attacker, entity attacked)
        {
            
network.gamepackets.attack attac = new attack(true);
            
attac.attacker = attacker.uid;
            
attac.attacked = attacked.uid;
            
attac.x = attacked.x;
            
attac.y = attacked.y;
            
attac.attacktype = 55;
            
attac.damage = dmg;
            
attacked.owner.sendscreen(attac, true);
        }
        public static 
int64 getagilityweapons(entity attacker)
        {
            
double result = 0;
            if (
attacker.transformed)
            {
                
result = attacker.transformationhitrate * 100.0f;
            }
            else
            {
                
int values = 0;
                
int junk = 0;
                for (
uint i = 0; i < 10; i++)
                {
                    if (
i != 5)
                    {
                        
conqueritem item = attacker.owner.equipment.trygetitem(i);
                        
database.conqueriteminformation cii = new database.conqueriteminformation(item.id, item.plus);
                        if (
item.durability != 0)
                            if (
item != null && item.id != 0)
                            {
                                
int now = (cii.baseinformation.agility + attacker.gems[2]) + attacker.gems[2] + values;
                                
values = now + cii.plusinformation.agility;
                                
junk += attacker.gems[2]; //unuse grin emoticon .
                            
}
                    }
                    else
                        continue;
                }
                
result = ((attacker.agility) * ((double)values + 100.0f) * 0.0099999998f * 100.0f);
            }
            return (
int64)result;
        }
        public static 
bool isdodged(entity attacker, entity attacked)
        {
            
int result = 0;
            
double percent = 0;
            if (
attacker != null && attacked != null)
            {
                if (!
attacker.transformed)
                {
                    
result = (attacker.agility >> 1 /* /2 */) - attacked.dodge + 100;
                    if (
attacker.agility != 0)
                    {
                        
percent = (double)((getagilityweapons(attacker) / attacker.agility) - 100.0f) * 0.01f + 1.0f;
                    }
                    else
                    {
                        
percent = 1.0f;
                    }
                    
//todo status hitrate status skill :d
                    
result = (int)(percent * result);
                    if (
attacker.owner.player.isbow())
                    {
                        
result = result * 1;
                    }
                    if (
attacker.owner.player.isshield())
                    {
                        
result = result * 12 / 100;
                    }
                    
result = math.max(10, math.min(90, result));
                    if (
attacker.entityflag == entityflag.entity)
                    {
                        if (
attacked.entityflag == entityflag.monster)
                        {
                            
int antimonsterpercent = attacker.level - attacked.level;
                            if (
antimonsterpercent > 0)
                            {
                                
result += 10 * (antimonsterpercent / 5);
                            }
                            if (
attacker.containsflag(update.flags.cyclone))
                                
result = 100;
                        }
                    }
                }
            }
            else
            {
                return 
true;
            }
            return 
kernel.randget(100) >= result;
        }
        public static 
void immu(entity attacked)
        {
            if (
attacked.entityflag == entityflag.entity)
            {
                
_string str = new _string(true);
                
str.uid = attacked.uid;
                
str.textscount = 1;
                
str.type = _string.effect;
                
str.texts.add("bossimmunity");

                
attacked.owner.sendscreen(str, true);
            }

        }
        public static 
void refinary(entity attacker, entity attacked, ref double damage, ref attack packet, bool magic = false)
        {
            if (
attacker.name == "thundercloud") return;
            if (
attacker.entityflag == entityflag.entity)
            {
                if (!
attacker.istaoist(attacker.class))
                {
                    if (
attacked.battlepower > attacker.battlepower)
                    {
                        if (
attacker.breaktrough > 0)
                        {
                            if (
attacker.breaktrough > attacked.counteraction)
                            {
                                
double power = (double)(attacker.breaktrough - attacked.counteraction);
                                if (
attacker.nobilityrank < conquerstructures.nobilityrank.king)
                                {
                                    
power = (double)(power / 0);
                                    if (
mymath.success2(power))
                                    {
                                        
damage += damage * 0 / 1;
                                        
damage += 15000;
                                        
packet.effect1 |= attack.attackeffects1.break;
                                    }
                                    else 
immu(attacked);
                                }
                                else
                                {
                                    
power = (double)(power / 0);
                                    if (
mymath.success(power))
                                    {
                                        
damage += damage * 0 / 1;
                                        
packet.effect1 |= attack.attackeffects1.break;
                                    }
                                    else 
immu(attacked);
                                }
                            }
                            else
                                
immu(attacked);

                        }
                    }
                    if (
ratestatus(80))
                    {

                        if (!
magic)
                        {
                            if (
attacker.criticalstrike > 0)
                            {
                                if (
attacker.criticalstrike > attacked.immunity)
                                {
                                    
double power = (double)(attacker.criticalstrike - attacked.immunity);
                                    if (
kernel.chancesuccess2(((float)attacker.criticalstrike / 300f) - ((float)attacked.immunity / 300f)))
                                    {
                                        
damage += 15000;
                                        
packet.effect1 |= attack.attackeffects1.criticalstrike;
                                    }

                                    else
                                        
immu(attacked);

                                }
                                else
                                    
immu(attacked);
                            }
                        }
                        else
                        {
                            if (
attacker.penetration > 0)
                            {
                                
double power = (double)(attacker.penetration / 1);
                                if (
mymath.success(power))
                                {
                                    
damage += damage * 0 / 4;
                                    
packet.effect1 |= attack.attackeffects1.penetration;
                                }
                                else if (
attacker.skillcstrike > 0)
                                {
                                    if (
attacker.skillcstrike >= attacked.immunity)
                                    {
                                        
power = (double)(attacker.skillcstrike - attacked.immunity);
                                        
power = (double)(power / 100);
                                        if (
mymath.success(power))
                                        {
                                            
damage += damage * 50 / 100;
                                            
packet.effect1 |= attack.attackeffects1.criticalstrike;
                                        }
                                        else
                                            
immu(attacked);
                                    }

                                }
                                else
                                    
immu(attacked);
                            }
                            else if (
attacker.skillcstrike > 0)
                            {
                                if (
attacker.skillcstrike >= attacked.immunity)
                                {
                                    
double power = (double)(attacker.skillcstrike - attacked.immunity);
                                    
power = (double)(power / 100);
                                    if (
mymath.success(power))
                                    {
                                        
damage += damage * 50 / 100;
                                        
packet.effect1 |= attack.attackeffects1.criticalstrike;
                                    }
                                    else
                                        
immu(attacked);
                                }

                            }
                            else
                                
immu(attacked);
                        }
                    }
                }
            }
            if (
attacked.entityflag == entityflag.entity)
            {
                if (
ratestatus(5))
                {
                    if (
attacked.block > 0)
                    {
                        
double power = (double)(attacked.block / 2);
                        if (
mymath.success(power))
                        {
                            
damage = damage / 2;
                            
packet.effect1 |= attack.attackeffects1.block;
                        }
                    }
                    if (
attacked.isshieldblock)
                    {
                        if (
mymath.success(attacked.shieldblockpercent))
                        {
                            
damage = damage / 2;
                            
packet.effect1 |= attack.attackeffects1.block;
                        }
                    }

                }
            }
        }
        public static 
void refinary(entity attacker, sobnpcspawn attacked, ref double damage, ref attack packet, bool magic = false)
        {
            if (
attacker.entityflag == entityflag.entity)
            {
                if (
ratestatus(10))
                {

                    if (!
magic)
                    {
                        if (
attacker.criticalstrike > 0)
                        {

                            
double power = (double)(attacker.criticalstrike);
                            
power = (double)(power / 100);
                            if (
mymath.success(power))
                            {
                                
damage += damage * 80 / 100;
                                
packet.effect1 |= attack.attackeffects1.criticalstrike;
                            }
                        }
                    }
                    else
                    {
                        if (
attacker.penetration > 0)
                        {
                            
double power = (double)(attacker.penetration / 100);
                            if (
mymath.success(power))
                            {
                                
damage = damage * 50 / 100;
                                
packet.effect1 |= attack.attackeffects1.penetration;
                            }

                        }
                        if (
attacker.skillcstrike > 0)
                        {
                            
double power = (double)(attacker.skillcstrike);
                            
power = (double)(power / 100);
                            if (
mymath.success(power))
                            {
                                
damage += damage * 50 / 100;
                                
packet.effect1 |= attack.attackeffects1.criticalstrike;
                            }
                        }
                    }
                }
            }
        }
    }

}
namespace 
mr_panda
{
    public class 
statusconstants
    
{
        public const 
int adjustset = -30000,
                         
adjustfull = -32768,
                         
adjustpercent = 30000;
    }
    public class 
mathhelper
    
{
        public static 
int bitfold32(int lower16, int higher16)
        {
            return (
lower16) | (higher16 << 16);
        }
        public static 
void bitunfold32(int bits32, out int lower16, out int upper16)
        {
            
lower16 = (int)(bits32 & uint16.maxvalue);
            
upper16 = (int)(bits32 >> 16);
        }
        public static 
void bitunfold64(ulong bits64, out int lower32, out int upper32)
        {
            
lower32 = (int)(bits64 & uint32.maxvalue);
            
upper32 = (int)(bits64 >> 32);
        }
        public static 
int roughdistance(int x1, int y1, int x2, int y2)
        {
            return 
math.max(math.abs(x1 - x2), math.abs(y1 - y2));
        }
        public static 
int conquerdirection(int x1, int y1, int x2, int y2)
        {
            
double angle = math.atan2(y2 - y1, x2 - x1);
            
angle -= math.pi / 2;

            if (
angle < 0) angle += 2 * math.pi;

            
angle *= 8 / (2 * math.pi);
            return (int)
angle;
        }
        public static 
int muldiv(int number, int numerator, int denominator)
        {
            return (
number * numerator + denominator / 2) / denominator;
        }
        public static 
bool overflowadd(ref int acc, int add)
        {
            if (
int.maxvalue - acc < add)
                return 
true;
            
acc = math.max(acc + add, 0);
            return 
false;
        }
        public static 
int adjustdataex(int data, int adjust, int maxdata = 0)
        {
            if (
adjust >= statusconstants.adjustpercent)
                return 
muldiv(data, adjust - statusconstants.adjustpercent, 100);

            if (
adjust <= statusconstants.adjustset)
                return -
1 * adjust + statusconstants.adjustset;

            if (
adjust == statusconstants.adjustfull)
                return 
maxdata;

            return 
data + adjust;
        }
    }
    public class 
gemtypes
    
{
        public const 
int
            phoenix 
= 0,
            
dragon = 1,
            
fury = 2,
            
rainbow = 3,
            
kylin = 4,
            
violet = 5,
            
moon = 6,
            
tortoise = 7,
            
thunder = 10,
            
glory = 12,

            
first = phoenix,
            
last = glory + 1;

        public static 
readonly string[] animation = new string[]
                {
                    
"phoenix",
                    
"goldendragon",
                    
"fastflash",
                    
"rainbow",
                    
"goldenkylin",
                    
"purpleray",
                    
"moon",
                    
"recovery"
                
};

        public static 
readonly int[][] effects = new[]
                {
                    new[] { 
0, 5, 10, 15 },
                    new[] { 
0, 5, 10, 15 },
                    new[] { 
0, 5, 10, 15 },
                    new[] { 
0, 10, 15, 25 },
                    new[] { 
0, 50, 100, 200 },
                    new[] { 
0, 30, 50, 100 },
                    new[] { 
0, 15, 30, 50 },
                    new[] { 
0, 2, 4, 6 },
                    new[] { 
0, 0, 0, 0 },
                    new[] { 
0, 0, 0, 0 },
                    new[] { 
0, 100, 300, 500 },
                    new[] { 
0, 0, 0, 0 },
                    new[] { 
0, 100, 300, 500 }
                };
    }
} 
مش كانت من الكلاس اصلن +انا حليتها