Experimental Police Chase Script - Beta Version 0.1 by DjDominias

Discussion in 'Utilities and programming' started by Dominias, Feb 6, 2025.

  1. Dominias

    Dominias
    Expand Collapse

    Joined:
    Feb 6, 2025
    Messages:
    1
    ---
    **Police Chase Script - Beta Version 0.1 by DjDominias**
    Hello BeamNG community,
    I'm excited to share a new script I've been working on: **Police Chase Script**. This script is designed to respawn 6 police vehicles that will chase the player in BeamNG.drive. The police vehicles are tough to destroy, have maximum driving skills, and minimal collision risk.
    ### How the Script Works:
    1. **Vehicle List**: The script defines a list of police vehicle names to be respawned:
    ```lua
    local policeVehicles = { "police1", "police2", "police3", "police4", "police5", "police6" }
    ```
    2. **Respawn Function**: This function respawns police vehicles, sets chase mode, durability, driver skills, and minimal collision risk:
    ```lua
    local function respawnPoliceVehicles()
    for _, vehicleName in ipairs(policeVehicles) do
    local vehicleId = scenetree.create("Vehicle", vehicleName, {position = vec3(0, 0, 0), rotation = quat(0, 0, 0, 1)})
    local ai = scenetree.findObjectById(vehicleId):getComponent("ai")
    ai:setMode("chase")
    local veh = scenetree.findObjectById(vehicleId)
    veh:setDamageType("high")
    ai:setSkill(1.0)
    ai:setAvoidRisk(0.0)
    end
    end
    ```
    3. **Initialization Function**: This function starts the respawn of police vehicles:
    ```lua
    local function onInit()
    respawnPoliceVehicles()
    end
    M.onInit = onInit
    return M
    ```
    4. **Loading the Script**:
    1. Find the game directory: Go to the BeamNG.drive game directory.
    2. Create a script folder: In the game directory, create a `lua` folder, then a `police_chase` folder, and place the Lua script (`police_chase.lua`) inside.
    3. Edit the mission file: Locate the mission file in the game directory and add the path to the `police_chase.lua` script.
    1. ### Potential Bugs:
    2. As this is a beta version (0.1), there might be some bugs. Potential issues include:
    3. - Vehicles not respawning correctly
    4. - AI behavior not functioning as intended
    5. - Collisions not being handled properly
    6. ### Request for Feedback:
    7. I kindly ask the community to report any bugs and provide suggestions for improvements. If I have posted this in the wrong section, I apologize. Please feel free to report any issues, suggestions, or problems either here or on my Steam profile: [DjDominias Steam Profile](https://steamcommunity.com/profiles/76561199443473490/).
    8. Thank you for your support and happy driving!
    9. ---

    10. Additionally, I am creating a Discord server for those who want to help me develop scripts further. The invitation to join the server will be in the next post. In the meantime, feel free to add me on Steam and ask about the script or any other related topics.

    Thank you for your support and happy driving!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice