From e92c994744de0fdb0fff13755c6df0cc4412ef51 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Fri, 2 Jun 2023 15:15:01 +0800 Subject: [PATCH] Added a new example mod gl_rest_encounter Added a burst control example script. --- .../BurstControl/gl_burstcontrol.ssl | 30 ++++++++ .../RestEncounter/gl_rest_encounter.int | Bin 0 -> 1352 bytes .../RestEncounter/gl_rest_encounter.ssl | 65 ++++++++++++++++++ .../example_mods/RestEncounter/readme.txt | 12 ++++ 4 files changed, 107 insertions(+) create mode 100644 artifacts/example_mods/BurstControl/gl_burstcontrol.ssl create mode 100644 artifacts/example_mods/RestEncounter/gl_rest_encounter.int create mode 100644 artifacts/example_mods/RestEncounter/gl_rest_encounter.ssl create mode 100644 artifacts/example_mods/RestEncounter/readme.txt diff --git a/artifacts/example_mods/BurstControl/gl_burstcontrol.ssl b/artifacts/example_mods/BurstControl/gl_burstcontrol.ssl new file mode 100644 index 00000000..e84217a3 --- /dev/null +++ b/artifacts/example_mods/BurstControl/gl_burstcontrol.ssl @@ -0,0 +1,30 @@ +/* + A basic example of how to use set_spray_settings function for script-based burst control +*/ + +#include "..\headers\define.h" +#include "..\headers\sfall\define_extra.h" +#include "..\headers\sfall\sfall.h" + +procedure start; +procedure ammocost_handler; + +procedure start begin + if game_loaded then begin + register_hook_proc(HOOK_AMMOCOST, ammocost_handler); + end +end + +procedure ammocost_handler begin + variable + weapon := get_sfall_arg, + bullets := get_sfall_arg, + cost := get_sfall_arg, + event := get_sfall_arg; + + if (event == 2 and weapon > 0) then begin // when calculating number of burst rounds + if (obj_pid(weapon) == PID_ASSAULT_RIFLE) then begin + set_spray_settings(1, 1, 1, 1); // burst attack will not hit other targets + end + end +end diff --git a/artifacts/example_mods/RestEncounter/gl_rest_encounter.int b/artifacts/example_mods/RestEncounter/gl_rest_encounter.int new file mode 100644 index 0000000000000000000000000000000000000000..1ae4965346c363ef9a95c3cb7b47767dfcf6a744 GIT binary patch literal 1352 zcmZo*I>5-lz#!DX3!)iI8dw?x8l)N&8l)N&8>AYP8l)PO8&n!p8`KyW7+4q>7}yw4 z0Am}JD*>gU6j&T&vK~|bN-^GoGR&Yflw#t6GF%u0^iTi;1A|CnQBh)Ld{JUvN`7v9 zSz=CUD##_pC5c5P3=Bf4dCB>uc_pbu@fnGEDLJV{4FCWC|Ifg{Fo}VQfq{WZkAZ>B zH?cqiq({?Ap&H~9D+Lg#119zK^cWbJY8e>Vd@_qmG#D7zG_4e(K{{g@7=-ln^b&J& z;=xWR1}kL{N>43`FG(#bO3ciQ&r8e&xkgP1i4OR_Xn!=j& z8+aQe8?+iU8+aOIz%mTTB48OAh?$IE8dDnd!D=9OFgGQEc{p`2FhJxXWaASE-Czi1 zF*bnR!fF5&hq#!r!MH&hB*K)@Akm=TAO&JGFv9&~3~>X~jR~MM5z|x#mKO$*%rBa< z8=&$qyPJ$bGH_magC&^H1hJdx0*J>{*>Ds@GcYumLriCoYTO1AVP$Aw0nyB1SZsSq zz&5WYm~D(8GZ?(#e5mcrejsrywo9Yh&SHYa_E!XKcY)gmvAq_~hvd^JSa6c LJ_V^~z>;?WbVnfx literal 0 HcmV?d00001 diff --git a/artifacts/example_mods/RestEncounter/gl_rest_encounter.ssl b/artifacts/example_mods/RestEncounter/gl_rest_encounter.ssl new file mode 100644 index 00000000..e2ea5c71 --- /dev/null +++ b/artifacts/example_mods/RestEncounter/gl_rest_encounter.ssl @@ -0,0 +1,65 @@ +/* + +Resting Encounters mod for Fallout 2 by Lexx +-------------------------------------------- + +- Check where we are on the world map and overwrite the default desert "resting" map +- Compatible with vanilla Fallout 2 and UP/RP + +Requires sfall 4.3.6/3.8.38 or higher + +*/ + +#include "..\headers\define.h" +#include "..\headers\sfall\sfall.h" +#include "..\headers\sfall\lib.arrays.h" + +procedure start; +procedure encounter_handler; + +#define is_terrain_desert (get_current_terrain_name == mstr_worldmap(1000)) +#define is_terrain_mountains (get_current_terrain_name == mstr_worldmap(1001)) +#define is_terrain_city (get_current_terrain_name == mstr_worldmap(1002)) +#define is_terrain_coast (get_current_terrain_name == mstr_worldmap(1003)) + +procedure start begin + if (game_loaded) then begin + register_hook_proc(HOOK_ENCOUNTER, encounter_handler); + end +end + +procedure encounter_handler begin + variable + event := get_sfall_arg, + mapID := get_sfall_arg, + mapsList; + + // If the player enters a map on the world map, we set it depending on the current terrain type + // event 0 is random encounter, 1 is player initiated "encounter" + if (event == 1 AndAlso mapID == MAP_RND_DESERT_1) then begin + if (is_terrain_desert) then begin + mapsList := [MAP_RND_DESERT_1]; + if (global_var(GVAR_CAR_PLACED_TILE) < 0) then set_car_current_town(AREA_RND_DESERT); + end + else if (is_terrain_mountains) then begin + mapsList := [MAP_RND_MOUNTAIN1, MAP_RND_MOUNTAIN2]; + if (global_var(GVAR_CAR_PLACED_TILE) < 0) then set_car_current_town(AREA_RND_MOUNTAIN); + end + else if (is_terrain_city) then begin + mapsList := [MAP_RND_CITY1, MAP_RND_CITY_2, MAP_RND_CITY_3, MAP_RND_CITY_4, MAP_RND_CITY_5, MAP_RND_CITY_6, MAP_RND_CITY_7, MAP_RND_CITY_8]; + if (global_var(GVAR_CAR_PLACED_TILE) < 0) then set_car_current_town(AREA_RND_CITY); + end + else if (is_terrain_coast) then begin + mapsList := [MAP_RND_COAST1, MAP_RND_COAST2]; + if (global_var(GVAR_CAR_PLACED_TILE) < 0) then set_car_current_town(AREA_RND_COAST); + end + else begin + mapsList := [MAP_RND_DESERT_1]; + if (global_var(GVAR_CAR_PLACED_TILE) < 0) then set_car_current_town(AREA_RND_DESERT); + debug_msg("!!! COULDN'T DETECT TERRAIN TYPE !!!"); + end + + mapID := array_random_value(mapsList); + set_sfall_return(mapID); + end +end diff --git a/artifacts/example_mods/RestEncounter/readme.txt b/artifacts/example_mods/RestEncounter/readme.txt new file mode 100644 index 00000000..2c13df7a --- /dev/null +++ b/artifacts/example_mods/RestEncounter/readme.txt @@ -0,0 +1,12 @@ +Resting Encounters mod for Fallout 2 by Lexx +-------------------------------------------- + +- Check where we are on the world map and overwrite the default desert "resting" map +- Compatible with vanilla Fallout 2 and UP/RP + + +Requires sfall 4.3.6/3.8.38 or higher. + +To use, copy gl_rest_encounter.int to your scripts folder. + +This mod is an example of how you can use HOOK_ENCOUNTER hooks.