Tragic global script question

Discussion in 'Fallout General Modding' started by Zaius238, Feb 3, 2017.

Tags:
  1. Zaius238

    Zaius238 Sunburn

    137
    Jul 14, 2007
    I've been doing some small changes to the game, like adding new items, making Power Armor require training so the player can't 'power game' and ruin the fun, instantly becoming a demigod, etc.
    One of the things I want is a kind of survival mode, so I used the Tragic script as example and modified so that it reduces the dude strength and endurance after ~2 weeks (I 'hunted' for scripts where a timer was added, and the one in tragic script is the nearer thing to what I had in mind. Good job, whoever created it). The characer is getting hungry so his strength and endurance is reduced.
    The problem is that I can't make the script run multiple times. I want the script to stop when the player eats, and reset.
    For an addiction is great (the gltragic script), it makes the dude stop in his travels and describes his urge to 'get moar!', and it ends, but for this mod it's not so great.
    I tried removing do_once from the script, but when I do that the script stops working, unfortunately.
    Something that would be awesome is if I could use a command like while (), but I doubt the Fallout language allows that. I know this place is frequented by some epic modders, so I thought about asking the vets for some advice.
     
  2. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Fallout's SSL already supports the while loop, if that's what you want to use.
     
  3. Lexx

    Lexx Background Radiant
    Moderator

    Apr 24, 2005
    Do you really need a global script for that stuff? Sounds to me like it could work perfectly fine in obj_dude.ssl with variables and a simple timer.
     
  4. Zaius238

    Zaius238 Sunburn

    137
    Jul 14, 2007
    In case someone is interested in using my mods, I'll be posting them here.
    The first one is a small mod, that was created after I finished my playthrough of Fallout 1.5, aka Fallout Ressurection.
    I liked the fact that the world was dark in the mod, so much that children getting killed wasn't something that made complete strangers hunt your head like it was their only reason to live, or someone pay mountains of coins just to get you assassinated.
    What this mod does - as you have probably guessed already:
    - NPCs (even Sulik and your other friends) don't give a damn if you killed a kid. Traders will no longer refuse to buy/sell things with you, just because you killed a little thief or reacted aggressively after one of them threw a frag granade at you.
    - No more out of place random encounters with knights of holy justice that magicaly get more advanced equipment with time, no one will waste their misarable lifes trying to capture a tribal.
    - Changes child killer image (Don't worry, you can keep original file. It's explained in the text file).

    Version a:
    Compatible with Restoration Project, nothing else
    http://www.filedropper.com/justrp233

    Version b:
    Compatible with Restoration Project + the excellent EcCo mod
    http://www.filedropper.com/compatiblewithphobos

    Do you mind posting the exact command, to me?
    I ask that, because in my tests, the game always frooze after I tried using while, here.
    Not sure it makes any difference, but I'm using Timeslip ScriptEditor to create/edit .ssl and .int files.
     
    • [Like] [Like] x 1
  5. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Example from CAVE01.ssl:
    Code:
    while (count > 0) do begin
        call Choose_Pid;
        call placeCritter(choose_enc_pid, choose_enc_sid, AREA_1);
        count -= 1;
    end
     
    • [Like] [Like] x 1
  6. Zaius238

    Zaius238 Sunburn

    137
    Jul 14, 2007
    Strange, it still doesn't works. =(

    Here is my super mega simple global script, to test:

    procedure start;
    procedure ttest;

    variable carrying;

    procedure start begin
    display_msg("Start");
    while (obj_is_carrying_obj_pid(dude_obj, 19)) do begin
    call ttest;
    end
    end

    procedure ttest begin
    set_global_var(25,1);
    display_msg("Radaway addiction");
    end

    When I load a save where the dude is holding a rock, the game freezes, with the above.
    But when I change the script, like this:

    procedure start;
    procedure ttest;

    variable carrying;

    procedure start begin
    display_msg("Start");
    if (obj_is_carrying_obj_pid(dude_obj, 19)) then begin
    call ttest;
    end
    end

    procedure ttest begin
    set_global_var(25,1);
    display_msg("Radaway addiction");
    end

    And load the same save file, it works perfectly. Both messages appear, and the dude becomes addicted to Radaway.
     
  7. Lexx

    Lexx Background Radiant
    Moderator

    Apr 24, 2005
    I am not an expert scripter, but aren't global scripts running in a loop by default? Also if you don't limit their "refresh rate", the game keeps throwing them, which probably explains why the freeze happens.
    Also, based on my experience, there really is no reason to put a while there at all. It's wrong and the game stops till it's done (which probably really explains why your game freezes). As global scripts run constantly anyway, a simple if-block should totally do the trick.

    Other than that, my global script that runs constantly every x ticks looks like this...
    Code:
    procedure start;
    procedure start begin
       if (game_loaded) then begin
          set_global_script_repeat(5);
          set_global_script_type(1);
       end
     
       // stuff happens
    end
    
    ... with "set_global_script_repeat(x)" defining how long till it is getting called again.
     
    Last edited: Feb 4, 2017
    • [Like] [Like] x 1
  8. Zaius238

    Zaius238 Sunburn

    137
    Jul 14, 2007
    The global script above runs when I load the save file, the messages appear once in the screen.
    If I reload the same save, it repeats again but I need to reload.

    I wanted to do the simplest script possible.
    Seems strange to only happen if I use while, if the only issue is in refresh rate.
    I'll try adding the game_loaded command, it can't hurt right?

    Thanks for the example.

    EDIT: Okay, it works now.

    procedure start;
    procedure ttest;

    variable carrying;

    procedure start begin
    if (game_loaded) then begin
    set_global_script_repeat(50000); //5 or 50000, it doesn't seem to change anything
    set_global_script_type(1);

    display_msg("Start");
    while ((obj_is_carrying_obj_pid(dude_obj, 19))and(carrying != 20)) do begin
    call ttest;
    end
    end
    end

    procedure ttest begin
    carrying++;
    set_global_var(25,1);
    display_msg("Radaway addiction");
    end
    I was crazy for making it repeat infinitely Fallout 2 doesn't have the 'endurance' to keep working LOL.
    Well thanks for the help.
    It seems my idea is not possible, maybe I could create a fake addiction with the symthoms of hungriness, but script that always decreases stats and kills in a specific time is something much more complex than I thought.
     
    Last edited: Feb 4, 2017
  9. SexyDeathclaw

    SexyDeathclaw First time out of the vault

    2
    Feb 18, 2017
    I liket it, being a criminal in a world in ruins shouldn't be that difficult.
    We are talking about Fallout, not Driver or GTA, where there is always someone to pursue you, at every street.