Ejemplo n.º 1
0
 public static uint MagicalAttack(ref Actor sActor, ref Actor dActor, uint damage, AttackElements element, ref Map.SkillArgs args)
 {
     //TODO:
     //Damage calculation and magical resists.
     if (args.isCritical == Map.SkillArgs.AttackResult.Critical)
     {
         damage = damage * 2;
         args.damage = damage;
     }
     SkillAttack(ref sActor, ref dActor, damage, ref args);
     return damage;
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public void SendActorToMap(Actor mActor, Map newMap, short x, short y)
        {
            // todo: add support for multiple map servers

            // obtain the new map
            byte mapid = (byte)newMap.id;
            if (mapid == mActor.MapID)
            {
                TeleportActor(mActor, x, y);
                return;
            }

            // delete the actor from this map
            this.DeleteActor(mActor);

            // update the actor
            mActor.MapID = mapid;
            mActor.X = x;
            mActor.Y = y;

            // register the actor in the new map
            if (mActor.type != ActorType.PC)
            {
                newMap.RegisterActor(mActor);
            }
            else
            {
                newMap.RegisterActor(mActor, mActor.ActorID);
            }
        }
Ejemplo n.º 4
0
        public void SendActorToMap(Actor mActor, Map newMap, float x, float y, float z)
        {
            // todo: add support for multiple map servers

            // obtain the new map
            byte mapid = (byte)newMap.id;
            if (mapid == mActor.mapID)
            {
                TeleportActor(mActor, x, y, z);
                return;
            }

            // delete the actor from this map
            this.DeleteActor(mActor);

            // update the actor
            mActor.mapID = mapid;
            mActor.x = x;
            mActor.y = y;
            mActor.z = z;
            ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)mActor.e;
            eh.C.map = newMap;

            // register the actor in the new map
            if (mActor.type != ActorType.PC)
            {
                newMap.RegisterActor(mActor);
            }
            else
            {
                newMap.RegisterActor(mActor, mActor.id);
            }
        }
Ejemplo n.º 5
0
        private static void SkillAttack(ref Actor sActor, ref Actor dActor, uint damage, ref Map.SkillArgs args)
        {
            ActorPC targetPC;
            ActorNPC targetNPC;
            if (dActor.stance == SagaLib.Global.STANCE.DIE)
                return;
            switch (dActor.type)
            {
                case ActorType.NPC:
                    targetNPC = (ActorNPC)dActor;
                    if (targetNPC.HP > damage) targetNPC.HP -= (ushort)damage; else targetNPC.HP = 0;
                    Mob mob = (Mob)targetNPC.e;
                    mob.BeenAttacked(sActor, args);
                    TimeSpan tmp = mob.timeSignature.time - DateTime.Now;
                    if (tmp.Minutes > 5 || tmp.Minutes < 0 || mob.timeSignature.actorID == 0 || mob.timeSignature.actorID == sActor.id)
                    {
                        mob.timeSignature.actorID = sActor.id;
                        mob.timeSignature.time = DateTime.Now;
                    }
                    if (targetNPC.HP == 0)
                    {
                        targetNPC.e.OnDie();
                        if (sActor.type == ActorType.PC)
                        {
                            targetPC = (ActorPC)sActor;
                            Quest.QuestsManager.UpdateEnemyInfo(targetPC, targetNPC.npcType);
                        }
                        mob.Map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, null, targetNPC, true);

                        //EXP calculation
                        foreach (uint i in mob.Damage.Keys)
                        {
                            targetPC = (ActorPC)mob.Map.GetActor(i);
                            if (targetPC == null) continue;

                            ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)targetPC.e;

                            // Apply player's part of the experience (determined by the percentage of HP deducted)
                            ExperienceManager.Instance.ApplyExp(targetPC, targetNPC, (float)mob.Damage[i] / (float)targetNPC.maxHP);

                            eh.C.SendCharStatus(36);

                            // Check experience (will send level up if relevant)
                            ExperienceManager.Instance.CheckExp(eh.C, ExperienceManager.LevelType.CLEVEL);
                            ExperienceManager.Instance.CheckExp(eh.C, ExperienceManager.LevelType.JLEVEL);
                            ExperienceManager.Instance.CheckExp(eh.C, ExperienceManager.LevelType.WLEVEL);

                            eh.C.UpdateWeaponInfo(SagaMap.Packets.Server.WeaponAdjust.Function.EXP,
                                                  SagaDB.Items.WeaponFactory.GetActiveWeapon(eh.C.Char).exp);
                        }
                        mob.Damage.Clear();
                    }
                    break;
                case ActorType.PC:
                    targetPC = (ActorPC)dActor;
                    if (targetPC.HP > damage) targetPC.HP -= (ushort)damage; else targetPC.HP = 0;
                    EquiptLoseDurability(targetPC);
                    if (targetPC.HP == 0)
                    {
                        ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)targetPC.e;
                        targetPC.e.OnDie();
                        eh.C.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, null, targetPC, true);

                    }

                    break;
            }
        }