- Joined
- Jun 20, 2005
- Messages
- 9
- Reaction score
- 1
Guard attack players, and give exp to user when he atack mob. I have based on PowerSource.
Ok lets begin
Start with Character.cs
Find:
Abowe add:
Find:
Bellow add:
search for:
and bellow add:
Next part is in Entities.cs
Search for:
replace it with:
Search for:
and bellow add:
search for:
abbowe add:
Now search for:
replace it with that:
Search:
replace it with:
Search:
and replace whole void with:
Same thing with:
Search:
Abowe add:
Find and replace:
with that:
find:
bellow add:
Next: Database.cs(External one)
find:
bellow add:
search:
bellow add:
Next Other.cs:
search for:
abowe add:
Next Packets.cs:
search for:
abowe add:
Next World.cs:
search:
abowe add:
I hope it will be usefull for someone
BTW post your comments positive or negative.
Bisiol
Edit1 I forget something
That fragment is for block you from attacking your guard
In Client.cs
search:
and replace it with:
And BlueName stuffs:
Character.cs:
search(4 times) for :
and replace all with:
search (3 times):
and replace all with:
search(3 times):
and replace all :
search(4 times):
replace all with:
Search(2 times):
replace with:
Ok lets begin
Start with Character.cs
Find:
Code:
public SingleMob MobTarget = null;
Abowe add:
Code:
public SingleMob Guard = null;
Find:
Code:
if (SkillAttributes[0] == 7)
{
Code:
if (SkillId == 4000 && Stamina >= 100)
{
if (Guard == null)
{
if (SkillLvl == 0)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 0);
if (SkillLvl == 1)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 1);
if (SkillLvl == 2)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 2);
if (SkillLvl == 3)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 3);
}
else
{
Guard.Dissappear();
if (SkillLvl == 0)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 0);
if (SkillLvl == 1)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 1);
if (SkillLvl == 2)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 2);
if (SkillLvl == 3)
Mobs.NewRBGuard(Convert.ToInt16(MyClient.MyChar.LocX), Convert.ToInt16(MyClient.MyChar.LocY), Convert.ToInt16(MyClient.MyChar.LocMap), MyClient.MyChar.UID, 3);
}
Stamina = 0;
;
MyClient.SendPacket(General.MyPackets.Vital(UID, 9, Stamina));
}
search for:
Code:
public void AddSkillExp(short Type, uint Amount)
{
Ready = false;
Amount *= ExternalDatabase.ProfExpRate;
and bellow add:
Code:
if (Type == 4000) Amount = 1;
Next part is in Entities.cs
Search for:
Code:
SingleMob Mob = new SingleMob(spawn_x, spawn_y, Convert.ToInt16(ThisSpawn[7]), uint.Parse(ThisMob[3]), uint.Parse(ThisMob[3]), short.Parse(ThisMob[6]), short.Parse(ThisMob[7]), UID, ThisMob[2], int.Parse(ThisMob[1]), short.Parse(ThisMob[4]), (byte)General.Rand.Next(8), byte.Parse(ThisMob[5]));
replace it with:
Code:
SingleMob Mob = new SingleMob(spawn_x, spawn_y, Convert.ToInt16(ThisSpawn[7]), uint.Parse(ThisMob[3]), uint.Parse(ThisMob[3]), short.Parse(ThisMob[6]), short.Parse(ThisMob[7]), UID, ThisMob[2], int.Parse(ThisMob[1]), short.Parse(ThisMob[4]), (byte)General.Rand.Next(8), byte.Parse(ThisMob[5]),0,true);
Code:
ExternalDatabase.Mobs = null;
ExternalDatabase.MobSpawns = null;
General.WriteLine("Spawned " + MobsSpawned + " mobs.");
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
}
Code:
public static void NewRBGuard(short x, short y, short map, uint owner,short glvl)
{
try
{
uint UID = (uint)General.Rand.Next(400000, 500000);
while (AllMobs.Contains(UID))
{
UID = (uint)General.Rand.Next(400000, 500000);
}
int gms=0;
uint ghp=0;
short gat=0, glv=0;
string gna="";
if (glvl == 0)
{
ghp = 10000;
gat = 300;
gna = "IronGuard";
gms = 920;
glv = 60;
}
else if (glvl == 1)
{
ghp = 20000;
gat = 600;
gna = "CopperGuard";
gms = 920;
glv = 90;
}
else if (glvl == 2)
{
ghp = 34895;
gat = 900;
gna = "SilverGuard";
gms = 920;
glv = 110;
}
else
{
ghp = 60000;
gat = 1300;
gna = "GoldGuard";
gms = 920;
glv = 120;
}
SingleMob Mob = new SingleMob(x, y, map, ghp, ghp, 150, gat, UID, gna, gms, glv, (byte)General.Rand.Next(8), 7, owner, false);
AllMobs.Add(UID, Mob);
Other.Charowner(owner).Guard = Mob;
World.SpawnMobForPlayers(Mob, true);
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
}
}
Code:
DateTime LastTargetting;
DateTime LastMove;
public DateTime Death;
bool Revive = false;
Code:
DateTime LastAtack;
Now search for:
Code:
public Timer MyTimer = new Timer();
Character Target = null;
replace it with that:
Code:
public Timer MyTimer = new Timer();
Character Target = null;
SingleMob Target2 = null;
public uint owner = 0;
Character owner2 = null;
public bool frev = true;
Code:
public SingleMob(short x, short y, short map, uint maxhp, uint curhp, short minatk, short maxatk, uint uid, string name, int mech, short lvl, byte pos, byte Type)
{
PosX = x;
PosY = y;
Map = map;
MaxHP = maxhp;
CurHP = curhp;
MinAtk = minatk;
MaxAtk = maxatk;
UID = uid;
Name = name;
Mech = mech;
Level = lvl;
Pos = pos;
XStart = PosX;
YStart = PosY;
Alive = true;
if (Type == 2)
BossMob = true;
MType = Type;
PrevX = PosX;
PrevY = PosY;
MyTimer.Interval = 500;
MyTimer.Elapsed += new ElapsedEventHandler(TimerElapsed);
MyTimer.Start();
}
Code:
public SingleMob(short x, short y, short map, uint maxhp, uint curhp, short minatk, short maxatk, uint uid, string name, int mech, short lvl, byte pos, byte Type, uint owner, bool Alive)
{
PosX = x;
PosY = y;
Map = map;
MaxHP = maxhp;
CurHP = curhp;
MinAtk = minatk;
MaxAtk = maxatk;
UID = uid;
Name = name;
Mech = mech;
Level = lvl;
Pos = pos;
XStart = PosX;
YStart = PosY;
Alive = true;
frev = true;
if (Type == 2)
BossMob = true;
MType = Type;
if (owner != 0)
owner2 = Other.Charowner(owner);
PrevX = PosX;
PrevY = PosY;
if (MType==7)
MyTimer.Interval = 100;
else
MyTimer.Interval = 500;
MyTimer.Elapsed += new ElapsedEventHandler(TimerElapsed);
MyTimer.Start();
}
Search:
Code:
public void TimerElapsed(object source, ElapsedEventArgs e)
and replace whole void with:
Code:
public void TimerElapsed(object source, ElapsedEventArgs e)
{
if (MType == 7)
{
GetTarget();
}
else
{
if (DateTime.Now > LastTargetting.AddMilliseconds(2000))
GetTarget();
}
if (Target != null)
if (Target.MyClient == null || !Target.MyClient.There || !Target.Alive || !Alive || Target.LocMap != Map)
Target = null;
if (Target != null)
if (MType != 1 && MType != 4 && MType != 5 && MType != 6)
if (Target.Flying)
Target = null;
if (MType == 7)
{
if (Target != null)
GuardMove(3);
else if (Target2 != null)
GuardMove(2);
else
GuardMove(1);
}
else
{
if (Target != null)
Move();
}
if (!Alive)
{
if (Revive == false)
{
if (DateTime.Now > Death.AddMilliseconds(3000))
Dissappear();
}
else
{
if (MType == 2)
{
if (Map == 1015)
{
if (DateTime.Now > Death.AddMilliseconds(60000))
ReSpawn();
}
if (Map != 1015)
{
if (DateTime.Now > Death.AddMilliseconds(600000))
ReSpawn();
}
}
if (MType == 0)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 1)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 4)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 3)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 5)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 6)
{
if (DateTime.Now > Death.AddMilliseconds(10000))
ReSpawn();
}
if (MType == 7)
{
if (DateTime.Now > Death.AddMilliseconds(100))
ReSpawn();
}
}
}
}
Code:
public void GetTarget()
{
LastTargetting = DateTime.Now;
if (MType != 1&&MType !=7)
Target = Other.CharNearest((uint)PosX, (uint)PosY, (uint)Map, false);
else if (MType == 1)
Target = Other.CharNearest((uint)PosX, (uint)PosY, (uint)Map, true);
else if (MType == 7)
{
if (owner2.MobTarget != null || owner2.PTarget != null)
{
if (owner2.MobTarget != null)
{
Target2 = owner2.MobTarget;
Target = null;
}
if (owner2.PTarget != null)
{
Target = owner2.PTarget;
Target2 = null;
}
}
else
{
Target = Target;
Target2 = Target2;
}
}
}
Code:
public void Move()
Abowe add:
Code:
public void GuardMove(short opc)
{
if (Alive)
{
if (owner2 != null && owner2.Alive && owner2.MyClient.Online&&Map==owner2.LocMap)
{
if (DateTime.Now > LastMove.AddMilliseconds(500))
{
if (MyMath.PointDistance(PosX, PosY, owner2.LocX, owner2.LocY) <= 25)
{
//Created by Bisiol
if (opc == 1)
{
if ((MyMath.PointDistance(PosX, PosY, owner2.LocX, owner2.LocY) >= 2) && (MyMath.PointDistance(PosX, PosY, owner2.LocX, owner2.LocY) <= 25))
{
byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(PosX, PosY, owner2.LocX, owner2.LocY) / 45 % 8)) - 1 % 8);
ToDir = (byte)((int)ToDir % 8);
short AddX = 0;
short AddY = 0;
if (ToDir == 255)
ToDir = 7;
Pos = ToDir;
switch (ToDir)
{
case 0:
{
AddY = 1;
break;
}
case 1:
{
AddX = -1;
AddY = 1;
break;
}
case 2:
{
AddX = -1;
break;
}
case 3:
{
AddX = -1;
AddY = -1;
break;
}
case 4:
{
AddY = -1;
break;
}
case 5:
{
AddX = 1;
AddY = -1;
break;
}
case 6:
{
AddX = 1;
break;
}
case 7:
{
AddY = 1;
AddX = 1;
break;
}
}
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
}
else if (MyMath.PointDistance(PosX, PosY, owner2.LocX, owner2.LocY) < 2)
{ }
}
else if (opc == 2)
{
if (DateTime.Now > LastAtack.AddMilliseconds(1000))
{
if (MyMath.PointDistance(PosX, PosY, Target2.PosX, Target2.PosY) <= 10)
{
LastMove = DateTime.Now;
int DMG = Convert.ToInt32(MaxAtk);
if (DMG < 1)
DMG = 1;
uint GEXP=0;
if (DMG<=Target2.CurHP)
GEXP=(uint)DMG;
else if(DMG>Target2.CurHP)
GEXP=Target2.CurHP;
Target2.GetDamage((uint)DMG);
if (Target2.MType != 1 && Target2.MType != 7)
{ owner2.AddExp(GEXP,true); }
foreach (DictionaryEntry DE in World.AllChars)
{
Character Charr = (Character)DE.Value;
if (Charr.MyClient.Online)
if (MyMath.CanSeeBig(PosX, PosY, Charr.LocX, Charr.LocY))
{
Charr.MyClient.SendPacket(General.MyPackets.MobSkillUse2(this, Target2, (uint)DMG, 1002, 1));
}
}
if (Target2.CurHP <= 0)
Target2 = null;
LastAtack = DateTime.Now;
}
else if ((MyMath.PointDistance(PosX, PosY, Target2.PosX, Target2.PosY) >= 11) && (MyMath.PointDistance(PosX, PosY, Target2.PosX, Target2.PosY) <= 25))
{
byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(PosX, PosY, Target2.PosX, Target2.PosY) / 45 % 8)) - 1 % 8);
ToDir = (byte)((int)ToDir % 8);
short AddX = 0;
short AddY = 0;
if (ToDir == 255)
ToDir = 7;
Pos = ToDir;
switch (ToDir)
{
case 0:
{
AddY = 1;
break;
}
case 1:
{
AddX = -1;
AddY = 1;
break;
}
case 2:
{
AddX = -1;
break;
}
case 3:
{
AddX = -1;
AddY = -1;
break;
}
case 4:
{
AddY = -1;
break;
}
case 5:
{
AddX = 1;
AddY = -1;
break;
}
case 6:
{
AddX = 1;
break;
}
case 7:
{
AddY = 1;
AddX = 1;
break;
}
}
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
}
}
}
else if (opc == 3)
{
if (DateTime.Now > LastAtack.AddMilliseconds(1000))
{
if (MyMath.PointDistance(PosX, PosY, Target.LocX, Target.LocY) <= 10)
{
int DMG = MaxAtk - (int)Target.MDefense;
if (DMG < 1)
DMG = 1;
if (Target.GetHitDie((uint)DMG))
{
if (MType == 7)
{
World.MobAttacksCharSkill(this, Target, (uint)DMG, 1002, 1);
}
}
else
{
if (MType == 7)
World.MobAttacksCharSkill(this, Target, (uint)DMG, 1002, 1);
}
if (Target.CurHP <= 0)
Target = null;
LastAtack = DateTime.Now;
}
else if ((MyMath.PointDistance(PosX, PosY, Target.LocX, Target.LocY) >= 11) && (MyMath.PointDistance(PosX, PosY, Target.LocX, Target.LocY) <= 25))
{
byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(PosX, PosY, Target.LocX, Target.LocY) / 45 % 8)) - 1 % 8);
ToDir = (byte)((int)ToDir % 8);
short AddX = 0;
short AddY = 0;
if (ToDir == 255)
ToDir = 7;
Pos = ToDir;
switch (ToDir)
{
case 0:
{
AddY = 1;
break;
}
case 1:
{
AddX = -1;
AddY = 1;
break;
}
case 2:
{
AddX = -1;
break;
}
case 3:
{
AddX = -1;
AddY = -1;
break;
}
case 4:
{
AddY = -1;
break;
}
case 5:
{
AddX = 1;
AddY = -1;
break;
}
case 6:
{
AddX = 1;
break;
}
case 7:
{
AddY = 1;
AddX = 1;
break;
}
}
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
PrevX = PosX;
PrevY = PosY;
PosX += AddX;
PosY += AddY;
World.MobMoves(this, ToDir);
World.SpawnMobForPlayers(this, true);
}
}
}
}
else
{
Gjump();
World.SpawnMobForPlayers(this, true);
Target = null;
Target2 = null;
}
LastMove = DateTime.Now;
}
}
else
Dissappear();
}
}
Code:
public void Dissappear()
{
World.RemoveEntity(this);
Revive = true;
}
Code:
public void Dissappear()
{
if (MType == 7&&frev==false)
{
World.RemoveEntity(this);
Mobs.AllMobs.Remove(this);
Alive = false;
}
else if (MType == 7 && frev == true)
{
World.RemoveEntity(this);
Revive = true;
frev = false;
}
else
{
World.RemoveEntity(this);
Revive = true;
}
}
Code:
public void ReSpawn()
{
CurHP = MaxHP;
Alive = true;
PosX = XStart;
PosY = YStart;
PrevX = PosX;
PrevY = PosY;
World.MobReSpawn(this);
Revive = false;
}
bellow add:
Code:
public void Gjump()
{
PosX = (short)owner2.LocX;
PosY = (short)owner2.LocY;
PrevX = PosX;
PrevY = PosY;
World.GuardReSpawn(this);
}
Next: Database.cs(External one)
find:
Code:
public static void DefineSkills()
{
bellow add:
Code:
SkillAttributes[4000] = new ushort[4][];
SkillAttributes[4000][0] = new ushort[6] { 7, 0, 0, 0, 100, 0 };
SkillAttributes[4000][1] = new ushort[6] { 7, 0, 0, 0, 100, 0 };
SkillAttributes[4000][2] = new ushort[6] { 7, 0, 0, 0, 100, 0 };
SkillAttributes[4000][3] = new ushort[6] { 7, 0, 0, 0, 100, 0 };
SkillsDone.Add(4000, 3);
search:
Code:
public static uint NeededSkillExp(short SkillId, byte Level)
{
bellow add:
Code:
if (SkillId == 4000)
{
if (Level == 0)
return 100;
if (Level == 1)
return 300;
if (Level == 2)
return 500;
else return 0;
}
Next Other.cs:
search for:
Code:
public static bool CharExist(string Needle, string HayStack)
abowe add:
Code:
public static Character Charowner(uint uid)
{
try
{
Character ownerchar = null;
foreach (DictionaryEntry DE in World.AllChars)
{
Character Charr = (Character)DE.Value;
if (uid == Charr.UID)
ownerchar = Charr;
}
return ownerchar;
}
catch (Exception Exc) { General.WriteLine(Exc.ToString()); return null; }
}
Next Packets.cs:
search for:
Code:
public byte[] SkillUse(Character Charr, Hashtable Targets, Hashtable PTargets, Hashtable NPCTargets, short AimX, short AimY, short SkillId, byte SkillLvl, byte Switch, uint OneTarget, uint TargetDMG)
{
abowe add:
Code:
public byte[] MobSkillUse2(SingleMob Mob, SingleMob Attacked, uint DMG, ushort SkillId, byte SkillLevel)
{
ushort PacketType = 1105;
byte[] Packet = new byte[32];
fixed (byte* p = Packet)
{
*((ushort*)p) = (ushort)Packet.Length;
*((ushort*)(p + 2)) = (ushort)PacketType;
*((uint*)(p + 4)) = (uint)Mob.UID;
*((ushort*)(p + 8)) = (ushort)Attacked.PosX;
*((ushort*)(p + 10)) = (ushort)Attacked.PosY;
*((ushort*)(p + 12)) = (ushort)SkillId;
*((ushort*)(p + 14)) = (ushort)SkillLevel;
*(p + 16) = 1;
*((uint*)(p + 20)) = (uint)Attacked.UID;
*((uint*)(p + 24)) = (uint)DMG;
}
return Packet;
}
Next World.cs:
search:
Code:
public static void MobDissappear(SingleMob Mob)
abowe add:
Code:
public static void GuardReSpawn(SingleMob Mob)
{
lock (AllChars)
{
foreach (DictionaryEntry DE in AllChars)
{
Character Charr = (Character)DE.Value;
if (Charr.MyClient.Online)
if (Mob.Map == Charr.LocMap)
if (MyMath.CanSee(Mob.PosX, Mob.PosY, Charr.LocX, Charr.LocY))
{
Charr.MyClient.SendPacket(General.MyPackets.SpawnMob(Mob));
}
}
}
}
I hope it will be usefull for someone

BTW post your comments positive or negative.
Bisiol
Edit1 I forget something

That fragment is for block you from attacking your guard
In Client.cs
search:
Code:
else if (Target > 400000 && Target < 500000)
{
SingleMob TargetMob = (SingleMob)Mobs.AllMobs[Target];
MyChar.MobTarget = null;
if (TargetMob != null)
{
MyChar.AtkType = (byte)AttackType;
MyChar.MobTarget = TargetMob;
}
}
and replace it with:
Code:
else if (Target > 400000 && Target < 500000)
{
if (MyChar.Guard != null)
{
if (Target != MyChar.Guard.UID)
{
SingleMob TargetMob = (SingleMob)Mobs.AllMobs[Target];
MyChar.MobTarget = null;
if (TargetMob != null)
{
MyChar.AtkType = (byte)AttackType;
MyChar.MobTarget = TargetMob;
}
}
}
else
{
SingleMob TargetMob = (SingleMob)Mobs.AllMobs[Target];
MyChar.MobTarget = null;
if (TargetMob != null)
{
MyChar.AtkType = (byte)AttackType;
MyChar.MobTarget = TargetMob;
}
}
}
And BlueName stuffs:
Character.cs:
search(4 times) for :
Code:
if (PKMode == 0 || Mob.MType != 1)
Code:
if (PKMode == 0 || Mob.MType != 1 && Mob.MType != 7)
search (3 times):
Code:
PKMode == 0 || Target.MType != 1
Code:
PKMode == 0 || Target.MType != 1 && Target.MType != 7
search(3 times):
Code:
Target.MType == 1
Code:
Target.MType == 1 || Target.MType == 7
search(4 times):
Code:
Mob.MType == 1
Code:
Mob.MType == 1||Mob.MType == 7
Search(2 times):
Code:
MobTarget.MType == 1
Code:
MobTarget.MType == 1 || MobTarget.MType == 7
Last edited: