multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.4k stars 431 forks source link

Add support for dynamic amount of seats for custom vehicle models #993

Open Dutchman101 opened 5 years ago

Dutchman101 commented 5 years ago

This request is the result of a discussion in #development on 12th June 2019.

Is your feature request related to a problem? Please describe. The problem is that when you replace an existing vehicle with a custom model, it will retain the amount of seats that GTA hardcoded for said vehicle. For example, when you apply a model for a 2-doored vehicle to a vehicle that has 4 doors (like a sedan), MTA will allow you to enter more seats than the model physically has, resulting in awkward appearance; players crammed up in invisible space on the backseat or trunk.

Likewise, if you apply a model for a 4-doored vehicle to a vehicle that originally has 2 doors, you won't be able to use the rear doors/seats by pressing Enter, despite them appearing correctly.

The reason behind this problem is easy to comprehend: GTA hardcoded the amount of seats for each vehicle, by its ID. You can tell because making sure the DFF's format tells about the amount of doors the mod has (like door objects and dummies all in the right place) won't make them usable if the original vehicle has a different number of doors.

Describe the solution you'd like MTA can easily support dynamic seats based on the amount of doors a custom model contains. In fact, some other projects (like multiplayers) already support it seamlessly.

My theory for the technical approach is:

As a modeller, I can tell you that door dummies are a reliable and accurate representation of the amount of doors.

Describe alternatives you've considered Scripters can work around the lack of support by handling vehicle entering themselves; for example play entering animation, and teleport player into a certain location within the vehicle's frame, supposedly the true location of a seat.

Additional context In order to prevent issues and guarantee a proper implementation, we need to take additional measures if developers decide to add support. So far, only a single matter comes to mind, but if anyone can think of anything else, feel free to comment:

Dutchman101 commented 5 years ago

Also please note that (custom) vehicle models already contain the entering locations of each door and seat position, so really all we need to do for support is write to GTA based on the DFF's door dummy count so that GTA tells MTA what we need in case of a custom model.

This means that there won't be concerns with sync. The server also doesn't know the amount of seats a vehicle has.

AlexTMjugador commented 5 years ago

Are you sure that GTA hardcodes the number of seats for each vehicle itself, or that's just something that MTA does for sync reasons? I vaguely remember replacing four-door sedans with two-door vehicles in singleplayer and it worked fine, without the back seats being usable. Moreover, as the DFF contains information to get the number of doors a vehicle has, it makes sense GTA uses that to process vehicle entering on runtime, doesn't it?

Edit: now I think more about it, as model replacements are clientsided in MTA, I think desyncs could occur if some clients see a two-door model, but others a four-door one.

dmi7ry commented 5 years ago

I vaguely remember replacing four-door sedans with two-door vehicles in singleplayer and it worked fine, without the back seats being usable.

You can replace 4-door vehicle with 2-door vehicle, but you can't replace 2-door vehicle with 4-door vehicle.

Dutchman101 commented 5 years ago

You can replace 4-door vehicle with 2-door vehicle, but you can't replace 2-door vehicle with 4-door vehicle.

Still, if you replace a 4-door vehicle with a 2-door vehicle, you will get 'invisible' seats in the 2-door vehicle, which is what I called "crammed up", it would appear as if players are sitting on eachother's lap. But yeah, the other way around (replacing a 2-door vehicle with a 4-door) is potentially worse than that visual glitch, since you'll get non-functional doors.

Note: @sbx320 worked on a patch for this and we have been testing it, we're yet to finish other scenarios to see if everything works as expected also considering the custom code SA seems to contain for certain 'special' vehicles (perhaps just a hardcoded count, or entirely changing/customizing their door handling)

special

Basically the full (so far local) change being tested is just adding pVehicleModelInfoInterface->ucNumDoors = 2; under this line.. obviously it misses checks (also for scripting functions like warpPedIntoVehicle)