Help a scripting retard with his script.

jargo, how about adding in new version (if not already planed) option for automatic including .h files from headers folder. just by clicking on the one of listed files it automaticlly adds full (or relative) file path in the script with all #include stuff at the place of cursor (typing cursor). just an idea :)
oh, and msg edit has bugs!

EDIT:

Oh, I have more stupid questions that i could not find answers in faq or tutorials. How do I fill the container? Is it done with mapper or with script, i just don't have a clue! I found some templates in mapper scripts but GOD they are so loooooooong. Could this posibly be the script for a container!?
 
2 Dvukomanovic:
I don't know if I got your question correctly, but: containers can be both filled with the mapper or via script (this is the case of shopkeeps containers).
Code:
procedure map_enter_p_proc begin
 Only_Once:=0;
      if (dude_is_male) then begin
         if (map_first_run) then begin
         item:=create_object(PID_FAKE_CITIZENSHIP,0,0);
         add_mult_objs_to_inven(self_obj,item,1);
         end
     end
end
Just an example for a non shopkeep related container...

2 Jargo: just a curiosity... When are you releasing FSE latest version? I'm just drooling here, you know...
 
In the mapper, to add items to a container (or to critter inventory), select the item (or critter) button, click on the container or critter, click EDIT, then you can select "Add to Inventory" and pick the items to be added. In my FO2XP mod, I do some random contents generation like this:
Code:
procedure map_enter_p_proc begin
    if (map_first_run) then begin
        call clearInvenAll(self_obj);
        call createRandomItem(self_obj, item_subgroup_primitive, 1, 1,  100, 80);
    end
end
The clearInvenAll and createRandomItem are new commands I added.
 
I'm sorry, I can't follow... where is this Add to inventory?
scr000007nt.jpg


is there a newer version of the mapper?


Ok, i found it! ;)

I never knew you can select instance on the map :roll: :lol: :wink:
And i call myself a modder :shock: :roll: :oops:

Is there any tutorial on using Local, global and map variables?
But like on real exeple? Caus i now what are they used for i just dont know how to use them :cry:
 
jargo, how about adding in new version (if not already planed) option for automatic including .h files from headers folder. just by clicking on the one of listed files it automaticlly adds full (or relative) file path in the script with all #include stuff at the place of cursor (typing cursor). just an idea Smile
Not sure if i understand you, there is already include option in FSE just press F5 and select file done. This way it always puts #include statement in right place.

and msg edit has bugs!
Can you be more specific? Like step by step guide how to replicate that bug?

Jargo: just a curiosity... When are you releasing FSE latest version? I'm just drooling here, you know...
Well, i try to do some work on it after next NA internal demo is finished.
 
Hi Dvukomanovic. This is my opinion about using variables: there's nothing to understand. They're just multi-positions switches you set in your scripts.
You want to tell a script that dude already met a character?
In the first node you write:
set_local_var(LVAR_Herebefore,1);
Then your talk_p_proc will check the LVAR to choose the correct node when dude meets that npc again.
procedure talk_p_proc begin
if (local_var(LVAR_Herebefore) == 0) then begin
say_something
end
else begin
say_something_else
end
end

Map and global variables work in the same way, which means:
there's nothing complex to learn. The complex thing lies in actually making sure you're using the correct variable or variable value. You must plan ahead what you want to achieve, which and how many variables you are using to achieve it, and last of all make sure that your scripts check the correct variable/variable value. In short it's just a matter of mere work.
Do not tarry while learning scripting, get into variables as soon as you can: they're a mod's skeleton. There are a couple of posts around dealing with quest making. Start with a simple quest. This is the easiest and most effective way I found.
Probably my teachers Jargo and Dude_object (I'm serious) will have something to say about this, or they won't agree with me. What I simply wanted to tell you is: no need to tear down a open door. Start using vars in your scripts, it's easier than you think. Bye.
 
Hi Sirren67! Thanks for tips! You speak of LVAR_Herebefore. I noticed this variable in many scripts. Does the value it holds effect only the script it's in or all the scripts that have same LVAR_herebefore or is that the only difference between LVAR and GVAR? Where do I place them? Where do i include them (their name that is)? Where do i find step by step tutorial for, say, making quest or dialog using Local and global variables? Now that you mentioned that they are important I NEED to learn about them!

Here's what I wanna do:

Item that when read 20 times gives +1 to intelligence
It disapears after reading once (so you need to find 20 of them)
they are on different locations so i think i should use GVAR...
Name the Variable GVAR_magazine.
Now, where do i include/define it's name other than ithe script?
And how do I test it if I have not made two maps?

jargo, i had problems with edit msg when i held my files in one of my subdirectories in my documents folder. i suppose it was due to long path or somethin? After making msg file, adding entity, saving it and closing msg editor, it just could not get it re-opened for editing... now that i use fallout2 dir the problems are gone.

What i meant to say about auto including is to get a dropdown menu that lists all .h files available in HEADERS folder so that we could just go and check ones we want. I Can make "concept art" if you still don't understand my bad english :)

Oh, yeah one more thing:

what's command for making critter animates as it use somthing (like stimpack) cause when thay use my scripted items thay don't move!
 
Hi again.
A): LVARs only have effect on the script they are in. You find the same name in different scripts becouse it is commonly used, and it's easier to have the same name than inventing new ones. You can add new local vars in your scripts. Just put them in the local vars list at the beginning of the script (the critter template in FSE has such list).
B): map vars are added/registered in two files. Let's say you add a map var to artemple: in your map folder there's a file called artemple.gam. In fo2 Mapper headers folder there is a artemple.h file. Use FSE to register it (on the taskbar: script-add map variable).
If you made a new map you have to create these files (in this case create them manually, it's safer this way. Open already existing ones to see what they contain). Map variables work only in the map you registered them.
To add a map variable include the .H file at the begginning of your script (if you made a new map include this header in the map script too):

#include "..\headers\define.h"
#include "..\headers\argarden.h"
#define NAME SCRIPT_FCBARTEN

C): global variables work througout the whole game and must be registered in vault13.gam. Simply register them with FSE: you don't need to declare them in the script, simply check them. Just remeber that when you register one then OLDER saves AREN'T compatible anymore.

D): You attach a script to the magazine: when dude uses it the scripts checks if there are 20 issues. I dont think that such a script needs a variable, unless you want a one-time use in a PC's "life"

E): Check "Quest problem" by 8-Ball, it's at the beginning of page three of the modding forum.

This will be a lot of work, it's worth it though. If you have problems we're more than glad to help you out. See you and happy scripting.
 
Sirren67 said:
there's nothing complex to learn.

Well, some usage of variable can be complex. For example, you can export a pointer to an instance of an object, and another script can import that pointer and reference it. You can also do interesting things with bwand (bitwise and) and bwor (bitwise or) to store many binary (yes/no) values in a single variable. I use this method to store which animations (FRM suffixes for attacks) are available for each of the character sets.

I agree that most variable handling stuff is pretty trivial, but I'd hesitate to call it simple or not complex overall. It depends on what your script is doing, and how many other scripts or objects it might interact with. I don't think I have seen any tutorials for scripting variables, but Sirren67 summarized the important stuff well. I suggest that when in doubt, look at the FO2 sources. You can find working examples for most things that way.
 
Wow, i just got wormed and ther is so much i need to know!

Here's the scrip i've been working on:

Code:
procedure use_p_proc
begin
if (GVAR_dvmag < 20)
   begin
        script_overrides;
        gfade_out(ONE_GAME_SECOND);
        temp := random( 101, 108 );
        GVAR_dvmag = GVAR_dvmag +1;
        rm_obj_from_inven(Dude_obj,Self_obj);
        gfade_in(ONE_GAME_SECOND);
        display_mstr(100);
        float_msg(dude_obj, mstr(temp),8);
        gfade_in(ONE_GAME_SECOND);
        scr_return(1);
end else 
begin
      script_overrides;
      gfade_out(ONE_GAME_SECOND);
      rm_obj_from_inven(Dude_obj,Self_obj);
      display_mstr(109);
      float_msg(dude_obj, mstr(110),9);
      gfade_in(ONE_GAME_SECOND);
      scr_return(1);
      
 end
end

see i WANT to use "GVAR_dvmag" but i don't know how. It cheks how many times the item had been used and if that is 20 it gives +1 int (this part is not done yet). but it needs gvar set right to work. and what are the command for working with GVARS. i found set_global_var but i'm not sure how to use it!

Thanks again for all your help!
 
Uhm, let's see:
I think we're dealing with many subjects, here.
First you have to check item quantity:

if (obj_is_carrying_obj_pid(dude_obj, PID_MAGAZINE) > 19) then begin
script_overrides and so on

Second: if you use a GVAR it means you want to make something with it, for example you want to make sure dude will get the bonus only once. If you want to allow multiple uses then you don't need it.

Third: You must find another way to raise the stat, for example give dude the "gain intelligence" perk. I don't think the way you're using the GVAR will work. Sorry but I haven't tried this, so I can't say more.

Fourth: remember to destroy ALL the magazine issues (if this what you want):

remove_pid_qty(dude_obj, PID_MAGAZINE, 20)

Hope this helps. Cheers.
 
