Changing player during the game

Started by Ralkai, Fri 30/11/2007 19:17:33

Previous topic - Next topic

Ralkai

Hello!

I'm new here and i have a little question... It's posible to change the player during the game? For example, you are using the player A, but in certain part of the history, A is killed and you pass to control the character B. It's posible to do this?

Thank's a lot!
"No tengas miedo de soñar lo imposible, pues ¿y si pasara? Nada es imposible, tan solo poco probable"

Actual Game: "Three Spheres Tale"

.M.M.

Yes it is possible.

SetAsPlayer
(Formerly known as SetPlayerCharacter, which is now obsolete)

Character.SetAsPlayer()

Changes the character which the player controls to the specified character. This function will also cause the room to change to the room which the chosen character is currently in (though as with ChangeRoom, the change won't happen until the end of the script).
Additionally, calling this command will cause the "player" variable to be updated to point to the specified character.

Example:

character[MAN].SetAsPlayer();

will change the character that the player controls to character MAN and also change to the room that MAN is in, if he is not in the current room.


If you want to next character has own items, cal
Code: ags
 invCustomInv.CharacterToUse = cMan 


invCustomInv is script name of default inventory window.

Radiant

And also, GetPlayerCharacter() will tell you which character is currently selected.

You can also make a GUI that lets you swap, like in Day of the Tentacle.

Ashen

GetPlayerCharacter() is obsolete in newer versons (2.7 and on). The player pointer will update to the current player character, for commands like player.Say, player.Walk, etc, and player.ID should be used if you need the character number.
invCustomInv has it's Character ID set to -1 in the editor - that means it updates to the player character too, so you don't need to use CharacterToUse. (If you make your own Inventory GUI, you can set it to use -1 as well.)

Ralkai, Character.SetAsPlayer is in the Manual (Mirek basically copied the entry here, so I won't link it), and this question is answered in the BFAQ. Please check in those places, and search the forums, before posting.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk