Some spawn scripts

Posts 18 of 8 · Page 1 of 1
Some spawn scripts
Spawn ammo bag:
Code:
pos = managers.player:player_unit():position()
rot = managers.player:player_unit():rotation()
		local ammo_upgrade_lvl = managers.player:upgrade_level( "ammo_bag", "ammo_increase" )
		if Network:is_client() then
			managers.network:session():send_to_host( "place_ammo_bag", pos, rot, ammo_upgrade_lvl )
		else 
			local unit = AmmoBagBase.spawn( pos, rot, ammo_upgrade_lvl )
		end
Spawn doctor bag:
Code:
pos = managers.player:player_unit():position()
rot = managers.player:player_unit():rotation()
local amount_upgrade_lvl = managers.player:upgrade_level( "doctor_bag", "amount_increase" )
		if Network:is_client() then
			managers.network:session():send_to_host( "place_doctor_bag", pos, rot, amount_upgrade_lvl )
		else 
			local unit = DoctorBagBase.spawn( pos, rot, amount_upgrade_lvl )
		end
Spawn trip mine:
Code:
local from = managers.player:player_unit():movement():m_head_pos()
  local to = from + managers.player:player_unit():movement():m_head_rot():y() * 200
  local ray = managers.player:player_unit():raycast("ray", from, to, "slot_mask", managers.slot:get_mask("trip_mine_placeables"), "ignore_unit", {})
unit = managers.player:player_unit()
	
	managers.challenges:count_up( "plant_tripmine" )
		managers.statistics:use_trip_mine()
		local sensor_upgrade = managers.player:has_category_upgrade( "trip_mine", "sensor_toggle" )
		if Network:is_client() then
			managers.network:session():send_to_host( "attach_device", ray.position, ray.normal, sensor_upgrade )
		else 
		local rot = Rotation(ray.normal, math.UP)
			local unit = TripMineBase.spawn( ray.position, rot, sensor_upgrade )
			unit:base():set_active( true, unit )
			-- unit:base():set_sensor_upgrade( managers.player:has_category_upgrade( "trip_mine", "sensor_toggle" ) )
		end
Spawn sentry gun:
Code:
		local ammo_multiplier = managers.player:upgrade_value( "sentry_gun", "extra_ammo_multiplier", 1 )
		local armor_multiplier = managers.player:upgrade_value( "sentry_gun", "armor_multiplier", 1 )
		local damage_multiplier = managers.player:upgrade_value( "sentry_gun", "damage_multiplier", 1 )
		unit = managers.player:player_unit()
		pos = managers.player:player_unit():position()
		rot = managers.player:player_unit():rotation()
		if Network:is_client() then
			managers.network:session():send_to_host( "place_sentry_gun", pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier, selected_index, unit )
		else
			local shield = managers.player:has_category_upgrade( "sentry_gun", "shield" )
			local sentry_gun_unit = SentryGunBase.spawn( unit, pos, rot, ammo_multiplier, armor_multiplier, damage_multiplier )
			if sentry_gun_unit then
				managers.network:session():send_to_peers_synched( "from_server_sentry_gun_place_result", managers.network:session():local_peer():id(), selected_index, sentry_gun_unit, sentry_gun_unit:movement()._rot_speed_mul, sentry_gun_unit:weapon()._setup.spread_mul, shield )
			else
				
			end
		end
Spawn ECM jammer:
Code:
unit = managers.player:player_unit()
local from = managers.player:player_unit():movement():m_head_pos()
  local to = from + managers.player:player_unit():movement():m_head_rot():y() * 200
  local ray = managers.player:player_unit():raycast("ray", from, to, "slot_mask", managers.slot:get_mask("trip_mine_placeables"), "ignore_unit", {})

		-- managers.challenges:count_up( "deploy_ecmjammer" )
		managers.statistics:use_ecm_jammer()
		
		local duration_multiplier = managers.player:upgrade_value( "ecm_jammer", "duration_multiplier", 1 ) * managers.player:upgrade_value( "ecm_jammer", "duration_multiplier_2", 1 )
		if Network:is_client() then
			managers.network:session():send_to_host( "request_place_ecm_jammer", ray.position, ray.normal, duration_multiplier )
		else 
		local rot = Rotation(ray.normal, math.UP)
			local unit = ECMJammerBase.spawn( ray.position, rot, duration_multiplier, unit )
			unit:base():set_active( true )
		end
