Quantcast

Jump to content

» «
Photo

[RELEASE] Scripted Speech

9 replies to this topic
iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#1

Posted 28 November 2012 - 02:26 AM Edited by iriedreadlock23, 01 December 2012 - 02:23 AM.

Here's source code for anyone who'd like to script conversations between ingame characters. Use SCOCL to compile. It should work with GTA IV, TBOGT and TLAD. I have tested in TBOGT. Feel free to modify as You wish to suit Your needs. This is not meant to replace original ingame scripted conversations, but instead to use as a alternative tool to learn game programming. It allows You combine unlimited voices in conversation. Make Your own script logic to trigger scripted speech at any time.

Speech lines in this example used:

Voice: JACOB
Source: GTA IV

* LJ1_CA
* LJ1_ZA

common.h (add lines)

CODE

typedef struct _ACTOR
{
Ped handle;
char* name;
char* voice;
} ACTOR, *PACTOR;

typedef struct _SPEECH
{
int startTime;
int actor;
char* line;
} SPEECH, *PSPEECH;


boolean speechWork(int startTime,Ped actorPed,char* Voice,char * Line)
{
uint SpeechTimer;
SpeechTimer=  TIMERA();

if(startTime>-1 && startTime < SpeechTimer )
{
 if(DOES_CHAR_EXIST(actorPed))
 {
  SAY_AMBIENT_SPEECH_WITH_VOICE(actorPed, Line,Voice,1,1,1);
   
  speechCurrent=speechCurrent+1;
  PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", Line, 1500, 1);
  return TRUE;
 }
 else
 {
  PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "Speaker nah exist", 1000, 1);
  return FALSE;
 }  
}
else
{
 return FALSE;
}

}



globals.h (add lines)

CODE

// GLOBAL SPEECH SECTION

int G_SPEECH_CURRENT = 0;
int G_SPEECH_COUNT = 0;
int G_SPEECH_ACTORS = 0;

boolean G_SPEECH_ACTIVE = FALSE;

ACTOR G_ACTORS[5];
SPEECH G_SPEECHES[455];



yourscript.sco

CODE

// PUT ANYWHERE IN NEW SCRIPT

void addSpeaker(int actorIndex,Ped speakerPed,char *speakerVoice,char *speakerName)
{
if(actorIndex<5)
{
 G_ACTORS[actorIndex].handle=speakerPed;
 G_ACTORS[actorIndex].voice=speakerVoice;
 G_ACTORS[actorIndex].name=speakerName;
}
}

void cleanSpeech(int lenght)
{
int f;
while(f<lenght)
{
 G_SPEECHES[f].actor=-1;
 G_SPEECHES[f].line="";
 G_SPEECHES[f].startTime=-1;
 f=f+1;
}
G_SPEECH_CURRENT=0;
G_SPEECH_COUNT=0;
SETTIMERA(0);
}

void addSpeechLine(int actorIndex, char *speakerLine,int sayAtTime)
{

if(G_SPEECH_COUNT<255)
{
 G_SPEECHES[G_SPEECH_COUNT].actor=actorIndex;
 G_SPEECHES[G_SPEECH_COUNT].line=speakerLine;
 G_SPEECHES[G_SPEECH_COUNT].startTime=sayAtTime;
 G_SPEECH_COUNT = G_SPEECH_COUNT+1;
}
}

void replaceSpeechLine(int lineIndex, int ActorID,char *speakerLine,int sayAtTime)
{

if(ActorID<5 && lineIndex<255)
{
 G_SPEECHES[lineIndex].actor=ActorID;
 G_SPEECHES[lineIndex].line=speakerLine;
 G_SPEECHES[lineIndex].startTime=sayAtTime;
}

}

void initGlobals(void)
{
G_SPEECH_ACTORS = 0;
G_SPEECH_COUNT = 0;
G_SPEECH_CURRENT = 0;

G_SPEECH_ACTIVE = FALSE;
}


void startSpeech(void)
{
SETTIMERA(0);
G_SPEECH_ACTIVE = TRUE;
}

void mainLoop(void)
{
while(TRUE)
{
if(G_SPEECH_ACTIVE)
{
 if(G_SPEECH_CURRENT<G_SPEECH_COUNT)
 {
  if(G_SPEECHES[G_SPEECH_CURRENT].actor>-1)
  {
   Ped pdx;
   pdx = G_ACTORS[G_SPEECHES[G_SPEECH_CURRENT].actor].handle;

   if(DOES_CHAR_EXIST(pdx))
   {
    int sInd;
    sInd = G_SPEECH_CURRENT;

     if(speechWork(G_SPEECHES[sInd].startTime,pdx,G_ACTORS[G_SPEECHES[sInd].actor].voice,G_SPEECHES[sInd].line))
     {
         PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING",G_SPEECHES[sInd].line,1000, 1);

     G_SPEECH_CURRENT = G_SPEECH_CURRENT + 1;

    }
    else
    {
     //
    }
   }
   else
   {
    PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING","SPEAKER DONT EXIST. STOPPING.",1000, 1);
    G_SPEECH_ACTIVE=FALSE;
   }
  }
 }
 else
 {
  PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING","SPEECH ENDED",1000, 1);
  G_SPEECH_ACTIVE=FALSE;
 }
}
}
}

void main(void)
{
initGlobals();

Ped anyPed; // assign some Ped


// SET SPEAKER TO SLOT
addSpeaker(0,GetPlayerPed(),"JACOB"); // speaker 0
addSpeaker(1,anyPed,"REAL_BADMAN"); // speaker 1
// ADD SPEECH AND SET TIME
addSpeechLine(0,"GENERIC_HI",5000);
addSpeechLine(1,"GENERIC_f*ck_OFF",7900);
addSpeechLine(0,"LJ1_CA",10000);
addSpeechLine(0,"LJ1_ZA",14000);
addSpeechLine(1,"CAR_SLOW",17000);

startSpeech();
mainLoop();
}

PacketOVerload_x64Bit
  • PacketOVerload_x64Bit

    Window Licker 4 Blondes

  • Members
  • Joined: 13 Mar 2010
  • Canada

#2

Posted 28 November 2012 - 02:52 AM

So awesome! I didnt think this was possible as of six months ago!

folypers
  • folypers

    Player Hater

  • Members
  • Joined: 14 Nov 2012

#3

Posted 29 November 2012 - 08:00 PM Edited by folypers, 23 December 2012 - 02:39 AM.



Thanks! cookie.gif

iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#4

Posted 12 November 2013 - 05:52 PM

Did you know that you can use more than 30000 speeches from 3 GTA IV games? We still don't see many mods utilizing scripted speeches which were used in missions, because it is not quite easy to understand which line to use with in game voices (JACOB etc). This code will help you to decode the "hidden" voices/speeches, and find out who says which of these lines, and then you can use this in your code. Grab <<SPEECH HELPER>> script and start decoding your own GTA IV/TBOGT/TLAD speeches.

 

INCLUDED

 

11500+ speech lines extracted from TBOGT

Play them all out of the box!

Edit script to meet your demands (save to file etc)

>>>> download here

 

FINDING MORE DATA

 

Format of these speeches is like "E2Tm2_TA", where data before the underscore ("_") tells us which script holds the information about voices & GXT entries, so we can make each of these lines into human friendly format later. Open GXT/SCO files and search for any string that looks like scripted speech. Add to your bank file, and let the show begin!


123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#5

Posted 14 November 2013 - 09:14 AM

Did you know that you can use more than 30000 speeches from 3 GTA IV games? We still don't see many mods utilizing scripted speeches which were used in missions, because it is not quite easy to understand which line to use with in game voices (JACOB etc). This code will help you to decode the "hidden" voices/speeches, and find out who says which of these lines, and then you can use this in your code. Grab <<SPEECH HELPER>> script and start decoding your own GTA IV/TBOGT/TLAD speeches.

 

INCLUDED

 

11500+ speech lines extracted from TBOGT

Play them all out of the box!

Edit script to meet your demands (save to file etc)

>>>> download here

 

FINDING MORE DATA

 

Format of these speeches is like "E2Tm2_TA", where data before the underscore ("_") tells us which script holds the information about voices & GXT entries, so we can make each of these lines into human friendly format later. Open GXT/SCO files and search for any string that looks like scripted speech. Add to your bank file, and let the show begin!

I have run your script, I ran TBoGT and press Insert, it started searching, but no speech were spoken, even I have waited till 1000 and the game started to lag. Is there anything wrong?!?


iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#6

Posted 14 November 2013 - 12:40 PM

Try to change BANK_ITEM offset. Default is 0. Try to start from 1000. Note that there are 11,500 lines to check. To find everything you will have to loop through all of them with the voices you have defined. To stop searching, press DELETE on your keyboard.

 

Try some more voices (Less you try at once, less lag you get)

 

 addActorCheck("ARMANDO")

 addActorCheck("HENRIQUE")


123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#7

Posted 19 November 2013 - 08:19 AM

In the mission Hostile Negotiation, in the battle, Niko often shouts "Test me! Test me!", "I'm living here with Roman", ect,...

Is there anyway I can trigger those speeches? Those speeches 're so cool you know :))


iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#8

Posted 19 November 2013 - 12:54 PM

It is possible, but you will have to get the names of those speech lines, which are inside of SCO and GXT, linked with Hostile Negotiation. Note that I couldn't manage to play main character's scripted speech, yet. We'll have to figure that one out.


123iamking
  • 123iamking

    Who am I?

  • Members
  • Joined: 21 Jan 2011

#9

Posted 20 November 2013 - 04:51 AM

In the mission Hostile Negotiation, in the battle, Niko often shouts "Test me! Test me!", "I'm living here with Roman", ect,...

Is there anyway I can trigger those speeches? Those speeches 're so cool you know :))

when u guy figure out how to this, plz post the code.
One more question, Does anyone know how to make random speeches like in SNT? I still don't understand how SNT can detect how many speeches one ped has.


iriedreadlock23
  • iriedreadlock23

    Dr. Frankenstein

  • Members
  • Joined: 14 Jan 2009

#10

Posted 20 November 2013 - 01:29 PM

Simple Native Trainer has a predefined structure to hold all of available voices/speeches in the game. You can ask someone to give you a c header file, or open RPF audio archives with OpenIV, and you can tell what each ped has in its vocabulary. As for Random speech, the game will check if ped has more than 1 variation of the requested speech. Depending on the number of available speech variations, it will play them one by one to the last, and back to 1st. By using certain flag with Native functions related to speech, you can prevent the same speech from being used again.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users