Advertisement
Guest User

Untitled

a guest
May 15th, 2015
1,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.78 KB | None | 0 0
  1. #include "script.h"
  2. #include <random>
  3. #include <iostream>
  4. #include <string>
  5. #include <ctime>
  6.  
  7. #pragma warning(disable : 4244 4305) // double <-> float conversions
  8.  
  9. Ped playerPed;
  10. float x, y, z, sx, sy, sz;
  11. Any blip[20];
  12. Vector3 spawnPt, spawnPt1, spawnPt2, position;
  13. Vector3 vehPos;
  14. DWORD combatMdl, driverMdl;
  15. DWORD crusaderHash, tankHash, lazerHash, insurgentHash, barracksHash, annihilatorHash, insurgentGHash, buzzardHash, valkyrieHash, polHeliHash, savageHash;
  16. // 14 slots, if it's too much, so what ?
  17. Any toDel;
  18. Any mainVehicle[20];
  19. Any crua[20], crub[20], cruc[20], crud[20];
  20. bool wasWanted = false;
  21. bool firstStart = true;
  22. bool ready[20];
  23. int delFlag = 0;
  24. float dist;
  25. bool debugV = true;
  26.  
  27. bool isInTank = false;
  28. bool isInAir = false;
  29. //void set_spawn_points(Ped playerPed)
  30. //{
  31. //  spawnPt1.x = position.x + 200.0f;
  32. //  spawnPt1.y = position.y;
  33. //  spawnPt1.z = position.z + 4.0f;
  34. //  spawnPt2.x = position.x;
  35. //  spawnPt2.y = position.y + 150.0f;
  36. //  spawnPt1.z = position.z + 4.0f;
  37. //  x = position.x;
  38. //  y = position.y;
  39. //  z = position.z;
  40. //}
  41.  
  42. void debug_func()
  43. {
  44.     if (debugV) {
  45.         debugV = false;
  46.         DWORD vehHash = savageHash;
  47.         STREAMING::REQUEST_MODEL(GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_SPACE_ROCKET")); STREAMING::REQUEST_MODEL(driverMdl); STREAMING::REQUEST_MODEL(combatMdl); STREAMING::REQUEST_MODEL(vehHash); STREAMING::REQUEST_MODEL(GAMEPLAY::GET_HASH_KEY("WEAPON_COMBATMG"));
  48.         // WAITING FOR LOADING //
  49.         while (!STREAMING::HAS_MODEL_LOADED(driverMdl) && !STREAMING::HAS_MODEL_LOADED(combatMdl) && !STREAMING::HAS_MODEL_LOADED(vehHash) && !STREAMING::HAS_MODEL_LOADED(GAMEPLAY::GET_HASH_KEY("WEAPON_COMBATMG")) && !STREAMING::HAS_MODEL_LOADED((GAMEPLAY::GET_HASH_KEY("WEAPON_CARBINERIFLE"))))
  50.             WAIT(100);
  51.         mainVehicle[19] = VEHICLE::CREATE_VEHICLE(vehHash, position.x + 20.0f, position.y, position.z, ENTITY::GET_ENTITY_HEADING(playerPed), 0, true); WAIT(100);
  52.         crua[19] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[19], 3, combatMdl, -1, false, false);
  53.         PED::SET_PED_SHOOT_RATE(crua[19], 1);
  54.         AI::TASK_VEHICLE_SHOOT_AT_PED(crua[19], playerPed, 100.0f);
  55.         //AI::TASK_SHOOT_AT_COORD(crua[19], position.x + 20.0f, position.y, position.z, true, true);
  56.     }
  57. }
  58.  
  59. void spawnIns(int type, int spawnId)
  60. {
  61.     bool gIns = false;
  62.     DWORD vehHash;
  63.     DWORD weapHash;
  64.     weapHash = GAMEPLAY::GET_HASH_KEY("WEAPON_CARBINERIFLE");
  65.     ready[spawnId] = false;
  66.     // DYNAMIC SPAWN PTS
  67.     spawnPt = spawnPt2;
  68.     if (rand() % 11 > 5) spawnPt = spawnPt1;
  69.     spawnPt.z += 15.0f;
  70.     if (type > 4) spawnPt.z += 250.0f;
  71.     // CRUSADER
  72.     if (type == 1) vehHash = crusaderHash;
  73.     if (type == 2) { vehHash = insurgentHash; if (rand() % 2 == 1) { vehHash = insurgentGHash; gIns = true; } }
  74.     if (type == 3) vehHash = barracksHash;
  75.     // TANK
  76.     if (type == 4) vehHash = tankHash;
  77.     // AIR VEHICLES
  78.     // ANIHILATOR
  79.     if (type == 5) vehHash = annihilatorHash;
  80.     if (type == 5) weapHash = GAMEPLAY::GET_HASH_KEY("WEAPON_COMBATMG");
  81.     // LAZERS
  82.     if (type == 6) vehHash = lazerHash;
  83.     if (type == 7) vehHash = buzzardHash;
  84.     if (type == 8) vehHash = valkyrieHash;
  85.     if (type == 9) vehHash = savageHash;
  86.  
  87.     ////////// STREAMING AND SPAWNING //////////
  88.     // STREAMING REQUESTS //
  89.     STREAMING::REQUEST_MODEL(GAMEPLAY::GET_HASH_KEY("WEAPON_CARBINERIFLE")); STREAMING::REQUEST_MODEL(driverMdl); STREAMING::REQUEST_MODEL(combatMdl); STREAMING::REQUEST_MODEL(vehHash); STREAMING::REQUEST_MODEL(GAMEPLAY::GET_HASH_KEY("WEAPON_COMBATMG"));
  90.     // WAITING FOR LOADING //
  91.     while (!STREAMING::HAS_MODEL_LOADED(driverMdl) && !STREAMING::HAS_MODEL_LOADED(combatMdl) && !STREAMING::HAS_MODEL_LOADED(vehHash) && !STREAMING::HAS_MODEL_LOADED(GAMEPLAY::GET_HASH_KEY("WEAPON_COMBATMG")) && !STREAMING::HAS_MODEL_LOADED((GAMEPLAY::GET_HASH_KEY("WEAPON_CARBINERIFLE"))))
  92.         WAIT(100);
  93.  
  94.     // SPAWNING VEHICLE FIRST //
  95.     mainVehicle[spawnId] = VEHICLE::CREATE_VEHICLE(vehHash, spawnPt.x, spawnPt.y, spawnPt.z - 15.0f, ENTITY::GET_ENTITY_HEADING(playerPed) , 0, true); WAIT(100);
  96.     // WAITING 100ms
  97.     // SETTING ON GROUND AND CREATING PEDS [ONLY FOR GROUND VEHICLES!!]
  98.     if (type < 5) VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(mainVehicle[spawnId]);
  99.     if (type < 5) WAIT(2000);
  100.     WAIT(100);
  101.     // ALWAYS SPAWNING PILOT
  102.     crua[spawnId] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[spawnId], 3, driverMdl, -1, false, false);
  103.     // ONLY SPAWNING SECOND PERSONNEL IF NOT AIR VEHICLE AND NOT TANK
  104.     if (type < 4) { if (gIns){ crub[spawnId] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[spawnId], 3, combatMdl, 7, false, false); } else { crub[spawnId] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[spawnId], 3, combatMdl, 0, false, false); } }
  105.     // ONLY SPAWNING IF IS ANNI CREW OR GROUND VEHICLES
  106.     if (type == 5 || type < 4 || type == 8) cruc[spawnId] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[spawnId], 3, combatMdl, 1, false, false);
  107.     if (type == 5 || type < 4 || type == 8) crud[spawnId] = PED::CREATE_PED_INSIDE_VEHICLE(mainVehicle[spawnId], 3, combatMdl, 2, false, false);
  108.  
  109.     ////////// TASKS ON SPAWN //////////
  110.     if (type < 5) AI::TASK_VEHICLE_DRIVE_TO_COORD(crua[spawnId], mainVehicle[spawnId], position.x, position.y, position.z, 70.0f, 1, ENTITY::GET_ENTITY_MODEL(mainVehicle[spawnId]), 1, 0xC00AB, -1);
  111.     if (type == 6){ VEHICLE::SET_VEHICLE_FORWARD_SPEED(mainVehicle[spawnId], 80.0f); }
  112.     else { VEHICLE::SET_VEHICLE_FORWARD_SPEED(mainVehicle[spawnId], 10.0f); }
  113.     if (type == 5 || type == 7) VEHICLE::SET_HELI_BLADES_FULL_SPEED(mainVehicle[spawnId]);
  114.     // ADDING ARMOUR TO 3 CREW MEMBERS, PILOT NEVER HAS ARMOR.
  115.     if (type < 4) PED::ADD_ARMOUR_TO_PED(crub[spawnId], 100);
  116.     if (type == 5 || type < 4) PED::ADD_ARMOUR_TO_PED(cruc[spawnId], 100);
  117.     if (type == 5 || type < 4) PED::ADD_ARMOUR_TO_PED(crud[spawnId], 100);
  118.     // WEAPON DELAYED
  119.     WEAPON::GIVE_DELAYED_WEAPON_TO_PED(crua[spawnId], weapHash, 100, false);
  120.     if (type < 4) WEAPON::GIVE_DELAYED_WEAPON_TO_PED(crub[spawnId], weapHash, 100, false);
  121.     if (type == 5 || type < 4) WEAPON::GIVE_DELAYED_WEAPON_TO_PED(cruc[spawnId], weapHash, 100, false);
  122.     if (type == 5 || type < 4) WEAPON::GIVE_DELAYED_WEAPON_TO_PED(crud[spawnId], weapHash, 100, false);
  123.     if (type == 5) WAIT(2000);
  124.     if (gIns) {
  125.         WEAPON::SET_CURRENT_PED_WEAPON(crub[spawnId], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_TURRET_INSURGENT"), true);
  126.         WEAPON::SET_PED_INFINITE_AMMO(crub[spawnId], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_TURRET_INSURGENT"));
  127.         PED::SET_PED_SHOOT_RATE(crub[spawnId], 1000);
  128.     }
  129.     if (type == 9) {
  130.         STREAMING::REQUEST_MODEL(GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_LAZER"));
  131.         WEAPON::SET_CURRENT_PED_WEAPON(crua[spawnId], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_LAZER"), true);
  132.         WEAPON::SET_PED_INFINITE_AMMO(crua[spawnId], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_LAZER"));
  133.         PED::SET_PED_SHOOT_RATE(crua[spawnId], 100);
  134.         AI::TASK_VEHICLE_SHOOT_AT_PED(crua[spawnId], playerPed, 100.0f);
  135.     }
  136.     if (type == 6) {
  137.         VEHICLE::SET_VEHICLE_STEER_BIAS(mainVehicle[spawnId], 250.0f);
  138.         VEHICLE::SET_VEHICLE_FORWARD_SPEED(mainVehicle[spawnId], 200.0f);
  139.         ENTITY::SET_ENTITY_MAX_SPEED(mainVehicle[spawnId], 200.0f);
  140.         AI::TASK_LOOK_AT_ENTITY(crua[spawnId], playerPed, -1, 2048, 3);
  141.         AI::TASK_PLANE_CHASE(crua[spawnId], playerPed, 150.0f, 150.0f, 250.0f);
  142.         WAIT(1000);
  143.     }
  144.     if (type == 7) {
  145.         WEAPON::SET_CURRENT_PED_WEAPON(crua[spawnId], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BUZZARD"), true);
  146.         WEAPON::SET_PED_INFINITE_AMMO(crua[spawnId], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BUZZARD"));
  147.         PED::SET_PED_SHOOT_RATE(crua[spawnId], 2000);
  148.         AI::TASK_VEHICLE_SHOOT_AT_PED(crua[spawnId], playerPed, 100.0f);
  149.         AI::TASK_VEHICLE_CHASE(crua[spawnId], playerPed);
  150.     }
  151.     if (type == 8)
  152.     {
  153.         WEAPON::SET_CURRENT_PED_WEAPON(crud[spawnId], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BULLET"), true);
  154.         WEAPON::SET_PED_INFINITE_AMMO(crud[spawnId], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BULLET"));
  155.         PED::SET_PED_SHOOT_RATE(crud[spawnId], 1000);
  156.         AI::TASK_VEHICLE_SHOOT_AT_PED(crud[spawnId], playerPed, 100.0f);
  157.         WEAPON::SET_CURRENT_PED_WEAPON(cruc[spawnId], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BULLET"), true);
  158.         WEAPON::SET_PED_INFINITE_AMMO(cruc[spawnId], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BULLET"));
  159.         PED::SET_PED_SHOOT_RATE(cruc[spawnId], 1000);
  160.         AI::TASK_VEHICLE_SHOOT_AT_PED(cruc[spawnId], playerPed, 100.0f);
  161.     }
  162.     if (spawnId == 6) {
  163.         blip[spawnId] = UI::GET_BLIP_FROM_ENTITY(mainVehicle[spawnId]);
  164.         UI::REMOVE_BLIP(&blip[spawnId]);
  165.         blip[spawnId] = UI::ADD_BLIP_FOR_ENTITY(mainVehicle[spawnId]);
  166.         UI::SET_BLIP_SPRITE(blip[spawnId], 16);
  167.         UI::SET_BLIP_AS_MISSION_CREATOR_BLIP(blip[spawnId], false);
  168.         UI::SET_BLIP_FADE(blip[spawnId], false, false);
  169.     }
  170.     if (spawnId < 7) {
  171.         blip[spawnId] = UI::ADD_BLIP_FOR_ENTITY(mainVehicle[spawnId]);
  172.         UI::SET_BLIP_SPRITE(blip[spawnId], 8);
  173.         UI::SET_BLIP_FLASHES(blip[spawnId], true);
  174.     }
  175.         UI::SET_BLIP_AS_SHORT_RANGE(blip[spawnId], false);
  176.         UI::SET_BLIP_COLOUR(blip[spawnId], 1);
  177.     // BLIP ID 16 IS JET FIGHTER
  178.  
  179. }
  180.  
  181. void set_spawn_points()
  182. {
  183.     //// setting offset
  184.     //y = 300.0f;
  185.     //x = 300.0f;
  186.  
  187.     //// setting up spawn pts
  188.     //spawnPt1 = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, y, 0.0);
  189.     //spawnPt2 = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, x, 0.0, 0.0);
  190.     if (isInAir == false) {
  191.         float step = 0.0f;
  192.         if (rand() % 2 == 1){ step = -180.0f; }
  193.         else { step = 180.0f; }
  194.         spawnPt1 = position;
  195.         spawnPt1.x = position.x + step;
  196.         if (rand() % 2 == 1){ step = -180.0f; }
  197.         else { step = 180.0f; }
  198.         spawnPt2 = position;
  199.         spawnPt2.y = position.y + step;
  200.        
  201.  
  202.         if (rand() % 2 == 1){ step = -2.0f; }
  203.         else { step = 2.0f; }
  204.  
  205.         // set spawn points with a radius of 500
  206.         int maxStep = 50;
  207.         // finding spawnpt1 loop.
  208.         while (!PATHFIND::IS_POINT_ON_ROAD(spawnPt1.x, spawnPt1.y, spawnPt1.z, 0) && maxStep > 0)
  209.         {
  210.             spawnPt1.x += step;
  211.             maxStep--;
  212.         }
  213.         // resetting max step to 75
  214.         maxStep = 50;
  215.         if (rand() % 2 == 1){ step = -2.0f; }
  216.         else { step = 2.0f; }
  217.         // finding spawnpt2 loop.
  218.         while (!PATHFIND::IS_POINT_ON_ROAD(spawnPt2.x, spawnPt2.y, spawnPt2.z, 0) && maxStep > 0)
  219.         {
  220.             spawnPt2.y -= step;
  221.             maxStep--;
  222.         }
  223.         GAMEPLAY::GET_GROUND_Z_FOR_3D_COORD(spawnPt2.x, spawnPt2.y, spawnPt2.z + 100.0f, &spawnPt2.z);
  224.         GAMEPLAY::GET_GROUND_Z_FOR_3D_COORD(spawnPt1.x, spawnPt1.y, spawnPt1.z + 100.0f, &spawnPt1.z);
  225.     }
  226.     else {
  227.         float step = 0.0f;
  228.         if (rand() % 2 == 1){ step = -150.0f; }
  229.         else { step = 150.0f; }
  230.         spawnPt1 = position;
  231.         spawnPt2 = position;
  232.         spawnPt1.x = position.x + step;
  233.         if (rand() % 2 == 1){ step = -150.0f; }
  234.         else { step = 150.0f; }
  235.         spawnPt2.y = position.y + step;
  236.         spawnPt1.z = position.z + 150.0f;
  237.         spawnPt2.z = position.z + 150.0f;
  238.     }
  239.  
  240. }
  241.  
  242.  
  243. void update()
  244. {
  245.     if (firstStart){
  246.         // setting up models
  247.         driverMdl = GAMEPLAY::GET_HASH_KEY("S_M_Y_Marine_01");
  248.         combatMdl = GAMEPLAY::GET_HASH_KEY("S_M_Y_Marine_03");
  249.  
  250.         // setting up vehicles
  251.         buzzardHash = GAMEPLAY::GET_HASH_KEY("buzzard");
  252.         crusaderHash = GAMEPLAY::GET_HASH_KEY("crusader");
  253.         tankHash = GAMEPLAY::GET_HASH_KEY("rhino");
  254.         annihilatorHash = GAMEPLAY::GET_HASH_KEY("annihilator");
  255.         insurgentHash = GAMEPLAY::GET_HASH_KEY("insurgent2");
  256.         insurgentGHash = GAMEPLAY::GET_HASH_KEY("insurgent");
  257.         lazerHash = GAMEPLAY::GET_HASH_KEY("lazer");
  258.         barracksHash = GAMEPLAY::GET_HASH_KEY("barracks");
  259.         polHeliHash = GAMEPLAY::GET_HASH_KEY("polmav");
  260.         savageHash = GAMEPLAY::GET_HASH_KEY("savage");
  261.         valkyrieHash = GAMEPLAY::GET_HASH_KEY("valkyrie");
  262.         firstStart = false;
  263.         for (int i = 0; i <= 19; i++){ ready[i] = true; }
  264.     }
  265.  
  266.     // SPAWN ID SYSTEM ///////
  267.     // LAND VEHICLES :: 0-5 //
  268.     // TANK          :: 6   //
  269.     // ANNIHILATORS  :: 7-8 //
  270.     // JETS          :: 9-16//
  271.     //////////////////////////
  272.     Player player = PLAYER::PLAYER_ID();
  273.     playerPed = PLAYER::PLAYER_PED_ID();
  274.     Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
  275.     position = ENTITY::GET_ENTITY_COORDS(playerPed, 1);
  276.     WAIT(1000);
  277.     isInAir = false;
  278.     if (PED::IS_PED_IN_FLYING_VEHICLE(playerPed)) isInAir = true;
  279.     isInTank = false;
  280.     toDel = PED::GET_VEHICLE_PED_IS_IN(playerPed, false);
  281.     if (ENTITY::GET_ENTITY_MODEL(toDel) == tankHash) isInTank = true;
  282.  
  283.  
  284.     if (PLAYER::GET_PLAYER_WANTED_LEVEL(player) > 4)
  285.     {
  286.         PED::SET_AI_WEAPON_DAMAGE_MODIFIER(0.020f);
  287.         dist = 210.0f;
  288.         if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, false)) dist = 180.0f;
  289.         set_spawn_points();
  290.         //CLEANING UP
  291.         for (int i = 0; i <= 19; i++)
  292.         {
  293.             delFlag = 0;
  294.             vehPos = ENTITY::GET_ENTITY_COORDS(mainVehicle[i], false);
  295.             if (isInAir && !ENTITY::DOES_ENTITY_EXIST(mainVehicle[i])) ready[i] = true;
  296.             if (ENTITY::IS_ENTITY_DEAD(mainVehicle[i])) { ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&mainVehicle[i]); ready[i] = true; }
  297.             if (ENTITY::IS_ENTITY_DEAD(crua[i])){ ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crua[i]); UI::REMOVE_BLIP(&blip[i]); delFlag++; }
  298.             if (ENTITY::IS_ENTITY_DEAD(crub[i])){ ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crub[i]); UI::REMOVE_BLIP(&blip[i]); delFlag++; }
  299.             if (ENTITY::IS_ENTITY_DEAD(cruc[i])){ ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&cruc[i]); UI::REMOVE_BLIP(&blip[i]); delFlag++; }
  300.             if (ENTITY::IS_ENTITY_DEAD(crud[i])){ ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crud[i]); UI::REMOVE_BLIP(&blip[i]); delFlag++; }
  301.             // DELFLAG IS USED TO CHECK IF ALL THE CREW IS DEAD. IF IT'S THE CASE, THEN WE DELETE THE VEHICLE
  302.             // DELFLAG ONLY WORKS ON GROUND VEHICLES.
  303.             if (delFlag == 4){ ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&mainVehicle[i]); ready[i] = true; }
  304.             if (i < 7 || (i > 8 && i < 16)){
  305.                 if (i > 8 && i < 16) dist = 900.0f;
  306.                 if (!ENTITY::IS_ENTITY_AT_COORD(mainVehicle[i], position.x, position.y, position.z, dist, dist, dist * 1.5f, 0, 1, 0)){
  307.                     ENTITY::DELETE_ENTITY(&mainVehicle[i]);
  308.                     ENTITY::DELETE_ENTITY(&crua[i]);
  309.                     ENTITY::DELETE_ENTITY(&crub[i]);
  310.                     ENTITY::DELETE_ENTITY(&cruc[i]);
  311.                     ENTITY::DELETE_ENTITY(&crud[i]);
  312.                     ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&mainVehicle[i]);
  313.                     ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crua[i]);
  314.                     ready[i] = true;
  315.                     UI::REMOVE_BLIP(&blip[i]);
  316.                 }
  317.             }
  318.  
  319.         }
  320.  
  321.  
  322.         // SPAWN INDEX SYSTEM ////
  323.         // LAND VEHICLES :: 0-5 //
  324.         // TANK          :: 6   //
  325.         // ANNIHILATORS  :: 7-8 //
  326.         // JETS          :: 9-15//
  327.         // BUZZARD       :: 16  //
  328.         // VALKYRIE      :: 17  //
  329.         // SAVAGE        :: 18  //
  330.         //////////////////////////
  331.  
  332.         // SPAWN IDs
  333.         // CRUSADER    :: 1
  334.         // INSURGENT   :: 2
  335.         // BARRACKS    :: 3
  336.         // TANK        :: 4
  337.         // ANNIHILATOR :: 5
  338.         // LAZER       :: 6
  339.         // BUZZARD     :: 7
  340.  
  341.         // SPAWN SYSTEM V3.0
  342.         // SPAWNS 6 GROUND VEHICLES REGARDLESS. (3 CRUSADERS, 2 INSURGENTS, 1 BARRACKS)
  343.         // SPAWN NEW WAVE IF :
  344.         //      - VEHICLES AND CREW ARE DEAD OR DO NOT EXIST
  345.         //      - PLAYERS HAS LEFT THEM BEHIND
  346.         // DYNAMIC SPAWN FOR OTHER ENTITIES.
  347.         // TANK : 1 chance out of 200 per update
  348.         // ANNIHILATOR : 2 max
  349.         // LAZERS : only when in air and high in the sky
  350.         wasWanted = true;
  351.  
  352.         for (int i = 0; i <= 19; i++)
  353.         {
  354.             position = ENTITY::GET_ENTITY_COORDS(playerPed, 1);
  355.             set_spawn_points();
  356.             switch (i){
  357.             case 0:
  358.                 if (ready[i] && !isInAir) { spawnIns(1, i); }
  359.                 break;
  360.             case 1:
  361.                 if (ready[i] && !isInAir) { spawnIns(1, i); }
  362.                 break;
  363.             case 2:
  364.                 if (ready[i] && !isInAir) { spawnIns(1, i); }
  365.                 break;
  366.             case 3:
  367.                 if (ready[i] && !isInAir) { spawnIns(2, i); }
  368.                 break;
  369.             case 4:
  370.                 if (ready[i] && !isInAir) { spawnIns(2, i); }
  371.                 break;
  372.             case 5:
  373.                 if (ready[i] && !isInAir) { spawnIns(3, i); }
  374.                 break;
  375.             case 6:
  376.                 if (ready[i] && rand() % 75 == 0 && !isInAir) { spawnIns(4, i); }
  377.                 break;
  378.             case 7:
  379.                 // REMOVED ANIHILATOR FOR BALANCING PURPOSES
  380.                 //if (ready[i] && !isInAir) { spawnIns(5, i); }
  381.                 break;
  382.             case 8:
  383.                 if (ready[i] && !isInAir) { spawnIns(5, i); }
  384.                 break;
  385.             case 9:
  386.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  387.                 break;
  388.             case 10:
  389.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  390.                 break;
  391.             case 11:
  392.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  393.                 break;
  394.             case 12:
  395.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  396.                 break;
  397.             case 13:
  398.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  399.                 break;
  400.             case 14:
  401.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  402.                 break;
  403.             case 15:
  404.                 if (ready[i] && isInAir) { spawnIns(6, i); }
  405.                 break;
  406.             case 16:
  407.                 if (ready[i] && !isInAir) { spawnIns(7, i); }
  408.                 break;
  409.             case 17:
  410.                 if (ready[i] && !isInAir) { spawnIns(8, i); }
  411.                 break;
  412.             case 18:
  413.                 if (ready[i] && !isInAir && isInTank) { spawnIns(9, i); }
  414.                 break;
  415.             }
  416.  
  417.         }
  418.  
  419.         if (!ENTITY::IS_ENTITY_DEAD(mainVehicle[16])) {
  420.             WEAPON::SET_CURRENT_PED_WEAPON(crua[16], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BUZZARD"), true);
  421.             WEAPON::SET_PED_INFINITE_AMMO(crua[16], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLAYER_BUZZARD"));
  422.             PED::SET_PED_SHOOT_RATE(crua[16], 2000);
  423.             if (ENTITY::IS_ENTITY_A_VEHICLE(playerPed) && rand() % 11 == 5 ) {
  424.                 WEAPON::SET_CURRENT_PED_WEAPON(crua[16], GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLANE_ROCKET"), true);
  425.                 WEAPON::SET_PED_INFINITE_AMMO(crua[16], true, GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_PLANE_ROCKET"));
  426.                 PED::SET_PED_SHOOT_RATE(crua[16], 1);
  427.             }
  428.            
  429.             AI::TASK_VEHICLE_SHOOT_AT_PED(crua[16], playerPed, 100.0f);
  430.         }
  431.  
  432.         if (isInAir)
  433.         {
  434.             for (int i = 9; i <= 15; i++) {
  435.                 if (mainVehicle[i], position.x, position.y, position.z, 250.0f, 250.0f, 250.0f, 0, 1, 0) { ENTITY::DELETE_ENTITY(&mainVehicle[i]); ENTITY::DELETE_ENTITY(&crua[i]); }
  436.                 //AI::TASK_VEHICLE_CHASE(crua[i], playerPed);
  437.                 //VEHICLE::SET_VEHICLE_FORWARD_SPEED(mainVehicle[i], 80.0f);
  438.             }
  439.         }
  440.  
  441.         GAMEPLAY::SET_DISPATCH_TIME_BETWEEN_SPAWN_ATTEMPTS_MULTIPLIER(playerPed, 20.0f);
  442.     }
  443.     else {
  444.         if (wasWanted){
  445.             PED::SET_AI_WEAPON_DAMAGE_MODIFIER(1.0f);
  446.             VEHICLE::SET_VEHICLE_MODEL_IS_SUPPRESSED(polHeliHash, false);
  447.             VEHICLE::SET_VEHICLE_MODEL_IS_SUPPRESSED(GAMEPLAY::GET_HASH_KEY("police3"), false);
  448.             GAMEPLAY::SET_DISPATCH_TIME_BETWEEN_SPAWN_ATTEMPTS_MULTIPLIER(playerPed, 1.0f);
  449.             wasWanted = false;
  450.             for (int i = 0; i <= 19; i++)
  451.             {
  452.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&mainVehicle[i]);
  453.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crua[i]);
  454.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crub[i]);
  455.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&cruc[i]);
  456.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crud[i]);
  457.                 AI::CLEAR_PED_TASKS_IMMEDIATELY(crua[i]);
  458.                 AI::CLEAR_PED_TASKS_IMMEDIATELY(crub[i]);
  459.                 AI::CLEAR_PED_TASKS_IMMEDIATELY(cruc[i]);
  460.                 AI::CLEAR_PED_TASKS_IMMEDIATELY(crud[i]);
  461.                 UI::REMOVE_BLIP(&blip[i]);
  462.             }
  463.             for (int i = 9; i <= 15; i++) {
  464.                 ENTITY::DELETE_ENTITY(&mainVehicle[i]);
  465.                 ENTITY::DELETE_ENTITY(&crua[i]);
  466.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&crua[i]);
  467.                 ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&mainVehicle[i]);
  468.             }
  469.         }
  470.         // USE THIS TO TRY FUNKY STUFF
  471.         //debug_func();
  472.     }
  473. }
  474.  
  475.  
  476.  
  477.  
  478. void main()
  479. {
  480.     while (true)
  481.     {
  482.         update();
  483.     }
  484. }
  485.  
  486. void ScriptMain()
  487. {
  488.     srand(GetTickCount());
  489.     main();
  490. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement