Skip to content

Commit

Permalink
Release v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaakma committed Nov 20, 2021
1 parent f4fc89a commit abecebe
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ local common = require('mer.chargenScenarioUtilities.common')
local function registerLocation()
local location = {
position = {
tes3.player.position.x,
tes3.player.position.y,
tes3.player.position.z
math.floor(tes3.player.position.x),
math.floor(tes3.player.position.y),
math.floor(tes3.player.position.z),
},
orientation = {
tes3.player.orientation.x,
tes3.player.orientation.y,
tes3.player.orientation.z
math.floor(tes3.player.orientation.x),
math.floor(tes3.player.orientation.y),
math.floor(tes3.player.orientation.z),
},
cell = tes3.player.cell.id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if interop then
locations = {
locations.shipwreck_01,
locations.shipwreck_02,
locations.shipwreck_03,
},
introMessage = "You are the lone survivor of a shipwreck. Cold, wet and hungry, can you make it to shore alive?",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,6 @@ local function runInitializedTests()
end)
UnitWind:finish(exitAfterInitialize)
end
event.register("initialized", runInitializedTests, { priority = 1000})
event.register("initialized", runInitializedTests, { priority = exitAfterInitialize and 1000 or -1000 })


Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ end


function Scenario:start()
tes3.findGlobal("CharGenState").value = -1
self:addClutter()
self:moveToLocation()
timer.start{
Expand All @@ -188,7 +189,6 @@ function Scenario:start()
self:addSpells()
self:doIntroMessage()
common.enableControls()
tes3.findGlobal("CharGenState").value = -1
end,
}
end
Expand Down
18 changes: 9 additions & 9 deletions Data Files/MWSE/mods/mer/chargenScenarios/config.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

local config = {
modName = "Chargen Scenarios",
modDescription = [[
Expand All @@ -9,24 +10,23 @@ local config = {
cell = "Imperial Prison Ship"
},
chargenLocation = {
position = {4200,3965,15520},
orientation = {0, 0, 180},
cell = "CREL Start"
position = {61, 135, 1000},
orientation = {0, 0, 340},
cell = "Imperial Prison Ship"
},
scenarios = {

--default
{
name = "No Scenario",
description = "Start the game normally, without a scenario.",
name = "Imperial Prisoner (vanilla)",
description = "Start the game in the Seyda Neen Census and Excise Office, without a scenario.",
location = {
position = {61, -135, 24},
orientation = {0, 0, 340},
cell = "Imperial Prison Ship"
orientation = {0,0,1.6740349531174},
position = {33,-87,194},
cell = "Seyda Neen, Census and Excise Office"
},
doVanillaChargen = true
},

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@

local common = require('mer.chargenScenarios.common')

local chargenObjects = {
"CharGen Boat",
"CharGen Boat Guard 1",
"CharGen Boat Guard 2",
"CharGen Dock Guard",
"CharGen_cabindoor",
"CharGen_chest_02_empty",
"CharGen_crate_01",
"CharGen_crate_01_empty",
"CharGen_crate_01_misc01",
"CharGen_crate_02",
"CharGen_lantern_03_sway",
"CharGen_ship_trapdoor",
"CharGen_barrel_01",
"CharGen_barrel_02",
"CharGenbarrel_01_drinks",
"CharGen_plank",
"CharGen StatsSheet",
}
local function disableChargenStuff()
--Disable chargen objects
for _, id in ipairs(chargenObjects) do
local command = string.format('"%s"->Disable', id)
tes3.runLegacyScript{ command = command}
end
--unlock door to census office
tes3.runLegacyScript{ command = '"CharGen Door Hall"->Unlock'}
end

local function startChargen()
local weatherController = tes3.worldController.weatherController
weatherController:switchImmediate(0)
Expand All @@ -10,10 +39,17 @@ local function startChargen()
--Disable Controls
common.log:debug("Disabling controls")
common.disableControls()
--Disable NPCs
common.log:debug("Disabling Vanilla Chargen stuff")
disableChargenStuff()

--Move Player to Chargen Cell
common.log:debug("Moving player to chargen cell")
tes3.positionCell(common.config.chargenLocation)
--Open Stat Review Menu

--"bk_a1_1_caiuspackage"

timer.start{
type = timer.simulate,
duration = 1,
Expand All @@ -29,21 +65,42 @@ local function startChargenOnLoad(e)
if common.modEnabled() and e.newGame then
common.log:debug("Starting Chargen")
startChargen()

end
end
event.register("loaded", startChargenOnLoad)

--[[
Prevent vanilla chargen script from running,
and set the weather to clear.
Prevent vanilla chargen scripts from running,
]]
local chargenScripts = {
"CharGen",
"CharGen_ring_keley",
"ChargenBed",
"ChargenBoatNPC",
"CharGenBoatWomen",
"CharGenClassNPC",
"CharGenCustomsDoor",
"CharGenDagger",
"CharGenDialogueMessage",
"CharGenDoorEnterCaptain",
"CharGenFatigueBarrel",
"CharGenDoorExit",
"CharGenDoorExitCaptain",
"CharGenDoorGuardTalker",
"CharGenJournalMessage",
"CharGenNameNPC",
"CharGenRaceNPC",
"CharGenStatsSheet",
"CharGenStuffRoom",
"CharGenWalkNPC",
}

local function setVanillaChargenScriptOnLoad()
if common.modEnabled() then
common.log:debug("Overriding Chargen Script")
mwse.overrideScript("CharGen", function() end)
--set to clear weather

common.log:debug("Overriding Chargen Scripts")
for _, script in pairs(chargenScripts) do
mwse.overrideScript(script, function() end)
end
end
end
event.register("load", setVanillaChargenScriptOnLoad)
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ local function modifyStatReviewMenu(e)

--Add scenario button
createScenarioButton(parent)
--OK button should trigger the scenario to start
local okButton = menu:findChild("MenuStatReview_Okbutton")
okButton:register("mouseClick", function(eMouseClick)
if hasCompletedChargen() then
okButton:forwardEvent(eMouseClick)
tes3.runLegacyScript{ script = "RaceCheck" }
tes3.player.tempData.selectedChargenScenario:start()
else
tes3.messageBox("You must complete the character generation process before you can continue.")
Expand All @@ -78,24 +80,21 @@ local function modifyStatReviewMenu(e)
end
event.register("uiActivated", modifyStatReviewMenu, { filter = "MenuStatReview"})



--[[
When the RaceSex menu is opened, override the Ok button
to trigger the statReviewMenu again
]]
---@param e uiActivatedEventData
local function modifyRaceSexMenu(e)
if (not e.newlyCreated) then
return
end

common.log:debug("Enter RaceSex Menu")
local okButton = e.element:findChild("MenuRaceSex_Okbutton")
if (not e.newlyCreated) then
return
end
local menu = e.element
--hide back button
e.element:findChild("MenuRaceSex_Backbutton").visible = false
menu:findChild("MenuRaceSex_Backbutton").visible = false
--OK button should trigger the class menu
local okButton = menu:findChild("MenuRaceSex_Okbutton")
okButton:register("mouseClick", function(eMouseClick)
common.log:debug("Clicked ok button, returning to stat review menu")
--trigger the stat review menu
okButton:forwardEvent(eMouseClick)
tes3.player.tempData.chargenScenariosRaceChosen = true
Expand All @@ -108,8 +107,6 @@ local function modifyRaceSexMenu(e)
end
event.register("uiActivated", modifyRaceSexMenu, { filter = "MenuRaceSex"})



--[[
Class has three different menus, we need to override the Ok and back buttons
for each one
Expand All @@ -119,6 +116,7 @@ local function modifyClassChoiceMenu(e)
if (not e.newlyCreated) then
return
end

local menu = e.element
--Create title and move to top of menu
local title = menu:createLabel{ text = "Choose Your Class"}
Expand All @@ -143,8 +141,11 @@ local function modifyCreateClassMenu(e)
if (not e.newlyCreated) then
return
end

local menu = e.element
common.log:debug("Enter CreateClass Menu")
local okButton = e.element:findChild("MenuCreateClass_Okbutton")
--OK button should trigger the birth sign menu
local okButton = menu:findChild("MenuCreateClass_Okbutton")
okButton:register("mouseClick", function(eMouseClick)
common.log:debug("Clicked ok button, returning to stat review menu")
--trigger the stat review menu
Expand All @@ -164,11 +165,12 @@ local function modifyChooseClassMenu(e)
if (not e.newlyCreated) then
return
end
common.log:debug("Enter ChooseClass Menu")
local okButton = e.element:findChild("MenuChooseClass_Okbutton")

local menu = e.element
--OK button should trigger the birth sign menu
local okButton = menu:findChild("MenuChooseClass_Okbutton")
okButton:register("mouseClick", function(eMouseClick)
common.log:debug("Clicked ok button, returning to stat review menu")
--trigger the stat review menu
okButton:forwardEvent(eMouseClick)
tes3.player.tempData.chargenScenariosClassChosen = true
if not tes3.player.tempData.chargenScenariosBirthsignChosen then
Expand All @@ -192,10 +194,10 @@ local function modifyBirthSignMenu(e)
return
end

common.log:debug("Enter BirthSign Menu")
local menu = e.element
local okButton = e.element:findChild("MenuBirthSign_Okbutton")
--hide back button
e.element:findChild("MenuBirthSign_Backbutton").visible = false
menu:findChild("MenuBirthSign_Backbutton").visible = false
okButton:register("mouseClick", function(eMouseClick)
common.log:debug("Clicked ok button, returning to stat review menu")
--trigger the stat review menu
Expand All @@ -220,15 +222,24 @@ local function modifyNameMenu(e)
if (not e.newlyCreated) then
return
end

local menu = e.element
common.log:debug("Enter Name Menu")
--Ok button should trigger the statReviewMenu
local okButton = menu:findChild("MenuName_OkNextbutton")
okButton:register("mouseClick", function(eMouseClick)
common.log:debug("Clicked okNext button, returning to stat review menu")
--trigger the stat review menu
okButton:forwardEvent(eMouseClick)
tes3.player.tempData.chargenScenariosNameChosen = true
scenarioSelector.openScenarioSelector()
okButton:forwardEvent(eMouseClick)
--If character backgrounds is installed, trigger the perks menu
if tes3.player.data.merBackgrounds then
common.log:debug("Backgrounds is active, opening perks menu")
timer.delayOneFrame(function()
event.trigger("CharacterBackgrounds:OpenPerksMenu")
end)
else
common.log:debug("Clicked okNext button, returning to stat review menu")
--trigger the stat review menu
scenarioSelector.openScenarioSelector()
end
end)

--Prepopulate name option based on player race
Expand All @@ -243,6 +254,10 @@ local function modifyNameMenu(e)
common.log:debug("Selecting %s", race)
textSelect:triggerEvent("mouseClick")
raceBlockNames.widget:contentsChanged()
local sexButton = menu:findChild("NameGenerator:sexBlock").children[1]
if sexButton and tes3.player.object.female then
sexButton:triggerEvent("mouseClick")
end
local generateButton = okButton.parent.children[1]
if generateButton then
common.log:debug("Generating a random name")
Expand All @@ -253,4 +268,10 @@ local function modifyNameMenu(e)
end
end
end
event.register("uiActivated", modifyNameMenu, { filter = "MenuName", priority = -10})
event.register("uiActivated", modifyNameMenu, { filter = "MenuName", priority = -10})

local function openScenarioSelectorOnBackgroundsFinish()
common.log:debug("Background selected, opening scenario menu")
scenarioSelector.openScenarioSelector()
end
event.register("CharacterBackgrounds:OkayMenuClicked", openScenarioSelectorOnBackgroundsFinish)
Loading

0 comments on commit abecebe

Please sign in to comment.