Hooks

Need help editing the game? Check for help here!

Moderators: Darksaber, General_Trageton, Forceflow

Re: Hooks

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 9464
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Sun May 20, 2018 7:03 pm

I like the idea, but I don't see how that would work, as far as I know you can't control what mesh is visible depending on FG

If it was possible you would be able to have the Xwing, Awing, Bwing and Ywing if one package and just select which was visible by which Flghtgroup you selected

The Partisan, nearly every texture would have to be replaced for the FG, the same problem as I've have explained above

The Krayt Xwing are really old textures as are the squadron xwing with the logo on the side, the textures would have to be updated really.

The easiest and most possible would be to modify the generic xwing as you would be replacing/adding less textures, just the outer wing textures and the sides of the fuselage perhaps the Astromech, but the astromech would have to be the same mesh.

I'm still confuse as to how this new Mission Hook works though

If FG is the number of Flightgroups (As in the texture Flightgroups, and say we still have the standard 4 Red, Yellow Blue and Green) then the value would be either 1, 2, 3 or 4 correct? So what it the "Markings" value for?

If I'm wrong, could a better explanation be given please
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

Bman
Lieutenant JG
Posts: 503
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Mon May 21, 2018 1:36 am

.
Last edited by Bman on Sun Jul 08, 2018 8:09 pm, edited 1 time in total.
W-I-P: ISD-II, XQ-1 Platform1, New Escort Carrier Hangar, & Misc.

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon May 21, 2018 3:50 pm

Hello,

The "fg" and "markings" values start with 0.

"fg, 0" refers to the first flight group in .tie file.
For backdrops, the marking value is ignored.

With the standard 4 Red, Yellow, Blue and Green, the marking value will be 0, 1, 2 or 3.

In AlliED,
the Red color refers to marking 0,
the Gold color refers to marking 1,
the Blue color refers to marking 2,
the Green color refers to marking 3,
others markings can't be selected.

Here is how the marking is overriden:

Code: Select all

int TieHook(int* params)
{
	const auto LoadMission = (int(*)(const char*))0x420300;
	const char* fileName = (const char*)params[0];

	if (LoadMission(fileName) == 0)
	{
		return 0;
	}

	std::string path = GetStringWithoutExtension(fileName);
	path.append(".txt");

	auto lines = GetFileListValues(path);

	if (lines.empty())
	{
		return 1;
	}

	for (const auto& line : lines)
	{
		if (line.size() < 4)
		{
			continue;
		}

		const auto& group = line[0];

		if (_stricmp(group.c_str(), "fg") == 0)
		{
			int fg = std::stoi(line[1]);

			if (fg < 0 || fg > 192)
			{
				continue;
			}

			const auto& element = line[2];
			int value = std::stoi(line[3]);

			if (_stricmp(element.c_str(), "markings") == 0)
			{
				s_XwaTieFlightGroups[fg].Markings = value;
			}
		}
	}

	return 1;
}

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 9464
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Mon May 21, 2018 4:10 pm

Ah right I get it, I had it arse ways upwards lol

Thanks Jeremy

Oh and Bman
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon May 21, 2018 4:46 pm

Darksaber wrote:
Sun May 20, 2018 7:03 pm
I like the idea, but I don't see how that would work, as far as I know you can't control what mesh is visible depending on FG

If it was possible you would be able to have the Xwing, Awing, Bwing and Ywing if one package and just select which was visible by which Flghtgroup you selected
The game engine supports rendering a different mesh based on the flightgroup color.

As a test, I've modified the X-Wing to regroup the 4 wings in a single switch node. In the image below, each wing is rendered based on the flightgroup color.

meshes_switch.png
meshes_switch.png (22.56 KiB) Viewed 767 times

The problem is that there is no opt editor that supports that. I've modified the X-Wing by directly modifying the file nodes with my opt library.

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 9464
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Mon May 21, 2018 5:49 pm

That's good to know, it's something you might be able to add to XwAOptEditor or the other one in time :)
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

User avatar
keiranhalcyon7
Cadet 1st Class
Posts: 102
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Tue May 22, 2018 6:16 am

