Hooks

Need help editing the game? Check for help here!

Moderators: Darksaber, General_Trageton, Forceflow

Re: Hooks

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

Post by JeremyaFr » Mon Jan 15, 2018 2:08 pm

Hello,

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.
else
  if the weapon sequence is < 4, the decharge rate is 3,
  else there is no decharge.

Bman
Ensign
Posts: 432
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Tue Jan 16, 2018 2:11 am

Hi Jeremy,
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 ?

Thanks

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

Post by JeremyaFr » Tue Jan 16, 2018 1:21 pm

Hi Bman,
Bman wrote: 1) Is the ship category check based on the data within the .exe, or is it read directly from the shiplist.txt file ?
The ship category is read in the exe.
Bman wrote: 2) Does the mesh type and WP (laser hardpoint) type have any bearing on this ?
The mesh type and WP have no incidence on the decharge rate.
Bman wrote: 3) Can weapon sequence be changed to a number greater than 4 ?
The weapon sequence is set by the exe.
Bman wrote: 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 ?
I can create a hook to set the decharge rate based on the model index. The decharge rate would be read from a txt file created next to the opt file. If needed, the recharge rate could also be based on the weapon type. If a such file is not present, default values would be used.
The recharge rate could be set the same manner.

By default, the recharge rate is controlled as this:

Code: Select all

if the craft is TieFighter or TieBomber, the recharge rate is 3 * PresetLaser,
else the recharge rate is 2 * PresetLaser.
The value could be read from a txt file. It would be based on the model index and maybe the weapon type.

Bman
Ensign
Posts: 432
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Fri Jan 19, 2018 5:39 am

Awesome! Thanks.

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

Post by JeremyaFr » Mon Jan 22, 2018 5:26 pm

Hello,

I've updated xwa_hook_mission_objects.
You can now define a gunner opt based on the player opt.

Suppose that the player craft is "FlightModels\[Player].opt".

The possible involved files are:
- "FlightModels\[Player]Gunner.opt"
- "FlightModels\CorellianTransportGunner.opt"

To define a custom gunner opt, you can either use the "Objects.txt" file to replace the "CorellianTransportGunner.opt" file or use a "[Player]Gunner.opt" file.

Please redownload xwa_hook_mission_objects.zip

User avatar
Darksaber

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

Post by Darksaber » Mon Jan 22, 2018 7:48 pm

Not sure I know what you mean by

- "FlightModels[Player]Gunner.opt"

By "Player" do you mean like in the pliot file so the opt would be called say DSUCPGunner.opt or if you have a custom opt, say YT-1760.opt the gunner opt (if it existed) would be called YT-1760Gunner.opt?

And if there wasn't a YT-1760Gunner.opt the game would automatically use the CorellianTransportGunner.opt instead?

Just trying to get my head around the "Player" bit :D

The next bit I understand :)
To define a custom gunner opt, you can either use the "Objects.txt" file to replace the "CorellianTransportGunner.opt" file or use a "[Player]Gunner.opt" file.
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

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

Post by JeremyaFr » Mon Jan 22, 2018 7:59 pm

[Player] designates the player opt.

If the player opt is YT-1760.opt, then the gunner opt will be YT-1760Gunner.opt. If this file doesn't exist, CorellianTransportGunner.opt will be used.

User avatar
Darksaber

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

Post by Darksaber » Mon Jan 22, 2018 8:07 pm

Ok got you :) cheers
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

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

Post by JeremyaFr » Mon Jan 22, 2018 8:58 pm

I've found a bug in xwa_hook_opt_limit.
Please redownload xwa_hook_opt_limit.zip

User avatar
Darksaber

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

Post by Darksaber » Mon Jan 22, 2018 9:12 pm

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

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

Post by JeremyaFr » Sun Jan 28, 2018 4:15 pm

Hello,
Here is a new hook: xwa_hook_weapon_rate.

This hook permits to define weapon decharge and recharge rates for any craft.

Suppose that the craft is "FlightModels\[Model].opt".

To define the decharge and recharge rates, create a file named "FlightModels\[Model]WeaponRate.txt".
The format is:
DechargeRate = decharge value
RechargeRate = recharge value

If the file does not exist, default values are used.

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.
else
  if the weapon sequence is < 4, the decharge rate is 3,
  else there is no decharge.
By default, the recharge rate is controlled as this:

Code: Select all

if the craft is TieFighter or TieBomber, the recharge rate is 3 * PresetLaser,
else the recharge rate is 2 * PresetLaser.
Download link:
xwa_hook_weapon_rate.zip

User avatar
Darksaber

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

Post by Darksaber » Sun Jan 28, 2018 7:31 pm

Thanks Jeremy :)

Quick question, what about the other craft like

Shuttle/Light Transport
Utility Craft
Container
Freighter/Heavy Transport
Starship
Station
Weapon emplacement (probably not applicable)
Satellite/Buoy (probably not applicable)

