饥荒是个自由度很高的游戏,shark工作组确实厉害,不过新手面对无穷尽的死亡还是很头疼。

下面两句mod里的代码注释后可以防止删档,当任务死亡后只需要按esc正常quit,小退下重进就可以了从最近的存档恢复。

目录每个版本都不一样,只要在安装目录下搜索到gamelogic.lua文件就可以了。

在OnPlayerDeath方法中注释所有调用HandleDeathCleanup的方法就可以了。

注释方法就是在句首加上“--”。

最后贴上最新版的完整代码,覆盖前友情提醒先备份原版的代码。

require "mods"
require "playerprofile"
require "saveindex"
require "screens/mainscreen"
require "screens/deathscreen"
require "screens/popupdialog"
require "screens/bigpopupdialog"
require "screens/endgamedialog"Print (VERBOSITY.DEBUG, "[Loading frontend assets]")local start_game_time = nilTheSim:SetRenderPassDefaultEffect( RENDERPASS.BLOOM, "data/shaders/anim_bloom.ksh" )
TheSim:SetErosionTexture( "data/images/erosion.tex" )--this is suuuuuper placeholdery. We need to think about how to handle all of the different types of updates for this
local function DoAgeWorld()for k,v in pairs(Ents) do--spoil all of the spoilablesif v.components.perishable thenv.components.perishable:Perish()end--send things to their homesif v.components.homeseeker and v.components.homeseeker.home thenif v.components.homeseeker.home.components.childspawner thenv.components.homeseeker.home.components.childspawner:GoHome(v)endif v.components.homeseeker.home.components.spawner thenv.components.homeseeker.home.components.spawner:GoHome(v)endendif v.components.fueled thenv.components.fueled:MakeEmpty()endend
endlocal function LoadAssets(fe)local be_prefabs = {"hud", "forest", "cave", "ceiling", "maxwell", "fire", "character_fire", "shatter"}local fe_prefabs = {"frontend"}local recipe_prefabs = {}for k,v in pairs(Recipes) dotable.insert(recipe_prefabs, v.name)if v.placer thentable.insert(recipe_prefabs, v.placer)endendif fe thenprint ("LOAD FE")TheSim:LoadPrefabs(fe_prefabs)TheSim:UnloadPrefabs(be_prefabs)TheSim:UnloadPrefabs(recipe_prefabs)print ("LOAD FE: done")elseprint ("LOAD BE")TheSim:UnloadPrefabs(fe_prefabs)TheSim:LoadPrefabs(be_prefabs)TheSim:LoadPrefabs(recipe_prefabs)print ("LOAD BE: done")end
endfunction GetTimePlaying()if not start_game_time thenreturn 0endreturn GetTime() - start_game_time
endfunction CalculatePlayerRewards(wilson)local Progression = require "progressionconstants"print("Calculating progression")--increment the xp counter and give rewardslocal days_survived = GetClock().numcycleslocal start_xp = wilson.profile:GetXP()local reward_xp = Progression.GetXPForDays(days_survived)local new_xp = math.min(start_xp + reward_xp, Progression.GetXPCap())local all_rewards = Progression.GetRewardsForTotalXP(new_xp)for k,v in pairs(all_rewards) dowilson.profile:UnlockCharacter(v)endwilson.profile:SetXP(new_xp)print("Progression: ",days_survived, start_xp, reward_xp, new_xp)return days_survived, start_xp, reward_xp, new_xp
endlocal function HandleDeathCleanup(wilson, data)local game_time = GetClock():ToMetricsString()if SaveGameIndex:GetCurrentMode() == "survival" thenlocal playtime = GetTimePlaying()playtime = math.floor(playtime*1000)SetTimingStat("time", "scenario", playtime)SendTrackingStats()local days_survived, start_xp, reward_xp, new_xp = CalculatePlayerRewards(wilson)ProfileStatsSet("xp_gain", reward_xp)ProfileStatsSet("xp_total", new_xp)SubmitCompletedLevel() --close off the instancewilson.components.health.invincible = truewilson.profile:Save(function()SaveGameIndex:EraseCurrent(function() scheduler:ExecuteInTime(3, function() TheFrontEnd:PushScreen(DeathScreen(days_survived, start_xp))end)end)end)elseif SaveGameIndex:GetCurrentMode() == "adventure" thenSaveGameIndex:OnFailAdventure(function()scheduler:ExecuteInTime(3, function() TheFrontEnd:Fade(false, 3, function()local params = json.encode{reset_action="loadslot", save_slot = SaveGameIndex:GetCurrentSaveSlot(), playeranim="failadventure"}TheSim:SetInstanceParameters(params)TheSim:Reset()end)end)end)   elseif SaveGameIndex:GetCurrentMode() == "cave" thenscheduler:ExecuteInTime(2, function()TheFrontEnd:Fade(false, 2, function()for k,v in pairs(Ents) doif v.prefab == "cave_exit" thenGetPlayer().Transform:SetPosition(v.Transform:GetWorldPosition())breakendendDoAgeWorld()SaveGameIndex:SaveCurrent(function()SaveGameIndex:OnFailCave(function()local params = json.encode{reset_action="loadslot", save_slot = SaveGameIndex:GetCurrentSaveSlot(), playeranim="failcave"}TheSim:SetInstanceParameters(params)TheSim:Reset()end)end)end)end)end
endlocal function OnPlayerDeath(wilson, data)local cause = data.cause or "unknown"local will_resurrect = wilson.components.resurrectable and wilson.components.resurrectable:CanResurrect() TheMixer:PushMix("death")wilson.HUD:Hide()local game_time = GetClock():ToMetricsString()RecordDeathStats(cause, GetClock():GetPhase(), wilson.components.sanity.current, wilson.components.hunger.current, will_resurrect)ProfileStatsAdd("killed_by_"..cause)ProfileStatsAdd("deaths")--local res = TheSim:FindFirstEntityWithTag("resurrector")if will_resurrect thenscheduler:ExecuteInTime(4, function()  TheMixer:PopMix("death")if wilson.components.resurrectable:DoResurrect() thenProfileStatsAdd("resurrections")else--HandleDeathCleanup(wilson, data)endend)else--HandleDeathCleanup(wilson, data)end
endfunction SetUpPlayerCharacterCallbacks(wilson)--set up on ondeath handlerwilson:ListenForEvent( "death", function(inst, data) OnPlayerDeath(wilson, data) end)wilson:ListenForEvent( "quit",function()Print (VERBOSITY.DEBUG, "I SHOULD QUIT!")TheMixer:PushMix("death")wilson.HUD:Hide()local playtime = GetTimePlaying()playtime = math.floor(playtime*1000)RecordQuitStats()SetTimingStat("time", "scenario", playtime)ProfileStatsSet("time_played", playtime)SendTrackingStats()SendAccumulatedProfileStats()TheSim:SetInstanceParameters()TheSim:Reset()end)        wilson:ListenForEvent( "daycomplete", function(it, data) if not wilson.components.health:IsDead() thenRecordEndOfDayStats()ProfileStatsAdd("nights_survived_iar")SendAccumulatedProfileStats()endend, GetWorld()) --[[wilson:ListenForEvent( "daytime", function(it, data) if not wilson.components.health:IsDead() and not wilson.is_teleporting then--print("Day has arrived...")--SaveGameIndex:SaveCurrent()endend, GetWorld()) --]]wilson:ListenForEvent("builditem", function(inst, data) ProfileStatsAdd("build_item_"..data.item.prefab) end)    wilson:ListenForEvent("buildstructure", function(inst, data) ProfileStatsAdd("build_structure_"..data.item.prefab) end)
endlocal function StartGame(wilson)TheFrontEnd:GetSound():KillSound("FEMusic") -- just in case...start_game_time = GetTime()SetUpPlayerCharacterCallbacks(wilson)
endlocal deprecated = { turf_webbing = true }
local replace = { farmplot = "slow_farmplot", farmplot2 = "fast_farmplot", farmplot3 = "fast_farmplot", sinkhole= "cave_entrance",cave_stairs= "cave_entrance"}function PopulateWorld(savedata, profile, playercharacter, playersavedataoverride)playercharacter = playercharacter or "wilson"Print(VERBOSITY.DEBUG, "PopulateWorld")Print(VERBOSITY.DEBUG,  "[Instantiating objects...]" )local wilson = nilif savedata then--figure out our start infolocal spawnpoint = Vector3(0,0,0)local playerdata = {}if savedata.playerinfo thenif savedata.playerinfo.x and savedata.playerinfo.z thenlocal y = savedata.playerinfo.y or 0spawnpoint = Vector3(savedata.playerinfo.x, y, savedata.playerinfo.z)endif savedata.playerinfo.data thenplayerdata = savedata.playerinfo.dataendendif playersavedataoverride thenplayerdata = playersavedataoverrideendlocal newents = {}--local world = SpawnPrefab("forest")local world = nillocal ceiling = nilif savedata.map.prefab == "cave" thenworld = SpawnPrefab("cave")ceiling = SpawnPrefab("ceiling")elseworld = SpawnPrefab("forest")end--spawn the player character and set him upTheSim:LoadPrefabs{playercharacter}wilson = SpawnPrefab(playercharacter)assert(wilson, "could not spawn player character")wilson:SetProfile(Profile)wilson.Transform:SetPosition(spawnpoint:Get())--this was spawned by the level file. kinda lame - we should just do everything from in here.local ground = GetWorld()if ground thenif GetCeiling() thenGetCeiling().MapCeiling:SetSize(savedata.map.width, savedata.map.height)GetCeiling().MapCeiling:SetFromString(savedata.map.tiles)GetCeiling().MapCeiling:Finalize(TheSim:GetSetting("graphics", "static_walls") == "true")endground.Map:SetSize(savedata.map.width, savedata.map.height)if savedata.map.prefab == "cave" thenground.Map:SetPhysicsWallDistance(0.75)--0) -- TEMP for STREAMelseground.Map:SetPhysicsWallDistance(0)--0.75)endground.Map:SetFromString(savedata.map.tiles)ground.Map:Finalize()if savedata.map.nav thenprint("Loading Nav Grid")ground.Map:SetNavSize(savedata.map.width, savedata.map.height)ground.Map:SetNavFromString(savedata.map.nav)elseprint("No Nav Grid")endground.hideminimap = savedata.map.hideminimapground.topology = savedata.map.topologyground.meta = savedata.metaassert(savedata.map.topology.ids, "[MALFORMED SAVE DATA] Map missing topology information. This save file is too old, and is missing neccessary information.")for i=#savedata.map.topology.ids,1, -1 dolocal name = savedata.map.topology.ids[i]if string.find(name, "LOOP_BLANK_SUB") ~= nil thentable.remove(savedata.map.topology.ids, i)table.remove(savedata.map.topology.nodes, i)for eid=#savedata.map.topology.edges,1,-1 doif savedata.map.topology.edges[eid].n1 == i or savedata.map.topology.edges[eid].n2 == i thentable.remove(savedata.map.topology.edges, eid)endendendend       if ground.topology.level_number ~= nil thenrequire("map/levels")if levels.story_levels[ground.topology.level_number] ~= nil thenprofile:UnlockWorldGen("preset", levels.story_levels[ground.topology.level_number].name)endendwilson:AddComponent("area_aware")--wilson:AddComponent("area_unlock")if ground.topology.override_triggers thenwilson:AddComponent("area_trigger")wilson.components.area_trigger:RegisterTriggers(ground.topology.override_triggers)endfor i,node in ipairs(ground.topology.nodes) dolocal story = ground.topology.ids[i]-- guard for old saveslocal story_depth = nilif ground.topology.story_depths thenstory_depth = ground.topology.story_depths[i]endif story ~= "START" thenstory = string.sub(story, 1, string.find(story,":")-1)
--
--                  if Profile:IsWorldGenUnlocked("tasks", story) == false then
--                      wilson.components.area_unlock:RegisterStory(story)
--                  endendwilson.components.area_aware:RegisterArea({idx=i, type=node.type, poly=node.poly, story=story, story_depth=story_depth})if node.type == "Graveyard" or node.type == "MistyCavern" thenif node.area_emitter == nil thenlocal mist = SpawnPrefab( "mist" )mist.Transform:SetPosition( node.cent[1], 0, node.cent[2] )mist.components.emitter.area_emitter = CreateAreaEmitter( node.poly, node.cent )if node.area == nil thennode.area = 1endmist.components.emitter.density_factor = math.ceil(node.area / 4)/31mist.components.emitter:Emit()endendendif savedata.map.persistdata ~= nil thenground:SetPersistData(savedata.map.persistdata)endwilson.components.area_aware:StartCheckingPosition()endwilson:SetPersistData(playerdata, newents)if wilson.components.health.currenthealth == 0 thenwilson.components.health.currenthealth = 1endif savedata.playerinfo and savedata.playerinfo.id thennewents[savedata.playerinfo.id] = {entity=wilson, data=playerdata} end--set the clock (LEGACY! this is now handled via the world object's normal serialization)if savedata.playerinfo.day and savedata.playerinfo.dayphase and savedata.playerinfo.timeleftinera thenGetClock().numcycles = savedata.playerinfo and savedata.playerinfo.day or 0if savedata.playerinfo and savedata.playerinfo.dayphase == "night" thenGetClock():StartNight(true)elseif savedata.playerinfo and savedata.playerinfo.dayphase == "dusk" thenGetClock():StartDusk(true)else GetClock():StartDay(true)endif savedata.playerinfo.timeleftinera thenGetClock().timeLeftInEra = savedata.playerinfo.timeleftineraendend-- Force overrides for ambientlocal retune = require("tuning_override")retune.OVERRIDES["areaambientdefault"].doit(savedata.map.prefab)-- Check for map overridesif ground.topology.overrides ~= nil and ground.topology.overrides ~= nil and GetTableSize(ground.topology.overrides) > 0 then         for area, overrides in pairs(ground.topology.overrides) do  for i,override in ipairs(overrides) do  if retune.OVERRIDES[override[1]] ~= nil thenretune.OVERRIDES[override[1]].doit(override[2])endendendend--instantiate all the dudesfor prefab, ents in pairs(savedata.ents) dolocal prefab = replace[prefab] or prefabif not deprecated[prefab] thenfor k,v in ipairs(ents) dov.prefab = v.prefab or prefab -- prefab field is stripped out when entities are saved in global entity collections, so put it backSpawnSaveRecord(v, newents)endendend    --post pass in neccessary to hook up referencesfor k,v in pairs(newents) dov.entity:LoadPostPass(newents, v.data)endGetWorld():LoadPostPass(newents, savedata.map.persistdata)--Run scenario scriptsfor guid, ent in pairs(Ents) doif ent.components.scenariorunner thenent.components.scenariorunner:Run()endend--Record mod informationModManager:SetModRecords(savedata.mods or {})if SaveGameIndex:GetCurrentMode() ~= "adventure" and GetWorld().components.age and GetPlayer().components.age thenlocal player_age = GetPlayer().components.age:GetAge()local world_age = GetWorld().components.age:GetAge()if world_age <= 0 thenGetWorld().components.age.saved_age = player_ageelseif player_age > world_age thenlocal catch_up = player_age - world_age print ("Catching up world", catch_up)LongUpdate(catch_up, true)--this is a cheesy workaround for coming out of a cave at night, so you don't get immediately eatenif SaveGameIndex:GetCurrentMode() == "survival" and not GetWorld().components.clock:IsDay() thenlocal light = SpawnPrefab("exitcavelight")light.Transform:SetPosition(GetPlayer().Transform:GetWorldPosition())endendendelsePrint(VERBOSITY.ERROR, "[MALFORMED SAVE DATA] PopulateWorld complete" )returnendPrint(VERBOSITY.DEBUG, "[FINISHED LOADING SAVED GAME] PopulateWorld complete" )return wilson
endlocal function DrawDebugGraph(graph)-- debug draw of new map genlocal debugdrawmap = CreateEntity()local draw = debugdrawmap.entity:AddDebugRender()draw:SetZ(0.1)for idx,node in ipairs(graph.nodes) dolocal colour = graph.colours[node.c]for i =1, #node.poly-1 dodraw:Line(node.poly[i][1], node.poly[i][2], node.poly[i+1][1], node.poly[i+1][2], colour.r, colour.g, colour.b, 255)enddraw:Line(node.poly[1][1], node.poly[1][2], node.poly[#node.poly][1], node.poly[#node.poly][2], colour.r, colour.g, colour.b, 255)draw:Poly(node.cent[1], node.cent[2], colour.r, colour.g, colour.b, colour.a, node.poly)draw:String(graph.ids[idx].."("..node.cent[1]..","..node.cent[2]..")",     node.cent[1], node.cent[2], node.ts)end draw:SetZ(0.15)for idx,edge in ipairs(graph.edges) doif edge.n1 ~= nil and edge.n2 ~= nil thenlocal colour = graph.colours[edge.c]local n1 = graph.nodes[edge.n1]local n2 = graph.nodes[edge.n2]if n1 ~= nil and n2 ~= nil thendraw:Line(n1.cent[1], n1.cent[2], n2.cent[1], n2.cent[2], colour.r, colour.g, colour.b, colour.a)endendend
end--OK, we have our savedata and a profile. Instatiate everything and start the game!
function DoInitGame(playercharacter, savedata, profile, next_world_playerdata, fast)    --print("DoInitGame",playercharacter, savedata, profile, next_world_playerdata, fast)TheFrontEnd:ClearScreens()   LoadAssets(false)assert(savedata.map, "Map missing from savedata on load")assert(savedata.map.prefab, "Map prefab missing from savedata on load")assert(savedata.map.tiles, "Map tiles missing from savedata on load")assert(savedata.map.width, "Map width missing from savedata on load")assert(savedata.map.height, "Map height missing from savedata on load")assert(savedata.map.topology, "Map topology missing from savedata on load")assert(savedata.map.topology.ids, "Topology entity ids are missing from savedata on load")--assert(savedata.map.topology.story_depths, "Topology story_depths are missing from savedata on load")assert(savedata.map.topology.colours, "Topology colours are missing from savedata on load")assert(savedata.map.topology.edges, "Topology edges are missing from savedata on load")assert(savedata.map.topology.nodes, "Topology nodes are missing from savedata on load")assert(savedata.map.topology.level_type, "Topology level type is missing from savedata on load")assert(savedata.map.topology.overrides, "Topology overrides is missing from savedata on load")assert(savedata.playerinfo, "Playerinfo missing from savedata on load")assert(savedata.playerinfo.x, "Playerinfo.x missing from savedata on load")--assert(savedata.playerinfo.y, "Playerinfo.y missing from savedata on load")   --y is often omitted for space, don't check for itassert(savedata.playerinfo.z, "Playerinfo.z missing from savedata on load")--assert(savedata.playerinfo.day, "Playerinfo day missing from savedata on load")assert(savedata.ents, "Entites missing from savedata on load")if savedata.map.roads thenRoads = savedata.map.roadsfor k, road_data in pairs( savedata.map.roads ) doRoadManager:BeginRoad()local weight = road_data[1]if weight == 3 thenfor i = 2, #road_data dolocal ctrl_pt = road_data[i]RoadManager:AddControlPoint( ctrl_pt[1], ctrl_pt[2] )endfor k, v in pairs( ROAD_STRIPS ) doRoadManager:SetStripEffect( v, "data/shaders/road.ksh" )endRoadManager:SetStripTextures( ROAD_STRIPS.EDGES, "data/images/roadedge.tex",       "data/images/roadnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.CENTER,    "data/images/square.tex",     "data/images/roadnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.CORNERS,   "data/images/roadcorner.tex", "data/images/roadnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.ENDS,      "data/images/roadendcap.tex", "data/images/roadnoise.tex" )RoadManager:GenerateVB(ROAD_PARAMETERS.NUM_SUBDIVISIONS_PER_SEGMENT,ROAD_PARAMETERS.MIN_WIDTH, ROAD_PARAMETERS.MAX_WIDTH,ROAD_PARAMETERS.MIN_EDGE_WIDTH, ROAD_PARAMETERS.MAX_EDGE_WIDTH,ROAD_PARAMETERS.WIDTH_JITTER_SCALE, true )elsefor i = 2, #road_data dolocal ctrl_pt = road_data[i]RoadManager:AddControlPoint( ctrl_pt[1], ctrl_pt[2] )endfor k, v in pairs( ROAD_STRIPS ) doRoadManager:SetStripEffect( v, "data/shaders/road.ksh" )endRoadManager:SetStripTextures( ROAD_STRIPS.EDGES, "data/images/roadedge.tex",       "data/images/pathnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.CENTER,    "data/images/square.tex",     "data/images/pathnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.CORNERS,   "data/images/roadcorner.tex", "data/images/pathnoise.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.ENDS,      "data/images/roadendcap.tex", "data/images/pathnoise.tex" )RoadManager:GenerateVB(ROAD_PARAMETERS.NUM_SUBDIVISIONS_PER_SEGMENT,0, 0,ROAD_PARAMETERS.MIN_EDGE_WIDTH*4, ROAD_PARAMETERS.MAX_EDGE_WIDTH*4,0, false )                       --[[elsefor i = 2, #road_data dolocal ctrl_pt = road_data[i]RoadManager:AddSmoothedControlPoint( ctrl_pt[1], ctrl_pt[2] )endfor k, v in pairs( ROAD_STRIPS ) doRoadManager:SetStripEffect( v, "data/shaders/river.ksh" )endRoadManager:SetStripTextures( ROAD_STRIPS.EDGES, "data/images/square.tex",     "data/images/river_bed.tex" )RoadManager:SetStripTextures( ROAD_STRIPS.CENTER,    "data/images/square.tex",     "data/images/water_river.tex" )RoadManager:SetStripUVAnimStep( ROAD_STRIPS.CENTER, 0, 0.25 )RoadManager:SetStripWrapMode( ROAD_STRIPS.EDGES, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.WRAP )--RoadManager:SetStripTextures( ROAD_STRIPS.CORNERS,    "data/images/roadcorner.tex", "data/images/pathnoise.tex" )--RoadManager:SetStripTextures( ROAD_STRIPS.ENDS,        "data/images/roadendcap.tex", "data/images/pathnoise.tex" )RoadManager:GenerateVB(ROAD_PARAMETERS.NUM_SUBDIVISIONS_PER_SEGMENT,5, 5,2, 2,0, false )--]]endendRoadManager:GenerateQuadTree()endSubmitStartStats(playercharacter)--some lame explicit loadsPrint(VERBOSITY.DEBUG, "DoInitGame Loading prefabs...")Print(VERBOSITY.DEBUG, "DoInitGame Adjusting audio...")TheMixer:SetLevel("master", 0)--apply the volumesPrint(VERBOSITY.DEBUG, "DoInitGame Populating world...")local wilson = PopulateWorld(savedata, profile, playercharacter, next_world_playerdata)if wilson thenTheCamera:SetTarget(wilson)StartGame(wilson)TheCamera:SetDefault()TheCamera:Snap()elsePrint(VERBOSITY.WARNING, "DoInitGame NO WILSON?")endif Profile.persistdata.debug_world  == 1 thenif savedata.map.topology == nil thenPrint(VERBOSITY.ERROR, "OI! Where is my topology info!")elseDrawDebugGraph(savedata.map.topology)endendlocal function OnStart()Print(VERBOSITY.DEBUG, "DoInitGame OnStart Callback... turning volume up")SetHUDPause(false)endif not TheFrontEnd:IsDisplayingError() thenlocal hud = PlayerHud()TheFrontEnd:PushScreen(hud)hud:SetMainCharacter(wilson)--clear the player stats, so that it doesn't count items "acquired" from the save fileGetProfileStats(true)RecordSessionStartStats()--after starting everything up, give the mods additional environment variablesModManager:SimPostInit(wilson)GetPlayer().components.health:RecalculatePenalty()if ( SaveGameIndex:GetCurrentMode() ~= "cave" and (SaveGameIndex:GetCurrentMode() == "survival" or SaveGameIndex:GetSlotWorld() == 1) and SaveGameIndex:GetSlotDay() == 1 and GetClock():GetNormTime() == 0) thenif GetPlayer().components.inventory.starting_inventory thenfor k,v in pairs(GetPlayer().components.inventory.starting_inventory) dolocal item = SpawnPrefab(v)if item thenGetPlayer().components.inventory:GiveItem(item)endendendendif fast thenOnStart()elseSetHUDPause(true,"InitGame")if Settings.playeranim == "failcave" thenGetPlayer().sg:GoToState("wakeup")GetClock():MakeNextDay()elseif Settings.playeranim == "failadventure" thenGetPlayer().sg:GoToState("failadventure")GetPlayer().HUD:Show()elseif GetWorld():IsCave() thenGetPlayer().sg:GoToState("caveenter")GetPlayer().HUD:Show()elseif Settings.playeranim == "wakeup" or playercharacter == "waxwell" or savedata.map.nomaxwell thenGetPlayer().sg:GoToState("wakeup")GetPlayer().HUD:Show()--announce your freedom if you are starting as waxwellif playercharacter == "waxwell" and SaveGameIndex:GetCurrentMode() == "survival" and (GetClock().numcycles == 0 and GetClock():GetNormTime() == 0) thenGetPlayer():DoTaskInTime( 3.5, function()GetPlayer().components.talker:Say(GetString("waxwell", "ANNOUNCE_FREEDOM"))end)endelseif (GetClock().numcycles == 0 and GetClock():GetNormTime() == 0) or Settings.maxwell ~= nil thenlocal max = SpawnPrefab("maxwellintro")local speechName = "NULL_SPEECH"if Settings.maxwell thenspeechName = Settings.maxwellelseif SaveGameIndex:GetCurrentMode() == "adventure" thenif savedata.map.override_level_string == true thenlocal level_id = 1if GetWorld().meta thenlevel_id = GetWorld().meta.level_id or level_id endspeechName = "ADVENTURE_"..level_idelsespeechName = "ADVENTURE_"..SaveGameIndex:GetSlotWorld()endelsespeechName = "SANDBOX_1"endmax.components.maxwelltalker:SetSpeech(speechName)max.components.maxwelltalker:Initialize()max.task = max:StartThread(function() max.components.maxwelltalker:DoTalk() end) --PlayNIS("maxwellintro", savedata.map.maxwell)endlocal title = STRINGS.UI.SANDBOXMENU.ADVENTURELEVELS[SaveGameIndex:GetSlotLevelIndexFromPlaylist()]local subtitle = STRINGS.UI.SANDBOXMENU.CHAPTERS[SaveGameIndex:GetSlotWorld()]local showtitle = SaveGameIndex:GetCurrentMode() == "adventure" and titleif showtitle thenTheFrontEnd:ShowTitle(title,subtitle)endTheFrontEnd:Fade(true, 1, function() SetHUDPause(false)TheMixer:SetLevel("master", 1) TheMixer:PushMix("normal") TheFrontEnd:HideTitle()--TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.HUD.READYTITLE, STRINGS.UI.HUD.READY, {{text=STRINGS.UI.HUD.START, cb = function() OnStart() end}}))end, showtitle and 3, showtitle and function() SetHUDPause(false) end )endif savedata.map.hideminimap ~= nil thenhud.minimap:DoTaskInTime(0, function(inst) inst.MiniMap:ClearRevealedAreas(savedata.map.hideminimap) end)endif savedata.map.teleportaction ~= nil thenlocal teleportato = TheSim:FindFirstEntityWithTag("teleportato")if teleportato thenlocal pickPosition = function() local portpositions = GetRandomInstWithTag("teleportlocation", teleportato, 1000)if portpositions thenreturn Vector3(portpositions.Transform:GetWorldPosition())elsereturn Vector3(savedata.playerinfo.x, savedata.playerinfo.y or 0, savedata.playerinfo.z)endendteleportato.action = savedata.map.teleportactionteleportato.maxwell = savedata.map.teleportmaxwellteleportato.teleportpos = pickPosition()endendend--DoStartPause("Ready!")Print(VERBOSITY.DEBUG, "DoInitGame complete")if PRINT_TEXTURE_INFO thenc_printtextureinfo( "texinfo.csv" )TheSim:Quit()end
end------------------------THESE FUNCTIONS HANDLE STARTUP FLOWlocal function DoLoadWorld(saveslot, playerdataoverride)local function onload(savedata)DoInitGame(SaveGameIndex:GetSlotCharacter(saveslot), savedata, Profile, playerdataoverride)endSaveGameIndex:GetSaveData(saveslot, SaveGameIndex:GetCurrentMode(saveslot), onload)
endlocal function DoGenerateWorld(saveslot, type_override)local function onComplete(savedata )local function onsaved()local success, world_table = RunInSandbox(savedata)if success thenDoInitGame(SaveGameIndex:GetSlotCharacter(saveslot), world_table, Profile, SaveGameIndex:GetPlayerData(saveslot))endendSaveGameIndex:OnGenerateNewWorld(saveslot, savedata, onsaved)endlocal world_gen_options ={level_type = type_override or SaveGameIndex:GetCurrentMode(saveslot),custom_options = SaveGameIndex:GetSlotGenOptions(saveslot,SaveGameIndex:GetCurrentMode()),level_world = SaveGameIndex:GetSlotLevelIndexFromPlaylist(saveslot),profiledata = Profile.persistdata,}if world_gen_options.level_type == "adventure" thenworld_gen_options["adventure_progress"] = SaveGameIndex:GetSlotWorld()elseif world_gen_options.level_type == "cave" thenworld_gen_options["cave_progress"] = SaveGameIndex:GetCurrentCaveLevel()endTheFrontEnd:PushScreen(WorldGenScreen(Profile, onComplete, world_gen_options))
endlocal function LoadSlot(slot)TheFrontEnd:ClearScreens()if SaveGameIndex:HasWorld(slot, SaveGameIndex:GetCurrentMode(slot)) thenDoLoadWorld(slot, SaveGameIndex:GetModeData(slot, SaveGameIndex:GetCurrentMode(slot)).playerdata)elseLoadAssets(true)if SaveGameIndex:GetCurrentMode(slot) == "survival" and SaveGameIndex:IsContinuePending(slot) thenlocal function onsave()DoGenerateWorld(slot)endlocal function onSet(character)SaveGameIndex:SetSlotCharacter(slot, character, onsave)endTheFrontEnd:PushScreen(CharacterSelectScreen(Profile, onSet, true, SaveGameIndex:GetSlotCharacter(slot)))else          DoGenerateWorld(slot)endend
end----------------LOAD THE PROFILE AND THE SAVE INDEX, AND START THE FRONTENDlocal function OnFilesLoaded()UpdateGamePurchasedState( function()--print( "[Settings]",Settings.character, Settings.savefile)if Settings.reset_action thenif Settings.reset_action == "loadslot" thenif not SaveGameIndex:GetCurrentMode(Settings.save_slot) thenLoadAssets(true)TheFrontEnd:ShowScreen(MainScreen(Profile))elseLoadSlot(Settings.save_slot)endelseif Settings.reset_action == "printtextureinfo" thenLoadAssets(true)DoGenerateWorld(1)elseLoadAssets(true)TheFrontEnd:ShowScreen(MainScreen(Profile))endelseif PRINT_TEXTURE_INFO thenSaveGameIndex:DeleteSlot(1,function()local function onsaved()local params = json.encode{reset_action="printtextureinfo", save_slot = 1}TheSim:SetInstanceParameters(params)TheSim:Reset()endSaveGameIndex:StartSurvivalMode(1, "wilson", {}, onsaved)end)elseLoadAssets(true)TheFrontEnd:ShowScreen(MainScreen(Profile))endendend)
endProfile = PlayerProfile()
SaveGameIndex = SaveIndex()Print(VERBOSITY.DEBUG, "[Loading profile and save index]")
Profile:Load( function() SaveGameIndex:Load( OnFilesLoaded )
end )--dont_load_save in profile

  

饥荒 死亡后不删存档的办法相关推荐

  1. win10系统更新后文件丢失的解决办法

    win10系统更新后文件丢失的解决办法 一.下载CCleaner的免费版Recuva软件 win10更新系统后,文件夹中的文件丢失了.百度了很久,一开始是参考了这个链接:win10系统更新导致文件丢失 ...

  2. office卸载后无法重装终极解决办法

    office卸载后无法重装终极解决办法 本来是轻松愉快的一上午,结果让office给毁了. 同事想装个新版本的office,我也是脑子一抽,用了office tool自带的卸载工具,结果就是没卸载干净 ...

  3. [Android] 转移“植物大战僵尸2”存档的办法,无需root

    作者:zyl910 查过了很多文章,都说需要root后才能转移存档.但很多时候是不能root的,此时该怎么办呢? 我研究了很久,最终找到了一种办法,无需root也能转移存档. 一.备份 我用的是联想手 ...

  4. 转 mvc项目中,解决引用jquery文件后智能提示失效的办法

    mvc项目中,解决用Url.Content方法引用jquery文件后智能提示失效的办法 这个标题不知道要怎么写才好, 但是希望文章的内容对大家有帮助. 场景如下: 我们在用开发开发程序的时候,经常会引 ...

  5. 定义了浮动元素后margin-bottom失效的解决办法

    2019独角兽企业重金招聘Python工程师标准>>> 虽然IE6慢慢的退出市场了,但是还是有必要了解一些兼容问题,让自己的知识有一个更好的沉淀.margin-bottom的bug是 ...

  6. 刷magisk模块后不能开机_联想启天商用电脑刷BIOS或维修换主板后 开机叫两声处理办法...

    联想启天商用电脑刷BIOS或维修换主板后 开机叫两声处理办法 主要症状是开机BIOS蜂鸣器叫两次短声,屏幕如下: 简单说说提示大致意思. Error 00CE Machine Type and ser ...

  7. ionic 安装 inappbrowser 插件后编译失败的解决办法

    layout: post title: ionic 安装 inappbrowser 插件后编译失败的解决办法 tags: description: 学习使用 ionic 框架开发 ios app 时遇 ...

  8. 借款人死亡后,贷款必须由家属偿还吗?

    这几天在网上看到一个网友发了这样一个问题,说在自己死之前,能不能在网上大量申请无抵押贷款,然后留给后代? 看了这填信息,估计很多网友都会灵光一现,这貌似留给后人一笔财产不错的选择,生前先大量在各个贷款 ...

  9. tomcat关闭后线程依然运行解决办法

    tomcat关闭后线程依然运行解决办法,设置线程为守护线程 守护线程与非守护线程 最近在看多线程的Timer章节,发现运用到了守护线程,感觉Java的基础知识还是需要补充. Java分为两种线程:用户 ...

