986 lines
46 KiB
Plaintext
986 lines
46 KiB
Plaintext
|
// 4Creative Game System - Main HUD [v0.07.02]
|
||
|
|
||
|
// ToDo:
|
||
|
// - Gegestände verarbeiten einbauen (Pfeilspitze + Holz = Pfeil)
|
||
|
// - Max. Traglast einbauen (Jedes Item hat einGewicht in seinem Script)
|
||
|
// - Spielername vom Chatter holen
|
||
|
// - Meter bauen
|
||
|
// - Max. Traglast = Level * 2 Gegenstände (In Items einbauen)
|
||
|
// - Anzahl gesammelter Gegenstände vom Level und Zufall abhängig
|
||
|
// - HUD muss nach TP den Status abfragen und ggf. den Timer ausschalten.
|
||
|
// - Wenn inaktiv oder abgeschaltet statt Level entspr. Text anzeigen
|
||
|
// - Game Option: Avatar verlangsamen, wenn max. Gewicht fast erreicht ist.
|
||
|
// - Baklenfarben ändern (von gelb in violett)
|
||
|
// - Game Option: Meter immer sichtbar oder nur bei Bedaf (dann wie lange sichtbar?)
|
||
|
// - Objekt HUDs mit 1, 2, 3, 4 Plätzen bauen.
|
||
|
|
||
|
// ► ◄ █ ▄ ■ ▲ ▼ © ▓ ░ ─ ↑ ↓ ▲ ▼ ✔ ✘ • ♫ « »
|
||
|
|
||
|
integer m_min = FALSE; // HUD minimiert?
|
||
|
integer m_max_slots = 8; // Anzahl mx. erreichbare Slots (Wird in allen Objekten vom Setup Tool gesetzt)
|
||
|
float m_maxweight = 0.0; // Max. Traglasgt bei Level 0.
|
||
|
integer m_refreshtime = 183; // Nach welcher Zeit soll das HUD aktualisiert werden (Wird vom Setup Tool vorgegeben).
|
||
|
integer m_listener_socket = 0;
|
||
|
integer m_listener_channel = 0;
|
||
|
list m_last_touch = [];
|
||
|
string m_listener_state = "";
|
||
|
string m_last_action = "";
|
||
|
integer m_lastlevel = -1; // Wird für Level Up benötigt.
|
||
|
integer regchan = -1; // Wird für regionsweite Messages vom Setup Tool benötigt
|
||
|
integer reghandler = -1;
|
||
|
|
||
|
string m_lang_groupMessage = "Das 4CDS Spielsystem ist hier noch nicht eingerichtet! Bitte benutze das Setup-Tool.";
|
||
|
string m_lang_groupMessage_hud = "4CGS NICHT EINGERICHTET!";
|
||
|
string m_lang_regionchange = "REGIONSWECHSEL...";
|
||
|
string m_lang_disabled = "Das 4CDS Spielsystem ist derzeit deaktiviert.";
|
||
|
string m_lang_disabled_hud = "4CGS DEAKTIVIERT";
|
||
|
string m_lang_blueBoxDescText = "Was willst du mit '{0}' machen?\n \n{1}";
|
||
|
string m_lang_useToOther = "Auf wen möchtest du ' {0}' anwenden?";
|
||
|
string m_lang_deleteConfirm = "Dies ist ein wichtiges, vielleicht sogar ein einzigartiges Gegenstand. Bist du dir wirklich sicher dass du {0} nicht mehr brauchst?";
|
||
|
string m_lang_sendToOther = "An wen möchtest Du '{0}' weitergeben?";
|
||
|
string m_lang_selectActions = "Was möchtest Du mit '{0}' machen?";
|
||
|
string m_lang_avatarNotOnRegion = "{0} ist nicht mehr auf der Region.";
|
||
|
string m_lang_noFreeSlot = "{0} hat keinen freien Inventarplatz mehr!";
|
||
|
string m_lang_getItem = "{0} hat Dir {1} gegeben.";
|
||
|
string m_lang_deleteText = "Du hast {0} x {1} weggeworfen. Deine Traglast erhöht sich um {2}kg auf {3}kg.";
|
||
|
string m_lang_ja = "JA";
|
||
|
string m_lang_nein = "NEIN";
|
||
|
string m_lang_leveltext = "Level: {0} [XP: {1}]";
|
||
|
string m_lang_init = "Aktualisierung...";
|
||
|
string m_lang_maxlevel = "Du hast den höchstmöglichen Level (Level {0}) erreicht.";
|
||
|
string m_lang_maxweight = "Sorry, Du kannst nicht mehr tragen.";
|
||
|
string m_lang_newname = "Gib bitte hier Deinen RP Spielernamen ein:";
|
||
|
string m_lang_kill = "Wegwerfen";
|
||
|
string m_lang_use = "Benutzen";
|
||
|
string m_lang_give = "Weitergeben";
|
||
|
string m_lang_btn_close = "Schließen ";
|
||
|
string m_lang_btn_sound = "Ton ✔";
|
||
|
string m_lang_btn_sound_on = "Ton ✔";
|
||
|
string m_lang_btn_sound_off = "Ton ✘";
|
||
|
string m_lang_btn_messages = "Meldungen ✔";
|
||
|
string m_lang_btn_messages_on = "Meldungen ✔";
|
||
|
string m_lang_btn_messages_off = "Meldungen ✘";
|
||
|
string m_lang_reset = "Zurücksetzen";
|
||
|
string line = "────────────────────────────────────────";
|
||
|
list m_dataStore = [];
|
||
|
list m_dataUserStore = [];
|
||
|
list m_current = [];
|
||
|
integer m_playsound = TRUE;
|
||
|
|
||
|
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;
|
||
|
|
||
|
llListenRemove(reghandler);
|
||
|
reghandler = llListen(regchan, "", "", "" );
|
||
|
}
|
||
|
|
||
|
change_iconsize(integer prim)
|
||
|
{
|
||
|
string primname = llGetLinkName(prim);
|
||
|
if(primname == llGetObjectName() || llSubStringIndex(primname, "inv-slot") == 0 || primname == "LOGO" || primname == "preferences")
|
||
|
{
|
||
|
vector size = llList2Vector(llGetLinkPrimitiveParams(prim, [PRIM_SIZE]), 0);
|
||
|
llSetLinkPrimitiveParamsFast(prim, [PRIM_SIZE, size - <0.00, size.y - (size.y * 0.8), size.z - (size.z * 0.8)>]);
|
||
|
if(llSubStringIndex(primname, "inv-slot") == 0)
|
||
|
{
|
||
|
if(m_playsound == TRUE)
|
||
|
osPlaySound(LINK_THIS, "inventar", 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(m_playsound == TRUE)
|
||
|
osPlaySound(LINK_THIS, "click", 1);
|
||
|
}
|
||
|
llSleep(0.20);
|
||
|
llSetLinkPrimitiveParamsFast(prim, [PRIM_SIZE, size]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
minmax()
|
||
|
{
|
||
|
m_min = !m_min;
|
||
|
vector minmax_size = llList2Vector(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_SIZE]), 0);
|
||
|
if(m_min == FALSE)
|
||
|
{
|
||
|
llSetLocalRot(llEuler2Rot(<0, 0, 0> * DEG_TO_RAD));
|
||
|
llSetTimerEvent(m_refreshtime);
|
||
|
refreshData();
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
llSetLocalRot(llEuler2Rot(<0, 180, 0> * DEG_TO_RAD));
|
||
|
llSetTimerEvent(0);
|
||
|
osMessageAttachments(llGetOwner(), "HIDE", [ATTACH_HEAD], 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
updateTime(integer _update)
|
||
|
{
|
||
|
// Wenn System inaktiv ist, nichts abziehen!
|
||
|
integer _checkTime = llGetUnixTime() - (integer)getDataEntryFromDataList(m_dataUserStore, "stats.lastCheck");
|
||
|
|
||
|
integer _food = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.essen");
|
||
|
integer _xp = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.xp");
|
||
|
integer _water = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.wasser");
|
||
|
|
||
|
integer _updatedStats = FALSE;
|
||
|
|
||
|
integer _currentMin = 0;
|
||
|
for(_currentMin = 1; _currentMin <= (_checkTime / 60); ++_currentMin)
|
||
|
{
|
||
|
_food -= (integer)getDataEntryFromDataList(m_dataUserStore, "stats.levels.sub_food");
|
||
|
_water -= (integer)getDataEntryFromDataList(m_dataUserStore, "stats.levels.sub_water");
|
||
|
//llOwnerSay("FOOD: " + (string)_food + " " + (string)_water);
|
||
|
_updatedStats = TRUE;
|
||
|
}
|
||
|
|
||
|
if(_updatedStats == TRUE)
|
||
|
{
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.essen", _food);
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.wasser", _water);
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.xp", _xp);
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.lastCheck", llGetUnixTime());
|
||
|
}
|
||
|
|
||
|
if(_update == TRUE)
|
||
|
refreshData();
|
||
|
}
|
||
|
|
||
|
default
|
||
|
{
|
||
|
state_entry()
|
||
|
{
|
||
|
getregionchannel();
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_init, <1, 0.8, 0>, 1]);
|
||
|
llPreloadSound("click");
|
||
|
llPreloadSound("inventar");
|
||
|
m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
m_max_slots = getDataEntryFromDataList(m_dataStore, "hud.slots");
|
||
|
if((integer)checkDataEntryInDataList(m_dataStore, "enable") == TRUE)
|
||
|
{
|
||
|
if((integer)getDataEntryFromDataList(m_dataStore, "stats.enable") == TRUE)
|
||
|
{
|
||
|
llSetTimerEvent(m_refreshtime);
|
||
|
startGame();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
llOwnerSay(m_lang_disabled);
|
||
|
disableBalken();
|
||
|
llSetTimerEvent(0);
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_disabled_hud, <1, 0.8, 0>, 1]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
llOwnerSay(m_lang_groupMessage);
|
||
|
disableBalken();
|
||
|
llSetTimerEvent(0);
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_groupMessage_hud, <1, 0.8, 0>, 1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
timer()
|
||
|
{
|
||
|
|
||
|
m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.lastCheck", llGetUnixTime());
|
||
|
updateTime(TRUE);
|
||
|
}
|
||
|
|
||
|
attach(key id)
|
||
|
{
|
||
|
if(id)
|
||
|
{
|
||
|
llResetScript();
|
||
|
// m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
// m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
|
||
|
// updateTime(FALSE);
|
||
|
// startGame();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
touch_start(integer i)
|
||
|
{
|
||
|
m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
change_iconsize(llDetectedLinkNumber(0));
|
||
|
if(checkDataEntryInDataList(m_dataStore, "enable") == FALSE)
|
||
|
{
|
||
|
llOwnerSay(m_lang_groupMessage);
|
||
|
disableBalken();
|
||
|
osMessageAttachments(llGetOwner(), "4CGS-DISABLE", [ATTACH_HUD_CENTER_1, ATTACH_HUD_CENTER_2], 0);
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_groupMessage_hud, <1, 0.8, 0>, 1]);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if((integer)getDataEntryFromDataList(m_dataStore, "stats.enable") == FALSE)
|
||
|
{
|
||
|
llOwnerSay(m_lang_disabled);
|
||
|
disableBalken();
|
||
|
osMessageAttachments(llGetOwner(), "4CGS-DISABLE", [ATTACH_HUD_CENTER_1, ATTACH_HUD_CENTER_2], 0);
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_disabled_hud, <1, 0.8, 0>, 1]);
|
||
|
return;
|
||
|
}
|
||
|
osMessageAttachments(llGetOwner(), "4CGS-ENABLE", [ATTACH_HUD_CENTER_1, ATTACH_HUD_CENTER_2], 0);
|
||
|
m_last_touch = llParseString2List(llGetLinkName(llDetectedLinkNumber(0)), ["-"], []);
|
||
|
m_listener_state = "main";
|
||
|
|
||
|
if(llList2String(m_last_touch, 0) == "inv" && llList2String(m_last_touch, 1) == "slot")
|
||
|
{
|
||
|
integer _inventarSlot = llList2String(m_last_touch, 2);
|
||
|
string _inventarItemName = getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _inventarSlot);
|
||
|
list _inventarItemDataStorage = getDataListFromDataStorage("item." +_inventarItemName);
|
||
|
string _inventarItemDisplayName = getDataEntryFromDataList(_inventarItemDataStorage, "displayname");
|
||
|
string _inventarItemBeschreibung = getDataEntryFromDataList(_inventarItemDataStorage, "beschreibung");
|
||
|
|
||
|
if(_inventarItemName != "")
|
||
|
{
|
||
|
list _aktionen = [m_lang_kill, m_lang_use, m_lang_give];
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "selected", _inventarSlot);
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
llDialog(llDetectedKey(0), line + "\n" + osFormatString(m_lang_blueBoxDescText, [_inventarItemDisplayName, _inventarItemBeschreibung]), _aktionen, m_listener_channel);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(llGetLinkName(llDetectedLinkNumber(0)) == llGetObjectName())
|
||
|
{
|
||
|
change_iconsize(llGetLinkName(llDetectedLinkNumber(0)));
|
||
|
minmax();
|
||
|
refreshData();
|
||
|
}
|
||
|
|
||
|
if(llGetLinkName(llDetectedLinkNumber(0)) == "preferences")
|
||
|
llResetScript();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
listen(integer channel, string name, key id, string message )
|
||
|
{
|
||
|
m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
if(left(message, ";") == "gamecommand")
|
||
|
{
|
||
|
if(right(message, ";") == "reload")
|
||
|
{
|
||
|
if(llSubStringIndex(llKey2Name(id), "4CGS - Control-Terminal") != -1)
|
||
|
{
|
||
|
disableBalken();
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_init, <1, 0.5, 0>, 1]);
|
||
|
llSleep(2.5);
|
||
|
}
|
||
|
refreshData();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
integer _inventarSlot = llList2String(m_last_touch, 2);
|
||
|
string _inventarItemName = getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _inventarSlot);
|
||
|
|
||
|
if(_inventarItemName != "")
|
||
|
{
|
||
|
list _inventarItemDataStorage = getDataListFromDataStorage("item." +_inventarItemName);
|
||
|
string _inventarItemDisplayName = getDataEntryFromDataList(_inventarItemDataStorage, "displayname");
|
||
|
string _inventarItemDUnique = getDataEntryFromDataList(_inventarItemDataStorage, "unique");
|
||
|
|
||
|
if(m_listener_state == "main")
|
||
|
{
|
||
|
if(message == m_lang_kill)
|
||
|
{
|
||
|
if(_inventarItemDUnique != "TRUE")
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_deleteText, [getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count"), _inventarItemDisplayName, llGetSubString(calcPlayerWeight(m_dataUserStore), 0, llSubStringIndex(calcPlayerWeight(m_dataUserStore), ".") + 2), llGetSubString(getMaxPlayerWeight(m_dataUserStore), 0, llSubStringIndex(getMaxPlayerWeight(m_dataUserStore), ".") + 2)]));
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot, "");
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", "0");
|
||
|
refreshData();
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_listener_state = "confirmDelete";
|
||
|
llDialog(llGetOwner(), osFormatString(m_lang_deleteConfirm, [_inventarItemDisplayName]), [m_lang_ja, m_lang_nein], m_listener_channel);
|
||
|
}
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(message == m_lang_give)
|
||
|
{
|
||
|
list _avatars = llGetAgentList(AGENT_LIST_REGION, []);
|
||
|
integer _avatarsCount = llGetListLength(_avatars);
|
||
|
list _player = [];
|
||
|
|
||
|
while(_avatarsCount--)
|
||
|
if(osCheckDataValue("game.hud.player." + llList2String(_avatars, _avatarsCount)))
|
||
|
if(llList2Key(_avatars, _avatarsCount) != llGetOwner())
|
||
|
_player += [left(left(llKey2Name(llList2String(_avatars, _avatarsCount)), " "), ".")];
|
||
|
|
||
|
m_listener_state = "give";
|
||
|
llDialog(llGetOwner(), osFormatString(m_lang_sendToOther, [_inventarItemDisplayName]), _player, m_listener_channel);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(message == m_lang_use)
|
||
|
{
|
||
|
list _actionen = [];
|
||
|
|
||
|
list _inventarItemInternalActions = llParseString2List(getDataEntryFromDataList(_inventarItemDataStorage, "actions"), [";"], []);
|
||
|
integer _inventarItemInternalActionsCount = llGetListLength(_inventarItemInternalActions);
|
||
|
|
||
|
while(_inventarItemInternalActionsCount--)
|
||
|
{
|
||
|
string _actionName = llList2String(_inventarItemInternalActions, _inventarItemInternalActionsCount);
|
||
|
|
||
|
if(_actionName != "")
|
||
|
_actionen += [getDataEntryFromDataList(_inventarItemDataStorage, "actions." + _actionName + ".displayname")];
|
||
|
}
|
||
|
|
||
|
m_listener_state = "use";
|
||
|
llDialog(llGetOwner(), osFormatString(m_lang_selectActions, [_inventarItemDisplayName]), _actionen, m_listener_channel);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else if(m_listener_state == "give")
|
||
|
{
|
||
|
list _allAvatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []);
|
||
|
integer _allAvatarsInRegionCount = llGetListLength(_allAvatarsInRegion);
|
||
|
key _selectedTargetAvatar = NULL_KEY;
|
||
|
|
||
|
while(_allAvatarsInRegionCount--)
|
||
|
{
|
||
|
string _avatarID = left(left(llKey2Name(llList2String(_allAvatarsInRegion, _allAvatarsInRegionCount)), " "), ".");
|
||
|
|
||
|
if(_avatarID == message)
|
||
|
_selectedTargetAvatar = llList2Key(_allAvatarsInRegion, _allAvatarsInRegionCount);
|
||
|
}
|
||
|
|
||
|
if(_selectedTargetAvatar == NULL_KEY)
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_avatarNotOnRegion, [llKey2Name(_selectedTargetAvatar)]));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
list _selectedTargetAvatarDataStorage = getDataListFromDataStorage("game.hud.player." + _selectedTargetAvatar);
|
||
|
integer _selectedTargetAvatarInventarSlot = getInventarSlot(_selectedTargetAvatarDataStorage, _inventarItemName);
|
||
|
|
||
|
if(_selectedTargetAvatarInventarSlot == 0)
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_noFreeSlot, [message]));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(getMaxPlayerWeight(_selectedTargetAvatarDataStorage) < calcPlayerWeight(_selectedTargetAvatarDataStorage))
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_maxweight, [llGetSubString((string)getMaxPlayerWeight(_selectedTargetAvatarDataStorage), llSubStringIndex((string)getMaxPlayerWeight(_selectedTargetAvatarDataStorage), ".") + 2, -1)]));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_selectedTargetAvatarDataStorage = setDataEntryInDataList(_selectedTargetAvatarDataStorage, "inventar.slot." + _selectedTargetAvatarInventarSlot, _inventarItemName);
|
||
|
_selectedTargetAvatarDataStorage = setDataEntryInDataList(_selectedTargetAvatarDataStorage, "inventar.slot." + _selectedTargetAvatarInventarSlot + ".count", getItemCountFromSlot(_selectedTargetAvatarDataStorage, _selectedTargetAvatarInventarSlot) + 1);
|
||
|
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", (integer)getItemCountFromSlot(m_dataUserStore, _inventarSlot) - 1);
|
||
|
|
||
|
if(getItemCountFromSlot(m_dataUserStore, _inventarSlot) <= 0)
|
||
|
{
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot, "");
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", "0");
|
||
|
}
|
||
|
|
||
|
saveDataListToDataStorage(_selectedTargetAvatarDataStorage, "game.hud.player." + _selectedTargetAvatar);
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
|
||
|
refreshData();
|
||
|
llRegionSay((integer)(integer)getDataEntryFromDataList(_selectedTargetAvatarDataStorage, "channel"), "gamecommand;reload");
|
||
|
llRegionSayTo(_selectedTargetAvatar, 0, osFormatString(m_lang_getItem, [llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], [""]), 0), _inventarItemDisplayName]));
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
else if(m_listener_state == "use")
|
||
|
{
|
||
|
useAction(_inventarItemName, message, _inventarSlot, llGetOwner(), FALSE);
|
||
|
}
|
||
|
else if(m_listener_state == "confirmDelete")
|
||
|
{
|
||
|
if(message == m_lang_ja)
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_deleteText, [getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count")]));
|
||
|
setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot, "");
|
||
|
setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", "0");
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
refreshData();
|
||
|
}
|
||
|
}
|
||
|
else if(m_listener_state == "getTarget")
|
||
|
{
|
||
|
list _allAvatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []);
|
||
|
integer _allAvatarsInRegionCount = llGetListLength(_allAvatarsInRegion);
|
||
|
key _selectedTargetAvatar = NULL_KEY;
|
||
|
|
||
|
while(_allAvatarsInRegionCount--)
|
||
|
{
|
||
|
string _avatarID = left(left(llKey2Name(llList2String(_allAvatarsInRegion, _allAvatarsInRegionCount)), " "), ".");
|
||
|
|
||
|
if(_avatarID == message)
|
||
|
_selectedTargetAvatar = llList2Key(_allAvatarsInRegion, _allAvatarsInRegionCount);
|
||
|
}
|
||
|
|
||
|
if(_selectedTargetAvatar == NULL_KEY)
|
||
|
{
|
||
|
llOwnerSay(osFormatString(m_lang_avatarNotOnRegion, [""]));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
useAction(_inventarItemName, m_last_action, _inventarSlot, _selectedTargetAvatar, TRUE);
|
||
|
if(m_playsound == TRUE)
|
||
|
osPlaySound(LINK_THIS, "inventar", 1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
dataserver(key id, string msg)
|
||
|
{
|
||
|
if(llSubStringIndex(llKey2Name(id), "4CGS") != -1)
|
||
|
{
|
||
|
if(llSubStringIndex(msg, "4CGS-DAMAGE:") != -1)
|
||
|
{
|
||
|
integer _hp = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.hp");
|
||
|
integer _damage = (integer)osReplaceString(msg, "4CGS-DAMAGE:", "", -1, 0);
|
||
|
if(_hp == 0)
|
||
|
return;
|
||
|
_hp -= _damage;
|
||
|
if(_hp <= 0)
|
||
|
{
|
||
|
_hp = 0;
|
||
|
osMessageAttachments(id, "4CGS-DIE", [31, 32, 33, 34, 35, 36, 37, 38], 0);
|
||
|
}
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", (string)_hp);
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
refreshData();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
changed(integer change)
|
||
|
{
|
||
|
if(change & (CHANGED_REGION | CHANGED_INVENTORY))
|
||
|
{
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_regionchange, <1, 0.5, 0>, 1]);
|
||
|
cleanGameState();
|
||
|
llSleep(5);
|
||
|
llResetScript();
|
||
|
//m_dataStore = getDataListFromDataStorage("game.hud");
|
||
|
//refreshData();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Spielfunktionen
|
||
|
|
||
|
cleanGameState()
|
||
|
{
|
||
|
if(m_listener_socket != 0)
|
||
|
llListenRemove(m_listener_socket);
|
||
|
|
||
|
integer i;
|
||
|
for(i = 1; i < m_max_slots; i++)
|
||
|
{
|
||
|
setInventarSlotImage(i, TEXTURE_BLANK, 0);
|
||
|
setInventarSlotCountNumber(i, 0);
|
||
|
}
|
||
|
|
||
|
disableBalken();
|
||
|
}
|
||
|
|
||
|
disableBalken()
|
||
|
{
|
||
|
setLevelDisplayNumber(0, 0, 0);
|
||
|
setBalkenValue("wasser", 0);
|
||
|
setBalkenValue("essen", 0);
|
||
|
setBalkenValue("xp", 0);
|
||
|
setBalkenValue("hp", 0);
|
||
|
setBalkenValue("weight", 0);
|
||
|
}
|
||
|
startGame()
|
||
|
{
|
||
|
cleanGameState();
|
||
|
disableBalken();
|
||
|
if((integer)checkDataEntryInDataList(m_dataStore, "enable") == FALSE || (integer)getDataEntryFromDataList(m_dataStore, "enable") == FALSE)
|
||
|
{
|
||
|
llOwnerSay(m_lang_groupMessage);
|
||
|
disableBalken();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
m_listener_channel = Key2AppChan(llGetOwner(), 39724);
|
||
|
m_listener_socket = llListen(m_listener_channel, "", "", "");
|
||
|
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "channel", m_listener_channel);
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "player", "true");
|
||
|
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "stats.essen") == FALSE)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.essen", "100");
|
||
|
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "stats.wasser") == FALSE)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.wasser", "100");
|
||
|
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "stats.xp") == FALSE)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.xp", "0");
|
||
|
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "stats.hp") == FALSE)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", "100");
|
||
|
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "stats.lastCheck") == FALSE)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.lastCheck", llGetUnixTime());
|
||
|
|
||
|
integer i;
|
||
|
for (i = 1; i <= m_max_slots; i++)
|
||
|
{
|
||
|
if(checkDataEntryInDataList(m_dataUserStore, "inventar.slot." + i) == FALSE)
|
||
|
{
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + i, "");
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + i + ".count", "0");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
refreshData();
|
||
|
}
|
||
|
|
||
|
integer getInventarSlot(list _userStorage, string itemName)
|
||
|
{
|
||
|
integer _currentSlot;
|
||
|
integer _freeSlot = 0;
|
||
|
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||
|
{
|
||
|
if(getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot) == itemName)
|
||
|
return _currentSlot;
|
||
|
|
||
|
if(getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot) == "")
|
||
|
if(_freeSlot == 0)
|
||
|
_freeSlot = _currentSlot;
|
||
|
}
|
||
|
|
||
|
return _freeSlot;
|
||
|
}
|
||
|
|
||
|
integer getItemCountFromSlot(list _userStorage, integer _slot)
|
||
|
{
|
||
|
integer _returnValue = (integer)getDataEntryFromDataList(_userStorage, "inventar.slot." + _slot + ".count");
|
||
|
return _returnValue;
|
||
|
}
|
||
|
|
||
|
float calcPlayerWeight(list _userStorage)
|
||
|
{
|
||
|
integer _currentSlot;
|
||
|
float _currentWeight = 0;
|
||
|
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||
|
{
|
||
|
if(getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot) != "")
|
||
|
{
|
||
|
string _itemName = getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot);
|
||
|
list _itemData = getDataListFromDataStorage("item." +_itemName);
|
||
|
|
||
|
integer _itemCount = getItemCountFromSlot(_userStorage, _currentSlot);
|
||
|
float _itemWeight = (float)getDataEntryFromDataList(_itemData, "weight");
|
||
|
|
||
|
_currentWeight = _currentWeight + (_itemCount * _itemWeight);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return _currentWeight;
|
||
|
}
|
||
|
|
||
|
float getMaxPlayerWeight(list _userDataStorage)
|
||
|
{
|
||
|
float _maxweight = (float)getDataEntryFromDataList(m_dataStore, "stats.levels.maxweight");
|
||
|
float _xpMultiplier = (float)getDataEntryFromDataList(m_dataStore, "stats.levels.multiplier");
|
||
|
|
||
|
list _levelData = calcLevelData(_userDataStorage);
|
||
|
integer _playerLevel = llList2Integer(_levelData, 0) + 1;
|
||
|
|
||
|
float _playerMaxWight = _maxweight + ((float)_playerLevel * _xpMultiplier);
|
||
|
|
||
|
return _playerMaxWight;
|
||
|
}
|
||
|
|
||
|
list calcLevelData(list _dataStorage)
|
||
|
{
|
||
|
integer _xpLevelStep = (integer)getDataEntryFromDataList(m_dataStore, "stats.levels.firstStep");
|
||
|
integer _maxlevel = (integer)getDataEntryFromDataList(m_dataStore, "stats.levels.maxlevel");
|
||
|
|
||
|
float _xpLevelStepMultiplier = (float)getDataEntryFromDataList(m_dataStore, "stats.levels.multiplier");
|
||
|
integer _currentXP = (integer)getDataEntryFromDataList(_dataStorage, "stats.xp");
|
||
|
integer _currentLevel = 0;
|
||
|
|
||
|
integer _xpNeedForNextLevel = _xpLevelStep * _xpLevelStepMultiplier;
|
||
|
|
||
|
while(_currentXP > _xpNeedForNextLevel)
|
||
|
{
|
||
|
if(_currentLevel <= _maxlevel)
|
||
|
{
|
||
|
_currentLevel = _currentLevel + 1;
|
||
|
_currentXP = _currentXP - _xpNeedForNextLevel;
|
||
|
_xpNeedForNextLevel = (_xpNeedForNextLevel * _xpLevelStepMultiplier);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return [_currentLevel, (integer)_currentXP, _xpNeedForNextLevel];
|
||
|
}
|
||
|
|
||
|
|
||
|
refreshData()
|
||
|
{
|
||
|
integer _currentSlot;
|
||
|
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||
|
{
|
||
|
if(getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _currentSlot) != "")
|
||
|
{
|
||
|
integer _count = getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _currentSlot + ".count");
|
||
|
setInventarSlotImage(_currentSlot, getInventarObjectImageKey(getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _currentSlot)), 255);
|
||
|
setInventarSlotCountNumber(_currentSlot, _count);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
setInventarSlotImage(_currentSlot, TEXTURE_BLANK, 0);
|
||
|
setInventarSlotCountNumber(_currentSlot, 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
list _levelData = calcLevelData(m_dataUserStore);
|
||
|
setLevelDisplayNumber(llList2Integer(_levelData, 0), llList2Integer(_levelData, 1), llList2Integer(_levelData, 2));
|
||
|
|
||
|
float _xpBalkenValue = (float)((100 / llList2Float(_levelData, 2)) * llList2Float(_levelData, 1));
|
||
|
float _hpBalkenValue = (float)((llList2Integer(_levelData, 0) * 100) / 100);
|
||
|
integer _food = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.essen");
|
||
|
integer _water = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.wasser");
|
||
|
integer _hp = (integer)getDataEntryFromDataList(m_dataUserStore, "stats.hp");
|
||
|
integer _level = llList2Integer(_levelData, 0);
|
||
|
if(_food > 100)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.essen", "100");
|
||
|
|
||
|
if(_food < 0)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.essen", "0");
|
||
|
|
||
|
if(_water > 100)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.wasser", "100");
|
||
|
|
||
|
if(_water < 0)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.wasser", "0");
|
||
|
|
||
|
if(_hp > 100)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", "100");
|
||
|
|
||
|
if(_hp < 0)
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", "0");
|
||
|
|
||
|
setBalkenValue("wasser", _water);
|
||
|
setBalkenValue("essen" , _food);
|
||
|
setBalkenValue("hp" , _hp);
|
||
|
setBalkenValue("xp" , _xpBalkenValue);
|
||
|
setBalkenValue("weight", (integer)(100 / (float)getMaxPlayerWeight(getDataListFromDataStorage("game.hud.player." + llGetOwner())) * (float)calcPlayerWeight(m_dataUserStore)));
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
osMessageAttachments(llGetOwner(), "LEVEL:" + (string)_level, [ATTACH_HEAD], 0);
|
||
|
osMessageAttachments(llGetOwner(), "HP:" + getDataEntryFromDataList(m_dataUserStore, "stats.hp"), [ATTACH_HEAD], 0);
|
||
|
|
||
|
if(m_lastlevel == -1)
|
||
|
m_lastlevel = _level;
|
||
|
|
||
|
if(_level > m_lastlevel)
|
||
|
{
|
||
|
m_lastlevel = _level;
|
||
|
osMessageAttachments(llGetOwner(), "LEVEL_UP:" + (string)_level, [ATTACH_HEAD], 0);
|
||
|
}
|
||
|
|
||
|
if((integer)checkDataEntryInDataList(m_dataStore, "enable") == FALSE || (integer)getDataEntryFromDataList(m_dataStore, "enable") == FALSE)
|
||
|
osMessageAttachments(llGetOwner(), "4CGS-DISABLE", [ATTACH_HUD_CENTER_1, ATTACH_HUD_CENTER_2], 0);
|
||
|
else
|
||
|
osMessageAttachments(llGetOwner(), "4CGS-ENABLE", [ATTACH_HUD_CENTER_1, ATTACH_HUD_CENTER_2], 0);
|
||
|
}
|
||
|
|
||
|
useAction(string _itemName, string _actionName, integer _slot, key _avatar, integer _other)
|
||
|
{
|
||
|
integer _inventarSlot = llList2String(m_last_touch, 2);
|
||
|
string _inventarItemName = getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _inventarSlot);
|
||
|
|
||
|
list _targetUserDataStore = getDataListFromDataStorage("game.hud.player." + _avatar);
|
||
|
list _getItems = [];
|
||
|
|
||
|
m_last_action = _actionName;
|
||
|
|
||
|
if(_inventarItemName != "")
|
||
|
{
|
||
|
list _inventarItemDataStorage = getDataListFromDataStorage("item." +_inventarItemName);
|
||
|
string _inventarItemDisplayName = getDataEntryFromDataList(_inventarItemDataStorage, "displayname");
|
||
|
string _inventarItemDUnique = getDataEntryFromDataList(_inventarItemDataStorage, "unique");
|
||
|
|
||
|
list _inventarItemInternalActions = llParseString2List(getDataEntryFromDataList(_inventarItemDataStorage, "actions"), [";"], []);
|
||
|
integer _inventarItemInternalActionsCount = llGetListLength(_inventarItemInternalActions);
|
||
|
|
||
|
while(_inventarItemInternalActionsCount--)
|
||
|
{
|
||
|
string _inventarItemInternalActionName = llList2String(_inventarItemInternalActions, _inventarItemInternalActionsCount);
|
||
|
string _inventarItemInternalActionDisplayname = getDataEntryFromDataList(_inventarItemDataStorage, "actions." + _inventarItemInternalActionName + ".displayname");
|
||
|
string _inventarItemInternalActionSetTarget = getDataEntryFromDataList(_inventarItemDataStorage, "actions." + _inventarItemInternalActionName + ".setTarget");
|
||
|
string _inventarItemInternalActionConsume = getDataEntryFromDataList(_inventarItemDataStorage, "actions." + _inventarItemInternalActionName + ".consume");
|
||
|
|
||
|
list _inventarItemInternalActionTasks = llParseString2List(getDataEntryFromDataList(_inventarItemDataStorage, "actions." + _inventarItemInternalActionName + ".tasks"), [";"], []);
|
||
|
integer _inventarItemInternalActionTasksCount = llGetListLength(_inventarItemInternalActionTasks);
|
||
|
|
||
|
if(_inventarItemInternalActionDisplayname == _actionName)
|
||
|
{
|
||
|
if(_inventarItemInternalActionSetTarget != "TRUE" || _other == TRUE)
|
||
|
{
|
||
|
while(_inventarItemInternalActionTasksCount--)
|
||
|
{
|
||
|
string _actionStringAction = left(llList2String(_inventarItemInternalActionTasks, _inventarItemInternalActionTasksCount), ":");
|
||
|
string _actionStringArgs = right(llList2String(_inventarItemInternalActionTasks, _inventarItemInternalActionTasksCount), ":");
|
||
|
|
||
|
if(_actionStringAction == "say")
|
||
|
llDialog(_avatar, " \n \n" + _actionStringArgs, [], -1);
|
||
|
|
||
|
if(_actionStringAction == "addFood")
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "stats.essen", (integer)getDataEntryFromDataList(_targetUserDataStore, "stats.essen") + (integer)_actionStringArgs);
|
||
|
|
||
|
if(_actionStringAction == "addWater")
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "stats.wasser", (integer)getDataEntryFromDataList(_targetUserDataStore, "stats.wasser") + (integer)_actionStringArgs);
|
||
|
|
||
|
if(_actionStringAction == "addXP")
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "stats.xp", (integer)getDataEntryFromDataList(_targetUserDataStore, "stats.xp") + (integer)_actionStringArgs);
|
||
|
|
||
|
if(_actionStringAction == "addHP")
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "stats.hp", (integer)getDataEntryFromDataList(_targetUserDataStore, "stats.hp") + (integer)_actionStringArgs);
|
||
|
|
||
|
if(_actionStringAction == "getItem")
|
||
|
_getItems += [_actionStringArgs];
|
||
|
|
||
|
if(_actionStringAction == "contextSwitch")
|
||
|
{
|
||
|
saveDataListToDataStorage(_targetUserDataStore, "game.hud.player." + _avatar);
|
||
|
_targetUserDataStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
_avatar = llGetOwner();
|
||
|
}
|
||
|
|
||
|
if(_actionStringAction == "attach")
|
||
|
llRegionSay((integer)_actionStringArgs, "attach|" + _avatar);
|
||
|
|
||
|
if(_actionStringAction == "custom")
|
||
|
{
|
||
|
integer customChannel = (integer)left(_actionStringArgs, ",");
|
||
|
string customText = right(_actionStringArgs, ",");
|
||
|
llRegionSay(customChannel, customText);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
integer _getItemsListCount = llGetListLength(_getItems);
|
||
|
while(_getItemsListCount--)
|
||
|
{
|
||
|
string _getItemsName = left(llList2String(_getItems, _getItemsListCount), "=");
|
||
|
string _getItemsCount = right(llList2String(_getItems, _getItemsListCount), "=");
|
||
|
|
||
|
integer _invSlot = getInventarSlot(_targetUserDataStore, _getItemsName);
|
||
|
|
||
|
if(_invSlot == 0)
|
||
|
{
|
||
|
llRegionSayTo(_avatar, 0, osFormatString(m_lang_noFreeSlot, [_getItemsName]));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "inventar.slot." + _invSlot, _getItemsName);
|
||
|
_targetUserDataStore = setDataEntryInDataList(_targetUserDataStore, "inventar.slot." + _invSlot + ".count", (integer)getItemCountFromSlot(_targetUserDataStore, _invSlot) + (integer)_getItemsCount);
|
||
|
|
||
|
}
|
||
|
|
||
|
saveDataListToDataStorage(_targetUserDataStore, "game.hud.player." + _avatar);
|
||
|
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||
|
|
||
|
if(_inventarItemInternalActionConsume == "TRUE")
|
||
|
{
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", (integer)getItemCountFromSlot(m_dataUserStore, _inventarSlot) - 1);
|
||
|
|
||
|
if(getItemCountFromSlot(m_dataUserStore, _inventarSlot) <= 0)
|
||
|
{
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot, "");
|
||
|
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", "");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||
|
|
||
|
if(_other == TRUE)
|
||
|
llRegionSay((integer)getDataEntryFromDataList(_targetUserDataStore, "channel"), "gamecommand;reload");
|
||
|
|
||
|
refreshData();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_listener_state = "getTarget";
|
||
|
|
||
|
list _allAvatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []);
|
||
|
integer _allAvatarsInRegionCount = llGetListLength(_allAvatarsInRegion);
|
||
|
list _player = [];
|
||
|
|
||
|
while(_allAvatarsInRegionCount--)
|
||
|
if(osCheckDataValue("game.hud.player." + llList2String(_allAvatarsInRegion, _allAvatarsInRegionCount)))
|
||
|
_player += [left(left(llKey2Name(llList2String(_allAvatarsInRegion, _allAvatarsInRegionCount)), " "), ".")];
|
||
|
|
||
|
llDialog(_avatar, osFormatString(m_lang_useToOther, [_inventarItemInternalActionDisplayname]), _player, m_listener_channel);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
key getInventarObjectImageKey(string objektName)
|
||
|
{
|
||
|
list _inventarItemDataStorage = getDataListFromDataStorage("item." + objektName);
|
||
|
string _inventarItemImage = getDataEntryFromDataList(_inventarItemDataStorage, "image");
|
||
|
|
||
|
if(_inventarItemImage != "")
|
||
|
return (key)_inventarItemImage;
|
||
|
|
||
|
return TEXTURE_BLANK;
|
||
|
}
|
||
|
|
||
|
setInventarSlotImage(integer slot, key imageID, integer alpha)
|
||
|
{
|
||
|
if(getDataEntryFromDataList(m_current, "state.slot."+ slot) != (string)imageID)
|
||
|
{
|
||
|
integer _linkCount = osGetLinkNumber("inv-slot-" + slot);
|
||
|
llSetLinkAlpha(_linkCount, alpha, 4);
|
||
|
llSetLinkTexture(_linkCount, imageID, 4);
|
||
|
|
||
|
m_current = setDataEntryInDataList(m_current, "state.slot."+ slot, (string)imageID);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
setBalkenValue(string balken, integer count) // integer max
|
||
|
{
|
||
|
if((integer)getDataEntryFromDataList(m_dataStore, "stats.enable") != TRUE)
|
||
|
count = 0;
|
||
|
|
||
|
if(getDataEntryFromDataList(m_current, "balken."+ balken) != (string)count)
|
||
|
{
|
||
|
integer _linkCount = osGetLinkNumber("display-balken-" + balken);
|
||
|
|
||
|
if(count != 0)
|
||
|
llSetLinkAlpha(_linkCount, 255, 4);
|
||
|
|
||
|
if(count == 0)
|
||
|
llSetLinkAlpha(_linkCount, 0, 4);
|
||
|
|
||
|
float _balkenValue = ((1.0 / 100) * (float)count);
|
||
|
// llOwnerSay((string)_balkenValue + " " + (string)count);
|
||
|
llSetLinkPrimitiveParamsFast(_linkCount, [PRIM_SLICE,< 0, _balkenValue, 0>]);
|
||
|
|
||
|
m_current = setDataEntryInDataList(m_current, "balken."+ balken, (string)count);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
setInventarSlotCountNumber(integer slot, integer count)
|
||
|
{
|
||
|
if(m_min == TRUE)
|
||
|
count = 0;
|
||
|
|
||
|
if(getDataEntryFromDataList(m_current, "state.slot."+ slot +".count") != (string)count)
|
||
|
{
|
||
|
integer _linkCount = osGetLinkNumber("inv-number-" + slot);
|
||
|
|
||
|
if(count != 0)
|
||
|
llSetLinkPrimitiveParamsFast(_linkCount, [PRIM_TEXT, (string)count, <1, 1, 0.5>, 1.0]);
|
||
|
|
||
|
if(count == 0)
|
||
|
llSetLinkPrimitiveParamsFast(_linkCount, [PRIM_TEXT, "", <0, 0, 0>, 0.0]);
|
||
|
|
||
|
m_current = setDataEntryInDataList(m_current, "state.slot."+ slot +".count", (string)count);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
setLevelDisplayNumber(integer level, integer xp, integer level_xp)
|
||
|
{
|
||
|
if(getDataEntryFromDataList(m_current, "level") != (string)level + (string)xp + (string)m_min)
|
||
|
{
|
||
|
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, osFormatString(m_lang_leveltext, [(string)level, (string)xp + "/" + (string)level_xp ]), <0, 1, .2>, !m_min]);
|
||
|
m_current = setDataEntryInDataList(m_current, "level", (string)level + (string)xp) + (string)m_min;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Hilfsfunktionen
|
||
|
|
||
|
integer Key2AppChan(key ID, integer App)
|
||
|
{
|
||
|
return 0x80000000 | ((integer)("0x"+(string)ID) ^ App);
|
||
|
}
|
||
|
|
||
|
list getDataListFromDataStorage(string _storage)
|
||
|
{
|
||
|
return llCSV2List(osGetDataValue(_storage));
|
||
|
}
|
||
|
|
||
|
saveDataListToDataStorage(list _dataList, string _storage)
|
||
|
{
|
||
|
string _csv = llList2CSV(_dataList);
|
||
|
osSetDataValue(_storage, _csv);
|
||
|
}
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
list setDataEntryInDataList(list _dataList, string _key, string _value)
|
||
|
{
|
||
|
integer _inListPosition = llListFindList(_dataList, [_key]);
|
||
|
|
||
|
if(_inListPosition == -1)
|
||
|
{
|
||
|
_dataList += [_key, _value];
|
||
|
return _dataList;
|
||
|
}
|
||
|
|
||
|
return llListReplaceList(_dataList, [_value], _inListPosition + 1, _inListPosition + 1);
|
||
|
}
|
||
|
|
||
|
string left(string src, string divider)
|
||
|
{
|
||
|
integer index = llSubStringIndex( src, divider );
|
||
|
if(~index)return llDeleteSubString( src, index, -1);
|
||
|
return src;
|
||
|
}
|
||
|
|
||
|
string right(string src, string divider)
|
||
|
{
|
||
|
integer index = llSubStringIndex( src, divider );
|
||
|
if(~index)return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
|
||
|
return src;
|
||
|
}
|