Implementing sneak skill check before using drugs on critters

Discussion in 'Fallout General Modding' started by Zorchar, Feb 13, 2021.

  1. Zorchar

    Zorchar Still Mildly Glowing

    262
    Jun 18, 2018
    Hey guys.

    I was thinking about the fact that you can use drugs (beer, super stimpaks, psycho etc') on critters, yet most of them don't seem to mind that at all. I can get using a beer on some guy. Yeah, sure he wouldn't mind some free beer. On the other hand, being able to use jet on Mrs. Wright is a bit too much.

    So I think drug use on critters could use a bit of modding.

    One change I would like to implement, is a sneak skill check for using a super stimpak on a critter. The logic behind this is the fact that you can actually inject someone using a needle without them noticing you actually injected stuff into them. This might be hard, but plausible. They might feel a sting, or nothing at all, but may remain oblivious to the fact they have been injected with anything.

    If you succeed - swell. If you fail, I would like some response (a generic floating text for all critters will do for now) to be given, acknowledging the fact that you were caught.

    tl;tr

    How should I implement a sneak skill check for all critters (without changing each critter's script one by one) before using super stimpaks on them? And how should I implement they're response (generic float text) once caught injecting the stimpak?

    Ideas and suggestions are more than welcome :)
    Thanks.
     
  2. gustarballs1983

    gustarballs1983 Water Chip? Been There, Done That

    836
    Oct 28, 2009
    Your worries have been taken care of already...
    In sfall there's a setting called SuperStimExploitFix= or something similar. I'm sure that if you set this one to "1" it will solve the issue you have with superstimping npcs, one way or another at least...
     
  3. Zorchar

    Zorchar Still Mildly Glowing

    262
    Jun 18, 2018
    Thanks for the suggestion.
    While I do agree that this sfall setting is better than nothing at all, it doesn't really solve the issue.
    I actually do want to be able to "exploit" the super stimpak mechanic. I just want it to be harder, instead of 100% success rate, and adding repercussions for getting caught.

    EDIT: My overall goal is to keep all the different ways that you can solve quests. I think it's cool that a solution for sneaking behind a guard can be made easier if the guard is "under the influence". I just think there should be some kind of mechanism that prevents you from succeeding 100% of the time in drugging anyone you want.
     
    Last edited: Feb 14, 2021
  4. Slaughter Manslaught

    Slaughter Manslaught Vault Senior Citizen

    Dec 11, 2006
    This is a cool idea, and I am all for making sneak more useful.
     
    • [Rad] [Rad] x 1
  5. banjo_oz

    banjo_oz First time out of the vault

    42
    Mar 3, 2007
    I really like the OPs idea too. Being able to do this makes Sneak and stealth builds a LOT more useful, but being able to do it freely is very overpowered and feels like cheating. The OPs suggestion would solve both issues.

    Having only taken a very basic look with limited understanding of the scripts, is it as "simple" (LOL!) as adding a Sneak check to any "if use item x on this critter" procedure?
     
    • [Rad] [Rad] x 1
  6. Zorchar

    Zorchar Still Mildly Glowing

    262
    Jun 18, 2018
    It is! For most items anyway. Some, such as first aid kit, are probably hardcoded to pass time and to give out a massage, regardless of "script_overides" in the critter's script.
     
  7. banjo_oz

    banjo_oz First time out of the vault

    42
    Mar 3, 2007
    That's awesome. I'd do it myself but I have just started modding so really don't feel skilled enough to not cock something up!

    How is item use handled generally? I can't seem to find it in the scripts. Is it...?
    1) most critters have a "item is used on me" script section that checks what the item was and then runs code (or another script) for it
    2) items have scripts that say "when I am used, do this" (and don't care if it's the player or another critter)
    3) a master script handles all "use item on x" functions
    4) something else?
     
  8. Lexx

    Lexx Testament to the ghoul lifespan
    Moderator Modder

    Apr 24, 2005
    Here is a very simple gl script that will check what item you use on a critter and then makes them react to it (using a stealing skill roll with potential modifier). It's very basic, but should work with any Fallout 2 mod to date.

    Code:
    /*
    
       Check if player is using drugs on critters and have them react to that.
    
    */
    
    /* Include Files */
    #include "define.h"
    #include "command.h"
    #include "sfall/main.h"
    
    /* Standard Script Procedures */
    procedure start;
    
    procedure useobjon_handler;
    
    #define good_drug                (obj_pid(item == PID_STIMPAK)
    #define soft_drug                (obj_pid(item) == PID_BEER or obj_pid(item) == PID_BOOZE or obj_pid(item) == PID_ROENTGEN_RUM or obj_pid(item) == PID_GAMMA_GULP_BEER)
    #define hard_drug                (obj_pid(item) == PID_SUPER_STIMPAK or obj_pid(item) == PID_PSYCHO or obj_pid(item) == PID_JET)
    
    #define crit_fid                 obj_art_fid(target)
    #define crit_loser               (crit_fid == FID_NMLOSR)
    #define crit_hooker              (crit_fid == FID_NFTRMP)
    
    #define target_can_see_dude      obj_can_see_obj(target, dude_obj)
    
    variable STEAL_MOD := 0;
    
    procedure start begin
       if (game_loaded) then begin
          set_global_script_type(0);
          register_hook_proc(HOOK_USEOBJON, useobjon_handler);
       end
    end
    
    procedure useobjon_handler begin
       variable
          target := get_sfall_arg,
          source := get_sfall_arg,
          item := get_sfall_arg;
    
       // Check using a drug on non-party member critters
       if ((source == dude_obj) and (obj_type(target) == OBJ_TYPE_CRITTER) and not(obj_in_party(target))) then begin
          // Change modifier based on critter graphic
          if (crit_loser or crit_hooker) then begin
             STEAL_MOD := 50;
          end
          else STEAL_MOD := 0;
    
          // Detect player interaction
          if (target_can_see_dude and not(is_success(roll_vs_skill(dude_obj, SKILL_STEAL, STEAL_MOD)))) then begin
             set_sfall_return(0);
             if (soft_drug) then begin
                float_msg(target, g_mstr(random(3054, 3058)), FLOAT_COLOR_BAD);
             end
             else if (hard_drug) then begin
                float_msg(target, g_mstr(random(3060, 3062)), FLOAT_COLOR_BAD);
                set_self(target);
                attack(source);
             end
          end
       end
    end
    

    /Edit:
    For vanilla Fallout scripts, item use is checked in the critter script use_obj_on_p_proc procedure. But as can be seen in my example above, we can also hook into it via Sfall global scripts. Stuff like first aid kits is hardcoded, but I guess their behavior can also be overridden by a script similar to what I posted above.
     

    Attached Files:

    Last edited: Apr 25, 2021
    • [Rad] [Rad] x 2
  9. banjo_oz

    banjo_oz First time out of the vault

    42
    Mar 3, 2007
    Thanks so much for the script and explanation.

    I thought that was how it was done (per critter) but for some reason I must have been looking at ones you can't use items on normally anyway! LOL!

    Had no idea bout hooking via sfall, which pretty much solves the issue of editing every critter for this purpose. Can't wait to try out your script! Does it work for using the poison syringe on someone too? If I'm reading it right, it seems like it works easier to give drugs to "losers" and "hookers" (model types) which made me laugh. :)

    This really is a great idea by the OP I feel, too.
     
  10. Lexx

    Lexx Testament to the ghoul lifespan
    Moderator Modder

    Apr 24, 2005
    Dunno. The issue with solutions like that is that they can feel very generic. For example, right now every critter will float the same random lines. If you want to get rid of that, it's probably better to write a custom config .ini file with lots of additional data which the script can run against. Suddenly it becomes a lot more work ... and then it's again the question of, is it worth it?
     
  11. Zorchar

    Zorchar Still Mildly Glowing

    262
    Jun 18, 2018
    Thank you Lexx for the script. Very elegant, as always:)