Dorcan GK template question

Started by Hobbes, Mon 21/03/2005 16:52:45

Previous topic - Next topic

Hobbes

Hey all,

I've recently begun to use AGS again after having waaaay too little free time. I'm overhauling a lot of the stuff for Buccaneer 2, have been doing so sporadically over the past few weeks.

Now, I am somewhat enamoured by the interface of Gabriel Knight 1. I know Dorcan wrote a script for the dialogs and Dragonrose did some work on a template.

However, I'm looking for an aspect of the game that hasn't yet been realized.

In GK1, when you look at something, make small talk, interact with objects, all your speech and messages are displayed in the bottom of the screen. It works exactly like the LucasArts style dialog (which would be the easiest way to do it). However, it isn't positioned above the character's head but at a fixed location somewhere in the bottom.

I've been toying with AGS a bit, but can't seem to find an easy way to do this... does anyone else know how?

Ashen

DisplayAt/DisplaySpeechAt (x,y,width,message) ( or Character.SayAt (x,y,width,message) in 2.7) sounds like what you want.
I know what you're thinking ... Don't think that.

Hobbes

DisplaySpeechAt is working quite well.

However, there's another problem in that AGS automatically centers the dialog. So now I use it in the following manner:

DisplaySpeechAt (2, 163, 300, EGO, "It's me.");

This works very well, except I like the text to be left-aligned instead of centered. Does anyone know how to overcome that issue?

Ashen

Quote from: The Manual
game.speech_text_align

Sets how text in Lucasarts-style speech is aligned. Same possible values as game.text_align, default ALIGN_CENTRE.
ALIGN_LEFT: text aligned to left within message box (default)
ALIGN_CENTRE: text is centred within the message box
ALIGN_RIGHT: text is right-aligned within the message box
(May be more of a paraphrase, I suppose.)

Anyway, setting it to ALIGN_LEFT in game_start should do the trick. (And maybe game.text_align for text boxes and sierra-style speech.)
I know what you're thinking ... Don't think that.

Hobbes

Fixed!

I now have a standard DisplaySpeechAt thing in Notepad, to copy-and-paste whenever I want to display speech on screen.

However, the placement changes when the dialog is 2 lines long instead of 1. Then I need to readjust the ammount of pixels on the Y-axis. This is quite a tedious scripting process.

Is there perhaps an easier way to do this? If there isn't, then I'll just settle with this. It looks really Gabriel Knightish. :)

strazer

#5
You might want to look into the GetTextHeight function.

Edit:

And it's better to use a custom function instead of pasting the script everywhere.
Does this work?:

Code: ags

// main global script

function DisplayGK1Speech(int charid, string text) {
  int font = 0; // number of speech font (is there a function or variable to get this?)
  int xoffset = 2; // left border
  int yoffset = 0; // bottom border

  int ypos = (system.viewport_height - GetTextHeight(text, font, system.viewport_width - xoffset)) - yoffset;

  DisplaySpeechAt(xoffset, ypos, system.viewport_width - xoffset, charid, text);
}


Code: ags

// main script header

import function DisplayGK1Speech(int charid, string text);


Code: ags

  // script for character 0: Look at EGO

  DisplayGK1Speech(EGO, "It's me.");


But I imagine you'll eventually have problems in dialog scripts since they use the standard speech display.

Hobbes

Thanks for that! It solves the stuff that happens outside of the real dialogs in a handy way. :)


Two other things I'm toying with, though.

1. Also, I started using Dorcan's template for GK1 style dialogs. This makes it unneccessary to have the dialogs displayed at the bottom, so it works quite well.

I was wondering, though, Dorcan's website is offline. Does anyone still have the full manual for the template? I believe I've integrated the global script material quite well and also the room100 which is needed. I can get the dialog screen to work (with full screen portraits) but it's riddled with bugs.

I'm eager to read the full manual on the thing so I can fix this.

2. In Gabriel Knight 1, the speech of the character is displayed like this:

"Hm. That doesn't seem to work." as opposed to the AGS standard:

Hm. That doesn't seem to work.

I'm not English so I don't know the correct name for these " " signs. However, I can't use the DisplaySpeech (or DisplaySpeechAt) command and have my dialog string within the " " brackets (?) use the " " again as well.

E.g. DisplaySpeech(EGO,""Hm. That doesn't seem to work.""); indeed, doesn't work.

Does anyone know a handy way to circumvent this?

strazer

1.) Does the file on this page contain the manual?

2.) Try
  DisplaySpeech(EGO,"\"Hm. That doesn't seem to work.\"");

DoorKnobHandle

2. The only way to do that is to edit your font with SCIStudio and change for example this character % to the " character and then use:

Code: ags

DisplaySpeech ( EGO, Ã, "%Hm, that doesn't seem to work%" );


EDIT: Strazer was faster and better... Anyways...

Hobbes

Quote from: strazer on Thu 24/03/2005 14:48:09
1.) Does the file on this page contain the manual?