thing is I don't want him to keep 19 of them in inventory till he finds one more. I want him to read them as he finds them, and GRAV will keep track of how many did he read. That's all!

tnx for this commands... there can be found great use for them in other scripts i'm planing ;)
 
dvukomanovic said:
if (GVAR_dvmag < 20)

When not sure how some script function works, first look in the documentation that came with the mapper, then do a search for files that contain that text keyword in the FO2 script source. The mapper2 docs state this:

global_var int Map var_index(unsigned int) - Returns the value of a global variable # (var_index).

(Note: the format they used, and even the text describing these functions is some of the worst API documentation I have ever seen, but we have to live with it). Okay so we (we and I) look at that and say to ourselves say what? LOL So what I do is search -> browse for files containing the text global_var in the directory where the mapper sources are. Example from ACKLINT.SSL:

if ((tile_contains_obj_pid(21303,0,PID_TEMPLE_SKULL_POLE)) and (global_var(GVAR_START_ARROYO_TRIAL) != 0)) then begin

Notice how they don't just refer to GVAR_START_ARROYO_TRIAL in the if statement, they use global_var(GVAR_START_ARROYO_TRIAL). So in your case you need to do if (global_var(GVAR_dvmag) < 20). You first need to edit the vault13.gam and add that to the list of globals. And of course, the inverse is set_global_var, example from ARVILLAG.SSL:

set_global_var(GVAR_START_ARROYO_TRIAL,TRIAL_SNEAK);

Two parameters, the name of the variable, and the value you are setting. They are integers, so they can be used for logical 0 or 1, but you should be able to increment a counter and store the value in there.

MCA or whoever could have made those docs much simpler thusly:

global_var(int var_index) - returns the value of a global variable.
set_global_var(int var_index, int value) - sets the value of a global variable.

One of these days I'm going to make some better API docs for this stuff. The format they used is just plain confusing.
 
Cool! So, if i want to increase the value of GVAR by one I should use something like:

Code:
set_global_var(GVAR_dvmag, GVAR_dvmag +1);
Or do i need something like this:

Code:
temp := GVAR_dvmag; 
set_global_var(GVAR_dvmag, temp +1);

or

Code:
temp := GVAR_dvmag +1; 
set_global_var(GVAR_dvmag, temp);

will all three work?

