mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Merge branch 'develop'
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# sfall
|
||||
|
||||
A set of engine modifications for the classic game Fallout 2 in form of a DLL, which modifies executable in memory without changing anything in EXE file itself.
|
||||
A set of engine modifications for the classic game Fallout 2 in form of a DLL, which modifies executable in memory without changing anything in EXE file itself.
|
||||
|
||||
Engine modifications include:
|
||||
**Engine modifications include:**
|
||||
- Better support for modern operating systems
|
||||
- Externalizing many settings like starting map and game time, skills, perks, critical hit tables, books, etc.
|
||||
- Bug fixes
|
||||
@@ -10,7 +10,7 @@ Engine modifications include:
|
||||
- Extended scripting capabilities for modders (many new opcodes to control sfall features as well as previously unavailable vanilla engine functions)
|
||||
|
||||
|
||||
Original author: timeslip
|
||||
Original author: timeslip
|
||||
|
||||
Original description: A set of engine modifications for the classic game Fallout 2 by Interplay. Includes fixes for bugs in the original engine, allows fallout to run correctly on modern operating systems, and adds additional features for modders.
|
||||
Original description: A set of engine modifications for the classic game Fallout 2 by Interplay. Includes fixes for bugs in the original engine, allows fallout to run correctly on modern operating systems, and adds additional features for modders.
|
||||
|
||||
|
||||
+29
-13
@@ -1,5 +1,5 @@
|
||||
;sfall configuration settings
|
||||
;v4.2.2
|
||||
;v4.2.3
|
||||
|
||||
[Main]
|
||||
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
|
||||
@@ -107,6 +107,11 @@ FadeMultiplier=100
|
||||
|
||||
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
[Interface]
|
||||
;Set to 1 to expand the number of action points displayed on the interface bar
|
||||
;Requires new IFACE_E.frm and HR_IFACE_<res>E.frm files in art\intrface\ (included in sfall.dat) to display correctly
|
||||
;The minimum supported version of High Resolution Patch is 4.1.8
|
||||
ActionPointsBar=0
|
||||
|
||||
;Set to 1 to use the expanded world map interface
|
||||
;Set to 2 to skip correcting the position of entrance markers on town maps
|
||||
;You can use resized FRMs in 700x682 for town maps in the expanded world map interface
|
||||
@@ -114,10 +119,17 @@ FadeMultiplier=100
|
||||
;The resolution of hi-res patch must be set to at least 890x720
|
||||
ExpandWorldMap=0
|
||||
|
||||
;Set to 1 to expand the number of action points displayed on the interface bar
|
||||
;Requires new IFACE_E.frm and HR_IFACE_<res>E.frm files in art\intrface\ (included in sfall.dat) to display correctly
|
||||
;The minimum supported version of High Resolution Patch is 4.1.8
|
||||
ActionPointsBar=0
|
||||
;Set to 1 to draw a dotted line while traveling on the world map (similar to Fallout 1)
|
||||
WorldMapTravelMarkers=0
|
||||
;Uncomment these lines to change the appearance of the markers
|
||||
;The color index in Fallout default palette (valid range: 1..255; default is 134)
|
||||
;TravelMarkerColor=134
|
||||
;The length and spacing of the dots in pixels for each type of terrain in worldmap.txt
|
||||
;Syntax is 'length:spacing', with each pair separated by a comma (valid range: 1..10; default is 2)
|
||||
;TravelMarkerStyles=2:2,2:2,2:2,2:2
|
||||
|
||||
;Set to 1 to display terrain types when hovering the cursor over the player's marker on the world map
|
||||
WorldMapTerrainInfo=0
|
||||
|
||||
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
[Input]
|
||||
@@ -198,6 +210,7 @@ DebugEditorKey=0
|
||||
;Changes some of Fallout 2 engine functions to Fallout 1 behavior:
|
||||
;- disables playing the final movie/credits after the endgame slideshow
|
||||
;- disables halving the weight for power armor items
|
||||
;- endgame_movie script function plays movie 10 or 11 based on the player's gender before the credits
|
||||
Fallout1Behavior=0
|
||||
|
||||
;Time limit in years. Must be between -3 and 13
|
||||
@@ -249,10 +262,15 @@ UseFileSystemOverride=0
|
||||
;Modified: master_patches > critter_patches > patchXXX.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat
|
||||
DataLoadOrderPatch=1
|
||||
|
||||
;Set to 1 to enable loading alternative dialog msg files from text\<language>\dialog_female\ for female PC
|
||||
;Set to 1 to load alternative dialog msg files from text\<language>\dialog_female\ for female PC
|
||||
;Set to 2 to also load subtitle files from text\<language>\cuts_female\ for female PC
|
||||
FemaleDialogMsgs=0
|
||||
|
||||
;Set to 1 to allow using the special '^' character in dialog msg files to specify the alternative text
|
||||
;that will be displayed in the dialogue based on the player's gender
|
||||
;The text must be enclosed in angle brackets (example: <MaleText^FemaleText>)
|
||||
DialogGenderWords=0
|
||||
|
||||
;To change the default and starting player models, uncomment the next four lines.
|
||||
;The default models can also be changed ingame via script
|
||||
;MaleStartModel=hmwarr
|
||||
@@ -314,9 +332,6 @@ DamageFormula=0
|
||||
;Prevents you from using 0 to escape from dialogue at any time.
|
||||
DialogueFix=1
|
||||
|
||||
;Prevents you from using number keys to enter unvisited areas on a town map
|
||||
TownMapHotkeysFix=1
|
||||
|
||||
;Set to 1 to disable the horrigan encounter
|
||||
DisableHorrigan=0
|
||||
|
||||
@@ -387,7 +402,7 @@ CorpseDeleteTime=6
|
||||
|
||||
;Set a number of milliseconds to idle each input loop
|
||||
;Set to -1 to disable
|
||||
;Set to 0 to idle only if other processes are waiting for processor time
|
||||
;Set to 0 to idle only if other processes are waiting for processor time (WinXP/2000: if processes have equal priority)
|
||||
;Set to 1 (or some higher number if needed, the maximum is 127) to prevent 100% CPU use
|
||||
ProcessorIdle=-1
|
||||
|
||||
@@ -497,9 +512,6 @@ BonusHtHDamageFix=1
|
||||
;Set to 1 to display additional points of damage from Bonus HtH/Ranged Damage perks in the inventory
|
||||
DisplayBonusDamage=0
|
||||
|
||||
;Set to 1 to display the range of the second attack mode in the inventory when you switch weapon modes in active item slots
|
||||
DisplaySecondWeaponRange=1
|
||||
|
||||
;Modify the maximum number of animations allowed to run on a map. (Default is 32, and the maximum is 127)
|
||||
AnimationsAtOnceLimit=120
|
||||
|
||||
@@ -572,6 +584,10 @@ StartGDialogFix=0
|
||||
;attacker_results - unused, must be 0 or not equal to the target_results argument when specifying result flags for the target
|
||||
AttackComplexFix=0
|
||||
|
||||
;Set to 1 to fix the issue with the division operator treating negative integers as unsigned
|
||||
;Note: To perform the unsigned integer division, use the new 'div' operator
|
||||
DivisionOperatorFix=1
|
||||
|
||||
;Set to 1 to enable the balanced bullet distribution formula for burst attacks
|
||||
ComputeSprayMod=0
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include "..\scripting\headers\sfall.h"
|
||||
#include "..\scripting\headers\define_lite.h"
|
||||
@@ -71,3 +73,5 @@ end
|
||||
procedure InitConfigs begin
|
||||
translationIni := GetIniConfigStr("Main", "TranslationsINI", "Translations.ini", "ddraw.ini");
|
||||
end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
The executation speed of scripts is not typically important in an unmodded game, given the difference in performance between a modern computer and what Fallout was designed for. When you start adding mods to the mix there's the potential for problems again, since sfall's global script system means that you can have a large amount of scripts being run every single frame.
|
||||
|
||||
======================
|
||||
=== sslc -O option ===
|
||||
======================
|
||||
|
||||
The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn't a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It's primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops.
|
||||
|
||||
There are several levels of optimization available:
|
||||
-O1 - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched.
|
||||
-O2 - Full, most code optimizations are on, but only those that were tested on complex scripts.
|
||||
-O3 - Experimental, provides most efficiency, but tend to break some complex code due to bugs.
|
||||
|
||||
The following optimizations are performed:
|
||||
|
||||
> constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result.
|
||||
|
||||
a:=2+2; -> a:=4;
|
||||
|
||||
> constant variable initialization: All variables are initialised to some value, ('0', if you don't specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression.
|
||||
|
||||
variable a; -> variable a:=4;
|
||||
a:=4; ->
|
||||
|
||||
> constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script.
|
||||
|
||||
a:=4 -> a:=4
|
||||
foo(a); -> foo(4);
|
||||
|
||||
> dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time.
|
||||
|
||||
if 1 then begin -> display_msg("foo");
|
||||
display_msg("foo"); ->
|
||||
end else begin ->
|
||||
display_msg("bar"); ->
|
||||
end ->
|
||||
|
||||
> unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export.
|
||||
|
||||
variable i, j, k; -> variable i;
|
||||
i:=1; -> i:=1;
|
||||
return; -> return;
|
||||
|
||||
> unreferenced procedure elimination: Checks for any procedures which are never called, and removes them.
|
||||
|
||||
procedure foo begin return "foo"; end -> procedure foo begin return "foo"; end
|
||||
procedure bar begin return "bar"; end -> procedure start begin
|
||||
procedure start begin -> display_msg(foo);
|
||||
display_msg(foo); -> end
|
||||
end ->
|
||||
|
||||
> dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See 'pure' keyword)
|
||||
|
||||
a:="moo"; -> a:="foo";
|
||||
a:="foo"; -> display_msg(a);
|
||||
display_msg(a); ->
|
||||
a:="bar"; ->
|
||||
|
||||
> store combination: Where there are two stores in a row to the same variable, the two expressions are combined.
|
||||
|
||||
var1 := var2; -> var1 := var2 + var3;
|
||||
var1 += var3; ->
|
||||
|
||||
> variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each.
|
||||
|
||||
a:="foo"; -> a:="foo";
|
||||
display_msg(a); -> display_msg(a);
|
||||
b:="bar"; -> a:="bar";
|
||||
display_msg(b); -> display_msg(a);
|
||||
|
||||
> namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter.
|
||||
|
||||
=============================
|
||||
=== writing your own code ===
|
||||
=============================
|
||||
|
||||
Don't have global scripts running any more often that you need them to. Not everything needs to be run every single frame.
|
||||
|
||||
Never concat constant strings with the '+' operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time.
|
||||
|
||||
#define GLOB_PREFIX "ts__" -> #define GLOB_PREFIX "ts__"
|
||||
|
||||
procedure start begin -> procedure start begin
|
||||
set_sfall_global(GLOB_PREFIX + "foo1", 0); -> set_sfall_global(GLOB_PREFIX "foo1", 0);
|
||||
end -> end
|
||||
|
||||
|
||||
Avoid function calls in while loops. function calls are expensive in comparison to variable lookups, so it's more efficient to move the function call out of the loop and store the result in a variable
|
||||
|
||||
while i < len_array(array) do begin -> tmp:= len_array(array);
|
||||
... -> while i < tmp do begin
|
||||
end -> ...
|
||||
-> end
|
||||
|
||||
Mark functions with pure or inline where relevent.
|
||||
|
||||
'pure' is a hint to the optimizer that a procedure has no side effects. (i.e. there's no way to tell that it's been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn't itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the 'call <procedure>' syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code.
|
||||
|
||||
'inline' is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. inlined procedures cannot use the 'return' command, cannot be predefined, and cannot be used as part of an expression. inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code.
|
||||
@@ -0,0 +1,405 @@
|
||||
This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional scripting functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer.
|
||||
|
||||
Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive.
|
||||
|
||||
If you use fallout script editor, you can extract compile.exe and dos4gw.exe to its \binary folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn't seem to be able to tell when errors occur when using this compiler though, so I'd recommend either using sfall's script editor instead or compiling by hand if possible.
|
||||
|
||||
When compiling global or hook scripts for sfall 3.4 or below, you _must_ include the line 'procedure start;' before any #includes that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5)
|
||||
|
||||
This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don't use any of the arrays syntax and any sfall scripting functions.
|
||||
|
||||
The original unmodified sslc source is over here:
|
||||
http://www.teamx.ru/eng/files/srcs/index.shtml
|
||||
|
||||
============================
|
||||
=== command line options ===
|
||||
============================
|
||||
|
||||
-q don't wait for input on error
|
||||
-n no warnings
|
||||
-b backward compatibility mode
|
||||
-l no logo
|
||||
-p preprocess source
|
||||
-O optimize code (full, see optimization.txt)
|
||||
-O<N> set specific level of optimization (0 - off, 1 - basic, 2 - full, 3 - experimental)
|
||||
-d print debug messages
|
||||
-D output an abstract syntax tree of the program
|
||||
-o set output path (follows the input file name)
|
||||
-s enable short-circuit evaluation for all AND, OR operators
|
||||
-m<macro[=val]> define a macro named "macro" for conditional compilation
|
||||
-I<path> specify an additional directory to search for include files
|
||||
|
||||
The original command line option -w to turn on warnings no longer has an effect, since warnings are now on by default
|
||||
|
||||
===================================
|
||||
=== Additional supported syntax ===
|
||||
===================================
|
||||
|
||||
Syntax which requires sfall for compiled scripts to be interpreted, is marked by asterix (*).
|
||||
|
||||
> Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.
|
||||
|
||||
new:
|
||||
procedure test(variable x, variable y := 0, variable z := -1) begin
|
||||
...
|
||||
end
|
||||
...
|
||||
call test("value");
|
||||
|
||||
old:
|
||||
procedure test(variable x, variable y, variable z) begin
|
||||
...
|
||||
end
|
||||
...
|
||||
call test("value", 0, -1);
|
||||
|
||||
|
||||
> New logical operators "AndAlso", "OrElse" for short-circuit evaluation of logical expressions.
|
||||
Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.
|
||||
|
||||
Example:
|
||||
if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...
|
||||
|
||||
if obj is null, the second condition will not be checked and your script won't fail with "obj is null" error in debug.log
|
||||
|
||||
This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always 0 (false) or 1 (true):
|
||||
obj := false;
|
||||
display_msg(obj orElse "something"); // will print "something"
|
||||
|
||||
You can also use the -s option to enable short-circuit evaluation for all the AND, OR operators in the script.
|
||||
NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly.
|
||||
|
||||
|
||||
> Conditional expressions (Python-inspired), also known as ternary operator:
|
||||
|
||||
new:
|
||||
X := value1 if condition else value2
|
||||
|
||||
old:
|
||||
if (condition) then
|
||||
X := value1;
|
||||
else
|
||||
X := value2;
|
||||
|
||||
|
||||
> To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax.
|
||||
|
||||
new:
|
||||
x = 5;
|
||||
old:
|
||||
x := 5;
|
||||
|
||||
|
||||
> Multiple variable decleration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.
|
||||
|
||||
new:
|
||||
variable a, b, c;
|
||||
old:
|
||||
variable begin a; b; c; end
|
||||
|
||||
|
||||
> Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants.
|
||||
|
||||
new:
|
||||
variable tile := tile_num(dude_obj);
|
||||
|
||||
old:
|
||||
variable tile;
|
||||
tile := tile_num(dude_obj);
|
||||
|
||||
NOTE: if your expression starts with a constant (eg. 2+2), enclose it in parentheses, otherwise compiler will be confused and give you errors.
|
||||
|
||||
|
||||
> Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and a-f are allowed in the number. The number may not have a decimal point.
|
||||
|
||||
new:
|
||||
a := 0x1000;
|
||||
old:
|
||||
a := 4096;
|
||||
|
||||
|
||||
> increment/decrement operators: ++ and -- can be used as shorthand for +=1 and -=1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where +=1 would normally be allowed.
|
||||
|
||||
new:
|
||||
a++;
|
||||
old:
|
||||
a += 1;
|
||||
|
||||
|
||||
> "break" & "continue" statements: they work just like in most high-level languages. "break" jumps out of the loop. "continue" jumps right to the beginning of the next iteration (see "for" and "foreach" sections for additional details).
|
||||
|
||||
new:
|
||||
while (i < N) begin
|
||||
// ...
|
||||
if (/* some condition */) then break;
|
||||
// ...
|
||||
end
|
||||
|
||||
old:
|
||||
while (i < N and not(breakFlag)) begin
|
||||
// ...
|
||||
if (/* condition */) then breakFlag := true;
|
||||
// ...
|
||||
end
|
||||
|
||||
new:
|
||||
for (i := 0; i < N; i++) begin
|
||||
// ...
|
||||
if (/* condition */) then begin
|
||||
// action
|
||||
continue;
|
||||
end
|
||||
// else actions
|
||||
end
|
||||
|
||||
old:
|
||||
for (i := 0; i < N; i++) begin
|
||||
// ...
|
||||
if (/* condition */) then begin
|
||||
// action
|
||||
end else begin
|
||||
// else actions
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
> "for" loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement).
|
||||
new:
|
||||
for (i := 0; i < 5; i++) begin
|
||||
display_msg("i = "+i);
|
||||
end
|
||||
old
|
||||
i := 0;
|
||||
while (i < 5) do begin
|
||||
display_msg("i = "+i);
|
||||
i++;
|
||||
end
|
||||
|
||||
NOTE: "continue" statement in a "for" loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.
|
||||
|
||||
|
||||
> switch statements: A shorthand way of writing big 'if then else if...' blocks
|
||||
new:
|
||||
switch get_attack_type begin
|
||||
case ATKTYPE_PUNCH: display_msg("punch");
|
||||
case ATKTYPE_KICK: display_msg("kick");
|
||||
default: display_msg("something else");
|
||||
end
|
||||
old:
|
||||
variable tmp;
|
||||
tmp := get_attack_type;
|
||||
if tmp == ATKTYPE_PUNCH then begin
|
||||
display_msg("punch");
|
||||
end else if tmp == ATKTYPE_KICK then begin
|
||||
display_msg("kick");
|
||||
end else begin
|
||||
display_msg("something else");
|
||||
end
|
||||
|
||||
|
||||
> empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it's always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition:
|
||||
|
||||
#define my_macro diplay_msg("foo");
|
||||
|
||||
procedure start begin
|
||||
my_macro;
|
||||
end
|
||||
|
||||
|
||||
> Procedure stringify operator "@": designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by "@" by a string constant.
|
||||
Not many people know that since vanilla Fallout you can call procedures by "calling a variable" containing it's name as a string value. There was a couple of problems using this:
|
||||
- optimizer wasn't aware that you are referencing a procedure, and could remove it, if you don't call it explicitly (can be solved by adding making procedure "critical")
|
||||
- you couldn't see all references of a procedure from a Script Editor
|
||||
- it was completely not obvious that you could do such a thing, it was a confusing syntax
|
||||
|
||||
old:
|
||||
callbackVar := "Node000";
|
||||
callbackVar();
|
||||
|
||||
new:
|
||||
callbackVar := @Node000;
|
||||
callbackVar();
|
||||
|
||||
|
||||
|
||||
> *arrays: In vanilla fallout arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []'s to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it's not required, see "arrays.txt" for more information)
|
||||
|
||||
new:
|
||||
procedure bingle begin
|
||||
variable a[2];
|
||||
a[0] := 5;
|
||||
a[a[0] - 4] := a[0] + 4;
|
||||
display_msg("a[0]=" + a[0] + ", a[1]=" + a[1]);
|
||||
end
|
||||
old:
|
||||
procedure bingle begin
|
||||
variable a;
|
||||
a := temp_array(2, 4);
|
||||
set_array(a, 0, 5);
|
||||
set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4);
|
||||
display_msg("a[0]=" + get_array(a, 0) + ", a[1]=" + get_array(a, 1));
|
||||
end
|
||||
|
||||
|
||||
> *array expressions: sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible:
|
||||
new:
|
||||
list := ["A", "B", "C", "D"];
|
||||
|
||||
old:
|
||||
list := temp_array(4, 2);
|
||||
list[0] := "A";
|
||||
list[1] := "B";
|
||||
list[2] := "C";
|
||||
list[3] := "D";
|
||||
|
||||
|
||||
Syntax specific for associative arrays is also available. (see "arrays.txt" for full introduction to this type of arrays).
|
||||
|
||||
> *map array expressions:
|
||||
|
||||
map := {5: "five", 10: "ten", 15: "fifteen", 20: "twelve"};
|
||||
|
||||
|
||||
> * "dot" syntax to access elements of associative arrays. "dot" syntax allows to work with arrays like objects:
|
||||
trap.radius := 3;
|
||||
trap.tile := tile_num(dude_obj);
|
||||
|
||||
you can chain dot and bracket syntax to access elements of multi-dimensional arrays:
|
||||
collectionList[5].objectList[5].name += " foo";
|
||||
|
||||
NOTE: when using incremental operators like +=, *=, ++, -- compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of "get_array" calls twice.
|
||||
|
||||
|
||||
> * "foreach" loops: A shorthand method of looping over all elements in an array. Syntax is 'foreach (<symbol> in <expression>) '
|
||||
new:
|
||||
procedure bingle begin
|
||||
variable critter;
|
||||
foreach (critter in list_as_array(LIST_CRITTERS)) begin
|
||||
display_msg(""+critter);
|
||||
end
|
||||
end
|
||||
old:
|
||||
procedure bingle begin
|
||||
variable begin critter; array; len; count; end
|
||||
array := list_as_array(LIST_CRITTERS);
|
||||
len := len_array(array);
|
||||
count := 0;
|
||||
while count < len do begin
|
||||
critter := array[count];
|
||||
display_msg("" + critter);
|
||||
end
|
||||
end
|
||||
|
||||
If you want an index array element (or key for "maps") at each iteration, use syntax: 'foreach (<symbol>: <symbol> in <expression>) '
|
||||
foreach (pid: price in itemPriceMap) begin
|
||||
if (itemPid == pid) then
|
||||
itemPrice := price;
|
||||
end
|
||||
|
||||
If you want to add additional condition for continuing the loop, use syntax: 'foreach (<symbol> in <expression> while <expression>) '. In this case loop will iterate over elements of an array until last element or until "while" expression is true (whatever comes first).
|
||||
|
||||
NOTE: just like "for" loop, "continue" statement will respect increments of a hidden counter variable, so you can safely use it inside "foreach".
|
||||
|
||||
|
||||
|
||||
|
||||
====================
|
||||
=== int2ssl note ===
|
||||
====================
|
||||
|
||||
int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.
|
||||
|
||||
=============
|
||||
=== Fixes ===
|
||||
=============
|
||||
|
||||
playmoviealpharect was using the token for playmoviealpha, breaking both functions in the process.
|
||||
|
||||
addbuttonflag had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.
|
||||
|
||||
The function tokenize was missing an entry in the token table, and so would not be recognised by the compiler.
|
||||
|
||||
fixed the check for the 'call "foo"' syntax so that non-string constants will no longer be accepted.
|
||||
|
||||
==============================
|
||||
=== Backward compatibility ===
|
||||
==============================
|
||||
|
||||
There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option '-b' is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:
|
||||
|
||||
- Since 'for', 'foreach', 'break', 'continue', 'in' and 'tokenize' are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.
|
||||
|
||||
- Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)
|
||||
|
||||
- The function addbuttonflag used to be recognised by the compiler, but would not emit any code into the int file.
|
||||
|
||||
- The function playmoviealpharect compiled as playmoviealpha
|
||||
|
||||
|
||||
=================
|
||||
=== Changelog ===
|
||||
=================
|
||||
|
||||
> sfall 4.2.3
|
||||
- fixed compiler giving "assignment operator expected" error when a variable-like macro is not being defined properly
|
||||
- added new logical operators "AndAlso", "OrElse" for short-circuit evaluation of logical expressions
|
||||
- added an alternative (C/Java-style) assignment operator "="
|
||||
- added support for new "div" operator (unsigned integer division)
|
||||
|
||||
> sfall 4.2.2
|
||||
- added support for new opcode "reg_anim_callback"
|
||||
|
||||
> sfall 4.2.1
|
||||
- the basic optimization is now enabled by default when not specifying any optimization options
|
||||
- added -m<macro[=val]> option to define a macro named "macro" for conditional compilation
|
||||
- added -I<path> option to specify an additional directory to search for include files
|
||||
- unreferenced "critical" procedures and procedures with the names "Node998" and "Node999" are now removed by the optimizer
|
||||
|
||||
> sfall 4.2
|
||||
- now it is possible to run preprocess or optimization passes in backward compatibility mode
|
||||
- added support for new opcode "register_hook_proc_spec"
|
||||
|
||||
> sfall 4.0:
|
||||
- enabled code for "ceil" math function
|
||||
- fixed missing argument for "how_much" function
|
||||
- added "desc_p_proc" (from Fallout 1) to protected procedures that should not be removed by the optimizer
|
||||
- fixed compiler giving "division by zero" error when using zero as the second factor in multiplication
|
||||
|
||||
> sfall 3.8
|
||||
- added support for new universal opcodes sfall_funcX
|
||||
|
||||
> sfall 3.6:
|
||||
- added Python-style ternary operator (conditional expression)
|
||||
- added -s short-circuit evalution option for AND, OR expressions
|
||||
- int2ssl will detect and decompile conditional expressions and short-circuit logical operators
|
||||
- added -F option to include full file paths in "#line" directives after preprocessing
|
||||
- added -D option to write abstract syntax tree into .txt file
|
||||
- fixed compiler crash when number of arguments in procedure declaration does not match definition
|
||||
- fixed incorrect constant folding of "bwnot" operator
|
||||
- fixed more invalid results in constant folding
|
||||
- implemented optional arguments for user-defined procedures
|
||||
- implemented stringify procedure names using @ operator, which is helpful to pass procedures around to call them from variables (it will properly handle references)
|
||||
- logic for procedures passed as arguments to scripting functions was moved from code generation to parsing stage
|
||||
- now it is possible to call user-defined procedures inside argument list of scripting functions, without compiler attempting to treat them as procedure references and probably fail (procedures will still be passed, but only to appropriate scripting functions at appropriate argument positions)
|
||||
- int2ssl will now place empty parantheses after a call to user-defined procedure - this will distinct calls from passing procedures to some scripting functions (like giq_option)
|
||||
- fixed inline procedure "calls" not working when optimization is enabled
|
||||
- added column numbers to error/warning output
|
||||
- added code to simplify adding sfall opcodes into compiler (need to add code in 3 places, instead of 7 places for each opcode)
|
||||
- fixed bug when initializing variable with expression starting from a symbol
|
||||
- added division by zero constant check
|
||||
|
||||
> sfall 3.5:
|
||||
- completed namespace compression optimization with respect to imported/exported variables
|
||||
- changed 'for' and 'foreach' syntax to allow parentheses which are easier to read IMHO
|
||||
- heavy code refactoring - split "parse.c" into several files, replaced all dirty workaround code in "lex()" (some syntax features) with parser-level equivalents
|
||||
- added syntax to reference elements in multi-dimensional arrays (unlimited sequence of brackets [] and dots . )
|
||||
- added fully featured "break" and "continue" statements for loops
|
||||
- moved some optimizations (namely constant propagation and variable reuse) to "experimental" because they were breaking my scripts
|
||||
- added ability to initialize variables with expressions
|
||||
|
||||
> sfall 3.4:
|
||||
- added "foreach .. while .." syntax
|
||||
- added array expressions for lists and maps
|
||||
- added "foreach (key: value in ...)" syntax for convenience
|
||||
- fixed crash bug in "for" loop parsing function
|
||||
- added ability to access array elements with string keys using OOP-like dot (".") syntax
|
||||
@@ -87,25 +87,34 @@
|
||||
#define FLAG_SEEN (0x40000000)
|
||||
#define FLAG_SHOOTTHRU (0x80000000)
|
||||
|
||||
/* Critter Flags */
|
||||
/* Critter flags */
|
||||
#define CFLG_BARTER 2 // 0x00000002 - Barter (can trade with)
|
||||
#define CFLG_NOSTEAL 32 // 0x00000020 - Steal (cannot steal from)
|
||||
#define CFLG_NOSTEAL 32 // 0x00000020 - Steal (cannot be stolen from)
|
||||
#define CFLG_NODROP 64 // 0x00000040 - Drop (doesn't drop items)
|
||||
#define CFLG_NOLIMBS 128 // 0x00000080 - Limbs (cannot lose limbs)
|
||||
#define CFLG_NOAGES 256 // 0x00000100 - Ages (dead body does not disappear)
|
||||
#define CFLG_NOHEAL 512 // 0x00000200 - Heal (damage is not cured with time)
|
||||
#define CFLG_NOHEAL 512 // 0x00000200 - Heal (damage is not healed with time)
|
||||
#define CFLG_INVULN 1024 // 0x00000400 - Invulnerable (cannot be hurt)
|
||||
#define CFLG_FLATTN 2048 // 0x00000800 - Flatten (leaves no dead body)
|
||||
#define CFLG_SPECIAL 4096 // 0x00001000 - Special (there is a special type of death)
|
||||
#define CFLG_RANGED 8192 // 0x00002000 - Range (melee attack is possible at a distance)
|
||||
#define CFLG_NOKNOCKDOWN 16384 // 0x00004000 - Knock (cannot be knocked down)
|
||||
#define CFLG_SPECIAL 4096 // 0x00001000 - Special (has a special type of death)
|
||||
#define CFLG_RANGED 8192 // 0x00002000 - Range (has extra hand-to-hand range)
|
||||
#define CFLG_NOKNOCKBACK 16384 // 0x00004000 - Knock (cannot be knocked back)
|
||||
#define CFLG_NOKNOCKDOWN CFLG_NOKNOCKBACK // obsolete
|
||||
|
||||
/* Window Flags */
|
||||
/* Window flags */
|
||||
#define WIN_FLAG_MOVEONTOP (0x4)
|
||||
#define WIN_FLAG_HIDDEN (0x8)
|
||||
#define WIN_FLAG_EXCLUSIVE (0x10)
|
||||
#define WIN_FLAG_TRANSPARENT (0x20)
|
||||
|
||||
/* Message window flags */
|
||||
#define MSGBOX_AUTOSIZE (0x0)
|
||||
#define MSGBOX_NORMAL (0x1)
|
||||
#define MSGBOX_SMALL (0x2)
|
||||
#define MSGBOX_ALIGN_LEFT (0x4) // text aligned to left
|
||||
#define MSGBOX_ALIGN_TOP (0x8) // text aligned to top
|
||||
#define MSGBOX_YESNO (0x10) // use YES/NO buttons instead of DONE
|
||||
#define MSGBOX_CLEAN (0x20) // no buttons
|
||||
|
||||
//remove inven obj defines
|
||||
#define RMOBJ_CONSUME_DRUG 4666772
|
||||
@@ -334,7 +343,6 @@
|
||||
#define ai_area_be_absolutely_sure (4)
|
||||
|
||||
// AI attack who mode values
|
||||
#define ai_attack_no_pref (-1)
|
||||
#define ai_attack_whomever_attacking_me (0)
|
||||
#define ai_attack_strongest (1)
|
||||
#define ai_attack_weakest (2)
|
||||
@@ -351,12 +359,12 @@
|
||||
#define ai_run_away_never (7)
|
||||
|
||||
// AI disposition values
|
||||
#define ai_disposition_none (0)
|
||||
#define ai_disposition_custom (1)
|
||||
#define ai_disposition_coward (2)
|
||||
#define ai_disposition_defensive (3)
|
||||
#define ai_disposition_aggressive (4)
|
||||
#define ai_disposition_berserk (5)
|
||||
#define ai_disposition_none (-1)
|
||||
#define ai_disposition_custom (0)
|
||||
#define ai_disposition_coward (1)
|
||||
#define ai_disposition_defensive (2)
|
||||
#define ai_disposition_aggressive (3)
|
||||
#define ai_disposition_berserk (4)
|
||||
|
||||
// AI distance values
|
||||
#define ai_distance_stay_close (0)
|
||||
@@ -400,7 +408,7 @@
|
||||
#define OBJ_DATA_COMBAT_STATE (0x3C) // flags: 1 - combat, 2 - target is out of range, 4 - flee
|
||||
#define OBJ_DATA_CUR_ACTION_POINT (0x40)
|
||||
#define OBJ_DATA_DAMAGE_LAST_TURN (0x48)
|
||||
#define OBJ_DATA_WHO_HIT_ME (0x54)
|
||||
#define OBJ_DATA_WHO_HIT_ME (0x54) // current target of the critter
|
||||
|
||||
// compute attack result data offsets
|
||||
#define C_ATTACK_SOURCE (0x00)
|
||||
|
||||
@@ -5,6 +5,17 @@
|
||||
Numbers...
|
||||
*/
|
||||
|
||||
#define above(a, b) (unsigned_comp(a, b) > 0)
|
||||
#define above_equal(a, b) (unsigned_comp(a, b) >= 0)
|
||||
#define below(a, b) (unsigned_comp(a, b) < 0)
|
||||
#define below_equal(a, b) (unsigned_comp(a, b) <= 0)
|
||||
|
||||
// for sfall 4.2.3/3.8.23
|
||||
pure procedure unsigned_comp(variable a, variable b) begin
|
||||
if ((a bwxor b) == 0) then return 0; // a == b
|
||||
return 1 if ((b == 0) orElse a div b) else -1;
|
||||
end
|
||||
|
||||
#define MAX(x, y) ((x > y) * x + (x <= y) * y)
|
||||
#define MIN(x, y) ((x < y) * x + (x >= y) * y)
|
||||
#define in_range(x, from, to) (x >= from and x <= to)
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef SFALL_H
|
||||
#define SFALL_H
|
||||
|
||||
//Recognised modes for set_shader_mode and get_game_mode
|
||||
#define WORLDMAP (0x1)
|
||||
#define DIALOG (0x4)
|
||||
@@ -65,20 +68,34 @@
|
||||
#define HOOK_STDPROCEDURE (40)
|
||||
#define HOOK_STDPROCEDURE_END (41)
|
||||
#define HOOK_TARGETOBJECT (42)
|
||||
#define HOOK_ENCOUNTER (43)
|
||||
|
||||
//Valid arguments to list_begin
|
||||
#define LIST_CRITTERS (0)
|
||||
#define LIST_GROUNDITEMS (1)
|
||||
#define LIST_SCENERY (2)
|
||||
#define LIST_WALLS (3)
|
||||
//#define LIST_TILES (4) //Not listable via sfall list functions
|
||||
//#define LIST_TILES (4) //Not listable via sfall list functions
|
||||
#define LIST_MISC (5)
|
||||
#define LIST_SPATIAL (6)
|
||||
#define LIST_ALL (9)
|
||||
|
||||
//Valid window types for get_window_attribute
|
||||
#define WINTYPE_INVENTORY (0) // any inventory window (player/loot/use/barter)
|
||||
#define WINTYPE_DIALOG (1)
|
||||
#define WINTYPE_PIPBOY (2)
|
||||
#define WINTYPE_WORLDMAP (3)
|
||||
#define WINTYPE_IFACEBAR (4) // the interface bar
|
||||
#define WINTYPE_CHARACTER (5)
|
||||
#define WINTYPE_SKILLDEX (6)
|
||||
#define WINTYPE_ESCMENU (7) // escape menu
|
||||
|
||||
//Valid flags for force_encounter_with_flags
|
||||
#define ENCOUNTER_FLAG_NO_CAR (1)
|
||||
#define ENCOUNTER_FLAG_LOCK (2) // block new forced encounter by the next function call until the current specified encounter occurs
|
||||
#define ENCOUNTER_FLAG_NO_CAR (0x1)
|
||||
#define ENCOUNTER_FLAG_LOCK (0x2) // block new forced encounter by the next function call until the current specified encounter occurs
|
||||
#define ENCOUNTER_FLAG_NO_ICON (0x4) // disable displaying the flashing icon
|
||||
#define ENCOUNTER_FLAG_ICON_SP (0x8) // use special encounter icon
|
||||
#define ENCOUNTER_FLAG_FADEOUT (0x10) // fade out the screen on encounter (Note: you yourself should restore the fade screen when entering the encounter)
|
||||
|
||||
//The attack types returned by get_attack_type
|
||||
#define ATKTYPE_LWEP1 (0)
|
||||
@@ -247,7 +264,7 @@
|
||||
// fake perks/traits add mode flags
|
||||
#define ADD_PERK_MODE_TRAIT (1) // add to the player's traits
|
||||
#define ADD_PERK_MODE_PERK (2) // add to the player's perks
|
||||
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks
|
||||
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks (after added to the player)
|
||||
|
||||
// sfall_funcX macros
|
||||
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
||||
@@ -273,6 +290,8 @@
|
||||
#define get_flags(obj) sfall_func1("get_flags", obj)
|
||||
#define get_ini_section(file, sect) sfall_func2("get_ini_section", file, sect)
|
||||
#define get_ini_sections(file) sfall_func1("get_ini_sections", file)
|
||||
#define get_interface_x(winType) sfall_func2("get_window_attribute", winType, 1)
|
||||
#define get_interface_y(winType) sfall_func2("get_window_attribute", winType, 2)
|
||||
#define get_inven_ap_cost sfall_func0("get_inven_ap_cost")
|
||||
#define get_map_enter_position sfall_func0("get_map_enter_position")
|
||||
#define get_metarule_table sfall_func0("get_metarule_table")
|
||||
@@ -287,6 +306,7 @@
|
||||
#define hide_window(winName) sfall_func1("hide_window", winName)
|
||||
#define intface_hide sfall_func0("intface_hide")
|
||||
#define intface_is_hidden sfall_func0("intface_is_hidden")
|
||||
#define intface_is_shown(winType) sfall_func1("get_window_attribute", winType)
|
||||
#define intface_redraw sfall_func0("intface_redraw")
|
||||
#define intface_show sfall_func0("intface_show")
|
||||
#define inventory_redraw(invSide) sfall_func1("inventory_redraw", invSide)
|
||||
@@ -294,6 +314,7 @@
|
||||
#define item_weight(obj) sfall_func1("item_weight", obj)
|
||||
#define lock_is_jammed(obj) sfall_func1("lock_is_jammed", obj)
|
||||
#define loot_obj sfall_func0("loot_obj")
|
||||
#define message_box(text) sfall_func1("message_box", text)
|
||||
#define metarule_exist(metaruleName) sfall_func1("metarule_exist", metaruleName)
|
||||
#define npc_engine_level_up(toggle) sfall_func1("npc_engine_level_up", toggle)
|
||||
#define obj_under_cursor(onlyCritter, includeDude) sfall_func2("obj_under_cursor", onlyCritter, includeDude)
|
||||
@@ -315,6 +336,8 @@
|
||||
#define set_outline(obj, color) sfall_func2("set_outline", obj, color)
|
||||
#define set_rest_heal_time(time) sfall_func1("set_rest_heal_time", time)
|
||||
#define set_rest_mode(mode) sfall_func1("set_rest_mode", mode)
|
||||
#define set_terrain_name(x, y, name) sfall_func3("set_terrain_name", x, y, name)
|
||||
#define set_town_title(areaID, title) sfall_func2("set_town_title", areaID, title)
|
||||
#define set_unique_id(obj) sfall_func1("set_unique_id", obj)
|
||||
#define set_unjam_locks_time(time) sfall_func1("set_unjam_locks_time", time)
|
||||
#define set_window_flag(winID, flag, value) sfall_func3("set_window_flag", winID, flag, value)
|
||||
@@ -323,6 +346,8 @@
|
||||
#define string_compare(str1, str2) sfall_func2("string_compare", str1, str2)
|
||||
#define string_compare_locale(str1, str2, codePage) sfall_func3("string_compare", str1, str2, codePage)
|
||||
#define string_format(format, a1, a2) sfall_func3("string_format", format, a1, a2)
|
||||
#define string_tolower(text) sfall_func2("string_to_case", text, 0)
|
||||
#define string_toupper(text) sfall_func2("string_to_case", text, 1)
|
||||
#define tile_by_position(x, y) sfall_func2("tile_by_position", x, y)
|
||||
#define tile_refresh_display sfall_func0("tile_refresh_display")
|
||||
#define unjam_lock(obj) sfall_func1("unjam_lock", obj)
|
||||
@@ -332,3 +357,5 @@
|
||||
#define set_fake_perk_npc(npc, perk, level, image, desc) sfall_func5("set_fake_perk_npc", npc, perk, level, image, desc)
|
||||
#define set_fake_trait_npc(npc, trait, active, image, desc) sfall_func5("set_fake_trait_npc", npc, trait, active, image, desc)
|
||||
#define set_selectable_perk_npc(npc, perk, active, image, desc) sfall_func5("set_selectable_perk_npc", npc, perk, active, image, desc)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -192,9 +192,15 @@ HOOK_FINDTARGET (hs_findtarget.int)
|
||||
Runs when the ai is trying to pick a target in combat. Fallout first chooses a list of 4 likely suspects, then normally sorts them in order of weakness/distance/etc depending on the ai caps of the attacker.
|
||||
This hook replaces that sorting function, allowing you to sort the targets in some arbitrary way.
|
||||
|
||||
The return values can include critters that weren't in the list of possible targets, but the additional targets may still be discarded later on in the combat turn if they are out of the attackers perception or the chance of a successful hit is too low. The list of possible targets often includes duplicated entries.
|
||||
The return values can include critters that weren't in the list of possible targets, but the additional targets may still be discarded later on in the combat turn if they are out of the attackers perception or the chance of a successful hit is too low. The list of possible targets often includes duplicated entries, but this is fixed in sfall 4.2.3/3.8.23.
|
||||
Use sfall_return to give the 4 targets, in order of preference. If you want to specify less than 4 targets, fill in the extra spaces with 0's or pass -1 to skip the return value.
|
||||
|
||||
NOTE: The engine can choose targets by the following criteria:
|
||||
1) The nearest enemy to the attacker.
|
||||
2) The enemy that attacked the attacker.
|
||||
3) The enemy that attacked an NPC from the same team as the attacker.
|
||||
4) The enemy that is attacked by an NPC from the same team as the attacker.
|
||||
|
||||
critter arg1 - The attacker
|
||||
critter arg2 - A possible target
|
||||
critter arg3 - A possible target
|
||||
@@ -663,3 +669,17 @@ int arg2 - 1 when the target object is valid to attack, 0 otherwise
|
||||
Obj arg3 - the target object
|
||||
|
||||
mixed ret1 - overrides the target object, or pass -1 to prevent the player from attacking the object
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
HOOK_ENCOUNTER (hs_encounter.int)
|
||||
|
||||
Runs whenever a random encounter occurs (except the Horrigan meeting and scripted encounters), or when the player enters a local map from the world map.
|
||||
You can override the map for loading or the encounter.
|
||||
|
||||
int arg1 - event type: 0 - when a random encounter occurs, 1 - when the player enters from the world map
|
||||
int arg2 - the map ID that the encounter will load (see MAPS.h or Maps.txt)
|
||||
int arg3 - 1 when the encounter occurs is a special encounter, 0 otherwise
|
||||
|
||||
int ret1 - overrides the map ID, or pass -1 for event type 0 to cancel the encounter and continue traveling
|
||||
int ret2 - pass 1 to cancel the encounter and load the specified map from the ret1 (only for event type 0)
|
||||
|
||||
@@ -137,7 +137,7 @@ array - array ID to be used with array-related functions (actually an integer)
|
||||
- The player will not get an outdoorsman skill check.
|
||||
|
||||
> void force_encounter_with_flags(int map, int flags)
|
||||
- does the same thing as force_encounter, but allows the specification of some extra options.
|
||||
- does the same thing as force_encounter, but allows the specification of some extra options (see sfall.h for available flags).
|
||||
- Forcing a random encounter on a map that is not normally used for random encounters may cause the player to lose the car, if they have it.
|
||||
- In this case use force_encounter_with_flags with the ENCOUNTER_FLAG_NO_CAR flag set.
|
||||
|
||||
@@ -281,10 +281,15 @@ Some utility/math functions are available:
|
||||
> int charcode(string string)
|
||||
- returns ASCII code for the first character in given string
|
||||
|
||||
> div operator (unsigned integer division)
|
||||
- use as a division operator, like 3 + (20 div 5)
|
||||
- if both dividend and divisor are integers, they will be treated as unsigned integers
|
||||
- if one of them is a float, div will perform the signed division just like vanilla division operator
|
||||
|
||||
> ^ operator (exponentiation)
|
||||
- use as any other arithmetic operator, like 5^(1/3)
|
||||
- if exponent is integer, you can use negative base, otherwise you will get "nan" with negative base
|
||||
- if both arguments are integers, result will be integer
|
||||
- if exponent is an integer, you can use a negative base, otherwise you will get "NaN" with a negative base
|
||||
- if both arguments are integers, the result will be an integer
|
||||
|
||||
> float log(float x)
|
||||
- natural logarithm of x
|
||||
@@ -694,9 +699,37 @@ optional argument:
|
||||
- the radius is limited to 50 hexes
|
||||
|
||||
> int sfall_func2("tile_by_position", int x, int y)
|
||||
- returns the tile number at the x, y position relative to the top-left corner of the screen
|
||||
- returns the tile number at the x, y position relative to the top-left corner of the game screen
|
||||
- if the position is outside of the range of tiles, it will return -1
|
||||
|
||||
> string sfall_func2("string_to_case", string text, int toCase)
|
||||
- converts all letters in the given string to the specified case
|
||||
- toCase: 0 - lowercase, 1 - uppercase
|
||||
- NOTE: this function works only for English letters of A-Z/a-z
|
||||
|
||||
> void sfall_func3("set_terrain_name", int x, int y, string name)
|
||||
- overrides the terrain type name for the sub-tile on the world map by the specified coordinates
|
||||
|
||||
> int sfall_func1("get_window_attribute", int winType)
|
||||
> int sfall_func2("get_window_attribute", int winType, int attrType)
|
||||
- returns the attribute of the specified interface window by the attrType argument
|
||||
- winType: the type number of the interface window (see WINTYPE_* constants in sfall.h)
|
||||
- attrType: 0 - checks and returns a value of 1 if the specified interface window is created by the game (same as without the argument)
|
||||
1 - X position, 2 - Y position (relative to the top-left corner of the game screen)
|
||||
- returns -1 if the specified attribute cannot be obtained
|
||||
|
||||
> void sfall_func2("set_town_title", int areaID, string title)
|
||||
- sets a floating text for a town on the world map when hovering the cursor over the player's marker
|
||||
- areaID: the ID number of the town from city.txt
|
||||
|
||||
> int sfall_func4("message_box", string message, int flags, int color1, int color2)
|
||||
- creates a dialog box with text and returns the result of pressing the button: 0 - No (Escape), 1 - Yes/Done (Enter)
|
||||
- returns -1 if for some reason the dialog box cannot be created
|
||||
- message: the text in the dialog box. Use the \n control character to move text to a new line (example: "Hello\nWorld!")
|
||||
optional arguments:
|
||||
- flags: mode flags (see MSGBOX_* constants in define_extra.h). Pass -1 to skip setting the flags (default flags are NORMAL and YESNO)
|
||||
- color1/2: the color index in Fallout palette. color1 sets the text color for the first line, and color2 for all subsequent lines of text (default color is 145)
|
||||
|
||||
------------------------
|
||||
------ MORE INFO -------
|
||||
------------------------
|
||||
|
||||
@@ -360,6 +360,8 @@
|
||||
0x827d - void register_hook_proc_spec(int hook, procedure proc)
|
||||
0x827e - void reg_anim_callback(procedure proc)
|
||||
|
||||
0x827f - div operator (unsigned integer division)
|
||||
|
||||
|
||||
* These functions require AllowUnsafeScripting to be enabled in ddraw.ini
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace sfall
|
||||
std::multimap<long, long> writeAddress;
|
||||
|
||||
static std::vector<long> excludeAddr = {
|
||||
0x42a14f, 0x42a178,
|
||||
0x42A14F, 0x42A178,
|
||||
0x44E949, 0x44E94A, 0x44E937, 0x4F5F40, 0x4CB850, // from movies.cpp
|
||||
};
|
||||
|
||||
struct HackPair {
|
||||
@@ -72,6 +73,7 @@ static std::vector<HackPair> hackAddr = {
|
||||
{0x484B18, 1}, {0x484B19, 4}, // hookcall
|
||||
// module: Movies
|
||||
{0x44E937, 1}, {0x44E938, 4}, {0x44E949, 1}, {0x44E94A, 4}, // hookcalls
|
||||
{0x4F5F40, 1}, {0x4CB850, 1},
|
||||
// module: Objects
|
||||
{0x4A364A, 5}, {0x4831D9, 1}, {0x4831DA, 1},
|
||||
{0x4841D6, 1}, {0x4841D7, 4}, // hookcall
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Functions.h"
|
||||
#include "FunctionOffsets.h"
|
||||
@@ -33,11 +32,11 @@ namespace fo
|
||||
|
||||
static MessageNode messageBuf;
|
||||
|
||||
const char* _stdcall GetMessageStr(const MessageList* fileAddr, long messageId) {
|
||||
const char* GetMessageStr(const MessageList* fileAddr, long messageId) {
|
||||
return fo::func::getmsg(fileAddr, &messageBuf, messageId);
|
||||
}
|
||||
|
||||
const char* _stdcall MessageSearch(const MessageList* fileAddr, long messageId) {
|
||||
const char* MessageSearch(const MessageList* fileAddr, long messageId) {
|
||||
messageBuf.number = messageId;
|
||||
if (fo::func::message_search(fileAddr, &messageBuf) == 1) {
|
||||
return messageBuf.message;
|
||||
@@ -118,11 +117,11 @@ long GetCurrentAttackMode() {
|
||||
long activeHand = fo::var::itemCurrentItem; // 0 - left, 1 - right
|
||||
switch (fo::var::itemButtonItems[activeHand].mode) {
|
||||
case 1:
|
||||
case 2: // 2 - called shot
|
||||
case 2: // called shot
|
||||
hitMode = fo::var::itemButtonItems[activeHand].primaryAttack;
|
||||
break;
|
||||
case 3:
|
||||
case 4: // 4 - called shot
|
||||
case 4: // called shot
|
||||
hitMode = fo::var::itemButtonItems[activeHand].secondaryAttack;
|
||||
break;
|
||||
case 5: // reload mode
|
||||
@@ -196,6 +195,51 @@ long __fastcall GetTopWindowID(long xPos, long yPos) {
|
||||
return win->wID;
|
||||
}
|
||||
|
||||
enum WinNameType {
|
||||
Inventory = 0, // any inventory window (player/loot/use/barter)
|
||||
Dialog = 1,
|
||||
PipBoy = 2,
|
||||
WorldMap = 3,
|
||||
IfaceBar = 4, // the interface bar
|
||||
Character = 5,
|
||||
Skilldex = 6,
|
||||
EscMenu = 7, // escape menu
|
||||
//Automap = 8 // for this window there is no global variable
|
||||
};
|
||||
|
||||
fo::Window* GetWindow(long winType) {
|
||||
long winID = 0;
|
||||
switch (winType) {
|
||||
case WinNameType::Inventory:
|
||||
winID = fo::var::i_wid;
|
||||
break;
|
||||
case WinNameType::Dialog:
|
||||
winID = fo::var::dialogueBackWindow;
|
||||
break;
|
||||
case WinNameType::PipBoy:
|
||||
winID = fo::var::pip_win;
|
||||
break;
|
||||
case WinNameType::WorldMap:
|
||||
winID = fo::var::wmBkWin;
|
||||
break;
|
||||
case WinNameType::IfaceBar:
|
||||
winID = fo::var::interfaceWindow;
|
||||
break;
|
||||
case WinNameType::Character:
|
||||
winID = fo::var::edit_win;
|
||||
break;
|
||||
case WinNameType::Skilldex:
|
||||
winID = fo::var::skldxwin;
|
||||
break;
|
||||
case WinNameType::EscMenu:
|
||||
winID = fo::var::optnwin;
|
||||
break;
|
||||
default:
|
||||
return (fo::Window*)-1;
|
||||
}
|
||||
return (winID > 0) ? fo::func::GNW_find(winID) : nullptr;
|
||||
}
|
||||
|
||||
// Returns an array of objects within the specified radius from the source tile
|
||||
void GetObjectsTileRadius(std::vector<fo::GameObject*> &objs, long sourceTile, long radius, long elev, long type = -1) {
|
||||
for (long tile = 0; tile < 40000; tile++) {
|
||||
@@ -212,87 +256,187 @@ void GetObjectsTileRadius(std::vector<fo::GameObject*> &objs, long sourceTile, l
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the type of the terrain sub tile at the the player's position on the world map
|
||||
long wmGetCurrentTerrainType() {
|
||||
long* terrainId = *(long**)FO_VAR_world_subtile;
|
||||
if (terrainId == nullptr) {
|
||||
__asm {
|
||||
lea ebx, terrainId;
|
||||
mov edx, dword ptr ds:[FO_VAR_world_ypos];
|
||||
mov eax, dword ptr ds:[FO_VAR_world_xpos];
|
||||
call fo::funcoffs::wmFindCurSubTileFromPos_;
|
||||
}
|
||||
}
|
||||
return *terrainId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//print text to surface
|
||||
void PrintText(char *DisplayText, BYTE ColourIndex, DWORD Xpos, DWORD Ypos, DWORD TxtWidth, DWORD ToWidth, BYTE *ToSurface) {
|
||||
DWORD posOffset = Ypos * ToWidth + Xpos;
|
||||
// copy the area from the interface buffer to the data array
|
||||
void SurfaceCopyToMem(long fromX, long fromY, long width, long height, long fromWidth, BYTE* fromSurface, BYTE* toMem) {
|
||||
fromSurface += fromY * fromWidth + fromX;
|
||||
long i = 0;
|
||||
for (long h = 0; h < height; h++) {
|
||||
for (long w = 0; w < width; w++) {
|
||||
toMem[i++] = fromSurface[w];
|
||||
}
|
||||
fromSurface += fromWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// safe copy data from memory to the area of the interface buffer
|
||||
void DrawToSurface(long toX, long toY, long width, long height, long toWidth, long toHeight, BYTE* toSurface, BYTE* fromMem) {
|
||||
BYTE* _toSurface = toSurface + (toY * toWidth + toX);
|
||||
BYTE* endToSurf = (toWidth * toHeight) + toSurface;
|
||||
long i = 0;
|
||||
for (long h = 0; h < height; h++) {
|
||||
for (long w = 0; w < width; w++) {
|
||||
if (_toSurface + w > endToSurf) return;
|
||||
if (_toSurface >= toSurface) _toSurface[w] = fromMem[i++];
|
||||
}
|
||||
_toSurface += toWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// safe copy data from surface to surface with mask
|
||||
void DrawToSurface(long width, long height, long fromX, long fromY, long fromWidth, BYTE* fromSurf,
|
||||
long toX, long toY, long toWidth, long toHeight, BYTE* toSurf, int maskRef)
|
||||
{
|
||||
BYTE* _fromSurf = fromSurf + (fromY * fromWidth + fromX);
|
||||
BYTE* _toSurf = toSurf + (toY * toWidth + toX);
|
||||
BYTE* endToSurf = (toWidth * toHeight) + toSurf;
|
||||
|
||||
for (long h = 0; h < height; h++) {
|
||||
for (long w = 0; w < width; w++) {
|
||||
if (_toSurf + w > endToSurf) return;
|
||||
if (_toSurf >= toSurf && _fromSurf[w] != maskRef) _toSurf[w] = _fromSurf[w];
|
||||
}
|
||||
_fromSurf += fromWidth;
|
||||
_toSurf += toWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// safe copy data from surface to surface
|
||||
void DrawToSurface(long width, long height, long fromX, long fromY, long fromWidth, BYTE* fromSurf,
|
||||
long toX, long toY, long toWidth, long toHeight, BYTE* toSurf)
|
||||
{
|
||||
BYTE* _fromSurf = fromSurf + (fromY * fromWidth + fromX);
|
||||
BYTE* _toSurf = toSurf + (toY * toWidth + toX);
|
||||
BYTE* endToSurf = (toWidth * toHeight) + toSurf;
|
||||
|
||||
for (long h = 0; h < height; h++) {
|
||||
for (long w = 0; w < width; w++) {
|
||||
if (_toSurf + w > endToSurf) return;
|
||||
if (_toSurf >= toSurf) _toSurf[w] = _fromSurf[w];
|
||||
}
|
||||
_fromSurf += fromWidth;
|
||||
_toSurf += toWidth;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// print text to surface
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) {
|
||||
DWORD posOffset = yPos * toWidth + xPos;
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
mov al, ColourIndex;
|
||||
mov al, colorIndex;
|
||||
mov edx, displayText;
|
||||
push eax;
|
||||
mov edx, DisplayText;
|
||||
mov ebx, TxtWidth;
|
||||
mov ecx, ToWidth;
|
||||
mov eax, ToSurface;
|
||||
mov ebx, txtWidth;
|
||||
mov eax, toSurface;
|
||||
mov ecx, toWidth;
|
||||
add eax, posOffset;
|
||||
call dword ptr ds:[FO_VAR_text_to_buf];
|
||||
}
|
||||
}
|
||||
|
||||
void PrintTextFM(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) {
|
||||
DWORD posOffset = yPos * toWidth + xPos;
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
mov al, colorIndex;
|
||||
mov edx, displayText;
|
||||
push eax;
|
||||
mov ebx, txtWidth;
|
||||
mov eax, toSurface;
|
||||
mov ecx, toWidth;
|
||||
add eax, posOffset;
|
||||
call fo::funcoffs::FMtext_to_buf_;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//gets the height of the currently selected font
|
||||
DWORD GetTextHeight() {
|
||||
DWORD TxtHeight;
|
||||
// DWORD TxtHeight;
|
||||
__asm {
|
||||
call dword ptr ds:[FO_VAR_text_height]; //get text height
|
||||
mov TxtHeight, eax;
|
||||
// mov TxtHeight, eax;
|
||||
}
|
||||
return TxtHeight;
|
||||
// return TxtHeight;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//gets the length of a string using the currently selected font
|
||||
DWORD GetTextWidth(const char *TextMsg) {
|
||||
DWORD GetTextWidth(const char* TextMsg) {
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[FO_VAR_text_width]; //get text width
|
||||
}
|
||||
}
|
||||
|
||||
DWORD GetTextWidthFM(const char* TextMsg) {
|
||||
return fo::func::FMtext_width(TextMsg); //get text width
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get width of Char for current font
|
||||
DWORD GetCharWidth(char CharVal) {
|
||||
DWORD charWidth;
|
||||
DWORD GetCharWidth(char charVal) {
|
||||
__asm {
|
||||
mov al, CharVal;
|
||||
mov al, charVal;
|
||||
call dword ptr ds:[FO_VAR_text_char_width];
|
||||
mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
DWORD GetCharWidthFM(char charVal) {
|
||||
__asm {
|
||||
mov al, charVal;
|
||||
call fo::funcoffs::FMtext_char_width_;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get maximum string length for current font - if all characters were maximum width
|
||||
DWORD GetMaxTextWidth(char *TextMsg) {
|
||||
DWORD msgWidth;
|
||||
DWORD GetMaxTextWidth(const char* TextMsg) {
|
||||
// DWORD msgWidth;
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[FO_VAR_text_mono_width];
|
||||
mov msgWidth, eax;
|
||||
// mov msgWidth, eax;
|
||||
}
|
||||
return msgWidth;
|
||||
// return msgWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get number of pixels between characters for current font
|
||||
DWORD GetCharGapWidth() {
|
||||
DWORD gapWidth;
|
||||
// DWORD gapWidth;
|
||||
__asm {
|
||||
call dword ptr ds:[FO_VAR_text_spacing];
|
||||
mov gapWidth, eax;
|
||||
// mov gapWidth, eax;
|
||||
}
|
||||
return gapWidth;
|
||||
// return gapWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get maximum character width for current font
|
||||
DWORD GetMaxCharWidth() {
|
||||
DWORD charWidth = 0;
|
||||
// DWORD charWidth = 0;
|
||||
__asm {
|
||||
call dword ptr ds:[FO_VAR_text_max];
|
||||
mov charWidth, eax;
|
||||
// mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
// return charWidth;
|
||||
}
|
||||
|
||||
void RedrawObject(GameObject* obj) {
|
||||
|
||||
@@ -36,10 +36,10 @@ inline void DisplayPrint(const std::string& str) {
|
||||
}
|
||||
|
||||
// returns message string from given file or "Error" when not found
|
||||
const char* _stdcall GetMessageStr(const MessageList* fileAddr, long messageId);
|
||||
const char* GetMessageStr(const MessageList* fileAddr, long messageId);
|
||||
|
||||
// similar to GetMessageStr, but returns nullptr when no message is found
|
||||
const char* _stdcall MessageSearch(const MessageList* fileAddr, long messageId);
|
||||
const char* MessageSearch(const MessageList* fileAddr, long messageId);
|
||||
|
||||
// returns pointer to prototype by PID, or nullptr on failure
|
||||
Proto* GetProto(long pid);
|
||||
@@ -78,20 +78,41 @@ long GetScriptLocalVars(long sid);
|
||||
|
||||
long __fastcall GetTopWindowID(long xPos, long yPos);
|
||||
|
||||
fo::Window* GetWindow(long winType);
|
||||
|
||||
void GetObjectsTileRadius(std::vector<fo::GameObject*> &objs, long sourceTile, long radius, long elev, long type);
|
||||
|
||||
long wmGetCurrentTerrainType();
|
||||
|
||||
void SurfaceCopyToMem(long fromX, long fromY, long width, long height, long fromWidth, BYTE* fromSurface, BYTE* toMem);
|
||||
|
||||
void DrawToSurface(long toX, long toY, long width, long height, long toWidth, long toHeight, BYTE* toSurface, BYTE* fromMem);
|
||||
|
||||
void DrawToSurface(long width, long height, long fromX, long fromY, long fromWidth, BYTE* fromSurf, long toX, long toY, long toWidth, long toHeight, BYTE* toSurf, int maskRef);
|
||||
|
||||
void DrawToSurface(long width, long height, long fromX, long fromY, long fromWidth, BYTE* fromSurf, long toX, long toY, long toWidth, long toHeight, BYTE* toSurf);
|
||||
|
||||
// Print text to surface
|
||||
void PrintText(char *displayText, BYTE colorIndex, DWORD x, DWORD y, DWORD textWidth, DWORD destWidth, BYTE *surface);
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface);
|
||||
void PrintTextFM(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface);
|
||||
|
||||
// gets the height of the currently selected font
|
||||
DWORD GetTextHeight();
|
||||
|
||||
// gets the length of a string using the currently selected font
|
||||
DWORD GetTextWidth(const char *textMsg);
|
||||
DWORD GetTextWidth(const char* textMsg);
|
||||
DWORD GetTextWidthFM(const char* textMsg);
|
||||
|
||||
// get width of Char for current font
|
||||
DWORD GetCharWidth(char charVal);
|
||||
DWORD GetCharWidthFM(char charVal);
|
||||
|
||||
// get maximum string length for current font - if all characters were maximum width
|
||||
DWORD GetMaxTextWidth(char *textMsg);
|
||||
DWORD GetMaxTextWidth(const char* textMsg);
|
||||
|
||||
// get number of pixels between characters for current font
|
||||
DWORD GetCharGapWidth();
|
||||
|
||||
// get maximum character width for current font
|
||||
DWORD GetMaxCharWidth();
|
||||
|
||||
|
||||
@@ -90,6 +90,24 @@ enum Animation : long
|
||||
ANIM_called_shot_pic = 64,
|
||||
};
|
||||
|
||||
enum CritterFlags : long
|
||||
{
|
||||
Sneak = 0x01, // Can sneak ?
|
||||
Barter = 0x02, // Can trade with
|
||||
Level = 0x04, // Level received ?
|
||||
Addict = 0x08, // Drug addiction ?
|
||||
NoSteal = 0x20, // Can't be stolen from
|
||||
NoDrop = 0x40, // Doesn't drop items
|
||||
NoLimbs = 0x80, // Can't lose limbs
|
||||
NoAges = 0x100, // Dead body does not disappear
|
||||
NoHeal = 0x200, // Damage is not healed with time
|
||||
Invulnerable = 0x400, // Is Invulnerable (cannot be hurt)
|
||||
NoFlatten = 0x800, // Doesn't flatten on death (leaves no dead body)
|
||||
SpecialDeath = 0x1000, // Has a special type of death
|
||||
RangeHtH = 0x2000, // Has extra hand-to-hand range
|
||||
NoKnockBack = 0x4000, // Can't be knocked back
|
||||
};
|
||||
|
||||
enum DamageFlag : long
|
||||
{
|
||||
DAM_KNOCKED_OUT = 0x1,
|
||||
@@ -646,6 +664,30 @@ enum BodyType : long
|
||||
Robotic = 2
|
||||
};
|
||||
|
||||
enum KillType : long
|
||||
{
|
||||
KILL_TYPE_men = 0,
|
||||
KILL_TYPE_women = 1,
|
||||
KILL_TYPE_children = 2,
|
||||
KILL_TYPE_super_mutant = 3,
|
||||
KILL_TYPE_ghoul = 4,
|
||||
KILL_TYPE_brahmin = 5,
|
||||
KILL_TYPE_radscorpion = 6,
|
||||
KILL_TYPE_rat = 7,
|
||||
KILL_TYPE_floater = 8,
|
||||
KILL_TYPE_centaur = 9,
|
||||
KILL_TYPE_robot = 10,
|
||||
KILL_TYPE_dog = 11,
|
||||
KILL_TYPE_manti = 12,
|
||||
KILL_TYPE_deathclaw = 13,
|
||||
KILL_TYPE_plant = 14,
|
||||
KILL_TYPE_gecko = 15,
|
||||
KILL_TYPE_alien = 16,
|
||||
KILL_TYPE_giant_ant = 17,
|
||||
KILL_TYPE_big_bad_boss = 18,
|
||||
KILL_TYPE_count
|
||||
};
|
||||
|
||||
#define PLAYER_ID (18000)
|
||||
|
||||
#define OBJFLAG_CAN_WEAR_ITEMS (0xF000000)
|
||||
@@ -662,6 +704,8 @@ enum BodyType : long
|
||||
|
||||
#define AUTOMAP_MAX (160)
|
||||
|
||||
#define MSG_GENDER_CHECK_FLG (0x80) // bit 8
|
||||
|
||||
enum TicksTime : unsigned long
|
||||
{
|
||||
ONE_GAME_YEAR = 315360000
|
||||
@@ -763,4 +807,14 @@ enum QueueType : long
|
||||
gsound_sfx_event = 13 // no object
|
||||
};
|
||||
|
||||
enum DialogOutFlags : long
|
||||
{
|
||||
DIALOGOUT_NORMAL = 0x01, // uses regular graphic
|
||||
DIALOGOUT_SMALL = 0x02, // uses smaller graphic
|
||||
DIALOGOUT_ALIGN_LEFT = 0x04, // text aligned to left
|
||||
DIALOGOUT_ALIGN_TOP = 0x08, // text aligned to top
|
||||
DIALOGOUT_YESNO = 0x10, // DONE button replaced by YES/NO buttons
|
||||
DIALOGOUT_CLEAN = 0x20 // no buttons
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ FUNC(barter_attempt_transaction_, 0x474C50)
|
||||
FUNC(barter_compute_value_, 0x474B2C)
|
||||
FUNC(barter_end_to_talk_to_, 0x448268)
|
||||
FUNC(barter_inventory_, 0x4757F0)
|
||||
FUNC(barter_move_from_table_inventory_, 0x475070)
|
||||
FUNC(barter_move_from_table_inventory_, 0x475070)
|
||||
FUNC(barter_move_inventory_, 0x474DAC)
|
||||
FUNC(bbox_comp_, 0x461624)
|
||||
FUNC(bi_flush_, 0x4E9738)
|
||||
|
||||
@@ -32,7 +32,7 @@ void __declspec(naked) dev_printf(const char* fmt, ...) {
|
||||
__asm jmp fo::funcoffs::debug_printf_;
|
||||
}
|
||||
#else
|
||||
void dev_printf(const char* fmt, ...) {}
|
||||
void dev_printf(...) {}
|
||||
#endif
|
||||
|
||||
// Fallout2.exe was compiled using WATCOM compiler, which uses Watcom register calling convention.
|
||||
@@ -228,24 +228,45 @@ DWORD __stdcall interpretPopLong(Program* scriptPtr) {
|
||||
WRAP_WATCOM_CALL1(interpretPopLong_, scriptPtr)
|
||||
}
|
||||
|
||||
// pushes value to Data stack (must be followed by InterpretPushShort)
|
||||
void __stdcall interpretPushLong(Program* scriptPtr, DWORD val) {
|
||||
WRAP_WATCOM_CALL2(interpretPushLong_, scriptPtr, val)
|
||||
}
|
||||
|
||||
// pushes value type to Data stack (must be preceded by InterpretPushLong)
|
||||
void __stdcall interpretPushShort(Program* scriptPtr, DWORD valType) {
|
||||
WRAP_WATCOM_CALL2(interpretPushShort_, scriptPtr, valType)
|
||||
}
|
||||
|
||||
DWORD __stdcall interpretAddString(Program* scriptPtr, const char* strval) {
|
||||
WRAP_WATCOM_CALL2(interpretAddString_, scriptPtr, strval)
|
||||
}
|
||||
|
||||
const char* __fastcall interpretGetString(Program* scriptPtr, DWORD dataType, DWORD strId) {
|
||||
WRAP_WATCOM_FCALL3(interpretGetString_, scriptPtr, dataType, strId)
|
||||
}
|
||||
|
||||
void interpretReturnValue(Program* scriptPtr, DWORD val, DWORD valType) {
|
||||
__asm {
|
||||
mov esi, scriptPtr;
|
||||
mov edx, val;
|
||||
cmp valType, VAR_TYPE_STR;
|
||||
jne isNotStr;
|
||||
mov eax, esi;
|
||||
call fo::funcoffs::interpretAddString_;
|
||||
mov edx, eax;
|
||||
isNotStr:
|
||||
mov eax, esi;
|
||||
call fo::funcoffs::interpretPushLong_; // pushes value to Data stack (must be followed by InterpretPushShort)
|
||||
mov edx, valType;
|
||||
mov eax, esi;
|
||||
call fo::funcoffs::interpretPushShort_; // pushes value type to Data stack (must be preceded by InterpretPushLong)
|
||||
}
|
||||
}
|
||||
|
||||
DWORD __fastcall interpretGetValue(Program* scriptPtr, DWORD &outType) {
|
||||
__asm {
|
||||
mov eax, ecx;
|
||||
call fo::funcoffs::interpretPopShort_; // pops value type from Data stack (must be followed by InterpretPopLong)
|
||||
mov [edx], eax; // out type
|
||||
mov edx, eax;
|
||||
mov eax, ecx;
|
||||
call fo::funcoffs::interpretPopLong_; // pops value from Data stack (must be preceded by InterpretPopShort)
|
||||
cmp dx, VAR_TYPE_STR;
|
||||
ja isNotStr;
|
||||
mov ebx, eax;
|
||||
mov eax, ecx;
|
||||
call fo::funcoffs::interpretGetString_; // retrieve string argument
|
||||
isNotStr:
|
||||
}
|
||||
}
|
||||
|
||||
// prints scripting error in debug.log and stops current script execution by performing longjmp
|
||||
// USE WITH CAUTION
|
||||
void __declspec(naked) interpretError(const char* fmt, ...) {
|
||||
@@ -317,7 +338,7 @@ long __stdcall message_exit(MessageList *msgList) {
|
||||
|
||||
long __fastcall tile_num(long x, long y) {
|
||||
__asm push ebx; // don't delete (bug in tile_num_)
|
||||
WRAP_WATCOM_FCALL2(tile_num_, x, x);
|
||||
WRAP_WATCOM_FCALL2(tile_num_, x, y)
|
||||
__asm pop ebx;
|
||||
}
|
||||
|
||||
@@ -404,21 +425,45 @@ long __stdcall win_register_button(DWORD winRef, long xPos, long yPos, long widt
|
||||
|
||||
void __stdcall DialogOut(const char* text) {
|
||||
__asm {
|
||||
push 1; // flag
|
||||
xor eax, eax;
|
||||
push eax; // ColorMsg
|
||||
push eax; // DisplayMsg
|
||||
mov al, byte ptr ds:[0x6AB718];
|
||||
push eax; // ColorIndex
|
||||
push 116; // y
|
||||
push 1; // DIALOGOUT_NORMAL flag
|
||||
xor edx, edx;
|
||||
push edx;
|
||||
push edx;
|
||||
mov dl, byte ptr ds:[0x6AB718];
|
||||
push edx; // ColorMsg
|
||||
mov ecx, 192; // x
|
||||
push 116; // y
|
||||
mov eax, text; // DisplayText
|
||||
xor ebx, ebx; // ?
|
||||
xor edx, edx; // ?
|
||||
xor ebx, ebx;
|
||||
call fo::funcoffs::dialog_out_;
|
||||
}
|
||||
}
|
||||
|
||||
long __fastcall DialogOutEx(const char* text, const char** textEx, long lines, long flags, long colors) {
|
||||
__asm {
|
||||
mov ebx, colors; // Color index
|
||||
xor eax, eax;
|
||||
push flags;
|
||||
test ebx, ebx;
|
||||
jnz cColor;
|
||||
mov al, byte ptr ds:[0x6AB718];
|
||||
mov bl, al;
|
||||
jmp skip;
|
||||
cColor:
|
||||
mov al, bh;
|
||||
and ebx, 0xFF
|
||||
skip:
|
||||
push eax; // ColorMsg2
|
||||
push 0; // DisplayMsg (unknown)
|
||||
mov eax, ecx; // DisplayText (first line)
|
||||
push ebx; // ColorMsg1
|
||||
mov ecx, 192; // x
|
||||
push 116; // y
|
||||
mov ebx, lines; // count second lines
|
||||
call fo::funcoffs::dialog_out_; // edx - DisplayText (seconds lines)
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall DrawWinLine(int winRef, DWORD startXPos, DWORD endXPos, DWORD startYPos, DWORD endYPos, BYTE colour) {
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
|
||||
@@ -30,7 +30,11 @@ namespace func
|
||||
{
|
||||
|
||||
// Prints debug message to debug.log file for develop build
|
||||
#ifndef NDEBUG
|
||||
void dev_printf(const char* fmt, ...);
|
||||
#else
|
||||
void dev_printf(...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Add functions here if they have non-trivial wrapper implementation (like vararg functions or too many arguments, etc.)
|
||||
@@ -116,15 +120,11 @@ DWORD __stdcall interpretPopShort(Program* scriptPtr);
|
||||
// pops value from Data stack (must be preceded by InterpretPopShort)
|
||||
DWORD __stdcall interpretPopLong(Program* scriptPtr);
|
||||
|
||||
// pushes value to Data stack (must be followed by InterpretPushShort)
|
||||
void __stdcall interpretPushLong(Program* scriptPtr, DWORD val);
|
||||
|
||||
// pushes value type to Data stack (must be preceded by InterpretPushLong)
|
||||
void __stdcall interpretPushShort(Program* scriptPtr, DWORD valType);
|
||||
|
||||
const char* __fastcall interpretGetString(Program* scriptPtr, DWORD dataType, DWORD strId);
|
||||
|
||||
DWORD __stdcall interpretAddString(Program* scriptPtr, const char* str);
|
||||
void interpretReturnValue(Program* scriptPtr, DWORD val, DWORD valType);
|
||||
|
||||
DWORD __fastcall interpretGetValue(Program* scriptPtr, DWORD &outType);
|
||||
|
||||
// prints scripting error in debug.log and stops current script execution by performing longjmp
|
||||
// USE WITH CAUTION
|
||||
@@ -204,6 +204,8 @@ long __stdcall win_register_button(DWORD winRef, long xPos, long yPos, long widt
|
||||
|
||||
void __stdcall DialogOut(const char* text);
|
||||
|
||||
long __fastcall DialogOutEx(const char* text, const char** textEx, long lines, long flags, long colors = 0);
|
||||
|
||||
// draws an image to the buffer without scaling and with transparency display toggle
|
||||
void __fastcall windowDisplayBuf(long x, long width, long y, long height, void* data, long noTrans);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ WRAP_WATCOM_FFUNC3(FrmFrameData*, frame_ptr, FrmHeaderData*, frm, long, frame, l
|
||||
WRAP_WATCOM_FFUNC3(void, intface_update_items, long, animate, long, modeLeft,long, modeRight)
|
||||
WRAP_WATCOM_FFUNC3(long, item_add_force, GameObject*, critter, GameObject*, item, long, count)
|
||||
WRAP_WATCOM_FFUNC7(void, make_straight_path_func, GameObject*, objFrom, DWORD, tileFrom, DWORD, tileTo, void*, rotationPtr, DWORD*, result, long, flags, void*, func)
|
||||
WRAP_WATCOM_FFUNC3(long, message_find, DWORD*, msgFile, long, msgNumber, DWORD*, outBuf)
|
||||
WRAP_WATCOM_FFUNC4(long, mouse_click_in, long, x, long, y, long, x_end, long, y_end)
|
||||
WRAP_WATCOM_FFUNC3(GameObject*, obj_blocking_at, GameObject*, object, long, tile, long, elevation)
|
||||
WRAP_WATCOM_FFUNC4(long, obj_move_to_tile, GameObject*, object, long, tile, long, elevation, RECT*, rect)
|
||||
@@ -49,6 +50,7 @@ WRAP_WATCOM_FUNC4(BYTE*, art_ptr_lock_data, long, frmId, long, frameNum, long, r
|
||||
WRAP_WATCOM_FUNC4(BYTE*, art_lock, long, frmId, DWORD*, lockPtr, long*, widthOut, long*, heightOut)
|
||||
WRAP_WATCOM_FUNC1(long, art_ptr_unlock, DWORD, lockId)
|
||||
WRAP_WATCOM_FUNC2(long, barter_compute_value, GameObject*, source, GameObject*, target)
|
||||
WRAP_WATCOM_FUNC1(long, block_for_tocks, long, ticks)
|
||||
WRAP_WATCOM_FUNC1(void*, dbase_open, const char*, fileName)
|
||||
WRAP_WATCOM_FUNC1(void, dbase_close, void*, dbPtr)
|
||||
WRAP_WATCOM_FUNC3(long, db_freadShortCount, DbFile*, file, WORD*, dest, long, count)
|
||||
@@ -62,11 +64,13 @@ WRAP_WATCOM_FUNC1(long, critter_is_dead, GameObject*, critter)
|
||||
WRAP_WATCOM_FUNC1(void, EndLoad, DbFile*, file)
|
||||
WRAP_WATCOM_FUNC1(long, folder_print_line, const char*, text)
|
||||
WRAP_WATCOM_FUNC1(long, folder_print_seperator, const char*, text)
|
||||
WRAP_WATCOM_FUNC1(long, FMtext_width, const char*, text)
|
||||
WRAP_WATCOM_FUNC1(long, game_get_global_var, long, globalVar)
|
||||
WRAP_WATCOM_FUNC1(void, gdialogDisplayMsg, const char*, message)
|
||||
WRAP_WATCOM_FUNC0(long, gmouse_3d_get_mode)
|
||||
WRAP_WATCOM_FUNC1(void, gmouse_3d_set_mode, long, mode)
|
||||
WRAP_WATCOM_FUNC1(long, gmouse_set_cursor, long, picNum)
|
||||
WRAP_WATCOM_FUNC1(long, gsound_background_volume_get_set, long, setVolume)
|
||||
WRAP_WATCOM_FUNC1(Window*, GNW_find, long, winRef)
|
||||
WRAP_WATCOM_FUNC2(long, intface_get_attack, DWORD*, hitMode, DWORD*, isSecondary)
|
||||
WRAP_WATCOM_FUNC0(long, intface_is_item_right_hand)
|
||||
@@ -172,9 +176,11 @@ WRAP_WATCOM_FUNC1(void, win_show, DWORD, winRef)
|
||||
WRAP_WATCOM_FUNC1(void, win_hide, DWORD, winRef)
|
||||
WRAP_WATCOM_FUNC1(BYTE*, win_get_buf, DWORD, winRef)
|
||||
WRAP_WATCOM_FUNC1(void, win_draw, DWORD, winRef)
|
||||
WRAP_WATCOM_FUNC2(void, win_draw_rect, DWORD, winRef, RECT*, rect)
|
||||
WRAP_WATCOM_FUNC1(void, win_delete, DWORD, winRef)
|
||||
WRAP_WATCOM_FUNC0(long, windowWidth)
|
||||
WRAP_WATCOM_FUNC1(void, wmCarUseGas, long, gasAmount)
|
||||
WRAP_WATCOM_FUNC0(void, wmPartyWalkingStep)
|
||||
WRAP_WATCOM_FUNC1(void, wmRefreshInterfaceOverlay, long, isRedraw)
|
||||
WRAP_WATCOM_FUNC2(DbFile*, xfopen, const char*, fileName, const char*, flags)
|
||||
WRAP_WATCOM_FUNC3(long, xfseek, DbFile*, file, long, fOffset, long, origin)
|
||||
|
||||
@@ -47,11 +47,16 @@
|
||||
#define FO_VAR_currentWindow 0x51DCB8
|
||||
#define FO_VAR_cursor_line 0x664514
|
||||
#define FO_VAR_debug_func 0x51DF04
|
||||
#define FO_VAR_dialog_red_button_down_buf 0x58F4A4
|
||||
#define FO_VAR_dialog_red_button_down_key 0x58F4BC
|
||||
#define FO_VAR_dialog_red_button_up_buf 0x58F4AC
|
||||
#define FO_VAR_dialog_red_button_up_key 0x58F46C
|
||||
#define FO_VAR_dialog_target 0x518848
|
||||
#define FO_VAR_dialog_target_is_party 0x51884C
|
||||
#define FO_VAR_dialogue_head 0x518850
|
||||
#define FO_VAR_dialogue_state 0x518714
|
||||
#define FO_VAR_dialogue_switch_mode 0x518718
|
||||
#define FO_VAR_dialog_target 0x518848
|
||||
#define FO_VAR_dialog_target_is_party 0x51884C
|
||||
#define FO_VAR_dialogueBackWindow 0x518740
|
||||
#define FO_VAR_display_win 0x631E4C
|
||||
#define FO_VAR_displayMapList 0x41B560
|
||||
#define FO_VAR_dropped_explosive 0x5190E0
|
||||
@@ -60,6 +65,7 @@
|
||||
#define FO_VAR_edit_win 0x57060C
|
||||
#define FO_VAR_Educated 0x57082C
|
||||
#define FO_VAR_elevation 0x631D2C
|
||||
#define FO_VAR_EncounterMapID 0x672E4C
|
||||
#define FO_VAR_Experience_ 0x6681B4
|
||||
#define FO_VAR_fade_steps 0x6642D0
|
||||
#define FO_VAR_fallout_game_time 0x51C720
|
||||
@@ -115,6 +121,8 @@
|
||||
#define FO_VAR_last_buttons 0x51E2AC
|
||||
#define FO_VAR_last_button_winID 0x51E404
|
||||
#define FO_VAR_last_level 0x5707B4
|
||||
#define FO_VAR_lastMovieH 0x638E64
|
||||
#define FO_VAR_lastMovieW 0x638E68
|
||||
#define FO_VAR_Level_ 0x6681B0
|
||||
#define FO_VAR_Lifegiver 0x570854
|
||||
#define FO_VAR_lips_draw_head 0x519248
|
||||
@@ -158,6 +166,8 @@
|
||||
#define FO_VAR_obj_seen_check 0x6610BC
|
||||
#define FO_VAR_objectTable 0x639DA0
|
||||
#define FO_VAR_objItemOutlineState 0x519798
|
||||
#define FO_VAR_old_world_xpos 0x672E5C
|
||||
#define FO_VAR_old_world_ypos 0x672E60
|
||||
#define FO_VAR_optionRect 0x58ECC0
|
||||
#define FO_VAR_optionsButtonDown 0x59D400
|
||||
#define FO_VAR_optionsButtonDown1 0x570518
|
||||
@@ -165,6 +175,7 @@
|
||||
#define FO_VAR_optionsButtonUp 0x59D3FC
|
||||
#define FO_VAR_optionsButtonUp1 0x570514
|
||||
#define FO_VAR_optionsButtonUpKey 0x518F28
|
||||
#define FO_VAR_optnwin 0x663900
|
||||
#define FO_VAR_outlined_object 0x518D94
|
||||
#define FO_VAR_partyMemberAIOptions 0x519DB8
|
||||
#define FO_VAR_partyMemberCount 0x519DAC
|
||||
@@ -203,6 +214,7 @@
|
||||
#define FO_VAR_script_path_base 0x51C710
|
||||
#define FO_VAR_scriptListInfo 0x51C7C8
|
||||
#define FO_VAR_skill_data 0x51D118
|
||||
#define FO_VAR_skldxwin 0x668140
|
||||
#define FO_VAR_slot_cursor 0x5193B8
|
||||
#define FO_VAR_sndfx_volume 0x518E90
|
||||
#define FO_VAR_sneak_working 0x56D77C // DWORD var
|
||||
@@ -214,6 +226,7 @@
|
||||
#define FO_VAR_stack_offset 0x59E844
|
||||
#define FO_VAR_stat_data 0x51D53C
|
||||
#define FO_VAR_stat_flag 0x66452A
|
||||
#define FO_VAR_subtitles 0x663974
|
||||
#define FO_VAR_sWindows 0x6727B0
|
||||
#define FO_VAR_Tag_ 0x5708B0
|
||||
#define FO_VAR_tag_skill 0x668070
|
||||
@@ -239,15 +252,21 @@
|
||||
#define FO_VAR_wd_obj 0x59E98C
|
||||
#define FO_VAR_window 0x6ADE58
|
||||
#define FO_VAR_wmAreaInfoList 0x51DDF8
|
||||
#define FO_VAR_wmBkWin 0x51DE14
|
||||
#define FO_VAR_wmBkWinBuf 0x51DE24
|
||||
#define FO_VAR_wmEncounterIconShow 0x672E48
|
||||
#define FO_VAR_wmLastRndTime 0x51DEA0
|
||||
#define FO_VAR_wmMaxMapNum 0x51DE10
|
||||
#define FO_VAR_wmMaxTileNum 0x51DDF0
|
||||
#define FO_VAR_wmMsgFile 0x672FB0
|
||||
#define FO_VAR_wmNumHorizontalTiles 0x51DDF4
|
||||
#define FO_VAR_wmRndCursorFid 0x672E58
|
||||
#define FO_VAR_wmViewportRightScrlLimit 0x672EFC
|
||||
#define FO_VAR_wmViewportBottomtScrlLimit 0x672F00
|
||||
#define FO_VAR_wmWorldOffsetX 0x51DE2C
|
||||
#define FO_VAR_wmWorldOffsetY 0x51DE30
|
||||
#define FO_VAR_wmYesNoStrs 0x51DD90
|
||||
#define FO_VAR_world_subtile 0x672E14
|
||||
#define FO_VAR_world_xpos 0x672E0C
|
||||
#define FO_VAR_world_ypos 0x672E10
|
||||
#define FO_VAR_WorldMapCurrArea 0x672E08
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user