4Creative_Sammel_und_Kampfs.../Meter v0.7.0

217 lines
5.8 KiB
Plaintext
Raw Normal View History

// 4CGS - Meter [v0.7.0]
// ► ◄ █ ▄ ■ ▲ ▼ © ▓ ░ ─ ↑ ↓ ▲ ▼ ✔ ✘ • ♫ « »
string PRGNAME = "4CGS - Meter";
string VERSION = "0.7.0";
string name = "";
integer hp = 0;
integer level = 0;
integer regchan = -1;
integer show_meter = TRUE;
integer meter_delay = 10; // 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 level {1} erreicht.";
default
{
state_entry()
{
getregionchannel();
name = llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], []), 0);
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)
{
if(id != llGetOwner())
check();
}
on_rez(integer x)
{
llResetScript();
}
changed(integer change)
{
if(change & (CHANGED_REGION | CHANGED_OWNER))
llResetScript();
}
dataserver(key id, string msg)
{
if(llSubStringIndex(llKey2Name(id), "4CGS") == 0)
{
if(msg == "HIDE")
{
llSetText("", <0,0,0>, 0);
return;
}
if(llSubStringIndex(msg, "NAME:") == 0 && llStringLength(msg) > 5)
name = llGetSubString(msg, 5, -1);
if(llSubStringIndex(msg, "LEVEL:") == 0 && llStringLength(msg) > 6)
{
level = (integer)llGetSubString(msg, 6, -1);
if(level > (integer)llGetObjectDesc())
{
llSetObjectDesc((string)level);
if(llGetTime() > meter_delay)
state level_up;
}
else if (level < (integer)llGetObjectDesc())
level = (integer)llGetObjectDesc();
}
if(llSubStringIndex(msg, "HP:") == 0 && llStringLength(msg) > 3)
{
set_hud_text();
hp = (integer)llGetSubString(msg, 3, -1);
if(hp < 0) hp = 0;
}
}
}
}
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(name);
llRegionSay(regchan, osFormatString(MSG_LEVELUP, [name, (string)level]));
llSetObjectName(n);
llSetTimerEvent(12);
llSetText("► LEVEL UP! ◄", <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);
}
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;
//llOwnerSay((string)prims);
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, 5, //(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;
}