Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed Jan 9, 2019
2 parents 68022f4 + 11ae4f5 commit 924288a
Show file tree
Hide file tree
Showing 65 changed files with 2,725 additions and 2,517 deletions.
4 changes: 2 additions & 2 deletions artifacts/config_files/Perks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
; have an additional NoHardcode option in this file which can
; be used to remove their hardcoded effects, and add new stat/skill effects

;Name=The name of the perk
;Desc=The description of the perk
;Name=The name of the perk (max 63 characters)
;Desc=The description of the perk (max 1023 characters)
;Image=The line number (0-indexed) of the corresponding FRM in skilldex.lst
;Ranks=The number of perk levels
;Level=The minimum required level
Expand Down
28 changes: 24 additions & 4 deletions artifacts/config_files/elevators.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
;Controls the elevators
;Image must match up with the image of an existing elevator
;Image must match up with the image of an existing elevator (can be overrided in sfall 4.1.4/3.8.14 or newer)
;Make sure you specify the correct number of exit targets
;The maximum number of elevators is currently capped at 50
;Use the line number (0-indexed) of the corresponding FRM in intrface.lst to set the appearance of the elevator

;Override elevator 0
[000]
;This elevator uses the frm of the original forth elevator
[0]
;This elevator will use the settings of the original forth elevator
Image=4

;Set up the first exit point
Expand All @@ -23,4 +24,23 @@ ID3=50
Elevation3=0
Tile3=12944

;No forth exit point
;No forth exit point

;Override FRM images of elevator 0. Set ButtonsFrm to -1 to use default buttons from MainFrm
MainFrm=143
ButtonsFrm=-1


;An example of a new elevator
[24]
;Set Image to 24 to create a new elevator type (0-23 are the original elevator types)
Image=24

;Set the number of buttons
ButtonCount=3

;Set the appearance of the elevator
MainFrm=148
ButtonsFrm=151

;Set up the exit points for all three buttons (see examples above)
12 changes: 12 additions & 0 deletions artifacts/config_files/npcarmor.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
;WeaponAnims codes
; 1 - Knife (D)
; 2 - Club (E)
; 3 - Sledgehammer (F)
; 4 - Spear (G)
; 5 - Pistol (H)
; 6 - SMG (I)
; 7 - Rifle (J)
; 8 - Big Gun (K)
; 9 - Minigun (L)
; 10 - Rocket Launcher (M)
; 11-15 - sfall additional weapon animation codes

; This section maps 7 armor types to corresponding armor item PIDs
[ArmorTypes]
Expand Down
9 changes: 8 additions & 1 deletion artifacts/ddraw.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.1.3
;v4.1.4

[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
Expand Down Expand Up @@ -601,6 +601,10 @@ EnableMusicInDialogue=0
;Set to 1 to prevent the player from running while sneaking without Silent Running perk
DontTurnOffSneakIfYouRun=0

;Changes the distance at which the player will switch to walking when trying to use objects (valid range: 0..3)
;Set to 0 to disable switching. (Default is 3)
UseWalkDistance=3

;Set to 1 to fix the bug that unable to sell used geiger counters or stealth boys
CanSellUsedGeiger=1

Expand Down Expand Up @@ -703,6 +707,9 @@ DontDeleteProtos=0
;Set to 1 to give scripts direct access to Fallout's address space, and to make arbitrary calls into Fallout's code
AllowUnsafeScripting=0

;Set to 1 to force sfall to search for global scripts every time the game loads rather than only once on the first game start
AlwaysFindScripts=0

;Set to 1 to force sfall to inject all hooks code into the game, even if corresponding hook scripts don't exist
InjectAllGameHooks=0

Expand Down
Binary file modified artifacts/mods/gl_npcarmor.int
Binary file not shown.
41 changes: 35 additions & 6 deletions artifacts/mods/gl_npcarmor.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ variable
modIni := "npcarmor.ini",
defaultFids,
armorPidMap, // maps armor PID to it's "type" - leather armor, metal, power armor, etc.
npcMap;
npcMap,
altWeapon,
unWieldWeapon;

procedure check_armor_change(variable critter, variable item, variable isWorn) begin
variable npc, armorType, fid;
Expand All @@ -49,16 +51,38 @@ procedure check_weapon_change(variable critter, variable item, variable isWield)
if isWield then begin
newWeaponAnim := get_proto_data(obj_pid(item), PROTO_WP_ANIM);
weaponAnimList := string_split(npc["WeaponAnims"], ",");
if newWeaponAnim then begin
if newWeaponAnim then begin // anim code 0 - none/unarmed
foreach (i in weaponAnimList) begin
if (newWeaponAnim == atoi(i)) then return -1;
end
end else begin // anim code 0 - none/unarmed
return -1;
return 0;
end
end else begin
unWieldWeapon := obj_pid(item);
end
end
return 0;
return -1;
end

procedure search_alt_weapon(variable critter) begin
variable obj, res, i := 0;
obj := inven_ptr(critter, 0);
while (obj) do begin
if (obj_item_subtype(obj) == item_type_weapon) then begin
if (unWieldWeapon == 0 or unWieldWeapon != obj_pid(obj)) then begin
res := check_weapon_change(critter, obj, 1);
if (res == -1) then begin
altWeapon := obj;
wield_obj_critter(critter, obj);
altWeapon := 0;
break;
end
end
end
i++;
obj := inven_ptr(critter, i);
end
unWieldWeapon := 0;
end

// for NPCs when they change armor/weapon themselves
Expand All @@ -74,11 +98,16 @@ procedure invenwield_handler begin
if (fid != -1) then begin
art_change_fid_num(critter, fid);
end
return;
end

if (critter and item and (slot == INVEN_TYPE_RIGHT_HAND or slot == INVEN_TYPE_LEFT_HAND)) then begin
if (critter and item and slot == INVEN_TYPE_RIGHT_HAND) then begin
if (altWeapon == item) then return;
canWield := check_weapon_change(critter, item, isWorn);
set_sfall_return(canWield);
if (canWield != -1) then begin
call search_alt_weapon(critter);
end
end
end

Expand Down
55 changes: 29 additions & 26 deletions artifacts/scripting/arrays.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ Array elements are accessed by index or key. For example:

// this code puts some string in array "list" at index 5:
list[5] := "Value";


There are 2 different types of arrays currently available:
1) Lists - a set of values with specific size (number of elements), where all elements have numeric indexes starting from zero (0) up to array length minus one.
For example:

// this creates list with 3 elements. Element "A" has index 0, element "B" has index 1, element "C" - 2
list := ["A", "B", "C"];

Limitations:
- all indexes are numeric, starting from 0;
- to assign value to a specific index, you must first resize array to contain this index
(for example, if list is of size 3 (indexes from 0 to 2), you can't assign value to index 4 unless you change list size to 5 first).


2) Maps (or associative arrays) - a set of key=>value pairs, where all elements (values) are accessed by corresponding keys.
Differences from list:
- maps don't have specific size (to assign values, you don't need to resize array first);
Expand All @@ -37,24 +37,24 @@ Both array types have their pros and cons and are suited for different tasks.
Basically arrays are implemented using number of new operators (scripting functions). But for ease of use, there are some new syntax elements:

1) Accessing elements. Use square brackets:

display_msg(arr[5]);
mymap["price"] := 515.23;

2) Alternative accessing for maps. Use dot:

display_msg(mymap.name);
mymap.price := 232.23;

3) Array expressions. Create and fill arrays with just one expression:

// create list with 5 values
[5, 777, 0, 3.14, "Cool Value"]

// create map:
{5: "Five", "health": 50, "speed": 0.252}
NOTES:

NOTES:
- make sure to call "fix_array" if you want new array to be available in the next frame or "save_array" if you want to use it for a longer period
(see next section for details)

Expand All @@ -64,16 +64,16 @@ NOTES:
foreach (item in myarray) begin
// this block is executed for each array element, where "item" contains current value on each step
end

