Permalink
Browse files

implemented the DREAM_SCRIPT_FILE pdialog.2da handling

currently used only when resting outside, so we don't have to bother
with the store window reloading
  • Loading branch information...
1 parent 3305f16 commit f8583b7480dfb5f33ab52b80c5008c39df2cd793 @lynxlynxlynx lynxlynxlynx committed Dec 28, 2013
Showing with 48 additions and 2 deletions.
  1. +7 −2 gemrb/GUIScripts/GUICommonWindows.py
  2. +1 −0 gemrb/GUIScripts/GUISTORE.py
  3. +40 −0 gemrb/plugins/GUIScript/GUIScript.cpp
View
9 gemrb/GUIScripts/GUICommonWindows.py
@@ -1851,6 +1851,11 @@ def ToggleAlwaysRun():
GemRB.GameControlToggleAlwaysRun()
def RestPress ():
- if GemRB.RestParty(0, 0, 1):
- GUICommon.CloseOtherWindow(None)
+ GUICommon.CloseOtherWindow(None)
+ GemRB.RunRestScripts ()
+ # ensure the scripts run before the actual rest
+ GemRB.SetTimedEvent (RealRestPress, 2)
+
+def RealRestPress ():
+ GemRB.RestParty(0, 0, 1)
return
View
1 gemrb/GUIScripts/GUISTORE.py
@@ -1567,6 +1567,7 @@ def RentConfirm ():
price = Store['StoreRoomPrices'][RentIndex]
Gold = GemRB.GameGetPartyGold ()
GemRB.GameSetPartyGold (Gold-price)
+ # TODO: run GemRB.RunRestScripts ()
cutscene = GemRB.RestParty (13, 1, RentIndex+1)
if RentConfirmWindow:
RentConfirmWindow.Unload ()
View
40 gemrb/plugins/GUIScript/GUIScript.cpp
@@ -9643,6 +9643,45 @@ static PyObject* GemRB_SetFullScreen(PyObject * /*self*/, PyObject* args)
return Py_None;
}
+PyDoc_STRVAR( GemRB_RunRestScripts__doc,
+ "RunRestScripts()\n\n"
+ "Executes the party pre-rest scripts if any.");
+
+static PyObject* GemRB_RunRestScripts(PyObject * /*self*/, PyObject* /*args*/)
+{
+ GET_GAME();
+
+ // check if anyone wants to banter first (bg2)
+ static int dreamer = -2;
+ if (dreamer == -2) {
+ AutoTable pdtable("pdialog");
+ dreamer = pdtable->GetColumnIndex("DREAM_SCRIPT_FILE");
+ }
+ if (dreamer >= 0) {
+ AutoTable pdtable("pdialog");
+ int ii = game->GetPartySize(true); // party size, only alive
+ bool bg2expansion = core->GetGame()->Expansion == 5;
+ while (ii--) {
+ Actor *tar = game->GetPC(ii, true);
+ const char* scriptname = tar->GetScriptName();
+ if (pdtable->GetRowIndex(scriptname) != -1) {
+ ieResRef resref;
+ if (bg2expansion) {
+ strnlwrcpy(resref, pdtable->QueryField(scriptname, "25DREAM_SCRIPT_FILE"), sizeof(ieResRef)-1);
+ } else {
+ strnlwrcpy(resref, pdtable->QueryField(scriptname, "DREAM_SCRIPT_FILE"), sizeof(ieResRef)-1);
+ }
+ GameScript* restscript = new GameScript(resref, tar, 0, 0);
+ restscript->Update();
+ delete restscript;
+ }
+ }
+ }
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
PyDoc_STRVAR( GemRB_RestParty__doc,
"RestParty(noareacheck, dream, hp)\n\n"
"Executes the party rest function, used from both stores and via the main screen.");
@@ -10718,6 +10757,7 @@ static PyMethodDef GemRBMethods[] = {
METHOD(RestParty, METH_VARARGS),
METHOD(RevealArea, METH_VARARGS),
METHOD(Roll, METH_VARARGS),
+ METHOD(RunRestScripts, METH_NOARGS),
METHOD(SaveCharacter, METH_VARARGS),
METHOD(SaveGame, METH_VARARGS),
METHOD(SaveConfig, METH_NOARGS),

0 comments on commit f8583b7

Please sign in to comment.