From: Laszlo T. <ave...@us...> - 2004-08-20 15:56:10
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29568 Modified Files: GameScript.cpp GameScript.h Log Message: added TakePartyItem* actions, SetMasterArea Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.187 retrieving revision 1.188 diff -C2 -d -r1.187 -r1.188 *** GameScript.cpp 20 Aug 2004 15:17:34 -0000 1.187 --- GameScript.cpp 20 Aug 2004 15:55:57 -0000 1.188 *************** *** 53,56 **** --- 53,61 ---- static int InDebug = 0; + #define MIC_INVALID -2 + #define MIC_FULL -1 + #define MIC_NOITEM 0 + #define MIC_GOTITEM 1 + //Make this an ordered list, so we could use bsearch! static TriggerLink triggernames[] = { *************** *** 457,460 **** --- 462,466 ---- {"setinternal", GameScript::SetInternal,0}, {"setleavepartydialogfile", GameScript::SetLeavePartyDialogFile,0}, + {"setmasterarea", GameScript::SetMasterArea,0}, {"setmoraleai", GameScript::SetMoraleAI,0}, {"setmusic", GameScript::SetMusic,0}, *************** *** 494,497 **** --- 500,504 ---- {"startdialogueoverrideinterrupt", GameScript::StartDialogueOverrideInterrupt,AF_BLOCKING}, {"startmovie", GameScript::StartMovie,AF_BLOCKING}, + {"startmusic", GameScript::StartMusic,0}, {"startsong", GameScript::StartSong,0}, {"stopmoving", GameScript::StopMoving,0}, *************** *** 503,506 **** --- 510,515 ---- {"takeitemreplace", GameScript::TakeItemReplace,0}, {"takepartygold", GameScript::TakePartyGold,0}, + {"takepartyitem", GameScript::TakePartyItem,0}, + {"takepartyitemall", GameScript::TakePartyItemAll,0}, {"textscreen", GameScript::TextScreen,0}, {"tomsstringdisplayer", GameScript::DisplayStringHead,0}, *************** *** 5647,5650 **** --- 5656,5662 ---- } + /*pst and bg2 can play a song designated by index*/ + /*actually pst has some extra params not currently implemented*/ + /*switchplaylist could implement fade */ void GameScript::StartSong(Scriptable* /*Sender*/, Action* parameters) { *************** *** 5661,5674 **** } ! void GameScript::BattleSong(Scriptable* /*Sender*/, Action* /*parameters*/) { Map *map=core->GetGame()->GetCurrentMap(); ! map->PlayAreaSong(3); //battlesong is in slot 3 } ! void GameScript::Continue(Scriptable* /*Sender*/, Action* /*parameters*/) { } void GameScript::SetMusic(Scriptable* /*Sender*/, Action* parameters) { --- 5673,5691 ---- } ! /*iwd2 can play any areasong slot at will*/ ! void GameScript::StartMusic(Scriptable* /*Sender*/, Action* parameters) { Map *map=core->GetGame()->GetCurrentMap(); ! map->PlayAreaSong(parameters->int0Parameter); } ! /*bg2 can play only the battle song*/ ! void GameScript::BattleSong(Scriptable* /*Sender*/, Action* /*parameters*/) { + Map *map=core->GetGame()->GetCurrentMap(); + map->PlayAreaSong(3); //battlesong is in slot 3 } + /*iwd2 can set an areasong slot*/ void GameScript::SetMusic(Scriptable* /*Sender*/, Action* parameters) { *************** *** 5699,5702 **** --- 5716,5723 ---- } + void GameScript::Continue(Scriptable* /*Sender*/, Action* /*parameters*/) + { + } + void GameScript::CreateVisualEffectCore(int X, int Y, const char *effect) { *************** *** 7285,7289 **** //transfering item from Sender to target, target must be an actor //if target can't get it, it will be dropped at its feet ! void GameScript::MoveItemCore(Scriptable *Sender, Scriptable *target, const char *resref, int flags) { Inventory *myinv; --- 7306,7310 ---- //transfering item from Sender to target, target must be an actor //if target can't get it, it will be dropped at its feet ! int GameScript::MoveItemCore(Scriptable *Sender, Scriptable *target, const char *resref, int flags) { Inventory *myinv; *************** *** 7291,7295 **** if(!target || target->Type!=ST_ACTOR) { ! return; } switch(Sender->Type) { --- 7312,7316 ---- if(!target || target->Type!=ST_ACTOR) { ! return MIC_INVALID; } switch(Sender->Type) { *************** *** 7303,7307 **** break; default: ! return; } Actor *scr = (Actor *) target; --- 7324,7328 ---- break; default: ! return MIC_INVALID; } Actor *scr = (Actor *) target; *************** *** 7309,7313 **** scr->inventory.RemoveItem(resref, flags, &item); if(!item) ! return; myinv->AddSlotItem(item, 0, &item); if( item ) { --- 7330,7334 ---- scr->inventory.RemoveItem(resref, flags, &item); if(!item) ! return MIC_NOITEM; myinv->AddSlotItem(item, 0, &item); if( item ) { *************** *** 7316,7320 **** --- 7337,7343 ---- int y = Sender->YPos; map->tm->AddItemToLocation(x, y, item); + return MIC_FULL; } + return MIC_GOTITEM; } *************** *** 7326,7329 **** --- 7349,7388 ---- } + //getting one single item + void GameScript::TakePartyItem(Scriptable* Sender, Action* parameters) + { + Game *game=core->GetGame(); + int i=game->GetPartySize(false); + while(i--) { + int res=MoveItemCore(game->GetPC(i), Sender, parameters->string0Parameter,0); + if(res!=MIC_NOITEM) return; + } + } + + //getting x single item + void GameScript::TakePartyItemNum(Scriptable* Sender, Action* parameters) + { + int count = parameters->int0Parameter; + Game *game=core->GetGame(); + int i=game->GetPartySize(false); + while(i--) { + int res=MoveItemCore(game->GetPC(i), Sender, parameters->string0Parameter,0); + if(res == MIC_GOTITEM) { + i++; + count--; + } + if(res!=MIC_NOITEM || !count) return; + } + } + + void GameScript::TakePartyItemAll(Scriptable* Sender, Action* parameters) + { + Game *game=core->GetGame(); + int i=game->GetPartySize(false); + while(i--) { + while(MoveItemCore(game->GetPC(i), Sender, parameters->string0Parameter,0)==MIC_GOTITEM); + } + } + //an actor can 'give' an item to a container or another actor void GameScript::GiveItem(Scriptable *Sender, Action* parameters) *************** *** 7628,7629 **** --- 7687,7693 ---- } + void GameScript::SetMasterArea(Scriptable* /*Sender*/, Action* parameters) + { + core->GetGame()->SetMasterArea(parameters->string0Parameter); + } + Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** GameScript.h 20 Aug 2004 13:03:42 -0000 1.133 --- GameScript.h 20 Aug 2004 15:55:57 -0000 1.134 *************** *** 706,710 **** static void CreateCreatureCore(Scriptable* Sender, Action* parameters, int flags); ! static void MoveItemCore(Scriptable *Sender, Scriptable *Target, const char *resref, int flags); static Action *GenerateActionCore(const char *src, const char *str, int acIndex, bool autoFree); static Trigger *GenerateTriggerCore(const char *src, const char *str, int trIndex, int negate); --- 706,710 ---- static void CreateCreatureCore(Scriptable* Sender, Action* parameters, int flags); ! static int MoveItemCore(Scriptable *Sender, Scriptable *Target, const char *resref, int flags); static Action *GenerateActionCore(const char *src, const char *str, int acIndex, bool autoFree); static Trigger *GenerateTriggerCore(const char *src, const char *str, int trIndex, int negate); *************** *** 1122,1125 **** --- 1122,1126 ---- static void SetInternal(Scriptable* Sender, Action* parameters); static void SetLeavePartyDialogFile(Scriptable* Sender, Action* parameters); + static void SetMasterArea(Scriptable* Sender, Action* parameters); static void SetMoraleAI(Scriptable* Sender, Action* parameters); static void SetMusic(Scriptable* Sender, Action* parameters); *************** *** 1151,1154 **** --- 1152,1156 ---- Action* parameters); static void StartMovie(Scriptable* Sender, Action* parameters); + static void StartMusic(Scriptable* Sender, Action* parameters); static void StartSong(Scriptable* Sender, Action* parameters); static void StopMoving(Scriptable* Sender, Action* parameters); *************** *** 1159,1162 **** --- 1161,1167 ---- static void TakeItemReplace(Scriptable* Sender, Action* parameters); static void TakePartyGold(Scriptable* Sender, Action* parameters); + static void TakePartyItem(Scriptable* Sender, Action* parameters); + static void TakePartyItemAll(Scriptable* Sender, Action* parameters); + static void TakePartyItemNum(Scriptable* Sender, Action* parameters); static void TextScreen(Scriptable* Sender, Action* parameters); static void TriggerActivation(Scriptable* Sender, Action* parameters); |