最新文章

  1. NVIDIA DRIVE AGX开发工具包
  2. linux内核路由反向检查,Linux非对称路由
  3. 邻接表终极解析===和vector写法的区别
  4. XAML 编辑调试工具 Kaxaml
  5. Acwing第 39 场周赛【完结】
  6. Thread.sleep还是TimeUnit.SECONDS.sleep
  7. Linux socket编程,对套接字进行封装
  8. tablesorter,jquery
  9. 【Ubuntu^Java】Ubuntu下JDK环境变量的配置
  10. openwrt nas_【群晖】用群晖虚拟机安装New Pi(OpenWRT)软路由系统
  11. JPG如何免费压缩大小并且保证清晰度
  12. 传感器是新技术革命和当前信息社会的重要技术
  13. 计算机能不能升级固态硬盘,笔记本升级固态硬盘后会怎样?秒懂
  14. dlp监控开除员工_说一说DLP的那些事儿
  15. alanwang[GDOU] 简单排序法:冒泡排序法(谭浩强例题)
  16. 【杂谈】嵌入式软件数据结构的特点
  17. C++:endl的作用
  18. 汇编语言实现计算2的3次方
  19. 自兴人工智能——Python第二课(列表和元组)
  20. 计算机网络设备安装调试,网络设备安装与调试

热门文章

  1. php 删除xls文件,使用PHPExcel将xls文件转换为xlsx时出错
  2. 允许自行设计赛道之后,参赛同学都想到了什么呢?
  3. 第十六届智能车竞赛过程中都发生了什么:怎么感到今年更难呢?
  4. 用linux集成电路版图设计,集成电路版图设计 [陆学斌 主编] 2012年版
  5. java 裁剪 pdf_Java PDF 切割、截取、合并工具类、转图片等
  6. FTP 服务搭建及常用的命令脚本及传输协议基础普及
  7. git 你get了吗(git命令日常使用)
  8. 怎么装python的keras库_matlab调用keras深度学习模型(环境搭建)
  9. 桂林哪些职校可以学计算机,桂林市有几个中等职业学校
  10. 计算机网络 物理层链路层