Casino

Jumpers -Explosive Pistol (credits to jumper for his hard wo

Nov 2nd, 2012
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.07 KB | None | 0 0
  1. #include <natives.h>
  2. #include <common.h>
  3. #include <strings.h>
  4. #include <types.h>
  5. #include <consts.h>
  6.  
  7.  
  8.  
  9. #define L1         0x4
  10. #define L2         0x5
  11. #define R1         0x6
  12. #define R2         0x7
  13. #define DPAD_UP    0x8
  14. #define DPAD_DOWN  0x9
  15. #define DPAD_LEFT  0xA
  16. #define DPAD_RIGHT 0xB
  17. #define START      0xC
  18. #define SELECT     0xD
  19. #define SQUARE     0xE
  20. #define TRIANGLE   0xF
  21. #define X          0x10
  22. #define CIRCLE     0x11
  23. #define STICK_L    0x12  // L3
  24. #define STICK_R    0x13  // R3
  25.  
  26.  
  27.  
  28. int justshot = 0;
  29. int wep;
  30. Object ObjectProjectile;
  31. int wepCheck;
  32. float prjX, prjY, prjZ, prjT, gcX, gcY, gcZ, gcrotX, gcrotY, gcrotZ, objrotX, objrotZ;
  33. Camera game_cam;
  34. float charX, charY, charZ , Object_X, Object_Y, Object_Z , dist;
  35. float expx,expy,expz;
  36. bool ChangeExpType=2; //Sets to rocket first
  37. bool exp=0;
  38.  
  39.  
  40. void Print(char *string,uint Time)
  41. {
  42.     PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", string, Time, 1);
  43. }
  44. void MainLoop()
  45. {
  46.    
  47.     GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &wepCheck);
  48.     if(wep == WEAPON_PISTOL)
  49.     {
  50.     //SET_TEXT_DROPSHADOW(1, 0, 0, 0, 255);
  51.     //SET_TEXT_SCALE(0.2f, 0.2f);
  52.     //DISPLAY_TEXT_WITH_STRING(0.832f, 0.069f, "STRING", "SPECAL");
  53.    
  54.     GET_GAME_CAM(&game_cam);
  55.     if (IS_CAM_ACTIVE(game_cam))
  56.     {
  57.         GET_CAM_ROT(game_cam, &gcrotX, &gcrotY, &gcrotZ);// used for setting the object rotation and for some weird trig stuff below
  58.         GET_CAM_POS(game_cam, &gcX, &gcY, &gcZ);// used for the spawn point of the object, because the player is offset while aiming
  59.         if (gcrotX < 0.0)// the range for cam rot is -180 to 180, to set object rot we need 0 to 360
  60.         {
  61.             objrotX = gcrotX + 360.0;
  62.         }
  63.         else
  64.         {
  65.             objrotX = gcrotX;
  66.         }
  67.         if (gcrotZ < 0.0)
  68.         {
  69.             objrotZ = gcrotZ + 360.0;
  70.         }
  71.         else
  72.         {
  73.             objrotZ = gcrotZ;
  74.         }
  75.         /*  the trig stuff below could possibly be replaced with vectors, I have no idea how to do that though.  *
  76.         *   I apologize if this is confusing, but if you want to change the distance from the game_cam that the  *
  77.         *   object is spawned, adjust "3.0" to your preference on the first and fourth lines.  Also prjT is the  *
  78.         *   adjacent side from the pitch calculation, its purpose is to be the tangent in the following 2 lines */
  79.         prjT = (3.0 * COS(gcrotX));       // adj side calculation to be used as a tangent below
  80.         prjX = gcX - (prjT * SIN(gcrotZ));// calculates how far to spawn the object from the game_cam on the X plane
  81.         prjY = gcY + (prjT * COS(gcrotZ));// calculates how far to spawn the object from the game_cam on the Y plane
  82.         prjZ = gcZ + (3.0 * SIN(gcrotX)); // calculates how far to spawn the object from the game_cam on the Z plane
  83.     }
  84.     }
  85. }
  86.  
  87. void Actions()
  88. {
  89.     GET_CURRENT_CHAR_WEAPON(GetPlayerPed(), &wep);
  90.     if((wep == WEAPON_PISTOL) && (IS_CHAR_SHOOTING(GetPlayerPed())))
  91.     {
  92.        
  93.         REQUEST_MODEL(0x8F2A7EB3);
  94.         while(!HAS_MODEL_LOADED(0x8F2A7EB3))
  95.         {
  96.             WAIT(0);
  97.         }
  98.        
  99.         CREATE_OBJECT(0x8F2A7EB3, prjX, prjY, prjZ, &ObjectProjectile, 1);
  100.         SET_OBJECT_VISIBLE(ObjectProjectile, 0);
  101.         MARK_MODEL_AS_NO_LONGER_NEEDED(0x8F2A7EB3);
  102.         if(DOES_OBJECT_EXIST(ObjectProjectile))
  103.         {
  104.             SET_OBJECT_AS_STEALABLE(ObjectProjectile, 1);
  105.             SET_OBJECT_ROTATION(ObjectProjectile, objrotX, 0.0, objrotZ);
  106.             SET_OBJECT_RECORDS_COLLISIONS(ObjectProjectile, true);
  107.             SET_OBJECT_DYNAMIC(ObjectProjectile, 1);
  108.             APPLY_FORCE_TO_OBJECT(ObjectProjectile, 1, 0.0, 90.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 1, 1);
  109.             WAIT(100);
  110.             justshot = 1;
  111.  
  112.         }
  113.     }
  114.    
  115. }
  116.  
  117. void ExplosionSelec(void)
  118. {
  119.     if(wep == WEAPON_PISTOL)
  120.     {
  121.         if((exp==0)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=1; exp=1; Print("EXPLOSION_MOLOTOV" , 200);}
  122.         else if((exp==1)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=2; exp=2; Print("EXPLOSION_ROCKET" , 200);}
  123.         else if((exp==2)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=3; exp=3; Print("EXPLOSION_HI_OCTANE" , 200); }
  124.         else if((exp==3)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=4; exp=4; Print("EXPLOSION_PETROL_PUMP" , 200);}
  125.         else if((exp==4)&& (IS_BUTTON_JUST_PRESSED(0,R1))) { ChangeExpType=5; exp=0; Print("EXPLOSION_SHIP_DESTROY" , 200);}
  126.        
  127.     }
  128. }
  129. void blowupobject()
  130. {
  131.     if(justshot==1)
  132.     {
  133.         if (HAS_OBJECT_COLLIDED_WITH_ANYTHING(ObjectProjectile ))  
  134.         {  
  135.             WAIT(200);
  136.             GET_OBJECT_COORDINATES(ObjectProjectile, &expx,&expy,&expz);
  137.             // press r1 to select explosives
  138.             if(ChangeExpType==1){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_MOLOTOV, 7.50, 1, 0, 0.7);   }
  139.             else if(ChangeExpType==2){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_ROCKET, 7.50, 1, 0, 0.7); }
  140.             else if(ChangeExpType==3){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_HI_OCTANE, 7.50, 1, 0, 0.7);}
  141.             else if(ChangeExpType==4){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_PETROL_PUMP, 7.50, 1, 0, 0.7); }
  142.             else if(ChangeExpType==5){ ADD_EXPLOSION(expx,expy,expz, EXPLOSION_SHIP_DESTROY, 7.50, 1, 0, 0.7); }
  143.             //cleanup object
  144.             if(DOES_OBJECT_EXIST(ObjectProjectile)) { DELETE_OBJECT(&ObjectProjectile);}
  145.             justshot = 0;      
  146.         }
  147.        
  148.     }
  149. }
  150. void main(void)
  151. {
  152.     THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  153.     while(true)
  154.     {
  155.         WAIT(0);
  156.         MainLoop();
  157.         Actions();
  158.         ExplosionSelec();
  159.         blowupobject();
  160.     }
  161. }
Advertisement
Add Comment
Please, Sign In to add comment