Topic: Hex Editing of Starfleet executables  (Read 182614 times)

0 Members and 1 Guest are viewing this topic.

Offline TarMinyatur

  • Lt.
  • *
  • Posts: 938
  • Gender: Male
Re: Hex Editing of Starfleet executables
« Reply #300 on: February 10, 2015, 03:04:03 am »
Quote from: Javora
Code that handles such intercepted function calls, events or messages is called a "hook".
"h" could also be a prefix for "handle", which I noticed today in IDA. I don't know much about them either.

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #301 on: February 10, 2015, 03:41:07 am »
The pseudocode (F9) option of the Hex Rays plugin for IDA seems to be quite useful. With it a pile of mov and push commands becomes a readable if statement or loop. This should in theory make it much easier to find stuff from now on.

@Adam, I haven't given up on phaser coloring/texturing, in principle color hex codes should stand out much more clearly when you come across them if you are looking at pseudocode. Eliminating irrelevant references and functions to narrow down a search also becomes easier.

Offline EschelonOfJudgemnt

  • Lt. Junior Grade
  • *
  • Posts: 259
Re: Hex Editing of Starfleet executables
« Reply #302 on: February 10, 2015, 11:05:53 am »
Another thing I'd like verified is the OP cloak seeking weapon damage reduction chart. Dave said it was "SFB specs", but I had to assume that. We would need the % damage reductions for tractored and non-tractored ships.

It'll look something like this and when found SFC-CE/EAW can be brought up to specs:


_Cloaked Ship Status_ _Chance of Normal Damage_ _Chance of 1/2 Damage_ _Chance of 1/4 Damage_
 
 
     Non-Tractored                     33.3%                                       33.3%                               33.3%
 
 
 
       Tractored                           66.7%                                       33.3%                                  0%

Found the function in OP today. Hidden in plain sight. Its associated string is tCloakSystem::mDetermineCloakSeekingWeaponDamageModifier

d6  |  Multiplier
-------------------
1   |   1.0
2   |   1.0
3   |   0.5
4   |   0.5
5   |   0.25
6   |   0.25
7   |   0.0 (I don't know if this value is ever used. It could be there to handle unexpected values.)

There is probably another function for ships that are tractored. I don't see a subtraction of 2 from the die roll in this one, but that -2 would do it, resulting in a 33% chance of half damage.

It's been a while, but at one point I seem to remember their being modifiers that were applied to this roll in SFB in some instances.  Can't remember what they are now - natural ECM maybe?.  Possibly even regular ECM...

That might be something that changed between edition updates in SFB, and I don't have a rulebook available at the moment, but it as I said this rings a bell...

Offline Corbomite

  • Commander
  • *
  • Posts: 2939
Re: Hex Editing of Starfleet executables
« Reply #303 on: February 10, 2015, 11:21:25 am »
There is reduced damage due to ECM in SFB (and presumably SFC). The cloak chart is supposed to supplant that chart.

Offline EschelonOfJudgemnt

  • Lt. Junior Grade
  • *
  • Posts: 259
Re: Hex Editing of Starfleet executables
« Reply #304 on: February 10, 2015, 01:54:01 pm »
There is reduced damage due to ECM in SFB (and presumably SFC). The cloak chart is supposed to supplant that chart.

I am aware of the reduced damage from ECM, although that's usually handled via to hit modifiers as I remember (and of course adders to the phaser chart roll, with results over six being carried to the next column(s) '6' result.

But I remember specifically the Cloak chart having  the 7+ column entry, with some modifiers applying to it.  Again, it's been decades since I played SFB last, so I'm working off of memory here.  Our group had a discussion about this very thing, and as I said it may pertain to an earlier edition of SFB.

Offline RazalYllib

  • Imperial Romulan Information Service-senior advisor
  • Lt.
  • *
  • Posts: 784
  • Gender: Male
    • IRIS
Re: Hex Editing of Starfleet executables
« Reply #305 on: February 10, 2015, 06:21:30 pm »
The chart is the Fire Vs Cloak table...from SFB, at least my copy of the ruleset.

Have zero idea what the 7 is on the table, perhaps to acct for "unexpected value"?

Basically, fire at cloak process was a 2 step affair

1) fire at cloak adjusted range = Real Range * 2 + 5 while cloaked, during fade in, it was Range + X , with X being the number of impulses of the fade in or out.

2) if a hit was scored, that hit was rolled on the fire vs cloak table to determine the true damage scored; the cloaked entity had to be fully cloaked, no fade in/out.

