iriedreadlock23 Posted November 28, 2012 Share Posted November 28, 2012 (edited) 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) 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) // GLOBAL SPEECH SECTIONint 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 // PUT ANYWHERE IN NEW SCRIPTvoid 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 SLOTaddSpeaker(0,GetPlayerPed(),"JACOB"); // speaker 0addSpeaker(1,anyPed,"REAL_BADMAN"); // speaker 1// ADD SPEECH AND SET TIMEaddSpeechLine(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();} Edited December 1, 2012 by iriedreadlock23 Link to comment Share on other sites More sharing options...
PacketOverload_x64bit Posted November 28, 2012 Share Posted November 28, 2012 So awesome! I didnt think this was possible as of six months ago! Link to comment Share on other sites More sharing options...
folypers Posted November 29, 2012 Share Posted November 29, 2012 (edited) Thanks! Edited December 23, 2012 by folypers Link to comment Share on other sites More sharing options...
iriedreadlock23 Posted November 12, 2013 Author Share Posted November 12, 2013 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! Link to comment Share on other sites More sharing options...
123iamking Posted November 14, 2013 Share Posted November 14, 2013 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?!? Link to comment Share on other sites More sharing options...
iriedreadlock23 Posted November 14, 2013 Author Share Posted November 14, 2013 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") Link to comment Share on other sites More sharing options...
123iamking Posted November 19, 2013 Share Posted November 19, 2013 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 ) Link to comment Share on other sites More sharing options...
iriedreadlock23 Posted November 19, 2013 Author Share Posted November 19, 2013 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. Link to comment Share on other sites More sharing options...
123iamking Posted November 20, 2013 Share Posted November 20, 2013 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. Link to comment Share on other sites More sharing options...
iriedreadlock23 Posted November 20, 2013 Author Share Posted November 20, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now