Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NewestCOServer.Game
{
public enum AttackType : byte
{
Melee = 2,
Ranged = 28,
Magic = 21,
Kill = 14,
FatalStrike = 45,
Scapegoat = 43
}
public enum MobBehaveour : byte
{
HuntPlayers = 1,
HuntMobs = 2,
HuntMobsAndPlayers = 3,
HuntBlueNames = 4,
HuntMobsAndBlue = 6
}
public class Mob
{
DateTime LastMove;
public byte Direction = 0;
public byte Action = 0;
public uint EntityID;
public Location Loc;
public Location StartLoc;
public bool Alive = true;
public bool Dissappeared = false;
public DateTime Died;
public uint RandomTime = 30;
public static Random Rnd = new Random();
public static DateTime LastTarget = DateTime.Now;
Character PlayerTarget;
Mob MobTarget;
public int MobID;
public ushort Mesh;
public byte Level;
public uint MaxHP;
public uint CurrentHP;
public ushort Defense;
public ushort MDef;
public ushort MAttack;
public ushort MinAttack;
public ushort MaxAttack;
public string Name;
public MobBehaveour Type;
public byte DmgReduceTimes;
public AttackType AtkType;
public byte Dodge;
public bool Gives;
public byte AttackDist;
public ushort MagicSkill = 0;
public byte MagicLvl = 0;
public int MinSilvers;
public int MaxSilvers;
uint SpawnSpeed = 0;
ushort MoveSpeed = 0;
bool LevDifDmg = true;
public PoisonType PoisonedInfo = null;
public Mob(string Line)
{
LastMove = DateTime.Now;
string[] Info = Line.Split(' ');
MobID = int.Parse(Info[0]);
Name = Info[1];
Type = (MobBehaveour)byte.Parse(Info[2]);
Mesh = ushort.Parse(Info[3]);
Level = byte.Parse(Info[4]);
MaxHP = uint.Parse(Info[5]);
Defense = ushort.Parse(Info[6]);
MDef = ushort.Parse(Info[7]);
MAttack = ushort.Parse(Info[8]);
MinAttack = ushort.Parse(Info[9]);
MaxAttack = ushort.Parse(Info[10]);
DmgReduceTimes = byte.Parse(Info[11]);
Dodge = byte.Parse(Info[12]);
AtkType = (AttackType)byte.Parse(Info[13]);
if (AtkType == AttackType.Magic)
{
MagicSkill = ushort.Parse(Info[14]);
MagicLvl = byte.Parse(Info[15]);
Gives = bool.Parse(Info[16]);
AttackDist = byte.Parse(Info[17]);
MinSilvers = int.Parse(Info[18]);
MaxSilvers = int.Parse(Info[19]);
MoveSpeed = ushort.Parse(Info[20]);
SpawnSpeed = uint.Parse(Info[21]);
LevDifDmg = bool.Parse(Info[22]);
}
else
{
Gives = bool.Parse(Info[14]);
AttackDist = byte.Parse(Info[15]);
MinSilvers = int.Parse(Info[16]);
MaxSilvers = int.Parse(Info[17]);
MoveSpeed = ushort.Parse(Info[18]);
SpawnSpeed = uint.Parse(Info[19]);
LevDifDmg = bool.Parse(Info[20]);
}
CurrentHP = MaxHP;
}
public Mob(Mob M)
{
LastMove = DateTime.Now;
MobID = M.MobID;
Mesh = M.Mesh;
Level = M.Level;
MaxHP = M.MaxHP;
CurrentHP = M.CurrentHP;
Defense = M.Defense;
MDef = M.MDef;
MAttack = M.MAttack;
MinAttack = M.MinAttack;
MaxAttack = M.MaxAttack;
Name = M.Name;
Type = M.Type;
DmgReduceTimes = M.DmgReduceTimes;
Dodge = M.Dodge;
AtkType = M.AtkType;
Gives = M.Gives;
AttackDist = M.AttackDist;
MagicSkill = M.MagicSkill;
MagicLvl = M.MagicLvl;
MinSilvers = M.MinSilvers;
MaxSilvers = M.MaxSilvers;
MoveSpeed = M.MoveSpeed;
SpawnSpeed = M.SpawnSpeed;
LevDifDmg = M.LevDifDmg;
}
uint PrepareAttack()
{
if (AtkType == AttackType.Melee || AtkType == AttackType.Ranged)
return (uint)Rnd.Next(MinAttack, MaxAttack);
else
return MAttack;
}
public bool NeedsPKMode
{
get
{
if (Type == MobBehaveour.HuntBlueNames || Type == MobBehaveour.HuntMobsAndBlue)
return true;
return false;
}
}
public uint TakeAttack(Character Attacker,ref uint Damage, AttackType AT, bool IsSkill)
{
if (AT != AttackType.Magic && Attacker.BuffOf(Features.SkillsClass.ExtraEffect.Superman).Eff == Features.SkillsClass.ExtraEffect.Superman)
Damage *= 10;
if (!IsSkill && Attacker.BuffOf(Features.SkillsClass.ExtraEffect.FatalStrike).Eff == Features.SkillsClass.ExtraEffect.FatalStrike)
{
AT = AttackType.FatalStrike;
Damage *= 5;
}
double e = 1;
if (Level + 4 < Attacker.Level)
e = 0.1;
if (Level + 4 >= Attacker.Level)
e = 1;
if (Level >= Attacker.Level)
e = 1.1;
if (Level - 4 > Attacker.Level)
e = 1.3;
if (Type == MobBehaveour.HuntBlueNames || Type == MobBehaveour.HuntMobsAndBlue)
{
Attacker.BlueName = true;
if (Attacker.BlueNameLasts < 60)
Attacker.BlueNameLasts = 15;
}
if (AT != AttackType.Magic && !IsSkill)
{
short _Agi = (short)(Attacker.Agi + Attacker.EqStats.ExtraDex);
Buff Accuracy = Attacker.BuffOf(Features.SkillsClass.ExtraEffect.Accuracy);
if (Accuracy.Eff == Features.SkillsClass.ExtraEffect.Accuracy)
_Agi = (short)(_Agi * Accuracy.Value);
Buff SM = Attacker.BuffOf(Features.SkillsClass.ExtraEffect.Superman);
if (SM.StEff == StatusEffectEn.SuperMan)
_Agi *= 2;
double MissValue = Rnd.Next(15 + _Agi, _Agi + Dodge + 15);
if (MissValue <= Dodge && AT != AttackType.FatalStrike)
Damage = 0;
else
{
if (LevDifDmg) Damage = (uint)(Damage * MyMath.LevelDifference(Attacker.Level, Level));
}
}
if (!IsSkill && Damage != 0)
{
if (AT == AttackType.Melee || AT == AttackType.FatalStrike)
{
if (Defense >= Damage)
Damage = 1;
else
Damage -= Defense;
Damage += Attacker.EqStats.MeleeDamageIncrease;
}
else if (AT == AttackType.Ranged)
{
Damage = (uint)((double)Damage * ((double)(200 - Dodge) / 100));
Damage += Attacker.EqStats.MeleeDamageIncrease;
}
else
{
if (MDef >= Damage)
Damage = 1;
else
Damage -= MDef;
Damage += Attacker.EqStats.MagicDamageIncrease;
}
Damage = (uint)(Damage / DmgReduceTimes);
}
uint Exp = 0;
if (Damage < CurrentHP)
{
CurrentHP -= Damage;
if (!IsSkill)
{
if (AT == AttackType.FatalStrike)
{
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, (ushort)(Loc.X + 1), (ushort)(Loc.Y + 1), Damage, (byte)AT).Get);
Attacker.Shift((ushort)(Loc.X), (ushort)(Loc.Y));
}
else if (AT == AttackType.Scapegoat)
{
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, 43).Get);
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, 2).Get);
}
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
}
if (Gives)
{
Exp = (uint)(Damage * e);
if (!IsSkill)
{
if (AT == AttackType.Ranged || AT == AttackType.Melee || AT == AttackType.FatalStrike)
{
if (Attacker.Equips.RightHand.ID != 0)
Attacker.AddProfExp((ushort)Game.ItemIDManipulation.Part(Attacker.Equips.RightHand.ID, 0, 3), Damage);
if (Attacker.Equips.LeftHand.ID != 0)
Attacker.AddProfExp((ushort)Game.ItemIDManipulation.Part(Attacker.Equips.LeftHand.ID, 0, 3), Damage / 3 * 2);
}
}
}
}
else
{
Attacker.XPKO++;
if (Attacker.Superman || Attacker.Cyclone)
Attacker.TotalKO++;
if (Attacker.MHunter == true & Attacker.HunterName == Name)
{
Attacker.MonsterHunter++;
}
PlayerTarget = null;
Alive = false;
uint Benefit = CurrentHP;
CurrentHP = 0;
PoisonedInfo = null;
Died = DateTime.Now;
if (!IsSkill)
{
if (AT == AttackType.FatalStrike)
{
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, (ushort)(Loc.X + 1), (ushort)(Loc.Y + 1), Damage, (byte)AT).Get);
Attacker.Shift((ushort)(Loc.X), (ushort)(Loc.Y));
}
else if (AT == AttackType.Scapegoat)
{
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, 43).Get);
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, 2).Get);
}
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
}
if (Attacker.Superman || Attacker.Cyclone)
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, (uint)(65536 * Attacker.TotalKO), (byte)AttackType.Kill).Get);
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, (uint)(1), (byte)AttackType.Kill).Get);
World.Action(this, Packets.Status(EntityID, Status.Effect, 2080).Get);
Attacker.AtkMem.Attacking = false;
Attacker.AtkMem.Target = 0;
if (Gives)
{
Exp = (uint)(Benefit * e);
if (Attacker.MyTeam != null)
{
foreach (Character C in Attacker.MyTeam.Members)
{
if (C != Attacker && C.Alive && MyMath.InBox(C.Loc.X, C.Loc.Y, Attacker.Loc.X, Attacker.Loc.Y, 18))
{
if (C.Level + 20 > Level || C.Level >= 70)
{
C.IncreaseExp(MaxHP / 10, true);
}
else
{
uint Amount = (uint)(356 + (C.Level * 27));
byte Lev = C.Level;
C.IncreaseExp(Amount, true);
for (; Lev < C.Level; Lev++)
{
uint VPAmount = (uint)Math.Max(1, Lev * 12 - 17);
Attacker.MyTeam.Leader.VP += VPAmount;
Attacker.MyTeam.Message(Packets.ChatMessage(45216, "SYSTEM", "ALL", Attacker.MyTeam.Leader.Name + " gained " + VPAmount + " virtue points.", 2003, 0));
}
}
}
}
}
Attacker.IncreaseExp(MaxHP / 10, false);
if (!IsSkill)
{
if (AT == AttackType.Ranged || AT == AttackType.Melee || AT == AttackType.FatalStrike)
{
if (Attacker.Equips.RightHand.ID != 0)
Attacker.AddProfExp((ushort)Game.ItemIDManipulation.Part(Attacker.Equips.RightHand.ID, 0, 3), Benefit);
if (Attacker.Equips.LeftHand.ID != 0)
Attacker.AddProfExp((ushort)Game.ItemIDManipulation.Part(Attacker.Equips.LeftHand.ID, 0, 3), Benefit / 3 * 2);
}
}
DropAnItem(Attacker.EntityID, Attacker.Level);
}
}
if (!IsSkill)
Attacker.IncreaseExp(Exp, false);
return Exp;
}
public void TakeAttack(Mob Attacker, uint Damage, AttackType AT)
{
try
{
if (LevDifDmg) Damage = (uint)(Damage * MyMath.LevelDifference(Attacker.Level, Level));
Damage = (uint)(Damage / DmgReduceTimes);
if (AT == AttackType.Melee)
{
if (Defense >= Damage)
Damage = 1;
else
Damage -= Defense;
}
else if (AT == AttackType.Ranged)
Damage = (uint)((double)Damage * ((double)Dodge / 100));
else if (AT == AttackType.Magic)
{
if (MDef >= Damage)
Damage = 1;
else
Damage -= MDef;
}
if (Damage < CurrentHP)
{
CurrentHP -= Damage;
if (AT == AttackType.Magic)
World.Action(this, Packets.SkillUse(Attacker.EntityID, EntityID, Damage, Attacker.MagicSkill, Attacker.MagicLvl, Loc.X, Loc.Y).Get);
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
}
else
{
PoisonedInfo = null;
PlayerTarget = null;
Alive = false;
uint Benefit = CurrentHP;
CurrentHP = 0;
Died = DateTime.Now;
if (AT == AttackType.Magic)
World.Action(this, Packets.SkillUse(Attacker.EntityID, EntityID, Damage, Attacker.MagicSkill, Attacker.MagicLvl, Loc.X, Loc.Y).Get);
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AttackType.Kill).Get);
World.Action(this, Packets.Status(EntityID, Status.Effect, 2080).Get);
if (Gives)
DropAnItem(0, Attacker.Level);
}
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
public void TakeAttack(Companion Attacker, uint Damage, AttackType AT)
{
try
{
if (LevDifDmg) Damage = (uint)(Damage * MyMath.LevelDifference(Attacker.Level, Level));
Damage = (uint)(Damage / DmgReduceTimes);
if (AT == AttackType.Melee)
{
if (Defense >= Damage)
Damage = 1;
else
Damage -= Defense;
}
else if (AT == AttackType.Ranged)
Damage = (uint)((double)Damage * ((double)Dodge / 100));
else if (AT == AttackType.Magic)
{
if (MDef >= Damage)
Damage = 1;
else
Damage -= MDef;
}
if (Damage < CurrentHP)
{
CurrentHP -= Damage;
if (AT == AttackType.Magic)
World.Action(this, Packets.SkillUse(Attacker.EntityID, EntityID, Damage, (ushort)Attacker.SkillUses, 0, Loc.X, Loc.Y).Get);
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
if (Gives)
Attacker.Owner.IncreaseExp(Damage, false);
}
else
{
PoisonedInfo = null;
PlayerTarget = null;
Alive = false;
uint Benefit = CurrentHP;
CurrentHP = 0;
Died = DateTime.Now;
if (AT == AttackType.Magic)
World.Action(this, Packets.SkillUse(Attacker.EntityID, EntityID, Damage, (ushort)Attacker.SkillUses, 0, Loc.X, Loc.Y).Get);
else
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AT).Get);
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AttackType.Kill).Get);
World.Action(this, Packets.Status(EntityID, Status.Effect, 2080).Get);
if (Gives)
{
DropAnItem(Attacker.Owner.EntityID, Attacker.Level);
Attacker.Owner.IncreaseExp(Benefit, false);
}
}
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
void DropAnItem(uint Owner, byte OwnerLevel)
{
try
{
ArrayList Arr = (ArrayList)DropRates.Specifics[MobID];
if (Arr != null)
{
foreach (DropRates.RateItemInfo R in Arr)
{
if (MyMath.ChanceSuccess(R.DropChance) && Level + 20 > OwnerLevel)
{
DroppedItem DI = new DroppedItem();
DI.DropTime = DateTime.Now;
DI.UID = (uint)Rnd.Next(10000000);
DI.Loc = new Location();
DI.Loc.X = (ushort)(Loc.X + Rnd.Next(4) - Rnd.Next(4));
DI.Loc.Y = (ushort)(Loc.Y + Rnd.Next(4) - Rnd.Next(4));
DI.Loc.Map = Loc.Map;
DI.Info = new Item();
DI.Info.ID = R.ID;
DI.Info.UID = (uint)Rnd.Next(10000000);
DI.Info.Plus = R.Plus;
DI.Info.Bless = R.Bless;
if (R.Sockets >= 1)
DI.Info.Soc1 = Item.Gem.EmptySocket;
if (R.Sockets >= 2)
DI.Info.Soc2 = Item.Gem.EmptySocket;
try
{
DI.Info.MaxDur = DI.Info.DBInfo.Durability;
DI.Info.CurDur = DI.Info.MaxDur;
}
catch (Exception Exc) { Program.WriteLine(Exc); }
DI.Owner = Owner;
if (!DI.FindPlace((Hashtable)Game.World.H_Items[Loc.Map]))
{
DI.Loc.X = (ushort)(Loc.X + Rnd.Next(4) - Rnd.Next(4));
DI.Loc.Y = (ushort)(Loc.Y + Rnd.Next(4) - Rnd.Next(4));
}
if (!DI.FindPlace((Hashtable)Game.World.H_Items[Loc.Map])) continue;
DI.Drop();
}
}
}
DroppedItem DI2 = new DroppedItem();
DI2.DropTime = DateTime.Now;
DI2.UID = (uint)Rnd.Next(10000000);
DI2.Loc = new Location();
DI2.Loc.X = (ushort)(Loc.X + Rnd.Next(4) - Rnd.Next(4));
DI2.Loc.Y = (ushort)(Loc.Y + Rnd.Next(4) - Rnd.Next(4));
DI2.Loc.Map = Loc.Map;
DI2.Info = new Item();
DI2.Info.UID = (uint)Rnd.Next(10000000);
DI2.Owner = Owner;
Game.Character Char = null;
if (Game.World.H_Chars.ContainsKey(Owner))
Char = (Character)Game.World.H_Chars[Owner];
if (MyMath.ChanceSuccess(30))
{
DI2.Silvers = (uint)(Rnd.Next(MinSilvers, MaxSilvers) * DropRates.Silver);
if(Char != null)
if (Char.VipLevel >= 12)
{
Char.Silvers += DI2.Silvers;
return;
}
DI2.UID = (uint)Rnd.Next(10000000);
DI2.Loc.X = (ushort)(Loc.X + Rnd.Next(4) - Rnd.Next(4));
DI2.Loc.Y = (ushort)(Loc.Y + Rnd.Next(4) - Rnd.Next(4));
if (DI2.Silvers < 10)
DI2.Info.ID = 1090000;
else if (DI2.Silvers < 100)
DI2.Info.ID = 1090010;
else if (DI2.Silvers < 1000)
DI2.Info.ID = 1090020;
else if (DI2.Silvers < 3000)
DI2.Info.ID = 1091000;
else if (DI2.Silvers < 10000)
DI2.Info.ID = 1091010;
else
DI2.Info.ID = 1091020;
if (!DI2.FindPlace((Hashtable)Game.World.H_Items[Loc.Map])) return;
DI2.Drop();
}
else
{
if (MyMath.ChanceSuccess(DropRates.DragonBall))
{
if (Char != null)
if (Char.VipLevel >= 12)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(1088000);
return;
}
}
DI2.Info.ID = 1088000;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.Meteor))
{
DI2.Info.ID = 1088001;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.CPMiniBag))
{
if (Char != null)
if (Char.VipLevel >= 12)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(729910);
return;
}
}
DI2.Info.ID = 729910;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.CPBag))
{
if (Char != null)
if (Char.VipLevel >= 12)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(729911);
return;
}
}
DI2.Info.ID = 729911;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.PowerExpBall))
{
if (Char != null)
if (Char.VipLevel >= 12)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(723744);
return;
}
}
DI2.Info.ID = 723744;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.BlackToken))
{
if (Char != null)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(710564);
return;
}
}
DI2.Info.ID = 710564;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.SoulOfStar))
{
if (Char != null)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(790000);
return;
}
}
DI2.Info.ID = 790000;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.HonorCake))
{
if (Char != null)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(722415);
return;
}
}
DI2.Info.ID = 722415;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.Feed))
{
if (Char != null)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(729921);
return;
}
}
DI2.Info.ID = 729921;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.CPs))
{
{
if (Char != null)
{
Char.CPs += 500;
}
}
}
else if (MyMath.ChanceSuccess(DropRates.CPBackpack))
{
if (Char != null)
if (Char.VipLevel >= 100)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(729912);
return;
}
}
DI2.Info.ID = 729912;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
/*if (Char.Loc.Map == 1043)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721010;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1044)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721011;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1045)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721012;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1046)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721013;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1047)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721014;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1048)
{
if (Name == "Toughorn")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 721015;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}*/
try
{
if (Char.Loc.Map == 1767)
{
if (Name == "ToxicScorpion")
{
if (MyMath.ChanceSuccess(1000.5))
{
DI2.Info.ID = 710905;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 1047)
{
if (Name == "GwPrize")
{
if (MyMath.ChanceSuccess(10.5))
{
DI2.Info.ID = 2100085;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
if (Char.Loc.Map == 10000 || Char.Loc.Map == 1077 || Char.Loc.Map == 1038)
{
if (Name == "Tiger" || Name == "TeratoDragon" || Name == "Iron" || Name == "Sarah" || Name == "Hyper")
{
if (MyMath.ChanceSuccess(1000))
{
DI2.Info.ID = 710887;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}
}
}
catch{}
else if (MyMath.ChanceSuccess(DropRates.PlusOneStone))
{
DI2.Info.ID = 730001;
DI2.Info.Plus = 1;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.PlusTwoStone))
{
DI2.Info.ID = 730002;
DI2.Info.Plus = 2;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(DropRates.CleanWater))
{
DI2.Info.ID = 721258;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
/*if (Char.Loc.Map == 1002)// example map
{
if (Name == "Pheasant")
{
DI2.Info.ID = 111009;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
}*/
else if (MyMath.ChanceSuccess(DropRates.Gem))
{
DI2.Info.ID = (uint)(700001 + Rnd.Next(8) * 10);
if (MyMath.ChanceSuccess(15)) DI2.Info.ID = 700121;
if (MyMath.ChanceSuccess(15)) DI2.Info.ID = 700101;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
#region CommandTokenDrop
/*else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1043)
{
DI2.Info.ID = 721010;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1044)
{
DI2.Info.ID = 721011;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1045)
{
DI2.Info.ID = 721012;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1046)
{
DI2.Info.ID = 721013;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1047)
{
DI2.Info.ID = 721014;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}
else if (MyMath.ChanceSuccess(100) && Name == "Toughorn" && Loc.Map == 1048)
{
DI2.Info.ID = 721015;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
}*/
#endregion
else if (MyMath.ChanceSuccess(DropRates.Item))
{
Item.ItemQuality Q = Item.ItemQuality.Simple;
if (MyMath.ChanceSuccess(DropRates.Refined))
Q = Item.ItemQuality.Refined;
if (MyMath.ChanceSuccess(DropRates.Unique))
Q = Item.ItemQuality.Unique;
if (MyMath.ChanceSuccess(DropRates.Elite))
Q = Item.ItemQuality.Elite;
if (MyMath.ChanceSuccess(DropRates.Super))
Q = Item.ItemQuality.Super;
uint ItemID = 0;
ArrayList From = new ArrayList();
foreach (DatabaseItem D in Database.DatabaseItems.Values)
{
if (D.LevReq + 5 > Level && D.LevReq - 5 <= Level)
{
if (D.LevReq != 0)
From.Add(D.ID);
}
}
if (From != null)
{
byte Tries = (byte)Rnd.Next(0, From.Count);
ItemID = (uint)From[Tries];
}
if (ItemID != 0)
{
DI2.Info.ID = ItemID;
if (DI2.Info.DBInfo.LevReq != 1)
{
ItemIDManipulation E = new ItemIDManipulation(ItemID);
E.QualityChange(Q);
DI2.Info.ID = E.ToID();
}
DI2.Info.Color = Item.ArmorColor.Orange;
if (ItemIDManipulation.Digit(DI2.Info.ID, 1) == 4 || ItemIDManipulation.Digit(DI2.Info.ID, 1) == 5)
{
if (MyMath.ChanceSuccess(DropRates.OneSoc))
DI2.Info.Soc1 = Item.Gem.EmptySocket;
if (MyMath.ChanceSuccess(DropRates.TwoSoc))
{
DI2.Info.Soc1 = Item.Gem.EmptySocket;
DI2.Info.Soc2 = Item.Gem.EmptySocket;
}
}
if (MyMath.ChanceSuccess(DropRates.PlusOne))
DI2.Info.Plus = 1;
DI2.Info.MaxDur = DI2.Info.DBInfo.Durability;
DI2.Info.CurDur = DI2.Info.MaxDur;
if (Q == Item.ItemQuality.Super || Q == Item.ItemQuality.Elite)
if (Char != null)
if (Char.VipLevel >= 15)
{
if (Char.Inventory.Count <= 39)
{
Char.AddItem(DI2.Info.ID);
return;
}
}
}
}
if (DI2.Info.ID != 0)
{
if (!DI2.FindPlace((Hashtable)Game.World.H_Items[Loc.Map])) return;
DI2.Drop();
}
}
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
public void Respawn()
{
try
{
Loc = StartLoc;
Alive = true;
CurrentHP = MaxHP;
Action = 100;
World.Spawn(this, false);
World.Action(this, Packets.String(EntityID, 10, "MBStandard").Get);
Dissappeared = false;
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
public void Step()
{
try
{
if (!Alive)
{
if (!Dissappeared && DateTime.Now > Died.AddSeconds(2))
{
World.Action(this, Packets.GeneralData(EntityID, 0, 0, 0, 135).Get);
Dissappeared = true;
RandomTime = (uint)(Rnd.Next(20, 60));
}
if (DateTime.Now > Died.AddSeconds(SpawnSpeed + RandomTime))//changed back to 30 by Ricardo
Respawn();
}
if (Alive && DateTime.Now > LastMove.AddMilliseconds(1000))
{
LastMove = DateTime.Now;
if ((Type == MobBehaveour.HuntPlayers || Type == MobBehaveour.HuntMobsAndBlue) && PlayerTarget == null && MobTarget == null)
{
byte NDist = 11;
byte MaxDist = 10;
foreach (Character C in World.H_Chars.Values)
{
if (C.Loc.Map == Loc.Map)
{
if (C.Alive)
{
if (C.CanBeMeleed || AtkType != AttackType.Melee)
{
byte Dst = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
if (Dst <= MaxDist && Dst < NDist)
{
if (Type != MobBehaveour.HuntMobsAndBlue || C.BlueName)
{
NDist = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
PlayerTarget = C;
}
}
}
}
}
}
}
if (Type == MobBehaveour.HuntMobs || Type == MobBehaveour.HuntMobsAndBlue && MobTarget == null && PlayerTarget == null)
{
byte NDist = 15;
byte MaxDist = 8;
foreach (Mob M in ((Hashtable)World.H_Mobs[Loc.Map]).Values)
if (M != this && M.Type == MobBehaveour.HuntPlayers && M.Alive && MyMath.PointDistance(Loc.X, Loc.Y, M.Loc.X, M.Loc.Y) <= MaxDist && MyMath.PointDistance(Loc.X, Loc.Y, M.Loc.X, M.Loc.Y) < NDist)
{
NDist = (byte)MyMath.PointDistance(Loc.X, Loc.Y, M.Loc.X, M.Loc.Y);
MobTarget = M;
}
}
#region Player Target
if (PlayerTarget != null && (PlayerTarget.CanBeMeleed || AtkType != AttackType.Melee) && PlayerTarget.Alive && PlayerTarget.MyClient != null && MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) < Math.Max(15, (int)AttackDist) && (Type != MobBehaveour.HuntMobsAndBlue || PlayerTarget.BlueName))
{
if (MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) >= AttackDist)
{
byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) / 45 % 8)) - 1 % 8);
Direction = (byte)((int)ToDir % 8);
Location eLoc = Loc;
eLoc.Walk(Direction);
System.Collections.Hashtable H = (System.Collections.Hashtable)World.H_Mobs[Loc.Map];
bool PlaceFree = true;
if (DMaps.Loaded)
{
if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;
}
foreach (Mob M in H.Values)
if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
{
PlaceFree = false;
break;
}
if (PlaceFree)
{
World.Action(this, Packets.Movement(EntityID, Direction).Get);
World.Spawn(this, true);
Loc.Walk(Direction);
}
else
{
for (int i = 0; i < 7; i++)
{
PlaceFree = true;
eLoc = Loc;
Direction = (byte)((Direction + 1) % 8);
eLoc.Walk(Direction);
if (DMaps.Loaded)
if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;
foreach (Mob M in H.Values)
if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
{
PlaceFree = false;
break;
}
if (PlaceFree)
{
World.Action(this, Packets.Movement(EntityID, Direction).Get);
World.Spawn(this, true);
Loc.Walk(Direction);
break;
}
}
}
}
else
{
if (MyMath.ChanceSuccess(15) || Type == MobBehaveour.HuntMobsAndBlue)
PlayerTarget.TakeAttack(this, PrepareAttack(), AtkType);
else
PlayerTarget.TakeAttack(this, 0, AtkType);
}
}
else PlayerTarget = null;
#endregion
#region Mob Target
if (MobTarget != null && MobTarget.Alive && MyMath.PointDistance(Loc.X, Loc.Y, MobTarget.Loc.X, MobTarget.Loc.Y) < 13)
{
if (MyMath.PointDistance(Loc.X, Loc.Y, MobTarget.Loc.X, MobTarget.Loc.Y) >= AttackDist)
{
byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(Loc.X, Loc.Y, MobTarget.Loc.X, MobTarget.Loc.Y) / 45 % 8)) - 1 % 8);
Direction = (byte)((int)ToDir % 8);
Location eLoc = Loc;
eLoc.Walk(Direction);
System.Collections.Hashtable H = (System.Collections.Hashtable)World.H_Mobs[Loc.Map];
bool PlaceFree = true;
if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;
foreach (Mob M in H.Values)
if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
{
PlaceFree = false;
break;
}
if (PlaceFree)
{
World.Action(this, Packets.Movement(EntityID, Direction).Get);
World.Spawn(this, true);
Loc.Walk(Direction);
}
else
{
for (int i = 0; i < 7; i++)
{
PlaceFree = true;
eLoc = Loc;
Direction = (byte)((Direction + 1) % 8);
eLoc.Walk(Direction);
if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;
foreach (Mob M in H.Values)
if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
{
PlaceFree = false;
break;
}
if (PlaceFree)
{
World.Action(this, Packets.Movement(EntityID, Direction).Get);
World.Spawn(this, true);
Loc.Walk(Direction);
break;
}
}
}
}
else
{
MobTarget.TakeAttack(this, PrepareAttack(), AtkType);
}
}
else MobTarget = null;
#endregion
}
}
catch { }
}
}
}