Complete noob tutorial

Discussion in 'Fallout General Modding' started by FeelTheRads, Jul 22, 2018.

  1. FeelTheRads

    FeelTheRads Vault Senior Citizen

    Sep 15, 2004
    For example artemple.ssl
    From the official scripts.

    And since you brought it up, what is the map index and why would you want to check it? :p

    Edit:
    And in addition to that, some map scripts have this, with different tile numbers, of course:

    Code:
    set_map_exit_tiles(8285,22658);
    For example denbus1.ssl

    Why? The exit tiles are set in the mapper anyway, no?

    Edit2:

    A non-related question:
    Is there somewhere I can see all the sound ID codes for the various type of objects? Like a list saying what code does what sound and so on.
     
    Last edited: Aug 10, 2018
  2. FDO

    FDO First time out of the vault

    Jul 4, 2018
    Hm, you are right, I had forgotten about the start map set_global_var(GVAR_LOAD_MAP_INDEX,0)
    Seem I copied it on my own start map script without given it too much thought, I don't even know if it does something useful in my case, my first map being unaccessible after moving on. Doesn't do anything to the rest of the script though, I guess I might just take it out.

    About the map index, it's a characters script thing for me.
    A simple example from vanilla I used as inspiration for floating dialogs:
    Code:
          if( cur_map_index == MAP_VAULTCITY_COURTYARD ) then
             call Node2001;
          else if( cassidy_doesnt_like_area ) then
             call Node2002;
          else if( ( cur_map_index == MAP_DEN_ENTRANCE ) or ( cur_map_index == MAP_NEW_RENO_1 ) ) then
             call Node2003;
          else if( cur_map_index == MAP_SAN_FRAN_CHINATOWN ) then
             call Node2004;
          else if( cur_map_index == MAP_ENCLAVE_DOCK ) then
             call Node2005;
          else if( cur_map_index == MAP_REDDING_DOWNTOWN ) then
             call Node2006;
          else if( cur_map_index == MAP_BROKEN_HILLS1 ) then
             call Node2007;
          else if( ( cur_map_index == MAP_VAULTCITY_DOWNTOWN ) and ( tile_distance( tile_num( self_obj ), 16056 ) <= 10 ) ) then
             call Node2018;
    If compiled with sfall script tool, the map names in the compiled script will become the numbers attributed to maps in data/data/maps. Of course, map index condition can be used for complex dialogs or other characters actions/reactions.

    The exit tile, no idea yet, I haven't been modding this engine long either. Since normal grids are defined in the mapper indeed, maybe this set_map_exit_tiles create/unhide a new exit grid not visible at first? Just speculating, but as with all commands the best approach would be to understand the context of the script it's part of. I tend to focus on adapting what I need to new scripts rather than trying to understand every lines, then trials and errors do the rest to make me understand. (just my personal approach)

    You can see what sound id is attributed to a item with the fallout 2 proto manager tool by mr Stalin.
     
  3. FeelTheRads

    FeelTheRads Vault Senior Citizen

    Sep 15, 2004
    Thanks!

    If you or anyone else has some time for another question.... about the dcorphan.ssl script, specifically the part where it tries to steal caps.
    First there's a roll to determine how much it will try to steal. Let's say it rolled for 80 and the variable will be called "item"

    So, we have:
    Code:
    item := 80;
    Then comes this part in the script:
    Code:
    item := item - (item % dude_caps);
    item_caps_adjust(dude_obj, -item);
    item_caps_adjust(self_obj, item);
    So, if I'm reading this correctly, if dude has less than 80 caps there's some weird stuff going on.
    For example, if he has 40 caps then the result will be:
    Code:
    item:= 80 - (80 % 40) = 80 - 0 = 80
    On the other hand if he has 41 then the result will be:
    Code:
    80 - (80 % 41) = 80 - 39 = 41
    And it seems the further dude is away from 40 the more will be attempted to be stolen from him.

    Of course, if the result is bigger than the dude total caps then actually nothing will be stolen from him, because it looks like item_caps_adjust does nothing if you try to subtract more than the total.

    So basically this means that if the total caps amount the dude has is less than half of the original roll then nothing will be stolen from him.
    But if he has more than half then everything will be stolen from him.

    So, I thought this was done so you won't get money stolen from you if you don't have that much.

    But, well, if you actually have more than the original roll then you're also fine. Say if you have 100. Because then the end result will be:
    Code:
    item:= 80 - (80 % 100) = 80 - 80  = 0
    So nothing will be stolen.

    However, the kid still gets money as long as the final result is more than 0, even if nothing is taken from you.

    Am I reading this correctly? My testing says that I am, but maybe I'm missing something since I only understand some basic scripting and if gets into math stuff then brian start hurtz.

    Sure, could be that all this is intended, like if you have over a certain amount of caps you don't get robbed since it won't make much of a difference anyway.

    There's also some other weird things in this script... like there's a MAX_WEIGHT defined which I assume it was supposed to be used so the kids can't steal items heavier than that but I don't see it used.
     
    Last edited: Aug 16, 2018 at 2:12 PM
  4. TorontRayne

    TorontRayne YOU CANNOT UNDERSTAND THIS TITLE Staff Member Moderator Orderite

    Apr 1, 2005
    The Den - the number one reason to have the "Kill a kid" mechanic. This always seemed bugged to me when I was younger. So I was right?
     
  5. FeelTheRads

    FeelTheRads Vault Senior Citizen

    Sep 15, 2004
    And another question related to this. How does "is_critical" work?

    In the orphan script to determine how much money the kid will attempt to steal there's this:

    Code:
    item := random(MIN_MONEY + (MIN_MONEY * is_critical(Skill_Roll)),MAX_MONEY + (MAX_MONEY * is_critical(Skill_Roll)));
    Which gives more money in case critical=1...which would make sense if it checked for a critical success.

    But in the old version of this script (not 1.02) there was also this

    Code:
     end else if ((is_critical(Skill_Roll)) or (is_success(do_check(dude_obj,STAT_pe,PERCEPTION_BONUS)))) then begin
                debug_msg("Orphan Critically Failed at stealing.");
    Here it looks like critical=1 is considered a failure.

    OK, so that was in a non-updated script. But in the updated zimtldor.ssl for example there's this

    Code:
    
          /* Critical Success of a Traps Check  (Start)*/
    
                   if (is_critical(Traps_Check)) then begin
    
                       if (is_success(Locks_Check)) then begin
                           if (is_critical(Locks_Check)) then begin
                               display_msg(mstr(102));
                           end                                      // critical success (Locks)
    
                           else begin
                               display_msg(mstr(103));
                           end                                      // regular success (Locks)
                       end
    
                       else if (is_critical(Locks_Check)) then begin
                           display_msg(mstr(104));
                       end                                          // critical Failure (Locks)
    
                       else begin
                           display_msg(mstr(105));
                       end                                          // end of regular failure (Locks)
                   end       
     
    and then a bit lower
    Code:
    /* Critical Failure of a Traps Check  (Start)*/
    
               else if (is_critical(Traps_Check)) then begin
                   if (is_success(Locks_Check)) then begin
                       if (is_critical(Locks_Check)) then begin
                           display_msg(mstr(110));
                       end                                          // critical success (Locks)
    
                       else begin
                           display_msg(mstr(111));
                       end                                          // regular success (Locks)
                   end
    
                   else if (is_critical(Locks_Check)) then begin
                       display_msg(mstr(112));
                   end                                              // critical Failure (Locks)
    
                   else begin
                       display_msg(mstr(113));
                   end                                              // end of regular failure (Locks)
              end                                                   // critical Failure (Traps)
    
    It's the exact same code, just displaying different messages?

    Edit: Alright, after posting this I realized I might have figured out how it works...
    So, first it's checked if the roll is a success and then it's checked if it's critical... if it was a success then obviously it was a critical success.
    Else if the roll was not a success then it's checked for a critical and if it is, then it will be a critical failure... obviously.

    Is that correct?
     
    Last edited: Aug 16, 2018 at 11:01 PM
  6. FDO

    FDO First time out of the vault

    Jul 4, 2018
    The way I am reading procedure Attempted_Theft in DCORPHAN:
    Code:
    procedure Attempted_Theft begin
       variable Inven_Roll;
       variable Skill_Roll;
       variable item;
       variable count;
    
       Skill_Roll := roll_vs_skill(self_obj, SKILL_STEAL,STEAL_BONUS);
       if (is_success(Skill_Roll)) then begin
          if (random(1,10) <= 3 + (2 * is_critical(Skill_Roll))) then begin
             Inven_Roll := random(0, (inven_count(dude_obj)-1));
             item := inven_ptr(dude_obj, Inven_Roll);
             if ((critter_inven_obj(dude_obj,INVEN_TYPE_RIGHT_HAND) != item) and (critter_inven_obj(dude_obj,INVEN_TYPE_LEFT_HAND) != item) and (critter_inven_obj(dude_obj,INVEN_TYPE_WORN) != item)) then begin
                debug_msg("\nOrphan Stole Inventory Item #"+Inven_Roll+".");
                count := rm_mult_objs_from_inven(dude_obj, item, 1);
                add_mult_objs_to_inven(self_obj, item, 1);
             end
          end else if (dude_caps > 0) then begin
             item := random(MIN_MONEY + (MIN_MONEY * is_critical(Skill_Roll)),MAX_MONEY + (MAX_MONEY * is_critical(Skill_Roll)));
             item := item - (item % dude_caps);
             item_caps_adjust(dude_obj, -item);
             item_caps_adjust(self_obj, item);
             debug_msg("Orphan Stole "+item+" NCR Brahma Bucks.");
          end
    The dude caps are stolen only if he/she has nothing else in the inventory, and if there is caps. How many is somewhere between the MIN and MAX_MONEY defined at the beginning of the script.
    I can't find a item := 80; anywhere in the versions I have, updated vanilla, UP and RP?
    So I am not sure if your calculations have a start point? You sure it doesn't come from a otherwise modded dcorphan, and that it is supposed to be a caps number?
    I wish I could tell you more based on tests of mine but my plans to have pickpocket gangs in my mod turned out with several versions, story wise and I am not decided on which is good if any, so I didn't try anything with thiefs npc yet.

    I think you are right about critical success/failure.
     
  7. FeelTheRads

    FeelTheRads Vault Senior Citizen

    Sep 15, 2004
    Oh, no, the 80 was just a number I chose to do my calculations. It's a random number between 20 and 100 (or 40 and 200 with critical success).
    When I said item:=80 I was unclear, sorry, I just meant if the random number was 80.

    And yeah, they steal money only if they fail to steal an item.

    So my question was mostly about this part:
    Code:
    item := item - (item % dude_caps);
    Which according to my calculations and tests does what I said above... no money is stolen if dude has more caps than "item" and stuff like that.

    Just for my testing I modified it to:
    Code:
    end else if (dude_caps > 0) then begin
             item := random(MIN_MONEY + (MIN_MONEY * is_critical(Skill_Roll)),MAX_MONEY + (MAX_MONEY * is_critical(Skill_Roll)));
    
             if (dude_caps <= item/2) then begin
                   item := 0;
                end
             else if (item > dude_caps) then begin
                   item := dude_caps;
                end
    item_caps_adjust(dude_obj, -item);
    item_caps_adjust(self_obj, item);
    
    Which makes it so you don't get stolen from if you have less caps than half of "item". Kinda like it seems to work in the original script. But the orphan also doesn't make money out of thin air unlike the original script.
    And it also makes it that if "item" is more than dude's caps it gets set to dude's caps, because as mentioned in the previous post, if you try to subtract a number bigger than the total caps then nothing is removed.
    And finally because I removed that brain hurting modulo line, you will get stolen from even if dude_caps > item. Because in the original script if dude_caps>item it makes that modulo line always result in
    Code:
    item := item - item
     
    Last edited: Aug 17, 2018 at 11:35 PM