Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Alynn on Mon 17/07/2006 21:07:48

Title: MODULE: Character Fonts v1.1 - Different speech font for each character
Post by: Alynn on Mon 17/07/2006 21:07:48
// Script header for module 'CharacterFonts'
/*
**Ã,  Author: James Favier (Alynn the Yellow Eyed)
**Ã,  Ã, 
**Ã,  Abstract: Allows a user to set individual fonts to each
**Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  character, and display those fonts while
**Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  talking.
**
**Ã,  AGS 2.71 and higher
**
**
** WARNING:
**Ã,  Ã,  Be sure you assign font numbers that actually exist on
**Ã,  Ã,  your game, it will break otherwise. Currently there is
**Ã,  Ã,  no way to check if the font exists beforehand. If that
**Ã,  Ã,  becomes available later I will incorperate it.
**
**---------------------------------------------------------------
** Functions:
**
**Ã,  Ã, SetCharFont(Character *ch, int font)
**Ã,  Ã,  Ã,  This sets the number of the character (ch) and
**Ã,  Ã,  Ã,  assigns it the font number (font).
**
**Ã,  Ã, GetCharFont(Character *ch)
**Ã,  Ã,  Ã,  Returns the font number currently in use by
**Ã,  Ã,  Ã,  the character (ch).
**
**Ã,  Ã, Say(Character *ch, String text)
**Ã,  Ã,  Ã,  Works like Character.Say, but assigns the correct
**Ã,  Ã,  Ã,  font first.
**
**Ã,  Ã, SayAt(Character *ch, int x, int y, int width, String text)
**Ã,  Ã,  Ã,  Works like Character.SayAt, but assigns the correct
**Ã,  Ã,  Ã,  font first.
**
**Ã,  Ã, SayBackground(Character *ch, String text)
**Ã,  Ã,  Ã,  Works like Character.SayBackground, but assigns the
**Ã,  Ã,  Ã,  correct font first.
**
**------------------------------------------------------------------
**
** Version History:
**Ã,  Ã,  1.0 Released upon an unsuspecting population
**Ã,  Ã,  1.1 Should work with AGS 2.71, maxed out the number of
**Ã,  Ã,  Ã,  Ã,  possible characters, now uses pointers for the characters.
**
**------------------------------------------------------------------


Ok looking over what Strazer said I took most of his ideas into consideration... Ok let's just face it I made all the changes.

Changes from version 1.0 to 1.1 are as follows...

The functionality of dialogs still must be done like below if using 2.72.
function dialog_request (int xvalue) {
Ã,  if (xvalue == 1){
Ã,  Ã,  Game.SpeechFont = CharFont.GetCharFont(cShip);
Ã,  }
Ã,  if (xvalue == 2){
Ã,  Ã,  Game.SpeechFont = CharFont.GetCharFont(cTest);
Ã,  }
}


Or this code using 2.71
function dialog_request (int xvalue) {
Ã,  if (xvalue == 1){
Ã,  Ã,  SetSpeechFont(CharFont.GetCharFont(cShip));
Ã,  }
Ã,  if (xvalue == 2){
Ã,  Ã,  SetSpeechFont(CharFont.GetCharFont(cTest));
Ã,  }
}


Replacing cShip and cTest with your Characters it will work as expected.
NOTE: you will have to have a dialog_request for each character you use.

Finally your dialog should look something like this:
run-script 1
ship: hi!
run-script 2
test: Hello!


I'm sorry I couldn't do it within the modual itself, this makes things a bit more difficult for running dialogs. But nothing too unmanagable.

Verified that Character Fonts 1.1 is compatable with AGS 2.71 .

DOWNLOAD HERE (http://www.yelloweyedstudio.com/projects/AGS/modules/CharFont.scm) 2.71 and Higher
Title: Re: MODULE: Character Fonts (Works with Dialogs, kinda)
Post by: strazer on Tue 18/07/2006 10:37:03
Good work!

For reference, the tracker entry for this idea is here (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=242).
Title: Re: MODULE: Character Fonts 1.0 (Works with Dialogs, kinda)
Post by: jasonjkay on Tue 18/07/2006 12:49:08
im not sure what this module is for but i'll add it to my site anyway.
Title: Re: MODULE: Character Fonts 1.0 (Works with Dialogs, kinda)
Post by: Alynn on Tue 18/07/2006 13:03:14
Jason, I know my first post was jumbled (it will be edited after the changes tonight) but it was late at night when I posted it and my thoughts aren't always coherant when I'm awake, so half asleep they are probably worse.

Anyway, the current AGS setup there is one speech font that is used by all characters, what this allows you to do is let each character have their own font. For instance, an easy flowing font for a hipple, and a military style font for a drill sergeant. Using this module they can have a conversation each using their own personallized font.

I hope that is a bit better wording... As I said the origional post will be edited once I implement some of the changes that strazer suggested, and put it online with the module coding conventions.
Title: Re: MODULE: Character Fonts v1.1 - Different speech font for each character
Post by: Alynn on Tue 18/07/2006 17:37:51
Ok... 1.1 is up... I've verified that it works with 2.71. And I also realized I forgot to put the download link on the first post... Origional post fixed and the finalized copy of the scm is on my website for download.

Maybe I should have bumped this, but I was wondering if anyone has tried it out?