[V] Dynamically adding carcols

Hello everyone,

today we’re going to have a look at how to add carcol settings in GTA V to vehicles at runtime. The file contains the siren patterns for emergency vehicles among others and people have been using it to create their own pattern with the most recent research being made here: http://www.lcpdfr.com/forums/topic/66806-researchwip-custom-light-patterns-through-carcolsymt/. When I stumbled across that post I decided to revisit my research on that topic as it was obvious that the current system was heavily limited, since it only allowed changes to be made before you start the game and only share patterns across a vehicle model.

MulleDK19 and I both had already made some interesting research on this topic and with the new information revealed in the topic, we felt it was time to complete it. Due to my ELS research I had large parts of the siren functions reversed already, so it wasn’t really a cold start. We also knew about the function retrieving the siren settings. At first I wanted to find out whether these settings could be altered in memory during runtime and would immediately reflect in-game.

First tests in memory

At first, I navigated to the siren settings instance in memory and played around with the values a little bit. It was immediately clear that no further work was needed to make those changes take effect in-game, as the pattern adjusted directly. So changing the pattern while in-game was no problem and exposing a function to do that seemed pretty easy. Now it was time to test how deeply wired the memory instance of the siren setting was, i.e. if it just contained the raw data and could be moved or whether there were various references we had to account for. Luckily, it just contains the data, so allocating memory, copying the instance and adjusting the pointer worked fine for any vehicles. At this point I was sure that adding custom patterns at runtime shouldn’t be too hard. But we still needed to solve the problem that it was limited to models instead of single vehicle instances.

Adding per vehicle support

To make it work on a per vehicle basis, we had to check where the siren settings were being used. Using a list to keep track of vehicles with a custom pattern seemed like a good idea. Thus, we intercepted the usage of the siren settings and checked whether the vehicle currently being processed had a custom pattern assigned. If that was the case, we would supply our own pattern, otherwise we would let the original call do its work and use the vanilla settings. This proved to be a really solid setup. You can see the result here:

We could now not only change a pattern at runtime, but also create new patterns and modify those. On top of that we are now also able to assign a specific pattern to a single vehicle instead of it being assigned to all vehicles of a certain model. This will be available for everyone to play around with soon in RAGE Plugin Hook!

2 thoughts on “[V] Dynamically adding carcols

  1. Root

    Hi does this have any effect or advantage for els in v can you do anything with it for els or is this just for vanilla lighting thx

    Reply
    1. LMS Post author

      We’re currently evaluating how/if we can make use of this for ELS, but we’ll probably use portions of it for ELS, too.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *