--[[
project files:
xr_kamp
xrs_ai
xrs_armor
xrs_grenade
xrs_medic
xrs_utils
]]

--[[
file: modules.script
after: <<<END
load_scheme("xr_patrol",      "patrol",      stype_stalker)  
END;
code: <<<END
if xrs_ai then xrs_ai.load_schemes() end 
END;
]]
function load_schemes()
	if xrs_grenade then load_scheme("xrs_grenade",      "grenadier",    stype_stalker) end 
	if xrs_medic  then load_scheme("xrs_medic",      	"medic",		stype_stalker) end 
	if xrs_armor  then load_scheme("xrs_armor",      	"pick_armor",	stype_stalker) end 
end

--[[
file: xr_logic.script
function: disable_generic_schemes(npc, stype)
after: <<<END
		xr_combat.disable_scheme(npc, "combat")
END;
code: <<<END
		if xrs_ai then xrs_ai.disable_schemes(npc, stype) end
END;
]]
function disable_schemes(npc, stype)
	if xrs_grenade then xrs_grenade.disable_scheme(npc, "grenadier") end
	if xrs_medic  then  xrs_medic.disable_scheme(npc, "medic") end
	if xrs_armor  then  xrs_armor.disable_scheme(npc, "pick_armor") end
end

--[[
file: xr_logic.script
function: enable_generic_schemes(ini, npc, stype, section)
before: <<<END
	elseif stype == modules.stype_mobile then
END;
code: <<<END
		if xrs_ai then xrs_ai.enable_schemes(ini, npc, stype, section) end

END;
]]
function enable_schemes(ini, npc, stype, section)
	if xrs_grenade then xrs_grenade.set_scheme(npc, ini, "grenadier", "grenadier") end
	if xrs_medic  then xrs_medic.set_scheme(npc, ini, "medic", "medic") end
	if xrs_armor  then xrs_armor.set_scheme(npc, ini, "pick_armor", "pick_armor") end
end

--[[
file: bind_stalker.script
function: actor_binder:net_spawn(data)
after: <<<END
	death_manager.init_drop_settings()
END;
code: <<<END

	if xrs_ai then xrs_ai.actor_net_spawn(self) end
END;
]]
function actor_net_spawn(binder)
	if xrs_grenade then xrs_grenade.net_spawn() end
end

--[[
file: bind_stalker.script
function: actor_binder:on_item_take (obj)
after: <<<END
    level_tasks.proceed(self.object)
END;
code: <<<END
	if xrs_ai then xrs_ai.actor_item_take(obj) end
END;
]]
function actor_item_take(obj)
	if xrs_grenade then xrs_grenade.fake_pickup(obj) end
	if xrs_medic then xrs_medic.pickup(obj) end
end

--[[
file: bind_stalker.script
function: actor_binder:update(delta)
add to end
code: <<<END
	if xrs_ai then xrs_ai.actor_update(delta) end
END;
]]
function actor_update(delta)
	if xrs_grenade then xrs_grenade.update(delta) end
	if xrs_armor then xrs_armor.update(delta) end
end

--[[
file: xr_motivator.script
function: motivator_binder:net_destroy()
add to begin
code: <<<END
	if xrs_ai then xrs_ai.npc_net_destroy(self.object) end
END;
]]
function npc_net_destroy(npc)
	if xrs_medic then xrs_medic.death_callback(npc) end
end

--[[
file: xr_motivator.script
function: motivator_binder:death_callback(victim, who)
add to begin
code: <<<END
	if xrs_ai then xrs_ai.npc_death_callback(self.object) end
END;
]]
function npc_death_callback(npc)
	if xrs_grenade then xrs_grenade.death_callback(npc) end
	if xrs_medic then xrs_medic.death_callback(npc) end
end

--[[
file: xr_motivator.script
function: motivator_binder:update(delta)
add to end
code: <<<END
	if xrs_ai then xrs_ai.npc_update(self) end
END;
]]
function npc_update(binder)
	if xrs_grenade then xrs_grenade.npc_update(binder) end
	if xrs_medic then xrs_medic.npc_update(binder) end
	if xrs_armor then xrs_armor.npc_update(binder) end
end

--[[
file: xr_motivator.script
function: addCommonPrecondition(action)
add to end
code: <<<END
	if xrs_ai then xrs_ai.addCommonPrecondition(action) end
END;
]]
function addCommonPrecondition(action)
	if xrs_grenade then action:add_precondition (world_property(xrs_grenade.evid_crazy_grenadier, false)) end
	if xrs_grenade then action:add_precondition (world_property(xrs_grenade.evid_aaa_grenade, false)) end
	if xrs_medic then action:add_precondition (world_property(xrs_medic.evid_medic, false)) end
	if xrs_medic then action:add_precondition (world_property(xrs_medic.evid_self_medic, false)) end
	if xrs_armor then action:add_precondition (world_property(xrs_armor.evid_armor, false)) end
end
