bullet.lsl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // :CATEGORY:Weapon
  2. // :NAME:HammerThrower
  3. // :AUTHOR:Anonymous
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-18 15:38:54
  6. // :ID:372
  7. // :NUM:514
  8. // :REV:1
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // bullet
  12. // :CODE:
  13. // Project: Hammer thrower
  14. // Script: Bullet
  15. // Fly to target and rez hammer. Tell hammer AV name
  16. // Target named avatar with thor's hammer
  17. // rezzed by Launcher and passed avatar name on control channel
  18. // weights fly to 30m above avatar, then rez weight which is physical and drops onto them
  19. // they delete themselves after 10 minutes
  20. // ZZZ can be deleted by chat
  21. // ZZZ orbit around sim for 3 minutes if cannot find AV named
  22. // pass channel number offset in rez param
  23. //Simple OpenSource Licence (I am trusting you to be nice)
  24. //1. PLEASE SEND ME UPDATES TO THE CODE
  25. //2. You can do what you want with this code and object including selling it in other objects and so on.
  26. //You can sell it in closed source objects if you must, but please try to send any updates or
  27. //improvements back to me for possible inclusion in the main trunk of development.
  28. //3. You must always leave these instructions in any object created; notecard written; posting to
  29. //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
  30. //already requested!)
  31. //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
  32. //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
  33. //Thank you for your co-operation
  34. //sparti Carroll
  35. key k_owner;
  36. integer channel_bullet = 540123;
  37. integer channel_hammer = 477591;
  38. integer time_livefor = 120; // could live longer
  39. vector bomb_offset = <0,0,10>;
  40. string avname;
  41. set_position(vector targetpos) {
  42. // fly to position
  43. while (llVecDist(llGetPos(),targetpos) > 0.001) llSetPos(targetpos);
  44. }
  45. reset() {
  46. k_owner = llGetOwner();
  47. llSetAlpha(0.0,ALL_SIDES);
  48. }
  49. fly_to_av(vector avpos) {
  50. set_position(avpos + bomb_offset);
  51. }
  52. drop_hammer() {
  53. llRezObject("Hammer",llGetPos() + <0,0,0>,<0,0,0>,<0,0,1,PI>,1);
  54. llSay(channel_hammer,"attack^" + avname);
  55. }
  56. default
  57. {
  58. on_rez(integer start_param) {
  59. reset();
  60. llSetTimerEvent(time_livefor);
  61. channel_bullet += start_param;
  62. llListen(channel_bullet,"","","");
  63. }
  64. state_entry() {
  65. }
  66. listen(integer channel,string name,key id, string message) {
  67. list cmdline = llParseString2List(message,["^"],[]);
  68. string cmd = llList2String(cmdline,0);
  69. string par = llList2String(cmdline,1);
  70. if (cmd == "attack") {
  71. // par is the avatar name
  72. avname = par;
  73. llSensor(avname,NULL_KEY,AGENT,300,PI);
  74. } else if (cmd == "die") {
  75. llDie();
  76. }
  77. }
  78. no_sensor() {
  79. // fly around looking for them
  80. }
  81. sensor(integer num_detected) {
  82. vector avpos = llDetectedPos(0);
  83. fly_to_av(avpos);
  84. drop_hammer();
  85. llDie();
  86. }
  87. }