Misc. odd behaviors in combat engine

Melindil

It Wandered In From the Wastes
I've been poking through a couple of areas of the combat engine I haven't decoded yet (e.g. the secondary weapon effects - knockdown, poison, stun, etc.). I've found a couple of oddities (likely bugs), and wanted to get some input on ideas for the best way to fix them.

First - can anyone confirm if they have seen a "critical miss" in vanilla FOT 1.27 (ideally with a save just before that miss could occur)? The reason I ask is that I found the routine that appears to calculate the critical miss chance (low luck and Jinxed trait increase the chances), but the subroutine that appears to have been intended to apply the critical miss effect has been nulled out, with the result that a "critical miss" always misses all targets (even for burst and area attacks). I've also found the tables that appear to determine the critical miss effect by weapon type (unarmed, melee, and ranged), but IDA tells me no code refers to them. I'll add a scripting hook for FTSE to allow mods to use and customize the behavior, but should I make an attempt at trying to recreate the original behavior? (Wondering if this was removed for balance reasons.)

Second - I've surprisingly found code in the secondary weapon effect routine that refers to the Bonsai perk, but unsurprisingly it's broken. The way the code is currently written is as follows:

1. When a character receives either radiation or poison damage, check if they have the Bonsai perk, and have already received 50 radiation / 20 poison damage. If so, continue; if not, skip below and apply the damage as normal.

2. Roll a number from 0-99, and check if it is less than the current radiation/poison damage being applied (for poison only, multiply the damage taken by 2.5 first). If so, continue; if not, skip below and apply the damage as normal.

3. Remove 50 radiation / 20 poison from the character that was hit.

4. Create a fruit item, but override the normal 4? points of healing from the fruit with either 10-20 radiation or 5-10 poison damage. (Presumably, the intent is that a Bonsai character can extract radiation or poison into fruit to expel it.) Unfortunately, the fruit item isn't added to any inventory or placed on the ground anywhere, so the player never sees the effect (and, an entity entry for the current level is permanently leaked).

5. A change of color is applied to the character's "base" color entry. This is quite odd - maybe this was supposed to be applied to the fruit object instead?

6. Finally, apply the original radiation/poison damage.

So, a question to everyone - what, if anything, should I do to fix this? The closest to original intent would probably be to add the fruit to the inventory, and get rid of the color swap. But is the perk really worth it? Or should I modify it to work more like the original docs described (random fruit appearing at times)? Or, zero out the effect entirely and free up a perk slot for future use?
 
Hehe that is pretty interesting, and hell of a complicated behaviour to say the least...

First, I never, never saw a critical miss in Fallout tactics, ever. Fallout 1 critical miss are pretty evident. You lose your gun, you shoot somebody else, you fall, you destroy your gun, you kill your dear partner. In tactics, nothing of the sort ever happened to me in at least 3 completed games. I always assumed it was all broken shit. The worse thing that can happen in vanilla Tactics is area damage caused by 12 gauge or bursts, but this is clearly not a critical miss. I don't think I'm inventing something if I say : consider it entirely broken to start with.

As for the poison, it works, but as soon as you change damage type other than normal (fire, electricity, etc.), no poison will be applied. It might not be a bug, but it is a bit bad. So, no "explosive poison" guys, it just don't work. :P

As for the radiation, it seems even more weird. I made tests a while back because I was using constant radiation as a hunger meter. I realized that radiation resistance either protect you (100%+) or do nothing (less than 100%). I tried and I tried to lower radiation intake with raditation resistances from 10% to 90%, but if you receive 100 rads and you have 90% resistance, from experience I think you still receive 100 rads. I would understand if, let's say, you took 1 rad and then 90% resistance still give you 1 rad. But 100? I think radiation was so much unused in the game that they didn't bother.

