Make NPCs use grenades

Hello,

is it possible to make NPCs use grenades, like the SWAT use flashbangs in the first mission?

It would be awesome to see SWAT officers actually throw flashbangs at the player and SNG soldiers throw grenades at the player. I have best chance by looking into the weapon.xtbl and tweak_table.xtbl I guess?
 
They don't throw actually throw flashbangs in the mission. That's just a scripted explosion:
Code:
    -- Flashbang callout!
    audio_play_persona_line(M01_shaundi, "M01_Flashbang_Callout")
    delay(1.0)
    
    -- just blow up the player        
    explosion_create("Flashbang", LOCAL_PLAYER, M01_group.swat2_pair.members[1], false)
    -- and the remote player
    if (coop_is_active() == true) then
        explosion_create("Flashbang", REMOTE_PLAYER, M01_group.swat2_pair.members[1], false)
    end
    
    clear_animation_state(M01_shaundi)
    clear_animation_state(M01_gat)
    
    delay(10.0)    -- give some time for player to figure out what is going on and kill some guys
    M01_throw_flashbangs = false

There's probably not going to be any way to implement what you want. Sorry.
 
They don't throw actually throw flashbangs in the mission. That's just a scripted explosion:
Code:
    -- Flashbang callout!
    audio_play_persona_line(M01_shaundi, "M01_Flashbang_Callout")
    delay(1.0)
 
    -- just blow up the player     
    explosion_create("Flashbang", LOCAL_PLAYER, M01_group.swat2_pair.members[1], false)
    -- and the remote player
    if (coop_is_active() == true) then
        explosion_create("Flashbang", REMOTE_PLAYER, M01_group.swat2_pair.members[1], false)
    end
 
    clear_animation_state(M01_shaundi)
    clear_animation_state(M01_gat)
 
    delay(10.0)    -- give some time for player to figure out what is going on and kill some guys
    M01_throw_flashbangs = false

There's probably not going to be any way to implement what you want. Sorry.

No problem, man ;)

I got another question though. I have made the M2 Grenade Launcher shoot flash bang grenades and now the SWAT uses them to, so basically the SWAT uses flashbangs which they shoot from the grenade launcher (they do that in real life to). But I'm pretty sure the grenade launcher is from a DLC so how can I make sure that anyone who will download my mod when I release it and does not own the DLC pack will not have any SWAT officers use it? If they would then the players without the DLC would be able to pick it up from any dead SWAT officer and use it, right?

I have edited the spawn_info_ranks.xtbl so that 90 percent of the SWAT officers at 4 shields uses the AR 55 and 10 percent the grenade launcher. So will the game detect that the player does not own the DLC and have 100 percent of the SWAT officers use the AR 55 or not?

And finally I also would like to know if it would be possible to make NPC use upgrades weapons? I was thinking of making the SWAT use the level 4 ultimax shotgun, which is fully automatic. Right now I made the lvl 1 fully automatic and made sure the cops don't use it anymore, only the some of the SWAT at 3 shields and some at 4 shields.
 
Your coop partner cannot pick up and use DLC weapons that he doesn't own no matter who drops them (other player, npcs, etc,) so that should be okay. No idea on the upgraded weapons thing. Maybe someone else has some insight.
 
Your coop partner cannot pick up and use DLC weapons that he doesn't own no matter who drops them (other player, npcs, etc,) so that should be okay. No idea on the upgraded weapons thing. Maybe someone else has some insight.

Thats a relief, thank you ;) And now you say its, the explosions in the first mission were scripted. The one when the SWAT Team enters via the robes I was sure it was scripted but I just wasn't sure about the 2 other ones because you could actually see the SWAT members grab the flash bang from their equipement and throw it. There even was a grenade indicator.

But anyway, thank you for helping me... again ;)
 
The one when the SWAT Team enters via the robes I was sure it was scripted but I just wasn't sure about the 2 other ones because you could actually see the SWAT members grab the flash bang from their equipement and throw it. There even was a grenade indicator.

The later ones are scripted as well
Code:
    ai_set_action_delay(M01_group.heli_fighter1.members[1], "throw grenade", 99999)
    ai_set_action_delay(M01_group.heli_fighter1.members[2], "throw grenade", 99999)

EDIT:
Derp. Not script. It does use a function to set specific AI to do it for that section though. There is no way to do that in the open world since no npcs are defined/spawned that way.
 
Is there a behaviors file that you could edit/add that behavior for them though?
 
Is there a behaviors file that you could edit/add that behavior for them though?

I don't know, I don't think that it is possible. You can change their behaviour from defensive to offensive etc... but I'm pretty sure its not possible, just like IdolNinja said.
 
I don't know, I don't think that it is possible. You can change their behaviour from defensive to offensive etc... but I'm pretty sure its not possible, just like IdolNinja said.

I did an indexed search on "throw grenade" which revealed the following files:
ai_behavior.xtbl
ai_goals.xtbl
combat_actions.xtbl

combat_actions.xtbl contains the definition, and it seems that "throw grenade" encompasses any projectile weapon such as rocket launchers, grenade launcher, and grenades.

ai_behavior are groups of actions that each ai can take, with "throw grenade" being one of a long list.

ai_goals are another list of actions that an ai can take depending on what "mode" they are in. "throw grenade" is part of actions they can take when in the following modes:
suppress
kill_enemy
flush out

Looking at ai_behaviors, the police defensive, and police average groups have Suppress as one of their listed goals, and "throw grenade" listed as an ability element. If I'm reading this right, it should mean that they are actually allowed to use grenades since that goal is part of the Suppress ai_goals entry.

Another indexed search on "police defensive" leads to spawn_info_ranks.xtbl which uses that as a class to how certain npcs will act. Looking a little deeper into this table, each entry has a weapon loadout list. Police Average doesn't seem to be listed, so this narrows it down to Police Defensive. Most of the law rank entries have Police Defensive as part of their AI rotation, and those mostly do have a flashbang listed as part of their thrown entry.

So, the question now is why aren't they actually doing it if all those elements are in place? It all looks right and we should see that kind of behavior happening in game at least every once in a while. If anyone wants to look deeper into it, feel free.
 
Well the option I only have left in mind is that there are missing animations for the grenade toss. And I checked the animations of COP.xtbl, and only in the Default group are grenade tossing animations. Maybe that's the reason why the flashbangs from mission 1 were scripted.
 
Back
Top