Пример #1
0
        public void OnGetAttribute(SagaMap.Packets.Client.GetTargetAttribute p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED)
            {
                return;
            }
            Actor aActor = map.GetActor(p.GetActorID());

            if (aActor == null)
            {
                return;
            }
            this.Char.CurTarget = aActor;
            if (aActor.type == ActorType.NPC)
            {
                // Temporary Display Info
                Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id);
                this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
            }
            else if (aActor.type == ActorType.PC)
            {
                Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id);
                this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
            }
            else if (aActor.type == ActorType.Item)
            {
                ActorItem item = (ActorItem)aActor;
                MapItem   e    = (MapItem)item.e;
                e.OnClicked(this.Char);
            }
        }
Пример #2
0
 public void OnGetCancel(SagaMap.Packets.Client.GetTargetCancel p)
 {
     if (this.state != SESSION_STATE.MAP_LOADED) return;
     // Temporary Display Info
     Map.ActorSelArgs arg = new Map.ActorSelArgs(0);
     this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
 }
Пример #3
0
 public void OnGetCancel(SagaMap.Packets.Client.GetTargetCancel p)
 {
     if (this.state != SESSION_STATE.MAP_LOADED)
     {
         return;
     }
     // Temporary Display Info
     Map.ActorSelArgs arg = new Map.ActorSelArgs(0);
     this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
        // 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);
            }
        }
Пример #6
0
 public void OnGetAttribute(SagaMap.Packets.Client.GetTargetAttribute p)
 {
     if (this.state != SESSION_STATE.MAP_LOADED) return;
     Actor aActor = map.GetActor(p.GetActorID());
     if (aActor == null) return;
     this.Char.CurTarget = aActor;
     if (aActor.type == ActorType.NPC)
     {
         // Temporary Display Info
         Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id);
         this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
     }
     else if (aActor.type == ActorType.PC)
     {
         Map.ActorSelArgs arg = new Map.ActorSelArgs(aActor.id);
         this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.ACTOR_SELECTION, arg, this.Char, true);
     }
     else if (aActor.type == ActorType.Item)
     {
         ActorItem item = (ActorItem)aActor;
         MapItem e = (MapItem)item.e;
         e.OnClicked(this.Char);
     }
 }
Пример #7
0
        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);
            }
        }
Пример #8
0
        // 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);
            }
        }
Пример #9
0
        public void SendEventToAllActorsWhoCanSeeActor(EVENT_TYPE etype, MapEventArgs args, Actor sActor, bool sendToSourceActor)
        {
            try
            {
                for (short deltaY = -1; deltaY <= 1; deltaY++)
                {
                    for (short deltaX = -1; deltaX <= 1; deltaX++)
                    {
                        uint region = (uint)(sActor.region + (deltaX * 1000000) + deltaY);
                        if (!this.actorsByRegion.ContainsKey(region))
                        {
                            continue;
                        }

                        foreach (Actor actor in this.actorsByRegion[region])
                        {
                            try
                            {
                                if (!sendToSourceActor && (actor.id == sActor.id))
                                {
                                    continue;
                                }

                                if (this.ACanSeeB(actor, sActor))
                                {
                                    switch (etype)
                                    {
                                    case EVENT_TYPE.APPEAR:
                                        actor.e.OnActorAppears(sActor);
                                        actor.e.OnActorChangesState(sActor, null);
                                        break;

                                    case EVENT_TYPE.DISAPPEAR:
                                        actor.e.OnActorDisappears(sActor);
                                        break;

                                    case EVENT_TYPE.CHANGE_STATE:
                                        actor.e.OnActorChangesState(sActor, args);
                                        break;

                                    case EVENT_TYPE.CHAT:
                                        actor.e.OnActorChat(sActor, args);
                                        break;

                                    case EVENT_TYPE.SKILL:
                                        actor.e.OnActorSkillUse(sActor, args);
                                        break;

                                    case EVENT_TYPE.CHANGE_EQUIP:
                                        actor.e.OnActorChangeEquip(sActor, args);
                                        break;

                                    case EVENT_TYPE.CHANGE_STATUS:
                                        actor.e.OnChangeStatus(sActor, args);
                                        break;

                                    case EVENT_TYPE.ACTOR_SELECTION:
                                        Map.ActorSelArgs arg    = (Map.ActorSelArgs)args;
                                        Actor            target = this.GetActor(arg.target);
                                        if (target != null)
                                        {
                                            if (actor == sActor)    //broadcast disabled temporaryly, which crashes the client
                                            {
                                                if (this.ACanSeeB(actor, target))
                                                {
                                                    actor.e.OnActorSelection((ActorPC)sActor, args);
                                                }
                                            }
                                        }
                                        break;

                                    case EVENT_TYPE.YAW_UPDATE:
                                        if (actor.type == ActorType.PC)
                                        {
                                            ActorPC pc = (ActorPC)actor;
                                            ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
                                            Packets.Server.UpdateActorYaw      p1 = new SagaMap.Packets.Server.UpdateActorYaw();
                                            p1.SetActor(sActor.id);
                                            p1.SetYaw(sActor.yaw);
                                            eh.C.netIO.SendPacket(p1, eh.C.SessionID);
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.ShowError(ex);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ShowError(ex);
            }
        }