That concludes the stripped down version of the cloak rule in SFB.
Comes a time when the blind man takes your hand
Says "don't you see?"
Gotta make it somehow
On the dreams you still believe
Don't give it up
You got an empty cup
Only love can fill
Only love can fill

Offline Corbomite

  • Commander
  • *
  • Posts: 2939
Re: Hex Editing of Starfleet executables
« Reply #306 on: February 10, 2015, 09:13:37 pm »
He's right, that is the damage correction vs DF and seeking weapons, but the 7+ slot can only come into play using one of two systems that the player is supposed to choose from during Fade In/Fade Out combined with an optional rule that allows the tracking ship to gain experience in firing after a few successful shots in the dark. It's not clear yet if they used this optional rule (I doubt it though as it is waaaay more complicated than using system 2 in the above description), so it is unclear why that entry exists.
« Last Edit: February 10, 2015, 10:09:06 pm by Corbomite »

Offline RazalYllib

  • Imperial Romulan Information Service-senior advisor
  • Lt.
  • *
  • Posts: 784
  • Gender: Male
    • IRIS
Re: Hex Editing of Starfleet executables
« Reply #307 on: February 12, 2015, 06:55:46 am »
I have a vague memory of testing the fade cycle in OP - many moons ago - I think we validated the fade in / out expected results based on the SFB standards. But that was a long time ago.
I do recall some other weirdness w/ cloak, that might have been EAW and fixed in OP.
Comes a time when the blind man takes your hand
Says "don't you see?"
Gotta make it somehow
On the dreams you still believe
Don't give it up
You got an empty cup
Only love can fill
Only love can fill

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #308 on: February 12, 2015, 06:09:32 pm »
Adam, I've managed to make some of the Klingon disruptors in SFC3 to use the Romulan disruptor texture (we're in luck: the textures are assigned per individual weapon, not per weapon class). When you search the strings list for the appropriate texture of a weapon you can trace the functions all the way back to one giant function. This giant function is sub_41C726 in SFC3, I believe the equivalent function in SFC:OP is sub_41C271. In pseudocode view (F5) the giant function becomes a neat list of if statements which will for example go something like "if a5 >= 20 then call function 123, if a5 >= 30 then call function 456", here a5 is some numbering system for all the weapons (plus tractor beam and possibly some other effects) in the game and functions 123 and 456 (fictitious names of course) are functions that lead to other functions which lead to other functions, etc... and ultimately point to a texture. There is some numbering before functions like 123 and 456, possibly indicating pixel coordinates on the texture, but it's more likely that's done in one of the intermediary functions.

Updates will follow...

P.S. I can't believe this weapon texture thing is turning out to be less hard than getting the damn DD and BC ship symbols to show up on the map...

Offline RazalYllib

  • Imperial Romulan Information Service-senior advisor
  • Lt.
  • *
  • Posts: 784
  • Gender: Male
    • IRIS
Re: Hex Editing of Starfleet executables
« Reply #309 on: February 13, 2015, 05:49:05 am »
Another vague memory of days gone by; IIRC, all the wpn gfx were bound to the textures, there were some mods to all of them by modifying the texture directly, I messed w/ the Plasma and couple other folks did others, including a rather nice non continuous phaser, like a string of B B 's. 

Could one clone the orig texture, rename, edit to the color/texture one desired, edit new weapon string to point to the new texture instead of the old (or the code equivalent) and still work?

If this is the case, new weapon textures could be used side by side with the stock ones.
Comes a time when the blind man takes your hand
Says "don't you see?"
Gotta make it somehow
On the dreams you still believe
Don't give it up
You got an empty cup
Only love can fill
Only love can fill

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #310 on: February 13, 2015, 06:52:46 am »
Another vague memory of days gone by; IIRC, all the wpn gfx were bound to the textures, there were some mods to all of them by modifying the texture directly, I messed w/ the Plasma and couple other folks did others, including a rather nice non continuous phaser, like a string of B B 's. 

Could one clone the orig texture, rename, edit to the color/texture one desired, edit new weapon string to point to the new texture instead of the old (or the code equivalent) and still work?

If this is the case, new weapon textures could be used side by side with the stock ones.

Sort of... Some weapons independently point to the same texture so the string "assets/textures/weapon" simply appears twice inside the .exe. The ion cannon and shield inversion beam in SFC3 do this and there it's trivial to decouple them from each other. Sub_41C271 in SFC3 points to chains of functions that ultimately lead to a texture, you can change these and for the Romulan and Klingon disruptors you could in theory do this for every individual weapon (eg. R-Disruptor IIIF), but the coordinates on the texture may be off, I think the Federation phasers might be an exception, their function chains point to the phaser1 texture but in the game the phasers only react to changes in the fx1 texture. Still working on this though.

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #311 on: February 13, 2015, 07:21:58 am »
Hmmm, when I set the link for fed phasers from the phaser1 to the tachyon texture it actually starts using that texture, even though previously it would not react to editing of the phaser1 texture. I suspect the fx1 texture is some kind of default for when a weapon texture is not accepted for some reason, or that the function chain for the fed phaser tells it to overwrite the phaser1 texture with its own orange color. Very strange, but I will keep investigating, if I can get the phasers to accept another texture I can get my polaron beams (by cannibalizing the slow phasers). If it turns out I have to redefine the sub_41C671 function somewhere else I might as well turn some (the slow) Romulan disruptors into Cardassian disruptors while I'm at it.

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #312 on: February 13, 2015, 10:31:23 am »
Ok, I now have proof the color of a beam weapon is determined (or referenced) somewhere in the function chain between the reference to the texture and the giant function (sub_41C726). I've been able to set some of the phasers to use the myotronic beam function chain, this works, but it also means they will use the beam color and short animation duration of the myotronic beam. However, it should be possible to create a new function chain in an empty spot and make it a copy of the normal phaser or Romulan disruptor chain and have it point to a different texture so that you can have a unique texture and have the beam properties of the phaser or R-disruptor (or decipher the beam duration length setting of the myotronic beam). One problem that remains is that the phasers are ranked from type IXS through type XIIIF, so by just changing the texture of the first 2 phasers both type IXS and type IXF will be affected, which means I can't separate the slow phaser from the fast phasers, of course I know I can change slow phasers into fast phasers (which I was going to do anyway), but I'm not sure how to create a long range starbase phaser with the alternative texture (I don't think I can just reverse the order of the range tables for phasers, but I hope I'm wrong). One extreme way to solve this would be to recreate sub_41C726 in an empty spot and try to change the if-statement list in it (very hard because it's a huge function and it's very hard to create new if-statements).

Long story short: all individual weapons can be given new textures, I've basically cracked the process, but it takes a lot of work.

Offline JanB

  • Lt. Junior Grade
  • *
  • Posts: 103
Re: Hex Editing of Starfleet executables
« Reply #313 on: February 13, 2015, 04:47:01 pm »
Yes, you start by following the function chains. Find a weapon texture, go to the function that references it, then go to the function that references that function, this second function is usually (sometimes there is a third in the chain) the one that gets referenced in the giant function, sub_41C271 in SFC2:OP. For SFC3 I made a list of these functions, the weapon they belong to, and where in the giant function they're referenced. Now look at the giant function in pseudocode mode (F5) and you should see a list of "if some variable has some value then call a function", the variable is the number of the weapon. You can change which weapon calls which function chain. You can usually get around the hardcoded colors by editing the texture image in the assets/textures folder, sure the hardcoded color gets mixed in but you can compensate for that most of the time, otherwise just use the function chain of another weapon that has a hardcoded color that you can work with (for example if you want to turn a blue phaser into an orange phaser I don't think there's any color you can paint the texture that would mix with the hardcoded blue to produce orange, but if you use the function chain of a white phaser you can mix that with an orange painted texture).

Note: some weapons will be grouped together in the giant function (though I think this is much less common in the SFC2 games than in SFC3), to separate them you have to rewrite the giant function, which is very hard.
« Last Edit: February 13, 2015, 05:10:43 pm by JanB »

Offline TarMinyatur

  • Lt.
  • *
  • Posts: 938
  • Gender: Male
Re: Hex Editing of Starfleet executables
« Reply #314 on: February 14, 2015, 06:19:16 am »
7 hours to find two new hotkeys.  :buck2:

The Shuttle Conversion hotkey is something I've wanted for a while. (Still need to choose the shuttle type.)

Still looking for a hotkey to "Send Marines"... Found it. The Capture panel has to already be open for it to work.

It's above AVtState_HotKeys@@ in a map format. 4-byte "key" followed by a 4-byte "value". The keys increase sequentially and are associated with a slot in the HotKey selection menu. The values are haphazard.

Moderately useful values discovered by trial and error:
13 01 01 00 = Shuttle Conversion Panel
7A 00 01 00 = Send All Marines to capture
Edit: The "Select All Weapons" hotkey doesn't work as I thought it did. It's the same as Red Alert.

The first key-value pair description begins at "data:00B33EB0 dd offset aHkadjustspeedm"

Which is put into this map, starting here:
"data:00B33FE0 HK_Number       dd 10004h"  // the key for increase speed
"data:00B33FE4 HK_Value        dd 1000Eh" // the value it reports (modifiable)
« Last Edit: February 16, 2015, 03:53:38 am by TarMinyatur »

Offline TarMinyatur

  • Lt.
  • *
  • Posts: 938
  • Gender: Male
Re: Hex Editing of Starfleet executables
« Reply #315 on: February 16, 2015, 12:01:22 am »
Worked on sprites today...

Fixed the Lyran Plasma Torpedoes. A good guess did the trick.

Bad data:
PlasF = [f..\f..]f..^f
PlasG = `f..af..bf..cf
PlasS = ef..ff..gf..hf
PlasR = jf..kf..lf..mf

It should be:
PlasF = jf..kf..lf..mf
PlasG = ef..ff..gf..hf
PlasS = `f..af..bf..cf
PlasR = [f..\f..]f..^f

Quicktips were inverted, too.

This fix, and the Klingon Defensive Plasma quicktip fix, will be included in 2.673.

Offline TarMinyatur

  • Lt.
  • *
  • Posts: 938
  • Gender: Male
Re: Hex Editing of Starfleet executables
« Reply #316 on: February 18, 2015, 10:36:46 am »
Quote from: Corbomite
Another thing I'd like verified is the OP cloak seeking weapon damage reduction chart. Dave said it was "SFB specs", but I had to assume that. We would need the % damage reductions for tractored and non-tractored ships.

It'll look something like this and when found SFC-CE/EAW can be brought up to specs:


_Cloaked Ship Status_ _Chance of Normal Damage_ _Chance of 1/2 Damage_ _Chance of 1/4 Damage_
 
 
     Non-Tractored                     33.3%                                       33.3%                               33.3%
 
 
 
       Tractored                           66.7%                                       33.3%                                  0%

The "Tractored" row is not used for direct-fire weapons.

I fired 30 Photons into the hull of a cloaked & tractored Romulan DN at range 0.40. I had 6 ECCM. The DN showed zero ECM.

12 Photons did 2 points each (25% of standard yield). The rest did either 4 or 8 points each. There appears to be no active code in single-player mode to modify damage in a special manner if the target is tractored. Maybe multiplayer is different, but I have my doubts after a battle with Moog's R-WVL on Gameranger yesterday.

Fusion beams did even worse. Sometimes doing only 1 point of damage, which should be impossible. The minimum should be 4 points at that range (or 2 points if using the first row of Corbomite's chart).

Offline Corbomite

  • Commander
  • *
  • Posts: 2939
Re: Hex Editing of Starfleet executables
« Reply #317 on: February 18, 2015, 10:43:28 am »
Hmm, well then you're on your own in finding the whole system. Tractor beams spilll over into many other systems. It'll be interesting to see how they tied it all together, or not. Good information to know though.

Offline TarMinyatur

  • Lt.
  • *
  • Posts: 938
  • Gender: Male
Re: Hex Editing of Starfleet executables
« Reply #318 on: February 18, 2015, 11:29:50 am »
More data indicates that the range remains effectively doubled even while the cloaked target is tractored.

30% (7/23) of my Fusion Beams did 1 point of damage at a true range of 0.9. None did more than 8. The effective range is assumed to be 1.8, resulting in a serious loss in damage potential compared to range zero. And a smart opponent will drop a WW for a +2 shift which also applies to weapons before they even reach the cloak chart. So trying to flash&blast a R-KE with OL Fusions just isn't going to cut the mustard, unless you have at least twice as many mines as the King Eagle has shuttles (or the Romulan captain falls asleep from boredom).

One would think that a tractor beam would negate range-doubling. At least the additive adjustment of +5 isn't in effect.

(This post applies only to SFC:OP.)

Offline Corbomite

  • Commander
  • *
  • Posts: 2939
Re: Hex Editing of Starfleet executables
« Reply #319 on: February 18, 2015, 12:29:14 pm »
The cloak chart is supposed to trump any ECM from any source. That needs to be confirmed.