Craft limit, Starship limit, Starfighter limit, Object limit

Want to edit the game, build your own craft and missions? Here you'll find help, tools, guides and people to discuss with.

Re: Craft limit, Starship limit, Starfighter limit, Object limit

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sat Oct 17, 2020 6:39 pm

Thanks for the answer! I had wanted to at least increase the amount of possible lasers from 256 to 512, but this blows it wide open. So I could have 192 flight groups AND 128 asteroids? But Asteroids are also classed as a flight group are the not?

Random Starfighter
Cadet 3rd Class
Posts: 34
Joined: Tue Oct 13, 2020 12:14 am

Post by Random Starfighter » Sat Oct 17, 2020 7:11 pm

FlightGroups are a separate thing from spawned objects, tied more closely to mission logic. When a FG is spawned into the mission, it depends on what kind of object it is. So a craft FG will spawn into the Craft section, counting towards the vanilla limit of 96 craft per region. Meanwhile an asteroid FG will spawn into the Space Object section, counting toward the 128 Space Object limit. But yes, they're both FlightGroups and both count toward the 192 FG limit in the mission file.

I can look into increasing the Space Object count for more asteroids. It didn't work very well when I tried it in XvT, causing some visual artifacts. But it's worth a try in XWA.

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sat Oct 17, 2020 7:23 pm

Awesome, thanks for the explanation :) Certainly separating out things like asteroids could be useful in populating a mission with a wider area of asteroids instead of travelling a few km out to be clear of it.

Random Starfighter
Cadet 3rd Class
Posts: 34
Joined: Tue Oct 13, 2020 12:14 am

Post by Random Starfighter » Sat Oct 17, 2020 8:01 pm

To increase the number of Space Objects, originally 128 per region, to something like 256:

Code: Select all

At offset 14CD3, replace C1E007 with C1E008
7 is 128 objects, 8 is 256, 9 is 512, etc. Adjust however you want. Since they're not commonly used it may not be necessary to go super high. When the game is performing frame updates, it has to loop over the entire allocated section, whether there's something there or not. That applies to craft and projectiles as well. So if performance is a concern, it's something to keep in mind.

As far as I can tell it's working without any problems. Although having lots of asteroids on screen, besides adding to visual clutter, does contribute to rendering slow-down. More stuff to test.

For mines, they spawn in a grid. So if you assign a mine FG with 8 craft per wave, they spawn an 8x8 grid for 64 total.
For asteroids, they randomly spawn around their starting waypoint. If you assign an asteroid FG with 8 craft per wave, it randomly generates 8 asteroids of varying size and distance.

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sat Oct 17, 2020 8:39 pm

Thanks mate. I noticed mines actual spawn numbers depend on the difficulty level you set. Lets just assume a single mine, then easy would only spawn the 1 mine, medium spawns 2, hard spawns 3. Also if I simply wanted to increase projectiles to 512 instead of something stupidly high, what would be the offset for that? Is that the same as above or a different code?

Random Starfighter
Cadet 3rd Class
Posts: 34
Joined: Tue Oct 13, 2020 12:14 am

Post by Random Starfighter » Sat Oct 17, 2020 9:17 pm

Difficulty shouldn't matter for mines.

For projectiles, same place, different value. This gives you 512 projectiles.

Code: Select all

At offset 14C68, replace 750BBA1000 with B800020000
At offset 14C6D, replace 0000 with EB0A

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sat Oct 17, 2020 9:27 pm

Random Starfighter wrote:
Sat Oct 17, 2020 9:17 pm
Difficulty shouldn't matter for mines.
.
It shouldn't but it does for some reason :D This behaviour is the same in TIE Fighter, harder difficulty spawns more mines.

Random Starfighter wrote:
Sat Oct 17, 2020 9:17 pm

For projectiles, same place, different value. This gives you 512 projectiles

Code: Select all

At offset 14C68, replace 750BBA1000 with B800020000
At offset 14C6D, replace 0000 with EB0A
Awesome, thank you! :)

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Sat Oct 17, 2020 9:50 pm

This is just friken awesome.... :)

So, unfortunately being arrays, while logical, doesn't seem to lend itself to any enhancement (tied to single thread cpu).

then again... maybe a hook could take every second entry and process it on a second cpu leaving only half the number for the original game to process.

Trev

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Sun Oct 18, 2020 9:12 am

Great! So having more than 6 wingmen per FG for AI FG's would be a great example of using the xwa_hook_mission_tie hook to assign FG texture maps. Asteroid fields would need LOD meshes for performance for sure.
.
Random, have a related question. 1) I know how to make Asteroids targetable in the CMD screen and destroyable by just changing a couple of offsets, the latter to that of a mine type object. The problem is their formation then becomes like a grid similar to the mines and if they take one laser hit, poof! Do you know to properly make them targetable and break up into pieces like a starship, station, and other "normal" object attributes ?
.
2) When enabling RotartyGunTurret meshes on starships, we know right now there is a limit of 16 RotaryGunTurret meshes with a maximum of 2 laser hardpoints per mesh, for any .opt model. Do you have any ideas on how to increase the possible number RotaryGunTurret meshes? Most starship models here have never utilized that feature, but the trade off is we get more laser hardpoints that are mirrored on both sides of a starship, up to 128 or something like that, instead of just 32. But they fire from the hull meshes or static turret meshes. Not as realistic.
.
3) Holy grail question everyone has asked for years... just looking in the Strings.txt file, I believe their is a limit of around 223 fixed craft slots, each with their own unique stats, some categorized by type such as starfighters, freighters, starships, stations, etc. Any clever ideas on how to expand on that to make an unlimited database of unique slots that could be dynamically added to and used for any given mission file? I would assume no, but just asking. Thanks :-)
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

Random Starfighter
Cadet 3rd Class
Posts: 34
Joined: Tue Oct 13, 2020 12:14 am

Post by Random Starfighter » Sun Oct 18, 2020 6:35 pm

I'm speaking from XvT experience here, but basic objects don't have hitpoints, so I'm not sure if there's any way around "one hit kill" without making them spawn in as a craft. If that could be accomplished, it might be possible to have fancier explosions too. But that would be a much more complex patch. I can make asteroids to be merely destructible like mines in XvT, but I don't know where to look in XWA.

No idea about the turrets. I wouldn't know where to begin, either. All I know is there's a limit of 50 mesh components and what looks like 16 active turrets. XvT was the same way.

Yes, the holy grail. These are all fixed-length arrays embedded into the game executable. Resizing or moving them would be a monumental task. The best idea I can think of would be to hook into the mission loading functions and hot-swap entire elements of the array with something else. Kind of like how the hangar hooks can do different things for each mission.

I'm really not very familiar with XWA's coding. Sorry this is all outside of my area of expertise...

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sun Oct 18, 2020 7:25 pm

Random Starfighter wrote:
Sun Oct 18, 2020 6:35 pm

Yes, the holy grail. These are all fixed-length arrays embedded into the game executable. Resizing or moving them would be a monumental task. The best idea I can think of would be to hook into the mission loading functions and hot-swap entire elements of the array with something else. Kind of like how the hangar hooks can do different things for each mission.
Is this what the hooks actually do? Replace entire sets of code by calling them instead of the base code? I'm not a coder, best I can do is manipulate it when I understand what some things do :D

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Sun Oct 18, 2020 10:26 pm

Hooks replace game code with new code, generally at the function level (that is, they replace original-game subroutines with new versions). That's why they're .dlls. As such, they can do very nearly anything; the trick is understanding the engine enough to know how to do what you want to do.

I've long thought that while circumventing the craft slot limit outright may be too complex a change to effect, Random's proposal may be tenable. A hook that runs during mission initialization should be able to rewrite the in-memory craft table using a mission-specific craft list, taking craft stats from individual craft text files (probably xml for this kind of data). In addition to that, the info loaded dynamically from the various files (strings.txt, .dat files for ship icons, etc.) would all have to be located and similarly reloaded from craft-specific files. Then there would be various side effects on areas of the game outside the flight engine to address - player stats, the tech room, multiplayer synchronization, maybe others.

By the way, thanks for dropping in, Random! Exciting stuff.

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Sun Oct 18, 2020 10:45 pm

So in theory, if someone had the knowledge, time and patience, they could rewrite the imuse code or at least make it... better? Perhaps even support higher quality sound like mp3s :D

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Mon Oct 19, 2020 4:11 am

Kieran, that's pretty much what I'm aluding to. Swapping out the strings.txt file with another one temporarily on a per mission basis. No need to change slots stats. For example using corvette slot and substituting with a hammerhead corvette. Crafts that can share reasonable and similar stats already defined in original slot. Just keeping it simple.
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

User avatar
keiranhalcyon7
Lieutenant JG
Posts: 599
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Mon Oct 19, 2020 6:23 am

I believe that can already be done with the mission objects hook.

User avatar
JeremyaFr
XWAU Member
Posts: 3921
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Oct 20, 2020 4:16 pm

WIP

Hello,
To make testing more easier, I've included the patch in a hook.

xwa_hook_crafts_count_WIP_2010201745.zip
You do not have the required permissions to view the files attached to this post.

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Thu Oct 22, 2020 4:52 am

Thanks Jeremy.
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

