Two player characters.

Started by Jon, Wed 27/12/2006 10:47:32

Previous topic - Next topic

Jon

Does anyone know how you would be able to have 2 player characters. In my situation a chapter is completed and then after a short cutscene (In a different room to the last) the player character is changed. How is this done?
Later on in the game I shall attempt to be able to switch characters freely (as in a button e.g. 'Knightsquire'). Would this also be possible?

Joe

#1
Hi Jon, yes it's very easy.

You just have to type after the cutscene this
Code: ags
character[X].SetAsPlayer();


And the code for the button would be
Code: ags

if(player.ID==character[X].ID){
character[Y].SetAsPlayer();
}
if(player.ID==character[Y].ID){
caracter[X].SetAsPlayer();
}


Hope you understand, where X and Y are the different characters ID, in this case "Y" would be the first character you control, and "X" would be the second one.
Copinstar © Oficial Site

Jon

Thank you Joe, it seems so easy!

Joe

Copinstar © Oficial Site

gypsysnail

Hi I just had a look at this thread, I feel I may need this feature at some stage and wanted to run a question by some of you who know how to work this feature of switching between two playng characters.... and pardon my newbie question lol.... but here goes, I want to know what a 'cutscene' actually is in a game... as in is it a specific feature that needs to be coded in or a room/background... and where would I put the code
Code: ags
character[X].SetAsPlayer();
in, as in what part of the script editor and which one - global or local? Just saying if I did have to use this code too. This is a good thread :)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Joe

A cutscene is a little scene which is played during the game and can be skipped.
Code: ags

StartCutscene(eSkipAnyKey);//here begins a cutscene which can be skipped pressing any key
//here you put all codes to make your scene like character[].Walk();...
EndCutscene();
//and you may need to type here "character[X].SetAsPlayer();"


Good luck ;)
Copinstar © Oficial Site

gypsysnail

Thanks :) that gives me the idea for the cutscenes that I may need to have in the game. I am going to make a sort of like a video-like scene, probably a room animation with a non-forever loop, should be an interesting experience for me to design it ;). Thanks again
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Khris

Just to point out some things about Joe Carls code:

Say the first character's script name is "JON" and his number is 2.
You *can* use character[JON] or character[2], and of course you can compare the IDs, so the following methods are valid:

if (player.ID==character[JON].ID)

if (player.ID==2)

if (player.ID==character[2].ID)

But the easiest, shortest and most readable way to do it is:

if (player==cJon)

gypsysnail

Ah thanks. The problem I found too just before I went to bed and before mum cut the connection for the night (lol she hates leavin it on at night incase of hackers and I'm stayin with her, cant wait to go home tho lol) was that the script is set under the enter room first time interaction, so as soon as I enter the room, the convo comes up, this wasn't what was supposed to happen. What I would like is to click the talk icon on the character that the player char needs to talk to for that to happen. So we may need to rework this but what is the best option, best way to put the script in?

EDIT: also forgot to mention, this is just to change the view of the character from normal face to angry face, just a reminder so we are on the right track in working it out ;)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ghost

#9
Hi Gypsy, it's not too hard, but viciously hidden in the depths of the manualÃ,  ;D

There are two ways, and which way's best depends on what you're planning.

First, simple: If you want to start the cutscene after the dialog is finished, just include your cutscene code into the talk to character interaction:
dMyTopic.Start();
StartCutscene(mode);
.
.
.
EndCutscene(mode);
This should work well but is pretty inflexible- the cutscene will always start again if the character is talked to in the future.

A better way would be to create a function in the global script like:

function dialog_request (int xvalue) {
Ã,  Ã,  Ã, }

This function can be called from anywhere in any dialogue by passing
run-script X
X being any number you want. So you could simply write

function dialog_request (int xvalue) {
Ã,  if (xvalue == 0) {CUTSCENE CODE) }
Ã,  Ã,  Ã, }

and Bob's your uncle.

If anything is still unclear, check the manual under "Dialogs".

Hope this helps; helpful ghosts are the best  8)


gypsysnail

Thanks :) though for some reason I think I got this thread confused with the other thread I began on changing views in middle of a convo so my apologies. But the info you and others just gave me for the cutscene is what I really needed as well ;) thanks. Could one of the moderators move my post:
QuoteAh thanks. The problem I found too just before I went to bed and before mum cut the connection for the night (lol she hates leavin it on at night incase of hackers and I'm stayin with her, cant wait to go home tho lol) was that the script is set under the enter room first time interaction, so as soon as I enter the room, the convo comes up, this wasn't what was supposed to happen. What I would like is to click the talk icon on the character that the player char needs to talk to for that to happen. So we may need to rework this but what is the best option, best way to put the script in?

EDIT: also forgot to mention, this is just to change the view of the character from normal face to angry face, just a reminder so we are on the right track in working it out

dont be too mad at me  :-[ lol. I was half asleep when I woke to come straight on here. Somehow the titles look a bit similar but we know they arent :P.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Khris

gypsysnail:
Wait, your mom pulls the cable because she's afraid of hackers? Wtf?

QuoteWhat I would like is to click the talk icon on the character that the player char needs to talk to for that to happen.
Select the other character in the editor, click on the Interaction...-button, then double click the Talk to character-Interaction, add a RunScript-action. Click the Edit...-button and enter the code there. And please do the tutorial in the manual, this forum isn't meant to explain such basic things.

Now, is this going to be an actual dialog (player chooses dialog options) or a cutscene with people talking?
In the first case, use dialog_request, in the second case, just use cOtherguy.SpeechView=X; in between the Say-commands.

Ghost:
Dialogs aren't run until the end of the script.
The solution is to use two RunScript-actions, one with the cutscene, the second one containing the dMydialog.Start();

gypsysnail

Yep just taking another look at the manual, as Ghost says, it is buried deep within ;). Yeah its annoyin about my parents bein afraid of hackers, but on the other hand, we hav had hackers using our time if we leave the modem on. Even so, she should have let me wait on a bit longer so I could talk to you about the issues with the game b4 I went to sleep and then woke up and got threads confused.. sorry again for that. Doesnt happen a lot tho :P.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Ghost

#13
Quote from: KhrisMUC on Thu 28/12/2006 02:24:12

Ghost:
Dialogs aren't run until the end of the script.
The solution is to use two RunScript-actions, one with the cutscene, the second one containing the dMydialog.Start();

But if she wants a dialog to start the cutscene, what does it matter when a dialog is run? I'm a bit hazy myself about the actual order (read it once, forgot it too fast)... If you start a cutscene from within a dialog via dialogrequest, then everything between startcut/endcut would be run outside the dialog itself, then returning to the dialog script, wouldn't it? I'm not picky, this is mere technical interest.

Khris

You wrote:
Quote from: Ghost on Thu 28/12/2006 02:08:09If you want to start the cutscene after the dialog is finished, just include your cutscene code into the talk to character interaction:
dMyTopic.Start();
StartCutscene(mode);
So I wanted to point out that that is wrong.
The cutscene won't start after the dialog is finished.

Running a cutscene inside dialog_request would pause the dialog, then return to it, correct.

Ghost


Jon

Hi again, I have attempted the ‘Button' Code in my new GUI, and an error has occurred
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:
In: 'Global script'
Error (line 72): Type mismatch: cannot convert 'Character*' to 'int'
Do you want to fix the script now? (Your game has not been saved).

This is my code, the first player character is ‘Ginnie' and the second ‘Tay'
Code:
if(player.ID==character[Tay].ID)(
character[Ginnie].SetAsPlayer();
)
if(player.ID==character[Ginnie].ID)(
character[Tay].SetAsPlayer();
)

I have put this code in the script (Is this the right place?).

strazer

First, to enclose code for an if-condition, you have to use braces, not brackets:
  if (x = 1) { // note { not (
   somecode();
   somemorecode();
  } // note } not )

Second, if you use the character[] array, the character names have to be capitalised:
  character[TAY].ID
and
  character[GINNIE].ID

But the capitalised character names already represent the character number, so you could just as well do
  if (player.ID == TAY) {

But as KhrisMUC already noted, the best way is this:
  if (player == cTay) {
and
  cTay.SetAsPlayer();

Jon

Hi again, I would like to thank all of you for your help but there is still a problem.
When I type in Khris and Strazers codes, it originally works, but there are problems from then on;
I change players from 'Ginnie' to 'Tay' but I cannot change back
And if I am one of these characters, when I click the coded button, the game changes rooms to the starting room (In my case room 1), and if I do this with 'Tay' then he remains the player character, no matter how many times I press the GUI button.

My apologies if I am not being clear but basically The GUI only works one-way and when the GUI is pressed outside the starting room, the game changes room to the starting room.

Can anyone help me with this?

strazer

If the character you're switching to is not in the current room, the game will change to the room this character is currently in.
If you want the room not to change, move the character to the current room first, then set it as the player character.

The not-being-able-to-change thing is probably just some misplaced braces. Please post the whole code for the button(s).

SMF spam blocked by CleanTalk