Misc. odd behaviors in combat engine

Discussion in 'Fallout Tactics Modding' started by Melindil, Oct 14, 2019.

  1. Melindil

    Melindil First time out of the vault

    67
    Apr 15, 2018
    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?
     
  2. nadeauhugo

    nadeauhugo Author of FOT mod THE SUM Modder

    460
    Mar 9, 2014
    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.)
     
  3. nadeauhugo

    nadeauhugo Author of FOT mod THE SUM Modder

    460
    Mar 9, 2014
    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
     
  4. Melindil

    Melindil First time out of the vault

    67
    Apr 15, 2018
    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.)

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

    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.

    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.

    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.
     
  5. nadeauhugo

    nadeauhugo Author of FOT mod THE SUM Modder

    460
    Mar 9, 2014
    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.