[Script] [Misc] Dirt Effects
So title needs elaboration. As u all knw there are some 2k Dirt (Texture) mods out there but u cant use 'em unless u drive in dirt or Use Trainer. All cars are just way too clean. So, a simple script that would add RANDOM level of dirt on some or all vehicles so we can hav much more variation in looks of car.
Like some are 20% dirty, some clean, some 50% and so on. Not all should be super shiny all the time. Should be a simple script. If any1 up for it. Would be Amazing.
@Sh3nZeR that's definitely possible. And since @LeeC2202 already has experience with material checking, maybe he is best suited for the job?
@stillhere Let's hope he does it
@stillhere This would be fairly simple as you just need to set the dirt level on the cars with
Vehicle.DirtLevel. The collection part of this is also easy, and you could even set it per class type and per zone. So Off-Road in the desert might have more dirt than say Sports in the desert. I don't think material checking would be needed in this, in fact, given the number of cars, it would be a massive overhead.
What would be the most cumbersome part, would be keeping track of all the vehicles you had set the dirt level on, so you didn't keep changing it. I've seen another mod do it with the registration and that's not a problem, just create a
Dictionary<string,float>that matches registrations with dirt levels.
The problem comes from addon cars that are all spawned with the same registration and I'm not sure how addon cars that have been spawned into traffic are given a registration.
On first glance, this seems so straight forward, I'm amazed it hasn't been done... and that makes me wonder if there isn't a gotcha somewhere that I'm missing.
I'll create a project and have a look when I'm in between tasks with my helicopter mod, because I very much agree that this would be nice for adding that bit of extra variety.
@LeeC2202 wow this is much deeper than I thought! I was simply thinking about the ground material affecting the dirt level. But vehicle type should definitely affect the chances too.
About the vehicle registration, you are referring to the plates right? Maybe a combination of plate number and primary color? Seems a bit much for something so simple but I wouldn't know for sure.
@stillhere I suspect the ground material already does affect the dirt level but if a car starts on a material that doesn't cause much dirt, then it will stay clean. I suspect that's why you do see dirty cars in the desert but don't tend to see them that much in the city.
So what you have to try and do, is to simulate cars coming in from outside the city, so they might already be dirty. So you allocate certain types to be out-of-city types and then bias those with heavier dirt levels.
If R* have generated the vehicles as I would think of doing it, every vehicle will have a completely unique registration number, just like in real life. There shouldn't really be any need for a secondary check.
I mean, you could just say "Let's collect all the vehicles and give them a random dirt level" but that's way too easy... there's no challenge or fun in that.
@Sh3nZeR Okay, I have something fairly simple set up which I want to send you to have a look at.
It is a zip file that contains three things.
- The mod dll file (called RandomDirtyCars.dll)
- A settings file that goes with the mod
- A readme file that explains what the settings file does
I was going to send you the project file as well but it depends on if you want that. If you do, there would just be a small change you would need to do in Visual Studio as one setting is specific to my setup.
As this is your request, I want you to have a look at it how it is now and make any suggestions that you can think of. It's not as complex as I want to do but I am still in the middle of another mod and have just discovered a bug in my camera mod, so I had to draw a line for now.
So let me know if you are ok with me sending you the files by PM, they are all zipped up ready to send.
I'll just explain a bit more how this works now that I have fixed my other bug.
The vehicle classes have been split into groups, and each of those groups has a dirt level set, based on a random value (within a range) and in some cases, a minimum value.
So for example, Emergency vehicles are given a maximum value of 0 - 2, simply because Emergency vehicles tend to be well looked after. Commercial and Industrial vehicles have a range of 0 - 5, but they get a minimum of 7 to start with... so in effect, 7 to 12. Service and Vans have a range of 0 - 6, with a minimum of 2. Offroad and SUVs have a range of 0 - 12.
All those values are for normal zones.
In the ini file, I have defined what I class as Dirty Zones, I have taken these from my helicopter mod as it uses the same system, you can add more to these if you like. If the vehicle is first seen in one of those zones, it gets a bias value added of 3 as well as the other values. So whereas an OffRoad normally has a value of 0 - 12, in a dirty zone, it would be 3 - 15. 15 is the maximum value you can have for the dirt level.
You can also define the range that the vehicles are collected and changed
SEARCH RANGE, default is 100, which is quite far away. You don't see them change at this distance. If your PC is okay for performance, you can up that even more. My helicopter mod uses a similar system at a range of 200 with no visible performance hit.
Finally, there is the
DIRT BIASvalue, which is the value that gets added in the dirty zones. You can increase this without causing a problem. The code won't allow a value over 15, so there is no problem setting this higher.
So that's pretty much it... I liked the idea anyway and now that I have it working, I will definitely be leaving it installed.
I do have one other idea for it but I don't know how the game deals with this already. What I was thinking was that if it was raining, I could run through the dictionary of values at regular intervals and decrease the dirt levels based on rain intensity. Then, if a matching vehicle was spotted again, it could check to see if the modified value was lower and if so, apply it. So it would look like the rain was cleaning the vehicles... but the game might already do that, I'm not sure.
And on that note... I'll stop talking.
@LeeC2202 bravo! Very well thought out and implemented, imo
One question: does dirt level also show mud on vehicles or is there some other native that controls that?
@stillhere That's all controlled by the dirt level... I'll post some screens shortly, to show what it does.
So here's just a couple of screens from the desert. All I did was stand by the same car and hit insert, to refresh the mod. You can see how there is more difference on the top image, that type of vehicle has a broader range that the dirt can work in.
In the city, you can still get this level of dirt variation on the right type of car.
@LeeC2202 Screens do look what i wanted 'em to be. So far its perfect.
@Sh3nZeR I'm going to send you the mod by PM for your first approval. If you're happy with it, I will release it on the site, with you credited as the requester of the mod.
Mod now pending approval here: https://www.gta5-mods.com/scripts/random-dirty-cars
Just putting an idea out there to see what people think... as I explained earlier, I have all these values predefined in the code to apply the dirt. What is the opinion of people about me making those values available in the ini file? So to give people total and complete control over how this works.
To give you an example, in the code for Utility vehicles, I have:
_dirt = (modRandomNumber.NextDouble() * 6) + 6;
So what that means, is that it takes a random number between 0 and 6, then adds a base value of 6 to that, giving a range of 6 to 12. In the dirty-zones that would be 9 to 15 of course.
Now in the ini file, I could in theory have
MAX = 6
BASE = 6
Is that making the ini file too complex, for something that is really a simple mod? Do people need that level of the control? I'm just curious as to how much control people want in things like this. To cover all wheeled vehicles, there would be sixteen sections like that, sorry, seventeen because I don't include cycles.