コード例 #1
0
ファイル: BaseService.cs プロジェクト: Kenji3108/SWLOR_NWN
        public void JumpPCToBuildingInterior(NWPlayer player, NWArea area)
        {
            NWObject exit = null;

            NWObject @object = (_.GetFirstObjectInArea(area.Object));

            while (@object.IsValid)
            {
                if (@object.Tag == "building_exit")
                {
                    exit = @object;
                }

                @object = (_.GetNextObjectInArea(area.Object));
            }

            if (exit == null)
            {
                player.FloatingText("ERROR: Couldn't find the building interior's exit. Inform an admin of this issue.");
                return;
            }

            _player.SaveLocation(player);

            exit.SetLocalLocation("PLAYER_HOME_EXIT_LOCATION", player.Location);
            exit.SetLocalInt("IS_BUILDING_DOOR", 1);

            Location location = area.GetLocalLocation("INSTANCE_ENTRANCE");

            player.AssignCommand(() =>
            {
                _.ActionJumpToLocation(location);
            });
        }
コード例 #2
0
ファイル: DeathService.cs プロジェクト: zunath/Freescape
        private void TeleportPlayerToBindPoint(NWObject pc, PlayerCharacter entity)
        {
            if (entity.CurrentHunger < 50)
            {
                entity.CurrentHunger = 50;
            }

            if (string.IsNullOrWhiteSpace(entity.RespawnAreaTag))
            {
                NWObject defaultRespawn = NWObject.Wrap(_.GetWaypointByTag("DEFAULT_RESPAWN_POINT"));
                Location location       = defaultRespawn.Location;

                pc.AssignCommand(() =>
                {
                    _.ActionJumpToLocation(location);
                });
            }
            else
            {
                pc.AssignCommand(() =>
                {
                    NWArea area       = NWArea.Wrap(_.GetObjectByTag(entity.RespawnAreaTag));
                    Vector position   = _.Vector((float)entity.RespawnLocationX, (float)entity.RespawnLocationY, (float)entity.RespawnLocationZ);
                    Location location = _.Location(area.Object, position, (float)entity.RespawnLocationOrientation);
                    _.ActionJumpToLocation(location);
                });
            }
        }
コード例 #3
0
        public bool Run(params object[] args)
        {
            NWPlayer    player = NWPlayer.Wrap(_.GetLastUsedBy());
            NWPlaceable warp   = NWPlaceable.Wrap(Object.OBJECT_SELF);
            bool        isExit = warp.GetLocalInt("IS_EXIT") == NWScript.TRUE;

            if (isExit)
            {
                PlayerCharacter entity   = _player.GetPlayerEntity(player.GlobalID);
                NWArea          area     = NWArea.Wrap(_.GetObjectByTag(entity.LocationAreaTag));
                Vector          position = _.Vector((float)entity.LocationX, (float)entity.LocationY, (float)entity.LocationZ);
                Location        location = _.Location(area.Object,
                                                      position,
                                                      (float)entity.LocationOrientation);

                player.AssignCommand(() => _.ActionJumpToLocation(location));
            }
            else
            {
                _player.SaveLocation(player);
                NWObject waypoint = NWObject.Wrap(_.GetWaypointByTag("TUTORIAL_WP"));
                player.AssignCommand(() => _.ActionJumpToLocation(waypoint.Location));
            }


            return(true);
        }
コード例 #4
0
ファイル: DeathService.cs プロジェクト: xephnin/SWLOR_NWN
        private void TeleportPlayerToBindPoint(NWObject pc, Player entity)
        {
            // Instances
            if (pc.Area.IsInstance)
            {
                var        area     = pc.Area;
                NWLocation entrance = area.GetLocalLocation("INSTANCE_ENTRANCE");
                pc.AssignCommand(() =>
                {
                    _.ActionJumpToLocation(entrance);
                });
            }
            // Send player to default respawn point if no bind point is set.
            else if (string.IsNullOrWhiteSpace(entity.RespawnAreaResref))
            {
                NWObject defaultRespawn = (_.GetWaypointByTag("DEFAULT_RESPAWN_POINT"));
                Location location       = defaultRespawn.Location;

                pc.AssignCommand(() =>
                {
                    _.ActionJumpToLocation(location);
                });
            }
            // Send player to their stored bind point.
            else
            {
                NWArea   area     = NWModule.Get().Areas.Single(x => x.Resref == entity.RespawnAreaResref);
                Vector   position = _.Vector((float)entity.RespawnLocationX, (float)entity.RespawnLocationY, (float)entity.RespawnLocationZ);
                Location location = _.Location(area.Object, position, (float)entity.RespawnLocationOrientation);
                pc.AssignCommand(() =>
                {
                    _.ActionJumpToLocation(location);
                });
            }
        }
コード例 #5
0
ファイル: ExitAreaInstance.cs プロジェクト: xephnin/SWLOR_NWN
        public bool Run(params object[] args)
        {
            NWObject door = Object.OBJECT_SELF;

            if (!door.Area.IsInstance)
            {
                return(false);
            }

            NWObject target = _.GetTransitionTarget(door);
            NWPlayer player = _.GetClickingObject();

            _.DelayCommand(6.0f, () =>
            {
                int playerCount = NWModule.Get().Players.Count(x => !Equals(x, player) && Equals(x.Area, door.Area));
                if (playerCount <= 0)
                {
                    _area.DestroyAreaInstance(door.Area);
                }
            });

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

            return(true);
        }
