SRTT NPCs shoot out of car

Hey

I've been looking at for a while, gang members shoot out of their cars when they are after you but the cops don't. How does the game allow gang members to do drive by's but not the cops?
It has something to do with the team right? Because changing AI behaviour doesn't seem to have any effect.
The only time I managed to make cops shoot out of their cars was when I changed their team from cops to gangs.
I have also noticed that during the 'Trafficking' activity the cops do shoot out of their cars and when checking out the activity xtbl I found a flag which allows this, but only during the activity.
Its just that for my mod, I really would like to have the cops shoot out of their cars once the player has reached police notoriety level 4.
 
Yorpie -
By default, NPCs set as a "law enforcement" (Police or STAG) or civilian teams are prevented from firing as passengers in regular vehicles. This behavior is hard coded based on an internal flag "Allow_cops_to_shoot_from_vehicles" and cannot be modified through the various AI tables.

As you have pointed out, setting cops to any "gang" team would make them fire out of vehicles at all notoriety levels. However, changing the team of cop NPCs will affect many of their other behaviors, which is likely why you are asking for another solution.

The other option would be to set the Allow_cops_to_shoot_from_vehicles flag that Trafficking and other activities use to true. There is a Lua script action, set_cops_shooting_from_vehicles(enable), that will allow you to modify that flag from script. You should be able to spawn a Lua thread inside of sr3_city.lua (see: http://www.saintsrowmods.com/forum/threads/advice-needed-on-a-lua-file-sandbox.2598/) that spins forever and toggles that flag based on the current notoriety level. The notoriety level is accessible from script via notoriety_get(team_name) or notoriety_get_decimal(team_name) (the first function returns the integer level number, and the second function returns the actual fractional notoriety value [2.5 or 3.4 for example])

The teams names for the notoriety functions are:
"luchadores"​
"deckers"​
"morningstar"​
"police"​

NOTE: Remember that certain activities and missions also modify this flag, and may interfere with the state your script thinks is currently set (and vice versa). You may want to take this into account by checking mission_is_active(mission_name). If you don't specify a mission name, it will check if any mission is active. Also, this function works with activities as well, since they are largely considered "missions" under the hood.

Best of luck to you as you work on your mod. Keep us all posted how it turns out!!
 
yorpie, I'd be glad to add this as a default behavior to Sandbox+ so it automatically loads on start, as well as creating a command toggle for it. Look for it in the next release. :)
 
yorpie, I'd be glad to add this as a default behavior to Sandbox+ so it automatically loads on start, as well as creating a command toggle for it. Look for it in the next release. :)


That would be great, a command toggle to make cops shoot out of their cars or not. I'll sure check it out when the version of sandbox+ mod will be released. :D
 
Yorpie -
By default, NPCs set as a "law enforcement" (Police or STAG) or civilian teams are prevented from firing as passengers in regular vehicles. This behavior is hard coded based on an internal flag "Allow_cops_to_shoot_from_vehicles" and cannot be modified through the various AI tables.

As you have pointed out, setting cops to any "gang" team would make them fire out of vehicles at all notoriety levels. However, changing the team of cop NPCs will affect many of their other behaviors, which is likely why you are asking for another solution.

The other option would be to set the Allow_cops_to_shoot_from_vehicles flag that Trafficking and other activities use to true. There is a Lua script action, set_cops_shooting_from_vehicles(enable), that will allow you to modify that flag from script. You should be able to spawn a Lua thread inside of sr3_city.lua (see: http://www.saintsrowmods.com/forum/threads/advice-needed-on-a-lua-file-sandbox.2598/) that spins forever and toggles that flag based on the current notoriety level. The notoriety level is accessible from script via notoriety_get(team_name) or notoriety_get_decimal(team_name) (the first function returns the integer level number, and the second function returns the actual fractional notoriety value [2.5 or 3.4 for example])

The teams names for the notoriety functions are:
"luchadores"​
"deckers"​
"morningstar"​
"police"​

NOTE: Remember that certain activities and missions also modify this flag, and may interfere with the state your script thinks is currently set (and vice versa). You may want to take this into account by checking mission_is_active(mission_name). If you don't specify a mission name, it will check if any mission is active. Also, this function works with activities as well, since they are largely considered "missions" under the hood.

Best of luck to you as you work on your mod. Keep us all posted how it turns out!!

About the notoriety_get(team_name) or notoriety_get_decimal(team_name) codes. If I enter 'police' in the 'team_name' part it means that it counts for the police only. But how can I then set at which notoriety level this 'set_cops_shooting_from_vehicles(enable)' flag becomes active?

With
and the second function returns the actual fractional notoriety value [2.5 or 3.4 for example]
do you mean that if I would for example set this to 3.5, the cops would start shooting out of their cars from the moment I have fought my way up to 3 notoriety shields and the game detects that I am halfway on reaching the fourth shield?

I already managed to do it, making the cops shoot out of their cars :) Super! Thank you tulip.sniper :D So happy now.
Now I only need to know how to set at which level the cops start shooting out of their vehicles.

EDIT: HAHA, even the SWAT team is shooting out of their black peacemakers, beautiful.
 
yorpie, I'm actually adding all this to Sandbox+ now and I'll post the code when I'm done so you can see it. In the meantime, what notoriety level would you like them to start shooting? I think 3 or 4 would probably work best.
 
do you mean that if I would for example set this to 3.5, the cops would start shooting out of their cars from the moment I have fought my way up to 3 notoriety shields and the game detects that I am halfway on reaching the fourth shield?

I'd do something like:
Code:
function sr3_city_thread_cops_shooting_out_windows()
    local cops_shoot_from_vehicle_notoriety = 4    -- control what notoriety level police will start shooting from their vehicles
 
    -- loop forever
    while(true) do
        -- Only process outside of missions
        if (mission_is_active() == false) then
            -- Should cops be shooting from vehicles?
            if (notoriety_get("police") >= cops_shoot_from_vehicle_notoriety) then
                set_cops_shooting_from_vehicles(true)
            else
                set_cops_shooting_from_vehicles(false)
            end
        end
 
        delay(0.5)    -- could be set to thread_yield() to process every frame
    end
end
 
EDIT: HAHA, even the SWAT team is shooting out of their black peacemakers, beautiful.
SWAT and STAG are also on the same "police" team, so yes, they will all shoot out of their vehicles with this mod. :P
 
I've updated Sandbox+ so that it always allows cops to shoot out of cars at notoriety 3 or higher. It will load this by default and I left an option at the top of the script for people to turn it off if they want. You can also manually toggle it on/off in-game by using F+RIGHT ARROW. I have attached the updated script to this post, and it will also be part of the next official Sandbox+ release.

Here's how I approached it.
Code:
-- *** POLICE SHOOT FROM VEHICLES AT NOTORIETY 3 OR HIGHER NOTE: THIS ONLY AFFECTS OPEN WORLD AND NOT MISSIONS/ACTIVITIES! ***
-- POLICE_SHOOT_FROM_VEHICLES = true (default) allows cops to start shooting at you from their vehicles at notoriety 3 or higher
-- POLICE_SHOOT_FROM_VEHICLES = false prevents them from shooting at you from their cars. This is the original behavior of the vanilla game
POLICE_SHOOT_FROM_VEHICLES = true
.
Code:
function keycombo_thread()
    while KEYCOMBO_THREAD_ON == 1 do
        SANDBOX_COP_NOTORIETY_CHECK = notoriety_get_decimal("police")
        if POLICE_SHOOT_FROM_VEHICLES and not mission_is_active() and SANDBOX_COP_NOTORIETY_CHECK >= 3.0 then
            set_cops_shooting_from_vehicles(true)
        elseif POLICE_SHOOT_FROM_VEHICLES and not mission_is_active() and SANDBOX_COP_NOTORIETY_CHECK < 3.0 then
            set_cops_shooting_from_vehicles(false)
        elseif not POLICE_SHOOT_FROM_VEHICLES and not mission_is_active() then
            set_cops_shooting_from_vehicles(false)
        end
.
.
Code:
            elseif player_action_is_pressed(B_RIGHT) and not MELEE_PUSHED then
                if POLICE_SHOOT_FROM_VEHICLES then
                    sandboxplus_message("Police shooting from vehicles disabled")
                else
                    sandboxplus_message("Police will now shoot from vehicles at 3 notoriety or higher")
                end
                POLICE_SHOOT_FROM_VEHICLES = not POLICE_SHOOT_FROM_VEHICLES
                MELEE_PUSHED = true

EDIT:
Matt's example is actually a more elegant approach. I will likely clean up my version before official release.
 

Attachments

yorpie, I'm actually adding all this to Sandbox+ now and I'll post the code when I'm done so you can see it. In the meantime, what notoriety level would you like them to start shooting? I think 3 or 4 would probably work best.


Well, since my modded police notoriety is different then the original one I would say that they start shooting out of their squad cars from level level 4.
This is my view on the notoriety level:
Level 1 cops try to take you out with melee and tasers
Level 2 cops actively start to hunt you and use deadly force (pistols and shotguns)
Level 3 SWAT arrives
And once the player reaches level 4 every unit is send after the player and officers are allowed to use 'all necessary force to take the suspect down' which offcoarse includes shooting while driving.
At level 5 the SNG arrives offcoarse, since reaching this level means that the SPD can't seem to bring the player down.
 
Back
Top