Advertisement
Eddlm

[SOURCECODE] Air condensation on wings

Oct 24th, 2017
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.90 KB | None | 0 0
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.IO;
  6. using System.Windows.Forms;
  7.  
  8.  
  9.  
  10. public class ScriptTest : Script
  11. {
  12.     string ScriptName = "PlaneAirCondensation";
  13.     string ScriptVer = "1.0";
  14.  
  15.     public ScriptTest()
  16.     {
  17.         Tick += OnTick;
  18.         KeyDown += OnKeyDown;
  19.         KeyUp += OnKeyUp;
  20.         LoadSettings(false);
  21.     }
  22.  
  23.     public static Vector3 LerpByDistance(Vector3 A, Vector3 B, float x)
  24.     {
  25.         Vector3 P = x * Vector3.Normalize(B - A) + A;
  26.         return P;
  27.     }
  28.     string core = "scr_recartheft";
  29.     string ptfx = "scr_wheel_burnout";
  30.  
  31.     float scale = 0.05f;
  32.  
  33.     float separation = 0.2f;
  34.  
  35.     float speed = 300;
  36.     void OnTick(object sender, EventArgs e)
  37.     {
  38.  
  39.  
  40.  
  41.         if(WasCheatStringJustEntered("pacupdate"))
  42.         {
  43.  
  44.             LoadSettings(true);
  45.             return;
  46.         }
  47.  
  48.         Vehicle v = Game.Player.Character.CurrentVehicle;
  49.  
  50.         if (CanWeUse(v) && v.Model.IsPlane&&v.HeightAboveGround>50)
  51.         {
  52.             // Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, core);
  53.  
  54.             //Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
  55.             // Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v,0,0,0, 0, 0, 0, 1f, 0, 1, 0);
  56.             // DisplayHelpTextThisFrame((Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, v, true).Y).ToString());
  57.  
  58.  
  59.             if (Math.Abs(Function.Call<Vector3>(Hash.GET_ENTITY_ROTATION_VELOCITY, v, true).Y) > 0.5f && v.Speed * 3.6f > speed)//Math.Abs(Function.Call<float>(Hash.GET_ENTITY_ROTATION_VELOCITY, v))>0.2f
  60.             {
  61.  
  62.  
  63.                 if (Function.Call<bool>(Hash.HAS_NAMED_PTFX_ASSET_LOADED, core))
  64.                 {
  65.                     Vector3 orientation = v.Rotation;
  66.  
  67.                     string left = "siren2";
  68.                     string right = "siren1";
  69.                     if (!v.HasBone("siren2"))
  70.                     {
  71.                         left = "wingtip_l";
  72.                         right = "wingtip_r";
  73.  
  74.                     }
  75.  
  76.  
  77.  
  78.                     Vector3 coord = Vector3.Zero;
  79.  
  80.                     if (v.HasBone(right))
  81.                     {
  82.                         coord = v.GetBoneCoord(v.GetBoneIndex(right));
  83.                     }
  84.                     else
  85.                     {
  86.                         coord = v.Position + (v.RightVector * v.Model.GetDimensions().X);
  87.                     }
  88.                     float i = 0.5f;
  89.                     while (i < v.Model.GetDimensions().Y / 3) //
  90.                     {
  91.                         i += separation;
  92.                         Vector3 localcoord = LerpByDistance(v.Position + (v.ForwardVector * 0), v.GetBoneCoord(v.GetBoneIndex(right)), i);
  93.                         localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, localcoord.X, localcoord.Y, localcoord.Z);
  94.                         Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
  95.                         Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v, localcoord.X, localcoord.Y, localcoord.Z, orientation.X, orientation.Y, orientation.Z, scale, 1, 1, 1);
  96.                     }
  97.  
  98.                     i = 0.5f;
  99.  
  100.                     if (v.HasBone(left))
  101.                     {
  102.                         coord = v.GetBoneCoord(v.GetBoneIndex(left));
  103.  
  104.                     }
  105.                     else
  106.                     {
  107.                         coord = v.Position - (v.RightVector * v.Model.GetDimensions().X);
  108.                     }
  109.                     while (i < v.Model.GetDimensions().Y / 3) //
  110.                     {
  111.                         i += separation;
  112.                         Vector3 localcoord = LerpByDistance(v.Position + (v.ForwardVector * 0), v.GetBoneCoord(v.GetBoneIndex(left)), i);
  113.                         localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, localcoord.X, localcoord.Y, localcoord.Z);
  114.                         Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, core);
  115.                         Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, ptfx, v, localcoord.X, localcoord.Y, localcoord.Z, orientation.X, orientation.Y, orientation.Z, scale, 1, 1, 1);
  116.                     }
  117.                     //scr_meth_pipe_smoke scr_familyscenem
  118.                     /*
  119.                     coord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, coord.X, coord.Y, coord.Z);
  120.  
  121.                     Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_familyscenem");
  122.                     Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_meth_pipe_smoke", v, coord.X, coord.Y, coord.Z, 0, 0, 0, 3f, 0, 1, 0);
  123.  
  124.  
  125.                 */
  126.  
  127.                     /*
  128.                     coord = v.GetBoneCoord(v.GetBoneIndex("siren1"));
  129.                     i = 0;
  130.                     while (i<10) //
  131.                     {
  132.                         i++;
  133.                         coord= LerpByDistance(coord, v.Position, 1f);
  134.                         Vector3 localcoord = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, v, coord.X, coord.Y, coord.Z);
  135.                         Function.Call(Hash._SET_PTFX_ASSET_NEXT_CALL, "scr_familyscenem");
  136.                         Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_ON_ENTITY, "scr_meth_pipe_smoke", v, localcoord.X, localcoord.Y, localcoord.Z, 0, 0, 0, 2f, 0, 1, 0);
  137.                     }
  138.                     */
  139.  
  140.  
  141.  
  142.  
  143.                 }
  144.                 else Function.Call(Hash.REQUEST_NAMED_PTFX_ASSET, core);
  145.  
  146.             }
  147.  
  148.         }
  149.     }
  150.     void OnKeyDown(object sender, KeyEventArgs e)
  151.     {
  152.  
  153.     }
  154.     void OnKeyUp(object sender, KeyEventArgs e)
  155.     {
  156.  
  157.     }
  158.     protected override void Dispose(bool dispose)
  159.     {
  160.         Function.Call(Hash._REMOVE_NAMED_PTFX_ASSET, core);
  161.        
  162.  
  163.         base.Dispose(dispose);
  164.     }
  165.  
  166.  
  167.  
  168.  
  169.  
  170.     public static bool WasCheatStringJustEntered(string cheat)
  171.     {
  172.         return Function.Call<bool>(Hash._0x557E43C447E700A8, Game.GenerateHash(cheat));
  173.     }
  174.  
  175.  
  176.     /// TOOLS ///
  177.     void LoadSettings(bool notify)
  178.     {
  179.         if (File.Exists(@"scripts\\PlaneAirCondensation.ini"))
  180.         {
  181.  
  182.             ScriptSettings config = ScriptSettings.Load(@"scripts\PlaneAirCondensation.ini");
  183.             core = config.GetValue<string>("SETTINGS", "PTFXAsset", "scr_recartheft");
  184.             ptfx = config.GetValue<string>("SETTINGS", "FX", "scr_wheel_burnout");
  185.             scale = config.GetValue<float>("SETTINGS", "Scale", 0.05f);
  186.             separation = config.GetValue<float>("SETTINGS", "Separation", 0.2f);
  187.             speed = config.GetValue<float>("SETTINGS", "MinSpeed", 300);
  188.  
  189.             if (notify) UI.Notify("~g~PTFXAsset: ~b~" + core);
  190.             if (notify) UI.Notify("~g~FX: ~b~" + ptfx);
  191.             if (notify) UI.Notify("~g~Scale: ~b~" + scale);
  192.             if (notify) UI.Notify("~g~Separation: ~b~" + separation);
  193.             if (notify) UI.Notify("~g~MinSpeed: ~b~" + speed);
  194.  
  195.            
  196.  
  197.         }
  198.         else
  199.         {
  200.             if (notify) WarnPlayer(ScriptName + " " + ScriptVer, "FILE NOT FOUND", "~r~PlaneAirCondensation.ini doesn't exist.");
  201.         }
  202.     }
  203.  
  204.     void WarnPlayer(string script_name, string title, string message)
  205.     {
  206.         Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "STRING");
  207.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, message);
  208.         Function.Call(Hash._SET_NOTIFICATION_MESSAGE, "CHAR_SOCIAL_CLUB", "CHAR_SOCIAL_CLUB", true, 0, title, "~b~" + script_name);
  209.     }
  210.  
  211.     bool CanWeUse(Entity entity)
  212.     {
  213.         return entity != null && entity.Exists();
  214.     }
  215.  
  216.     void DisplayHelpTextThisFrame(string text)
  217.     {
  218.         Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  219.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  220.         Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
  221.     }
  222.  
  223.  
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement