Some spawn scripts
Spawn ammo bag:
Spawn doctor bag:
Spawn trip mine:
Spawn sentry gun:
Spawn ECM jammer:
Spawn two cops whenever you kill one:
Spawn bulldozer whenever you kill a cop:
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
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
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
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
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
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
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
