Player Object Questions

Using the GUI preferably, how do you make sure that Quest knows which "can become player" object is the current player object if they're both in play/in the same room?

I have object Xia a named Female Character and she is the player object at the start of the game. I have a named Female Character Scion and she can become the player object later in the game. They both start out in room quarters1.

I feel like this is a really really simple thing and I am just worrying over nothing. I just want to make sure that we're not going to start the game with two players or accidentally controlling Scion, who's supposed to be asleep.


On a slightly less simple note: if I wanted Scion to follow Xia at points, is that a built in function, would I need to get an extra library, would I need to/be able to code that in myself, or is that something that can't be done?

An example would be if I wanted Scion to follow Xia north from quarters1 into hall1 then north into hall2 but for the following to stop if Xia tells Scion to wait.

Could it be done by temporarily making Scion's parent object be Xia?

//other code
if (this.followXia = true) {
   MoveObject (this, Xia)
} else {
   msg "\"I'll wait here."\"
//other code

I just made a real simple test game for this and it works.

In the game object in the GUI click on the script tab. In code view I typed the following under the 'script when entering a room'' section.

if (GetBoolean(dog, "following")) {
  msg ("The dog follows closely at your heels.")
  dog.parent = game.pov.parent
}

It is simply an If script that checks for the flag 'following'. If that flag is present, then I printed the message about the dog following. I also set the dog parent equal to the current pov (our character) parent. In the GUI, it is the set variable script. In the first box I typed dog.parent, I left the drop down set to expression, and I typed game.pov.parent in the last box.

In this demo, I set the flag 'following' on the dog object after the player entered the room that had the dog. In another room, I unset the flag and moved the dog back to the original room. If you want the 'following' flag to be set whenever the two characters "run into each other" in the same room, just move the flag setting script to the game tab to be run after every turn. You can also unset the flag for any event that you choose.

As far as changing the player object. Whenever you change the player object, the pov switches to that object and the object that used to be the game pov object will remain where ever the switch of pov occurred. In X2, I have a character that the main character can switch to with a simple command if they are in the same room. The original player passes out and remains put until the player decides to switch back. Another option there is to move the non-pov character to a "storage room" or make them invisible.


Thanks, that answered my question perfectly! I think, to avoid cluttering the forum, I'll use this thread for all my questions about the player object and how it interacts with the world.

I have another one now actually. I want the look at description of an object to change based on which of the two possible player characters is currently the game pov character. I know this can be done by selecting script and setting it as an if script and doing the code to present different messages based on who is looking.

However, I also know it can be done in the text processor. Doing it in the text processor would make it easier because for most things I only need to change for example when looking at the ArtWallScion's Art into your art. But how would I format the thing attribute it's looking for to be able to check who is the pov character? I know that game.pov.parent would give what room the game pov is in, would game.pov give the object that is the game pov?

Any ideas or hints there?


This is not something I have played arouind with, but if you set an object to be the player, you get a new tab appearing. Does that have a description on it? If so, I would assume that would be the description when the object is the player, and he normal one is the description otherwise.


HK edit: added in another link (the 'ChangePov' Function/Command) that I forgot the first time


yes, Object Attributes (which the 'pov' is a special one) are pointers/object-references (well, I think technically an Object's name is the actual pointer, but whatever, lol), which hold the 'name' of the Object:

game.pov = player

player.parent = room
// game.pov.parent = room

game.pov = player
player.parent = room
// which is the same as:
game.pov.parent = room

game.pov = player
MoveObject (player, room2)
// which is the same as:
MoveObject (game.pov, room2)

// think of 'game.pov' as being the same as using 'player' (or whatever Player Object's 'name' is the Value of the 'game.pov' Object Attribute)

another built-in and special Object Attribute: 'parent'


some custom Object Attribute examples:

player.right_arm = sword
player.left_hand = shield
player.selected_spell = fireball

<object name="player"></object>
<object name="sword"></object>
<object name="shield"></object>
<object name="fireball"></object>

---------------

// simplistic-example code for allowing being able to go 'back' to your previous room (we'd need to use an Objectlist Attribute, to be able to go back to further/multiple previous rooms):

<object name="player">
  <attr name="parent" type="object">room</attr>
  <attr name="current_room" type="object">room</attr>
  <attr name="previous_room" type="object">room</attr>
  <attr name="changedparent" type="script">
    player.previous_room = current_room
    player.current_room = player.parent
  </attr>
</object>

<command name="back_cheat_command">
  <pattern>cheat_back</pattern>
  <script>
    game.pov.parent = game.pov.previous_room
  </script>
</command

the 'game.pov' is what is used to determine who's your currently controlled Player Object

'game' Game Settings Object -> 'Features' Tab -> toggle on the 'Player' Tabs (if needed)

'game' Game Settings Object -> 'Player' Tab (I think, or maybe it's some other Tab, meh) -> 'pov' Object Attribute (drop down box, I think)

'NAME_OF_PLAYER_OBJECT' Player Object -> 'Player' Tab (I think, or maybe it's some other Tab, meh) -> 'can be a player object' -> (think this creates the '<inherit name="editor_player' />' in code, which then auto-gives the various things needed, otherwise you got to find out what all of the various things are needed, and add them in code, manually)

Object Name: game
Attribute Name: pov
Attribute Type: object
Attribute Value: NAME_OF_PLAYER_OBJECT

the 'game' Game Settings Object and Player Objects have the 'statusattributes' String Dictionary Attribute.

You got to be careful when using multiple Player Objects, as when to use 'game.pov' (it'll apply to who-ever is your current Value of game.pov) vs their (the Player Objects') individual names (it'll only apply to that Player Object) in code, depending on what you're doin for your game design or varios parts of it.

lastly, be aware ...that for your Player Objects, you've got your 'non-player object description' (when you're NOT controlling the Player Object, aka it's currenting acting as an npc) normal area in the 'setup' Tab of your Player Object in/for the GUI/Editor (the 'look/lookat'String/Script Attribute/Verb/Command) and you've also got a 'player object description' (when you ARE controlling it) area in the 'Player' Tab of your Player Object  in/for the GUI/Editor (this is the 'pov_look' String/Script Attribute/Verb/Command). Many people don't realize this, and are baffled at why they can't see the description that they gave to their Player Object... due to not realizing that Player Objects have now two Attributes for handling their descriptions, the normal 'loo/lookat' String/Script Attribute and also the 'pov_look' String/Script Attribute.

http://docs.textadventures.co.uk/quest/functions/corelibrary/changepov.html
https://docs.textadventures.co.uk/quest/tutorial/changing_the_player_object.html

https://blog.textadventures.co.uk/2012/09/19/pov-support-multiple-player-objects-in-quest-5-3/
^^^^^^^^^^^
https://blog.textadventures.co.uk/2012/12/03/quest-5-3-beta-is-now-available/ (scroll down to 'game behavior - new things' -> changeable pov)
^^^^^
https://docs.textadventures.co.uk/quest/upgrade_notes.html

or

http://docs.textadventures.co.uk/quest/tutorial/changing_the_player_object.html

http://blog.textadventures.co.uk/2012/09/19/pov-support-multiple-player-objects-in-quest-5-3/
^^^^^^^^^^^
http://blog.textadventures.co.uk/2012/12/03/quest-5-3-beta-is-now-available/ (scroll down to 'game behavior - new things' -> changeable pov)
^^^^^
http://docs.textadventures.co.uk/quest/upgrade_notes.html


ask me if you need help with anything


there's no built-in 'follower' code, but creating one is very simple, credit goes to 'Sgrieg', for his/her generalized 'follower' code of how to do it:

subtletylost.parent = hegemonkhan.parent // you're following me, hehe
or
MoveObject (subtletylost, hegemonkhan.parent) // you're following me, hehe

Warning:

if you just did this:

subtletylost.parent = hegemonkhan
or
MoveObject (subletylost, hegemonkhan) 

you'd be moving/putting/setting 'subletylost' INSIDE OF 'hegemonkhan', which you probably don't want, lol

an example of it in use (your almost classic D&D party/team: you and 6 team/party members: you merely select their actions, they're NOT separate/world-controllable characters):

<object name="room">
</object>

<object name="room2">
</object>

<object name="player">
  <attr name="parent" type="object">room</attr>
  <attr name="team_objectlist_attribute" type="objectlist">barbarian;knight;thief;cleric;wizard;bard</attr>
  <attr name="changedparent" type="script">
    foreach (team_member_object_variable, this.team_objectlist_attribute) {
      team_member_object_variable.parent = this.parent
    }
  <attr>
</object>

<object name="barbarian">
  <attr name="parent" type="object">room</attr>
</object>

<object name="knight">
  <attr name="parent" type="object">room</attr>
</object>

<object name="thief">
  <attr name="parent" type="object">room</attr>
</object>

<object name="cleric">
  <attr name="parent" type="object">room</attr>
</object>

<object name="wizard">
  <attr name="parent" type="object">room</attr>
</object>

<object name="bard">
  <attr name="parent" type="object">room</attr>
</object>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums