[HARD-CODED] FTL: Hyperspace

Distribute and discuss mods that are functional. Moderator - Grognak
rous
Posts: 3
Joined: Mon Sep 07, 2020 2:47 am

Re: [HARD-CODED] FTL: Hyperspace

Postby rous » Sun Apr 11, 2021 7:07 pm

Hello,
I have some knowledge about C/C++ and such and recently decided to see how feasible it would be to mod FTL by patching the binary to i.e. add in new C++ functions or classes.
Can you explain how exactly this works technically i.e. what's the process that is gone through to add new code to this?
TheSwiftTiger
Posts: 68
Joined: Sun May 12, 2013 9:21 am

Re: [HARD-CODED] FTL: Hyperspace

Postby TheSwiftTiger » Sun Apr 18, 2021 12:45 pm

rous wrote:Hello,
I have some knowledge about C/C++ and such and recently decided to see how feasible it would be to mod FTL by patching the binary to i.e. add in new C++ functions or classes.
Can you explain how exactly this works technically i.e. what's the process that is gone through to add new code to this?


So there's 2 DLLs you need for Hyperspace: xinput1_4.dll and Hyperspace.dll
xinput1_4.dll is always loaded by the game for some XInput controller support that's not used, so that's just used to load Hyperspace.dll into the game.

Hyperspace.dll uses a backend built on a detours library (MologieDetours) to patch bytes at the start of subroutines during runtime with calls to our methods in Hyperspace.dll (called hooking).
Using the debugging symbols in FTL 1.6.9, we can define the classes in the game in our code as well as hook specific functions we need to change their behaviour, as well as being able to call functions in the game.
zeGman
Posts: 33
Joined: Fri Apr 16, 2021 6:48 pm

Re: [HARD-CODED] FTL: Hyperspace

Postby zeGman » Tue Apr 20, 2021 8:07 pm

G3PSx wrote:I’ve got a stupid Mac so can’t play around with this at all but the first thing that popped into my mind was to create the most illusive race of all.

GIANT Alien Spiders!!!

Multiverse added this into the game, has a chance to appear in any civilian or militia sector...
A station controlled by spiders...
kiester kid
Posts: 1
Joined: Wed Apr 21, 2021 6:06 am

Re: [HARD-CODED] FTL: Hyperspace

Postby kiester kid » Wed Apr 21, 2021 6:32 am

TheSwiftTiger wrote:

Code: Select all

 

- Added ih8ih8sn0w's infinite mode (enabled in hyperspace.xml)



How does this work? Odds are I just don't know what to look for, but I set <infinite enabled="true"/> in hyperspace.xml, re-ran SMM, and tried a run to see what the sector map looked like. This is what I got: https://imgur.com/a/75aGrx2
I'm sure it's just some cue I'm missing, but any input would be much appreciated. Loving the mod so far, lots of fun lore stuff to mess around with.

EDIT: Turns out I was editing the hyperspace.xml from Hyperspace.ftl, not the one included in Multiverse.ftl. Works as expected now that I'm editing the correct file.
Cheers!
TheSwiftTiger
Posts: 68
Joined: Sun May 12, 2013 9:21 am

Re: [HARD-CODED] FTL: Hyperspace

Postby TheSwiftTiger » Wed Apr 28, 2021 7:15 pm

Update 0.7

This update DOES NOT make the mod work on the latest version of FTL. You will have to downgrade to version 1.6.9 - the instructions for that are in the main post.

Changelog

Code: Select all


Custom Crew:
   - Stat boosts!
      > Modifiers can now be applied to certain crew stats
      > These modifiers have many conditions to choose from
      > Modifier sources include: augments, passive crew abilities and temporary crew abilities
      
   - Added <stunMultiplier> tag
   - Added <truePassiveHealAmount> tag
   - Changed <passiveHealAmount> and <healAmount> to be health/sec instead of medbays/sec
   - Can now transform crew by name (for some reason)

Custom Stores:
   - You can now make an event generate a custom store
   - Custom stores can have infinite pages of items
   - Items have custom characteristics, such as:
      > Price modifiers
      > Mystery items
      > Scaling price with sector
   - Can choose to remove hull repair/resource purchasing
   - Can have a purchase limit for a store
   - Custom store categories can have custom titles

Ships:
   - Ships with 2 or fewer weapon slots now have an autofire button
   - Ships without a weapon system can have a drone system without broken UI
   - Enemy ships can now have icons displaying certain properties
   - Can now force ships to be/not be auto ships

Events:
   - Items you get in an event can now be hovered over to see their stats
   - Added quests in nebula beacons and the Last Stand
   - Added quests that can only spawn in the current sector

Misc:
   - New "extra info mode" which gives extra information about certain aspects of the game (also has a UI button)
      > Currently includes:
         > Crew tooltips showing powers
         > Redesigned weapon tooltips
         > Numerical Weapon cooldowns
   - Hotkeys have been added for the console, speedhack key and more info button
   - Vanilla race definitions have been added to hyperspace.xml (but commented out by default to mantain vanilla functionality)

Fixes:
   - Crew can no longer transform while teleporting
   - Some janky crew AI has been fixed
   - Fix for nebula crashes in large mods (can cause weird generation though)
   - Fixed crash when going to the stats screen after a run
   - Fixed crew power activation when dying
   - Fixed ship arrows not working for mods with 100+ ships
   - Fixed exit beacon fleet dives having an ion storm
   - Fixed bombs sometimes not damaging your own systems
   - Fixed a vanilla bug with map generation that made names inconsistently change the random state, causing different outcomes for the same seed
   - Fixed a crash when crew with an animBase transform
   
Technical:
   - The game now runs in -directx mode by default - to switch to OpenGL, open the game with the -opengl launch command


Download link is on the main post
TheSwiftTiger
Posts: 68
Joined: Sun May 12, 2013 9:21 am

Re: [HARD-CODED] FTL: Hyperspace

Postby TheSwiftTiger » Sun May 02, 2021 2:36 pm

Update 0.7.1

This update DOES NOT make the mod work on the latest version of FTL. You will have to downgrade to version 1.6.9 - the instructions for that are in the main post.

Changelog

Code: Select all

Fixes:
   - Neutral ships with crew in the teleporter no longer teleport their crew to attack you
   - Crew name seeding actually fixed
   - Fixed some incorrect weapon attribute descriptions
   - Fixed rangedDamageMultiplier being a much larger value
   - Fixed enemy maximum ship hull
Weapons:
   - Redesigned tooltips now shows scrap value of item


Download link is on the main post
torbenbeta
Posts: 4
Joined: Tue May 18, 2021 8:47 am

Re: [HARD-CODED] FTL: Hyperspace

Postby torbenbeta » Tue May 18, 2021 9:16 am

Hello, I just registered to submit this bug report.

Bug description
The game screen remains black after placing hyperspace.dll and xinput1_4.dll in the game folder.

Steps to reproduce
    Get FTL version 1.6.9 via GOG Galaxy.
    Install FTL version 1.6.9. via wine/crossover.
    Unzip hyperspace.zip and place hyperspace.dll and xinput1_4.dll in the FTL folder.
    Run winecfg and override hyperspace.dll and xinput1_4.dll with native Windows
    Run wine FTLGame.exe

Expected behavior
The game loads and displays graphics.

Versions and configuration
OS: Linux
OS Version: Linux Mint Debian Edition 64 bit (LMDE4 Debbie)
Game Version: 1.6.9, via GOG Galaxy, for Windows [64-bit]
Wine Version: wine-4.0 (Debian 4.0-2).
Graphics Version: windowed
Mods loaded: [
Hyperspace
]

Additional context
The error message says “0009:err:d3dcompiler:compile_shader HLSL shader parsing failed.“
Full terminal output:

Code: Select all

Initializing Hyperspace...
Hyperspace initialized
Version: 1.6.9
Loading settings
Starting up
Loading text
Initializing Video
Video: 1280x720, windowed
Video Initialized
Renderer: Direct3D 11.0, feature level 11_0
Creating FBO...
0009:err:d3dcompiler:compile_shader HLSL shader parsing failed.“

Deleting xinput1_4.dll leads to normal startup of the orginal FTL version with the following terminal output:

Code: Select all

Version: 1.6.9
Loading settings
Starting up
Loading text
Initializing Video
Video: 1280x720, windowed
Video Initialized
Renderer: OpenGL version 3.0 (GL_VERSION: 3.0 Mesa 18.3.6)
Creating FBO...
Starting audio library...
0009:err:ole:CoCreateInstanceEx apartment not initialised
Audio Initialized!
Resource Preload: 4.336
Initializing animations...
Animations Initialized!
Loading Ship Blueprints....
Blueprints Loaded!
Initializing Sound Data....
Generating world...
Loading achievements...
Loading score file...
Running Game!
torbenbeta
Posts: 4
Joined: Tue May 18, 2021 8:47 am

Re: [HARD-CODED] FTL: Hyperspace

Postby torbenbeta » Sun May 23, 2021 10:44 pm

Well, after some trials and reading the very succinct and helpful stack-trace (as found in the crashlogs folder) I managed to solve the problem. The solution is far from pretty, is in my opinion haphazard and probably unreliable and still generates warnings but the game with hyperspace.ftl enabled loads (seed entering and showing functions, correct main screen displays) and multiverse without hyperspace.ftl enabled loads, saving and loading works, custom functions (separatist Engi's nano function) works too. What does not work are shops. They crash the game but not reliable. Reloading the game and assessing the shop again crashes at a different time or not at all.
EDIT: apparently the shop crash is connected to drones.

Solution:
Running the game via terminal and aborting via SIGTERM (ctl+c) generates a list of loaded modules in a log file. Inspecting that I sought out which version of d3dcompiler (cf. my last post where d3dcompiler threw the fatal error) is used. In my case it is d3dcompiler_47.dll. I ran several instances with different versions of d3dcompiler_??.dll (?? stands for 34 to 47) enabled via winecfg. That did not work but maybe explains why surprisingly in one logfile I once had d3dcompiler_46.dll loaded.

So, I downloaded d3dcompiler_46.dll (32 bit version) and d3dcompiler_47.dll (64 bit version) and put them in the FTLGame.exe folder where the hyperspace.dll and xinput1_4.dll files reside. Now the game runs as described above.

Open issue
I am far from sure, actually I have no inkling why this mix of 32bit and 64bit dll's is needed and if my wild screening of a working dll via winecfg has something to do with that? Furthermore, activating d3dcompiler_46 and _47 via winecfg. led to the same parser not found error described in the last post.
Having both as 64 bit versions did not work neither did both as 32 bit.
More reports from other users would be helpful.
Last edited by torbenbeta on Sun May 23, 2021 11:07 pm, edited 3 times in total.
Agrrox
Posts: 1
Joined: Thu May 06, 2021 8:41 am

Re: [HARD-CODED] FTL: Hyperspace

Postby Agrrox » Sun May 23, 2021 10:46 pm

Hello, can you please add native support for Mac and Linux? Is it difficult to make it support latest FTL versions?
TheSwiftTiger
Posts: 68
Joined: Sun May 12, 2013 9:21 am

Re: [HARD-CODED] FTL: Hyperspace

Postby TheSwiftTiger » Mon May 24, 2021 5:21 pm

torbenbeta wrote:Well, after some trials and reading the very succinct and helpful stack-trace (as found in the crashlogs folder) I managed to solve the problem. The solution is far from pretty, is in my opinion haphazard and probably unreliable and still generates warnings but the game with hyperspace.ftl enabled loads (seed entering and showing functions, correct main screen displays) and multiverse without hyperspace.ftl enabled loads, saving and loading works, custom functions (separatist Engi's nano function) works too. What does not work are shops. They crash the game but not reliable. Reloading the game and assessing the shop again crashes at a different time or not at all.
EDIT: apparently the shop crash is connected to drones.

Solution:
Running the game via terminal and aborting via SIGTERM (ctl+c) generates a list of loaded modules in a log file. Inspecting that I sought out which version of d3dcompiler (cf. my last post where d3dcompiler threw the fatal error) is used. In my case it is d3dcompiler_47.dll. I ran several instances with different versions of d3dcompiler_??.dll (?? stands for 34 to 47) enabled via winecfg. That did not work but maybe explains why surprisingly in one logfile I once had d3dcompiler_46.dll loaded.

So, I downloaded d3dcompiler_46.dll (32 bit version) and d3dcompiler_47.dll (64 bit version) and put them in the FTLGame.exe folder where the hyperspace.dll and xinput1_4.dll files reside. Now the game runs as described above.

Open issue
I am far from sure, actually I have no inkling why this mix of 32bit and 64bit dll's is needed and if my wild screening of a working dll via winecfg has something to do with that? Furthermore, activating d3dcompiler_46 and _47 via winecfg. led to the same parser not found error described in the last post.
Having both as 64 bit versions did not work neither did both as 32 bit.
More reports from other users would be helpful.


You could try running the game with the -opengl launch command, it might help since the crash seems directx related?