Пример #1
0
 private static void Deactivate(Actor actor)
 {
     Tasks.PassiveSkillStatus           ss;
     ActorEventHandlers.PC_EventHandler eh;
     ss = (PassiveSkillStatus)actor.Tasks["MentalTraining"];
     BonusHandler.Instance.SkillAddAddition(actor, (uint)(baseID + ss.level - 1), true);
     if (actor.type == ActorType.PC)
     {
         ActorPC targetpc = (ActorPC)actor;
         eh = (ActorEventHandlers.PC_EventHandler)actor.e;
         SkillHandler.CalcHPSP(ref targetpc);
         eh.C.SendCharStatus(0);
     }
 }
Пример #2
0
        private static void Deactivate(Actor actor)
        {
            Tasks.PassiveSkillStatus           ss;
            ActorEventHandlers.PC_EventHandler eh;
            ss = (PassiveSkillStatus)actor.Tasks["Meditation"];
            actor.BattleStatus.fireresist -= CalcValue(ss.level);
            actor.BattleStatus.iceresist  -= CalcValue(ss.level);
            actor.BattleStatus.windresist -= CalcValue(ss.level);
            actor.BattleStatus.holyresist -= CalcValue(ss.level);
            actor.BattleStatus.darkresist -= CalcValue(ss.level);

            if (actor.type == ActorType.PC)
            {
                ActorPC targetpc = (ActorPC)actor;
                eh = (ActorEventHandlers.PC_EventHandler)actor.e;
                SkillHandler.CalcHPSP(ref targetpc);
                eh.C.SendCharStatus(0);
            }
        }
