|
المشاركات 539 |
+التقييم 0.27 |
تاريخ التسجيل May 2019 |
الاقامة |
نظام التشغيل |
رقم العضوية 188 |
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 }
};
}
}
using System;
using System.Linq;
using System.Collections.Generic;
using Mr_Panda.Network.GamePackets;
using System.IO;
namespace Mr_Panda.Game.ConquerStructures
{
public class Nobility : Mr_Panda.Network.Writer
{
public static ulong MaxDonation = 0;
public static ulong MaxDonation1 = 0;
public static ulong MaxDonation2 = 0;
public static SafeDictionary<uint, NobilityInformation> Board = new SafeDictionary<uint, NobilityInformation>(10000);
public static List<NobilityInformation> BoardList = new List<NobilityInformation>(10000);
public static void Handle(NobilityInfo information, Client.GameState client)
{
if (information.Type == NobilityInfo.Donate)
return;
switch (information.Type)
{
case NobilityInfo.Donate:
{
if (client.Trade.InTrade)
return;
if (client.Player.DonateTime)
return;
ulong silvers = information.dwParam;
bool newDonator = false;
client.NobilityInformation.Gender = (byte)(client.Player.Body % 10);
if (client.NobilityInformation.Donation == 0)
newDonator = true;
if (information.MoneyType == 1)
{
ulong cps = silvers / 50000;
if (client.Player.ConquerPoints >= 10000)
{
client.Player.ConquerPoints -= 10000;
client.NobilityInformation.Donation += silvers;
}
}
else
{
if (client.Player.Money >= silvers)
{
client.Player.Money -= (uint)silvers;
client.NobilityInformation.Donation += silvers;
}
}
if (!Board.ContainsKey(client.Player.UID) && client.NobilityInformation.Donation == silvers && newDonator)
{
Board.Add(client.Player.UID, client.NobilityInformation);
try
{
Database.NobilityTable.InsertNobilityInformation(client.NobilityInformation);
}
catch
{
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
}
}
else
{
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
}
Sort(client.Player.UID);
break;
}
case NobilityInfo.List:
{
byte[] packet = new byte[600 + 8];
Network.Writer.WriteUInt16(600, 0, packet);
Network.Writer.WriteUInt16(2064, 2, packet);
Network.Writer.WriteUInt16(2, 4, packet);
Network.Writer.WriteUInt16(5, 10, packet);
Network.Writer.WriteUInt16(20, 12, packet);
int offset = 120;
for (int i = (int)(information.wParam1 * 10); i < information.wParam1 * 10 + 10 && i < BoardList.Count; i++)
{
var nob = BoardList[i];
Network.Writer.WriteUInt32(nob.EntityUID, offset, packet);
offset += 4;
if (Kernel.GamePool.ContainsKey(nob.EntityUID))
{
Network.Writer.WriteUInt32(1, offset, packet);
offset += 4;
Network.Writer.WriteUInt32(nob.Mesh, offset, packet);
offset += 4;
}
else
{
offset += 8;
}
Network.Writer.WriteString(nob.Name, offset, packet);
offset += 20;
Network.Writer.WriteUInt64(nob.Donation, offset, packet);
offset += 8;
Network.Writer.WriteUInt32((uint)nob.Rank, offset, packet);
offset += 4;
Network.Writer.WriteUInt32((uint)i, offset, packet);
offset += 4;
}
client.Send(packet);
break;
}
}
}
public static void Donate(ulong silvers, Client.GameState client, bool Npc = false)
{
if (Npc == false)
return;
bool newDonator = false;
client.NobilityInformation.Gender = (byte)(client.Player.Body % 10);
if (client.NobilityInformation.Donation == 0)
newDonator = true;
client.NobilityInformation.Donation += silvers;
if (!Board.ContainsKey(client.Player.UID) && client.NobilityInformation.Donation == silvers && newDonator)
{
Board.Add(client.Player.UID, client.NobilityInformation);
try
{
Database.NobilityTable.InsertNobilityInformation(client.NobilityInformation);
}
catch
{
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
}
}
else
{
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
}
Sort(client.Player.UID);
}
public static void Sort(uint updateUID)
{
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>();
int Place = 0;
foreach (NobilityInformation entry in Board.Values.OrderByDescending((p) => p.Donation))
{
Client.GameState client = null;
try
{
int previousPlace = entry.Position;
entry.Position = Place;
NobilityRank Rank = NobilityRank.Serf;
if (Place >= 10000)
{
if (entry.Donation >= 200000)
{
Rank = NobilityRank.Earl;
}
else if (entry.Donation >= 100000)
{
Rank = NobilityRank.Baron;
}
else if (entry.Donation >= 300000)
{
Rank = NobilityRank.Knight;
}
}
else
{
if (Place < 99999999)
{
Rank = NobilityRank.King;
if (Place < (99999999))
{
MaxDonation = entry.Donation;
}
}
else if (Place < 20)
{
Rank = NobilityRank.Prince;
if (Place < 20)
{
MaxDonation1 = entry.Donation;
}
}
else
{
if (Place < 9999)
{
}
Rank = NobilityRank.Duke;
if (Place < (9999))
{
MaxDonation2 = entry.Donation;
}
}
}
var oldRank = entry.Rank;
entry.Rank = Rank;
if (Kernel.GamePool.TryGetValue(entry.EntityUID, out client))
{
bool updateTheClient = false;
if (oldRank != Rank)
{
updateTheClient = true;
if (Rank == NobilityRank.Baron)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has the Baron In Pharaohs-Eu ", System.Drawing.Color.White, Message.TopLeft), Program.Values);
}
if (Rank == NobilityRank.Earl)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has the Earl In Pharaohs-Eu ", System.Drawing.Color.White, Message.TopLeft), Program.Values);
}
if (Rank == NobilityRank.Duke)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has the Duke In Pharaohs-Eu ", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.Prince)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has the Prince In Pharaohs-Eu ", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.King)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has become the new King/Queen In Pharaohs-Eu ", System.Drawing.Color.White, Message.Center), Program.Values);
}
if (Rank == NobilityRank.Knight)
{
Kernel.SendWorldMessage(new Message(" Congratulation " + client.Player.Name + " has become a Knight By In Pharaohs-Eu ", System.Drawing.Color.White, Message.TopLeft), Program.Values);
}
}
else
{
if (previousPlace != Place)
{
updateTheClient = true;
}
}
if (updateTheClient || client.Player.UID == updateUID)
{
NobilityInfo update = new NobilityInfo(true);
update.Type = NobilityInfo.Icon;
update.dwParam = entry.EntityUID;
update.UpdateString(entry);
client.SendScreen(update, true);
client.Player.NobilityRank = entry.Rank;
}
}
sortedBoard.Add(entry.EntityUID, entry);
Place++;
}
catch { }
}
Board = sortedBoard;
lock (BoardList)
BoardList = Board.Values.ToList();
}
}
public class NobilityInformation
{
public string Name;
public uint EntityUID;
public uint Mesh;
public ulong Donation;
public byte Gender;
public int Position;
public NobilityRank Rank;
public bool king;
public DateTime KingDays;
}
public enum NobilityRank : byte
{
Serf = 0,
Knight = 1,
Baron = 3,
Earl = 5,
Duke = 7,
Prince = 9,
King = 12
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
لو تكرمتم اى شخص عندى ف الجيم بيفتح الرانك الاكونت يهنج | megokarika | مشكلات السيرفيرات كونكر الشخصيه | 6 | 2020-02-20 02:58 PM |
مشكلة غريبه جدآ الاسطفا بتظهر من غير ال hp وي الدمج 7 الحل ايه يا رجاله | ahmedfathy | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-11-30 03:51 PM |
حل يا رجاله | abdo01120248447 | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-10-24 11:47 AM |
حل مشكلة بسرعه يا رجاله | ElSaher | مشكلات السيرفيرات كونكر الشخصيه | 2 | 2019-09-16 09:35 AM |
حل مشكلة الرانك | osama | مشكلات السيرفيرات كونكر الشخصيه | 19 | 2019-07-21 01:41 PM |