What would be the Recharge and Decharge rates for these craft?

Or does this Hook only apply to Starfighters?
Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

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

Post by JeremyaFr » Sun Jan 28, 2018 7:40 pm

For these crafts, the default decharge rate will be 3 and the default recharge rate will be 2.

Drinkinmiester
Cadet 2nd Class
Posts: 68
Joined: Sun Nov 09, 2008 9:37 pm

Post by Drinkinmiester » Sun Mar 18, 2018 9:12 pm

So reading about this and, I'm trying to figure out how to use this to switch to different opts in a mission. I want to check and see if I'm getting this right. When I want to replace an opt in missions do I need both a "[MissionDir]\[Mission]_Objects.txt" for each mission as well as "FlightModels\Objects.txt"? Or just a "[MissionDir]\[Mission]_Objects.txt" for each instance I want to replace? Also I assume that the lines in the "[MissionDir]\[Mission]_Objects.txt" would be the same format as in the sample "objects.txt" included in the download, correct? Am I way off? Does somebody have an example that they've made that they can share to ilustrate how this is put into practice?

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

Post by Driftwood » Mon Mar 19, 2018 1:44 am

If it's in a specific mission you only need the MissionName_Objects.txt

Here's an example from one of DTM's missions.

1b9m1_Reunion_Objects.txt

Code: Select all

FlightModels\ContainerBrick.opt = FlightModels\Naboo_26Km.opt
FlightModels\ContainerHexBox.opt = FlightModels\Cielo_Notte.opt
FlightModels\ContainerTube.opt = FlightModels\TheedCity_26Km.opt
1b9m1_Reunion_HangarObjects.txt

Code: Select all

FlightModels\Ywing.opt = FlightModels\Blank.opt
FlightModels\Xwing.opt = FlightModels\Blank.opt
FlightModels\NabooN1L.opt = FlightModels\NabooN1LExterior.opt
FlightModels\Bwing.opt = FlightModels\Blank.opt
FlightModels\shuttle.opt = FlightModels\Blank.opt
FlightModels\HangarCrane.opt = FlightModels\Blank.opt
FlightModels\HangarDroid.opt = FlightModels\Blank.opt
FlightModels\HangarDroid2.OPT = FlightModels\Blank.opt
FlightModels\HangarGenerator.opt = FlightModels\Blank.opt
FlightModels\HangarMonitor.opt = FlightModels\Blank.opt
FlightModels\HangarRoofCrane.opt = FlightModels\Blank.opt
FlightModels\HangarWorkStand.opt = FlightModels\Blank.opt
Image
R.I.P RSF_Zjon1, RSF_Mac, RSF_Vasquez

Drinkinmiester
Cadet 2nd Class
Posts: 68
Joined: Sun Nov 09, 2008 9:37 pm

Post by Drinkinmiester » Mon Mar 19, 2018 5:55 am

Thank you, I have used this info to free up the platform slots as suggested by dtm

Bman
Ensign
Posts: 432
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Sat Apr 14, 2018 10:33 pm

Hello, Jeremy just discovered a wonderful way to stop "Gun-Turret" meshes from randomly rotating when an enemy craft is not present. For example, on a number of non-flyable starships and stations you often see the meshes spinning and randomly rotating which looks silly in-game and not realistic. No more. Now those meshes can remain still and then resume moving/targeting enemy craft when within firing range.

Per Jeremy: "The code that controls the gun turret rotation speed is situated in function L00401880 at offset 1553 (:00402153). It looks like this:

Code: Select all


if( s_pXwaCurrentCraft->WeaponRacks[weaponIndex].ObjectIndex != -1 )
{
  the turret is oriented towards the targetted craft
}
else
{
  if( ( s_pXwaCurrentCraft->MeshRotationAngles[meshIndex] & 0x01 ) != 0 )
    s_pXwaCurrentCraft->MeshRotationAngles[meshIndex] += 0x04;
  else
    s_pXwaCurrentCraft->MeshRotationAngles[meshIndex] -= 0x04;

  if( XwaRandom() < 0x0600 )
  {
    s_pXwaCurrentCraft->MeshRotationAngles[meshIndex] ^= 0x01;
  }
}
To disable the rotation when there is no targetted craft, you can apply this:

Code: Select all

At offset 1553, replace 8A843160020000 with EB2E9090909090.
"
I'm not sure if this also applies to all other types of crafts such as fighters, freighters, and stationary gun emplacements and so forth.
Jeremy can better clarify that. Also, I've asked him if maybe he could make this patch offset as a separate runtime .dll file or just add it to an existing .dll file to keep things easier to install. :-)

EDIT: Moderators, I'm not sure if this should be posted under the XWA.Exe Patches thread instead ? If so, please move. Thanks.

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

Post by JeremyaFr » Sun Apr 15, 2018 12:24 pm

Hello,
I've added this patch to XwaExePatcher.
I don't know if it applies to all types of crafts. It needs to be tested.

Post Reply