Пример #3
0
        public void OnMoveItem(SagaMap.Packets.Client.MoveItem p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED)
            {
                return;
            }
            Packets.Client.ITEM_MOVE_TYPE moveType = p.GetMoveType();

            if (moveType == Packets.Client.ITEM_MOVE_TYPE.EquToInv)
            {
                // unequip, equip items are not stackable?
                byte index, amount;
                UnequipItemResult ures = this.Char.inv.UnequipItem(p.GetSourceIndex(), out index, out amount);
                if (ures == UnequipItemResult.NEW_INDEX || ures == UnequipItemResult.STACKED)
                {
                    Packets.Server.MoveItem p1 = new SagaMap.Packets.Server.MoveItem();
                    p1.SetMoveType(SagaMap.Packets.Server.ITEM_MOVE_TYPE.EquToInv);
                    p1.SetSourceIndex(p.GetSourceIndex());
                    p1.SetDestIndex(index);
                    this.netIO.SendPacket(p1, this.SessionID);
                    Item item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, index);
                    item.equipSlot = -1;
                    MapServer.charDB.UpdateItem(this.Char, item);
                    Bonus.BonusHandler.Instance.EquiqItem(this.Char, item, true);
                    SkillHandler.CalcHPSP(ref this.Char);
                    SendCharStatus(0);
                    SendExtStats();
                    SendBattleStatus();

                    this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_EQUIP, new Map.ChangeEquipArgs((EQUIP_SLOT)(p.GetSourceIndex()), 0), this.Char, false);
                }
                else
                {
                    SendMessage("Saga", "unequip error");
                }
            }
            else if (moveType == Packets.Client.ITEM_MOVE_TYPE.InvToEqu)
            {
                // equip
                Item item;
                Item itemori = null;
                if (this.Char.inv.EquipList.ContainsKey((EQUIP_SLOT)p.GetDestIndex()))
                {
                    itemori = this.Char.inv.EquipList[(EQUIP_SLOT)p.GetDestIndex()];
                }
                EquipItemResult eres = this.Char.inv.EquipItem(p.GetSourceIndex(), p.GetDestIndex(), out item);

                if (eres == EquipItemResult.NO_ERROR)
                {
                    Packets.Server.MoveItem p1 = new SagaMap.Packets.Server.MoveItem();
                    p1.SetMoveType(SagaMap.Packets.Server.ITEM_MOVE_TYPE.InvToEqu);
                    p1.SetSourceIndex(p.GetSourceIndex());
                    p1.SetDestIndex(item.index);
                    item.equipSlot = item.index;
                    MapServer.charDB.UpdateItem(this.Char, item);
                    this.netIO.SendPacket(p1, this.SessionID);
                    if (itemori != null)
                    {
                        Bonus.BonusHandler.Instance.EquiqItem(this.Char, itemori, true);
                        itemori.equipSlot = -1;
                        MapServer.charDB.UpdateItem(this.Char, itemori);
                    }
                    Bonus.BonusHandler.Instance.EquiqItem(this.Char, item, false);
                    SkillHandler.CalcHPSP(ref this.Char);
                    SendCharStatus(0);
                    SendExtStats();
                    SendBattleStatus();
                    this.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_EQUIP, new Map.ChangeEquipArgs((EQUIP_SLOT)(item.index), item.id), this.Char, false);
                }
                else if (eres == EquipItemResult.NOT_EQUIPABLE)
                {
                    SendMessage("Saga", "error, item is not equipable");
                }
                else if (eres == EquipItemResult.WRONG_EQUIPSLOT)
                {
                    SendMessage("Saga", "error, wrong equip slot");
                }
                else
                {
                    SendMessage("Saga", "error, cannot equip item");
                }
            }
            else if (moveType == Packets.Client.ITEM_MOVE_TYPE.InvToSto)
            {
                Item item;
                byte index, amount;
                item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, p.GetSourceIndex());
                if (item == null)
                {
                    return;
                }
                if (!this.Char.inv.HasFreeSpaceStorage())
                {
                    return;
                }
                if (this.Char.inv.AddItemStorage(item, out index, out amount) == AddItemResult.ERROR)
                {
                    return;
                }

                this.Char.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, p.GetSourceIndex(), item.id, p.GetAmount(), out amount);
                MapServer.charDB.DeleteItem(this.Char, item);
                MapServer.charDB.NewStorage(this.Char, item);
                Packets.Server.MoveItem p1 = new SagaMap.Packets.Server.MoveItem();
                p1.SetMoveType(SagaMap.Packets.Server.ITEM_MOVE_TYPE.InvToSto);
                p1.SetSourceIndex(p.GetSourceIndex());
                p1.SetDestIndex(item.index);
                this.netIO.SendPacket(p1, this.SessionID);
            }
            else if (moveType == Packets.Client.ITEM_MOVE_TYPE.StoToInv)
            {
                Item item;
                byte amount;
                item = this.Char.inv.GetItem(CONTAINER_TYPE.STORAGE, p.GetSourceIndex());
                if (item == null)
                {
                    return;
                }
                if (!this.Char.inv.HasFreeSpace())
                {
                    return;
                }
                if (this.Char.inv.AddItem(item) == AddItemResult.ERROR)
                {
                    return;
                }
                this.Char.inv.DeleteItem(CONTAINER_TYPE.STORAGE, p.GetSourceIndex(), item.id, p.GetAmount(), out amount);
                MapServer.charDB.DeleteStorage(this.Char, item);
                MapServer.charDB.NewItem(this.Char, item);
                Packets.Server.MoveItem p1 = new SagaMap.Packets.Server.MoveItem();
                p1.SetMoveType(SagaMap.Packets.Server.ITEM_MOVE_TYPE.StoToInv);
                p1.SetSourceIndex(p.GetSourceIndex());
                p1.SetDestIndex(item.index);
                this.netIO.SendPacket(p1, this.SessionID);;
            }

            //Send Answer
            // Do item movement stuff in inventory db?
            Packets.Server.MoveReply sendPacket = new SagaMap.Packets.Server.MoveReply();
            // Todo : Switch result of move and obtain relevent string to send from GameStringTable
            sendPacket.SetMessage(0);
            this.netIO.SendPacket(sendPacket, this.SessionID);
        }
Пример #4
0
        public void OnMapLoaded()
        {
            this.Char.invisble = false;
            this.client.map.OnActorVisibilityChange(this.Char);
            this.client.map.SendTimeWeatherToActor(this.Char);
            this.Char.e.OnMapLoaded();
            this.client.map.SendVisibleActorsToActor(this.Char);
            this.client.SendMaxInvSlots();
            this.client.SendInventoryList();
            this.client.SendEquipList();
            this.client.SendWeaponList();
            this.client.SendSkillList();
            //this.client.SendShortcutsList();
            this.client.SendZeny();
            Quest.QuestsManager.SendNavPoint(this.Char);
            if (!this.client.initialized)
            {
                this.client.SendQuestInfo();
                Scenario.SetCurrentScenario(this.Char, 2, this.Char.Scenario);
                Quest.QuestsManager.UpdateQuestItem(this.Char, true);
                if (Config.Instance.MessageOfTheDay != null)
                {
                    foreach (string i in Config.Instance.MessageOfTheDay)
                    {
                        this.client.SendMessage("Saga", i, SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE_RED);
                    }
                }
                this.client.CheckNewMail();
                this.client.initialized = true;
            }
            if (MapServer.ScriptManager.Scenario != null)
            {
                MapServer.ScriptManager.Scenario.OnChangeMap(this.Char, Char.mapID);
            }
            else
            {
                Logger.ShowDebug("MapServer.ScriptManager.Scenario==null, maybe scenario script is missing?", null);
            }

            if (this.Char.stance == Global.STANCE.DIE)
            {
                this.Char.stance = Global.STANCE.REBORN;
                this.client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, null, this.Char, true);
            }
            if (this.Char.Tasks.ContainsKey("AutoSave") == false)
            {
                Tasks.AutoSave newtask = new SagaMap.Tasks.AutoSave(this.client);
                this.Char.Tasks.Add("AutoSave", newtask);
                newtask.Activate();
            }
            if (this.Char.Tasks.ContainsKey("RegenerationHP") == false)
            {
                Tasks.Regeneration newtask = new SagaMap.Tasks.Regeneration(this.client, 2, 0, 1000);
                this.Char.Tasks.Add("RegenerationHP", newtask);
                newtask.Activate();
            }
            if (this.Char.Tasks.ContainsKey("RegenerationSP") == false)
            {
                Tasks.Regeneration newtask = new SagaMap.Tasks.Regeneration(this.client, 0, 35, 4000);
                this.Char.Tasks.Add("RegenerationSP", newtask);
                newtask.Activate();
            }
            if (this.Char.Tasks.ContainsKey("LPReduction") == false)
            {
                Tasks.LPReduction newtask = new SagaMap.Tasks.LPReduction(this.client);
                this.Char.Tasks.Add("LPReduction", newtask);
                newtask.Activate();
            }
            Bonus.BonusHandler.Instance.CalcEquipBonus(this.Char);
            SkillHandler.CastPassivSkill(ref this.client.Char);
            SkillHandler.CalcHPSP(ref this.client.Char);
            this.client.SendBattleStatus();
            this.Char.LC = this.Char.maxLC;
            this.client.SendCharStatus(0);
            this.client.SendExtStats();
            SkillHandler.SendAllStatusIcons(this.Char, this.Char);
            //if (this.client.Party != null)
            //{
            //    this.client.Party.UpdateMemberInfo(this.client);
            //}
            //this.SendMessage("Saga", "Welcome to Saga!", Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE);
            Packets.Server.ShowMapInfo p = new SagaMap.Packets.Server.ShowMapInfo();
            p.SetMapInfo(this.Char.MapInfo);
            this.client.netIO.SendPacket(p, client.SessionID);
        }
Пример #5
0
        public void OnStatUpdate(ushort str, ushort dex, ushort intel, ushort con, byte pointsleft)
        {
            bool cheat_detected = false;

            // check wheter all new stats are bigger or at least equal to their old values
            int deltaSTR = str - this.Char.str;

            if (deltaSTR < 0)
            {
                cheat_detected = true;
            }

            int deltaDEX = dex - this.Char.dex;

            if (deltaDEX < 0)
            {
                cheat_detected = true;
            }

            int deltaINTEL = intel - this.Char.intel;

            if (deltaINTEL < 0)
            {
                cheat_detected = true;
            }

            int deltaCON = con - this.Char.con;

            if (deltaCON < 0)
            {
                cheat_detected = true;
            }

            // check wheter the player tries to use more stpoints then he does have
            int delta = deltaSTR + deltaDEX + deltaINTEL + deltaCON;

            if (this.Char.stpoints < delta)
            {
                cheat_detected = true;
            }

            /// verify the value of p.PointsLeft()
            if ((this.Char.stpoints - delta) != pointsleft)
            {
                cheat_detected = true;
            }

            if (cheat_detected)
            {
                this.client.SendMessage("Saga", "Stop cheating!");
                return;
            }

            this.Char.str      = (byte)str;
            this.Char.dex      = (byte)dex;
            this.Char.intel    = (byte)intel;
            this.Char.con      = (byte)con;
            this.Char.stpoints = pointsleft;

            SkillHandler.CalcHPSP(ref this.client.Char);
        }