User avatar
JeremyaFr
XWAU Member
Posts: 3921
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Wed Nov 04, 2020 2:54 pm

WIP

You can now define the crafts count in the config file.

xwa_hook_crafts_count_WIP_2011041545.zip
You do not have the required permissions to view the files attached to this post.

User avatar
Trevor
Lieutenant JG
Posts: 541
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Thu Nov 05, 2020 10:02 pm

Awsome, and yeah, very easy to test numbers now.

Trev

User avatar
JeremyaFr
XWAU Member
Posts: 3921
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Wed Mar 03, 2021 4:28 pm

WIP

Hello,
Here is new WIP version of the crafts count hook.

I've fixed a bug with the init code in the hook.

xwa_hook_crafts_count_WIP_2103031722.zip
You do not have the required permissions to view the files attached to this post.

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Thu Dec 30, 2021 7:01 am

JeremyaFr wrote:
Wed Mar 03, 2021 4:28 pm
WIP

Hello,
Here is new WIP version of the crafts count hook.

I've fixed a bug with the init code in the hook.


xwa_hook_crafts_count_WIP_2103031722.zip
@JeremyaFr would it be possible for you to publish the source code for this hook? There's a bug with the flight group friendly/enemy list displays when using multi-region missions.

User avatar
JeremyaFr
XWAU Member
Posts: 3921
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Fri Dec 31, 2021 5:30 pm

AngeI wrote:
Thu Dec 30, 2021 7:01 am
@JeremyaFr would it be possible for you to publish the source code for this hook? There's a bug with the flight group friendly/enemy list displays when using multi-region missions.
Hello,
I've uploaded the source code for the crafts count hook and for the tourmultiplayer hook.
These hooks are marked as WIP and are not downloaded with XwaHooksSetup.

User avatar
AngeI
Lieutenant JG
Posts: 523
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Fri Dec 31, 2021 6:23 pm

JeremyaFr wrote:
Fri Dec 31, 2021 5:30 pm
AngeI wrote:
Thu Dec 30, 2021 7:01 am
@JeremyaFr would it be possible for you to publish the source code for this hook? There's a bug with the flight group friendly/enemy list displays when using multi-region missions.
Hello,
I've uploaded the source code for the crafts count hook and for the tourmultiplayer hook.
These hooks are marked as WIP and are not downloaded with XwaHooksSetup.
Thank you!

Random Starfighter
Cadet 3rd Class
Posts: 34
Joined: Tue Oct 13, 2020 12:14 am

Post by Random Starfighter » Sat Jan 01, 2022 11:54 pm

JeremyaFr wrote:
Fri Dec 31, 2021 5:30 pm
Hello,
I've uploaded the source code for the crafts count hook and for the tourmultiplayer hook.
These hooks are marked as WIP and are not downloaded with XwaHooksSetup.
Thank you for the source code. I've made some modifications to fix a bug with the friend/enemy craft lists. My original solution to fix a crash was to stop checking craft beyond index 192, but this only allows the craft list to be visible in the first region because the other regions spawn their craft into higher index ranges.

This new modification is a proper fix to the craft list, allowing it to scan all craft instead of the first 192 slots, with additional array bounds checking to prevent overflowing and causing a game crash.

xwa_hook_crafts_count_SOURCE.zip
My project files are different but these are my changes:

craftlist.h/craftlist.cpp:
Contains one new hook function for the craft list filter, and its needed structure definitions.

hooks.h
Added two new locations to call hook functions.
Deleted the bad craft list patch, replaced with new patch. This calls the new function and contains bounds checking.

Code: Select all

DELETED:
	{ 0x0BFC61, "A1B8A37C00", "B8C0000000" },
	{ 0x0C0D63, "A1B8A37C00", "B8C0000000" },
	
ADDED:
	{ 0x0BFC13, "807C3204097447668B443202663DCB00743C663DCC007436663DCD0074308B443223", "57E817830E005985C0744389E825FFFF0000894C84404581FDC00000007440EB2D90" },
	{ 0x0C0D15, "807C3204097447668B443202663DCB00743C663DCC007436663DCD0074308B443223", "57E815720E005985C0744389E825FFFF0000894C845C4581FDC00000007440EB2D90" },
exe_edit.txt
I've added documentation for the patch code here, but also in rs_exe_edit.txt

And here's the final DLL.
xwa_hook_crafts_count_DLL.zip
You do not have the required permissions to view the files attached to this post.

User avatar
JeremyaFr
XWAU Member
Posts: 3921
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Jan 29, 2022 1:26 pm

UPDATE

Hello,
I've updated the crafts count hook.

I've added a fix from RS for the friendly and enemy craft lists.

Post Reply