From: <ave...@us...> - 2004-02-08 16:46:54
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19301 Modified Files: ActorBlock.h Game.cpp Game.h GameControl.cpp GameControl.h GameScript.cpp GameScript.h Interface.cpp Interface.h Map.cpp Log Message: Add: Added global script Index: ActorBlock.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ActorBlock.h 7 Feb 2004 23:52:47 -0000 1.19 --- ActorBlock.h 8 Feb 2004 16:43:49 -0000 1.20 *************** *** 62,66 **** ST_DOOR = 4, ST_CONTAINER = 5, ! ST_AREA = 6 } ScriptableType; --- 62,67 ---- ST_DOOR = 4, ST_CONTAINER = 5, ! ST_AREA = 6, ! ST_GLOBAL = 7 } ScriptableType; Index: Game.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Game.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Game.cpp 31 Jan 2004 18:45:19 -0000 1.12 --- Game.cpp 8 Feb 2004 16:43:49 -0000 1.13 *************** *** 28,34 **** extern Interface * core; ! Game::Game(void) { PartySize=6; //this could be modified later } --- 28,35 ---- extern Interface * core; ! Game::Game(void) : Scriptable(ST_GLOBAL) { PartySize=6; //this could be modified later + SetScript(core->GlobalScript); } *************** *** 44,47 **** --- 45,50 ---- delete(NPCs[i]); } + if(GlobalScript) + delete GlobalScript; } *************** *** 182,183 **** --- 185,201 ---- return NPCs[Index]; } + + //sets the global script (baldur.bcs, etc) + //it is used only in bg2 (baldur) or tob (baldur25), but exists everywhere + //except torment + void Game::SetScript(const char *aScript) + { + if(GlobalScript) delete GlobalScript; + GlobalScript=0; + if(aScript[0]) { + GlobalScript = new GameScript(aScript, 0, 0); //no locals!!! + //don't crash if the script is nonexistent (only in torment) + if(GlobalScript) GlobalScript->MySelf = this; + } + } + Index: Game.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Game.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Game.h 31 Jan 2004 18:45:19 -0000 1.9 --- Game.h 8 Feb 2004 16:43:49 -0000 1.10 *************** *** 41,45 **** #include "Map.h" ! class GEM_EXPORT Game { public: --- 41,45 ---- #include "Map.h" ! class GEM_EXPORT Game : public Scriptable { public: *************** *** 51,54 **** --- 51,55 ---- std::vector<Map*> Maps; public: + GameScript *GlobalScript; int PartySize; public: *************** *** 71,74 **** --- 72,77 ---- int AddNPC(Actor *npc); Actor* GetNPC(unsigned int Index); + //sets the global script (baldur.bcs) + void SetScript(const char *aScript); }; Index: GameControl.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameControl.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** GameControl.cpp 8 Feb 2004 08:34:43 -0000 1.86 --- GameControl.cpp 8 Feb 2004 16:43:49 -0000 1.87 *************** *** 1045,1048 **** --- 1045,1049 ---- int i; ta->SetMinRow(true); + int idx=0; for(int x = 0; x < ds->transitionsCount; x++) { if(ds->transitions[x]->Flags & IE_DLG_TR_TRIGGER) { *************** *** 1063,1067 **** char * s = core->GetString(ds->transitions[x]->textStrRef); string = (char*)malloc(30); ! sprintf(string, "[s=%d,ffffff,ff0000]%d - [p]", x, x+1); i = ta->AppendText(string, -1); ta->AppendText(s, i); --- 1064,1069 ---- char * s = core->GetString(ds->transitions[x]->textStrRef); string = (char*)malloc(30); ! idx++; ! sprintf(string, "[s=%d,ffffff,ff0000]%d - [p]", x, idx); i = ta->AppendText(string, -1); ta->AppendText(s, i); Index: GameControl.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameControl.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** GameControl.h 7 Jan 2004 20:36:43 -0000 1.26 --- GameControl.h 8 Feb 2004 16:43:49 -0000 1.27 *************** *** 86,94 **** public: char Destination[33], EntranceName[33]; void SetCutSceneMode(bool active); void HideGUI(); void UnhideGUI(); void InitDialog(Actor * speaker, Actor * target, Dialog * dlg); - bool Dialogue; void DialogChoose(int choose); void DisplayString(Scriptable * target); --- 86,95 ---- public: char Destination[33], EntranceName[33]; + bool Dialogue; + public: void SetCutSceneMode(bool active); void HideGUI(); void UnhideGUI(); void InitDialog(Actor * speaker, Actor * target, Dialog * dlg); void DialogChoose(int choose); void DisplayString(Scriptable * target); Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** GameScript.cpp 8 Feb 2004 07:52:53 -0000 1.59 --- GameScript.cpp 8 Feb 2004 16:43:49 -0000 1.60 *************** *** 46,49 **** --- 46,52 ---- {"allegiance", GameScript::Allegiance}, {"bitcheck",GameScript::BitCheck}, + {"checkstat",GameScript::CheckStat}, + {"checkstatgt",GameScript::CheckStatGT}, + {"checkstatlt",GameScript::CheckStatLT}, {"class", GameScript::Class}, {"clicked", GameScript::Clicked}, *************** *** 58,61 **** --- 61,65 ---- {"globalsequal", GameScript::GlobalsEqual}, {"inparty", GameScript::InParty}, + {"isvalidforpartydialog", GameScript::IsValidForPartyDialog}, {"numtimestalkedto", GameScript::NumTimesTalkedTo}, {"numtimestalkedtogt", GameScript::NumTimesTalkedToGT}, *************** *** 571,575 **** if(!func) { triggers[trigger->triggerID]=False; ! printf("[IEScript]: Unhandled trigger code: %x\n",trigger->triggerID); return false; } --- 575,579 ---- if(!func) { triggers[trigger->triggerID]=False; ! printf("[IEScript]: Unhandled trigger code: 0x%04x\n",trigger->triggerID); return false; } *************** *** 1170,1173 **** --- 1174,1203 ---- } + //atm this checks for InParty and See, it is unsure what is required + int GameScript::IsValidForPartyDialog(Scriptable *Sender, Trigger *parameters) + { + Scriptable * actor = GetActorFromObject(Sender, parameters->objectParameter); + if(actor==NULL) + return 0; + //non actors got no visual range, needs research + if(Sender->Type!=ST_ACTOR) + return 0; + Actor * snd = (Actor*)Sender; + if(actor->Type!=ST_ACTOR) + return 0; + //return actor->InParty?1:0; //maybe ??? + if(!core->GetGame()->InParty((Actor *) actor) ) + return 0; + long x = (actor->XPos - Sender->XPos); + long y = (actor->YPos - Sender->YPos); + double distance = sqrt((double)(x*x+y*y)); + if(distance > (snd->Modified[IE_VISUALRANGE]*20)) + return 0; + if(!core->GetPathFinder()->IsVisible(Sender->XPos, Sender->YPos, actor->XPos, actor->YPos)) + return 0; + //further checks, is target alive and talkative + return 1; + } + int GameScript::InParty(Scriptable * Sender, Trigger * parameters) { *************** *** 1418,1421 **** --- 1448,1498 ---- int GameScript::Dead(Scriptable * Sender, Trigger * parameters) { + Scriptable * target = GetActorFromObject(Sender, parameters->objectParameter); + if(!target) + return 0; + if(target->Type!=ST_ACTOR) + return 0; + Actor *actor=(Actor *) target; + if(actor->GetStat(IE_STATE_ID)&STATE_DEAD) + return 1; + return 0; + } + + int GameScript::CheckStat(Scriptable * Sender, Trigger * parameters) + { + Scriptable * target = GetActorFromObject(Sender, parameters->objectParameter); + if(!target) + return 0; + if(target->Type!=ST_ACTOR) + return 0; + Actor *actor=(Actor *) target; + if(actor->GetStat(parameters->int0Parameter)==parameters->int1Parameter) + return 1; + return 0; + } + + int GameScript::CheckStatGT(Scriptable * Sender, Trigger * parameters) + { + Scriptable * target = GetActorFromObject(Sender, parameters->objectParameter); + if(!target) + return 0; + if(target->Type!=ST_ACTOR) + return 0; + Actor *actor=(Actor *) target; + if(actor->GetStat(parameters->int0Parameter)>parameters->int1Parameter) + return 1; + return 0; + } + + int GameScript::CheckStatLT(Scriptable * Sender, Trigger * parameters) + { + Scriptable * target = GetActorFromObject(Sender, parameters->objectParameter); + if(!target) + return 0; + if(target->Type!=ST_ACTOR) + return 0; + Actor *actor=(Actor *) target; + if(actor->GetStat(parameters->int0Parameter)<parameters->int1Parameter) + return 1; return 0; } *************** *** 1675,1678 **** --- 1752,1757 ---- return; Actor * actor = (Actor*)scr; + //changeaiscript clears the queue, i believe + actor->ClearActions(); actor->SetScript(parameters->string0Parameter, parameters->int0Parameter); } *************** *** 2011,2014 **** --- 2090,2094 ---- if(scr != Sender) { //this is an Action Override scr->AddAction(Sender->CurrentAction); + Sender->CurrentAction = NULL; return; } *************** *** 2018,2021 **** --- 2098,2102 ---- //source could be other than Actor, we need to handle this too! if(scr->Type != ST_ACTOR) { + Sender->CurrentAction = NULL; return; } *************** *** 2027,2030 **** --- 2108,2112 ---- if(gc->ControlType != IE_GUI_GAMECONTROL) { printf("[IEScript]: Dialog cannot be initiated because there is no GameControl.\n"); + Sender->CurrentAction = NULL; return; } *************** *** 2032,2035 **** --- 2114,2118 ---- if(gc->Dialogue) { printf("[IEScript]: Dialog cannot be initiated because there is already one.\n"); + Sender->CurrentAction = NULL; return; } *************** *** 2042,2047 **** case BD_TARGET: Dialog=target->Dialog; break; } ! if(!Dialog) return; //we also need to freeze active scripts during a dialog! --- 2125,2132 ---- case BD_TARGET: Dialog=target->Dialog; break; } ! if(!Dialog) { ! Sender->CurrentAction = NULL; return; + } //we also need to freeze active scripts during a dialog! *************** *** 2051,2055 **** if(target->GetNextAction()) { ! printf("Target appears busy!\n"); return; } --- 2136,2141 ---- if(target->GetNextAction()) { ! printf("[IEScript]: Target appears busy!\n"); ! Sender->CurrentAction = NULL; return; } Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** GameScript.h 8 Feb 2004 07:52:54 -0000 1.39 --- GameScript.h 8 Feb 2004 16:43:49 -0000 1.40 *************** *** 594,597 **** --- 594,598 ---- static int Exists(Scriptable * Sender, Trigger * parameters); static int InParty(Scriptable * Sender, Trigger * parameters); + static int IsValidForPartyDialog(Scriptable * Sender, Trigger * parameters); static int General(Scriptable * Sender, Trigger * parameters); static int Range(Scriptable * Sender, Trigger * parameters); *************** *** 602,605 **** --- 603,609 ---- static int See(Scriptable * Sender, Trigger * parameters); static int BitCheck(Scriptable * Sender, Trigger * parameters); + static int CheckStat(Scriptable * Sender, Trigger * parameters); + static int CheckStatGT(Scriptable * Sender, Trigger * parameters); + static int CheckStatLT(Scriptable * Sender, Trigger * parameters); public: //Actions Index: Interface.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.cpp,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** Interface.cpp 2 Feb 2004 01:14:43 -0000 1.118 --- Interface.cpp 8 Feb 2004 16:43:49 -0000 1.119 *************** *** 79,82 **** --- 79,84 ---- memcpy(ButtonFont,"STONESML",9); memcpy(CursorBam,"CAROT\0\0\0",9); + memcpy(GlobalScript,"BALDUR\0\0",9); + memcpy(GlobalMap,"WORLDMAP",9); GameFeatures=0; printMessage("Core", "Loading Configuration File...", WHITE); *************** *** 1587,1591 **** delete(game); game = sgm->GetGame(); - printf("game loaded and set\n"); FreeInterface(sgm); } --- 1589,1592 ---- Index: Interface.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** Interface.h 7 Feb 2004 23:52:47 -0000 1.70 --- Interface.h 8 Feb 2004 16:43:50 -0000 1.71 *************** *** 121,124 **** --- 121,126 ---- char CursorBam[9]; public: + char GlobalScript[9]; + char GlobalMap[9]; Animation **Cursors; int CursorCount; Index: Map.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.cpp,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** Map.cpp 30 Jan 2004 22:35:10 -0000 1.71 --- Map.cpp 8 Feb 2004 16:43:50 -0000 1.72 *************** *** 116,119 **** --- 116,121 ---- if(tm) tm->DrawOverlay(0, viewport); + //Run the Global Script + ExecuteScript(core->GetGame()->GlobalScript); //Run the Map Script if(Scripts[0]) |