User:Allen Kerensky/Myriad Lite Preview 5/Creator Template
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Preview 5(Difference between revisions)
(created) |
m (moved User:Allen Kerensky:Myriad Lite Preview 5:Creator Template to User:Allen Kerensky/Myriad Lite Preview 5/Creator Template: move into subsite) |
Latest revision as of 14:43, 6 February 2012
[edit] Myriad Lite Creator Template
[edit] Myriad_Lite_Creator_Template-v0.0.1-20120203.lsl
// Myriad_Lite_Character_Creator-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_SPECIES; list REGION_SPECIES_NAMES; list REGION_SPECIES_COSTS; list REGION_BACKGROUNDS; list REGION_BACKGROUND_NAMES; list REGION_BACKGROUND_COSTS; list REGION_CAREERS; list REGION_CAREER_NAMES; list REGION_CAREER_COSTS; list REGION_EQUIPMENT; integer AV_MAX_GP_POOL; integer AV_MAX_RP_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_SPECIES; list AV_BACKGROUNDS; list AV_CAREERS; list AV_EQUIPMENT; 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 = []; string TEMPLATE_OP = "NONE"; // add or delete when template data comes in 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 == "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 == "Species" ) { CUR_POINTS = AV_CUR_GP_POOL; CUR_POOL_NAME = "General"; CUR_ITEM_NAME = llList2String(AV_SPECIES,CUR_ITEM_NUM * 2 ); CUR_ITEM_VALUE = llList2Integer(AV_SPECIES,(CUR_ITEM_NUM * 2) + 1); } if ( CUR_CAT_NAME == "Backgrounds" ) { CUR_POINTS = AV_CUR_GP_POOL; CUR_POOL_NAME = "General"; CUR_ITEM_NAME = llList2String(AV_BACKGROUNDS,CUR_ITEM_NUM * 2); CUR_ITEM_VALUE = llList2Integer(AV_BACKGROUNDS,(CUR_ITEM_NUM * 2) + 1); } if ( CUR_CAT_NAME == "Careers" ) { CUR_POINTS = AV_CUR_GP_POOL; CUR_POOL_NAME = "General"; CUR_ITEM_NAME = llList2String(AV_CAREERS,CUR_ITEM_NUM * 2); CUR_ITEM_VALUE = llList2Integer(AV_CAREERS,(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 == "Boons" ) numitems = llGetListLength(AV_BOONS) / 2 ; if ( CUR_CAT_NAME == "Flaws" ) numitems = llGetListLength(AV_FLAWS) / 2; if ( CUR_CAT_NAME == "Species" ) numitems = llGetListLength(AV_SPECIES) / 2; if ( CUR_CAT_NAME == "Backgrounds" ) numitems = llGetListLength(AV_BACKGROUNDS) / 2; if ( CUR_CAT_NAME == "Careers" ) numitems = llGetListLength(AV_CAREERS) /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 == "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_CAT_NAME == "Species" ) { integer pos = llListFindList(REGION_SPECIES_NAMES,[CUR_ITEM_NAME]); if ( pos != -1 ) { integer cost = llList2Integer(REGION_SPECIES_COSTS,pos); if ( cost <= AV_CUR_GP_POOL ) { integer specpos = llListFindList(AV_SPECIES,[CUR_ITEM_NAME]); integer curspec = llList2Integer(AV_SPECIES,specpos + 1); AV_SPECIES = llListReplaceList(AV_SPECIES,[++curspec],specpos + 1, specpos + 1); AV_CUR_GP_POOL -= cost; ADD_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"You do not have "+(string)cost+" general points to buy template "+CUR_ITEM_NAME); } } } if ( CUR_CAT_NAME == "Backgrounds" ) { integer pos = llListFindList(REGION_BACKGROUND_NAMES,[CUR_ITEM_NAME]); if ( pos != -1 ) { integer cost = llList2Integer(REGION_BACKGROUND_COSTS,pos); if ( cost <= AV_CUR_GP_POOL ) { integer backpos = llListFindList(AV_BACKGROUNDS,[CUR_ITEM_NAME]); integer curback = llList2Integer(AV_BACKGROUNDS,backpos + 1); AV_BACKGROUNDS = llListReplaceList(AV_BACKGROUNDS,[++curback],backpos + 1,backpos + 1); AV_CUR_GP_POOL -= cost; ADD_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"You do not have "+(string)cost+" general points to buy template "+CUR_ITEM_NAME); } } } if ( CUR_CAT_NAME == "Careers" ) { integer pos = llListFindList(REGION_CAREER_NAMES,[CUR_ITEM_NAME]); if ( pos != -1 ) { integer cost = llList2Integer(REGION_CAREER_COSTS,pos); if ( cost <= AV_CUR_GP_POOL ) { integer carpos = llListFindList(AV_CAREERS,[CUR_ITEM_NAME]); integer curcar = llList2Integer(AV_CAREERS,carpos + 1); AV_CAREERS = llListReplaceList(AV_CAREERS,[++curcar],carpos + 1,carpos + 1); AV_CUR_GP_POOL -= cost; ADD_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"You do not have "+(string)cost+" general points to buy template "+CUR_ITEM_NAME); } } } } 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 == "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_CAT_NAME == "Species" ) { integer specpos = llListFindList(AV_SPECIES,[CUR_ITEM_NAME]); integer curspec = llList2Integer(AV_SPECIES,specpos + 1); if ( curspec > 0 ) { integer cost = llList2Integer(REGION_SPECIES_COSTS,llListFindList(REGION_SPECIES_NAMES,[CUR_ITEM_NAME])); AV_SPECIES = llListReplaceList(AV_SPECIES,[--curspec],specpos + 1,specpos + 1); AV_CUR_GP_POOL += cost; DEL_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"No points in Species Template "+CUR_ITEM_NAME+" to return to the pool."); } } if ( CUR_CAT_NAME == "Backgrounds" ) { integer backpos = llListFindList(AV_BACKGROUNDS,[CUR_ITEM_NAME]); integer curback = llList2Integer(AV_BACKGROUNDS,backpos + 1); if ( curback > 0 ) { integer cost = llList2Integer(REGION_BACKGROUND_COSTS,llListFindList(REGION_BACKGROUND_NAMES,[CUR_ITEM_NAME])); AV_BACKGROUNDS = llListReplaceList(AV_BACKGROUNDS,[--curback],backpos + 1,backpos + 1); AV_CUR_GP_POOL += cost; DEL_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"No points in Background Template "+CUR_ITEM_NAME+" to return to the pool."); } } if ( CUR_CAT_NAME == "Careers" ) { integer carpos = llListFindList(AV_CAREERS,[CUR_ITEM_NAME]); integer curcar = llList2Integer(AV_CAREERS,carpos + 1); if ( curcar > 0 ) { integer cost = llList2Integer(REGION_CAREER_COSTS,llListFindList(REGION_CAREER_NAMES,[CUR_ITEM_NAME])); AV_CAREERS = llListReplaceList(AV_CAREERS,[--curcar],carpos + 1,carpos + 1); AV_CUR_GP_POOL += cost; DEL_TEMPLATE(CUR_ITEM_NAME); } else { llSay(PUBLIC_CHANNEL,"No points in Career Template "+CUR_ITEM_NAME+" 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=Unknown"); // Species integer n = llGetListLength(AV_SPECIES); integer i; list outlist; for ( i=0; i < n; i += 2 ) { integer num = llList2Integer(AV_SPECIES,i + 1); if ( num > 0 ) outlist = outlist + [llList2String(AV_SPECIES,i)]; } llSay(PUBLIC_CHANNEL,"SPECIES="+llList2CSV(outlist)); // Backgrounds n = llGetListLength(AV_BACKGROUNDS); outlist = []; for ( i=0; i < n; i += 2 ) { integer num = llList2Integer(AV_BACKGROUNDS,i + 1); if ( num > 0 ) outlist = outlist + [llList2String(AV_BACKGROUNDS,i)]; } llSay(PUBLIC_CHANNEL,"BACKGROUNDS="+llList2CSV(outlist)); // Careers n = llGetListLength(AV_CAREERS); outlist = []; for ( i=0; i < n; i += 2 ) { integer num = llList2Integer(AV_CAREERS,i + 1); if ( num > 0 ) outlist = outlist + [llList2String(AV_CAREERS,i)]; } llSay(PUBLIC_CHANNEL,"CAREERS="+llList2CSV(outlist)); 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(); } ADD_TEMPLATE(string tempname) { TEMPLATE_OP = "ADD"; llRegionSay(CHANMYRIAD,"GET_TEMPLATE|"+tempname); } DEL_TEMPLATE(string tempname) { TEMPLATE_OP = "DEL"; llRegionSay(CHANMYRIAD,"GET_TEMPLATE|"+tempname); } 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 == "SPECIES" ) { REGION_SPECIES = llCSV2List(DATA); integer num_ts = llGetListLength(REGION_SPECIES); integer count; AV_SPECIES = []; for ( count = 0; count < num_ts; count++) { AV_SPECIES = AV_SPECIES + [llList2String(REGION_SPECIES,count),0]; } return; } if ( CMD == "BACKGROUNDS" ) { REGION_BACKGROUNDS = llCSV2List(DATA); integer num_tb = llGetListLength(REGION_BACKGROUNDS); integer count; AV_BACKGROUNDS = []; for ( count = 0; count < num_tb; count++) { AV_BACKGROUNDS = AV_BACKGROUNDS + [llList2String(REGION_BACKGROUNDS,count),0]; } return; } if ( CMD == "CAREERS" ) { REGION_CAREERS = llCSV2List(DATA); integer num_tc = llGetListLength(REGION_CAREERS); integer count; AV_CAREERS = []; for ( count = 0; count < num_tc; count++) { AV_CAREERS = AV_CAREERS + [llList2String(REGION_CAREERS,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); // this delay is weak coding - need more reliable fix state Template; } 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 Template { state_entry() { llOwnerSay("State: Template"); CATEGORIES = ["Species","Backgrounds","Careers","Boons","Flaws","Equipment"]; SETUP(); string region_pool = llList2String(REGION_POINT_POOLS,0); if ( region_pool == "Mundane" ) { AV_MAX_GP_POOL = 53; AV_CUR_GP_POOL = 53; } else if ( region_pool == "Heroic" ) { AV_MAX_GP_POOL = 82; AV_CUR_GP_POOL = 82; } else if ( region_pool == "Godlike" ) { AV_MAX_GP_POOL = 112; AV_CUR_GP_POOL = 112; } llOwnerSay("General Points for "+region_pool+" pool: "+(string)AV_CUR_GP_POOL); // now get resource points llRegionSay(-999,"GET_POINT_POOL|"+region_pool); llSleep(1.0); // now load templates integer count = 0; integer len = llGetListLength(REGION_BACKGROUNDS); for ( count = 0; count < len; count++ ) { llRegionSay(CHANMYRIAD,"GET_TEMPLATE|"+llList2String(REGION_BACKGROUNDS,count)); } count = 0; len = llGetListLength(REGION_CAREERS); for ( count = 0; count < len; count++ ) { llRegionSay(CHANMYRIAD,"GET_TEMPLATE|"+llList2String(REGION_CAREERS,count)); } count = 0; len = llGetListLength(REGION_SPECIES); for ( count = 0; count < len; count++ ) { llRegionSay(CHANMYRIAD,"GET_TEMPLATE|"+llList2String(REGION_SPECIES,count)); } llSleep(1.0); // cheap hack UPDATE(); } link_message(integer sendernum,integer number,string message,key id) { sendernum = 0; // LSLINT number = 0; // LSLINT id = NULL_KEY; // LSLINT COMMAND(message); } listen(integer channel,string name,key id,string message) { name = ""; // LSLINT id = NULL_KEY; // LSLINT if ( channel == CHANCOMMAND) { COMMAND(message); return; } if ( channel == CHANOBJECT ) { if ( llSubStringIndex(message,"POINT_POOL|") >= 0 ) { list attribs = llParseString2List(message,["|"],[]); 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 == "RESOURCE_POINTS" ) { // starting resource points AV_MAX_RP_POOL = llList2Integer(keyvalpair,1); AV_CUR_RP_POOL = AV_MAX_RP_POOL; } } return; } if ( llGetSubString(message,0,8) == "TEMPLATE|") { list tokens = llParseString2List(message,["|"],[]); integer numtokens = llGetListLength(tokens); integer count; if ( TEMPLATE_OP == "ADD" ) { // FIXME - needs bounds checking on values for (count = 0; count < numtokens; count++) { list attribvalpair = llParseString2List(llList2String(tokens,count),["="],[]); string attrib = llList2String(attribvalpair,0); list values = llParseString2List(llList2String(attribvalpair,1),[","],[]); string item = llList2String(values,0); integer amount = llList2Integer(values,1); if ( attrib == "ADDSTATISTIC" ) { integer pos = llListFindList(AV_STATISTICS,[item]); integer val = llList2Integer(AV_STATISTICS,pos + 1 ); AV_STATISTICS = llListReplaceList(AV_STATISTICS,[val + amount],pos + 1, pos + 1); } if ( attrib == "ADDSKILL" ) { integer pos = llListFindList(AV_SKILLS,[item]); integer val = llList2Integer(AV_SKILLS,pos + 1 ); AV_SKILLS = llListReplaceList(AV_SKILLS,[val + amount],pos + 1, pos + 1); } if ( attrib == "ADDBOON" ) { integer pos = llListFindList(AV_BOONS,[item]); integer val = llList2Integer(AV_BOONS,pos + 1 ); AV_BOONS = llListReplaceList(AV_BOONS,[val + amount],pos + 1, pos + 1); } if ( attrib == "ADDFLAW" ) { integer pos = llListFindList(AV_FLAWS,[item]); integer val = llList2Integer(AV_FLAWS,pos + 1 ); AV_STATISTICS = llListReplaceList(AV_FLAWS,[val + amount],pos + 1, pos + 1); } } TEMPLATE_OP = "NONE"; return; } if ( TEMPLATE_OP == "DEL" ) { // FIXME - needs bounds checking on values for (count = 0; count < numtokens; count++) { list attribvalpair = llParseString2List(llList2String(tokens,count),["="],[]); string attrib = llList2String(attribvalpair,0); list values = llParseString2List(llList2String(attribvalpair,1),[","],[]); string item = llList2String(values,0); integer amount = llList2Integer(values,1); if ( attrib == "ADDSTATISTIC" ) { integer pos = llListFindList(AV_STATISTICS,[item]); integer val = llList2Integer(AV_STATISTICS,pos + 1 ); AV_STATISTICS = llListReplaceList(AV_STATISTICS,[val - amount],pos + 1, pos + 1); } if ( attrib == "ADDSKILL" ) { integer pos = llListFindList(AV_SKILLS,[item]); integer val = llList2Integer(AV_SKILLS,pos + 1 ); AV_SKILLS = llListReplaceList(AV_SKILLS,[val - amount],pos + 1, pos + 1); } if ( attrib == "ADDBOON" ) { integer pos = llListFindList(AV_BOONS,[item]); integer val = llList2Integer(AV_BOONS,pos + 1 ); AV_BOONS = llListReplaceList(AV_BOONS,[val - amount],pos + 1, pos + 1); } if ( attrib == "ADDFLAW" ) { integer pos = llListFindList(AV_FLAWS,[item]); integer val = llList2Integer(AV_FLAWS,pos + 1 ); AV_FLAWS = llListReplaceList(AV_FLAWS,[val - amount],pos + 1, pos + 1); } } TEMPLATE_OP = "NONE"; return; } string tname = ""; string ttype = ""; integer tcost = 0; for (count = 0; count < numtokens; count++) { list attribvalpair = llParseString2List(llList2String(tokens,count),["="],[]); string attrib = llList2String(attribvalpair,0); string value = llList2String(attribvalpair,1); if ( attrib == "NAME" ) tname = value; if ( attrib == "TYPE" ) ttype = value; if ( attrib == "GPCOST" ) tcost = (integer)value; } //llOwnerSay("Template Name=["+tname+"] Type=["+ttype+"] GPCost=["+(string)tcost+"]"); if ( ttype == "Background" ) { REGION_BACKGROUND_NAMES = REGION_BACKGROUND_NAMES + [tname]; REGION_BACKGROUND_COSTS = REGION_BACKGROUND_COSTS + [tcost]; } else if ( ttype == "Career" ) { REGION_CAREER_NAMES = REGION_CAREER_NAMES + [tname]; REGION_CAREER_COSTS = REGION_CAREER_COSTS + [tcost]; } else if ( ttype == "Species" ) { REGION_SPECIES_NAMES = REGION_SPECIES_NAMES + [tname]; REGION_SPECIES_COSTS = REGION_SPECIES_COSTS + [tcost]; } } } } touch_start(integer total_number) { total_number = 0; // LSLINT string primname = llGetLinkName(llDetectedLinkNumber(0)); COMMAND(primname); } }