So, I've been messing around with one of Messi's sources for modern CO. I can't seem to figure out wtf he did to the attack system, but it seems to all be in calculate.cs
Me and some friends have been looking at it, and playing with the values attempting to understand it. Ingame, trojans of the same stats hit 1.2k-1.4k with skills and 3.8k crits with skills. Even less with regular hits. Taoists hit 600 with fire.
How would I go about upping the values?
Heres the entire Calculate.cs incase you would like to see that and pick through it. If anything else is needed, I can provide.
Me and some friends have been looking at it, and playing with the values attempting to understand it. Ingame, trojans of the same stats hit 1.2k-1.4k with skills and 3.8k crits with skills. Even less with regular hits. Taoists hit 600 with fire.
How would I go about upping the values?
Heres the entire Calculate.cs incase you would like to see that and pick through it. If anything else is needed, I can provide.
Code:
using System;
using MessiProject.Network.GamePackets;
using System.Collections.Generic;
using MessiProject.Interfaces;
using MessiProject.Game.ConquerStructures;
using MessiProject.Network.GamePackets;
//using Conquer.Network.GamePackets;
namespace MessiProject.Game.Attacking
{
public class Calculate
{
static float
goldPrizePsyAttackCoefficient = .2f,
goldPrizePsyDefenceCoefficient = .2f,
goldPrizeMagAttackCoefficient = .2f,
goldPrizeMagDefenceCoefficient = .2f;
//static float reduceValue = 0.6f;
#region BattlePowerCalculation
public static int BattlePowerCalculation(int damage, int battlepowerExcess)
{
if (battlepowerExcess == 0)
{
return damage;
}
if (battlepowerExcess < -50)
{
battlepowerExcess = -50;
}
if (battlepowerExcess > 50)
{
battlepowerExcess = 50;
}
return damage + (damage * battlepowerExcess / 100);
}
#endregion
#region ChanceSuccess
public static bool ChanceSuccess(double Chance, double offset = 0.0)
{
Random random = new Random();
if (Chance <= 0.0)
{
return false;
}
return ((Chance >= 100.0) || ((((double)random.Next(1, 0xf4240)) / 10000.0) >= ((100.0 + offset) - Chance)));
}
public static bool ChanceSuccess(int c, int inchance)
{
int num = new Random().Next(inchance);
return ((num != 0) && (num <= c));
}
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;
}
#endregion
public static uint Melee(Entity attacker, Entity attacked, ref Attack Packet)
{
if (attacked != null && attacked.EntityFlag == EntityFlag.Player)
BlessEffect.Effect(attacked);
if (attacker != null && attacker.EntityFlag == EntityFlag.Player)
GemEffect.Effect(attacker);
#region Base Calculate
int Damage = 0;
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Action == Enums.ConquerAction.Sit)
if (attacked.Stamina > 20)
attacked.Stamina -= 20;
else
attacked.Stamina = 0;
attacked.Action = Enums.ConquerAction.None;
}
if (attacker.MinAttack > attacker.MaxAttack)
return 1;
int Leveldiffs = (attacker.Level + 2) - attacked.Level;
int Damageadds = (int)Math.Floor(1 + (Leveldiffs / 5) * 0.8);
if (Damageadds > 1)
Damage = Damageadds * Damage;
Damage -= attacked.Defence;
if (attacked.Reborn == 1)
{
Damage = (int)Math.Floor(Damage * .7);
}
else if (attacked.Reborn == 2)
{
Damage = (int)Math.Floor(Damage * .7);
if (attacker.Reborn < 2)
Damage = (int)Math.Floor(Damage * .5);
}
Damage *= (int)(1 - attacked.Gems[7]);
if (attacker.EntityFlag == EntityFlag.Monster)
if (attacked.EntityFlag == EntityFlag.Player)
if (Kernel.Rate(Math.Min(60, attacked.Dodge + 30)))
return 0;
if (Calculate.IsTargetDodged(attacker, attacked))
return 0;
//Durability(attacker, attacked, null);
if (attacker.EntityFlag == EntityFlag.Player)
{
DurabilityItems.AttackDurabilityItems(attacker, attacked);
}
if (attacked.EntityFlag == EntityFlag.Player)
{
DurabilityItems.DefenceDurabilityItems(attacker, attacked);
}
if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
return 1;
int MinAttack = (int)(attacker.MinAttack + (attacker.MinAttack * (1 + attacker.Gems[1])) * 2);
int MaxAttack = (int)(attacker.MaxAttack + (attacker.MaxAttack * (1 + attacker.Gems[1])) * 2);
if (!attacker.Transformed)
Damage = Kernel.Random.Next((int)Math.Min((long)MinAttack, (long)MaxAttack), (int)Math.Max((long)MinAttack, (long)MaxAttack) + 1);
else
Damage = Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);
if (attacker.WearsGoldPrize) Damage += (int)(Damage * goldPrizePsyAttackCoefficient);
if (attacked.WearsGoldPrize) Damage -= (int)(Damage * goldPrizePsyDefenceCoefficient);
if (attacked.ItemBless > 0)
{
Damage -= attacked.ItemBless * Damage / 100;
}
if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
if (!attacker.Transformed && Damage > 1)
Damage = (int)(Damage * 1.30);
#endregion
#region Attacked[Monster]
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Monster)
{
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * (1.0 + Calculate.GetLevelBonus(attacker.Level, attacked.Level) * 0.08));
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * Calculate.AttackMultiplier(attacker, attacked));
#region Xp Skills
if (attacker.OnSuperman())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 5;
else
return (uint)(Damage /= 1);
}
else if (attacker.OnFatalStrike())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 2;
else
return (uint)(Damage /= 1);
}
else if (attacker.OnOblivion())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 1;
else
return (uint)(Damage /= 1);
}
#endregion
if (Constants.Boss.Contains(attacked.Name))
return (uint)(Damage /= 1);
else if (Constants.QuestsMonster.Contains(attacked.Name))
{
uint ran = (uint)MessiProject.Kernel.Random.Next(0, 3);
return ran;
}
}
#endregion
#region MagicShield
uint _B = attacker.Penetration;
if (!Kernel.Rate(_B /= 170))
{
if (!attacked.Transformed)
{
if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
{
if (attacked.ShieldTime > 0)
Damage -= (ushort)(attacked.Defence * attacked.ShieldIncrease);
else
Damage -= (ushort)(attacked.Defence * attacked.MagicShieldIncrease);
}
else
{
Damage -= attacked.Defence;
}
if (Time64.Now <= attacked.DefensiveStanceStamp.AddSeconds(attacked.FatigueSecs))
{
Database.SpellInformation spellInformation = Database.SpellTable.SpellInformations[11160][attacked.Owner.Spells[11160].Level];
Damage -= (int)(attacked.Defence * spellInformation.PowerPercent);
}
}
else
Damage -= attacked.TransformationDefence;
Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);
}
else
{
_String str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("zf2-e295");
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(str, true);
}
#endregion
#region LuckTime
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
if (Kernel.Rate(5))
{
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Owner.BlessTime > 0)
{
Damage /= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacked.Owner.SendScreen(str, true);
}
}
}
#endregion
#region RemoveExcess
Damage = RemoveExcessDamage(Damage, attacker, attacked);
Damage += attacker.PhysicalDamageIncrease;
Damage -= attacked.PhysicalDamageDecrease;
if (attacked.EntityFlag == EntityFlag.Monster)
{
if (Damage >= 700 * attacked.MaxHitpoints)
{
Damage = (int)(700 * attacked.MaxHitpoints);
}
}
if (Damage <= 0)
{
Damage = 1;
}
AutoRespone(attacker, attacked, ref Damage);
#endregion
#region AzureShield
if (attacked.ContainsFlag2(Update.Flags2.AzureShield))
{
if (attacked.AzureDamage >= Damage)
{
attacked.AzureDamage -= Damage;
int sec = 60 - (Time64.Now - attacked.MagicShieldStamp).AllSeconds;
attacked.Owner.Send(Constants.Shield(attacked.AzureDamage, sec));
Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
attack.AttackType = Network.GamePackets.Attack.Shield;
//attack.Decoded = true;
attack.X = attacked.X;
attack.Y = attacked.Y;
attack.Attacked = attacked.UID;
attack.Attacker = attacker.UID;
attack.Damage = (ushort)(Damage);
attacked.Send(attack);
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(attack, true);
return 0;
}
else
{
Damage -= attacked.AzureDamage;
attacked.AzureDamage = 0;
attacked.RemoveFlag2(Update.Flags2.AzureShield);
//return (uint)(Damage * reduceValue);
return (uint)Damage;
}
}
#endregion
#region Block
if (attacked.EntityFlag == EntityFlag.Player && attacked.Block > 0)
{
uint _bb = attacked.Block;
if (Kernel.Rate(_bb /= 170))
{
Packet.Effect1 |= Attack.AttackEffects1.Block;
uint blockdamage = (uint)((Damage * (attacked.Block / 100)) / 100);
if (Damage > blockdamage)
Damage -= (int)blockdamage;
else
Damage = Damage /= 2;
_String str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("ShieldBlock");
attacked.Owner.SendScreen(str, true);
}
}
#endregion
#region CriticalStrike
if (attacker.EntityFlag == EntityFlag.Player)
{
if (Kernel.ChanceSuccess(((float)attacker.CriticalStrike / 100f) - ((float)attacked.Immunity / 100f)))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.5);
}
}
#region Breakthrough
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.BattlePower < attacked.BattlePower)
{
if (Kernel.ChanceSuccess(((float)attacker.Breaktrough / 10f) - (float)(attacked.Counteraction / 10f)))
{
Damage = (Int32)attacker.MaxAttack/* + 3000*/;
Packet.Effect1 |= Attack.AttackEffects1.Penetration;
}
}
}
#endregion
#endregion
#region Elements
try
{
if (attacked.EntityFlag == EntityFlag.Player)
{
int wr = (int)attacked.WaterResistance * 2;
int wd = (int)attacked.WoodResistance * 2;
int fr = (int)attacked.FireResistance * 2;
int er = (int)attacked.EarthResistance * 2;
int mr = (int)attacked.MetalResistance * 2;
Damage -= fr;
Damage -= wd;
Damage -= er;
Damage -= wr;
Damage -= mr;
}
if (Damage <= 0)
Damage = 1;
}
catch (Exception exception)
{
Console.WriteLine(exception); Program.SaveException(exception);
}
#endregion//
#region Nobility Damage
try
{
if (attacked.EntityFlag == EntityFlag.Player && (attacker.BattlePower < attacked.BattlePower))
{
if (attacked.Owner.Challenge == null)
{
int sub = attacked.BattlePower - attacker.BattlePower;
//sub *= 2000;//##Samak BattlePower
if (sub > 41)
{
Damage = 1;
}
else
{//Samak
Damage = (Int32)Math.Floor((float)Damage * (.70 - (sub * 0.01)));
}
}
}
if (attacked.EntityFlag == EntityFlag.Player && (attacker.BattlePower > attacked.BattlePower))
{
if (attacked.Owner.Challenge == null)
{
int dmg = attacked.BattlePower - attacker.BattlePower;
if (dmg > 50)
{
Damage = Damage * 2;
}
else
Damage = (Int32)Math.Floor((float)Damage * (1.30 - (dmg * 0.01)));
}
}
}
catch (Exception) { }
#endregion
#region Chars
if (attacked.Fire())
{
double dmg = (double)(Damage / 1.3);
Damage = (int)(dmg);
}
if (attacked.Water())
{
double dmg = (double)(Damage / 2);
Damage = (int)(dmg);
}
if (attacked.Assassin())
{
double dmg = (double)(Damage * 1.1);
Damage = (int)(dmg);
}
#endregion
if (attacked.EntityFlag == EntityFlag.Monster)
attacker.LatestSkill = 0;
#region FB && SS
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Player)
if (attacker.MapID == 1707 && attacked.MapID == 1707)
Damage = 0;
#endregion
return (uint)Damage;
}
public static uint Melee(Entity attacker, Entity attacked, Database.SpellInformation spell, ref Attack Packet)
{
if (attacked != null && attacked.EntityFlag == EntityFlag.Player)
BlessEffect.Effect(attacked);
if (attacker != null && attacker.EntityFlag == EntityFlag.Player)
GemEffect.Effect(attacker);
#region Base Calculate
int Damage = 0;
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Action == Enums.ConquerAction.Sit)
if (attacked.Stamina > 20)
attacked.Stamina -= 20;
else
attacked.Stamina = 0;
attacked.Action = Enums.ConquerAction.None;
}
if (attacker.EntityFlag == EntityFlag.Monster)
if (attacked.EntityFlag == EntityFlag.Player)
if (Kernel.Rate(Math.Min(60, attacked.Dodge + 30)))
return 0;
if (Calculate.IsTargetDodged(attacker, attacked))
return 0;
//Durability(attacker, attacked, null);
if (attacker.EntityFlag == EntityFlag.Player)
{
DurabilityItems.AttackDurabilityItems(attacker, attacked);
}
if (attacked.EntityFlag == EntityFlag.Player)
{
DurabilityItems.DefenceDurabilityItems(attacker, attacked);
}
if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
return 1;
int MinAttack = (int)(attacker.MinAttack + (attacker.MinAttack * (1 + attacker.Gems[1])) * 2);
int MaxAttack = (int)(attacker.MaxAttack + (attacker.MaxAttack * (1 + attacker.Gems[1])) * 2);
if (!attacker.Transformed)
Damage = Kernel.Random.Next((int)Math.Min((long)MinAttack, (long)MaxAttack), (int)Math.Max((long)MinAttack, (long)MaxAttack) + 1);
else
Damage = Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);
if (attacker.WearsGoldPrize) Damage += (int)(Damage * goldPrizePsyAttackCoefficient);
if (attacked.WearsGoldPrize) Damage -= (int)(Damage * goldPrizePsyDefenceCoefficient);
if (attacked.ItemBless > 0)
{
Damage -= attacked.ItemBless * Damage / 100;
}
if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
if (!attacker.Transformed && Damage > 1)
Damage = (int)(Damage * 1.30);
#endregion
#region Attacked[Monster]
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Monster)
{
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * (1.0 + Calculate.GetLevelBonus(attacker.Level, attacked.Level) * 0.08));
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * Calculate.AttackMultiplier(attacker, attacked));
#region Xp Skills
if (attacker.OnSuperman())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 10;
else
return (uint)(Damage /= 2);
}
else if (attacker.OnFatalStrike())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 5;
else
return (uint)(Damage /= 2);
}
else if (attacker.OnOblivion())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 2;
else
return (uint)(Damage /= 2);
}
#endregion
if (Constants.Boss.Contains(attacked.Name))
return (uint)(Damage /= 3);
else if (Constants.QuestsMonster.Contains(attacked.Name))
{
uint ran = (uint)MessiProject.Kernel.Random.Next(0, 3);
return ran;
}
}
#endregion
#region LuckTime
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
if (Kernel.Rate(5))
{
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Owner.BlessTime > 0)
{
Damage /= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacked.Owner.SendScreen(str, true);
}
}
}
#endregion
#region Remove Excess
if (spell != null)
{
if (spell.ID == 6000 && attacked.EntityFlag == EntityFlag.Monster)
{
if (spell.PowerPercent != 0)
Damage = (int)(Damage * spell.PowerPercent);
}
else if (spell.ID != 6000)
{
if (spell.PowerPercent != 0)
Damage = (int)(Damage * spell.PowerPercent);
}
}
Damage = RemoveExcessDamage(Damage, attacker, attacked);
Damage += attacker.PhysicalDamageIncrease;
Damage -= attacked.PhysicalDamageDecrease;
if (attacked.EntityFlag == EntityFlag.Monster)
{
if (Damage >= 700 * attacked.MaxHitpoints)
Damage = (int)(700 * attacked.MaxHitpoints);
}
if (Damage <= 0)
Damage = 1;
AutoRespone(attacker, attacked, ref Damage);
#region Nobility Damage
if (attacker.NobilityRank != attacked.NobilityRank)
{
int addnobility_damage = 0;
if ((byte)attacker.NobilityRank == 12)
addnobility_damage = (Damage * ((byte)attacker.NobilityRank + 30)) / 100;
else
if ((byte)attacker.NobilityRank > 5)
addnobility_damage = (Damage * ((byte)attacker.NobilityRank + 25)) / 100;
if ((byte)attacked.NobilityRank > 5)
{
if ((addnobility_damage - (uint)((Damage * ((byte)attacked.NobilityRank + 8)) / 100)) > 0)
{
addnobility_damage -= (int)((Damage * ((byte)attacked.NobilityRank + 8)) / 100);
}
else
{
if (Damage > (uint)((Damage * ((byte)attacked.NobilityRank + 8)) / 100))
{
Damage -= (int)((Damage * ((byte)attacked.NobilityRank + 8)) / 100);
}
else
Damage = 1;
}
}
if (Damage != 1)
{
Damage += addnobility_damage;
}
}
#endregion
#endregion
#region AzureShield
if (attacked.ContainsFlag2(Update.Flags2.AzureShield))
{
if (attacked.AzureDamage >= Damage)
{
attacked.AzureDamage -= Damage;
int sec = 60 - (Time64.Now - attacked.MagicShieldStamp).AllSeconds;
attacked.Owner.Send(Constants.Shield(attacked.AzureDamage, sec));
Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
attack.AttackType = Network.GamePackets.Attack.Shield;
//attack.Decoded = true;
attack.X = attacked.X;
attack.Y = attacked.Y;
attack.Attacked = attacked.UID;
attack.Attacker = attacker.UID;
attack.Damage = (ushort)(Damage);
attacked.Send(attack);
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(attack, true);
return 0;
}
else
{
Damage -= attacked.AzureDamage;
attacked.AzureDamage = 0;
attacked.RemoveFlag2(Update.Flags2.AzureShield);
//return (uint)(Damage * reduceValue);
return (uint)Damage;
}
}
#endregion
#region Block
if (attacked.EntityFlag == EntityFlag.Player && attacked.Block > 0)
{
uint _bb = attacked.Block;
if (Kernel.Rate(_bb /= 170))
{
Packet.Effect1 |= Attack.AttackEffects1.Block;
uint blockdamage = (uint)((Damage * (attacked.Block / 100)) / 100);
if (Damage > blockdamage)
Damage -= (int)blockdamage;
else
Damage = Damage /= 2;
_String str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("ShieldBlock");
attacked.Owner.SendScreen(str, true);
}
}
#endregion
#region CriticalStrike
if (attacker.EntityFlag == EntityFlag.Player)
{
if (Kernel.ChanceSuccess(((float)attacker.CriticalStrike / 100f) - ((float)attacked.Immunity / 100f)))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.5);
}
}
#region Breakthrough
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.BattlePower < attacked.BattlePower)
{
if (Kernel.ChanceSuccess(((float)attacker.Breaktrough / 10f) - (float)(attacked.Counteraction / 10f)))
{
Damage = (Int32)attacker.MaxAttack/* + 3000*/;
Packet.Effect1 |= Attack.AttackEffects1.Penetration;
}
}
}
#endregion
#endregion
#region Elements
try
{
if (attacked.EntityFlag == EntityFlag.Player)
{
int wr = (int)attacked.WaterResistance * 2;
int wd = (int)attacked.WoodResistance * 2;
int fr = (int)attacked.FireResistance * 2;
int er = (int)attacked.EarthResistance * 2;
int mr = (int)attacked.MetalResistance * 2;
Damage -= fr;
Damage -= wd;
Damage -= er;
Damage -= wr;
Damage -= mr;
}
if (Damage <= 0)
Damage = 1;
}
catch (Exception exception)
{
Console.WriteLine(exception); Program.SaveException(exception);
}
#endregion
#region Nobility Damage
try
{
if (attacked.EntityFlag == EntityFlag.Player && attacker.BattlePower < attacked.BattlePower)
{
if (attacked.Owner.Challenge == null)
{
int sub = attacked.BattlePower - attacker.BattlePower;
if (sub > 41)
{
Damage = 1;
}
else
{//Samak
Damage = (Int32)Math.Floor((float)Damage * (.70 - (sub * 0.01)));
}
}
}
if (attacked.EntityFlag == EntityFlag.Player && (attacker.BattlePower > attacked.BattlePower))
{
if (attacked.Owner.Challenge == null)
{
int dmg = attacked.BattlePower - attacker.BattlePower;
if (dmg > 50)
{
Damage = Damage * 2;
}
else
Damage = (Int32)Math.Floor((float)Damage * (1.30 - (dmg * 0.01)));
}
}
}
catch (Exception) { }
#endregion
#region Chars
if (attacked.Fire())
{
double dmg = (double)(Damage / 1.3);
Damage = (int)(dmg);
}
if (attacked.Water())
{
double dmg = (double)(Damage / 2);
Damage = (int)(dmg);
}
if (attacked.Assassin())
{
double dmg = (double)(Damage * 1.1);
Damage = (int)(dmg);
}
#endregion
if (attacked.EntityFlag == EntityFlag.Monster)
attacker.LatestSkill = spell.ID;
#region FB && SS
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Player)
if (attacker.MapID == 1707 && attacked.MapID == 1707)
if (spell.ID == 1045 || spell.ID == 1047)
Damage = 1;
else
Damage = 0;
#endregion
return (uint)Damage;
}
public static uint Melee(Entity attacker, SobNpcSpawn attacked, ref Attack Packet)
{
#region Base Calculate
int Damage = 0;
try
{
//Durability(attacker, null, null);
if (attacker.EntityFlag == EntityFlag.Player)
{
DurabilityItems.AttackDurabilityItems(attacker, null);
}
if (attacker.MinAttack > attacker.MaxAttack)
{
uint _ma = attacker.MinAttack;
uint ma = attacker.MaxAttack;
attacker.MinAttack = ma;
attacker.MaxAttack = _ma;
}
int MinAttack = (int)(attacker.MinAttack + (attacker.MinAttack * (1 + attacker.Gems[1])));
int MaxAttack = (int)(attacker.MaxAttack + (attacker.MaxAttack * (1 + attacker.Gems[1])));
if (!attacker.Transformed)
Damage = Kernel.Random.Next((int)Math.Min((long)MinAttack, (long)MaxAttack), (int)Math.Max((long)MinAttack, (long)MaxAttack) + 1);
else
Damage = Kernel.Random.Next((int)attacker.TransformationMinAttack, (int)attacker.TransformationMaxAttack + 1);
if (attacker.WearsGoldPrize) Damage += (int)(Damage * goldPrizePsyAttackCoefficient);
if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
if (!attacker.Transformed && Damage > 1)
Damage = (int)(Damage * 1.30);
Damage += attacker.PhysicalDamageIncrease;
#endregion
#region LuckTime
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
}
catch (Exception exception)
{
Console.WriteLine(exception); Program.SaveException(exception);
}
if (Damage <= 0)
Damage = 1;
#endregion
return (uint)Damage;
}
public static bool Miss(int Percent)
{
if (Percent >= 100)
return false;
return Kernel.Rate(Percent, 100);
}
public static uint Magic(Entity Attacker, Entity Attacked, Database.SpellInformation SInfo, ref Attack Packet)
{
if (Attacked.EntityFlag == EntityFlag.Player)
{
BlessEffect.Effect(Attacked);
}
if (Attacker.EntityFlag == EntityFlag.Player)
{
GemEffect.Effect(Attacker);
}
Boolean CritImmune = false;
switch (Attacked.EntityFlag)
{
case EntityFlag.Player:
{
Int32 Damage = 0;
Int32 Defence = 0;
if (ChanceSuccess((float)Attacked.Immunity / 100f))
CritImmune = true;
Int32 Fan = 0, Tower = 0;
if (Attacker.EntityFlag == EntityFlag.Player)
Fan = Attacker.getFan(true);
if (Attacked.EntityFlag == EntityFlag.Player)
Tower = Attacked.getTower(true);
Damage = (int)Attacker.MagicAttack;
if (Attacked.EntityFlag == EntityFlag.Player)
if (Attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex))
return 1;
if (Miss(SInfo.Percent))
return 0;
Defence = (Int32)Attacked.MagicDefence;
Defence = (Int32)Attacked.MagicDamageDecrease;
int MinAttack2 = (int)(Attacker.MagicAttack + (Attacker.MagicAttack * (1 + Attacker.Gems[0])) / 60);
if (!Attacker.Transformed)
Damage = Kernel.Random.Next((int)Math.Min((long)MinAttack2, (long)MinAttack2), (int)Math.Max((long)MinAttack2, (long)MinAttack2) + 1);
if (Attacked.EntityFlag == EntityFlag.Player)
{
if (Attacked.Reborn == 1)
Damage = (Int32)(Damage * 0.10);
if (Attacked.Reborn == 2)
Damage = (Int32)(Damage * 0.10);
}
Damage += Fan;
if (Attacker.EntityFlag == EntityFlag.Player)
Damage += Attacker.MagicDamageIncrease;
//UInt32 bpdmage = 0, bpdefence = 0;
//if (Attacked.EntityFlag == EntityFlag.Player)
//bpdefence = (UInt32)(Attacked.BattlePower * 3.5);
//Damage -= (int)bpdefence;
//Damage -= Attacked.MagicDamageDecrease;
Damage -= Defence;
Damage -= Tower;
//if (Damage <= 1) Damage = 1;
//return (UInt32)Damage;
//if (Damage <= 1) Damage = 1;
//return (UInt32)Damage;
//the new block offers us the behavior of the melee response.
if (!CritImmune)
{
if (ChanceSuccess((float)Attacker.SkillCStrike / 100f))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.3);
}
}
if (Attacked.EntityFlag == EntityFlag.Player)
{
if (ChanceSuccess((float)Attacked.Block / 100f))
{
Packet.Effect1 |= Attack.AttackEffects1.Block;
Damage = (Int32)Math.Floor((float)Damage / 2);
}
}
if (Attacked.EntityFlag == EntityFlag.Player)
{
if (Attacker.EntityFlag == EntityFlag.Player)
{
if (Damage > 0)
{
if (Attacker.GemBonus(ItemSocket.Phoenix) != null)
{
Damage += (Int32)(Math.Floor((Double)Damage * Attacker.GemBonus(ItemSocket.Phoenix)));
}
if (Attacked.GemBonus(ItemSocket.Tortoise) != null)
{
Damage -= (Int32)(Math.Floor((Double)Damage * Attacked.GemBonus(ItemSocket.Tortoise)));
}// grbha kda
}
}
}
if (Damage <= 0)
Damage = 1;
Damage = Damage / 3;
AutoRespone(Attacker, Attacked, ref Damage);
if (Constants.Damage1Map.Contains(Attacker.MapID))
Damage = 1;
//Console.WriteLine(Damage.ToString() + " 7");
if (Attacked.ContainsFlag2(Network.GamePackets.Update.Flags2.AzureShield))
{
if (Attacked.AzureDamage >= Damage)
{
// Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
Attacked.AzureDamage -= Damage;
int sec = 60 - (Time64.Now - Attacked.MagicShieldStamp).AllSeconds;
// Attacked.Owner.Send(ServerBase.Constants.Shield(Attacked.AzureDamage, sec));
SyncPacket packet4 = new SyncPacket
{
Identifier = Attacked.UID,
Count = 2,
Type = SyncPacket.SyncType.StatusFlag,
StatusFlag1 = (ulong)Attacked.StatusFlag,
StatusFlag2 = (ulong)Attacked.StatusFlag2,
Unknown1 = 0x31,
StatusFlagOffset = 0x5d,
Time = (uint)sec,
Value = (uint)Attacked.AzureDamage,
Level = 4
};
Attacked.Owner.Send((byte[])packet4);
//Console.WriteLine("^^^^Damage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
return 0;
}
else
{
//Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
Damage -= Attacked.AzureDamage;
Attacked.AzureDamage = 0;
Attacked.RemoveFlag2(Update.Flags2.AzureShield);
SyncPacket packet4 = new SyncPacket
{
Identifier = Attacked.UID,
Count = 2,
Type = SyncPacket.SyncType.StatusFlag,
StatusFlag1 = (ulong)Attacked.StatusFlag,
StatusFlag2 = (ulong)Attacked.StatusFlag2,
Unknown1 = 0x31,
StatusFlagOffset = 0x5d,
Time = 0,
Value = 0,
Level = 4
};
Attacked.Owner.Send((byte[])packet4);
// Console.WriteLine("XXXXDamage is " + Damage.ToString() + " Azure is : " + Attacked.AzureDamage.ToString());
//Console.WriteLine(Damage.ToString() + " 8");
return (uint)Damage;
}
}
if (Constants.Damage1Map.Contains(Attacker.MapID))
Damage = 1;
return (uint)Damage;
}
case EntityFlag.Monster:
{
Int32 Damage = 0;
Int32 Defence = 0;
Int32 Fan = 0;
if (Attacker.EntityFlag == EntityFlag.Player)
Fan = Attacker.getFan(true);
if (Miss(SInfo.Percent))
return 0;
Damage = (int)Attacker.MagicAttack;
if (SInfo != null)
Damage += SInfo.Power;
Defence = Attacked.MonsterInfo.Level * 20;
if (Attacked.MonsterInfo != null)
if (Attacked.Name == "Guard1")
Damage = Damage / 30;
Damage += Fan;
if (Attacker.EntityFlag == EntityFlag.Player)
Damage += Attacker.MagicDamageIncrease;
Damage *= (int)(2.5);
//Damage += (int)bpdamage;
Damage -= Defence;
if (!CritImmune)
{
if (ChanceSuccess((float)Attacker.SkillCStrike / 100f))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.2);
}
}
if (Damage <= 1) Damage = 1;
if (Constants.Damage1Map.Contains(Attacker.MapID))
Damage = 1;
return (UInt32)Damage;
}
}
return 0;
}
public static uint Magic(Entity attacker, Entity attacked, ushort spellID, byte spellLevel, ref Attack Packet)
{
Database.SpellInformation spell = Database.SpellTable.SpellInformations[spellID][spellLevel];
return Magic(attacker, attacked, spell, ref Packet);
}
public static uint Magic(Entity attacker, SobNpcSpawn attacked, Database.SpellInformation spell, ref Attack Packet)
{
if (spell != null)
if (!Kernel.Rate(spell.Percent))
return 0;
if (spell != null)
Durability(attacker, null, spell);
if (attacker.Transformed)
return 0;
if (attacker.EntityFlag == EntityFlag.Player)
{
GemEffect.Effect(attacker);
}
int Damage = 0;
Damage = (int)attacker.MagicAttack;
if (spell != null)
Damage += spell.Power;
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
int MinAttack2 = (int)(attacker.MagicAttack + (attacker.MagicAttack * (1 + attacker.Gems[0])) / 65);
if (!attacker.Transformed)
Damage = Kernel.Random.Next((int)Math.Min((long)MinAttack2, (long)MinAttack2), (int)Math.Max((long)MinAttack2, (long)MinAttack2) + 1);
Damage += attacker.MagicDamageIncrease;
if (ChanceSuccess((float)attacker.SkillCStrike / 100f))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.2);
}
if (Damage <= 0)
Damage = 1;
if (Constants.Damage1Map.Contains(attacker.MapID))
Damage = 1;
if (attacker.MonsterInfo != null)
if (attacker.MonsterInfo.Name == "Guard1")
Damage = (int)attacked.MaxHitpoints + 1;
if (Constants.Damage1Map.Contains(attacker.MapID))
Damage = 1;
return (uint)Damage;
}
public static uint Ranged(Entity attacker, Entity attacked, ref Attack Packet)
{
if (attacked.EntityFlag == EntityFlag.Player)
BlessEffect.Effect(attacked);
if (attacker.EntityFlag == EntityFlag.Player)
GemEffect.Effect(attacker);
#region Base Calculate
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Action == Enums.ConquerAction.Sit)
if (attacked.Stamina > 20)
attacked.Stamina -= 20;
else
attacked.Stamina = 0;
attacked.Action = Enums.ConquerAction.None;
}
int Damage = 0;
//Durability(attacker, attacked, null);
if (attacker.EntityFlag == EntityFlag.Player)
{
DurabilityItems.AttackDurabilityItems(attacker, attacked);
}
if (attacked.EntityFlag == EntityFlag.Player)
{
DurabilityItems.DefenceDurabilityItems(attacker, attacked);
}
if (attacked.ContainsFlag(Network.GamePackets.Update.Flags.ShurikenVortex) || attacker.Transformed)
return 1;
int MinAttack = (int)(attacker.MinAttack + (attacker.MinAttack * (1 + attacker.Gems[1])));
int MaxAttack = (int)(attacker.MaxAttack + (attacker.MaxAttack * (1 + attacker.Gems[1])));
Damage = Kernel.Random.Next(Math.Min((int)MinAttack, (int)MaxAttack), Math.Max((int)MinAttack, (int)MaxAttack) + 1);
Damage -= Damage * attacked.ItemBless / 100;
if (attacker.WearsGoldPrize) Damage += (int)(Damage * goldPrizePsyAttackCoefficient);
if (attacked.WearsGoldPrize) Damage -= (int)(Damage * goldPrizePsyDefenceCoefficient);
if (attacked.ItemBless > 0)
{
Damage -= attacked.ItemBless * Damage / 100;
}
byte dodge = attacked.Dodge;
if (dodge > 100)
dodge = 99;
if (!attacked.Transformed)
Damage -= Damage * dodge / 100;
else
Damage -= Damage * attacked.TransformationDodge / 100;
if (attacker.OnIntensify && Time64.Now >= attacker.IntensifyStamp.AddSeconds(4))
{
Damage *= 2;
attacker.OnIntensify = false;
}
if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
if (!attacker.Transformed && Damage > 1)
Damage = (int)(Damage * 1.30);
Damage = BattlePowerCalculation(Damage, attacker.BattlePower - attacked.BattlePower);
#endregion
#region Attacked[Monster]
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Monster)
{
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * (1.0 + Calculate.GetLevelBonus(attacker.Level, attacked.Level) * 0.08));
if (attacked.MapID < 1351 || attacked.MapID > 1354)
Damage = (int)(Damage * Calculate.AttackMultiplier(attacker, attacked));
#region Xp Skills
if (attacker.OnSuperman())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 10;
else
return (uint)(Damage /= 2);
}
else if (attacker.OnFatalStrike())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 5;
else
return (uint)(Damage /= 2);
}
else if (attacker.OnOblivion())
{
if (!attacked.MonsterInfo.Boss)
Damage *= 2;
else
return (uint)(Damage /= 2);
}
#endregion
if (Constants.Boss.Contains(attacked.Name))
return (uint)(Damage /= 3);
else if (Constants.QuestsMonster.Contains(attacked.Name))
{
uint ran = (uint)MessiProject.Kernel.Random.Next(0, 3);
return ran;
}
}
#endregion
#region LuckTime
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
if (Kernel.Rate(5))
{
if (attacked.EntityFlag == EntityFlag.Player)
{
if (attacked.Owner.BlessTime > 0)
{
Damage /= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacked.Owner.SendScreen(str, true);
}
}
}
#endregion
#region Remove Excess
if (attacked.EntityFlag == EntityFlag.Monster)
{
if (Damage >= 700 * attacked.MaxHitpoints)
Damage = (int)(700 * attacked.MaxHitpoints);
}
Damage += attacker.PhysicalDamageIncrease;
Damage -= attacked.PhysicalDamageDecrease;
if (Damage <= 0)
Damage = 1;
AutoRespone(attacker, attacked, ref Damage);
#endregion
#region AzureShield
if (attacked.ContainsFlag2(Update.Flags2.AzureShield))
{
if (attacked.AzureDamage >= Damage)
{
attacked.AzureDamage -= Damage;
int sec = 60 - (Time64.Now - attacked.MagicShieldStamp).AllSeconds;
attacked.Owner.Send(Constants.Shield(attacked.AzureDamage, sec));
Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
attack.AttackType = Network.GamePackets.Attack.Shield;
//attack.Decoded = true;
attack.X = attacked.X;
attack.Y = attacked.Y;
attack.Attacked = attacked.UID;
attack.Attacker = attacker.UID;
attack.Damage = (ushort)(Damage);
attacked.Send(attack);
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(attack, true);
return 0;
}
else
{
Damage -= attacked.AzureDamage;
attacked.AzureDamage = 0;
attacked.RemoveFlag2(Update.Flags2.AzureShield);
//return (uint)(Damage * reduceValue);
return (uint)Damage;
}
}
#endregion
#region Breakthrough
int rateBreakthrough = (attacker.Breaktrough - attacked.Counteraction) / 100;
if (attacker.BattlePower < attacked.BattlePower && (attacker.Breaktrough / 100) > 0 && rateBreakthrough > 0 && Kernel.Rate(rateBreakthrough))
{
//Damage += (Int32)attacker.MaxAttack + 3000;
Damage = Calculate.CalculateBreak(attacker, attacked, Damage);
Packet.Effect1 |= Attack.AttackEffects1.Break;
_String str = new _String(true);
str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("partbehithead");
if (attacked.EntityFlag == EntityFlag.Player)
{
attacked.Owner.SendScreen(str, true);
attacked.Owner.Send(new Message("Breakthrough Has a chance to exceed Max Attack when the enemy has a higher BP.", System.Drawing.Color.Red, 2012U));
}
}
//}
#endregion
#region Transfor
uint _B = attacker.Penetration;
if (!Kernel.Rate(_B /= 170))
{
if (!attacked.Transformed)
Damage -= attacked.Defence;
else
Damage -= attacked.TransformationDefence;
}
else
{
_String str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("zf2-e295");
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(str, true);
}
#endregion
#region Block
if (attacked.EntityFlag == EntityFlag.Player && attacked.Block > 0)
{
uint _bb = attacked.Block;
if (Kernel.Rate(_bb /= 170))
{
Packet.Effect1 |= Attack.AttackEffects1.Block;
uint blockdamage = (uint)((Damage * (attacked.Block / 100)) / 100);
if (Damage > blockdamage)
Damage -= (int)blockdamage;
else
Damage = Damage /= 2;
_String str = new _String(true);
str.UID = attacked.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("ShieldBlock");
attacked.Owner.SendScreen(str, true);
}
}
#endregion
#region CriticalStrike
if (attacker.EntityFlag == EntityFlag.Player)
{
if (Kernel.ChanceSuccess(((float)attacker.CriticalStrike / 100f) - ((float)attacked.Immunity / 100f)))
{
Packet.Effect1 |= Attack.AttackEffects1.CriticalStrike;
Damage = (Int32)Math.Floor((float)Damage * 1.5);
}
}
#region Breakthrough
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.BattlePower < attacked.BattlePower)
{
if (Kernel.ChanceSuccess(((float)attacker.Breaktrough / 10f) - (float)(attacked.Counteraction / 10f)))
{
Damage = (Int32)attacker.MaxAttack/* + 3000*/;
Packet.Effect1 |= Attack.AttackEffects1.Penetration;
}
}
}
#endregion
#endregion
#region Elements
try
{
if (attacked.EntityFlag == EntityFlag.Player)
{
int wr = (int)attacked.WaterResistance * 2;
int wd = (int)attacked.WoodResistance * 2;
int fr = (int)attacked.FireResistance * 2;
int er = (int)attacked.EarthResistance * 2;
int mr = (int)attacked.MetalResistance * 2;
Damage -= fr;
Damage -= wd;
Damage -= er;
Damage -= wr;
Damage -= mr;
}
if (Damage <= 0)
Damage = 1;
}
catch (Exception exception)
{
Console.WriteLine(exception); Program.SaveException(exception);
}
#endregion//
#region Nobility Damage
try
{
if (attacked.EntityFlag == EntityFlag.Player && attacker.BattlePower < attacked.BattlePower)
{
if (attacked.Owner.Challenge == null)
{
int sub = attacked.BattlePower - attacker.BattlePower;
//sub *= 2000;//##Samak BattlePower
if (sub > 41)
{
Damage = 1;
}
else
{//Samak
Damage = (Int32)Math.Floor((float)Damage * (.70 - (sub * 0.01)));
}
}
}
if (attacked.EntityFlag == EntityFlag.Player && (attacker.BattlePower > attacked.BattlePower))
{
if (attacked.Owner.Challenge == null)
{
int dmg = attacked.BattlePower - attacker.BattlePower;
if (dmg > 50)
{
Damage = Damage * 2;
}
else
Damage = (Int32)Math.Floor((float)Damage * (1.30 - (dmg * 0.01)));
}
}
}
catch (Exception) { }
#endregion
if (attacked.EntityFlag == EntityFlag.Monster)
attacker.LatestSkill = 0;
#region FB && SS
if (attacker.EntityFlag == EntityFlag.Player && attacked.EntityFlag == EntityFlag.Player)
if (attacker.MapID == 1707 && attacked.MapID == 1707)
Damage = 0;
#endregion
return (uint)Damage;
}
public static uint Ranged(Entity attacker, Entity attacked, Database.SpellInformation spell, ref Attack Packet)
{
return Calculate.Ranged(attacker, attacked, ref Packet);
}
public static uint Ranged(Entity attacker, SobNpcSpawn attacked, ref Attack Packet)
{
#region Base Calculate
int Damage = 0;
//Durability(attacker, null, null);
if (attacker.EntityFlag == EntityFlag.Player)
{
DurabilityItems.AttackDurabilityItems(attacker, null);
}
if (attacker.Transformed)
return 0;
int MinAttack = (int)(attacker.MinAttack + (attacker.MinAttack * (1 + attacker.Gems[1])));
int MaxAttack = (int)(attacker.MaxAttack + (attacker.MaxAttack * (1 + attacker.Gems[1])));
Damage = Kernel.Random.Next(Math.Min((int)MinAttack, (int)MaxAttack), Math.Max((int)MinAttack, (int)MaxAttack) + 1);
if (attacker.WearsGoldPrize) Damage += (int)(Damage * goldPrizePsyAttackCoefficient);
if (attacker.OnIntensify && Time64.Now >= attacker.IntensifyStamp.AddSeconds(4))
{
Damage *= 2;
attacker.OnIntensify = false;
}
#region LuckTime
if (Kernel.Rate(5))
{
if (attacker.EntityFlag == EntityFlag.Player)
{
if (attacker.Owner.BlessTime > 0)
{
Damage *= 2;
_String str = new _String(true);
str.UID = attacker.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("LuckyGuy");
attacker.Owner.SendScreen(str, true);
}
}
}
#endregion
if (attacker.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
if (!attacker.Transformed && Damage > 1)
Damage = (int)(Damage * 1.30);
Damage += attacker.PhysicalDamageIncrease;
Damage = (int)(Damage / 4);
if (Damage <= 0)
Damage = 1;
return (uint)Damage;
#endregion
}
public static int RemoveExcessDamage(int CurrentDamage, Entity Attacker, Entity Opponent)
{
if (Opponent.EntityFlag != EntityFlag.Player)
return CurrentDamage;
if (Opponent.Reborn == 1)
CurrentDamage = (int)Math.Round((double)(CurrentDamage * 0.7));
else if (Opponent.Reborn == 2)
CurrentDamage = (int)Math.Round((double)(CurrentDamage * 0.5));
CurrentDamage = (int)Math.Round((double)(CurrentDamage * (Math.Max(0.1, 1.00 - (Opponent.ItemBless * 0.01)))));
//CurrentDamage -= (int)(CurrentDamage * Math.Min(Opponent.Gems[7], (ushort)75) / 100);
return CurrentDamage;
}
public static uint Percent(Entity attacked, float percent)
{
#region AzureShield
if (attacked.ContainsFlag2(Update.Flags2.AzureShield) && attacked.EntityFlag == EntityFlag.Player)
{
uint dam = (uint)(attacked.Hitpoints * percent);
if (attacked.AzureDamage >= dam)
{
attacked.AzureDamage -= (int)dam;
int sec = 60 - (Time64.Now - attacked.MagicShieldStamp).AllSeconds;
attacked.Owner.Send(Constants.Shield(attacked.AzureDamage, sec));
Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
attack.AttackType = Network.GamePackets.Attack.Shield;
//attack.Decoded = true;
attack.X = attacked.X;
attack.Y = attacked.Y;
attack.Attacked = attacked.UID;
//attack.Attacker = attacker.UID;
attack.Damage = (ushort)(dam);
attacked.Send(attack);
if (attacked.EntityFlag == EntityFlag.Player)
attacked.Owner.SendScreen(attack, true);
return 0;
}
else
{
dam -= (uint)attacked.AzureDamage;
attacked.AzureDamage = 0;
attacked.RemoveFlag2(Update.Flags2.AzureShield);
return (uint)dam;
}
}
else
return (uint)(attacked.Hitpoints * percent);
#endregion
}
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);
}
private static void Durability(Entity attacker, Entity attacked, Database.SpellInformation spell)
{
if (spell != null)
if (!spell.CanKill)
return;
if (attacker.EntityFlag == EntityFlag.Player)
if (attacker.Owner.Map.ID == 1039)
return;
#region Attack
if (attacker != null)
if (attacker.EntityFlag == EntityFlag.Player)
{
for (byte i = 4; i <= 6; i++)
{
if (!attacker.Owner.Equipment.Free(i))
{
var item = attacker.Owner.Equipment.TryGetItem(i);
if (i == 5)
{
if (Network.PacketHandler.IsArrow(item.ID))
{
continue;
}
}
if (Kernel.Rate(20, 100))
{
if (item.Durability != 0)
{
item.Durability--;
if (item.Durability == 0)
//attacker.Owner.UnloadItemStats(item, true);
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacker.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
if (i == 6)
break;
}
if (!attacker.Owner.Equipment.Free(10))
{
var item = attacker.Owner.Equipment.TryGetItem(10);
if (Kernel.Rate(20, 100))
{
if (item.Durability != 0)
{
item.Durability--;
if (item.Durability == 0)
//attacker.Owner.UnloadItemStats(item, true);
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacker.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
}
#endregion
#region Defence
if (attacked != null)
if (attacked.EntityFlag == EntityFlag.Player)
{
for (byte i = 1; i <= 8; i++)
{
if (i == 4 || i == 6 || i == 7)
continue;
if (!attacked.Owner.Equipment.Free(i))
{
var item = attacked.Owner.Equipment.TryGetItem(i);
if (i == 5)
{
if (Network.PacketHandler.ItemPosition(item.ID) != 5 && Network.PacketHandler.IsArrow(item.ID))
{
continue;
}
}
if (Kernel.Rate(30, 100))
{
if (item.Durability != 0)
{
item.Durability--;
if (item.Durability == 0)
//attacked.Owner.UnloadItemStats(item, true);
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacked.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
if (i == 8)
break;
}
if (!attacked.Owner.Equipment.Free(11) && Kernel.Rate(30, 100))
{
var item = attacked.Owner.Equipment.TryGetItem(11);
if (Kernel.Rate(30, 100))
{
if (item.Durability != 0)
{
item.Durability--;
if (item.Durability == 0)
//attacked.Owner.UnloadItemStats(item, true);
Database.ConquerItemTable.UpdateDurabilityItem(item);
item.Mode = Enums.ItemMode.Update;
item.Send(attacked.Owner);
item.Mode = Enums.ItemMode.Default;
}
}
}
}
#endregion
}
private static void AutoRespone(Entity attacker, Entity attacked, ref int Damage)
{
try
{
if (attacker.EntityFlag == EntityFlag.Player)
{
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 (MessiProject.Kernel.Rate(spell.Percent))
{
var ent = attacked as Entity;
if (!ent.IsBlackSpotted)
{
ent.IsBlackSpotted = true;
ent.BlackSpotStamp = Time64.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.Player)
{
if (attacked.Owner.Spells.ContainsKey(11130) && attacked.Owner.Entity.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.Entity.IsEagleEyeShooted = false;
SpellUse ssuse = new SpellUse(true);
ssuse.Attacker = attacked.UID;
ssuse.SpellID = spell.ID;
ssuse.SpellLevel = spell.Level;
ssuse.AddTarget(attacked.Owner.Entity.UID, new SpellUse.DamageClass().Damage = 11030, null);
if (attacked.EntityFlag == EntityFlag.Player)
{
attacked.Owner.SendScreen(ssuse, true);
}
}
}
}
if (attacked.CounterKillSwitch && Kernel.Rate(30) && !attacker.ContainsFlag(Update.Flags.Fly) && Time64.Now > attacked.CounterKillStamp.AddSeconds(15))
{
attacked.CounterKillStamp = Time64.Now;
Network.GamePackets.Attack attack = new MessiProject.Network.GamePackets.Attack(true);
attack.Effect1 = Attack.AttackEffects1.None;
uint damage = Melee(attacked, attacker, ref attack);
//Database.SpellInformation information = Database.SpellTable.SpellInformations[6003][attacked.Owner.Spells[6003].Level];
damage = (uint)(damage / 1.2);
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.Player)
{
attacked.Owner.UpdateQualifier(attacked.Owner, attacker.Owner, attacker.Hitpoints);
attacker.Owner.SendScreen(attack, true);
attacked.AttackPacket = null;
}
else
{
attacker.MonsterInfo.SendScreen(attack);
}
attacker.Die(attacked);
}
else
{
attacker.Hitpoints -= damage;
if (attacker.EntityFlag == EntityFlag.Player)
{
attacked.Owner.UpdateQualifier(attacked.Owner, attacker.Owner, 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 MessiProject.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.Player)
{
attacked.Owner.UpdateQualifier(attacked.Owner, attacker.Owner, attacker.Hitpoints);
attacker.Owner.SendScreen(attack, true);
attacked.AttackPacket = null;
}
else
{
attacker.MonsterInfo.SendScreen(attack);
}
attacker.Die(attacked);
}
else
{
attacker.Hitpoints -= damage;
if (attacker.EntityFlag == EntityFlag.Player)
{
attacked.Owner.UpdateQualifier(attacked.Owner, attacker.Owner, damage);
attacker.Owner.SendScreen(attack, true);
}
else
{
attacker.MonsterInfo.SendScreen(attack);
}
}
Damage = 0;
}
}
}
catch (Exception e) { Program.SaveException(e); }
}
public static int GetLevelBonus(int l1, int l2)
{
int num = l1 - l2;
int bonus = 0;
if (num >= 3)
{
num -= 3;
bonus = 1 + (num / 5);
}
return bonus;
}
private static double AttackMultiplier(Entity attacker, Entity attacked)
{
if (attacked.Level > attacker.Level)
return 1;
return ((double)(attacker.Level - attacked.Level)) / 10 + 1;
}
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;
}
public static int CalculateSkillCryitical(Entity AttackerClient, Entity AttackedClient, int damage)
{
if (AttackerClient.SkillCStrike == AttackedClient.Immunity || AttackerClient.SkillCStrike <= AttackedClient.Immunity)
return damage;
damage = (int)((double)damage * 1.5);
return damage;
}
public static int CalculateMaleCryitical(Entity AttackerClient, Entity AttackedClient, int damage)
{
if (AttackerClient.CriticalStrike == AttackedClient.Immunity || AttackerClient.CriticalStrike <= AttackedClient.Immunity)
return damage;
damage = (int)((double)damage * 1.5);
return damage;
}
public static int CalculateBreak(Entity AttackerClient, Entity AttackedClient, int damage)
{
/*if ((int)AttackerClient.Breaktrough == (int)AttackedClient.Counteraction || (int)AttackerClient.Breaktrough <= (int)AttackedClient.Counteraction)
return damage;
int num = (int)AttackerClient.Breaktrough - (int)AttackedClient.Counteraction;
damage += damage * (num / 100) / 100;
return damage;*/
if (AttackerClient.Breaktrough == AttackedClient.Counteraction || AttackerClient.Breaktrough <= AttackedClient.Counteraction)
return damage;
damage = (int)((double)damage * 1.5);
return damage;
}
public static bool IsTargetDodged(Entity attacker, Entity attacked)
{
int num = 0;
if (attacked.EntityFlag == EntityFlag.Player)
num = 40;
if (!attacked.Transformed)
Math.Min(100, Math.Max(0, 100 + (int)(ushort)(attacker.frequency * 0.25) + (int)attacker.Gems[2] + attacker.HitRate - num - (int)attacked.Dodge));
else
Math.Min(100, Math.Max(0, 100 + attacker.TransformationHitRate - num - (int)attacked.TransformationDodge));
return false;
}
}
}