4Creative_Sammel_und_Kampfs.../4CGS-Meter v0.07.02

225 lines
6.0 KiB
Plaintext
Raw Normal View History

2020-06-14 23:48:37 +00:00
// 4CGS - Meter [v0.07.01]
// ► ◄ █ ▄ ■ ▲ ▼ © ▓ ░ ─ ↑ ↓ ▲ ▼ ✔ ✘ • ♫ « »
string PRGNAME = "4CGS - Meter";
string VERSION = "0.07.01";
string name = "";
integer hp = 0;
integer level = 0;
integer regchan = -1;
integer show_meter = TRUE;
integer meter_delay = 15; // Zeit, wie lange der Text sichtbar ist.
string MSG_DROPPED = "Du hast Dein 4cGS Meter auf der Region an Position {0} fallen lassen. Es wird in 15 Minuten automatisch gelöscht.";
string MSG_WRONGATTACH = "Du musst das Meter an den Kopf Deines Avatars anlegen, damit es korrekt funktionieren kann.";
string MSG_LEVELUP = "{0} hat Stufe {1} erreicht.";
default
{
state_entry()
{
getregionchannel();
name = llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], []), 0);
// name in HUD Datei checken, wenn nicht vorhanden, Avaname setzen, sonst Rollenname
llSetAlpha(1, ALL_SIDES);
check();
llParticleSystem([]);
llPreloadSound("Level_Up");
llResetTime();
llSetTimerEvent(5);
}
timer()
{
if(llGetTime() > meter_delay)
{
llSetText("", <0,0,0>, 0);
llResetTime();
}
}
attach(key id)
{
llResetScript();
}
on_rez(integer x)
{
llResetScript();
}
changed(integer change)
{
if(change & (CHANGED_REGION | CHANGED_OWNER | CHANGED_INVENTORY))
llResetScript();
}
dataserver(key id, string msg)
{
if(llSubStringIndex(llKey2Name(id), "4CGS - Main HUD") == 0)
{
if(msg == "HIDE")
{
llSetText("", <0,0,0>, 0);
return;
}
if(llSubStringIndex(msg, "NAME:") == 0)
{
string _name_old = name;
name = llGetSubString(msg, 5, -1);
if(_name_old != name)
set_hud_text();
}
if(llSubStringIndex(msg, "LEVEL:") == 0)
{
integer _level_old = level;
level = (integer)llGetSubString(msg, 6, -1);
if(_level_old != level)
set_hud_text();
}
if(llSubStringIndex(msg, "LEVEL_UP:") == 0)
{
level = (integer)llGetSubString(msg, 9, -1);
state level_up;
}
if(llSubStringIndex(msg, "HP:") == 0)
{
integer _hp_old = hp;
hp = (integer)llGetSubString(msg, 3, -1);
if(hp < 0) hp = 0;
if(_hp_old != hp)
set_hud_text();
}
}
}
}
state inworld
{
state_entry()
{
llOwnerSay(osFormatString(MSG_WRONGATTACH, [(string)llGetPos()]));
llSetAlpha(1, ALL_SIDES);
llSetTimerEvent(900);
}
timer()
{
llDie();
}
}
state level_up
{
state_entry()
{
string n = llGetObjectName();
llSetObjectName("4CGS - System");
llRegionSay(regchan, osFormatString(">> " + MSG_LEVELUP, [name, (string)level]));
llSetObjectName(n);
particle_level_up();
llSetTimerEvent(12);
llSetText("► STUFENAUFSTIEG ◄", <1,1,0>, 1);
osAvatarPlayAnimation(llGetOwner(), "level_up");
llPlaySound("Level_Up", 1);
}
timer()
{
llSetTimerEvent(0);
llStopSound();
llParticleSystem([]);
osAvatarStopAnimation(llGetOwner(), "level_up");
llSetText("", <0,0,0>, 0);
state default;
}
}
set_hud_text()
{
if(show_meter == TRUE)
{
vector color = <0, 1, 0>;
if(hp == 0) color = <0,0,0>;
if (hp > 0) color = <0.8,0,0>;
if (hp > 24) color = <1,1,0>;
if (hp > 49) color = <0,1,0>;
llSetText("4CGS [v" + VERSION + "]\n────────────────────\n• " + name + " •\nLevel: " + level + "\n" + bar((float)hp, 100.0, 15), color, 1);
}
else
llSetText("", <0,0,0>,0);
llResetTime();
}
check()
{
if(llGetAttached() == 0)
state inworld;
if(llGetAttached() != 2)
{
llOwnerSay(MSG_WRONGATTACH);
osForceDetachFromAvatar();
}
else
llSetAlpha(0, ALL_SIDES);
}
string bar(float val, float max, integer len)
{
integer pro = llFloor((len / max) * val);
integer y;
string txt = "";
for(y = 0; y < len; y++)
txt += "░";
txt = osReplaceString(txt, "░", "█", pro, 0);
return txt;
}
particle_level_up()
{
//float prims = llRound(((float)llGetParcelPrimCount(llGetPos(), PARCEL_COUNT_TOTAL, TRUE) / 500) / 10) * 10;
llParticleSystem([
PSYS_PART_FLAGS,( 0
|PSYS_PART_INTERP_COLOR_MASK
|PSYS_PART_INTERP_SCALE_MASK
|PSYS_PART_FOLLOW_SRC_MASK
|PSYS_PART_FOLLOW_VELOCITY_MASK
|PSYS_PART_EMISSIVE_MASK ),
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE ,
PSYS_PART_START_ALPHA,1,
PSYS_PART_END_ALPHA,0.3,
PSYS_PART_START_COLOR,<1.0, 0.95, 0.3> ,
PSYS_PART_END_COLOR ,<1.0, 0.2, 0.5> ,
PSYS_PART_START_SCALE,<0.2, 0.2, 0>,
PSYS_PART_END_SCALE,<1, 1, 0>,
PSYS_PART_MAX_AGE,3,
PSYS_SRC_MAX_AGE,8.5,
PSYS_SRC_ACCEL,<0,0,-0.3>,
PSYS_SRC_BURST_PART_COUNT, 15, //(integer)prims,
PSYS_SRC_BURST_RADIUS, 10,
PSYS_SRC_BURST_RATE,0.05,
PSYS_SRC_BURST_SPEED_MIN,0.1,
PSYS_SRC_BURST_SPEED_MAX,0.7,
PSYS_SRC_ANGLE_BEGIN,1.5625,
PSYS_SRC_ANGLE_END,1.5625,
PSYS_SRC_OMEGA,<0,0,0>,
PSYS_SRC_TEXTURE, "star",
PSYS_SRC_TARGET_KEY, (key)llGetOwner()
]);
}
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;
}