[Request] Stranded: Alien Dawn

Ask about cheats/tables for single player games here
DarkriftX2
Noobzor
Noobzor
Posts: 14
Joined: Thu Nov 10, 2022 11:45 pm
Reputation: 3

Re: [Request] Stranded: Alien Dawn

Post by DarkriftX2 »

souldev7 wrote:
Tue Nov 08, 2022 10:39 am
-----------

SADEnabler_tool_src.zip

I do not intend to provide support, nor updates.
All source code included, so it's all yours. :)

--------------
Dont expect you to provide support or updates, but I did notice that when your DLC is enabled, I cannot start a new game because the max-survivors seems to be broken. The slider is empty (no min/max cant slide, etc). To create a new game I had to remove the DLC file from the folder, create a game, close game, put DLC file back and then restart the game. Just a little workaround.

I did look through the code on where I could set the max-survivors (it is set to 0 in there), but I am not experienced enough to know how to edit your existing packaged DLC file, then repackage it so I will leave that to those with more experience. For those without, my workaround above should get you by until then.

Phantom Flan Flinger
What is cheating?
What is cheating?
Posts: 4
Joined: Sun Oct 30, 2022 1:15 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Phantom Flan Flinger »

same for me sadly.

DarkriftX2
Noobzor
Noobzor
Posts: 14
Joined: Thu Nov 10, 2022 11:45 pm
Reputation: 3

Re: [Request] Stranded: Alien Dawn

Post by DarkriftX2 »

I can use the tool batch file to unpack the stuff in the game folders, but not stuff in the DLC folder. I am sure I can read through the batch to see how it works and find a way to unpack the DLC content and fix it, but honestly its more work than just moving the file out while I create a new game and moving it back in. Im sure someone with the correct knowledge will either fix it or use it to make similar items that will do what I want.

Chaisen
What is cheating?
What is cheating?
Posts: 3
Joined: Fri Oct 28, 2022 9:24 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Chaisen »

DarkriftX2 wrote:
Mon Nov 14, 2022 12:55 am
I can use the tool batch file to unpack the stuff in the game folders, but not stuff in the DLC folder. I am sure I can read through the batch to see how it works and find a way to unpack the DLC content and fix it, but honestly its more work than just moving the file out while I create a new game and moving it back in. Im sure someone with the correct knowledge will either fix it or use it to make similar items that will do what I want.
Here is the full Code of the autorun.lua from SADEnabler.hpk
Spoiler

Code: Select all

local SADEnabler={
	force_mod_window=false,
	use_max_survivors=true,
	max_survivors=0,
	original = {
		GetMaxSurvivorsCount = GetMaxSurvivorsCount
	}
}
rawset(_G, "SADEnabler", SADEnabler)

if FirstLoad then
end

function SADEnabler:GetMaxSurvivorsCount(scenario_id)
	if (SADEnabler.use_max_survivors and SADEnabler.max_survivors ~= 0) then   
		for key, scdef in pairs(ScenarioDefs) do
			-- seems to be unnecessary at this time. Global override below will work just fine..
			--scdef.StartingCharacters = SADEnabler.max_survivors;
		end
		return SADEnabler.max_survivors
	end

	return SADEnabler.original.GetMaxSurvivorsCount(scenario_id)
end


local function OptionsApply()
	local EnableDeveloper = GetAccountStorageOptionValue("EnableDeveloper")
	local EnableCheats = GetAccountStorageOptionValue("EnableCheats")
	local AlwaysLoadMods = GetAccountStorageOptionValue("AlwaysLoadMods")
	SADEnabler.max_survivors = GetAccountStorageOptionValue("MaxSurvivorsOverride")
	
	if (AlwaysLoadMods and not AccountOptions.LoadAllMods) then
		print('Enabled Mods Force Loading - for user account.');
		AccountStorage.LoadAllMods = true
		SaveAccountStorage(1000)
	elseif (not AlwaysLoadMods and AccountStorage.LoadAllMods) then
		AccountStorage.LoadAllMods = false
		SaveAccountStorage(1000)
	end
	
	if (EnableDeveloper and not Platform.developer) then
		Platform.developer=true;
	elseif (not EnableDeveloper and Platform.developer) then
		Platform.developer=false;
	end
	if (EnableCheats and not Platform.cheats) then
		Platform.cheats=true;
	elseif (not EnableCheats and Platform.cheats) then
		Platform.cheats=false;
	end
	
end


local function AccountReady()
	print('Account and SADEnabler ready.')
	OptionsApply();
end

local function ModDefsLoaded()
	--print('ModDefsLoaded')
	
	local AlwaysLoadMods = GetAccountStorageOptionValue("AlwaysLoadMods")
	-- the idea here is pretty simple. We only force the mod menu to show when a.) user isn't forcing load-all strategy, and b.) the game developers haven't pushed out the future DLC that enables modding. 
	-- the logic in source code clearly dictates a check for a DLC called "Modding". 
	-- so if it ever becomes true at boot up (aka time of this func running), then this code "self disables" so to speak. Since a better mod manager will then be available, rendering this moot.
	if (not AlwaysLoadMods and not g_AvailableDlc["Modding"]) then 
		SADEnabler.force_mod_window=true
		g_AvailableDlc["Modding"]=true
	end
end


-- this never gets called during game boot due to gamedeveloper source that blocks the event for DLC. And/or this thread becomes in orphan. Might be the latter actually.
-- we will have to run a thread during Reload event, to monitor for completion..
local function ModsReloaded()
end


local function adjustOptions() 
	if (OptionsCategories[#OptionsCategories].id=="X") then return end;
	
	table.iappend(OptionsCategories, {
	  {
		id = "X",
		display_name = T(8565, "X"),
		caps_name = "X",
	  },
	})

	table.iappend(OptionsObject.properties, {		
		{
		  name = "Enable Developer",
		  id = "EnableDeveloper",
		  category = "X",
		  editor = "bool",
		  default = false
		},
		{
		  name = "Enable Cheats",
		  id = "EnableCheats",
		  category = "X",
		  editor = "bool",
		  default = false
		},
		{
		  name = "Load All Mods",
		  id = "AlwaysLoadMods",
		  category = "X",
		  editor = "bool",
		  default = true
		},
		{
		  name = "Max Survivors",
		  id = "MaxSurvivorsOverride",
		  category = "X",
		  editor = "choice",
		  default = "off",
		  items = {
			{
			  value = 0,
			  text = "Default"
			},
			{
			  value = 5,
			  text = "5"
			},
			{
			  value = 6,
			  text = "6"
			},
			{
			  value = 8,
			  text = "8"
			},
			{
			  value = 10,
			  text = "10"
			}
		  }
		},
	});
end


local function DialogSetMode(dialogSelf, mode, mParam) 
	--SADEnabler:printtable(dialogSelf)
	--print('MODE('.. dialogSelf.Id .. '): '..mode)

	if (SADEnabler.force_mod_window) then
		if (dialogSelf.Id == "idModsUIDialog") then 
			if (mode=="") then 
				CloseDialog("ModManagerDialog")
				local pgm = GetDialog('PreGameMenu')
				pgm:SetMode("Main")
			end
		elseif (dialogSelf.Id == "idPreGameMenu") then
			if (mode == "Main") then 

			elseif (mode == "ModManager") then
				OpenDialog("ModManagerDialog")
			end
		end
	end

	if (mode == "Survivors") then -- Mission, Settings, Properties, Survivors
		local dlg_context = GetDialogContext(dialogSelf);
		--SADEnabler:printtable(dlg_context)
		--SADEnabler:printtable(dlg_context.game_rules)
		
		if (dlg_context.game_rules.MaxSurvivors) then
			SADEnabler.use_max_survivors=true
		else 
			-- disabled this feature.. since there's no point in putting it into game rules. Legacy thing here for posterity..
			--SADEnabler.use_max_survivors=false
		end
	end

end



-- this doesn't appear to function, despite the code seeming to be correct..
local function InjectModButton()
	--print("PreGameMenuOpen")
	
	local pgm = GetDialog('PreGameMenu')
	--SADEnabler:printtable(pgm)
	
	if (pgm.actions[#pgm.actions].ActionId == "idMods") then 
		return
	end
	
	local bottomBarHost = pgm.actions[#pgm.actions].host
	local bb_idbl_last = bottomBarHost.idButtonsList[#bottomBarHost.idButtonsList]
	--SADEnabler:printtable(bottomBarHost.idButtonsList)
	--SADEnabler:printtable(bb_idbl_last)
	
	bottomBarHost:AddAction(XAction:new({
		ActionId = "idMods",
		ActionName = "MODS",
		ActionToolbar = "bottommenu",
		ActionToolbarSplit = true,
		OnAction = function(action, host)
			OpenDialog("ModManagerDialog")
		end,
	}))
	
end
-- leaving this legacy code here for posterity. Don't see a point in doing this as a game rule, when it's already in the Options dialog as a global hook var stored at account level.
-- servers as a decent sample of implementing a custom GameRule checkbox. Noting that the value is only persisted for NEW games, as existing ones won't have the stored value.
local function addGameRules()
	--[[
	PlaceObj("GameRuleDef", {
	  description = "Set the max survivors to value assigned in Options menu",
	  display_name = "Unlock Max Survivors",
	  exclusionlist = {},
	  group = "Default",
	  id = "MaxSurvivors",
	  
	  effects = {},
	  
	  msg_reactions = {
	  
		PlaceObj("MsgReaction", {
		  Event = "OptionsApply",
		  Handler = function(self)
			
		  end
		}),
		
		PlaceObj("MsgReaction", {
		  Event = "DialogSetMode",
		  Handler = function(self, dialogSelf, mode, mParam)
			
		  end
		}),
	  }
	})
	--]]
end




local function Boot()
	print("SADEnabler is running")
	
	adjustOptions()
	--addGameRules()
end
local function Registration()
	OnMsg.ModDefsLoaded = function()
		ModDefsLoaded()
	end
	OnMsg.ModsReloaded = function()
		ModsReloaded()
	end
	OnMsg.DialogSetMode = function(dialogSelf, mode, mParam)
		DialogSetMode(dialogSelf, mode, mParam)
	end
	OnMsg.OptionsApply = function()
		OptionsApply()
	end
	OnMsg.ReloadLua = function()
		--print('ReloadLua')
		local old_onmsg = tostring(OnMsg.Autorun) -- ghetto detection approach.
		CreateRealTimeThread(function()
			Sleep(50)
			
			while Loading do
				Sleep(20)
			end
			
			Registration();
			Boot();
		end)
	end
	
	_G.GetMaxSurvivorsCount = SADEnabler.GetMaxSurvivorsCount
	--print('SurvivorCount Orig: '..tostring(GetMaxSurvivorsCount))
	--print('SurvivorCount New: '..tostring(SADEnabler.original.GetMaxSurvivorsCount))
end

local function Preload(self)
	CreateRealTimeThread(function() 
		while not g_ConsoleFENV do
			Sleep(150)
		end
		-- todo: code this file. Since it has access to a ready console, that may be of use for exposing something for easier hooking and eval scripting, in cheat engine.
		dofile(self.folder.."/console.lua", g_ConsoleFENV._G)
	end)
	CreateRealTimeThread(function()
		WaitMsg("AccountStorageChanged")
		while not AccountStorage do
			Sleep(50)
		end
		
		AccountReady();		
	end)
end

local function Postload(self) 
	g_AvailableDlc[self.name] = true
    --g_AccessibleDlc[self.name] = true
	
	Registration()
	Boot()
end



-- some helper funcs to expose globally...

function SADEnabler:printtable(table, indent)
  if (table == nil) then
	print('nil')
	return
  end
  print(tostring(table) .. '\n')
  for index, value in pairs(table) do 
    local temp = value
	if (value==nil) then
		temp = 'nil'
	--elseif (type(value) == 'table') then
	--	printtable(value)
	end
    print('    ' .. tostring(index) .. ' : ' .. tostring(temp) .. '\n')
  end
end
function SADEnabler:shallowcopy(orig)
    local orig_type = type(orig)
    local copy
    if orig_type == 'table' then
        copy = {}
        for orig_key, orig_value in pairs(orig) do
            copy[orig_key] = orig_value
        end
    else -- number, string, boolean, etc
        copy = orig
    end
    return copy
end
function SADEnabler:min(x, m)
    if not x or x < m then return m end
	return x
end
function SADEnabler:clamp(x, min, max)
    if x < min then return min end
    if x > max then return max end
    return x
end

-- todo: consider using a non-mod strategy, allowing users to simply drop LUA files into a target folder, and thus simplifying the footprint of work effort here. 
-- debatable. If the goal is to Mod stuff, then we should not do this, so as to align with developer track and online guides for surviving mars. 
-- need to verify the "AppData" reference here is fully mounted. There is a mounting operation somewhere that likely needs called first. (see Dlc.lua and Mod.lua)
-- also look into the svndeveloper/ prefix. Seems the devs already have a dedicated folder for exactly this purpose, using the original unpacked decrypted sources in full.
--dofolder('AppData/CustomLUA/');

return {
  display_name = T(8565,"SAD Enabler"),
  enabled = true,
  name = "SADEnabler",
  pops_dlc_id = "stranded_alien_dawn_enabler",
  pre_load = function(self)
	Preload(self)
  end,
  post_load = function(self)
	Postload(self)
  end,
  ps4_gid = 0,
  ps4_label = "SADEnabler",
  ps4_trophy_group_description = false,
  required_lua_revision = 227000,
  steam_dlc_id = 1234567
}

Chapi
Noobzor
Noobzor
Posts: 14
Joined: Mon Nov 14, 2022 6:07 am
Reputation: 15

Re: [Request] Stranded: Alien Dawn

Post by Chapi »

It looks like the first selection does not work.

Change this

Code: Select all

		{
		  name = "Max Survivors",
		  id = "MaxSurvivorsOverride",
		  category = "X",
		  editor = "choice",
		  default = "off",
		  items = {
			{
			  value = 0,
			  text = "Default"
			},
			{
			  value = 5,
			  text = "5"
			},
			{
			  value = 6,
			  text = "6"
			},
			{
			  value = 8,
			  text = "8"
			},
			{
			  value = 10,
			  text = "10"
			}
		  }
to this

Code: Select all

		{
		  name = "Max Survivors",
		  id = "MaxSurvivorsOverride",
		  category = "X",
		  editor = "choice",
		  default = 0,
		  items = {
			{
			  value = 0,
			  text = "Broken (Use next one)"
			},
			{
			  value = 4,
			  text = "4"
			},
			{
			  value = 5,
			  text = "5"
			},
			{
			  value = 6,
			  text = "6"
			},
			{
			  value = 7,
			  text = "7"
			},
			{
			  value = 8,
			  text = "8"
			},
			{
			  value = 9,
			  text = "9"
			},
			{
			  value = 10,
			  text = "10"
			},
			{
			  value = 30,
			  text = "all"
			}
		  }
then you will need to Change the Value in Settings to the next one. Looks like the first Choice is always broken.

DarkriftX2
Noobzor
Noobzor
Posts: 14
Joined: Thu Nov 10, 2022 11:45 pm
Reputation: 3

Re: [Request] Stranded: Alien Dawn

Post by DarkriftX2 »

Nice, that works. I repacked it (with a 2 at the end) and will upload here for anyone who doesnt feel like editing it.

This is just the original source provided by earlier with the changes from the post above mine added to it and re-packaged. I take zero credit for any of it except for the 2 minutes it took to zip it lol.
SADEnabler2.zip
(3.76 KiB) Downloaded 630 times

Airwane
What is cheating?
What is cheating?
Posts: 2
Joined: Thu Nov 17, 2022 1:28 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Airwane »

Hi Al glad to see that there is a command consol after all.
now I'm not good at coding and all that so I get the

Platform.cheats = true
return {


and where to place it but How to I make it permanent because I have to do this every time before launching the game.
I'm doing this with Visual Studio Code app

also why you guy are talking about Surviving mars lol it's confusing

Chapi
Noobzor
Noobzor
Posts: 14
Joined: Mon Nov 14, 2022 6:07 am
Reputation: 15

Re: [Request] Stranded: Alien Dawn

Post by Chapi »

You have to add write protection on LocalStorage.lua.

Surviving Mars is using the same Engine.

Airwane
What is cheating?
What is cheating?
Posts: 2
Joined: Thu Nov 17, 2022 1:28 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Airwane »

Chapi wrote:
Thu Nov 17, 2022 2:00 pm
You have to add write protection on LocalStorage.lua.

Surviving Mars is using the same Engine.
how do I do that?

Chapi
Noobzor
Noobzor
Posts: 14
Joined: Mon Nov 14, 2022 6:07 am
Reputation: 15

Re: [Request] Stranded: Alien Dawn

Post by Chapi »

Airwane wrote:
Thu Nov 17, 2022 2:07 pm
Chapi wrote:
Thu Nov 17, 2022 2:00 pm
You have to add write protection on LocalStorage.lua.

Surviving Mars is using the same Engine.
how do I do that?
right-click then properties.

BlackEagle
Novice Cheater
Novice Cheater
Posts: 21
Joined: Fri Sep 10, 2021 12:42 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by BlackEagle »

DarkriftX2 wrote:
Mon Nov 14, 2022 6:34 am
Nice, that works. I repacked it (with a 2 at the end) and will upload here for anyone who doesnt feel like editing it.

This is just the original source provided by earlier with the changes from the post above mine added to it and re-packaged. I take zero credit for any of it except for the 2 minutes it took to zip it lol.

SADEnabler2.zip
what i must do with it?!

Omani2999
What is cheating?
What is cheating?
Posts: 1
Joined: Mon Nov 21, 2022 11:28 am
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Omani2999 »

souldev7 wrote:
Sun Oct 30, 2022 12:16 am
It's the same as [Surviving Mars] by same company, except would appear mods are disabled.
The loader apparatus is there, and it uses same bootstrap. But obviously not shown in the UI, nor does it appear to load metadata files.

So instead, best way to tweak the insanity of this game to some degree, is to unpack the HPK, decompile the LUA, modify it, and pack it back up.
This 100% worked for me, was easy enough to do with GREP scans to find what I wanted.

For instance, you can increase max # of survivors when starting a game:

Code: Select all

--   ./Lua/Lua/__const.lua
DefineConst({
  group = "Gameplay",
  id = "MaxSurvivorsCount",
  value = 6
})
-- ./Lua/Lua/PreGameSetup.lua
function GetMaxSurvivorsCount(scenario_id)
  local scenario_def = scenario_id and ScenarioDefs[scenario_id]
  return const.Gameplay.MaxSurvivorsCount
end
Or double the speed of movement of your survivors (1000 = 1, so 2000 = 2; same applies for all integers in the game, if you search for "movement_adjust" you'll see it's a multiplier reduced by 1k affecting a 100% scaled integer.. so it's like: 0.25 * 1 = 25% where .25 is dynamic based on condition of the unit):

Code: Select all

-- ./Lua/Lua/UnitComponents/UnitHealth.lua
  invulnerable = false,
  is_falling = false,
  next_vomit_time = false,
  is_vomiting = false,
  movement_adjust = 2000
Or speed up bandage craft speed:

Code: Select all

-- ./Data/Recipe.lua
Activity = "Crafting",
  ActivityDuration = 10000,
  ActivityXPGrade = "Crafting_Low",
  BuildCategory = "CraftResources",
  Description = T(746560224749, "Make bandages from cloth pieces."),
  DisplayName = T(751595636010, "Bandages (scrap cloth)"),
Or let people chill the F out a little:

Code: Select all

-- ./Lua/Lua/UnitComponents/UnitRelaxation.lua
category = "Relaxation",
      id = "RelaxationLossPerDay",
      name = T(241929465459, "Daily relaxation loss"),
      editor = "number",
      modifiable = true,
      scale = 1000,
      default = 30000
---------------------

So in order to do that, you need the HPK extractor.. [Link]
Then you need a decompiler. I used the Mod package here: https://www.fearlessrevolution.com/surv ... ?tab=files
(which is just a powershell script to extract everything)
Combined with unluac: [Link]

I found that the Victor Vran bytecode header situation applies here. Given that they switched to lua 5.3.
Powershell script handles that for you when executing hpk.exe.
However when repackaging I found that you HAVE to disable compression or the game just crashes, or fails to load the main menu runtime (step 4 below).
That could just be a switch for lz4 algorithm that needs tweaked a bit. Not sure, but uncompressed works just fine for me.

So the process is like so:
1. Follow the guide for the NexusMod powershell script (you need java, unluac, and hpk.exe sitting in the root folder of the game. set exec policy, and run it)
2. Now you have extracted everything (__Unpacked folder). __Unpacked/Packs/Lua and ./Data are of interest.
3. Modify whatever you want.
4. Pack it up using the command: (specify the folder to repackage, ex. "Lua", or "Data")

Code: Select all

hpk create --cripple-lua-files --dont-compress-files Lua Lua.hpk


and copy that to C:\Program Files (x86)\Steam\SteamApps\common\Stranded Alien Dawn\Packs (and overwrite, after you backup original obviously).
Test that game boots and no corrupt decompilation/repackaging, & off you go.

I still haven't been able to find certain things, like % chance of Expedition resulting in a new recruit (I'm on year 8 and still 5 people; rough as hell with 100+ unit enemy spawns. I like it tough, just not without hope for the future :P ).
I'm also very curious about fixing the pathing (character runs back and forth across a field to gather, when it could rather target the closest pickup), and spotted several files in there relating to it. So far looks like potentially a simple array sort will resolve.

Anyway - good luck to he who reads, and he who doesn't too.
How to read data from a file in Lua ?
Image

toffi86ch
What is cheating?
What is cheating?
Posts: 1
Joined: Mon Nov 21, 2022 4:59 pm
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by toffi86ch »

can confirm that editing data.hpk works with savegame. start a new game with original data.hpk, make a save game and overwrite the data.hpk with the selfpacked hpk. done modification with decay timers, stacksizes, energyconsumption/production and humantraits. all works well. its kinda a cheaty one. had blackscreen at lunch with lua.hkp editing.

Chapi
Noobzor
Noobzor
Posts: 14
Joined: Mon Nov 14, 2022 6:07 am
Reputation: 15

Re: [Request] Stranded: Alien Dawn

Post by Chapi »

Now the Mod Editor and the ModManager is activated in Developer mode.
But when you Enable a mod it will not save the Enabled mods.

Violation
Noobzor
Noobzor
Posts: 9
Joined: Thu Feb 27, 2020 4:24 am
Reputation: 0

Re: [Request] Stranded: Alien Dawn

Post by Violation »

anyone know what the cheat for god mode or heal all is via the cheat menu? I wasn't watching and almost killed my party on fast speed and didn't notice a bug raid.

Post Reply

Who is online

Users browsing this forum: YandexBot