I'm just curious, has anyone out there added the dying effect to their 5165? At the moment, when you die you instantly turn into a ghost which is pretty lame.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NewestCOServer.Features;
namespace NewestCOServer.PacketHandling
{
public class Attack
{
public static void Handle(Main.GameClient GC, byte[] Data)
{
try
{
uint AttackType = BitConverter.ToUInt32(Data, 20);
if (AttackType != 24)
GC.MyChar.AtkMem.AtkType = (byte)AttackType;
GC.MyChar.Action = 100;
if (!GC.MyChar.Alive) return;
if (GC.MyChar.Loc.Map == PKTournament.Map)
{
if (!(PKTournament.Stage == PKTournamentStage.None || PKTournament.Stage == PKTournamentStage.Over))
{
if (PKTournament.Stage == PKTournamentStage.Inviting || PKTournament.Stage == PKTournamentStage.Countdown)
{
return;
}
if (PKTournament.Stage == PKTournamentStage.Fighting)
{
if (AttackType != 24 || GC.GM)
{
return;
}
}
}
}
if (AttackType == 2 || AttackType == 28)
{
uint TargetUID = BitConverter.ToUInt32(Data, 12);
Game.Mob PossMob = null;
Game.Character PossChar = null;
if (Game.World.H_Mobs.Contains(GC.MyChar.Loc.Map))
{
Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[GC.MyChar.Loc.Map];
if (MapMobs.Contains(TargetUID))
PossMob = (Game.Mob)MapMobs[TargetUID];
else if (Game.World.H_Chars.Contains(TargetUID))
PossChar = (Game.Character)Game.World.H_Chars[TargetUID];
}
else if (Game.World.H_Chars.Contains(TargetUID))
PossChar = (Game.Character)Game.World.H_Chars[TargetUID];
if (PossMob != null || PossChar != null)
{
GC.MyChar.AtkMem.Target = TargetUID;
GC.MyChar.AtkMem.Attacking = true;
if (DateTime.Now > GC.MyChar.AtkMem.LastAttack.AddMilliseconds(GC.MyChar.AtkFrequence))
{
uint Damage = GC.MyChar.PrepareAttack((byte)AttackType, true);
if (PossMob != null && PossMob.Alive && (MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossMob.Loc.X, PossMob.Loc.Y) <= 3 || AttackType == 28 && MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossMob.Loc.X, PossMob.Loc.Y) <= 15 || GC.MyChar.StatEff.Contains(Game.StatusEffectEn.FatalStrike)))
{
if (!GC.MyChar.WeaponSkill(PossMob.Loc.X, PossMob.Loc.Y, PossMob.EntityID))
PossMob.TakeAttack(GC.MyChar, ref Damage, (NewestCOServer.Game.AttackType)AttackType, false);
}
else if (PossChar != null && (PossChar.CanBeMeleed || GC.MyChar.AtkMem.AtkType != 2) && PossChar.Alive && (MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossChar.Loc.X, PossChar.Loc.Y) <= 2 || AttackType == 28 && MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossChar.Loc.X, PossChar.Loc.Y) <= 15))
{
if (!GC.MyChar.WeaponSkill(PossChar.Loc.X, PossChar.Loc.Y, PossChar.EntityID))
PossChar.TakeAttack(GC.MyChar, Damage, (NewestCOServer.Game.AttackType)AttackType, false);
}
else
{
GC.MyChar.AtkMem.Target = 0;
GC.MyChar.AtkMem.Attacking = false;
}
}
}
else if (TargetUID >= 6700 && TargetUID <= 6702)
{
GC.MyChar.AtkMem.Target = TargetUID;
GC.MyChar.AtkMem.Attacking = true;
if (DateTime.Now > GC.MyChar.AtkMem.LastAttack.AddMilliseconds(GC.MyChar.AtkFrequence))
{
uint Damage = GC.MyChar.PrepareAttack((byte)AttackType, true);
if (TargetUID == 6700)
{
if (Features.GuildWars.War)
{
if (!GC.MyChar.WeaponSkill(Features.GuildWars.ThePole.Loc.X, Features.GuildWars.ThePole.Loc.Y, Features.GuildWars.ThePole.EntityID))
Features.GuildWars.ThePole.TakeAttack(GC.MyChar, Damage, (byte)AttackType);
}
else
{
GC.MyChar.AtkMem.Target = 0;
GC.MyChar.AtkMem.Attacking = false;
}
}
else if (TargetUID == 6701)
{
if (!GC.MyChar.WeaponSkill(Features.GuildWars.TheLeftGate.Loc.X, Features.GuildWars.TheLeftGate.Loc.Y, Features.GuildWars.TheLeftGate.EntityID))
Features.GuildWars.TheLeftGate.TakeAttack(GC.MyChar, Damage, (byte)AttackType);
}
else
{
if (!GC.MyChar.WeaponSkill(Features.GuildWars.TheRightGate.Loc.X, Features.GuildWars.TheRightGate.Loc.Y, Features.GuildWars.TheRightGate.EntityID))
Features.GuildWars.TheRightGate.TakeAttack(GC.MyChar, Damage, (byte)AttackType);
}
}
return;
}
else
GC.MyChar.AtkMem.Attacking = false;
if (PossChar == null && PossMob == null)
{
Game.NPC PossNPC = (Game.NPC)Game.World.H_NPCs[TargetUID];
if (PossNPC != null && PossNPC.Flags == 21 && (MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossNPC.Loc.X, PossNPC.Loc.Y) <= 3 || AttackType == 28 && MyMath.PointDistance(GC.MyChar.Loc.X, GC.MyChar.Loc.Y, PossNPC.Loc.X, PossNPC.Loc.Y) <= 15))
{
GC.MyChar.AtkMem.Target = TargetUID;
GC.MyChar.AtkMem.Attacking = true;
if (DateTime.Now > GC.MyChar.AtkMem.LastAttack.AddMilliseconds(GC.MyChar.AtkFrequence))
{
uint Damage = GC.MyChar.PrepareAttack((byte)AttackType, true);
if (!GC.MyChar.WeaponSkill(PossNPC.Loc.X, PossNPC.Loc.Y, PossNPC.EntityID))
PossNPC.TakeAttack(GC.MyChar, Damage, (NewestCOServer.Game.AttackType)AttackType, false);
}
}
}
}
else if (AttackType == 44)
{
ushort SkillId = 6003;
ushort x = GC.MyChar.Loc.X;
ushort y = GC.MyChar.Loc.Y;
uint Target = GC.MyChar.EntityID;
for (byte i = 1; i < 8; i++)
{
Game.Item I = GC.MyChar.Equips.Get(i);
if (I.ID != 0 && I.Soc1 != Game.Item.Gem.EmptySocket)
{
Features.GemEffect.GemEffects(I.Soc1, GC);
}
}
if (SkillId != 0 && GC.MyChar.Skills.Contains(SkillId))
{
Game.Skill S = (Game.Skill)GC.MyChar.Skills[SkillId];
if (Features.SkillsClass.SkillInfos.Contains(S.ID + " " + S.Lvl))
{
Features.SkillsClass.SkillUse SU = new NewestCOServer.Features.SkillsClass.SkillUse();
SU.Init(GC.MyChar, S.ID, S.Lvl, (ushort)x, (ushort)y);
if (SU.Info.ID == 0)
return;
SU.GetTargets(Target);
SU.Use();
}
}
}
else if (AttackType == 24)
{
ushort SkillId;
long x;
long y;
uint Target;
#region GetSkillID
SkillId = Convert.ToUInt16(((long)Data[24] & 0xFF) | (((long)Data[25] & 0xFF) << 8));
SkillId ^= (ushort)0x915d;
SkillId ^= (ushort)GC.MyChar.EntityID;
SkillId = (ushort)(SkillId << 0x3 | SkillId >> 0xd);
SkillId -= 0xeb42;
#endregion
#region GetCoords
x = (Data[16] & 0xFF) | ((Data[17] & 0xFF) << 8);
x = x ^ (uint)(GC.MyChar.EntityID & 0xffff) ^ 0x2ed6;
x = ((x << 1) | ((x & 0x8000) >> 15)) & 0xffff;
x |= 0xffff0000;
x -= 0xffff22ee;
y = (Data[18] & 0xFF) | ((Data[19] & 0xFF) << 8);
y = y ^ (uint)(GC.MyChar.EntityID & 0xffff) ^ 0xb99b;
y = ((y << 5) | ((y & 0xF800) >> 11)) & 0xffff;
y |= 0xffff0000;
y -= 0xffff8922;
#endregion
#region GetTarget
Target = ((uint)Data[12] & 0xFF) | (((uint)Data[13] & 0xFF) << 8) | (((uint)Data[14] & 0xFF) << 16) | (((uint)Data[15] & 0xFF) << 24);
Target = ((((Target & 0xffffe000) >> 13) | ((Target & 0x1fff) << 19)) ^ 0x5F2D2463 ^ GC.MyChar.EntityID) - 0x746F4AE6;
#endregion
for (byte i = 1; i < 8; i++)
{
Game.Item I = GC.MyChar.Equips.Get(i);
if (I.ID != 0 && I.Soc1 != Game.Item.Gem.EmptySocket)
{
Features.GemEffect.GemEffects(I.Soc1, GC);
}
}
if (GC.MyChar.Loc.Map == PKTournament.Map)
{
if (PKTournament.Stage == PKTournamentStage.Fighting)
{
if (SkillId != 1045 && SkillId != 1046)
{
GC.LocalMessage(2005, "You can't use anything except FB/SS in a tournament.");
return;
}
}
}
if (SkillId != 0 && GC.MyChar.Skills.Contains(SkillId))
{
Game.Skill S = (Game.Skill)GC.MyChar.Skills[SkillId];
if (Features.SkillsClass.SkillInfos.Contains(S.ID + " " + S.Lvl))
{
Features.SkillsClass.SkillUse SU = new NewestCOServer.Features.SkillsClass.SkillUse();
SU.Init(GC.MyChar, S.ID, S.Lvl, (ushort)x, (ushort)y);
if (SU.Info.ID == 0)
return;
bool EnoughArrows = true;
if (SU.Info.ArrowsCost > 0)
{
if (GC.MyChar.Loc.Map != 1039)
{
if (GC.MyChar.Equips.LeftHand.ID != 0 && Game.Item.IsArrow(GC.MyChar.Equips.LeftHand.ID))
{
if (GC.MyChar.Equips.LeftHand.CurDur >= SU.Info.ArrowsCost)
GC.MyChar.Equips.LeftHand.CurDur -= SU.Info.ArrowsCost;
else
GC.MyChar.Equips.LeftHand.CurDur = 0;
if (GC.MyChar.Equips.LeftHand.CurDur == 0)
{
GC.AddSend(Packets.ItemPacket(GC.MyChar.Equips.LeftHand.UID, 5, 6));
GC.AddSend(Packets.ItemPacket(GC.MyChar.Equips.LeftHand.UID, 0, 3));
GC.MyChar.Equips.LeftHand = new Game.Item();
}
else
GC.AddSend(Packets.AddItem(GC.MyChar.Equips.LeftHand, 5));
}
else
{
GC.MyChar.AtkMem.Attacking = false;
EnoughArrows = false;
}
}
}
if (GC.MyChar.CurMP >= SU.Info.ManaCost && GC.MyChar.Stamina >= SU.Info.StaminaCost && EnoughArrows || GC.MyChar.Loc.Map == 1039)
{
if (SU.Info.EndsXPWait)
{
if (GC.MyChar.StatEff.Contains(NewestCOServer.Game.StatusEffectEn.XPStart))
{
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.XPStart);
GC.MyChar.XPKO = 0;
}
else
return;
}
try
{
if (GC.MyChar.Loc.Map != 1039)
{
GC.MyChar.CurMP -= SU.Info.ManaCost;
GC.MyChar.Stamina -= SU.Info.StaminaCost;
if (SkillId >= 1000 && SkillId <= 1002)
{
GC.MyChar.AtkMem.AtkType = 21;
GC.MyChar.AtkMem.Skill = SU.Info.ID;
GC.MyChar.AtkMem.Attacking = true;
GC.MyChar.AtkMem.Target = Target;
GC.MyChar.AtkMem.LastAttack = DateTime.Now;
GC.MyChar.AtkMem.SX = (ushort)x;
GC.MyChar.AtkMem.SY = (ushort)y;
}
}
else
{
GC.MyChar.AtkMem.AtkType = 21;
GC.MyChar.AtkMem.Skill = SU.Info.ID;
GC.MyChar.AtkMem.Attacking = true;
GC.MyChar.AtkMem.Target = Target;
GC.MyChar.AtkMem.LastAttack = DateTime.Now;
GC.MyChar.AtkMem.SX = (ushort)x;
GC.MyChar.AtkMem.SY = (ushort)y;
}
}
catch (Exception c) { Program.WriteLine(c.ToString()); }
if (SU.Info.ID == 6001)//toxic fog
{
#region ToxicFog
if (true)
if (GC.MyChar.Loc.Map != 1039)
{
#region Mobs
try
{
foreach (Game.Mob Mob in (Game.World.H_Mobs[GC.MyChar.Loc.Map] as Hashtable).Values)
{
if (Mob.Alive)
{
int Dst = 6;
if (MyMath.PointDistance(Mob.Loc.X, Mob.Loc.Y, x, y) <= Dst)
{
if (Mob.Name.Contains("Guard"))
{
continue;
}
Mob.PoisonedInfo = new NewestCOServer.Game.PoisonType(SU.Info.Level);
foreach (Game.Character C in Game.World.H_Chars.Values)
if (Mob.Loc.Map == C.Loc.Map)
if (MyMath.PointDistance(Mob.Loc.X, Mob.Loc.Y, C.Loc.X, C.Loc.Y) <= 20)
C.MyClient.AddSend(Packets.Status(Mob.EntityID, NewestCOServer.Game.Status.Effect, (ulong)Game.StatusEffectEn.Poisoned));
uint Damage = 0;
Mob.TakeAttack(GC.MyChar, ref Damage, NewestCOServer.Game.AttackType.Magic, true);
GC.MyChar.AddSkillExp(SU.Info.ID, 100);
}
}
}
}
catch { }
#endregion
#region Players
try
{
if (!Game.World.NoPKMaps.Contains(GC.MyChar.Loc.Map))
{
foreach (Game.Character Player in Game.World.H_Chars.Values)
{
if (Player.Alive)
{
int Dst = 6;
if (MyMath.PointDistance(Player.Loc.X, Player.Loc.Y, x, y) <= Dst)
{
if (GC.MyChar.PKMode == NewestCOServer.Game.PKMode.PK)
{
if (Player != GC.MyChar)
{
if (Player.Potency <= GC.MyChar.Potency)
{
Player.PoisonedInfo = new NewestCOServer.Game.PoisonType(SU.Info.Level);
Player.StatEff.Add(NewestCOServer.Game.StatusEffectEn.Poisoned);
Player.TakeAttack(GC.MyChar, 0, NewestCOServer.Game.AttackType.Magic, true);
SU.PlayerTargets.Add(Player, (uint)1);
}
else
{
SU.PlayerTargets.Add(Player, (uint)0);
}
}
}
GC.MyChar.AddSkillExp(SU.Info.ID, 100);
}
}
}
}
}
catch { }
#endregion
}
else
GC.MyChar.AddSkillExp(SU.Info.ID, 10);
Game.World.Action(GC.MyChar, Packets.SkillUse(SU).Get);
#endregion
}
else if (SU.Info.ID == 1100 || SU.Info.ID == 1050)
{
#region Pray
if (GC.MyChar.EntityID != Target)
{
if (Game.World.H_Chars.ContainsKey(Target))
{
Game.Character Char = (Game.Character)Game.World.H_Chars[Target];
if (!Char.Alive)
{
SU.GetTargets(Target);
SU.PlayerTargets[Char] = (uint)1;
Game.World.Action(Char, Packets.SkillUse(SU).Get);
Char.Ghost = false;
Char.BlueName = false;
Char.CurHP = (ushort)Char.MaxHP;
Char.Alive = true;
Char.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
Char.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
Char.Body = Char.Body;
Char.Hair = Char.Hair;
Char.Equips.Send(Char.MyClient, false);
}
}
}
#endregion
}
else
{
SU.GetTargets(Target);
SU.Use();
}
}
}
}
}
}
catch (Exception e) { Program.WriteLine(e); }
}
}
}
okay so where exactly is this.. like you said it's messy so idkQuote:
whenever you attack something, check if the attack will kill them. If it will then change the attack packet to type 14, if not use the regular one.
Simple stuff but lotf is a big mess and you should essentially re-write it all or use a source worth coding imo.
Char.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
Char.StatEff.Add(NewestCOServer.Game.StatusEffectEn.Dead);
NewestCOServer.Game.StatusEffectEn.Dead)
StatEff.Add(StatusEffectEn.Dead);
AttackType = 14;
Quote:
okay so where exactly is this.. like you said it's messy so idk
#edit: alright so I know what to add but idk where I know that its suppose to be where it's something like the opposite ofand I even searched forCode:Char.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);but can't find it. I even searchedCode:Char.StatEff.Add(NewestCOServer.Game.StatusEffectEn.Dead);and still :xCode:NewestCOServer.Game.StatusEffectEn.Dead)
#edit 2: ok so I think this is where I'm suppose to add itbut when I put inCode:StatEff.Add(StatusEffectEn.Dead);and it gives me an error that says "'NewestCOServer.Game.AttackType' is a 'type' but is used like a 'variable'. ?Code:AttackType = 14;
Quote:
okay so where exactly is this.. like you said it's messy so idk
#edit: alright so I know what to add but idk where I know that its suppose to be where it's something like the opposite ofand I even searched forCode:Char.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);but can't find it. I even searchedCode:Char.StatEff.Add(NewestCOServer.Game.StatusEffectEn.Dead);and still :xCode:NewestCOServer.Game.StatusEffectEn.Dead)
#edit 2: ok so I think this is where I'm suppose to add itbut when I put inCode:StatEff.Add(StatusEffectEn.Dead);and it gives me an error that says "'NewestCOServer.Game.AttackType' is a 'type' but is used like a 'variable'. ?Code:AttackType = 14;
public enum AttackType : byte
{
Melee = 2,
Ranged = 28,
Magic = 21,
Kill = 14,
FatalStrike = 45,
Scapegoat = 43
}
World.Action(this, Packets.AttackPacket(Attacker.EntityID, EntityID, Loc.X, Loc.Y, Damage, (byte)AttackType.Kill).Get);
Ensure you send it to ALL clients in range, not just your own.Quote:
Alright so I noticed that when you die, on YOUR SCREEN it shows the dying effect (you falling down THEN turning into a ghost) but on other people's screen, you instantly turn into a ghost without the 'effect'.