„Main HUD v0.07.02“ ändern
parent
6b61c4b242
commit
46a9640203
|
@ -1,4 +1,4 @@
|
|||
// 4Creative Game System - Main HUD v0.7.1
|
||||
// 4Creative Game System - Main HUD [v0.07.02]
|
||||
|
||||
// ToDo:
|
||||
// - Gegestände verarbeiten einbauen (Pfeilspitze + Holz = Pfeil)
|
||||
|
@ -7,30 +7,42 @@
|
|||
// - 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_num_slots = 8; // Anzahl Slots, die der Spieler hat.
|
||||
integer m_max_slots = 8; // Anzahl mx. erreichbare Slots (WICHTIG: AUCH IN JEDEM ITEM SETZEN!)
|
||||
integer m_refreshtime = 190; // Nach welcher Zeit soll das HUD aktualisiert werden.
|
||||
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 Sammelsystem ist hier noch nicht eingerichtet! Bitte benutze das Setup-Tool.";
|
||||
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 Item. Bist du dir wirklich sicher dass du dieses Item nicht mehr brauchst?";
|
||||
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} weggeworfen.";
|
||||
string m_lang_toHighWeight = "Dies kann nicht mehr getragen werden.";
|
||||
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}]";
|
||||
|
@ -55,6 +67,17 @@ 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);
|
||||
|
@ -99,10 +122,11 @@ minmax()
|
|||
|
||||
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 _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;
|
||||
|
@ -110,8 +134,9 @@ updateTime(integer _update)
|
|||
integer _currentMin = 0;
|
||||
for(_currentMin = 1; _currentMin <= (_checkTime / 60); ++_currentMin)
|
||||
{
|
||||
_food = _food - (integer)getDataEntryFromDataList(m_dataUserStore, "stats.levels.sub_food");
|
||||
_water = _water - (integer)getDataEntryFromDataList(m_dataUserStore, "stats.levels.sub_water");
|
||||
_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;
|
||||
}
|
||||
|
||||
|
@ -130,49 +155,90 @@ updateTime(integer _update)
|
|||
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());
|
||||
|
||||
llSetTimerEvent(m_refreshtime);
|
||||
startGame();
|
||||
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_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)
|
||||
{
|
||||
m_dataStore = getDataListFromDataStorage("game.hud");
|
||||
m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||||
|
||||
updateTime(FALSE);
|
||||
startGame();
|
||||
llResetScript();
|
||||
// m_dataStore = getDataListFromDataStorage("game.hud");
|
||||
// m_dataUserStore = getDataListFromDataStorage("game.hud.player." + llGetOwner());
|
||||
|
||||
// updateTime(FALSE);
|
||||
// startGame();
|
||||
}
|
||||
}
|
||||
|
||||
touch_start(integer i)
|
||||
{
|
||||
change_iconsize(llDetectedLinkNumber(0));
|
||||
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);
|
||||
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");
|
||||
|
@ -180,9 +246,7 @@ default
|
|||
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;
|
||||
|
@ -204,14 +268,21 @@ default
|
|||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -230,6 +301,7 @@ default
|
|||
{
|
||||
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();
|
||||
|
@ -238,7 +310,7 @@ default
|
|||
else
|
||||
{
|
||||
m_listener_state = "confirmDelete";
|
||||
llDialog(llGetOwner(), m_lang_deleteConfirm, [m_lang_ja, m_lang_nein], m_listener_channel);
|
||||
llDialog(llGetOwner(), osFormatString(m_lang_deleteConfirm, [_inventarItemDisplayName]), [m_lang_ja, m_lang_nein], m_listener_channel);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -311,7 +383,7 @@ default
|
|||
|
||||
if(getMaxPlayerWeight(_selectedTargetAvatarDataStorage) < calcPlayerWeight(_selectedTargetAvatarDataStorage))
|
||||
{
|
||||
llOwnerSay(m_lang_toHighWeight);
|
||||
llOwnerSay(osFormatString(m_lang_maxweight, [llGetSubString((string)getMaxPlayerWeight(_selectedTargetAvatarDataStorage), llSubStringIndex((string)getMaxPlayerWeight(_selectedTargetAvatarDataStorage), ".") + 2, -1)]));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -330,7 +402,7 @@ default
|
|||
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||||
|
||||
refreshData();
|
||||
llRegionSay((integer)getDataEntryFromDataList(_selectedTargetAvatarDataStorage, "channel"), "gamecommand;reload");
|
||||
llRegionSay((integer)(integer)getDataEntryFromDataList(_selectedTargetAvatarDataStorage, "channel"), "gamecommand;reload");
|
||||
llRegionSayTo(_selectedTargetAvatar, 0, osFormatString(m_lang_getItem, [llList2String(llParseString2List(llKey2Name(llGetOwner()), [" "], [""]), 0), _inventarItemDisplayName]));
|
||||
|
||||
return;
|
||||
|
@ -343,8 +415,9 @@ default
|
|||
{
|
||||
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");
|
||||
setDataEntryInDataList(m_dataUserStore, "inventar.slot." + _inventarSlot + ".count", "0");
|
||||
saveDataListToDataStorage(m_dataUserStore, "game.hud.player." + llGetOwner());
|
||||
refreshData();
|
||||
}
|
||||
|
@ -377,12 +450,39 @@ default
|
|||
}
|
||||
}
|
||||
|
||||
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_TELEPORT)
|
||||
if(change & (CHANGED_REGION | CHANGED_INVENTORY))
|
||||
{
|
||||
m_dataStore = getDataListFromDataStorage("game.hud");
|
||||
refreshData();
|
||||
llSetLinkPrimitiveParamsFast(osGetLinkNumber("level-anzeige"), [PRIM_TEXT, m_lang_regionchange, <1, 0.5, 0>, 1]);
|
||||
cleanGameState();
|
||||
llSleep(5);
|
||||
llResetScript();
|
||||
//m_dataStore = getDataListFromDataStorage("game.hud");
|
||||
//refreshData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,31 +493,35 @@ cleanGameState()
|
|||
{
|
||||
if(m_listener_socket != 0)
|
||||
llListenRemove(m_listener_socket);
|
||||
|
||||
|
||||
integer i;
|
||||
for(i = 1; i < m_num_slots; i++)
|
||||
for(i = 1; i < m_max_slots; i++)
|
||||
{
|
||||
setInventarSlotImage(i, TEXTURE_BLANK, 0);
|
||||
setInventarSlotCountNumber(i, 0);
|
||||
}
|
||||
|
||||
disableBalken();
|
||||
}
|
||||
|
||||
setLevelDisplayNumber(0, 0);
|
||||
disableBalken()
|
||||
{
|
||||
setLevelDisplayNumber(0, 0, 0);
|
||||
setBalkenValue("wasser", 0);
|
||||
setBalkenValue("essen", 0);
|
||||
setBalkenValue("xp", 0);
|
||||
setBalkenValue("hp", 0);
|
||||
setBalkenValue("weight", 0);
|
||||
}
|
||||
|
||||
|
||||
startGame()
|
||||
{
|
||||
cleanGameState();
|
||||
|
||||
if(checkDataEntryInDataList(m_dataStore, "enable") == FALSE || getDataEntryFromDataList(m_dataStore, "enable") == "FALSE")
|
||||
disableBalken();
|
||||
if((integer)checkDataEntryInDataList(m_dataStore, "enable") == FALSE || (integer)getDataEntryFromDataList(m_dataStore, "enable") == FALSE)
|
||||
{
|
||||
llOwnerSay(m_lang_groupMessage);
|
||||
return;
|
||||
llOwnerSay(m_lang_groupMessage);
|
||||
disableBalken();
|
||||
return;
|
||||
}
|
||||
|
||||
m_listener_channel = Key2AppChan(llGetOwner(), 39724);
|
||||
|
@ -438,14 +542,11 @@ startGame()
|
|||
if(checkDataEntryInDataList(m_dataUserStore, "stats.hp") == FALSE)
|
||||
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", "100");
|
||||
|
||||
if(checkDataEntryInDataList(m_dataUserStore, "stats.weight") == FALSE)
|
||||
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.weight", "0");
|
||||
|
||||
if(checkDataEntryInDataList(m_dataUserStore, "stats.lastCheck") == FALSE)
|
||||
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.lastCheck", llGetUnixTime());
|
||||
|
||||
integer i;
|
||||
for (i = 1; i <= m_num_slots; i++)
|
||||
for (i = 1; i <= m_max_slots; i++)
|
||||
{
|
||||
if(checkDataEntryInDataList(m_dataUserStore, "inventar.slot." + i) == FALSE)
|
||||
{
|
||||
|
@ -462,7 +563,7 @@ integer getInventarSlot(list _userStorage, string itemName)
|
|||
{
|
||||
integer _currentSlot;
|
||||
integer _freeSlot = 0;
|
||||
for(_currentSlot = 1; _currentSlot <= m_num_slots; ++_currentSlot)
|
||||
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||||
{
|
||||
if(getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot) == itemName)
|
||||
return _currentSlot;
|
||||
|
@ -481,11 +582,11 @@ integer getItemCountFromSlot(list _userStorage, integer _slot)
|
|||
return _returnValue;
|
||||
}
|
||||
|
||||
integer calcPlayerWeight(list _userStorage)
|
||||
float calcPlayerWeight(list _userStorage)
|
||||
{
|
||||
integer _currentSlot;
|
||||
integer _currentWeight = 0;
|
||||
for(_currentSlot = 1; _currentSlot <= m_num_slots; ++_currentSlot)
|
||||
float _currentWeight = 0;
|
||||
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||||
{
|
||||
if(getDataEntryFromDataList(_userStorage, "inventar.slot." + _currentSlot) != "")
|
||||
{
|
||||
|
@ -493,24 +594,24 @@ integer calcPlayerWeight(list _userStorage)
|
|||
list _itemData = getDataListFromDataStorage("item." +_itemName);
|
||||
|
||||
integer _itemCount = getItemCountFromSlot(_userStorage, _currentSlot);
|
||||
integer _itemWeight = (integer)getDataEntryFromDataList(_itemData, "weight");
|
||||
float _itemWeight = (float)getDataEntryFromDataList(_itemData, "weight");
|
||||
|
||||
_currentWeight = _currentWeight + (_itemCount * _itemWeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return _currentWeight;
|
||||
}
|
||||
|
||||
integer getMaxPlayerWeight(list _userDataStorage)
|
||||
float getMaxPlayerWeight(list _userDataStorage)
|
||||
{
|
||||
integer _maxweight = (integer)getDataEntryFromDataList(m_dataStore, "stats.levels.maxweight");
|
||||
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;
|
||||
|
||||
integer _playerMaxWight = _maxweight * (_playerLevel * _xpMultiplier);
|
||||
float _playerMaxWight = _maxweight + ((float)_playerLevel * _xpMultiplier);
|
||||
|
||||
return _playerMaxWight;
|
||||
}
|
||||
|
@ -543,7 +644,7 @@ list calcLevelData(list _dataStorage)
|
|||
refreshData()
|
||||
{
|
||||
integer _currentSlot;
|
||||
for(_currentSlot = 1; _currentSlot <= m_num_slots; ++_currentSlot)
|
||||
for(_currentSlot = 1; _currentSlot <= m_max_slots; ++_currentSlot)
|
||||
{
|
||||
if(getDataEntryFromDataList(m_dataUserStore, "inventar.slot." + _currentSlot) != "")
|
||||
{
|
||||
|
@ -557,18 +658,16 @@ refreshData()
|
|||
setInventarSlotCountNumber(_currentSlot, 0);
|
||||
}
|
||||
}
|
||||
|
||||
list _levelData = calcLevelData(m_dataUserStore);
|
||||
//llOwnerSay("leveldata " + llList2CSV(_levelData));
|
||||
|
||||
setLevelDisplayNumber(llList2Integer(_levelData, 0), llList2Integer(_levelData, 1));
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
|
@ -587,16 +686,28 @@ refreshData()
|
|||
if(_hp < 0)
|
||||
m_dataUserStore = setDataEntryInDataList(m_dataUserStore, "stats.hp", "0");
|
||||
|
||||
setBalkenValue("wasser", (integer)getDataEntryFromDataList(m_dataUserStore, "stats.wasser"));
|
||||
setBalkenValue("essen", (integer)getDataEntryFromDataList(m_dataUserStore, "stats.essen"));
|
||||
setBalkenValue("hp", (integer)getDataEntryFromDataList(m_dataUserStore, "stats.hp"));
|
||||
setBalkenValue("xp", _xpBalkenValue);
|
||||
setBalkenValue("weight", (integer)getMaxPlayerWeight(getDataListFromDataStorage("game.hud.player." + llGetOwner())));
|
||||
|
||||
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(), "SHOW" + NAME, [ATTACH_HEAD], 0);
|
||||
osMessageAttachments(llGetOwner(), "LEVEL:" + (string)llList2Integer(_levelData, 0), [ATTACH_HEAD], 0);
|
||||
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)
|
||||
|
@ -756,9 +867,11 @@ setInventarSlotImage(integer slot, key imageID, integer alpha)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
setBalkenValue(string balken, integer count) // integer max
|
||||
{
|
||||
if(getDataEntryFromDataList(m_dataStore, "stats.enable") != "TRUE")
|
||||
if((integer)getDataEntryFromDataList(m_dataStore, "stats.enable") != TRUE)
|
||||
count = 0;
|
||||
|
||||
if(getDataEntryFromDataList(m_current, "balken."+ balken) != (string)count)
|
||||
|
@ -767,13 +880,14 @@ setBalkenValue(string balken, integer count) // integer max
|
|||
|
||||
if(count != 0)
|
||||
llSetLinkAlpha(_linkCount, 255, 4);
|
||||
|
||||
|
||||
if(count == 0)
|
||||
llSetLinkAlpha(_linkCount, 0, 4);
|
||||
|
||||
float _balkenValue = (1.0 / 100) * count;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -797,12 +911,11 @@ setInventarSlotCountNumber(integer slot, integer count)
|
|||
}
|
||||
}
|
||||
|
||||
setLevelDisplayNumber(integer level, integer xp)
|
||||
setLevelDisplayNumber(integer level, integer xp, integer level_xp)
|
||||
{
|
||||
if(getDataEntryFromDataList(m_current, "level") != (string)level + (string)xp + (string)m_min)
|
||||
{
|
||||
integer _linkCount = osGetLinkNumber("level-anzeige");
|
||||
llSetLinkPrimitiveParamsFast(_linkCount, [PRIM_TEXT, osFormatString(m_lang_leveltext, [(string)level, (string)xp]), <0, 1, .2>, !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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue