home *** CD-ROM | disk | FTP | other *** search
- property lsStateData, currentGameFile, ancestor
-
- on birth me
- set lsStateData to [:]
- set ancestor to birth(script "cStoryteller.2")
- set currentGameFile to #None
- return me
- end
-
- on newGame me
- global domainIsReady, gCPU
- installMenu(0)
- updateStage()
- if objectp(oBackdrop) then
- oBackdrop(mPatToWindow, -5)
- end if
- set domainIsReady to 0
- suspendSounds(#fadeOut)
- gammaFade(#down)
- repeat with whichSprite = 1 to 48
- set the loc of sprite whichSprite to point(-1000, -1000)
- puppetSprite(whichSprite, 0)
- end repeat
- updateStage()
- if the colorDepth <> 16 then
- setColor(16)
- end if
- gammaFade(#clearStage)
- set lsStateData to [:]
- set currentGameFile to #None
- enterNewDomain(me, "ROXY")
- end
-
- on loadSavedGame me, jumpSwitch
- global builderwindow, oUtility, oStoryteller, gSavePath, gAmberPath, domainIsReady, oGrabber, gSoundPath, oPuppeteer, gCDswapStash, gSoundPath2, gCPU, thisCursor, lastCursor, gDeferredTransit, gHorsepower
- if jumpSwitch <> #jumping then
- installMenu(0)
- updateStage()
- if objectp(oBackdrop) then
- oBackdrop(mPatToWindow, -5)
- end if
- REPORT2("ΓÇó> Starting timer for loadSavedGame( oStoryteller )...")
- startTimer()
- oUtility(mSetDefaultPath, gSavePath)
- if gCPU = #PC then
- set loadTest to new(xtra("FileIO"))
- if not objectp(loadTest) then
- alert("Sorry, there's some problem creating a fileio object.")
- quit()
- end if
- setFilterMask(loadTest, "Amber: Journeys Beyond saved games,*.sav")
- set strCurrentFile to displayOpen(loadTest)
- else
- set hCurrentFile to FileIO(mnew, "?append", "HFE ")
- end if
- if voidp(strCurrentFile) then
- end if
- if objectp(oPuppeteer) then
- refreshVidSprites(oPuppeteer)
- end if
- if the movie contains "AMBERHUB" then
- put "<!> Sorry, can't cursorDance in AMBERHUB"
- else
- set thisCursor to #pointer
- set lastCursor to #bogus
- cursorDance()
- end if
- if voidp(strCurrentFile) then
- set gDeferredTransit to #None
- set loadTest to 0
- if the movie contains "AMBERHUB" then
- installMenu(the number of member "Amber menus")
- end if
- if the number of menus > 1 then
- set the checkMark of menuItem (8 - the soundLevel) of menu 2 to 1
- end if
- return #cancelled
- else
- end if
- set domainIsReady to 0
- suspendSounds(#fadeOut)
- openFile(loadTest, strCurrentFile, 1)
- setPosition(loadTest, 0)
- set currentGameFile to strCurrentFile
- set lsStateData to value(readFile(loadTest))
- if not listp(lsStateData) then
- alert("Sorry, there's some problem with this file.")
- quit()
- end if
- setState(me, #horsePower, gHorsepower)
- set gDeferredTransit to "nothing --waiting for " & getState(oStoryteller, #currentDomain)
- set loadTest to 0
- unLoadCast()
- gammaFade(#down)
- repeat with whichSprite = 1 to 48
- set the loc of sprite whichSprite to point(-1000, -1000)
- puppetSprite(whichSprite, 0)
- end repeat
- updateStage()
- gammaFade(#clearStage)
- set destination to getState(oStoryteller, #currentDomain)
- set gCDswapStash to [#destination: destination, #loadFrame: #None, #callingHandler: #loadSavedGame]
- ensureProperCD(me, destination)
- else
- set destination to getState(oStoryteller, #currentDomain)
- end if
- if gCPU = #PC then
- set pathDelim to "\"
- end if
- if gCPU = #Mac then
- set pathDelim to ":"
- end if
- set the searchPath to [gAmberPath & destination & pathDelim, gSoundPath]
- put "new searchPath (before entering domain-movie) ="
- put the searchPath
- go(1, destination)
- if destination = "roxy" then
- set movieFolder to "movies" & pathDelim
- end if
- if destination = "margaret" then
- set movieFolder to "Movies_M" & pathDelim
- end if
- if destination = "brice" then
- set movieFolder to "Movies_B" & pathDelim
- end if
- if destination = "edwin" then
- set movieFolder to "Movies_E" & pathDelim
- end if
- set the searchPath to [gAmberPath & destination & pathDelim & movieFolder, gSoundPath]
- put "new searchPath (after entering domain-movie) ="
- put the searchPath
- if gCPU = #PC then
- set gSoundPath2 to gAmberPath & "CD_DATA\"
- else
- set gSoundPath2 to gAmberPath & "CD_SOUNDS:"
- end if
- put "new gSoundPath2 = "
- put gSoundPath2
- if getPos(the windowList, builderwindow) then
- put "trying to display state"
- displayState()
- end if
- end
-
- on saveCurrentGame me, overWriteOrSaveAs
- global oUtility, gSavePath, gCPU, oPuppeteer, thisCursor, lastCursor
- writePrefsFile(oPuppeteer)
- oUtility(mSetDefaultPath, gSavePath)
- if overWriteOrSaveAs = #overWrite then
- if currentGameFile = #None then
- set overWriteOrSaveAs to #saveAs
- else
- set saveTest to new(xtra("FileIO"))
- if not objectp(saveTest) then
- put "Sorry, there's some problem creating a fileio object."
- return #fileio_error
- end if
- openFile(saveTest, currentGameFile, 2)
- if error(saveTest, status(saveTest)) <> "OK" then
- put error(saveTest, status(saveTest))
- set saveTest to 0
- return #fileio_error
- else
- put "name: " & fileName(saveTest)
- setPosition(saveTest, 0)
- set saveString to string(lsStateData)
- put "writeString result: " & writeString(saveTest, saveString)
- put "helpful error code: " & error(saveTest, status(saveTest))
- set saveTest to 0
- return #OK
- end if
- end if
- end if
- if overWriteOrSaveAs = #saveAs then
- set saveTest to new(xtra("FileIO"))
- if not objectp(saveTest) then
- alert("Sorry, there's some problem creating a fileio object.")
- quit()
- end if
- setFilterMask(saveTest, "Amber: Journeys Beyond saved games,*.sav")
- set strCurrentFile to displaySave(saveTest, "Save Game as", "my saved game.sav")
- if objectp(oPuppeteer) then
- refreshVidSprites(oPuppeteer)
- end if
- if the movie contains "AMBERHUB" then
- else
- set thisCursor to #pointer
- set lastCursor to #bogus
- cursorDance()
- end if
- if strCurrentFile <> EMPTY then
- createFile(saveTest, strCurrentFile)
- set saveError to error(saveTest, status(saveTest))
- if (saveError <> "OK") and (saveError <> "File already exists") then
- alert("Sorry, there was an error creating the saved-game file: " & saveError)
- end if
- openFile(saveTest, strCurrentFile, 2)
- writeString(saveTest, string(lsStateData))
- set writeError to error(saveTest, status(saveTest))
- if writeError <> "OK" then
- alert("Sorry, there was an error writing the saved-game file: " & writeError)
- end if
- else
- put "error: " & error(saveTest, status(saveTest))
- end if
- set saveTest to 0
- end if
- end
-
- on enterNewDomain me, destination, desiredFrame, jumpSwitch
- global domainIsReady, gAmberPath, gSoundPath, gCDswapStash, gSoundPath2, gCPU, gCurrentHotspot, gDeferredTransit, gHorsepower
- set gDeferredTransit to "nothing --waiting for " & destination
- if jumpSwitch <> #jumping then
- if (destination = "ROXY") and (count(lsStateData) > 0) then
- set recentOuterDomain to value("#" & getState(me, #currentDomain))
- set frozenRoxy to getProp(lsStateData, #StateOnIce)
- set ghostList to getProp(frozenRoxy, #ghostsRemaining)
- set ghostPosition to getPos(ghostList, recentOuterDomain)
- if ghostPosition <> 0 then
- deleteAt(ghostList, ghostPosition)
- end if
- set lastDomainName to string(recentOuterDomain)
- else
- set lastDomainName to #neverMind
- end if
- set gCDswapStash to [#destination: destination, #loadFrame: desiredFrame, #callingHandler: #enterNewDomain]
- ensureProperCD(me, destination, lastDomainName)
- else
- end if
- if gCPU = #PC then
- set pathDelim to "\"
- end if
- if gCPU = #Mac then
- set pathDelim to ":"
- end if
- set the searchPath to [gAmberPath & destination & pathDelim, gSoundPath]
- put "new searchPath (before entering domain-movie) ="
- put the searchPath
- REPORT2("ΓÇó> Starting timer for enterNewDomain( oStoryteller )...")
- startTimer()
- set domainIsReady to 0
- set gCurrentHotspot to #None
- if desiredFrame <> 0 then
- go(desiredFrame, destination)
- else
- go(1, destination)
- end if
- if destination = "roxy" then
- set movieFolder to "movies" & pathDelim
- end if
- if destination = "margaret" then
- set movieFolder to "Movies_M" & pathDelim
- end if
- if destination = "brice" then
- set movieFolder to "Movies_B" & pathDelim
- end if
- if destination = "edwin" then
- set movieFolder to "Movies_E" & pathDelim
- end if
- set the searchPath to [gAmberPath & destination & pathDelim & movieFolder, gSoundPath]
- put "new searchPath (after entering domain-movie) ="
- put the searchPath
- if gCPU = #PC then
- set gSoundPath2 to gAmberPath & "CD_DATA\"
- else
- set gSoundPath2 to gAmberPath & "CD_SOUNDS:"
- end if
- put "new gSoundPath2 = "
- put gSoundPath2
- REPORT2("[enterNewDomain of oStoryteller]: Just finished 'go to movie ''ROXY'' ' ( at " & the timer & " ticks)")
- if destination = "ROXY" then
- if count(lsStateData) > 0 then
- set lastOuterDomain to getState(me, #currentDomain)
- set savedRoxy to getProp(lsStateData, #StateOnIce)
- set lsStateData to savedRoxy
- setState(me, #horsePower, gHorsepower)
- setState(me, #lastDomainVisited, lastOuterDomain)
- if lastOuterDomain = "MARGARET" then
- setProp(lsStateData, #currentLocation, [#DarkUp_40sReentry])
- end if
- if lastOuterDomain = "BRICE" then
- setProp(lsStateData, #currentLocation, [#Ggaz_Reentry])
- end if
- if lastOuterDomain = "EDWIN" then
- setProp(lsStateData, #currentLocation, [#Gbhs_Reentry1])
- end if
- else
- set lsStateData to value(field "stateData")
- REPORT2("Just put stored state-data into lsStateData of oPuppeteer, at" & the timer & " ticks..")
- setState(me, #horsePower, gHorsepower)
- end if
- else
- if count(lsStateData) then
- setProp(lsStateData, #houseLightsAreOn, [0, 1])
- setState(me, #AMBERVISION, #off)
- endLoop(#amberHum)
- setState(me, #inventoryStatus, #hot)
- end if
- set storedState to lsStateData
- set lsStateData to value(field "stateData")
- REPORT2("Just put stored state-data into lsStateData of oPuppeteer, at" & the timer & " ticks..")
- addProp(lsStateData, #StateOnIce, storedState)
- REPORT2("Just stashed Roxy's state-data into #stateOnIce, at" & the timer & " ticks..")
- setState(me, #horsePower, gHorsepower)
- end if
- set theTime to the timer
- REPORT2(" enterNewDomain( oStoryteller ) done: at " & theTime & " ticks")
- end
-
- on getState me, stateVar
- return getAt(getProp(lsStateData, stateVar), 1)
- end
-
- on setState me, stateVar, suggestion
- global builderwindow
- set valueList to getProp(lsStateData, stateVar)
- if count(valueList) > 1 then
- set oldPos to getPos(valueList, suggestion)
- if oldPos then
- addAt(valueList, 1, suggestion)
- deleteAt(valueList, oldPos + 1)
- if getPos(the windowList, builderwindow) then
- tell builderwindow
- showState(stateVar)
- end tell
- end if
- return #OK
- else
- return #badValue
- end if
- else
- set customFuncResult to value("set" & stateVar & "( #" & suggestion & " )")
- if getPos(the windowList, builderwindow) then
- tell builderwindow
- showState(stateVar)
- end tell
- end if
- return customFuncResult
- end if
- end
-
- on evaluate me, IFlist
- set myProp to getPropAt(IFlist, 1)
- if myProp = #equals then
- return getState(me, getAt(getAt(IFlist, 1), 1)) = getAt(getAt(IFlist, 1), 2)
- end if
- if myProp = #less then
- return getState(me, getAt(getAt(IFlist, 1), 1)) < getAt(getAt(IFlist, 1), 2)
- end if
- if myProp = #not then
- return getState(me, getAt(getAt(IFlist, 1), 1)) <> getAt(getAt(IFlist, 1), 2)
- end if
- if myProp = #greater then
- return getState(me, getAt(getAt(IFlist, 1), 1)) > getAt(getAt(IFlist, 1), 2)
- end if
- if myProp = #includes then
- return getPos(getProp(lsStateData, getAt(getAt(IFlist, 1), 1)), getAt(getAt(IFlist, 1), 2))
- end if
- if myProp = #lacks then
- return not getPos(getProp(lsStateData, getAt(getAt(IFlist, 1), 1)), getAt(getAt(IFlist, 1), 2))
- end if
- if myProp = #and then
- set subList1 to [:]
- set subList2 to [:]
- addProp(subList1, getPropAt(getAt(IFlist, 1), 1), getAt(getAt(IFlist, 1), 1))
- addProp(subList2, getPropAt(getAt(IFlist, 1), 2), getAt(getAt(IFlist, 1), 2))
- return evaluate(me, subList1) and evaluate(me, subList2)
- end if
- if myProp = #or then
- set subList1 to [:]
- set subList2 to [:]
- addProp(subList1, getPropAt(getAt(IFlist, 1), 1), getAt(getAt(IFlist, 1), 1))
- addProp(subList2, getPropAt(getAt(IFlist, 1), 2), getAt(getAt(IFlist, 1), 2))
- return evaluate(me, subList1) or evaluate(me, subList2)
- end if
- end
-