Banner
Sandbox Helper
Thumbnail
Downloads300
Views5,586
Publish Date4 years ago
Last Updated4 years ago
Version3
Members
Avatar

I don't suppose you could link to an example mod that might use this framework? To see how it is implemented, that is.

Avatar

You put hooks from the mod into your mod and copy the file into your mod then rename

local mod_to_check = "intimidate specials"

and use sandboxer:allow_mod() for checks in your functions. Your init functions are loaded before youre in the heist, so for a more dynamic toggle, you would have to make it yourself, not sure if what i have bellow would turn intimidation on/off dynamicly in game

elseif RequiredScript == "lib/units/enemies/cop/copbrain" then
	intimsp_o_copbrain_post_init = intimsp_o_copbrain_post_init or CopBrain.post_init
	function CopBrain:post_init()
		intimsp_o_copbrain_post_init(self)
		if not self._logics.intimidated then self._logics.intimidated = CopLogicIntimidated end
		if not self._logics.flee then self._logics.flee = CopLogicFlee end
	end
	intimsp_o_convert_to_criminal = intimsp_o_convert_to_criminal or CopBrain.convert_to_criminal
	function CopBrain:convert_to_criminal(mastermind_criminal)
		intimsp_o_convert_to_criminal(self, mastermind_criminal)
		if sandboxer:allow_mod(true) then
			managers.mission._fading_debug_output:script().log(string.format("%s", ".."), Color.green)
			local category = self._unit:base()._tweak_table
			local groupai = managers.groupai:state()
			if groupai._special_units[category] then groupai._special_units[category][self._unit:key()] = nil end
		end
	end
elseif RequiredScript == "lib/managers/playermanager" then
	intimsp_o_has_upgrade = intimsp_o_has_upgrade or PlayerManager.has_category_upgrade
	function PlayerManager:has_category_upgrade(category, upgrade)
		return sandboxer:allow_mod() and upgrade == "intimidate_specials" or intimsp_o_has_upgrade(self, category, upgrade)
	end
end

This is what i tried to post as a mod before, it's dynamic

local surrender = CopLogicIdle._surrender
		local on_intimidated = CopLogicIdle.on_intimidated
		local function run_function(data, amount, aggressor_unit, ...)
			if sandboxer:allow_mod(true) and (data.unit:base()._tweak_table == "phalanx_vip") or (data.unit:base()._tweak_table == "phalanx_minion") then
				return on_intimidated(data, amount, aggressor_unit, ...)
			end
			return surrender(data, amount, aggressor_unit)
		end
		CopLogicIdle.on_intimidated = run_function
		CopLogicArrest.on_intimidated = run_function
		CopLogicSniper.on_intimidated = run_function

		--Shield logic
		CopBrain._logic_variants.shield.intimidated = CopLogicIntimidated
		local _do_tied = CopLogicIntimidated._do_tied
		local _chk_spawn_shield = CopInventory._chk_spawn_shield
		local on_intimidated = CopLogicIntimidated.on_intimidated
		function CopLogicIntimidated.on_intimidated(data, amount, aggressor_unit, ...) 
			if sandboxer:allow_mod(true) and data.unit:base()._tweak_table == "shield" then
				_do_tied(data, aggressor_unit)
				_chk_spawn_shield(data.unit:inventory())
			else
				on_intimidated(data, amount, aggressor_unit, ...)
			end
		end
Avatar

@✌Playhouse✌ So, this will essentially disable the mod when playing online with users who don't have it? And those who do, or if singleplayer, it will remain enabled.

Avatar

@△urelius Yeah

Avatar

@✌Playhouse✌ That is really cool, thanks.

38 857