aimer.lsl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // :CATEGORY:Tour
  2. // :NAME:TourCopter
  3. // :AUTHOR:Ferd Frederix
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-18 15:39:08
  6. // :ID:909
  7. // :NUM:1287
  8. // :REV:1
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // Tour
  12. // :CODE:
  13. // ______ _ ______ _ _
  14. // | ___| | | | ___| | | (_)
  15. // | |_ ___ _ __ __| | | |_ _ __ ___ __| | ___ _ __ ___ __
  16. // | _/ _ \ '__/ _` | | _| '__/ _ \/ _` |/ _ \ '__| \ \/ /
  17. // | || __/ | | (_| | | | | | | __/ (_| | __/ | | |> <
  18. // \_| \___|_| \__,_| \_| |_| \___|\__,_|\___|_| |_/_/\_\
  19. //
  20. // fred@mitsi.com
  21. // tour copter script
  22. // aimer 1 of 3
  23. //
  24. //Revisions:
  25. // 1/28/2010 initial release
  26. key gunnerId = NULL_KEY;
  27. integer debug = 1;
  28. Gun(string str, key ShootAt )
  29. {
  30. if (str == "gun-aim")
  31. {
  32. gunnerId = ShootAt;
  33. if (ShootAt == NULL_KEY)
  34. {
  35. llSensorRemove();
  36. llSetLocalRot(<0.00000, 0.70711, 0.00000, 0.70711>);
  37. }
  38. else
  39. {
  40. llSensorRepeat("", "", AGENT, 20.0, TWO_PI, 0.1); // aim at an avatar
  41. }
  42. }
  43. else if (str == "gun-stop")
  44. {
  45. llSensorRemove();
  46. llSetLocalRot(<0.00000, 0.70711, 0.00000, 0.70711>);
  47. }
  48. else if (str == "pilot")
  49. {
  50. gunnerId = ShootAt;
  51. }
  52. }
  53. default
  54. {
  55. state_entry()
  56. {
  57. llSetLocalRot(<0.00000, 0.70711, 0.00000, 0.70711>); // point down.
  58. if (debug)
  59. {
  60. Gun("gun-aim", llGetOwner());
  61. }
  62. }
  63. link_message(integer sender_num, integer num, string str, key id)
  64. {
  65. Gun(str,id);
  66. }
  67. no_sensor()
  68. {
  69. gunnerId = NULL_KEY;
  70. llSensorRemove();
  71. llSetLocalRot(<0.00000, 0.70711, 0.00000, 0.70711>);
  72. }
  73. sensor(integer num_detected)
  74. {
  75. integer i;
  76. for (i = 0; i < num_detected; i++)
  77. {
  78. if (llDetectedKey(i) != gunnerId)
  79. {
  80. // rotation headRot = llDetectedRot(0) * llEuler2Rot(<0,0,DEG_TO_RAD * 180>);
  81. //llSay(0, (string)(llRot2Euler(headRot) * RAD_TO_DEG));
  82. //headRot = llEuler2Rot(<0.0, DEG_TO_RAD * 180.0, 0.0>) * llEuler2Rot(<headRot.y, 0.0, headRot.z>);
  83. //llSay(0, (string)(llRot2Euler(llDetectedRot(0)) * RAD_TO_DEG));
  84. llSetLocalRot(<0.00000, 0.70711, 0.00000, 0.70711> * ((llDetectedRot(i) / llGetRootRotation()) / llGetRootRotation()));
  85. llSleep(0.5);
  86. }
  87. }
  88. }
  89. }