Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Template:box Sheet Auteur

From Roll20 Wiki

Revision as of 17:57, 28 April 2017 by jhorox (Talk | contribs)

Jump to: navigation, search

<input class="npc_toggle" name="attr_npc_toggle" type="hidden" value="0">

   <input class="npc_options-flag" type="checkbox" name="attr_npc_options-flag" checked="checked">y
           NPC OPTIONS
           NAME
           <input type="text" name="attr_npc_name" accept="Name">
           NPC TYPE
           <input type="text" name="attr_npc_type" placeholder="Medium fiend, any evil alignment" data-i18n-placeholder="npc-type-place">
           ARMOR CLASS
           <input class="num" type="text" name="attr_npc_ac" placeholder="10">
           TYPE
           <input type="text" name="attr_npc_actype" placeholder="scale mail" data-i18n-placeholder="npc-armor-place">
           HIT POINTS
           <input class="num" type="text" name="attr_hp_max" placeholder="82">
           FORMULA
           <input type="text" name="attr_npc_hpformula" placeholder="11d8 + 33">
           SPEED
           <input type="text" name="attr_npc_speed" placeholder="30 ft., fly 60ft." accept="Speed" data-i18n-placeholder="npc-speed-place">
           ATTRIBUTES
           STR
           <input class="num" type="text" name="attr_strength" value="10" accept="STR">
           DEX
           <input class="num" type="text" name="attr_dexterity" value="10" accept="DEX">
           CON
           <input class="num" type="text" name="attr_constitution" value="10" accept="CON">
           INT
           <input class="num" type="text" name="attr_intelligence" value="10" accept="INT">
           WIS
           <input class="num" type="text" name="attr_wisdom" value="10" accept="WIS">
           CHA
           <input class="num" type="text" name="attr_charisma" value="10" accept="CHA">
           SAVES
           STR
           <input class="num" type="text" name="attr_npc_str_save" placeholder="0">
           DEX
           <input class="num" type="text" name="attr_npc_dex_save" placeholder="0">
           CON
           <input class="num" type="text" name="attr_npc_con_save" placeholder="0">
           INT
           <input class="num" type="text" name="attr_npc_int_save" placeholder="0">
           WIS
           <input class="num" type="text" name="attr_npc_wis_save" placeholder="0">
           CHA
           <input class="num" type="text" name="attr_npc_cha_save" placeholder="0">
           SKILLS
                   ACROBATICS
                   <input class="num" type="text" name="attr_npc_acrobatics" placeholder="0">
                   ANIMAL HANDLING
                   <input class="num" type="text" name="attr_npc_animal_handling" placeholder="0">
                   ARCANA
                   <input class="num" type="text" name="attr_npc_arcana" placeholder="0">
                   ATHLETICS
                   <input class="num" type="text" name="attr_npc_athletics" placeholder="0">
                   DECEPTION
                   <input class="num" type="text" name="attr_npc_deception" placeholder="0">
                   HISTORY
                   <input class="num" type="text" name="attr_npc_history" placeholder="0">
                   INSIGHT
                   <input class="num" type="text" name="attr_npc_insight" placeholder="0">
                   INTIMIDATION
                   <input class="num" type="text" name="attr_npc_intimidation" placeholder="0">
                   INVESTIGATION
                   <input class="num" type="text" name="attr_npc_investigation" placeholder="0">
                   MEDICINE
                   <input class="num" type="text" name="attr_npc_medicine" placeholder="0">
                   NATURE
                   <input class="num" type="text" name="attr_npc_nature" placeholder="0">
                   PERCEPTION
                   <input class="num" type="text" name="attr_npc_perception" placeholder="0">
                   PERFORMANCE
                   <input class="num" type="text" name="attr_npc_performance" placeholder="0">
                   PERSUASION
                   <input class="num" type="text" name="attr_npc_persuasion" placeholder="0">
                   RELIGION
                   <input class="num" type="text" name="attr_npc_religion" placeholder="0">
                   SLEIGHT OF HAND
                   <input class="num" type="text" name="attr_npc_sleight_of_hand" placeholder="0">
                   STEALTH
                   <input class="num" type="text" name="attr_npc_stealth" placeholder="0">
                   SURVIVAL
                   <input class="num" type="text" name="attr_npc_survival" placeholder="0">
           DAMAGE VULNERABILITIES
           <input type="text" name="attr_npc_vulnerabilities" placeholder="fire" accept="Vulnerabilities" data-i18n-placeholder="npc-dmg-vuln-place">
           DAMAGE RESISTANCES
           <input type="text" name="attr_npc_resistances" placeholder="cold" accept="Resistances" data-i18n-placeholder="npc-dmg-res-place">
           DAMAGE IMMUNITIES
           <input type="text" name="attr_npc_immunities" placeholder="lighting, thunder" accept="Immunities" data-i18n-placeholder="npc-dmg-imm-place">
           CONDITION IMMUNITIES
           <input type="text" name="attr_npc_condition_immunities" placeholder="charmed" accept="Condition Immunities" data-i18n-placeholder="npc-cond-imm-place">
           SENSES
           <input type="text" name="attr_npc_senses" placeholder="darkvision 120ft., passive Perception 16" data-i18n-placeholder="npc-senses-place">
           LANGUAGES
           <input type="text" name="attr_npc_languages" placeholder="Abyssal, Common, Infernal" accept="Languages" data-i18n-placeholder="npc-langs-place">
           CHALLENGE
           <input class="num" type="text" name="attr_npc_challenge" placeholder="1" accept="Challenge Rating">
           XP
           <input type="text" name="attr_npc_xp" placeholder="250">
           <input class="npcspellcastingflag" type="checkbox" name="attr_npcspellcastingflag" value="1">
           SPELLCASTING NPC
               SPELLCASTING ABILITY
               <select name="attr_spellcasting_ability" style="margin: 0px; width: auto; padding: 0px; height: 15px;">
                   <option value="0*" data-i18n="none-u">NONE</option>
                   <option value="@{strength_mod}+" data-i18n="strength-u">STRENGTH</option>
                   <option value="@{dexterity_mod}+" data-i18n="dexterity-u">DEXTERITY</option>
                   <option value="@{constitution_mod}+" data-i18n="constitution-u">CONSTITUTION</option>
                   <option value="@{intelligence_mod}+" data-i18n="intelligence-u">INTELLIGENCE</option>
                   <option value="@{wisdom_mod}+" data-i18n="wisdom-u">WISDOM</option>
                   <option value="@{charisma_mod}+" data-i18n="charisma-u">CHARISMA</option>
               </select>
               SPELL DC
               <input class="num" type="text" name="attr_npc_spelldc" placeholder="10">
               SPELL ATTACK BONUS
               <input class="num" type="text" name="attr_npc_spellattackmod" placeholder="3">
           <input type="checkbox" name="attr_npcreactionsflag" value="1">
           HAS REACTIONS
           LEGENDARY ACTIONS:
           <input class="num" type="text" name="attr_npc_legendary_actions" placeholder="0">
       <input type="hidden" name="attr_npc_sizebase" accept="Size">
       <input type="hidden" name="attr_npc_typebase" accept="Type">
       <input type="hidden" name="attr_npc_alignmentbase" accept="Alignment">
       <input type="hidden" name="attr_npc_acbase" accept="AC">
       <input type="hidden" name="attr_npc_hpbase" accept="HP">
       <input type="hidden" name="attr_npc_savingthrowsbase" accept="Saving Throws">
       <input type="hidden" name="attr_npc_sensesbase" accept="Senses">
       <input type="hidden" name="attr_npc_passiveperceptionbase" accept="Passive Perception">
       <input type="hidden" name="attr_npc_skillsbase" accept="Skills">
       <input type="hidden" name="attr_npc_content" accept="Content">
       <input type="hidden" name="attr_token_size" accept="Token Size">
           GENERAL OPTIONS
       <input type="checkbox" name="attr_npc" value="1">
           NPC
           ROLL QUERIES:
           <select name="attr_rtype">
               <option value="Template:Always=1 {{r2=[[1d20" data-i18n="always-adv">Always Roll Advantage</option>
               <option value="@{advantagetoggle}" data-i18n="adv-toggle">Advantage Toggle</option>
               <option value="Template:Query=1 ?{Advantage?|Normal Roll,&#123&#123normal=1&#125&#125 &#123&#123r2=[[0d20|Advantage,&#123&#123advantage=1&#125&#125 &#123&#123r2=[[1d20|Disadvantage,&#123&#123disadvantage=1&#125&#125 &#123&#123r2=[[1d20}" data-i18n="query-adv">Query Advantage</option>
               <option value="Template:Normal=1 {{r2=[[0d20" data-i18n="never-adv">Never Roll Advantage</option>
           </select>
           WHISPER ROLLS TO GM:
           <select name="attr_wtype">
               <option value=""  data-i18n="never-whisp">Never Whisper Rolls</option>
               <option value="?{Whisper?|Public Roll,|Whisper Roll,/w gm }" data-i18n="query-whisp">Query Whisper</option>
               <option value="/w gm " data-i18n="always-whisp">Always Whisper Rolls</option>
           </select>
           AUTO DAMAGE ROLL:
           <select class="dtype" name="attr_dtype">
               <option value="pick" data-i18n="never-dmg">Don't Auto Roll Damage</option>
               <option value="full" data-i18n="always-dmg">Auto Roll Damage & Crit</option>
           </select>
           <button type="roll" name="roll_npc_init" style="width: 100%;" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{init}}} {{mod=[[[[@{dexterity_mod}]][DEX]]]}} {{r1=[[1d20+[[@{dexterity_mod}]][DEX] &{tracker}]]}} Template:Normal=1">
               <input type="text" name="attr_npcd_name" style="text-align: left; margin-left: -4px;">
           </button>
           <input class="italics" type="text" name="attr_npcd_type">
           Armor Class
           <input class="num" type="text" name="attr_npcd_ac">
           <input class="parens" type="text" name="attr_npcd_actype">
           Hit Points
           <input class="num3" type="text" name="attr_npcd_hp">
           <button type="roll" name="roll_npc_hpformula" value="@{wtype}&{template:npc} Template:Normal=1 {{name=@{npc_name}}} {{rname=^{hp}}} {{mod=@{npc_hpformula}}} {{r1=[[@{npc_hpformula}]]}} charname=@{character_name}">
               <input class="parens" type="text" name="attr_npcd_hpformula" style="width: 200px; text-align: left;">
           </button>
           Speed
           <input type="text" name="attr_npcd_speed">
               <button type="roll" name="roll_npc_str" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{strength}}} {{mod=[[[[@{strength_mod}]][STR]]]}} {{r1=[[1d20+[[@{strength_mod}]][STR]]]}} @{rtype}+[[@{strength_mod}]][STR]]]}}">
                   STR
                   <input type="text" name="attr_npcd_str">
                   <input type="text" name="attr_npcd_str_mod">
               </button>
               <button type="roll" name="roll_npc_dex" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{dexterity}}} {{mod=[[[[@{dexterity_mod}]][DEX]]]}} {{r1=[[1d20+[[@{dexterity_mod}]][DEX]]]}} @{rtype}+[[@{dexterity_mod}]][DEX]]]}}">
                   DEX
                   <input type="text" name="attr_npcd_dex">
                   <input type="text" name="attr_npcd_dex_mod">
               </button>
               <button type="roll" name="roll_npc_con" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{constitution}}} {{mod=[[[[@{constitution_mod}]][CON]]]}} {{r1=[[1d20+[[@{constitution_mod}]][CON]]]}} @{rtype}+[[@{constitution_mod}]][CON]]]}}">
                   CON
                   <input type="text" name="attr_npcd_con">
                   <input type="text" name="attr_npcd_con_mod">
               </button>
               <button type="roll" name="roll_npc_int" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{intelligence}}} {{mod=[[[[@{intelligence_mod}]][INT]]]}} {{r1=[[1d20+[[@{intelligence_mod}]][INT]]]}} @{rtype}+[[@{intelligence_mod}]][INT]]]}}">
                   INT
                   <input type="text" name="attr_npcd_int">
                   <input type="text" name="attr_npcd_int_mod">
               </button>
               <button type="roll" name="roll_npc_wis" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{wisdom}}} {{mod=[[[[@{wisdom_mod}]][WIS]]]}} {{r1=[[1d20+[[@{wisdom_mod}]][WIS]]]}} @{rtype}+[[@{wisdom_mod}]][WIS]]]}}">
                   WIS
                   <input type="text" name="attr_npcd_wis">
                   <input type="text" name="attr_npcd_wis_mod">
               </button>
               <button type="roll" name="roll_npc_cha" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{charisma}}} {{mod=[[[[@{charisma_mod}]][CHA]]]}} {{r1=[[1d20+[[@{charisma_mod}]][CHA]]]}} @{rtype}+[[@{charisma_mod}]][CHA]]]}}">
                   CHA
                   <input type="text" name="attr_npcd_cha">
                   <input type="text" name="attr_npcd_cha_mod">
               </button>
       <input class="flag" type="hidden" name="attr_npc_saving_flag" value="0">
           Saving Throws
           <input class="flag" type="hidden" name="attr_npc_str_save_flag" value="0">
           <button type="roll" name="roll_npc_str_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{strength-save}}} {{mod=[[[[@{npc_str_save}]][STR SAVE]]]}} {{r1=[[1d20+[[@{npc_str_save}]][STR SAVE]]]}} @{rtype}+[[@{npc_str_save}]][STR SAVE]]]}}">
               Str +
               <input type="text" name="attr_npcd_str_save">
           </button>
           <input class="flag" type="hidden" name="attr_npc_dex_save_flag" value="0">
           <button type="roll" name="roll_npc_dex_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{dexterity-save}}} {{mod=[[[[@{npc_dex_save}]][DEX SAVE]]]}} {{r1=[[1d20+[[@{npc_dex_save}]][DEX SAVE]]]}} @{rtype}+[[@{npc_dex_save}]][DEX SAVE]]]}}">
               , 
               Dex +
               <input type="text" name="attr_npcd_dex_save">
           </button>
           <input class="flag" type="hidden" name="attr_npc_con_save_flag" value="0">
           <button type="roll" name="roll_npc_con_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{constitution-save}}} {{mod=[[[[@{npc_con_save}]][CON SAVE]]]}} {{r1=[[1d20+[[@{npc_con_save}]][CON SAVE]]]}} @{rtype}+[[@{npc_con_save}]][CON SAVE]]]}}">
               , 
               Con +
               <input type="text" name="attr_npcd_con_save">
           </button>
           <input class="flag" type="hidden" name="attr_npc_int_save_flag" value="0">
           <button type="roll" name="roll_npc_int_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{intelligence-save}}} {{mod=[[[[@{npc_int_save}]][INT SAVE]]]}} {{r1=[[1d20+[[@{npc_int_save}]][INT SAVE]]]}} @{rtype}+[[@{npc_int_save}]][INT SAVE]]]}}">
               , 
               Int +
               <input type="text" name="attr_npcd_int_save">
           </button>
           <input class="flag" type="hidden" name="attr_npc_wis_save_flag" value="0">
           <button type="roll" name="roll_npc_wis_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{wisdom-save}}} {{mod=[[[[@{npc_wis_save}]][WIS SAVE]]]}} {{r1=[[1d20+[[@{npc_wis_save}]][WIS SAVE]]]}} @{rtype}+[[@{npc_wis_save}]][WIS SAVE]]]}}">
               , 
               Wis +
               <input type="text" name="attr_npcd_wis_save">
           </button>
           <input class="flag" type="hidden" name="attr_npc_cha_save_flag" value="0">
           <button type="roll" name="roll_npc_cha_save" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{charisma-save}}} {{mod=[[[[@{npc_cha_save}]][CHA SAVE]]]}} {{r1=[[1d20+[[@{npc_cha_save}]][CHA SAVE]]]}} @{rtype}+[[@{npc_cha_save}]][CHA SAVE]]]}}">
               , 
               Cha +
               <input type="text" name="attr_npcd_cha_save">
           </button>
       <input class="flag" type="hidden" name="attr_npc_skills_flag" value="0">
           Skills
           
               <input class="flag" type="hidden" name="attr_npc_acrobatics_flag" value="0">
               <button type="roll" name="roll_npc_acrobatics" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{acrobatics}}} {{mod=@{npc_acrobatics}}} {{r1=[[1d20+@{npc_acrobatics}]]}} @{rtype}+@{npc_acrobatics}]]}}">
                   , 
                   Acrobatics +
                   <input type="text" name="attr_npcd_acrobatics">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_animal_handling_flag" value="0">
               <button type="roll" name="roll_npc_animal_handling" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{animal-handling}}} {{mod=@{npc_animal_handling}}} {{r1=[[1d20+@{npc_animal_handling}]]}} @{rtype}+@{npc_animal_handling}]]}}">
                   , 
                   Animal Handling +
                   <input type="text" name="attr_npcd_animal_handling">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_arcana_flag" value="0">
               <button type="roll" name="roll_npc_arcana" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{arcana}}} {{mod=@{npc_arcana}}} {{r1=[[1d20+@{npc_arcana}]]}} @{rtype}+@{npc_arcana}]]}}">
                   , 
                   Arcana +
                   <input type="text" name="attr_npcd_arcana">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_athletics_flag" value="0">
               <button type="roll" name="roll_npc_athletics" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{athletics}}} {{mod=@{npc_athletics}}} {{r1=[[1d20+@{npc_athletics}]]}} @{rtype}+@{npc_athletics}]]}}">
                   , 
                   Athletics +
                   <input type="text" name="attr_npcd_athletics">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_deception_flag" value="0">
               <button type="roll" name="roll_npc_deception" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{deception}}} {{mod=@{npc_deception}}} {{r1=[[1d20+@{npc_deception}]]}} @{rtype}+@{npc_deception}]]}}">
                   , 
                   Deception +
                   <input type="text" name="attr_npcd_deception">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_history_flag" value="0">
               <button type="roll" name="roll_npc_history" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{history}}} {{mod=@{npc_history}}} {{r1=[[1d20+@{npc_history}]]}} @{rtype}+@{npc_history}]]}}">
                   , 
                   History +
                   <input type="text" name="attr_npcd_history">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_insight_flag" value="0">
               <button type="roll" name="roll_npc_insight" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{insight}}} {{mod=@{npc_insight}}} {{r1=[[1d20+@{npc_insight}]]}} @{rtype}+@{npc_insight}]]}}">
                   , 
                   Insight +
                   <input type="text" name="attr_npcd_insight">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_intimidation_flag" value="0">
               <button type="roll" name="roll_npc_intimidation" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{intimidation}}} {{mod=@{npc_intimidation}}} {{r1=[[1d20+@{npc_intimidation}]]}} @{rtype}+@{npc_intimidation}]]}}">
                   , 
                   Intimidation +
                   <input type="text" name="attr_npcd_intimidation">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_investigation_flag" value="0">
               <button type="roll" name="roll_npc_investigation" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{investigation}}} {{mod=@{npc_investigation}}} {{r1=[[1d20+@{npc_investigation}]]}} @{rtype}+@{npc_investigation}]]}}">
                   , 
                   Investigation +
                   <input type="text" name="attr_npcd_investigation">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_medicine_flag" value="0">
               <button type="roll" name="roll_npc_medicine" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{medicine}}} {{mod=@{npc_medicine}}} {{r1=[[1d20+@{npc_medicine}]]}} @{rtype}+@{npc_medicine}]]}}">
                   , 
                   Medicine +
                   <input type="text" name="attr_npcd_medicine">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_nature_flag" value="0">
               <button type="roll" name="roll_npc_nature" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{nature}}} {{mod=@{npc_nature}}} {{r1=[[1d20+@{npc_nature}]]}} @{rtype}+@{npc_nature}]]}}">
                   , 
                   Nature +
                   <input type="text" name="attr_npcd_nature">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_perception_flag" value="0">
               <button type="roll" name="roll_npc_perception" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{perception}}} {{mod=@{npc_perception}}} {{r1=[[1d20+@{npc_perception}]]}} @{rtype}+@{npc_perception}]]}}">
                   , 
                   Perception +
                   <input type="text" name="attr_npcd_perception">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_performance_flag" value="0">
               <button type="roll" name="roll_npc_performance" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{performance}}} {{mod=@{npc_performance}}} {{r1=[[1d20+@{npc_performance}]]}} @{rtype}+@{npc_performance}]]}}">
                   , 
                   Performance +
                   <input type="text" name="attr_npcd_performance">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_persuasion_flag" value="0">
               <button type="roll" name="roll_npc_persuasion" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{persuasion}}} {{mod=@{npc_persuasion}}} {{r1=[[1d20+@{npc_persuasion}]]}} @{rtype}+@{npc_persuasion}]]}}">
                   , 
                   Persuasion +
                   <input type="text" name="attr_npcd_persuasion">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_religion_flag" value="0">
               <button type="roll" name="roll_npc_religion" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{religion}}} {{mod=@{npc_religion}}} {{r1=[[1d20+@{npc_religion}]]}} @{rtype}+@{npc_religion}]]}}">
                   , 
                   Religion +
                   <input type="text" name="attr_npcd_religion">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_sleight_of_hand_flag" value="0">
               <button type="roll" name="roll_npc_sleight_of_hand" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{sleight-of-hand}}} {{mod=@{npc_sleight_of_hand}}} {{r1=[[1d20+@{npc_sleight_of_hand}]]}} @{rtype}+@{npc_sleight_of_hand}]]}}">
                   , 
                   Sleight of Hand +
                   <input type="text" name="attr_npcd_sleight_of_hand">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_stealth_flag" value="0">
               <button type="roll" name="roll_npc_stealth" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{stealth}}} {{mod=@{npc_stealth}}} {{r1=[[1d20+@{npc_stealth}]]}} @{rtype}+@{npc_stealth}]]}}">
                   , 
                   Stealth +
                   <input type="text" name="attr_npcd_stealth">
               </button>
           
           
               <input class="flag" type="hidden" name="attr_npc_survival_flag" value="0">
               <button type="roll" name="roll_npc_survival" value="@{wtype}&{template:npc} {{name=@{npc_name}}} {{rname=^{survival}}} {{mod=@{npc_survival}}} {{r1=[[1d20+@{npc_survival}]]}} @{rtype}+@{npc_survival}]]}}">
                   , 
                   Survival +
                   <input type="text" name="attr_npcd_survival">
               </button>
           
       <input class="flag" type="hidden" name="attr_npc_vulnerabilities_flag" value="0">
           Damage Vulnerabilities
           
       <input class="flag" type="hidden" name="attr_npc_resistances_flag" value="0">
           Damage Resistances
           
       <input class="flag" type="hidden" name="attr_npc_immunities_flag" value="0">
           Damage Immunities
           
       <input class="flag" type="hidden" name="attr_npc_condition_immunities_flag" value="0">
           Condition Immunities
           
           Senses
           
           Languages
           
           Challenge
           <input class="num" type="text" name="attr_npcd_challenge">
           <input type="text" name="attr_npcd_xp">
           <fieldset class="repeating_npctrait">
                   <input type="text" name="attr_name" placeholder="False Appearance." data-i18n-placeholder="npc-trait-name-place">
                   <textarea name="attr_desc" placeholder="If the dragon fails..." data-i18n-placeholder="npc-trait-desc-place"></textarea>
           </fieldset>
       <input class="dflag" type="hidden" name="attr_dflag" value="pick">
               Actions
               <input type="hidden" class="toggleflag" name="attr_toggleflag">
                   <input type="radio" class="toggle-left" name="attr_advantagetoggle" value="Template:Query=1  Template:Advantage=1 {{r2=[[1d20">Advantage
                   <input type="radio" class="toggle-center" name="attr_advantagetoggle" value="Template:Query=1  Template:Normal=1 {{r2=[[0d20" checked="checked">Normal
                   <input type="radio" class="toggle-right" name="attr_advantagetoggle" value="Template:Query=1  Template:Disadvantage=1 {{r2=[[1d20">Disadvantage
           <fieldset class="repeating_npcaction">
                   <input class="npc_options-flag" type="checkbox" name="attr_npc_options-flag" checked="checked">y
                           NAME:
                           <input type="text" name="attr_name" accept="Name">
                           <input type="checkbox" name="attr_attack_flag">
                           ATTACK
                       <input type="hidden" class="attack_options" name="attr_attack_options" value="0">
                           TYPE:
                           <select name="attr_attack_type" accept="Spell Attack">
                               <option value="Melee" data-i18n="melee">Melee</option>
                               <option value="Ranged" data-i18n="ranged">Ranged</option>
                           </select>
                           RANGE/REACH:
                           <input type="text" name="attr_attack_range" placeholder="5 ft." style="width: 100px;" accept="Range" data-i18n-placeholder="range-reach-place">
                           TO HIT:
                           <input type="text" name="attr_attack_tohit" placeholder="5" style="width: 30px;">
                           TARGET:
                           <input type="text" name="attr_attack_target" placeholder="One target" style="width: 100px;" data-i18n-placeholder="to-hit-place">
                       <input type="hidden" name="attr_damage_flag">
                           ON HIT:
                           <input type="text" name="attr_attack_damage" placeholder="1d10" style="width: 65px;" accept="Damage">
                           <input type="text" name="attr_attack_damagetype" placeholder="slashing" style="width: 100px;" accept="Damage Type" data-i18n-placeholder="on-hit-place">
                           <input type="hidden" name="attr_attack_crit">
                           ON HIT 2:
                           <input type="text" name="attr_attack_damage2" placeholder="2d6+5" style="width: 65px;" accept="Secondary Damage">
                           <input type="text" name="attr_attack_damagetype2" placeholder="fire" style="width: 100px;" accept="Secondary Damage Type" data-i18n-placeholder="on-hit-2-place">
                           <input type="hidden" name="attr_attack_crit2">
                           <textarea name="attr_description" accept="Content"></textarea>
                       <button class="pick" type="roll" name="roll_npc_action" value="@{rollbase}">
                               <input class="bold wide" type="text" name="attr_name_display">
                           <input class="attack_options" type="hidden" name="attr_attack_display_flag"  value="0">
                               <input class="italics" type="text" name="attr_attack_type_display" style="width: 140px; text-align: left;"><input type="text" name="attr_attack_tohitrange" style="width: 220px; text-align: left;">
                               Hit: <input type="text" name="attr_attack_onhit" style="width: 340px; text-align: left;">
                           <input class="description_flag" type="hidden" name="attr_description_flag" value="0">
                           <textarea name="attr_description"></textarea>
                       </button>
                   <input type="hidden" name="attr_updateflag">
                   <input type="hidden" name="attr_rollbase">
                   <button type="roll" style="display: none;" name="roll_npc_dmg" value="@{wtype}&{template:npcdmg} @{damage_flag} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}}"></button>
                   <button type="roll" style="display: none;" name="roll_npc_crit" value="@{wtype}&{template:npcdmg} @{damage_flag} Template:Crit=1 {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}}"></button>
           </fieldset>
       <input class="reaction_flag" type="hidden" name="attr_reaction_flag">
               Reactions
           <fieldset class="repeating_npcreaction">
                   <input type="text" name="attr_name" placeholder="Parry." data-i18n-placeholder="npc-repeating-name-place">
                   <textarea name="attr_desc" placeholder="The creature adds 2 to its AC against..." data-i18n-placeholder="npc-repeating-desc-place"></textarea>
           </fieldset>
       <input class="npcspell_flag" type="hidden" name="attr_npcspell_flag">
               Spells
               <fieldset class="repeating_spell-npc">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" style="margin-left: 17px;" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Melee" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="npc-atk-effect-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollbase">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
       <input class="legendary_flag" type="hidden" name="attr_legendary_flag">
               Legendary Actions
The can take legendary actions, choosing from the options below. Only one legendary option can be used at a time and only at the end of another creature's turn. The regains spent legendary actions at the start of its turn.
           <fieldset class="repeating_npcaction-l">
                   <input class="npc_options-flag" type="checkbox" name="attr_npc_options-flag" checked="checked">y
                           NAME:
                           <input type="text" name="attr_name">
                           <input type="checkbox" name="attr_attack_flag">
                           ATTACK
                       <input type="hidden" class="attack_options" name="attr_attack_options" value="0">
                           TYPE:
                           <select name="attr_attack_type">
                               <option value="Melee" data-i18n="melee">Melee</option>
                               <option value="Ranged">Ranged</option>
                           </select>
                           RANGE/REACH:
                           <input type="text" name="attr_attack_range" placeholder="5 ft." style="width: 100px;" data-i18n-placeholder="atk-range-place">
                           TO HIT:
                           <input type="text" name="attr_attack_tohit" placeholder="5" style="width: 30px;">
                           TARGET:
                           <input type="text" name="attr_attack_target" placeholder="One target" style="width: 100px;" data-i18n-placeholder="atk-target-place">
                       <input type="hidden" name="attr_damage_flag">
                           ON HIT:
                           <input type="text" name="attr_attack_damage" placeholder="1d10" style="width: 65px;">
                           <input type="text" name="attr_attack_damagetype" placeholder="slashing" style="width: 100px;" data-i18n-placeholder="atk-dmg-type-place">
                           <input type="hidden" name="attr_attack_crit">
                           ON HIT 2:
                           <input type="text" name="attr_attack_damage2" placeholder="2d6+5" style="width: 65px;">
                           <input type="text" name="attr_attack_damagetype2" placeholder="fire" style="width: 100px;" data-i18n-placeholder="atk-dmg-type2-place">
                           <input type="hidden" name="attr_attack_crit2">
                           <textarea name="attr_description"></textarea>
                       <button class="pick" type="roll" name="roll_npc_action" value="@{rollbase}">
                               <input class="bold wide" type="text" name="attr_name_display">
                           <input class="attack_options" type="hidden" name="attr_attack_display_flag"  value="0">
                               <input class="italics" type="text" name="attr_attack_type_display" style="width: 140px; text-align: left;"><input type="text" name="attr_attack_tohitrange" style="width: 220px; text-align: left;">
                               Hit: <input type="text" name="attr_attack_onhit" style="width: 340px; text-align: left;">
                           <input class="description_flag" type="hidden" name="attr_description_flag" value="0">
                           <textarea name="attr_description"></textarea>
                       </button>
                   <input type="hidden" name="attr_updateflag">
                   <input type="hidden" name="attr_rollbase">
                   <button type="roll" style="display: none;" name="roll_npc_dmg" value="@{wtype}&{template:npcdmg} @{damage_flag} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}}"></button>
                   <button type="roll" style="display: none;" name="roll_npc_crit" value="@{wtype}&{template:npcdmg} @{damage_flag} Template:Crit=1 {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}}"></button>
           </fieldset>


<input type="hidden" class="toggleflag" name="attr_toggleflag">

   <input type="radio" class="toggle-left" name="attr_advantagetoggle" value="Template:Query=1 Template:Advantage=1 {{r2=[[1d20">ADVANTAGE
   <input type="radio" class="toggle-center" name="attr_advantagetoggle" value="Template:Query=1 Template:Normal=1 {{r2=[[0d20" checked="checked">NORMAL
   <input type="radio" class="toggle-right" name="attr_advantagetoggle" value="Template:Query=1 Template:Disadvantage=1 {{r2=[[1d20">DISADVANTAGE

<input class="tab-button core" type="radio" name="attr_tab" value="core" checked="checked">CORE <input class="tab-button bio" type="radio" name="attr_tab" value="bio">BIO <input class="tab-button spells" type="radio" name="attr_tab" value="spells">SPELLS <input class="tab-button options" type="radio" name="attr_tab" value="options">y

           <img src="http://i.imgur.com/ZgULBCp.png" style="padding-bottom: 5px;">
           <input type="text" name="attr_character_name" style="width: 100%;">
           CHARACTER NAME
                   <input class="flag" type="hidden" name="attr_customclass_flag" value="0">
                   <input class="showing" type="text" name="attr_cust_class" value="@{cust_classname}" disabled="true" style="width: 64px; height: 28px; padding-top: 10px;">
                   <select class="hiding class" name="attr_class">
                       <option value="Barbarian" data-i18n="barbarian">Barbarian</option>
                       <option value="Bard" data-i18n="bard">Bard</option>
                       <option value="Cleric" data-i18n="cleric">Cleric</option>
                       <option value="Druid" data-i18n="druid">Druid</option>
                       <option value="Fighter" data-i18n="fighter">Fighter</option>
                       <option value="Monk" data-i18n="monk">Monk</option>
                       <option value="Paladin" data-i18n="paladin">Paladin</option>
                       <option value="Ranger" data-i18n="ranger">Ranger</option>
                       <option value="Rogue" data-i18n="rogue">Rogue</option>
                       <option value="Sorcerer" data-i18n="sorcerer">Sorcerer</option>
                       <option value="Warlock" data-i18n="warlock">Warlock</option>
                       <option value="Wizard" data-i18n="wizard">Wizard</option>
                   </select>
                   <input type="number" class="class-level" name="attr_base_level" value="1">
                   CLASS & LEVEL
                   <input class="flag" type="hidden" name="attr_mutliclass1_showingflag" value="0">
                   
                   
                   
                   
                   <input class="flag" type="hidden" name="attr_mutliclass2_showingflag" value="0">
                   
                   
                   
                   
                   <input class="flag" type="hidden" name="attr_mutliclass3_showingflag" value="0">
                   
                   
                   
                   
                   <input type="text" name="attr_background" style="width: 122px;">
                   BACKGROUND
                   <input type="text" name="attr_race">
                   RACE
                   <input type="text" name="attr_alignment">
                   ALIGNMENT
                   <input type="text" name="attr_experience">
                   EXPERIENCE POINTS
                   <button type="roll" name="roll_strength" value="@{wtype}&{template:simple} {{rname=^{strength-u}}} {{mod=[[[[@{strength_mod}]][STR]]]}} {{r1=[[1d20@{halflingluck}+[[@{strength_mod}]][STR]]]}} @{rtype}@{halflingluck}+[[@{strength_mod}]][STR]]]}} @{charname_output}" data-i18n="strength-u">STRENGTH</button>
                   <input class="attr" type="text" name="attr_strength_mod" title="@{strength_mod}" value="(floor((@{strength}-10)/2))" disabled="true">
                       <input type="text" name="attr_strength" title="@{strength}" value="10">
                   <button type="roll" name="roll_dexterity" value="@{wtype}&{template:simple} {{rname=^{dexterity-u}}} {{mod=[[[[@{dexterity_mod}]][DEX]]]}} {{r1=[[1d20@{halflingluck}+[[@{dexterity_mod}]][DEX]]]}} @{rtype}@{halflingluck}+[[@{dexterity_mod}]][DEX]]]}} @{charname_output}" data-i18n="dexterity-u">DEXTERITY</button>
                   <input class="attr" type="text" name="attr_dexterity_mod" title="@{dexterity_mod}" value="(floor((@{dexterity}-10)/2))" disabled="true">
                       <input type="text" name="attr_dexterity" title="@{dexterity}" value="10">
                   <button type="roll" name="roll_constitution" value="@{wtype}&{template:simple} {{rname=^{constitution-u}}} {{mod=[[[[@{constitution_mod}]][CON]]]}} {{r1=[[1d20@{halflingluck}+[[@{constitution_mod}]][CON]]]}} @{rtype}@{halflingluck}+[[@{constitution_mod}]][CON]]]}} @{charname_output}" data-i18n="constitution-u">CONSTITUTION</button>
                   <input class="attr" type="text" name="attr_constitution_mod" title="@{constitution_mod}" value="(floor((@{constitution}-10)/2))" disabled="true">
                       <input type="text" name="attr_constitution" title="@{constitution}" value="10">
                   <button type="roll" name="roll_intelligence" value="@{wtype}&{template:simple} {{rname=^{intelligence-u}}} {{mod=[[[[@{intelligence_mod}]][INT]]]}} {{r1=[[1d20@{halflingluck}+[[@{intelligence_mod}]][INT]]]}} @{rtype}@{halflingluck}+[[@{intelligence_mod}]][INT]]]}} @{charname_output}" data-i18n="intelligence-u">INTELLIGENCE</button>
                   <input class="attr" type="text" name="attr_intelligence_mod" title="@{intelligence_mod}" value="(floor((@{intelligence}-10)/2))" disabled="true">
                       <input type="text" name="attr_intelligence" title="@{intelligence}" value="10">
                   <button type="roll" name="roll_wisdom" value="@{wtype}&{template:simple} {{rname=^{wisdom-u}}} {{mod=[[[[@{wisdom_mod}]][WIS]]]}} {{r1=[[1d20@{halflingluck}+[[@{wisdom_mod}]][WIS]]]}} @{rtype}@{halflingluck}+[[@{wisdom_mod}]][WIS]]]}} @{charname_output}" data-i18n="wisdom-u">WISDOM</button>
                   <input class="attr" type="text" name="attr_wisdom_mod" title="@{wisdom_mod}" value="(floor((@{wisdom}-10)/2))" disabled="true">
                       <input type="text" name="attr_wisdom" title="@{wisdom}" value="10">
                   <button type="roll" name="roll_charisma" value="@{wtype}&{template:simple} {{rname=^{charisma-u}}} {{mod=[[[[@{charisma_mod}]][CHA]]]}} {{r1=[[1d20@{halflingluck}+[[@{charisma_mod}]][CHA]]]}} @{rtype}@{halflingluck}+[[@{charisma_mod}]][CHA]]]}} @{charname_output}" data-i18n="charisma-u">CHARISMA</button>
                   <input class="attr" type="text" name="attr_charisma_mod" title="@{charisma_mod}" value="(floor((@{charisma}-10)/2))" disabled="true">
                       <input type="text" name="attr_charisma" title="@{charisma}" value="10">
                       <input type="checkbox" name="attr_inspiration">
                       INSPIRATION
                       <input type="text" name="attr_pb" title="@{pb}" value="(ceil((@{level})/1e10) + ceil((@{level})/4))" disabled="true" >
                       PROFICIENCY BONUS
                       <input type="checkbox" name="attr_strength_save_prof" title="@{strength_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_strength_save_bonus" title="@{strength_save_bonus}" value="(@{strength_mod}+@{strength_save_prof})" disabled="true">
                       <button type="roll" name="roll_strength_save" value="@{wtype}&{template:simple} {{rname=^{strength-save-u}}} {{mod=[[[[@{strength_save_bonus}]][STR+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{strength_save_bonus}]][STR+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{strength_save_bonus}]][STR+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="strength">Strength</button>
                       <input type="checkbox" name="attr_dexterity_save_prof" title="@{dexterity_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_dexterity_save_bonus" title="@{dexterity_save_bonus}" value="(@{dexterity_mod}+@{dexterity_save_prof})" disabled="true">
                       <button type="roll" name="roll_dexterity_save" value="@{wtype}&{template:simple} {{rname=^{dexterity-save-u}}} {{mod=[[[[@{dexterity_save_bonus}]][DEX+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{dexterity_save_bonus}]][DEX+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{dexterity_save_bonus}]][DEX+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="dexterity">Dexterity</button>
                       <input type="checkbox" name="attr_constitution_save_prof" title="@{constitution_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_constitution_save_bonus" title="@{constitution_save_bonus}" value="(@{constitution_mod}+@{constitution_save_prof})" disabled="true">
                       <button type="roll" name="roll_constitution_save" value="@{wtype}&{template:simple} {{rname=^{constitution-save-u}}} {{mod=[[[[@{constitution_save_bonus}]][CON+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{constitution_save_bonus}]][CON+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{constitution_save_bonus}]][CON+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="constitution">Constitution</button>
                       <input type="checkbox" name="attr_intelligence_save_prof" title="@{intelligence_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_intelligence_save_bonus" title="@{intelligence_save_bonus}" value="(@{intelligence_mod}+@{intelligence_save_prof})" disabled="true">
                       <button type="roll" name="roll_intelligence_save" value="@{wtype}&{template:simple} {{rname=^{intelligence-save-u}}} {{mod=[[[[@{intelligence_save_bonus}]][INT+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{intelligence_save_bonus}]][INT+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{intelligence_save_bonus}]][INT+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="intelligence">Intelligence</button>
                       <input type="checkbox" name="attr_wisdom_save_prof" title="@{wisdom_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_wisdom_save_bonus" title="@{wisdom_save_bonus}" value="(@{wisdom_mod}+@{wisdom_save_prof})" disabled="true">
                       <button type="roll" name="roll_wisdom_save" value="@{wtype}&{template:simple} {{rname=^{wisdom-save-u}}} {{mod=[[[[@{wisdom_save_bonus}]][WIS+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{wisdom_save_bonus}]][WIS+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{wisdom_save_bonus}]][WIS+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="wisdom">Wisdom</button>
                       <input type="checkbox" name="attr_charisma_save_prof" title="@{charisma_save_prof}" value="(@{pb})">
                       <input type="text" name="attr_charisma_save_bonus" title="@{charisma_save_bonus}" value="(@{charisma_mod}+@{charisma_save_prof})" disabled="true">
                       <button type="roll" name="roll_charisma_save" value="@{wtype}&{template:simple} {{rname=^{charisma-save-u}}} {{mod=[[[[@{charisma_save_bonus}]][CHA+PROF]@{globalsavingthrowbonus}]]}} {{r1=[[1d20@{halflingluck}+[[@{charisma_save_bonus}]][CHA+PROF]@{globalsavingthrowbonus}]]}} @{rtype}@{halflingluck}+[[@{charisma_save_bonus}]][CHA+PROF]@{globalsavingthrowbonus}]]}} @{charname_output}" data-i18n="charisma">Charisma</button>
                       SAVING THROWS
                           <input type="checkbox" name="attr_acrobatics_prof" title="@{acrobatics_prof}" value="(@{pb}*@{acrobatics_type})">
                           <input type="text" name="attr_acrobatics_bonus" title="@{acrobatics_bonus}" value="(@{dexterity_mod}+@{acrobatics_proficiency}+@{acrobatics_flat})" disabled="true">
                           <button type="roll" name="roll_acrobatics" value="@{wtype}&{template:simple} {{rname=^{acrobatics-u}}} {{mod=[[[[@{acrobatics_bonus}]][ACR]]]}} {{r1=[[1d20@{halflingluck}+[[@{acrobatics_bonus}]][ACR]]]}} @{rtype}@{halflingluck}+[[@{acrobatics_bonus}]][ACR]]]}} @{charname_output}" data-i18n="acrobatics-core">Acrobatics (Dex)</button>
                           <input type="checkbox" name="attr_animal_handling_prof" title="@{animal_handling_prof}" value="(@{pb}*@{animal_handling_type})">
                           <input type="text" name="attr_animal_handling_bonus" title="@{animal_handling_bonus}" value="(@{wisdom_mod}+@{animal_handling_proficiency}+@{animal_handling_flat})" disabled="true">
                           <button type="roll" name="roll_animal_handling" value="@{wtype}&{template:simple} {{rname=^{animal-handling-u}}} {{mod=[[[[@{animal_handling_bonus}]][ANI]]]}} {{r1=[[1d20@{halflingluck}+[[@{animal_handling_bonus}]][ANI]]]}} @{rtype}@{halflingluck}+[[@{animal_handling_bonus}]][ANI]]]}} @{charname_output}" data-i18n="animal-handling-core">Animal Handling (Wis)</button>
                           <input type="checkbox" name="attr_arcana_prof" title="@{arcana_prof}" value="(@{pb}*@{arcana_type})">
                           <input type="text" name="attr_arcana_bonus" title="@{arcana_bonus}" value="(@{intelligence_mod}+@{arcana_proficiency}+@{arcana_flat})" disabled="true">
                           <button type="roll" name="roll_arcana" value="@{wtype}&{template:simple} {{rname=^{arcana-u}}} {{mod=[[[[@{arcana_bonus}]][ARC]]]}} {{r1=[[1d20@{halflingluck}+[[@{arcana_bonus}]][ARC]]]}} @{rtype}@{halflingluck}+[[@{arcana_bonus}]][ARC]]]}} @{charname_output}" data-i18n="arcana-core">Arcana (Int)</button>
                           <input type="checkbox" name="attr_athletics_prof" title="@{athletics_prof}" value="(@{pb}*@{athletics_type})">
                           <input type="text" name="attr_athletics_bonus" title="@{athletics_bonus}" value="(@{strength_mod}+@{athletics_proficiency}+@{athletics_flat})" disabled="true">
                           <button type="roll" name="roll_athletics" value="@{wtype}&{template:simple} {{rname=^{athletics-u}}} {{mod=[[[[@{athletics_bonus}]][ATH]]]}} {{r1=[[1d20@{halflingluck}+[[@{athletics_bonus}]][ATH]]]}} @{rtype}@{halflingluck}+[[@{athletics_bonus}]][ATH]]]}} @{charname_output}" data-i18n="athletics-core">Athletics (Str)</button>
                           <input type="checkbox" name="attr_deception_prof" title="@{deception_prof}" value="(@{pb}*@{deception_type})">
                           <input type="text" name="attr_deception_bonus" title="@{deception_bonus}" value="(@{charisma_mod}+@{deception_proficiency}+@{deception_flat})" disabled="true">
                           <button type="roll" name="roll_deception" value="@{wtype}&{template:simple} {{rname=^{deception-u}}} {{mod=[[[[@{deception_bonus}]][DEC]]]}} {{r1=[[1d20@{halflingluck}+[[@{deception_bonus}]][DEC]]]}} @{rtype}@{halflingluck}+[[@{deception_bonus}]][DEC]]]}} @{charname_output}" data-i18n="deception-core">Deception (Cha)</button>
                           <input type="checkbox" name="attr_history_prof" title="@{history_prof}" value="(@{pb}*@{history_type})">
                           <input type="text" name="attr_history_bonus" title="@{history_bonus}" value="(@{intelligence_mod}+@{history_proficiency}+@{history_flat})" disabled="true">
                           <button type="roll" name="roll_history" value="@{wtype}&{template:simple} {{rname=^{history-u}}} {{mod=[[[[@{history_bonus}]][HIS]]]}} {{r1=[[1d20@{halflingluck}+[[@{history_bonus}]][HIS]]]}} @{rtype}@{halflingluck}+[[@{history_bonus}]][HIS]]]}} @{charname_output}" data-i18n="history-core">History (Int)</button>
                           <input type="checkbox" name="attr_insight_prof" title="@{insight_prof}" value="(@{pb}*@{insight_type})">
                           <input type="text" name="attr_insight_bonus" title="@{insight_bonus}" value="(@{wisdom_mod}+@{insight_proficiency}+@{insight_flat})" disabled="true">
                           <button type="roll" name="roll_insight" value="@{wtype}&{template:simple} {{rname=^{insight-u}}} {{mod=[[[[@{insight_bonus}]][INS]]]}} {{r1=[[1d20@{halflingluck}+[[@{insight_bonus}]][INS]]]}} @{rtype}@{halflingluck}+[[@{insight_bonus}]][INS]]]}} @{charname_output}" data-i18n="insight-core">Insight (Wis)</button>
                           <input type="checkbox" name="attr_intimidation_prof" title="@{intimidation_prof}" value="(@{pb}*@{intimidation_type})">
                           <input type="text" name="attr_intimidation_bonus" title="@{intimidation_bonus}" value="(@{charisma_mod}+@{intimidation_proficiency}+@{intimidation_flat})" disabled="true">
                           <button type="roll" name="roll_intimidation" value="@{wtype}&{template:simple} {{rname=^{intimidation-u}}} {{mod=[[[[@{intimidation_bonus}]][INT]]]}} {{r1=[[1d20@{halflingluck}+[[@{intimidation_bonus}]][INT]]]}} @{rtype}@{halflingluck}+[[@{intimidation_bonus}]][INT]]]}} @{charname_output}" data-i18n="intimidation-core">Intimidation (Cha)</button>
                           <input type="checkbox" name="attr_investigation_prof" title="@{investigation_prof}" value="(@{pb}*@{investigation_type})">
                           <input type="text" name="attr_investigation_bonus" title="@{investigation_bonus}" value="(@{intelligence_mod}+@{investigation_proficiency}+@{investigation_flat})" disabled="true">
                           <button type="roll" name="roll_investigation" value="@{wtype}&{template:simple} {{rname=^{investigation-u}}} {{mod=[[[[@{investigation_bonus}]][INV]]]}} {{r1=[[1d20@{halflingluck}+[[@{investigation_bonus}]][INV]]]}} @{rtype}@{halflingluck}+[[@{investigation_bonus}]][INV]]]}} @{charname_output}" data-i18n="investigation-core">Investigation (Int)</button>
                           <input type="checkbox" name="attr_medicine_prof" title="@{medicine_prof}" value="(@{pb}*@{medicine_type})">
                           <input type="text" name="attr_medicine_bonus" title="@{medicine_bonus}" value="(@{wisdom_mod}+@{medicine_proficiency}+@{medicine_flat})" disabled="true">
                           <button type="roll" name="roll_medicine" value="@{wtype}&{template:simple} {{rname=^{medicine-u}}} {{mod=[[[[@{medicine_bonus}]][MED]]]}} {{r1=[[1d20@{halflingluck}+[[@{medicine_bonus}]][MED]]]}} @{rtype}@{halflingluck}+[[@{medicine_bonus}]][MED]]]}} @{charname_output}" data-i18n="medicine-core">Medicine (Wis)</button>
                           <input type="checkbox" name="attr_nature_prof" title="@{nature_prof}" value="(@{pb}*@{nature_type})">
                           <input type="text" name="attr_nature_bonus" title="@{nature_bonus}" value="(@{intelligence_mod}+@{nature_proficiency}+@{nature_flat})" disabled="true">
                           <button type="roll" name="roll_nature" value="@{wtype}&{template:simple} {{rname=^{nature-u}}} {{mod=[[[[@{nature_bonus}]][NAT]]]}} {{r1=[[1d20@{halflingluck}+[[@{nature_bonus}]][NAT]]]}} @{rtype}@{halflingluck}+[[@{nature_bonus}]][NAT]]]}} @{charname_output}" data-i18n="nature-core">Nature (Int)</button>
                           <input type="checkbox" name="attr_perception_prof" title="@{perception_prof}" value="(@{pb}*@{perception_type})">
                           <input type="text" name="attr_perception_bonus" title="@{perception_bonus}" value="(@{wisdom_mod}+@{perception_proficiency}+@{perception_flat})" disabled="true">
                           <button type="roll" name="roll_perception" value="@{wtype}&{template:simple} {{rname=^{perception-u}}} {{mod=[[[[@{perception_bonus}]][PER]]]}} {{r1=[[1d20@{halflingluck}+[[@{perception_bonus}]][PER]]]}} @{rtype}@{halflingluck}+[[@{perception_bonus}]][PER]]]}} @{charname_output}" data-i18n="perception-core">Perception (Wis)</button>
                           <input type="checkbox" name="attr_performance_prof" title="@{performance_prof}" value="(@{pb}*@{performance_type})">
                           <input type="text" name="attr_performance_bonus" title="@{performance_bonus}" value="(@{charisma_mod}+@{performance_proficiency}+@{performance_flat})" disabled="true">
                           <button type="roll" name="roll_performance" value="@{wtype}&{template:simple} {{rname=^{performance-u}}} {{mod=[[[[@{performance_bonus}]][PER]]]}} {{r1=[[1d20@{halflingluck}+[[@{performance_bonus}]][PER]]]}} @{rtype}@{halflingluck}+[[@{performance_bonus}]][PER]]]}} @{charname_output}" data-i18n="performance-core">Performance (Cha)</button>
                           <input type="checkbox" name="attr_persuasion_prof" title="@{persuasion_prof}" value="(@{pb}*@{persuasion_type})">
                           <input type="text" name="attr_persuasion_bonus" title="@{persuasion_bonus}" value="(@{charisma_mod}+@{persuasion_proficiency}+@{persuasion_flat})" disabled="true">
                           <button type="roll" name="roll_persuasion" value="@{wtype}&{template:simple} {{rname=^{persuasion-u}}} {{mod=[[[[@{persuasion_bonus}]][PER]]]}} {{r1=[[1d20@{halflingluck}+[[@{persuasion_bonus}]][PER]]]}} @{rtype}@{halflingluck}+[[@{persuasion_bonus}]][PER]]]}} @{charname_output}" data-i18n="persuasion-core">Persuasion (Cha)</button>
                           <input type="checkbox" name="attr_religion_prof" title="@{religion_prof}" value="(@{pb}*@{religion_type})">
                           <input type="text" name="attr_religion_bonus" title="@{religion_bonus}" value="(@{intelligence_mod}+@{religion_proficiency}+@{religion_flat})" disabled="true">
                           <button type="roll" name="roll_religion" value="@{wtype}&{template:simple} {{rname=^{religion-u}}} {{mod=[[[[@{religion_bonus}]][REL]]]}} {{r1=[[1d20@{halflingluck}+[[@{religion_bonus}]][REL]]]}} @{rtype}@{halflingluck}+[[@{religion_bonus}]][REL]]]}} @{charname_output}" data-i18n="religion-core">Religion (Int)</button>
                           <input type="checkbox" name="attr_sleight_of_hand_prof" title="@{sleight_of_hand_prof}" value="(@{pb}*@{sleight_of_hand_type})">
                           <input type="text" name="attr_sleight_of_hand_bonus" title="@{sleight_of_hand_bonus}" value="(@{dexterity_mod}+@{sleight_of_hand_proficiency}+@{sleight_of_hand_flat})" disabled="true">
                           <button type="roll" name="roll_sleight_of_hand" value="@{wtype}&{template:simple} {{rname=^{sleight-of-hand-u}}} {{mod=[[[[@{sleight_of_hand_bonus}]][SLE]]]}} {{r1=[[1d20@{halflingluck}+[[@{sleight_of_hand_bonus}]][SLE]]]}} @{rtype}@{halflingluck}+[[@{sleight_of_hand_bonus}]][SLE]]]}} @{charname_output}" data-i18n="sleight-of-hand-core">Sleight of Hand (Dex)</button>
                           <input type="checkbox" name="attr_stealth_prof" title="@{stealth_prof}" value="(@{pb}*@{stealth_type})">
                           <input type="text" name="attr_stealth_bonus" title="@{stealth_bonus}" value="(@{dexterity_mod}+@{stealth_proficiency}+@{stealth_flat})" disabled="true">
                           <button type="roll" name="roll_stealth" value="@{wtype}&{template:simple} {{rname=^{stealth-u}}} {{mod=[[[[@{stealth_bonus}]][STE]]]}} {{r1=[[1d20@{halflingluck}+[[@{stealth_bonus}]][STE]]]}} @{rtype}@{halflingluck}+[[@{stealth_bonus}]][STE]]]}} @{charname_output}" data-i18n="stealth-core">Stealth (Dex)</button>
                           <input type="checkbox" name="attr_survival_prof" title="@{survival_prof}" value="(@{pb}*@{survival_type})">
                           <input type="text" name="attr_survival_bonus" title="@{survival_bonus}" value="(@{wisdom_mod}+@{survival_proficiency}+@{survival_flat})" disabled="true">
                           <button type="roll" name="roll_survival" value="@{wtype}&{template:simple} {{rname=^{survival-u}}} {{mod=[[[[@{survival_bonus}]][SUR]]]}} {{r1=[[1d20@{halflingluck}+[[@{survival_bonus}]][SUR]]]}} @{rtype}@{halflingluck}+[[@{survival_bonus}]][SUR]]]}} @{charname_output}" data-i18n="survival-core">Survival (Wis)</button>
                       SKILLS
                   <input type="text" name="attr_passive_wisdom" title="@{passive_wisdom}" value="(10+@{perception_bonus}+@{passiveperceptionmod})" disabled="true" >
                   PASSIVE WISDOM (PERCEPTION)
                   TOOL
                   PRO
                   ATTRIBUTE
                <fieldset class="repeating_tool">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_toolname_base" style="width: 95px;">
                               PROFICIENCY BONUS:
                               <select name="attr_toolbonus_base">
                                   <option value="(@{pb})" selected="selected" data-i18n="prof-u">PROFICIENT</option>
                                   <option value="(@{pb}*2)" data-i18n="expertise-u">EXPERTISE</option>
                                   <option value="(floor(@{pb}/2))" data-i18n="jack-of-all-u">JACK OF ALL TRADES</option>
                               </select>
                               ATTRIBUTE:
                               <select name="attr_toolattr_base">
                                   <option value="@{strength_mod}" selected="selected" data-i18n="strength-u">STRENGTH</option>
                                   <option value="@{dexterity_mod}" data-i18n="dexterity-u">DEXTERITY</option>
                                   <option value="@{constitution_mod}" data-i18n="constitution-u">CONSTITUTION</option>
                                   <option value="@{intelligence_mod}" data-i18n="intelligence-u">INTELLIGENCE</option>
                                   <option value="@{wisdom_mod}" data-i18n="wisdom-u">WISDOM</option>
                                   <option value="@{charisma_mod}" data-i18n="charisma-u">CHARISMA</option>
                               </select>
                               MODS:
                               <input type="text" class="num" name="attr_tool_mod" title="@{tool_mod}" value="0">
                           <button type="roll" name="roll_tool" value="@{wtype}&{template:simple} {{rname=@{toolname}}} {{mod=[[[[@{toolbonus}]][TOOL]]]}} {{r1=[[1d20@{halflingluck}+[[@{toolbonus}]][TOOL]]]}} @{rtype}@{halflingluck}+[[@{toolbonus}]][TOOL]]]}} @{charname_output}">
                               <input type="text" name="attr_toolname" style="width: 95px;">
                               <input type="text" name="attr_toolbonus" style="width: 30px; text-align: center;">
                               <input type="text" name="attr_toolattr" style="width: 100px;">
                           </button>
                </fieldset>
                   TOOL PROFICIENCIES
               <textarea name="attr_other_proficiencies_and_languages" style="min-height: 91px; height: 91px;"></textarea>
                   OTHER PROFICIENCIES & LANGUAGES
                   <input type="text" name="attr_ac" title="@{ac}">
                   ARMOR CLASS
                   <input type="text" name="attr_initiative_bonus" title="@{initiative_bonus}" value="(@{dexterity_mod}+@{initmod}+@{jack_of_all_trades})" disabled="true">
                   <button type="roll" name="roll_initiative" value="@{wtype}&{template:simple} {{rname=^{init-u}}} {{mod=[[@{initiative_bonus}[INIT]]]}} {{r1=[[1d20@{halflingluck}+[[@{initiative_bonus}]][INIT] &{tracker}]]}} Template:Normal=1 @{charname_output}" data-i18n="init-u">INITIATIVE</button>
                   <input type="text" name="attr_speed" title="@{speed}">
                   SPEED
                   Hit Point Maximum
                   <input type="text" name="attr_hp_max" title="@{hp_max}">
               <input type="number" name="attr_hp" title="@{hp}">
               CURRENT HIT POINTS
               <input type="number" name="attr_hp_temp" title="@{hp_temp}">
               TEMPORARY HIT POINTS
                       Total
                       <input type="text" name="attr_hit_dice_max" title="@{hit_dice_max}">
                   <input type="number" name="attr_hit_dice" title="@{hit_dice}" style="margin-bottom: -6px;">
                   <button type="roll" name="roll_hit_dice" value="@{wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=D@{hitdie_final}+[[@{constitution_mod}[CON]]]}} {{r1=[[1d@{hitdie_final}+[[@{constitution_mod}]][CON]]]}} Template:Normal=1 @{charname_output}" data-i18n="hit-dice-u">HIT DICE</button>
                       SUCCESSES
                       <input type="checkbox" name="attr_deathsave_succ1">
                       <input type="checkbox" name="attr_deathsave_succ2">
                       <input type="checkbox" name="attr_deathsave_succ3">
                       FAILURES
                       <input type="checkbox" name="attr_deathsave_fail1">
                       <input type="checkbox" name="attr_deathsave_fail2">
                       <input type="checkbox" name="attr_deathsave_fail3">
                   <button type="roll" name="roll_death_save" style="margin-top: 6px;" value="@{wtype}&{template:simple} {{rname=^{death-save-u}}} {{mod=@{deathsavemod}}} {{r1=[[1d20@{halflingluck}+@{deathsavemod}[MOD]]]}} Template:Normal=1 @{charname_output}" data-i18n="death-saves-u">DEATH SAVES</button>
           <input type="hidden" class="ammoflag" name="attr_ammoflag">
                   NAME
                   ATK
                   DAMAGE/TYPE
               <fieldset class="repeating_attack">
                       <input type="hidden" name="attr_updateflag">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_atkname_base">
                               <input type="checkbox" name="attr_atkflag" value="Template:Attack=1" checked="checked">
                               ATTACK:
                               <select name="attr_atkattr_base">
                                   <option value="@{strength_mod}" selected="selected" data-i18n="str-u">STR</option>
                                   <option value="@{dexterity_mod}" data-i18n="dex-u">DEX</option>
                                   <option value="@{constitution_mod}" data-i18n="con-u">CON</option>
                                   <option value="@{intelligence_mod}" data-i18n="int-u">INT</option>
                                   <option value="@{wisdom_mod}" data-i18n="wis-u">WIS</option>
                                   <option value="@{charisma_mod}" data-i18n="cha-u">CHA</option>
                                   <option value="0">-</option>
                               </select>
                               +
                               <input type="text" class="num" name="attr_atkmod" placeholder="0">
                               +
                               <input type="checkbox" name="attr_atkprofflag" value="(@{pb})" checked="checked" style="margin-left: 3px;">
                               PROFICIENT
                               RANGE:
                               <input type="text" name="attr_atkrange" placeholder="Self (60-foot cone)" style="width: 170px;" data-i18n-placeholder="range-place">
                               MAGIC BONUS:
                               <input type="text" class="num" name="attr_atkmagic" placeholder="0">
                               CRIT RANGE:
                               <input type="text" class="num" name="attr_atkcritrange" value="20" placeholder="20">
                               <input type="checkbox" name="attr_dmgflag" value="Template:Damage=1 Template:Dmg1flag=1" checked="checked">
                               DAMAGE:
                               <input type="text" name="attr_dmgbase" placeholder="1d6" style="width: 50px;">
                               +
                               <select name="attr_dmgattr">
                                   <option value="@{strength_mod}" selected="selected" data-i18n="str-u">STR</option>
                                   <option value="@{dexterity_mod}" data-i18n="dex-u">DEX</option>
                                   <option value="@{constitution_mod}" data-i18n="con-u">CON</option>
                                   <option value="@{intelligence_mod}" data-i18n="int-u">INT</option>
                                   <option value="@{wisdom_mod}" data-i18n="wis-u">WIS</option>
                                   <option value="@{charisma_mod}" data-i18n="cha-u">CHA</option>
                                   <option value="0">-</option>
                               </select>
                               +
                               <input type="text" class="num" name="attr_dmgmod" placeholder="0">
                               TYPE:
                               <input type="text" name="attr_dmgtype" placeholder="Slashing" style="width: 50px;" data-i18n-placeholder="dmg-type-place">
                               CRIT:
                               <input type="text" name="attr_dmgcustcrit" placeholder="1d6" style="width: 80px;">
                               <input type="checkbox" name="attr_dmg2flag" value="Template:Damage=1 Template:Dmg2flag=1">
                               DAMAGE2:
                               <input type="text" name="attr_dmg2base" placeholder="1d6" style="width: 50px;">
                               +
                               <select name="attr_dmg2attr">
                                   <option value="@{strength_mod}" selected="selected" data-i18n="str-u">STR</option>
                                   <option value="@{dexterity_mod}" data-i18n="dex-u">DEX</option>
                                   <option value="@{constitution_mod}" data-i18n="con-u">CON</option>
                                   <option value="@{intelligence_mod}" data-i18n="int-u">INT</option>
                                   <option value="@{wisdom_mod}" data-i18n="wis-u">WIS</option>
                                   <option value="@{charisma_mod}" data-i18n="cha-u">CHA</option>
                                   <option value="0">-</option>
                               </select>
                               +
                               <input type="text" class="num" name="attr_dmg2mod" placeholder="0">
                               TYPE:
                               <input type="text" name="attr_dmg2type" placeholder="Slashing" style="width: 50px;" data-i18n-placeholder="dmg-type-place">
                               CRIT:
                               <input type="text" name="attr_dmg2custcrit" placeholder="1d6" style="width: 80px;">
                               <input type="checkbox" name="attr_saveflag" value="Template:Save=1 {{saveattr=@{saveattr}}} {{savedesc=@{saveeffect}}} {{savedc=[[[[@{savedc}]][SAVE]]]}}">
                               SAVING THROW:
                               <select name="attr_saveattr">
                                   <option value="Strength" selected="selected" data-i18n="str-u">STR</option>
                                   <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                   <option value="Constitution" data-i18n="con-u">CON</option>
                                   <option value="Intelligence" data-i18n="int-u">INT</option>
                                   <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                   <option value="Charisma" data-i18n="cha-u">CHA</option>
                               </select>
                               VS DC:
                               <select name="attr_savedc">
                                   <option value="(@{spell_save_dc})" selected="selected" data-i18n="spell-u">SPELL</option>
                                   <option value="(@{strength_mod}+8+@{pb})" data-i18n="str-u">STR</option>
                                   <option value="(@{dexterity_mod}+8+@{pb})" data-i18n="dex-u">DEX</option>
                                   <option value="(@{constitution_mod}+8+@{pb})" data-i18n="con-u">CON</option>
                                   <option value="(@{intelligence_mod}+8+@{pb})" data-i18n="int-u">INT</option>
                                   <option value="(@{wisdom_mod}+8+@{pb})" data-i18n="wis-u">WIS</option>
                                   <option value="(@{charisma_mod}+8+@{pb})" data-i18n="cha-u">CHA</option>
                                   <option value="(@{saveflat})" data-i18n="flat-u">FLAT</option>
                               </select>
                               <input class="flatflag" type="hidden" name="attr_flatflag">
                               <input class="num flat" type="text" name="attr_saveflat" placeholder="10">
                               SAVE EFFECT:
                               <input type="text" name="attr_saveeffect" placeholder="half damage" style="width: 160px;" data-i18n-placeholder="save-effect-place">
                               AMMUNITION:
                               <input type="text" name="attr_ammo" placeholder="Arrows" style="width: 160px;" data-i18n-placeholder="ammunition-place">
                               DESCRIPTION:
                               <textarea name="attr_atk_desc" placeholder="Up to 2 creatures within 5 feet" data-i18n-placeholder="description-place"></textarea>
                           <button type="roll" name="roll_attack" value="@{rollbase}">
                               <input type="text" name="attr_atkname" style="width: 95px;" value="">
                               <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="">
                               <input type="text" name="attr_atkdmgtype" style="width: 95px;" value="">
                           </button>
                   <input type="hidden" name="attr_hidden_r1base">
                   <input type="hidden" name="attr_hidden_r2base">
                   <input type="hidden" name="attr_hidden_atkbonus">
                   <input type="hidden" name="attr_hidden_dmg1">
                   <input type="hidden" name="attr_hidden_dmg2">
                   <input type="hidden" name="attr_hidden_dmg1type">
                   <input type="hidden" name="attr_hidden_dmg2type">
                   <input type="hidden" name="attr_hidden_crit1">
                   <input type="hidden" name="attr_hidden_crit2">
                   <input type="hidden" name="attr_hldmg">
                   <input type="hidden" name="attr_spelllevel">
                   <input type="hidden" name="attr_rollbase">
                   <button type="roll" name="roll_attack_dmg" style="display: none;" value="@{wtype}&{template:dmg} {{rname=@{atkname}}} @{atkflag} {{range=@{atkrange}}} @{dmgflag} {{dmg1=[[@{hidden_dmg1}]]}} {{dmg1type=@{hidden_dmg1type}}} @{dmg2flag} {{dmg2=[[@{hidden_dmg2}]]}} {{dmg2type=@{hidden_dmg2type}}} @{saveflag} {{desc=@{atk_desc}}} @{hldmg} @{spelllevel} @{charname_output}"></button>
                   <button type="roll" name="roll_attack_crit" style="display: none;" value="@{wtype}&{template:dmg} Template:Crit=1 {{rname=@{atkname}}} @{atkflag} {{range=@{atkrange}}} @{dmgflag} {{dmg1=[[@{hidden_dmg1}]]}} {{dmg1type=@{hidden_dmg1type}}} @{dmg2flag} {{dmg2=[[@{hidden_dmg2}]]}} {{dmg2type=@{hidden_dmg2type}}} {{crit1=[[@{hidden_crit1}]]}} {{crit2=[[@{hidden_crit2}]]}} @{saveflag} {{desc=@{atk_desc}}} @{hldmg} @{spelllevel} @{charname_output}"></button>
                   <input type="hidden" name="attr_itemid">
                   <input type="hidden" name="attr_spellid">
               </fieldset>
               ATTACKS & SPELLCASTING
                       CP
                       <input type="text" name="attr_cp" title="@{cp}">
                       SP
                       <input type="text" name="attr_sp" title="@{sp}">
                       EP
                       <input type="text" name="attr_ep" title="@{ep}">
                       GP
                       <input type="text" name="attr_gp" title="@{gp}">
                       PP
                       <input type="text" name="attr_pp" title="@{pp}">
               <input type="hidden" class="inventoryflag" name="attr_inventoryflag" value="complex">
               <textarea class="simple" name="attr_equipment"></textarea>
                   <input type="hidden" class="warningflag" name="attr_armorwarningflag">
                       
                           <input type="checkbox" name="attr_armorwarning" value="hide">
                           WARNING - MULTIPLE SETS OF ARMOR OR SHIELDS HAVE BEEN ADDED AND AC IS NOT CORRECTLY CALCULATED. UNEQUIP THE ARMOR PIECE FROM THE ITEM DETAILS.
                       
                       *
                       ITEM NAME
                       <img src="http://i.imgur.com/3OxOqmb.png" style="width: 15px; margin-bottom: -3px;">
                   <fieldset class="repeating_inventory">
                       <input type="hidden" class="equippedflag" name="attr_equippedflag">
                           <input class="weight" type="text" name="attr_itemcount" value="1">
                           <input class="name" type="text" name="attr_itemname" accept="Name">
                           <input class="weight" type="text" name="attr_itemweight" accept="Weight">
                           <input class="inventorysubflag" type="checkbox" name="attr_inventorysubflag">i
                               <input class="equipped" type="checkbox" name="attr_equipped" value="1" checked="checked">
                               EQUIPPED
                               <input class="equipped" type="checkbox" name="attr_useasresource" value="1">
                               USE AS A RESOURCE
                               PROP:
                               <input class="subfield" type="text" name="attr_itemproperties" accept="Properties">
                               MODS:
                               <input class="subfield" type="text" name="attr_itemmodifiers" accept="Modifiers">
                               <textarea class="subtextarea" name="attr_itemcontent" accept="Content"></textarea>
                           <input type="hidden" name="attr_itemtype" accept="Item Type">
                           <input type="hidden" name="attr_itemdamage" accept="Damage">
                           <input type="hidden" name="attr_itemdamagetype" accept="Damage Type">
                           <input type="hidden" name="attr_itemrange" accept="Range">
                           <input type="hidden" name="attr_itemac" accept="AC">
                           <input type="hidden" name="attr_itemattackid">
                           <input type="hidden" name="attr_itemresourceid">
                   </fieldset>
                       TOTAL WEIGHT
                       <input type="text" name="attr_weighttotal" value="0">
                       <input type="hidden" class="encumberance" name="attr_encumberance">
                       IMMOBILE
                       HEAVILY ENCUMBERED
                       ENCUMBERED
                       OVER CARRYING CAPACITY
               EQUIPMENT
               <textarea name="attr_personality_traits" style="min-height: 50px; height: 50px;"></textarea>
               PERSONALITY TRAITS
               <textarea name="attr_ideals"></textarea>
               IDEALS
               <textarea name="attr_bonds"></textarea>
               BONDS
               <textarea name="attr_flaws" style="min-height: 46px; height: 46px;"></textarea>
               FLAWS
                           Total
                           <input type="text" name="attr_class_resource_max" title="@{class_resource_max}">
                       <input type="number" name="attr_class_resource" title="@{class_resource}" style="margin-bottom: -6px;">
                       <input type="text" class="label" name="attr_class_resource_name" title="@{class_resource_name}" placeholder="CLASS RESOURCE" data-i18n-placeholder="class-resource-u">
                           Total
                           <input type="text" name="attr_other_resource_max" title="@{other_resource_max}">
                       <input type="number" name="attr_other_resource" title="@{other_resource}" style="margin-bottom: -6px;">
                       <input type="text" class="label" name="attr_other_resource_name" title="@{other_resource_name}" placeholder="OTHER RESOURCE" data-i18n-placeholder="other-resource-u">
                       <input type="hidden" name="attr_other_resource_itemid">
               <fieldset class="repeating_resource">
                               Total
                               <input type="text" name="attr_resource_left_max" title="@{repeating_resource_left_max}">
                           <input type="number" name="attr_resource_left" title="@{repeating_resource_left}" style="margin-bottom: -6px;">
                           <input type="text" class="label" name="attr_resource_left_name" title="@{repeating_resource_left_name}" placeholder="OTHER RESOURCE" data-i18n-placeholder="other-resource-u">
                           <input type="hidden" name="attr_resource_left_itemid">
                               Total
                               <input type="text" name="attr_resource_right_max" title="@{repeating_resource_right_max}">
                           <input type="number" name="attr_resource_right" title="@{repeating_resource_right}" style="margin-bottom: -6px;">
                           <input type="text" class="label" name="attr_resource_right_name" title="@{repeating_resource_right_name}" placeholder="OTHER RESOURCE" data-i18n-placeholder="other-resource-u">
                           <input type="hidden" name="attr_resource_right_itemid">
               </fieldset>
               <textarea name="attr_features_and_traits" style="min-height: 461px; height: 461px;"></textarea>
               FEATURES & TRAITS
           <img src="http://i.imgur.com/ZgULBCp.png" style="padding-bottom: 5px;">
           <input type="text" name="attr_character_name" style="width: 100%;">
           CHARACTER NAME
                   <input type="text" name="attr_age" style="width: 120px;">
                   AGE
                   <input type="text" name="attr_size" style="width: 120px;">
                   SIZE
                   <input type="text" name="attr_height" style="width: 120px;">
                   HEIGHT
                   <input type="text" name="attr_weight" style="width: 120px;">
                   WEIGHT
                   <input type="text" name="attr_eyes" style="width: 160px;">
                   EYES
                   <input type="text" name="attr_skin" style="width: 160px;">
                   SKIN
                   <input type="text" name="attr_hair" style="width: 160px;">
                   HAIR
               <textarea name="attr_character_appearance" style="min-height: 300px; height: 300px;"></textarea>
               CHARACTER APPEARANCE
               <textarea name="attr_character_backstory" style="min-height: 623px; height: 623px;"></textarea>
               CHARACTER BACKSTORY
               <textarea name="attr_allies_and_organizations" style="min-height: 288px; height: 300px;"></textarea>
               ALLIES & ORGANIZATIONS
               <textarea name="attr_additional_feature_and_traits" style="min-height: 289px; height: 300px;"></textarea>
               ADDITIONAL FEATURES & TRAITS
               <textarea name="attr_treasure" style="min-height: 300px; height: 300px;"></textarea>
               TREASURE
           <img src="http://i.imgur.com/ZgULBCp.png" style="padding-bottom: 5px;">
           <input type="text" name="attr_character_name" style="width: 100%;">
           CHARACTER NAME
               <select name="attr_spellcasting_ability">
                   <option value="0*" data-i18n="none-u">NONE</option>
                   <option value="@{strength_mod}+" data-i18n="strength-u">STRENGTH</option>
                   <option value="@{dexterity_mod}+" data-i18n="dexterity-u">DEXTERITY</option>
                   <option value="@{constitution_mod}+" data-i18n="constitution-u">CONSTITUTION</option>
                   <option value="@{intelligence_mod}+" data-i18n="intelligence-u">INTELLIGENCE</option>
                   <option value="@{wisdom_mod}+" data-i18n="wisdom-u">WISDOM</option>
                   <option value="@{charisma_mod}+" data-i18n="charisma-u">CHARISMA</option>
               </select>
               SPELLCASTING ABILITY
               <input type="text" name="attr_spell_save_dc" value="(@{spellcasting_ability}(8+@{pb}+@{spell_dc_mod}))" disabled="true">
               SPELL SAVE DC
               <input type="text" name="attr_spell_attack_bonus" value="(@{spellcasting_ability}@{pb})" disabled="true">
               SPELL ATTACK BONUS
                   0
                   CANTRIPS
               <fieldset class="repeating_spell-cantrip">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="Abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="Conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="Divination" data-i18n="divination">Divination</option>
                                   <option value="Enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="Evocation" data-i18n="evocation">Evocation</option>
                                   <option value="Illusion" data-i18n="illusion">Illusion</option>
                                   <option value="Necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="Transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_spell_damage_progression" accept="Damage Progression">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 3px;" value="">
                           </button>
               </fieldset>
                   1
                   <input type="number" name="attr_lvl1_slots_total">
                   <input type="number" name="attr_lvl1_slots_expended" value="0">
               <fieldset class="repeating_spell-1">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   2
                   <input type="number" name="attr_lvl2_slots_total">
                   <input type="number" name="attr_lvl2_slots_expended" value="0">
               <fieldset class="repeating_spell-2">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   3
                   <input type="number" name="attr_lvl3_slots_total">
                   <input type="number" name="attr_lvl3_slots_expended" value="0">
               <fieldset class="repeating_spell-3">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   4
                   <input type="number" name="attr_lvl4_slots_total">
                   <input type="number" name="attr_lvl4_slots_expended" value="0">
               <fieldset class="repeating_spell-4">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   5
                   <input type="number" name="attr_lvl5_slots_total">
                   <input type="number" name="attr_lvl5_slots_expended" value="0">
               <fieldset class="repeating_spell-5">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   6
                   <input type="number" name="attr_lvl6_slots_total">
                   <input type="number" name="attr_lvl6_slots_expended" value="0">
               <fieldset class="repeating_spell-6">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   7
                   <input type="number" name="attr_lvl7_slots_total">
                   <input type="number" name="attr_lvl7_slots_expended" value="0">
               <fieldset class="repeating_spell-7">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   8
                   <input type="number" name="attr_lvl8_slots_total">
                   <input type="number" name="attr_lvl8_slots_expended" value="0">
               <fieldset class="repeating_spell-8">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
                   9
                   <input type="number" name="attr_lvl9_slots_total">
                   <input type="number" name="attr_lvl9_slots_expended" value="0">
               <fieldset class="repeating_spell-9">
                       <input class="options-flag" type="checkbox" name="attr_options-flag" checked="checked">y
                               NAME:
                               <input type="text" name="attr_spellname_base" accept="Name">
                               <input type="checkbox" name="attr_spellprepared" value="1" checked="checked">
                               PREP
                               SCHOOL:
                               <select name="attr_spellschool" accept="School">
                                   <option value="abjuration" data-i18n="abjuration">Abjuration</option>
                                   <option value="conjuration" data-i18n="conjuration">Conjuration</option>
                                   <option value="divination" data-i18n="divination">Divination</option>
                                   <option value="enchantment" data-i18n="enchantment">Enchantment</option>
                                   <option value="evocation" data-i18n="evocation">Evocation</option>
                                   <option value="illusion" data-i18n="illusion">Illusion</option>
                                   <option value="necromancy" data-i18n="necromancy">Necromancy</option>
                                   <option value="transmutation" data-i18n="transmutation">Transmutation</option>
                               </select>
                               <input type="hidden" name="attr_spellritualflag" accept="Ritual">
                               <input type="checkbox" name="attr_spellritual" value="Template:Ritual=1">
                               RITUAL
                               CASTING TIME:
                               <input type="text" name="attr_spellcastingtime" accept="Casting Time">
                               RANGE:
                               <input type="text" name="attr_spellrange" accept="Range">
                               TARGET:
                               <input type="text" name="attr_spelltarget" accept="Target">
                           <input type="hidden" name="attr_spellcomp" accept="Components">
                               COMPONENTS:
                               <input type="checkbox" name="attr_spellcomp_v" value="Template:V=1" checked="checked">
                               V
                               <input type="checkbox" name="attr_spellcomp_s" value="Template:S=1" checked="checked">
                               S
                               <input type="checkbox" name="attr_spellcomp_m" value="Template:M=1" checked="checked">
                               M
                               <input type="text" name="attr_spellcomp_materials" accept="Material" placeholder="ruby dust worth 50gp" data-i18n-placeholder="ruby-dust-place">
                               <input type="hidden" name="attr_spellconcentrationflag" accept="Concentration">
                               <input type="checkbox" name="attr_spellconcentration" value="Template:Concentration=1">
                               CONCENTRATION
                               DURATION:
                               <input type="text" name="attr_spellduration" accept="Duration">
                               OUTPUT:
                               <select name="attr_spelloutput">
                                   <option value="SPELLCARD" data-i18n="spellcard-u">SPELLCARD</option>
                                   <option value="ATTACK" data-i18n="attack-u">ATTACK</option>
                               </select>
                           <input type="hidden" class="spellattackinfoflag" name="attr_spellattackinfoflag">
                                   SPELL ATTACK:
                                   <select name="attr_spellattack" accept="Spell Attack">
                                       <option value="None" data-i18n="none">None</option>
                                       <option value="Melee" data-i18n="melee">Melee</option>
                                       <option value="Ranged" data-i18n="ranged">Ranged</option>
                                   </select>
                                   DAMAGE:
                                   <input type="text" name="attr_spelldamage" accept="Damage" style="width: 50px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype" accept="Damage Type" style="width: 103px;">
                                   DAMAGE2:
                                   <input type="text" name="attr_spelldamage2" accept="Secondary Damage" style="width: 45px;">
                                   TYPE:
                                   <input type="text" name="attr_spelldamagetype2" accept="Secondary Damage Type" style="width: 103px;">
                                   HEALING:
                                   <input type="text" name="attr_spellhealing" accept="Healing" style="width: 45px;">
                                   <input type="checkbox" name="attr_spelldmgmod" value="Yes" accept="Add Casting Modifier">
                                   ADD ABILITY MOD TO DAMAGE OR HEALING
                                   SAVING THROW:
                                   <select name="attr_spellsave" accept="Save">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="Strength" data-i18n="str-u">STR</option>
                                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                                       <option value="Constitution" data-i18n="con-u">CON</option>
                                       <option value="Intelligence" data-i18n="int-u">INT</option>
                                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                                   </select>
                                   EFFECT:
                                   <input type="text" name="attr_spellsavesuccess" accept="Save Success" style="width: 78px;" placeholder="Half damage" data-i18n-placeholder="half-dmg-place">
                                   HIGHER LVL CAST DMG:
                                   <input type="text" name="attr_spellhldie" placeholder="1" accept="Higher Spell Slot Dice" style="width: 15px; text-align: right;">
                                   <select name="attr_spellhldietype" accept="Higher Spell Slot Die">
                                       <option value="" selected="selected" data-i18n="none-u">NONE</option>
                                       <option value="d4">d4</option>
                                       <option value="d6">d6</option>
                                       <option value="d8">d8</option>
                                       <option value="d10">d10</option>
                                       <option value="d12">d12</option>
                                       <option value="d20">d20</option>
                                   </select>
                                   +
                                   <input type="text" name="attr_spellhlbonus" placeholder="0" accept="Higher Spell Slot Bonus" style="width: 15px; text-align: center;">
                               DESCRIPTION:
                           <input type="hidden" name="attr_spellcontent" accept="Content">
                               <textarea name="attr_spelldescription"></textarea>
                               AT HIGHER LEVELS:
                               <textarea name="attr_spellathigherlevels" style="height: 36px; min-height: 36px;"></textarea>
                           <input type="hidden" name="attr_spellattackid">
                           <input type="hidden" name="attr_spelllevel" accept="Level">
                           <input type="hidden" name="attr_spell_updateflag">
                           <input type="hidden" name="attr_rollcontent" value="@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}}  {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}">
                           <button class="spellcard" type="roll" name="roll_spell" value="@{rollcontent}">
                               <input type="hidden" name="attr_prep" value="">
                               <input type="text" name="attr_spellname" style="width: 225px; margin-left: 13px;" value="">
                           </button>
               </fieldset>
           <img src="http://i.imgur.com/ZgULBCp.png" style="padding-bottom: 5px;">
           <input type="text" name="attr_character_name" style="width: 100%;">
           CHARACTER NAME
                   <input class="flag" type="hidden" name="attr_customclass_flag" value="0">
                   <input class="showing" type="text" name="attr_cust_class" value="@{cust_classname}" disabled="true" style="width: 64px; height: 28px; padding-top: 10px;">
                   <select class="hiding class" name="attr_class">
                       <option value="Barbarian" data-i18n="barbarian">Barbarian</option>
                       <option value="Bard" data-i18n="bard">Bard</option>
                       <option value="Cleric" data-i18n="cleric">Cleric</option>
                       <option value="Druid" data-i18n="druid">Druid</option>
                       <option value="Fighter" data-i18n="fighter">Fighter</option>
                       <option value="Monk" data-i18n="monk">Monk</option>
                       <option value="Paladin" data-i18n="paladin">Paladin</option>
                       <option value="Ranger" data-i18n="ranger">Ranger</option>
                       <option value="Rogue" data-i18n="rogue">Rogue</option>
                       <option value="Sorcerer" data-i18n="sorcerer">Sorcerer</option>
                       <option value="Warlock" data-i18n="warlock">Warlock</option>
                       <option value="Wizard" data-i18n="wizard">Wizard</option>
                   </select>
                   <input type="number" class="class-level" name="attr_base_level" value="1">
                   CLASS & LEVEL
                   <input class="flag" type="hidden" name="attr_mutliclass1_showingflag" value="0">
                   
                   
                   
                   
                   <input class="flag" type="hidden" name="attr_mutliclass2_showingflag" value="0">
                   
                   
                   
                   
                   <input class="flag" type="hidden" name="attr_mutliclass3_showingflag" value="0">
                   
                   
                   
                   
                   <input type="text" name="attr_background" style="width: 122px;">
                   BACKGROUND
                   <input type="text" name="attr_race">
                   RACE
                   <input type="text" name="attr_alignment">
                   ALIGNMENT
                   <input type="text" name="attr_experience">
                   EXPERIENCE POINTS
                   HIT DIE:
                   <select name="attr_hitdietype">
                       <option value="4">D4</option>
                       <option value="6">D6</option>
                       <option value="8">D8</option>
                       <option value="10">D10</option>
                       <option value="12">D12</option>
                   </select>
                   INITIATIVE MODIFIER:
                   <input type="text" class="num" name="attr_initmod" placeholder="0" value="0">
                   GLOBAL SAVING THROW MODIFIER:
                   <input type="text" class="num" name="attr_globalsavemod" placeholder="0" value="0">
                   GLOBAL ARMOR CLASS MODIFIER:
                   <input type="text" class="num" name="attr_globalacmod" placeholder="0" value="0">
                   GLOBAL MAGIC ATTACK MODIFIER:
                   <input type="text" class="num" name="attr_globalmagicmod" placeholder="0" value="0">
                   PASSIVE PERCEPTION MODIFIER:
                   <input type="text" class="num" name="attr_passiveperceptionmod" placeholder="0" value="0">
                   DEATH SAVE MODIFIER:
                   <input type="text" class="num" name="attr_deathsavemod" placeholder="0" value="0">
                   MAGIC CASTER LEVEL:
                   <input type="text" class="num" name="attr_caster_level">
                   SPELL SAVE DC MOD:
                   <input type="text" class="num" name="attr_spell_dc_mod" placeholde="0" value="0">
                   <input type="checkbox" name="attr_custom_ac_flag" value="1">
                   CUSTOM AC:
                   <input type="text" class="num" name="attr_custom_ac_base" placeholde="10" value="10">
                   +
                   <select name="attr_custom_ac_part1">
                       <option value="none" selected="selected" data-i18n="none-u">NONE</option>
                       <option value="Strength" data-i18n="str-u">STR</option>
                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                       <option value="Constitution" data-i18n="con-u">CON</option>
                       <option value="Intelligence" data-i18n="int-u">INT</option>
                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                   </select>
                   +
                   <select name="attr_custom_ac_part2">
                       <option value="none" selected="selected" data-i18n="none-u">NONE</option>
                       <option value="Strength" data-i18n="str-u">STR</option>
                       <option value="Dexterity" data-i18n="dex-u">DEX</option>
                       <option value="Constitution" data-i18n="con-u">CON</option>
                       <option value="Intelligence" data-i18n="int-u">INT</option>
                       <option value="Wisdom" data-i18n="wis-u">WIS</option>
                       <option value="Charisma" data-i18n="cha-u">CHA</option>
                   </select>
                   <input type="checkbox" name="attr_halflingluck_flag" value="1">
                   HALFLING LUCK
                   <input type="checkbox" name="attr_arcane_fighter" value="1">
                   ARCANE FIGHTER
                   <input type="checkbox" name="attr_arcane_rogue" value="1">
                   ARCANE ROGUE
                   CLASS OPTIONS ()
                   <input type="checkbox" name="attr_multiclass1_flag" value="1">
                   2ND CLASS:
                   <select name="attr_multiclass1" style="width: 64px;">
                       <option value="barbarian" data-i18n="barbarian">Barbarian</option>
                       <option value="bard" data-i18n="bard">Bard</option>
                       <option value="cleric" data-i18n="cleric">Cleric</option>
                       <option value="druid" data-i18n="druid">Druid</option>
                       <option value="fighter" data-i18n="fighter">Fighter</option>
                       <option value="monk" data-i18n="monk">Monk</option>
                       <option value="paladin" data-i18n="paladin">Paladin</option>
                       <option value="ranger" data-i18n="ranger">Ranger</option>
                       <option value="rogue" data-i18n="rogue">Rogue</option>
                       <option value="sorcerer" data-i18n="sorcerer">Sorcerer</option>
                       <option value="warlock" data-i18n="warlock">Warlock</option>
                       <option value="wizard" data-i18n="wizard">Wizard</option>
                   </select>
                   LEVEL:
                   <input type="text" name="attr_multiclass1_lvl" value="1" style="width: 28px; text-align: center;">
                   <input type="checkbox" name="attr_multiclass2_flag" value="1">
                   3RD CLASS:
                   <select name="attr_multiclass2" style="width: 64px;">
                       <option value="barbarian" data-i18n="barbarian">Barbarian</option>
                       <option value="bard" data-i18n="bard">Bard</option>
                       <option value="cleric" data-i18n="cleric">Cleric</option>
                       <option value="druid" data-i18n="druid">Druid</option>
                       <option value="fighter" data-i18n="fighter">Fighter</option>
                       <option value="monk" data-i18n="monk">Monk</option>
                       <option value="paladin" data-i18n="paladin">Paladin</option>
                       <option value="ranger" data-i18n="ranger">Ranger</option>
                       <option value="rogue" data-i18n="rogue">Rogue</option>
                       <option value="sorcerer" data-i18n="sorcerer">Sorcerer</option>
                       <option value="warlock" data-i18n="warlock">Warlock</option>
                       <option value="wizard" data-i18n="wizard">Wizard</option>
                   </select>
                   LEVEL:
                   <input type="text" name="attr_multiclass2_lvl" value="1" style="width: 28px; text-align: center;">
                   <input type="checkbox" name="attr_multiclass3_flag" value="1">
                   4TH CLASS:
                   <select name="attr_multiclass3" style="width: 64px;">
                       <option value="barbarian" data-i18n="barbarian">Barbarian</option>
                       <option value="bard" data-i18n="bard">Bard</option>
                       <option value="cleric" data-i18n="cleric">Cleric</option>
                       <option value="druid" data-i18n="druid">Druid</option>
                       <option value="fighter" data-i18n="fighter">Fighter</option>
                       <option value="monk" data-i18n="monk">Monk</option>
                       <option value="paladin" data-i18n="paladin">Paladin</option>
                       <option value="ranger" data-i18n="ranger">Ranger</option>
                       <option value="rogue" data-i18n="rogue">Rogue</option>
                       <option value="sorcerer" data-i18n="sorcerer">Sorcerer</option>
                       <option value="warlock" data-i18n="warlock">Warlock</option>
                       <option value="wizard" data-i18n="wizard">Wizard</option>
                   </select>
                   LEVEL:
                   <input type="text" name="attr_multiclass3_lvl" value="1" style="width: 28px; text-align: center;">
                   MULTICLASS OPTIONS
                   <input type="checkbox" name="attr_custom_class" value="1">
                   USE CUSTOM CLASS
                   CLASS NAME:
                   <input type="text" name="attr_cust_classname">
                   HIT DIE:
                   <select name="attr_cust_hitdietype">
                       <option value="4">D4</option>
                       <option value="6">D6</option>
                       <option value="8">D8</option>
                       <option value="10">D10</option>
                       <option value="12">D12</option>
                   </select>
                   SPELLCASTING ABILITY:
                   <select name="attr_cust_spellcasting_ability">
                       <option value="0*" data-i18n="none-u">NONE</option>
                       <option value="@{strength_mod}+" data-i18n="strength-u">STRENGTH</option>
                       <option value="@{dexterity_mod}+" data-i18n="dexterity-u">DEXTERITY</option>
                       <option value="@{constitution_mod}+" data-i18n="constitution-u">CONSTITUTION</option>
                       <option value="@{intelligence_mod}+" data-i18n="intelligence-u">INTELLIGENCE</option>
                       <option value="@{wisdom_mod}+" data-i18n="wisdom-u">WISDOM</option>
                       <option value="@{charisma_mod}+" data-i18n="charisma-u">CHARISMA</option>
                   </select>
                   SPELL SLOTS:
                   <select name="attr_cust_spellslots">
                       <option value="none" data-i18n="none-u">NONE</option>
                       <option value="full" data-i18n="spell-full-u">FULL (Cleric, Druid, Wizard)</option>
                       <option value="half" data-i18n="spell-half-u">HALF (Paladin, Ranger)</option>
                       <option value="third" data-i18n="spell-third-u">THIRD (Arcane Fighter/Rogue)</option>
                   </select>
                   SAVES
                   <input type="checkbox" name="attr_cust_strength_save_prof" value="(@{pb})">
                   Strength
                   <input type="checkbox" name="attr_cust_dexterity_save_prof" value="(@{pb})">
                   Dexterity
                   <input type="checkbox" name="attr_cust_constitution_save_prof" value="(@{pb})">
                   Constitution
                   <input type="checkbox" name="attr_cust_intelligence_save_prof" value="(@{pb})">
                   Intelligence
                   <input type="checkbox" name="attr_cust_wisdom_save_prof" value="(@{pb})">
                   Wisdom
                   <input type="checkbox" name="attr_cust_charisma_save_prof" value="(@{pb})">
                   Charisma
                   CUSTOM CLASS OPTIONS
                       <select name="attr_acrobatics_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Acrobatics (Dex)
                       +<input type="text" class="num" name="attr_acrobatics_flat" value="0" placeholder="0" title="@{acrobatics_flat}">
                       <select name="attr_animal_handling_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Animal Handling (Wis)
                       +<input type="text" class="num" name="attr_animal_handling_flat" value="0" placeholder="0" title="@{animal_handling_flat}">
                       <select name="attr_arcana_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Arcana (Int)
                       +<input type="text" class="num" name="attr_arcana_flat" value="0" placeholder="0" title="@{arcana_flat}">
                       <select name="attr_athletics_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Athletics (Str)
                       +<input type="text" class="num" name="attr_athletics_flat" value="0" placeholder="0" title="@{athletics_flat}">
                       <select name="attr_deception_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Deception (Cha)
                       +<input type="text" class="num" name="attr_deception_flat" value="0" placeholder="0" title="@{deception_flat}">
                       <select name="attr_history_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       History (Int)
                       +<input type="text" class="num" name="attr_history_flat" value="0" placeholder="0" title="@{history_flat}">
                       <select name="attr_insight_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Insight (Wis)
                       +<input type="text" class="num" name="attr_insight_flat" value="0" placeholder="0" title="@{insight_flat}">
                       <select name="attr_intimidation_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Intimidation (Cha)
                       +<input type="text" class="num" name="attr_intimidation_flat" value="0" placeholder="0" title="@{intimidation_flat}">
                       <select name="attr_investigation_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Investigation (Int)
                       +<input type="text" class="num" name="attr_investigation_flat" value="0" placeholder="0" title="@{investigation_flat}">
                       <select name="attr_medicine_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Medicine (Wis)
                       +<input type="text" class="num" name="attr_medicine_flat" value="0" placeholder="0" title="@{medicine_flat}">
                       <select name="attr_nature_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Nature (Int)
                       +<input type="text" class="num" name="attr_nature_flat" value="0" placeholder="0" title="@{nature_flat}">
                       <select name="attr_perception_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Perception (Wis)
                       +<input type="text" class="num" name="attr_perception_flat" value="0" placeholder="0" title="@{perception_flat}">
                       <select name="attr_performance_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Performance (Cha)
                       +<input type="text" class="num" name="attr_performance_flat" value="0" placeholder="0" title="@{performance_flat}">
                       <select name="attr_persuasion_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Persuasion (Cha)
                       +<input type="text" class="num" name="attr_persuasion_flat" value="0" placeholder="0" title="@{persuasion_flat}">
                       <select name="attr_religion_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Religion (Int)
                       +<input type="text" class="num" name="attr_religion_flat" value="0" placeholder="0" title="@{religion_flat}">
                       <select name="attr_sleight_of_hand_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Sleight of Hand (Dex)
                       +<input type="text" class="num" name="attr_sleight_of_hand_flat" value="0" placeholder="0" title="@{sleight_of_hand_flat}">
                       <select name="attr_stealth_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Stealth (Dex)
                       +<input type="text" class="num" name="attr_stealth_flat" value="0" placeholder="0" title="@{stealth_flat}">
                       <select name="attr_survival_type"><option value="1" selected="selected" data-i18n="normal">Normal</option><option value="2" data-i18n="expirtise">Expertise</option></select>
                       Survival (Wis)
                       +<input type="text" class="num" name="attr_survival_flat" value="0" placeholder="0" title="@{survival_flat}">
                   <input type="checkbox" name="attr_jack_of_all_trades" value="(floor(@{pb}/2))">
                   JACK OF ALL TRADES
                   SKILL OPTIONS
                   v
                   <input type="text" name="attr_version" value="1.6">
                   <input type="checkbox" name="attr_npc" value="1">
                   NPC
                   ROLL QUERIES:
                   <select name="attr_rtype">
                       <option value="Template:Always=1 {{r2=[[1d20" data-i18n="always-roll-adv">Always Roll Advantage</option>
                       <option value="@{advantagetoggle}" data-i18n="toggle-roll-adv">Advantage Toggle</option>
                       <option value="Template:Query=1 ?{Advantage?|Normal Roll,&#123&#123normal=1&#125&#125 &#123&#123r2=[[0d20|Advantage,&#123&#123advantage=1&#125&#125 &#123&#123r2=[[1d20|Disadvantage,&#123&#123disadvantage=1&#125&#125 &#123&#123r2=[[1d20}" data-i18n="query-roll-adv">Query Advantage</option>
                       <option value="Template:Normal=1 {{r2=[[0d20" data-i18n="never-roll-adv">Never Roll Advantage</option>
                   </select>
                   WHISPER ROLLS TO GM:
                   <select name="attr_wtype">
                       <option value="" data-i18n="never-whisper-roll">Never Whisper Rolls</option>
                       <option value="?{Whisper?|Public Roll,|Whisper Roll,/w gm }" data-i18n="query-whisper-roll">Query Whisper</option>
                       <option value="/w gm " data-i18n="always-whisper-roll">Always Whisper Rolls</option>
                   </select>
                   AUTO DAMAGE ROLL:
                   <select class="dtype" name="attr_dtype">
                       <option value="pick" data-i18n="never-roll-dmg">Don't Auto Roll Damage</option>
                       <option value="full" data-i18n="always-roll-dmg">Auto Roll Damage & Crit</option>
                   </select>
                   ADD CHARACTER NAME TO TEMPLATES:
                   <select class="dtype" name="attr_charname_output">
                       <option value="{{charname=@{character_name}}}" data-i18n="on">On</option>
                       <option value="charname=@{character_name}" selected="selected" data-i18n="off">Off</option>
                   </select>
                   INVENTORY:
                   <select name="attr_simpleinventory">
                       <option value="complex" data-i18n="compendium-compatible">Compendium Compatible</option>
                       <option value="simple" data-i18n="simple">Simple</option>
                   </select>
                   ENCUMBERANCE:
                   <select name="attr_encumberance_setting">
                       <option value="on" data-i18n="on">On</option>
                       <option value="off" data-i18n="off">Off</option>
                   </select>
                   AMMO TRACKING:
                   <select name="attr_ammotracking">
                       <option value="on" data-i18n="on">On</option>
                       <option value="off" selected="selected" data-i18n="off">Off</option>
                   </select>
                   (API REQUIRED)
                   GENERAL OPTIONS
           <input type="hidden" class="already_transitioned" name="attr_already_transitioned" value="0">
                   Clicking one of the images below will reformat the data from your current sheet to this sheet. These changes are permanent and cannot be undone.
                   Please make a copy of your game before you use this tool.
                   CHOOSE THE SHEET YOU ARE TRANSFERING FROM


                       COMMUNITY SHEET
                       <input type="checkbox" name="attr_is_simple" id="isSimple" value="1" style="display: none;">
                       <label for="isSimple" style="cursor: pointer;"><img src="http://i.imgur.com/py5B0cm.png" width="220" height="177"></label>
                       SHAPED SHEET
                       <input type="checkbox" name="attr_is_shaped" id="isShaped" value="1" style="display: none;">
                       <label for="isShaped"><img src="http://i.imgur.com/LoT21n1.png" width="220" height="177"></label>
                   <input type="checkbox" class="already_transitioned" name="attr_already_transitioned" value="1">
                   Hide TRANSITION OPTIONS
                   TRANSITION OPTIONS

