Explode.nas 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var V1_explode = props.globals.getNode("sim/multiplay/generic/int[1]");
  2. var V1_fire = props.globals.getNode("sim/multiplay/generic/int[2]");
  3. var V1_DetonateControl = 0; #used to check double Shift-D trigger
  4. V1_explode.setIntValue(0);
  5. V1_fire.setIntValue(0);
  6. setprop("/autopilot/settings/target-altitude-ft", 0);
  7. #automatic detonation on impact, with fire
  8. var listener_explode = setlistener("sim/crashed",
  9. func {
  10. if( getprop("sim/multiplay/generic/int[2]") < 1 and getprop("sim/crashed") ){
  11. V1_explode.setIntValue(1);
  12. V1_fire.setIntValue(1);
  13. settimer( func {
  14. V1_explode.setIntValue(0);} , 0.2);
  15. }
  16. }
  17. );
  18. #manual detonation, temporary fire
  19. var detonate = func {
  20. if ( V1_DetonateControl and getprop("sim/multiplay/generic/int[2]") < 1 ){
  21. setprop("controls/engines/engine/throttle", 0);
  22. setprop("/controls/flight/elevator", 1);
  23. setprop("/autopilot/settings/target-altitude-ft", -5000);
  24. V1_explode.setIntValue(1);
  25. V1_fire.setIntValue(2);
  26. settimer( func {
  27. V1_explode.setIntValue( 0);
  28. } , 0.2);
  29. settimer( func {
  30. V1_fire.setIntValue(3);
  31. } , 20);
  32. }
  33. else {
  34. V1_DetonateControl = 1;
  35. settimer( func {
  36. V1_DetonateControl = 0;
  37. } , 2);
  38. }
  39. }
  40. #reset the explosive load
  41. var rearm = func {
  42. V1_fire.setIntValue(0);
  43. }