float timefullhealth; // the time when the health will be full
float timefullenergy;
string OWNER;
string KK;
string KO;
string KS;
integer mychan = 0;
string KF="";
integer status = 0;
integer str = 10;
integer sta = 20;
integer agi = 10;
integer int = 10;
float armor_reduction = 1;
integer maxhealth = 0;
float regen_per_sec = 0.2;
float dmg_per_sec = 0;
float lastcall;
integer settings=0;
string label="";
float f_stun = 0;
float f_bleed = 0;
float f_bleed_dps;
float f_poison = 0;
float f_poison_dps;
updateLabel() {
label = "";
if (settings & 8) label += "(S) ";
if (settings & 2) label += "(Arena) ";
if (settings & 4) label += "(AFK) ";
if (settings & 32) label += "(OOC) ";
armor_reduction = 1;
if ((settings & 448) == 448) { label += "(H)"; armor_reduction = 0.5;} else
if ((settings & 192) == 192) { label += "(M)"; armor_reduction = 0.7;} else
if (settings & 64) { label += "(L)"; armor_reduction = 0.8;}
if (label != "") label += "\n";
}
saveSettings() {
llHTTPRequest("http://66.103.230.111/sys/meter_savesettings.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +(string)settings);
}
integer getHealth() {
float now = llGetTime();
timefullhealth += ((now - lastcall)*dmg_per_sec)/regen_per_sec;
lastcall = now;
integer currentHealth = maxhealth - llRound((timefullhealth - now)*regen_per_sec); // calculates the current health,
// if we know when it will be full then we know how much health is missing
// couse there is 10 health missing per 2seconds
if (currentHealth >maxhealth) currentHealth = maxhealth;
if (currentHealth <0) currentHealth = 0;
return currentHealth;
}
integer getEnergy() {
integer currentEnergy = 100 - llRound(timefullenergy - llGetTime()); // calculates the current health,
// if we know when it will be full then we know how much health is missing
// couse there is 10 health missing per 2seconds
if (currentEnergy >100) currentEnergy = 100;
if (currentEnergy <0) currentEnergy = 0;
return currentEnergy;
}
init() {
OWNER = llKey2Name(llGetOwner());
llSetObjectName("["+llGetScriptName()+"] "+OWNER);
mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
llSetTimerEvent(2);
KK = llUnescapeURL("%E2%96%93");
KO = llUnescapeURL("%E2%96%91");
KS = llUnescapeURL("%E2%98%BA");
KF = KK+KK+KK+KK+KK+KK+KK+KK+KK+KK+KK;
llListen(mychan, "", NULL_KEY, "");
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
lastcall = llGetTime();
llMessageLinked(LINK_ALL_CHILDREN, 1, "", NULL_KEY);
// download avatar attributes
llHTTPRequest("http://66.103.230.111/sys/meter.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" + OWNER +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName());
}
default
{
state_entry()
{
init();
}
attach(key who) {
if (who != NULL_KEY) {
llResetScript();
} else {
integer currentHealth = getHealth();
if (currentHealth <70) llShout(0, "/me DETACHED METER!");
}
}
run_time_permissions(integer perm) { // permissions dialog answered
if (perm & PERMISSION_TAKE_CONTROLS) { // we got a yes
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON |CONTROL_ML_LBUTTON, TRUE,FALSE);
}
}
http_response(key request_id, integer status, list metadata, string body) {
list tmp = llParseString2List(body,["|"],[]);
integer RCODE = llList2Integer(tmp,1);
if (llStringLength(llList2String(tmp,0)) > 1) llOwnerSay(llList2String(tmp,0)); // pass message
if (RCODE != 1) {
if (RCODE == 10) {
//settings saved we can Reset
return;
}
state off;
}
str = llList2Integer(tmp,2);
agi = llList2Integer(tmp,3);
sta = llList2Integer(tmp,4);
int = llList2Integer(tmp,5);
settings = llList2Integer(tmp,6);
settings = ~((~settings) |448); // clear armor bits
llWhisper(mychan-5,"p"); // pings the armor channel to see if there is any attached
updateLabel();
maxhealth = sta*5;
regen_per_sec = 0.2;
llOwnerSay("Str:"+(string)str+" Agi:"+(string)agi+" Sta:"+(string)sta+" Int:"+(string)int);
tmp = [];
llWhisper(mychan-20,"3,"+(string)llGetTime()+","+(string)maxhealth);
settings = ~((~settings) |8); // clear shield bit
llWhisper(mychan-1,"1"); // sheath all weapons
llWhisper(mychan-10,"2"); // sheath shield
}
timer() {
float now = llGetTime();
if (f_bleed != 0) if (f_bleed<now) { f_bleed=0; dmg_per_sec -= f_bleed_dps;}
if (f_poison != 0) if (f_poison<now) { f_poison=0; dmg_per_sec -= f_poison_dps;}
if (f_stun != 0) if (f_stun<now) { f_stun=0; llReleaseControls(); llStopAnimation("a_stun"); llStopAnimation("a_bash");}
integer currentHealth = getHealth();
integer currentEnergy = getEnergy();
if ( (currentHealth > 0) && (status == 1)) {
// get up no more down
llReleaseControls();
llMessageLinked(LINK_ALL_CHILDREN, 1, "", NULL_KEY);
status = 0;
if (settings & 2) {
llShout(0,"/me is in arena mode and reseted automaticaly!");
timefullhealth = now;
timefullenergy = now;
currentHealth = maxhealth;
currentEnergy = 100;
} else {
llShout(0,"/me rised up from the dirt");
}
llStopAnimation("a_dead");
}
if ((currentHealth ==0) && (status != 1)) {
status = 1;
if (settings & 2) { // arena
timefullhealth = now + 500 + 5;
timefullenergy = now + 100 + 5;
} else {
maxhealth = maxhealth;
timefullhealth = now + 500 + 300;
timefullenergy = now + 100 + 300;
}
settings = ~((~settings) |8); // clear shield bit
llMessageLinked(LINK_ALL_CHILDREN, 2, "", NULL_KEY);
llWhisper(mychan-1,"1"); // sheath all weapons
llWhisper(mychan-10,"2"); // sheath shield
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
llShout(0,"/me has been crushed");
llStartAnimation("a_dead");
}
if (currentHealth ==0) {
integer remainingsec = llRound(timefullhealth - llGetTime() -500);
llSetText("knockout "+(string)remainingsec+"sec. remaining", <1,0.2,0>, 1);
} else {
if ((timefullhealth > now) || (timefullenergy > now)) {
llWhisper(mychan-20,"1,"+(string)currentHealth+","+(string)currentEnergy);
integer points = llRound((float)currentEnergy/10);
string ss="";
if (points != 0) ss = llGetSubString(KF,0,points);
float color = (float)currentHealth / 100;
llSetText(label+ss+"\nH:"+(string)currentHealth + "% E:"+(string)currentEnergy+"%", <1-color,color,0>, 1);
} else {
llSetText(label+KS,<0.3,1,0.3>,1);
}
}
}
listen(integer channel, string name, key id, string message)
{
// float ds = llGetTime();
integer attack = (integer)message;
if (attack & 1073741824) { // settings
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(); }
integer bit = attack & 4294967295; // strips the system bits
if (attack & 536870912) { // forcing the bit to
if (attack & 268435456) // turn on
settings = settings | bit;
else // turn off
settings = ~((~settings) | bit);
} else { // switching the bit
settings = settings ^ bit;
}
if (!(bit & 8) && !(bit & 448)) saveSettings(); // wont save if we just pull shield
updateLabel();
return;
}
float now = llGetTime();
float reduction = ((attack&65535)>>9) *armor_reduction; // TODO: -str*0.2 the attack is blocked
integer angle = attack&511;
if (status != 0) return; // our target is down or afk or ooc
if (((angle >-30) && (angle<=0)) || ((angle < 30) && (angle > 0))) reduction = reduction*2;
if ((angle < 180) && (angle > 50) && (settings&8)) {
llTriggerSound("7b805eda-4128-f21f-e91e-81dc6b2b0569",1);
reduction -= 4 + str*0.5;
if (reduction <0) reduction = 0;
} else
if (attack&65536) { // stun
llOwnerSay("stunned");
llStartAnimation("a_stun");
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
f_stun = now + (attack>>19);
llWhisper(mychan-1, (string)(268435456 | (attack>>19)));
} else
if (attack&131072) { // bleed
if (f_bleed > now) return; // wont stack
f_bleed = now + 15;
f_bleed_dps = ((float)((attack&65535)>>9))/20; // dmg value / 20 per sec for 15 seconds
dmg_per_sec += f_bleed_dps;
} else
if (attack&262144) { // bash
float vec = PI* ((attack>>19) - 180) /180;
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
f_stun = now + 1;
integer tmp = ((attack>>19) - 180);
if ((tmp < 135) && (tmp >45)) llStartAnimation("a_bash_r");
if ((tmp >= 135) || (tmp <= -135))llStartAnimation("a_bash");
if ((tmp >= -45) && (tmp <= 45)) llStartAnimation("a_bash_b");
if ((tmp < -45) && (tmp >-135)) llStartAnimation("a_bash_l");
llMoveToTarget(llGetPos() + <llCos(vec), llSin(vec), 0>*7, 0.5);
llSleep(0.1);
llStopMoveToTarget();
} else
if (attack&524288) { // disarm
llOwnerSay("disarmed");
llWhisper(mychan-1, (string)(attack>>19));
} else
if (attack&1048576) { // poison
if (f_poison >now) return; // wont stack
f_poison = now + 216000; // 1hour
f_poison_dps = ((float)((attack&65535)>>9))/400; // dmg value / 40 per sec for 15 seconds
dmg_per_sec += f_poison_dps;
return;
} else
if (attack&2097152) { // lifesteal
llOwnerSay("lifesteal");
} else
if (attack&8388608) { // lifesteal
llOwnerSay("maim");
} else
if (attack&16777216) { // arrow
llOwnerSay("arrow");
} else
if (attack&33554432) { // perma poison
llOwnerSay("perma poison");
} else
if (attack&67108864) { // heal
timefullhealth -= 5*reduction;
return;
} else
if (attack&134217728) { // cure
f_bleed=0;
f_poison=0;
dmg_per_sec =0;
return;
} else
if (attack&268435456) {
llOwnerSay("energy dmg"+(string)((attack&65535)>>9));
if (timefullenergy <now) timefullenergy = now;
timefullenergy += 2*((attack&65535)>>9);
return;
}
if (timefullhealth < now) timefullhealth = now;
if (timefullenergy < now) timefullenergy = now;
integer currentEnergy = getEnergy();
if (currentEnergy <5) {
// full hit
timefullhealth += 5*reduction;
timefullenergy = now + 100;
} else {
// defended hit
timefullhealth += 5*reduction/3; //15dmg / 3 = 5*5sec = 25sec
timefullenergy += (2*reduction/3); // 15 2/3 = 10
}
integer currentHealth = getHealth();
if ((currentHealth <=0) && (status ==0)) {
status = 1;
if (settings & 2) { // arena
timefullhealth = now + 500 + 5;
timefullenergy = now + 100 + 5;
} else {
maxhealth = maxhealth;
timefullhealth = now + 500 + 300;
timefullenergy = now + 100 + 300;
}
settings = ~((~settings) |8); // clear shield bit
llMessageLinked(LINK_ALL_CHILDREN, 2, "", NULL_KEY);
llWhisper(mychan-1,"1"); // sheath all weapons
llWhisper(mychan-10,"2"); // sheath shield
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
llShout(0,"/me has been crushed by "+name);
llStartAnimation("a_dead");
return;
}
llStopAnimation("a_hit");
llStartAnimation("a_hit");
if (settings & 1) llTriggerSound("1a77ee8c-4a38-5a46-f173-8ee81db79776",1); else llTriggerSound("575716be-37d3-dc33-5b75-fe99d78c03eb",1);
llShout(-(integer)("0x"+llGetSubString(llMD5String(name, 0), 0, 6)) - 37641,"2,"+OWNER+","+(string)((integer)(getHealth()/(maxhealth/100))));
}
}
state off {
state_entry() {
llSetText("-"+KS+"-",<1,1,1>,1);
}
attach(key who) {
if (who == NULL_KEY) state default;
}
}
SHIELD:
Code:
integer drawn=0;
string OWNER;
integer mychan;
draw() {
if (drawn == 1) return;
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
llWhisper(mychan,(string)(1879048192 | 8));
llWhisper(mychan-11,"1");
drawn=1;
}
sheath() {
if (drawn == 0) return;
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
llWhisper(mychan,(string)(1610612736 | 8));
llWhisper(mychan-11,"2");
drawn=0;
}
default
{
state_entry()
{
OWNER = llKey2Name(llGetOwner());
mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
llListen(mychan-10,"",NULL_KEY,"");
drawn=1;
sheath();
}
listen(integer chan, string name, key id, string msg) {
if ((integer)msg == 1) draw();
if ((integer)msg == 2) sheath();
}
attach(key who) {
llResetScript();
}
}
ARMOR:
Code:
string OWNER;
integer mychan;
integer armortype;
float run;
default
{
state_entry()
{
OWNER = llKey2Name(llGetOwner());
mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
list tmpvar = llCSV2List(llGetScriptName());
if (llList2String(tmpvar,1) == "L") armortype = 64;
if (llList2String(tmpvar,1) == "M") armortype = 192;
if (llList2String(tmpvar,1) == "H") armortype = 448;
tmpvar = [];
llWhisper(mychan,(string)(1879048192 | armortype));
llListen(mychan-5,"",NULL_KEY,"");
llSetTimerEvent(2);
}
listen(integer chan, string name, key id, string msg) {
llWhisper(mychan,(string)(1879048192 | armortype));
}
timer() {
vector v = llGetVel();
float norm = llFabs(llSqrt(v.x*v.x + v.y*v.y + v.z*v.z));
norm -= 2;
run += norm;
if (run > 10) {
if (armortype == 64) llWhisper(mychan, (string)(268435456 + (3<<9)));
else if (armortype == 192) llWhisper(mychan, (string)(268435456 + (5<<9)));
else if (armortype == 448) llWhisper(mychan, (string)(268435456 + (10<<9)));
run=0;
}
if (run<-20) run = -20;
}
attach(key who) {
if (who == NULL_KEY) {
llWhisper(mychan,(string)(1610612736 | 448)); //takes off all armor settings
} else {
llResetScript();
}
}
}
RANGED WEAPON (BOW):
Code:
// Era Of Gods Weapon Script
// Server Variables
integer str; // Strength
integer agi; // Agility
float delay; // Delay Between hits
float range; // Range of weapon
float arc; // Arc of weapon
integer special1;
integer chance1;
integer special2;
integer chance2;
integer damage;
integer energy1;
integer energy2;
//LSL Variables
integer attacknum=0;
float holdbutton = 0;
float nexthit=0;
string WeaponType = "bow";
integer mychan;
integer special_type;
integer sensortype=0;
string OWNER;
on_attach() {
// download avatar attributes and weapon stats
// if (OWNER != llKey2Name(llGetOwner())) llResetScript(); // will kill all listeners of the previous AV
OWNER = llKey2Name(llGetOwner());
mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
}
// --------------------------------------------------------------
default
{
state_entry()
{
on_attach();
llResetTime();
llHTTPRequest("http://eraofgods.com/sys/weapons.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +
llKey2Name(llGetOwner()) +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName()+"|4"); // the last one is the weapon id in the database
}
http_response(key request_id, integer status, list metadata, string body) {
list tmp = llParseString2List(body,["|"],[]);
if (llList2Integer(tmp,1) != 1) {
llOwnerSay(llList2String(tmp,0)); // pass message
llOwnerSay("ERROR CODE:"+(string)llList2Integer(tmp,1));
return;
}
str = llList2Integer(tmp,2);
agi = llList2Integer(tmp,3);
delay = llList2Float(tmp,4);
range = llList2Float(tmp,5);
arc = llList2Float(tmp,6);
special1 = llList2Integer(tmp,7);
chance1 = llList2Integer(tmp,8);
special2 = llList2Integer(tmp,9);
chance2 = llList2Integer(tmp,10);
damage = llList2Integer(tmp,11);
energy1 = llList2Integer(tmp,12);
energy2 = llList2Integer(tmp,13);
tmp = [];
state sheath;
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
// --------------------------------------------------------------
state drawn {
state_entry() {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llListen(mychan-1,"",NULL_KEY,"");
llListen(1,"",llGetOwner(),"");
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
llTriggerSound("sound_draw",1);
llTakeControls(CONTROL_DOWN | CONTROL_ML_LBUTTON | CONTROL_LBUTTON | CONTROL_BACK, TRUE, TRUE);
llStartAnimation("anim_draw");
llSleep(1);
llStartAnimation("hold_L_bow");
llStartAnimation("bowholdfix");
}
listen(integer chan, string name, key id, string msg)
{
if (chan != 1) {
integer command = (integer)msg;
if (command & 268435456) { // disarm
// llOwnerSay("You are stunned for "+((string)(command & 256))+" seconds");
// llSleep(command & 256);
llSleep(2);
} else
if (command & 134217728) { // slow
}
return;
} else {
if(msg == llToLower("sheath "+WeaponType)) state sheath;
}
}
control(key id, integer down, integer change)
{
float now = llGetTime();
if ( change & CONTROL_ML_LBUTTON ) {
if (down & CONTROL_BACK) return;
if (nexthit > now) return;
rotation rot = llGetRot();
vector fwd = llRot2Fwd(rot);
vector pos = llGetPos();
pos.z += 1.20;
pos += fwd;
fwd = fwd * 60;
vector vel = llGetVel();
float shift = llSqrt(vel.x*vel.x + vel.y*vel.y + vel.z*vel.z);
fwd = fwd + <llFrand(shift),llFrand(shift),llFrand(shift)>;
llRezObject("arrow", pos, fwd, rot, 1);
llTriggerSound("sound_shoot",1);
llStartAnimation("shoot_L_bow");
// llStopAnimation("h0");
// llStartAnimation("a0");
nexthit = now + delay;
}
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
// --------------------------------------------------------------
state sheath {
state_entry() {
llListen(1,"",llGetOwner(),"");
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llReleaseControls();
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
llTriggerSound("sound_sheath",1);
llStartAnimation("anim_sheath");
llStopAnimation("hold_L_bow");
}
listen(integer chan, string name, key id, string msg) {
if(msg == llToLower("reload")) state default;
if(msg != llToLower("draw "+WeaponType)) return;
state drawn;
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
ARROW:
Code:
string OWNER;
vector fwd;
float mass;
vector startpos;
float VecMag(vector v) {
return llSqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}
default
{
state_entry()
{
llCollisionSound("d4eb4f5d-e93c-3800-579f-2beef5a6b476", 1);
llCollisionSprite("");
llSetStatus( STATUS_ROTATE_Y | STATUS_ROTATE_X | STATUS_ROTATE_Z, FALSE);
llSetStatus( STATUS_DIE_AT_EDGE, TRUE);
}
on_rez(integer rezzed)
{
if (rezzed) {
startpos = llGetPos();
llSetBuoyancy(0.30);
OWNER = llKey2Name(llGetOwner());
fwd = llGetVel();
mass = llGetMass();
// llPlaySound("190acea2-0c1f-fb5a-5035-b108b25ae91f",1);
// llSetTimerEvent(20);
} else {
llSetStatus(STATUS_PHYSICS, FALSE);
llSetStatus(STATUS_PHANTOM, TRUE);
}
}
collision_start(integer detected)
{
llApplyImpulse(-mass*fwd,FALSE);
llSetStatus(STATUS_PHANTOM, TRUE);
if (VecMag(startpos - llGetPos()) < 5) {
llSetStatus(STATUS_PHYSICS, FALSE);
llSleep(3);
llDie();
return;
}
if ((llDetectedType(0) & AGENT) && ((llDetectedKey(0) != llGetOwner()))) {
vector myfwd = llRot2Fwd(llGetRot());
vector targfwd = llRot2Fwd(llDetectedRot(0));
float a1 = llAtan2(myfwd.y,myfwd.x);
float a2 = llAtan2(targfwd.y, targfwd.x);
float q;
if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
if ((a1 >0) && (a2>0)) q = a2 - a1;
if ((a1 >0) && (a2<0)) q = a2 - a1;
if ((a1 <0) && (a2<0)) q = a2 - a1;
if (q<PI) q = 2*PI + q;
if (q>PI) q = q - 2*PI;
integer angle = llRound(180*q/PI);
integer mydirection = llRound(180*a1/PI);
integer attack = (22<<9) + angle ; // numbers mean: stun, bleed, bash
llSetObjectName(OWNER);
llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(0), 0), 0, 6)) -37621, (string)attack);
llSetStatus(STATUS_PHYSICS, FALSE);
llTriggerSound("f91d5919-0265-0a5d-bfae-657f578419c2",1);
llSleep(3);
llDie();
}
llSensor("",NULL_KEY,AGENT,3.5,PI);
llSetStatus(STATUS_PHYSICS, FALSE);
}
land_collision_start(vector pos)
{
if (VecMag(startpos - llGetPos()) < 7) {
llSetStatus(STATUS_PHYSICS, FALSE);
llSleep(3);
llDie();
return;
}
llApplyImpulse(-mass*fwd,FALSE);
llSetStatus(STATUS_PHANTOM, TRUE);
llSensor("",NULL_KEY,AGENT,3.5,PI);
llSetStatus(STATUS_PHYSICS, FALSE);
}
sensor(integer tnum)
{
vector myfwd = llRot2Fwd(llGetRot());
vector targfwd = llRot2Fwd(llDetectedRot(0));
vector d = llDetectedPos(0) - llGetPos();
float a1 = llAtan2(myfwd.y,myfwd.x);
float a2 = llAtan2(targfwd.y, targfwd.x);
float q;
if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
if ((a1 >0) && (a2>0)) q = a2 - a1;
if ((a1 >0) && (a2<0)) q = a2 - a1;
if ((a1 <0) && (a2<0)) q = a2 - a1;
if (q<PI) q = 2*PI + q;
if (q>PI) q = q - 2*PI;
integer angle = llRound(180*q/PI);
integer mydirection = llRound(180*a1/PI);
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
llSetObjectName(OWNER);
llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(0), 0), 0, 6)) -37621, (string)attack);
llTriggerSound("f91d5919-0265-0a5d-bfae-657f578419c2",1);
llSleep(3);
llDie();
}
no_sensor() {
llTriggerSound("264dbd2f-c325-e291-52f7-9f1fb483a570",1);
//llRezObject("xxxtest",llGetPos(),<0,0,0>,<0,0,0,0>,1);
llSleep(3);
llDie();
}
timer()
{
llDie();
}
}
MACE (MELEE):
Code:
// Era Of Gods Weapon Script
// Server Variables
integer str; // Strength
integer agi; // Agility
float delay; // Delay Between hits
float range; // Range of weapon
float arc; // Arc of weapon
integer special1;
integer chance1;
integer special2;
integer chance2;
integer damage;
integer energy1;
integer energy2;
//LSL Variables
integer attacknum=0;
float holdbutton = 0;
float nexthit=0;
string WeaponType = "";
integer mychan;
integer special_type;
integer sensortype=0;
integer settings=0;
string OWNER;
on_attach() {
// download avatar attributes and weapon stats
// if (OWNER != llKey2Name(llGetOwner())) llResetScript(); // will kill all listeners of the previous AV
OWNER = llKey2Name(llGetOwner());
mychan = -(integer)("0x"+llGetSubString(llMD5String(OWNER, 0), 0, 6)) - 37621;
}
// --------------------------------------------------------------
default
{
state_entry()
{
on_attach();
list tmpvar = llCSV2List(llGetScriptName());
WeaponType = llList2String(tmpvar,1);
settings = llList2Integer(tmpvar,3);
llSetObjectName(OWNER);
llResetTime();
llHTTPRequest("http://eraofgods.net/sys/weapons.php",[HTTP_METHOD,"POST"],(string)llGetOwner() + "|" +
llKey2Name(llGetOwner()) +"|"+llGetRegionName() +"|"+(string)llGetPos()+"|"+llGetScriptName()+"|"+llList2String(tmpvar,2)+"|"+llKey2Name(llGetCreator())); // the last one is the weapon id in the database
tmpvar = [];
}
http_response(key request_id, integer status, list metadata, string body) {
list tmp = llParseString2List(body,["|"],[]);
if (llList2Integer(tmp,1) != 1) {
llOwnerSay(llList2String(tmp,0)); // pass message
llOwnerSay("ERROR CODE:"+(string)llList2Integer(tmp,1));
return;
}
str = llList2Integer(tmp,2);
agi = llList2Integer(tmp,3);
delay = llList2Float(tmp,4);
range = llList2Float(tmp,5);
arc = llList2Float(tmp,6);
special1 = llList2Integer(tmp,7);
chance1 = llList2Integer(tmp,8);
special2 = llList2Integer(tmp,9);
chance2 = llList2Integer(tmp,10);
damage = llList2Integer(tmp,11);
energy1 = llList2Integer(tmp,12);
energy2 = llList2Integer(tmp,13);
tmp = [];
state sheath;
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
// --------------------------------------------------------------
state drawn {
state_entry() {
if (settings & 1) llWhisper(mychan-10,(string)1); // draw shield if we have weapon that allows shield
else llWhisper(mychan-10,(string)2); // sheath shield
llWhisper(mychan-1, "1");
llWhisper(mychan-2, "draw "+WeaponType);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llListen(mychan-1,"",NULL_KEY,"");
llListen(1,"",llGetOwner(),"");
llSetLinkAlpha(LINK_SET,1,ALL_SIDES);
llTriggerSound("sound_draw",1);
llTakeControls(CONTROL_DOWN | CONTROL_ML_LBUTTON | CONTROL_LBUTTON, TRUE, TRUE);
llStartAnimation("anim_draw");
llSleep(1);
llStartAnimation("anim_stance");
}
listen(integer chan, string name, key id, string msg)
{
if (chan != 1) {
integer command = (integer)msg;
if (command & 268435456) { // disarm
// llOwnerSay("You are stunned for "+((string)(command & 256))+" seconds");
// llSleep(command & 256);
llSleep(2);
} else
if (command & 134217728) { // slow
}
if (command == 1) state sheath;
if (command == 2) settings = settings | 2; // turn on friendly protection
if (command == 3) settings = ~((~settings) | 2); // turn off friendly protection
return;
} else {
if ((msg == llToLower("sheath")) || (msg == llToLower("sheath "+WeaponType))) {
llWhisper(mychan-10, "2"); // sheath shield
state sheath;
}
}
}
control(key id, integer down, integer change)
{
float now = llGetTime();
// integer pressed = down & change;
// integer specialattack0 = CONTROL_FWD | CONTROL_BACK;
// integer specialattack1 = CONTROL_DOWN | CONTROL_BACK;
// integer specialattack2 = CONTROL_FWD | CONTROL_RIGHT;
// integer specialattack3 = CONTROL_BACK | CONTROL_LEFT;
// Manually Triger Specials ONLY ONE TYPE SHOULD BE ACTIVE
// if ((pressed & specialattack0) == specialattack0) Bash();
//else if ((pressed & specialattack1) == specialattack1) Bleed();
//else if ((pressed & specialattack2) == specialattack2) Cleve();
//else if ((pressed & specialattack3) == specialattack3) Disarm();
if ((down & change) & (CONTROL_DOWN)) {
sensortype =1;
llSensor("",NULL_KEY,AGENT,20,0.1);
}
if ( (~down) & change & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON) ) {
if (nexthit > now) llSleep(nexthit - now);
if (holdbutton == 0) holdbutton = now;
llSensor("",NULL_KEY,AGENT,range,arc);
llStopAnimation("h"+(string)attacknum);
llStartAnimation("a"+(string)attacknum);
nexthit = llGetTime() + delay;
}
if ((down & change) & (CONTROL_ML_LBUTTON | CONTROL_LBUTTON)) {
holdbutton = now;
attacknum = (integer)llFrand(3);
llStartAnimation("h"+(string)attacknum);
}
}
sensor(integer tnum)
{
integer who=-1;
if (settings & 2) { // if friendly fire on
integer i=0;
for (i=0;i<tnum;i++) {
if (!llDetectedGroup(i)) who=i;
}
if (who ==-1) return;
} else who =0;
vector myfwd = llRot2Fwd(llGetRot());
vector targfwd = llRot2Fwd(llDetectedRot(who));
if (sensortype ==1) {
sensortype =0;
llMoveToTarget(llDetectedPos(who), 0.1);
llSleep(0.2);
llStopMoveToTarget();
llWhisper(mychan, (string)(268435456 + (10<<9)));
return;
}
float a1 = llAtan2(myfwd.y,myfwd.x);
float a2 = llAtan2(targfwd.y, targfwd.x);
float q;
if ((a1 <0) && (a2>0)) q = -a1 + a2 - 2*PI;
if ((a1 >0) && (a2>0)) q = a2 - a1;
if ((a1 >0) && (a2<0)) q = a2 - a1;
if ((a1 <0) && (a2<0)) q = a2 - a1;
if (q<PI) q = 2*PI + q;
if (q>PI) q = q - 2*PI;
integer angle = llRound(180*q/PI);
integer mydirection = 180 + llRound(180*a1/PI);
float heldtime = llGetTime() - holdbutton;
if (heldtime>2) heldtime =2;
integer attack = ((damage + llRound(3*heldtime))<<9) + angle ; // numbers mean: stun, bleed, bash
if ((integer)llFrand(101) < chance1) attack = attack | special1;
if ((integer)llFrand(101) < chance2) attack = attack | special2;
if (attack & 262144) {
attack += (mydirection<<19);
}
llWhisper(-(integer)("0x"+llGetSubString(llMD5String(llDetectedName(who), 0), 0, 6)) -37621, (string)attack);
llTriggerSound("sound_hit",1);
}
no_sensor()
{
llTriggerSound("sound_miss",1);
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
// --------------------------------------------------------------
state sheath {
state_entry() {
llListen(1,"",llGetOwner(),"");
llWhisper(mychan-2, "sheath "+WeaponType);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llReleaseControls();
llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
llTriggerSound("sound_sheath",1);
llStartAnimation("anim_sheath");
llStopAnimation("anim_stance");
}
listen(integer chan, string name, key id, string msg) {
if(msg == llToLower("reload")) state default;
if(msg != llToLower("draw "+WeaponType)) return;
state drawn;
}
attach(key okey) { if(okey != NULL_KEY) llResetScript(); } // the weapon resets each 12 hours taking the stats from the server
}
Comments