Home |
Add a script
|
||
|---|---|---|---|
| Category: | Contributor: | Description | |
| Weapons | Anonymous | Dueling Sword.lsl | |
Dueling Sword, with directional action, sounds
Dueling Sword.lsl
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
1 // CATEGORY:Weapons 2 // DESCRIPTION:Dueling Sword.lsl 3 // ARCHIVED BY:Ferd Frederix 4 5 integer SWORD = 1; 6 integer PUNCH12 = 2; 7 integer PUNCHL = 3; 8 integer KICK = 4; 9 integer FLIP = 5; 10 11 integer strike_type; 12 13 default 14 { 15 state_entry() 16 { 18 } 19 run_time_permissions(integer perm) 20 { 21 if (perm) 22 { 23 llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT | CONTROL_DOWN, TRUE, TRUE); 24 } 25 } 26 28 { 29 if (on != NULL_KEY) 30 { 31 integer perm = llGetPermissions(); 32 33 if (perm != (PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)) 34 { 36 } 37 else 38 { 39 llTakeControls(CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_UP | CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_RIGHT, TRUE, TRUE); 40 } 41 42 } 43 else 44 { 45 llSay(0, "releasing controls"); 47 } 48 } 49 50 timer() 51 { 52 if ( (strike_type == FLIP) 53 || (strike_type == SWORD)) 54 { 56 } 57 else 58 { 60 } 61 llSetTimerEvent(0.0); 62 } 63 65 { 66 if (level & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON)) 67 { 68 if (edge & CONTROL_UP) 69 { 70 llApplyImpulse(<0,0,3.5>,FALSE); 71 llStartAnimation("backflip"); 72 llSetTimerEvent(0.25); 73 strike_type = FLIP; 74 } 75 if (edge & CONTROL_FWD) 76 { 77 llStartAnimation("sword_strike_R"); 78 llSleep(0.5); 79 llSetTimerEvent(0.25); 80 strike_type = SWORD; 81 } 82 if (edge & (CONTROL_LEFT | CONTROL_ROT_LEFT)) 83 { 84 llStartAnimation("punch_L"); 85 llSetTimerEvent(0.25); 86 strike_type = PUNCHL; 87 } 88 if (edge & (CONTROL_RIGHT | CONTROL_ROT_RIGHT)) 89 { 90 llStartAnimation("kick_roundhouse_R"); 91 llSetTimerEvent(0.25); 92 strike_type = KICK; 93 } 94 if (edge & CONTROL_BACK) 95 { 96 llStartAnimation("punch_onetwo"); 97 llSetTimerEvent(0.25); 98 strike_type = PUNCH12; 99 }100 if (edge & CONTROL_DOWN)101 {102 llMoveToTarget(llGetPos(), 0.25);103 llSleep(1.0);104 llStopMoveToTarget();105 }106 }107 }108 110 {112 dir.z = 0.0;113 dir = llVecNorm(dir);115 if (strike_type == SWORD)116 {117 llTriggerSound("crunch", 0.5);118 dir += llRot2Up(rot);119 dir *= 20.0;121 }122 else if (strike_type == PUNCH12)123 {124 llTriggerSound("crunch", 0.2);125 dir += dir;126 dir *= 20.0;128 }129 else if (strike_type == PUNCHL)130 {131 llTriggerSound("crunch", 0.2);132 dir -= llRot2Left(rot);133 dir *= 20.0;135 }136 else if (strike_type == KICK)137 {138 llTriggerSound("crunch", 0.2);139 dir += dir;140 dir *= 20.0;142 }143 else if (strike_type == FLIP)144 {145 llTriggerSound("crunch", 0.2);147 }148 strike_type= 0;149 }150 }151 // END //