From: Laszlo T. <ave...@us...> - 2005-03-08 19:58:31
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9055/plugins/GUIScript Modified Files: GUIScript.cpp Log Message: Improved GetSlots guiscript command (it takes PartyID as parameter) Added IncreaseReputation Improved IncreaseChapter (clears some PC stats) Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.284 retrieving revision 1.285 diff -C2 -d -r1.284 -r1.285 *** GUIScript.cpp 7 Mar 2005 18:05:40 -0000 1.284 --- GUIScript.cpp 8 Mar 2005 19:58:19 -0000 1.285 *************** *** 59,62 **** --- 59,65 ---- static SpellDescType *StoreSpells = NULL; + static int ReputationIncrease[20]={0xcccccccc}; + static int ReputationDonation[20]={0xcccccccc}; + inline bool valid_number(const char* string, long& val) { *************** *** 2697,2701 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } return PyInt_FromLong( game->GetPartySize(0) ); --- 2700,2704 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } return PyInt_FromLong( game->GetPartySize(0) ); *************** *** 2718,2727 **** static PyObject* GemRB_GameGetReputation(PyObject * /*self*/, PyObject* /*args*/) { ! int Reputation = core->GetGame()->Reputation; return PyInt_FromLong( Reputation ); } PyDoc_STRVAR( GemRB_GameSetReputation__doc, ! "GameSetReputation() => int\n\n" "Sets current party reputation." ); --- 2721,2730 ---- static PyObject* GemRB_GameGetReputation(PyObject * /*self*/, PyObject* /*args*/) { ! int Reputation = (int) core->GetGame()->Reputation; return PyInt_FromLong( Reputation ); } PyDoc_STRVAR( GemRB_GameSetReputation__doc, ! "GameSetReputation(Reputation)\n\n" "Sets current party reputation." ); *************** *** 2733,2737 **** return AttributeError( GemRB_GameSetReputation__doc ); } ! core->GetGame()->Reputation=Reputation; Py_INCREF( Py_None ); --- 2736,2740 ---- return AttributeError( GemRB_GameSetReputation__doc ); } ! core->GetGame()->SetReputation( Reputation ); Py_INCREF( Py_None ); *************** *** 2739,2742 **** --- 2742,2795 ---- } + void ReadReputation() + { + int table = core->LoadTable( "reputati" ); + if (table<0) { + memset(ReputationIncrease,0,sizeof(ReputationIncrease) ); + memset(ReputationDonation,0,sizeof(ReputationDonation) ); + return; + } + TableMgr *tab = core->GetTable( table ); + for (int i = 0; i < 20; i++) { + ReputationIncrease[i] = atoi( tab->QueryField(i,4) ); + ReputationDonation[i] = atoi( tab->QueryField(i,8) ); + } + core->DelTable( table ); + } + + PyDoc_STRVAR( GemRB_IncreaseReputation__doc, + "IncreaseReputation( donation ) => int\n\n" + "Increases party reputation according to the donation. (See reputati.2da)" ); + + static PyObject* GemRB_IncreaseReputation(PyObject * /*self*/, PyObject* args) + { + int Donation; + int Increase = 0; + + if (!PyArg_ParseTuple( args, "i", &Donation )) { + return AttributeError( GemRB_IncreaseReputation__doc ); + } + + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + int Row = (game->Reputation-9)/10; + if (Row>19) { + Row = 19; + } + if (ReputationDonation[0]==(int) 0xcccccccc) { + ReadReputation(); + } + int Limit = ReputationDonation[Row]; + if (Limit<=Donation) { + Increase = ReputationIncrease[Row]; + if (Increase) { + game->SetReputation( game->Reputation + Increase ); + } + } + return PyInt_FromLong ( Increase ); + } + PyDoc_STRVAR( GemRB_GameGetPartyGold__doc, "GameGetPartyGold() => int\n\n" *************** *** 2750,2754 **** PyDoc_STRVAR( GemRB_GameSetPartyGold__doc, ! "GameSetPartyGold() => int\n\n" "Sets current party gold." ); --- 2803,2807 ---- PyDoc_STRVAR( GemRB_GameSetPartyGold__doc, ! "GameSetPartyGold(Gold)\n\n" "Sets current party gold." ); *************** *** 2978,2982 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } Actor* MyActor = game->FindPC( PartyID ); --- 3031,3035 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Actor* MyActor = game->FindPC( PartyID ); *************** *** 3002,3006 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } PlayerSlot = game->FindPlayer( PlayerSlot ); --- 3055,3059 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } PlayerSlot = game->FindPlayer( PlayerSlot ); *************** *** 3047,3051 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } Actor* MyActor = game->FindPC( PartyID ); --- 3100,3104 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Actor* MyActor = game->FindPC( PartyID ); *************** *** 3134,3138 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } --- 3187,3191 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } *************** *** 3167,3171 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } PlayerSlot = game->FindPlayer( PlayerSlot ); --- 3220,3224 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } PlayerSlot = game->FindPlayer( PlayerSlot ); *************** *** 3237,3241 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } PlayerSlot = game->FindPlayer( PlayerSlot ); --- 3290,3294 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } PlayerSlot = game->FindPlayer( PlayerSlot ); *************** *** 3300,3304 **** Game *game = core->GetGame(); if (!game) { ! return NULL; } PlayerSlot = game->FindPlayer( PlayerSlot ); --- 3353,3357 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } PlayerSlot = game->FindPlayer( PlayerSlot ); *************** *** 3581,3588 **** --- 3634,3647 ---- if (type) { STOItem* si = store->GetItem( Slot ); + if (!si) { + return NULL; + } ItemResRef = si->ItemResRef; Flags = si->Flags; } else { CREItem* si = actor->inventory.GetSlotItem( Slot ); + if (!si) { + return NULL; + } ItemResRef = si->ItemResRef; Flags = si->Flags; *************** *** 4111,4131 **** PyDoc_STRVAR( GemRB_GetSlots__doc, ! "GetSlots(SlotType)=>dict\n\n" ! "Returns a tuple of slot items matching the slot type criteria." ); static PyObject* GemRB_GetSlots(PyObject * /*self*/, PyObject* args) { ! int SlotType, Count, MaxCount; ! if (!PyArg_ParseTuple( args, "i", &SlotType)) { return AttributeError( GemRB_GetSlots__doc ); } MaxCount = core->SlotTypes; Count = 0; for (int i=0;i<MaxCount;i++) { ! if ((core->QuerySlotType(i) & SlotType) == SlotType) { ! Count++; } } --- 4170,4201 ---- PyDoc_STRVAR( GemRB_GetSlots__doc, ! "GetSlots(PartyID, SlotType)=>dict\n\n" ! "Returns a tuple of slots of the inventory of a PC matching the slot type criteria." ); static PyObject* GemRB_GetSlots(PyObject * /*self*/, PyObject* args) { ! int SlotType, Count, MaxCount, PartyID; ! if (!PyArg_ParseTuple( args, "ii", &PartyID, &SlotType)) { return AttributeError( GemRB_GetSlots__doc ); } + Game *game = core->GetGame(); + Actor* actor = game->FindPC( PartyID ); + if (! actor) { + return NULL; + } + MaxCount = core->SlotTypes; Count = 0; for (int i=0;i<MaxCount;i++) { ! if ((core->QuerySlotType( i ) & SlotType) != SlotType) { ! continue; } + CREItem *slot = actor->inventory.GetSlotItem( i ); + if (!slot) { + continue; + } + Count++; } *************** *** 4133,4137 **** Count = 0; for (int i=0;i<MaxCount;i++) { ! if ((core->QuerySlotType( i ) & SlotType) == SlotType) { PyTuple_SetItem( tuple, Count++, PyInt_FromLong( i ) ); } --- 4203,4211 ---- Count = 0; for (int i=0;i<MaxCount;i++) { ! if ((core->QuerySlotType( i ) & SlotType) != SlotType) { ! continue; ! } ! CREItem *slot = actor->inventory.GetSlotItem( i ); ! if (!slot) { PyTuple_SetItem( tuple, Count++, PyInt_FromLong( i ) ); } *************** *** 4167,4170 **** --- 4241,4246 ---- PyDict_SetItemString(dict, "StackAmount", PyInt_FromLong (item->StackAmount)); PyDict_SetItemString(dict, "Dialog", PyString_FromResRef (item->Dialog)); + PyDict_SetItemString(dict, "Price", PyInt_FromLong (item->Price)); + int function=0; switch( item->ItemType ) { *************** *** 4324,4328 **** Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "Not in game" ); } Actor* actor = game->FindPC( PartyID ); --- 4400,4404 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Actor* actor = game->FindPC( PartyID ); *************** *** 4363,4367 **** Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "Not in game" ); } Map *map = game->GetCurrentMap(); --- 4439,4443 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Map *map = game->GetCurrentMap(); *************** *** 4399,4403 **** Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "Not in game" ); } Actor* actor = game->FindPC( PartyID ); --- 4475,4479 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Actor* actor = game->FindPC( PartyID ); *************** *** 4428,4432 **** Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "Not in game" ); } Map *map=game->GetCurrentMap(); --- 4504,4508 ---- Game *game = core->GetGame(); if (!game) { ! return RuntimeError( "No game loaded!" ); } Map *map=game->GetCurrentMap(); *************** *** 4480,4483 **** --- 4556,4560 ---- METHOD(GameGetReputation, METH_NOARGS), METHOD(GameSetReputation, METH_VARARGS), + METHOD(IncreaseReputation, METH_VARARGS), METHOD(GameGetPartyGold, METH_NOARGS), METHOD(GameSetPartyGold, METH_VARARGS), |