Skip to content

Commit

Permalink
bg1: add support for dream sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
fizzet committed Jan 5, 2013
1 parent 730f659 commit 6c6f233
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
17 changes: 14 additions & 3 deletions gemrb/GUIScripts/TextScreen.py
Expand Up @@ -34,21 +34,28 @@ def FindTextRow (Table):
#this is still not the full implementation, but the original engine never used this stuff
Row = Table.GetRowIndex("DEFAULT")
if Table.GetValue (Row, 1)== -1:
Row = Table.GetRowIndex("GOOD_REPUTATION")
if GemRB.GameGetReputation() >= 100:
Row = Table.GetRowIndex("GOOD_REPUTATION")
else:
Row = Table.GetRowIndex("BAD_REPUTATION")
return

def StartTextScreen ():
global TextScreen, TextArea, Chapter, TableName, Row

GemRB.GamePause (1, 3)
GemRB.DisplayString (17556, 0xff0000) #Paused for chapter text

LoadPic = TableName = GemRB.GetGameString (STR_LOADMOS)
if TableName[:6] == "drmtxt":
GemRB.DisplayString (17558, 0xff0000) #Paused for rest
else:
GemRB.DisplayString (17556, 0xff0000) #Paused for chapter text

if GUICommon.GameIsIWD2():
GemRB.LoadWindowPack ("GUICHAP", 800, 600)
else:
GemRB.LoadWindowPack ("GUICHAP", 640, 480)

LoadPic = TableName = GemRB.GetGameString (STR_LOADMOS)
#if there is no preset loadpic, try to determine it from the chapter
#fixme: we always assume there isn't for non-bg2
if GUICommon.GameIsBG2():
Expand All @@ -59,6 +66,8 @@ def StartTextScreen ():
EndTextScreen ()
return
ID = 62
elif TableName[:6] == "drmtxt":
ID = 50 + (GemRB.GetGameVar("DREAM") & 0x7fffffff)
else:
ID = GemRB.GetGameVar("CHAPTER") & 0x7fffffff
Chapter = ID + 1
Expand Down Expand Up @@ -114,6 +123,8 @@ def StartTextScreen ():
Button.SetText (16510)
Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, ReplayTextScreen)

#if this was opened from somewhere other than game control close that window
GUICommon.CloseOtherWindow(None)
GemRB.HideGUI ()
GUICommon.GameWindow.SetVisible(WINDOW_INVISIBLE) #removing the gamecontrol screen
TextScreen.SetVisible (WINDOW_VISIBLE)
Expand Down
39 changes: 37 additions & 2 deletions gemrb/core/Game.cpp
Expand Up @@ -1508,6 +1508,38 @@ void Game::PlayerDream()
delete( gs );
}

//Start a TextScreen dream for the protagonist
void Game::TextDream()
{
ieDword dream, chapter;
locals->Lookup("CHAPTER", chapter);
if (!locals->Lookup("DREAM", dream)) {
dream = 1;
}
snprintf(LoadMos, sizeof(ieResRef)-1, "drmtxt%d", dream+1);
if ((chapter > dream) && (core->Roll(1, 100, 0) <= 33)
&& gamedata->Exists(LoadMos, IE_2DA_CLASS_ID)) {

// give innate spell to protagonist
AutoTable drm(LoadMos);
if (drm) {
const char *repLabel;
if (Reputation >= 100)
repLabel = "GOOD_POWER";
else
repLabel = "BAD_POWER";
int row = drm->GetRowIndex(repLabel);
if (row != -1) {
Actor *actor = GetPC(0, false);
actor->LearnSpell(drm->QueryField(row, 0), LS_MEMO|LS_LEARN);
}
}

locals->SetAt("DREAM", dream+1);
core->SetEventFlag(EF_TEXTSCREEN);
}
}

//noareacheck = no random encounters
//dream = 0 - based on area non-0 - select from list
//-1 no dream
Expand Down Expand Up @@ -1604,11 +1636,14 @@ void Game::RestParty(int checks, int dream, int hp)
return;
}

//movie and cutscene dreams
//movie, cutscene, and still frame dreams
if (dream>=0) {
//cutscene dreams
if (gamedata->Exists("player1d",IE_BCS_CLASS_ID, true))
if (gamedata->Exists("player1d",IE_BCS_CLASS_ID, true)) {
PlayerDream();
} else if (gamedata->Exists("drmtxt2", IE_2DA_CLASS_ID, true)) {
TextDream();
}

//select dream based on area
ieResRef *movie;
Expand Down
1 change: 1 addition & 0 deletions gemrb/core/Game.h
Expand Up @@ -502,6 +502,7 @@ class GEM_EXPORT Game : public Scriptable {
bool DetermineStartPosType(const TableMgr *strta);
ieResRef *GetDream(Map *area);
void PlayerDream();
void TextDream();
};

}
Expand Down

0 comments on commit 6c6f233

Please sign in to comment.