示例#1
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (client.Player.Group != null && client.Player.Group.Leader != client.Player)
            {
                client.Out.SendMessage("You are not the leader of your group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (IsSpammingCommand(client.Player, "invite"))
            {
                return;
            }

            string     targetName = string.Join(" ", args, 1, args.Length - 1);
            GamePlayer target;

            if (args.Length < 2)
            {             // Inviting by target
                if (client.Player.TargetObject == null || client.Player.TargetObject == client.Player)
                {
                    client.Out.SendMessage("You have not selected a valid player as your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (!(client.Player.TargetObject is GamePlayer))
                {
                    client.Out.SendMessage("You have not selected a valid player as your target.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
                target = (GamePlayer)client.Player.TargetObject;
                if (!GameServer.ServerRules.IsAllowedToGroup(client.Player, target, false))
                {
                    return;
                }
            }
            else
            {             // Inviting by name
                GameClient targetClient = WorldMgr.GetClientByPlayerNameAndRealm(targetName, 0, true);
                if (targetClient == null)
                {
                    target = null;
                }
                else
                {
                    target = targetClient.Player;
                }
                if (target == null || !GameServer.ServerRules.IsAllowedToGroup(client.Player, target, true))
                {                 // Invalid target or realm restriction
                    client.Out.SendMessage("No players online with that name.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
                if (target == client.Player)
                {
                    client.Out.SendMessage("You can't invite yourself.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
            }

            if (target.Group != null)
            {
                client.Out.SendMessage("The player is still in a group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvP &&
                target.IsStealthed)
            {
                client.Out.SendMessage("You can't find the player around here.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            if (client.Account.PrivLevel > target.Client.Account.PrivLevel)
            {
                // you have no choice!

                if (client.Player.Group == null)
                {
                    Group group = new Group(client.Player);
                    GroupMgr.AddGroup(group, group);
                    group.AddMember(client.Player);
                    group.AddMember(target);
                }
                else
                {
                    client.Player.Group.AddMember(target);
                }

                client.Out.SendMessage("(GM) You have added " + target.Name + " to your group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                target.Out.SendMessage("GM " + client.Player.Name + " has added you to " + client.Player.GetPronoun(1, false) + " group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
            else
            {
                client.Out.SendMessage("You have invited " + target.Name + " to join your group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                target.Out.SendGroupInviteCommand(client.Player, client.Player.Name + " has invited you to join\n" + client.Player.GetPronoun(1, false) + " group. Do you wish to join?");
                target.Out.SendMessage(client.Player.Name + " has invited you to join " + client.Player.GetPronoun(1, false) + " group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
示例#2
0
            /// <summary>
            /// Called on every timer tick
            /// </summary>
            protected override void OnTick()
            {
                var player = (GamePlayer)m_actionSource;

                if (player == null)
                {
                    return;
                }

                // log.DebugFormat("Dialog - response: {0}, messageType: {1}, data1: {2}, data2: {3}, data3: {4}", m_response, m_messageType, m_data1, m_data2, m_data3);

                switch ((eDialogCode)m_messageType)
                {
                case eDialogCode.CustomDialog:
                {
                    if (m_data2 == 0x01)
                    {
                        CustomDialogResponse callback;
                        lock (player)
                        {
                            callback = player.CustomDialogCallback;
                            player.CustomDialogCallback = null;
                        }

                        if (callback == null)
                        {
                            return;
                        }

                        callback(player, m_response);
                    }
                    break;
                }

                case eDialogCode.GuildInvite:
                {
                    var guildLeader = WorldMgr.GetObjectByIDFromRegion(player.CurrentRegionID, (ushort)m_data1) as GamePlayer;
                    if (m_response == 0x01)                                     //accept
                    {
                        if (guildLeader == null)
                        {
                            player.Out.SendMessage("You need to be in the same region as the guild leader to accept an invitation.",
                                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (player.Guild != null)
                        {
                            player.Out.SendMessage("You are still in a guild, you'll have to leave it first.", eChatType.CT_System,
                                                   eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (guildLeader.Guild != null)
                        {
                            guildLeader.Guild.AddPlayer(player);
                            return;
                        }

                        player.Out.SendMessage("Player doing the invite is not in a guild!", eChatType.CT_System,
                                               eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (guildLeader != null)
                    {
                        guildLeader.Out.SendMessage(player.Name + " declined your invite.", eChatType.CT_System,
                                                    eChatLoc.CL_SystemWindow);
                    }
                    return;
                }

                case eDialogCode.GuildLeave:
                {
                    if (m_response == 0x01)                                     //accepte
                    {
                        if (player.Guild == null)
                        {
                            player.Out.SendMessage("You are not in a guild.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }

                        player.Guild.RemovePlayer(player.Name, player);
                    }
                    else
                    {
                        player.Out.SendMessage("You decline to quit your guild.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    break;
                }

                case eDialogCode.QuestSubscribe:
                {
                    var questNPC = (GameLiving)WorldMgr.GetObjectByIDFromRegion(player.CurrentRegionID, (ushort)m_data2);
                    if (questNPC == null)
                    {
                        return;
                    }

                    var args = new QuestEventArgs(questNPC, player, (ushort)m_data1);
                    if (m_response == 0x01)                                     // accept
                    {
                        // TODO add quest to player
                        // Note: This is done withing quest code since we have to check requirements, etc for each quest individually
                        // i'm reusing the questsubscribe command for quest abort since its 99% the same, only different event dets fired
                        player.Notify(m_data3 == 0x01 ? GamePlayerEvent.AbortQuest : GamePlayerEvent.AcceptQuest, player, args);
                        return;
                    }
                    player.Notify(m_data3 == 0x01 ? GamePlayerEvent.ContinueQuest : GamePlayerEvent.DeclineQuest, player, args);
                    return;
                }

                case eDialogCode.GroupInvite:
                {
                    if (m_response == 0x01)
                    {
                        GameClient cln = WorldMgr.GetClientFromID(m_data1);
                        if (cln == null)
                        {
                            return;
                        }

                        GamePlayer groupLeader = cln.Player;
                        if (groupLeader == null)
                        {
                            return;
                        }

                        if (player.Group != null)
                        {
                            player.Out.SendMessage("You are still in a group.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (!GameServer.ServerRules.IsAllowedToGroup(groupLeader, player, false))
                        {
                            return;
                        }
                        if (player.InCombatPvE)
                        {
                            player.Out.SendMessage("You can't join a group while in combat!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        if (groupLeader.Group != null)
                        {
                            if (groupLeader.Group.Leader != groupLeader)
                            {
                                return;
                            }
                            if (groupLeader.Group.MemberCount >= ServerProperties.Properties.GROUP_MAX_MEMBER)
                            {
                                player.Out.SendMessage("The group is full.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                                return;
                            }
                            groupLeader.Group.AddMember(player);
                            GameEventMgr.Notify(GamePlayerEvent.AcceptGroup, player);
                            return;
                        }

                        var group = new Group(groupLeader);
                        GroupMgr.AddGroup(group);

                        group.AddMember(groupLeader);
                        group.AddMember(player);

                        GameEventMgr.Notify(GamePlayerEvent.AcceptGroup, player);

                        return;
                    }
                    break;
                }

                case eDialogCode.KeepClaim:
                {
                    if (m_response == 0x01)
                    {
                        if (player.Guild == null)
                        {
                            player.Out.SendMessage("You have to be a member of a guild, before you can use any of the commands!",
                                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }

                        AbstractGameKeep keep = GameServer.KeepManager.GetKeepCloseToSpot(player.CurrentRegionID, player.Position, WorldMgr.VISIBILITY_DISTANCE);
                        if (keep == null)
                        {
                            player.Out.SendMessage("You have to be near the keep to claim it.", eChatType.CT_System,
                                                   eChatLoc.CL_SystemWindow);
                            return;
                        }

                        if (keep.CheckForClaim(player))
                        {
                            keep.Claim(player);
                        }
                        break;
                    }
                    break;
                }

                case eDialogCode.HousePayRent:
                {
                    if (m_response == 0x00)
                    {
                        if (player.TempProperties.getProperty <long>(HousingConstants.MoneyForHouseRent, -1) != -1)
                        {
                            player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                        }

                        if (player.TempProperties.getProperty <long>(HousingConstants.BPsForHouseRent, -1) != -1)
                        {
                            player.TempProperties.removeProperty(HousingConstants.BPsForHouseRent);
                        }

                        player.TempProperties.removeProperty(HousingConstants.HouseForHouseRent);

                        return;
                    }

                    var house      = player.TempProperties.getProperty <House>(HousingConstants.HouseForHouseRent, null);
                    var moneyToAdd = player.TempProperties.getProperty <long>(HousingConstants.MoneyForHouseRent, -1);
                    var bpsToMoney = player.TempProperties.getProperty <long>(HousingConstants.BPsForHouseRent, -1);

                    if (moneyToAdd != -1)
                    {
                        // if we're giving money and already have some in the lockbox, make sure we don't
                        // take more than what would cover 4 weeks of rent.
                        if (moneyToAdd + house.KeptMoney > HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS)
                        {
                            moneyToAdd = (HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS) - house.KeptMoney;
                        }

                        // take the money from the player
                        if (!player.RemoveMoney(moneyToAdd))
                        {
                            return;
                        }
                        InventoryLogging.LogInventoryAction(player, "(HOUSE;" + house.HouseNumber + ")", eInventoryActionType.Other, moneyToAdd);

                        // add the money to the lockbox
                        house.KeptMoney += moneyToAdd;

                        // save the house and the player
                        house.SaveIntoDatabase();
                        player.SaveIntoDatabase();

                        // notify the player of what we took and how long they are prepaid for
                        player.Out.SendMessage("You deposit " + Money.GetString(moneyToAdd) + " in the lockbox.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The lockbox now has " + Money.GetString(house.KeptMoney) + " in it.  The weekly payment is " +
                                               Money.GetString(HouseMgr.GetRentByModel(house.Model)) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The house is now prepaid for the next " + (house.KeptMoney / HouseMgr.GetRentByModel(house.Model)) +
                                               " payments.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                        // clean up
                        player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                    }
                    else
                    {
                        if (bpsToMoney + house.KeptMoney > HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS)
                        {
                            bpsToMoney = (HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS) - house.KeptMoney;
                        }

                        if (!player.RemoveBountyPoints(Money.GetGold(bpsToMoney)))
                        {
                            return;
                        }

                        // add the bps to the lockbox
                        house.KeptMoney += bpsToMoney;

                        // save the house and the player
                        house.SaveIntoDatabase();
                        player.SaveIntoDatabase();

                        // notify the player of what we took and how long they are prepaid for
                        player.Out.SendMessage("You deposit " + Money.GetString(bpsToMoney) + " in the lockbox.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The lockbox now has " + Money.GetString(house.KeptMoney) + " in it.  The weekly payment is " +
                                               Money.GetString(HouseMgr.GetRentByModel(house.Model)) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        player.Out.SendMessage("The house is now prepaid for the next " + (house.KeptMoney / HouseMgr.GetRentByModel(house.Model)) +
                                               " payments.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                        // clean up
                        player.TempProperties.removeProperty(HousingConstants.BPsForHouseRent);
                    }

                    // clean up
                    player.TempProperties.removeProperty(HousingConstants.MoneyForHouseRent);
                    break;
                }

                case eDialogCode.MasterLevelWindow:
                {
                    player.Out.SendMasterLevelWindow(m_response);
                    break;
                }
                }
            }