Oh, will FSE edit vault13.gam automatically? (I see it won't)

Got erorr on first one... says that GVAR_DVMAG is undefined symbol.
is thera a get_global_var or something else to extract the var values and use them in calculations?

Do I have to include vault13.gam cause my script just won't work (says that GVAR_DVMAG is undefined)

Code:
procedure use_p_proc
begin
if (global_var(GVAR_DVMAG) < 19)
   begin
        script_overrides;
        gfade_out(ONE_GAME_SECOND);
        set_global_var(GVAR_DVMAG, ++1);
        temp := random( 101, 108 );
        rm_obj_from_inven(Dude_obj,Self_obj);
        gfade_in(ONE_GAME_SECOND);
        display_mstr(100);
        float_msg(dude_obj, mstr(temp),8);
        gfade_in(ONE_GAME_SECOND);
        scr_return(1);
end else if (global_var(GVAR_DVMAG) == 19)
begin
        script_overrides;
        gfade_out(ONE_GAME_SECOND);
        rm_obj_from_inven(Dude_obj,Self_obj);
        set_global_var(GVAR_DVMAG, ++1);
        critter_add_trait(dude_obj,TRAIT_PERK, PERK_gain_intelligence_perk, 1);
        display_mstr(100);
        display_mstr(111);
        float_msg(dude_obj, 112,8);
        gfade_in(ONE_GAME_SECOND);
        scr_return(1);
        end else
begin
      script_overrides;
      gfade_out(ONE_GAME_SECOND);
      rm_obj_from_inven(Dude_obj,Self_obj);
      display_mstr(109);
      float_msg(dude_obj, mstr(110),9);
      gfade_in(ONE_GAME_SECOND);
      scr_return(1);
      
 end
end
 
There is one important thing to remember when working with variables:

GVAR_dvmag - will return you the number of variable
global_var(GVAR_dvmag) - will return you value stored in this variable(in most cases this is what you want)

So to increase value of global variable GVAR_dvmag you need to write:
Code:
set_global_var( GVAR_dvmag, global_var(GVAR_dvmag) +1);
In first parameter you put number of var in second one you put value of that var.

Oh, will FSE edit vault13.gam automatically? (I see it won't)

Got erorr on first one... says that GVAR_DVMAG is undefined symbol.
is thera a get_global_var or something else to extract the var values and use them in calculations?

Do I have to include vault13.gam cause my script just won't work (says that GVAR_DVMAG is undefined

This is because GVAR_DVMAG is not registered.
In FSE registering global var is very simple:
from main menu chose Script->add global variable
Enter variable name
and optional descryption
Press ok
Done.

To check if it worked do this:
Type in script (in FSE) GVAR_ and wait a second, a window should popup with list of all registered global vars, at the very end of this list you should see your new var.

In most scripts (95%) you need only two includes:
define.h and command.h most of other *.h files are included in them.
 
thanx jargo! Now to see will it work! ;)

IT WORKED!!! HA HA! THANK YOU!!! :D :D :D :D (FLOWERS EVERYWHERE!)

hmm... for some reason script's ignoring this line:
Code:
rm_obj_from_inven(Dude_obj,Self_obj);
any idea why?

oh, game store this magazines separately... why? how to make them as one item with the count over it? (like money or stimpacks)

More questions for experts:

Say I want to make this script even more usefull. I want it go give +3 to random selectet skill. Now as i understand skills are basicly numbers assigned to a simboly. numbers would be much easer to use for rundom command. So, what's the bast way I could do this?
I'm sorry if I bore you with my stupid questions, but you guys know so much more then me... :oops:
 
dvukomanovic said:
rm_obj_from_inven(Dude_obj,Self_obj);

An item's script cannot remove itself (self_obj) from the player's inventory, because its like a circular reference. Some other script must remove the item. See this topic:

http://www.nma-fallout.com/forum/viewtopic.php?t=10789

More specifically, see this solution:
http://www.nma-fallout.com/forum/viewtopic.php?t=10789&start=8

This is already into the "variables can be complex, because you can export a pointer to an object" that I mentioned earlier :D The way that books are handled and destroyed in FO2 is ... hardcoded in the engine based on item PID number ... :roll: The solution is not perfect, but then what is in FO2 scripting?

BOOK1.SSL
--------------
#include "..\headers\define.h"
#define NAME SCRIPT_BOOK1
#include "..\headers\command.h"
procedure use_p_proc;
export variable book_ptr;

procedure use_p_proc begin
script_overrides;
book_ptr := self_obj;
add_timer_event(dude_obj, 3, 1 );
end


OBJ_DUDE.SSL
-------------------
#include "..\headers\define.h"
#define NAME SCRIPT_OBJ_DUDE
#include "..\headers\command.h"
procedure timed_event_p_proc;
import variable book_ptr;

procedure timed_event_p_proc begin
destroy_object(book_ptr);
end
 
ok, that brings another problem up!

see, i want to use TeamX Mr.Fixit, addon attached to dude_obj.int. I would have to go and edit temp.i and that is NOT GOING TO HAPPEND. :)

I think i have something here:
The items that have rm_obj_from_inven(Dude_obj,Self_obj); in it can disapear, but only if used from hands. Can I then apply something that won't let item to be used from inventory?

Oh, I edited my post before this one. I don't know if you saw what I added there... :)

Have you tried that "drug" script.
 
dvukomanovic said:
Say I want to make this script even more usefull. I want it go give +3 to random selectet skill. Now as i understand skills are basicly numbers assigned to a simboly. numbers would be much easer to use for rundom command. So, what's the bast way I could do this?

Take a look at define.h header. You see in there:
#define SKILL_SMALL_GUNS (0)
#define SKILL_BIG_GUNS (1)
#define SKILL_ENERGY_WEAPONS (2)
#define SKILL_UNARMED_COMBAT (3)
#define SKILL_MELEE (4)
#define SKILL_THROWING (5)
#define SKILL_FIRST_AID (6)
#define SKILL_DOCTOR (7)
#define SKILL_SNEAK (8 )
#define SKILL_LOCKPICK (9)
#define SKILL_STEAL (10)
#define SKILL_TRAPS (11)
#define SKILL_SCIENCE (12)
#define SKILL_REPAIR (13)
#define SKILL_CONVERSANT (14)
#define SKILL_BARTER (15)
#define SKILL_GAMBLING (16)
#define SKILL_OUTDOORSMAN (17)

Everything in Fallout is a number, including critters, art, skills, perks, everything. You see above that skills are numbered 0-17.

variable RandomSkill
RandomSkill := random(0,17)

critter_mod_skill(object_pointer who, int skill, int amount).

Is this an encyclopedia? hehe
 
That's just what I had in mind! Thanx dude_obj!
Is this an encyclopedia? hehe
:lol: :lol: :lol:
No, it's just very very VERY usefull magazine. (It's a Playboy :lol: )

Too bad you can't trash it that easilly after you're done...reading... :lol:
 
Back
Top