From: Laszlo T. <ave...@us...> - 2006-08-28 17:11:46
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv23412/plugins/GUIScript Modified Files: GUIScript.cpp Log Message: implemented ApplyEffect guiscript command (for bg2 proficiencies) fixed bg2 chargen to use the correct proficiency settings fixed doors in iwd/how started implementing core feat functions Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.415 retrieving revision 1.416 diff -C2 -d -r1.415 -r1.416 *** GUIScript.cpp 22 Aug 2006 22:15:56 -0000 1.415 --- GUIScript.cpp 28 Aug 2006 17:11:42 -0000 1.416 *************** *** 44,47 **** --- 44,48 ---- #include "../Core/DataFileMgr.h" #include "../Core/WorldMap.h" + #include "../Core/EffectQueue.h" //this stuff is missing from Python 2.2 *************** *** 7115,7138 **** return RuntimeError( "Actor not found" ); } - int Slot = -1; int i = SpecialItemsCount; while(i--) { ! if (SpecialItems[i].value!=(ieDword) itemtype) { ! continue; ! } ! Slot = actor->inventory.FindItem(SpecialItems[i].resref,0); ! if (Slot!=-1) { break; } } ! if (Slot==-1) { return PyInt_FromLong( 0 ); } if (useup) { ! useup = actor->UseItem(Slot, actor); ! } else { ! useup = 1; } return PyInt_FromLong( useup ); --- 7116,7132 ---- return RuntimeError( "Actor not found" ); } int i = SpecialItemsCount; while(i--) { ! if (actor->inventory.HasItem(SpecialItems[i].resref,0)) { break; } } ! if (i<0) { return PyInt_FromLong( 0 ); } if (useup) { ! //useup = actor->UseItem(SpecialItems[i].resref, actor); } return PyInt_FromLong( useup ); *************** *** 7179,7182 **** --- 7173,7218 ---- } + PyDoc_STRVAR( GemRB_ApplyEffect__doc, + "ApplyEffect(pc, effect, param1, param2)\n\n" + "Creates a basic effect and applies it on the player character." + "This function could be used to add stats that are stored in effect blocks.\n\n"); + + static EffectRef work_ref; + + static PyObject* GemRB_ApplyEffect(PyObject * /*self*/, PyObject* args) + { + int PartyID; + char *opcodename; + int param1, param2; + + if (!PyArg_ParseTuple( args, "isii", &PartyID, &opcodename, ¶m1, ¶m2)) { + return AttributeError( GemRB_ApplyEffect__doc ); + } + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + Actor* actor = game->FindPC( PartyID ); + if (!actor) { + return RuntimeError( "Actor not found" ); + } + work_ref.Name=opcodename; + work_ref.EffText=-1; + EffectQueue::ResolveEffect(work_ref); + Effect *fx = core->GetEffect(work_ref.EffText); + if (!fx) { + //invalid effect name didn't resolve to opcode + return RuntimeError( "Invalid effect name!" ); + } + fx->Parameter1=param1; + fx->Parameter2=param2; + fx->Probability1=100; + fx->TimingMode=FX_DURATION_INSTANT_PERMANENT_AFTER_BONUSES; + //fx is freed by this function + core->ApplyEffect(fx, actor, actor); + Py_INCREF( Py_None ); + return Py_None; + } + static PyMethodDef GemRBMethods[] = { METHOD(SetInfoTextColor, METH_VARARGS), *************** *** 7388,7391 **** --- 7424,7428 ---- METHOD(HasSpecialItem, METH_VARARGS), METHOD(HasSpecialSpell, METH_VARARGS), + METHOD(ApplyEffect, METH_VARARGS), // terminating entry {NULL, NULL, 0, NULL} |