AI Spawning.

Posts 1–15 of 24 · Page 1 of 2
AI Spawning.
Found this script that Spawns AI, All credit goes to creator.
I am aware that this is on UC as said above All credit goes to creator.

Code:
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_point = managers.network:game():get_next_spawn_point()

local spawn_pos = spawn_point.pos_rot[1]
local spawn_rot = spawn_point.pos_rot[2]

local unit_name = Idstring( "units/payday2/characters/ene_spook_1/ene_spook_1" )
local myobjective = FollowUnit()

local spawn_ai = { 
init_state = "idle",
objective = myobjective
}

local unit = World:spawn_unit( unit_name, spawn_pos, spawn_rot )

unit:movement():set_character_anim_variables()


end
If you want to spawn a different Ai, replace 'Spook' with AI Name.

AI List:
"units/payday2/characters/ene_biker_1/ene_biker_1",
"units/payday2/characters/ene_biker_2/ene_biker_2",
"units/payday2/characters/ene_biker_3/ene_biker_3",
"units/payday2/characters/ene_biker_4/ene_biker_4",
"units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1",
"units/payday2/characters/ene_cop_1/ene_cop_1",
"units/payday2/characters/ene_cop_2/ene_cop_2",
"units/payday2/characters/ene_cop_3/ene_cop_3",
"units/payday2/characters/ene_cop_4/ene_cop_4",
"units/payday2/characters/ene_fbi_1/ene_fbi_1",
"units/payday2/characters/ene_fbi_2/ene_fbi_2",
"units/payday2/characters/ene_fbi_3/ene_fbi_3",
"units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1",
"units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1",
"units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2",
"units/payday2/characters/ene_gang_black_1/ene_gang_black_1",
"units/payday2/characters/ene_gang_black_2/ene_gang_black_2",
"units/payday2/characters/ene_gang_black_3/ene_gang_black_3",
"units/payday2/characters/ene_gang_black_4/ene_gang_black_4",
"units/payday2/characters/ene_gang_mexican_1/ene_gang_mexican_1",
"units/payday2/characters/ene_gang_mexican_2/ene_gang_mexican_2",
"units/payday2/characters/ene_gang_mexican_3/ene_gang_mexican_3",
"units/payday2/characters/ene_gang_mexican_4/ene_gang_mexican_4",
"units/payday2/characters/ene_gang_russian_1/ene_gang_russian_1",
"units/payday2/characters/ene_gang_russian_2/ene_gang_russian_2",
"units/payday2/characters/ene_gang_russian_3/ene_gang_russian_3",
"units/payday2/characters/ene_gang_russian_4/ene_gang_russian_4",
"units/payday2/characters/ene_gang_russian_5/ene_gang_russian_5",
"units/payday2/characters/ene_secret_service_1/ene_secret_service_1",
"units/payday2/characters/ene_secret_service_2/ene_secret_service_2",
"units/payday2/characters/ene_security_1/ene_security_1",
"units/payday2/characters/ene_security_2/ene_security_2",
"units/payday2/characters/ene_security_3/ene_security_3",
"units/payday2/characters/ene_shield_1/ene_shield_1",
"units/payday2/characters/ene_shield_2/ene_shield_2",
"units/payday2/characters/ene_sniper_1/ene_sniper_1",
"units/payday2/characters/ene_sniper_2/ene_sniper_2",
"units/payday2/characters/ene_spook_1/ene_spook_1",
"units/payday2/characters/ene_swat_1/ene_swat_1",
"units/payday2/characters/ene_swat_2/ene_swat_2",
"units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1",
"units/payday2/characters/ene_tazer_1/ene_tazer_1",
"units/payday2/characters/ene_biker_escape/ene_biker_escape",
}
I change the "Spook" to "units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1" and then save and press del, It doesn't change the character ai.
Quote Originally Posted by jreynolds552 View Post
I change the "Spook" to "units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1" and then save and press del, It doesn't change the character ai.
Dont press delete, just save the file and hit insert when you're in a game.

@FenixFire yes it works Online. If you want I Can provide screenshots.

Since people dont think this works here is some screenshots.

Would this work Online?
It doesnt work for me...I copied everything from first post and no spawn.
Do i need to update dll? I have one with delete fuction to spawn ai...
Yea it must be an updated DLL I know if that this must be the correct code but just not the correct DLL. Im going to try another DLL then edit this post if it works.
@Win32
@jreynolds552

I'm using the old .Dll works fine.
Can you copy and paste the code for the bulldozer because i tried it and it does not work
Quote Originally Posted by FORGETME86 View Post
Can you copy and paste the code for the bulldozer because i tried it and it does not work
Here is all my scripts.
Code:
-- Message on screen
if managers.hud then
	managers.hud:show_hint( { text = "" } )
end

-- debug menu
if managers.menu then
        managers.menu:set_debug_menu_enabled(true)
end



-- Infinite ammo clip
if not _fireWep then _fireWep = NewRaycastWeaponBase.fire end
function NewRaycastWeaponBase:fire( from_pos, direction, dmg_mul, shoot_player, spread_mul, autohit_mul, suppr_mul, target_unit )
    _fireWep( self, from_pos, direction, dmg_mul, shoot_player, spread_mul, autohit_mul, suppr_mul, target_unit )
    
    if managers.player:player_unit() == self._setup.user_unit then
        self.set_ammo(self, 1.0)
    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_point = managers.network:game():get_next_spawn_point()

local spawn_pos = spawn_point.pos_rot[1]
local spawn_rot = spawn_point.pos_rot[2]

local unit_name = Idstring( "units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1" )
local myobjective = FollowUnit()

local spawn_ai = { 
init_state = "idle",
objective = myobjective
}

local unit = World:spawn_unit( unit_name, spawn_pos, spawn_rot )

unit:movement():set_character_anim_variables()


end


if Network:is_server() then
SpawnMob()
managers.hud:show_hint( { text = " " } )
end
Man, you could tell me that they are anemy and i have to be a host...
Quote Originally Posted by Win32 View Post
Man, you could tell me that they are anemy and i have to be a host...
LMAO, I'm so sorry. How the fuck did i forget.
Your code works great for me I must not have had debug menu or something, thanks.
Quote Originally Posted by jreynolds552 View Post
Your code works great for me I must not have had debug menu or something, thanks.
Thanks mate.

As i said above, It's not my code, All credit to creator.

Enjoy.
are they supposed to spawn at the ally spawn point? cause every time i run the script it just spawns an enemy beside the van, how could i get them to spawn somewhere else
THIS CODE ONLY WORKS IF YOU'RE HOST

I'm not sure why, but that's the way it was designed.
Posts 1–15 of 24 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us