Divergent/mods/Western Goods/gamedata/scripts/western_goods_unisg_fob.script

74 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
---==================================================================================================================---
--- ---
--- Original Author(s) : NLTP_ASHES ---
--- Edited : N/A ---
--- Date : 17/04/2023 ---
--- License : Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) ---
--- ---
--- Script used to manage the UNISG Forward Operating Base in the Meadows (y04_pole). ---
--- ---
---==================================================================================================================---
-- ---------------------------------------------------------------------------------------------------------------------
-- Constants, global variables and imported functions
-- ---------------------------------------------------------------------------------------------------------------------
local dbg_printf = western_goods_utils.dbg_printf
local fob_enabled = false
local fob_no_anomaly_restrictor = { ax=-32.640064239502,ay=-3.688939332962,az=214.10537719727,bx=119.68379211426,by=12.376997947693,bz=89.003326416016 }
-- ---------------------------------------------------------------------------------------------------------------------
-- Functions
-- ---------------------------------------------------------------------------------------------------------------------
local anom_binder_update_base = bind_anomaly_field.anomaly_field_binder.update
--- Monkey patch of bind_anomaly_field.script's update method of anomaly_field_binder class to prevent anomalies from spawning in UNISG FOB.
function bind_anomaly_field.anomaly_field_binder:update(delta)
if fob_enabled and level.name() == "y04_pole" and western_goods_restrictors.in_bounds(self.object,fob_no_anomaly_restrictor) then
dbg_printf("[WG] Disabled anomaly in UNISG FOB : %s", self.object:id())
self.object:disable_anomaly()
end
anom_binder_update_base(self, delta)
end
-- ---------------------------------------------------------------------------------------------------------------------
-- Callbacks registration
-- ---------------------------------------------------------------------------------------------------------------------
--- Function used to register callbacks.
--- @return nil
function on_game_start()
RegisterScriptCallback("save_state", save_state)
RegisterScriptCallback("load_state", load_state)
-- TODO : Test code - to be removed
-- RegisterScriptCallback("on_key_press",test_func)
end
-- ---------------------------------------------------------------------------------------------------------------------
-- Data persistence
-- ---------------------------------------------------------------------------------------------------------------------
--- Function used to store information in the save file.
--- @param m_data table
--- @return nil
function save_state(m_data)
m_data.fob_enabled = fob_enabled
end
--- Function used to load information stored in the save file.
--- @param m_data table
--- @return nil
function load_state(m_data)
fob_enabled = m_data.fob_enabled
end
-- ---------------------------------------------------------------------------------------------------------------------
-- Test functions TODO : Remove this section
-- ---------------------------------------------------------------------------------------------------------------------
function test_func(dik)
if dik ~= DIK_keys.DIK_P then return end
end