// alternative syntax:
foreach (key: item in myarray) begin
// "key" will contain current key (or numeric index, for lists)
end

See "Script editor\docs\sslc readme.txt" file for full information on new SSL syntax features.

>>> STORING ARRAYS <<<

Apart from lists/maps arrays are divided by how they are stored.
There a 3 types of arrays:

Expand All @@ -85,21 +85,21 @@ where you create temp_array, it will not be available next time your global scri
This type of arrays are always available (by their ID) until you start a new game or load a saved game (at which point they are deleted).

3) Saved. If you want your array to really stay for a while, use function "save_array" to make any array "saved". However, they are, like permanent arrays,
"deleted" from memory when loading game. In order to use them properly, you must load them from the savegame using "load_array" whenever you want to use them.
"deleted" from memory when loading game. In order to use them properly, you must load them from the savegame using "load_array" whenever you want to use them.
Example:

variable savedArray;
procedure start begin
if game_loaded then begin
savedArray := load_array("traps");
end else begin
foreach trap in traps begin
....
....
end
end
end



>>> PRACTICAL EXAMPLES <<<

Expand All @@ -114,8 +114,8 @@ Example:

// call it:
call give_item(dude_obj, {PID_SHOTGUN: 1, PID_SHOTGUN_SHELLS: 4, PID_STIMPAK: 3});


> Create arrays of objects (maps) for advanced scripting:

variable traps;
Expand All @@ -130,14 +130,14 @@ Example:
traps[k] := load_array("trap_"+k); // each object is stored separately
end
end

procedure add_trap(variable trapArray) begin
variable index;
index := len_array(traps);
save_array("trap_"+k, trapArray);
array_push(traps, trapArray);
end

// use them:
foreach trap in traps begin
if (self_elevation == trap["elev"] and tile_distance(self_tile, trap["tile"]) < trap["radius"]) then
Expand All @@ -151,14 +151,16 @@ Example:

*mixed means any type

> int create_array(int size, int nothing):
> int create_array(int size, int flags):
- creates permanent array (but not "saved")
- if size is >= 0, creates list with given size
- if size == -1, creates map (associative array)
- second argument is not used yet, just use 0
- if size == -1 and flags == 2, creates a "lookup" map in which the values of existing keys are read-only and can't be updated.
This type of array allows you to store a zero (0) key value
- NOTE: in earlier versions (up to 4.1.3/3.8.13) the second argument is not used, just use 0
- returns arrayID (valid until array is deleted)

> int temp_array(int size, int nothing):
> int temp_array(int size, int flags):
- works exactly like "create_array", only created array becomes "temporary"

> void fix_array(int arrayID):
Expand All @@ -169,6 +171,7 @@ Example:
- if used on list, "key" must be numeric and within valid index range (0..size-1)
- if used on map, key can be of any type
- to "unset" a value from map, just set it to zero (0)
- NOTE: to add a value of 0 for the key, use the float value of 0.0
- this works exactly like statement:
arrayID[key] := value;

Expand All @@ -182,7 +185,7 @@ Example:
- changes array size
- applicable to maps too, but only to reduce elements
- there are number of special negative values of "size" which perform various operations on the array,
use macros sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h header
use macros sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h header

> void free_array(int arrayID):
- deletes any array
Expand Down
11 changes: 11 additions & 0 deletions artifacts/scripting/headers/lib.arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
/*
Generic array functions
*/
// returns True if the specified key exists in the associative array
procedure map_contains_key(variable arrayMap, variable key);

// push new item at the end of array, returns array
procedure array_push(variable array, variable item);

Expand Down Expand Up @@ -151,6 +154,14 @@ procedure load_collection(variable name);

#define ARRAY_SET_BLOCK_SIZE (10)

procedure map_contains_key(variable arrayMap, variable key) begin
variable i;
for (i := 0; i < len_array(arrayMap); i++) begin
if (array_key(arrayMap, i) == key) then return true;
end
return false;
end

/**
* Returns first index of zero value
*/
Expand Down
Loading

0 comments on commit 924288a

Please sign in to comment.