Non-matching scrname.msg/scripts.h AND script crashing Fo2

Sirren67

Look, Ma! Two Heads!
Now, that's odd...
My latest working script was number 1550 in scrname... I made a new script and couldn't get its msg lines work... checked my files and noticed something wrong: the latest script registered in scripts.h was an old one. Edited manually, tested the script... Nothing. Unregistered the script manually, registered it again with Fse and I found the .h file messed again. At that point I checked all the "registration files" and noticed that my latest working script is number 1550 in scrname.msg and 1450 in script.h... I checked half a dozen backups I have and they all show this discrepancy... I never noticed it before. Is it normal?
Second problem: I couldn't fix my script number "1551", so I renamed it and registered it. I opened the mapper for testing... and SURPRISE: this time it crashes the mapper when I put the mouse cursor upon the critter...
All my other scripts are still working as intended. Any clues?
 
The mapper (and game engine) use the position of the script name in \data\scripts\scripts.lst to determine the number, and read the names. So check that scripts.lst is correct. Internally the scripts are accessed by a number.
 
\data\scripts\scripts.lst file is a most important one.
Basically scripts.lst is a list of all scripts in system, if you add new script to scripts.lst then game will see it and you can use it.
As Dude mentioned game determine scripts by it's number in scripts.lst.
Starting from 0 (dude_obj.int) to 1403(ntRicRom.int) in patched version.
scrname.msg file holds names for all scripted objects(all scripts from scripts.lst), those names are used in combat.
Enumeration in scrname.msg starts from 101 (dude_obj.int), so if you want calculate script number from this file you need to do:

script dude_obj.int
101 - 101 = 0

scrnumber - 101 = script number

Scripts.h is a header file, it is not used by game or mapper it is only used in script. It holds names and numbers for scripts in the very same order as in scripts.lst. Why it is used?

You can use script number to call it's msg file:

Code:
display_msg( message_str( 0,111 )) ;

But using name from scripts.h you can do the same thing like this:

Code:
display_msg( message_str( SCRIPT_OBJ_DUDE, 111 )) ;

Nice heh ;)

At start of script you will often see:
Code:
#define NAME                   SCRIPT_OBJ_DUDE
In this way we have current script number in NAME.
And name is used by default as script number in many predefined macros:

Code:
Reply(x) is in reality gSay_Reply(NAME,x) 
NOption(x,y,z) is in reality giQ_Option(z,NAME,x,y,NEUTRAL_REACTION) 
mstr(x)  is   message_str(NAME,x)
So we can write:
Code:
display_msg(mstr(111)) ;
 
I checked all the files and couldn't find anything wrong...
The point is I have a script that does not work for no apparent reason. I tried to register and compile it with 3 names: the original one works except for msg lines, the second one crashes the mapper when I pass my mouse cursor upon the critter, the last one works in full. At this point I checked sripts.h and... Surprise! It had been kinda messed up:

#define SCRIPT_GARYBOX (1448) // garybox.int ; gary box in arvillag
#define SCRIPT_FCDONNA (1449) // fcdonna.int ; Donna in flschool
#define SCRIPT_FCKARSTE (1450) // fckarste.int ; karsten, dude who can't read in denbus1
#define SCRIPT_MSGTEST (1452) // msgtest.int ; test in flschool
#define SCRIPT_MSGTEST1 (1453) // msgtest1.int ; test in flschool
#define SCRIPT_FCSARAH (1451) // fcsarah.int ; sarah in flschool
Now, I can't understand this :scratch:
1) Why my scripts stopped working all of the sudden.
2) Why they started to work again all of the sudden (same script, 3 behaviors).
3)What's the deal with the messed .H? This is new...
Thanks for your help, folks.
 
the original one works except for msg lines
This is because script SCRIPT_MSGTEST has wrong number (1452), but it seems that in scripts.lst exists some other script with that number so engine has found a msg file but line numbers are wrong so dialog don't work.
the second one crashes the mapper when I pass my mouse cursor upon the critter
It's because SCRIPT_MSGTEST1 has wrong number (1452) but there is no script in scripts.lst with that number so engine crash on display_msg call from look_at_p_proc(its called when you move mouse over object).
the last one works in full
This is because SCRIPT_FCSARAH has right number from scripts.lst(1451). Before last registration you edited scripts.lst deleting two entrys from it.

If your last entry from scripts.h has number 1452 then you should have exactly 1453 scripts registered in scripts.lst.
There can be no empty lines in scripts.lst
 
Actually fcsarah (1451) only displays error as a msg, MSGTEST (1452) crashes the mapper and MSGTEST1 (1453) is the working one, still I think I'm getting the mechanics. If I can't fix the thing and keep getting troubles I'm afraid you'll know for sure :wink: .
Thank you and have a good time.
 
Back
Top