public static void UseSkillRequest(IRealmClient client, RealmPacketIn packet) { client.ActiveCharacter.IsFighting = false; client.ActiveCharacter.IsMoving = false; short skillId = packet.ReadInt16(); ++packet.Position; int num1 = (int)packet.ReadInt16(); int num2 = (int)packet.ReadInt16(); byte targetType = packet.ReadByte(); ushort targetId = packet.ReadUInt16(); Spell spellByRealId = client.ActiveCharacter.Spells.GetSpellByRealId(skillId); if (spellByRealId == null) { return; } if (spellByRealId.SoulGuardProffLevel != (byte)0) { client.ActiveCharacter.YouAreFuckingCheater("Trying to use SoulguardSkill as normal skill.", 1); } else { Asda2SpellHandler.ProcessUseSkill(client, targetType, skillId, targetId); } }
public static void LearnSkillRequest(IRealmClient client, RealmPacketIn packet) { short skillId = packet.ReadInt16(); byte level = packet.ReadByte(); SkillLearnStatus status = client.ActiveCharacter.PlayerSpells.TryLearnSpell(skillId, level); if (status == SkillLearnStatus.Ok) { return; } Asda2SpellHandler.SendSkillLearnedResponse(status, client.ActiveCharacter, 0U, 0); }
[PacketHandler(RealmServerOpCode.AtackCharacter)]//4203 public static void AtackCharacterRequest(IRealmClient client, RealmPacketIn packet) { var targetSessId = packet.ReadUInt16();//default : 105Len : 2 var target = World.GetCharacterBySessionId(targetSessId); if (target == null || target == client.ActiveCharacter || !client.ActiveCharacter.CanHarm(target)) { StartAtackResponse(client.ActiveCharacter, target, 0); return; } client.ActiveCharacter.IsFighting = true; Asda2SpellHandler.SendSetAtackStateGuiResponse(client.ActiveCharacter); }
[PacketHandler(RealmServerOpCode.StartAtackCharacter)]//4201 public static void StartAtackCharacterRequest(IRealmClient client, RealmPacketIn packet) { var targetSessId = packet.ReadUInt16(); var victim = World.GetCharacterBySessionId(targetSessId); if (victim == null || !victim.IsAlive) { return; } client.ActiveCharacter.Target = victim; SendStartAtackCharacterResponseResponse(client.ActiveCharacter, victim); Asda2SpellHandler.SendSetAtackStateGuiResponse(client.ActiveCharacter); }
/// <summary>Clears a single spell's cooldown</summary> public static void SendClearCoolDown(Character chr, SpellId spellId) { Spell spell = SpellHandler.Get(spellId); if (spell == null) { chr.SendSystemMessage(string.Format("Can't clear cooldown for {0} cause skill not exist.", (object)spellId)); } else { Asda2SpellHandler.SendClearCoolDown(chr, spell.RealId); } }
public static void AtackCharacterRequest(IRealmClient client, RealmPacketIn packet) { Character characterBySessionId = World.GetCharacterBySessionId(packet.ReadUInt16()); if (characterBySessionId == null || characterBySessionId == client.ActiveCharacter || !client.ActiveCharacter.CanHarm((WorldObject)characterBySessionId)) { Asda2CombatHandler.StartAtackResponse(client.ActiveCharacter, (Unit)characterBySessionId, (byte)0); } else { client.ActiveCharacter.IsFighting = true; Asda2SpellHandler.SendSetAtackStateGuiResponse(client.ActiveCharacter); } }
public static void StartAtackCharacterRequest(IRealmClient client, RealmPacketIn packet) { Character characterBySessionId = World.GetCharacterBySessionId(packet.ReadUInt16()); if (characterBySessionId == null || !characterBySessionId.IsAlive) { return; } if ((int)client.ActiveCharacter.Asda2FactionId == (int)characterBySessionId.Asda2FactionId && characterBySessionId.IsAsda2BattlegroundInProgress && client.ActiveCharacter.IsAsda2BattlegroundInProgress) { Asda2CombatHandler.SendStartAtackCharacterError(client.ActiveCharacter, characterBySessionId, Asda2CharacterAtackStatus.Fail); } else { client.ActiveCharacter.Target = (Unit)characterBySessionId; Asda2CombatHandler.SendStartAtackCharacterResponseResponse(client.ActiveCharacter, characterBySessionId); Asda2SpellHandler.SendSetAtackStateGuiResponse(client.ActiveCharacter); } }
public static void SendAnimateSkillStrikeResponse(Character caster, short spellRealId, DamageAction[] actions, Unit initialTarget) { Asda2SpellHandler.SendSetAtackStateGuiResponse(caster); using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.AnimateSkillStrike)) { NPC npc = initialTarget as NPC; Character character = initialTarget as Character; if (character == null && npc == null) { caster.SendSystemMessage(string.Format("Wrong spell target {0}. can't animate cast. SpellId {1}", (object)initialTarget, (object)spellRealId)); } packet.WriteInt16(caster.SessionId); packet.WriteInt16(spellRealId); packet.WriteInt16(6); packet.WriteByte(1); packet.WriteByte(npc == null ? (byte)1 : (byte)0); if (character != null && actions != null) { for (int index = 0; index < actions.Length; ++index) { DamageAction action = actions[index]; if (action != null) { SpellHitStatus spellHitStatus = SpellHitStatus.Ok; if (action.IsCritical) { spellHitStatus = SpellHitStatus.Crit; } else if (action.Damage == 0) { spellHitStatus = SpellHitStatus.Miss; } else if (action.Blocked > 0) { spellHitStatus = SpellHitStatus.Bloced; } if (index < 16) { packet.WriteUInt16(character.SessionId); packet.WriteInt32(action.ActualDamage); packet.WriteInt32((byte)spellHitStatus); packet.WriteInt32(797); packet.WriteSkip(Asda2SpellHandler.unk12); } action.OnFinished(); } } } else if (actions != null) { for (int index = 0; index < actions.Length; ++index) { DamageAction action = actions[index]; if (action != null) { SpellHitStatus spellHitStatus = SpellHitStatus.Ok; if (action.IsCritical) { spellHitStatus = SpellHitStatus.Crit; } else if (action.Damage == 0) { spellHitStatus = SpellHitStatus.Miss; } else if (action.Blocked > 0) { spellHitStatus = SpellHitStatus.Bloced; } ushort val = 0; if (initialTarget is NPC) { val = action.Victim == null || !(action.Victim is NPC) ? ushort.MaxValue : action.Victim.UniqIdOnMap; } if (index < 16) { packet.WriteUInt16(val); packet.WriteInt32(action.ActualDamage); packet.WriteInt32((byte)spellHitStatus); packet.WriteInt32(797); packet.WriteSkip(Asda2SpellHandler.unk12); } action.OnFinished(); } } } else if (character != null) { packet.WriteUInt16(character.SessionId); packet.WriteInt32(0); packet.WriteInt32(3); packet.WriteInt32(0); packet.WriteSkip(Asda2SpellHandler.unk12); } caster.SendPacketToArea(packet, true, false, Locale.Any, new float?()); } }
public static void UseSoulGuardSkillRequest(IRealmClient client, RealmPacketIn packet) { client.ActiveCharacter.IsFighting = false; client.ActiveCharacter.IsMoving = false; short skillId = packet.ReadInt16(); ++packet.Position; int num1 = (int)packet.ReadInt16(); int num2 = (int)packet.ReadInt16(); byte targetType = packet.ReadByte(); ushort targetId = packet.ReadUInt16(); Spell spellByRealId = client.ActiveCharacter.Spells.GetSpellByRealId(skillId); if (spellByRealId == null) { return; } if (spellByRealId.SoulGuardProffLevel < (byte)1 || spellByRealId.SoulGuardProffLevel > (byte)3) { client.ActiveCharacter.YouAreFuckingCheater("Trying to use skill as SoulguardSkill.", 1); } else { switch (spellByRealId.SoulGuardProffLevel) { case 1: if (client.ActiveCharacter.GreenCharges < (byte)5) { client.ActiveCharacter.SendInfoMsg("Not enougt charges."); Asda2SpellHandler.SendSetSkiillPowersStatsResponse(client.ActiveCharacter, false, (short)0); return; } client.ActiveCharacter.GreenCharges -= (byte)5; break; case 2: if (client.ActiveCharacter.BlueCharges < (byte)5) { client.ActiveCharacter.SendInfoMsg("Not enougt charges."); Asda2SpellHandler.SendSetSkiillPowersStatsResponse(client.ActiveCharacter, false, (short)0); return; } client.ActiveCharacter.BlueCharges -= (byte)5; break; case 3: if (client.ActiveCharacter.RedCharges < (byte)5) { client.ActiveCharacter.SendInfoMsg("Not enougt charges."); Asda2SpellHandler.SendSetSkiillPowersStatsResponse(client.ActiveCharacter, false, (short)0); return; } client.ActiveCharacter.RedCharges -= (byte)5; break; } Asda2SpellHandler.ProcessUseSkill(client, targetType, skillId, targetId); Asda2SpellHandler.SendSetSkiillPowersStatsResponse(client.ActiveCharacter, false, (short)0); } }
private static void ProcessUseSkill(IRealmClient client, byte targetType, short skillId, ushort targetId) { Unit target = (Unit)null; switch (targetType) { case 0: target = (Unit)client.ActiveCharacter.Map.GetNpcByUniqMapId(targetId); break; case 1: target = (Unit)World.GetCharacterBySessionId(targetId); break; default: client.ActiveCharacter.SendSystemMessage(string.Format( "Unknown skill target type {0}. SkillId {1}. Please report to developers.", (object)targetType, (object)skillId)); break; } if (target == null) { Asda2SpellHandler.SendUseSkillResultResponse(client.ActiveCharacter, skillId, Asda2UseSkillResult.ChooseATarget); } else { if (targetType == (byte)1) { Character characterBySessionId = World.GetCharacterBySessionId(targetId); if ((int)characterBySessionId.Asda2FactionId == (int)client.ActiveCharacter.Asda2FactionId && client.ActiveCharacter.IsAsda2BattlegroundInProgress && characterBySessionId.IsAsda2BattlegroundInProgress) { Asda2SpellHandler.SendUseSkillResultResponse(client.ActiveCharacter, skillId, Asda2UseSkillResult.YouCannotUseSkillToTargetYet); return; } if (characterBySessionId == null) { Asda2SpellHandler.SendUseSkillResultResponse(client.ActiveCharacter, skillId, Asda2UseSkillResult.ChooseATarget); return; } } Spell spellByRealId = client.ActiveCharacter.Spells.GetSpellByRealId(skillId); if (spellByRealId == null) { return; } switch (client.ActiveCharacter.SpellCast.Start(spellByRealId, target)) { case SpellFailedReason.OutOfRange: Asda2MovmentHandler.MoveToSelectedTargetAndAttack(client.ActiveCharacter); break; case SpellFailedReason.Ok: if (spellByRealId.LearnLevel >= (byte)10) { if (spellByRealId.LearnLevel < (byte)30) { if (client.ActiveCharacter.GreenCharges < (byte)10) { ++client.ActiveCharacter.GreenCharges; } } else if (spellByRealId.LearnLevel < (byte)50) { if (client.ActiveCharacter.BlueCharges < (byte)10) { ++client.ActiveCharacter.BlueCharges; } if (client.ActiveCharacter.GreenCharges < (byte)10) { ++client.ActiveCharacter.GreenCharges; } } else { if (client.ActiveCharacter.RedCharges < (byte)10) { ++client.ActiveCharacter.RedCharges; } if (client.ActiveCharacter.BlueCharges < (byte)10) { ++client.ActiveCharacter.BlueCharges; } if (client.ActiveCharacter.GreenCharges < (byte)10) { ++client.ActiveCharacter.GreenCharges; } } } AchievementProgressRecord progressRecord = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(6U); switch (++progressRecord.Counter) { case 50: client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Skilled44); break; case 100: client.ActiveCharacter.GetTitle(Asda2TitleId.Skilled44); break; } progressRecord.SaveAndFlush(); Asda2SpellHandler.SendSetSkiillPowersStatsResponse(client.ActiveCharacter, true, skillId); break; } } }