Skip to content

Commit efcc29f

Browse files
committed
Drifting: restrict to automobiles and bikes
1 parent 8c15b64 commit efcc29f

3 files changed

Lines changed: 124 additions & 89 deletions

File tree

‎pawn/Driver/Drift/DriftHelpers.pwn‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ new Float: g_playerDriftStartHealth[MAX_PLAYERS];
1616
new g_playerDriftStartTime[MAX_PLAYERS] = { 0, ... };
1717
new g_playerDriftUpdateTime[MAX_PLAYERS] = { 0, ... };
1818

19+
// Determines whether the given |vehicleId| is able to drift. This generally is restricted to bikes
20+
// and automobiles, because >250k scores are easily obtainable through helicopters.
21+
IsValidDriftVehicle(vehicleId) {
22+
new const modelId = GetVehicleModel(vehicleId);
23+
24+
return VehicleModel->isAutomobile(modelId) ||
25+
VehicleModel->isBike(modelId);
26+
}
27+
1928
// Calculates the vehicle's principal axes based on it's rotation quaternion, which allows us to
2029
// determine the vehicle's orientation during a drift. Drifts on a flat plane are great, but they
2130
// become a lot more interesting when exercised on e.g. a hill.
@@ -147,6 +156,9 @@ ProcessDriftUpdateForPlayer(playerId) {
147156
if (!vehicleId)
148157
return; // the |playerId| is not currently in a vehicle
149158

159+
if (!IsValidDriftVehicle(vehicleId))
160+
return; // the |vehicleId| is not valid for drifting
161+
150162
if ((++g_playerDriftUpdateCounter[playerId] % DRIFT_UPDATE_INTERVAL) != 0)
151163
return; // this tick will be ignored to decrease server load
152164

‎pawn/Entities/Vehicles/VehicleModel.pwn‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ enum _: VehicleModelFlags {
5353
DisableNitroInjectionVehicleFlag = 0x1000,
5454

5555
// Marks this vehicle as being unable to be created (i.e. because it's useless).
56-
DisableCreationVehicleFlag = 0x2000
56+
DisableCreationVehicleFlag = 0x2000,
57+
58+
// Indicates that this vehicle is an automobile.
59+
AutomobileVehicleFlag = 0x4000,
5760
};
5861

5962
/**
@@ -230,6 +233,26 @@ class VehicleModel <modelId (NumberOfVehicleModels)> {
230233
return this->hasFlag(modelId, AirplaneVehicleFlag);
231234
}
232235

236+
/**
237+
* Returns whether this model Id represents an automobile.
238+
*
239+
* @param modelId Id of the vehicle model to check against.
240+
* @return boolean Is this model representing an automobile?
241+
*/
242+
public static inline bool: isAutomobile(modelId) {
243+
return this->hasFlag(modelId, AutomobileVehicleFlag);
244+
}
245+
246+
/**
247+
* Returns whether this model Id represents a bike.
248+
*
249+
* @param modelId Id of the vehicle model to check against.
250+
* @return boolean Is this model representing a bike?
251+
*/
252+
public static inline bool: isBike(modelId) {
253+
return this->hasFlag(modelId, BikeVehicleFlag);
254+
}
255+
233256
/**
234257
* Returns whether this vehicle model Id represents a trailer. Trailers cannot be driven by
235258
* players, and must be positioned in a different way.

0 commit comments

Comments
 (0)