Player transformation Help

Brandon 10
10 Aug 2016, 07:37Hey all, I'm new here and I wanted to try and do something different with a series I'm working on by creating a text adventure game for it. I think I'm doing quite alright so far but I do seem to get stuck on certain bits as I progress through the game. The forums have been helping a lot as well as the document tutorials but one thing that I am finding difficult is changing my player into a different player.
What I'm planning on doing is making an item in the inventory of the player usable and depending on what the actual player (person playing my game) types in, the player will become one of the few other available players.
For example: Bob uses the item in his inventory, player types in the phrase "Dave" and Bob transforms into Dave. Dave is now playable until the player chooses to transform back into Bob. I also want each player to have unique abilities (although I think I can manage that using verbs but then again, I'm not entirely sure). And I noticed that some topics were answered with coding and I have no idea how to code here so can you please describe it to me like I will with what I have so far.
I already have the item in the player's inventory. Under Use/Give (for the item), I have a script that says Print Message which displays instructions on how to transform (to be added later on, of course), underneath is Switch: "text" -> Cases: Dave --> Change player object to object Dave. I tested it in game and I'm only able to use the item which displays the instructions but "Dave" can't be seen. I'm not sure where to put the Dave object so I moved it inside the item (player->Item->Dave). Like I said, I'm stuck at this part and not really sure what else to do as this seems a little advanced for me but necessary for my story. Thank you to anyone that helps me with this.
The Pixie
10 Aug 2016, 08:00There are two ways to approach this.
- Have two objects, Dave and Bob, both of which are present in game, and can move room to room independently, and allow the player to flip between them. I.e., the player is controlling two different characters. The code to change from Dave to Bob is:
game.pov = Bob
If you are using the GUI, it looks a bit like this:
Set variable [game.pov] [expression] [Bob]
To handle different abilities either check the value of game.pov, or its attributes.
if (game.pov = Bob) {
msg("Bob cannot do that.")
}
else {
...
damage = game.pov.strength * 3
- If there is one character, and he can transform from Bob to Dave, I would just change his name.
player.alias = "Bob"
If you are using the GUI, it looks a bit like this:
Set variable [player] [expression] ["Bob"]
To handle different abilities check the value of player.alias
if (player.alias = "Bob") {
msg("Bob cannot do that.")
}
else {
...
hegemonkhan
10 Aug 2016, 12:46aside from what Pixie has alread explained, here's my own repsonse:
Brandon's quote:
I already have the item in the player's inventory. Under Use/Give (for the item), I have a script that says Print Message which displays instructions on how to transform (to be added later on, of course), underneath is Switch: "text" -> Cases: Dave --> Change player object to object Dave.
you almost got it right... here's the changes you need:
-
I already have the item in the player's inventory.
-
Under Use/Give (for the item), I have a script that says Print Message which displays instructions on how to transform (to be added later on, of course) // and ask them for the typed-in input
(let's say they're currently 'Bob', and they want to change control over to 'Dave' Player Object, so during game play, they type in: Dave)
- (see below) --- this is a good link on using 'get input' Script and etc stuff: http://docs.textadventures.co.uk/quest/guides/character_creation.html
add new script -> 'output' section/category -> 'get input' Script
(with the 'get input' and 'show menu' Scripts/Functions, quest automatically, and hidden from you, sets the 'result' variable to your choice: result = YOUR_TYPED_IN_INPUT_OR_YOUR_MENU_SELECTED_CHOICE, which you can then use this 'result' variable for whatever you want, such as in your 'switch' Script/Function as seen: switch (result) { cases (blah) { blah } } stuff)
- (see below)
then,
-> add new script -> underneath is Switch: result -> (see below)
-> -> Cases: "Bob" --> Change player object to object Bob.
-> -> Cases: "Dave" --> Change player object to object Dave.
-> -> (etc) Cases: "WHOEVER/ETC" --> Change player object to object WHOEVER/ETC.
explanation of the 'pov' System:
the default new game Player Object is the 'player' Player Object
you can have more Player objects, which are the characters that you can control --- but only one at a time obviously:
thus, you switch control amongst them, in who you're currently controlling, which is done via the 'ChangePov(NAME)' Script/Function in code, or in the GU~Editor: 'change player object to object BLAH' Script/Function
you can reference your CURRENTLY CONTROLLED Player object (pov), via using this Attribute 'game.pov', but you got to be careful, as it'll apply to whoever is your pov (CURRENTLY CONTROLED Player Object), which you may not want, for example:
let's say you got a reward in game for doing something, +5 strength, but you only want it to occur (be given) to/for 'dave', and not 'Bob'
well if you use this:
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable game.pov.strength = [EXPRESSION] game.pov.strength + 5
then you'll get the +5 strength increase to WHOEVER is your pov (currently controlled Player object): so even if you're 'Bob', then Bob's strength will be increased by 5, when you didn't want Bob to be able to increase his strength, you only wanted 'Dave' to be able to increase his strength.
whereas, if you used this:
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable Dave.strength = [EXPRESSION] Dave.strength + 5
it'll give +5 strength to Dave, regardless of whoever you're currently controlling
if you only want it to give the +5 strength to Dave, only when/if you're currently controlling Dave, then you need to do some 'if' scripting:
add new script -> 'scripts' section/category -> 'if' Script -> [EXPRESSION] -> (see below)
if [EXPRESSION] game.pov = Dave
then,
-> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)
set variable Dave.strength = [EXPRESSION] Dave.strength + 5
so, you got to be careful in whether you use, for this example, 'game.pov.strength' vs the individual Player Object references: 'Bob.strength', 'Dave.strength', 'player.strength', 'player2.strength', etc.
on the other hand, if you DO want something to be applied to WHOEVER is your pov, then the 'game.pov' is great.
another great example of this is with 'experience / experience points / exp / xp', do you want all of your Player Objects to get 'experience' upon killing a monster, or do you want just that specific individual Player Object you're currently controlling, which is killing the mosnter, to get the 'experience', and NOT any of your other Player Objects? This is the difference between using 'game.pov.experience' and 'player.experience, player_2.experience, or etc player_X.experience'
http://docs.textadventures.co.uk/quest/tutorial/changing_the_player_object.html
some info on changing pov
by using multiple Player Objects, you can have each of them have their own stats/attributes easily, control them easily, switch between them easily, and display them easily (using 'Status Attributes'). I'd recommend this as it's built into quest already for you, as opposed to your own handling of it all with the alternative method of designing it yourself with Objects and 'if' checking scripts and etc, as Pixie touched upon for that alternative method of-with using just a single Player Object.
P.S.
also here's a bunch of guides, that will likely be helpful for you:
http://docs.textadventures.co.uk/quest/guides/
they're a bit hidden on the doc site, so I like to post the link for it for people.

Brandon 10
11 Aug 2016, 05:44Thank you for all of the help, guys. I tried to apply as much as I could but I ended up getting stuck again. Fortunately, I found a way around this by creating a command for transforming so now the player can type "transform into (name)" and it will prompt a message saying that they are (name) while switching the player pov as proven by the different look at self dialogues that I provided. My only problem so far is that I still don't know where to put the other characters (right now I have three plus the default player which I renamed "Bob"). When I tested my game, the commands worked well except that once you travel to another room and transform there, you're teleported to the character you're playing as who is in the room I had him in.
For example: Bob starts in the lounge then travels to the kitchen. He transforms into Dave in the kitchen but is now Dave in the lounge rather than the kitchen.
Afterwards, I tried attaching the characters to Bob but when I transformed into them, I ended up inside of Bob's inventory which was pretty weird. Is there a way to have the other characters follow me so that when I transform into them, I don't teleport anywhere else?
The Pixie
11 Aug 2016, 07:23To have characters follow you around, see here:
http://docs.textadventures.co.uk/quest/guides/following.html
To quote that page, "The best way to do this is to set up a script that is triggered when a player enters a new room. To do this, go to the Script tab of the game object. The bit we want is “Script when entering a room”." Assuming the whole group are always going to be there, the code would be:
Dave.parent = game.pov.parent
Bob.parent = game.pov.parent
Edith.parent = game.pov.parent
msg ("The rest of the gang follow along behind.")
That should be fine, even if the player is Dave; he will already be there, so nothing will change.