Пример #6
0
        public void OnJobChange(byte NewJob, byte ChangeWeapon, ushort postfix)
        {
            //removing passive status

            #region Old Addition handling
            List <string> dellist = new List <string>();
            foreach (string i in this.Char.Tasks.Keys)
            {
                try
                {
                    if (i == "AutoSave" || i == "RegenerationHP" || i == "RegenerationSP" || i == "LPReduction")
                    {
                        continue;
                    }
                    MultiRunTask task = this.Char.Tasks[i];
                    task.Deactivate();
                    dellist.Add(i);
                }
                catch (Exception ex)
                {
                    Logger.ShowError(ex);
                }
            }
            foreach (string i in dellist)
            {
                this.Char.Tasks.Remove(i);
            }
            #endregion

            #region New Addition Handling
            Addition[] additionlist = new Addition[this.Char.BattleStatus.Additions.Count];
            this.Char.BattleStatus.Additions.Values.CopyTo(additionlist, 0);
            foreach (Addition i in additionlist)
            {
                if (i.Activated)
                {
                    i.AdditionEnd();
                }
            }
            this.Char.BattleStatus.Additions.Clear();
            #endregion

            if (!this.Char.JobLevels.ContainsKey(this.Char.job))
            {
                this.Char.JobLevels.Add(this.Char.job, (byte)this.Char.jLevel);
                MapServer.charDB.NewJobLevel(this.Char, this.Char.job, (byte)this.Char.jLevel);
            }
            else
            {
                this.Char.JobLevels[this.Char.job] = (byte)this.Char.jLevel;
                MapServer.charDB.UpdateJobLevel(this.Char, this.Char.job, (byte)this.Char.jLevel);
            }
            this.Char.job = (JobType)NewJob;
            if (!this.Char.JobLevels.ContainsKey(this.Char.job))
            {
                this.Char.JobLevels.Add(this.Char.job, 1);
                MapServer.charDB.NewJobLevel(this.Char, this.Char.job, 1);
            }
            this.Char.jLevel = this.Char.JobLevels[this.Char.job];
            this.Char.jExp   = ExperienceManager.Instance.GetExpForLevel(this.Char.jLevel - 1, ExperienceManager.LevelType.JLEVEL);

            Weapon weapon = WeaponFactory.GetActiveWeapon(this.Char);
            //Change weapon
            if (ChangeWeapon == 1)
            {
                WeaponInfo info;
                switch (this.Char.job)
                {
                case JobType.ENCHANTER:
                    weapon.type        = (ushort)WeaponType.SWORD_STICK;
                    weapon.augeSkillID = 150029;
                    break;

                case JobType.SWORDMAN:
                    weapon.type        = (ushort)WeaponType.LONG_SWORD;
                    weapon.augeSkillID = 150015;
                    break;

                case JobType.THIEF:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;

                case JobType.RECRUIT:
                    weapon.type        = (ushort)WeaponType.DAMPTFLINTE;
                    weapon.augeSkillID = 150043;
                    break;

                case JobType.CLOWN:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;

                case JobType.NOVICE:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;
                }
                info = WeaponFactory.GetWeaponInfo((byte)weapon.type, weapon.level);
                if (weapon.durability > info.maxdurability)
                {
                    weapon.durability = (ushort)info.maxdurability;
                }
            }

            /*this.Char.str = 5;
             * this.Char.dex = 3;
             * this.Char.con = 3;
             * this.Char.intel = 2;
             * this.Char.luk = 0;
             * this.Char.stpoints = (byte)(2 * (this.Char.cLevel - 1));*/
            SkillHandler.SkillResetOnJobChange(this.Char);
            SkillHandler.CalcHPSP(ref this.client.Char);
            this.client.SendCharStatus(0);
            this.client.SendBattleStatus();
            this.client.SendExtStats();
            Packets.Server.WeaponTypeChange p = new SagaMap.Packets.Server.WeaponTypeChange();
            p.SetType(weapon.type);
            p.SetWeaponAuge(weapon.augeSkillID);
            p.SetPostFix(postfix);
            this.client.netIO.SendPacket(p, client.SessionID);
            //if (this.checkTwoHanded())  //this is not working
            this.MakeInactive(EQUIP_SLOT.LEFT_HAND);
            Packets.Server.ChangedJob p2 = new SagaMap.Packets.Server.ChangedJob();
            p2.SetJob(NewJob);
            p2.SetUnknown(this.Char.id);
            this.client.netIO.SendPacket(p2, client.SessionID);
            if (this.Char.CurTarget != null)
            {
                Npc npc = (Npc)this.Char.CurTarget.e;
                npc.NPCChat(this.Char, 1758);
            }
            else
            {
                Logger.ShowDebug(this.Char.name + "->CurTarget == null ", null);
            }
            if (this.client.Party != null)
            {
                this.client.Party.UpdateMemberInfo(this.client);
            }
        }