„4CGS-Crosshair v0.07.02“ hinzufügen

master
Kxirya 2020-06-14 23:49:12 +00:00
parent 45c4f06004
commit 3bdf526b43
1 changed files with 294 additions and 0 deletions

294
4CGS-Crosshair v0.07.02 Normal file
View File

@ -0,0 +1,294 @@
// 4CGS-Crosshair [v0.07.02]
// ► ◄ █ ▄ ■ ▲ ▼ © ▓ ░ ─ ↑ ↓ ▲ ▼ ✔ ✘ • ♫ « »
integer fire = FALSE;
integer snd = FALSE;
integer dead = FALSE;
float armlength = 0.6;
float weaponlength = 96.0;
integer regchan = -1; // Wird für Systemmeldungen benötigt
integer enabled = TRUE;
string VER = "0.07.02";
string DATE = "13.06.2020";
string MSG_VER = "Version:";
string MSG_SIMLAG = "Das Fadenkreuz wird kurz angehalten, da die Region etwas laggt.";
string MSG_ATTACH = "Du musst das Fadenkreuz als HUD an der Position 'HUD Mitte 1' oder 'HUD Mitte 2' anlegen";
string MSG_ATT = "BITTE ALS HUD IN\nDER MITTE ANLEGEN!";
string MSG_DEFEAT = "wurde von {0} getroffen und besiegt.";
string MSG_HIT = "wurde von {0} getroffen und erhielt {1} Trefferpunkte.";
string MSG_DEFEATBY = "Du wurdest im Kampf von {0} besiegt.";
string MSG_NOSCAN = "KEIN SCAN";
string MSG_HEALTH = "Gesundheit";
string MSG_DISABLED = "4CGS DEAKTIVIERT";
list m_dataUserStore = [];
list m_dataStore = [];
getregionchannel()
{
list lstParcelDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID, PARCEL_DETAILS_AREA]);
regchan = (integer)("0x" + llGetSubString(llList2String(lstParcelDetails, 0), 0, 7));
if(regchan > 0)
regchan = -regchan;
}
list getDataListFromDataStorage(string _storage)
{
return llCSV2List(osGetDataValue(_storage));
}
integer checkDataEntryInDataList(list _dataList, string _key)
{
integer _inListPosition = llListFindList(_dataList, [_key]);
if(_inListPosition == -1)
return FALSE;
return TRUE;
}
string getDataEntryFromDataList(list _dataList, string _key)
{
integer _inListPosition = llListFindList(_dataList, [_key]);
if(_inListPosition == -1)
return "";
return llList2String(_dataList, _inListPosition + 1);
}
stopall()
{
list anim = llGetAnimationList(llGetOwner());
integer x;
for (x = 0; x < llGetListLength(anim); x++)
llStopAnimation(llList2Key(anim, x));
}
default
{
state_entry()
{
getregionchannel();
llReleaseControls();
llSensorRemove();
vector avsize = llGetAgentSize(llGetOwner());
armlength = avsize.z * 0.33;
if(llGetAttached() != 31 && llGetAttached() != 35)
{
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, MSG_ATT, <1,0,0>, 1, PRIM_COLOR, ALL_SIDES, <1,1,1>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
llRegionSayTo(llGetOwner(), 0, MSG_ATTACH);
llPreloadSound("male Cry 1");
llPreloadSound("male Cry 2");
llPreloadSound("female Cry 1");
llPreloadSound("female Cry 2");
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
else
{
llSetText("", <0,0,0>, 0);
llSensorRepeat("+++nothing+++", NULL_KEY, AGENT, 0.01, PI, 0.01);
llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS);
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, " ", <0,0,0>, 0, PRIM_COLOR, ALL_SIDES, <0,0,0>, 0, PRIM_SIZE, <0.1, 0.1, 0.1>]);
}
}
attach(key id)
{
if(id == llGetOwner())
llResetScript();
}
on_rez(integer num)
{
llResetScript();
}
control(key id, integer level, integer edge)
{
integer start = level & edge;
integer end = ~level & edge;
integer held = level & ~edge;
integer untouched = ~(level | edge);
if(start & CONTROL_ML_LBUTTON) fire = TRUE;
if(held & CONTROL_ML_LBUTTON) fire = TRUE;
if(end & CONTROL_ML_LBUTTON) fire = FALSE;
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llSensorRepeat("+++nothing+++", NULL_KEY, AGENT, 0.01, PI, 0.05);
}
if(perm & PERMISSION_ATTACH)
{
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_COLOR, ALL_SIDES, <0,0,0>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
llDetachFromAvatar();
}
}
no_sensor()
{
if (llGetAgentInfo(llGetOwner()) & AGENT_MOUSELOOK)
{
if(enabled == FALSE)
{
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, MSG_DISABLED, <1,0.6,0>, 1, PRIM_COLOR, ALL_SIDES, <1,1,1>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
return;
}
rotation rot = llGetCameraRot();
vector start = llGetPos() + <armlength, 0.0 ,1.0> * rot;
vector end = start + <weaponlength, 0.0 ,0.0> * rot;
list found = llCastRay(start, end, [RC_DETECT_PHANTOM, FALSE, RC_REJECT_TYPES, RC_REJECT_LAND, RC_DATA_FLAGS, RC_GET_ROOT_KEY, RC_MAX_HITS , 1]);
if (llList2Integer(found, 2) < 0 )
{
llSensorRepeat("+++nothing+++", NULL_KEY, AGENT, 0.01, PI, 5);
llOwnerSay(MSG_SIMLAG);
}
key id = llList2Key(found, 0);
vector pos = llList2Vector(found, 1);
string dist = llGetSubString((string)llVecDist(pos, llGetPos()), 0, 3);
vector size = llGetAgentSize(id);
string desc = llList2String(llGetObjectDetails(id, [OBJECT_NAME]), 0);
string name = osReplaceString(desc, "4CGS_TARGET_", "", -1, 0);
string nameold = llGetObjectName();
if (id != NULL_KEY & (size.z > 0 || llGetSubString(desc, 0, 10) == "4CGS_TARGET"))
{
// if(size.z > 0)
// name = llList2String(llParseString2List(llList2String(llGetObjectDetails(id, [OBJECT_OWNER]), 0), [" "], []), 0);
integer h = 100;
integer chan = -1;
if(size.z > 0)
{
// h = (integer)osGetHealth(id);
m_dataStore = getDataListFromDataStorage("game.hud");
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + id);
h = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.hp");
chan = (integer)getDataEntryFromDataList(m_dataUserStore, "channel");
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "[" + name + "]\n▲ " + dist + "m ▲\n" + MSG_HEALTH + ": " + (string)h + "%", <1,0.6,0>, 1, PRIM_COLOR, ALL_SIDES, <1,0.2,0>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
}
else
{
// h = getobjectdesc
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "[" + name + "]\n▲ " + dist + "m ▲\n" + MSG_HEALTH + ": " + (string)h + "%", <0.3,0.3,1>, 1, PRIM_COLOR, ALL_SIDES, <1,0.2,0>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
}
if(fire == TRUE && llGetTime() >= 0.25)
{
fire = FALSE;
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "[" + name + "]\n▲ " + dist + "m ▲\n" + MSG_HEALTH + ": " + (string)h + "%", <1, 0.0, 0>, 1, PRIM_COLOR, ALL_SIDES, <1,0.0,0>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
//llSetObjectName(llList2String(llParseString2List(name, [" "], []), 0));
// llRegionSay(chan, "gamecommand;reload");
integer damage = (5 + (integer)llFrand(5));
if(size.z > 0)
{
osMessageAttachments(id, "4CGS-DAMAGE:" + (string)damage, [31, 32, 33, 34, 35, 36, 37, 38], 0);
llSleep(0.1);
string sound = osGetGender(id) + " Cry " + (string)snd;
snd = !snd;
llTriggerSoundLimited(sound, 1, pos + <100, 100, 100>, pos - <100, 100, 100>);
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "[" + name + "]\n▲ " + dist + "m ▲\n" + MSG_HEALTH + ": " + (string)h + "%", <1,0.7,0>, 1, PRIM_COLOR, ALL_SIDES, <1,0.2,0>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
llSetObjectName(llList2String(llParseString2List(llKey2Name(llGetOwnerKey(id)), [" "], []), 0));
llShout(0, "/me " + osFormatString(MSG_HIT, [llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], []), 0), (string)damage]));
llSetObjectName(nameold);
llResetTime();
}
}
}
else
llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "► " + MSG_NOSCAN + " ◄", <0,1,0>, 0, PRIM_COLOR, ALL_SIDES, <1,1,1>, 1, PRIM_SIZE, <0.1, 0.1, 0.1>]);
}
else
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, ALL_SIDES, <1,1,1>, 0, PRIM_TEXT, " ", <0,1,0>, 0, PRIM_SIZE, <0.001, 0.001, 0.001>]);
}
dataserver(key uuid, string msg)
{
//llOwnerSay(llKey2Name(uuid));
// llOwnerSay(msg);
if(msg == "4CGS-SHOWVER")
llOwnerSay(MSG_VER + " " + VER + " [" + DATE + "]");
if(msg == "4CGS-DISABLE")
enabled = FALSE;
if(msg == "4CGS-ENABLE")
enabled = TRUE;
if(msg == "4CGS-DIE")
{
dead = TRUE;
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, ALL_SIDES, <0,0,0>, 0, PRIM_TEXT, " ", <1,0,0>, 0, PRIM_SIZE, <0.1, 0.1, 0.1>]);
string nameold = llGetObjectName();
llSetObjectName(llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], []), 0));
llShout(0, "/me " + osFormatString(MSG_DEFEAT, [llList2String(llParseString2List(llKey2Name(llGetOwnerKey(uuid)), [" "], []), 0)]));
// llRegionSayTo(llGetOwner(), 0, osFormatString(MSG_DEFEATBY, [llList2String(llParseString2List(llKey2Name(llGetOwnerKey(uuid)), [" "], []), 0)]));
llSetObjectName(nameold);
state dead;
}
}
changed(integer change)
{
if(change & (CHANGED_REGION | CHANGED_OWNER | CHANGED_INVENTORY))
llResetScript();
}
}
state dead
{
state_entry()
{
llReleaseControls();
osSetSpeed(llGetOwner(), 0);
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
osAvatarPlayAnimation(llGetOwner(), "dead");
llSensorRemove();
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, ALL_SIDES, <0,0,0>, 0, PRIM_TEXT, " ", <0,0,0>, 0, PRIM_SIZE, <0.01, 0.01, 0.01>]);
llSetTimerEvent(10);
}
run_time_permissions(integer perm)
{
if(PERMISSION_TRIGGER_ANIMATION & perm)
stopall();
if(PERMISSION_TAKE_CONTROLS & perm)
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON | CONTROL_ML_LBUTTON, TRUE, FALSE);
}
}
control(key id, integer level, integer edge)
{
}
timer()
{
llSetTimerEvent(0);
llReleaseControls();
stopall();
osAvatarStopAnimation(llGetOwner(), "dead");
osAvatarPlayAnimation(llGetOwner(), "stand");
dead = FALSE;
osSetHealth(llGetOwner(), 100);
osSetSpeed(llGetOwner(), 1);
llResetScript();
}
changed(integer change)
{
if(change & (CHANGED_REGION | CHANGED_OWNER | CHANGED_INVENTORY))
llResetScript();
}
}