Skip to content

Instantly share code, notes, and snippets.

@Tustin
Last active May 28, 2016 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tustin/c0348fc8e9cf082a0fe05450d390ecc1 to your computer and use it in GitHub Desktop.
Save Tustin/c0348fc8e9cf082a0fe05450d390ecc1 to your computer and use it in GitHub Desktop.
GTAV singleplayer JB700 recreation
int scene = -1;
int spikes[3];
void jb700_eject()
{
Vehicle veh = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), 1);
REQUEST_AMBIENT_AUDIO_BANK("CAR_STEAL_3_SCREAM", 0);
REQUEST_AMBIENT_AUDIO_BANK("CAR_THEFT_MOVIE_LOT", 0);
REQUEST_ANIM_DICT("misscarsteal4@actress");
if (IS_CONTROL_JUST_PRESSED(2, 0xCD) && GET_ENTITY_MODEL(GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), 1)) == GET_HASH_KEY("jb700"))
{
if (!IS_ENTITY_UPSIDEDOWN(veh) && !IS_SYNCHRONIZED_SCENE_RUNNING(scene))
{
scene = CREATE_SYNCHRONIZED_SCENE(0, 0, 0, 0, 0, 0, 2);
SET_SYNCHRONIZED_SCENE_LOOPED(scene, 0);
_0x2DE48DA1(scene, 0);
ATTACH_SYNCHRONIZED_SCENE_TO_ENTITY(scene, veh, _0xE4ECAC22(veh, "seat_pside_f"));
SET_ENTITY_NO_COLLISION_ENTITY(PLAYER_PED_ID(), veh, 1);
TASK_SYNCHRONIZED_SCENE(PLAYER_PED_ID(), scene, "misscarsteal4@actress", "eject_girl", 1000, -1000, 129, 512, 1148846080, 0);
SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(PLAYER_PED_ID(), 1);
TASK_LOOK_AT_ENTITY(PLAYER_PED_ID(), PLAYER_PED_ID(), 2000, 2048, 3);
START_AUDIO_SCENE("CAR_3_ACTIVATE_EJECTOR_SEAT");
SET_AUDIO_FLAG("AllowScriptedSpeechInSlowMo", 1);
SET_AUDIO_FLAG("DisableAbortConversationForRagdoll", 1);
SET_AUDIO_FLAG("DisableAbortConversationForDeathAndInjury", 1);
PLAY_SOUND_FROM_ENTITY(-1, "CAR_THEFT_MOVIE_LOT_EJECT_SEAT", veh, 0, 0, 0);
}
}
}
int spike_drop_tick = -1, spike_press_tick = 0, spike_delay = 500;
void jb700_spikes()
{
Vehicle veh = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), 1);
Vector3 offset;
int spike_count = 0;
if (IS_CONTROL_JUST_PRESSED(2, 0xCB) && GET_GAME_TIMER() - spike_press_tick > spike_delay)
{
while (spike_count < 2)
{
if (DOES_ENTITY_EXIST(spikes[spike_count]))
{
SET_ENTITY_AS_MISSION_ENTITY(spikes[spike_count], 0, 1);
DELETE_OBJECT(&spikes[spike_count]);
}
spike_count++;
}
spike_drop_tick = GET_GAME_TIMER();
}
if (spike_drop_tick != 0)
{
if (GET_GAME_TIMER() - spike_drop_tick > 100)
{
if (!DOES_ENTITY_EXIST(spikes[0])){
offset = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, 0, -1.2f, -0.4f);
spikes[0] = CREATE_OBJECT(GET_HASH_KEY("prop_tyre_spike_01"), offset.x, offset.y, offset.z, 1, 0, 0);
SET_ENTITY_NO_COLLISION_ENTITY(spikes[0], veh, 1);
PLAY_SOUND_FROM_ENTITY(-1, "CAR_THEFT_MOVIE_LOT_DROP_SPIKES", veh, 0, 0, 0);
}
}
if (GET_GAME_TIMER() - spike_drop_tick > 200)
{
if (!DOES_ENTITY_EXIST(spikes[1])){
offset = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, 0.1f, -1.1f, -0.4f);
spikes[1] = CREATE_OBJECT(GET_HASH_KEY("prop_tyre_spike_01"), offset.x, offset.y, offset.z, 1, 0, 0);
SET_ENTITY_NO_COLLISION_ENTITY(spikes[1], veh, 1);
}
}
if (GET_GAME_TIMER() - spike_drop_tick > 300)
{
if (!DOES_ENTITY_EXIST(spikes[2])){
offset = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, -0.1f, -1, -0.34f);
spikes[2] = CREATE_OBJECT(GET_HASH_KEY("prop_tyre_spike_01"), offset.x, offset.y, offset.z, 1, 0, 0);
SET_ENTITY_NO_COLLISION_ENTITY(spikes[2], veh, 1);
}
spike_drop_tick = 0;
}
}
spike_count = 0;
while (spike_count < 2)
{
if (DOES_ENTITY_EXIST(spikes[spike_count]))
{
if (!DOES_ENTITY_HAVE_PHYSICS(spikes[spike_count]))
{
ACTIVATE_PHYSICS(spikes[spike_count]);
SET_ENTITY_DYNAMIC(spikes[spike_count], 1);
}
}
spike_count++;
}
}
void jb700_spikes_listener()
{
for (int i = 0; i < 2; i++)
{
if (DOES_ENTITY_EXIST(spikes[i]))
{
Vector3 spike_coords = GET_ENTITY_COORDS(spikes[i], 1);
Vehicle veh = GET_CLOSEST_VEHICLE(spike_coords.x, spike_coords.y, spike_coords.z, 20, 0, 100359);
if (DOES_ENTITY_EXIST(veh) && !IS_VEHICLE_TYRE_BURST(veh, 0, 0))
{
SET_VEHICLE_TYRE_BURST(veh, 0, 1, 1000);
SET_VEHICLE_TYRE_BURST(veh, 1, 1, 1000);
PLAY_SOUND_FROM_ENTITY(-1, "CAR_STEAL_3_AGENT_TYRE_BURST", veh, "CAR_STEAL_3_AGENT", 0, 0);
}
}
}
}
void jb700_shoot()
{
Vehicle veh = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), 1);
DISABLE_CONTROL_ACTION(0, 64);
if (IS_CONTROL_PRESSED(2, 0xc8) || IS_CONTROL_JUST_PRESSED(2, 0xc8))
{
Vehicle veh = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(), 0);
int distance = 250;
Hash hash = GET_HASH_KEY("WEAPON_ASSAULTRIFLE");
float speed = 1500.0f;
Vector3 coords1 = { 0.6f, 0.6707f, 0.3711f };
Vector3 getcoords1 = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, coords1.x, coords1.y, coords1.z);
Vector3 coords2 = { -0.6f, 0.6707f, 0.3711f };
Vector3 getcoords2 = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, coords2.x, coords2.y, coords2.z);
Vector3 coords3 = { 0.6f, 5.0707f, 0.3711f };
Vector3 getcoords3 = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, coords3.x, coords3.y, coords3.z);
Vector3 coords4 = { -0.6f, 5.0707f, 0.3711f };
Vector3 getcoords4 = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, coords4.x, coords4.y, coords4.z);
Vector3 final1 = { getcoords1.x, getcoords1.y, getcoords1.z };
Vector3 final2 = { getcoords2.x, getcoords2.y, getcoords2.z };
Vector3 final3 = { getcoords3.x, getcoords3.y, getcoords3.z };
Vector3 final4 = { getcoords4.x, getcoords4.y, getcoords4.z };
SHOOT_SINGLE_BULLET_BETWEEN_COORDS(final1.x, final1.y, final1.z, final3.x, final3.y, final3.z, distance, 0, hash, PLAYER_PED_ID(), 1, 1, speed);
SHOOT_SINGLE_BULLET_BETWEEN_COORDS(final2.x, final2.y, final2.z, final4.x, final4.y, final4.z, distance, 0, hash, PLAYER_PED_ID(), 1, 1, speed);
PLAY_SOUND_FROM_ENTITY(-1, "JB700_GUN_PLAYER_MASTER", veh, 0, 0, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment