Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- @stunt.inc v26/12/16 - by Enzo
- Check out original post for updates!
- */
- #if defined _stunt_included
- #endinput
- #endif
- #define _stunt_included
- #if !defined _samp_included
- #include <a_samp>
- #endif
- //
- #include <MapAndreas>
- enum pStuntInfo_enum
- {
- stunt_ID,
- stunt_Time,
- Float:stunt_fX,
- Float:stunt_fY,
- Float:stunt_fZ,
- Float:stunt_LQ,
- Float:stunt_Dist,
- };
- new pStuntInfo[MAX_PLAYERS][pStuntInfo_enum];
- new Stunt_ModelsType[212 char];
- /* Macros */
- #define STUNT_UNABLE (-1) // Player is unable to do stunts
- #define STUNT_NONE (0)
- #define STUNT_WHEELIE (1)
- #define STUNT_STOPPIE (2)
- #define STUNT_TWO_WHEELS (3) // deprecated
- #define STUNT_ROLL_LEFT (4)
- #define STUNT_ROLL_RIGHT (5)
- #define STUNT_LOOP (6) // deprecated
- #define STUNT_INSANE (7)
- #define STUNT_DRIFT (8) // deprecated
- #define STUNT_INVALID (0xFF) // internal
- #define VEHICLE_TYPE_NONE (0)
- #define VEHICLE_TYPE_CAR (1) // Two-wheels stunt
- #define VEHICLE_TYPE_BIKE (2) // Wheelie/Stoppie stunt
- #define VEHICLE_TYPE_PLANE (3) // Barrer-Roll/Loop stunt
- #if !defined fix_angle
- #define fix_angle(%1) (float(floatround(%1, floatround_floor) % 360))
- #endif
- /* Forwards */
- forward OnPlayerStartStunt(playerid, stuntid);
- forward OnPlayerUpdateStunt(playerid, stuntid, time, Float:dist);
- forward OnPlayerFinishStunt(playerid, stuntid, time, Float:dist, bool:success);
- /* i_quat.inc - thanks to sprtik! http://forum.sa-mp.com/showthread.php?t=608341 */
- static stock Float:asin_limit(Float:value)
- {
- if(value > 1.0) value = 1.0;
- else if(value < -1.0) value = -1.0;
- return asin(value);
- }
- static stock Float:atan2_limit(Float:x, Float:y)
- {
- if(x > 1.0) x = 1.0;
- else if(x < -1.0) x = -1.0;
- if(y > 1.0) y = 1.0;
- else if(y < -1.0) y = -1.0;
- return atan2(x, y);
- }
- // Returns a set of Euler angles from a quaternion
- stock GetQuaternionAngles(Float:w, Float:x, Float:y, Float:z, &Float:xa, &Float:ya, &Float:za)
- {
- xa = asin_limit(2.0 * y * z - 2.0 * x * w);
- ya = -atan2_limit(x * z + y * w, 0.5 - x * x - y * y);
- za = -atan2_limit(x * y + z * w, 0.5 - x * x - z * z);
- return 1;
- }
- stock GetVehicleRotation(vehicleid, &Float:x, &Float:y, &Float:z)
- {
- new Float:qw, Float:qx, Float:qy, Float:qz;
- GetVehicleRotationQuat(vehicleid, qw, qx, qy, qz);
- return GetQuaternionAngles(qw, qx, qy, qz, x, y, z);
- }
- //
- public OnFilterScriptInit()
- {
- // Load vehicle models data
- Stunt_ModelsType{0} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{1} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{2} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{3} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{4} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{5} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{6} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{7} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{8} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{9} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{10} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{11} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{12} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{13} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{14} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{15} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{16} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{17} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{18} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{19} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{20} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{21} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{22} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{23} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{24} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{25} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{26} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{27} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{28} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{29} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{30} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{31} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{32} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{33} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{34} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{35} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{36} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{37} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{38} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{39} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{40} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{41} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{42} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{43} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{44} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{45} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{46} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{47} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{48} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{49} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{50} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{51} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{52} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{53} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{54} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{55} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{56} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{57} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{58} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{59} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{60} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{61} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{62} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{63} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{64} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{65} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{66} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{67} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{68} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{69} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{70} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{71} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{72} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{73} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{74} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{75} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{76} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{77} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{78} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{79} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{80} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{81} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{82} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{83} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{84} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{85} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{86} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{87} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{88} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{89} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{90} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{91} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{92} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{93} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{94} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{95} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{96} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{97} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{98} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{99} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{100} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{101} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{102} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{103} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{104} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{105} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{106} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{107} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{108} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{109} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{110} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{111} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{112} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{113} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{114} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{115} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{116} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{117} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{118} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{119} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{120} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{121} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{122} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{123} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{124} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{125} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{126} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{127} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{128} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{129} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{130} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{131} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{132} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{133} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{134} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{135} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{136} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{137} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{138} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{139} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{140} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{141} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{142} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{143} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{144} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{145} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{146} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{147} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{148} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{149} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{150} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{151} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{152} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{153} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{154} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{155} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{156} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{157} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{158} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{159} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{160} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{161} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{162} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{163} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{164} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{165} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{166} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{167} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{168} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{169} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{170} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{171} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{172} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{173} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{174} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{175} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{176} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{177} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{178} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{179} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{180} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{181} = VEHICLE_TYPE_BIKE;
- Stunt_ModelsType{182} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{183} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{184} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{185} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{186} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{187} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{188} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{189} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{190} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{191} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{192} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{193} = VEHICLE_TYPE_PLANE;
- Stunt_ModelsType{194} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{195} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{196} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{197} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{198} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{199} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{200} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{201} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{202} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{203} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{204} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{205} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{206} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{207} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{208} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{209} = VEHICLE_TYPE_CAR;
- Stunt_ModelsType{210} = VEHICLE_TYPE_NONE;
- Stunt_ModelsType{211} = VEHICLE_TYPE_NONE;
- EnableStuntBonusForAll(false);
- print("\n*****************************************");
- print("* stunt.inc loaded successfuly! *");
- print("*****************************************\n");
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- static vehicleid,
- Float:fX, Float:fY, Float:fZ,
- Float:QX, Float:QY, Float:QZ,
- Float:vX, Float:vY, Float:vZ,
- Float:dist, Float:angle, Float:min_z, Float:speed,
- time;
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER || pStuntInfo[playerid][stunt_ID] == STUNT_UNABLE) return 1;
- GetVehiclePos(vehicleid, fX, fY, fZ);
- GetVehicleZAngle(vehicleid, angle);
- vehicleid = GetPlayerVehicleID(playerid);
- time = GetTickCount() - pStuntInfo[playerid][stunt_Time];
- dist = VectorSize(pStuntInfo[playerid][stunt_fX] - fX, pStuntInfo[playerid][stunt_fY] - fY, pStuntInfo[playerid][stunt_fZ] - fZ);
- angle -= fix_angle(atan2(fY - pStuntInfo[playerid][stunt_fY], fX - pStuntInfo[playerid][stunt_fX]) + 270.0);
- pStuntInfo[playerid][stunt_fX] = fX;
- pStuntInfo[playerid][stunt_fY] = fY;
- pStuntInfo[playerid][stunt_fZ] = fZ;
- pStuntInfo[playerid][stunt_Dist] += dist;
- switch(Stunt_ModelsType{GetVehicleModel(vehicleid) - 400})
- {
- case VEHICLE_TYPE_BIKE: // Wheelie or stoppie
- {
- MapAndreas_FindZ_For2DCoord(fX, fY, min_z);
- if(fZ - min_z < 2.5)
- {
- GetVehicleRotation(vehicleid, QX, QY, QZ);
- QX -= atan2(fZ - pStuntInfo[playerid][stunt_fZ], dist); // Subtract height angle
- if(QX > 20.0) // Wheelie
- {
- if(pStuntInfo[playerid][stunt_ID] == STUNT_WHEELIE)
- {
- OnPlayerUpdateStunt(playerid, STUNT_WHEELIE, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- return 1;
- }
- if(++pStuntInfo[playerid][stunt_LQ] < 15.0) return 1; // Avoid false-positives
- pStuntInfo[playerid][stunt_ID] = STUNT_WHEELIE;
- pStuntInfo[playerid][stunt_Time] = GetTickCount();
- pStuntInfo[playerid][stunt_Dist] =
- pStuntInfo[playerid][stunt_LQ] = 0.0;
- OnPlayerStartStunt(playerid, STUNT_WHEELIE);
- return 1;
- }
- if(QX < -10.0) // Stoppie
- {
- if(pStuntInfo[playerid][stunt_ID] == STUNT_WHEELIE)
- {
- OnPlayerUpdateStunt(playerid, STUNT_STOPPIE, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- return 1;
- }
- if(++pStuntInfo[playerid][stunt_LQ] < 15.0) return 1; // Avoid false-positives
- pStuntInfo[playerid][stunt_ID] = STUNT_STOPPIE;
- pStuntInfo[playerid][stunt_Time] = GetTickCount();
- pStuntInfo[playerid][stunt_Dist] =
- pStuntInfo[playerid][stunt_LQ] = 0.0;
- OnPlayerStartStunt(playerid, STUNT_STOPPIE);
- return 1;
- }
- }
- if(pStuntInfo[playerid][stunt_ID] != STUNT_NONE) // Player finished stunt
- {
- FinishPlayerStunt(playerid, true);
- }
- pStuntInfo[playerid][stunt_LQ] = 0.0;
- }
- case VEHICLE_TYPE_PLANE: // Roll
- {
- // Check Roll
- if(!(-45.0 < QX < 45.0)) return 1; // Avoid false-positives
- GetVehicleRotation(vehicleid, QX, QY, QZ);
- if(QY > 20.0)
- {
- if(pStuntInfo[playerid][stunt_LQ] < 0.0) pStuntInfo[playerid][stunt_LQ] = QY; // Fix
- switch(pStuntInfo[playerid][stunt_ID])
- {
- case STUNT_NONE: // Start stunt
- {
- pStuntInfo[playerid][stunt_ID] = STUNT_ROLL_RIGHT;
- pStuntInfo[playerid][stunt_Time] = GetTickCount();
- pStuntInfo[playerid][stunt_Dist] = 0.0;
- OnPlayerStartStunt(playerid, STUNT_ROLL_RIGHT);
- }
- case STUNT_ROLL_RIGHT:
- {
- if(QY >= pStuntInfo[playerid][stunt_LQ]) OnPlayerUpdateStunt(playerid, STUNT_ROLL_RIGHT, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- else FinishPlayerStunt(playerid, false);
- }
- case STUNT_ROLL_LEFT:
- {
- if(QY <= pStuntInfo[playerid][stunt_LQ]) OnPlayerUpdateStunt(playerid, STUNT_ROLL_LEFT, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- else FinishPlayerStunt(playerid, false);
- }
- }
- pStuntInfo[playerid][stunt_LQ] = QY;
- return 1;
- }
- if(QY < -20.0)
- {
- if(pStuntInfo[playerid][stunt_LQ] > 0.0) pStuntInfo[playerid][stunt_LQ] = QY; // Fix
- switch(pStuntInfo[playerid][stunt_ID])
- {
- case STUNT_NONE: // Start stunt
- {
- pStuntInfo[playerid][stunt_ID] = STUNT_ROLL_LEFT;
- pStuntInfo[playerid][stunt_Time] = GetTickCount();
- pStuntInfo[playerid][stunt_Dist] = 0.0;
- OnPlayerStartStunt(playerid, STUNT_ROLL_LEFT);
- }
- case STUNT_ROLL_RIGHT:
- {
- if(QY >= pStuntInfo[playerid][stunt_LQ]) OnPlayerUpdateStunt(playerid, STUNT_ROLL_RIGHT, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- else FinishPlayerStunt(playerid, false);
- }
- case STUNT_ROLL_LEFT:
- {
- if(QY <= pStuntInfo[playerid][stunt_LQ]) OnPlayerUpdateStunt(playerid, STUNT_ROLL_LEFT, time, pStuntInfo[playerid][stunt_Dist]); // Update stunt info
- else FinishPlayerStunt(playerid, false);
- }
- }
- pStuntInfo[playerid][stunt_LQ] = QY;
- return 1;
- }
- if(STUNT_NONE < pStuntInfo[playerid][stunt_ID] < STUNT_INVALID) FinishPlayerStunt(playerid, true);
- pStuntInfo[playerid][stunt_ID] = STUNT_NONE;
- pStuntInfo[playerid][stunt_LQ] = QY;
- }
- case VEHICLE_TYPE_CAR: // Insane stunt
- {
- GetVehicleVelocity(vehicleid, vX, vY, vZ);
- MapAndreas_FindZ_For2DCoord(fX, fY, min_z);
- speed = VectorSize(vX, vY, vZ);
- if(fZ - min_z > 2.5 && speed > 0.2) // Insane stunt
- {
- switch(pStuntInfo[playerid][stunt_ID])
- {
- case STUNT_INSANE:
- {
- OnPlayerUpdateStunt(playerid, STUNT_INSANE, time, pStuntInfo[playerid][stunt_Dist]);
- return 1;
- }
- case STUNT_NONE:
- {
- if(++pStuntInfo[playerid][stunt_LQ] < 5.0) return 1;
- pStuntInfo[playerid][stunt_ID] = STUNT_INSANE;
- pStuntInfo[playerid][stunt_Time] = GetTickCount();
- pStuntInfo[playerid][stunt_Dist] = 0.0;
- OnPlayerStartStunt(playerid, STUNT_INSANE);
- return 1;
- }
- default: return FinishPlayerStunt(playerid, false);
- }
- return 1;
- }
- }
- }
- return 1;
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate stunt_OnPlayerUpdate
- forward OnPlayerUpdate(playerid);
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(pStuntInfo[playerid][stunt_ID] == STUNT_UNABLE) return 1;
- if(newstate == PLAYER_STATE_DRIVER && pStuntInfo[playerid][stunt_ID] != STUNT_NONE)
- {
- new Float:fX, Float:fY, Float:fZ, vehicleid = GetPlayerVehicleID(playerid);
- GetVehiclePos(vehicleid, fX, fY, fZ);
- pStuntInfo[playerid][stunt_ID] =
- pStuntInfo[playerid][stunt_Time] = 0;
- pStuntInfo[playerid][stunt_fX] = fX;
- pStuntInfo[playerid][stunt_fY] = fY;
- pStuntInfo[playerid][stunt_fZ] = fZ;
- pStuntInfo[playerid][stunt_Dist] = 0.0;
- return 1;
- }
- if(oldstate == PLAYER_STATE_DRIVER && pStuntInfo[playerid][stunt_ID] != STUNT_NONE)
- {
- OnPlayerFinishStunt(playerid, pStuntInfo[playerid][stunt_ID], GetTickCount() - pStuntInfo[playerid][stunt_Time], pStuntInfo[playerid][stunt_Dist], false);
- pStuntInfo[playerid][stunt_ID] =
- pStuntInfo[playerid][stunt_Time] = 0;
- pStuntInfo[playerid][stunt_fX] =
- pStuntInfo[playerid][stunt_fY] =
- pStuntInfo[playerid][stunt_fZ] =
- pStuntInfo[playerid][stunt_Dist] = 0.0;
- return 1;
- }
- return 1;
- }
- #if defined _ALS_OnPlayerStateChange
- #undef OnPlayerStateChange
- #else
- #define _ALS_OnPlayerStateChange
- #endif
- #define OnPlayerStateChange stunt_OnPlayerStateChange
- forward stunt_OnPlayerStateChange(playerid, newstate, oldstate);
- /* Functions */
- #define MAX_STUNT_NAME (18)
- #define TogglePlayerStunt(%1,%2) (pStuntInfo[playerid][stunt_ID] = STUNT_UNABLE + clamp(%1, 0, 1))
- #define IsPlayerStunting(%1) (STUNT_NONE < pStuntInfo[playerid][stunt_ID] < STUNT_INVALID)
- #define GetPlayerStunt(%1) (pStuntInfo[playerid][stunt_ID])
- #define GetPlayerStuntTime(%1) (GetTickCount() - pStuntInfo[playerid][stunt_Time])
- #define GetPlayerStuntDist(%1) (pStuntInfo[playerid][stunt_Dist])
- #if !defined GetModelType
- #define GetModelType(%1) {Stunt_ModelsType{%1 - 400}
- #endif
- stock FinishPlayerStunt(playerid, bool:success)
- {
- new ret = 1;
- if(STUNT_NONE < pStuntInfo[playerid][stunt_ID] < STUNT_INVALID) ret = 0;
- else OnPlayerFinishStunt(playerid, pStuntInfo[playerid][stunt_ID], GetTickCount() - pStuntInfo[playerid][stunt_Time], pStuntInfo[playerid][stunt_Dist], success);
- pStuntInfo[playerid][stunt_ID] =
- pStuntInfo[playerid][stunt_Time] = 0;
- pStuntInfo[playerid][stunt_fX] =
- pStuntInfo[playerid][stunt_fY] =
- pStuntInfo[playerid][stunt_fZ] =
- pStuntInfo[playerid][stunt_Dist] =
- pStuntInfo[playerid][stunt_LQ] = 0.0;
- return ret;
- }
- stock GetStuntName(stuntid)
- {
- new stunt[MAX_STUNT_NAME];
- switch(stuntid)
- {
- case STUNT_UNABLE: stunt = "Unable";
- case STUNT_WHEELIE: stunt = "Wheelie";
- case STUNT_STOPPIE: stunt = "Stoppie";
- case STUNT_TWO_WHEELS: stunt = "Two Wheels";
- case STUNT_ROLL_LEFT: stunt = "Roll Left";
- case STUNT_ROLL_RIGHT: stunt = "Roll Right";
- case STUNT_LOOP: stunt = "Loop";
- case STUNT_INSANE: stunt = "Insane";
- case STUNT_DRIFT: stunt = "Drift";
- default: stunt = "None";
- }
- return stunt;
- }
- /*
- - EOS
- */
Add Comment
Please, Sign In to add comment