Yeah, screw that last post. It was an April fools thingy.
Now back onto the serious stuff.
The CBaseVehicle class is siting at around 400 lines of code right now.
Since last time, I have added multi-seat support, seat switching, and better controls. But also, a very important change for modders who decide to use this tech one day.
And that is the following: creating new vehicle classes is super duper easy.
1. Define a vehicle class e.g. CVehicleVWGolf and base it off CBaseVehicle (however, it'll likely be CBaseCar, since each base is devoted to different vehicle types)
2. Define the VehicleInit() function
3. Let the base take care of the rest
And what did I do to make the two-seated couch work?
I just defined VehicleInit() like this:
m_iSeats = 2;
v_Seats[0].Init(Driver, v_Body.pos, 0);
v_Seats[1].Init(Passenger, v_Body.pos, 1);
Of course, this is just a part of the total function, but I'm planning to make it as easy as possible. For two reasons, really. Firstly, people would have to learn the whole vehicle system (and it can only get more complex in the following months), and that is not optimal for someone who just wants to create a vehicle. Secondly, I'm just too lazy to type 400 lines for each vehicle class, and you may agree that it's a bit inconvenient too. <w<
Either way, the new controls have arrived, finally. Up until now, my controls looked something like this:
if W -> push the vehicle in the direction the player's looking at
if A -> push the vehicle negatively in the X axis
if D -> push the vehicle positively in the X axis
if S -> push the vehicle negatively in the Y axis
That is, obviously, wrong (the ADS part) because those axes are world axes, not ones that are local to the vehicle.
So what I did was, I made it more standard, how you'd usually expect a car to be driven in games.
if W -> push the vehicle in the vehicle's front direction
if A -> rotate the vehicle's direction to the left
if D -> rotate the vehicle's direction to the right
if S -> push the vehicle in its back direction
All of this new stuff was programmed just today. Lastly, the seat switching. This one was the most tedious one, but it turns out I had a small inconsistency:
// Standard for all seats - always listen to unuse and seatswitch
fCommands[bi_unuse] = pSessilis->GetKeyButton(vehicle_unuse);
fCommands[bi_seatswitch] = pSessilis->GetKeyButton(vehicle_seatswitch);
This is what it's supposed to be like ^
However, I somehow placed the seatswitch listener into the Driver seat category, so only Driver and Driver-Gunner seats could switch. D:
But it was resolved in about 30 minutes.
Here are some videos:
https://i.imgur.com/5RWNHld.mp4https://i.imgur.com/uRG4rmv.mp4https://i.imgur.com/94xW83F.mp4What's next?
Engines/motors. There's already some code, including the jokes:
void VehicleEngine::Damage(float hp)
{
if (MadeInGermany)
return; // engine was made in Germany, can't break
This is an actual part of the code and it'll stay that way.
Either way, the engines will be responsible for the vehicle performance. Think of RPM, gears, shifting and perhaps fuel if we want to be that realistic (though I don't really wanna add fuel). Either way, the engine will be damageable, and if it's broken, the vehicle cannot accelerate etc.
Wheels. Currently only the struct definition.
Wheels are interesting. They define the grip of the vehicle, and its handling. They will also be damageable, except the vehicle will still be able to operate after these are destroyed.
However, I will eventually create a new vehicle class to utilise all the 4 components: the body, the seats, the engine and the wheels.
A couch won't cut it. Once I get to the cars, then I can show the real power of the vehicle system.