Page 3 of 4

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

Posted: Sat Oct 17, 2020 6:39 pm
by AngeI
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?

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

Posted: Sat Oct 17, 2020 7:11 pm
by Random Starfighter
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.

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

Posted: Sat Oct 17, 2020 7:23 pm
by AngeI
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.

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

Posted: Sat Oct 17, 2020 8:01 pm
by Random Starfighter
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.

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

Posted: Sat Oct 17, 2020 8:39 pm
by AngeI
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?

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

Posted: Sat Oct 17, 2020 9:17 pm
by Random Starfighter
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

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

Posted: Sat Oct 17, 2020 9:27 pm
by AngeI
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! :)

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

Posted: Sat Oct 17, 2020 9:50 pm
by Trevor
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

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

Posted: Sun Oct 18, 2020 9:12 am
by Bman
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 :-)

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

Posted: Sun Oct 18, 2020 6:35 pm
by Random Starfighter
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...

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

Posted: Sun Oct 18, 2020 7:25 pm
by AngeI
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

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

Posted: Sun Oct 18, 2020 10:26 pm
by keiranhalcyon7
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.

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

Posted: Sun Oct 18, 2020 10:45 pm
by AngeI
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

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

Posted: Mon Oct 19, 2020 4:11 am
by Bman
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.

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

Posted: Mon Oct 19, 2020 6:23 am
by keiranhalcyon7
I believe that can already be done with the mission objects hook.

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

Posted: Tue Oct 20, 2020 4:16 pm
by JeremyaFr
WIP

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

xwa_hook_crafts_count_WIP_2010201745.zip

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

Posted: Thu Oct 22, 2020 4:52 am
by Bman
Thanks Jeremy.

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

Posted: Wed Nov 04, 2020 2:54 pm
by JeremyaFr
WIP

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

xwa_hook_crafts_count_WIP_2011041545.zip

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

Posted: Thu Nov 05, 2020 10:02 pm
by Trevor
Awsome, and yeah, very easy to test numbers now.

Trev

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

Posted: Wed Mar 03, 2021 4:28 pm
by JeremyaFr
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

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

Posted: Thu Dec 30, 2021 7:01 am
by AngeI
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.

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

Posted: Fri Dec 31, 2021 5:30 pm
by JeremyaFr
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.

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

Posted: Fri Dec 31, 2021 6:23 pm
by AngeI
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!

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

Posted: Sat Jan 01, 2022 11:54 pm
by Random Starfighter
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

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

Posted: Sat Jan 29, 2022 1:26 pm
by JeremyaFr
UPDATE

Hello,
I've updated the crafts count hook.

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