Need help with a script

Discussion in 'Fallout General Modding' started by DForge, Nov 25, 2011.

  1. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    I need help with the WCSecBot script. I have used it as a script for the map encounter with robots in my mod, however, it doesn't work too well because it's full of unnecessary SAD triggers. It results in the robots not attacking on sight, like they should in a encounter. I could give them a script made for raiders, but that would just make them throw raider floats in the battle, and that would look retarded.

    So, is there anyone who can simply make me a version of WCSecBot that has the "attack on sight" without the unnecessary SAD stuff?

    Also...

    I made a couple of special encounters. I want them to repeat until the player has actually beaten them (killed everyone hostile). I take it that Counter:1 in worldmap doesn't really work and it takes a GVAR? However, I'm dumb as a rock in this. If anyone knows how to do this, please help. And by "how to do this" I mean "do it for me" since giving me instructions on how to script is hopeless.

    I have 4 encounters that happen after the defeat of enclave (Enclave revenge teams). They are meant to be special encounters, so after you killed a team, I want it to stop popping, however if you avoid it via outdoorsman, I want it to keep popping.

    After those 4 are done, I want a "final" encounter in the game.

    I take it that making it work like Morton script would be the best: killing any of the unique 4 encounters would push the counter up by 2 and there would be a if gvar>7 for the final encounter. I am however too stupid to do this. Anyone willing to help?


    I took care of everything else. Only those two things remain...
     
  2. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Something like this?
    Code:
    #include "..\headers\define.h"
    
    #define NAME                    SCRIPT_RNSECBOT
    
    #include "..\headers\command.h"
    
    #define PID_ROBO_ROCKETS                PID_ROBO_ROCKET_AMMO
    
    #define ROCKET_MIN                      (2)
    #define ROCKET_MAX                      (3)
    #define BULLETS_MIN                     (1)
    #define BULLETS_MAX                     (3)
    #define SHELLS_MIN                      (1)
    #define SHELLS_MAX                      (3)
    
    procedure start;
    procedure critter_p_proc;
    
    #define LVAR_Ammo_Rocket                (5)
    #define LVAR_Ammo_5mm                   (6)
    #define LVAR_Ammo_Shells                (7)
    #define LVAR_Initialized_Ammo           (8)
    
    variable starttile := 0;
    
    procedure start begin
       variable Ammo1;
       variable Ammo2;
       variable Amount1;
       variable Amount2;
       variable Weapon1;
       variable Weapon2;
    
       critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_TEAM_NUM,TEAM_SIERRA_BASE);
       critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_AI_PACKET,AI_TOUGH_BOT);
    
       if (local_var(LVAR_Initialized_Ammo) == 0) then begin
           set_local_var(LVAR_Initialized_Ammo,1);
           if (obj_pid(self_obj) == PID_MISSILE_BOT) then begin
               if (random(0,1) == 1) then begin
                   Ammo1:=create_object(PID_ROBO_ROCKETS,0,0);
                   Amount1:=random(ROCKET_MIN,ROCKET_MAX);
    
                   Weapon1:=create_object(PID_ROBO_ROCKET_LAUNCHER,0,0);
    
                   set_local_var(LVAR_Ammo_Rocket,Amount1);
                   set_local_var(LVAR_Ammo_5mm,-1);
                   set_local_var(LVAR_Ammo_Shells,-1);
               end
               else begin
                   Ammo1:=create_object(PID_5MM_AP,0,0);
                   Amount1:=random(BULLETS_MIN,BULLETS_MAX);
    
                   Weapon1:=create_object(PID_MINIGUN,0,0);
    
                   set_local_var(LVAR_Ammo_Rocket,-1);
                   set_local_var(LVAR_Ammo_5mm,Amount1);
                   set_local_var(LVAR_Ammo_Shells,-1);
               end
    
               add_mult_objs_to_inven(self_obj,Ammo1,Amount1);
               add_mult_objs_to_inven(self_obj,Weapon1,1);
           end
           else if (obj_pid(self_obj) == PID_TOUGH_MISSILE_BOT) then begin
               Ammo1:=create_object(PID_ROBO_ROCKETS,0,0);
               Ammo2:=create_object(PID_5MM_AP,0,0);
    
               Amount1:=random(ROCKET_MIN,ROCKET_MAX);
               Amount2:=random(BULLETS_MIN,BULLETS_MAX);
    
               Weapon1:=create_object(PID_MINIGUN,0,0);
               Weapon2:=create_object(PID_ROBO_ROCKET_LAUNCHER,0,0);
    
               add_mult_objs_to_inven(self_obj,Ammo1,Amount1);
               add_mult_objs_to_inven(self_obj,Ammo2,Amount2);
               add_mult_objs_to_inven(self_obj,Weapon1,1);
               add_mult_objs_to_inven(self_obj,Weapon2,1);
    
               set_local_var(LVAR_Ammo_Rocket,Amount1);
               set_local_var(LVAR_Ammo_5mm,Amount2);
               set_local_var(LVAR_Ammo_Shells,-1);
           end
           else if (obj_pid(self_obj) == PID_ROBOBRAIN) then begin
               Ammo1:=create_object(PID_SHOTGUN_SHELLS,0,0);
               Amount1:=random(SHELLS_MIN,SHELLS_MAX);
    
               Weapon1:=create_object(PID_COMBAT_SHOTGUN,0,0);
    
               add_mult_objs_to_inven(self_obj,Ammo1,Amount1);
               add_mult_objs_to_inven(self_obj,Weapon1,1);
    
               set_local_var(LVAR_Ammo_Rocket,-1);
               set_local_var(LVAR_Ammo_5mm,-1);
               set_local_var(LVAR_Ammo_Shells,Amount1);
           end
       end
    end
    
    procedure critter_p_proc begin
       if (obj_can_see_obj(self_obj, dude_obj)) then begin
          attack(dude_obj);
       end
    
       if (not anim_busy(self_obj)) then begin
          reg_anim_clear(self_obj);
          reg_anim_begin();
          animate_move_to_tile(tile_num_in_direction(starttile, Random(0, 5), Random(3, 10)));
          reg_anim_end();
       end
    end
     
  3. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    well, it looks like Greek to me :) But I'm guessing this is what I'm looking for. If only I knew how to compile sfall scripts :P

    thank you very much!

    Now all I need is a way to prevent unique encounters from re-popping.
     
  4. Ardent

    Ardent A Smooth-Skin
    Modder

    678
    Jul 24, 2009
    There's a parameter in the encounter tables called "Counter". With it, you can determine the number of times this encounter can be triggered. Alternatively, you can set up a global variable, flip it to 1 in one of the encounter scripts, and set up a condition in worldmap.txt that the encounter can only take place when the variable == 0.

    More details on editing random encounters here.
     
  5. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    Unfortunately, setting global variables is something I have no clue how to do.

    I'm not sure the "Counter" parameter does work... can anyone confirm that?
     
  6. Darek

    Darek is currently unavailable

    Jan 7, 2008
    He, I just cut out all the unnecessary stuff from the WCSECBOT script and added the attack on sight part from ECALIEN.SSL. OH, and I changed it to use the tough bot AI. I haven't actually tested it.
    What it is supposed to do is give the robots weapons depending on what type of bot they are (original code). If it's a normal missile bot it will either get a rocket launcher or a minigun, if it's a tough missile bot it will get both, and if it's a robobrain it will get a combat shotgun.
    The amount of ammo they get is somewhat randomized. None of it is really needed as you can just set that up in worldmap.txt (I'm guessing you have to choose only one way to do it as I expect having both will give you a double set of weapons and ammo).

    The important part is in 'procedure critter_p_proc', where the bot is told to attack if he sees you or otherwise walk around randomly.

    Anyway, you can grab it here if you want it.

    As for using the "counter" in worldmap, it won't really work if you have to beat your opponent for it to count. The game will not know whether you have killed your enemies or just run away from them. You will have to have a global variable to tell when to stop getting an encounter in that way.

    You add your global variable in VAULT13.GAM and then you will have to include it in your script as well.
    I don't know exactly what you have in mind but you could do something like this if your encounters are sequential:

    Let's say your global variable number is 1000. You add that to procedure destroy_p_proc (what happens when the critter dies).

    Code:
    procedure destroy_p_proc begin
    	set_global_var(1000, global_var(1000) + 1);
    end
    If your first encounter have 8 enemies (with the same script), your G_var will go up by 1 for every one of them you kill.
    So when you have killed everyone in your first encounter, your G_var will be 8. So that would be what you would set your second encounter to start in worldmap, at 8.

    enc_00=Chance:2%,Enc:(4-7) Enclave_remnants AMBUSH Player, If (Global(1000) < 8)
    enc_01=Chance:2%,Enc:(4-7) Enclave_remnants2 AMBUSH Player, If (Global(1000) >= 8) And If Global(1000) < 16)
    enc_02=Chance:2%,Enc:(4-7) Enclave_remnants2 AMBUSH Player, If (Global(1000) >= 16) And If Global(1000) < 24)
    etc..
     
  7. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    Thanks for the script!

    By the way, to add a new critter, do I have to work with that horrible mapper program? Because adding a new *.pro and pid number doesn't really do anything (when the encounter with the new critter is meant to be played, it just goes back to world map instantly).
     
  8. Lexx

    Lexx Testament to the ghoul lifespan
    Moderator Modder

    Apr 24, 2005
    Well, you either have to create a new proto object via one of the few editors around (which is highly unhandy, imo) or you do it via mapper (which is much easier and faster). You can't simply copy&paste a proto file and just change the number. That's not going to work.
     
  9. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    I consider the mapper one of the worst tools ever. But I'll try :(
     
  10. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    Darek, when I use your script, Floating eye bots (the one with melee weapons) work fine. But brain bots still don't attack on sight, UNLESS they have no gear defined in worldmap (but the scripts fails to provide them with the guns too and they end gearless)

    could you remove the parts that spawn weapons for bots? I suspect it's that part's fault?
     
  11. Darek

    Darek is currently unavailable

    Jan 7, 2008
    DForge, nothing wrong with the script. After all, it's original code :P

    I'm pretty sure the problem is that you are using the BRAINBOT pid (Skynet) instead of ROBOBRAIN (pid 16777291) that is specified in the script.

    Sure I can remove the weapon code or change the pid in the script, but first try to use the pid I wrote above in your worldmap file.
    And like I said before, don't give them gear in worldmap too when you use that script.
     
  12. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    I'm using the 291 one. Double-checked. When I used 295, the brainbots weren't even generated.

    Removing their weapons (in worldmap.txt) ends with them being unarmed, however working properly.

    I'm not sure what went wrong here. They only fire back when attacked, unless they are unarmed (that makes them join the melee bots and rush towards you in the 1st turn). In any other case they are not hostile.


    Oh, and also, I just can't get to do anything with that mapper tool. I set a new critter, pick the frm, set stats, and it's not saved nowhere. I exit the mapper, open it again and it's gone...
    how to save critters made by mapper?

    Working with that tool reminded me how horrible it is :(
     
  13. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Strange then. I just tested the script and it works well for me.
    Did you add the script to scripts.lst and enter the number correctly in worldmap?
    There was however a problem with the bots moving around when they don't see you, I forgot to add that part, but have updated the script in my earlier link.

    as for your mapper problems, do a search, it has come up a few times before. Sorry but I have a date with my bed...
     
  14. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    I think I know the problem... I typed

    rnsecbot.int ; Random Encounter with Bots # local_vars=0


    guess local_vars shouldn't be 0 :P

    I entered 4. While it's annoying that the bots waste AP by equipping their gun (makes the encounter easier), it at least works. Thanks!

    I have another problem though:

    [Encounter: Brain_Horde]
    type_00=pid:16777291, Script:1549
    position=Surrounding, Spacing:3

    enc_00=Chance:80%,Enc:(8-9) Brain_Horde

    is there anything wrong here? Every time I encounter them, it's just a single brain bot ... I looked up the radscorp encounter, it's similarly written yet it works and mine doesn't.
     
  15. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    EDIT: okay, turns out I'm an idiot. without ratio=x%, the game won't generate more than 1 critter, no matter how many you set in encounter table.

    Either way, now all that's left is to get the mapper to save critters and to set a script.

    I like the idea of kill count. All unique encounters use a special critter (enclave squad leader, legendary deathclaw). Killcount >1 for deathclaw and >5 for enclave would end those encounters. Seems very easy to do. Need to set that GVAR and script... but how to make the script work?

    EDIT2: I managed to deal with the mapper. The protos are ready and working... all that's left is to set GVARS now.

    EDIT3: I made the scripts myself, hope it works. Can't compile it on 64bit windows tho, so can someone compile them?

    http://www.mediafire.com/?kb0p6838q67m006
     
  16. Darek

    Darek is currently unavailable

    Jan 7, 2008
    I tried to download them but all I get is an empty rar file at 20b.
     
  17. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
  18. Darek

    Darek is currently unavailable

    Jan 7, 2008
    DForge, here are the scripts.
    I included a version of the bot script without any weapons code in case you prefer it that way.

    For someone who just earlier said the code looked like Greek, good job. :)
    You only missed an op_ in front of the lines you added.
    If you use int2ssl to decompile a script you don't have to deal with all that op_ crap (and I can't compile those scripts anyway). So I decompiled the original scripts and added your changes to destroy_p_proc to them. There were no other changes, were there?

    By the way earlier
    Is this so? I've been under the impression that they don't spend any AP on arming/changing weapons. I'm not swearing on it, but that's the impression I've got.
     
  19. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    yes, there are no other changes, I just added that line. Thanks a lot for all your help. :)

    I'm kinda curious what's that "op_" you mentioned for. Either way, thanks again :)

    With the scripts done, the mod will be ready really soon, all it takes now for me is to finish up the encounter tables. :)
     
  20. DForge

    DForge Look, Ma! Two Heads!

    343
    Jul 29, 2006
    One more problem...

    there's this encounter in RP:

    {5320}{}{A gathering of important looking individuals.}

    referring to the endgame easter egg

    However, there's no enc_20 corresponding...

    should I leave enc_20 empty and get enc_19 and then enc_21?

    OR should I send that "a gathering"... to the last position of each table of worldmap.msg?