2.) Try
Ã,  DisplaySpeech(EGO,"\"Hm. That doesn't seem to work.\"");

Thanks again :)

The site you mentioned has the template (got it from there) but the file doesn't contain the manual. DragonRose's GK template has a very short description, but refers to Dorcan's site as well. :(

The DisplaySpeech works perfectly now. Thanks!

Hobbes

Hey all,

Perhaps someone with knowledge of Dorcan's stuff can help me out anyway. My last question was more of a general-forum question... since this is the technical one, I've decided to post some code. :)

What you see below is the first area of my global script. It's copied-and-pasted from Dorcan's stuff.

Code: ags
//===================CONVERSATION=====================

int QstNbr=2;		//NUMBER OF BASIC QUESTIONS.

int Player;
int PNView;
int TNView;

int PrevRoom;
int Px;int Py;
int Tx;int Ty;

int TalkTo=0;

int Change_Dialog=-1;
int Exit_Dialog=0;

int Replies[200];

function SetReply(int Char, int Reply, int Topic){ 
  Replies[((QstNbr*Char)-QstNbr)+Reply]=Topic;
}



function InitReplies(){		//Set here wich topic must start when asking a basic question.
  SetReply(KEV, 1, 1);
  SetReply(KEV, 2, 2);

}


function StartDialog(int talkto){
  GUIOn(3);
  TalkTo=talkto;
  Player=GetPlayerCharacter();
  PrevRoom=character[Player].room;
  
  Px=character[Player].x;character[Player].x=50;
  Py=character[Player].y;character[Player].y=100;
  PNView=character[Player].view+1;
  ChangeCharacterView(Player,character[Player].talkview+1);
  
  Tx=character[talkto].x;character[talkto].x=250;
  Ty=character[talkto].y;character[talkto].y=170;
  TNView=character[talkto].view+1;
  ChangeCharacterView(talkto,character[talkto].talkview+1);
  
  
  character[talkto].room=100; 
  NewRoom(100);
}

function Exit_Room_Dialog(){
  GUIOff(3);
  character[TalkTo].room=PrevRoom;
  character[Player].room=PrevRoom;
   
  ChangeCharacterView(Player,PNView);
  character[Player].x=Px;
  character[Player].y=Py;
    
  ChangeCharacterView(TalkTo,TNView);
  character[TalkTo].x=Tx;
  character[TalkTo].y=Ty;   
}

#sectionstart dialog_request  // DO NOT EDIT OR REMOVE THIS LINE
function dialog_request (int xvalue) {
    // your code here
  if (xvalue==1) {
    Exit_Dialog=1;
    StopDialog();
  } else
  if (xvalue==100){
    SetDialogOption(0,GetGlobalInt(100),1);
  } else
  if (xvalue<QstNbr+2) {
    Change_Dialog=Replies[ ((QstNbr*TalkTo)-QstNbr)+(xvalue-1)];
    StopDialog();
  } else
  if (xvalue==20) {
    
  }
  
  
}
#sectionend dialog_request  // DO NOT EDIT OR REMOVE THIS LINE


//===================EVENTS============================

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  game.speech_text_align=ALIGN_LEFT;
  SetNormalFont(1);
  SetSpeechFont(1);
  GUIOff(3);
  // called when the game starts, before the first room is loaded
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
  
    if (Change_Dialog>-1) {
    RunDialog(Change_Dialog);
    Change_Dialog=-1;
  } else
  if (Exit_Dialog==1){
    Exit_Dialog=0;
    NewRoom(PrevRoom);  
  }
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


Now, it supposedly works like this:

I have a simple dialog now. With topics 0 to 2 filled. 0 is the opening topic when EGO talks to KEV.

Topic 0 has 3 options: Question 1, Question 2 and End Dialog. The last one has a run-script 1 to it. This triggers the Exit-Dialog stuff. And works perfectly. I've placed some custom change-view stuff in the room where KEV is, so my character doesn't remain one big talking head.

However, when I ask question 1 or question 2, it won't go on. Clicking either question immediately returns me to the topic-0 dialog. It should be this way that after question 1, topic 1 runs. Then if I ask question 2, topic 2 should run.

My dialog code for topic 0 is like this:

Code: ags

// dialog script file
@S  // dialog startup entry point
return
@1  // option 1
EGO: "How're you doing?"
run-script 2
return
@2  // option 2
EGO: "What can you tell me about the Orchid murders?"
run-script 3
return
@3  // option 3
EGO: "Bye."
KEV: "See you."
run-script 1
stop


Topic 1 is like this (same structure as Topic 2):

Code: ags

// dialog script file
@S  // dialog startup entry point
KEV: Sure... I'm doing shit.
goto-dialog 0;
@1  // option 1


---------

Now, I'm somewhat stumped with this. I've compared it with Dorcan's template quite a few times, but can't seem to figure out what I'm doing wrong.

Perhaps someone can? Or perhaps someone has used Dorcan's template as well, with perfect results? In that case, I'd gladly hear about it! :-)

SMF spam blocked by CleanTalk