Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Myriad_Lite_To_D6_Module_Character_Sheet.lsl
- // This script was adapted to the Open D6 System by KeeperS Karu (Keeper S. Karu).
- // The adapted script uses the dual-license established by Allen Kerensky.
- //
- // The Open D6 System was developed by West End Games.
- // The Open D6 System is licensed under:
- // OPEN GAME LICENSE Version 1.0a
- // http://www.opengamingfoundation.org/ogl.html
- //
- // Myriad_Lite_Module_Character_Sheet-v0.0.6-20120827.lsl
- // Copyright (c) 2012 by Allen Kerensky (OSG/SL) All Rights Reserved.
- // This work is dual-licensed under
- // Creative Commons Attribution (CC BY) 3.0 Unported
- // http://creativecommons.org/licenses/by/3.0/
- // - or -
- // Modified BSD License (3-clause)
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions are met:
- // * Redistributions of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- // * Redistributions in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- // * Neither the name of Myriad Lite nor the names of its contributors may be
- // used to endorse or promote products derived from this software without
- // specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
- // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- // NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- //
- // The Myriad RPG System was designed, written, and illustrated by Ashok Desai
- // Myriad RPG System licensed under:
- // Creative Commons Attribution (CC BY) 2.0 UK: England and Wales
- // http://creativecommons.org/licenses/by/2.0/uk/
- //================
- // VERSION CONTROL
- //================
- string VERSION = "0.0.6"; // Allen Kerensky's script version
- string VERSIONDATE = "20120827"; // Allen Kerensky's script yyyymmdd
- string D6VERSION = "1"; //Keeper's version of the D6-adapted script
- string D6VERSIONDATE = "20130521"; // Keeper's D6-adapted script yyyymmdd
- //========================
- // CHARACTER SHEET STORAGE
- //========================
- // Cardversion
- string CARDVERSION = "0.0.5"; // what card format version do we expect
- string D6CARDVERSION = "1.0.0"; // Myriad Lite to D6 card format version to expect
- // Special Points
- list CHARACTERPOINTS = []; // character points [integer TotalCharPoints, integer StartCharacterPoints]
- list FATEPOINTS = []; // fate points [integer TotalFatePoints, integer StartFatePoints]
- // Character Personal Info
- string PLAYERNAME = ""; // player's avatar name
- string CHARACTERNAME = ""; // character name
- string CHARACTERALIASES = ""; // character aliases
- string OCCUPATION = ""; // occupation template
- string SPECIES = ""; // species template used for character
- string GENDER = ""; // Your character's gender
- string AGE = ""; // Your character's age
- string HEIGHT = ""; // Your character's height
- string WEIGHT = ""; // Your character's weight
- string PHYSICALDESCRIPTION = ""; // Your character's additional physical description
- string PERSONALITY = ""; // Your character's personality
- string OBJECTIVES = ""; // Your character's objectives
- string NATIVELANGUAGE = ""; // Your character's native languages
- string OTHERINFORMATION = ""; // otherinformation template
- // Character Attributes
- list ATTRIBUTES = []; // attributes [string AttributeName, integer TotalATTRank, integer BaseATTRank, integer StartATTRank]
- list SKILLS = []; // skills [ string SkillName, integer TotalSkillRank, integer BaseSkillRank, integer StartSkillRank ]
- list SKILL_SPECIALIZATIONS = []; // specialization [ string SpecName,integer TotalSpecRank, integer BaseSpecRank, integer StartSpecRank] ; SpecName = Specialization/MainSkill
- list EXTRANORMAL_PSIONICS = []; // psionics [ string PsiSkillName, integer TotalPsiRank, integer BasePsiRank, integer StartPsiRank]
- list EXTRANORMAL_MAGIC = []; // magic [ string MagicSkillName, integer TotalMagicRank, integer BaseMagicRank, integer StartMagicRank]
- list EXTRANORMAL_POWERS = []; // powers [ string PowerSkillName, integer TotalPowerRank, integer BasePowerRank, integer StartPowerRank]
- list ADVAN = []; // advantages [ string ADVANName, integer TotalADVANRank, integer StartingADVANRank ]
- list DISAD = []; // disad [ string DISADName, integer TotalDISADRank, integer StartingDISADRank ]
- list SPECIAL_ABILITIES = []; // special ability [string SpecName, integer BaseRank, integer StartRank] TotalRank not needed as there are no modifiers to character options
- list ENHANCEMENTS = []; // enhancement [string EnhanceName, integer BaseRank, integer StartRank]
- list LIMITATIONS = []; // limits [string LimitName, integer BaseRank, integer StartRank]
- // Derived Statistics
- list BODYPOINTS = []; // bodypoints [integer TotalBodypoints, StartingBodypoints]
- list CURRENTBODYPOINTS = []; // currentbodypoints [integer tempbody, integer actualbody]
- list MOVEMENT = []; // movement [integer TotalModifiedMovement, BaseMovement]
- // Personal Resources
- list FUNDS = []; // FUNDS [integer TotalFunds, integer StartingFunds]
- list EQUIPMENT = []; // Equipment [ string ItemName, integer NumberCarried, integer ItemDieCode ]
- // Level-Based Progress
- integer XP = 0; // 0-2320
- integer XPLEVEL = 1; // 1-30
- integer ATTPOOL = 0; // attributes die pool
- integer SKILLPOOL = 0; // skill die pool
- integer FUNDSPOOL = 0; // resource die pool
- // Gradual Progress
- integer XPLEFT = 0; // unspent XP
- // Random Progress
- integer SKILL_INCREASES; // how many times have we increased skills, when 5 skills, get new skill
- list SKILLS_INCREASED = []; // [ SkillName, TimesFailed ] if TimesFailed = 5, increase skill and reset
- integer NEW_SKILLS; // number of new skills earned through RANDOM skill increases since last reset
- list ATTS_INCREASED = []; // [ AttName, Times Advanced ] if TimesAdvanced = 5, increase att and reset
- //=================
- // MYRIAD CONSTANTS
- //=================
- integer MINXP = 0; // min experience points
- integer MAXXP = 2320; // max experience points
- integer MIN_XPLEVEL = 1; // min XP level
- integer MAX_XPLEVEL = 30; // max XP level
- list XP_BY_LEVEL = [ 0,0,10,25,45,70,100,135,175,220,270,325,385,450,520,595,675,760,850,945,1045,1150,1260,1375,1495,1620,1750,1885,2025,2170,2320 ];
- integer MINATT = 1; // min value for attributes
- integer MAXATT = 6; // max human value for an attribute
- integer MAXSTARTATT = 6; // max value for an attribute at character creation
- integer MINBODYPOINTS = 21; // min value for bodypoints at character creation
- integer MAXBODYPOINTS = 75; // max value for bodypoints at character creation
- integer MINADVAN = 1; // min value for advan rank
- integer MAXADVAN = 100; // max value for advan rank at character creation
- integer MINDISAD = 1; // min value for disad rank
- integer MAXDISAD = 100; // max value for disad rank at character creation
- integer MINSKILL = 1; // min value for skill rank
- integer MAXSKILL = 3; // max value for skill rank at character creation
- integer MINSPEC = 1; // min value for specialization rank
- integer MAXSPEC = 2; // max value for specialization rank at character creation
- integer MINEXTRASKILL = 1; // min value for extranormal skills
- integer MAXEXTRASKILL = 100; // max value for extranormal skills
- integer MINEQUIPPED = 1; // min number of items player can carry
- integer MAXEQUIPPED = 100; // max number of items player can carry TODO: what about bullets?
- //integer MINDAMAGE = 1; // min attack dice for weapon
- //integer MAXDAMAGE = 5; // max attack dice for weapon
- //=====================================
- // MODULE TO MODULE MESSAGING CONSTANTS
- //=====================================
- //integer MODULE_HUD = -1;
- integer MODULE_CHARSHEET = -2;
- //integer MODULE_ARMOR = -3;
- //integer MODULE_BAM = -4;
- //integer MODULE_RUMORS = -5;
- // integer MODULE_CLOSE = -6;
- // integer MODULE_RANGED = -7;
- // integer MODULE_RESILIENCE = -8;
- // integer MODULE_PROGRESS = -9;
- // integer MODULE_WELL = -10;
- // integer MODULE_METER = -11;
- integer LM_SENDTOATTACHMENT = 0x80000000;
- //=========
- // Runtimes
- //=========
- integer FLAG_DEBUG;
- key PLAYERID;
- string DIV="|";
- string ESTATE; // what estate does this region belong to - loaded from region server
- string PROGRESSION; // Progression Method: LEVEL, GRADUAL, or RANDOM
- integer CHANMYRIAD = -999;
- integer CHANOBJECT;
- integer HANDOBJECT;
- //==============
- // Menu Handling
- //==============
- integer MENU_TIMER;
- integer MENU_TIMEOUT = 30;
- integer MENU_CHANNEL;
- integer MENU_HANDLE;
- list MENU;
- //==================
- // NOTECARD HANDLING
- //==================
- list CHARACTERS;
- string CARD;
- string DEFAULT = "Myriad_Lite_To_D6_Character_Sheet_v1.txt"; // character sheet notecard
- integer LINE = 0; // reading line number
- key QUERY = NULL_KEY; // track notecard queries
- //=======================
- // USER-DEFINED FUNCTIONS
- //=======================
- // ADD_XP - Add a point of XP
- ADD_XP(key granterid)
- {
- key objectowner = llList2Key(llGetObjectDetails(granterid,[OBJECT_OWNER]),0);
- key regionowner = llList2Key(llGetParcelDetails(<0,0,0>,[PARCEL_DETAILS_OWNER]),0);
- if ( objectowner!= regionowner )
- {
- ERROR("ADD_XP called by object or player who is not region owner. ["+(string)objectowner+"]["+(string)regionowner+"]");
- return;
- }
- DEBUG("Progression="+PROGRESSION+" XP="+(string)XP+" XPLEVEL="+(string)XPLEVEL);
- if ( PROGRESSION == "RANDOM" )
- {
- ERROR("Unable to add XP in region using Random Progression");
- return;
- }
- if ( XP < MAXXP )
- {
- XP++; // add one to total XP
- if ( PROGRESSION == "LEVEL-BASED" )
- {
- integer currentlevel = XPLEVEL;
- integer templevel = GET_LEVEL_BY_XP(XP);
- if ( templevel > currentlevel )
- {
- XPLEVEL = templevel;
- llOwnerSay("LEVEL UP! Congratulations, you are now XP Level "+(string)XPLEVEL);
- RPEVENT("LEVEL UP! Congratulations, "+llKey2Name(llGetOwner())+" is now XP Level "+(string)XPLEVEL);
- LEVELUP(XPLEVEL);
- }
- return;
- }
- if ( PROGRESSION == "GRADUAL" )
- {
- XPLEFT++; // add one to XP you can spend in gradual progress mode
- return;
- }
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"XP_CHANGED|XP="+(string)XP,llGetOwner());
- DEBUG("Progression="+PROGRESSION+" XP="+(string)XP+" XPLEVEL="+(string)XPLEVEL);
- }
- else
- {
- ERROR("XP already maxed.");
- }
- }
- CALCULATE_LEVEL_BY_XP()
- {
- integer i;
- for ( i=1; i < llGetListLength(XP_BY_LEVEL); i++ )
- {
- integer basexp = llList2Integer(XP_BY_LEVEL,i);
- if ( XP >= basexp )
- {
- SET_XPLEVEL(i);
- }
- }
- }
- CHECK_D6CARDVERSION(string ncversion)
- {
- if ( ncversion!= D6CARDVERSION )
- {
- ERROR("Character sheet format "+ncversion+" found. Format version "+D6CARDVERSION+" expected. Please update character sheets to newer versions.");
- }
- }
- DEBUG(string debugmsg)
- {
- if ( FLAG_DEBUG == TRUE ) // are we debugging?
- {
- llSay(DEBUG_CHANNEL,"("+llKey2Name(PLAYERID)+") MOD CHARSHEET DEBUG: "+debugmsg);
- }
- }
- DEL_PROGRESS(key id)
- {
- key objectowner = llList2Key(llGetObjectDetails(id,[OBJECT_OWNER]),0);
- key regionowner = llList2Key(llGetParcelDetails(<0,0,0>,[PARCEL_DETAILS_OWNER]),0);
- if ( objectowner!= regionowner )
- {
- ERROR("DEL_PROGRESS called by object or player who is not region owner. ["+(string)objectowner+"]["+(string)regionowner+"]");
- return;
- }
- if ( PROGRESSION == "LEVEL-BASED" )
- {
- ATTPOOL = 0;
- SKILLPOOL = 0;
- FUNDSPOOL = 0;
- return;
- }
- if ( PROGRESSION == "GRADUAL" )
- {
- XPLEFT = 0;
- return;
- }
- if ( PROGRESSION == "RANDOM" )
- {
- SKILL_INCREASES = 0;
- NEW_SKILLS = 0;
- SKILLS_INCREASED = [];
- ATTS_INCREASED = [];
- return;
- }
- }
- DUMP_SHEET(key id) // dump current character sheet
- {
- key objectowner = llList2Key(llGetObjectDetails(id,[OBJECT_OWNER]),0);
- key regionowner = llList2Key(llGetParcelDetails(<0,0,0>,[PARCEL_DETAILS_OWNER]),0);
- if ( objectowner!= regionowner )
- {
- ERROR("DUMP_SHEET called by object or player who is not region owner. ["+(string)objectowner+"]["+(string)regionowner+"]");
- return;
- }
- DEBUG("Dumping character sheet to "+llKey2Name(id)+" ("+(string)id+")");
- integer chan = (integer)("0x"+llGetSubString((string)id,0,6));
- string tempname = llGetObjectName();
- llSetObjectName("");
- llSay(chan,"D6VERSION|D6VERSION="+D6VERSION);
- llSay(chan,"CHARACTERNAME|CHARACTERNAME="+CHARACTERNAME);
- // Characteraliases
- llSay(chan,"CHARACTERALIASES|CHARACTERALIASES="+CHARACTERALIASES);
- // Occupations
- llSay(chan,"OCCUPATION|OCCUPATION="+OCCUPATION);
- // Species
- llSay(chan,"SPECIES|SPECIES="+SPECIES);
- // Gender
- llSay(chan,"GENDER|GENDER="+GENDER);
- // Age
- llSay(chan,"AGE|AGE="+AGE);
- // Height
- llSay(chan,"HEIGHT|HEIGHT="+HEIGHT);
- // Weight
- llSay(chan,"WEIGHT|WEIGHT="+WEIGHT);
- // Physicaldescription
- llSay(chan,"PHYSICALDESCRIPTION|PHYSICALDESCRIPTION="+PHYSICALDESCRIPTION);
- // Personality
- llSay(chan,"PERSONALITY|PERSONALITY="+PERSONALITY);
- // Objectives
- llSay(chan,"OBJECTIVES|OBJECTIVES="+OBJECTIVES);
- // Nativelanguage
- llSay(chan,"NATIVELANGUAGE|NATIVELANGUAGE="+NATIVELANGUAGE);
- // Otherinformation
- llSay(chan,"OTHERINFORMATION|OTHERINFORMATION="+OTHERINFORMATION);
- //llSay(chan,"XP="+(string)XP);
- //llSay(chan,"XPLEVEL="+(string)XPLEVEL);
- // Attributes
- integer numstats = llGetListLength(ATTRIBUTES);
- integer count;
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(ATTRIBUTES,count);
- integer totalrank = llList2Integer(ATTRIBUTES,count + 1);
- integer baserank = llList2Integer(ATTRIBUTES,count + 2);
- integer startrank = llList2Integer(ATTRIBUTES,count + 3);
- if ( totalrank > 0 ) llSay(chan,"ATTRIBUTE|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Skills
- numstats = llGetListLength(SKILLS);
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(SKILLS,count);
- integer totalrank = llList2Integer(SKILLS,count +1);
- integer baserank = llList2Integer(SKILLS,count +2);
- integer startrank = llList2Integer(SKILLS,count +3);
- if ( totalrank > 0 ) llSay(chan,"SKILL|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Skill_Specializations
- numstats = llGetListLength(SKILL_SPECIALIZATIONS);
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(SKILL_SPECIALIZATIONS,count);
- integer totalrank = llList2Integer(SKILL_SPECIALIZATIONS,count +1);
- integer baserank = llList2Integer(SKILL_SPECIALIZATIONS,count +2);
- integer startrank = llList2Integer(SKILL_SPECIALIZATIONS,count +3);
- if ( totalrank > 0 ) llSay(chan,"SKILL_SPECIALIZATIONS|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Extranormal_Psionics
- numstats = llGetListLength(EXTRANORMAL_PSIONICS);
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(EXTRANORMAL_PSIONICS,count);
- integer totalrank = llList2Integer(EXTRANORMAL_PSIONICS,count +1);
- integer baserank = llList2Integer(EXTRANORMAL_PSIONICS,count +2);
- integer startrank = llList2Integer(EXTRANORMAL_PSIONICS,count +3);
- if ( totalrank > 0 ) llSay(chan,"EXTRANORMAL_PSIONICS|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Extranormal_Magic
- numstats = llGetListLength(EXTRANORMAL_MAGIC);
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(EXTRANORMAL_MAGIC,count);
- integer totalrank = llList2Integer(EXTRANORMAL_MAGIC,count +1);
- integer baserank = llList2Integer(EXTRANORMAL_MAGIC,count +2);
- integer startrank = llList2Integer(EXTRANORMAL_MAGIC,count +3);
- if ( totalrank > 0 ) llSay(chan,"EXTRANORMAL_MAGIC|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Extranormal_Powers
- numstats = llGetListLength(EXTRANORMAL_POWERS);
- for ( count = 0; count < numstats; count += 4 )
- {
- string name = llList2String(EXTRANORMAL_POWERS,count);
- integer totalrank = llList2Integer(EXTRANORMAL_POWERS,count +1);
- integer baserank = llList2Integer(EXTRANORMAL_POWERS,count +2);
- integer startrank = llList2Integer(EXTRANORMAL_POWERS,count +3);
- if ( totalrank > 0 ) llSay(chan,"EXTRANORMAL_POWERS|"+name+"="+(string)totalrank+(string)baserank+(string)startrank);
- }
- // Advantages
- numstats = llGetListLength(ADVAN);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(ADVAN,count);
- integer totalrank = llList2Integer(ADVAN,count +1);
- integer startrank = llList2Integer(ADVAN,count +2);
- if ( totalrank > 0 ) llSay(chan,"ADVAN|"+name+"="+(string)totalrank+(string)startrank);
- }
- // Disadvantages
- numstats = llGetListLength(DISAD);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(DISAD,count);
- integer totalrank = llList2Integer(DISAD,count +1);
- integer startrank = llList2Integer(DISAD,count +2);
- if ( totalrank > 0 ) llSay(chan,"DISAD|"+name+"="+(string)totalrank+(string)startrank);
- }
- // Special_Abilities
- numstats = llGetListLength(SPECIAL_ABILITIES);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(SPECIAL_ABILITIES,count);
- integer totalrank = llList2Integer(SPECIAL_ABILITIES,count +1);
- integer startrank = llList2Integer(SPECIAL_ABILITIES,count +2);
- if ( totalrank > 0 ) llSay(chan,"SPECIAL_ABILITIES|"+name+"="+(string)totalrank+(string)startrank);
- }
- // Enhancements
- numstats = llGetListLength(ENHANCEMENTS);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(ENHANCEMENTS,count);
- integer totalrank = llList2Integer(ENHANCEMENTS,count +1);
- integer startrank = llList2Integer(ENHANCEMENTS,count +2);
- if ( totalrank > 0 ) llSay(chan,"ENHANCEMENTS|"+name+"="+(string)totalrank+(string)startrank);
- }
- // Limitations
- numstats = llGetListLength(LIMITATIONS);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(LIMITATIONS,count);
- integer totalrank = llList2Integer(LIMITATIONS,count +1);
- integer startrank = llList2Integer(LIMITATIONS,count +2);
- if ( totalrank > 0 ) llSay(chan,"LIMITATIONS|"+name+"="+(string)totalrank+(string)startrank);
- }
- // Bodypoints
- string totalamount = llList2Integer(BODYPOINTS,0);
- integer startingamount = llList2Integer(BODYPOINTS,1);
- llSay(chan,"BODYPOINTS|="+(string)(totalamount)+(string)startingamount);
- // CurrentBodypoints
- string tempamount = llList2Integer(CURRENTBODYPOINTS,0);
- string actualamount = llList2Integer (CURRENTBODYPOINTS,1);
- llSay(chan,"CURRENTBODYPOINTS|="+(string)tempamount+(string)(actualamount));
- // Movement
- string totalmovement = llList2Integer(MOVEMENT,0);
- integer startingmovement = llList2Integer(MOVEMENT,1);
- llSay(chan,"MOVEMENT|="+(string)(totalmovement)+(string)startingmovement);
- // Character Points
- integer TotalPoints = llList2Integer(CHARACTERPOINTS,0);
- integer StartingPoints = llList2Integer(CHARACTERPOINTS,1);
- llSay(chan,"CHARACTERPOINTS|="+(string)TotalPoints+(string)StartingPoints);
- //Fatepoints
- integer TotalFatePoints = llList2Integer(FATEPOINTS,0);
- integer StartingFatePoints = llList2Integer(FATEPOINTS,1);
- llSay(chan,"FATEPOINTS|="+(string)TotalFatePoints+(string)StartingFatePoints);
- // Funds
- integer TotalFunds = llList2Integer(FUNDS,0);
- integer StartingFunds = llList2Integer(FUNDS,1);
- llSay(chan,"FUNDS|="+(string)TotalFunds+(string)StartingFunds);
- // Equipment
- numstats = llGetListLength(EQUIPMENT);
- for ( count = 0; count < numstats; count +=3)
- {
- string name = llList2String(EQUIPMENT,count);
- integer numcarried = llList2Integer(EQUIPMENT,count +1);
- integer diecode = llList2Integer(EQUIPMENT,count +2);
- if ( numcarried > 0 ) llSay(chan,"EQUIPMENT|"+name+"="+(string)numcarried+(string)diecode);
- }
- llSay(chan,"CHARACTER_LOADED");
- llSetObjectName(tempname);
- }
- DUMP_PROGRESS(key id)
- { // id to dump progress back to
- key objectowner = llList2Key(llGetObjectDetails(id,[OBJECT_OWNER]),0);
- key regionowner = llList2Key(llGetParcelDetails(<0,0,0>,[PARCEL_DETAILS_OWNER]),0);
- if ( objectowner!= regionowner )
- {
- ERROR("DUMP_PROGRESS called by object or player who is not region owner. ["+(string)objectowner+"]["+(string)regionowner+"]");
- return;
- }
- integer chan = (integer)("0x"+llGetSubString((key)id,0,6));
- if ( PROGRESSION == "LEVEL-BASED" )
- {
- llSay(chan,"PROGRESS|XP="+(string)XP);
- llSay(chan,"PROGRESS|XPLEVEL="+(string)XPLEVEL);
- llSay(chan,"PROGRESS|ATTPOOL="+(string)ATTPOOL);
- llSay(chan,"PROGRESS|SKILLPOOL="+(string)SKILLPOOL);
- llSay(chan,"PROGRESS|FUNDSPOOL="+(string)FUNDSPOOL);
- return;
- }
- if ( PROGRESSION == "GRADUAL" )
- {
- llSay(chan,"PROGRESS|XP="+(string)XP);
- llSay(chan,"PROGRESS|XPLEFT="+(string)XPLEFT);
- return;
- }
- if ( PROGRESSION == "RANDOM" )
- {
- llSay(chan,"PROGRESS|SKILL_INCREASES="+(string)SKILL_INCREASES);
- llSay(chan,"PROGRESS|NEW_SKILLS="+(string)NEW_SKILLS);
- integer count = llGetListLength(SKILLS_INCREASED);
- integer i;
- for ( i=0; i< count; i++)
- {
- llSay(chan,"PROGRESS|SKILL="+llList2String(SKILLS_INCREASED,i)+"|TIMESFAILED="+llList2String(SKILLS_INCREASED,i + 1));
- }
- count = llGetListLength(ATTS_INCREASED);
- for ( i=0; i< count; i++)
- {
- llSay(chan,"PROGRESS|ATT="+llList2String(ATTS_INCREASED,i)+"|TIMESADVANCERD="+llList2String(ATTS_INCREASED,i + 1));
- }
- return;
- }
- }
- ERROR(string errmsg)
- {
- llSay(DEBUG_CHANNEL,"("+llKey2Name(PLAYERID)+") MOD CHARSHEET ERROR: "+errmsg);
- }
- FIND_NOTECARD()
- {
- CHARACTERS = [];
- MENU = ["Default"];
- //string regionname = llGetRegionName();
- integer count = llGetInventoryNumber(INVENTORY_NOTECARD);
- while (count--)
- {
- string currentcard = llGetInventoryName(INVENTORY_NOTECARD,count);
- list tokens = llParseString2List(currentcard,["@"],[]);
- string cardname = llList2String(tokens,0);
- string cardestate = llList2String(tokens,1);
- if ( cardname!= DEFAULT && cardestate == ESTATE )
- {
- CHARACTERS = [cardname,currentcard] + CHARACTERS;
- MENU = [cardname] + MENU;
- DEBUG("Found estate-specific character sheet "+cardname+"@"+cardestate);
- }
- }
- MENU_CHANNEL = (integer)llFrand(9999.0) * -1;
- MENU_HANDLE = llListen(MENU_CHANNEL,"",llGetOwner(),"");
- llDialog(llGetOwner(),"Choose your character",MENU,MENU_CHANNEL);
- MENU_TIMER = MENU_TIMEOUT;
- llSetTimerEvent(1.0);
- }
- integer GET_ATT(string gattname, integer gtotattrank, integer gbaseattrank, integer gstartattrank) // gattname = get attribute name
- {
- integer pos = llListFindList(ATTRIBUTES,[gattname]);
- if ( pos >= 0 )
- {
- integer gtotattrank = llList2Integer(ATTRIBUTES,pos + 1);
- integer gbaseattrank = llList2Integer(ATTRIBUTES,pos + 2);
- integer gstartattrank = llList2Integer(ATTRIBUTES,pos +3);
- return;
- }
- return 0;
- }
- integer GET_CURRENTBODYPOINTS(integer gcurbodytemp, integer gcurbodyactual)
- {
- integer gcurbodytemp = llList2Integer(CURRENTBODYPOINTS,0);
- integer gcurbodyactual = llList2Integer(CURRENTBODYPOINTS,1);
- return CURRENTBODYPOINTS;
- }
- integer GET_LEVEL_BY_XP(integer amount)
- {
- integer count = 0;
- integer outlevel = 0;
- for (count = 0; count < MAX_XPLEVEL; count++ )
- {
- if ( amount > llList2Integer(XP_BY_LEVEL,count) ) outlevel = count;
- }
- DEBUG("GET_LEVEL_BY_XP("+(string)amount+") returning "+(string)outlevel);
- return outlevel;
- }
- integer GET_BODYPOINTS(integer gtotmaxbody, integer gstartbody)
- {
- integer gtotalmaxbody = llList2Integer(BODYPOINTS,0);
- integer gstartmaxbody = llList2Integer(BODYPOINTS,1);
- return BODYPOINTS;
- }
- GETVERSION()
- {
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"VERSION_INFO"+DIV+"NAME="+llGetScriptName()+DIV+"D6VERSION="+D6VERSION+DIV+"D6VERSIONDATE="+D6VERSIONDATE,llGetOwner());
- }
- integer GET_XP()
- {
- if ( XP >= MINXP && XP <= MAXXP)
- {
- // inform all other modules that might need to track XPLEVEL
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"GET_XP|XP="+(string)XP,llGetOwner());
- return XP;
- } else
- {
- ERROR("GET_XP("+(string)XP+") AMOUNT OUT OF RANGE "+(string)MINXP+"-"+(string)MAXXP+"! RESETTING");
- }
- RESET();
- return 0;
- }
- integer GET_XPLEVEL()
- {
- if ( XPLEVEL >= MIN_XPLEVEL && XPLEVEL <= MAX_XPLEVEL)
- {
- // inform all other modules that might need to track XPLEVEL
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"GET_XPLEVEL|XPLEVEL="+(string)XPLEVEL,llGetOwner());
- return XPLEVEL;
- } else
- {
- ERROR("GET_XPLEVEL ["+(string)XPLEVEL+"] AMOUNT OUT OF RANGE "+(string)MIN_XPLEVEL+"-"+(string)MAX_XPLEVEL+"! RESETTING");
- }
- RESET();
- return 0;
- }
- INCREASE_ATT(string iattname) // iattname = increase attribute name
- {
- integer pos = llListFindList(ATTRIBUTES,[iattname]);
- if ( pos >= 0 ) // found skill in list
- {
- integer totcurval = llList2Integer(ATTRIBUTES,pos +1);
- integer curval = llList2Integer(ATTRIBUTES,pos + 2);
- if ( curval < MAXATT )
- {
- ATTRIBUTES = llListReplaceList(ATTRIBUTES,[totcurval++,curval++],pos +1, pos +2);
- RPEVENT("increased their "+iattname+" attribute by one.");
- }
- } else
- {
- ERROR("Requested att increase for nonexistent att "+iattname);
- }
- }
- INCREASE_SKILL(string isname) // isname = increase skill name
- {
- integer pos = llListFindList(SKILLS,[isname]);
- if ( pos >= 0 ) // found skill in list
- {
- integer totcurval = llList2Integer(SKILLS,pos +1);
- integer curval = llList2Integer(SKILLS,pos + 2);
- SKILLS = llListReplaceList(SKILLS,[totcurval++,curval++],pos + 1,pos + 2);
- RPEVENT("increased their "+isname+" skill by one.");
- llRegionSay(CHANMYRIAD,"GET_SKILL|"+isname);
- } else
- {
- ERROR("Requested Skill increase for nonexistent skill "+isname);
- }
- }
- INCREASE_SKILL_SPECIALIZATIONS(string issname) // isname = increase skill specialization name
- {
- integer pos = llListFindList(SKILL_SPECIALIZATIONS,[issname]);
- if ( pos >= 0 ) // found skill in list
- {
- integer totcurval = llList2Integer(SKILL_SPECIALIZATIONS,pos +1)
- integer curval = llList2Integer(SKILL_SPECIALIZATIONS,pos + 2);
- SKILL_SPECIALIZATIONS = llListReplaceList(SKILL_SPECIALIZATIONS,[totcurvall++,curval++],pos + 1,pos + 2);
- RPEVENT("increased their "+issname+" skill by one.");
- llRegionSay(CHANMYRIAD,"GET_SKILL|"+issname);
- } else
- {
- ERROR("Requested Skill increase for nonexistent skill "+issname);
- }
- }
- // LEVEL UP - Calculate bonuses related to new level
- LEVELUP(integer newlevel)
- {
- // In the Myriad system, each time a character gains a new level he is given two skill points, each of which can be used to purchase a new skill at level 1 or improve an existing skill by one level. Keeping this method as an alternate means of character improvement for Open D6, with the addition that 1 skill point can increase a specialization skill by 2 ranks.
- SKILLPOOL += 2; // add two skill points per level
- // Finally, the character earns one quarter of a attribute point to improve any one attribute with.
- if ( ( newlevel% 4 ) == 0 ) // every 4th level
- {
- ATTPOOL++; // add a new att point
- }
- }
- RESET()
- {
- // do any final work, then reset
- llResetScript();
- }
- RPEVENT(string text)
- {
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,text,llGetOwner());
- }
- SET_ADVAN(string advanname,integer advantotrank, integer advanstartrank) // TODO how to verify advan names are valid?
- {
- if ( advanstartrank >= MINADVAN && advanstartrank <= MAXADVAN ) // rank valid?
- {
- ADVAN = [advanname,advantotrank,advanstartrank] + ADVAN; // add advan to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_ADVAN|"+advanname+"="+(string)advantotrank+(string)advanstartrank,llGetOwner());
- } else // invalid, report it
- {
- ERROR("ADVAN "+advanname+" rank "+(string)advanstartrank+" value out of allowed range: "+(string)MINADVAN+"-"+(string)MAXADVAN);
- }
- }
- SET_ATT(string attname,integer atttotrank,integer attbaserank,integer attstartrank) // TODO how to verify att names are valid?
- {
- if ( attbaserank >= MINATT && attbaserank <= MAXATT && attstartrank <= MAXSTARTATT ) // rank valid?
- {
- integer attpos = llListFindList(ATTRIBUTES,[attname]);
- if ( attpos < 0 )
- {
- ATTRIBUTES = [attname,atttotrank,attbaserank,attstartrank] + ATTRIBUTES; // add attribute to list
- }
- else
- {
- ATTRIBUTES = llListReplaceList(ATTRIBUTES,[atttotrank,attbaserank,attstartrank],attpos + 1,attpos + 3);
- }
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_ATTRIBUTE|"+attname+"="+(string)atttotrank+(string)attbaserank+(string)attstartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("ATTRIBUTE "+attname+" base rank "+(string)attbaserank+" or starting rank"+(string)attstartrank+" value out of allowed range: "+(string)MINATT+"-"+(string)MAXATT+" for base rank,"+(string)MAXSTARTATT+" for maximum starting rank.");
- }
- }
- SET_ATTPOOL(integer attamt)
- {
- if ( attamt >= 0 )
- {
- ATTPOOL = attamt;
- }
- else
- {
- ERROR("SET_ATTPOOL("+(string)attamt+") REQUESTED AMOUNT OUT OF RANGE: LESS THAN ZERO");
- }
- }
- // Set Bodypoints and Current Bodypoints
- // SET_BODYPOINTS updates the total number and starting number of bodypoints from the character sheet, replacing the old list with the new information. In addition, this sets the current bodypoints' actual bodypoint total, using the total number of bodypoints as a reference. Until I've managed to find a way to work in temporary current bodypoints from special abilities, the temporary current bodypoints will remain at a constant of 0.
- SET_BODYPOINTS(integer totbody,integer startbody)
- {
- if ( startbody >= MINBODYPOINTS && startbody <= MAXBODYPOINTS ) // rank valid?
- {
- BODYPOINTS = llListReplaceList(BODYPOINTS,[totbody,startbody],0,1); // replace the BODYPOINTS list with the values in the notecard
- CURRENTBODYPOINTS = llListReplaceList(CURRENTBODYPOINTS,[totbody,startbody],0,1); // replace the CURRENTBODYPOINTS list with the values from the notecard
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_CURRENTBODYPOINTS|"+(string)totbody+(string)startbody,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("BODYPOINTS start rank "+(string)startbody+" value out of allowed range: "+(string)MINBODYPOINTS+"-"+(string)MAXBODYPOINTS);
- }
- }
- SET_CURRENTBODYPOINTS(integer newtempbody,integer newcurbody)
- {
- CURRENTBODYPOINTS = llListReplaceList(CURRENTBODYPOINTS,[newtempbody,newcurbody],0,1);
- // Idea on keeping track of temporary body points: the Resilience Module recieves the temp and current body points from the character sheet module. From there, if the character is struck, have the Resilience Module FIRST check to see if there are any temporary body points. If so, the code first removes the temporary points. If there are still points past the temporary point count, the Res Module THEN removes the actual current bodypoints. If there are no temporary bodypoints, then it reduces the actual current bodypoints by the amount of damage caused.
- // Keeping track of temporary skill and attribute boosts is a bit tricky, however. I'm considering the idea of creating a Buff/Debuff Module that sends and receives data on the total attribute and skill points. If a particular buff/debuff mode is active, it sends out information concerning how to modify stats to the main and/or character sheet module. When they are inactive, it changes the stats back to the default stats. Basically, the Buff/Debuff module will be a list of buffs/debuffs that note if they are active, sending this information out. If they are active, it starts a timer based on whatever conditions that particular debuff/buff requires. When the timer reaches 0, it deactivates the buff/debuff, and it sends this information out. Meanwhile, the main and/or character module notes that the buff/debuff is active, takes the information on much much to raise the stat by, then when the buff/debuff is inactive, returns the stat to its default state.
- }
- SET_CHARACTERNAME(string aname)
- {
- CHARACTERNAME = aname;
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_CHARACTERNAME|CHARACTERNAME="+CHARACTERNAME,llGetOwner());
- }
- SET_DISAD(string disadname,integer disadtotrank,integer disadstartrank) // TODO how to verify disad names are valid?
- {
- if ( disadstartrank >= MINDISAD && disadstartrank <= MAXDISAD ) // rank valid?
- {
- DISAD = [disadname,disadtotrank,disadstartrank] + DISAD; // add disad to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_DISAD|"+disadname+"="+(string)disadtotrank+(string)disadstartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("DISAD "+disadname+" starting rank "+(string)disadstartrank+" value out of allowed range: "+(string)MINDISAD+"-"+(string)MAXDISAD);
- }
- }
- SET_EQUIPMENT(string equipmentname,integer equipmentamount,integer equipmentdiecode) // TODO how to verify the equipment name is valid?
- {
- if ( equipmentamount >= MINEQUIPPED && equipmentamount <= MAXEQUIPPED ) // amount valid?
- {
- EQUIPMENT = [equipmentname,equipmentamount,equipmentdiecode] + EQUIPMENT; // add equipment to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_EQUIPMENT|"+equipmentname+"="+(string)equipmentamount+(string)equipmentdiecode,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("EQUIPMENT "+equipmentname+" amount "+(string)equipmentamount+" value out of allowed range: "+(string)MINEQUIPPED+"-"+(string)MAXEQUIPPED);
- }
- }
- SET_ESTATE(string anestate)
- {
- ESTATE = anestate;
- DEBUG("Estate: ["+ESTATE+"]");
- }
- SET_EXTRANORMAL_MAGIC(string magname,integer magtotrank,integer magbaserank,integer magstartrank)
- {
- // TODO how to verify effect name?
- if ( magbaserank >= MINEXTRASKILL && magbaserank <= MAXEXTRASKILL ) // effect rank valid?
- {
- EXTRANORMAL_MAGIC = [magname,magtotrank,magbaserank,magstartrank] + EXTRANORMAL_MAGIC; // add effect to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_EXTRANORMAL_MAGIC|"+magname+"="+(string)magtotrank+(string)magbaserank+(string)magstartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("EXTRANORMAL MAGIC "+magname+" base rank "+(string)magbaserank+" value out of allowed range: "+(string)MINEXTRASKILL+"-"+(string)MAXEXTRASKILL);
- }
- }
- SET_EXTRANORMAL_POWERS(string powername,integer powertotrank,integer powerbaserank,integer powerstartrank)
- {
- // TODO how to verify effect name?
- if ( powerbaserank >= MINEXTRASKILL && powerbaserank <= MAXEXTRASKILL ) // effect rank valid?
- {
- EXTRANORMAL_POWERS = [powername,powertotrank,powerbaserank,powerstartrank] + EXTRANORMAL_POWERS; // add effect to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_EXTRANORMAL_POWERS|"+powername+"="+(string)powertotrank+(string)powerbaserank+(string)powerstartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("EXTRANORMAL POWER "+powername+" base rank "+(string)powerbaserank+" value out of allowed range: "+(string)MINEXTRASKILL+"-"+(string)MAXEXTRASKILL);
- }
- }
- SET_EXTRANORMAL_PSIONICS(string psiname,integer psitotrank,integer psibaserank,integer psistartrank) // TODO how to verify effect name?
- {
- if ( psitotrank >= MINEXTRASKILL && psitotrank <= MAXEXTRASKILL ) // effect rank valid?
- {
- EXTRANORMAL_PSIONICS = [psiname,psitotrank,psibaserank,psistartrank] + EXTRANORMAL_PSIONICS; // add effect to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_EXTRANORMAL_PSIONICS|"+psiname+"="+(string)psitotrank+(string)psibaserank+(string)psistartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("EXTRANORMAL PSIONICS "+psiname+" rank "+(string)psibaserank+" value out of allowed range: "+(string)MINEXTRASKILL+"-"+(string)MAXEXTRASKILL);
- }
- }
- SET_FUNDS(integer fundstotal,integer fundsstart) // TODO how to verify funds?
- {
- FUNDS = [fundstotal,fundsstart] + FUNDS; // add funds to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_FUNDS|FUNDS="+(string)fundstotal+(string)fundsstart,llGetOwner());
- }
- SET_FUNDSPOOL(integer fundsamt)
- {
- if ( fundsamt >= 0 )
- {
- FUNDSPOOL = fundsamt;
- } else
- {
- ERROR("SET_FUNDSPOOL("+(string)fundsamt+") REQUESTED AMOUNT OUT OF RANGE: LESS THAN ZERO");
- }
- }
- SET_OTHERINFORMATION(string someinfo)
- {
- OTHERINFORMATION = someinfo;
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_OTHERINFORMATION|OTHERINFORMATION="+OTHERINFORMATION,llGetOwner());
- }
- SET_OCCUPATION(string anoccupation)
- {
- OCCUPATION = anoccupation;
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_OCCUPATION|OCCUPATION="+OCCUPATION,llGetOwner());
- }
- SET_PROGRESSION(string method)
- {
- method = llToUpper(method);
- if ( method == "LEVEL-BASED" || method == "GRADUAL" || method == "RANDOM" )
- {
- PROGRESSION = method;
- DEBUG("Character progression method set to: "+method);
- }
- else
- {
- ERROR("Unknown progression method: "+method+"! Roleplay progress will not be counted.");
- }
- }
- SET_SPECIAL_ABILITIES(string abilityname,integer abilitytotrank, integer abilitystartrank) // TODO how to verify effect name?
- {
- if ( abilitystartrank >= MINEXTRASKILL && abilitystartrank <= MAXEXTRASKILL ) // effect rank valid?
- {
- SPECIAL_ABILITIES = [abilityname,abilitytotrank,abilitystartrank] + SPECIAL_ABILITIES; // add effect to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_SPECIAL_ABILITIES|"+abilityname+"="+(string)abilitytotrank+(string)abilitystartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("VEHICLE EFFECT "+abilityname+" starting rank "+(string)abilitystartrank+" value out of allowed range: "+(string)MINEXTRASKILL+"-"+(string)MAXEXTRASKILL);
- }
- }
- SET_SPECIES(string aspecies)
- {
- SPECIES = aspecies;
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_SPECIES|SPECIES="+SPECIES,llGetOwner());
- }
- SET_SKILL(string skillname,integer skilltotrank,integer skillbaserank,integer skillstartrank) // TODO how to verify skill names are valid?
- {
- if ( skillstartrank >= MINSKILL && skillstartrank <= MAXSKILL ) // skill rank valid?
- {
- SKILLS = [skillname,skilltotrank,skillbaserank,skillstartrank] + SKILLS; // add skill to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_SKILL|"+skillname+"="+(string)skilltotrank+(string)skillbaserank+(string)skillstartrank,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("SKILL "+skillname+" starting rank "+(string)skillstartrank+" value out of allowed range: "+(string)MINSKILL+"-"+(string)MAXSKILL);
- }
- }
- SET_SKILLPOOL(integer skillamt)
- {
- if ( skillamt >= 0 )
- {
- SKILLPOOL = skillamt;
- }
- else
- {
- ERROR("SET_SKILLPOOL("+(string)skillamt+") REQUESTED AMOUNT OUT OF RANGE: LESS THAN ZERO");
- }
- }
- SET_SKILL_SPECIALIALIZATION(string specname,integer spectot,integer specbase,integer specstart) // TODO how to verify specialization?
- {
- if ( specstart >= MINSPEC && specstart <= MAXSPEC) // skill rank valid?
- {
- SKILL_SPECIALIALIZATION = [specname,spectot,specbase,specstart] + SKILL_SPECIALIALIZATION; // add skill to list
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SKILL_SPECIALIALIZATION|"+specname+"="+(string)spectot+(string)specbase+(string)specstart,llGetOwner());
- }
- else // invalid, report it
- {
- ERROR("SKILL_SPECIALIALIZATION "+specname+" starting rank "+(string)specstart+" value out of allowed range: "+(string)MINSPEC+"-"+(string)MAXSPEC);
- }
- }
- SET_XP(integer xpamt)
- {
- if ( xpamt >= MINXP && xpamt <= MAXXP )
- {
- XP = xpamt;
- CALCULATE_LEVEL_BY_XP();
- // inform all other modules that might need to track XP
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_XP|XP="+(string)XP,llGetOwner());
- }
- else
- {
- ERROR("SET_XP("+(string)xpamt+") REQUESTED AMOUNT OF RANGE: "+(string)MINXP+"-"+(string)MAXXP);
- }
- }
- SET_XPLEVEL(integer xplevelamt)
- {
- if ( xplevelamt >= MIN_XPLEVEL && xplevelamt <= MAX_XPLEVEL )
- {
- XPLEVEL = xplevelamt; // save local state
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"SET_XPLEVEL|XPLEVEL="+(string)XPLEVEL,llGetOwner());
- }
- else
- {
- ERROR("SET_XPLEVEL("+(string)xplevelamt+") REQUESTED AMOUNT OUT OF RANGE: "+(string)MIN_XPLEVEL+"-"+(string)MAX_XPLEVEL);
- }
- }
- SETUP()
- {
- FLAG_DEBUG = FALSE;
- PLAYERID = llGetOwner();
- CHANOBJECT = (integer)("0x"+llGetSubString(llGetKey(),0,6));
- if ( HANDOBJECT!= 0 ) llListenRemove(HANDOBJECT);
- HANDOBJECT = llListen(CHANOBJECT,"",NULL_KEY,"");
- llRegionSay(CHANMYRIAD,"GET_REGION_SETTING|PROGRESSION"); // ask for this first, asking for estate triggers find_notecard function
- llRegionSay(CHANMYRIAD,"GET_REGION_SETTING|ESTATE");
- MENU_TIMER = MENU_TIMEOUT;
- llSetTimerEvent(1.0);
- }
- SKILL_FAILED(string sname)
- {
- if ( PROGRESSION!= "RANDOM" ) return; // tracking skill failure only applies to random progression - ignore message
- integer pos = llListFindList(SKILLS_INCREASED,[sname]);
- if ( pos >= 0 ) // skill already in increase list
- {
- integer current = llList2Integer(SKILLS_INCREASED,pos + 1);
- if ( current < 4 ) // not yet, just note it
- {
- }
- else // has hit 5, increase skill and att
- {
- INCREASE_SKILL(sname); // increase skill
- SKILLS_INCREASED = llListReplaceList(SKILLS_INCREASED,[0],pos + 1,pos + 1);
- }
- }
- else // skill not in increase list
- {
- SKILLS_INCREASED = [sname,1] + SKILLS_INCREASED; // add the skill to the increased list
- }
- SKILL_INCREASES++;
- // now - 5 skill increases = new skill earned
- if ( SKILL_INCREASES == 5 )
- {
- SKILL_INCREASES = 0;
- NEW_SKILLS++;
- RPEVENT("earned a new skill!");
- }
- }
- PARSE(string message,key id)
- {
- //DEBUG("Parse: message=["+message+"] id=["+(string)id+"]");
- // First - handle type 1 messages that do not require breaking down
- string msg = llToLower(message);
- if ( msg == "debugoff" ) { FLAG_DEBUG=FALSE; } // turn off debugging on request
- if ( msg == "debugon" ) { FLAG_DEBUG=TRUE; } // turn on debugging on request
- if ( msg == "reset" ) { RESET(); } // reset on request
- if ( msg == "version") { GETVERSION(); } // respond with version info when requested
- if ( msg == "get_xp" ) { GET_XP(); return; }
- if ( msg == "get_xplevel" ) { GET_XPLEVEL(); return; }
- if ( msg == "dump_sheet" ) { DUMP_SHEET(id); return; } // id is UUID of character builder, sent over from HUD script
- if ( msg == "dump_progress" ) { DUMP_PROGRESS(id); return; } // id is UUID of character builder, sent over from HUD script
- if ( msg == "del_progress" ) { DEL_PROGRESS(id); return; } // id is UUID of item that requested del progress
- if ( msg == "add_xp" ) { ADD_XP(id); return; } // add a point of total and spendable XP
- // Set up variables to process type 2 and type 3 messages
- list tokens; // The parts of the message
- string cmd; // command (example: set attribute)
- string data; // just data, like the character's physical description, or the character's aliases
- list subtokens; // statistic category; (Example: POWERS)
- string statname; // statistic name; (Example: Telepathy)
- integer idata; // integer data; (Example: Telepathy Total Rank)
- integer i2data; // integer data 2 (Example: Telepathy Base Rank)
- integer i3data; // integer data 3 (Example: Telepathy Starting Rank)
- string sdata; // string data (Used for getting the list of skills/attributes that fail to advance, when levelling)
- // process type 2 bus messages COMMAND|DATA=...|DATA=...
- if ( llSubStringIndex(message,DIV) >=0 )
- {
- tokens = llParseString2List(message,[DIV],[]);
- cmd = llToLower(llStringTrim(llList2String(tokens,0),STRING_TRIM));
- data = llList2String(tokens,1);
- subtokens = llParseString2List(data,["="],[]);
- statname = llList2String(subtokens,0);
- idata = llList2Integer(subtokens,1);
- i2data = llList2Integer(subtokens,2);
- i3data = llList2Integer(subtokens,3);
- sdata = llList2String(subtokens,1);
- //if ( command == "SET_ESTATE" ) { SET_ESTATE(svalue); return;}
- if ( cmd == "set_xp" ) { SET_XP(idata); return; }
- if ( cmd == "set_xplevel" ) { SET_XPLEVEL(idata); return; }
- if ( cmd == "get_att" ) { GET_ATT(statname,idata,i2data,i3data); return; }
- if ( cmd == "get_bodypoints" ) { GET_BODYPOINTS(idata,i2data); return; }
- if ( cmd == "get_currentbodypoints" ) { GET_CURRENTBODYPOINTS(idata,i2data); return; }
- if ( cmd == "set_currentbodypoints" ) { SET_CURRENTBODYPOINTS(idata,i2data); return; }
- // Progress
- if ( cmd == "skill_failed" ) { SKILL_FAILED(sdata); return; } // SKILL_FAILED|SKILL=name
- if ( cmd == "progress" )
- {
- if ( llToLower(statname) == "xp" )
- {
- XP = idata;
- if ( XP > MAXXP ) XP = MAXXP;
- llSay(PUBLIC_CHANNEL,"Progress XP: "+(string)XP);
- return;
- }
- if ( llToLower(statname) == "xplevel" )
- {
- XPLEVEL = idata;
- if ( XPLEVEL > MAX_XPLEVEL ) XPLEVEL = MAX_XPLEVEL;
- llSay(PUBLIC_CHANNEL,"Progress XP Level: "+(string)XPLEVEL);
- return;
- }
- if ( llToLower(statname) == "attpool" )
- {
- ATTPOOL=idata;
- llSay(PUBLIC_CHANNEL,"Progress Attributes Pool: "+(string)ATTPOOL);
- return;
- }
- if ( llToLower(statname) == "skillpool" )
- {
- SKILLPOOL=idata;
- llSay(PUBLIC_CHANNEL,"Progress Skill Pool: "+(string)SKILLPOOL);
- return;
- }
- return;
- }
- // done processing commands with DIV
- return;
- }
- // Process type 3 messages CATEGORY=ATTRIBUTE,VALUE
- tokens = llParseString2List(message,["="],[]);
- cmd = llToLower(llStringTrim(llList2String(tokens,0),STRING_TRIM));
- data = llList2String(tokens,1);
- subtokens = llCSV2List(data);
- statname = llList2String(subtokens,0);
- idata = llList2Integer(subtokens,1);
- i2data = llList2Integer(subtokens,2);
- i3data = llList2Integer(subtokens,3);
- sdata = llList2String(subtokens,1);
- if ( cmd == "version" ) { CHECK_D6CARDVERSION(data); return;}
- if ( cmd == "charactername" ) { SET_CHARACTERNAME(data); return; }
- if ( cmd == "species" ) { SET_SPECIES(data); return;}
- if ( cmd == "otherinformation" ) { SET_OTHERINFORMATION(data); return; }
- if ( cmd == "occupation" ) { SET_OCCUPATION(data); return; }
- if ( cmd == "attribute" ) { SET_ATT(statname,idata,i2data,i3data); return; }
- if ( cmd == "advan" ) { SET_ADVAN(statname,idata,i2data); return;}
- if ( cmd == "disad" ) { SET_DISAD(statname,idata,i2data); return;}
- if ( cmd == "skill" ) { SET_SKILL(statname,idata,i2data,i3data); return;}
- if ( cmd == "extranormal_psionics" ) { SET_EXTRANORMAL_PSIONICS(statname,idata,i2data,i3data); return;}
- if ( cmd == "extranormal_magic" ) { SET_EXTRANORMAL_MAGIC(statname,idata,i2data,i3data); return;}
- if ( cmd == "extranormal_powers" ) { SET_EXTRANORMAL_POWERS(statname,idata,i2data,i3data); return;}
- if ( cmd == "special_abilities" ) { SET_SPECIAL_ABILITIES(statname,idata,i2data,i3data); return;}
- if ( cmd == "skill_specializations" ) { SET_SKILL_SPECIALIZATIONS(statname,idata,i2data,i3data); return;}
- if ( cmd == "bodypoints" ) { SET_BODYPOINTS(idata,i2data); return;}
- if ( cmd == "funds" ) { SET_FUNDS(idata,i2data); return;}
- if ( cmd == "equipment" ) { SET_EQUIPMENT(statname,idata,i2data,i3data); return;}
- if ( cmd == "xp" ) { SET_XP(idata); return; }
- if ( cmd == "xplevel" ) { SET_XPLEVEL(idata); return; }
- if ( cmd == "attpool" ) { SET_ATTPOOL(idata); return; }
- if ( cmd == "skillpool" ) { SET_SKILLPOOL(idata); return; }
- if ( cmd == "fundspool" ) { SET_FUNDSPOOL(idata); return; }
- if ( cmd == "character_loaded" )
- {
- llSay(PUBLIC_CHANNEL,llKey2Name(PLAYERID)+"'s character loaded.");
- }
- }
- //=======
- //DEFAULT
- //=======
- default
- {
- // dataserver called for each line of notecard requested - process character sheet
- dataserver(key queryid,string data)
- {
- if ( queryid == QUERY ) // ataserver gave us line we asked for?
- {
- if ( data!= EOF ) // we're not at end of notecard file?
- {
- if ( llGetSubString(data,0,0) == "#" ) // does this line start with comment mark?
- {
- QUERY = llGetNotecardLine(CARD,LINE++); // ignore comment and ask for the next line
- return;
- }
- PARSE(data,llGetOwner()); // parse incoming notecard line
- QUERY = llGetNotecardLine(CARD,LINE++); // finished with known keywords, get next line
- }
- else // end of notecard
- {
- // TODO how to verify entire character sheet was completed and loaded?
- llMessageLinked(LINK_THIS,MODULE_CHARSHEET,"CHARACTER_LOADED",llGetOwner()); // done loading
- DEBUG("Character Sheet Loaded.");
- } // end if data not equal eof
- } // end if query id equal
- } // end if data server event
- link_message(integer sender_num,integer num,string str,key id)
- {
- if ( num == MODULE_CHARSHEET || num == LM_SENDTOATTACHMENT ) return; // ignore link messages not sent to us specifically
- DEBUG("EVENT: link_message("+(string)sender_num+","+(string)num+","+str+","+(string)id+")");
- PARSE(str,id); // parse incoming message
- }
- listen(integer channel,string name,key id, string msg)
- {
- name = ""; // LSLint
- id = NULL_KEY; // LSLint
- if ( channel == CHANOBJECT )
- {
- list tokens = llParseString2List(msg,[DIV],[]);
- string command = llToLower(llStringTrim(llList2String(tokens,0),STRING_TRIM));
- if ( command == "region_setting" )
- {
- list sublist = llParseString2List(llList2String(tokens,1),["="],[]);
- if ( llToLower(llStringTrim(llList2String(sublist,0),STRING_TRIM)) == "progression" )
- {
- SET_PROGRESSION(llToUpper(llList2String(sublist,1)));
- return;
- }
- if ( llToLower(llStringTrim(llList2String(sublist,0),STRING_TRIM)) == "estate" )
- {
- SET_ESTATE(llList2String(sublist,1));
- FIND_NOTECARD();
- return;
- }
- return;
- }
- if ( command == "skill" )
- {
- integer t = llGetListLength(tokens);
- integer c;
- for ( c = 0; c < t; c++)
- {
- list sublist = llParseString2List(llList2String(tokens,c),["="],[]);
- string statname = llToLower(llList2String(sublist,0));
- if ( statname == "basestat" )
- {
- string value = llList2String(sublist,1);
- INCREASE_STAT(value);
- }
- }
- }
- PARSE(msg,id); // parse incoming chat message not REGION_SETTING or SKILL data
- return;
- }
- if ( channel == MENU_CHANNEL )
- {
- if ( msg == "Default" )
- {
- CARD = DEFAULT;
- }
- else
- {
- integer listpos = llListFindList(CHARACTERS,[msg]);
- if ( listpos >= 0 )
- {
- CARD = llList2String(CHARACTERS,listpos + 1);
- }
- }
- DEBUG("Loading character sheet: "+CARD);
- llSetTimerEvent(0.0);
- MENU_TIMER = 0;
- llListenRemove(MENU_HANDLE);
- QUERY = llGetNotecardLine(CARD,LINE++); // ask for line from notecard and advance to next line
- return;
- }
- }
- state_entry()
- {
- SETUP();
- }
- timer()
- {
- MENU_TIMER--; // timer still running, decrement
- if ( MENU_TIMER <= 0 ) // timed out
- {
- DEBUG("Character Sheet Menu timed out. Using default character sheet."); // tell the owner
- llListenRemove(MENU_HANDLE); // remove the listener
- MENU_TIMER = 0;
- llSetTimerEvent(0.0); // stop the timer
- CARD = DEFAULT;
- QUERY = llGetNotecardLine(CARD,LINE++);
- }
- }
- }
- // END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement