Ejemplo n.º 1
0
        public bool Run(params object[] args)
        {
            NWPlayer player = _.GetLastUsedBy();

            if (!player.IsPlayer)
            {
                return(false);
            }

            NWPlaceable placeable = Object.OBJECT_SELF;
            int         keyItemID = placeable.GetLocalInt("KEY_ITEM_ID");

            if (keyItemID <= 0)
            {
                return(false);
            }

            if (_keyItem.PlayerHasKeyItem(player, keyItemID))
            {
                player.SendMessage("You already have this key item.");
                return(false);
            }

            _keyItem.GivePlayerKeyItem(player, keyItemID);

            string visibilityGUID = placeable.GetLocalString("VISIBILITY_OBJECT_ID");

            if (!string.IsNullOrWhiteSpace(visibilityGUID))
            {
                _ovs.AdjustVisibility(player, placeable, false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void RequestItemsFromPC(NWPlayer oPC, NWObject questOwner, int questID)
        {
            if (!oPC.IsPlayer)
            {
                return;
            }

            PCQuestStatus pcStatus = _data.SingleOrDefault <PCQuestStatus>(x => x.PlayerID == oPC.GlobalID && x.QuestID == questID);

            if (pcStatus == null)
            {
                oPC.SendMessage("You have not accepted this quest yet.");
                return;
            }

            QuestState questState       = _data.Get <QuestState>(pcStatus.CurrentQuestStateID);
            var        requiredKeyItems = _data.Where <QuestRequiredKeyItem>(x => x.QuestStateID == pcStatus.CurrentQuestStateID);

            foreach (QuestRequiredKeyItem ki in requiredKeyItems)
            {
                if (!_keyItem.PlayerHasKeyItem(oPC, ki.KeyItemID))
                {
                    oPC.SendMessage("You are missing a required key item.");
                    return;
                }
            }

            if (questState.QuestTypeID != (int)QuestType.CollectItems)
            {
                oPC.SendMessage("The quest state you are currently on is not configured to collect items. Please inform an admin of this issue. (QuestID: " + questID + ")");
                return;
            }

            Location    location  = oPC.Location;
            NWPlaceable collector = (_.CreateObject(OBJECT_TYPE_PLACEABLE, "qst_item_collect", location));

            collector.SetLocalObject("QUEST_OWNER", questOwner);

            collector.AssignCommand(() =>
            {
                _.SetFacingPoint(oPC.Position);
            });
            collector.SetLocalInt("QUEST_ID", questID);

            oPC.AssignCommand(() =>
            {
                _.ActionInteractObject(collector.Object);
            });
        }
Ejemplo n.º 3
0
        public void RequestItemsFromPC(NWPlayer oPC, NWObject questOwner, int questID, int sequenceID)
        {
            if (!oPC.IsPlayer)
            {
                return;
            }

            PCQuestStatus pcStatus = _db.PCQuestStatus.Single(x => x.PlayerID == oPC.GlobalID && x.QuestID == questID);

            if (pcStatus == null)
            {
                oPC.SendMessage("You have not accepted this quest yet.");
                return;
            }

            QuestState questState = pcStatus.CurrentQuestState;

            if (questState.Sequence != sequenceID)
            {
                oPC.SendMessage("SequenceID mismatch. Please inform an admin there is a bug with this quest. (QuestID = " + questID + ")");
                return;
            }

            foreach (QuestRequiredKeyItemList ki in questState.QuestRequiredKeyItemLists)
            {
                if (!_keyItem.PlayerHasKeyItem(oPC, ki.KeyItemID))
                {
                    oPC.SendMessage("You are missing a required key item.");
                    return;
                }
            }

            Location    location  = oPC.Location;
            NWPlaceable collector = NWPlaceable.Wrap(_.CreateObject(OBJECT_TYPE_PLACEABLE, "qst_item_collect", location));

            collector.AssignCommand(() =>
            {
                _.SetFacingPoint(oPC.Position);
            });
            collector.SetLocalInt("QUEST_ID", questID);
            _.CreateItemOnObject(SubmitQuestItemResref, collector.Object);

            oPC.AssignCommand(() =>
            {
                _.ActionInteractObject(collector.Object);
            });
        }
Ejemplo n.º 4
0
        public bool Run(params object[] args)
        {
            NWPlayer oPC = _.GetLastUsedBy();

            if (_.GetIsInCombat(oPC) == TRUE)
            {
                _.SendMessageToPC(oPC, "You are in combat.");
                return(false);
            }

            NWPlaceable self                  = Object.OBJECT_SELF;
            string      destination           = self.GetLocalString("DESTINATION");
            int         visualEffectID        = self.GetLocalInt("VISUAL_EFFECT");
            int         keyItemID             = self.GetLocalInt("KEY_ITEM_ID");
            string      missingKeyItemMessage = self.GetLocalString("MISSING_KEY_ITEM_MESSAGE");
            bool        isInstance            = self.GetLocalInt("INSTANCE") == TRUE;
            bool        personalInstanceOnly  = self.GetLocalInt("PERSONAL_INSTANCE_ONLY") == TRUE;

            if (keyItemID > 0)
            {
                if (!_keyItem.PlayerHasKeyItem(oPC, keyItemID))
                {
                    if (!string.IsNullOrWhiteSpace(missingKeyItemMessage))
                    {
                        oPC.SendMessage(missingKeyItemMessage);
                    }
                    else
                    {
                        oPC.SendMessage("You don't have the necessary key item to access that object.");
                    }

                    return(false);
                }
            }

            if (visualEffectID > 0)
            {
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(visualEffectID), oPC.Object);
            }

            NWObject   entranceWP = _.GetWaypointByTag(destination);
            NWLocation location   = _.GetLocation(entranceWP);

            if (!entranceWP.IsValid)
            {
                oPC.SendMessage("Cannot locate entrance waypoint. Inform an admin.");
                return(false);
            }

            if (isInstance)
            {
                var members = oPC.PartyMembers.Where(x => x.GetLocalString("ORIGINAL_RESREF") == entranceWP.Area.Resref).ToList();

                // A party member is in an instance of this type already.
                // Prompt player to select which instance to enter.
                if (members.Count >= 1 && !personalInstanceOnly)
                {
                    oPC.SetLocalString("INSTANCE_RESREF", entranceWP.Resref);
                    oPC.SetLocalString("INSTANCE_DESTINATION_TAG", destination);
                    _dialog.StartConversation(oPC, self, "InstanceSelection");
                    return(false);
                }

                // Otherwise no instance exists yet or this instance only allows one player. Make a new one for this player.
                NWArea instance = _area.CreateAreaInstance(oPC, entranceWP.Area.Resref, entranceWP.Area.Name, destination);
                location = instance.GetLocalLocation("INSTANCE_ENTRANCE");
                _player.SaveLocation(oPC);
            }

            oPC.AssignCommand(() =>
            {
                _.ActionJumpToLocation(location);
            });

            return(true);
        }