Page 1 of 10
Posted: Fri Sep 15, 2017 1:19 pm
This thread is made for a general discussion about the hooks.
A hook is a way to inject code into the exe. It enhances, adds a feature to, or fixes a problem with the game. Read the readme file inside the hook package for more informations about what the hook does.
You can download the hooks here:
https://onedrive.live.com/redir?resid=A ... 94FB%21116
The hooks are packaged in zip files. The filenames start with "xwa_hook_".
The easiest way to download all the hook is to use XwaHookSetup: see viewtopic.php?p=154911#p154911
The first hook is xwa_hook_main. It is a custom Dinput dll that loads the other hooks and auto patches the game exe. If you use a custom Dinput.dll, it will conflict with this hook. In this case, use xwa_hook_main_no_dinput instead of xwa_hook_main.
The source code of the hooks is here:
To discuss the hooks, you can post here. Or to discuss about a specific hook, there may be a sticky thread in the Editing section.
Posted: Fri Oct 20, 2017 2:35 pm
Here is an "Hello World" sample to show how to create a hook.
The hook shows "Hello, World!" at the bottom of the game menu, before the version string.
The sample comes in 2 versions: a C++ version and a C# version.
link: https://github.com/JeremyAnsel/xwa_hook ... orld%20Cpp
The hook does this:
Code: Select all
int HelloWorldHook(int* params)
const auto XwaGetFrontTxtString = (const char* (*)(int))0x55CB50;
char* bufferPtr = (char*)0xABD680;
const int bufferSize = 256;
const int FrontTxt_STR_CONFIG_VERSION = 1168;
strcpy_s(bufferPtr, bufferSize, "Hello, World! ");
strcat_s(bufferPtr, bufferSize, XwaGetFrontTxtString(FrontTxt_STR_CONFIG_VERSION));
strcat_s(bufferPtr, bufferSize, "2.02");
link: https://github.com/JeremyAnsel/xwa_hook ... World%20Cs
The hook does this:
Code: Select all
delegate string XwaGetFrontTxtStringDelegate(int index);
static XwaGetFrontTxtStringDelegate XwaGetFrontTxtString = (XwaGetFrontTxtStringDelegate)Marshal.GetDelegateForFunctionPointer(
new IntPtr(0x55CB50), typeof(XwaGetFrontTxtStringDelegate));
public static int HelloWorldHook(IntPtr @params)
IntPtr bufferPtr = new IntPtr(0xABD680);
const int FrontTxt_STR_CONFIG_VERSION = 1168;
byte message = Encoding.ASCII.GetBytes("Hello, World! \0");
Marshal.Copy(message, 0, bufferPtr, message.Length);
byte message2 = Encoding.ASCII.GetBytes(XwaGetFrontTxtString(FrontTxt_STR_CONFIG_VERSION) + "2.02\0");
Marshal.Copy(message2, 0, IntPtr.Add(bufferPtr, message.Length - 1), message2.Length);
Posted: Sat Nov 11, 2017 9:16 pm
Posted: Sun Dec 31, 2017 4:27 pm
Here is a hook to replace mission objects.
Suppose that the mission is "[MissionDir]\[Mission].tie".
The possible involved files are:
To replace the objects, create a file named "[MissionDir]\[Mission]_Objects.txt".
The dll searches a "Objects.txt" file in this order (from first to last):
If a "Objects.txt" file doesn't exist, no model is replaced.
The format is a line per object: "FlightModels\ObjectA = FlightModels\NewObjA"
Posted: Sun Dec 31, 2017 5:37 pm
It's incredible, how many applications can this new hook have ...
Posted: Sun Dec 31, 2017 7:39 pm
Another one jezz, you spoil us
Posted: Sun Dec 31, 2017 10:23 pm
Wonderful Jeremy! So this hook temporarily allows the flexibility of switching .opt files for specific flight mission(s).
How are you defining "objects"? Is it only stationary/non-flyable .opt models like cargo canisters and such things?
Posted: Sun Dec 31, 2017 11:05 pm
Looks like you can replace any object i.e. opt
Looks like you can replace specific opts in a mission you would place the object.txt file in the missions Dir,
"[MissionDir][Mission]_Objects.txt" it would be rename to 1b0m1fw_Objects.txt say you want to replace Harlequin Station which is Platform1.opt with say a Star Destroyer, then you open the 1b0m1fw_Objects.txt and type
FlightModels/Platform1.opt = FlightModels/ImperialStarDestroyer.opt
If you want to replace an certain opt in ALL missions the Object.txt file is placed in the Flightmodels folder and is just named Object.txt
So if you had the same FlightModels/Platform1.opt = FlightModels/ImperialStarDestroyer.opt
All instances of the Platform1.opt would be replaced with the ImperialStarDestroyer.opt
but remember the replaced opts stats would remain the same as the craft it's replacing, so if you replace the Platform1.opt with the ImperialStarDestroyer.opt, the ImperialStarDestroyer.opt would still act as though it was still the Platform1.opt
Unless Jeremy's offset changes the stats for the replaced opt, which I doubt it would do, but I maybe wrong
Perhaps Jeremy can shed some light on this matter
Happy New Year
Posted: Mon Jan 01, 2018 12:27 am
Thanks to this hook it's possible to have many plantary scenarios using only one slot. That's brilliant!!! Also it is possible to introduce special FG colors to be used in special missions, or modified customezed crafts...it's a good solution to avoid vaste of empty slots! Other applications? Relic starships...many types of modular space stations, many types of shipyards...everything you can imagine without the limit of the empty slot...
Happy new year!!!!
Posted: Mon Jan 01, 2018 11:06 am
The stats of the replaced crafts are not changed.
Posted: Thu Jan 04, 2018 5:13 pm
I've fixed a bug in the main hook.
Please redownload xwa_hook_main.zip
Posted: Fri Jan 12, 2018 12:44 pm
I have updated xwa_hook_mission_objects.
The craft turrets are no longer limited to CorellianTransport2, MilleniumFalcon2, and FamilyTransport. You can now enable turrets for any craft.
Note that the CorellianTransport2 stats need to be edited to disable the second turret (It has only one turret).
Please redownload xwa_hook_mission_objects.zip
Posted: Fri Jan 12, 2018 1:39 pm
Lol I knew it
a bit of editing to do know
EDIT: Found out a couple of things while testing, you will have to add a Gunner Hardpoint to your turret Mesh otherwise the Turret Gunner Tunnel Opt (Not sure what else to call it) will not show in game. Your still able to use a turret, but there will be NO visible Gunner Tunnel thingy
Plus the Turrets POV's have to be set to X=0, Y=250, Z=19 for the CorellianTransportGunner.opt, of course if you make your own Gunner Tunnel OPT the POVs might be different.
Posted: Sat Jan 13, 2018 3:42 am
How do you find the X/Y/X turret coordinates and the pod orientation X/Y and arc coordinates?
I'm debating starting up my escort shuttle cockpit again in what little free time I have, and I figure it couldn't hurt to do a turret for it either now that this hook exists. However, I need to figure out how to figure out positioning for the rear facing turret.
I just enabled the MUTR, but obviously the data exists already so I have no idea how everything is calculated. Though I do somewhat wonder if the turrets are indeed aligned the direction they should be. (will look into this later)
Y/W (B) is something else I'm pondering conceptually.
Well, I've made a dummy (test) opt for the Y/W (B) using a modified exterior opt, since I figured it'd be the easiest way to give this a try.
Flightmodels folder has:
The technical details as I have come to find them:
Arc 1 controls up/down range of motion of turret 1
Arc 3 controls left/right range of motion of turret 1
Arc 2 controls up/down range of motion of turret 2
Arc 4 controls left/right range of motion of turret 2
Setting pod 1 (or 2) x/y orientation to 0/0 sets POV straight forward. I do not at this time have any other stats for the other cardinal directions.
Setting pod orientation X / Y to zero for the Y/W (B) is perfect for the forward facing default direction
Setting Gunner 1 coordinates to X 150, Y 65, and Z 0 is just right for gunner POV
Setting Arc 1 to 1200, and Arc 3 to 31000 is perfect ARC wise, though the climb on the turret is extremely limited since I'm trying to avoid clipping through the model on the turret depression side of things. It should be playable enough however.
Model wise it appears to need little modification besides removing hidden faces and the clone trooper in the turret. (see animation issue below)
DO NOT GO BEYOND +/- 31000 on your arc range of motion! You will not be happy!
So far the gun animation doesn't work right, there's limited movement (almost no movement)it seems with the turret animation at this point, but then I've not modified the YwingBExteroir.opt (duplicated to be YwingBGunner.opt) beyond adding in 4x empire laser hardpoints thus far (which seem to do nothing as of yet). I imagine this has to do with the mesh assignments. So one issue graphically is that the gun turret doesn't pivot with the player camera at all.
I still can't for the life of me get the bloody turret to fire at all while controlling it, and I'm starting to wonder if that's because technically on the base opt itself it doesn't have a turret weapon technically. Still trying to figure this out.
I was originally testing this in skirmish mode as I was somewhat under the impression that it would reference the turret similarly to the way the game references the cockpit and exterior models. Apparently this doesn't seem to be the case and is still calling the default corellian transportgunner.opt. It would be great if this could be looked into and hopefully fixed so custom turrets can be used in skirmishes as well as custom missions.
Probably more of a DSUCP bug the other issue I noticed is that the Y/W (B) base opt in this version of DSUCP (before modifications in any way) the lasers/ions/missiles all come out between where the weapon hardpoints actually are. I imagine the weaponry tab needs some tweaking to work correctly.
Posted: Sat Jan 13, 2018 7:31 pm
# arc range
The arc range are short values. Values go from -32768 to 32767.
# custom gunner opt
You replace the gunner opt, you can either use the Objects txt file to replace the CorellianTransportGunner with a custom opt, either modify the craft stats to point the turret to a custom gunner opt instead of the CorellianTransportGunner (317). The second option requires an empty craft slot.
# working turret
If you replace the Outrider with the CorellianTransport2 (stats and opt), the turret works. You can inspect the opt to figure out how to make the turrets to work.
Posted: Sat Jan 13, 2018 8:25 pm
Okay well that turned out simple enough then.
I typed in 42 (YW/B) craft # in place of 317 in the turret 1 activation status and it called the correct opt in the flightmodels folder no problem when loading a skirmish mission by default.
As for the YT2400 example, it already appears to work by default without changing any settings once I enabled the turret hook; that said, I'll take a look and see if I can figure out what you're referencing looking for.
Also, do you have any idea in regards to negative numbers vs positive in relation to turret functions? I'm kind of wondering if you can somehow restrict up/down left/right movement depending on whether or not the number is pos/neg.
Posted: Sat Jan 13, 2018 8:34 pm
The YT-2400 turret doesn't work in the vanilla game. It works fine with the UCP.
Posted: Sat Jan 13, 2018 9:12 pm
Apparently the Y/W B opt as installed by DSUCP has no hardpoints on the opt. At all. Also apparently, the weapons were only defined in MXvTED, which would (could) explain why the lasers and missiles were firing from the center point.
After adding hardpoints the weapons are firing from where they are supposed to. However, while the AI fire turret works fine, the player controlled turret fires the pilot's lasers, and for some reason stops firing altogether after a while (not regenerating?).
One other oddity, is that unless the turret weapon is set to rebel/empire turbo-laser, it links with the primary/secondary weapons. (easy fix)
The turret animation also doesn't work at all it seems on the player craft at the moment - that is with the arcs set up the way I have them perhaps?
Edit: I can't figure the following issues.
1. The player controlled gun turret runs out of charge and just stops putting out shots. Period. I even put a "power regeneration" designated mesh like the YT1300 has in the XWAU version. Function wise this is the biggest problem I'm having since there's no point in having a player controlled turret that goes dead.
2. The player controlled gun turret is firing from the pilot's forward laser hardpoints, not the ones attached to the turret. Second biggest issue since it's not firing from the correct source, ie; the turret turbo-laser hardpoints. (But I can't figure out why)
3. The player turret animation is not following the camera and barely moves. (Not pretty, but minor issue that hopefully can be fixed)
4. When pushing auto/defensive fire (using (F) from the pilot's seat, the turret behaves correctly. (Fires red lasers in skirmish - non-issue)
5. Player craft turret animation doesn't function in external view. (Not sure it does by default anyways)
Issues 1-2 are the priority to figure out at the moment as far as I am concerned.
Posted: Sat Jan 13, 2018 9:32 pm
The Y/W B Base opt has since been fixed with all hardpoints accounted for, not sure why they where missing ?? A new version of the DSUCP is in the works, but I won't be adding or chaning any opts to account for the Turret info, I have removed the 2nd turret info from the YT1300.
If you trying to get a version of the Y/W B turret working like the Gunner turret you need to study how the Gunner turret works, what order the meshes are in, how the meshes rotates, what the meshes are named, are any hardpoints added and so on, you can't just bash together a gunner opt and expect it to work the same as the gunner turret.
I've never really looked at the gunner turret so I know little about it, there has never been any necessity to do so before now, that is.
Posted: Sat Jan 13, 2018 9:51 pm
Yeah, I have no idea why the hardpoints were missing, I was surprised when I opened up the opt myself.
I've been studying the gunner opt, the YT1300 base opt, and the Y/W B opts pretty much all last evening before bed, and part of this afternoon.
I realize that gunner opt =/= custom opt will not likely work 1:1. At this point I'm just trying to figure something out for proof of concept using an already existing opt (my modeling/texturing skills are limited) as a basis for said concept. Most of the work has been thus far in figuring out the function within MXvTED via trial by error.
My theory with the animation part of things is likely due to the fact that the arcs range of motion are more limited in the up/down range than the YT1300's, and I believe that most of the animation from the original turret is tied to the up/down axis, rather than the left/right axis. There may not be much of a fix for that if that's the case, as far as I can see. Either that, or I just haven't imagined up a solution yet and am thinking too far inside the box.
At the moment, I'm double checking my order for the meshes compared to the gunner opt.
But honestly, I'd rather find a fix for the lasers firing from the wrong hardpoints and then suddenly going dead for no obvious reason.
Functionality is more important to me at the moment than aesthetics since there are likely still going to be certain engine limitations to turret functionality regarding animations.
EDIT: I've changed around the meshes to match the gunner opt, and there's zero impact in animation functionality.
Still unable to figure out why turret lasers are firing from the wrong hardpoints, and won't recharge.
Posted: Sat Jan 13, 2018 11:02 pm
Okay, I'm officially entirely stuck.
1. Still fires from the wrong hardpoints for no obvious reason.
2. Runs out of laser charge and won't regen.
Can't figure out how to resolve either issue. Kind of fixed #1, but then the laser's stopped firing at all while controlling the turret for no obvious reason. So I reverted back.
This is starting to annoy me.
Posted: Sun Jan 14, 2018 12:20 am
Have you tried setting it as a shuttle?
Posted: Sun Jan 14, 2018 1:27 am
Well, apparently that does in fact make the turret controlled weapons unlimited charge. But not an ideal fix given it requires changing the ship classification. Still the issue of firing from the wrong hardpoints remains, still no idea why. Doesn't make a lick of sense. Getting to where I want to scrap my efforts and move onto something else.
I did notice the superrebel lasers firing from the wingtip lasers on the Moldy Crow also when manually firing, though the superrebel lasers did fire from the turret as they are supposed to with auto-fire. I'm starting to wonder if there's a general bug with the engine. However, with that said I have not seen this issue with the YT1300, YT2000, YT2400 or Falcon models, so I'm scratching my head on that one. It's not consistent.
It's strange though, turret auto fire works fine when classed as a fighter, but the manual control doesn't work right both on what hardpoints fire, doesn't have unlimited charge (or regenerate when recharging lasers) when assigned to a fighter designated ship.
Am I overthinking this?
Posted: Mon Jan 15, 2018 2:08 pm
To get unlimited turret ammo without changing the craft type, you can try this:
Code: Select all
At offset 90A5C, replace 7424 with 9090.
This will disable the ship category check.
By default, the decharge rate is controlled as this:
Code: Select all
if the ship category is Starfighter,
if the craft is TieFighter or TieBomber, the decharge rate is 3,
else the decharge rate is 4.
if the weapon sequence is < 4, the decharge rate is 3,
else there is no decharge.
Posted: Tue Jan 16, 2018 2:11 am
1) Is the ship category check based on the data within the .exe, or is it read directly from the shiplist.txt file ?
2) Does the mesh type and WP (laser hardpoint) type have any bearing on this ?
3) Can weapon sequence be changed to a number greater than 4 ?
4) Finally, is it possible if could you implement the above unlimited ammo offset through an optional .cfg .lst, or .txt file like xwa_hook_main.cfg that is processed at runtime where for example... Offset 90A5c = 1 means unlimited, else = 0 means default status ?