コード例 #6
0
ファイル: Stuck.cs プロジェクト: zunath/SolarOdyssey2_NWN
        public void DoAction(NWPlayer user, params string[] args)
        {
            PlayerCharacter pc       = _db.PlayerCharacters.Single(x => x.PlayerID == user.GlobalID);
            Location        location = _.Location(
                _.GetObjectByTag(pc.RespawnAreaTag),
                _.Vector((float)pc.RespawnLocationX, (float)pc.RespawnLocationY, (float)pc.RespawnLocationZ),
                (float)pc.RespawnLocationOrientation
                );

            user.AssignCommand(() => _.ActionJumpToLocation(location));
            _.SendMessageToPC(user.Object, "Alpha feature: Returning to bind point. Please report bugs on Discord/GitHub. And for the love of all that is Zunath, don't abuse this!");
        }
コード例 #7
0
ファイル: WarpToWaypoint.cs プロジェクト: xephnin/SWLOR_NWN
        public bool Run(params object[] args)
        {
            NWPlayer player    = _.GetPCSpeaker();
            NWObject talkingTo = Object.OBJECT_SELF;

            string   waypointTag = talkingTo.GetLocalString("DESTINATION");
            NWObject waypoint    = _.GetWaypointByTag(waypointTag);

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

            return(true);
        }
コード例 #8
0
        public bool Run(params object[] args)
        {
            const int   QuestID = 30;
            NWPlaceable crystal = Object.OBJECT_SELF;
            NWPlayer    player  = _.GetLastUsedBy();

            // Check player's current quest state. If they aren't on stage 2 of the quest only show a message.
            var status       = _data.Single <PCQuestStatus>(x => x.PlayerID == player.GlobalID && x.QuestID == QuestID);
            var currentState = _data.Single <QuestState>(x => x.ID == status.CurrentQuestStateID);

            if (currentState.Sequence != 2)
            {
                player.SendMessage("The crystal glows quietly...");
                return(false);
            }

            // Player is on stage 2, so they're able to click the crystal, get a cluster, complete the quest, and teleport back to the cavern.
            int    type = crystal.GetLocalInt("CRYSTAL_COLOR_TYPE");
            string cluster;

            switch (type)
            {
            case 1: cluster = "c_cluster_blue"; break;    // Blue

            case 2: cluster = "c_cluster_red"; break;     // Red

            case 3: cluster = "c_cluster_green"; break;   // Green

            case 4: cluster = "c_cluster_yellow"; break;  // Yellow

            default: throw new Exception("Invalid crystal color type.");
            }

            _.CreateItemOnObject(cluster, player);
            _quest.AdvanceQuestState(player, crystal, QuestID);

            // Hide the "Source of Power?" placeable so the player can't use it again.
            _ovs.AdjustVisibility(player, "81533EBB-2084-4C97-B004-8E1D8C395F56", false);

            NWObject tpWP = _.GetObjectByTag("FORCE_QUEST_LANDING");

            player.AssignCommand(() => _.ActionJumpToLocation(tpWP.Location));

            // Notify the player that new lightsaber perks have unlocked.
            player.FloatingText("You have unlocked the Lightsaber Blueprints perk. Find this under the Engineering category in your perks menu.");

            return(true);
        }
コード例 #9
0
        public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args)
        {
            string   tag = args[0];
            NWObject wp  = _.GetWaypointByTag(tag);

            if (!wp.IsValid)
            {
                user.SendMessage("Invalid waypoint tag. Did you enter the right tag?");
                return;
            }

            user.AssignCommand(() =>
            {
                _.ActionJumpToLocation(wp.Location);
            });
        }
コード例 #10
0
ファイル: PlayerService.cs プロジェクト: zunath/Freescape
        private void LoadLocation(NWPlayer player)
        {
            if (!player.IsPlayer)
            {
                return;
            }

            if (player.Area.Tag == "ooc_area")
            {
                PlayerCharacter entity   = GetPlayerEntity(player.GlobalID);
                NWArea          area     = NWArea.Wrap(_.GetObjectByTag(entity.LocationAreaTag));
                Vector          position = _.Vector((float)entity.LocationX, (float)entity.LocationY, (float)entity.LocationZ);
                Location        location = _.Location(area.Object,
                                                      position,
                                                      (float)entity.LocationOrientation);

                player.AssignCommand(() => _.ActionJumpToLocation(location));
            }
        }
コード例 #11
0
        public bool Run(params object[] args)
        {
            NWObject    oPC            = NWObject.Wrap(_.GetLastUsedBy());
            NWPlaceable self           = NWPlaceable.Wrap(Object.OBJECT_SELF);
            string      destination    = self.GetLocalString("DESTINATION");
            int         visualEffectID = self.GetLocalInt("VISUAL_EFFECT");

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

            oPC.AssignCommand(() =>
            {
                Location location = _.GetLocation(_.GetWaypointByTag(destination));
                _.ActionJumpToLocation(location);
            });

            return(true);
        }
コード例 #12
0
        private void LoadLocation(NWPlayer player)
        {
            if (!player.IsPlayer)
            {
                return;
            }

            if (player.Area.Tag == "ooc_area")
            {
                Player entity = GetPlayerEntity(player.GlobalID);
                NWArea area   = NWModule.Get().Areas.SingleOrDefault(x => x.Resref == entity.LocationAreaResref);
                if (area == null)
                {
                    return;
                }

                Vector   position = _.Vector((float)entity.LocationX, (float)entity.LocationY, (float)entity.LocationZ);
                Location location = _.Location(area.Object,
                                               position,
                                               (float)entity.LocationOrientation);

                player.AssignCommand(() => _.ActionJumpToLocation(location));
            }
        }
コード例 #13
0
ファイル: OnUsed.cs プロジェクト: Liareth/SWLOR_NWN
        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);
        }