Myriad Lite Creator Points
Myriad_Lite_Creator_Points-v0.0.1-20120203.lsl
// Myriad_Lite_Creator_Points-v0.0.1-20120203.lsl
// Copyright (c) 2012 By Allen Kerensky (OSG/SL)
// The Myriad RPG System was designed, written, and illustrated by Ashok Desai
// Myriad RPG licensed under the Creative Commons Attribution 2.0 UK: England and Wales
// http://creativecommons.org/licenses/by/2.0/uk/
// Myriad Lite software Copyright (c) 2011-2012 by Allen Kerensky (OSG/SL)
// Baroun's Adventure Machine Copyright (c) 2008-2011 by Baroun Tardis (SL)
// Myriad Lite and Baroun's Adventure Machine licensed under the
// Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported
// http://creativecommons.org/licenses/by-nc-sa/3.0/
// You must agree to the terms of this license before making any use of this software.
// If you do not agree to this license, simply delete these materials.
// There is no warranty, express or implied, for your use of these materials.
integer CHANOBJECT;
integer HANDOBJECT;
integer CHANMYRIAD = -999;
integer HANDMYRIAD;
integer CHANCOMMAND = 5;
integer HANDCOMMAND;
list REGION_GENERATORS;
list REGION_POINT_POOLS;
list REGION_GENRES;
list REGION_EQUIPMENT;
integer NUM_STATS;
integer NUM_SKILLS;
integer NUM_RESILIENCES;
integer MAX_STAT_CAP;
integer MAX_SKILL_CAP;
integer AV_MAX_STAT_POOL;
integer AV_MAX_SKILL_POOL;
integer AV_MAX_SFX_POOL;
integer AV_MAX_HEALTH_POOL;
integer AV_MAX_GP_POOL;
integer AV_MAX_RP_POOL;
integer AV_CUR_STAT_POOL;
integer AV_CUR_SKILL_POOL;
integer AV_CUR_SFX_POOL;
integer AV_CUR_HEALTH_POOL;
integer AV_CUR_GP_POOL;
integer AV_CUR_RP_POOL;
list AV_STATISTICS;
list AV_RESILIENCES;
list AV_SKILLS;
list AV_BOONS;
list AV_FLAWS;
list AV_MORTAL_EFFECTS;
list AV_SOCIAL_EFFECTS;
list AV_MAGIC_EFFECTS;
list AV_VEHICLE_EFFECTS;
list AV_EQUIPMENT;
key POSER; // who is sitting here
list CATEGORIES;
integer PN_SHOWCAT = 0;
integer PN_SHOWITEM = 0;
integer PN_SHOWPOOL = 0;
string CUR_CAT_NAME;
integer CUR_CAT_NUM;
string CUR_ITEM_NAME;
integer CUR_ITEM_NUM;
string CUR_POOL_NAME;
integer CUR_POINTS;
integer CUR_ITEM_VALUE;
list RES_STATS = [];
list RES_TYPES = [];
SETUP() {
// calculate listener channel
CHANOBJECT = (integer)("0x"+llGetSubString((string)llGetKey(),0,6));
// release previous object channel
if ( HANDOBJECT != 0 ) llListenRemove(HANDOBJECT);
// start object-specific listener
HANDOBJECT = llListen(CHANOBJECT,"",NULL_KEY,"");
// release previous Myriad channel
if ( HANDMYRIAD != 0 ) llListenRemove(HANDMYRIAD);
// listen on Myriad region event channel
HANDMYRIAD = llListen(CHANMYRIAD,"",NULL_KEY,"");
// release previous command channel
if ( HANDCOMMAND != 0 ) llListenRemove(CHANCOMMAND);
// listen on command channel
HANDCOMMAND = llListen(CHANCOMMAND,"",llGetOwner(),"");
// search all prims for prims to show output on, by name
integer numprims = llGetNumberOfPrims();
integer i;
for ( i=2; i <= numprims; i++) {
llSetLinkPrimitiveParamsFast(i,[PRIM_TEXT,"",<0,0,0>,0]);
string primname = llGetLinkName(i);
if ( primname == "SHOW ITEM" ) { PN_SHOWITEM = i; }
if ( primname == "SHOW CATEGORY" ) { PN_SHOWCAT = i; }
if ( primname == "SHOW POINTPOOL" ) { PN_SHOWPOOL = i; }
}
}
COMMAND(string cmd ) {
if ( cmd == "NEXT CATEGORY" ) { NEXT_CATEGORY(); return; }
if ( cmd == "PREV CATEGORY" ) { PREV_CATEGORY(); return; }
if ( cmd == "NEXT ITEM" ) { NEXT_ITEM(); return; }
if ( cmd == "PREV ITEM" ) { PREV_ITEM(); return; }
if ( cmd == "BUY ITEM" ) { BUY_ITEM(); return; }
if ( cmd == "SELL ITEM" ) { SELL_ITEM(); return; }
if ( cmd == "RESET" ) { RESET(); return; }
if ( cmd == "SAVE" ) { SAVE(); return; }
}
UPDATE() {
CUR_CAT_NAME = llList2String(CATEGORIES,CUR_CAT_NUM);
CUR_POINTS = 0;
if ( CUR_CAT_NAME == "Statistics" ) {
CUR_POINTS = AV_CUR_STAT_POOL;
CUR_POOL_NAME = "Stat";
CUR_ITEM_NAME = llList2String(AV_STATISTICS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_STATISTICS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Resiliences" ) {
CUR_POINTS = AV_CUR_HEALTH_POOL;
CUR_POOL_NAME = "Health";
CUR_ITEM_NAME = llList2String(AV_RESILIENCES,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_RESILIENCES,(CUR_ITEM_NUM * 2) + 1);
string base = llList2String(RES_STATS,llListFindList(RES_STATS,[CUR_ITEM_NAME]) + 1);
if ( llList2String(RES_TYPES,llListFindList(RES_TYPES,[CUR_ITEM_NAME]) + 1 ) == "Critical" ) {
CUR_ITEM_VALUE += llCeil( llList2Float(AV_STATISTICS,llListFindList(AV_STATISTICS,[base]) + 1) / 2.0);
} else {
CUR_ITEM_VALUE += llList2Integer(AV_STATISTICS,llListFindList(AV_STATISTICS,[base]) + 1);
}
}
if ( CUR_CAT_NAME == "Skills" ) {
CUR_POINTS = AV_CUR_SKILL_POOL;
CUR_POOL_NAME = "Skill";
CUR_ITEM_NAME = llList2String(AV_SKILLS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_SKILLS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Mortal Effects" ) {
CUR_POINTS = AV_CUR_SFX_POOL;
CUR_POOL_NAME = "SFX";
CUR_ITEM_NAME = llList2String(AV_MORTAL_EFFECTS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_MORTAL_EFFECTS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Social Effects" ) {
CUR_POINTS = AV_CUR_SFX_POOL;
CUR_POOL_NAME = "SFX";
CUR_ITEM_NAME = llList2String(AV_SOCIAL_EFFECTS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_SOCIAL_EFFECTS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Vehicle Effects" ) {
CUR_POINTS = AV_CUR_SFX_POOL;
CUR_POOL_NAME = "SFX";
CUR_ITEM_NAME = llList2String(AV_VEHICLE_EFFECTS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_VEHICLE_EFFECTS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Magic Effects" ) {
CUR_POINTS = AV_CUR_SFX_POOL;
CUR_POOL_NAME = "SFX";
CUR_ITEM_NAME = llList2String(AV_MAGIC_EFFECTS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_MAGIC_EFFECTS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Boons" ) {
CUR_POINTS = AV_CUR_GP_POOL;
CUR_POOL_NAME = "General";
CUR_ITEM_NAME = llList2String(AV_BOONS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_BOONS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Flaws" ) {
CUR_POINTS = AV_CUR_GP_POOL;
CUR_POOL_NAME = "General";
CUR_ITEM_NAME = llList2String(AV_FLAWS,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_FLAWS,(CUR_ITEM_NUM * 2) + 1);
}
if ( CUR_CAT_NAME == "Equipment" ) {
CUR_POINTS = AV_CUR_RP_POOL;
CUR_POOL_NAME = "Resource";
CUR_ITEM_NAME = llList2String(AV_EQUIPMENT,CUR_ITEM_NUM * 2);
CUR_ITEM_VALUE = llList2Integer(AV_EQUIPMENT,(CUR_ITEM_NUM * 2) + 1);
}
llSetLinkPrimitiveParamsFast(PN_SHOWCAT,[PRIM_TEXT,CUR_CAT_NAME,<1,1,1>,1.0]);
llSetLinkPrimitiveParamsFast(PN_SHOWITEM,[PRIM_TEXT,CUR_ITEM_NAME+": "+(string)CUR_ITEM_VALUE,<1,1,1>,1.0]);
if ( CUR_POINTS != 0 ) {
llSetLinkPrimitiveParamsFast(PN_SHOWPOOL,[PRIM_TEXT,(string)CUR_POINTS+" "+CUR_POOL_NAME+" Points",<1,1,1>,1.0]);
} else {
llSetLinkPrimitiveParamsFast(PN_SHOWPOOL,[PRIM_TEXT,"---",<1,1,1>,1.0]);
}
}
NEXT_CATEGORY() {
integer numcats = llGetListLength(CATEGORIES);
CUR_CAT_NUM++;
CUR_ITEM_NUM = 0;
if ( CUR_CAT_NUM >= numcats ) { CUR_CAT_NUM = numcats - 1;}
UPDATE();
}
PREV_CATEGORY() {
CUR_CAT_NUM--;
CUR_ITEM_NUM = 0;
if ( CUR_CAT_NUM < 0 ) CUR_CAT_NUM = 0;
UPDATE();
}
NEXT_ITEM() {
integer numitems;
CUR_ITEM_NUM++;
if ( CUR_CAT_NAME == "Statistics" ) numitems = llGetListLength(AV_STATISTICS) / 2;
if ( CUR_CAT_NAME == "Resiliences" ) numitems = llGetListLength(AV_RESILIENCES) / 2;
if ( CUR_CAT_NAME == "Skills" ) numitems = llGetListLength(AV_SKILLS) / 2;
if ( CUR_CAT_NAME == "Mortal Effects" ) numitems = llGetListLength(AV_MORTAL_EFFECTS) / 2 ;
if ( CUR_CAT_NAME == "Social Effects" ) numitems = llGetListLength(AV_SOCIAL_EFFECTS) / 2 ;
if ( CUR_CAT_NAME == "Vehicle Effects" ) numitems = llGetListLength(AV_VEHICLE_EFFECTS) / 2;
if ( CUR_CAT_NAME == "Magic Effects" ) numitems = llGetListLength(AV_MAGIC_EFFECTS) / 2 ;
if ( CUR_CAT_NAME == "Boons" ) numitems = llGetListLength(AV_BOONS) / 2 ;
if ( CUR_CAT_NAME == "Flaws" ) numitems = llGetListLength(AV_FLAWS) / 2;
if ( CUR_CAT_NAME == "Equipment" ) numitems = llGetListLength(AV_EQUIPMENT) / 2;
if ( CUR_ITEM_NUM >= numitems ) { CUR_ITEM_NUM = numitems - 1;}
UPDATE();
}
PREV_ITEM() {
CUR_ITEM_NUM--;
if ( CUR_ITEM_NUM < 0 ) CUR_ITEM_NUM = 0;
UPDATE();
}
BUY_ITEM() {
if ( CUR_POINTS > 0 ) {
if ( CUR_POOL_NAME == "Stat" ) {
integer statpos = llListFindList(AV_STATISTICS,[CUR_ITEM_NAME]);
integer curstat = llList2Integer(AV_STATISTICS,statpos + 1);
if ( curstat < MAX_STAT_CAP ) {
AV_STATISTICS = llListReplaceList(AV_STATISTICS,[++curstat],statpos + 1,statpos + 1);
AV_CUR_STAT_POOL--;
} else {
llSay(PUBLIC_CHANNEL,"Statistic is already at maximum");
}
}
if ( CUR_POOL_NAME == "Health" ) {
integer respos = llListFindList(AV_RESILIENCES,[CUR_ITEM_NAME]);
integer curres = llList2Integer(AV_RESILIENCES,respos + 1);
AV_RESILIENCES = llListReplaceList(AV_RESILIENCES,[++curres],respos + 1,respos + 1);
AV_CUR_HEALTH_POOL--;
}
if ( CUR_POOL_NAME == "Skill" ) {
integer skillpos = llListFindList(AV_SKILLS,[CUR_ITEM_NAME]);
integer curskill = llList2Integer(AV_SKILLS,skillpos + 1);
if ( curskill < MAX_SKILL_CAP ) {
AV_SKILLS = llListReplaceList(AV_SKILLS,[++curskill],skillpos + 1,skillpos + 1);
AV_CUR_SKILL_POOL--;
} else {
llSay(PUBLIC_CHANNEL,"Skill is already at maximum.");
}
}
if ( CUR_POOL_NAME == "SFX" ) {
if ( llListFindList(AV_MORTAL_EFFECTS,[CUR_ITEM_NAME]) >= 0 ) {
integer sfxpos = llListFindList(AV_MORTAL_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_MORTAL_EFFECTS,sfxpos + 1);
AV_MORTAL_EFFECTS = llListReplaceList(AV_MORTAL_EFFECTS,[++cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL--;
}
if ( llListFindList(AV_SOCIAL_EFFECTS,[CUR_ITEM_NAME]) >= 0 ) {
integer sfxpos = llListFindList(AV_SOCIAL_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_SOCIAL_EFFECTS,sfxpos + 1);
AV_SOCIAL_EFFECTS = llListReplaceList(AV_SOCIAL_EFFECTS,[++cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL--;
}
if ( llListFindList(AV_MAGIC_EFFECTS,[CUR_ITEM_NAME]) >= 0 ) {
integer sfxpos = llListFindList(AV_MAGIC_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_MAGIC_EFFECTS,sfxpos + 1);
AV_MAGIC_EFFECTS = llListReplaceList(AV_MAGIC_EFFECTS,[++cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL--;
}
if ( llListFindList(AV_VEHICLE_EFFECTS,[CUR_ITEM_NAME]) >= 0 ) {
integer sfxpos = llListFindList(AV_VEHICLE_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_VEHICLE_EFFECTS,sfxpos + 1);
AV_VEHICLE_EFFECTS = llListReplaceList(AV_VEHICLE_EFFECTS,[++cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL--;
}
}
if ( CUR_POOL_NAME == "General" ) {
if ( CUR_CAT_NAME == "Boons" ) {
integer boonpos = llListFindList(AV_BOONS,[CUR_ITEM_NAME]);
integer curboon = llList2Integer(AV_BOONS,boonpos + 1);
AV_BOONS = llListReplaceList(AV_BOONS,[++curboon],boonpos + 1,boonpos + 1);
AV_CUR_GP_POOL--;
}
if ( CUR_CAT_NAME == "Flaws" ) {
integer flawpos = llListFindList(AV_FLAWS,[CUR_ITEM_NAME]);
integer curflaw = llList2Integer(AV_FLAWS,flawpos + 1);
AV_FLAWS = llListReplaceList(AV_FLAWS,[++curflaw],flawpos + 1,flawpos + 1);
AV_CUR_GP_POOL--;
}
}
if ( CUR_POOL_NAME == "Resource" ) {
integer eqpos = llListFindList(AV_EQUIPMENT,[CUR_ITEM_NAME]);
integer cureq = llList2Integer(AV_EQUIPMENT,eqpos + 1);
AV_EQUIPMENT = llListReplaceList(AV_EQUIPMENT,[++cureq],eqpos + 1,eqpos + 1);
AV_CUR_RP_POOL--;
}
} else {
llSay(PUBLIC_CHANNEL,"Not enough points left in this point pool.");
}
UPDATE();
}
SELL_ITEM() {
if ( CUR_POOL_NAME == "Stat" ) {
integer statpos = llListFindList(AV_STATISTICS,[CUR_ITEM_NAME]);
integer curstat = llList2Integer(AV_STATISTICS,statpos + 1);
if ( curstat > 0 ) {
AV_STATISTICS = llListReplaceList(AV_STATISTICS,[--curstat],statpos + 1,statpos + 1);
AV_CUR_STAT_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that stat to return to the pool.");
}
}
if ( CUR_POOL_NAME == "Health" ) {
integer respos = llListFindList(AV_RESILIENCES,[CUR_ITEM_NAME]);
integer curres = llList2Integer(AV_RESILIENCES,respos + 1);
if ( curres > 0 ) {
AV_RESILIENCES = llListReplaceList(AV_RESILIENCES,[--curres],respos + 1, respos + 1);
AV_CUR_HEALTH_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that resilience to return to the pool.");
}
}
if ( CUR_POOL_NAME == "Skill" ) {
integer skillpos = llListFindList(AV_SKILLS,[CUR_ITEM_NAME]);
integer curskill = llList2Integer(AV_SKILLS,skillpos + 1);
if ( curskill > 0 ) {
AV_SKILLS = llListReplaceList(AV_SKILLS,[--curskill],skillpos + 1,skillpos + 1);
AV_CUR_SKILL_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that skill to return to the pool.");
}
}
if ( CUR_POOL_NAME == "SFX" ) {
if ( CUR_CAT_NAME == "Mortal Effects" ) {
integer sfxpos = llListFindList(AV_MORTAL_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_MORTAL_EFFECTS,sfxpos + 1);
if ( cursfx > 0 ) {
AV_MORTAL_EFFECTS = llListReplaceList(AV_MORTAL_EFFECTS,[--cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that SFX to return to the pool.");
}
}
if ( CUR_CAT_NAME == "Social Effects" ) {
integer sfxpos = llListFindList(AV_SOCIAL_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_SOCIAL_EFFECTS,sfxpos + 1);
if ( cursfx > 0 ) {
AV_SOCIAL_EFFECTS = llListReplaceList(AV_SOCIAL_EFFECTS,[--cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that SFX to return to the pool.");
}
}
if ( CUR_CAT_NAME == "Magic Effects" ) {
integer sfxpos = llListFindList(AV_MAGIC_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_MAGIC_EFFECTS,sfxpos + 1);
if ( cursfx > 0 ) {
AV_MAGIC_EFFECTS = llListReplaceList(AV_MAGIC_EFFECTS,[--cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that SFX to return to the pool.");
}
}
if ( CUR_CAT_NAME == "Vehicle Effects" ) {
integer sfxpos = llListFindList(AV_VEHICLE_EFFECTS,[CUR_ITEM_NAME]);
integer cursfx = llList2Integer(AV_VEHICLE_EFFECTS,sfxpos + 1);
if ( cursfx > 0 ) {
AV_VEHICLE_EFFECTS = llListReplaceList(AV_VEHICLE_EFFECTS,[--cursfx],sfxpos + 1,sfxpos + 1);
AV_CUR_SFX_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that SFX to return to the pool.");
}
}
}
if ( CUR_POOL_NAME == "General" ) {
if ( CUR_CAT_NAME == "Boons" ) {
integer boonpos = llListFindList(AV_BOONS,[CUR_ITEM_NAME]);
integer curboon = llList2Integer(AV_BOONS,boonpos + 1);
if ( curboon > 0 ) {
AV_BOONS = llListReplaceList(AV_BOONS,[--curboon],boonpos + 1,boonpos + 1);
AV_CUR_GP_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that Boon to return to the pool.");
}
}
if ( CUR_CAT_NAME == "Flaws" ) {
integer flawpos = llListFindList(AV_FLAWS,[CUR_ITEM_NAME]);
integer curflaw = llList2Integer(AV_FLAWS,flawpos + 1);
if ( curflaw > 0 ) {
AV_FLAWS = llListReplaceList(AV_FLAWS,[--curflaw],flawpos + 1,flawpos + 1);
AV_CUR_GP_POOL++;
} else {
llSay(PUBLIC_CHANNEL,"No points in that Flaw to return to the pool.");
}
}
}
if ( CUR_POOL_NAME == "Resource" ) {
integer eqpos = llListFindList(AV_EQUIPMENT,[CUR_ITEM_NAME]);
integer cureq = llList2Integer(AV_EQUIPMENT,eqpos + 1);
if ( cureq > 0 ) {
AV_EQUIPMENT = llListReplaceList(AV_EQUIPMENT,[--cureq],eqpos + 1,eqpos + 1);
AV_CUR_RP_POOL++;
}
}
UPDATE();
}
SAVE() {
string tempname = llGetObjectName();
llSetObjectName("");
llSay(PUBLIC_CHANNEL,"VERSION=0.0.3");
llSay(PUBLIC_CHANNEL,"NAME="+llKey2Name(POSER));
// Species
llSay(PUBLIC_CHANNEL,"SPECIES=Unknown");
// Backgrounds
llSay(PUBLIC_CHANNEL,"BACKGROUNDS=Unknown");
// Careers
llSay(PUBLIC_CHANNEL,"CAREERS=Unknown");
llSay(PUBLIC_CHANNEL,"XP=0");
llSay(PUBLIC_CHANNEL,"XPLEVEL=1");
// Statistics
integer numstats = llGetListLength(AV_STATISTICS);
integer count;
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_STATISTICS,count++);
integer amount = llList2Integer(AV_STATISTICS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"STATISTIC="+name+","+(string)amount);
}
// Resiliences
numstats = llGetListLength(AV_RESILIENCES);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_RESILIENCES,count++);
integer amount = llList2Integer(AV_RESILIENCES,count);
string base = llList2String(RES_STATS,llListFindList(RES_STATS,[name]) + 1);
integer baseamt;
if ( llList2String(RES_TYPES,llListFindList(RES_TYPES,[name]) + 1 ) == "Critical" ) {
baseamt = llCeil( llList2Float(AV_STATISTICS,llListFindList(AV_STATISTICS,[base]) + 1) / 2 );
} else {
baseamt = llList2Integer(AV_STATISTICS,llListFindList(AV_STATISTICS,[base]) + 1);
}
if ( (baseamt + amount ) > 0 ) llSay(PUBLIC_CHANNEL,"RESILIENCE="+name+","+(string)(baseamt+amount));
}
// Boons
numstats = llGetListLength(AV_BOONS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_BOONS,count++);
integer amount = llList2Integer(AV_BOONS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"BOON="+name+","+(string)amount);
}
// Flaws
numstats = llGetListLength(AV_FLAWS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_FLAWS,count++);
integer amount = llList2Integer(AV_FLAWS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"FLAW="+name+","+(string)amount);
}
// Skills
numstats = llGetListLength(AV_SKILLS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_SKILLS,count++);
integer amount = llList2Integer(AV_SKILLS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"SKILL="+name+","+(string)amount);
}
// Mortal Combat SFX
numstats = llGetListLength(AV_MORTAL_EFFECTS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_MORTAL_EFFECTS,count++);
integer amount = llList2Integer(AV_MORTAL_EFFECTS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"EFFECT="+name+","+(string)amount);
}
// Social Combat SFX
numstats = llGetListLength(AV_SOCIAL_EFFECTS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_SOCIAL_EFFECTS,count++);
integer amount = llList2Integer(AV_SOCIAL_EFFECTS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"EFFECT="+name+","+(string)amount);
}
// Magic SFX
numstats = llGetListLength(AV_MAGIC_EFFECTS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_MAGIC_EFFECTS,count++);
integer amount = llList2Integer(AV_MAGIC_EFFECTS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"EFFECT="+name+","+(string)amount);
}
// Vehicle SFX
numstats = llGetListLength(AV_VEHICLE_EFFECTS);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_VEHICLE_EFFECTS,count++);
integer amount = llList2Integer(AV_VEHICLE_EFFECTS,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"EFFECT="+name+","+(string)amount);
}
// Stunts
llSay(PUBLIC_CHANNEL,"STUNTS=");
// Quotes
llSay(PUBLIC_CHANNEL,"QUOTE=");
// Equipment
numstats = llGetListLength(AV_EQUIPMENT);
for ( count = 0; count < numstats; count++) {
string name = llList2String(AV_EQUIPMENT,count++);
integer amount = llList2Integer(AV_EQUIPMENT,count);
if ( amount > 0 ) llSay(PUBLIC_CHANNEL,"EQUIPMENT="+name+","+(string)amount);
}
llSetObjectName(tempname);
UPDATE();
}
RESET() {
key who = llAvatarOnSitTarget();
if ( who != NULL_KEY ) { llUnSit(who); }
llResetScript();
}
default {
state_entry() {
SETUP();
llRegionSay(CHANMYRIAD,"LIST_REGION_SETTINGS");
}
listen(integer channel,string name,key id,string message) {
name = ""; // LSLINT
id = NULL_KEY; // LSLINT
if ( channel == CHANOBJECT ) {
if ( llSubStringIndex(message,"REGION_SETTING") == 0 ) {
// Parse non-comment lines in keyword = value[,value,...] format
list FIELDS = llParseString2List(message,["|"],[]); // break line of text into = delimited fields
string SUBFIELD = llStringTrim(llList2String(FIELDS,1),STRING_TRIM); // field one is the data
list SUBFIELDS = llParseString2List(SUBFIELD,["="],[]);
string CMD = llList2String(SUBFIELDS,0);
string DATA = llList2String(SUBFIELDS,1); // break data field into comma-delimited subfields if needed
if ( CMD == "GENERATORS" ) {
REGION_GENERATORS = llCSV2List(DATA);
llOwnerSay("REGION_GENERATORS = "+(string)REGION_GENERATORS);
return;
}
if ( CMD == "POINT_POOLS") {
REGION_POINT_POOLS = llCSV2List(DATA);
return;
}
if ( CMD == "STATISTICS") {
list stats = llCSV2List(DATA);
integer num_stats = llGetListLength(stats);
integer count;
AV_STATISTICS = [];
for ( count = 0; count < num_stats; count++) {
AV_STATISTICS = AV_STATISTICS + [llList2String(stats,count),0];
}
return;
}
if ( CMD == "RESILIENCES" ) {
list res = llCSV2List(DATA);
integer num_res = llGetListLength(res);
integer count;
AV_RESILIENCES = [];
for ( count = 0; count < num_res; count++) {
AV_RESILIENCES = AV_RESILIENCES + [llList2String(res,count),0];
}
return;
}
if ( CMD == "SKILLS" ) {
list skills = llCSV2List(DATA);
integer num_skills = llGetListLength(skills);
integer count;
AV_SKILLS = [];
for ( count = 0; count < num_skills; count++) {
AV_SKILLS = AV_SKILLS + [llList2String(skills,count),0];
}
return;
}
if ( CMD == "GENRES" ) {
REGION_GENRES = llCSV2List(DATA);
return;
}
if ( CMD == "BOONS" ) {
list boons = llCSV2List(DATA);
integer num_boons = llGetListLength(boons);
integer count;
AV_BOONS = [];
for ( count = 0; count < num_boons; count++) {
AV_BOONS = AV_BOONS + [llList2String(boons,count),0];
}
return;
}
if ( CMD == "FLAWS" ) {
list flaws = llCSV2List(DATA);
integer num_flaws = llGetListLength(flaws);
integer count;
AV_FLAWS = [];
for ( count = 0; count < num_flaws; count++) {
AV_FLAWS = AV_FLAWS + [llList2String(flaws,count),0];
}
return;
}
if ( CMD == "MORTAL_EFFECTS" ) {
list meffects = llCSV2List(DATA);
integer num_meffects = llGetListLength(meffects);
integer count;
AV_MORTAL_EFFECTS = [];
for ( count = 0; count < num_meffects; count++) {
AV_MORTAL_EFFECTS = AV_MORTAL_EFFECTS + [llList2String(meffects,count),0];
}
return;
}
if ( CMD == "SOCIAL_EFFECTS" ) {
list seffects = llCSV2List(DATA);
integer num_seffects = llGetListLength(seffects);
integer count;
AV_SOCIAL_EFFECTS = [];
for ( count = 0; count < num_seffects; count++) {
AV_SOCIAL_EFFECTS = AV_SOCIAL_EFFECTS + [llList2String(seffects,count),0];
}
return;
}
if ( CMD == "MAGIC_EFFECTS" ) {
list mageffects = llCSV2List(DATA);
integer num_mageffects = llGetListLength(mageffects);
integer count;
AV_MAGIC_EFFECTS = [];
for ( count = 0; count < num_mageffects; count++) {
AV_MAGIC_EFFECTS = AV_MAGIC_EFFECTS + [llList2String(mageffects,count),0];
}
return;
}
if ( CMD == "VEHICLE_EFFECTS" ) {
list veffects = llCSV2List(DATA);
integer num_veffects = llGetListLength(veffects);
integer count;
AV_VEHICLE_EFFECTS = [];
for ( count = 0; count < num_veffects; count++) {
AV_VEHICLE_EFFECTS = AV_VEHICLE_EFFECTS + [llList2String(veffects,count),0];
}
return;
}
if ( CMD == "EQUIPMENT" ) {
REGION_EQUIPMENT = llCSV2List(DATA);
integer numeq = llGetListLength(REGION_EQUIPMENT);
integer count;
AV_EQUIPMENT = [];
for ( count = 0; count < numeq; count++) {
AV_EQUIPMENT = AV_EQUIPMENT + [llList2String(REGION_EQUIPMENT,count),0];
}
return;
}
if ( CMD == "LIST_COMPLETE" ) {
state GetRes;
}
return;
}
return;
}
}
}
state GetRes { // get resilience base stats
state_entry() {
SETUP();
integer reslen = llGetListLength(AV_RESILIENCES);
integer count;
for ( count = 0; count < reslen; count += 2) {
string resname = llList2String(AV_RESILIENCES,count);
llRegionSay(CHANMYRIAD,"GET_RESILIENCE|"+resname);
}
llSleep(1.0); // cheap hack - FIXME needs better way to know when all resilience replies are back and safe to continue
state CalcPointPools;
}
listen(integer channel,string name,key id,string message) {
channel = 0; // LSLINT
name = ""; // LSLINT
id = NULL_KEY; // LSLINT
if ( llGetSubString(message,0,10) == "RESILIENCE|" ) {
// RESILIENCE|RESILIENCE=Wounds|BASE_STAT=Power|TYPE=Critical|ACTION=Death|DESCRIPTION=how damaged the players body is
list tokens = llParseString2List(message,["|"],[]);
integer tokencount = llGetListLength(tokens);
integer i;
string resname = "";
string resstat = "";
string restype = "";
for ( i = 1; i < tokencount; i++) {
string attrib = llList2String(llParseString2List(llList2String(tokens,i),["="],[]),0);
string value = llList2String(llParseString2List(llList2String(tokens,i),["="],[]),1);
if ( attrib == "RESILIENCE" ) resname = value;
if ( attrib == "BASE_STAT" ) resstat = value;
if ( attrib == "TYPE" ) restype = value;
}
RES_STATS += [resname,resstat];
RES_TYPES += [resname,restype];
}
}
}
state CalcPointPools {
state_entry() {
SETUP();
llRegionSay(-999,"GET_POINT_POOL|"+llList2String(REGION_POINT_POOLS,0));
}
listen(integer channel,string name,key id,string msg) {
channel = 0; // LSLINT
name = ""; // LSLINT
id = NULL_KEY; // LSLINT
if ( llSubStringIndex(msg,"POINT_POOL|") >= 0 ) {
list attribs = llParseString2List(msg,["|"],[]);
integer attribcount = llGetListLength(attribs);
integer count;
for ( count = 0; count < attribcount; count++ ) {
list keyvalpair = llParseString2List(llList2String(attribs,count),["="],[]);
string keyname = llList2String(keyvalpair,0);
if ( keyname == "STAT_POOL" ) { // cut stat list in half to get number of stats
NUM_STATS = llGetListLength(AV_STATISTICS) / 2;
AV_MAX_STAT_POOL = NUM_STATS * llList2Integer(keyvalpair,1);
}
if ( keyname == "SKILL_POOL" ) { // cut skill list in half to get #skills, then divide by 4 again for "per 4 skills"
NUM_SKILLS = llGetListLength(AV_SKILLS) / 2;
AV_MAX_SKILL_POOL = NUM_SKILLS * llList2Integer(keyvalpair,1);
}
if ( keyname == "PER_SKILLS" ) { // now divide skill pool by per skills value
AV_MAX_SKILL_POOL /= llList2Integer(keyvalpair,1);
}
if ( keyname == "SFX_POOL" ) { // sfx pool is not "per" anything
AV_MAX_SFX_POOL = llList2Integer(keyvalpair,1);
}
if ( keyname == "HEALTH_POOL" ) {
NUM_RESILIENCES = llGetListLength(AV_RESILIENCES) / 2;
AV_MAX_HEALTH_POOL = NUM_RESILIENCES * llList2Integer(keyvalpair,1);
}
if ( keyname == "GP_POOL" ) { // sfx pool is not "per" anything
AV_MAX_GP_POOL = llList2Integer(keyvalpair,1);
}
if ( keyname == "MAX_STAT_CAP" ) { // sfx pool is not "per" anything
MAX_STAT_CAP = llList2Integer(keyvalpair,1);
}
if ( keyname == "MAX_SKILL_CAP" ) { // sfx pool is not "per" anything
MAX_SKILL_CAP = llList2Integer(keyvalpair,1);
}
if ( keyname == "RESOURCE_POINTS" ) { // starting resource points
AV_MAX_RP_POOL = llList2Integer(keyvalpair,1);
}
}
state PointsBased;
}
}
}
state PointsBased {
state_entry() {
CATEGORIES = ["Statistics","Resiliences","Skills","Boons","Flaws","Mortal Effects","Social Effects","Magic Effects","Vehicle Effects","Equipment"];
SETUP();
llOwnerSay("Points-Based");
AV_CUR_STAT_POOL = AV_MAX_STAT_POOL;
AV_CUR_SKILL_POOL = AV_MAX_SKILL_POOL;
AV_CUR_SFX_POOL = AV_MAX_SFX_POOL;
AV_CUR_HEALTH_POOL = AV_MAX_HEALTH_POOL;
AV_CUR_GP_POOL = AV_MAX_GP_POOL;
AV_CUR_RP_POOL = AV_MAX_RP_POOL;
UPDATE();
}
changed(integer change) {
if ( change & CHANGED_LINK ) {
POSER = llAvatarOnSitTarget();
UPDATE();
}
}
link_message(integer sendernum,integer number,string message,key id) {
sendernum = 0; // LSLINT
number = 0; // LSLINT
message = ""; // LSLINT
id = NULL_KEY; // LSLINT
COMMAND(message);
}
touch_start(integer total_number) {
total_number = 0; // LSLINT
string primname = llGetLinkName(llDetectedLinkNumber(0));
COMMAND(primname);
}
}