Can we (sort of) make Fallout object oriented?

JimTheDinosaur

Vault Dweller
Modder
Initial note: I'm no programmer, so forgive me if I'm misusing terminology concerning OOP.

The single biggest limitation of modding FO is that almost everything of note is done through the use of prototypes. That is to say, any critter, piece of scenery, or pistol mainly exists not as a separate entity, but only as an instantiation of a prototype: a clone of all others sharing its PID except for a few exceptions such as location on a certain map, or having a certain amount of hitpoints in case of a critter, etc.

Working with these prototypes is cumbersome because they're extremely inflexible: you can't dynamically create new ones, and you can only temporarily change them on the fly, and when changing them, you of course immediately implement these changes for all those sharing the PID (which leads to amusing things such as one of Metzger's goons drinking alcohol leading to all his buddies feeling the effects as well). FO2 already saw devs experiencing the hindrances created by this approach as they implemented things like separate NPC levels and a greater variety of weapon modifications. This created the absurd situation where one single party member object had to have several prototypes, and weapons had to have another prototype with a different modification because an object in itself can't change.

So, could some limited form of individuality be attained given the tools we have? Let's look at the tools first, (limited) individuality exists in two forms for objects:

- local variables (LVAR's) in map object scripts.
- object pointers.

The way you could try working with LVAR's is by giving say, every object with a script a separate LVAR which gives them a permanent global ID, and having these objects communicate this ID to some global script whenever the script is loaded. This has some obvious limitations tho which makes it undesirable for me:

- Not every object (notably items due to the too many items bug) can or will have a script.
- Changing every single map object script in this way isn't just a hassle, but is a hassle which instantly makes any mod made with this new feature uncompatible with pretty much everything else.

So, let's move on to object pointers. An obvious drawback they have from LVAR's is that they're temporary: they're refreshed every map load. Another problem is that, like with LVAR's, they're pretty much useless for items because items stack, which disintegrates the pointer to the item that is stacked, making them more or less useless for tracking items consistently. So this route seems a dead end as well.

The only way I see it work is by concentrating solely on critters, which have the sturdiest pointers, and which also have the advantage of something else that gets registered: an inventory. Suppose you were to give every critter a separate amount of some useless misc item (e.g. bottlecaps for FO2), which then gets communicated to a global script, then you'd have persistent objects. You check at map entry/game load for how many bottlecaps are in the critter's inventory, which you can then connect with his object pointer and easily use from that point on (e.g. you have an array with {x bottlecaps : "Hank"}, then at map load you translate that to a temporary array with {obj pointer: "Hank"}). Whenever you don't find any bottlecaps on the critter (e.g. because he's been created recently or because you're entering a new map) then you simply give him a fresh ID and the bottlecaps that correspond. When the critter dies, you remove the bottlecaps from his inventory, which just leaves their appearance (and the player's possible manipulation) during stealing as an inconvenience.

I think this is a viable approach (which, as I said, sadly only works for critters) which is relatively light in terms of computing (and memory, tho that of course depends on how info much you want to store for each individual).


edit: I forgot to mention a second possible approach for critters, which is not to track them based on inventory, but location (i.e. hex, elevation and map). The problem with this is that it's not always easy to track changes (e.g. when a script uses move_to; inventory switches are by comparison AFAIK exclusively reversed immediately after, such as with merchants).
 
Last edited:
Why is this needed? It sounds like an immense hurdle just for fixing the drug bug.

A much easier solution would be to simply create a separate proto file for every single critter in the game, and then edit the maps accordingly. This means no two critters would have the same proto. Then you'd have to do the same for the random encounters. It'd take time, but it could be automated with a program or batch file.
 
Last edited:
Why is this needed? It sounds like an immense hurdle just for fixing the drug bug.

Oh, don't you worry about the immensity of my insane plans ;)

A much easier solution would be to simply create a separate proto file for every single critter in the game, and then edit the maps accordingly. This means no two critters would have the same proto. Then you'd have to do the same for the random encounters. It'd take time, but it could be automated with a program or batch file.

Eh, not sure how this'd be easier: (A) shipping your mod with 100k protos is more of a hassle than giving each critter 1-100,000 bottlecaps, and (B) having to manually edit each map renders it incompatible with every mod out there.
 
It could work of course, the bottle cap idea is wonderfully hacky, but I'm not sure how it'd fix the drugs. As far as I know the drugs modify the proto directly. You'd have to put a script on them to make them use the bottle cap id'd critter object, not the actual critter.
 
It could work of course, the bottle cap idea is wonderfully hacky, but I'm not sure how it'd fix the drugs. As far as I know the drugs modify the proto directly. You'd have to put a script on them to make them use the bottle cap id'd critter object, not the actual critter.

Oh right, yeah I was just using drugs as an example really, but it's mostly a function of how much of the vanilla mechanics you're willing to override (in my case, it's pretty much everything). An example how a modder could handle, e.g., Buffout's ST bonus is that you store that "Hank" just took Buffout, and that when he punches a guy five minutes later, you use the strength bonus to re-calculate his melee damage in the combatdamage hookscript.

That's what I should've responded to your proto-copying alternative: the point (for me) isn't to use the existing proto system, but to bypass it as much as possible.
 
It could work of course, the bottle cap idea is wonderfully hacky, but I'm not sure how it'd fix the drugs. As far as I know the drugs modify the proto directly. You'd have to put a script on them to make them use the bottle cap id'd critter object, not the actual critter.

Oh right, yeah I was just using drugs as an example really, but it's mostly a function of how much of the vanilla mechanics you're willing to override (in my case, it's pretty much everything). An example how a modder could handle, e.g., Buffout's ST bonus is that you store that "Hank" just took Buffout, and that when he punches a guy five minutes later, you use the strength bonus to re-calculate his melee damage in the combatdamage hookscript.

That's what I should've responded to your proto-copying alternative: the point (for me) isn't to use the existing proto system, but to bypass it as much as possible.

I agree the current system is clunky, if you can somehow write your own engine with scripts then go for it.
 
Just a post to quickly run through what gets stored on the individual critter level other than self-explanatory stuff like location and rotation (also see http://falloutmods.wikia.com/wiki/MAP_File_Format):

- FRMID: This seems very counterintuitive, but the type of sprite isn't determined by the PID (i.e. you can have clones who look nothing like one another). The uses for this become greater as you start treating critters as individuals: imagine a critter putting on a new suit of armor, which previously you couldn't do anything with because armor values were determined by its PID, etc.
- current HP and crippled states.
- AI packet and Team # (sadly the uses of these are limited because almost every map object script resets them at map entry for some weird reason).
- light radius/intensity (critters carrying flares/torches can happen).
- ? lots of unknowns in the link, would be nice to know what they are.
 
Jim, you should join our engine remake project. Everything is object-oriented and we need some programming muscle right now ;-)
 
Jim, you should join our engine remake project. Everything is object-oriented and we need some programming muscle right now ;-)

I'm flattered man, but like I said, I ain't no programmer, I've just managed squirm around with my limited SSL knowledge through sheer trial and error. Also, I sort of feel pot commited at this point to just release this fucking insane mod I'm working on at some point. Getting another engine with even more options would make me do even more insanely ambitious nonsense.
 
Just a post to quickly run through what gets stored on the individual critter level other than self-explanatory stuff like location and rotation (also see http://falloutmods.wikia.com/wiki/MAP_File_Format):

- FRMID: This seems very counterintuitive, but the type of sprite isn't determined by the PID (i.e. you can have clones who look nothing like one another). The uses for this become greater as you start treating critters as individuals: imagine a critter putting on a new suit of armor, which previously you couldn't do anything with because armor values were determined by its PID, etc.
- current HP and crippled states.
- AI packet and Team # (sadly the uses of these are limited because almost every map object script resets them at map entry for some weird reason).
- light radius/intensity (critters carrying flares/torches can happen).
- ? lots of unknowns in the link, would be nice to know what they are.

The unknowns actually just correspond to values like you'd see in the prototypes (see the PRO File Format page). Someone was going to update the wiki, but I guess they haven't gotten around to it yet.

And, yeah, the new engine projects are the best bet for this if you want completely customizable stuff.

- Not every object (notably items due to the too many items bug) can or will have a script.

What's the too many items bug? You can just give every object without a script a dummy script.
 
Jim, you should join our engine remake project. Everything is object-oriented and we need some programming muscle right now ;-)
Which project is it? Timeslip's Cross engine fallout was abandoned from what I was told, when I (as Fox Wernicke with the Facebook login) mentioned it. I saw it on this page, and then someone else told me about Falltergeist… what about the FOnline engine though?
 
Jim, you should join our engine remake project. Everything is object-oriented and we need some programming muscle right now ;-)
Which project is it? Timeslip's Cross engine fallout was abandoned from what I was told, when I (as Fox Wernicke with the Facebook login) mentioned it. I saw it on this page, and then someone else told me about Falltergeist… what about the FOnline engine though?

Yeah, it's Falltergeist. FOnline doesn't support original fallout resources, especially the scripts, so you can't use it as engine replacement (thus, it's not a remake).
 
Back
Top