Beispiel #1
0
        public void SendSpawnMobs(WvsGameClient c)
        {
            foreach (var mob in Mobs)
            {
                if (mob.Controller == 0 || mob.Controller == c.Character.CharId)
                {
                    mob.Controller = c.Character.CharId;
                    c.SendPacket(CPacket.MobChangeController(mob, 1));
                }

                c.SendPacket(CPacket.MobEnterField(mob));
            }
        }
Beispiel #2
0
        public static void OnPacket(WvsGameClient c, CInPacket p)
        {
            var   chr      = c.Character;
            var   targetId = p.Decode4();
            short type     = p.Decode1();

            var targetChar = chr.Field.Users[targetId];

            if (targetChar is null || chr.dwId == targetId)
            {
                c.SendPacket(GivePopularityResult_Error(GivePopularityRes.InvalidCharacterID));
                return;
            }
        public QuestScript GetQuestScript(int nQuestID, int nAct, QuestEntry pQuest, WvsGameClient c)
        {
            var sScriptName = $"{nQuestID}";

            var script = GetScript(ScriptType.Quest, sScriptName, c);

            if (script.Length <= 0)
            {
                return(null);
            }

            return(new QuestScript(sScriptName, nAct, script, pQuest, c));
        }
        // ----------------------------------------------------- handlers

        public override void HandleVisit(CInPacket p, WvsGameClient c) // accept invite
        {
            base.HandleVisit(p, c);

            if (c?.Character.dwId != Partner?.dwId)
            {
                return;
            }

            tempInvOwner   = new TempInventory(nMiniRoomType, 9, OwnerID);
            tempInvPartner = new TempInventory(nMiniRoomType, 9, Partner.dwId);

            Parent.SendPacket(AcceptInvitePacket());
            Partner.SendPacket(GetMiniRoomPacket());

            acceptedInvite = true;
        }
Beispiel #5
0
        /// <summary>
        /// Client summon remove request
        /// </summary>
        /// <param name="c"></param>
        /// <param name="p"></param>
        public static void Handle_Remove(WvsGameClient c, CInPacket p)
        {
            var dwSummonedID = p.Decode4();
            var summon       = c.Character.Field.Summons[dwSummonedID];

            if (summon?.dwParentID != c.Character.dwId)
            {
                return;
            }

            if (summon.Parent.Buffs.GetOrDefault((int)Skills.MECHANIC_SAFETY) is BuffSkill safety)             // satellite safety
            {
                switch ((Skills)summon.nSkillID)
                {
                case Skills.MECHANIC_SATELITE3:
                    summon.Parent.Cooldowns.UpdateOrInsert(safety.nSkillID, safety.Template.Cooltime(safety.nSLV));
                    summon.Field.Summons.CreateSummon(summon.Parent, (int)Skills.MECHANIC_SATELITE2, summon.Parent.Skills.Get((int)Skills.MECHANIC_SATELITE2, true).nSLV, summon.Parent.Position.X, summon.Parent.Position.Y);
                    summon.nLeaveType = SummonLeaveType.LEAVE_TYPE_UPDATE;
                    c.Character.Field.Summons.Remove(summon);                             // has to be last
                    return;

                case Skills.MECHANIC_SATELITE2:
                    summon.Parent.Cooldowns.UpdateOrInsert(safety.nSkillID, safety.Template.Cooltime(safety.nSLV));
                    summon.Field.Summons.CreateSummon(summon.Parent, (int)Skills.MECHANIC_SATELITE, summon.Parent.Skills.Get((int)Skills.MECHANIC_SATELITE, true).nSLV, summon.Parent.Position.X, summon.Parent.Position.Y);
                    summon.nLeaveType = SummonLeaveType.LEAVE_TYPE_UPDATE;
                    c.Character.Field.Summons.Remove(summon);                             // has to be last
                    return;

                case Skills.MECHANIC_SATELITE:
                    summon.Parent.Cooldowns.UpdateOrInsert(safety.nSkillID, safety.Template.Cooltime(safety.nSLV));
                    summon.Parent.Buffs.Remove(safety);
                    summon.nLeaveType = SummonLeaveType.LEAVE_TYPE_UPDATE;
                    c.Character.Field.Summons.Remove(summon);                             // has to be last
                    return;
                }
            }

            summon.nLeaveType = SummonLeaveType.LEAVE_TYPE_ON_REMOVE;

            if (summon.nMoveAbility == SummonMoveAbility.Follow || summon.nMoveAbility == SummonMoveAbility.CircleFollow)
            {
                summon.Parent.Buffs.Remove(summon.nSkillID);
            }

            c.Character.Field.Summons.Remove(summon);             // has to be last
        }
Beispiel #6
0
        //========================

        public void OnResultPacket(WvsGameClient c, CInPacket p)
        {
            var pChar  = c.Character;
            var opCode = (PartyOps)p.Decode1();

            switch (opCode)
            {
            case PartyOps.PartyRes_InviteParty_Rejected:
                InviteParty_Rejected(pChar, p);
                break;

            case PartyOps.PartyRes_InviteParty_Accepted:
                InviteParty_Accepted(pChar, p);
                break;
            }
            c.Character.Action.Enable();
        }
Beispiel #7
0
        public static void Handle_UserShopRequest(WvsGameClient c, CInPacket p)
        {
            if (c.ActiveShop is null)
            {
                c.Character.SendMessage("Unable to find active shop. Please re-open the shop or report this to staff.");
                return;
            }

            switch ((ShopReq)p.Decode1())             // nOperation
            {
            case ShopReq.Buy:
            {
                var nPos         = p.Decode2();                         //Item index within the npc shop lol
                var dwTemplateID = p.Decode4();
                var nCount       = p.Decode2();

                BuyItem(c.Character, nPos, dwTemplateID, nCount);
                break;
            }

            case ShopReq.Sell:
            {
                var nSlot        = p.Decode2();                          //Item inventory index
                var dwTemplateID = p.Decode4();
                var nCount       = p.Decode2();

                SellItem(c.Character, nSlot, dwTemplateID, nCount);

                break;
            }

            case ShopReq.Recharge:
            {
                var nSlot = p.Decode2();

                RechargeItem(c.Character, nSlot);
                break;
            }

            case ShopReq.Close:
            {
                Close(c.Character);
                break;
            }
            }
        }
Beispiel #8
0
        public static void OnPacket(WvsGameClient c, CInPacket p)
        {
            var nRecipeClass = p.Decode4();
            var nItemID      = p.Decode4();

            switch (nRecipeClass)
            {
            case 1:
            case 2:                     // create
                var bMounted        = p.Decode1();
                var nNumGem_Mounted = p.Decode4();

                var aGemSlot_pItemp = new List <int>();

                for (int i = 0; i < nNumGem_Mounted; i++)
                {
                    aGemSlot_pItemp.Add(p.Decode4());
                }

                HandleCreateItemOp(c.Character, nItemID, bMounted > 0, aGemSlot_pItemp);

                break;

            case 3:                     // build monster crystal

                HandleBuildMonsterCrystalOp(c.Character, nItemID);

                break;

            case 4:                     // disassemble

                var nInvType      = (InventoryType)p.Decode4();
                var nSlotPosition = p.Decode4();

                HandleDisassembleOp(c.Character, nInvType, nItemID, nSlotPosition);

                break;

            default:
                Log.Info("Found unhandled ItemMakeRequest opcode : " + nRecipeClass);
                break;
            }

            c.SendPacket(MakerRelease());
        }
        /**
         * Die packet:
         * Recv [CP_UserTransferFieldRequest] [29 00] [01] [00 00 00 00] 00 00 00 01 00 // last bytes possibly related to death-items
         * Portal to other map packet:
         * Recv [CP_UserTransferFieldRequest] [29 00] [01] [FF FF FF FF] [06 00] [65 61 73 74 30 30] [4D 06] [C7 01] 00 00 00
         */
        public static void Field(WvsGameClient c, CInPacket p)
        {
            //void __thiscall CUser::OnTransferFieldRequest(CUser *this, int bLoopback, CInPacket *iPacket)

            //Exit Cash Shop -> Not used in WvsGame
            if (p.Available == 0)
            {
                return;
            }

            //TODO: Portal count checks
            //TODO: XY rect checks to ensure player is on portal when activating it
            //TODO: Keep track if player spawns when entering a field

            var bFieldKey   = p.Decode1();           //CField::GetFieldKey(v20);
            var dwField     = p.Decode4();
            var sPortalName = p.DecodeString();

            if (c.Character.Stats.nHP <= 0)
            {
                c.Character.Field.OnUserWarpDie(c.Character);
            }
            else if (sPortalName.Length > 0)                // not death
            {
                var x = p.Decode2();
                var y = p.Decode2();

                p.Decode1();                 // used to be bTownPortal
                var bPremium = p.Decode1();
                var bChase   = p.Decode1();

                if (bChase > 0)
                {
                    var nTargetPosition_X = p.Decode4();
                    var nTargetPosition_Y = p.Decode4();
                }

                c.Character.Field.OnUserEnterPortal(c.Character, sPortalName);
            }
            else             // gm warp command
            {
                // TODO admin checks
                // tp to desired field
            }
        }
Beispiel #10
0
        public static void UnEquip(WvsGameClient c, short src, short dst)
        {
            var character = c.Character;

            var source = character.aInvEquippedNormal.GetKvp(src);

            //var target = character.aInvEquip.GetKvp(dst);


            if (character.aInvEquippedNormal.Remove(src))
            {
                character.aInvEquip.Add(dst, source.Value);
                character.Look.anHairEquip[Math.Abs(src)] = 0;
            }

            c.SendPacket(CPacket.InventoryMoveItem(1, src, dst, 1));
            Broadcast_UserAvatarModified(c);
        }
Beispiel #11
0
        public static void Drop(WvsGameClient c, byte type, short src, short qty)
        {
            var ret = GetInventory(type, c.Character);

            if (ret is CInventory <short, GW_ItemSlotEquip> v1)
            {
                var source = v1.Get(src);

                if (source == null)
                {
                    return;
                }

                v1.Remove(src);

                //This pocket is not working :(
                c.SendPacket(CPacket.InventoryDropItem(type, src, qty));
                c.SendPacket(CPacket.BroadcastPinkMsg("Deleted item, doesnt drop yet"));
            }
            else if (ret is CInventory <byte, GW_ItemSlotBundle> v2)
            {
                var source = v2.Get((byte)src);

                if (source == null)
                {
                    return;
                }

                source.nNumber -= qty;

                if (source.nNumber <= 0)
                {
                    v2.Remove((byte)src);
                    c.SendPacket(CPacket.BroadcastPinkMsg("Deleted item"));
                }

                //This pocket is not working :(
                c.SendPacket(CPacket.InventoryDropItem(type, src, qty));
            }
            else
            {
                Logger.Write(LogLevel.Error, "What the f**k have you done?");
            }
        }
Beispiel #12
0
        public static void Handle_GroupMessage(WvsGameClient c, CInPacket p)
        {
            // : [8C 00] [5B BE 87 0F] [01] [01] [69 04 00 00] [03 00] [61 73 64]

            var get_update_time = p.Decode4();
            var nChatTarget     = p.Decode1();
            var nMemberCnt      = p.Decode1();
            var aMemberList     = p.DecodeIntArray(nMemberCnt);
            var sText           = p.DecodeString();

            // [INFO] Recv [CP_GroupMessage] 8C 00 30 9F 4F 0F 01 01 69 04 00 00 05 00 61 73 64 77 64

            if (sText.Length >= sbyte.MaxValue)
            {
                c.Character.SendMessage("Chat message exceeded allowed length.");
                return;
            }

            MasterManager.Log.Debug("Text: " + sText);

            switch ((GroupMessageType)nChatTarget)
            {
            case GroupMessageType.BuddyChat:
                c.Character.Friends.HandleBuddyChat(sText, aMemberList);
                break;

            case GroupMessageType.PartyChat:
                c.Character.Party?.HandlePartyChat(c.Character.dwId, c.Character.Stats.sCharacterName, sText);
                break;

            case GroupMessageType.ExpeditionChat:
                // todo
                break;

            case GroupMessageType.GuildChat:
                // todo
                break;

            case GroupMessageType.AllianceChat:
                // todo
                break;
            }
        }
Beispiel #13
0
        /// <summary>
        /// Packet handler for throw animation
        /// </summary>
        /// <param name="c"></param>
        /// <param name="p"></param>
        public static void Handle_UserThrowGrenade(WvsGameClient c, CInPacket p)
        {
            var nX       = p.Decode4();
            var nY       = p.Decode4();
            var nY2      = p.Decode4();
            var tKeyDown = p.Decode4();
            var nSkillID = p.Decode4();
            var nSLV     = p.Decode4();

            var pSkill = c.Character.Skills.Get(nSkillID);

            if (pSkill == null)
            {
                c.Character.Action.Enable();
                return;
            }

            c.Character.Field.Broadcast(UserThrowGrenadeRemote(c.Character.dwId, nX, nY, tKeyDown, nSkillID, nSLV), c);
        }
Beispiel #14
0
        public static void Move(WvsGameClient c, byte type, short src, short dst)
        {
            var ret = GetInventory(type, c.Character);

            if (ret is CInventory <short, GW_ItemSlotEquip> v1)
            {
                var source = v1.GetKvp(src);
                var target = v1.GetKvp(dst);

                if (v1.Remove(target.Key))
                {
                    v1.Add(src, target.Value);
                }

                if (v1.Remove(source.Key))
                {
                    v1.Add(dst, source.Value);
                }
            }
            else if (ret is CInventory <byte, GW_ItemSlotBundle> v2)
            {
                var source = v2.GetKvp((byte)src);
                var target = v2.GetKvp((byte)dst);

                if (v2.Remove(target.Key))
                {
                    v2.Add((byte)src, target.Value);
                }

                if (v2.Remove(source.Key))
                {
                    v2.Add((byte)dst, source.Value);
                }
            }
            else
            {
                Logger.Write(LogLevel.Error, "What the f**k have you done?");
            }

            c.SendPacket(CPacket.InventoryMoveItem(type, src, dst, 0xFF));
        }
        // note: uses another header (0x69) than regular skill req (0x67)
        public static void Handle(WvsGameClient c, CInPacket p)
        {
            //COutPacket::COutPacket(&oPacket, 105);
            //v71 = 10;
            //COutPacket::Encode4(&oPacket, v5);
            //COutPacket::Encode1(&oPacket, nSLV);
            //COutPacket::Encode2(&oPacket, v4->m_nOneTimeAction & 0x7FFF | ((unsigned __int16)v4->m_nMoveAction << 15));
            //COutPacket::Encode1(&oPacket, v57);
            //if (v5 == 33101005)
            //    COutPacket::Encode4(&oPacket, v4->m_dwSwallowMobID);
            //CClientSocket::SendPacket(TSingleton < CClientSocket >::ms_pInstance, &oPacket);

            var nSkillID     = p.Decode4();
            var nSLV         = p.Decode1();
            var nMoveAction  = p.Decode2();
            var nActionSpeed = p.Decode1();

            var pSkill = c.Character.Skills.Get(nSkillID, true);

            if (pSkill is null)
            {
                return;
            }

            if (nSkillID == (int)Skills.WILDHUNTER_SWALLOW)
            {
                var dwSwallowMobId = p.Decode4();

                var pMob = c.Character.Field.Mobs[dwSwallowMobId];

                if (pMob is object && !GameConstants.is_not_swallowable_mob(pMob.nMobTemplateId))
                {
                    if (!pMob.TrySwallowMob(c.Character))
                    {
                        return;
                    }
                }
            }

            c.Character.Field.Broadcast(UserSkillPrepare(c.Character.dwId, nSkillID, pSkill.nSLV, nMoveAction, nActionSpeed), c);
        }
        public static void Channel(WvsGameClient c, CInPacket p)
        {
            if (c.Character.Stats.nHP <= 0)
            {
                return;
            }
            if (c.Character.Field.Template.HasMigrateLimit())
            {
                return;
            }
            if (c.Character.Field.IsInstanced)
            {
                return;
            }

            var center   = ServerApp.Container.Resolve <WvsCenter>();
            var Parent   = c.Character;
            var nChannel = p.Decode1();

            if (nChannel >= center.WvsGames.Length)
            {
                Parent.SendPacket(CPacket.TransferChannelReqIgnore(1));
            }
            else
            {
                var nPort = (short)center.WvsGames[nChannel].Port;

                var storage = ServerApp.Container.Resolve <CenterStorage>();
                storage.AddCharacterMigrate(Parent.dwId);

                Parent.Stats.Channel = center.WvsGames[nChannel].ChannelId;

                Parent.Socket.Account.Save();
                Parent.Save();

                Parent.NotifySocialChannels(SocialNotiflag.ChangeChannel);

                Parent.SendPacket(CPacket.MigrateCommand(Constants.ServerAddress, nPort));
            }
        }
Beispiel #17
0
        // --------------------------------------------------- Handlers

        public override void HandleVisit(CInPacket p, WvsGameClient c) // 0x04
        {
            if (c.Character.dwId == OwnerID)
            {
                c.Character.SendMessage("Handle maintenance");
                HandleMaintenance();
            }
            else if (InBlackList(c.Character))
            {
                c.SendPacket(CPacket.SystemMessage("The owner of this room has blocked you."));
            }
            else if (!ShopOpen)
            {
                c.SendPacket(CPacket.SystemMessage("The shop is currently undergoing maintenance."));
            }
            else if (!HasSpace)
            {
                c.SendPacket(CPacket.SystemMessage("The shop is currently at max capacity. Please try again later."));
            }
            else
            {
                VisitorAdd(c.Character);
            }
        }
Beispiel #18
0
 protected NpcScript(int npcId, WvsGameClient client)
 {
     m_npcId  = npcId;
     m_client = client;
 }
        public static void OnQuestRequest(WvsGameClient c, CInPacket p)
        {
            if (c.Character.Stats.nHP <= 0)
            {
                return;
            }

            var nType    = (QuestRequestType)p.Decode1();
            var nQuestId = p.Decode2();
            var pQuest   = MasterManager.QuestTemplates[nQuestId];

            if (pQuest is null)
            {
                //c.Character.SendMessage($"Unable to find quest ID {nQuestId}.");
                return;
            }

            var dwNpcTemplateID = 0;

            if (nType != QuestRequestType.LostItem && nType != QuestRequestType.ResignQuest)
            {
                dwNpcTemplateID = p.Decode4();

                var npcTemplate = MasterManager.NpcTemplates[dwNpcTemplateID];

                // TODO check for if NPC should be in the same map as the player
                //if (!c.Character.Field.Npcs.Contains(dwNpcTemplateID))
                //{
                //	c.Character.SendMessage($"Unable to find NPC {nQuestId} in current field.");
                //	// return;
                //}

                if (!pQuest.AutoStart)
                {
                    var ptUserPosX = p.Decode2();
                    var ptUserPosY = p.Decode2();

                    // TODO quest location check
                    // if ( abs(v16) > 1200 || (v8 = *(v20 + 136) - pTemplate, v17 = *(v20 + 132), abs(v8) > 800) )
                    // tick AB
                }
            }

            switch (nType)
            {
            case QuestRequestType.LostItem:
                c.Character.Quests.OnLostQuestItem(p, nQuestId);
                break;

            case QuestRequestType.AcceptQuest:
                c.Character.Quests.OnAcceptQuest(p, nQuestId, dwNpcTemplateID);
                break;

            case QuestRequestType.CompleteQuest:
                c.Character.Quests.OnCompleteQuest(p, nQuestId, dwNpcTemplateID, false);
                break;

            case QuestRequestType.ResignQuest:
                c.Character.Quests.OnResignQuest(p, nQuestId);
                break;

            case QuestRequestType.OpeningScript:
                c.Character.Quests.OnScriptLinkedQuest(nQuestId, dwNpcTemplateID, 0);
                break;

            case QuestRequestType.CompleteScript:
                c.Character.Quests.OnScriptLinkedQuest(nQuestId, dwNpcTemplateID, 1);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(nType));
            }
        }
Beispiel #20
0
        // ------------------------------------

        public static void Handle_SkillUpRequest(WvsGameClient c, CInPacket p)
        {
            // TODO validate that skill exists in player job

            var dwTickCount = p.Decode4();
            var nSkillId    = p.Decode4();

            var template = MasterManager.SkillTemplates[nSkillId];

            if (template is null)
            {
                c.Character.SendMessage($"Skill template null for input value {nSkillId}");
                return;
            }

            if (template.IsHiddenSkill)
            {
                c.Character.SendMessage("Unable to add points to hidden skills.");
                return;
            }

            foreach (var item in template.Req)
            {
                if (c.Character.Skills.Get(item.Key)?.nSLV < item.Value)
                {
                    c.Character.SendMessage($"Missing pre-required skills. {item.Key} - {item.Value}");
                    return;
                }
            }

            var skill = c.Character.Skills[nSkillId];

            if (skill != null && skill.nSLV >= skill.MaxLevel)
            {
                c.Character.SendMessage($"Skill level higher than allowed max level. SLV: {skill.nSLV}. MaxLevel: {skill.MaxLevel}.");
                return;
            }

            if (template.is_skill_need_master_level && template.MasterLevel != 0 &&
                (skill is null || skill.nSLV >= skill.CurMastery))
            {
                c.Character.SendMessage($"Needs Master Level: {template.is_skill_need_master_level}. MaxLevel: {skill.MaxLevel}. SLV: {skill.nSLV}. CurMastery: {skill.CurMastery}.");
                return;
            }

            if (!SkillLogic.IsBeginnerSkill(nSkillId))
            {
                var sp = c.Character.Stats.GetSpBySkillID(nSkillId);
                if (sp <= 0)
                {
                    c.Character.SendMessage($"Not enough skill points. ({sp}).");
                    return;
                }

                c.Character.Modify.Stats(ctx =>
                {
                    ctx.ReduceSpBySkillID(nSkillId);
                });
            }

            c.Character.Modify.Skills(mod =>
                                      mod.AddEntry(nSkillId, entry =>
                                                   entry.nSLV += 1));

            c.Character.Action.Enable();
        }
Beispiel #21
0
        public static void Handle_UserSkillLearnItemUseRequest(WvsGameClient c, CInPacket p)
        {
            int   dwTickCount = p.Decode4();
            short nPOS        = p.Decode2();
            int   nItemID     = p.Decode4();

            c.Character.Action.Enable();

            if (c.Character.Stats.nHP <= 0)
            {
                return;
            }

            if (InventoryManipulator.GetItem(c.Character, ItemConstants.GetInventoryType(nItemID), nPOS) is GW_ItemSlotBundle item &&
                item.Template is ConsumeItemTemplate template)
            {
                var jobroot = Math.Floor(c.Character.Stats.nJob * 0.01);                 // 3500 -> 35

                var bUsed         = false;
                var bSuccess      = false;
                var bIsMasterBook = item.nItemID / 10000 == 229;

                foreach (var skillId in template.SkillData)
                {
                    var skillJob  = (int)Math.Floor(skillId / 10000f); // 35111010 -> 3511
                    var skillRoot = (int)Math.Floor(skillJob / 100f);  // 3511 -> 35

                    if (skillRoot == jobroot)                          // this can only be true once
                    {
                        if (skillJob > c.Character.Stats.nJob)
                        {
                            break;
                        }

                        var skill = c.Character.Skills.FirstOrDefault(s => s.nSkillID == skillId);

                        if (bIsMasterBook)
                        {
                            if (skill is null || skill.nSLV < template.ReqSkillLevel || skill.CurMastery >= template.MasterLevel)
                            {
                                return;
                            }
                        }
                        else
                        {
                            if (skill != null && skill.CurMastery > 0)
                            {
                                break;
                            }
                        }

                        bUsed = true;

                        if (template.SuccessRate != 100)
                        {
                            if (Constants.Rand.Next() % 100 > template.SuccessRate)
                            {
                                break;
                            }
                        }

                        c.Character.Modify.Skills(mod => mod.AddEntry(skillId, s => s.CurMastery = (byte)template.MasterLevel));
                        bSuccess = true;
                        break;
                    }
                }

                if (bUsed)
                {
                    InventoryManipulator.RemoveFrom(c.Character, item.InvType, nPOS);                     // always remove
                }

                c.Character.Field.Broadcast(CPacket.SkillLearnItemResult(c.dwCharId, bIsMasterBook, bUsed, bSuccess));
            }
        }