Spawn two cops whenever you kill one:
Code:
function spawn_cop_1(position, rotation)

	local unit_name = Idstring( "units/payday2/characters/ene_cop_1/ene_cop_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
	unit:base().cop_1 = true
end

function spawn_cop_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_2/ene_cop_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().cop_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_cop_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_3/ene_cop_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().cop_3 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_cop_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_4/ene_cop_4" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().cop_4 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_bulldozer(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().bulldozer = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_fbi_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_1/ene_fbi_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().fbi_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_fbi_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_2/ene_fbi_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().fbi_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_fbi_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_3/ene_fbi_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().fbi_3 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_fbi_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().fbi_4 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_swat_f_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().swat_f_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_swat_f_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().swat_f_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_shield_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_1/ene_shield_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().shield_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_shield_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_2/ene_shield_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().shield_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_sniper_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_1/ene_sniper_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().sniper_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_sniper_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_2/ene_sniper_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().sniper_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_spook_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_spook_1/ene_spook_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().spook_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_swat_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_1/ene_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().swat_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_swat_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_2/ene_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().swat_2 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_swat_heavy_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().swat_heavy_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end

function spawn_tazer_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_tazer_1/ene_tazer_1" )
	local spawn_ai = { init_state = "idle" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().tazer_1 = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end


if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( variant )

	return _deadCop(self, variant)
end

			

if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( ... )


if not self._unit:base().cop_1 and self._unit:name() == Idstring("units/payday2/characters/ene_cop_1/ene_cop_1") then
spawn_cop_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().cop_2 and self._unit:name() == Idstring("units/payday2/characters/ene_cop_2/ene_cop_2") then
spawn_cop_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().cop_3 and self._unit:name() == Idstring("units/payday2/characters/ene_cop_3/ene_cop_3") then
spawn_cop_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().cop_4 and self._unit:name() == Idstring("units/payday2/characters/ene_cop_4/ene_cop_4") then
spawn_cop_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().bulldozer and self._unit:name() == Idstring("units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1") then
spawn_bulldozer(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_bulldozer(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().fbi_1 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_1/ene_fbi_1") then
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().fbi_2 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_2/ene_fbi_2") then
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().fbi_3 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_3/ene_fbi_3") then
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().fbi_4 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1") then
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().swat_f_1 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1") then
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().swat_f_2 and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2") then
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().shield_1 and self._unit:name() == Idstring("units/payday2/characters/ene_shield_1/ene_shield_1") then
spawn_shield_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().shield_2 and self._unit:name() == Idstring("units/payday2/characters/ene_shield_2/ene_shield_2") then
spawn_shield_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().sniper_1 and self._unit:name() == Idstring("units/payday2/characters/ene_sniper_1/ene_sniper_1") then
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().sniper_2 and self._unit:name() == Idstring("units/payday2/characters/ene_sniper_2/ene_sniper_2") then
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().spook_1 and self._unit:name() == Idstring("units/payday2/characters/ene_spook_1/ene_spook_1") then
spawn_spook_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_spook_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().swat_1 and self._unit:name() == Idstring("units/payday2/characters/ene_swat_1/ene_swat_1") then
spawn_swat_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().swat_2 and self._unit:name() == Idstring("units/payday2/characters/ene_swat_2/ene_swat_2") then
spawn_swat_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().swat_heavy_1 and self._unit:name() == Idstring("units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1") then
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().tazer_1 and self._unit:name() == Idstring("units/payday2/characters/ene_tazer_1/ene_tazer_1") then
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end



	local result = _deadCop( self, ... )

	return result
	
end
Spawn bulldozer whenever you kill a cop:
Code:
function spawn_bulldozer(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().bulldozer = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
end


if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( variant )

	return _deadCop(self, variant)
end

			

if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( ... )

if not self._unit:base().bulldozer then
spawn_bulldozer(self._unit:position(), self._unit:rotation())
end


	local result = _deadCop( self, ... )

	return result
	
end
Thanks for the scripts.
Any chance to get the spawn 2 cops or the spawn bulldozer to work if your NOT hosting?
Thanks.
Quote Originally Posted by sandman332 View Post
Any chance to get the spawn 2 cops or the spawn bulldozer to work if your NOT hosting?
Thanks.
No, i think.
did you write these or did you just find them? I like them.
Quote Originally Posted by Revenge2K View Post
did you write these or did you just find them? I like them.
I wrote this.
Alright I put my own spin on your script and released it. Let me add you to the credits.



Revenge2K's Jackpot Scripts!

Scripts can be turned on or off

Simple Loot Drop, all cops drop loot on death (meth)
Code:
--Cop Killer loot drop by Revenge2K, original loot bag code by dougbenham

if r2khackenabled == nil or r2khackenabled == false then
		r2khackenabled = true
	else
		r2khackenabled = false
end


function spawn_loot(type, _position, z_offset)
	local position = mvector3.copy(_position)
	if z_offset then mvector3.set_z(position, position.z + z_offset) end
	if Network:is_client() then
		managers.network:session():send_to_host( "server_drop_carry", type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	else 
		managers.player:server_drop_carry( type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	end
end

if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( variant )
	if r2khackenabled == false then
		local result = _deadCop( self, ... )
		return result
	end

		spawn_loot("meth", self._unit:position(), 120)

	return _deadCop(self, variant)
end

The Midas Touch, spawns 2 cops once that drop gold bags
Code:
--The Midas Touch script by Revenge2K, makes cops drop that gold. Gold loot bag drop code originally by dougbenham, original spawn code by Simplity

if r2khackenabled == nil or r2khackenabled == false then
		r2khackenabled = true
	else
		r2khackenabled = false
end


function spawn_cop_1(position, rotation)

	local unit_name = Idstring( "units/payday2/characters/ene_cop_1/ene_cop_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
	unit:base().made_of_gold = true

end

function spawn_cop_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_2/ene_cop_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_cop_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_3/ene_cop_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_cop_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_4/ene_cop_4" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_bulldozer(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_1/ene_fbi_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_2/ene_fbi_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_3/ene_fbi_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_f_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_f_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_shield_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_1/ene_shield_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_shield_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_2/ene_shield_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_sniper_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_1/ene_sniper_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_sniper_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_2/ene_sniper_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_spook_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_spook_1/ene_spook_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_1/ene_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_2/ene_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_heavy_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_tazer_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_tazer_1/ene_tazer_1" )
	local spawn_ai = { init_state = "idle" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_loot(type, _position, z_offset)
	local position = mvector3.copy(_position)
	if z_offset then mvector3.set_z(position, position.z + z_offset) end
	if Network:is_client() then
		managers.network:session():send_to_host( "server_drop_carry", type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	else 
		managers.player:server_drop_carry( type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	end
end
			

			
if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( ... )
	if r2khackenabled == false then
		local result = _deadCop( self, ... )
		return result
	end

	if self._unit:base().made_of_gold then
		spawn_loot("gold", self._unit:position(), 120)
	end

if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_cop_1/ene_cop_1") then
spawn_cop_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_cop_2/ene_cop_2") then
spawn_cop_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_cop_3/ene_cop_3") then
spawn_cop_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_cop_4/ene_cop_4") then
spawn_cop_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
--commented out to exclude bulldozers
--if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1") then
--spawn_bulldozer(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
--spawn_bulldozer(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
--end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_1/ene_fbi_1") then
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_2/ene_fbi_2") then
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_3/ene_fbi_3") then
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1") then
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1") then
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2") then
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_shield_1/ene_shield_1") then
spawn_shield_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_shield_2/ene_shield_2") then
spawn_shield_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_sniper_1/ene_sniper_1") then
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_sniper_2/ene_sniper_2") then
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_spook_1/ene_spook_1") then
spawn_spook_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_spook_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_swat_1/ene_swat_1") then
spawn_swat_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_swat_2/ene_swat_2") then
spawn_swat_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1") then
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if not self._unit:base().made_of_gold and self._unit:name() == Idstring("units/payday2/characters/ene_tazer_1/ene_tazer_1") then
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end



	local result = _deadCop( self, ... )

	return result
	
end

The Golden Plague, infinitely spawns cops who drops gold upon death. This is the most fun.

Code:
--The Golden Plague script by Revenge2K, makes cops drop that gold. Gold loot bag drop code originally by dougbenham, original spawn code by Simplity

if r2khackenabled == nil or r2khackenabled == false then
		r2khackenabled = true
	else
		r2khackenabled = false
end


function spawn_cop_1(position, rotation)

	local unit_name = Idstring( "units/payday2/characters/ene_cop_1/ene_cop_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )
	unit:base().made_of_gold = true

end

function spawn_cop_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_2/ene_cop_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_cop_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_3/ene_cop_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_cop_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_cop_4/ene_cop_4" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_bulldozer(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_1/ene_fbi_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_2/ene_fbi_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_3(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_3/ene_fbi_3" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_fbi_4(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_f_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_f_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_shield_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_1/ene_shield_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_shield_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_shield_2/ene_shield_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_sniper_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_1/ene_sniper_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_sniper_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_sniper_2/ene_sniper_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_spook_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_spook_1/ene_spook_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_1/ene_swat_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_2(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_2/ene_swat_2" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_swat_heavy_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1" )
	local spawn_ai = { init_state = "attack" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_tazer_1(position, rotation)
	local unit_name = Idstring( "units/payday2/characters/ene_tazer_1/ene_tazer_1" )
	local spawn_ai = { init_state = "idle" }
	local unit = World:spawn_unit( unit_name, position, rotation )
	unit:base().made_of_gold = true
	unit:movement():set_character_anim_variables()
	unit:brain():set_spawn_ai( spawn_ai )
	unit:brain():set_active( true )

end

function spawn_loot(type, _position, z_offset)
	local position = mvector3.copy(_position)
	if z_offset then mvector3.set_z(position, position.z + z_offset) end
	if Network:is_client() then
		managers.network:session():send_to_host( "server_drop_carry", type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	else 
		managers.player:server_drop_carry( type, managers.money:get_bag_value( type ), nil, nil, 0, position, Rotation( math.UP, math.random() * 360 ), Vector3( 0,0,0 ), 0 )
	end
end
			

			
if not _deadCop then _deadCop = CopDamage.die end
function CopDamage:die( ... )
	if r2khackenabled == false then
		local result = _deadCop( self, ... )
		return result
	end

	if self._unit:base().made_of_gold then
		spawn_loot("gold", self._unit:position(), 120)
	end

if self._unit:name() == Idstring("units/payday2/characters/ene_cop_1/ene_cop_1") then
spawn_cop_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_cop_2/ene_cop_2") then
spawn_cop_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_cop_3/ene_cop_3") then
spawn_cop_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_cop_4/ene_cop_4") then
spawn_cop_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_cop_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
--commented out to exclude bulldozers
--if self._unit:name() == Idstring("units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1") then
--spawn_bulldozer(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
--spawn_bulldozer(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
--end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_1/ene_fbi_1") then
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_2/ene_fbi_2") then
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_3/ene_fbi_3") then
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_3(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1") then
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_fbi_4(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1") then
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2") then
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_f_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_shield_1/ene_shield_1") then
spawn_shield_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_shield_2/ene_shield_2") then
spawn_shield_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_shield_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_sniper_1/ene_sniper_1") then
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_sniper_2/ene_sniper_2") then
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_sniper_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_spook_1/ene_spook_1") then
spawn_spook_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_spook_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_swat_1/ene_swat_1") then
spawn_swat_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_swat_2/ene_swat_2") then
spawn_swat_2(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_2(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1") then
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_swat_heavy_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end
if self._unit:name() == Idstring("units/payday2/characters/ene_tazer_1/ene_tazer_1") then
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(9,10) * 5), self._unit:position().y + (math.random(9,10) * 5), self._unit:position().z), self._unit:rotation())
spawn_tazer_1(Vector3(self._unit:position().x + (math.random(3,5) * 3), self._unit:position().y + (math.random(3,5) * 3), self._unit:position().z), self._unit:rotation())
end



	local result = _deadCop( self, ... )

	return result
	
end
Spawn friendly unit:
Code:
if not _upgradeValueIntimidate then _upgradeValueIntimidate = PlayerManager.upgrade_value end 
function PlayerManager:upgrade_value( category, upgrade, default ) 
	if category == "player" and upgrade == "convert_enemies" then
		return true
	elseif category == "player" and upgrade == "convert_enemies_max_minions" then
		return 500
	elseif category == "player" and upgrade == "convert_enemies_health_multiplier" then   
		return 0.25
	elseif category == "player" and upgrade == "convert_enemies_damage_multiplier" then
		return 4.5
	else 
		return _upgradeValueIntimidate(self, category, upgrade, default) 
	end 
end

function FollowUnit()

local new_objective

 local valid_criminals = {}
 for pl_key, pl_record in pairs( managers.groupai:state():all_player_criminals() ) do
 if pl_record.status ~= "dead" then
 table.insert( valid_criminals, pl_key )
 end
 end

if #valid_criminals > 0 then
local follow_unit = managers.groupai:state():all_player_criminals()[ valid_criminals[ math.random( #valid_criminals ) ] ].unit -- pick a random player
 new_objective = { type = "follow", follow_unit = follow_unit, scan = true, is_default = true}
 end
 return new_objective
 end

function SpawnMob()
 local spawn_pos = managers.player:player_unit():position()
 local spawn_rot = managers.player:player_unit():rotation()
 local unit_name = Idstring( "units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1")  --unit name
 local myobjective = FollowUnit()
 local spawn_ai = { init_state = "attack", objective = myobjective}
 local unit = World:spawn_unit( unit_name, spawn_pos, spawn_rot )
	 unit:movement():set_character_anim_variables()
	 unit:remove_interact()
	 unit:set_active(true)
	 managers.groupai:state():convert_hostage_to_criminal( unit )
 end
 if Network:is_server() then
 SpawnMob()
 end
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?