That's awesome! And here I thought it was going to be an inefficient kludge like applying transparent textures to the meshes that you don't want to be visible for a given variant.

Question - is there any possibility of applying different fg colors to different ships in the same fg?

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue May 22, 2018 12:08 pm

Note that the ships stats will not be different (only the geometry and textures are selectable). You can't set different stats for different ships in the same craft slot.

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat May 26, 2018 8:11 pm

SAMPLE

Hello,
Here is an example showing how to setup turret/gunner for a starfighter.
As a test, I choose to edit the Y-Wing.

- Edit the OPTs.
Rename YWing.opt to YWing_.opt
Rename YWingExterior.opt to YWingExterior_.opt
Make a copy of FamilyTransport.opt and name it YWing.opt
Make a copy of CorellianTransportGunner.opt and name it YWingGunner.opt
Open YWingGunner.opt with XwaOptEditor and modify the textures so that you can distinguish the two Gunner OPTs.
Create a text file named YWingWeaponRate.txt with the following content:

Code: Select all

DechargeRate = 4
RechargeRate = 2
- Edit the craft stats with MXvTED.
Backup XWingAlliance.exe
Select the Y-Wing (n° 2).
In the Cockpit tab:
Gunner 1 = 0, 250, 19
Turret 1 Activated = 317
Pod1 X Orientation = -16384
Pod2 X Orientation = 16384
Arc1 = 12040
Arc3 = 17308
Click Write.

- Launch XWingAlliance.exe and test the Y-Wing.

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Jun 11, 2018 6:27 pm

UPDATE

Hello,
I've updated the main hook (dinput.dll) to be compatible with the Windows' Data Execution Prevention (DEP).
See viewtopic.php?f=10&t=11902.

Please redownload xwa_hook_main.zip

User avatar
Driftwood
Lieutenant Commander
XWAU Member
Posts: 1284
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Sun Jul 08, 2018 7:20 pm

Jeremyah, I'm having a bug with the turret hook all of a sudden and I cannot figure out why.

So as you know I've been working on updating the shuttle with a cockpit and rear player turret gunner opt. Last week everything was working fine. The default turret was assigned and functioning correctly for both slots 58, 59, 60, and 34 (Yt1760 and all the stock YT series craft) plus slot 50 (updated shuttle) with the new shuttle gunner opt.

Now all of a sudden things are not working correctly.

The issue I'm having is that the game is suddenly replacing the CorellianTransportGunner opt for slots 58, 59, 60, and 34 with the shuttlegunner opt when it is installed in the flightmodels folder, but with the YT1300 POV and arcs, while the shuttle in slot 50 is loading the stats for the shuttle gunner POV / arcs as well as loading the shuttle gunner turret opt.

I've done a clean install, twice, based on DSUCP and REBCP, and updated all the hooks to current versions manually after installing the Luxury Yacht and Rebel Platform updates to ensure everything is up to date as I believed at first that I messed something up.

I have also manually input the shuttle turret stats into MXvTED rather than loading a .shp, assuming that the .shp file may be corrupted. Just in case.

So here's the thing, prior to this week (haven't loaded the game in a week or so till today), the custom turret for the shuttle worked fine, as did the corellian transport opt. Both worked independently, and correctly with no issue.

I had the shuttle configured as such:
Turret 1 activated: 50 Turret On

This worked fine. It called the shuttlegunner opt.

The Corellian transport series craft (including DTM's YT1760) were configured as
Turret 1 (and/or 2 depending on craft) activated: 317 Turret On.

This also worked fine. It called the corelliantransportgunner opt.

Now, this week something has happened.
I had the shuttle configured as such:
Turret 1 activated: 50 Turret On

Now it calls the Shuttle (Base) opt for the turret mesh

The Corellian transport series craft (including DTM's YT1760) were configured as
Turret 1 (and/or 2 depending on craft) activated: 317 Turret On.

Now it calls the Shuttlegunner opt for the turret mesh

I also discovered upon reinstalling my Shuttle base opt did not have a gunner hardpoint, so I added that (again, don't know why it was missing)
I still had the shuttle configured as such:
Turret 1 activated: 50 Turret On

Still it calls the Shuttle (Base) opt for the turret mesh.

I check the YT1300s
The Corellian transport series craft (including DTM's YT1760) were configured as
Turret 1 (and/or 2 depending on craft) activated: 317 Turret On.

Still calls the Shuttlegunner opt for the turret mesh

So I switch back to the shuttle and reconfigure it to
Turret 1 activated: 317 Turret On

And now it calls the shuttle gunner mesh correctly. Problem solved!

However, I check the Corellian transports again, and they are still calling the shuttle gunner mesh instead of the correct corelliantransportgunner opt.

For some reason the stupid game is now overriding the default gunner opt for all the YT transports with the new custom shuttle one if it is in the flightmodels folder for no discernible reason. It never did that before, and it continues to do it until I delete the shuttlegunner opt.
The other oddity of course is that prior to this I discovered I could set the turret activation for slot 50, to 50 Turret On instead of 317 Turret On and it would call the shuttle gunner opt properly, whereas now it calls the base opt if configured as such.

EDIT # four thousand and fifty....

Okay so there's definitely a bug with the hook. But I'm not sure that it's game breaking provided you only have one player turret craft in a mission, though perhaps there's a fix for this now that I've isolated things further.

I am testing this in skirmish/solo and I had both the YT1300 and the Lambda shuttle in the mission, lambda in slot 1 on team 1, and Yt1300 in slot 2 on team 1.

I put the player in the lambda. Loaded up the turret, displayed fine.

I exited the mission and put the player into the YT1300, the game loaded up the shuttlegunner turret instead, with the YT1300 arc/POVs.

I removed the Lambda shuttle from the team and put the player in the yt1300 again, the corelliantransportgunner opt loaded up just fine.

I removed the YT1300 from the mission, added the lambda and put the player in the lambda and loaded up the mission, the shuttlegunner opt loaded up fine.

SO, I conclude that everything is in fact configured 100% correctly on my end in all areas and everything works, PROVIDED that there are not two ships with player turrets in the same mission. For some reason the game overrides the corelliantransportgunner turret with whatever customgunner turret is installed. It does not however, seem to work the other way around.

Perhaps there can be a way to denote what opt loads what gun turret via text file config to avoid this bug if one wanted to have a skirmish with two turreted craft/in multiplayer?
Last edited by Driftwood on Sun Jul 08, 2018 10:54 pm, edited 7 times in total.

Bman
Lieutenant JG
Posts: 503
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Sun Jul 08, 2018 8:19 pm

The Lambda shuttle with a working rear turret mesh ... nice! Have you made the shuttle "Flyable" in the text file ?
W-I-P: ISD-II, XQ-1 Platform1, New Escort Carrier Hangar, & Misc.

User avatar
Driftwood
Lieutenant Commander
XWAU Member
Posts: 1284
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Sun Jul 08, 2018 8:59 pm

Of course. Everything is configured correctly, but the hook is calling the wrong meshes all of a sudden. It's very strange. At first I thought i corrupted something, but since reverting to a fresh install did nothing to resolve the issue I'm wondering if this is a bug since the last couple hook, main hook perhaps, updates.

The really strange thing is that the shuttle slot is behaving like the custom gunner opt doesn't exist even though it does and is named correctly, and that conversely the default gunner opt is being replaced by the shuttle gunner opt instead as default. It makes no sense since nothing has changed regarding that opt or the corresponding other slots that should be calling the default gunner opt.

Literally only the shuttle slot turret data has been altered, and the file structure for the shuttle opts are set up correctly, so by all rights it should work as intended, and nothing should be interacting with the default gunner opt, or corresponding slots as data and files pertaining to them have not been touched.

:kopfwand:

EDIT: See above re-re-re-re-re-edited post above Bma's for my conclusions regarding the issue I've encountered and "somewhat fixed".

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Jul 09, 2018 3:49 pm

The hook replaces "CorellianTransportGunner.opt" with "[Player]Gunner.opt" if it exists. It doesn't work when there are multiple players with custom gunner. It seems that the first custom gunner is loaded.
As a workaround, you can place the different gunner opts to different slots.

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Aug 11, 2018 4:11 pm

UPDATE

Hello,
Here is a tool to easily download the hooks.
XwaHooksSetup.zip
(4.63 KiB) Downloaded 17 times
Usage:
1) Run XwaHooksSetup.exe.
2) It will create a directory named "Hooks" and download the hooks from GitHub into this directory. To redownload the hooks, delete the directory "Hooks".
3) It will extract the hooks into a directory named "Setup".
4) Copy the content of the "Setup" directory in your XWA install directory.

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 9464
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Sat Aug 11, 2018 6:21 pm

