Exemplo n.º 1
0
        public override void DoAction(NWPlayer player, string pageName, int responseID)
        {
            var        model = GetDialogCustomData <Model>();
            NWLocation location;

            if (responseID == 1) // Create new instance
            {
                var instance = AreaService.CreateAreaInstance(player, model.AreaResref, string.Empty, model.DestinationTag);
                location = instance.GetLocalLocation("INSTANCE_ENTRANCE");
            }
            else
            {
                var      response = GetResponseByID("MainPage", responseID);
                NWObject member   = (NWObject)response.CustomData;

                if (!member.IsValid)
                {
                    player.SendMessage("Unable to locate party member.");
                    return;
                }

                var area = member.Area;
                location = area.GetLocalLocation("INSTANCE_ENTRANCE");
            }

            PlayerService.SaveLocation(player);

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

            EndConversation();
        }
Exemplo n.º 2
0
        private void DoPreview()
        {
            NWPlayer player = GetPC();
            var      data   = BaseService.GetPlayerTempData(GetPC());
            var      style  = DataService.BuildingStyle.GetByID(data.BuildingStyleID);
            var      area   = AreaService.CreateAreaInstance(player, style.Resref, "APARTMENT PREVIEW: " + style.Name, "PLAYER_HOME_ENTRANCE");

            SetLocalBool(area, "IS_BUILDING_PREVIEW", true);
            BaseService.JumpPCToBuildingInterior(player, area);
        }
Exemplo n.º 3
0
        private void DoPreview()
        {
            NWPlayer player = GetPC();
            var      data   = BaseService.GetPlayerTempData(GetPC());
            var      style  = DataService.Single <BuildingStyle>(x => x.ID == data.BuildingStyleID);
            var      area   = AreaService.CreateAreaInstance(player, style.Resref, "APARTMENT PREVIEW: " + style.Name, "PLAYER_HOME_ENTRANCE");

            area.SetLocalInt("IS_BUILDING_PREVIEW", TRUE);
            BaseService.JumpPCToBuildingInterior(player, area);
        }
Exemplo n.º 4
0
        private void DoInteriorPreview()
        {
            var data    = BaseService.GetPlayerTempData(GetPC());
            int styleID = data.StructureItem.GetLocalInt("STRUCTURE_BUILDING_INTERIOR_ID");
            var style   = DataService.BuildingStyle.GetByID(styleID);
            var area    = AreaService.CreateAreaInstance(GetPC(), style.Resref, "BUILDING PREVIEW: " + style.Name, "PLAYER_HOME_ENTRANCE");

            area.SetLocalInt("IS_BUILDING_PREVIEW", TRUE);
            NWPlayer player = GetPC();

            BaseService.JumpPCToBuildingInterior(player, area);
        }
Exemplo n.º 5
0
        public void Main()
        {
            NWPlayer oPC = GetLastUsedBy();

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

            NWPlaceable self                  = OBJECT_SELF;
            string      destination           = self.GetLocalString("DESTINATION");
            var         visualEffectID        = self.GetLocalInt("VISUAL_EFFECT") > 0 ? (VisualEffect)self.GetLocalInt("VISUAL_EFFECT") : VisualEffect.Invalid;
            int         keyItemID             = self.GetLocalInt("KEY_ITEM_ID");
            string      missingKeyItemMessage = self.GetLocalString("MISSING_KEY_ITEM_MESSAGE");
            bool        isInstance            = GetLocalBool(self, "INSTANCE") == true;
            bool        personalInstanceOnly  = GetLocalBool(self, "PERSONAL_INSTANCE_ONLY");

            if (keyItemID > 0)
            {
                if (!KeyItemService.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;
                }
            }

            if (visualEffectID > 0)
            {
                ApplyEffectToObject(DurationType.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;
            }

            if (isInstance)
            {
                var members = oPC.PartyMembers.Where(x => x.Area.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.Area.Resref);
                    oPC.SetLocalString("INSTANCE_DESTINATION_TAG", destination);
                    DialogService.StartConversation(oPC, self, "InstanceSelection");
                    return;
                }

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

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