Beispiel #22
0
        public static void Handle_SkillUseRequest(WvsGameClient c, CInPacket p)
        {
            // Recv [CP_UserSkillUseRequest] [67 00] [86 1E 31 2F] [9B BA 3E 00] [14] 02 12 27 00 00 23 27 00 00 C2 01
            var dwTickCount = p.Decode4();
            var nSkillID    = p.Decode4();
            var nSLV        = p.Decode1();

            var pSkill = c.Character.Skills.Get(nSkillID, true);

            // do validation here so we dont need to validate in called functions
            if (pSkill is null || nSLV > pSkill.nSLV)
            {
                return;
            }

            if (SkillLogic.IsMobCaptureSkill(nSkillID))
            {
                ActiveSkill_MobCapture.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsSummonCapturedMobSkill(nSkillID))
            {
                ActiveSkill_SummonMonster.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsHookAndHitSkill(nSkillID))
            {
                ActiveSkill_HookAndHit.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsSmokeShellSkill(nSkillID))
            {
                ActiveSkill_SmokeShell.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsDamageMeterSkill(nSkillID, c.Character.Stats.nJob))
            {
                ActiveSkill_DamageMeter.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsFlyingSkill(nSkillID, c.Character.Stats.nJob))
            {
                ActiveSkill_Flying.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsClericHealSkill(nSkillID))
            {
                ActiveSkill_Heal.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsOpenGateSkill(nSkillID))
            {
                ActiveSkill_OpenGate.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsRecoveryAura(nSkillID))
            {
                ActiveSkill_RecoveryAura.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsMysticDoorSkill(nSkillID, c.Character.Stats.nJob) || nSkillID == (int)Skills.PRIEST_MYSTIC_DOOR)
            {
                ActiveSkill_TownPortal.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (SkillLogic.IsStatChangeAdminSkill(nSkillID, c.Character.Stats.nJob))
            {
                ActiveSkill_StatChangeAdmin.Handle(nSkillID, nSLV, c.Character, p);
            }
            else if (pSkill.Template.IsSummonSkill && nSkillID != (int)Skills.BMAGE_REVIVE)
            {
                ActiveSkill_Summon.Handle(nSkillID, nSLV, c.Character, p);
            }
            else
            {
                var bLeft = false;

                if (pSkill.Template.is_antirepeat_buff_skill)
                {
                    var x = p.Decode2();
                    var y = p.Decode2();

                    bLeft = x < c.Character.Position.X;
                }

                //  Recv [CP_UserSkillUseRequest] [67 00] [4B 5E 91 0B] [CD 14 F9 01] 14

                var nSpiritJavelinItemID = 0;
                if (nSkillID == (int)Skills.NIGHTLORD_SPIRIT_JAVELIN)       //Spirit Claw
                {
                    nSpiritJavelinItemID = p.Decode4();                     //nSpiritJavelinItemID
                }
                if (pSkill.Template.is_event_vehicle_skill)
                {
                    p.Skip(1);                     // dwAffectedMemberBitmap

                    if (nSkillID == 2311001)
                    {
                        p.Skip(2);                         // tDelay
                    }
                }

                var nRemaining = p.Available - 2;

                if (nRemaining > 0)
                {
                    p.Skip(nRemaining);
                }

                //if (nRemaining > 0)
                //{
                //    var nMobCount = p.Decode1(); // nMobCount
                //    for (int i = 0; i < nMobCount; i++)
                //    {
                //        p.Decode4(); // adwMobID
                //    }
                //}

                var tDelay = p.Available >= 2 ? p.Decode2() : (short)0;                 // tDelay

                if (nSkillID == 0 || c.Character.Skills.Cast(nSkillID, bLeft, false, nSpiritJavelinItemID))
                {
                    new UserEffectPacket(UserEffect.SkillUse)
                    {
                        nSkillID = nSkillID,
                        nSLV     = nSLV
                    }.BroadcastEffect(c.Character, false);
                }
            }

            c.Character.Action.Enable();
        }
Beispiel #23
0
        public static void OnPacket(WvsGameClient c, CInPacket p)
        {
            var pChar     = c.Character;
            var pMiniRoom = pChar.CurMiniRoom;

            Log.Debug($"Begin Handle_MiniRoom");

            var opcode = p.Decode1();

            Log.Debug($"Operation: {opcode}");

            switch ((MR_Action)opcode)
            {
            case MR_Action.MRP_Create:
            {
                var type = p.Decode1();
                Log.Debug($"Create Type: {type}");
                c.Character.Field.MiniRooms.CreateMiniRoom(c.Character, (MR_Type)type, p);
                break;
            }

            case MR_Action.MRP_Invite:     // occurs in some but not all rooms (games, messenger, trade, not shops)
            {
                var dwTargetCharId = p.Decode4();
                Log.Debug($"Processing trade invite request to char ID {dwTargetCharId}");

                if (pMiniRoom is CTradingRoom room)
                {
                    room.HandleSendInvite(dwTargetCharId);
                }

                break;
            }

            case MR_Action.MRP_InviteResult:
            {
                if (pMiniRoom is CTradingRoom ctr)
                {
                    ctr.HandleDecline();
                }

                break;
            }

            case MR_Action.MRP_Enter:
            {
                var targetRoomId = p.Decode4();         // theres two more bytes after this which im curious to know what they do...
                // the extra bytes might be fm room?? for remote merchants??

                Log.Info($"DWID: {targetRoomId}");
                var room = pChar.Field.MiniRooms.FirstOrDefault(r => r.dwId == targetRoomId);
                // if remote merchant operations use this same packet process then it will not work because we're searching by field.. we'd need to search by a range of fields in the channel instead
                if (room is null)
                {
                    c.SendPacket(FailedEnterPacket());
                }
                else
                {
                    room?.HandleVisit(p, c);
                }

                break;
            }

            case MR_Action.MRP_Chat:
            {
                p.Skip(4);         // timestamp

                pChar.CurMiniRoom?.HandleChat(pChar, p.DecodeString());
                break;
            }

            case MR_Action.MRP_Leave:
            {
                pChar.CurMiniRoom?.HandlePlayerExit(pChar, MR_LeaveResult.UserRequest);
                break;
            }

            case MR_Action.ESP_WithdrawAll:     // owner close
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && ces.OwnerID == pChar.dwId)
                {
                    ces.WithdrawAll();
                    ces.HandlePlayerExit(pChar, MR_LeaveResult.UserRequest);
                    ces.Destroy();
                }
                break;
            }

            case MR_Action.MRP_Balloon:     // ?? these names lmao
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    // pChar.Field.Broadcast(r.MakeEnterFieldPacket()); // gms spawns the shop after owner fills it with items

                    ces.ShopOpen      = true;
                    pChar.CurMiniRoom = null;
                }
                break;
            }

            case MR_Action.TRP_PutItem:
            {
                if (pChar.CurMiniRoom is CTradingRoom ctr)
                {
                    ctr.HandleAddItem(p, pChar);
                }
                break;
            }

            case MR_Action.TRP_PutMoney:
            {
                if (pChar.CurMiniRoom is CTradingRoom ctr)
                {
                    ctr.HandleSetMeso(pChar, p.Decode4());
                }
                break;
            }

            case MR_Action.TRP_Trade:
            {
                if (pChar.CurMiniRoom is CTradingRoom ctr)
                {
                    ctr.HandleConfirmTrade(pChar);
                }
                break;
            }

            case MR_Action.PSP_PutItem:
            case MR_Action.ESP_PutItem:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.AddItem(p);
                }
                break;
            }

            case MR_Action.ESP_BuyItem:
            case MR_Action.PSP_BuyItem:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces)
                {
                    ces.SellItem(c.Character, p);
                }
                break;
            }

            case MR_Action.ESP_Refresh:
            case MR_Action.PSP_Refresh:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces)
                {
                    ces.Refresh(pChar);
                }
                break;
            }

            case MR_Action.ESP_MoveItemToInventory:
            case MR_Action.PSP_MoveItemToInventory:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces)
                {
                    ces.RemoveItem(p);
                }
                break;
            }

            case MR_Action.PSP_Ban:
            case MR_Action.MGRP_Ban:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    //ces.BanPlayer(p.DecodeString());
                }
                break;
            }

            case MR_Action.ESP_ArrangeItem:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.ArrangeItems();
                }
                break;
            }

            case MR_Action.ESP_DeliverVisitList:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.DeliverVisitList();
                }
                break;
            }

            case MR_Action.ESP_DeliverBlackList:
            case MR_Action.PSP_DeliverBlackList:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.DeliverBlackList();
                }
                break;
            }

            case MR_Action.ESP_AddBlackList:
            case MR_Action.PSP_AddBlackList:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.AddBlackList(p);
                }
                break;
            }

            case MR_Action.PSP_DeleteBlackList:
            case MR_Action.ESP_DeleteBlackList:
            {
                if (pChar.CurMiniRoom is CEntrustedShop ces && pChar.CurMiniRoom.OwnerID == pChar.dwId)
                {
                    ces.DeleteBlackList(p);
                }
                break;
            }

            default:
                Log.Info($"Unhandled MiniRoom packet. OpCode: {opcode}.");
                Log.Info($"Full packet: {BitConverter.ToString(p.ToArray()).Replace("-", " ")}");
                break;
            }
            pChar.Action.Enable();
        }
Beispiel #24
0
 public void RemoveMob(WvsGameClient c, CMob mob)
 {
     Mobs.Remove(mob.dwMobId);
     Broadcast(CPacket.MobLeaveField(mob));
 }
Beispiel #25
0
 public virtual void HandleVisit(CInPacket p, WvsGameClient c)
 {
     nCurUsers += 1;
     c.Character.CurMiniRoom = this;
 }
 public QuestScript(string sScriptName, int nAct, string sScriptContents, QuestEntry quest, WvsGameClient client)
     : base(sScriptName, sScriptContents, client)
 {
     Context   = new QuestScriptContext(this);
     Quest     = quest;
     this.nAct = nAct;
 }
Beispiel #27
0
 protected ScriptBase(string sScriptName, string sScriptContents, WvsGameClient client)
 {
     Parent     = client;
     Engine     = new PyEngine(sScriptContents);
     ScriptName = sScriptName;
 }
Beispiel #28
0
 public NpcDefault(int npcId, WvsGameClient client) : base(npcId, client)
 {
 }
Beispiel #29
0
 public static void Handle_PassiveskillInfoUpdate(WvsGameClient c, CInPacket p) => c.Character.Buffs.Update();
        public void OnPacket(WvsGameClient c, CInPacket p)
        {
            var MSMP = p.Decode1();

            switch ((MSMPType)MSMP)
            {
            case MSMPType.MSMP_Enter:
                var id = p.Decode4();

                if (Contains(id))
                {
                    if (!this[id].TryJoin(c.Character))
                    {
                        c.Character.SendMessage("The room is full.");
                    }
                }
                else
                {
                    Add(new CUIMessenger(c.Character));
                }

                break;

            case MSMPType.MSMP_SelfEnterResult:
                break;

            case MSMPType.MSMP_Leave:
                GetByCharId(c.Character.dwId)?.Leave(c.Character.dwId);
                break;

            case MSMPType.MSMP_Invite:     // same in/out
                GetByCharId(c.Character.dwId)?.TrySendInvite(c.Character, p.DecodeString());
                break;

            case MSMPType.MSMP_InviteResult:
                break;

            case MSMPType.MSMP_Blocked:
                var sInviter = p.DecodeString();

                if (sInviter.Length > Constants.MaxCharNameLength)
                {
                    return;
                }

                var pInviter = MasterManager.CharacterPool.Get(sInviter);

                if (pInviter is null)
                {
                    return;
                }

                GetByCharId(pInviter.dwId)?.Blocked(c.Character.dwId, c.Character.Stats.sCharacterName);
                break;

            case MSMPType.MSMP_Chat:
                GetByCharId(c.Character.dwId)?.DoChat(c.Character, p.DecodeString());
                break;

            case MSMPType.MSMP_Avatar:
                break;

            case MSMPType.MSMP_Migrated:
                break;
            }
        }