How to add secondary players?

HyperMasenko
14 Jul 2013, 20:14
I need to know how to add secondary characters, such as pets or partners, if you will.
So, any ideas?

jaynabonne
14 Jul 2013, 20:20
Just a note (since is your second post here): the Libraries and Code Samples forum is for posting, well, libraries and code samples. :) If you have a question, you'd be better off asking it in the main Quest forum.

Characters (also sometimes called "non-player characters or "NPC"s) can be implemented as objects. Create a new object and give it the name you want for the character. You might want to make it "character-like" (e.g. can't be taken, etc). When you create this character object, go to the "Setup" tab for the object and under "Type", change it from "Inanimate object" to whatever you want.

HyperMasenko
14 Jul 2013, 20:41
Oh, OK, I never really payed much attention to the Setup tab for anything rather than "player" lol. Thanks! Oh, and, I will be sure to ask all of my future questions in the main Quest forum. Thanks for that, too!

HyperMasenko
14 Jul 2013, 21:19
jaynabonne wrote:Characters (also sometimes called "non-player characters or "NPC"s) can be implemented as objects. Create a new object and give it the name you want for the character. You might want to make it "character-like" (e.g. can't be taken, etc). When you create this character object, go to the "Setup" tab for the object and under "Type", change it from "Inanimate object" to whatever you want.



But, how do I make them follow me? Or is there a way?

HyperMasenko
14 Jul 2013, 21:20
jaynabonne wrote:Characters (also sometimes called "non-player characters or "NPC"s) can be implemented as objects. Create a new object and give it the name you want for the character. You might want to make it "character-like" (e.g. can't be taken, etc). When you create this character object, go to the "Setup" tab for the object and under "Type", change it from "Inanimate object" to whatever you want.



But, how do I make them follow me? Or is there a way?

jaynabonne
14 Jul 2013, 21:38
*That* is a whole 'nother kettle of fish. There is nothing built into Quest to have autonomous behaviors for NPCs. If you want to do that, you would have to code it yourself. (For a basic example, when the NPC is "following" you, there could be a Quest turn script that checks which room the player is in and, if the player has changed rooms, moves the NPC there as well. But you have to do it all yourself.) It's not trivial. Again, I'm sure folks would be happy to help once you get down to specifics.

HegemonKhan
16 Jul 2013, 01:49
obviously, like in rpgs, there's two types of characters:

the character you're actually (CURRENTLY) controlling (your "first person view" character).

"POV" = Point of View

in Quest this is done with:

game.pov

and then there's the "NPCs", which can be "monsters", "townspeoples", and "party~team members (as A.I. controlled or as done in older rpgs like might and magic IV~V)".

Quest now enables you to create~have more than just a single "Game Player Object" (the default is named as: "player"), and be able to switch between them.

just go into the GUI~Editor, and look at how your "player" Game Player Object is set up, and make your own object with the same~similar options set up.

so let's say I create a new Game Player Object called "HK", so I got two Game Player Objects now: "player" and "HK".

game.pov = whoever is your currently controlled Game Object Player.

so, by default, game.pov = player

"game.pov.strength" is the same as: "player.strength"

there's then a script method (see below at the bottom of this post), to change from one Game Player Object to another Game Player Object, such as from "player" to "HK" and back from "HK" to "player", or to a third Game Player Object named "bob", etc etc etc.

however, what you have to be careful about, is that "game.pov.strength" will be applied to whoever is your current Game Player Object. So, if you, for CONCEPT ONLY example, want your stat gains to remain for that character who got the stat gains, then use: "player.strength = player.strength + 5" or "HK.strength = HK.strength + 5", and NOT "game.pov.strength = game.pov.strength + 5".

links on this stuff:

http://quest5.net/wiki/Changing_the_player_object
http://quest5.net/wiki/Pov_alias
http://quest5.net/wiki/Pov_alt
http://quest5.net/wiki/Pov_article
http://quest5.net/wiki/Pov_gender
http://quest5.net/wiki/Pov_look

also, in the GUI~Editor, here are the options for some of this stuff:

Game -> Player (Tab) -> Player Object Box
Game -> Player (Tab) -> Player Object Status Attributes
Game Player Object (such as the default "player") -> Options (Tab) -> Player box

Add a script -> Objects -> Change player object

enjoy ;)

HegemonKhan
16 Jul 2013, 02:06
as for a following code, credit goes to Sgrieg for the original code, but here it is in simpliest form:

add this attribute to all the objects that you want to be able to follow you:

(for example) Object: pet_dog

Name: following
Type: boolean
Value: false

now, you'll need to work with "turnscripts" (if this is your first time, this is just a script, which is always active~running):

click on "Object" (in the left pane, the "tree of stuff"), so that it ("Object") is highlighted, so that our turnscript that we will add, will be "global", and not just for a single room ("local"),

To add the turnscript, you've got to go to the top of the screen's bar (File ~ Edit ~ Add ~ etc ~ etc), and click on "Add", then choose "turnscript".

you want your turn script to look like this (in code anyways):

<turnscript name="global_events">
if (pet_dog.following=true) {
pet_dog.parent = game.pov.parent
}
game.turns = game.turns + 1
</turnscript>


you also need to add this as an attribute to your Game Object:

Name: turns
Type: int
Value: 0

now, as script, just place this where~when you want to "flag" the npc object to now be "following", which is done by:

pet_dog.following = true