Kane_Red

Untitled

Jan 12th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.88 KB | None | 0 0
  1. float timefullhealth; // the time when the health will be full
  2. float timefullenergy;
  3. string OWNER;
  4. string KK;
  5. string KO;
  6. string KS;
  7. integer mychan = 0;
  8. string KF="";
  9. integer status = 0;
  10. integer str = 10;
  11. integer sta = 20;
  12. integer agi = 10;
  13. integer int = 10;
  14. float armor_reduction = 1;
  15. integer maxhealth = 0;
  16. float regen_per_sec = 0.2;
  17. float dmg_per_sec = 0;
  18. float lastcall;
  19. integer settings=0;
  20. string label="";
  21. float f_stun = 0;
  22. float f_bleed = 0;
  23. float f_bleed_dps;
  24. float f_poison = 0;
  25. float f_poison_dps;
  26.  
  27. updateLabel() {
  28. label = "";
  29. if (settings & 8) label += "(S) ";
  30. if (settings & 2) label += "(Arena) ";
  31. if (settings & 4) label += "(AFK) ";
  32. if (settings & 32) label += "(OOC) ";
  33.  
  34. armor_reduction = 1;
  35. if ((settings & 448) == 448) { label += "(H)"; armor_reduction = 0.5;} else
  36. if ((settings & 192) == 192) { label += "(M)"; armor_reduction = 0.7;} else
  37. if (settings & 64) { label += "(L)"; armor_reduction = 0.8;}
  38.  
  39. if (label != "") label += "\n";
  40. }
  41. saveSettings() {
  42. llHTTPRequest("http://66.103.230.111/sys/meter_savesettings.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +(string)settings);
  43. }
  44.  
  45. integer getHealth() {
  46. float now = llGetTime();
  47. timefullhealth += ((now - lastcall)*dmg_per_sec)/regen_per_sec;
  48. lastcall = now;
  49.  
  50. integer currentHealth = maxhealth - llRound((timefullhealth - now)*regen_per_sec); // calculates the current health,
  51. // if we know when it will be full then we know how much health is missing
  52. // couse there is 10 health missing per 2seconds
  53. if (currentHealth >maxhealth) currentHealth = maxhealth;
  54. if (currentHealth <0) currentHealth = 0;
  55. return currentHealth;
  56. }
  57.  
  58.  
  59. integer getEnergy() {
  60. integer currentEnergy = 100 - llRound(timefullenergy - llGetTime()); // calculates the current health,
  61. // if we know when it will be full then we know how much health is missing
  62. // couse there is 10 health missing per 2seconds
  63. if (currentEnergy >100) currentEnergy = 100;
  64. if (currentEnergy <0) currentEnergy = 0;
  65. return currentEnergy;
  66. }
  67.  
  68.  
  69.  
  70. init() {
  71. OWNER = llKey2Name(llGetOwner());
  72. llSetObjectName("["+llGetScriptName()+"] "+OWNER);
  73. mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
  74.  
  75. llSetTimerEvent(2);
  76. KK = llUnescapeURL("%E2%96%93");
  77. KO = llUnescapeURL("%E2%96%91");
  78. KS = llUnescapeURL("%E2%98%BA");
  79. KF = KK+KK+KK+KK+KK+KK+KK+KK+KK+KK+KK;
  80. llListen(mychan, "", NULL_KEY, "");
  81. llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
  82.  
  83. lastcall = llGetTime();
  84.  
  85. llMessageLinked(LINK_ALL_CHILDREN, 1, "", NULL_KEY);
  86. // download avatar attributes
  87. llHTTPRequest("http://66.103.230.111/sys/meter.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" + OWNER +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName());
  88. }
  89.  
  90.  
  91. default
  92. {
  93. state_entry()
  94. {
  95.  
  96. init();
  97. }
  98.  
  99. attach(key who) {
  100. if (who != NULL_KEY) {
  101. llResetScript();
  102. } else {
  103. integer currentHealth = getHealth();
  104. if (currentHealth <70) llShout(0, "/me DETACHED METER!");
  105. }
  106. }
  107.  
  108. run_time_permissions(integer perm) { // permissions dialog answered
  109. if (perm & PERMISSION_TAKE_CONTROLS) { // we got a yes
  110. llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON |CONTROL_ML_LBUTTON, TRUE,FALSE);
  111. }
  112. }
  113.  
  114.  
  115. http_response(key request_id, integer status, list metadata, string body) {
  116. list tmp = llParseString2List(body,["|"],[]);
  117. integer RCODE = llList2Integer(tmp,1);
  118. if (llStringLength(llList2String(tmp,0)) > 1) llOwnerSay(llList2String(tmp,0)); // pass message
  119. if (RCODE != 1) {
  120. if (RCODE == 10) {
  121. //settings saved we can Reset
  122. return;
  123. }
  124.  
  125. state off;
  126. }
  127.  
  128. str = llList2Integer(tmp,2);
  129. agi = llList2Integer(tmp,3);
  130. sta = llList2Integer(tmp,4);
  131. int = llList2Integer(tmp,5);
  132. settings = llList2Integer(tmp,6);
  133.  
  134. settings = ~((~settings) |448); // clear armor bits
  135. llWhisper(mychan-5,"p"); // pings the armor channel to see if there is any attached
  136. updateLabel();
  137.  
  138. maxhealth = sta*5;
  139. regen_per_sec = 0.2;
  140.  
  141. llOwnerSay("Str:"+(string)str+" Agi:"+(string)agi+" Sta:"+(string)sta+" Int:"+(string)int);
  142. tmp = [];
  143. llWhisper(mychan-20,"3,"+(string)llGetTime()+","+(string)maxhealth);
  144.  
  145. settings = ~((~settings) |8); // clear shield bit
  146. llWhisper(mychan-1,"1"); // sheath all weapons
  147. llWhisper(mychan-10,"2"); // sheath shield
  148. }
  149.  
  150. timer() {
  151. float now = llGetTime();
  152.  
  153.  
  154. if (f_bleed != 0) if (f_bleed<now) { f_bleed=0; dmg_per_sec -= f_bleed_dps;}
  155. if (f_poison != 0) if (f_poison<now) { f_poison=0; dmg_per_sec -= f_poison_dps;}
  156. if (f_stun != 0) if (f_stun<now) { f_stun=0; llReleaseControls(); llStopAnimation("a_stun"); llStopAnimation("a_bash");}
  157.  
  158. integer currentHealth = getHealth();
  159. integer currentEnergy = getEnergy();
  160.  
  161. if ( (currentHealth > 0) && (status == 1)) {
  162. // get up no more down
  163. llReleaseControls();
  164. llMessageLinked(LINK_ALL_CHILDREN, 1, "", NULL_KEY);
  165. status = 0;
  166.  
  167. if (settings & 2) {
  168. llShout(0,"/me is in arena mode and reseted automaticaly!");
  169. timefullhealth = now;
  170. timefullenergy = now;
  171. currentHealth = maxhealth;
  172. currentEnergy = 100;
  173. } else {
  174. llShout(0,"/me rised up from the dirt");
  175. }
  176.  
  177. llStopAnimation("a_dead");
  178.  
  179.  
  180.  
  181.  
  182. }
  183.  
  184.  
  185. if ((currentHealth ==0) && (status != 1)) {
  186. status = 1;
  187.  
  188. if (settings & 2) { // arena
  189. timefullhealth = now + 500 + 5;
  190. timefullenergy = now + 100 + 5;
  191. } else {
  192. maxhealth = maxhealth;
  193. timefullhealth = now + 500 + 300;
  194. timefullenergy = now + 100 + 300;
  195. }
  196.  
  197.  
  198. settings = ~((~settings) |8); // clear shield bit
  199. llMessageLinked(LINK_ALL_CHILDREN, 2, "", NULL_KEY);
  200. llWhisper(mychan-1,"1"); // sheath all weapons
  201. llWhisper(mychan-10,"2"); // sheath shield
  202. llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
  203. llShout(0,"/me has been crushed");
  204. llStartAnimation("a_dead");
  205. }
  206. if (currentHealth ==0) {
  207. integer remainingsec = llRound(timefullhealth - llGetTime() -500);
  208. llSetText("knockout "+(string)remainingsec+"sec. remaining", <1,0.2,0>, 1);
  209. } else {
  210.  
  211.  
  212.  
  213. if ((timefullhealth > now) || (timefullenergy > now)) {
  214.  
  215. llWhisper(mychan-20,"1,"+(string)currentHealth+","+(string)currentEnergy);
  216.  
  217. integer points = llRound((float)currentEnergy/10);
  218. string ss="";
  219. if (points != 0) ss = llGetSubString(KF,0,points);
  220.  
  221. float color = (float)currentHealth / 100;
  222.  
  223. llSetText(label+ss+"\nH:"+(string)currentHealth + "% E:"+(string)currentEnergy+"%", <1-color,color,0>, 1);
  224.  
  225. } else {
  226. llSetText(label+KS,<0.3,1,0.3>,1);
  227. }
  228.  
  229.  
  230.  
  231.  
  232. }
  233.  
  234.  
  235.  
  236. }
  237.  
  238.  
  239. listen(integer channel, string name, key id, string message)
  240. {
  241. // float ds = llGetTime();
  242. integer attack = (integer)message;
  243.  
  244. if (attack & 1073741824) { // settings
  245.  
  246. if ((attack & 2013265920) == 2013265920) {llStopAnimation("a_dead"); if (settings & 2) llShout(0,"/me reseted their meter in arena mode!"); else llShout(0,"/me RESETED THEIR METER!"); llResetScript(); }
  247.  
  248. integer bit = attack & 4294967295; // strips the system bits
  249. if (attack & 536870912) { // forcing the bit to
  250. if (attack & 268435456) // turn on
  251. settings = settings | bit;
  252. else // turn off
  253. settings = ~((~settings) | bit);
  254. } else { // switching the bit
  255. settings = settings ^ bit;
  256. }
  257. if (!(bit & 8) && !(bit & 448)) saveSettings(); // wont save if we just pull shield
  258. updateLabel();
  259. return;
  260. }
  261.  
  262.  
  263. float now = llGetTime();
  264.  
  265. float reduction = ((attack&65535)>>9) *armor_reduction; // TODO: -str*0.2 the attack is blocked
  266. integer angle = attack&511;
  267.  
  268. if (status != 0) return; // our target is down or afk or ooc
  269.  
  270.  
  271. if (((angle >-30) && (angle<=0)) || ((angle < 30) && (angle > 0))) reduction = reduction*2;
  272.  
  273. if ((angle < 180) && (angle > 50) && (settings&8)) {
  274.  
  275. llTriggerSound("7b805eda-4128-f21f-e91e-81dc6b2b0569",1);
  276. reduction -= 4 + str*0.5;
  277. if (reduction <0) reduction = 0;
  278. } else
  279. if (attack&65536) { // stun
  280. llOwnerSay("stunned");
  281. llStartAnimation("a_stun");
  282. llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
  283. f_stun = now + (attack>>19);
  284. llWhisper(mychan-1, (string)(268435456 | (attack>>19)));
  285.  
  286. } else
  287. if (attack&131072) { // bleed
  288. if (f_bleed > now) return; // wont stack
  289. f_bleed = now + 15;
  290. f_bleed_dps = ((float)((attack&65535)>>9))/20; // dmg value / 20 per sec for 15 seconds
  291. dmg_per_sec += f_bleed_dps;
  292.  
  293. } else
  294. if (attack&262144) { // bash
  295.  
  296. float vec = PI* ((attack>>19) - 180) /180;
  297. llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
  298. f_stun = now + 1;
  299. integer tmp = ((attack>>19) - 180);
  300. if ((tmp < 135) && (tmp >45)) llStartAnimation("a_bash_r");
  301. if ((tmp >= 135) || (tmp <= -135))llStartAnimation("a_bash");
  302. if ((tmp >= -45) && (tmp <= 45)) llStartAnimation("a_bash_b");
  303. if ((tmp < -45) && (tmp >-135)) llStartAnimation("a_bash_l");
  304. llMoveToTarget(llGetPos() + <llCos(vec), llSin(vec), 0>*7, 0.5);
  305. llSleep(0.1);
  306. llStopMoveToTarget();
  307. } else
  308. if (attack&524288) { // disarm
  309. llOwnerSay("disarmed");
  310. llWhisper(mychan-1, (string)(attack>>19));
  311. } else
  312. if (attack&1048576) { // poison
  313. if (f_poison >now) return; // wont stack
  314. f_poison = now + 216000; // 1hour
  315. f_poison_dps = ((float)((attack&65535)>>9))/400; // dmg value / 40 per sec for 15 seconds
  316. dmg_per_sec += f_poison_dps;
  317. return;
  318. } else
  319. if (attack&2097152) { // lifesteal
  320. llOwnerSay("lifesteal");
  321. } else
  322. if (attack&8388608) { // lifesteal
  323. llOwnerSay("maim");
  324. } else
  325. if (attack&16777216) { // arrow
  326. llOwnerSay("arrow");
  327. } else
  328. if (attack&33554432) { // perma poison
  329. llOwnerSay("perma poison");
  330.  
  331. } else
  332. if (attack&67108864) { // heal
  333. timefullhealth -= 5*reduction;
  334. return;
  335. } else
  336. if (attack&134217728) { // cure
  337. f_bleed=0;
  338. f_poison=0;
  339. dmg_per_sec =0;
  340. return;
  341. } else
  342. if (attack&268435456) {
  343. llOwnerSay("energy dmg"+(string)((attack&65535)>>9));
  344. if (timefullenergy <now) timefullenergy = now;
  345. timefullenergy += 2*((attack&65535)>>9);
  346. return;
  347. }
  348.  
  349.  
  350.  
  351. if (timefullhealth < now) timefullhealth = now;
  352. if (timefullenergy < now) timefullenergy = now;
  353.  
  354. integer currentEnergy = getEnergy();
  355.  
  356. if (currentEnergy <5) {
  357. // full hit
  358. timefullhealth += 5*reduction;
  359. timefullenergy = now + 100;
  360. } else {
  361. // defended hit
  362. timefullhealth += 5*reduction/3; //15dmg / 3 = 5*5sec = 25sec
  363. timefullenergy += (2*reduction/3); // 15 2/3 = 10
  364. }
  365.  
  366. integer currentHealth = getHealth();
  367.  
  368. if ((currentHealth <=0) && (status ==0)) {
  369. status = 1;
  370.  
  371. if (settings & 2) { // arena
  372. timefullhealth = now + 500 + 5;
  373. timefullenergy = now + 100 + 5;
  374. } else {
  375. maxhealth = maxhealth;
  376. timefullhealth = now + 500 + 300;
  377. timefullenergy = now + 100 + 300;
  378. }
  379.  
  380.  
  381. settings = ~((~settings) |8); // clear shield bit
  382. llMessageLinked(LINK_ALL_CHILDREN, 2, "", NULL_KEY);
  383. llWhisper(mychan-1,"1"); // sheath all weapons
  384. llWhisper(mychan-10,"2"); // sheath shield
  385. llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
  386. llShout(0,"/me has been crushed by "+name);
  387. llStartAnimation("a_dead");
  388.  
  389. return;
  390. }
  391. llStopAnimation("a_hit");
  392. llStartAnimation("a_hit");
  393. if (settings & 1) llTriggerSound("1a77ee8c-4a38-5a46-f173-8ee81db79776",1); else llTriggerSound("575716be-37d3-dc33-5b75-fe99d78c03eb",1);
  394.  
  395. llShout(-(integer)("0x"+llGetSubString(llMD5String(name, 0), 0, 6)) - 37641,"2,"+OWNER+","+(string)((integer)(getHealth()/(maxhealth/100))));
  396.  
  397. }
  398.  
  399. }
  400.  
  401. state off {
  402. state_entry() {
  403. llSetText("-"+KS+"-",<1,1,1>,1);
  404. }
  405.  
  406. attach(key who) {
  407. if (who == NULL_KEY) state default;
  408. }
  409. }
  410.  
  411. SHIELD:
  412. Code:
  413. integer drawn=0;
  414. string OWNER;
  415. integer mychan;
  416. draw() {
  417. if (drawn == 1) return;
  418. llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
  419. llWhisper(mychan,(string)(1879048192 | 8));
  420. llWhisper(mychan-11,"1");
  421. drawn=1;
  422. }
  423.  
  424. sheath() {
  425. if (drawn == 0) return;
  426. llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
  427. llWhisper(mychan,(string)(1610612736 | 8));
  428. llWhisper(mychan-11,"2");
  429. drawn=0;
  430. }
  431.  
  432.  
  433.  
  434. default
  435. {
  436. state_entry()
  437. {
  438. OWNER = llKey2Name(llGetOwner());
  439. mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
  440. llListen(mychan-10,"",NULL_KEY,"");
  441. drawn=1;
  442. sheath();
  443. }
  444.  
  445. listen(integer chan, string name, key id, string msg) {
  446. if ((integer)msg == 1) draw();
  447. if ((integer)msg == 2) sheath();
  448. }
  449.  
  450. attach(key who) {
  451. llResetScript();
  452. }
  453. }
  454.  
  455. ARMOR:
  456. Code:
  457. string OWNER;
  458. integer mychan;
  459. integer armortype;
  460. float run;
  461.  
  462.  
  463. default
  464. {
  465. state_entry()
  466. {
  467. OWNER = llKey2Name(llGetOwner());
  468. mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
  469. list tmpvar = llCSV2List(llGetScriptName());
  470. if (llList2String(tmpvar,1) == "L") armortype = 64;
  471. if (llList2String(tmpvar,1) == "M") armortype = 192;
  472. if (llList2String(tmpvar,1) == "H") armortype = 448;
  473. tmpvar = [];
  474. llWhisper(mychan,(string)(1879048192 | armortype));
  475. llListen(mychan-5,"",NULL_KEY,"");
  476. llSetTimerEvent(2);
  477. }
  478.  
  479. listen(integer chan, string name, key id, string msg) {
  480. llWhisper(mychan,(string)(1879048192 | armortype));
  481. }
  482.  
  483. timer() {
  484. vector v = llGetVel();
  485. float norm = llFabs(llSqrt(v.x*v.x + v.y*v.y + v.z*v.z));
  486. norm -= 2;
  487. run += norm;
  488. if (run > 10) {
  489. if (armortype == 64) llWhisper(mychan, (string)(268435456 + (3<<9)));
  490. else if (armortype == 192) llWhisper(mychan, (string)(268435456 + (5<<9)));
  491. else if (armortype == 448) llWhisper(mychan, (string)(268435456 + (10<<9)));
  492. run=0;
  493. }
  494. if (run<-20) run = -20;
  495. }
  496. attach(key who) {
  497. if (who == NULL_KEY) {
  498. llWhisper(mychan,(string)(1610612736 | 448)); //takes off all armor settings
  499. } else {
  500. llResetScript();
  501. }
  502.  
  503. }
  504. }
  505.  
  506. RANGED WEAPON (BOW):
  507. Code:
  508. // Era Of Gods Weapon Script
  509.  
  510. // Server Variables
  511. integer str; // Strength
  512. integer agi; // Agility
  513. float delay; // Delay Between hits
  514. float range; // Range of weapon
  515. float arc; // Arc of weapon
  516. integer special1;
  517. integer chance1;
  518. integer special2;
  519. integer chance2;
  520. integer damage;
  521. integer energy1;
  522. integer energy2;
  523.  
  524.  
  525.  
  526.  
  527. //LSL Variables
  528. integer attacknum=0;
  529. float holdbutton = 0;
  530. float nexthit=0;
  531. string WeaponType = "bow";
  532. integer mychan;
  533. integer special_type;
  534. integer sensortype=0;
  535. string OWNER;
  536.  
  537. on_attach() {
  538. // download avatar attributes and weapon stats
  539. // if (OWNER != llKey2Name(llGetOwner())) llResetScript(); // will kill all listeners of the previous AV
  540. OWNER = llKey2Name(llGetOwner());
  541. mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
  542. }
  543.  
  544.  
  545.  
  546. // --------------------------------------------------------------
  547. default
  548. {
  549. state_entry()
  550. {
  551.  
  552. on_attach();
  553.  
  554.  
  555. llResetTime();
  556. llHTTPRequest("http://eraofgods.com/sys/weapons.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +
  557. llKey2Name(llGetOwner()) +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName()+"|4"); // the last one is the weapon id in the database
  558. }
  559.  
  560. http_response(key request_id, integer status, list metadata, string body) {
  561. list tmp = llParseString2List(body,["|"],[]);
  562.  
  563. if (llList2Integer(tmp,1) != 1) {
  564. llOwnerSay(llList2String(tmp,0)); // pass message
  565. llOwnerSay("ERROR CODE:"+(string)llList2Integer(tmp,1));
  566. return;
  567. }
  568. str = llList2Integer(tmp,2);
  569. agi = llList2Integer(tmp,3);
  570. delay = llList2Float(tmp,4);
  571. range = llList2Float(tmp,5);
  572. arc = llList2Float(tmp,6);
  573. special1 = llList2Integer(tmp,7);
  574. chance1 = llList2Integer(tmp,8);
  575. special2 = llList2Integer(tmp,9);
  576. chance2 = llList2Integer(tmp,10);
  577. damage = llList2Integer(tmp,11);
  578. energy1 = llList2Integer(tmp,12);
  579. energy2 = llList2Integer(tmp,13);
  580.  
  581.  
  582. tmp = [];
  583.  
  584. state sheath;
  585. }
  586.  
  587.  
  588. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  589.  
  590. }
  591.  
  592. // --------------------------------------------------------------
  593. state drawn {
  594. state_entry() {
  595.  
  596.  
  597. llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
  598.  
  599. llListen(mychan-1,"",NULL_KEY,"");
  600. llListen(1,"",llGetOwner(),"");
  601.  
  602. llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
  603. llTriggerSound("sound_draw",1);
  604.  
  605. llTakeControls(CONTROL_DOWN | CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_BACK, TRUE, TRUE);
  606. llStartAnimation("anim_draw");
  607.  
  608. llSleep(1);
  609. llStartAnimation("hold_L_bow");
  610. llStartAnimation("bowholdfix");
  611.  
  612.  
  613. }
  614.  
  615. listen(integer chan, string name, key id, string msg)
  616. {
  617. if (chan != 1) {
  618. integer command = (integer)msg;
  619. if (command & 268435456) { // disarm
  620. // llOwnerSay("You are stunned for "+((string)(command & 256))+" seconds");
  621. // llSleep(command & 256);
  622. llSleep(2);
  623. } else
  624. if (command & 134217728) { // slow
  625.  
  626. }
  627. return;
  628. } else {
  629. if(msg == llToLower("sheath "+WeaponType)) state sheath;
  630. }
  631. }
  632.  
  633.  
  634. control(key id, integer down, integer change)
  635. {
  636. float now = llGetTime();
  637.  
  638. if ( change & CONTROL_ML_LBUTTON ) {
  639. if (down & CONTROL_BACK) return;
  640. if (nexthit > now) return;
  641.  
  642. rotation rot = llGetRot();
  643. vector fwd = llRot2Fwd(rot);
  644. vector pos = llGetPos();
  645. pos.z += 1.20;
  646. pos += fwd;
  647. fwd = fwd * 60;
  648. vector vel = llGetVel();
  649. float shift = llSqrt(vel.x*vel.x + vel.y*vel.y + vel.z*vel.z);
  650. fwd = fwd + <llFrand(shift),llFrand(shift),llFrand(shift)>;
  651.  
  652. llRezObject("arrow", pos, fwd, rot, 1);
  653. llTriggerSound("sound_shoot",1);
  654. llStartAnimation("shoot_L_bow");
  655.  
  656. // llStopAnimation("h0");
  657. // llStartAnimation("a0");
  658. nexthit = now + delay;
  659. }
  660.  
  661. }
  662.  
  663. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  664. }
  665.  
  666. // --------------------------------------------------------------
  667. state sheath {
  668. state_entry() {
  669. llListen(1,"",llGetOwner(),"");
  670.  
  671. llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
  672. llReleaseControls();
  673.  
  674. llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
  675.  
  676. llTriggerSound("sound_sheath",1);
  677. llStartAnimation("anim_sheath");
  678. llStopAnimation("hold_L_bow");
  679.  
  680. }
  681.  
  682. listen(integer chan, string name, key id, string msg) {
  683. if(msg == llToLower("reload")) state default;
  684. if(msg != llToLower("draw "+WeaponType)) return;
  685.  
  686. state drawn;
  687.  
  688. }
  689.  
  690. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  691. }
  692.  
  693. ARROW:
  694. Code:
  695. string OWNER;
  696. vector fwd;
  697. float mass;
  698. vector startpos;
  699.  
  700. float VecMag(vector v) {
  701. return llSqrt(v.x*v.x + v.y*v.y + v.z*v.z);
  702. }
  703.  
  704. default
  705. {
  706. state_entry()
  707. {
  708.  
  709. llCollisionSound("d4eb4f5d-e93c-3800-579f-2beef5a6b476", 1);
  710. llCollisionSprite("");
  711. llSetStatus( STATUS_ROTATE_Y | STATUS_ROTATE_X | STATUS_ROTATE_Z, FALSE);
  712. llSetStatus( STATUS_DIE_AT_EDGE, TRUE);
  713.  
  714.  
  715. }
  716.  
  717. on_rez(integer rezzed)
  718. {
  719. if (rezzed) {
  720. startpos = llGetPos();
  721. llSetBuoyancy(0.30);
  722. OWNER = llKey2Name(llGetOwner());
  723. fwd = llGetVel();
  724. mass = llGetMass();
  725. // llPlaySound("190acea2-0c1f-fb5a-5035-b108b25ae91f",1);
  726. // llSetTimerEvent(20);
  727. } else {
  728. llSetStatus(STATUS_PHYSICS, FALSE);
  729. llSetStatus(STATUS_PHANTOM, TRUE);
  730. }
  731. }
  732.  
  733. collision_start(integer detected)
  734. {
  735. llApplyImpulse(-mass*fwd,FALSE);
  736. llSetStatus(STATUS_PHANTOM, TRUE);
  737.  
  738. if (VecMag(startpos - llGetPos()) < 5) {
  739. llSetStatus(STATUS_PHYSICS, FALSE);
  740. llSleep(3);
  741. llDie();
  742. return;
  743. }
  744.  
  745. if ((llDetectedType(0) & AGENT) && ((llDetectedKey(0) != llGetOwner()))) {
  746.  
  747. vector myfwd = llRot2Fwd(llGetRot());
  748. vector targfwd = llRot2Fwd(llDetectedRot(0));
  749.  
  750. float a1 = llAtan2(myfwd.y,myfwd.x);
  751. float a2 = llAtan2(targfwd.y, targfwd.x);
  752. float q;
  753.  
  754. if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
  755. if ((a1 >0) && (a2>0)) q = a2 - a1;
  756. if ((a1 >0) && (a2<0)) q = a2 - a1;
  757. if ((a1 <0) && (a2<0)) q = a2 - a1;
  758. if (q<PI) q = 2*PI + q;
  759. if (q>PI) q = q - 2*PI;
  760.  
  761. integer angle = llRound(180*q/PI);
  762. integer mydirection = llRound(180*a1/PI);
  763.  
  764. integer attack = (22<<9) + angle ; // numbers mean: stun, bleed, bash
  765. llSetObjectName(OWNER);
  766. llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(0), 0), 0, 6)) -37621, (string)attack);
  767. llSetStatus(STATUS_PHYSICS, FALSE);
  768. llTriggerSound("f91d5919-0265-0a5d-bfae-657f578419c2",1);
  769.  
  770. llSleep(3);
  771. llDie();
  772.  
  773. }
  774.  
  775. llSensor("",NULL_KEY,AGENT,3.5,PI);
  776. llSetStatus(STATUS_PHYSICS, FALSE);
  777.  
  778. }
  779.  
  780. land_collision_start(vector pos)
  781. {
  782. if (VecMag(startpos - llGetPos()) < 7) {
  783. llSetStatus(STATUS_PHYSICS, FALSE);
  784. llSleep(3);
  785. llDie();
  786. return;
  787. }
  788.  
  789. llApplyImpulse(-mass*fwd,FALSE);
  790. llSetStatus(STATUS_PHANTOM, TRUE);
  791. llSensor("",NULL_KEY,AGENT,3.5,PI);
  792. llSetStatus(STATUS_PHYSICS, FALSE);
  793. }
  794.  
  795. sensor(integer tnum)
  796. {
  797.  
  798. vector myfwd = llRot2Fwd(llGetRot());
  799. vector targfwd = llRot2Fwd(llDetectedRot(0));
  800. vector d = llDetectedPos(0) - llGetPos();
  801. float a1 = llAtan2(myfwd.y,myfwd.x);
  802. float a2 = llAtan2(targfwd.y, targfwd.x);
  803. float q;
  804.  
  805. if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
  806. if ((a1 >0) && (a2>0)) q = a2 - a1;
  807. if ((a1 >0) && (a2<0)) q = a2 - a1;
  808. if ((a1 <0) && (a2<0)) q = a2 - a1;
  809. if (q<PI) q = 2*PI + q;
  810. if (q>PI) q = q - 2*PI;
  811.  
  812. integer angle = llRound(180*q/PI);
  813. integer mydirection = llRound(180*a1/PI);
  814.  
  815. integer attack = ((20 - 3*(integer)llSqrt(d.x*d.x + d.y*d.y +d.z*d.z))<<9) + angle ; // numbers mean: stun, bleed, bash
  816. llSetObjectName(OWNER);
  817. llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(0), 0), 0, 6)) -37621, (string)attack);
  818.  
  819. llTriggerSound("f91d5919-0265-0a5d-bfae-657f578419c2",1);
  820. llSleep(3);
  821. llDie();
  822. }
  823.  
  824. no_sensor() {
  825. llTriggerSound("264dbd2f-c325-e291-52f7-9f1fb483a570",1);
  826. //llRezObject("xxxtest",llGetPos(),<0,0,0>,<0,0,0,0>,1);
  827. llSleep(3);
  828. llDie();
  829. }
  830. timer()
  831. {
  832. llDie();
  833. }
  834. }
  835.  
  836. MACE (MELEE):
  837. Code:
  838. // Era Of Gods Weapon Script
  839.  
  840. // Server Variables
  841. integer str; // Strength
  842. integer agi; // Agility
  843. float delay; // Delay Between hits
  844. float range; // Range of weapon
  845. float arc; // Arc of weapon
  846. integer special1;
  847. integer chance1;
  848. integer special2;
  849. integer chance2;
  850. integer damage;
  851. integer energy1;
  852. integer energy2;
  853.  
  854.  
  855.  
  856.  
  857. //LSL Variables
  858. integer attacknum=0;
  859. float holdbutton = 0;
  860. float nexthit=0;
  861. string WeaponType = "";
  862. integer mychan;
  863. integer special_type;
  864. integer sensortype=0;
  865. integer settings=0;
  866. string OWNER;
  867.  
  868. on_attach() {
  869. // download avatar attributes and weapon stats
  870. // if (OWNER != llKey2Name(llGetOwner())) llResetScript(); // will kill all listeners of the previous AV
  871. OWNER = llKey2Name(llGetOwner());
  872. mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
  873. }
  874.  
  875.  
  876.  
  877. // --------------------------------------------------------------
  878. default
  879. {
  880. state_entry()
  881. {
  882.  
  883. on_attach();
  884. list tmpvar = llCSV2List(llGetScriptName());
  885. WeaponType = llList2String(tmpvar,1);
  886. settings = llList2Integer(tmpvar,3);
  887. llSetObjectName(OWNER);
  888. llResetTime();
  889. llHTTPRequest("http://eraofgods.net/sys/weapons.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +
  890. llKey2Name(llGetOwner()) +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName()+"|"+llList2String(tmpvar,2)+"|"+llKey2Name(llGetCreator())); // the last one is the weapon id in the database
  891. tmpvar = [];
  892. }
  893.  
  894. http_response(key request_id, integer status, list metadata, string body) {
  895. list tmp = llParseString2List(body,["|"],[]);
  896.  
  897. if (llList2Integer(tmp,1) != 1) {
  898. llOwnerSay(llList2String(tmp,0)); // pass message
  899. llOwnerSay("ERROR CODE:"+(string)llList2Integer(tmp,1));
  900. return;
  901. }
  902. str = llList2Integer(tmp,2);
  903. agi = llList2Integer(tmp,3);
  904. delay = llList2Float(tmp,4);
  905. range = llList2Float(tmp,5);
  906. arc = llList2Float(tmp,6);
  907. special1 = llList2Integer(tmp,7);
  908. chance1 = llList2Integer(tmp,8);
  909. special2 = llList2Integer(tmp,9);
  910. chance2 = llList2Integer(tmp,10);
  911. damage = llList2Integer(tmp,11);
  912. energy1 = llList2Integer(tmp,12);
  913. energy2 = llList2Integer(tmp,13);
  914.  
  915.  
  916. tmp = [];
  917.  
  918. state sheath;
  919. }
  920.  
  921.  
  922. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  923.  
  924. }
  925.  
  926. // --------------------------------------------------------------
  927. state drawn {
  928. state_entry() {
  929.  
  930. if (settings & 1) llWhisper(mychan-10,(string)1); // draw shield if we have weapon that allows shield
  931. else llWhisper(mychan-10,(string)2); // sheath shield
  932.  
  933. llWhisper(mychan-1, "1");
  934. llWhisper(mychan-2, "draw "+WeaponType);
  935.  
  936. llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
  937.  
  938. llListen(mychan-1,"",NULL_KEY,"");
  939. llListen(1,"",llGetOwner(),"");
  940.  
  941. llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
  942. llTriggerSound("sound_draw",1);
  943.  
  944. llTakeControls(CONTROL_DOWN | CONTROL_ML_LBUTTON | CONTROL_LBUTTON, TRUE, TRUE);
  945. llStartAnimation("anim_draw");
  946. llSleep(1);
  947. llStartAnimation("anim_stance");
  948.  
  949. }
  950.  
  951. listen(integer chan, string name, key id, string msg)
  952. {
  953. if (chan != 1) {
  954. integer command = (integer)msg;
  955. if (command & 268435456) { // disarm
  956. // llOwnerSay("You are stunned for "+((string)(command & 256))+" seconds");
  957. // llSleep(command & 256);
  958. llSleep(2);
  959. } else
  960. if (command & 134217728) { // slow
  961.  
  962. }
  963. if (command == 1) state sheath;
  964. if (command == 2) settings = settings | 2; // turn on friendly protection
  965. if (command == 3) settings = ~((~settings) | 2); // turn off friendly protection
  966. return;
  967. } else {
  968. if ((msg == llToLower("sheath")) || (msg == llToLower("sheath "+WeaponType))) {
  969. llWhisper(mychan-10, "2"); // sheath shield
  970. state sheath;
  971. }
  972. }
  973. }
  974.  
  975.  
  976. control(key id, integer down, integer change)
  977. {
  978. float now = llGetTime();
  979.  
  980. // integer pressed = down & change;
  981. // integer specialattack0 = CONTROL_FWD | CONTROL_BACK;
  982. // integer specialattack1 = CONTROL_DOWN | CONTROL_BACK;
  983. // integer specialattack2 = CONTROL_FWD | CONTROL_RIGHT;
  984. // integer specialattack3 = CONTROL_BACK | CONTROL_LEFT;
  985. // Manually Triger Specials ONLY ONE TYPE SHOULD BE ACTIVE
  986. // if ((pressed & specialattack0) == specialattack0) Bash();
  987. //else if ((pressed & specialattack1) == specialattack1) Bleed();
  988. //else if ((pressed & specialattack2) == specialattack2) Cleve();
  989. //else if ((pressed & specialattack3) == specialattack3) Disarm();
  990. if ((down & change) & (CONTROL_DOWN)) {
  991. sensortype =1;
  992. llSensor("",NULL_KEY,AGENT,20,0.1);
  993. }
  994.  
  995. if ( (~down) & change & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON) ) {
  996. if (nexthit > now) llSleep(nexthit - now);
  997. if (holdbutton == 0) holdbutton = now;
  998. llSensor("",NULL_KEY,AGENT,range,arc);
  999. llStopAnimation("h"+(string)attacknum);
  1000. llStartAnimation("a"+(string)attacknum);
  1001. nexthit = llGetTime() + delay;
  1002. }
  1003.  
  1004. if ((down & change) & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON)) {
  1005. holdbutton = now;
  1006. attacknum = (integer)llFrand(3);
  1007. llStartAnimation("h"+(string)attacknum);
  1008. }
  1009.  
  1010. }
  1011.  
  1012. sensor(integer tnum)
  1013. {
  1014. integer who=-1;
  1015. if (settings & 2) { // if friendly fire on
  1016. integer i=0;
  1017. for (i=0;i<tnum;i++) {
  1018. if (!llDetectedGroup(i)) who=i;
  1019. }
  1020. if (who ==-1) return;
  1021. } else who =0;
  1022.  
  1023. vector myfwd = llRot2Fwd(llGetRot());
  1024. vector targfwd = llRot2Fwd(llDetectedRot(who));
  1025.  
  1026. if (sensortype ==1) {
  1027. sensortype =0;
  1028.  
  1029. llMoveToTarget(llDetectedPos(who), 0.1);
  1030. llSleep(0.2);
  1031. llStopMoveToTarget();
  1032. llWhisper(mychan, (string)(268435456 + (10<<9)));
  1033. return;
  1034. }
  1035. float a1 = llAtan2(myfwd.y,myfwd.x);
  1036. float a2 = llAtan2(targfwd.y, targfwd.x);
  1037. float q;
  1038.  
  1039. if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
  1040. if ((a1 >0) && (a2>0)) q = a2 - a1;
  1041. if ((a1 >0) && (a2<0)) q = a2 - a1;
  1042. if ((a1 <0) && (a2<0)) q = a2 - a1;
  1043. if (q<PI) q = 2*PI + q;
  1044. if (q>PI) q = q - 2*PI;
  1045.  
  1046. integer angle = llRound(180*q/PI);
  1047. integer mydirection = 180 + llRound(180*a1/PI);
  1048.  
  1049. float heldtime = llGetTime() - holdbutton;
  1050. if (heldtime>2) heldtime =2;
  1051.  
  1052. integer attack = ((damage + llRound(3*heldtime))<<9) + angle ; // numbers mean: stun, bleed, bash
  1053.  
  1054. if ((integer)llFrand(101) < chance1) attack = attack | special1;
  1055. if ((integer)llFrand(101) < chance2) attack = attack | special2;
  1056.  
  1057. if (attack & 262144) {
  1058. attack += (mydirection<<19);
  1059. }
  1060.  
  1061. llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(who), 0), 0, 6)) -37621, (string)attack);
  1062. llTriggerSound("sound_hit",1);
  1063. }
  1064. no_sensor()
  1065. {
  1066. llTriggerSound("sound_miss",1);
  1067. }
  1068.  
  1069. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  1070. }
  1071.  
  1072. // --------------------------------------------------------------
  1073. state sheath {
  1074. state_entry() {
  1075. llListen(1,"",llGetOwner(),"");
  1076.  
  1077. llWhisper(mychan-2, "sheath "+WeaponType);
  1078.  
  1079.  
  1080. llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
  1081. llReleaseControls();
  1082.  
  1083. llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
  1084.  
  1085. llTriggerSound("sound_sheath",1);
  1086. llStartAnimation("anim_sheath");
  1087. llStopAnimation("anim_stance");
  1088.  
  1089. }
  1090.  
  1091. listen(integer chan, string name, key id, string msg) {
  1092. if(msg == llToLower("reload")) state default;
  1093. if(msg != llToLower("draw "+WeaponType)) return;
  1094.  
  1095. state drawn;
  1096.  
  1097. }
  1098.  
  1099. attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
  1100. }
Advertisement
Add Comment
Please, Sign In to add comment