From: <ave...@us...> - 2004-02-08 07:55:58
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14156 Modified Files: GameScript.cpp GameScript.h Log Message: Fix: cleaned the dialog actions up a bit, don't initiate a second dialog when one is already active. Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** GameScript.cpp 7 Feb 2004 23:52:47 -0000 1.58 --- GameScript.cpp 8 Feb 2004 07:52:53 -0000 1.59 *************** *** 148,151 **** --- 148,152 ---- {"startcutscenemode",GameScript::StartCutSceneMode}, {"startdialogue",GameScript::StartDialogue,AF_BLOCKING}, + {"startdialogueinterrupt",GameScript::StartDialogueInterrupt,AF_BLOCKING}, {"startdialoguenoset",GameScript::StartDialogueNoSet,AF_BLOCKING}, {"startdialoguenosetinterrupt",GameScript::StartDialogueNoSetInterrupt,AF_BLOCKING}, *************** *** 2003,2011 **** } ! void GameScript::BeginDialog(Actor *actor, Actor *target, const char *Dialog, int Set) { ! if(!actor || !target) return; ! if((Set&BD_INTERRUPT) ) target->ClearActions(); else { --- 2004,2050 ---- } ! void GameScript::BeginDialog(Scriptable *Sender, Action * parameters, int Flags) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! //source could be other than Actor, we need to handle this too! ! if(scr->Type != ST_ACTOR) { ! return; ! } ! //no need to check these for NULL ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! ! GameControl * gc = (GameControl*)core->GetWindow(0)->GetControl(0); ! if(gc->ControlType != IE_GUI_GAMECONTROL) { ! printf("[IEScript]: Dialog cannot be initiated because there is no GameControl.\n"); ! return; ! } ! //can't initiate dialog, because it is already there ! if(gc->Dialogue) { ! printf("[IEScript]: Dialog cannot be initiated because there is already one.\n"); ! return; ! } ! ! const char *Dialog; ! switch(Flags&BD_LOCMASK) ! { ! case BD_STRING0: Dialog=parameters->string0Parameter; break; ! case BD_SOURCE: Dialog=actor->Dialog; break; ! case BD_TARGET: Dialog=target->Dialog; break; ! } ! if(!Dialog) ! return; ! ! //we also need to freeze active scripts during a dialog! ! if((Flags&BD_INTERRUPT) ) target->ClearActions(); else { *************** *** 2018,2035 **** actor->Orientation = GetOrient(target->XPos, target->YPos, actor->XPos, actor->YPos); ! actor->resetAction = true; target->Orientation = GetOrient(actor->XPos, actor->YPos, target->XPos, target->YPos); ! target->resetAction = true; if(Dialog[0]) { //increasing NumTimesTalkedTo ! if(Set) actor->TalkCount++; DialogMgr * dm = (DialogMgr*)core->GetInterface(IE_DLG_CLASS_ID); dm->Open(core->GetResourceMgr()->GetResource(Dialog, IE_DLG_CLASS_ID), true); ! GameControl * gc = (GameControl*)core->GetWindow(0)->GetControl(0); ! if(gc->ControlType == IE_GUI_GAMECONTROL) ! gc->InitDialog(actor, target, dm->GetDialog()); core->FreeInterface(dm); } --- 2057,2072 ---- actor->Orientation = GetOrient(target->XPos, target->YPos, actor->XPos, actor->YPos); ! actor->resetAction = true; //im not sure this is needed target->Orientation = GetOrient(actor->XPos, actor->YPos, target->XPos, target->YPos); ! target->resetAction = true;//nor this if(Dialog[0]) { //increasing NumTimesTalkedTo ! if(Flags&BD_TALKCOUNT) actor->TalkCount++; DialogMgr * dm = (DialogMgr*)core->GetInterface(IE_DLG_CLASS_ID); dm->Open(core->GetResourceMgr()->GetResource(Dialog, IE_DLG_CLASS_ID), true); ! gc->InitDialog(actor, target, dm->GetDialog()); core->FreeInterface(dm); } *************** *** 2039,2079 **** void GameScript::Dialogue(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! Sender->CurrentAction = NULL; ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target,actor->Dialog,BD_TALKCOUNT); } void GameScript::DialogueForceInterrupt(Scriptable *Sender, Action *parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! Sender->CurrentAction = NULL; ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! tar->ClearActions(); ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, actor->Dialog, BD_INTERRUPT); } --- 2076,2085 ---- void GameScript::Dialogue(Scriptable * Sender, Action * parameters) { ! BeginDialog(Sender, parameters, BD_SOURCE|BD_TALKCOUNT); } void GameScript::DialogueForceInterrupt(Scriptable *Sender, Action *parameters) { ! BeginDialog(Sender, parameters, BD_SOURCE|BD_TALKCOUNT|BD_INTERRUPT); } *************** *** 2124,2142 **** void GameScript::StartDialogue(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, parameters->string0Parameter,BD_TALKCOUNT); } --- 2130,2134 ---- void GameScript::StartDialogue(Scriptable * Sender, Action * parameters) { ! BeginDialog(Sender, parameters, BD_STRING0|BD_TALKCOUNT); } *************** *** 2144,2181 **** void GameScript::PlayerDialogue(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, actor->Dialog,0); } void GameScript::StartDialogueInterrupt(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, parameters->string0Parameter,BD_INTERRUPT|BD_TALKCOUNT); } --- 2136,2147 ---- void GameScript::PlayerDialogue(Scriptable * Sender, Action * parameters) { ! //i think playerdialog is when a player initiates dialog with the ! //target, in this case, the dialog is the target's dialog ! BeginDialog(Sender, parameters, BD_TARGET); } void GameScript::StartDialogueInterrupt(Scriptable * Sender, Action * parameters) { ! BeginDialog(Sender, parameters, BD_STRING0|BD_INTERRUPT|BD_TALKCOUNT); } *************** *** 2183,2220 **** void GameScript::StartDialogueNoSet(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, actor->Dialog,0); } void GameScript::StartDialogueNoSetInterrupt(Scriptable * Sender, Action * parameters) { ! Scriptable * scr = GetActorFromObject(Sender, parameters->objects[0]); ! if(!scr) ! return; ! if(scr != Sender) { //this is an Action Override ! scr->AddAction(Sender->CurrentAction); ! return; ! } ! Scriptable * tar = GetActorFromObject(Sender, parameters->objects[1]); ! if(!tar) ! return; ! if(scr->Type != ST_ACTOR) ! return; ! Actor * actor = (Actor*)scr; ! Actor * target = (Actor*)tar; ! BeginDialog(actor, target, actor->Dialog,BD_INTERRUPT); } --- 2149,2158 ---- void GameScript::StartDialogueNoSet(Scriptable * Sender, Action * parameters) { ! BeginDialog(Sender, parameters, BD_SOURCE); } void GameScript::StartDialogueNoSetInterrupt(Scriptable * Sender, Action * parameters) { ! BeginDialog(Sender, parameters, BD_SOURCE|BD_INTERRUPT); } Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** GameScript.h 7 Feb 2004 23:52:47 -0000 1.38 --- GameScript.h 8 Feb 2004 07:52:54 -0000 1.39 *************** *** 496,501 **** }; ! #define BD_INTERRUPT 1 //interrupts action ! #define BD_TALKCOUNT 2 //increases talkcount #define AF_NONE 0 --- 496,506 ---- }; ! #define BD_STRING0 0 ! #define BD_TARGET 1 ! #define BD_SOURCE 2 ! #define BD_RESERVED 3 ! #define BD_LOCMASK 3 //where is the dialog resref ! #define BD_INTERRUPT 4 //interrupts action ! #define BD_TALKCOUNT 8 //increases talkcount #define AF_NONE 0 *************** *** 554,558 **** static Trigger * GenerateTrigger(char * String); static Scriptable * GetActorFromObject(Scriptable * Sender, Object * oC); ! static void BeginDialog(Actor *actor, Actor *target, const char *dialog, int flags); static unsigned char GetOrient(short sX, short sY, short dX, short dY); private: //Internal variables --- 559,563 ---- static Trigger * GenerateTrigger(char * String); static Scriptable * GetActorFromObject(Scriptable * Sender, Object * oC); ! static void BeginDialog(Scriptable *Sender, Action *parameters, int flags); static unsigned char GetOrient(short sX, short sY, short dX, short dY); private: //Internal variables |