Nice :D
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

User avatar
Driftwood
Lieutenant Commander
XWAU Member
Posts: 1284
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Tue Sep 04, 2018 6:33 am

I updated via the hook downloader and copied all the files over.

Triangling to infinity patch doesn't seem to work anymore, and the s-foil one is broken too by the look of it.

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 9464
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Tue Sep 04, 2018 7:26 am

You'll have to first remove the Triangling to infinity from the exe using XWA Exe Patcher
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

Bman
Lieutenant JG
Posts: 503
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Wed Sep 05, 2018 2:32 am

Yep, I saw DTM post that too. At top of the list, click "Restore" as DS just mentioned. Then, in the .xml file, you can edit it with notepad and either delete the first patch section (two lines of code plus the opening Patch array header and Patch trailer, or just put a semi-colon " ; " to comment out these four lines then save. The compiler will ignore anything that follows a semi-colon.
W-I-P: ISD-II, XQ-1 Platform1, New Escort Carrier Hangar, & Misc.

JeremyaFr
Lieutenant
XWAU Member
Posts: 851
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Thu Oct 11, 2018 4:22 pm

TEST
xwa_hook_backdrops_test.zip
(94.36 KiB) Downloaded 6 times

Hello,
Here is an updated test version of the backdrops hook.
Now you can replace dat images for any missions.

Suppose that the mission is "[MissionDir]\[Mission].tie".
To replace dat images, create a file named "[MissionDir]\[Mission]_Resdata.txt" and list your new dat files.
The format of this file is the same as "Resdata.txt".

User avatar
DTM
Lieutenant Commander
XWAU Member
Posts: 1078
Joined: Tue Apr 22, 2003 11:01 pm
Contact:

Post by DTM » Thu Oct 11, 2018 6:22 pm

Wow! I will test the new hook this week end!
Thanks to your update it will be possible:
- To introduce new different starfields in different reagions of custom missions.
- To create new sky and athmosferic custom missions without distance limitations
- To create low and high orbit scenarios

All options above have been already tested, but they have been nevere applied, because it was important to keep the original planet.dat file, that is randomly loaded in the skirmish missions. Changes to the original planet.dat are not well accepted by the comunity. Now it will possible to create custom mission using multiple dat files. Excellent. Thanks Jeremya!

MTD industries
WIPs: Fixing missions and new editing for the REBCP, Resistance Mon Calamari Cruiser, New advanced base OPT files for all playable XWAUP crafts.

Bman
Lieutenant JG
Posts: 503
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Fri Oct 12, 2018 1:09 am

Awesome, thanks for this. Do you think it will be possible to allow for true 32-bit colored static images, yet ?
Last edited by Bman on Fri Oct 12, 2018 1:37 am, edited 1 time in total.
W-I-P: ISD-II, XQ-1 Platform1, New Escort Carrier Hangar, & Misc.

User avatar
Driftwood
Lieutenant Commander
XWAU Member
Posts: 1284
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Fri Oct 12, 2018 1:20 am

What about animated Gifs, lol? I know, it's probably not possible.

User avatar
DTM
Lieutenant Commander
XWAU Member
Posts: 1078
Joined: Tue Apr 22, 2003 11:01 pm
Contact:

Post by DTM » Sat Oct 13, 2018 12:38 pm

First test: it works perfectly! :thumbs:

MTD industries
WIPs: Fixing missions and new editing for the REBCP, Resistance Mon Calamari Cruiser, New advanced base OPT files for all playable XWAUP crafts.

User avatar
Driftwood
Lieutenant Commander
XWAU Member
Posts: 1284
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Sat Oct 13, 2018 2:23 pm

Pics or it didn't happen. (IE, me no have time to test right now)

Post Reply