Code:
#region attack
public void Attack()
{
LastAttack = DateTime.Now;
if (!Alive)
{
MobTarget = null;
SkillLoopingTarget = 0;
TGTarget = null;
PTarget = null;
return;
}
Ready = false;
try
{
if (AtkType == 25 || AtkType == 2)
{
if (!WeaponSkill())
{
if (MobTarget != null)
{
if (MobTarget.Alive)
if (MobTarget.Map == LocMap)
if (MyMath.PointDistance(LocX, LocY, MobTarget.PosX, MobTarget.PosY) < 6 || AtkType == 25)
{
if (!SMOn && !AccuracyOn)
{
if (!Other.ChanceSuccess(RealAgi / 2 + Math.Abs((110 - Level) / 2)))
{
MissAttack(MobTarget);
return;
}
}
else if (SMOn)
{
if (!Other.ChanceSuccess(RealAgi + Math.Abs((110 - Level) / 2)))
{
MissAttack(MobTarget);
return;
}
}
else
{
if (!Other.ChanceSuccess(RealAgi * 1.2 + Math.Abs((110 - Level) / 2)))
{
MissAttack(MobTarget);
return;
}
}
double LDF = (Level - MobTarget.Level + 7) / 5;
LDF = Math.Max(LDF, 1);
double eDMG = ((Convert.ToUInt32(LDF) - 1) * .8) + 1;
double AttackDMG = (double)General.Rand.Next((int)MinAtk, (int)MaxAtk) * eDMG;
if (StigBuff)
AttackDMG = (int)(AttackDMG * (double)(1 + ((double)(10 + StigLevel) / 100)));
AttackDMG = ((double)AttackDMG * AddAtkPc);
if (SMOn)
AttackDMG *= 10;
double ProfExpAdd = 0;
double ExpQuality = 0;
if (MobTarget.Level + 4 < Level)
ExpQuality = 0.1;
if (MobTarget.Level + 4 >= Level)
ExpQuality = 1;
if (MobTarget.Level >= Level)
ExpQuality = 1.1;
if (MobTarget.Level - 4 > Level)
ExpQuality = 1.3;
double EAddExp = 0;
ulong UAddExp = 0;
uint MobCurHP = MobTarget.CurHP;
if (MobTarget.MType == 1)
AttackDMG /= 100;
if (MobTarget.MType == 1)
{
BlueName = true;
GotBlueName = DateTime.Now;
MyClient.SendPacket(General.MyPackets.Vital(UID, 26, GetStat()));
World.UpdateSpawn(this);
}
if (!Praying && !CastingPray == true && Other.ChanceSuccess(9.7) && Stamina < 100)
{
Stamina = 100;
MyClient.SendPacket(General.MyPackets.Vital(UID, 9, Stamina));
MyClient.SendPacket(General.MyPackets.SendMsg(MyClient.MessageId, "System", Name, "You got lucky and got your stamina refilled!", 2005));
MyClient.SendPacket(General.MyPackets.String(UID, 10, "LuckyGuy"));
}
if (!Praying && !CastingPray == true && Other.ChanceSuccess(6.7))
{
XpCircle = 100;
XpList = true;
MyClient.SendPacket(General.MyPackets.Vital(UID, 26, GetStat()));
XpCircle = 0;
MyClient.SendPacket(General.MyPackets.SendMsg(MyClient.MessageId, "System", Name, "You got lucky and your XP skill activated!", 2005));
MyClient.SendPacket(General.MyPackets.String(UID, 10, "LuckyGuy"));
}
if (!Praying && !CastingPray == true && Other.ChanceSuccess(6.9))
{
AttackDMG *= 2;
MyClient.SendPacket(General.MyPackets.SendMsg(MyClient.MessageId, "System", Name, "You got lucky and attacked double damage!", 2005));
MyClient.SendPacket(General.MyPackets.String(UID, 10, "LuckyGuy"));
}
if (MobTarget.GetDamage((uint)AttackDMG))
{
if (MobTarget.Name == QuestMob)
{
QuestKO++;
if (QuestKO >= 300)
{
MyClient.SendPacket(General.MyPackets.SendMsg(MyClient.MessageId, "SYSTEM", Name, "You have killed enough monsters for the quest. Go report to the captain.", 2005));
}
}
Attacking = false;
if (Level >= 70)
{
foreach (Character Member in Team)
{
if (!Member.Alive)
continue;
double PlvlExp = 1;
if (MobTarget.Level - 20 <= Member.Level)
PlvlExp = 0.1;
if (Member != null)
if (Member.Level + 20 < Level)
if (Member.LocMap == LocMap)
if (MyMath.PointDistance(Member.LocX, Member.LocY, LocX, LocY) < 30)
if (Member.AddExp((ulong)((double)(52 + (Member.Level * 30)) * PlvlExp), true))
{
VP += (uint)((Member.Level * 17 / 13 * 12 / 2) + Member.Level * 3);
Member.MyTeamLeader.MyClient.SendPacket(General.MyPackets.SendMsg(Member.MyClient.MessageId, "SYSTEM", Member.Name, Name + " has gained " + ((Member.Level * 17 / 13 * 12 / 2) + Member.Level * 3) + " virtue points.", 2003));
foreach (Character Member2 in Team)
{
if (Member2 != null)
Member2.MyClient.SendPacket(General.MyPackets.SendMsg(Member2.MyClient.MessageId, "SYSTEM", Member2.Name, Name + " has gained " + ((Member.Level * 17 / 13 * 12 / 2) + Member.Level * 3) + " virtue points.", 2003));
}
}
}
}
XpCircle++;
if (CycloneOn || SMOn)
ExtraXP += 820;
TargetUID = 0;
EAddExp = MobCurHP * ExpQuality;
UAddExp = Convert.ToUInt64(EAddExp);
AddExp(UAddExp, true);
ProfExpAdd = MobCurHP;
MobTarget.Death = DateTime.Now;
if (Equips[4] != null && Equips[4] != "0")
{
string[] Splitter2 = Equips[4].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
if (Equips[5] != null && Equips[5] != "0")
{
string[] Splitter2 = Equips[5].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
World.AttackMob(this, MobTarget, AtkType, (uint)AttackDMG);
World.AttackMob(this, MobTarget, 14, 0);
World.MobDissappear(MobTarget);
MobTarget.Death = DateTime.Now;
MobTarget = null;
}
else
{
EAddExp = AttackDMG * ExpQuality;
UAddExp = Convert.ToUInt64(EAddExp);
AddExp(UAddExp, true);
ProfExpAdd = AttackDMG;
if (Equips[4] != null && Equips[4] != "0")
{
string[] Splitter2 = Equips[4].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
if (Equips[5] != null && Equips[5] != "0")
{
string[] Splitter2 = Equips[5].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
World.AttackMob(this, MobTarget, AtkType, (uint)AttackDMG);
}
}
else
{
MobTarget = null;
}
}
else if (PTarget != null && (PKMode == 2 || PKMode == 0) && !Other.NoPK(LocMap) && PTarget.Alive)
{
if (PTarget.Alive)
if (LocMap == PTarget.LocMap)
if (AtkType == 2 && MyMath.PointDistance(LocX, LocY, PTarget.LocX, PTarget.LocY) < 5 || AtkType == 25 && MyMath.PointDistance(LocX, LocY, PTarget.LocX, PTarget.LocY) < 16)
{
int Damage = General.Rand.Next((int)MinAtk, (int)MaxAtk);
if (!SMOn && !AccuracyOn)
{
if (!Other.ChanceSuccess(RealAgi / 1.7 + Math.Abs((110 - Level) / 2)))
{
MissAttack(PTarget);
return;
}
}
else if (SMOn)
{
if (!Other.ChanceSuccess(RealAgi + Math.Abs((110 - Level) / 2)))
{
MissAttack(PTarget);
return;
}
}
else
{
if (!Other.ChanceSuccess(RealAgi * 1.2 + Math.Abs((110 - Level) / 2)))
{
MissAttack(PTarget);
return;
}
}
double reborn = 1;
int Atk = General.Rand.Next((int)MyClient.MyChar.MinAtk, (int)MyClient.MyChar.MaxAtk);
Atk = (int)((double)Atk * MyClient.MyChar.AddAtkPc);
if (SMOn)
Atk *= 2;
if (StigBuff)
Atk = (int)(Atk * (double)(1 + ((double)(10 + MyClient.MyChar.StigLevel) / 100)));
if (PTarget.RBCount == 1)
reborn = 0.7;
else if (PTarget.RBCount == 2)
reborn = 0.4;
double Dodge = (double)(PTarget.Dodge / 100);
if (Dodge == 0)
Dodge = 1;
Damage = (int)(((Atk - PTarget.Defense) * reborn) * Dodge);
if (Damage < 1)
Damage = 1;
if (PTarget.PKPoints < 100)
if (!PTarget.BlueName)
if (!Other.CanPK(LocMap))
if (LocMap != 1005 && LocMap != 6000 && LocMap != 1038)
{
PKPoints += 0;
GotBlueName = DateTime.Now;
BlueName = false;
MyClient.SendPacket(General.MyPackets.Vital(UID, 26, GetStat()));
World.UpdateSpawn(this);
}
World.PVP(this, PTarget, AtkType, (uint)Damage);
if (PTarget.GetHitDie((uint)Damage))
{
Attacking = false;
if (!Other.CanPK(LocMap))
if (!PTarget.BlueName)
if (PTarget.PKPoints < 100)
{
GotBlueName = DateTime.Now;
BlueName = false;
PKPoints += 0;
MyClient.SendPacket(General.MyPackets.Vital(UID, 6, PKPoints));
if ((PKPoints > 29 && PKPoints - 10 < 30) || (PKPoints > 99 && PKPoints - 10 < 100))
{
MyClient.SendPacket(General.MyPackets.Vital(UID, 26, GetStat()));
World.UpdateSpawn(this);
}
}
World.PVP(this, PTarget, 14, 0);
PTarget.PTarget = null;
PTarget.MobTarget = null;
PTarget = null;
}
}
else
PTarget = null;
}
else if (TGTarget != null)
if (Level >= TGTarget.Level)
{
{
if (!SMOn && !AccuracyOn)
{
if (!Other.ChanceSuccess(RealAgi / 1.7 + Math.Abs((110 - Level) / 2)))
{
MissAttack(TGTarget);
return;
}
}
else if (SMOn)
{
if (!Other.ChanceSuccess(RealAgi + Math.Abs((110 - Level) / 2)))
{
MissAttack(TGTarget);
return;
}
}
else
{
if (!Other.ChanceSuccess(RealAgi * 1.2 + Math.Abs((110 - Level) / 2)))
{
MissAttack(TGTarget);
return;
}
}
uint Damage = (uint)General.Rand.Next((int)MinAtk, (int)MaxAtk);
uint THP = TGTarget.CurHP;
Damage = (uint)((double)Damage * AddAtkPc);
if (StigBuff)
Damage = (uint)(Damage * (double)(1 + ((double)(10 + StigLevel) / 100)));
double ExpQuality = 1;
if (TGTarget.Level + 5 < Level)
ExpQuality = 0.1;
if (TGTarget.GetDamageDie((uint)Damage, this))
{
AddExp((ulong)(THP / 10 * ExpQuality), true);
uint ProfExpAdd = THP / 10;
if (Equips[4] != null && Equips[4] != "0")
{
string[] Splitter2 = Equips[4].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
if (Equips[5] != null && Equips[5] != "0")
{
string[] Splitter2 = Equips[5].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
};
World.PlAttacksTG(TGTarget, this, (byte)AtkType, (uint)Damage);
World.PlAttacksTG(TGTarget, this, 14, (uint)Damage);
}
else
{
AddExp((ulong)(Damage / 10 * ExpQuality), true);
uint ProfExpAdd = Damage / 10;
if (Equips[4] != null && Equips[4] != "0")
{
string[] Splitter2 = Equips[4].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
}
if (Equips[5] != null && Equips[5] != "0")
{
string[] Splitter2 = Equips[5].Split('-');
if (Other.ItemType(uint.Parse(Splitter2[0])) == 4 || Other.ItemType(uint.Parse(Splitter2[0])) == 5)
AddProfExp((short)Other.WeaponType(uint.Parse(Splitter2[0])), (uint)(ProfExpAdd * AddProfPc));
};
World.PlAttacksTG(TGTarget, this, (byte)AtkType, (uint)Damage);
}
}
}
else
MyClient.SendPacket(General.MyPackets.SendMsg(MyClient.MessageId, "SYSTEM", Name, "You can't attack this, you are not high level enough. Find a lower level one.", 2000));
Ready = true;
}
}
else if (AtkType == 21)
{
if (SkillLooping != 0)
{
if (SkillLoopingTarget != 0)
{
if (SkillLoopingTarget > 400000 && SkillLoopingTarget < 500000)
{
SingleMob Targ = (SingleMob)Mobs.AllMobs[SkillLoopingTarget];
if (Targ == null || !Targ.Alive)
return;
else
UseSkill(SkillLooping, (ushort)Targ.PosX, (ushort)Targ.PosY, SkillLoopingTarget);
}
else if (SkillLoopingTarget < 7000 && SkillLoopingTarget >= 5000)
{
SingleNPC Targ = (SingleNPC)NPCs.AllNPCs[SkillLoopingTarget];
if (Targ == null)
return;
else
UseSkill(SkillLooping, (ushort)Targ.X, (ushort)Targ.Y, SkillLoopingTarget);
}
else
{
Character Targ = (Character)World.AllChars[SkillLoopingTarget];
if (Targ == null || !Targ.Alive)
return;
else
UseSkill(SkillLooping, Targ.LocX, Targ.LocY, SkillLoopingTarget);
}
}
else
{
UseSkill(SkillLooping, SkillLoopingX, SkillLoopingY, 0);
}
}
else
{
SkillLooping = 0;
}
}
Ready = true;
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
}
#endregion