As for the bonsai perk, the only way I always understood it was that fruit were supposed to appear "from time to time" (https://fallout.fandom.com/wiki/Bonsai), so it should in theory have nothing to do with combat at all. You should even be able to sit there, and act as fruit tree as long as you want hehe. If you want to add some code to create a fruit at random intervals, I think that would be the best option to me, as it might be very moddable afterwards (change the fruit for another item, use the code to spawn items if some other conditions occur, etc.)
 
5. A change of color is applied to the character's "base" color entry. This is quite odd - maybe this was supposed to be applied to the fruit object instead?

This made me think about something here... Following this strange behaviour code, could it be easy to integrate in 0.50a a LUA code to permanently change a character's team color when a specific .ent item is worn? You already have a clue on how to apply a color. Considering that all armors could be added in the code, we would get a way to setup character color based on armor worn. Maybe I'm a bit too optimistic here ha
 
First, I never, never saw a critical miss in Fallout tactics, ever. Fallout 1 critical miss are pretty evident. You lose your gun, you shoot somebody else, you fall, you destroy your gun, you kill your dear partner. In tactics, nothing of the sort ever happened to me in at least 3 completed games. I always assumed it was all broken shit. The worse thing that can happen in vanilla Tactics is area damage caused by 12 gauge or bursts, but this is clearly not a critical miss. I don't think I'm inventing something if I say : consider it entirely broken to start with.

I'll do a little more poking to see if I can find the routine that applies the critical miss behaviors, but otherwise I'll just add a scripting hook at the current code. Any thoughts on whether I should leave the "critical miss = guaranteed miss" behavior that currently exists? (Testing shows that even burst, cone, and area weapons miss entirely when the critical miss check succeeds.)

As for the poison, it works, but as soon as you change damage type other than normal (fire, electricity, etc.), no poison will be applied. It might not be a bug, but it is a bit bad. So, no "explosive poison" guys, it just don't work. :P

That's interesting. I might check the behavior of the poison damage application to see what it's doing.

As for the radiation, it seems even more weird. I made tests a while back because I was using constant radiation as a hunger meter. I realized that radiation resistance either protect you (100%+) or do nothing (less than 100%). I tried and I tried to lower radiation intake with raditation resistances from 10% to 90%, but if you receive 100 rads and you have 90% resistance, from experience I think you still receive 100 rads. I would understand if, let's say, you took 1 rad and then 90% resistance still give you 1 rad. But 100? I think radiation was so much unused in the game that they didn't bother.

I've seen this too - my test character (a ghoul) was taking 10 radiation damage each long tick from the radiation pool, which was set to strength 10. Interestingly, though, it appears weapons which have a secondary effect of "radiation" will have that damage reduced.

As for the bonsai perk, the only way I always understood it was that fruit were supposed to appear "from time to time" (https://fallout.fandom.com/wiki/Bonsai), so it should in theory have nothing to do with combat at all. You should even be able to sit there, and act as fruit tree as long as you want hehe. If you want to add some code to create a fruit at random intervals, I think that would be the best option to me, as it might be very moddable afterwards (change the fruit for another item, use the code to spawn items if some other conditions occur, etc.)

That's likely what I will do. Basic inventory manipulation will be in 0.50, since all of the other entity types will be done at that point. Just need to set a check in OnLongTick, at whatever interval seems appropriate, then just add 1 fruit entity to inventory.

This made me think about something here... Following this strange behaviour code, could it be easy to integrate in 0.50a a LUA code to permanently change a character's team color when a specific .ent item is worn? You already have a clue on how to apply a color. Considering that all armors could be added in the code, we would get a way to setup character color based on armor worn. Maybe I'm a bit too optimistic here ha

Almost. The color change in the entity can be made when I get hooks for equipment change. The one thing I'm not sure of is when the game reloads the sprites for the character - even though the base color is changed, it isn't immediately reflected in the sprite (I saw the same thing when I was poking colors with the debugger). Once I see the routine that changes armor, I may be able to find a "sprite reload" function, and hopefully calling that will update colors too.
 
Thanks a lot for the replies! Again, trully encouraging stuff.

I really think that "critical miss = guaranteed miss" is a problem and I never care much for game balance, so it might need to be taken down as it will probably prevent all other behaviour to take place eventually, no? Or is it just a failsafe to make sure that when you miss you never hurt intended character? Again, this might be wrong as, in Fallout 2 for example, you can miss with a grenade and still hurt your target. But still I don't know what critical miss do in F2 in this case.

Oh you might be right about the need of a "sprite reload" function... I remember having tried a crafting mod in a really advanced game (Divinity 2), with the possibility to change armor colors, but the game suffered that same problem. No changes were applied until a save/load or a change of location.
 
So, a question to everyone - what, if anything, should I do to fix this? The closest to original intent would probably be to add the fruit to the inventory, and get rid of the color swap. But is the perk really worth it? Or should I modify it to work more like the original docs described (random fruit appearing at times)? Or, zero out the effect entirely and free up a perk slot for future use?

I've been watching a Let's Play recently, and your analysis of the Bonsai perk explains why Harold's texture bugs out in it. Harold starts with both Bonsai and the Way of the Fruit.



The only way Bonsai could be remotely considered useful is if the Way of the Fruit perk also had an expanded table of stronger effects. As is, bringing it to a level where it does what the description of it says would at least be an improvement. What would be a reasonable frequency for fruit spawns, though? Once per day would be too much, once per week, maybe? 3-4 days? I'd also look at how eating fruit and the WotF perk work, exactly. It seems you're not even guaranteed to get the +1 ST effect, and I have no idea if they're stackable.

Edit: Thought about it a bit more. Since Bonsai and WotF are supposed to be paired anyway, and you have discovered what Bonsai was originally supposed to do, it might be more straightforward to make Bonsai create fruit at infrequent intervals, like the description says, and have WotF add poison and radiation removal effects when the character eats fruit. Still not worth two perks, but better than it is now.

As for critical misses: the most plausible explanation would be that they ran out of time for playtesting (especially multiplayer) and decided to scrap it instead of risking having exploitable game mechanics in the shipped product. I have no idea how closely the FOT tables stick to FO1&2 - it was always fun to see an enemy's gun explode or they knocking themselves out due to Jinxed. Does Jinxed apply to enemies and party members too in Tactics? Not having critical miss effects is a bummer, but making enemy attacks miss entirely with some frequency wouldn't be completely useless.
 
Last edited:
Re: Bonsai and Way of the Fruit: I've thought about these, and will probably change them to something like the following:

a) Add a hex patch, enabled by default, to disable built in behavior of both perks, since they're pretty much broken.

b) Add a built-in script (part of the FTSE base Lua file) that enables the documented behavior of both perks - Bonsai gives fruit once a week, and WotF gives a non-stacking +2 STR for a time (+2 to make it a little bit more worth taking both perks).

c) Ensure that the above script is replaceable, so that any players or mods that want different behavior can change it. Might provide a sample case that gets closer to the (maybe) intended effect of Bonsai: Have it reduce a percentage of poison and radiation damage, and after a set amount of prevention, create a "poison fruit" or "radiated fruit". Could then have WotF give different benefits for each fruit type: still +2 STR for regular, and maybe short-term immunity to poison/radiation for the other fruits.

Re: critical miss, I will probably:

a) Document existing behavior and leave it as-is

b) Provide a hex patch (disabled by default) which will turn off the existing critical miss behavior, such that a modder could change the behavior (maybe provide a reference example as well),

c) Document the effects and chances from the leftover code, for historical purposes.

Re: Jinxed, the only things I've seen it do so far are:

a) Increase chance of critical miss, especially with low Luck,

b) Increase critical hit chance by 20% if either the attacker or the target has the trait,

c) I think I remember it also affected the HP lost from Fear the Reaper, but I'm not 100% sure about this.
 
Last edited:
Back
Top