//09 0A public void OnItemToggle(SagaMap.Packets.Client.ItemToggle p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } Actor target; Map.SkillArgs args; Actor sActor = (Actor)this.Char; int id; byte index = p.GetIndex(); target = this.map.GetActor(p.GetTargetID()); args = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetID(), 0); SkillHandler.CastSkill(ref sActor, ref target, ref args); Packets.Server.ItemActive packet = new SagaMap.Packets.Server.ItemActive(); packet.SetSkillType(p.GetSkillType()); packet.SetContainer(p.GetContainer()); packet.SetIndex(p.GetIndex()); packet.SetSkillID(p.GetSkillID()); packet.SetSActor(this.Char.id); packet.SetDActor(p.GetTargetID()); packet.SetValue(args.damage); this.netIO.SendPacket(packet, this.SessionID);; this.SendCharStatus(0); Item item = this.Char.inv.GetItem((CONTAINER_TYPE)p.GetContainer(), index); id = item.id; this.map.RemoveItemFromActorPC(this.Char, index, id, 1, ITEM_UPDATE_REASON.PURCHASED); }
/// <summary> /// Receive the fall from the client. /// Damage the client for an 8th of the units fallen? /// Send the client the result of the fall. /// </summary> public void OnSendFall(Packets.Client.SendFall p) { uint value = p.GetValue(); value /= 8; Actor pc = (Actor)this.Char; SagaMap.Map.SkillArgs args = new Map.SkillArgs(); Skills.SkillHandler.PhysicalAttack(ref pc, ref pc, value, SkillHandler.AttackElements.NEUTRAL, ref args); this.SendCharStatus(0); Packets.Server.TakeDamage p1 = new SagaMap.Packets.Server.TakeDamage(); if (this.Char.HP == 0) { p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING_DEAD); } else if (this.Char.HP < (this.Char.maxHP / 10)) { p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING_SURVIVE); } else { p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING); } p1.SetDamage(value); this.netIO.SendPacket(p1, this.SessionID);; }
//09 0A public void OnItemToggle(SagaMap.Packets.Client.ItemToggle p) { if (this.state != SESSION_STATE.MAP_LOADED) return; Actor target; Map.SkillArgs args; Actor sActor = (Actor)this.Char; int id; byte index = p.GetIndex(); target = this.map.GetActor(p.GetTargetID()); args = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetID(), 0); SkillHandler.CastSkill(ref sActor, ref target, ref args); Packets.Server.ItemActive packet = new SagaMap.Packets.Server.ItemActive(); packet.SetSkillType(p.GetSkillType()); packet.SetContainer(p.GetContainer()); packet.SetIndex(p.GetIndex()); packet.SetSkillID(p.GetSkillID()); packet.SetSActor(this.Char.id); packet.SetDActor(p.GetTargetID()); packet.SetValue(args.damage); this.netIO.SendPacket(packet, this.SessionID); ; this.SendCharStatus(0); Item item = this.Char.inv.GetItem((CONTAINER_TYPE)p.GetContainer(), index); id = item.id; this.map.RemoveItemFromActorPC(this.Char, index, id, 1, ITEM_UPDATE_REASON.PURCHASED); }
public override void CallBack(object o) { ClientManager.EnterCriticalArea(); try { if (mob.Actor.stance == Global.STANCE.DIE || dActor.stance == Global.STANCE.DIE || !mob.Hate.ContainsKey(dActor.id) || mob.Actor.Tasks.ContainsKey("Stunned")) { if (mob.Hate.ContainsKey(dActor.id)) mob.Hate.Remove(dActor.id); if (this.Activated()) this.Deactivate(); ClientManager.LeaveCriticalArea(); return; } if (dActor.type == ActorType.PC) { ActorPC pc = (ActorPC)dActor; if (pc.HP == 0) { if (mob.Hate.ContainsKey(dActor.id)) mob.Hate.Remove(dActor.id); if (this.Activated()) this.Deactivate(); ClientManager.LeaveCriticalArea(); return; } } Actor sActor = (Actor)mob.Actor; Map.SkillArgs args = new Map.SkillArgs(1, 0, 1, dActor.id, 0); Skills.SkillHandler.CastSkill(ref sActor, ref dActor, ref args); mob.Map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, args, sActor, false); } catch (Exception ex) { Logger.ShowError(ex); } ClientManager.LeaveCriticalArea(); }
public void OnSkillCastCancel(Packets.Client.SkillCastCancel p) { Map.SkillArgs sArgs; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), this.Char.id, 0); sArgs.castcancel = true; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); }
public void OnUseOffensiveSkill(Packets.Client.UseOffensiveSkill p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } // Attack try { if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = this.map.GetActor(p.GetTargetActorID()); Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), 0); //cast skill if (aActor == null) { sArgs.isCritical = Map.SkillArgs.AttackResult.Miss; sArgs.failed = true; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); return; } SkillHandler.CastSkill(ref sActor, ref aActor, ref sArgs); if (aActor.type == ActorType.NPC) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } if (aActor.type == ActorType.PC && aActor.id != this.Char.id) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } // Emoticon if (p.GetSkillType() == 9) { this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), (uint)Global.Random.Next()), this.Char, true); } } catch (Exception ex) { Logger.ShowError(ex, null); } }
/// <summary> /// Update the state of the client and send to all other actors /// </summary> public void OnSendChangeState(SagaMap.Packets.Client.SendChangeState p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } byte state, stance; state = p.GetState(); stance = p.GetStance(); this.Pc.OnChangeStatus(state, stance); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); arg.targetActorID = p.GetTargetActor(); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, this.Char, true); }
/// <summary> /// When oxygen runs out, damage the char for 10% of health per second. /// </summary> public void OxygenTakeDamage() { uint damage = (uint)(this.Char.maxHP / 10); Actor pc = (Actor)this.Char; SagaMap.Map.SkillArgs args = new Map.SkillArgs(); Skills.SkillHandler.PhysicalAttack(ref pc, ref pc, damage, SkillHandler.AttackElements.NEUTRAL, ref args); this.SendCharStatus(0); Packets.Server.TakeDamage p1 = new SagaMap.Packets.Server.TakeDamage(); if (this.Char.HP == 0) { p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.OXYGEN_DEAD); } else { p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.OXYGEN); } p1.SetDamage(damage); this.netIO.SendPacket(p1, this.SessionID);; }
// 0x09 Packets ========================================= public void OnSkillCast(Packets.Client.SkillCast p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } // Attack if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = this.map.GetActor(p.GetTargetActorID()); Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), 0); sArgs.casting = true; if (aActor == null) { sArgs.isCritical = Map.SkillArgs.AttackResult.Miss; sArgs.failed = true; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); return; } //cast skill if (aActor.type == ActorType.NPC) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } if (aActor.type == ActorType.PC && aActor.id != this.Char.id) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } }
public void OnSkillToggle(Packets.Client.SkillToggle p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } // Attack if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = (Actor)this.Char; Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), sActor.id, 0); //cast skill SkillHandler.CastSkill(ref sActor, ref aActor, ref sArgs); Packets.Server.SkillToggle p1 = new SagaMap.Packets.Server.SkillToggle(); p1.SetSkillType(p.GetSkillType()); p1.SetSkillID(p.GetSkillID()); p1.SetToggle(sArgs.failed); this.netIO.SendPacket(p1, this.SessionID); sArgs.failed = false; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } }
public void ProcessRRes(MapClient client, string playername) { MapClient target = MapClientManager.Instance.GetClient(playername); if (target != null && target.Char.stance == Global.STANCE.DIE) { target.Char.HP = target.Char.maxHP; target.Char.stance = Global.STANCE.REBORN; target.Char.state = 0; target.SendBattleStatus(); target.SendCharStatus(0); Packets.Server.ActorChangeState p1 = new SagaMap.Packets.Server.ActorChangeState(); p1.SetActorID(target.Char.id); p1.SetBattleState(false); p1.SetStance(Global.STANCE.REBORN); target.netIO.SendPacket(p1, target.SessionID); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); target.map.TeleportActor(target.Char, target.Char.x, target.Char.y, target.Char.z); target.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, target.Char, false); } else { client.SendMessage(_MasterName, "Player doesn't exist or isn't dead."); } }
public void ProcessRDie(MapClient client, string playername) { MapClient target = MapClientManager.Instance.GetClient(playername); if (target != null && (target.Char.stance != Global.STANCE.STAND || target.Char.stance != Global.STANCE.RUN)) { target.Char.HP = 0; target.Char.e.OnDie(); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); target.Char.e.OnActorChangesState(target.Char, arg); target.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, target.Char, false); } else { client.SendMessage(_MasterName, "Player doesn't exist, or isn't standing."); } }
public void ProcessRes(MapClient client, string args) { if (client.Char.stance == Global.STANCE.DIE) { client.Char.HP = client.Char.maxHP; client.Char.stance = Global.STANCE.REBORN; client.Char.state = 0; client.SendBattleStatus(); client.SendCharStatus(0); Packets.Server.ActorChangeState p1 = new SagaMap.Packets.Server.ActorChangeState(); p1.SetActorID(client.Char.id); p1.SetBattleState(false); p1.SetStance(Global.STANCE.REBORN); client.netIO.SendPacket(p1, client.SessionID); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, client.Char, false); client.map.TeleportActor(client.Char, client.Char.x, client.Char.y, client.Char.z); } else { client.SendMessage(_MasterName, "You aren't dead >:["); } }
public static uint PhysicalAttack(ref Actor sActor, ref Actor dActor, uint damage, AttackElements element,ref Map.SkillArgs args) { //Real damage calculation if (element != AttackElements.NATRAL) { if (damage > (uint.MaxValue / 2)) damage = 0; if (args.isCritical == Map.SkillArgs.AttackResult.Critical) { damage = damage * 2; args.damage = damage; } float reduced; if (dActor.BattleStatus.def < 1000) { reduced = ((float)(dActor.BattleStatus.def) / 1000) * damage; damage -= (uint)reduced; args.damage = damage; } else { damage = 0; args.damage = 0; args.isCritical = Map.SkillArgs.AttackResult.Block; } } //Shield Block: Damage reduction if (sActor.BattleStatus.Additions.ContainsKey("ShieldBlock")) { damage = (uint)(damage * 0.7); } //Shiel Block: Attack reflection if (dActor.BattleStatus.Additions.ContainsKey("ShieldBlock")) { Addition addition = dActor.BattleStatus.Additions["ShieldBlock"]; Map.SkillArgs newarg = new Map.SkillArgs(args.skillType, args.isCritical, (uint)SkillIDs.ShieldBlock, sActor.id, 0); Map map; newarg.damage = (uint)(damage * (0.07 + 0.03)); if (MapManager.Instance.GetMap(dActor.mapID, out map)) { map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, newarg, dActor, true); SkillAttack(ref dActor, ref sActor, newarg.damage, ref newarg); } } SkillAttack(ref sActor, ref dActor, damage, ref args); return damage; }
public void ProcessDie(MapClient client, string args) { if (client.Char.stance != Global.STANCE.STAND || client.Char.stance != Global.STANCE.RUN) { client.Char.HP = 0; client.Char.e.OnDie(); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, client.Char, true); } else { client.SendMessage(_MasterName, "You must be standing to die"); } }
public void OnSkillToggle(Packets.Client.SkillToggle p) { if (this.state != SESSION_STATE.MAP_LOADED) return; // Attack if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = (Actor)this.Char; Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), sActor.id, 0); //cast skill SkillHandler.CastSkill(ref sActor, ref aActor, ref sArgs); Packets.Server.SkillToggle p1 = new SagaMap.Packets.Server.SkillToggle(); p1.SetSkillType(p.GetSkillType()); p1.SetSkillID(p.GetSkillID()); p1.SetToggle(sArgs.failed); this.netIO.SendPacket(p1, this.SessionID); sArgs.failed = false; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } }
public void OnUseOffensiveSkill(Packets.Client.UseOffensiveSkill p) { if (this.state != SESSION_STATE.MAP_LOADED) return; // Attack try { if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = this.map.GetActor(p.GetTargetActorID()); Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), 0); //cast skill if (aActor == null) { sArgs.isCritical = Map.SkillArgs.AttackResult.Miss; sArgs.failed = true; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); return; } SkillHandler.CastSkill(ref sActor, ref aActor, ref sArgs); if (aActor.type == ActorType.NPC) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } if (aActor.type == ActorType.PC && aActor.id != this.Char.id) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } // Emoticon if (p.GetSkillType() == 9) { this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), (uint)Global.Random.Next()), this.Char, true); } } catch (Exception ex) { Logger.ShowError(ex, null); } }
// 0x09 Packets ========================================= public void OnSkillCast(Packets.Client.SkillCast p) { if (this.state != SESSION_STATE.MAP_LOADED) return; // Attack if (p.GetSkillType() != 9) { Map.SkillArgs sArgs; Actor aActor = this.map.GetActor(p.GetTargetActorID()); Actor sActor = (Actor)this.Char; sArgs = new Map.SkillArgs(p.GetSkillType(), 0, p.GetSkillID(), p.GetTargetActorID(), 0); sArgs.casting = true; if (aActor == null) { sArgs.isCritical = Map.SkillArgs.AttackResult.Miss; sArgs.failed = true; this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); return; } //cast skill if (aActor.type == ActorType.NPC) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } if (aActor.type == ActorType.PC && aActor.id != this.Char.id) { Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true); } this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.SKILL, sArgs, this.Char, true); } }
/// <summary> /// Receive the fall from the client. /// Damage the client for an 8th of the units fallen? /// Send the client the result of the fall. /// </summary> public void OnSendFall(Packets.Client.SendFall p) { uint value = p.GetValue(); value /= 8; Actor pc = (Actor)this.Char; SagaMap.Map.SkillArgs args = new Map.SkillArgs(); Skills.SkillHandler.PhysicalAttack(ref pc, ref pc, value, SkillHandler.AttackElements.NEUTRAL, ref args); this.SendCharStatus(0); Packets.Server.TakeDamage p1 = new SagaMap.Packets.Server.TakeDamage(); if (this.Char.HP == 0) p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING_DEAD); else if (this.Char.HP < (this.Char.maxHP / 10)) p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING_SURVIVE); else p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.FALLING); p1.SetDamage(value); this.netIO.SendPacket(p1, this.SessionID); ; }
/// <summary> /// When oxygen runs out, damage the char for 10% of health per second. /// </summary> public void OxygenTakeDamage() { uint damage = (uint)(this.Char.maxHP / 10); Actor pc = (Actor)this.Char; SagaMap.Map.SkillArgs args = new Map.SkillArgs(); Skills.SkillHandler.PhysicalAttack(ref pc, ref pc, damage, SkillHandler.AttackElements.NEUTRAL, ref args); this.SendCharStatus(0); Packets.Server.TakeDamage p1 = new SagaMap.Packets.Server.TakeDamage(); if (this.Char.HP == 0) p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.OXYGEN_DEAD); else p1.SetReason(SagaMap.Packets.Server.TakeDamage.REASON.OXYGEN); p1.SetDamage(damage); this.netIO.SendPacket(p1, this.SessionID); ; }
/// <summary> /// Update the state of the client and send to all other actors /// </summary> public void OnSendChangeState(SagaMap.Packets.Client.SendChangeState p) { if (this.state != SESSION_STATE.MAP_LOADED) return; byte state, stance; state = p.GetState(); stance = p.GetStance(); this.Pc.OnChangeStatus(state, stance); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); arg.targetActorID = p.GetTargetActor(); this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, this.Char, true); }