<input type="hidden" name="attr_level" value="1"> <input type="hidden" name="attr_acrobatics_proficiency" value="(((@{acrobatics_prof} + @{jack_of_all_trades}) + abs(@{acrobatics_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_animal_handling_proficiency" value="(((@{animal_handling_prof} + @{jack_of_all_trades}) + abs(@{animal_handling_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_arcana_proficiency" value="(((@{arcana_prof} + @{jack_of_all_trades}) + abs(@{arcana_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_athletics_proficiency" value="(((@{athletics_prof} + @{jack_of_all_trades}) + abs(@{athletics_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_deception_proficiency" value="(((@{deception_prof} + @{jack_of_all_trades}) + abs(@{deception_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_history_proficiency" value="(((@{history_prof} + @{jack_of_all_trades}) + abs(@{history_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_insight_proficiency" value="(((@{insight_prof} + @{jack_of_all_trades}) + abs(@{insight_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_intimidation_proficiency" value="(((@{intimidation_prof} + @{jack_of_all_trades}) + abs(@{intimidation_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_investigation_proficiency" value="(((@{investigation_prof} + @{jack_of_all_trades}) + abs(@{investigation_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_medicine_proficiency" value="(((@{medicine_prof} + @{jack_of_all_trades}) + abs(@{medicine_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_nature_proficiency" value="(((@{nature_prof} + @{jack_of_all_trades}) + abs(@{nature_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_perception_proficiency" value="(((@{perception_prof} + @{jack_of_all_trades}) + abs(@{perception_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_performance_proficiency" value="(((@{performance_prof} + @{jack_of_all_trades}) + abs(@{performance_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_persuasion_proficiency" value="(((@{persuasion_prof} + @{jack_of_all_trades}) + abs(@{persuasion_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_religion_proficiency" value="(((@{religion_prof} + @{jack_of_all_trades}) + abs(@{religion_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_sleight_of_hand_proficiency" value="(((@{sleight_of_hand_prof} + @{jack_of_all_trades}) + abs(@{sleight_of_hand_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_stealth_proficiency" value="(((@{stealth_prof} + @{jack_of_all_trades}) + abs(@{stealth_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_survival_proficiency" value="(((@{survival_prof} + @{jack_of_all_trades}) + abs(@{survival_prof} - @{jack_of_all_trades})) / 2)" disabled="true"> <input type="hidden" name="attr_hitdie_final" value=""> <input type="hidden" name="attr_globalsavingthrowbonus" value=""> <input type="hidden" name="attr_halflingluck" value="">

   <rolltemplate class="sheet-rolltemplate-simple">
   </rolltemplate>
   <rolltemplate class="sheet-rolltemplate-atk">
           {{#range}}
           Template:/range
               {{#normal}}
{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1 {{#^rollWasCrit() r1}}Template:Rname ()Template:/^rollWasCrit() r1
               Template:/normal
               {{#always}}
{{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:Rnamec ()Template:/rollWasCrit() r2Template:/rollLess() r1 r2 {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1Template:/rollTotal() r1 r2 {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1Template:/rollGreater() r1 r2 {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:Rname ()Template:/^rollWasCrit() r2Template:/^rollWasCrit() r1
               Template:/always
               {{#advantage}}
{{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:Rnamec ()Template:/rollWasCrit() r2Template:/rollLess() r1 r2 {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1Template:/rollTotal() r1 r2 {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1Template:/rollGreater() r1 r2 {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:Rname ()Template:/^rollWasCrit() r2Template:/^rollWasCrit() r1
               Template:/advantage
               {{#disadvantage}}
{{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec ()Template:/rollWasCrit() r1Template:/rollTotal() r1 r2 {{#rollTotal() r1 r2}}{{#^rollWasCrit() r1}}Template:Rname ()Template:/^rollWasCrit() r1Template:/rollTotal() r1 r2 {{#rollLess() r1 r2}}Template:Rname ()Template:/rollLess() r1 r2 {{#rollGreater() r1 r2}}Template:Rname ()Template:/rollGreater() r1 r2
               Template:/disadvantage
           {{#charname}}
           Template:/charname
       {{#desc}}
       Template:/desc
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-dmg">
       {{#save}}
           {{#attack}}
           Template:/attack
           Template:^attack
       Template:/save
       Template:^attack
           {{#desc}}
           Template:/desc
       Template:/attack
       {{#hldmg}}
           {{#^rollTotal() hldmg 0}}
                   Template:Hldmg
                   Template:Dmg1type
                       Higher Level Cast
           Template:/^rollTotal() hldmg 0
       Template:/hldmg
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-atkdmg">
       {{#attack}}
       Template:/attack
       {{#save}}
           {{#attack}}
           Template:/attack
           Template:^attack
       Template:/save
       {{#desc}}
       Template:/desc
       {{#hldmg}}
           {{#^rollTotal() hldmg 0}}
                   Template:Hldmg
                   Template:Dmg1type
                       Higher Level Cast
           Template:/^rollTotal() hldmg 0
       Template:/hldmg
       {{#damage}}
                   {{#dmg1flag}}
                       Template:^dmg2flag
                               
                                   Template:Dmg1
                                   {{#attack}}
                                       {{#normal}}
                                           {{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1
                                       Template:/normal
                                       {{#always}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/always
                                       {{#advantage}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/advantage
                                       {{#disadvantage}}
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                       Template:/disadvantage
                                   Template:/attack
                               
                               Template:Dmg1type
                       Template:/dmg2flag
                   Template:/dmg1flag
                   {{#dmg2flag}}
                       Template:^dmg1flag
                               
                                   Template:Dmg2
                                   {{#attack}}
                                       {{#normal}}
                                           {{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1
                                       Template:/normal
                                       {{#always}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/always
                                       {{#advantage}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/advantage
                                       {{#disadvantage}}
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                       Template:/disadvantage
                                   Template:/attack
                               
                               Template:Dmg2type
                       Template:/dmg1flag
                   Template:/dmg2flag
                   {{#dmg1flag}}
                       {{#dmg2flag}}
                               
                                   Template:Dmg1
                                   {{#attack}}
                                       {{#normal}}
                                           {{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1
                                       Template:/normal
                                       {{#always}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/always
                                       {{#advantage}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/advantage
                                       {{#disadvantage}}
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                       Template:/disadvantage
                                   Template:/attack
                               
                               Template:Dmg1type
                               
                                   Template:Dmg2
                                   {{#attack}}
                                       {{#normal}}
                                           {{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1
                                       Template:/normal
                                       {{#always}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/always
                                       {{#advantage}}
                                           {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}+ Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                           {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                                       Template:/advantage
                                       {{#disadvantage}}
                                           {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}+ Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                                       Template:/disadvantage
                                   Template:/attack
                               
                               Template:Dmg2type
                       Template:/dmg2flag
                   Template:/dmg1flag
               Template:^attack
                   {{#range}}
                   Template:/range
                   {{#charname}}
                   Template:/charname
               Template:/attack
       Template:/damage
   </rolltemplate>
   <rolltemplate class="sheet-rolltemplate-desc">
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-spell">
           {{#castingtime}}
               Casting Time: Template:Castingtime
           </div>
           Template:/castingtime
           {{#range}}
               Range: Template:Range
           </div>
           Template:/range
           {{#target}}
               Target: Template:Target
           </div>
           Template:/target
               Components:
               
                   {{#v}}V{{#s}}, Template:/sTemplate:^s{{#m}}, Template:/mTemplate:/sTemplate:/v
                   {{#s}}S{{#m}}, Template:/mTemplate:/s
                   {{#m}}M {{#material}}(Template:Material)Template:/materialTemplate:/m
               
           </div>
           {{#duration}}
               Duration: {{#concentration}}Concentration Template:/concentrationTemplate:Duration
           </div>
           Template:/duration
           {{#description}}
               Template:Description
           </div>
           Template:/description
           {{#athigherlevels}}
               At Higher Levels. Template:Athigherlevels
           </div>
           Template:/athigherlevels
       </div>
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-npc">
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-npcatk">
           {{#normal}}
               {{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1
               {{#^rollWasCrit() r1}}Template:RnameTemplate:/^rollWasCrit() r1
           Template:/normal
           {{#always}}
               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:RnamecTemplate:/rollWasCrit() r2Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1Template:/rollGreater() r1 r2
               {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:RnameTemplate:/^rollWasCrit() r2Template:/^rollWasCrit() r1
           Template:/always
           {{#advantage}}
               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:RnamecTemplate:/rollWasCrit() r2Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1Template:/rollGreater() r1 r2
               {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:RnameTemplate:/^rollWasCrit() r2Template:/^rollWasCrit() r1
           Template:/advantage
           {{#disadvantage}}
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:RnamecTemplate:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollTotal() r1 r2}}{{#^rollWasCrit() r1}}Template:RnameTemplate:/^rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollLess() r1 r2}}Template:RnameTemplate:/rollLess() r1 r2
               {{#rollGreater() r1 r2}}Template:RnamecTemplate:/rollGreater() r1 r2
           Template:/disadvantage
           {{#normal}}
               {{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1
               {{#^rollWasCrit() r1}}Template:Rname: Template:/^rollWasCrit() r1
           Template:/normal
           {{#always}}
               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:Rnamec: Template:/rollWasCrit() r2Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
               {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:Rname: Template:/^rollWasCrit() r2Template:/^rollWasCrit() r1
           Template:/always
           {{#advantage}}
               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}}Template:Rnamec: Template:/rollWasCrit() r2Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
               {{#^rollWasCrit() r1}}{{#^rollWasCrit() r2}}Template:Rname: Template:/^rollWasCrit() r2Template:/^rollWasCrit() r1
           Template:/advantage
           {{#disadvantage}}
               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}}Template:Rnamec: Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollTotal() r1 r2}}{{#^rollWasCrit() r1}}Template:Rname: Template:/^rollWasCrit() r1Template:/rollTotal() r1 r2
               {{#rollLess() r1 r2}}Template:Rname: Template:/rollLess() r1 r2
               {{#rollGreater() r1 r2}}Template:Rnamec: Template:/rollGreater() r1 r2
           Template:/disadvantage
           {{#normal}}
               Template:R1
           Template:/normal
           {{#always}}
               Template:R1 | Template:R2
           Template:/always
           {{#advantage}}
               {{#rollLess() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollGreater() r1 r2
           Template:/advantage
           {{#disadvantage}}
               {{#rollLess() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollLess() r1 r2
               {{#rollTotal() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollTotal() r1 r2
               {{#rollGreater() r1 r2}}
                   Template:R1 | Template:R2
               Template:/rollGreater() r1 r2
           Template:/disadvantage
       {{#description}}
       Template:/description
   </rolltemplate>
   
   <rolltemplate class="sheet-rolltemplate-npcdmg">    
   </rolltemplate> 
   
   <rolltemplate class="sheet-rolltemplate-npcaction">
           {{#damage}}
                   Damage: 
                   
                       {{#dmg1flag}}
                           Template:Dmg1 
                           {{#normal}}
                               {{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1
                           Template:/normal
                           {{#always}}
                               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}} + Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                           Template:/always
                           {{#advantage}}
                               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}} + Template:Crit1Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                           Template:/advantage
                           {{#disadvantage}}
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit1Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                           Template:/disadvantage
                           Template:Dmg1type
                       Template:/dmg1flag
                       {{#dmg1flag}}{{#dmg2flag}}+Template:/dmg2flagTemplate:/dmg1flag
                       {{#dmg2flag}}
                           Template:Dmg2 
                           {{#normal}}
                               {{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1
                           Template:/normal
                           {{#always}}
                               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}} + Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                           Template:/always
                           {{#advantage}}
                               {{#rollLess() r1 r2}}{{#rollWasCrit() r2}} + Template:Crit2Template:/rollWasCrit() r2Template:/rollLess() r1 r2
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                               {{#rollGreater() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1Template:/rollGreater() r1 r2
                           Template:/advantage
                           {{#disadvantage}}
                               {{#rollTotal() r1 r2}}{{#rollWasCrit() r1}} + Template:Crit2Template:/rollWasCrit() r1Template:/rollTotal() r1 r2
                           Template:/disadvantage
                           Template:Dmg2type
                       Template:/dmg2flag
                   
           Template:/damage
   </rolltemplate>

</div>

<script type="text/worker">

   on("sheet:opened", function() {
       versioning();
       getAttrs(['meleedmg1','rangeddmg1','pro_weapons','pro_armor','inventoryname1','barbarian_level','bard_level','cleric_level','druid_level','figher_level','monk_level','paladin_level','ranger_level','rogue_level','sorcerer_level','warlock_level','wizard_level','npc_type','npc_size','npc_alignment','npc_hp','npc_HP_hit_dice','npc_AC_note','npc_strength','npc_dexterity','npc_constitution','npc_intelligence','npc_wisdom','npc_charisma','speed','speed_fly','speed_burrow','speed_swim','speed_climb','prolanguages','blindsight','darkvision','tremorsense','truesight','challenge','xp','multiattack','npc_traits','lair_actions','legendary_action_notes','damage_vulnerability','damage_resistance','damage_immunity','condition_immunity'], function(attrs) {
           var hasOldData = false;
           var updates = {};
           _.each(attrs, function(value, key) {
               if(value) {
                   hasOldData = true;
               }
           });
           if(!hasOldData) {
               updates.already_transitioned = '1';
           }
           setAttrs(updates);
       });
       getAttrs(['multiclass1', 'multiclass2', 'multiclass3'], function(attrs) {
           var updates = {};
           var updated = false;
           if(typeof attrs['multiclass1'] !== 'undefined') {
               updates.multiclass1 = attrs['multiclass1'].toLowerCase();
               updated = true;
           }
           if(typeof attrs['multiclass2'] !== 'undefined') {
               updates.multiclass2 = attrs['multiclass2'].toLowerCase();
               updated = true;
           }
           if(typeof attrs['multiclass3'] !== 'undefined') {
               updates.multiclass3 = attrs['multiclass3'].toLowerCase();
               updated = true;
           }
           if (updated) {
               setlevel();
           }
           setAttrs(updates);
       });
   });
   on("change:npc", function() {
       getAttrs(["npc"], function(v) {
           if(v.npc && v.npc === "1") {
               setAttrs({
                   npc_toggle: 1
               });
           }
           else {
               setAttrs({
                   npc_toggle: 0
               });
           };
       });
   });
   on("change:class change:cust_classname change:cust_hitdietype change:cust_spellcasting_ability change:cust_spellslots change:cust_strength_save_prof change:cust_dexterity_save_prof change:cust_constitution_save_prof change:cust_intelligence_save_prof change:cust_wisdom_save_prof change:cust_charisma_save_prof", function() {
       updateClass();
   });
   
   on("change:custom_class", function() {
       getAttrs(["custom_class"], function(v) {
           if(v.custom_class && v.custom_class === "1") {
               setAttrs({
                   customclass_flag: 1
               });
           }
           else {
               setAttrs({
                   customclass_flag: 0
               });
           };
       });
       updateClass();
   });
       
   on("change:base_level change:multiclass1 change:multiclass1_lvl change:multiclass2 change:multiclass2_lvl change:multiclass3 change:multiclass3_lvl change:arcane_fighter change:arcane_rogue", function() {
       setlevel();
   });
   
   on("change:multiclass1_flag", function() {
       setlevel();
       getAttrs(["multiclass1_flag"], function(v) {
           if(v.multiclass1_flag && v.multiclass1_flag === "1") {
               setAttrs({
                   mutliclass1_showingflag: 1
               });
           }
           else {
               setAttrs({
                   mutliclass1_showingflag: 0
               });
           };
       });
   });
   
   on("change:multiclass2_flag", function() {
       setlevel();
       getAttrs(["multiclass2_flag"], function(v) {
           if(v.multiclass2_flag && v.multiclass2_flag === "1") {
               setAttrs({
                   mutliclass2_showingflag: 1
               });
           }
           else {
               setAttrs({
                   mutliclass2_showingflag: 0
               });
           };
       });
   });
   
   on("change:multiclass3_flag", function() {
       setlevel();
       getAttrs(["multiclass3_flag"], function(v) {
           if(v.multiclass3_flag && v.multiclass3_flag === "1") {
               setAttrs({
                   mutliclass3_showingflag: 1
               });
           }
           else {
               setAttrs({
                   mutliclass3_showingflag: 0
               });
           };
       });
   });
   
   on("change:repeating_tool:toolname_base change:repeating_tool:toolbonus_base change:repeating_tool:toolattr_base change:repeating_tool:tool_mod", function() {
       updateTool();
   });
   
   on("change:repeating_attack:atkflag change:repeating_attack:atkname_base change:repeating_attack:atkattr_base change:repeating_attack:atkmod change:repeating_attack:atkmagic change:repeating_attack:atkprofflag change:repeating_attack:dmgflag change:repeating_attack:dmgbase change:repeating_attack:dmgattr change:repeating_attack:dmgmod change:repeating_attack:dmgtype change:repeating_attack:dmg2flag change:repeating_attack:dmg2base change:repeating_attack:dmg2attr change:repeating_attack:dmg2mod change:repeating_attack:dmg2type change:repeating_attack:saveflag change:repeating_attack:savedc change:repeating_attack:saveflat change:repeating_attack:updateflag change:repeating_attack:dmgcustcrit change:repeating_attack:dmg2custcrit change:repeating_attack:ammo", function(eventinfo) {
       updateAttack(eventinfo);
   });
   
   on("change:dtype", function() {
       force_refresh_attacks();
       force_refresh_npcactions();
       // getAttrs(["dtype"], function(v) {
       //     setAttrs({
       //         dflag: v.dtype
       //     });
       //     var updatepickbase = v.dtype;
       //     getSectionIDs("repeating_attack", function(idarray) {
       //         _.each(idarray, function(currentID) {
       //             getAttrs(["repeating_attack_" + currentID + "_atkflag", "repeating_attack_" + currentID + "_dmgflag"], function(v) {
       //                 update = {};
       //                 if(updatepickbase === "full") {
       //                     update["repeating_attack_" + currentID + "_hidden_pickbase"] = "full";
       //                 }
       //                 else {
       //                     if(!v["repeating_attack_" + currentID + "_atkflag"] || v["repeating_attack_" + currentID + "_atkflag"] != 0) {
       //                         update["repeating_attack_" + currentID + "_hidden_pickbase"] = "pick";
       //                     }
       //                     else if(!v["repeating_attack_" + currentID + "_dmgflag"] || v["repeating_attack_" + currentID + "_dmgflag"] != 0) {
       //                         update["repeating_attack_" + currentID + "_hidden_pickbase"] = "dmg";
       //                     }
       //                     else {
       //                         update["repeating_attack_" + currentID + "_hidden_pickbase"] = "empty";
       //                     }
       //                 }
       //                 setAttrs(update);
       //             });
       //         });
       //     });
       // });
   });
   
   on("change:repeating_spell-cantrip:spellname_base change:repeating_spell-1:spellname_base change:repeating_spell-1:spellprepared change:repeating_spell-2:spellname_base change:repeating_spell-2:spellprepared change:repeating_spell-3:spellname_base change:repeating_spell-3:spellprepared change:repeating_spell-4:spellname_base change:repeating_spell-4:spellprepared change:repeating_spell-5:spellname_base change:repeating_spell-5:spellprepared change:repeating_spell-6:spellname_base change:repeating_spell-6:spellprepared change:repeating_spell-7:spellname_base change:repeating_spell-7:spellprepared change:repeating_spell-8:spellname_base change:repeating_spell-8:spellprepared change:repeating_spell-9:spellname_base change:repeating_spell-9:spellprepared change:repeating_spell-cantrip:spellrange change:repeating_spell-1:spellrange change:repeating_spell-2:spellrange change:repeating_spell-3:spellrange change:repeating_spell-4:spellrange change:repeating_spell-5:spellrange change:repeating_spell-6:spellrange change:repeating_spell-7:spellrange change:repeating_spell-8:spellrange change:repeating_spell-9:spellrange change:repeating_spell-cantrip:spelltarget change:repeating_spell-1:spelltarget change:repeating_spell-2:spelltarget change:repeating_spell-3:spelltarget change:repeating_spell-4:spelltarget change:repeating_spell-5:spelltarget change:repeating_spell-6:spelltarget change:repeating_spell-7:spelltarget change:repeating_spell-8:spelltarget change:repeating_spell-9:spelltarget change:repeating_spell-cantrip:spelldamage change:repeating_spell-1:spelldamage change:repeating_spell-2:spelldamage change:repeating_spell-3:spelldamage change:repeating_spell-4:spelldamage change:repeating_spell-5:spelldamage change:repeating_spell-6:spelldamage change:repeating_spell-7:spelldamage change:repeating_spell-8:spelldamage change:repeating_spell-9:spelldamage change:repeating_spell-cantrip:spelldamagetype change:repeating_spell-1:spelldamagetype change:repeating_spell-2:spelldamagetype change:repeating_spell-3:spelldamagetype change:repeating_spell-4:spelldamagetype change:repeating_spell-5:spelldamagetype change:repeating_spell-6:spelldamagetype change:repeating_spell-7:spelldamagetype change:repeating_spell-8:spelldamagetype change:repeating_spell-9:spelldamagetype change:repeating_spell-cantrip:spelldamage2 change:repeating_spell-1:spelldamage2 change:repeating_spell-2:spelldamage2 change:repeating_spell-3:spelldamage2 change:repeating_spell-4:spelldamage2 change:repeating_spell-5:spelldamage2 change:repeating_spell-6:spelldamage2 change:repeating_spell-7:spelldamage2 change:repeating_spell-8:spelldamage2 change:repeating_spell-9:spelldamage2 change:repeating_spell-cantrip:spelldamagetype2 change:repeating_spell-1:spelldamagetype2 change:repeating_spell-2:spelldamagetype2 change:repeating_spell-3:spelldamagetype2 change:repeating_spell-4:spelldamagetype2 change:repeating_spell-5:spelldamagetype2 change:repeating_spell-6:spelldamagetype2 change:repeating_spell-7:spelldamagetype2 change:repeating_spell-8:spelldamagetype2 change:repeating_spell-9:spelldamagetype2 change:repeating_spell-cantrip:spellhealing change:repeating_spell-1:spellhealing change:repeating_spell-2:spellhealing change:repeating_spell-3:spellhealing change:repeating_spell-4:spellhealing change:repeating_spell-5:spellhealing change:repeating_spell-6:spellhealing change:repeating_spell-7:spellhealing change:repeating_spell-8:spellhealing change:repeating_spell-9:spellhealing change:repeating_spell-cantrip:spelldmgmod change:repeating_spell-1:spelldmgmod change:repeating_spell-2:spelldmgmod change:repeating_spell-3:spelldmgmod change:repeating_spell-4:spelldmgmod change:repeating_spell-5:spelldmgmod change:repeating_spell-6:spelldmgmod change:repeating_spell-7:spelldmgmod change:repeating_spell-8:spelldmgmod change:repeating_spell-9:spelldmgmod change:repeating_spell-cantrip:spellsave change:repeating_spell-1:spellsave change:repeating_spell-2:spellsave change:repeating_spell-3:spellsave change:repeating_spell-4:spellsave change:repeating_spell-5:spellsave change:repeating_spell-6:spellsave change:repeating_spell-7:spellsave change:repeating_spell-8:spellsave change:repeating_spell-9:spellsave change:repeating_spell-cantrip:spellsavesuccess change:repeating_spell-1:spellsavesuccess change:repeating_spell-2:spellsavesuccess change:repeating_spell-3:spellsavesuccess change:repeating_spell-4:spellsavesuccess change:repeating_spell-5:spellsavesuccess change:repeating_spell-6:spellsavesuccess change:repeating_spell-7:spellsavesuccess change:repeating_spell-8:spellsavesuccess change:repeating_spell-9:spellsavesuccess change:repeating_spell-cantrip:spellhldie change:repeating_spell-1:spellhldie change:repeating_spell-2:spellhldie change:repeating_spell-3:spellhldie change:repeating_spell-4:spellhldie change:repeating_spell-5:spellhldie change:repeating_spell-6:spellhldie change:repeating_spell-7:spellhldie change:repeating_spell-8:spellhldie change:repeating_spell-9:spellhldie change:repeating_spell-cantrip:spellhldietype change:repeating_spell-1:spellhldietype change:repeating_spell-2:spellhldietype change:repeating_spell-3:spellhldietype change:repeating_spell-4:spellhldietype change:repeating_spell-5:spellhldietype change:repeating_spell-6:spellhldietype change:repeating_spell-7:spellhldietype change:repeating_spell-8:spellhldietype change:repeating_spell-9:spellhldietype change:repeating_spell-cantrip:spell_updateflag change:repeating_spell-1:spell_updateflag change:repeating_spell-2:spell_updateflag change:repeating_spell-3:spell_updateflag change:repeating_spell-4:spell_updateflag change:repeating_spell-5:spell_updateflag change:repeating_spell-6:spell_updateflag change:repeating_spell-7:spell_updateflag change:repeating_spell-8:spell_updateflag change:repeating_spell-9:spell_updateflag change:repeating_spell-cantrip:spellattack change:repeating_spell-1:spellattack change:repeating_spell-2:spellattack change:repeating_spell-3:spellattack change:repeating_spell-4:spellattack change:repeating_spell-5:spellattack change:repeating_spell-6:spellattack change:repeating_spell-7:spellattack change:repeating_spell-8:spellattack change:repeating_spell-9:spellattack change:repeating_spell-cantrip:spellhlbonus change:repeating_spell-1:spellhlbonus change:repeating_spell-2:spellhlbonus change:repeating_spell-3:spellhlbonus change:repeating_spell-4:spellhlbonus change:repeating_spell-5:spellhlbonus change:repeating_spell-6:spellhlbonus change:repeating_spell-7:spellhlbonus change:repeating_spell-8:spellhlbonus change:repeating_spell-9:spellhlbonus change:repeating_spell-npc:spellname_base change:repeating_spell-npc:spellrange change:repeating_spell-npc:spelltarget change:repeating_spell-npc:spelldamage change:repeating_spell-npc:spelldamagetype change:repeating_spell-npc:spelldamage2 change:repeating_spell-npc:spelldamagetype2 change:repeating_spell-npc:spellhealing change:repeating_spell-npc:spelldmgmod change:repeating_spell-npc:spellsave change:repeating_spell-npc:spellsavesuccess change:repeating_spell-npc:spellhldie change:repeating_spell-npc:spellhldietype change:repeating_spell-npc:spell_updateflag change:repeating_spell-npc:spellattack change:repeating_spell-npc:spellhlbonus change:repeating_spell-npc:spellprepared", function(eventinfo) {
       updateSpell("","",eventinfo);
   });
   
   on("change:npc_name change:npc_type change:npc_ac change:npc_actype change:hp_max change:npc_hpformula change:npc_speed change:strength change:dexterity change:constitution change:intelligence change:wisdom change:charisma change:npc_str_save change:npc_dex_save change:npc_con_save change:npc_int_save change:npc_wis_save change:npc_cha_save change:npc_acrobatics change:npc_animal_handling change:npc_arcana change:npc_athletics change:npc_deception change:npc_history change:npc_insight change:npc_intimidation change:npc_investigation change:npc_medicine change:npc_nature change:npc_perception change:npc_performance change:npc_persuasion change:npc_religion change:npc_sleight_of_hand change:npc_stealth change:npc_survival change:npc_vulnerabilities change:npc_resistances change:npc_immunities change:npc_condition_immunities change:npc_senses change:npc_languages change:npc_challenge change:npc_xp change:npc_legendary_actions change:npcreactionsflag change:npcspellcastingflag", function() {
       updateNPC();
   });
   on("change:repeating_spell-cantrip:spellritualflag change:repeating_spell-1:spellritualflag change:repeating_spell-2:spellritualflag change:repeating_spell-3:spellritualflag change:repeating_spell-4:spellritualflag change:repeating_spell-5:spellritualflag change:repeating_spell-6:spellritualflag change:repeating_spell-7:spellritualflag change:repeating_spell-8:spellritualflag change:repeating_spell-9:spellritualflag change:repeating_spell-npc:spellritualflag", function() {
       getAttrs(["repeating_spell_spellritualflag"], function(v) {
           flag = v.repeating_spell_spellritualflag === "Yes" ? "Template:Ritual=1" : "0";
           setAttrs({
               repeating_spell_spellritual: flag
           });
       });
   });
   on("change:repeating_spell-cantrip:spellconcentrationflag change:repeating_spell-1:spellconcentrationflag change:repeating_spell-2:spellconcentrationflag change:repeating_spell-3:spellconcentrationflag change:repeating_spell-4:spellconcentrationflag change:repeating_spell-5:spellconcentrationflag change:repeating_spell-6:spellconcentrationflag change:repeating_spell-7:spellconcentrationflag change:repeating_spell-8:spellconcentrationflag change:repeating_spell-9:spellconcentrationflag change:repeating_spell-npc:spellconcentrationflag", function() {
       getAttrs(["repeating_spell_spellconcentrationflag"], function(v) {
           flag = v.repeating_spell_spellconcentrationflag === "Yes" ? "Template:Concentration=1" : "0";
           setAttrs({
               repeating_spell_spellconcentration: flag
           });
       });
   });
   
   on("change:repeating_spell-cantrip:spellcomp change:repeating_spell-1:spellcomp change:repeating_spell-2:spellcomp change:repeating_spell-3:spellcomp change:repeating_spell-4:spellcomp change:repeating_spell-5:spellcomp change:repeating_spell-6:spellcomp change:repeating_spell-7:spellcomp change:repeating_spell-8:spellcomp change:repeating_spell-9:spellcomp change:repeating_spell-npc:spellcomp", function() {
       getAttrs(["repeating_spell_spellcomp"], function(v) {
           spellv = v.repeating_spell_spellcomp.indexOf("V") > -1 ? "Template:V=1" : "0"
           spells = v.repeating_spell_spellcomp.indexOf("S") > -1 ? "Template:S=1" : "0"
           spellm = v.repeating_spell_spellcomp.indexOf("M") > -1 ? "Template:M=1" : "0"
           setAttrs({
               repeating_spell_spellcomp_v: spellv,
               repeating_spell_spellcomp_s: spells,
               repeating_spell_spellcomp_m: spellm
           });
       });
   });
   on("change:repeating_spell-cantrip:spellcontent change:repeating_spell-1:spellcontent change:repeating_spell-2:spellcontent change:repeating_spell-3:spellcontent change:repeating_spell-4:spellcontent change:repeating_spell-5:spellcontent change:repeating_spell-6:spellcontent change:repeating_spell-7:spellcontent change:repeating_spell-8:spellcontent change:repeating_spell-9:spellcontent change:repeating_spell-npc:spellcontent", function() {
       getAttrs(["repeating_spell_spellcontent"], function(v) {
           content = v.repeating_spell_spellcontent.split("At Higher Levels:");
           if(content.length > 1) {
               spelldesc = content[0].trim();
               spellhigherlvl = content[1].trim();
           }
           else {
               spelldesc = v.repeating_spell_spellcontent;
               spellhigherlvl = "";
           }
           setAttrs({
               repeating_spell_spelldescription: spelldesc,
               repeating_spell_spellathigherlevels: spellhigherlvl
           });
       });
   });
   // on("change:repeating_spell-cantrip:spellhealing change:repeating_spell-1:spellhealing change:repeating_spell-2:spellhealing change:repeating_spell-3:spellhealing change:repeating_spell-4:spellhealing change:repeating_spell-5:spellhealing change:repeating_spell-6:spellhealing change:repeating_spell-7:spellhealing change:repeating_spell-8:spellhealing change:repeating_spell-9:spellhealing", function() {
   //     getAttrs(["repeating_spell_spellhealing","repeating_spell_spelldamage","repeating_spell_spelldamage2","repeating_spell_spelldmgmod"], function(v) {
   //         if(v.repeating_spell_spellhealing && v.repeating_spell_spellhealing != "") {
   //             update = {};
   //             // castingbonus = v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod === "Yes" ? " + @{spellcasting_ability}" : "";
   //             if(!v.repeating_spell_spelldamage || v.repeating_spell_spelldamage === "") {
   //                 update["repeating_spell_spelldamage"] = v.repeating_spell_spellhealing;
   //             }
   //             else if(!v.repeating_spell_spelldamage2 || v.repeating_spell_spelldamage2 === "") {
   //                 update["repeating_spell_spelldamage2"] = v.repeating_spell_spellhealing;
   //             }
   //             update["repeating_spell_spellhealing"] = "";
   //             setAttrs(update);
   //         }
   //     });
   // });
   on("change:repeating_spell-cantrip:spelloutput change:repeating_spell-1:spelloutput change:repeating_spell-2:spelloutput change:repeating_spell-3:spelloutput change:repeating_spell-4:spelloutput change:repeating_spell-5:spelloutput change:repeating_spell-6:spelloutput change:repeating_spell-7:spelloutput change:repeating_spell-8:spelloutput change:repeating_spell-9:spelloutput change:repeating_spell-npc:spelloutput", function(eventinfo) {
       var idlvl = "-" + eventinfo.sourceAttribute.match(/repeating_spell-(.*?)-/)[1];
       var spid = eventinfo.sourceAttribute.split("_")[2];
       var ourid = idlvl + spid;
       getAttrs(["repeating_spell_spellattackid","repeating_spell_spelloutput","character_id","repeating_spell_pickbase"], function(v) {
           if(v.repeating_spell_spelloutput === "ATTACK") {
               // if(idlvl != "-npc_") {
               setAttrs({repeating_spell_spellattackinfoflag:"show"});
               if(!v.repeating_spell_spellattackid) {
                   addspellattack(ourid);
               } 
               else {
                   getSectionIDs("repeating_attack", function(idarray) {
                       var existingid = _.find(idarray, function(thisid) { 
                           return (thisid.toLowerCase() === v.repeating_spell_spellattackid.toLowerCase() ) 
                       });
                       if(!existingid) {
                           addspellattack(ourid);
                       }
                       else {
                           getAttrs(["repeating_attack_" + v.repeating_spell_spellattackid + "_hidden_pickbase"], function(x) {
                               // pbase = x["repeating_attack_" + v.repeating_spell_spellattackid + "_hidden_pickbase"];
                               setAttrs({
                                   repeating_spell_rollcontent: "%{" + v.character_id + "|repeating_attack_" + v.repeating_spell_spellattackid + "_attack}"
                               });
                           });
                       }
                   });
               };
               // }
               // else {
               //     setAttrs({
               //         repeating_spell_rollcontent: "@{rollbase}"
               //     });
               //     updateNPCspell(eventinfo);
               // }
           }
           else {
               setAttrs({
                   repeating_spell_rollcontent: "@{wtype}&{template:spell} {{level=@{spellschool} @{spelllevel}}} {{name=@{spellname_base}}} {{castingtime=@{spellcastingtime}}} {{range=@{spellrange}}} {{target=@{spelltarget}}} @{spellcomp_v} @{spellcomp_s} @{spellcomp_m} {{material=@{spellcomp_materials}}} {{duration=@{spellduration}}} {{description=@{spelldescription}}} {{athigherlevels=@{spellathigherlevels}}} @{spellritual} @{spellconcentration} @{charname_output}",
                   repeating_spell_spellattackinfoflag: "hide"
               });
           }
       });
   });
   on("change:repeating_spell-cantrip:spelldamage change:repeating_spell-1:spelldamage change:repeating_spell-2:spelldamage change:repeating_spell-3:spelldamage change:repeating_spell-4:spelldamage change:repeating_spell-5:spelldamage change:repeating_spell-6:spelldamage change:repeating_spell-7:spelldamage change:repeating_spell-8:spelldamage change:repeating_spell-9:spelldamage change:repeating_spell-npc:spelldamage change:repeating_spell-cantrip:spellhealing change:repeating_spell-1:spellhealing change:repeating_spell-2:spellhealing change:repeating_spell-3:spellhealing change:repeating_spell-4:spellhealing change:repeating_spell-5:spellhealing change:repeating_spell-6:spellhealing change:repeating_spell-7:spellhealing change:repeating_spell-8:spellhealing change:repeating_spell-9:spellhealing change:repeating_spell-npc:spellhealing", function() {
       getAttrs(["repeating_spell_spelldamage","repeating_spell_spellhealing"], function(v) {
           if((v.repeating_spell_spelldamage && v.repeating_spell_spelldamage != "") || (v.repeating_spell_spellhealing && v.repeating_spell_spellhealing != "")) {
               setAttrs({
                   repeating_spell_spelloutput: "ATTACK"
               });
           }
       });
   });
   on("change:repeating_spell-cantrip:spell_damage_progression", function() {
       getAttrs(["repeating_spell_spell_damage_progression", "repeating_spell_spelldamage"], function(v) {
           if(v.repeating_spell_spell_damage_progression && v.repeating_spell_spell_damage_progression === "Cantrip Dice" && v.repeating_spell_spelldamage && v.repeating_spell_spelldamage.substring(0,2) === "1d") {
               var damageformula = "[[round((@{level} + 1) / 6 + 0.5)]]" + v.repeating_spell_spelldamage.substring(1);
               setAttrs({
                   repeating_spell_spelldamage: damageformula
               });
           }
       });
   })
   // on("change:repeating_spell-cantrip:spelldmgmod change:repeating_spell-1:spelldmgmod change:repeating_spell-2:spelldmgmod change:repeating_spell-3:spelldmgmod change:repeating_spell-4:spelldmgmod change:repeating_spell-5:spelldmgmod change:repeating_spell-6:spelldmgmod change:repeating_spell-7:spelldmgmod change:repeating_spell-8:spelldmgmod change:repeating_spell-9:spelldmgmod", function() {
   //     getAttrs(["repeating_spell_spelldmgmod","repeating_spell_spelldamage","repeating_spell_spelldamage2","repeating_spell_spellhealing"], function(v) {
   //         if(v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod != "" && (!v.repeating_spell_spellhealing) || v.repeating_spell_spellhealing ==="") {
   //             update = {};
   //             castingbonus = v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod === "Yes" ? " + @{spellcasting_ability}" : ""
   //             if(v.repeating_spell_spelldamage && v.repeating_spell_spelldamage != "") {
   //                 update["repeating_spell_spelldamage"] = v.repeating_spell_spelldamage + castingbonus;
   //             }
   //             else if(v.repeating_spell_spelldamage2 && v.repeating_spell_spelldamage2 != "") {
   //                 update["repeating_spell_spelldamage2"] = v.repeating_spell_spelldamage2 + castingbonus;
   //             }
   //             setAttrs(update);
   //         }
   //     });
   // });
   // on("change:repeating_attack:hidden_pickbase", function(eventinfo) {
   //     getAttrs(["repeating_attack_hidden_pickbase"], function(x) {
   //         getSectionIDs("repeating_spell", function(idarray) {
   //             attackid = eventinfo.sourceAttribute.substring(17, 37);
   //             _.each(idarray, function(currentID) {
   //                 getAttrs(["repeating_spell-cantrip_" + currentID + "_spelloutput","repeating_spell-cantrip_" + currentID + "_spellattackid","repeating_spell-1_" + currentID + "_spelloutput","repeating_spell-1_" + currentID + "_spellattackid","repeating_spell-2_" + currentID + "_spelloutput","repeating_spell-2_" + currentID + "_spellattackid","repeating_spell-3_" + currentID + "_spelloutput","repeating_spell-3_" + currentID + "_spellattackid","repeating_spell-4_" + currentID + "_spelloutput","repeating_spell-4_" + currentID + "_spellattackid","repeating_spell-5_" + currentID + "_spelloutput","repeating_spell-5_" + currentID + "_spellattackid","repeating_spell-6_" + currentID + "_spelloutput","repeating_spell-6_" + currentID + "_spellattackid","repeating_spell-7_" + currentID + "_spelloutput","repeating_spell-7_" + currentID + "_spellattackid","repeating_spell-8_" + currentID + "_spelloutput","repeating_spell-8_" + currentID + "_spellattackid","repeating_spell-9_" + currentID + "_spelloutput","repeating_spell-9_" + currentID + "_spellattackid","character_name"], function(v) {
   //                     lvl = Object.keys(v)[0].match(/repeating_spell-(.*?)-/);
   //                     if(lvl && v["repeating_spell-" + lvl[1] + currentID + "_spellattackid"] && v["repeating_spell-" + lvl[1] + currentID + "_spellattackid"].toLowerCase() === attackid && v["repeating_spell-" + lvl[1] + currentID + "_spelloutput"] === "ATTACK") {
   //                         update = {};
   //                         update["repeating_spell-" + lvl[1] + currentID + "_rollcontent"] = "%{" + v.character_name + "|repeating_attack_" + attackid + "_attack_" + x.repeating_attack_hidden_pickbase + "}";
   //                         setAttrs(update);
   //                     }
   //                 });
   //             });
   //         });
   //     })
   // });
   on("change:repeating_npcaction:name change:repeating_npcaction:attack_flag change:repeating_npcaction:attack_type change:repeating_npcaction:attack_range change:repeating_npcaction:attack_target change:repeating_npcaction:attack_tohit change:repeating_npcaction:attack_damage change:repeating_npcaction:attack_damagetype change:repeating_npcaction:attack_damage2 change:repeating_npcaction:attack_damagetype2 change:repeating_npcaction:description change:repeating_npcaction-l:name change:repeating_npcaction-l:attack_flag change:repeating_npcaction-l:attack_type change:repeating_npcaction-l:attack_range change:repeating_npcaction-l:attack_target change:repeating_npcaction-l:attack_tohit change:repeating_npcaction-l:attack_damage change:repeating_npcaction-l:attack_damagetype change:repeating_npcaction-l:attack_damage2 change:repeating_npcaction-l:attack_damagetype2 change:repeating_npcaction-l:description change:repeating_npcaction:updateflag change:repeating_npcaction-l:updateflag", function(eventinfo) {
       updateNPCaction(eventinfo);
   });
   on("change:npc_challenge", function() {
       getAttrs(["npc_challenge"], function(v) {
           var xp = 0;
           switch(v.npc_challenge) {
               case "0":
                   xp = "10";
                   break;
               case "1/8":
                   xp = "25";
                   break;
               case "1/4":
                   xp = "50";
                   break;
               case "1/2":
                   xp = "100";
                   break;
               case "1":
                   xp = "200";
                   break;
               case "2":
                   xp = "450";
                   break;
               case "3":
                   xp = "700";
                   break;
               case "4":
                   xp = "1100";
                   break;
               case "5":
                   xp = "1800";
                   break;
               case "6":
                   xp = "2300";
                   break;
               case "7":
                   xp = "2900";
                   break;
               case "8":
                   xp = "3900";
                   break;
               case "9":
                   xp = "5000";
                   break;
               case "10":
                   xp = "5900";
                   break;
               case "11":
                   xp = "7200";
                   break;
               case "12":
                   xp = "8400";
                   break;
               case "13":
                   xp = "10000";
                   break;
               case "14":
                   xp = "11500";
                   break;
               case "15":
                   xp = "13000";
                   break;
               case "16":
                   xp = "15000";
                   break;
               case "17":
                   xp = "18000";
                   break;
               case "18":
                   xp = "20000";
                   break;
               case "19":
                   xp = "22000";
                   break;
               case "20":
                   xp = "25000";
                   break;
               case "21":
                   xp = "33000";
                   break;
               case "22":
                   xp = "41000";
                   break;
               case "23":
                   xp = "50000";
                   break;
               case "24":
                   xp = "62000";
                   break;
               case "30":
                   xp = "155000";
                   break;
           }
           setAttrs({npc_xp: xp});
       });
   });
   on("change:simpleinventory", function() {
       getAttrs(["simpleinventory"], function(v) {
           setAttrs({
              inventoryflag: v.simpleinventory
           });
       });
   });
   on("change:repeating_inventory:itemweight change:repeating_inventory:equipped change:repeating_inventory:itemcount change:cp change:sp change:ep change:gp change:pp", function() {
       updateitemweight();
   });
   on("change:repeating_inventory:itemtype", function(eventinfo) {
       id = eventinfo.sourceAttribute.substring(20, 40);
       getAttrs(["repeating_inventory_itemtype","repeating_inventory_itemname"], function(v) {
           if(v.repeating_inventory_itemtype) {
               updateglobalsave();
               if(v.repeating_inventory_itemtype.indexOf("Weapon") > -1) {
                   existingattacks = [];
                   getSectionIDs("repeating_attack", function(idarray) {
                       if(idarray.length > 0) {
                           _.each(idarray, function(currentID, i) {
                               getAttrs(["repeating_attack_" + currentID + "_atkname_base"], function(x) {
                                   if(v["repeating_attack_" + currentID + "_atkname_base"] && v["repeating_attack_" + currentID + "_atkname_base"] != "") {
                                       existingattacks.push(x["repeating_attack_" + currentID + "_atkname_base"].toLowerCase());
                                   }
                                   if(i === idarray.length - 1 && v.repeating_inventory_itemname) {
                                       if(existingattacks.indexOf(v.repeating_inventory_itemname.toLowerCase()) === -1) {
                                           additemattack(id);
                                       }
                                   }
                               });
                           })
                       }
                       else {
                           additemattack(id);
                       }
                   });
               }
               else {
                   updateac();
               }
           }
           else {
               updateac();
               updateitemweight();
               updateglobalsave();
           }
       });
   });
   on("remove:repeating_spell-cantrip remove:repeating_spell-1 remove:repeating_spell-2 remove:repeating_spell-3 remove:repeating_spell-4 remove:repeating_spell-5 remove:repeating_spell-6 remove:repeating_spell-7 remove:repeating_spell-8 remove:repeating_spell-9 remove:repeating_spell-npc", function(eventinfo) {
       id = eventinfo.sourceAttribute.split("_")[2];
       getSectionIDs("repeating_attack", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_attack_" + currentID + "_spellid"], function(v) {
                   var spellid = v["repeating_attack_" + currentID + "_spellid"] && v["repeating_attack_" + currentID + "_spellid"].indexOf("_") > -1 ? v["repeating_attack_" + currentID + "_spellid"].split("_")[1] : v["repeating_attack_" + currentID + "_spellid"];
                   if(spellid === id.toLowerCase()) {
                       removeRepeatingRow("repeating_attack_" + currentID);
                   }
               });
           });
       });
   });
   on("remove:repeating_inventory", function(eventinfo) {
       id = eventinfo.sourceAttribute.substring(20, 40);
       getSectionIDs("repeating_attack", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_attack_" + currentID + "_itemid"], function(v) {
                   if(v["repeating_attack_" + currentID + "_itemid"] === id.toLowerCase()) {
                       removeRepeatingRow("repeating_attack_" + currentID);
                   }
               });
           });
       });
       getAttrs(["other_resource_itemid"], function(v) {
           if(v["other_resource_itemid"] === id.toLowerCase()) {
               update["other_resource_itemid"] = "";
               update["other_resource"] = "";
               update["other_resource_name"] = "";
               update["other_resource_max"] = "";
               setAttrs(update);
           }
       });
       getSectionIDs("repeating_resource", function(idarray) {
           var update = {};
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_resource_" + currentID + "_resource_left_itemid","repeating_resource_" + currentID + "_resource_right_itemid"], function(v) {
                   if(v["repeating_resource_" + currentID + "_resource_left_itemid"] === id.toLowerCase()) {
                       update["repeating_resource_" + currentID + "_resource_left_itemid"] = "";
                       update["repeating_resource_" + currentID + "_resource_left"] = "";
                       update["repeating_resource_" + currentID + "_resource_left_name"] = "";
                       update["repeating_resource_" + currentID + "_resource_left_max"] = "";
                       setAttrs(update);
                   }
                   if(v["repeating_resource_" + currentID + "_resource_right_itemid"] === id.toLowerCase()) {
                       update["repeating_resource_" + currentID + "_resource_right_itemid"] = "";
                       update["repeating_resource_" + currentID + "_resource_right"] = "";
                       update["repeating_resource_" + currentID + "_resource_right_name"] = "";
                       update["repeating_resource_" + currentID + "_resource_right_max"] = "";
                       setAttrs(update);
                   }
               });
           });
       });
       updateac();
       updateitemweight();
       updateglobalsave();
   });
   on("change:dexterity change:repeating_inventory:equipped change:globalacmod change:repeating_inventory:itemmodifiers change:custom_ac_flag change:custom_ac_base change:custom_ac_part1 change:custom_ac_part2", function() {
       getAttrs(["simpleinventory","custom_ac_flag"], function(v) {
           if(v.custom_ac_flag === "1") {
               getAttrs(["custom_ac_base","custom_ac_part1","custom_ac_part2","strength","dexterity","constitution","intelligence","wisdom","charisma"], function(b) {
                   var base = isNaN(parseInt(b.custom_ac_base, 10)) === false ? parseInt(b.custom_ac_base, 10) : 10;
                   var part1attr = b.custom_ac_part1.toLowerCase();
                   var part2attr = b.custom_ac_part2.toLowerCase();
                   var part1 = part1attr === "none" ? 0 : Math.floor((parseInt(b[part1attr])-10)/2);
                   var part2 = part2attr === "none" ? 0 : Math.floor((parseInt(b[part2attr])-10)/2);
                   var total = base + part1 + part2;
                   setAttrs({ac: total});
               });
           }
           else if(v.simpleinventory === "complex") {
               updateac();
           }
       });
   });
   on("change:repeating_inventory:itemmodifiers", function() {
       updateglobalsave();
       getAttrs(["repeating_inventory_itemmodifiers"], function(v) {
           if(v.repeating_inventory_itemmodifiers && v.repeating_inventory_itemmodifiers.toLowerCase().indexOf("spell attack") > -1) {
               var spellbonus = 0;
               getSectionIDs("repeating_inventory", function(idarray) {
                   if(idarray.length > 0) {
                       _.each(idarray, function(currentID, i) {
                           getAttrs(["repeating_inventory_" + currentID + "_itemmodifiers"], function(x) {
                               if(x["repeating_inventory_" + currentID + "_itemmodifiers"] && x["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().indexOf("spell attack") > -1) {
                                   spellbonus = spellbonus + parseInt(x["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().split("spell attack +")[1].substring(0,1), 10);
                               }
                               if(i === idarray.length - 1) {
                                   setAttrs({globalmagicmod: spellbonus});
                               }
                           });
                       });
                   }
               });
           }
       });
   });
   on("change:armorwarning", function() {
       getAttrs(["armorwarning"], function(v) {
           if(v.armorwarning === "hide") {
               setAttrs({armorwarningflag: "0"});
           }
       });
   });
   var npc_exception_actions = ["Web (Recharge 5-6)"];
   on("change:npc_typebase", function() {
       getAttrs(["npc_typebase","npc_sizebase","npc_alignmentbase","npc_acbase","npc_hpbase","npc_savingthrowsbase","npc_sensesbase","npc_passiveperceptionbase","npc_skillsbase","npc_content"], function(v) {
           if(v.npc_typebase && v.npc_typebase != "") {
               update = {};
               update["npc_typebase"] = "";
               update["npc_options-flag"] = "0";
               update["npc_type"] = v.npc_sizebase + " " + v.npc_typebase.toLowerCase() + ", " + v.npc_alignmentbase;
               if(v.npc_acbase.indexOf("(") > -1) {
                   update["npc_ac"] = v.npc_acbase.split(" (")[0];
                   update["npc_actype"] = v.npc_acbase.split(" (")[1].slice(0, -1);
               }
               else {
                   update["npc_ac"] = v.npc_acbase;
                   update["npc_actype"] = "";
               }
               if(v.npc_hpbase.indexOf("(") > -1) {
                   update["hp_max"] = v.npc_hpbase.split(" (")[0];
                   update["npc_hpformula"] = v.npc_hpbase.split(" (")[1].slice(0, -1);
               }
               else {
                   update["hp_max"] = v.npc_hpbase;
                   update["npc_hpformula"] = "";
               }
               update["npc_senses"] = v.npc_sensesbase + ", passive Perception " + v.npc_passiveperceptionbase;
               if(v.npc_savingthrowsbase && v.npc_savingthrowsbase != "") {
                   savearray = v.npc_savingthrowsbase.split(", ");
                   _.each(savearray, function(save) {
                       kv = save.split(" +");
                       update["npc_" + kv[0].toLowerCase() + "_save"] = parseInt(kv[1], 10);
                   });
               }
               if(v.npc_skillsbase && v.npc_skillsbase != "") {
                   skillarray = v.npc_skillsbase.split(", ");
                   _.each(skillarray, function(skill) {
                       kv = skill.split(" +");
                       update["npc_" + kv[0].toLowerCase().replace(/ /g, '_')] = parseInt(kv[1], 10);
                   });
               }
               var contentarray = v.npc_content;
               if(contentarray && contentarray.indexOf("Legendary Actions") > -1) {
                   if(contentarray.indexOf(/\n Legendary Actions\n/) > -1) {
                       temp = contentarray.split(/\n Legendary Actions\n/)
                   }
                   else {
                       temp = contentarray.split(/Legendary Actions\n/)
                   }
                   var legendaryactionsarray = temp[1];
                   contentarray = temp[0];
               }
               if(contentarray && contentarray.indexOf("Reactions") > -1) {
                   if(contentarray.indexOf(/\n Reactions\n/) > -1) {
                       temp = contentarray.split(/\n Reactions\n/)
                   }
                   else {
                       temp = contentarray.split(/Reactions\n/)
                   }
                   var reactionsarray = temp[1];
                   contentarray = temp[0];
               }
               if(contentarray && contentarray.indexOf("Actions") > -1) {
                   if(contentarray.indexOf("Lair Actions") > -1) {
                       contentarray = contentarray.replace("Lair Actions","Lair Action");
                   }
                   if(contentarray.indexOf(/\n Actions\n/) > -1) {
                       temp = contentarray.split(/\n Actions\n/)
                   }
                   else {
                       temp = contentarray.split(/Actions\n/)
                   }
                   var actionsarray = temp[1];
                   contentarray = temp[0];
               }
               if(contentarray && contentarray.indexOf("Traits") > -1) {
                   if(contentarray.indexOf("Lair Traits") > -1) {
                       contentarray = contentarray.replace("Lair Traits","Lair Trait");
                   }
                   if(contentarray.indexOf(/\n Traits\n/) > -1) {
                       temp = contentarray.split(/\n Traits\n/)
                   }
                   else {
                       temp = contentarray.split(/Traits\n/)
                   }
                   var traitsarray = temp[1];
                   contentarray = temp[0];
               }
               if(traitsarray) {
                   traitsarray = traitsarray.split("**");
                   traitsarray.shift();
                   var traitsobj = {};
                   traitsarray.forEach(function(val, i) {
                       if (i % 2 === 1) return;
                       traitsobj[val] = traitsarray[i + 1];
                   });
                   _.each(traitsobj, function(desc, name) {
                       newrowid = generateRowID();
                       update["repeating_npctrait_" + newrowid + "_name"] = name + ".";
                       if(desc.substring(0,2) === ": " || encodeURI(desc.substring(0,2)) === ":%C2%A0") {
                           desc = desc.substring(2);
                       }
                       update["repeating_npctrait_" + newrowid + "_desc"] = desc.trim();
                   });
               }
               if(actionsarray) {
                   actionsarray = actionsarray.split("**");
                   actionsarray.shift();
                   var actionsobj = {};
                   actionsarray.forEach(function(val, i) {
                       if (i % 2 === 1) return;
                       actionsobj[val] = actionsarray[i + 1];
                   });
                   _.each(actionsobj, function(desc, name) {
                       newrowid = generateRowID();
                       update["repeating_npcaction_" + newrowid + "_npc_options-flag"] = "0";
                       update["repeating_npcaction_" + newrowid + "_name"] = name;
                       if(desc.substring(0,2) === ": " || encodeURI(desc.substring(0,2)) === ":%C2%A0") {
                           desc = desc.substring(2);
                       }
                       if(desc.indexOf(" Attack:") > -1) {
                           update["repeating_npcaction_" + newrowid + "_attack_flag"] = "on";
                           update["repeating_npcaction_" + newrowid + "_attack_display_flag"] = "Template:Attack=1";
                           update["repeating_npcaction_" + newrowid + "_attack_options"] = "Template:Attack=1";
                           if(desc.indexOf(" Weapon Attack:") > -1) {
                               attacktype = desc.split(" Weapon Attack:")[0];
                           }
                           else if(desc.indexOf(" Spell Attack:") > -1) {
                               attacktype = desc.split(" Spell Attack:")[0];
                           }
                           else {
                               console.log("FAILED TO IMPORT ATTACK - NO ATTACK TYPE FOUND (Weapon Attack/Spell Attack)");
                               return;
                           }
                           
                           update["repeating_npcaction_" + newrowid + "_attack_type"] = attacktype;
                           if(attacktype === "Melee") {
                               update["repeating_npcaction_" + newrowid + "_attack_range"] = (desc.match(/reach (.*?),/) || ["",""])[1];
                           }
                           else {
                               update["repeating_npcaction_" + newrowid + "_attack_range"] = (desc.match(/range (.*?),/) || ["",""])[1];
                           }
                           update["repeating_npcaction_" + newrowid + "_attack_tohit"] = (desc.match(/\+(.*) to hit/) || ["",""])[1];
                           update["repeating_npcaction_" + newrowid + "_attack_target"] = (desc.match(/\.,(?!.*\.,)(.*)\. Hit:/) || ["",""])[1];
                           if(desc.toLowerCase().indexOf("damage") > -1 && npc_exception_actions.indexOf(name) === -1) {
                               update["repeating_npcaction_" + newrowid + "_attack_damage"] = (desc.match(/\(([^)]+)\)/) || ["",""])[1];
                               update["repeating_npcaction_" + newrowid + "_attack_damagetype"] = (desc.match(/\) (.*?) damage/) || ["",""])[1];
                               if((desc.match(/\(/g) || []).length > 1 && (!desc.match(/\((?!.*\()([^)]+)\)/).indexOf(" DC")[1] || desc.match(/\((?!.*\()([^)]+)\)/).indexOf(" DC")[1] === -1)) {
                                   update["repeating_npcaction_" + newrowid + "_attack_damage2"] = (desc.match(/\((?!.*\()([^)]+)\)/) || ["",""])[1];
                                   update["repeating_npcaction_" + newrowid + "_attack_damagetype2"] = (desc.match(/\)(?!.*\)) (.*?) damage/) || ["",""])[1];
                               }
                               ctest1 = desc.split("damage.")[1];
                               ctest2 = desc.split("damage, ")[1];
                               if(ctest1 && ctest1.length > 0) {
                                   update["repeating_npcaction_" + newrowid + "_description"] = ctest1.trim();
                               }
                               else if(ctest2 && ctest2.length > 0) {
                                   update["repeating_npcaction_" + newrowid + "_description"] = ctest2.trim();
                               }
                           }
                           else {
                               update["repeating_npcaction_" + newrowid + "_description"] = desc.split("Hit:")[1].trim();
                           }
                       }
                       else {
                           update["repeating_npcaction_" + newrowid + "_description"] = desc;
                       }
                   });
               }
               if(reactionsarray) {
                   update["npcreactionsflag"] = 1;
                   reactionsarray = reactionsarray.split("**");
                   reactionsarray.shift();
                   var reactionsobj = {};
                   reactionsarray.forEach(function(val, i) {
                       if (i % 2 === 1) return;
                       reactionsobj[val] = reactionsarray[i + 1];
                   });
                   _.each(reactionsobj, function(desc, name) {
                       newrowid = generateRowID();
                       update["repeating_npcreaction_" + newrowid + "_name"] = name + ".";
                       if(desc.substring(0,2) === ": " || encodeURI(desc.substring(0,2)) === ":%C2%A0") {
                           desc = desc.substring(2);
                       }
                       update["repeating_npcreaction_" + newrowid + "_desc"] = desc.trim();
                   });
               }
               if(legendaryactionsarray) {
                   update["npc_legendary_actions"] = (legendaryactionsarray.match(/\d+/) || [""])[0];
                   legendaryactionsarray = legendaryactionsarray.split("**");
                   legendaryactionsarray.shift();
                   var actionsobj = {};
                   legendaryactionsarray.forEach(function(val, i) {
                       if (i % 2 === 1) return;
                       actionsobj[val] = legendaryactionsarray[i + 1];
                   });
                   _.each(actionsobj, function(desc, name) {
                       newrowid = generateRowID();
                       update["repeating_npcaction-l_" + newrowid + "_npc_options-flag"] = "0";
                       update["repeating_npcaction-l_" + newrowid + "_name"] = name;
                       if(desc.substring(0,2) === ": " || encodeURI(desc.substring(0,2)) === ":%C2%A0") {
                           desc = desc.substring(2);
                       }
                       if(desc.indexOf(" Attack:") > -1) {
                           update["repeating_npcaction-l_" + newrowid + "_attack_flag"] = "on";
                           update["repeating_npcaction-l_" + newrowid + "_attack_display_flag"] = "Template:Attack=1";
                           update["repeating_npcaction-l_" + newrowid + "_attack_options"] = "Template:Attack=1";
                           if(desc.indexOf(" Weapon Attack:") > -1) {
                               attacktype = desc.split(" Weapon Attack:")[0];
                           }
                           else if(desc.indexOf(" Spell Attack:") > -1) {
                               attacktype = desc.split(" Spell Attack:")[0];
                           }
                           else {
                               console.log("FAILED TO IMPORT ATTACK - NO ATTACK TYPE FOUND (Weapon Attack/Spell Attack)");
                               return;
                           }
                           update["repeating_npcaction-l_" + newrowid + "_attack_type"] = attacktype;
                           if(attacktype === "Melee") {
                               update["repeating_npcaction-l_" + newrowid + "_attack_range"] = (desc.match(/reach (.*?),/) || ["",""])[1];
                           }
                           else {
                               update["repeating_npcaction-l_" + newrowid + "_attack_range"] = (desc.match(/range (.*?),/) || ["",""])[1];
                           }
                           update["repeating_npcaction-l_" + newrowid + "_attack_tohit"] = (desc.match(/\+(.*) to hit/) || ["",""])[1];
                           update["repeating_npcaction-l_" + newrowid + "_attack_target"] = (desc.match(/\.,(?!.*\.,)(.*)\. Hit:/) || ["",""])[1];
                           update["repeating_npcaction-l_" + newrowid + "_attack_damage"] = (desc.match(/\(([^)]+)\)/) || ["",""])[1];
                           update["repeating_npcaction-l_" + newrowid + "_attack_damagetype"] = (desc.match(/\) (.*?) damage/) || ["",""])[1];
                           if((desc.match(/\(/g) || []).length > 1 && (!desc.match(/\((?!.*\()([^)]+)\)/).indexOf(" DC")[1] || desc.match(/\((?!.*\()([^)]+)\)/).indexOf(" DC")[1] === -1)) {
                               update["repeating_npcaction-l_" + newrowid + "_attack_damage2"] = (desc.match(/\((?!.*\()([^)]+)\)/) || ["",""])[1];
                               update["repeating_npcaction-l_" + newrowid + "_attack_damagetype2"] = (desc.match(/\)(?!.*\)) (.*?) damage/) || ["",""])[1];
                           }
                       }
                       else {
                           update["repeating_npcaction-l_" + newrowid + "_description"] = desc;
                       }
                   });
               }
               setAttrs(update);
           }
       });
   });
   on("change:spellcasting_ability change:strength change:dexterity change:constitution change:intelligence change:wisdom change:charisma", function() {
       getSectionIDs("repeating_attack", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_attack_" + currentID + "_updateflag"], function(v) {
                   update = {};
                   toggle = v["repeating_attack_" + currentID + "_updateflag"] === true ? false : true;
                   update["repeating_attack_" + currentID + "_updateflag"] = toggle;
                   setAttrs(update);
               });
           });
       });
   });
   on("change:globalsavemod", function() {
       getAttrs(["globalsavemod"], function(v) {
           bonus = v.globalsavemod && v.globalsavemod != "" ? "+@{globalsavemod}[UNIV]" : "";
           setAttrs({globalsavingthrowbonus: bonus});
       });
   });
   on("change:halflingluck_flag", function() {
       getAttrs(["halflingluck_flag"], function(v) {
           toggle = v.halflingluck_flag && v.halflingluck_flag === "1" ? "ro<1" : "";
           setAttrs({halflingluck: toggle});
       });
   });
   on("change:weighttotal change:encumberance_setting change:strength", function() {
       getAttrs(["weighttotal","encumberance_setting","strength"], function(v) {
           var update = {};
           var str = parseInt(v.strength, 10);
           var weight = parseInt(v.weighttotal, 10);
           if(!v.encumberance_setting || v.encumberance_setting === "on") {
               if(weight > str*15) {
                   update["encumberance"] = "IMMOBILE";
               }
               else if(weight > str*10) {
                   update["encumberance"] = "HEAVILY ENCUMBERED";
               }
               else if(weight > str*5) {
                   update["encumberance"] = "ENCUMBERED";
               }
               else {
                   update["encumberance"] = " ";
               }
           }
           else {
               if(weight > str*15) {
                   update["encumberance"] = "OVER CARRYING CAPACITY";
               }
               else {
                   update["encumberance"] = " ";
               }
           }
           setAttrs(update);
       });
   });
   on("change:repeating_inventory:useasresource change:repeating_inventory:itemcount change:repeating_inventory:itemname", function(eventinfo) {
       itemid = eventinfo.sourceAttribute.substring(20, 40);
       sourcetype = eventinfo.sourceType;
       var update = {};
       var newrowid = generateRowID();
       getAttrs(["repeating_inventory_itemresourceid","repeating_inventory_useasresource","repeating_inventory_itemcount","repeating_inventory_itemname","repeating_inventory_itemattackid"], function(v) {
           var count = v["repeating_inventory_itemcount"] && v["repeating_inventory_itemcount"] != "" ? v["repeating_inventory_itemcount"] : 0;
           var name = v["repeating_inventory_itemname"] && v["repeating_inventory_itemname"] != "" ? v["repeating_inventory_itemname"] : "";
           if(v.repeating_inventory_useasresource && v.repeating_inventory_useasresource === "1") {
               if(v.repeating_inventory_itemresourceid && v.repeating_inventory_itemresourceid != "") {
                   if(sourcetype && sourcetype === "player") {
                       if(v.repeating_inventory_itemresourceid === "other_resource") {
                           update["other_resource"] = count;
                           update["other_resource_name"] = name;
                       }
                       else {
                           update["repeating_resource_" + v.repeating_inventory_itemresourceid] = count;
                           update["repeating_resource_" + v.repeating_inventory_itemresourceid + "_name"] = name;
                       }
                       setAttrs(update, {silent: true});
                   }
               }
               else {
                   getAttrs(["other_resource_name"], function(x) {
                       if(x.other_resource_name && x.other_resource_name != "") {
                           getSectionIDs("repeating_resource", function(idarray) {
                               if(idarray.length > 0) {
                                   var match = false;
                                   _.each(idarray, function(currentID, i) {
                                       getAttrs(["repeating_resource_" + currentID + "_resource_left_name","repeating_resource_" + currentID + "_resource_right_name"], function(y) {
                                           if((!y["repeating_resource_" + currentID + "_resource_left_name"] || y["repeating_resource_" + currentID + "_resource_left_name"] === "") && match === false) {
                                               match = true;
                                               update["repeating_inventory_itemresourceid"] = currentID + "_resource_left";
                                               update["repeating_resource_" + currentID + "_resource_left_itemid"] = itemid;
                                               update["repeating_resource_" + currentID + "_resource_left"] = count;
                                               update["repeating_resource_" + currentID + "_resource_left_name"] = name;
                                           }
                                           else if((!y["repeating_resource_" + currentID + "_resource_right_name"] || y["repeating_resource_" + currentID + "_resource_right_name"] === "") && match === false){
                                               match = true;
                                               update["repeating_inventory_itemresourceid"] = currentID + "_resource_right";
                                               update["repeating_resource_" + currentID + "_resource_right_itemid"] = itemid;
                                               update["repeating_resource_" + currentID + "_resource_right"] = count;
                                               update["repeating_resource_" + currentID + "_resource_right_name"] = name;
                                           }
                                           if(i === idarray.length - 1 && match === false) {
                                               update["repeating_inventory_itemresourceid"] = newrowid + "_resource_left";
                                               update["repeating_resource_" + newrowid + "_resource_left_itemid"] = itemid;
                                               update["repeating_resource_" + newrowid + "_resource_left"] = count;
                                               update["repeating_resource_" + newrowid + "_resource_left_name"] = name;
                                           }
                                           setAttrs(update, {silent: true});
                                       });
                                   });
                               }
                               else {
                                   update["repeating_inventory_itemresourceid"] = newrowid + "_resource_left";
                                   update["repeating_resource_" + newrowid + "_resource_left_itemid"] = itemid;
                                   update["repeating_resource_" + newrowid + "_resource_left"] = count;
                                   update["repeating_resource_" + newrowid + "_resource_left_name"] = name;
                                   setAttrs(update, {silent: true});
                               }
                           });
                       }
                       else {
                           update["repeating_inventory_itemresourceid"] = "other_resource";
                           update["other_resource_itemid"] = itemid;
                           update["other_resource"] = count;
                           update["other_resource_name"] = name;
                           setAttrs(update, {silent: true});
                       }
                   });
               }
           }
           else {
               if(v.repeating_inventory_itemresourceid && v.repeating_inventory_itemresourceid != "") {
                   update["repeating_inventory_itemresourceid"] = "";
                   if(v.repeating_inventory_itemresourceid === "other_resource") {
                       update["other_resource"] = "";
                       update["other_resource_name"] = "";
                       update["other_resource_max"] = "";
                   }
                   else {
                       update["repeating_resource_" + v.repeating_inventory_itemresourceid] = "";
                       update["repeating_resource_" + v.repeating_inventory_itemresourceid + "_name"] = "";
                       update["repeating_resource_" + v.repeating_inventory_itemresourceid + "_max"] = "";
                   }
                   setAttrs(update, {silent: true});
               }
           }
           if(sourcetype && sourcetype === "player" && v["repeating_inventory_itemattackid"] && v["repeating_inventory_itemattackid"] != "") {
               update["repeating_attack_" + v["repeating_inventory_itemattackid"] + "_atkname_base"] = name;
               setAttrs(update);
           }
       });
   });
   on("change:other_resource change:other_resource_name change:repeating_resource:resource_left change:repeating_resource:resource_left_name change:repeating_resource:resource_right change:repeating_resource:resource_right_name", function(eventinfo) {
       if(eventinfo.sourceType && eventinfo.sourceType === "player") {
           var update = {};
           if(eventinfo.sourceAttribute === "other_resource") {
               getAttrs(["other_resource_itemid","other_resource","other_resource_name"], function(v) {
                   update["repeating_inventory_" + v["other_resource_itemid"] + "_itemcount"] = v["other_resource"];
                   update["repeating_inventory_" + v["other_resource_itemid"] + "_itemname"] = v["other_resource_name"];
                   setAttrs(update, {silent: true});
               });
           }
           else if(eventinfo.sourceAttribute.indexOf("left") > -1) {
               getAttrs(["repeating_resource_resource_left_itemid","repeating_resource_resource_left","repeating_resource_resource_left_name"], function(v) {
                   update["repeating_inventory_" + v["repeating_resource_resource_left_itemid"] + "_itemcount"] = v["repeating_resource_resource_left"];
                   update["repeating_inventory_" + v["repeating_resource_resource_left_itemid"] + "_itemname"] = v["repeating_resource_resource_left_name"];
                   setAttrs(update, {silent: true});
               });
           }
           else if(eventinfo.sourceAttribute.indexOf("right") > -1) {
               getAttrs(["repeating_resource_resource_right_itemid","repeating_resource_resource_right","repeating_resource_resource_right_name"], function(v) {
                   update["repeating_inventory_" + v["repeating_resource_resource_right_itemid"] + "_itemcount"] = v["repeating_resource_resource_right"];
                   update["repeating_inventory_" + v["repeating_resource_resource_right_itemid"] + "_itemname"] = v["repeating_resource_resource_right_name"];
                   setAttrs(update, {silent: true});
               });
           }
       }
   });
   on("change:repeating_attack:savedc", function() {
       getAttrs(["repeating_attack_savedc"], function(v) {
           var update = {};
           if(v.repeating_attack_savedc && v.repeating_attack_savedc === "(@{saveflat})") {
               update["repeating_attack_flatflag"] = "show";
           }
           else {
               update["repeating_attack_flatflag"] = "hide";
           }
           setAttrs(update);
       });
   });
   on("change:charname_output change:globalmagicmod", function() {
       force_refresh_attacks();
   });
   on("change:rtype", function() {
       var update = {};
       getAttrs(["rtype"], function(v) {
           if(v.rtype && v.rtype === "@{advantagetoggle}") {
               update["toggleflag"] = "show";
           }
           else {
               update["toggleflag"] = "hide";
           }
           setAttrs(update);
       });
   });
   on("change:npc_spelldc change:npc_spellattackmod change:spellcasting_ability ", function() {
       force_refresh_spells();
   });
   on("change:ammotracking", function() {
       getAttrs(["ammotracking"], function(v) {
           if(v["ammotracking"] && v["ammotracking"] === "on") {
               setAttrs({ammoflag: "show"});
           }
           else {
               setAttrs({ammoflag: "hide"});
           }
       });
   });
   on("change:npc_name", function() {
       getAttrs(["npc"], function(v) {
           if(v["npc"] != 1) {
               setAttrs({
                   npc: "1",
                   npc_toggle: "1"
               });
           }
       });
   });
   on("sheet:compendium-drop", function() {
       setAttrs({dtype: "full"});
       getAttrs(["hp_max","npc_senses","token_size"], function(v) {
           var lr = "";
           var tokenwidth = 70;
           var tokenheight = 70;
           if(v["npc_senses"].toLowerCase().match(/(darkvision|blindsight|tremorsense|truesight)/)) {
               lr = Math.max.apply(Math, v["npc_senses"].match(/\d+/g));
           }
           if(v["token_size"]) {
               var squarelength = 70;
               if(v["token_size"].indexOf(",") > -1) {
                   var setwidth = !isNaN(v["token_size"].split(",")[0]) ? v["token_size"].split(",")[0] : 1;
                   var setheight = !isNaN(v["token_size"].split(",")[1]) ? v["token_size"].split(",")[1] : 1;
                   tokenwidth = setwidth * squarelength;
                   tokenheight = setheight * squarelength;
               } 
               else {
                   tokenwidth = squarelength * v["token_size"]
                   tokenheight = squarelength * v["token_size"]
               };
           }
           setDefaultToken({
               width: tokenwidth,
               height: tokenheight,
               bar2_link: "npc_ac",
               bar1_value: v["hp_max"],
               bar1_max: v["hp_max"],
               showname: true,
               light_radius: lr,
               light_hassight: true
           })
       });
   });
   var updateitemweight = function() {
       var wtotal = 0;
       getAttrs(["cp","sp","ep","gp","pp"], function(v) {
           cp = isNaN(parseInt(v.cp, 10)) === false ? parseInt(v.cp, 10) : 0;
           sp = isNaN(parseInt(v.sp, 10)) === false ? parseInt(v.sp, 10) : 0;
           ep = isNaN(parseInt(v.ep, 10)) === false ? parseInt(v.ep, 10) : 0;
           gp = isNaN(parseInt(v.gp, 10)) === false ? parseInt(v.gp, 10) : 0;
           pp = isNaN(parseInt(v.pp, 10)) === false ? parseInt(v.pp, 10) : 0;
           wtotal = wtotal + ((cp + sp + ep + gp + pp) / 50);
           getSectionIDs("repeating_inventory", function(idarray) {
               if(idarray.length > 0) {
                   _.each(idarray, function(currentID, i) {
                       getAttrs(["repeating_inventory_" + currentID + "_itemweight", "repeating_inventory_" + currentID + "_itemcount"], function(v) {
                           if(v["repeating_inventory_" + currentID + "_itemweight"] && isNaN(parseInt(v["repeating_inventory_" + currentID + "_itemweight"], 10)) === false) {
                               count = v["repeating_inventory_" + currentID + "_itemcount"] && isNaN(parseFloat(v["repeating_inventory_" + currentID + "_itemcount"])) === false ? parseFloat(v["repeating_inventory_" + currentID + "_itemcount"]) : 1;
                               wtotal = wtotal + (parseFloat(v["repeating_inventory_" + currentID + "_itemweight"]) * count);
                           }
                           if(i === idarray.length - 1) {
                               setAttrs({weighttotal: wtotal});
                           }
                       });
                   });
               }
               else {
                   setAttrs({weighttotal: wtotal});
               }
               
           });
       });
   }
   var updateac = function() {
       var itemtypes = [];
       getSectionIDs("repeating_inventory", function(idarray) {
           if(idarray.length > 0) {
               _.each(idarray, function(currentID, i) {
                   getAttrs(["repeating_inventory_" + currentID + "_itemtype","repeating_inventory_" + currentID + "_equipped"], function(x) {
                       var update = {};
                       if(x["repeating_inventory_" + currentID + "_equipped"] === "0") {
                           update["repeating_inventory_" + currentID + "_equippedflag"] = "unequipped";
                       }
                       else {
                           update["repeating_inventory_" + currentID + "_equippedflag"] = "equipped";
                       }
                       setAttrs(update);
                       if(x["repeating_inventory_" + currentID + "_itemtype"] && (!x["repeating_inventory_" + currentID + "_equipped"] || x["repeating_inventory_" + currentID + "_equipped"] === "1")) {
                           itemtypes.push(x["repeating_inventory_" + currentID + "_itemtype"].toLowerCase());
                       }
                       if(i === idarray.length - 1) {
                           armorcount = itemtypes.filter(function(item){ return item.indexOf("armor") > -1 }).length
                           shieldcount = itemtypes.filter(function(item){ return item.indexOf("shield") > -1 }).length
                           if(armorcount > 1 || shieldcount > 1) {
                               setAttrs({
                                   armorwarningflag: "show",
                                   armorwarning: "0"
                               });
                           }
                           else {
                               setAttrs({
                                   armorwarningflag: "hide",
                                   armorwarning: "0"
                               });
                               setac(itemtypes);
                           }
                       }
                   });
               })
           }
           else {
               getAttrs(["dexterity"], function(v) {
                   setAttrs({ac: 10 + Math.floor((parseInt(v.dexterity, 10) - 10) / 2)})
               });
           }
           
       });
   }
   var setac = function (itemtypes) {
       var actotal = 0;
       getSectionIDs("repeating_inventory", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_inventory_" + currentID + "_itemac","repeating_inventory_" + currentID + "_equipped","repeating_inventory_" + currentID + "_itemmodifiers","dexterity","globalacmod"], function(v) {
                   var dexmod = Math.floor((parseInt(v.dexterity, 10) - 10) / 2);
                   var globalacmod = isNaN(parseInt(v.globalacmod, 10)) === false ? parseInt(v.globalacmod, 10) : 0;
                   if(v["repeating_inventory_" + currentID + "_itemac"] && isNaN(parseInt(v["repeating_inventory_" + currentID + "_itemac"], 10)) === false && (!v["repeating_inventory_" + currentID + "_equipped"] || v["repeating_inventory_" + currentID + "_equipped"] === "1")) {
                       actotal = actotal + parseInt(v["repeating_inventory_" + currentID + "_itemac"], 10);
                   }
                   if(v["repeating_inventory_" + currentID + "_itemmodifiers"] && v["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().indexOf("ac +") > -1 && (!v["repeating_inventory_" + currentID + "_equipped"] || v["repeating_inventory_" + currentID + "_equipped"] === "1")) {
                       newac = v["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().split("ac")[1].match(/\d/);
                       actotal = actotal + parseInt(newac[0], 10);
                   }
                   if(i === idarray.length - 1) {
                       if(itemtypes.indexOf("light armor") > -1) {
                           actotal = actotal + dexmod;
                       }
                       else if(itemtypes.indexOf("medium armor") > -1) {
                           actotal = actotal + Math.min(dexmod, 2);
                       }
                       else if(itemtypes.indexOf("heavy armor") > -1) {
                           actotal = actotal;
                       }
                       else {
                           actotal = actotal + 10 + dexmod;
                       }
                       actotal = actotal + globalacmod;
                       setAttrs({ac: actotal});
                   }
               });
           })
       });
   }
   var updateglobalsave = function() {
       var savetotal = 0;
       getSectionIDs("repeating_inventory", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_inventory_" + currentID + "_itemmodifiers"], function(v) {
                   if(v["repeating_inventory_" + currentID + "_itemmodifiers"] && v["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().indexOf("saving throws +") > -1) {
                       newmod = v["repeating_inventory_" + currentID + "_itemmodifiers"].toLowerCase().split("saving throws")[1].match(/\d/);
                       savetotal = savetotal + parseInt(newmod[0], 10);
                   }
                   if(i === idarray.length - 1) {
                       setAttrs({globalsavemod: savetotal});
                   }
               });
           })
       });
   }
   var additemattack = function(id) {
       getAttrs(["repeating_inventory_itemname","repeating_inventory_itemproperties","repeating_inventory_itemmodifiers","repeating_inventory_itemdamage","repeating_inventory_itemdamage2","repeating_inventory_itemdamagetype","repeating_inventory_itemrange","repeating_inventory_itemtype"], function(v) {
           var newrowid = generateRowID();
           var newrowattrs = {};
           newrowattrs["repeating_inventory_itemattackid"] = newrowid;
           newrowattrs["repeating_attack_" + newrowid + "_itemid"] = id;
           newrowattrs["repeating_attack_" + newrowid + "_options-flag"] = "0";
           if(v.repeating_inventory_itemname && v.repeating_inventory_itemname != "") {
               newrowattrs["repeating_attack_" + newrowid + "_atkname_base"] = v.repeating_inventory_itemname;
           }
           if(v.repeating_inventory_itemdamage && v.repeating_inventory_itemdamage != "") {
               newrowattrs["repeating_attack_" + newrowid + "_dmgbase"] = v.repeating_inventory_itemdamage;
           }
           if(v.repeating_inventory_itemdamagetype && v.repeating_inventory_itemdamagetype != "") {
               newrowattrs["repeating_attack_" + newrowid + "_dmgtype"] = v.repeating_inventory_itemdamagetype;
           }
           if(v.repeating_inventory_itemrange && v.repeating_inventory_itemrange != "") {
               newrowattrs["repeating_attack_" + newrowid + "_atkrange"] = v.repeating_inventory_itemrange;
           }
           if(v.repeating_inventory_itemtype.indexOf("Melee") > -1) {
               newrowattrs["repeating_attack_" + newrowid + "_atkattr_base"] = "@{strength_mod}";
               newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = "@{strength_mod}";
           }
           else {
               newrowattrs["repeating_attack_" + newrowid + "_atkattr_base"] = "@{dexterity_mod}";
               newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = "@{dexterity_mod}";
           }
           if(v.repeating_inventory_itemmodifiers.indexOf("Attacks") > -1 && v.repeating_inventory_itemmodifiers.indexOf("Damage")) {
               newrowattrs["repeating_attack_" + newrowid + "_atkmagic"] = v.repeating_inventory_itemmodifiers.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2').substring(0,1);
           }
           setAttrs(newrowattrs);
       });
   }
   var addspellattack = function(sid) {
       getAttrs(["repeating_spell_spelloutput","repeating_spell_spellname_base","repeating_spell_spellrange","repeating_spell_spellattack","spellcasting_ability","repeating_spell_spelldamage","repeating_spell_spelldamagetype","repeating_spell_spelldamage2","repeating_spell_spelldamagetype2","repeating_spell_spellsave","repeating_spell_spellsavesuccess","repeating_spell_spellattackid","character_id","repeating_spell_spellhldie","repeating_spell_spellhldietype","repeating_spell_spellhlbonus","repeating_spell_spelldmgmod","repeating_spell_spellhealing","repeating_spell_spelllevel","npc_spellattackmod","level","npc_spelldc"], function(v) {
           var newrowid = generateRowID();
           var newrowattrs = {};
           var npcspell = sid.substring(0,4) === "-npc" ? true : false;
           newrowattrs["repeating_spell_spellattackid"] = newrowid;
           newrowattrs["repeating_spell_rollcontent"] = "%{" + v.character_id + "|repeating_attack_" + newrowid + "_attack}";
           newrowattrs["repeating_attack_" + newrowid + "_options-flag"] = "0";
           newrowattrs["repeating_attack_" + newrowid + "_atkname_base"] = v.repeating_spell_spellname_base;
           newrowattrs["repeating_attack_" + newrowid + "_spellid"] = sid;
           if(v.repeating_spell_spellrange && v.repeating_spell_spellrange != "") {
               newrowattrs["repeating_attack_" + newrowid + "_atkrange"] = v.repeating_spell_spellrange;
           }
           if(!v.repeating_spell_spellattack || v.repeating_spell_spellattack === "None") {
               newrowattrs["repeating_attack_" + newrowid + "_atkflag"] = "0";
           }
           else {
               newrowattrs["repeating_attack_" + newrowid + "_atkattr_base"] = v.spellcasting_ability.slice(0, -1);
           }
           if(v.repeating_spell_spelldamage && v.repeating_spell_spelldamage != "") {
               newrowattrs["repeating_attack_" + newrowid + "_dmgbase"] = v.repeating_spell_spelldamage;
               newrowattrs["repeating_attack_" + newrowid + "_dmgtype"] = v.repeating_spell_spelldamagetype;
               if(v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod === "Yes") {
                   newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = v.spellcasting_ability.slice(0, -1);
               }
               else {
                   newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = "0";
               }
           }
           else {
               newrowattrs["repeating_attack_" + newrowid + "_dmgflag"] = "0";
           }
           if(v.repeating_spell_spelldamage2 && v.repeating_spell_spelldamage2 != "") {
               newrowattrs["repeating_attack_" + newrowid + "_dmg2flag"] = "Template:Damage=1 Template:Dmg2flag=1";
               newrowattrs["repeating_attack_" + newrowid + "_dmg2base"] = v.repeating_spell_spelldamage2;
               newrowattrs["repeating_attack_" + newrowid + "_dmg2attr"] = "0";
               newrowattrs["repeating_attack_" + newrowid + "_dmg2type"] = v.repeating_spell_spelldamagetype2;
           }
           if(v.repeating_spell_spellsave && v.repeating_spell_spellsave != "") {
               newrowattrs["repeating_attack_" + newrowid + "_saveflag"] = "Template:Save=1 {{saveattr=@{saveattr}}} {{savedesc=@{saveeffect}}} {{savedc=[[[[@{savedc}]][SAVE]]]}}";
               newrowattrs["repeating_attack_" + newrowid + "_saveattr"] = v.repeating_spell_spellsave;
               newrowattrs["repeating_attack_" + newrowid + "_saveeffect"] = v.repeating_spell_spellsavesuccess;
           }
           if(v.repeating_spell_spellhldie && v.repeating_spell_spellhldie != "" && v.repeating_spell_spellhldietype && v.repeating_spell_spellhldietype != "") {
               var bonus = "";
               var query = "?{Cast at what level?";
               for(i = 0; i < 10-v.repeating_spell_spelllevel; i++) {
                   query = query + "|Level " + (parseInt(i, 10) + parseInt(v.repeating_spell_spelllevel, 10)) + "," + i;
               }
               query = query + "}";
               if(v.repeating_spell_spellhlbonus && v.repeating_spell_spellhlbonus != "") {
                   bonus = "+(" + v.repeating_spell_spellhlbonus + "*" + query + ")";
               }
               newrowattrs["repeating_attack_" + newrowid + "_hldmg"] = "{{hldmg=(" + v.repeating_spell_spellhldie + "*" + query + ")" + v.repeating_spell_spellhldietype + bonus + "}}";
           }
           if(v.repeating_spell_spellhealing && v.repeating_spell_spellhealing != "") {
               if(!v.repeating_spell_spelldamage || v.repeating_spell_spelldamage === "") {
                   newrowattrs["repeating_attack_" + newrowid + "_dmgflag"] = "Template:Damage=1 Template:Dmg1flag=1";
                   newrowattrs["repeating_attack_" + newrowid + "_dmgbase"] = v.repeating_spell_spellhealing;
                   newrowattrs["repeating_attack_" + newrowid + "_dmgtype"] = "Healing";
                   if(v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod === "Yes") {
                       newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = v.spellcasting_ability.slice(0, -1);
                   }
                   else {
                       newrowattrs["repeating_attack_" + newrowid + "_dmgattr"] = "0";
                   }
               } 
               else if(!v.repeating_spell_spelldamage2 || v.repeating_spell_spelldamage2 === "") {
                   newrowattrs["repeating_attack_" + newrowid + "_dmg2flag"] = "Template:Damage=1 Template:Dmg2flag=1";
                   newrowattrs["repeating_attack_" + newrowid + "_dmg2base"] = v.repeating_spell_spellhealing;
                   newrowattrs["repeating_attack_" + newrowid + "_dmg2type"] = "Healing";
                   if(v.repeating_spell_spelldmgmod && v.repeating_spell_spelldmgmod === "Yes") {
                       newrowattrs["repeating_attack_" + newrowid + "_dmg2attr"] = v.spellcasting_ability.slice(0, -1);
                   }
                   else {
                       newrowattrs["repeating_attack_" + newrowid + "_dmg2attr"] = "0";
                   }
               }
           }
           if(npcspell === true) {
               var pb = Math.ceil((v.level)/1e10) + Math.ceil((v.level)/4);
               pb = isNaN(pb) === false ? pb : 0;
               newrowattrs["repeating_attack_" + newrowid + "_atkattr_base"] = "0";
               newrowattrs["repeating_attack_" + newrowid + "_atkmod"] = v.npc_spellattackmod && isNaN(parseInt(v.npc_spellattackmod, 10)) === false ? parseInt(v.npc_spellattackmod, 10) - pb : 0 - pb;
               newrowattrs["repeating_attack_" + newrowid + "_savedc"] = "(@{saveflat})";
               newrowattrs["repeating_attack_" + newrowid + "_saveflat"] = v.npc_spelldc && isNaN(parseInt(v.npc_spelldc, 10)) === false ? parseInt(v.npc_spelldc, 10) : 0;
           }
           setAttrs(newrowattrs);
       });
   }
   var setlevel = function() {
      getAttrs(["base_level","multiclass1_flag","multiclass2_flag","multiclass3_flag","multiclass1_lvl","multiclass2_lvl","multiclass3_lvl","class","multiclass1","multiclass2","multiclass3", "arcane_fighter", "arcane_rogue", "custom_class", "cust_spellslots"], function(v) {
           var multiclass = false;
           var casterlevel = 0;
           var m1casterlevel = 0;
           var m2casterlevel = 0;
           var m3casterlevel = 0;
           var m1hitdie = "";
           var m2hitdie = "";
           var m3hitdie = "";
           var d10class = ["fighter","paladin","ranger"];
           var d8class = ["bard","cleric","druid","monk","rogue","warlock"];
           var d6class = ["sorcerer","wizard"];
           var charclass = v.custom_class && v.custom_class != "0" ? v.cust_spellslots : v.class;
           var full = ["bard","cleric","druid","sorcerer","wizard","full"];
           var half = ["paladin","ranger","half"];
           var finallevel = (v.base_level && v.base_level > 0) ? parseInt(v.base_level,10) : 1;
           
           if(v.multiclass1_flag && v.multiclass1_flag === "1") {
               finallevel = finallevel + parseInt(v.multiclass1_lvl,10); 
               multiclass = true;
               if(full.indexOf(v.multiclass1) != -1) {
                   m1casterlevel = parseInt(v.multiclass1_lvl,10)
               }
               else if(half.indexOf(v.multiclass1) != -1) {
                   m1casterlevel = Math.floor(parseInt(v.multiclass1_lvl,10)/2)
               }
               else if((v.multiclass1 === "fighter" && v.arcane_fighter === "1") || (v.multiclass1 === "rogue" && v.arcane_rogue === "1")) {
                   m1casterlevel = Math.floor(parseInt(v.multiclass1_lvl,10)/3)
               }
               if(v.multiclass1 === "barbarian") {m1hd = "12"}
               else if (d10class.indexOf(v.multiclass1) != -1) {m1hd = "10"}
               else if (d8class.indexOf(v.multiclass1) != -1) {m1hd = "8"}
               else if (d6class.indexOf(v.multiclass1) != -1) {m1hd = "6"};
               let classname = v.multiclass1; // temporary fix until we can translate query strings via i18n tools
               m1hitdie = "|" + classname.substring(0,1).toUpperCase() + classname.substring(1) + "," + m1hd;
           };
           if(v.multiclass2_flag && v.multiclass2_flag === "1") {
               finallevel = finallevel + parseInt(v.multiclass2_lvl,10); 
               multiclass = true;
               if(full.indexOf(v.multiclass2) != -1) {
                   m2casterlevel = parseInt(v.multiclass2_lvl,10)
               }
               else if(half.indexOf(v.multiclass2) != -1) {
                   m2casterlevel = Math.floor(parseInt(v.multiclass2_lvl,10)/2)
               }
               else if((v.multiclass2 === "fighter" && v.arcane_fighter === "1") || (v.multiclass2 === "rogue" && v.arcane_rogue === "1")) {
                   m2casterlevel = Math.floor(parseInt(v.multiclass2_lvl,10)/3)
               }
               if(v.multiclass2 === "barbarian") {m2hd = "12"}
               else if (d10class.indexOf(v.multiclass2) != -1) {m2hd = "10"}
               else if (d8class.indexOf(v.multiclass2) != -1) {m2hd = "8"}
               else if (d6class.indexOf(v.multiclass2) != -1) {m2hd = "6"};
               let classname = v.multiclass2; // temporary fix until we can translate query strings via i18n tools
               m2hitdie = "|" + classname.substring(0,1).toUpperCase() + classname.substring(1) + "," + m2hd;
           };
           if(v.multiclass3_flag && v.multiclass3_flag === "1") {
               finallevel = finallevel + parseInt(v.multiclass3_lvl,10); 
               multiclass = true;
               if(full.indexOf(v.multiclass3) != -1) {
                   m3casterlevel = parseInt(v.multiclass3_lvl,10)
               }
               else if(half.indexOf(v.multiclass3) != -1) {
                   m3casterlevel = Math.floor(parseInt(v.multiclass3_lvl,10)/2)
               }
               else if((v.multiclass3 === "fighter" && v.arcane_fighter === "1") || (v.multiclass3 === "rogue" && v.arcane_rogue === "1")) {
                   m3casterlevel = Math.floor(parseInt(v.multiclass3_lvl,10)/3)
               }
               if(v.multiclass3 === "barbarian") {m3hd = "12"}
               else if (d10class.indexOf(v.multiclass3) != -1) {m3hd = "10"}
               else if (d8class.indexOf(v.multiclass3) != -1) {m3hd = "8"}
               else if (d6class.indexOf(v.multiclass3) != -1) {m3hd = "6"};
               let classname = v.multiclass3; // temporary fix until we can translate query strings via i18n tools
               m3hitdie = "|" + classname.substring(0,1).toUpperCase() + classname.substring(1) + "," + m3hd;
           };
           
           if(multiclass === false) {
               if(full.indexOf(charclass.toLowerCase()) != -1) {
                   casterlevel = finallevel
               }
               else if(half.indexOf(charclass.toLowerCase()) != -1) {
                   casterlevel = finallevel === 1 ? 0 : Math.ceil(finallevel/2)
               }
               else if((charclass === "Fighter" && v.arcane_fighter === "1") || (charclass === "Rogue" && v.arcane_rogue === "1") || (charclass === "third")) {
                   casterlevel = finallevel < 3 ? 0 : Math.ceil(finallevel/3)
               }
               hitdie_final = "@{hitdietype}"
           }
           else {
               if(full.indexOf(charclass.toLowerCase()) != -1) {
                   casterlevel = parseInt(v.base_level,10)
               }
               else if(half.indexOf(charclass.toLowerCase()) != -1) {
                   casterlevel = Math.floor(parseInt(v.base_level,10)/2)
               }
               else if((charclass === "Fighter" && v.arcane_fighter === "1") || (charclass === "Rogue" && v.arcane_rogue === "1") || (charclass === "third")) {
                   casterlevel = Math.floor(parseInt(v.base_level,10)/3)
               }
               casterlevel = casterlevel + m1casterlevel + m2casterlevel + m3casterlevel
               hitdie_final = "?{Hit Die Class|" + charclass + ",@{hitdietype}" + m1hitdie + m2hitdie + m3hitdie + "}"
           }
           
           setAttrs({
              level: finallevel,
              caster_level: casterlevel,
              hitdie_final: hitdie_final
           });
           
           updateSpellSlots(casterlevel);
       });
   }
   
   var updateClass = function() {
       getAttrs(["class","base_level","custom_class","cust_classname","cust_hitdietype","cust_spellcasting_ability","cust_strength_save_prof","cust_dexterity_save_prof","cust_constitution_save_prof","cust_intelligence_save_prof","cust_wisdom_save_prof","cust_charisma_save_prof","strength_save_prof","dexterity_save_prof","constitution_save_prof","intelligence_save_prof","wisdom_save_prof","charisma_save_prof"], function(v) {
           if(v.custom_class && v.custom_class != "0") {
               setAttrs({
                   hitdietype: v.cust_hitdietype,
                   spellcasting_ability: v.cust_spellcasting_ability,
                   strength_save_prof: v.cust_strength_save_prof,
                   dexterity_save_prof: v.cust_dexterity_save_prof,
                   constitution_save_prof: v.cust_constitution_save_prof,
                   intelligence_save_prof: v.cust_intelligence_save_prof,
                   wisdom_save_prof: v.cust_wisdom_save_prof,
                   charisma_save_prof: v.cust_charisma_save_prof
               });
           }
           else {
               update = {};
               switch(v.class) {
                   case "Barbarian":
                       update["hitdietype"] = 12;
                       update["spellcasting_ability"] = "0*";
                       if(!v.strength_save_prof || v.strength_save_prof != "(@{pb})" || !v.constitution_save_prof || v.constitution_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = "(@{pb})";
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = "(@{pb})";
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = 0;
                           update["class_resource_name"] = "Rage";
                       }
                       break;
                   case "Bard":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "@{charisma_mod}+";
                       if(!v.dexterity_save_prof || v.dexterity_save_prof != "(@{pb})" || !v.charisma_save_prof || v.charisma_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = "(@{pb})";
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = "(@{pb})";
                           update["class_resource_name"] = "Bardic Inspiration";
                       }
                       break;
                   case "Cleric":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "@{wisdom_mod}+";
                       if(!v.wisdom_save_prof || v.wisdom_save_prof != "(@{pb})" || !v.charisma_save_prof || v.charisma_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = "(@{pb})";
                           update["charisma_save_prof"] = "(@{pb})";
                           update["class_resource_name"] = "Channel Divinity";
                       }
                       break;
                   case "Druid":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "@{wisdom_mod}+";
                       if(!v.wisdom_save_prof || v.wisdom_save_prof != "(@{pb})" || !v.intelligence_save_prof || v.intelligence_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = "(@{pb})";
                           update["wisdom_save_prof"] = "(@{pb})";
                           update["charisma_save_prof"] = 0;
                           update["class_resource_name"] = "Wild Shape";
                       }
                       break;
                   case "Fighter":
                       update["hitdietype"] = 10;
                       update["spellcasting_ability"] = "0*";
                       if(!v.strength_save_prof || v.strength_save_prof != "(@{pb})" || !v.constitution_save_prof || v.constitution_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = "(@{pb})";
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = "(@{pb})";
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = 0;
                           update["class_resource_name"] = "Second Wind";
                       }
                       break;
                   case "Monk":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "0*";
                       if(!v.strength_save_prof || v.strength_save_prof != "(@{pb})" || !v.dexterity_save_prof || v.dexterity_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = "(@{pb})";
                           update["dexterity_save_prof"] = "(@{pb})";
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = 0;
                           update["class_resource_name"] = "Ki";
                       }
                       break;
                   case "Paladin":
                       update["hitdietype"] = 10;
                       update["spellcasting_ability"] = "@{charisma_mod}+";
                       if(!v.wisdom_save_prof || v.wisdom_save_prof != "(@{pb})" || !v.charisma_save_prof || v.charisma_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = "(@{pb})";
                           update["charisma_save_prof"] = "(@{pb})";
                           update["class_resource_name"] = "Channel Divinity";
                       }
                       break;
                   case "Ranger":
                       update["hitdietype"] = 10;
                       update["spellcasting_ability"] = "@{wisdom_mod}+";
                       if(!v.strength_save_prof || v.strength_save_prof != "(@{pb})" || !v.dexterity_save_prof || v.dexterity_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = "(@{pb})";
                           update["dexterity_save_prof"] = "(@{pb})";
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = 0;
                       }
                       break;
                   case "Rogue":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "0*";
                       if(!v.intelligence_save_prof || v.intelligence_save_prof != "(@{pb})" || !v.dexterity_save_prof || v.dexterity_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = "(@{pb})";
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = "(@{pb})";
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = 0;
                       }
                       break;
                   case "Sorcerer":
                       update["hitdietype"] = 6;
                       update["spellcasting_ability"] = "@{charisma_mod}+";
                       if(!v.constitution_save_prof || v.constitution_save_prof != "(@{pb})" || !v.charisma_save_prof || v.charisma_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = "(@{pb})";
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = 0;
                           update["charisma_save_prof"] = "(@{pb})";
                           update["class_resource_name"] = "Sorcery Points";
                       }
                       break;
                   case "Warlock":
                       update["hitdietype"] = 8;
                       update["spellcasting_ability"] = "@{charisma_mod}+";
                       if(!v.wisdom_save_prof || v.wisdom_save_prof != "(@{pb})" || !v.charisma_save_prof || v.charisma_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = 0;
                           update["wisdom_save_prof"] = "(@{pb})";
                           update["charisma_save_prof"] = "(@{pb})";
                       }
                       break;
                   case "Wizard":
                       update["hitdietype"] = 6;
                       update["spellcasting_ability"] = "@{intelligence_mod}+";
                       if(!v.wisdom_save_prof || v.wisdom_save_prof != "(@{pb})" || !v.intelligence_save_prof || v.intelligence_save_prof != "(@{pb})") {
                           update["strength_save_prof"] = 0;
                           update["dexterity_save_prof"] = 0;
                           update["constitution_save_prof"] = 0;
                           update["intelligence_save_prof"] = "(@{pb})";
                           update["wisdom_save_prof"] = "(@{pb})";
                           update["charisma_save_prof"] = 0;
                       }
                       break;
               }
               setAttrs(update);
           };
       });
       setlevel();
   };
   
   var updateTool = function() {
       getAttrs(["repeating_tool_toolname_base","repeating_tool_toolbonus_base","repeating_tool_tool_mod","level","repeating_tool_toolattr_base","strength","dexterity","constitution","intelligence","wisdom","charisma"], function(v) {
           var pb = (Math.ceil((v.level)/1e10) + Math.ceil((v.level)/4))
           if(v.repeating_tool_toolbonus_base === "(@{pb})") {bonus = pb}
           else if(v.repeating_tool_toolbonus_base === "(@{pb}*2)") {bonus = pb*2}
           else if(v.repeating_tool_toolbonus_base === "(floor(@{pb}/2))") {bonus = Math.floor(pb/2)};
           var attr = v.repeating_tool_toolattr_base.substring(0, v.repeating_tool_toolattr_base.length - 5).substr(2).toUpperCase();
           var mod = v.repeating_tool_tool_mod && isNaN(parseInt(v.repeating_tool_tool_mod,10)) === false ? parseInt(v.repeating_tool_tool_mod,10) : 0;
           var bonus = bonus + Math.floor((parseInt(v[attr.toLowerCase()],10) - 10) / 2) + mod;
           setAttrs({
               repeating_tool_toolname: v.repeating_tool_toolname_base,
               repeating_tool_toolbonus: bonus,
               repeating_tool_toolattr: attr
           });
       });
   };
   
   var updateAttack = function(eventinfo) {
       var sourcetype = eventinfo.sourceType;
       var attackid = eventinfo.sourceAttribute.substring(17, 37);
       getAttrs(["level","repeating_attack_atkflag","repeating_attack_atkname_base","repeating_attack_atkattr_base","repeating_attack_atkmod","repeating_attack_atkprofflag","repeating_attack_atkmagic","repeating_attack_dmgflag","repeating_attack_dmgbase","repeating_attack_dmgattr","repeating_attack_dmgmod","repeating_attack_dmgtype","repeating_attack_dmg2flag","repeating_attack_dmg2base","repeating_attack_dmg2attr","repeating_attack_dmg2mod","repeating_attack_dmg2type","strength","dexterity","constitution","intelligence","wisdom","charisma","spellcasting_ability","repeating_attack_dmgcustcrit","repeating_attack_dmg2custcrit","repeating_attack_saveflag","repeating_attack_savedc","repeating_attack_saveeffect","repeating_attack_saveflat","dtype","repeating_attack_hldmg","repeating_attack_spellid","repeating_attack_atkrange","repeating_attack_itemid","globalmagicmod","repeating_attack_ammo"], function(v) {
           var update = {};
           var quietupdate = {};
           var hbonus = "";
           var hdmg1 = "";
           var hdmg2 = "";
           var dmg = "";
           var dmg2 = "";
           var rollbase = "";
           var spellattack = false;
           var magicattackmod = 0;
           var spelllevel = "";
           if(v.repeating_attack_spellid && v.repeating_attack_spellid != "") {
               spellattack = true; 
               magicattackmod = parseInt(v.globalmagicmod, 10);
               spelllevel = "{{spelllevel=" + v["repeating_attack_spellid"].split("_")[0].substr(1) + "}}";
           };
           if(v.repeating_attack_atkattr_base === "0") {atkattr_base = 0} else {atkattr_base = Math.floor((v[v.repeating_attack_atkattr_base.substring(0, v.repeating_attack_atkattr_base.length - 5).substr(2)] - 10) / 2 );};
           if(v.repeating_attack_dmgattr === "0") {dmgattr = 0} else {dmgattr = Math.floor((v[v.repeating_attack_dmgattr.substring(0, v.repeating_attack_dmgattr.length - 5).substr(2)] - 10) / 2 );};
           if(v.repeating_attack_dmg2attr === "0") {dmg2attr = 0} else {dmg2attr = Math.floor((v[v.repeating_attack_dmg2attr.substring(0, v.repeating_attack_dmg2attr.length - 5).substr(2)] - 10) / 2 );};
           var dmgbase = v.repeating_attack_dmgbase && v.repeating_attack_dmgbase != "" ? v.repeating_attack_dmgbase : 0;
           var dmg2base = v.repeating_attack_dmg2base && v.repeating_attack_dmg2base != "" ? v.repeating_attack_dmg2base : 0;
           var dmgmod = v.repeating_attack_dmgmod && isNaN(parseInt(v.repeating_attack_dmgmod,10)) === false ? parseInt(v.repeating_attack_dmgmod,10) : 0;
           var dmg2mod = v.repeating_attack_dmg2mod && isNaN(parseInt(v.repeating_attack_dmg2mod,10)) === false ? parseInt(v.repeating_attack_dmg2mod,10) : 0;
           var dmgtype = v.repeating_attack_dmgtype ? v.repeating_attack_dmgtype + " " : "";
           var dmg2type = v.repeating_attack_dmg2type ? v.repeating_attack_dmg2type + " " : "";
           var pb = v.repeating_attack_atkprofflag && v.repeating_attack_atkprofflag != 0 ? (Math.ceil((v.level)/1e10) + Math.ceil((v.level)/4)) : 0;
           var atkmod = v.repeating_attack_atkmod && v.repeating_attack_atkmod != "" ? parseInt(v.repeating_attack_atkmod,10) : 0;
           var atkmag = v.repeating_attack_atkmagic && v.repeating_attack_atkmagic != "" ? parseInt(v.repeating_attack_atkmagic,10) : 0;
           var dmgmag = isNaN(atkmag) === false && atkmag != 0 && ((v.repeating_attack_dmgflag && v.repeating_attack_dmgflag != 0) || (v.repeating_attack_dmg2flag && v.repeating_attack_dmg2flag != 0)) ? "+ " + atkmag + " Magic Bonus" : "";
           var name = v.repeating_attack_atkname_base ? v.repeating_attack_atkname_base : "-";
           if(v.repeating_attack_atkflag && v.repeating_attack_atkflag != 0) {
               bonus_mod = atkattr_base + atkmod + pb + atkmag + magicattackmod;
               plus_minus = bonus_mod > -1 ? "+" : "";
               bonus = plus_minus + bonus_mod;
           }
           else if(v.repeating_attack_saveflag && v.repeating_attack_saveflag != 0) {
               savedcattr = v.repeating_attack_savedc.indexOf("spell") > -1 ? v.spellcasting_ability : v.repeating_attack_savedc;
               savedcattr = savedcattr.replace(/^[^{]*{/,"").replace(/\_.*$/,"");
               if(v.repeating_attack_savedc && v.repeating_attack_savedc === "(@{saveflat})") {
                   var tempdc = isNaN(parseInt(v.repeating_attack_saveflat)) === false ? parseInt(v.repeating_attack_saveflat) : "0";
               }
               else {
                   var tempdc = isNaN(Math.floor((parseInt(v[savedcattr], 10) - 10) / 2) + 8 + pb) === false ? (Math.floor((parseInt(v[savedcattr], 10) - 10) / 2) + 8 + pb) : "0";
               }
               bonus = "DC" + tempdc;
           }
           else {
               bonus = "-";
           }
           if(v.repeating_attack_dmgflag && v.repeating_attack_dmgflag != 0) {
               if(spellattack === true && dmgbase.indexOf("@{level}") > -1) {
                   // SPECIAL CANTRIP DAMAGE
                   dmgdiestring = Math.round(((parseInt(v.level, 10) + 1) / 6) + 0.5).toString()
                   dmg = dmgdiestring + dmgbase.substring(dmgbase.lastIndexOf("d")) + " " + dmgtype;
               }
               else {
                   if(dmgbase === 0 && (dmgattr + dmgmod === 0)){
                       dmg = 0;
                   }
                   if(dmgbase != 0) {
                       dmg = dmgbase;
                   }
                   if(dmgbase != 0 && (dmgattr + dmgmod != 0)){
                       dmg = dmgattr + dmgmod > 0 ? dmg + "+" : dmg;
                   }
                   if(dmgattr + dmgmod != 0) {
                       dmg = dmg + (dmgattr + dmgmod);
                   }
                   dmg = dmg + " " + dmgtype;
               }
           }
           else {
               dmg = "";
           };
           if(v.repeating_attack_dmg2flag && v.repeating_attack_dmg2flag != 0) {
               if(dmg2base === 0 && (dmg2attr + dmg2mod === 0)){
                   dmg2 = 0;
               }
               if(dmg2base != 0) {
                   dmg2 = dmg2base;
               }
               if(dmg2base != 0 && (dmg2attr + dmg2mod != 0)){
                   dmg2 = dmg2attr + dmg2mod > 0 ? dmg2 + "+" : dmg2;
               }
               if(dmg2attr + dmg2mod != 0) {
                   dmg2 = dmg2 + (dmg2attr + dmg2mod);
               }
               dmg2 = dmg2 + " " + dmg2type;
           }
           else {
               dmg2 = "";
           };
           dmgspacer = v.repeating_attack_dmgflag && v.repeating_attack_dmgflag != 0 && v.repeating_attack_dmg2flag && v.repeating_attack_dmg2flag != 0 ? "+ " : "";
           crit1 = v.repeating_attack_dmgcustcrit && v.repeating_attack_dmgcustcrit != "" ? v.repeating_attack_dmgcustcrit : dmgbase;
           crit2 = v.repeating_attack_dmg2custcrit && v.repeating_attack_dmg2custcrit != "" ? v.repeating_attack_dmg2custcrit : dmg2base;
           r1 = v.repeating_attack_atkflag && v.repeating_attack_atkflag != 0 ? "1d20" : "0d20";
           r2 = v.repeating_attack_atkflag && v.repeating_attack_atkflag != 0 ? "@{rtype}" : "{{r2=[[0d20";
           if(v.repeating_attack_atkflag && v.repeating_attack_atkflag != 0) {
               if(magicattackmod != 0) {hbonus = " + " + magicattackmod + "[SPELLATK]" + hbonus};
               if(atkmag != 0) {hbonus = " + " + atkmag + "[MAGIC]" + hbonus};
               if(pb != 0) {hbonus = " + " + pb + "[PROF]" + hbonus};
               if(atkmod != 0) {hbonus = " + " + atkmod + "[MOD]" + hbonus};
               if(atkattr_base != 0) {hbonus = " + " + atkattr_base + "[" + v.repeating_attack_atkattr_base.substring(2, 5).toUpperCase() + "]" + hbonus};
           }
           else {
               hbonus = "";
           }
           if(v.repeating_attack_dmgflag && v.repeating_attack_dmgflag != 0) {
               if(atkmag != 0) {hdmg1 = " + " + atkmag + "[MAGIC]" + hdmg1};
               if(dmgmod != 0) {hdmg1 = " + " + dmgmod + "[MOD]" + hdmg1};
               if(dmgattr != 0) {hdmg1 = " + " + dmgattr + "[" + v.repeating_attack_dmgattr.substring(2, 5).toUpperCase() + "]" + hdmg1};
               hdmg1 = dmgbase + hdmg1;
           }
           else {
               hdmg1 = "0";
           }
           if(v.repeating_attack_dmg2flag && v.repeating_attack_dmg2flag != 0) {
               if(dmg2mod != 0) {hdmg2 = " + " + dmg2mod + "[MOD]" + hdmg2};
               if(dmg2attr != 0) {hdmg2 = " + " + dmg2attr + "[" + v.repeating_attack_dmg2attr.substring(2, 5).toUpperCase() + "]" + hdmg2};
               hdmg2 = dmg2base + hdmg2;
           }
           else {
               hdmg2 = "0";
           }
           if(v.dtype === "full") {
               pickbase = "full";
               rollbase = "@{wtype}&{template:atkdmg} {{mod=@{atkbonus}}} {{rname=@{atkname}}} {{r1=[[@{hidden_r1base}@{halflingluck}cs>@{atkcritrange}@{hidden_atkbonus}]]}} @{hidden_r2base}@{halflingluck}cs>@{atkcritrange}@{hidden_atkbonus}]]}} @{atkflag} {{range=@{atkrange}}} @{dmgflag} {{dmg1=[[@{hidden_dmg1}]]}} {{dmg1type=@{hidden_dmg1type}}} @{dmg2flag} {{dmg2=[[@{hidden_dmg2}]]}} {{dmg2type=@{hidden_dmg2type}}} {{crit1=[[@{hidden_crit1}]]}} {{crit2=[[@{hidden_crit2}]]}} @{saveflag} {{desc=@{atk_desc}}} @{hldmg} @{spelllevel} ammo=@{ammo} @{charname_output}";
           }
           else if(v.repeating_attack_atkflag && v.repeating_attack_atkflag != 0) {
               pickbase = "pick";
               rollbase = "@{wtype}&{template:atk} {{mod=@{atkbonus}}} {{rname=[@{atkname}](~repeating_attack_attack_dmg)}} {{rnamec=[@{atkname}](~repeating_attack_attack_crit)}} {{r1=[[@{hidden_r1base}@{halflingluck}cs>@{atkcritrange}@{hidden_atkbonus}]]}} @{hidden_r2base}@{halflingluck}cs>@{atkcritrange}@{hidden_atkbonus}]]}} {{range=@{atkrange}}} {{desc=@{atk_desc}}} @{spelllevel} ammo=@{ammo} @{charname_output}";
           }
           else if(v.repeating_attack_dmgflag && v.repeating_attack_dmgflag != 0) {
               pickbase = "dmg";
               rollbase = "@{wtype}&{template:dmg} {{rname=@{atkname}}} @{atkflag} {{range=@{atkrange}}} @{dmgflag} {{dmg1=[[@{hidden_dmg1}]]}} {{dmg1type=@{hidden_dmg1type}}} @{dmg2flag} {{dmg2=[[@{hidden_dmg2}]]}} {{dmg2type=@{hidden_dmg2type}}} @{saveflag} {{desc=@{atk_desc}}} @{hldmg} @{spelllevel} ammo=@{ammo} @{charname_output}"
           }
           else {
               pickbase = "empty";
               rollbase = "@{wtype}&{template:dmg} {{rname=@{atkname}}} @{atkflag} {{range=@{atkrange}}} @{saveflag} {{desc=@{atk_desc}}} @{spelllevel} ammo=@{ammo} @{charname_output}"
           }
           update["repeating_attack_atkname"] = name;
           update["repeating_attack_atkbonus"] = bonus;
           update["repeating_attack_atkdmgtype"] = dmg + dmgspacer + dmg2 + dmgmag + " ";
           update["repeating_attack_hidden_r1base"] = r1;
           update["repeating_attack_hidden_r2base"] = r2;
           update["repeating_attack_hidden_atkbonus"] = hbonus;
           update["repeating_attack_hidden_dmg1"] = hdmg1;
           update["repeating_attack_hidden_dmg2"] = hdmg2;
           update["repeating_attack_hidden_dmg1type"] = dmgtype;
           update["repeating_attack_hidden_dmg2type"] = dmg2type;
           update["repeating_attack_hidden_crit1"] = crit1 + "[CRIT]";
           update["repeating_attack_hidden_crit2"] = crit2 + "[CRIT]";
           update["repeating_attack_hidden_pickbase"] = pickbase;
           update["repeating_attack_spelllevel"] = spelllevel;
           update["repeating_attack_rollbase"] = rollbase;
           if(sourcetype && sourcetype === "player" && v.repeating_attack_spellid && v.repeating_attack_spellid != "") {
               var spellid = v.repeating_attack_spellid;
               quietupdate["repeating_spell" + spellid + "_spellname_base"] = name;
               if(v.repeating_attack_atkrange && v.repeating_attack_atkrange != "") {
                   quietupdate["repeating_spell" + spellid + "_spellrange"] = v.repeating_attack_atkrange;
               }
               if(dmgbase && dmgbase != 0) {
                   quietupdate["repeating_spell" + spellid + "_spelldamage"] = dmgbase;
                   quietupdate["repeating_spell" + spellid + "_spelldamagetype"] = dmgtype;
               }
               if(dmg2base && dmg2base != 0) {
                   quietupdate["repeating_spell" + spellid + "_spelldamage2"] = dmg2base;
                   quietupdate["repeating_spell" + spellid + "_spelldamagetype2"] = dmg2type;
               }
               if(v.repeating_attack_saveflag && v.repeating_attack_saveflag != "0") {
                   quietupdate["repeating_spell" + spellid + "_spellsave"] = savedcattr;
                   quietupdate["repeating_spell" + spellid + "_spellsavesuccess"] = v.repeating_attack_saveeffect;
               }
           }
           if(sourcetype && sourcetype === "player" && v.repeating_attack_itemid && v.repeating_attack_itemid != "") {
               var itemid = v.repeating_attack_itemid;
               quietupdate["repeating_inventory_" + itemid + "_itemname"] = name;
           }
           setAttrs(quietupdate, {silent: true});
           setAttrs(update);
       });
   };
   
   var updateSpell = function(spellid, category, eventinfo, forceupdate) {
       var sourcetype = eventinfo ? eventinfo.sourceType : "";
       var cat = category ? "-" + category : "";
       var repid = spellid ? spellid + "_" : "";
       var update = {};
       var quietupdate = {};
       var npcspell = false;
       if((eventinfo && eventinfo.sourceAttribute && eventinfo.sourceAttribute.split("_")[1] === "spell-npc") || (category && category === "npc")) {
           npcspell = true;
       } 
       getAttrs(["npc_spellattackmod","level","npc_spelldc","repeating_spell" + cat + "_" + repid + "spellname_base","repeating_spell" + cat + "_" + repid + "spellprepared","repeating_spell" + cat + "_" + repid + "spellrange","repeating_spell" + cat + "_" + repid + "spelltarget","repeating_spell" + cat + "_" + repid + "spellattack","repeating_spell" + cat + "_" + repid + "spelldamage","repeating_spell" + cat + "_" + repid + "spelldamagetype","repeating_spell" + cat + "_" + repid + "spelldamage2","repeating_spell" + cat + "_" + repid + "spelldamagetype2","repeating_spell" + cat + "_" + repid + "spellhealing","repeating_spell" + cat + "_" + repid + "spelldmgmod","repeating_spell" + cat + "_" + repid + "spellsave","repeating_spell" + cat + "_" + repid + "spellsavesuccess","repeating_spell" + cat + "_" + repid + "spellhldie","repeating_spell" + cat + "_" + repid + "spellhldietype","repeating_spell" + cat + "_" + repid + "spellhlbonus","repeating_spell" + cat + "_" + repid + "spellattackid","character_id","repeating_spell" + cat + "_" + repid + "spelloutput","repeating_spell" + cat + "_" + repid + "spelllevel","spellcasting_ability","repeating_spell" + cat + "_" + repid + "spell_damage_progression"], function(v) {
           update["repeating_spell" + cat + "_" + repid + "spellname"] = v["repeating_spell" + cat + "_" + repid + "spellname_base"] ? v["repeating_spell" + cat + "_" + repid + "spellname_base"] : "";
           update["repeating_spell" + cat + "_" + repid + "prep"] = v["repeating_spell" + cat + "_" + repid + "spellprepared"] ? v["repeating_spell" + cat + "_" + repid + "spellprepared"] : 1;
           update["repeating_spell" + cat + "_" + repid + "spellattackinfoflag"] = v["repeating_spell" + cat + "_" + repid + "spelloutput"] && v["repeating_spell" + cat + "_" + repid + "spelloutput"] === "ATTACK" ? "show" : "hide";
           if(v["repeating_spell" + cat + "_" + repid + "spellattackid"] && v["repeating_spell" + cat + "_" + repid + "spellattackid"] != "") {
               atkid = v["repeating_spell" + cat + "_" + repid + "spellattackid"];
               quietupdate["repeating_spell" + cat + "_" + repid + "rollcontent"] = "%{" + v.character_id + "|repeating_attack_" + atkid + "_attack}";
               if((sourcetype && sourcetype === "player") || (forceupdate && forceupdate === true)) {
                   quietupdate["repeating_attack_" + atkid + "_options-flag"] = "0";
                   quietupdate["repeating_attack_" + atkid + "_atkname_base"] = v["repeating_spell" + cat + "_" + repid + "spellname_base"];
                   if(v["repeating_spell" + cat + "_" + repid + "spellrange"] && v["repeating_spell" + cat + "_" + repid + "spellrange"] != "") {
                       quietupdate["repeating_attack_" + atkid + "_atkrange"] = v["repeating_spell" + cat + "_" + repid + "spellrange"];
                   }
                   if(!v["repeating_spell" + cat + "_" + repid + "spellattack"] || v["repeating_spell" + cat + "_" + repid + "spellattack"] === "None") {
                       quietupdate["repeating_attack_" + atkid + "_atkflag"] = "0";
                   }
                   else {
                       quietupdate["repeating_attack_" + atkid + "_atkattr_base"] = v.spellcasting_ability.slice(0, -1);
                       quietupdate["repeating_attack_" + atkid + "_atkflag"] = "Template:Attack=1";
                   }
                   if(v["repeating_spell" + cat + "_" + repid + "spelldamage"] && v["repeating_spell" + cat + "_" + repid + "spelldamage"] != "") {
                       quietupdate["repeating_attack_" + atkid + "_dmgbase"] = v["repeating_spell" + cat + "_" + repid + "spelldamage"];
                       quietupdate["repeating_attack_" + atkid + "_dmgtype"] = v["repeating_spell" + cat + "_" + repid + "spelldamagetype"] ? v["repeating_spell" + cat + "_" + repid + "spelldamagetype"] : "";
                       quietupdate["repeating_attack_" + atkid + "_dmgflag"] = "Template:Damage=1 Template:Dmg1flag=1";
                       if(v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] && v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] === "Yes") {
                           quietupdate["repeating_attack_" + atkid + "_dmgattr"] = v.spellcasting_ability.slice(0, -1);
                       }
                       else {
                           quietupdate["repeating_attack_" + atkid + "_dmgattr"] = "0";
                       }
                   }
                   else {
                       quietupdate["repeating_attack_" + atkid + "_dmgflag"] = "0";
                       quietupdate["repeating_attack_" + atkid + "_dmgbase"] = "";
                       quietupdate["repeating_attack_" + atkid + "_dmgtype"] = "";
                   }
                   if(v["repeating_spell" + cat + "_" + repid + "spelldamage2"] && v["repeating_spell" + cat + "_" + repid + "spelldamage2"] != "") {
                       quietupdate["repeating_attack_" + atkid + "_dmg2flag"] = "Template:Damage=1 Template:Dmg2flag=1";
                       quietupdate["repeating_attack_" + atkid + "_dmg2base"] = v["repeating_spell" + cat + "_" + repid + "spelldamage2"];
                       quietupdate["repeating_attack_" + atkid + "_dmg2attr"] = "0";
                       quietupdate["repeating_attack_" + atkid + "_dmg2type"] = v["repeating_spell" + cat + "_" + repid + "spelldamagetype2"];
                   }
                   else {
                       quietupdate["repeating_attack_" + atkid + "_dmg2flag"] = "0";
                       quietupdate["repeating_attack_" + atkid + "_dmg2base"] = "";
                       quietupdate["repeating_attack_" + atkid + "_dmg2type"] = "";
                   }
                   if(v["repeating_spell" + cat + "_" + repid + "spellsave"] && v["repeating_spell" + cat + "_" + repid + "spellsave"] != "") {
                       quietupdate["repeating_attack_" + atkid + "_saveflag"] = "Template:Save=1 {{saveattr=@{saveattr}}} {{savedesc=@{saveeffect}}} {{savedc=[[[[@{savedc}]][SAVE]]]}}";
                       quietupdate["repeating_attack_" + atkid + "_saveattr"] = v["repeating_spell" + cat + "_" + repid + "spellsave"];
                       quietupdate["repeating_attack_" + atkid + "_saveeffect"] = v["repeating_spell" + cat + "_" + repid + "spellsavesuccess"];
                   }
                   if(v["repeating_spell" + cat + "_" + repid + "spellhldie"] && v["repeating_spell" + cat + "_" + repid + "spellhldie"] != "" && v["repeating_spell" + cat + "_" + repid + "spellhldietype"] && v["repeating_spell" + cat + "_" + repid + "spellhldietype"] != "") {
                       var bonus = "";
                       var spelllevel = v["repeating_spell" + cat + "_" + repid + "spelllevel"];
                       if(!spelllevel) {
                           spelllevel = eventinfo.sourceAttribute.split("_")[1].replace("spell-", "");
                       }
                       var query = "?{Cast at what level?";
                       for(i = 0; i < 10-spelllevel; i++) {
                           query = query + "|Level " + (parseInt(i, 10) + parseInt(spelllevel, 10)) + "," + i;
                       }
                       query = query + "}";
                       if(v["repeating_spell" + cat + "_" + repid + "spellhlbonus"] && v["repeating_spell" + cat + "_" + repid + "spellhlbonus"] != "") {
                           bonus = "+(" + v["repeating_spell" + cat + "_" + repid + "spellhlbonus"] + "*" + query + ")";
                       }
                       quietupdate["repeating_attack_" + atkid + "_hldmg"] = "{{hldmg=[[(" + v["repeating_spell" + cat + "_" + repid + "spellhldie"] + "*" + query + ")" + v["repeating_spell" + cat + "_" + repid + "spellhldietype"] + bonus + "]]}}";
                   }
                   else {
                       quietupdate["repeating_attack_" + atkid + "_hldmg"] = "";
                   }
                   if(v["repeating_spell" + cat + "_" + repid + "spellhealing"] && v["repeating_spell" + cat + "_" + repid + "spellhealing"] != "") {
                       if(!v["repeating_spell" + cat + "_" + repid + "spelldamage"] || v["repeating_spell" + cat + "_" + repid + "spelldamage"] === "") {
                           quietupdate["repeating_attack_" + atkid + "_dmgflag"] = "Template:Damage=1 Template:Dmg1flag=1";
                           quietupdate["repeating_attack_" + atkid + "_dmgbase"] = v["repeating_spell" + cat + "_" + repid + "spellhealing"];
                           quietupdate["repeating_attack_" + atkid + "_dmgtype"] = "Healing";
                           if(v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] && v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] === "Yes") {
                               quietupdate["repeating_attack_" + atkid + "_dmgattr"] = v.spellcasting_ability.slice(0, -1);
                           }
                           else {
                               quietupdate["repeating_attack_" + atkid + "_dmgattr"] = "0";
                           }
                       } 
                       else if(!v["repeating_spell" + cat + "_" + repid + "spelldamage2"] || v["repeating_spell" + cat + "_" + repid + "spelldamage2"] === "") {
                           quietupdate["repeating_attack_" + atkid + "_dmg2flag"] = "Template:Damage=1 Template:Dmg2flag=1";
                           quietupdate["repeating_attack_" + atkid + "_dmg2base"] = v["repeating_spell" + cat + "_" + repid + "spellhealing"];
                           quietupdate["repeating_attack_" + atkid + "_dmg2type"] = "Healing";
                           if(v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] && v["repeating_spell" + cat + "_" + repid + "spelldmgmod"] === "Yes") {
                               quietupdate["repeating_attack_" + atkid + "_dmg2attr"] = v.spellcasting_ability.slice(0, -1);
                           }
                           else {
                               quietupdate["repeating_attack_" + atkid + "_dmg2attr"] = "0";
                           }
                       }
                   }
                   if(npcspell === true) {
                       var pb = Math.ceil((v.level)/1e10) + Math.ceil((v.level)/4);
                       pb = isNaN(pb) === false ? pb : 0;
                       quietupdate["repeating_attack_" + atkid + "_atkattr_base"] = "0";
                       quietupdate["repeating_attack_" + atkid + "_atkmod"] = v.npc_spellattackmod && isNaN(parseInt(v.npc_spellattackmod, 10)) === false ? parseInt(v.npc_spellattackmod, 10) - pb : 0 - pb;
                       quietupdate["repeating_attack_" + atkid + "_savedc"] = "(@{saveflat})";
                       quietupdate["repeating_attack_" + atkid + "_saveflat"] = v.npc_spelldc && isNaN(parseInt(v.npc_spelldc, 10)) === false ? parseInt(v.npc_spelldc, 10) : 0;
                   }
               }
           }
           setAttrs(quietupdate, {silent: true});
           setAttrs(update);
       });
   };
   
   var updateSpellSlots = function(lvl) {
       if(lvl < 1) {
           l1 = 0; l2 = 0; l3 = 0; l4 = 0; l5 = 0; l6 = 0; l7 = 0; l8 = 0;  l9 = 0;
       }
       else {
           l1 = Math.min((lvl + 1),4);
           if(lvl < 3) {l2 = 0;} else if(lvl === 3) {l2 = 2;} else {l2 = 3;};
           if(lvl < 5) {l3 = 0;} else if(lvl === 5) {l3 = 2;} else {l3 = 3;};
           if(lvl < 7) {l4 = 0;} else if(lvl === 7) {l4 = 1;} else if(lvl === 8) {l4 = 2;} else {l4 = 3;};
           if(lvl < 9) {l5 = 0;} else if(lvl === 9) {l5 = 1;} else if(lvl < 18) {l5 = 2;} else {l5 = 3;};
           if(lvl < 11) {l6 = 0;} else if(lvl < 19) {l6 = 1;} else {l6 = 2;};
           if(lvl < 13) {l7 = 0;} else if(lvl < 20) {l7 = 1;} else {l7 = 2;};
           if(lvl < 15) {l8 = 0;} else {l8 = 1;};
           if(lvl < 17) {l9 = 0;} else {l9 = 1;};
       }
       
       setAttrs({
           lvl1_slots_total: l1,
           lvl2_slots_total: l2,
           lvl3_slots_total: l3,
           lvl4_slots_total: l4,
           lvl5_slots_total: l5,
           lvl6_slots_total: l6,
           lvl7_slots_total: l7,
           lvl8_slots_total: l8,
           lvl9_slots_total: l9
       });
   };
   
   var updateNPC = function() {
       getAttrs(["npc_name","npc_type","npc_ac","npc_actype","hp_max","npc_hpformula","npc_speed","strength","dexterity","constitution","intelligence","wisdom","charisma","npc_str_save","npc_dex_save","npc_con_save","npc_int_save","npc_wis_save","npc_cha_save","npc_acrobatics","npc_animal_handling","npc_arcana","npc_athletics","npc_deception","npc_history","npc_insight","npc_intimidation","npc_investigation","npc_medicine","npc_nature","npc_perception","npc_performance","npc_persuasion","npc_religion","npc_sleight_of_hand","npc_stealth","npc_survival","npc_vulnerabilities","npc_resistances","npc_immunities","npc_condition_immunities","npc_senses","npc_languages","npc_challenge","npc_xp","npc_legendary_actions","npcreactionsflag","npcspellcastingflag"], function(v) {
           var rollbase = "";
           var first_save = 0;
           var first_skill = 0;
           var hp_max = isNaN(parseInt(v.hp_max, 10)) === false ? parseInt(v.hp_max, 10) : 0;
           var actype = v.npc_actype && v.npc_actype != "" ? "(" + v.npc_actype + ")" : "";
           var hpformula = v.npc_hpformula && v.npc_hpformula != "" ? "(" + v.npc_hpformula + ")" : "";
           var str_mod_base = v.strength && isNaN(v.strength) === false ? Math.floor((parseInt(v.strength, 10) - 10) / 2) : 0;
           var str_mod = str_mod_base > -1 ? "(+" + str_mod_base + ")" : "(" + str_mod_base + ")"
           var dex_mod_base = v.dexterity && isNaN(v.dexterity) === false ? Math.floor((parseInt(v.dexterity, 10) - 10) / 2) : 0;
           var dex_mod = dex_mod_base > -1 ? "(+" + dex_mod_base + ")" : "(" + dex_mod_base + ")"
           var con_mod_base = v.constitution && isNaN(v.constitution) === false ? Math.floor((parseInt(v.constitution, 10) - 10) / 2) : 0;
           var con_mod = con_mod_base > -1 ? "(+" + con_mod_base + ")" : "(" + con_mod_base + ")"
           var int_mod_base = v.intelligence && isNaN(v.intelligence) === false ? Math.floor((parseInt(v.intelligence, 10) - 10) / 2) : 0;
           var int_mod = int_mod_base > -1 ? "(+" + int_mod_base + ")" : "(" + int_mod_base + ")"
           var wis_mod_base = v.wisdom && isNaN(v.wisdom) === false ? Math.floor((parseInt(v.wisdom, 10) - 10) / 2) : 0;
           var wis_mod = wis_mod_base > -1 ? "(+" + wis_mod_base + ")" : "(" + wis_mod_base + ")"
           var cha_mod_base = v.charisma && isNaN(v.charisma) === false ? Math.floor((parseInt(v.charisma, 10) - 10) / 2) : 0;
           var cha_mod = cha_mod_base > -1 ? "(+" + cha_mod_base + ")" : "(" + cha_mod_base + ")"
           if(v.npc_vulnerabilities && v.npc_vulnerabilities) {vulnerabilities_flag = 1; vulnerabilities = v.npc_vulnerabilities} else {vulnerabilities_flag = 0; vulnerabilities = 0;};
           if(v.npc_resistances && v.npc_resistances) {resistances_flag = 1; resistances = v.npc_resistances} else {resistances_flag = 0; resistances = 0;};
           if(v.npc_immunities && v.npc_immunities) {immunities_flag = 1; immunities = v.npc_immunities} else {immunities_flag = 0; immunities = 0;};
           if(v.npc_condition_immunities && v.npc_condition_immunities) {condition_immunities_flag = 1; condition_immunities = v.npc_condition_immunities} else {condition_immunities_flag = 0; condition_immunities = 0;};
           var senses = v.npc_senses && v.npc_senses != "" ? v.npc_senses : "-";
           var languages = v.npc_languages && v.npc_languages != "" ? v.npc_languages : "-";
           var challenge = v.npc_challenge && v.npc_challenge != "" ? v.npc_challenge : "-";
           var xp = v.npc_xp && v.npc_xp != "" ? "(" + v.npc_xp + " XP)" : "(-)";
           // 1 = First Entry Single Digit, 2 = First Entry Double Digit, 3 = Later Entry Single Digit, 4 = Later Entry Double Digit, 5 = Negative Bonus
           if(v.npc_str_save && v.npc_str_save != "") {str_save = parseInt(v.npc_str_save, 10); if(str_save < 0) {str_save_flag = 5} else if(first_save === 0 && str_save < 10) {str_save_flag = 1} else if(first_save === 0 && str_save > 9) {str_save_flag = 2}  else if(first_save === 1 && str_save < 10) {str_save_flag = 3} else if(first_save === 1 && str_save > 9) {str_save_flag = 4}; first_save = 1;} else {str_save_flag = 0; str_save = "";}
           if(v.npc_dex_save && v.npc_dex_save != "") {dex_save = parseInt(v.npc_dex_save, 10); if(dex_save < 0) {dex_save_flag = 5} else if(first_save === 0 && dex_save < 10) {dex_save_flag = 1} else if(first_save === 0 && dex_save > 9) {dex_save_flag = 2}  else if(first_save === 1 && dex_save < 10) {dex_save_flag = 3} else if(first_save === 1 && dex_save > 9) {dex_save_flag = 4}; first_save = 1;} else {dex_save_flag = 0; dex_save = "";}
           if(v.npc_con_save && v.npc_con_save != "") {con_save = parseInt(v.npc_con_save, 10); if(con_save < 0) {con_save_flag = 5} else if(first_save === 0 && con_save < 10) {con_save_flag = 1} else if(first_save === 0 && con_save > 9) {con_save_flag = 2}  else if(first_save === 1 && con_save < 10) {con_save_flag = 3} else if(first_save === 1 && con_save > 9) {con_save_flag = 4}; first_save = 1;} else {con_save_flag = 0; con_save = "";}
           if(v.npc_int_save && v.npc_int_save != "") {int_save = parseInt(v.npc_int_save, 10); if(int_save < 0) {int_save_flag = 5} else if(first_save === 0 && int_save < 10) {int_save_flag = 1} else if(first_save === 0 && int_save > 9) {int_save_flag = 2}  else if(first_save === 1 && int_save < 10) {int_save_flag = 3} else if(first_save === 1 && int_save > 9) {int_save_flag = 4}; first_save = 1;} else {int_save_flag = 0; int_save = "";}
           if(v.npc_wis_save && v.npc_wis_save != "") {wis_save = parseInt(v.npc_wis_save, 10); if(wis_save < 0) {wis_save_flag = 5} else if(first_save === 0 && wis_save < 10) {wis_save_flag = 1} else if(first_save === 0 && wis_save > 9) {wis_save_flag = 2}  else if(first_save === 1 && wis_save < 10) {wis_save_flag = 3} else if(first_save === 1 && wis_save > 9) {wis_save_flag = 4}; first_save = 1;} else {wis_save_flag = 0; wis_save = "";}
           if(v.npc_cha_save && v.npc_cha_save != "") {cha_save = parseInt(v.npc_cha_save, 10); if(cha_save < 0) {cha_save_flag = 5} else if(first_save === 0 && cha_save < 10) {cha_save_flag = 1} else if(first_save === 0 && cha_save > 9) {cha_save_flag = 2}  else if(first_save === 1 && cha_save < 10) {cha_save_flag = 3} else if(first_save === 1 && cha_save > 9) {cha_save_flag = 4}; first_save = 1;} else {cha_save_flag = 0; cha_save = "";}
           if(v.npc_acrobatics && v.npc_acrobatics != "") {acrobatics = parseInt(v.npc_acrobatics, 10); if(acrobatics < 0) {acrobatics_flag = 5} else if(first_skill === 0 && acrobatics < 10) {acrobatics_flag = 1} else if(first_skill === 0 && acrobatics > 9) {acrobatics_flag = 2}  else if(first_skill === 1 && acrobatics < 10) {acrobatics_flag = 3} else if(first_skill === 1 && acrobatics > 9) {acrobatics_flag = 4}; first_skill = 1;} else {acrobatics_flag = 0; acrobatics = "";}
           if(v.npc_animal_handling && v.npc_animal_handling != "") {animal_handling = parseInt(v.npc_animal_handling, 10); if(animal_handling < 0) {animal_handling_flag = 5} else if(first_skill === 0 && animal_handling < 10) {animal_handling_flag = 1} else if(first_skill === 0 && animal_handling > 9) {animal_handling_flag = 2}  else if(first_skill === 1 && animal_handling < 10) {animal_handling_flag = 3} else if(first_skill === 1 && animal_handling > 9) {animal_handling_flag = 4}; first_skill = 1;} else {animal_handling_flag = 0; animal_handling = "";}
           if(v.npc_arcana && v.npc_arcana != "") {arcana = parseInt(v.npc_arcana, 10); if(arcana < 0) {arcana_flag = 5} else if(first_skill === 0 && arcana < 10) {arcana_flag = 1} else if(first_skill === 0 && arcana > 9) {arcana_flag = 2}  else if(first_skill === 1 && arcana < 10) {arcana_flag = 3} else if(first_skill === 1 && arcana > 9) {arcana_flag = 4}; first_skill = 1;} else {arcana_flag = 0; arcana = "";}
           if(v.npc_athletics && v.npc_athletics != "") {athletics = parseInt(v.npc_athletics, 10); if(athletics < 0) {athletics_flag = 5} else if(first_skill === 0 && athletics < 10) {athletics_flag = 1} else if(first_skill === 0 && athletics > 9) {athletics_flag = 2}  else if(first_skill === 1 && athletics < 10) {athletics_flag = 3} else if(first_skill === 1 && athletics > 9) {athletics_flag = 4}; first_skill = 1;} else {athletics_flag = 0; athletics = "";}
           if(v.npc_deception && v.npc_deception != "") {deception = parseInt(v.npc_deception, 10); if(deception < 0) {deception_flag = 5} else if(first_skill === 0 && deception < 10) {deception_flag = 1} else if(first_skill === 0 && deception > 9) {deception_flag = 2}  else if(first_skill === 1 && deception < 10) {deception_flag = 3} else if(first_skill === 1 && deception > 9) {deception_flag = 4}; first_skill = 1;} else {deception_flag = 0; deception = "";}
           if(v.npc_history && v.npc_history != "") {history = parseInt(v.npc_history, 10); if(history < 0) {history_flag = 5} else if(first_skill === 0 && history < 10) {history_flag = 1} else if(first_skill === 0 && history > 9) {history_flag = 2}  else if(first_skill === 1 && history < 10) {history_flag = 3} else if(first_skill === 1 && history > 9) {history_flag = 4}; first_skill = 1;} else {history_flag = 0; history = "";}
           if(v.npc_insight && v.npc_insight != "") {insight = parseInt(v.npc_insight, 10); if(insight < 0) {insight_flag = 5} else if(first_skill === 0 && insight < 10) {insight_flag = 1} else if(first_skill === 0 && insight > 9) {insight_flag = 2}  else if(first_skill === 1 && insight < 10) {insight_flag = 3} else if(first_skill === 1 && insight > 9) {insight_flag = 4}; first_skill = 1;} else {insight_flag = 0; insight = "";}
           if(v.npc_intimidation && v.npc_intimidation != "") {intimidation = parseInt(v.npc_intimidation, 10); if(intimidation < 0) {intimidation_flag = 5} else if(first_skill === 0 && intimidation < 10) {intimidation_flag = 1} else if(first_skill === 0 && intimidation > 9) {intimidation_flag = 2}  else if(first_skill === 1 && intimidation < 10) {intimidation_flag = 3} else if(first_skill === 1 && intimidation > 9) {intimidation_flag = 4}; first_skill = 1;} else {intimidation_flag = 0; intimidation = "";}
           if(v.npc_investigation && v.npc_investigation != "") {investigation = parseInt(v.npc_investigation, 10); if(investigation < 0) {investigation_flag = 5} else if(first_skill === 0 && investigation < 10) {investigation_flag = 1} else if(first_skill === 0 && investigation > 9) {investigation_flag = 2}  else if(first_skill === 1 && investigation < 10) {investigation_flag = 3} else if(first_skill === 1 && investigation > 9) {investigation_flag = 4}; first_skill = 1;} else {investigation_flag = 0; investigation = "";}
           if(v.npc_medicine && v.npc_medicine != "") {medicine = parseInt(v.npc_medicine, 10); if(medicine < 0) {medicine_flag = 5} else if(first_skill === 0 && medicine < 10) {medicine_flag = 1} else if(first_skill === 0 && medicine > 9) {medicine_flag = 2}  else if(first_skill === 1 && medicine < 10) {medicine_flag = 3} else if(first_skill === 1 && medicine > 9) {medicine_flag = 4}; first_skill = 1;} else {medicine_flag = 0; medicine = "";}
           if(v.npc_nature && v.npc_nature != "") {nature = parseInt(v.npc_nature, 10); if(nature < 0) {nature_flag = 5} else if(first_skill === 0 && nature < 10) {nature_flag = 1} else if(first_skill === 0 && nature > 9) {nature_flag = 2}  else if(first_skill === 1 && nature < 10) {nature_flag = 3} else if(first_skill === 1 && nature > 9) {nature_flag = 4}; first_skill = 1;} else {nature_flag = 0; nature = "";}
           if(v.npc_perception && v.npc_perception != "") {perception = parseInt(v.npc_perception, 10); if(perception < 0) {perception_flag = 5} else if(first_skill === 0 && perception < 10) {perception_flag = 1} else if(first_skill === 0 && perception > 9) {perception_flag = 2}  else if(first_skill === 1 && perception < 10) {perception_flag = 3} else if(first_skill === 1 && perception > 9) {perception_flag = 4}; first_skill = 1;} else {perception_flag = 0; perception = "";}
           if(v.npc_performance && v.npc_performance != "") {sperformance = parseInt(v.npc_performance, 10); if(sperformance < 0) {performance_flag = 5} else if(first_skill === 0 && sperformance < 10) {performance_flag = 1} else if(first_skill === 0 && sperformance > 9) {performance_flag = 2}  else if(first_skill === 1 && sperformance < 10) {performance_flag = 3} else if(first_skill === 1 && sperformance > 9) {performance_flag = 4}; first_skill = 1;} else {performance_flag = 0; sperformance = "";}
           if(v.npc_persuasion && v.npc_persuasion != "") {persuasion = parseInt(v.npc_persuasion, 10); if(persuasion < 0) {persuasion_flag = 5} else if(first_skill === 0 && persuasion < 10) {persuasion_flag = 1} else if(first_skill === 0 && persuasion > 9) {persuasion_flag = 2}  else if(first_skill === 1 && persuasion < 10) {persuasion_flag = 3} else if(first_skill === 1 && persuasion > 9) {persuasion_flag = 4}; first_skill = 1;} else {persuasion_flag = 0; persuasion = "";}
           if(v.npc_religion && v.npc_religion != "") {religion = parseInt(v.npc_religion, 10); if(religion < 0) {religion_flag = 5} else if(first_skill === 0 && religion < 10) {religion_flag = 1} else if(first_skill === 0 && religion > 9) {religion_flag = 2}  else if(first_skill === 1 && religion < 10) {religion_flag = 3} else if(first_skill === 1 && religion > 9) {religion_flag = 4}; first_skill = 1;} else {religion_flag = 0; religion = "";}
           if(v.npc_sleight_of_hand && v.npc_sleight_of_hand != "") {sleight_of_hand = parseInt(v.npc_sleight_of_hand, 10); if(sleight_of_hand < 0) {sleight_of_hand_flag = 5} else if(first_skill === 0 && sleight_of_hand < 10) {sleight_of_hand_flag = 1} else if(first_skill === 0 && sleight_of_hand > 9) {sleight_of_hand_flag = 2}  else if(first_skill === 1 && sleight_of_hand < 10) {sleight_of_hand_flag = 3} else if(first_skill === 1 && sleight_of_hand > 9) {sleight_of_hand_flag = 4}; first_skill = 1;} else {sleight_of_hand_flag = 0; sleight_of_hand = "";}
           if(v.npc_stealth && v.npc_stealth != "") {stealth = parseInt(v.npc_stealth, 10); if(stealth < 0) {stealth_flag = 5} else if(first_skill === 0 && stealth < 10) {stealth_flag = 1} else if(first_skill === 0 && stealth > 9) {stealth_flag = 2}  else if(first_skill === 1 && stealth < 10) {stealth_flag = 3} else if(first_skill === 1 && stealth > 9) {stealth_flag = 4}; first_skill = 1;} else {stealth_flag = 0; stealth = "";}
           if(v.npc_survival && v.npc_survival != "") {survival = parseInt(v.npc_survival, 10); if(survival < 0) {survival_flag = 5} else if(first_skill === 0 && survival < 10) {survival_flag = 1} else if(first_skill === 0 && survival > 9) {survival_flag = 2}  else if(first_skill === 1 && survival < 10) {survival_flag = 3} else if(first_skill === 1 && survival > 9) {survival_flag = 4}; first_skill = 1;} else {survival_flag = 0; survival = "";}
           leg_act = v.npc_legendary_actions && v.npc_legendary_actions != "" ? v.npc_legendary_actions : 0;
           react = v.npcreactionsflag && v.npcreactionsflag != "0" ? v.npcreactionsflag : 0;
           npcspells = v.npcspellcastingflag && v.npcspellcastingflag != "0" ? v.npcspellcastingflag : 0;
           // legendary_actions_display = "The " + v.npc_name + " can take " + leg_act + " legendary actions, choosing from the options below. Only one legendary option can be used at a time and only at the end of another creature's turn. The " + v.npc_name + " regains spent legendary actions at the start of its turn."
           setAttrs({
               npcd_name: v.npc_name,
               npcd_type: v.npc_type,
               npcd_ac: v.npc_ac,
               npcd_actype: actype,
               npcd_hp: hp_max,
               npcd_hpformula: hpformula,
               npcd_speed: v.npc_speed,
               npcd_str: v.strength,
               npcd_str_mod: str_mod,
               npcd_dex: v.dexterity,
               npcd_dex_mod: dex_mod,
               npcd_con: v.constitution,
               npcd_con_mod: con_mod,
               npcd_int: v.intelligence,
               npcd_int_mod: int_mod,
               npcd_wis: v.wisdom,
               npcd_wis_mod: wis_mod,
               npcd_cha: v.charisma,
               npcd_cha_mod: cha_mod,
               npcd_str_save: str_save,
               npc_str_save_flag: str_save_flag,
               npcd_dex_save: dex_save,
               npc_dex_save_flag: dex_save_flag,
               npcd_con_save: con_save,
               npc_con_save_flag: con_save_flag,
               npcd_int_save: int_save,
               npc_int_save_flag: int_save_flag,
               npcd_wis_save: wis_save,
               npc_wis_save_flag: wis_save_flag,
               npcd_cha_save: cha_save,
               npc_cha_save_flag: cha_save_flag,
               npc_saving_flag: first_save,
               npcd_acrobatics: acrobatics,
               npc_acrobatics_flag: acrobatics_flag,
               npcd_animal_handling: animal_handling,
               npc_animal_handling_flag: animal_handling_flag,
               npcd_arcana: arcana,
               npc_arcana_flag: arcana_flag,
               npcd_athletics: athletics,
               npc_athletics_flag: athletics_flag,
               npcd_deception: deception,
               npc_deception_flag: deception_flag,
               npcd_history: history,
               npc_history_flag: history_flag,
               npcd_insight: insight,
               npc_insight_flag: insight_flag,
               npcd_intimidation: intimidation,
               npc_intimidation_flag: intimidation_flag,
               npcd_investigation: investigation,
               npc_investigation_flag: investigation_flag,
               npcd_medicine: medicine,
               npc_medicine_flag: medicine_flag,
               npcd_nature: nature,
               npc_nature_flag: nature_flag,
               npcd_perception: perception,
               npc_perception_flag: perception_flag,
               npcd_performance: sperformance,
               npc_performance_flag: performance_flag,
               npcd_persuasion: persuasion,
               npc_persuasion_flag: persuasion_flag,
               npcd_religion: religion,
               npc_religion_flag: religion_flag,
               npcd_sleight_of_hand: sleight_of_hand,
               npc_sleight_of_hand_flag: sleight_of_hand_flag,
               npcd_stealth: stealth,
               npc_stealth_flag: stealth_flag,
               npcd_survival: survival,
               npc_survival_flag: survival_flag,
               npc_skills_flag: first_skill,
               npcd_vulnerabilities: vulnerabilities,
               npc_vulnerabilities_flag: vulnerabilities_flag,
               npcd_resistances: resistances,
               npc_resistances_flag: resistances_flag,
               npcd_immunities: immunities,
               npc_immunities_flag: immunities_flag,
               npcd_condition_immunities: condition_immunities,
               npc_condition_immunities_flag: condition_immunities_flag,
               npcd_senses: senses,
               npcd_languages: languages,
               npcd_challenge: challenge,
               npcd_xp: xp,
               legendary_flag: leg_act,
               // legendary_actions_display: legendary_actions_display,
               reaction_flag: react,
               npcspell_flag: npcspells
           });
       });
   };
   
   var updateNPCaction = function(eventinfo) {
       getAttrs(["repeating_npcaction_name","repeating_npcaction_attack_flag","repeating_npcaction_attack_type","repeating_npcaction_attack_range","repeating_npcaction_attack_target","repeating_npcaction_attack_tohit","repeating_npcaction_attack_damage","repeating_npcaction_attack_damagetype","repeating_npcaction_attack_damage2","repeating_npcaction_attack_damagetype2","repeating_npcaction_description","dtype"], function(v) {
           var onhit = "";
           var damage_flag = "";
           description_flag = v.repeating_npcaction_description && v.repeating_npcaction_description != "" ? Math.max(Math.ceil(v.repeating_npcaction_description.length/57),1) : 0;
           attack_flag = v.repeating_npcaction_attack_flag && v.repeating_npcaction_attack_flag != "0" ? "Template:Attack=1" : 0;
           attack_type = v.repeating_npcaction_attack_type + " Weapon Attack:";
           tohit = v.repeating_npcaction_attack_tohit && isNaN(parseInt(v.repeating_npcaction_attack_tohit, 10)) === false ? parseInt(v.repeating_npcaction_attack_tohit, 10) : 0;
           if(v.repeating_npcaction_attack_range && v.repeating_npcaction_attack_range) {
               if(v.repeating_npcaction_attack_type === "Melee") {rangetype = "Reach";}
               else {rangetype = "Range";}
               range = ", " + rangetype + " " + v.repeating_npcaction_attack_range
           }
           else {range = "";}
           target = v.repeating_npcaction_attack_target && v.repeating_npcaction_attack_target != "" ? ", " + v.repeating_npcaction_attack_target : ""
           attack_tohitrange = "+" + tohit + range + target + ".";
           dmg1 = v.repeating_npcaction_attack_damage && v.repeating_npcaction_attack_damage != "" ? v.repeating_npcaction_attack_damage : "";
           dmg1type = v.repeating_npcaction_attack_damagetype && v.repeating_npcaction_attack_damagetype != "" ? " " + v.repeating_npcaction_attack_damagetype : "";
           dmg2 = v.repeating_npcaction_attack_damage2 && v.repeating_npcaction_attack_damage2 != "" ? v.repeating_npcaction_attack_damage2 : "";
           dmg2type = v.repeating_npcaction_attack_damagetype2 && v.repeating_npcaction_attack_damagetype2 != "" ? " " + v.repeating_npcaction_attack_damagetype2 : "";
           dmgspacer = dmg1 != "" && dmg2 != "" ? " plus " : "";
           if(dmg1 != "") {
               dmg1t = dmg1.replace(/\s/g, ).split(/d|(?=\+|\-)/g);
               dmg1t2 = isNaN(eval(dmg1t[1])) === false ? eval(dmg1t[1]) : 0;
               if(dmg1t.length < 2) {
                   onhit = onhit + dmg1t[0] + " (" + dmg1 + ")" + dmg1type + " damage";
               }
               else if(dmg1t.length < 3) {
                   onhit = onhit + Math.floor(dmg1t[0]*((dmg1t2/2)+0.5)) + " (" + dmg1 + ")" + dmg1type + " damage";
               }
               else {
                   onhit = onhit + (Math.floor(dmg1t[0]*((dmg1t2/2)+0.5))+parseInt(dmg1t[2],10)) + " (" + dmg1 + ")" + dmg1type + " damage";
               };
           };
           dmgspacer = dmg1 != "" && dmg2 != "" ? " plus " : "";
           onhit = onhit + dmgspacer;
           if(dmg2 != "") {
               dmg2t = dmg2.replace(/\s/g, ).split(/[d+]+/);
               dmg2t2 = isNaN(eval(dmg2t[1])) === false ? eval(dmg2t[1]) : 0;
               if(dmg2t.length < 2) {
                   onhit = onhit + dmg2t[0] + " (" + dmg2 + ")" + dmg2type + " damage";
               }
               else if(dmg2t.length < 3) {
                   onhit = onhit + Math.floor(dmg2t[0]*((dmg2t2/2)+0.5)) + " (" + dmg2 + ")" + dmg2type + " damage";
               }
               else {
                   onhit = onhit + (Math.floor(dmg2t[0]*((dmg2t2/2)+0.5))+parseInt(dmg2t[2],10)) + " (" + dmg2 + ")" + dmg2type + " damage";
               };
           };
           if(dmg1 != "" || dmg2 != "") {damage_flag = damage_flag + "Template:Damage=1 "};
           if(dmg1 != "") {damage_flag = damage_flag + "Template:Dmg1flag=1 "};
           if(dmg2 != "") {damage_flag = damage_flag + "Template:Dmg2flag=1 "};
           crit1 = dmg1 != "" && dmg1t.length > 1 ? dmg1t[0] + "d" + dmg1t[1] : "";
           crit2 = dmg2 != "" && dmg2t.length > 1 ? dmg2t[0] + "d" + dmg2t[1] : "";
           if(v.dtype === "full") {
               rollbase = "@{wtype}&{template:npcaction} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=@{name}}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}} {{description=@{description}}} @{charname_output}";
           }
           else if(v.repeating_npcaction_attack_flag && v.repeating_npcaction_attack_flag != "0") {
               if(eventinfo.sourceAttribute.indexOf("npcaction-l") === -1) {
                   rollbase = "@{wtype}&{template:npcatk} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=[@{name}](~repeating_npcaction_npc_dmg)}} {{rnamec=[@{name}](~repeating_npcaction_npc_crit)}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{description=@{description}}} @{charname_output}";
               }
               else {
                   rollbase = "@{wtype}&{template:npcatk} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=[@{name}](~repeating_npcaction-l_npc_dmg)}} {{rnamec=[@{name}](~repeating_npcaction-l_npc_crit)}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{description=@{description}}} @{charname_output}"
               }
           }
           else if(v.repeating_npcaction_attack_damage && v.repeating_npcaction_attack_damage != "") {
               rollbase = "@{wtype}&{template:npcdmg} @{damage_flag} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}} @{charname_output}"
           }
           else {
               rollbase = "@{wtype}&{template:npcaction} {{name=@{npc_name}}} {{rname=@{name}}} {{description=@{description}}} @{charname_output}"
           }
           
           setAttrs({
               repeating_npcaction_name_display: v.repeating_npcaction_name + ".",
               repeating_npcaction_attack_display_flag: attack_flag,
               repeating_npcaction_attack_options: attack_flag,
               repeating_npcaction_attack_type_display: attack_type,
               repeating_npcaction_attack_tohitrange: attack_tohitrange,
               repeating_npcaction_attack_onhit: onhit,
               repeating_npcaction_description_flag: description_flag,
               repeating_npcaction_damage_flag: damage_flag,
               repeating_npcaction_attack_crit: crit1,
               repeating_npcaction_attack_crit2: crit2,
               repeating_npcaction_rollbase: rollbase
           });
       });
   };
   // var updateNPCspell = function(eventinfo) {
   //     var id = eventinfo.sourceAttribute.split("_")[2];
   //     console.log(id);
   //     var update = {};
   //     var rollbase = "";
   //     getAttrs(["dtype","spellcasting_ability","npc_spelldc","character_id","npc_spellattackmod","repeating_spell-npc_"+id+"_spelloutput","repeating_spell-npc_"+id+"_spellattack","repeating_spell-npc_"+id+"_spellattack","repeating_spell-npc_"+id+"_spellname_base"], function(v) {
   //         var atk_flag = v["repeating_spell-npc_"+id+"_spellattack"] != "None" ? "Template:Attack=1 " : "";
   //         var dmg_flag = v["repeating_spell-npc_"+id+"_spelldamage"] != "" ? "Template:Damage=1 " : "";
   //         if(v["repeating_spell-npc_"+id+"_spelloutput"] === "ATTACK") {
   //             if(v.dtype === "full") {
   //                 rollbase = "@{wtype}&{template:npcaction} " + atk_flag + dmg_flag + "{{name=@{npc_name}}} {{rname=" + v["repeating_spell-npc_"+id+"_spellname_base"] + "}} {{r1=[[1d20+(@{npc_spellattackmod}+0)]]}} @{rtype}+(@{npc_spellattackmod}+0)]]}} {{dmg1=[[@{spelldamage}+0]]}} {{dmg1type=@{spelldamagetype}}} {{dmg2=[[@{spelldamage2}+0]]}} {{dmg2type=@{spelldamagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}} {{description=@{spelldescription}}}";
   //             }
   //             // else if(v.repeating_npcaction_attack_flag && v.repeating_npcaction_attack_flag != "0") {
   //             //     if(eventinfo.sourceAttribute.indexOf("npcaction-l") === -1) {
   //             //         rollbase = "@{wtype}&{template:npcatk} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=[@{name}](~repeating_npcaction_npc_dmg)}} {{rnamec=[@{name}](~repeating_npcaction_npc_crit)}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{description=@{description}}} @{charname_output}";
   //             //     }
   //             //     else {
   //             //         rollbase = "@{wtype}&{template:npcatk} @{attack_display_flag} @{damage_flag} {{name=@{npc_name}}} {{rname=[@{name}](~repeating_npcaction-l_npc_dmg)}} {{rnamec=[@{name}](~repeating_npcaction-l_npc_crit)}} {{r1=[[1d20+(@{attack_tohit}+0)]]}} @{rtype}+(@{attack_tohit}+0)]]}} {{description=@{description}}} @{charname_output}"
   //             //     }
   //             // }
   //             // else if(v.repeating_npcaction_attack_damage && v.repeating_npcaction_attack_damage != "") {
   //             //     rollbase = "@{wtype}&{template:npcdmg} @{damage_flag} {{dmg1=[[@{attack_damage}+0]]}} {{dmg1type=@{attack_damagetype}}} {{dmg2=[[@{attack_damage2}+0]]}} {{dmg2type=@{attack_damagetype2}}} {{crit1=[[@{attack_crit}+0]]}} {{crit2=[[@{attack_crit2}+0]]}} @{charname_output}"
   //             // }
   //             // else {
   //             //     rollbase = "@{wtype}&{template:npcaction} {{name=@{npc_name}}} {{rname=@{name}}} {{description=@{description}}} @{charname_output}"
   //             }
   //             update["repeating_spell-npc_"+id+"_rollbase"] = rollbase;
   //             setAttrs(update);
   //         }
   //     });
   // }
   var force_refresh_spells = function() {
       spellcats = ["cantrip","1","2","3","4","5","6","7","8","9","npc"];
       _.each(spellcats, function(cat) {
           getSectionIDs("repeating_spell-" + cat, function(idarray) {
               _.each(idarray, function(currentID, i) {
                   updateSpell(currentID,cat,"",true);
               });
           });
       })
   }
   var force_refresh_attacks = function() {
       getSectionIDs("repeating_attack", function(idarray) {
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_attack_" + currentID + "_updateflag"], function(v) {
                   var update = {};
                   var toggle = v["repeating_attack_" + currentID + "_updateflag"] === true ? false : true;
                   update["repeating_attack_" + currentID + "_updateflag"] = toggle;
                   setAttrs(update);
               });
           });
       });
   }
   var force_refresh_npcactions = function() {
       getSectionIDs("repeating_npcaction-l", function(idarray) {
           legendaryarray = idarray;
           if(legendaryarray.length > 0) {
               _.each(legendaryarray, function(currentID, i) {
                   getAttrs(["repeating_npcaction-l_" + currentID + "_updateflag"], function(v) {
                       var update_l = {};
                       var toggle_l = v["repeating_npcaction-l_" + currentID + "_updateflag"] === true ? false : true;
                       update_l["repeating_npcaction-l_" + currentID + "_updateflag"] = toggle_l;
                       setAttrs(update_l);
                   });
               });
           }
       });
           
       getSectionIDs("repeating_npcaction", function(idarray) {
           cleanarray = idarray.filter(function(el) {
               return legendaryarray.indexOf(el) < 0;
           });
           if(cleanarray.length > 0) {
               _.each(cleanarray, function(currentID, i) {
                   getAttrs(["repeating_npcaction_" + currentID + "_updateflag"], function(v) {
                       var update = {};
                       var toggle = v["repeating_npcaction_" + currentID + "_updateflag"] === true ? false : true;
                       update["repeating_npcaction_" + currentID + "_updateflag"] = toggle;
                       setAttrs(update);
                   });
               });
           }
       });
   }
   // TRANSITION SCRIPT
   on("change:is_shaped change:is_simple", function() {
       transitionCharacterSheet();
   });
   var transitionCharacterSheet = function() {
       getAttrs(['already_transitioned','is_npc','is_shaped'], function(attrs) {
           if (attrs.already_transitioned === "1") {
               console.log('do nothing, already transitioned');
               return;
           }
           setAttrs({ already_transitioned: '1' });
           if(attrs.is_npc && (attrs.is_npc === '1' || attrs.is_npc === 1)) {
               if(attrs.is_shaped === '1') {
                   transferNPCShaped();
               }
               else {
                   transferNPCSimple();
               }
           }
           else {
               transferPC(attrs.is_shaped === '1');
           }
       });
   };
   var transferNPCShaped = function() {
       getAttrs(['character_name','speed','speed_fly','speed_burrow','speed_swim','speed_climb','prolanguages','wisdom','blindsight','darkvision','tremorsense','truesight','challenge','xp','multiattack','npc_traits','lair_actions','legendary_action_notes','reactions','damage_vulnerability','damage_resistance','damage_immunity','condition_immunity'],function(attrs) {
           var updates = {},
               senses = [],
               newRowId = ;
           updates.npc = '1';
           //updates['npc_options-flag'] = 0;
           updates.npc_name = attrs.character_name;
           updates.npc_speed = attrs.speed+
               (attrs.speed_fly && attrs.speed_fly !==  ? ' | '+attrs.speed_fly+' fly' : )+
               (attrs.speed_climb && attrs.speed_climb !==  ? ' | '+attrs.speed_climb+' climb' : )+
               (attrs.speed_swim && attrs.speed_swim !==  ? ' | '+attrs.speed_swim+' swim' : )+
               (attrs.speed_burrow && attrs.speed_burrow !==  ? ' | '+attrs.speed_burrow+' burrow' : );
           updates.npc_vulnerabilities = attrs.damage_vulnerability;
           updates.npc_resistances = attrs.damage_resistance;
           updates.npc_immunities = attrs.damage_immunity;
           updates.npc_condition_immunities = attrs.condition_immunity;
           updates.npc_languages = attrs.prolanguages;
           updates.npc_senses = 'pass Perc: '+attrMod(attrs.wisdom)+
               (attrs.blindsight && attrs.blindsight !==  ? ' | blindsight: '+attrs.blindsight : )+
               (attrs.darkvision && attrs.darkvision !==  ? ' | darkvision: '+attrs.darkvision : )+
               (attrs.tremorsense && attrs.tremorsense !==  ? ' | tremorsense: '+attrs.tremorsense : )+
               (attrs.truesight && attrs.truesight !==  ? ' | truesight: '+attrs.truesight : );
           updates.npc_challenge = attrs.challenge;
           updates.npc_xp = attrs.xp;


           if(attrs.multiattack && attrs.multiattack !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'Multiattack';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.multiattack;
           }
           if(attrs.npc_traits && attrs.npc_traits !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'NPC Traits';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.npc_traits;
           }
           if(attrs.lair_actions && attrs.lair_actions !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'Lair Actions';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.lair_actions;
           }
           if(attrs.legendary_action_notes && attrs.legendary_action_notes !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'Legendary Actions Notes';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.legendary_action_notes;
               updates.npc_legendary_actions = 3;
           }
           if(attrs.reactions && attrs.reactions !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'Reactions';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.reactions;
           }
           // var npcActionBase = ['name','emote','reach','range','target','tohit','dmg','dmg_type','crit_dmg','crit_range','second_dmg','second_dmg_type','second_crit_dmg','save_dc','save_stat','save_dmg','save_dmg_type','save_success','effect','recharge'],
           //     npcActionAttrs = [];
           // // Lair Actions
           // for(var i = 0; i < 4; i++) {
           //     npcActionAttrs = npcActionAttrs.concat(npcActionBase.map(function(attr) { return 'repeating_lair_actions_'+i+'_'+attr; }));
           // }
           // getAttrs(npcActionAttrs,function(attrs) {
           //     console.log('Lair Actions');
           //     console.log(attrs);
           // });
           // // Legendary Actions
           // npcActionAttrs = [];
           // for(var i = 0; i < 4; i++) {
           //     npcActionAttrs = npcActionAttrs.concat(npcActionBase.map(function(attr) { return 'repeating_legendary_actions_'+i+'_'+attr; }));
           // }
           // getAttrs(npcActionAttrs,function(attrs) {
           //     console.log('Legendary Actions');
           //     console.log(attrs);
           // });
           // // Actions
           // npcActionAttrs = [];
           // for(var i = 0; i < 4; i++) {
           //     npcActionAttrs = npcActionAttrs.concat(npcActionBase.map(function(attr) { return 'repeating_actions_'+i+'_'+attr; }));
           // }
           // getAttrs(npcActionAttrs,function(attrs) {
           //     console.log('Actions');
           //     console.log(attrs);
           // });
           setAttrs(JSON.parse(JSON.stringify(updates)));
       });
       function attrMod(value) {
           return Math.floor((parseInt(value)-10)/2);
       }
   }
   var transferNPCSimple = function() {
       getAttrs(['npc_type','npc_size','npc_alignment','character_name','npc_hp','npc_HP_hit_dice','npc_AC_note','npc_strength','npc_dexterity','npc_constitution','npc_intelligence','npc_wisdom','npc_charisma','npc_strength_save_bonus','npc_dexterity_save_bonus','npc_constitution_save_bonus','npc_intelligence_save_bonus','npc_wisdom_save_bonus','npc_charisma_save_bonus','npc_speed','npc_speed_fly','npc_speed_climb','npc_speed_swim','npc_damage_immunity','npc_damage_resistance','npc_condition_immunity','npc_damage_vulnerability','npc_acrobatics_bonus','npc_animalhandling_bonus','npc_arcana_bonus','npc_athletics_bonus','npc_deception_bonus','npc_history_bonus','npc_insight_bonus','npc_intimidation_bonus','npc_investigation_bonus','npc_medicine_bonus','npc_nature_bonus','npc_perception_bonus','npc_performance_bonus','npc_persuasion_bonus','npc_religion_bonus','npc_sleightofhand_bonus','npc_stealth_bonus','npc_survival_bonus','npc_multiattack','npc_traits'],function(attrs) {
           var updates = {},
               newRowId = ;
           updates.npc = '1';
           //updates['npc_options-flag'] = 0;
           updates.npc_name = attrs.character_name;
           updates.hp_max = attrs.npc_hp;
           updates.npc_hpformula = attrs.npc_HP_hit_dice;
           updates.npc_actype = attrs.npc_AC_note;
           updates.npc_type = (attrs.npc_size || )+' '+(attrs.npc_type || )+(attrs.npc_alignment && attrs.npc_alignment !==  ? (attrs.npc_size || attrs.npc_type ? ', ' : )+attrs.npc_alignment : );
           updates.strength = attrs.npc_strength;
           updates.dexterity = attrs.npc_dexterity;
           updates.constitution = attrs.npc_constitution;
           updates.intelligence = attrs.npc_intelligence;
           updates.wisdom = attrs.npc_wisdom;
           updates.charisma = attrs.npc_charisma;
           updates.npc_str_save = attrs.npc_strength_save_bonus === '0' ?  : attrs.npc_strength_save_bonus;
           updates.npc_dex_save = attrs.npc_dexterity_save_bonus === '0' ?  : attrs.npc_dexterity_save_bonus;
           updates.npc_con_save = attrs.npc_constitution_save_bonus === '0' ?  : attrs.npc_constitution_save_bonus;
           updates.npc_int_save = attrs.npc_intelligence_save_bonus === '0' ?  : attrs.npc_intelligence_save_bonus;
           updates.npc_wis_save = attrs.npc_wisdom_save_bonus === '0' ?  : attrs.npc_wisdom_save_bonus;
           updates.npc_cha_save = attrs.npc_charisma_save_bonus === '0' ?  : attrs.npc_charisma_save_bonus;
           updates.npc_speed = attrs.npc_speed+
               (attrs.npc_speed_fly && attrs.npc_speed_fly !==  ? ' | '+attrs.npc_speed_fly+' fly' : )+
               (attrs.npc_speed_climb && attrs.npc_speed_climb !==  ? ' | '+attrs.npc_speed_climb+' climb' : )+
               (attrs.npc_speed_swim && attrs.npc_speed_swim !==  ? ' | '+attrs.npc_speed_swim+' swim' : );
           updates.npc_vulnerabilities = attrs.npc_damage_vulnerability === 'None' ?  : attrs.npc_damage_vulnerability;
           updates.npc_resistances = attrs.npc_damage_resistance === 'None' ?  : attrs.npc_damage_resistance;
           updates.npc_immunities = attrs.npc_damage_immunity === 'None' ?  : attrs.npc_damage_immunity;
           updates.npc_condition_immunities = attrs.npc_condition_immunity === 'None' ?  : attrs.npc_condition_immunity;
           updates.npc_acrobatics = attrs.npc_acrobatics_bonus;
           updates.npc_animal_handling = attrs.npc_animalhandling_bonus;
           updates.npc_arcana = attrs.npc_arcana_bonus;
           updates.npc_athletics = attrs.npc_athletics_bonus;
           updates.npc_deception = attrs.npc_deception_bonus;
           updates.npc_history = attrs.npc_history_bonus;
           updates.npc_insight = attrs.npc_insight_bonus;
           updates.npc_intimidation = attrs.npc_intimidation_bonus;
           updates.npc_investigation = attrs.npc_investigation_bonus;
           updates.npc_medicine = attrs.npc_medicine_bonus;
           updates.npc_nature = attrs.npc_nature_bonus;
           updates.npc_perception = attrs.npc_perception_bonus;
           updates.npc_performance = attrs.npc_performance_bonus;
           updates.npc_persuasion = attrs.npc_persuasion_bonus;
           updates.npc_religion = attrs.npc_religion_bonus;
           updates.npc_sleight_of_hand = attrs.npc_sleightofhand_bonus;
           updates.npc_stealth = attrs.npc_stealth_bonus;
           updates.npc_survival = attrs.npc_survival_bonus;
           updates.wtype = (attrs.npc_output_option && attrs.npc_output_option !== '/w GM ' ?  : '/w gm ');
           if(attrs.npc_multiattack && attrs.npc_multiattack !== ) {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'Multiattack';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.npc_multiattack;
           }
           if(attrs.npc_traits && attrs.npc_traits !==  && attrs.npc_traits !== 'None') {
               newRowId = generateRowID();
               updates['repeating_npctrait_'+newRowId+'_name'] = 'NPC Traits';
               updates['repeating_npctrait_'+newRowId+'_desc'] = attrs.npc_traits;
           }
           setAttrs(JSON.parse(JSON.stringify(updates)));
       });
       // set NPC Actions
       var npcActions = [];
       for(var i = 1; i <= 20; i++) {
           npcActions.push('npc_action_name'+i);
           npcActions.push('npc_action_type'+i);
           npcActions.push('npc_action_description'+i);
           npcActions.push('npc_action_effect'+i);
       }
       getAttrs(npcActions,function(attrs) {
           var updates = {};
           for(var i = 1; i <= 20; i++) {
               var actionName = attrs['npc_action_name'+i],
                   actionType = (attrs['npc_action_type'+i] || '(Normal Action)').trim(),
                   actionDescription = attrs['npc_action_description'+i],
                   actionEffect = attrs['npc_action_effect'+i],
                   newRowId = generateRowID();
               if(actionName && actionName !==  && ((actionDescription && actionDescription !== ) || (actionEffect && actionEffect !== ))) {
                   if(actionType && (actionType === '(Legendary Action)' || actionType === '(Lair Action)')) {
                       updates.npc_legendary_actions = '3';
                       updates['repeating_npcaction-l_'+newRowId+'_npc_options-flag'] = 0;
                       updates['repeating_npcaction-l_'+newRowId+'_name'] = actionName;
                       updates['repeating_npcaction-l_'+newRowId+'_description'] = actionType+(actionDescription && actionDescription !==  ? '\n'+actionDescription : )+(actionEffect && actionEffect !==  ? '\n'+actionEffect : );
                   }
                   else {
                       updates['repeating_npcaction_'+newRowId+'_npc_options-flag'] = 0;
                       updates['repeating_npcaction_'+newRowId+'_name'] = actionName;
                       updates['repeating_npcaction_'+newRowId+'_description'] = actionType+(actionDescription && actionDescription !==  ? '\nDescription:\n'+actionDescription : )+(actionEffect && actionEffect !==  ? '\nEffect:\n'+actionEffect : );
                   }
               }
           }
           setAttrs(updates);
       });
   };
   var transferPC = function(isShaped) {
       var classHitDice = {
           'barbarian':'d12',
           'bard':'d8',
           'cleric':'d8',
           'druid':'d8',
           'fighter':'d10',
           'monk':'d8',
           'paladin':'d10',
           'ranger':'d10',
           'rogue':'d8',
           'sorcerer': 'd6',
           'warlock': 'd8',
           'wizard': 'd6'
       };
       // set 1to1 values
       getAttrs(['temp_hp','xp','death_save_success_1','death_save_success_2','death_save_success_3','death_save_fail_1','death_save_fail_2','death_save_fail_3','inspiration','background','prolanguages','pro_weapons',(isShaped ? 'pro_armor' : 'pro_armour'),'class_features','class_abilities_and_feats','notes'], function(attrs) {
           // one-to-one mappings
           var updates = {};
           updates.hp_temp = (attrs.temp_hp && attrs.temp_hp !== '0' ? attrs.temp_hp : );
           updates.experience = (attrs.xp && attrs.xp !== '0' ? attrs.xp : 0);
           updates.deathsave_succ1 = (attrs.death_save_success_1 && attrs.death_save_success_1 !== '0' ? 'on' : 0);
           updates.deathsave_succ2 = (attrs.death_save_success_2 && attrs.death_save_success_2 !== '0' ? 'on' : 0);
           updates.deathsave_succ3 = (attrs.death_save_success_3 && attrs.death_save_success_3 !== '0' ? 'on' : 0);
           updates.deathsave_fail1 = (attrs.death_save_fail_1 && attrs.death_save_fail_1 !== '0' ? 'on' : 0);
           updates.deathsave_fail2 = (attrs.death_save_fail_2 && attrs.death_save_fail_2 !== '0' ? 'on' : 0);
           updates.deathsave_fail3 = (attrs.deathsave_fail3 && attrs.deathsave_fail3 !== '0' ? 'on' : 0);
           updates.inspiration = (attrs.inspiration && attrs.inspiration !== '0' ? 'on' : 0);
           updates.character_backstory = (attrs['background'] && attrs['background'] !==  ? attrs['background'] : );
           updates.features_and_traits = (attrs.class_features ? attrs.class_features : );
           updates.additional_feature_and_traits = (attrs.class_abilities_and_feats ? attrs.class_abilities_and_feats : );
           updates.treasure = (attrs.notes ? attrs.notes : );
           updates['background'] = ' ';
           if (isShaped) {
               updates.other_proficiencies_and_languages = (attrs.prolanguages ? attrs.prolanguages : )+(attrs.pro_weapons && attrs.pro_weapons !==  ? (attrs.prolanguages ? '\n' : )+attrs.pro_weapons : )+(attrs.pro_armor && attrs.pro_armor !==  ? (attrs.prolanguages || attrs.pro_weapons ? '\n' : )+attrs.pro_armor : );
           }
           else {
               updates.other_proficiencies_and_languages = (attrs.prolanguages ? attrs.prolanguages : )+(attrs.pro_weapons && attrs.pro_weapons !==  ? (attrs.prolanguages ? '\n' : )+attrs.pro_weapons : )+(attrs.pro_armour && attrs.pro_armour !==  ? (attrs.prolanguages || attrs.pro_weapons ? '\n' : )+attrs.pro_armour : );
           }
           updateAll(updates,'core stats/direct mapping');
       });
       // set ability proficiency checkboxes
       getAttrs(['strength_save_prof','dexterity_save_prof','constitution_save_prof','intelligence_save_prof','wisdom_save_prof','charisma_save_prof'], function (attrs) {
           var updates = {};
           _.each(attrs, function(value, key) {
               if(value !== "0") {
                   updates[key] = '(@{pb})';
               }
           });
           updateAll(updates,'ability proficiencies');
       });
       // set skill proficiency checkboxes/expertise
       getAttrs(['acrobatics_prof_exp','animal_handling_prof_exp','arcana_prof_exp','athletics_prof_exp','arcana_prof_exp','deception_prof_exp','history_prof_exp','insight_prof_exp','intimidation_prof_exp','investigation_prof_exp','medicine_prof_exp','nature_prof_exp','perception_prof_exp','performance_prof_exp','religion_prof_exp','sleight_of_hand_prof_exp','stealth_prof_exp','survival_prof_exp'], function(attrs) {
           var updates = {};
           _.each(attrs, function(value, key) {
               var skillName = key.slice(0, -9);
               switch(value) {
                   case '(2*@{PB})': //expertise
                       updates[skillName+'_type'] = '2';
                   case '@{PB}': // proficiency or expertise
                       updates[key.slice(0, -4)] = '(@{pb}*@{'+skillName+'_type'+'})';
                   break;
               }
           });
           updateAll(updates,'skill proficiencies/expertise');
       });
       // get AC value, add armor to inventory
       var baseArmorValues = ['armouractive','armouracbase','armourmagicbonus','armouractiveunarmoured','armourstealthpen','amourname','armourtype','armourspeedpen'],
           armorFields = [];
       for(var i = 1; i <= 10; i++) {
           armorFields = armorFields.concat(baseArmorValues.map(function(armorValue) { return armorValue+i; }));
       }
       armorFields.push('dexterity','constitution','wisdom','unarmoured_class_bonus');
       if (isShaped) {
           armorFields = armorFields.map(function (name) { return name.replace(/armour|amour/g,'armor'); });
       }
       getAttrs(armorFields, function(attrs) {
           var updates = {},
               armorTotal = 0,
               unarmoredTotal = 10 + attrMod(attrs.dexterity);
           // Change the spelling of armour to armor, so that this function will fork for both shaped and
           if (!isShaped) {
               _.each(attrs, function(value, key) {
                   Object.defineProperty(attrs, key.replace(/armour|amour/g,'armor'), Object.getOwnPropertyDescriptor(attrs, key));
                   delete(key);
               });
           }
           for(var i = 1; i <= 10; i++) {
               var active = (!attrs['armoractive'+i] || attrs['armoractive'+i] !== '0'),
                   unarmored = (attrs['armoractiveunarmored'+i] && attrs['armoractiveunarmored'+i] !== '0'),
                   baseAC = (parseInt(attrs['armoracbase'+i])||0),
                   magicBonusAC = (parseInt(attrs['armormagicbonus'+i])||0),
                   totalBaseAC = baseAC+magicBonusAC,
                   newRowId = generateRowID(),
                   armorTypeBonus = 0,
                   armorType = ,
                   armorTypeMod = ;
               switch (attrs['armortype'+i]) {
                   case '@{dexterity_mod} + 0.002': // light armor
                       armorTypeBonus = attrMod(attrs.dexterity);
                       armorType = 'Light Armor: ';
                       armorTypeMod = ' (DEX mod)';
                   break;
                   case '(ceil((@{dexterity_mod}-1)/1e10)*2 - floor((@{dexterity_mod}-2)/1e10)*@{dexterity_mod}) + 0.003': // medium armor
                       armorTypeBonus = attrMod(attrs.dexterity) > 1 ? 2 : attrMod(attrs.dexterity);
                       armorType = 'Medium Armor: ';
                       armorTypeMod = ' (DEX mod, max 2)';
                   break;
                   case '0.004': // heavy armor
                       armorType = 'Heavy Armor: ';
                   break;
               }
               if(active && !unarmored) {
                   armorTotal += totalBaseAC+armorTypeBonus;
               }
               else if(active && unarmored) {
                   unarmoredTotal += totalBaseAC;
               }
               if(attrs['armorname'+i] && attrs['armorname'+i] !== ) {
                   var stealthPen = (attrs['armorstealthpen'+i] && attrs['armorstealthpen'+i] !== 'No Penalty' ? 'Disadvantage Stealth' : ),
                       speedPen = (attrs['armorspeedpen'+i] && attrs['armorspeedpen'+i] !== 'No' ? ('STR '+attrs['armorspeedpen'+i].slice(-2)) : );
                   updates['repeating_inventory_'+newRowId+'_itemcount'] = 1;
                   updates['repeating_inventory_'+newRowId+'_itemname'] = attrs['armorname'+i];
                   updates['repeating_inventory_'+newRowId+'_itemproperties'] = armorType+(totalBaseAC+armorTypeBonus)+' AC';
                   updates['repeating_inventory_'+newRowId+'_itemmodifiers'] = (magicBonusAC !== 0 ? 'AC +'+magicBonusAC : );
                   updates['repeating_inventory_'+newRowId+'_itemcontent'] = '['+baseAC+(magicBonusAC !== 0 ? ' + '+magicBonusAC : )+(armorTypeMod !== ? ' + '+armorTypeBonus+armorTypeMod : )+']'+(stealthPen !==  || speedPen !==  ? '\n' : )+(stealthPen !==  ? stealthPen : )+(stealthPen !==  && speedPen !==  ? '; ' : )+(speedPen !==  ? speedPen : );
               }
           }
           if(attrs.unarmored_class_bonus === '(@{constitution_mod} + 0.002)') {
               unarmoredTotal += attrMod(attrs.constitution);
           }
           else if(attrs.unarmored_class_bonus === '(@{wisdom_mod} + 0.003)') {
               unarmoredTotal += attrMod(attrs.wisdom);
           }
           else if(attrs.unarmored_class_bonus === '(3 + 0.004)') {
               unarmoredTotal += 3;
           }
           updates['ac'] = (armorTotal > unarmoredTotal ? armorTotal : unarmoredTotal);
           updateAll(updates,'armor inventory + ac calc');
       });
       // set character levels/multiclass/hit dice
       getAttrs(['barbarian_level','bard_level','cleric_level','druid_level','figher_level','monk_level','paladin_level','ranger_level','rogue_level','sorcerer_level','warlock_level','wizard_level','hd_d6','hd_d8','hd_d10','hd_d12'], function(attrs) {
           var classLevels = [],
               updates = {},
               currentHitDice = [];
           _.each(attrs, function(value, key) {
               if(value && key.indexOf('level') !== -1 && value !== '0') {
                   classLevels.push({ 'class': key.slice(0,-6), 'level': parseInt(value)});
               }
               else if(value && value !== "0") {
                   currentHitDice.push({ 'dice': key.substr(3), 'count': parseInt(value) });
               }
           });
           if(classLevels.length > 1) {
               classLevels.sort(function(a,b) { return b['level']-a['level']; });
               updates['base_level'] = classLevels[0]['level'];
               updates['class'] = classLevels[0]['class'].substr(0,1).toUpperCase()+classLevels[0]['class'].substr(1);
               var hitDiceMax = {},
                   hitDiceMaxArray = [];
               _.each(classLevels, function(classLevel) {
                   var numHitDice = hitDiceMax[classHitDice[classLevel['class']]];
                   hitDiceMax[classHitDice[classLevel['class']]] = (!numHitDice ? classLevel['level'] : numHitDice + classLevel['level']);
               });
               _.each(hitDiceMax, function(value, key) {
                   hitDiceMaxArray.push({ 'dice': key, 'count': value });
               });
               updates['hit_dice_max'] = hitDiceMaxArray.sort(function(a,b) { return a['dice'].localeCompare(b['dice']); }).map(function(x) { return x['dice']+' '+x['count']; }).join('|');
               _.each(classLevels, function(classLevel, i) {
                   if (i > 0) {
                       updates['multiclass'+i+'_flag'] = "1";
                       updates['multiclass'+i] = classLevel['class'].substr(0,1).toUpperCase()+classLevel['class'].substr(1);
                       updates['multiclass'+i+'_lvl'] = classLevel['level'];
                   }
               });
           }
           else if(classLevels.length > 0) {
               updates['base_level'] = classLevels[0]['level'];
               updates['class'] = classLevels[0]['class'].substr(0,1).toUpperCase()+classLevels[0]['class'].substr(1);
               updates['hit_dice_max'] = classLevels[0]['level'];
           }
           if(currentHitDice.length > 1) {
               updates['hit_dice'] = currentHitDice.sort(function(a,b) { return a['dice'].localeCompare(b['dice']); }).map(function(x) { return x['dice']+' '+x['count']; }).join('|');
           }
           else if(currentHitDice.length === 1) {
               updates['hit_dice'] = currentHitDice[0]['count'];
           }
           updateAll(updates,'character levels/multclassing');
       });
       // set proficiencies
       getAttrs(['pro_tools'],function(toolAttrs) {
           var updates = {},
               tools = (toolAttrs.pro_tools || ).split(/, and|,and|and|;|:|\||,/);
           if(toolAttrs.pro_tools && toolAttrs.pro_tools.trim() !== ) {
               _.each(tools, function(tool) {
                   var newRowId = generateRowID();
                   updates['repeating_tool_'+newRowId+'_toolname_base'] = tool.trim();
                   updates['repeating_tool_'+newRowId+'_options-flag'] = '0';
               });
           }
           updateAll(updates,'tool proficiencies');
       });
       // set class/other resources
       getSectionIDs('repeating_classresources',function(classResourceIds) {
           var newRowId = ;
           if(classResourceIds.length === 0) {
               updateAll({},'class/other resources');
           }
           else expectedUpdates += (classResourceIds.length - 1);
           _.each(classResourceIds,function(repeatingId, i) {
               var classResources = ['repeating_classresources_'+repeatingId+'_classresourcename','repeating_classresources_'+repeatingId+'_classresourcerecharge','repeating_classresources_'+repeatingId+'_classresourcetotal','repeating_classresources_'+repeatingId+'_classresourcetotal_max'];
               getAttrs(classResources, function(attrs) {
                   var updates = {},
                       resourceCurrent = attrs['repeating_classresources_'+repeatingId+'_classresourcetotal'],
                       resourceMax = attrs['repeating_classresources_'+repeatingId+'_classresourcetotal_max'],
                       resourceName = attrs['repeating_classresources_'+repeatingId+'_classresourcename'];
                   if(i === 0) {
                       updates.class_resource = resourceCurrent || ;
                       updates.class_resource_max = resourceMax || ;
                       updates.class_resource_name = resourceName || ;
                   }
                   else if(i === 1) {
                       updates.other_resource = resourceCurrent || ;
                       updates.other_resource_max = resourceMax || ;
                       updates.other_resource_name = resourceName || ;
                   }
                   else if(i%2 === 0) {
                       newRowId = generateRowID();
                       updates['repeating_resource_'+newRowId+'_resource_left'] = resourceCurrent || ;
                       updates['repeating_resource_'+newRowId+'_resource_left_max'] = resourceMax || ;
                       updates['repeating_resource_'+newRowId+'_resource_left_name'] = resourceName || ;
                   }
                   else {
                       updates['repeating_resource_'+newRowId+'_resource_right'] = resourceCurrent || ;
                       updates['repeating_resource_'+newRowId+'_resource_right_max'] = resourceMax || ;
                       updates['repeating_resource_'+newRowId+'_resource_right_name'] = resourceName || ;
                   }
                   updateAll(updates,'class/other resources');
               });
           });
       });
       // transfer weapons to inventory/attacks
       var baseWeaponValues = ['pbmelee','meleeweaponname','meleeattackstat','meleemagic','meleedmg','meleedmgtype','meleeattackstatdmg','meleecritdmg','meleeweaponcritrange'],
           weaponFields = [];
       for(var i = 1; i <= 6; i++) {
           weaponFields = weaponFields.concat(baseWeaponValues.map(function(weaponValue) { return weaponValue+i; })); //melee weapons
           weaponFields = weaponFields.concat(baseWeaponValues.map(function(weaponValue) { return (weaponValue+i).replace(/melee/g,'ranged'); })); // ranged weapons
       }
       getAttrs(weaponFields,function(attrs) {
           var newRowId = ,
               updates = {},
               attackAttr = ;
           for(var i = 1; i <= 6; i++) {
               if(attrs['meleeweaponname'+i] && attrs['meleeweaponname'+i] !== ) {
                   newRowId = generateRowID();
                   updates['repeating_inventory_'+newRowId+'_itemcount'] = 1;
                   updates['repeating_inventory_'+newRowId+'_itemname'] = attrs['meleeweaponname'+i];
                   updates['repeating_inventory_'+newRowId+'_itemmodifiers'] = attrs['meleemagic'+i] && attrs['meleemagic'+i] !==  && attrs['meleemagic'+i] !== '0' ? '+'+attrs['meleemagic'+i]+' Attack/Damage' : ;
                   updates['repeating_inventory_'+newRowId+'_itemcontent'] = 'Damage: '+(attrs['meleedmg'+i]||)+' '+(attrs['meleedmgtype'+i]||)+(attrs['meleemagic'+i] && attrs['meleemagic'+i] !==  && attrs['meleemagic'+i] !== '0' ? '+'+attrs['meleemagic'+i]+' magic' : );
                   newRowId = generateRowID();
                   attackAttr = (!attrs['meleeattackstat'+i] || attrs['meleeattackstat'+i] === '@{finesse_mod}' ? '@{strength_mod}' : attrs['meleeattackstat'+i]);
                   updates['repeating_attack_'+newRowId+'_options-flag'] = 0;
                   updates['repeating_attack_'+newRowId+'_atkname_base'] = attrs['meleeweaponname'+i];
                   updates['repeating_attack_'+newRowId+'_atknattr_base'] = attackAttr;
                   updates['repeating_attack_'+newRowId+'_atkprofflag'] = !attrs['pbmelee'+i] || attrs['pbmelee'] === '@{PB}' ? '(@{pb})' : '0';
                   updates['repeating_attack_'+newRowId+'_atkmagic'] = attrs['meleemagic'+i] || ;
                   updates['repeating_attack_'+newRowId+'_dmgcustcrit'] = attrs['meleecritdmg'+i] || ;
                   updates['repeating_attack_'+newRowId+'_atkcritrange'] = attrs['meleeweaponcritrange'+i] || '20';
                   updates['repeating_attack_'+newRowId+'_dmgbase'] = attrs['meleedmg'+i] || ;
                   updates['repeating_attack_'+newRowId+'_dmgattr'] = !attrs['meleeattackstatdmg'+i] || attrs['meleeattackstatdmg'+i] === '1' ? attackAttr : '0';
                   updates['repeating_attack_'+newRowId+'_dmgtype'] = attrs['meleedmgtype'+i] || ;
               }
           }
           for(var i = 1; i <= 6; i++) {
               if(attrs['rangedweaponname'+i] && attrs['rangedweaponname'+i] !== ) {
                   newRowId = generateRowID();
                   updates['repeating_inventory_'+newRowId+'_itemcount'] = 1;
                   updates['repeating_inventory_'+newRowId+'_itemname'] = attrs['rangedweaponname'+i];
                   updates['repeating_inventory_'+newRowId+'_itemmodifiers'] = attrs['rangedmagic'+i] && attrs['rangedmagic'+i] !==  && attrs['rangedmagic'+i] !== '0' ? '+'+attrs['rangedmagic'+i]+' Attack/Damage' : ;
                   updates['repeating_inventory_'+newRowId+'_itemcontent'] = 'Damage: '+(attrs['rangeddmg'+i]||)+' '+(attrs['rangeddmgtype'+i]||)+(attrs['rangedmagic'+i] && attrs['rangedmagic'+i] !==  && attrs['rangedmagic'+i] !== '0' ? '+'+attrs['rangedmagic'+i]+' magic' : );
                   newRowId = generateRowID();
                   attackAttr = (!attrs['rangedattackstat'+i] || attrs['rangedattackstat'+i] === '@{finesse_mod}' ? '@{strength_mod}' : attrs['rangedattackstat'+i]);
                   updates['repeating_attack_'+newRowId+'_options-flag'] = 0;
                   updates['repeating_attack_'+newRowId+'_atkname_base'] = attrs['rangedweaponname'+i];
                   updates['repeating_attack_'+newRowId+'_atknattr_base'] = attackAttr;
                   updates['repeating_attack_'+newRowId+'_atkprofflag'] = !attrs['pbranged'+i] || attrs['pbranged'] === '@{PB}' ? '(@{pb})' : '0';
                   updates['repeating_attack_'+newRowId+'_atkmagic'] = attrs['rangedmagic'+i] || ;
                   updates['repeating_attack_'+newRowId+'_atkcritrange'] = attrs['rangedcritdmg'+i] || ;
                   updates['repeating_attack_'+newRowId+'_atkcritrange'] = attrs['rangedweaponcritrange'+i] || '20';
                   updates['repeating_attack_'+newRowId+'_dmgbase'] = attrs['rangeddmg'+i] || ;
                   updates['repeating_attack_'+newRowId+'_dmgattr'] = !attrs['rangedattackstatdmg'+i] || attrs['rangedattackstatdmg'+i] === '1' ? attackAttr : '0';
                   updates['repeating_attack_'+newRowId+'_dmgtype'] = attrs['rangeddmgtype'+i] || ;
               }
           }
           updateAll(updates,'weapons + weapon attacks');
       });
       // transfer inventory
       var baseInventoryValues = ['inventorycarried','inventoryqty','inventoryname','inventoryweight','inventorydescription'],
           inventoryFields = [];
       for(var i = 1; i <= 60; i++) {
           inventoryFields = inventoryFields.concat(baseInventoryValues.map(function(inventoryValue) { return inventoryValue+i; }));
       }
       getAttrs(inventoryFields,function(attrs) {
           var newRowId = ,
               updates = {};
           for(var i = 1; i <= 60; i++) {
               if((!attrs['inventorycarried'+i] || attrs['inventorycarried'+i] !== '0') && attrs['inventoryname'+i] && attrs['inventoryname'+i] !== ) {
                   newRowId = generateRowID();
                   updates['repeating_inventory_'+newRowId+'_itemcount'] = attrs['inventorycount'+i] || 1;
                   updates['repeating_inventory_'+newRowId+'_itemname'] = attrs['inventoryname'+i] || ;
                   updates['repeating_inventory_'+newRowId+'_itemweight'] = (attrs['inventoryweight'+i] && attrs['invetoryweight'+i] !== '0' ? attrs['inventoryweight'+i] : );
                   updates['repeating_inventory_'+newRowId+'_itemcontent'] = attrs['inventorydescription'+i] || ;
               }
           }
           updateAll(updates,'inventory');
       });
       function attrMod(value) {
           return Math.floor((parseInt(value)-10)/2);
       }
       var totalUpdates = 0,
           expectedUpdates = 9,
           allUpdates = {};
       function updateAll(newUpdates, updateArea) {
           console.log('update: '+updateArea);
           console.log(newUpdates);
           allUpdates = _.extend(allUpdates, newUpdates);
           totalUpdates++;
           console.log('expected: '+expectedUpdates+' vs actual: '+totalUpdates);
           if(expectedUpdates === totalUpdates) {
               console.log('expected reached, updating');
               console.log(allUpdates);
               setAttrs(allUpdates);
               allUpdates = {};
           }
       }
   };
   // /TRANSITION SCRIPT
   var upgrade_1_1_to_1_2 = function(doneupdating) {
       force_refresh_spells();
       force_refresh_attacks();
       doneupdating();
   }
   var upgrade_1_2_to_1_3 = function(doneupdating) {
       // UPGRADING SAVING THROW TOGGLE
       getSectionIDs("repeating_attack", function(idarray) {
           var update = {};
           _.each(idarray, function(currentID, i) {
               getAttrs(["repeating_attack_" + currentID + "_saveflag"], function(v) {
                   if(v["repeating_attack_" + currentID + "_saveflag"] && ["repeating_attack_" + currentID + "_saveflag"] != "0") {
                       update["repeating_attack_" + currentID + "_saveflag"] = "Template:Save=1 {{saveattr=@{saveattr}}} {{savedesc=@{saveeffect}}} {{savedc=[[[[@{savedc}]][SAVE]]]}}";
                   }
                   if(i === idarray.length - 1) {
                       setAttrs(update, {}, function() {
                           force_refresh_npcactions();
                           updateac();
                           force_refresh_spells();
                           force_refresh_attacks();
                           doneupdating();
                       });
                   }
               });
           });
       });
   }
   var upgrade_1_3_to_1_4 = function(doneupdating) {
       force_refresh_spells();
       force_refresh_attacks();
       doneupdating();
   }
   var upgrade_1_4_to_1_5 = function(doneupdating) {
       force_refresh_spells();
       force_refresh_attacks();
       doneupdating();
   }
   var upgrade_1_5_to_1_6 = function(doneupdating) {
       doneupdating();
   }
   
   var versioning = function() {
       getAttrs(["version"], function(v) {
           if(!v["version"] || v["version"] === "") {
               console.log("UPGRADING TO v1.0");
               setAttrs({version: "1.0"});
               versioning();
           }
           else if(v["version"] === "1.0") {
               console.log("UPGRADING TO v1.1");
               setAttrs({version: "1.1"});
               versioning();
           }
           else if(v["version"] === "1.1") {
               console.log("UPGRADING TO v1.2");
               upgrade_1_1_to_1_2(function() {
                   setAttrs({version: "1.2"});
                   versioning();
               });
               
           }
           else if(v["version"] === "1.2") {
               console.log("UPGRADING TO v1.3");
               upgrade_1_2_to_1_3(function() {
                   setAttrs({version: "1.3"});
                   versioning();
               });
               
           }
           else if(v["version"] === "1.3") {
               console.log("UPGRADING TO v1.4");
               upgrade_1_3_to_1_4(function() {
                   setAttrs({version: "1.4"});
                   versioning();
               });
           }
           else if(v["version"] === "1.4") {
               console.log("UPGRADING TO v1.5");
               upgrade_1_4_to_1_5(function() {
                   setAttrs({version: "1.5"});
                   versioning();
               });
           }
           else if(v["version"] === "1.5") {
               console.log("UPGRADING TO v1.6");
               upgrade_1_5_to_1_6(function() {
                   setAttrs({version: "1.6"});
                   versioning();
               });
           }
           else {
               setAttrs({version: "1.6"});
               console.log("5th Edition OGL by Roll20 version " + v["version"]);
           }
       });
   };
   

</script>