Jump to content

Unitref.dat


Bomb Bloke

Recommended Posts

Unitref.dat is one of the larger files that are used in a battlescape game. I've been working on this for a while now, but it's getting to the stage where I can't think what to look for. So, what I'm after is a fresh perspective.

 

What I've got is a big list of what all the values in this file does. Simply put, it's full of the information that defines the units in play. The information I have now is a combination of NKF's and my own discoveries.

 

What I want to know is, what pieces of information need to be found? That is to say, it's much easier to think, 'I need to find the value that stores how long a unit will remain on fire' then it is to think 'I wonder what walue 43 does?'.

 

I've run out of ideas. If you can add to my list, please do. If you know the use of any values that I don't, that's great as well. :(

 

Here's the list:

 

https://www.ufopaedia.org/index.php?title=UNITREF.DAT

Link to comment
Share on other sites

For the experience flags, only the Kills are global. It literally mimicks the one in soldier.dat for that particular soldier. All the others are for the current battlescape mission only. Also note, for the aliens, all these values are filled with rubbish data. Might be a good idea to note whether or not some of the stats listed in the above have rubbish filled in for AI or player controlled units (if known, of course!).

 

As for the HWP turrets, I think the blanks I mentioned were just turrets that I was able to load and not crash the game. They're invalid in any case so don't worry about them.

 

You might want to list unitpos.dat as well, as it's very closely related to unitpos.

 

- NKF

Link to comment
Share on other sites

B) Thats one heck of a list there, Bomb Bloke, its too bad that information of this volume isn't available for the Geoscape.exe :( .....

 

Programming errors in not only this game, but Tftd could be solved rather easily and modding the game would be a snap.

 

The true value of huge amounts of info on the Geoscape (if it existed) would really shine through in being able to correct all the screw ups in the 2nd game: Hwp Gauss arming error, Craft Gauss arming error, Not Being able to produce Ion Beam Accelerators after completing the research, Not to mention all the research tree errors in the Tftd.

Link to comment
Share on other sites

Hmm, it IS a big list. I have to scroll down quite a ways to get to the replies! :lol:

 

Another thing, NKF. In your original turret notes, you mentioned a weapon '22' (I think it was) with an 'overpowered' armor piercing shot. What was that all about?

Link to comment
Share on other sites

I think that one was just a note I kept for myself after I put in an incorrect weapon. Ended up with incredibly low firing cost and it fired AP-like shells that blew away bits of the Skyranger.

 

It's not a valid weapon though.

 

- NKF

Link to comment
Share on other sites

  • 4 years later...

I was hacking Unitref.dat today to set up a testing scenario in the desert landscape. Nothing new there. To have a featureless landscape, I applied my Flat Terrain Map pack (found in the files section). After killing all the aliens except for an Engineer in the engine room of the Large Scout to keep the mission from ending, I decided I may as well collect all the bodies littered across the landscape to make it clean. After hauling all the bodies inside the craft, I thought it may be nice to have the whole map explored. So I sent my guy into the engine room to reveal it. Fine, the Sectoid was in there looking directly at me though. As I moved my soldier out of the room the game crashed. I noticed this a lot in the past from editing Unitref.dat and thought it was because the alien was trying to reaction fire. :laugh:

 

This engineer had all his current/max TU set to 0, current/max energy set to 0 and energy recharge was also 0. Crash. After editing current/max reactions to 0, I tried again. Crash. What gives? You would think that if the alien had no time units and no reactions he wouldn't be able to reaction fire, right? So besides editing the facing of the alien, is there any other byte I can edit to prevent the game from crashing due to reaction fire? (BTW, the game crashes no matter if the alien had a weapon or not). Maybe all the zeros in the alien's stats are causing a division by zero error when the game compares the reaction stats of the alien and your soldier? :D Would values of 1 be better?

 

Edit: well, editing TU/reactions and energy all to 1 fixed the crashes so a division by zero was the likely culprit. (Can we deduce the reaction fire equation used by the game from this info)? The alien was still able to reaction fire, but only when my TUs were depleted. How can I stop it completely though? :D

 

- Zombie

Link to comment
Share on other sites

TUs and energy can naturally fall to 0. Reactions cannot. Did you really have to put each of the three values to 1 before the crashes stopped? :laugh:

 

Solutions:

 

Use my battlescape editor to remove surplus items from the map (eg corpses, weapons live aliens might be holding, etc). WAY faster then manually lugging everything around.

 

Alternatively you can use this (a tool I wrote long ago, but I can't seem to work out where I previously uploaded it) to reveal the map, or take mind control of the alien in order to make it throw it's gun.

Link to comment
Share on other sites

TUs and energy can naturally fall to 0. Reactions cannot. Did you really have to put each of the three values to 1 before the crashes stopped? :D

No, I set each of them to 1 as I was sure that would probably fix it. I narrowed it down just before. What's causing the problem is a base TU (offset 25) of 0. Swap that for a number 1 or greater and the crashes stop. All the other base/current variables (such as reactions and energy) can safely hold a 0. Even with those zeros, the alien can still reaction fire when a soldier depletes his TU in front of an alien though. :)

 

Solutions:

 

Use my battlescape editor to remove surplus items from the map (eg corpses, weapons live aliens might be holding, etc). WAY faster then manually lugging everything around.

 

Alternatively you can use this (a tool I wrote long ago, but I can't seem to work out where I previously uploaded it) to reveal the map, or take mind control of the alien in order to make it throw it's gun.

I probably could use them (the second one looks really cool by the way), but I'm hesitant to use any kind of a mod or utility for this test I'm running. I really hate things polluting my saved games and anything I don't know about could affect results. No offense or anything, I love your stuff. Just not for this situation. :laugh: That's neither hear nor there though.

 

I have MC abilities for my soldiers, that's not a problem. Neither is lugging stuff around. (With soldiers having 200 TU and 180 Energy, they can literally walk around an entire map in 1 turn). I'm looking for a way to edit something to prevent reactions shot completely. I've edited as much as I could think of for unitref.dat but nothing stops the aliens from taking a pot shot. Am I missing a variable somewhere? Or is reactions hard-coded into the exe? I'm guessing it's a hard coded thing because reactions are an integral part of all units in the game. :D

 

- Zombie

Link to comment
Share on other sites

Well, whenever a unit walks in front of another unit, the reaction fire code fires up. The only way to get around that is to prevent the aliens from seeing your units. Whether the aliens will actually be allowed to fire is a different matter entirely - this is what the reaction fire code determines. Firing is just firing.

 

(I didn't realise you'd set MAX TUs to 0 for the alien, though it's pretty obvious that's what you would've done, come to think of it.)

 

Anyway, your chance is dependant on how many TUs you've got left, right? And to get that percentage, you need to divide your current TUs by your maximum. Doesn't work if the maximum is 0 (which is, again, something that should never happen under normal circumstances).

 

While I'm not exactly sure as to the point of this exercise, given that the reaction fire code runs every time a unit sees a hostile, the only solution I can possibly think of to make your units invisible somehow. I know that if you set an alien's UnitRef[48] to an empty LOFTEMPS record (eg 0) it'll pop out of sight. Whether this works for your units? I never got around to testing it, but I see no reason why it wouldn't. Regardless it should make it impossible for the aliens to actually HIT you (except maybe with melee attacks).

 

Re my tools, after that inventory screen fiasco I realised it was stupid of me to mess with ANY variables of a save without the user's permission (EVEN IF they were fully documented parts of the save). Hence I removed that tweak (and the one that randomised civilians too). If you use the editor to remove items from the table... then that's all it does (keeping in mind it also needs to update UnitRef when messing with what's in a unit's hands).

 

Likewise for the smaller tool. For example, to make the map visible, all you need to do is fill SEEMAP.DAT with 7s. So that's all it does. You can check the "date modified" tags on your files if you really don't believe me. :laugh:

 

The purpose of most of what I've written is specifically to allow me to quickly setup testing scenarios. If the tools made random edits, they'd be pointless.

Link to comment
Share on other sites

While I'm not exactly sure as to the point of this exercise, given that the reaction fire code runs every time a unit sees a hostile, the only solution I can possibly think of to make your units invisible somehow. I know that if you set an alien's UnitRef[48] to an empty LOFTEMPS record (eg 0) it'll pop out of sight. Whether this works for your units? I never got around to testing it, but I see no reason why it wouldn't. Regardless it should make it impossible for the aliens to actually HIT you (except maybe with melee attacks).

Ah, I totally forgot about the LOFTEMPS! (Gee, and I even tested it over at the X-COM Wiki too). Yeah, that'll do the trick. I wonder where the loftemps are located for your units/tanks though? The game has to pass that on to unitref to fill it out and since it isn't in soldier.dat, the executable is the probable location, right? Would be nice to permanently make your units invisible without having to edit unitref every time. Then again, it's only a byte. :laugh:

 

Re my tools, after that inventory screen fiasco I realised it was stupid of me to mess with ANY variables of a save without the user's permission (EVEN IF they were fully documented parts of the save). Hence I removed that tweak (and the one that randomised civilians too). If you use the editor to remove items from the table... then that's all it does (keeping in mind it also needs to update UnitRef when messing with what's in a unit's hands).

 

Likewise for the smaller tool. For example, to make the map visible, all you need to do is fill SEEMAP.DAT with 7s. So that's all it does. You can check the "date modified" tags on your files if you really don't believe me. :D

 

The purpose of most of what I've written is specifically to allow me to quickly setup testing scenarios. If the tools made random edits, they'd be pointless.

Oh, I didn't realize you made changes to your editor after the problems which cropped up when I was editing Soldier.dat that time. Well, I applaud you for being as conscientious as myself for testing and also being concerned about the validity of test data with mods. Nice to know none of your utilities are messing with things other than what they are intended for. I'll be sure to give them a whirl soon. Thanks! :D

 

- Zombie

Link to comment
Share on other sites

  • 8 months later...

You're right! I was all excited, then I got to the UnitRef.dat wiki page and found that someone had already documented it... ;)

 

So I took the old outdated list out of the top post and just replaced it with a link to that page.

 

Well spotted, though. :)

Link to comment
Share on other sites

You're right! I was all excited, then I got to the UnitRef.dat wiki page and found that someone had already documented it... :)

 

So I took the old outdated list out of the top post and just replaced it with a link to that page.

 

Well spotted, though. :)

 

aw! Well, I thought it may have been; as I posted it I thought, gosh, I'm really necroing this one.

 

I'll have to go check the wiki again myself ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...