From: Laszlo T. <ave...@us...> - 2005-04-11 21:41:24
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13889/Core Modified Files: ActorBlock.cpp ActorBlock.h GameControl.cpp GameScript.cpp GameScript.h Map.cpp Log Message: Fixed some problems with deactivating actors Implemented OnScreen trigger fixed a small dialogue problem Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.170 retrieving revision 1.171 diff -C2 -d -r1.170 -r1.171 *** GameScript.h 9 Apr 2005 19:13:42 -0000 1.170 --- GameScript.h 11 Apr 2005 21:41:13 -0000 1.171 *************** *** 845,848 **** --- 845,849 ---- static int ObjectActionListEmpty(Scriptable* Sender, Trigger* parameters); static int OnCreation(Scriptable* Sender, Trigger* parameters); + static int OnScreen(Scriptable* Sender, Trigger* parameters); static int OpenState(Scriptable* Sender, Trigger* parameters); static int Or(Scriptable* Sender, Trigger* parameters); Index: Map.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.cpp,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** Map.cpp 10 Apr 2005 17:34:33 -0000 1.155 --- Map.cpp 11 Apr 2005 21:41:13 -0000 1.156 *************** *** 417,421 **** for (unsigned int i = 0; i < 8; i++) { if (actor->Scripts[i]) { ! if(actor->GetNextAction()) break; actor->ExecuteScript( actor->Scripts[i] ); } --- 417,421 ---- for (unsigned int i = 0; i < 8; i++) { if (actor->Scripts[i]) { ! if (actor->GetNextAction()) break; actor->ExecuteScript( actor->Scripts[i] ); } *************** *** 539,548 **** // starting with lowest priority (so they are drawn over) GenerateQueues(); ! int q = 3; while (q--) { int index = Qcount[q]; while (true) { Actor* actor = GetRoot( q, index ); ! if(!actor) break; //text feedback --- 539,548 ---- // starting with lowest priority (so they are drawn over) GenerateQueues(); ! int q = 2; //skip inactive actors, don't even sort them while (q--) { int index = Qcount[q]; while (true) { Actor* actor = GetRoot( q, index ); ! if (!actor) break; //text feedback *************** *** 573,584 **** int explored = actor->Modified[IE_DONOTJUMP]&2; if (!IsVisible( actor->Pos, explored)) { if (actor->Modified[IE_ENABLEOFFSCREENAI]) continue; ! if (!actor->GetNextAction()) continue; ! //turning actor inactive, clearing path actor->Active&=~SCR_ACTIVE; actor->SetStance(IE_ANI_READY); - actor->ClearPath(); continue; } --- 573,590 ---- int explored = actor->Modified[IE_DONOTJUMP]&2; if (!IsVisible( actor->Pos, explored)) { + //finding an excuse why we don't hybernate the actor if (actor->Modified[IE_ENABLEOFFSCREENAI]) continue; ! if (actor->CurrentAction) continue; ! if (actor->path) ! continue; ! if (actor->GetNextAction()) ! continue; ! if (actor->GetWait()) //would never stop waiting ! continue; ! //turning actor inactive actor->Active&=~SCR_ACTIVE; actor->SetStance(IE_ANI_READY); continue; } *************** *** 1615,1619 **** void Map::UpdateFog() { ! if(!core->FogOfWar) { SetMapVisibility( -1 ); return; --- 1621,1625 ---- void Map::UpdateFog() { ! if (!core->FogOfWar) { SetMapVisibility( -1 ); return; Index: GameControl.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameControl.cpp,v retrieving revision 1.219 retrieving revision 1.220 diff -C2 -d -r1.219 -r1.220 *** GameControl.cpp 11 Apr 2005 17:40:16 -0000 1.219 --- GameControl.cpp 11 Apr 2005 21:41:11 -0000 1.220 *************** *** 1468,1471 **** --- 1468,1472 ---- } char *string = ( char * ) malloc( 40 ); + idx++; if (ds->transitions[x]->textStrRef == 0xffffffff) { sprintf( string, "[s=%d,ffffff,ff0000]Continue", x ); *************** *** 1474,1478 **** ta->AppendText( "[/s]", i ); } else { - idx++; sprintf( string, "[s=%d,ffffff,ff0000]%d - [p]", x, idx ); i = ta->AppendText( string, -1 ); --- 1475,1478 ---- Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.259 retrieving revision 1.260 diff -C2 -d -r1.259 -r1.260 *** GameScript.cpp 11 Apr 2005 17:37:37 -0000 1.259 --- GameScript.cpp 11 Apr 2005 21:41:11 -0000 1.260 *************** *** 224,227 **** --- 224,228 ---- {"objectactionlistempty", GameScript::ObjectActionListEmpty,0}, //same function {"oncreation", GameScript::OnCreation,0}, + {"onscreen", GameScript::OnScreen,0}, {"openstate", GameScript::OpenState,0}, {"or", GameScript::Or,0}, *************** *** 614,618 **** {"verbalconstanthead", GameScript::VerbalConstantHead,0}, {"wait", GameScript::Wait, AF_BLOCKING}, ! {"waitanimation", GameScript::WaitAnimation,0}, {"waitrandom", GameScript::WaitRandom, AF_BLOCKING}, { NULL,NULL,0}, }; --- 615,619 ---- {"verbalconstanthead", GameScript::VerbalConstantHead,0}, {"wait", GameScript::Wait, AF_BLOCKING}, ! {"waitanimation", GameScript::WaitAnimation,AF_BLOCKING}, {"waitrandom", GameScript::WaitRandom, AF_BLOCKING}, { NULL,NULL,0}, }; *************** *** 821,825 **** MEMCPY( newAction->string0Parameter, parameters->string0Parameter ); MEMCPY( newAction->string1Parameter, parameters->string1Parameter ); ! for(int c=0;c<3;c++) { newAction->objects[c]= ObjectCopy( parameters->objects[c] ); } --- 822,826 ---- MEMCPY( newAction->string0Parameter, parameters->string0Parameter ); MEMCPY( newAction->string1Parameter, parameters->string1Parameter ); ! for (int c=0;c<3;c++) { newAction->objects[c]= ObjectCopy( parameters->objects[c] ); } *************** *** 890,895 **** int hptable = core->LoadTable( "happy" ); TableMgr *tab = core->GetTable( hptable ); ! for(int alignment=0;alignment<3;alignment++) { ! for(int reputation=0;reputation<20;reputation++) { happiness[alignment][reputation]=strtol(tab->QueryField(reputation,alignment), NULL, 0); } --- 891,896 ---- int hptable = core->LoadTable( "happy" ); TableMgr *tab = core->GetTable( hptable ); ! for (int alignment=0;alignment<3;alignment++) { ! for (int reputation=0;reputation<20;reputation++) { happiness[alignment][reputation]=strtol(tab->QueryField(reputation,alignment), NULL, 0); } *************** *** 962,966 **** targettype Target = {actor, distance}; targetlist::iterator m; ! for(m = objects.begin(); m != objects.end(); ++m) { if ( (*m).distance>distance) { objects.insert( m, Target); --- 963,967 ---- targettype Target = {actor, distance}; targetlist::iterator m; ! for (m = objects.begin(); m != objects.end(); ++m) { if ( (*m).distance>distance) { objects.insert( m, Target); *************** *** 1654,1658 **** return 0; } ! if (InDebug&8) { printf( "[GameScript]: Executing trigger code: 0x%04x %s\n", trigger->triggerID, tmpstr ); --- 1655,1659 ---- return 0; } ! if (InDebug&16) { printf( "[GameScript]: Executing trigger code: 0x%04x %s\n", trigger->triggerID, tmpstr ); *************** *** 1749,1752 **** --- 1750,1754 ---- //uninterruptable actions will set it back if (Sender->Type==ST_ACTOR) { + Sender->Active|=SCR_ACTIVE; ((Actor *)Sender)->InternalFlags&=~IF_NOINT; } *************** *** 1791,1795 **** } //else branch, IDS targeting ! for(int j = 0; j < ObjectIDSCount; j++) { if (!oC->objectFields[j]) { continue; --- 1793,1797 ---- } //else branch, IDS targeting ! for (int j = 0; j < ObjectIDSCount; j++) { if (!oC->objectFields[j]) { continue; *************** *** 1966,1970 **** char symbolname[64]; int x; ! for(x=0;isalnum(*symbol) && x<(int) sizeof(symbolname)-1;x++) { symbolname[x]=*symbol; symbol++; --- 1968,1972 ---- char symbolname[64]; int x; ! for (x=0;isalnum(*symbol) && x<(int) sizeof(symbolname)-1;x++) { symbolname[x]=*symbol; symbol++; *************** *** 1976,1980 **** static void ParseIdsTarget(const char *&src, Object *&object) { ! for(int i=0;i<ObjectFieldsCount;i++) { object->objectFields[i]=GetIdsValue(src, ObjectIDSTableNames[i]); if (*src!='.') { --- 1978,1982 ---- static void ParseIdsTarget(const char *&src, Object *&object) { ! for (int i=0;i<ObjectFieldsCount;i++) { object->objectFields[i]=GetIdsValue(src, ObjectIDSTableNames[i]); if (*src!='.') { *************** *** 1994,1998 **** src++; int i; ! for(i=0;i<(int) sizeof(object->objectName)-1 && *src!='"';i++) { object->objectName[i] = *src; --- 1996,2000 ---- src++; int i; ! for (i=0;i<(int) sizeof(object->objectName)-1 && *src!='"';i++) { object->objectName[i] = *src; *************** *** 2170,2174 **** //is to be readed later if (mergestrings) { ! for(i=0;i<6;i++) { *dst++='*'; } --- 2172,2176 ---- //is to be readed later if (mergestrings) { ! for (i=0;i<6;i++) { *dst++='*'; } *************** *** 2328,2332 **** //is to be readed later if (mergestrings) { ! for(i=0;i<6;i++) { *dst++='*'; } --- 2330,2334 ---- //is to be readed later if (mergestrings) { ! for (i=0;i<6;i++) { *dst++='*'; } *************** *** 2386,2390 **** { strlwr( String ); ! if (InDebug&8) { printf("Compiling:%s\n",String); } --- 2388,2392 ---- { strlwr( String ); ! if (InDebug&16) { printf("Compiling:%s\n",String); } *************** *** 3789,3793 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } --- 3791,3795 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } *************** *** 3802,3806 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } --- 3804,3808 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } *************** *** 3815,3819 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } --- 3817,3821 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { cnt+=actor->inventory.CountItems(parameters->string0Parameter,1); } *************** *** 3943,3947 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter,parameters->int0Parameter) ) { return 1; --- 3945,3949 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter,parameters->int0Parameter) ) { return 1; *************** *** 3957,3961 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter, IE_INV_ITEM_IDENTIFIED) ) { return 1; --- 3959,3963 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter, IE_INV_ITEM_IDENTIFIED) ) { return 1; *************** *** 3964,3968 **** return 0; } ! // 0 1 2 3 4 static char spellnames[5][5]={"ITEM", "SPPR", "SPWI", "SPIN", "SPCL"}; --- 3966,3970 ---- return 0; } ! // 0 1 2 3 4 static char spellnames[5][5]={"ITEM", "SPPR", "SPWI", "SPIN", "SPCL"}; *************** *** 4007,4011 **** } //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->spellbook.HaveSpell(poi, 1) ) { return 1; --- 4009,4013 ---- } //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->spellbook.HaveSpell(poi, 1) ) { return 1; *************** *** 5467,5470 **** --- 5469,5484 ---- } + //this checks if the launch point is onscreen, a more elaborate check + //would see if any piece of the Scriptable is onscreen, what is the original + //behaviour? + int GameScript::OnScreen( Scriptable* Sender, Trigger* /*parameters*/) + { + Region vp = core->GetVideoDriver()->GetViewport(); + if (vp.PointInside(Sender->Pos) ) { + return 1; + } + return 0; + } + //------------------------------------------------------------- // Action Functions *************** *** 5966,5970 **** Map *map = Sender->GetCurrentArea(); ab->SetPosition(map, pnt, flags&CC_CHECK_IMPASSABLE, radius ); ! //i think this isn't needed, the creature's stance should be set in //the creature, GetActor sets it correctly //ab->SetStance( IE_ANI_AWAKE ); --- 5980,5984 ---- Map *map = Sender->GetCurrentArea(); ab->SetPosition(map, pnt, flags&CC_CHECK_IMPASSABLE, radius ); ! //i think this isn't needed, the creature's stance should be set in //the creature, GetActor sets it correctly //ab->SetStance( IE_ANI_AWAKE ); *************** *** 6444,6448 **** //there is an assignment here ! for(int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter,parameters->int0Parameter) ) { DisplayStringCore(actor, parameters->int0Parameter, DS_CONSOLE|DS_HEAD ); --- 6458,6462 ---- //there is an assignment here ! for (int i=0; (actor = game->GetPC(i)) ; i++) { if (actor->inventory.HasItem(parameters->string0Parameter,parameters->int0Parameter) ) { DisplayStringCore(actor, parameters->int0Parameter, DS_CONSOLE|DS_HEAD ); *************** *** 6770,6773 **** --- 6784,6794 ---- } } + //making sure speaker is the protagonist, player, actor + bool swap = false; + if (scr->Type != ST_ACTOR) swap = true; + else if (tar->Type == ST_ACTOR) { + if ( ((Actor *) tar)->InParty == 1) swap = true; + else if ( (((Actor *) scr)->InParty !=1) && ((Actor *) tar)->InParty) swap = true; + } GameControl* gc = core->GetGameControl(); *************** *** 6793,6803 **** const char* Dialog = NULL; int pdtable = -1; - //making sure speaker is the protagonist, player, actor - bool swap = false; - if (scr->Type != ST_ACTOR) swap = true; - else if (tar->Type == ST_ACTOR) { - if ( ((Actor *) tar)->InParty == 1) swap = true; - else if ( (((Actor *) scr)->InParty !=1) && ((Actor *) tar)->InParty) swap = true; - } switch (Flags & BD_LOCMASK) { --- 6814,6817 ---- *************** *** 6838,6852 **** //dialog is not meaningful if (!Dialog || Dialog[0]=='*') { ! goto end_of_quest; } //we also need to freeze active scripts during a dialog! ! if (Sender!=tar) { ! if (( Flags & BD_INTERRUPT )) { ! tar->ClearActions(); ! } else { ! if (tar->GetNextAction()) { ! core->DisplayConstantString(STR_TARGETBUSY,0xff0000); ! goto end_of_quest; } } --- 6852,6874 ---- //dialog is not meaningful if (!Dialog || Dialog[0]=='*') { ! goto end_of_quest; } //we also need to freeze active scripts during a dialog! ! if (scr!=tar) { ! if (swap) { ! Scriptable *tmp = tar; ! tar = scr; ! scr = tmp; ! } ! ! if (Sender!=tar) { ! if (Flags & BD_INTERRUPT) { ! tar->ClearActions(); ! } else { ! if (tar->GetNextAction()) { ! core->DisplayConstantString(STR_TARGETBUSY,0xff0000); ! goto end_of_quest; ! } } } *************** *** 6868,6877 **** } ! if ( swap ) { ! gc->InitDialog( (Actor *) tar, scr, Dialog ); ! } ! else { ! gc->InitDialog( (Actor *) scr, tar, Dialog ); ! } } //if pdtable was allocated, free it now, it will release Dialog --- 6890,6894 ---- } ! gc->InitDialog( (Actor *) scr, tar, Dialog ); } //if pdtable was allocated, free it now, it will release Dialog *************** *** 7064,7068 **** } Actor *actor = (Actor *) Sender; ! if (!game->EveryoneNearPoint(actor->Area, actor->Pos, true) ) { //we abort the command, everyone should be here Sender->CurrentAction = NULL; --- 7081,7085 ---- } Actor *actor = (Actor *) Sender; ! if (!game->EveryoneNearPoint(actor->Area, actor->Pos, true) ) { //we abort the command, everyone should be here Sender->CurrentAction = NULL; *************** *** 7337,7340 **** --- 7354,7361 ---- return; } + if (Sender->Type == ST_ACTOR) { + Actor *actor = (Actor *) Sender; + actor->SetStance (IE_ANI_CAST); + } Point s,d; GetPositionFromScriptable( Sender, s, true ); *************** *** 7552,7556 **** Actor* act = ( Actor* ) Sender; act->SetStat( IE_EA, PC ); ! if (core->HasFeature( GF_HAS_DPLAYER )) { act->SetScript( "DPLAYER2", SCR_DEFAULT ); } --- 7573,7577 ---- Actor* act = ( Actor* ) Sender; act->SetStat( IE_EA, PC ); ! if (core->HasFeature( GF_HAS_DPLAYER )) { act->SetScript( "DPLAYER2", SCR_DEFAULT ); } *************** *** 7579,7583 **** act->SetStat( IE_EA, NEUTRAL ); core->GetGame()->LeaveParty( act ); ! if (core->HasFeature( GF_HAS_DPLAYER )) { act->SetScript( "", SCR_DEFAULT ); } --- 7600,7604 ---- act->SetStat( IE_EA, NEUTRAL ); core->GetGame()->LeaveParty( act ); ! if (core->HasFeature( GF_HAS_DPLAYER )) { act->SetScript( "", SCR_DEFAULT ); } *************** *** 7594,7598 **** } ! //no idea why we would need this if we have activate/deactivate void GameScript::HideCreature(Scriptable* Sender, Action* parameters) { --- 7615,7619 ---- } ! //no idea why we would need this if we have activate/deactivate void GameScript::HideCreature(Scriptable* Sender, Action* parameters) { *************** *** 7719,7722 **** --- 7740,7744 ---- actor->SetStance( IE_ANI_DIE ); actor->InternalFlags|=IF_NOINT; + actor->playDeadCounter = parameters->int0Parameter; actor->SetWait( parameters->int0Parameter ); } *************** *** 7733,7736 **** --- 7755,7759 ---- actor->SetStance( IE_ANI_DIE ); //also set time for playdead! + actor->playDeadCounter = parameters->int0Parameter; actor->SetWait( parameters->int0Parameter ); } *************** *** 8970,8974 **** void GameScript::AttackCore(Scriptable *Sender, Scriptable *target, Action *parameters, int flags) { ! //this is a dangerous cast, make sure actor is Actor * !!! Actor *actor = (Actor *) Sender; unsigned int wrange = actor->GetWeaponRange() * 10; --- 8993,8997 ---- void GameScript::AttackCore(Scriptable *Sender, Scriptable *target, Action *parameters, int flags) { ! //this is a dangerous cast, make sure actor is Actor * !!! Actor *actor = (Actor *) Sender; unsigned int wrange = actor->GetWeaponRange() * 10; Index: ActorBlock.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.h,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** ActorBlock.h 10 Apr 2005 18:47:34 -0000 1.67 --- ActorBlock.h 11 Apr 2005 21:41:11 -0000 1.68 *************** *** 153,157 **** void SetScript(ieResRef aScript, int idx); void SetWait(unsigned long time); ! //void SetMySelf(Scriptable* MySelf); char* GetScriptName(); Map* GetCurrentArea(); --- 153,157 ---- void SetScript(ieResRef aScript, int idx); void SetWait(unsigned long time); ! unsigned long GetWait(); char* GetScriptName(); Map* GetCurrentArea(); Index: ActorBlock.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** ActorBlock.cpp 10 Apr 2005 18:49:08 -0000 1.84 --- ActorBlock.cpp 11 Apr 2005 21:41:11 -0000 1.85 *************** *** 168,171 **** --- 168,172 ---- return; } + Active|=SCR_ACTIVE; actionQueue.push_front( aC ); aC->IncRef(); *************** *** 221,226 **** if (WaitCounter) { WaitCounter--; ! if (!WaitCounter) CurrentAction = NULL; return; } --- 222,228 ---- if (WaitCounter) { WaitCounter--; ! if (!WaitCounter) { CurrentAction = NULL; + } return; } *************** *** 253,256 **** --- 255,263 ---- } + unsigned long Scriptable::GetWait() + { + return WaitCounter; + } + /******************** * Selectable Class * |