"use strict"; const Character = { firstname: "", surname: "", background: { arctic:false, temperate:false, tropical:false, mountains:false, plains:false, coast:false, forest:false, desert:false, urban:false, }, SoulShards: {remainingSoulShards:2, strength:0, perception:0, agility:0, charisma:0, endurance:0, magic: { //something like this whmb1sp1:0, whmb1sp2:0, whmb1sp3:0, whmb1rad:0, whmb1wav:0, whmb1dur:0, whmb1crit:0, whmb1num:0, whmb2sp1:0, whmb2sp2:0, whmb2sp3:0, whmb2rad:0, whmb2wav:0, whmb2dur:0, whmb2crit:0, whmb2num:0, whmb3sp1:0, whmb3sp2:0, whmb3sp3:0, whmb3rad:0, whmb3wav:0, whmb3dur:0, whmb3crit:0, whmb3num:0, elmb1sp1:0, elmb1sp2:0, elmb1sp3:0, elmb1rad:0, elmb1wav:0, elmb1dur:0, elmb1crit:0, elmb1num:0, elmb2sp1:0, elmb2sp2:0, elmb2sp3:0, elmb2rad:0, elmb2wav:0, elmb2dur:0, elmb2crit:0, elmb2num:0, elmb3sp1:0, elmb3sp2:0, elmb3sp3:0, elmb3rad:0, elmb3wav:0, elmb3dur:0, elmb3crit:0, elmb3num:0, drub1sp1:0, drub1sp2:0, drub1sp3:0, drub1rad:0, drub1wav:0, drub1dur:0, drub1crit:0, drub1num:0, drub2sp1:0, drub2sp2:0, drub2sp3:0, drub2rad:0, drub2wav:0, drub2dur:0, drub2crit:0, drub2num:0, drub3sp1:0, drub3sp2:0, drub3sp3:0, drub3rad:0, drub3wav:0, drub3dur:0, drub3crit:0, drub3num:0, mirb1sp1:0, mirb1sp2:0, mirb1sp3:0, mirb1rad:0, mirb1wav:0, mirb1dur:0, mirb1crit:0, mirb1num:0, mirb2sp1:0, mirb2sp2:0, mirb2sp3:0, mirb2rad:0, mirb2wav:0, mirb2dur:0, mirb2crit:0, mirb2num:0, mirb3sp1:0, mirb3sp2:0, mirb3sp3:0, mirb3rad:0, mirb3wav:0, mirb3dur:0, mirb3crit:0, mirb3num:0, necb1sp1:0, necb1sp2:0, necb1sp3:0, necb1rad:0, necb1wav:0, necb1dur:0, necb1crit:0, necb1num:0, necb2sp1:0, necb2sp2:0, necb2sp3:0, necb2rad:0, necb2wav:0, necb2dur:0, necb2crit:0, necb2num:0, necb3sp1:0, necb3sp2:0, necb3sp3:0, necb3rad:0, necb3wav:0, necb3dur:0, necb3crit:0, necb3num:0, }, mutations: { gills:false, wings:false, senses:false, metabolism:0, //use more elixirs at once naturalArmor:0, magicalAffinity:0 //use more magical items at once }, resistances: { bleed:0, disease:0, poison:0, burn:0, freeze:0, stun:0, stagger:0, slow:0, root:0, calm:0, frenzy:0, confusion:0, panic:0, paralyze:0, blind:0, turn:0, knockback:0, prone:0, deaf:0 } }, skillLevelUpFactors: { athletics:0, evasion:0, stealth:0, negotiation:0, charm:0, command:0, medical:0, nature:0, engineering:0, arcana:0, security:0, liberal_arts:0, slash:0, hew:0, stab:0, parry:0, shoot:0, throw:0, white_magic:0, elemental_magic:0, druidic_magic:0, mirror_magic:0, necromancy:0 }, XP:8, equipment: { weaponslot1:undefined, shieldslot1:undefined, weaponslot2:undefined, shieldslot2:undefined, armor:undefined, helmet:undefined, leftglove:undefined, rightglove:undefined, boots:undefined, shirt:undefined, trousers:undefined, cloak:undefined, belt:undefined, backpack:undefined, magicItem1:undefined, magicItem2:undefined, magicItem3:undefined, quickItems:undefined, spells:undefined //to be determined }, Inventory: { carriedItems:undefined, craftingComponents:undefined, stash:undefined }, Journal: { questlog:undefined, map:undefined, notes:undefined } }; const fillVals = ()=>{ const attribute = { attibuteXP:0, attributeItemXP:0, attributeSoulShards:0, skillWeights:0 }; const skill = { skillXP:0, skillItemXP:0, attributeWeights:0, LevelUpFactor:0 }; const background = { numberOfBackgrounds:0, backgroundAttrib:0, backgroundSkill:0 } Character.firstname = document.getElementById("firstname").value; Character.surname = document.getElementById("surname").value; //Soul (background) //Climate let arctic = document.getElementById("Arctic"), temperate = document.getElementById("Temperate"), tropical = document.getElementById("Tropical"); //Elevation let mountains = document.getElementById("Mountains"), plains = document.getElementById("Plains"), coast = document.getElementById("Coast"); //Vegetation let forest = document.getElementById("Forest"), desert = document.getElementById("Desert"), urban = document.getElementById("Urban"); //Attributes and skills let strength=0, perception=0, agility=0, charisma=0, endurance=0; let athletics=0, evasion=0, stealth=0, negotiation=0, charm=0, command=0, medical=0, nature=0, engineering=0, arcana=0, security=0, liberal_arts=0; //Skills //transport element and translate into number function transPortLate(element) { return parseInt(document.getElementById(element).value||document.getElementById(element).innerHTML||0) } let numberOfBackgrounds=0 //the overall BackgroundXP is divided by this number to ensure balancing. //Attribute and skill changes due to your soul (background) function backgroundAttrib(a1, a2, a3, a4, a5) { return strength+=a1, perception+=a2, agility+=a3, charisma+=a4, endurance+=a5; } function backgroundSkill(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) { return athletics+=s1, evasion+=s2, stealth+=s3, negotiation+=s4, charm+=s5, command+=s6, medical+=s7, nature+=s8, engineering+=s9, arcana+=s10, security+=s11, liberal_arts+=s12; } if (arctic.checked==true) { backgroundAttrib(1,4,1,1,3), backgroundSkill(1,0,1,3,0,0,2,0,2,1,2,0), numberOfBackgrounds+=1; } if (temperate.checked==true) { backgroundAttrib(2,2,2,3,1), backgroundSkill(0,0,1,0,1,2,0,2,0,1,2,3), numberOfBackgrounds+=1; } if (tropical.checked==true) { backgroundAttrib(1,1,3,3,2), backgroundSkill(1,0,2,0,2,0,0,2,2,1,1,1), numberOfBackgrounds+=1; } if (mountains.checked==true) { backgroundAttrib(4,1,1,1,3), backgroundSkill(3,1,1,1,0,3,1,0,2,0,0,0), numberOfBackgrounds+=1; } if (plains.checked==true) { backgroundAttrib(2,2,2,2,2), backgroundSkill(0,2,1,0,2,2,1,2,0,2,0,0), numberOfBackgrounds+=1; } if (coast.checked==true) { backgroundAttrib(1,3,2,3,1), backgroundSkill(1,1,1,1,1,0,2,0,1,1,0,3), numberOfBackgrounds+=1; } if (forest.checked==true) { backgroundAttrib(1,2,3,1,3), backgroundSkill(2,2,2,0,0,1,0,2,1,1,1,0), numberOfBackgrounds+=1; } if (desert.checked==true) { backgroundAttrib(2,3,2,1,2), backgroundSkill(1,1,0,3,0,0,2,1,0,2,2,0), numberOfBackgrounds+=1; } if (urban.checked==true) { backgroundAttrib(2,2,1,4,1), backgroundSkill(0,2,0,1,3,1,1,0,1,0,1,2), numberOfBackgrounds+=1; } if (numberOfBackgrounds==0) { backgroundAttrib(2,2,2,2,2), backgroundSkill(1,1,1,1,1,1,1,1,1,1,1,1), numberOfBackgrounds=1; } //The BackgroundXP gets divided athletics/=numberOfBackgrounds; evasion/=numberOfBackgrounds; stealth/=numberOfBackgrounds; negotiation/=numberOfBackgrounds; charm/=numberOfBackgrounds; command/=numberOfBackgrounds; medical/=numberOfBackgrounds; nature/=numberOfBackgrounds; engineering/=numberOfBackgrounds; arcana/=numberOfBackgrounds; security/=numberOfBackgrounds; liberal_arts/=numberOfBackgrounds; //Your soul (background) gives you passive Soul Shards let SoulShardBackground = 6; //Being a human gives you distributable Soul Shards let SoulShards = -2; //Soul Shards for attributes let StrengthSoulShard = transPortLate("StrengthIncreaseField"), PerceptionSoulShard = transPortLate("PerceptionIncreaseField"), AgilitySoulShard = transPortLate("AgilityIncreaseField"), CharismaSoulShard = transPortLate("CharismaIncreaseField"), EnduranceSoulShard = transPortLate("EnduranceIncreaseField"); let FireBolt = transPortLate("FireBoltField"), FireWave = transPortLate("FireWaveField"), FireShield = transPortLate("FireShieldField"), WallOfFire = transPortLate("WallOfFireField"), FireSummon = transPortLate("FireSummonField"), FireRad = transPortLate("FireRadField"), FireBurn = transPortLate("FireBurnField"), FireStagger = transPortLate("FireStaggerField"), FirePanic = transPortLate("FirePanicField"), FireSummonEquip = transPortLate("FireSummonEquipField"); let FrostBlast = transPortLate("FrostBlastField"), IceShard = transPortLate("IceShardField"), FrostWeapon = transPortLate("FrostWeaponField"), WallOfIce = transPortLate("WallOfIceField"), IceSummon = transPortLate("IceSummonField"), FrostRad = transPortLate("FrostRadField"), FrostFreeze = transPortLate("FrostFreezeField"), PiercingCold = transPortLate("PiercingColdField"), FrostBlind = transPortLate("FrostBlindField"), IceSummonEquip = transPortLate("IceSummonEquipField"); let LightningStrike = transPortLate("LightningStrikeField"), Lightning = transPortLate("LightningField"), ShockWeapon = transPortLate("ShockWeaponField"), WallOfLightning = transPortLate("WallOfLightningField"), ShockSummon = transPortLate("ShockSummonField"), ShockRad = transPortLate("ShockRadField"), ShockStun = transPortLate("ShockStunField"), ShockBlind = transPortLate("ShockBlindField"), ShockDeafen = transPortLate("ShockDeafenField"), ShockSummonEquip = transPortLate("ShockSummonEquipField"); let VampDrain = transPortLate("VampDrainField"), VampSlow = transPortLate("VampSlowField"), VampJoy = transPortLate("VampJoyField"), VampFog = transPortLate("VampFogField"), VampFlow = transPortLate("VampFlowField"), VampRad = transPortLate("VampRadField"), VampWeapon = transPortLate("VampWeaponField"), VampKnight = transPortLate("VampKnightField"), KnightDrain = transPortLate("KnightDrainField"), KnightSlow = transPortLate("KnightSlowField"); let ArmyMinion = transPortLate("ArmyMinionField"), ArmyChampion = transPortLate("ArmyChampionField"), ArmyGeneral = transPortLate("ArmyGeneralField"), ArmyPoison = transPortLate("ArmyPoisonField"), ArmyDisease = transPortLate("ArmyDiseaseField"), ArmyEquip = transPortLate("ArmyEquipField"), ArmyPanic = transPortLate("ArmyPanicField"), ArmyKnight = transPortLate("ArmyKnightField"), KnightPanic = transPortLate("KnightPanicField"), KnightSummonEquip = transPortLate("KnightSummonEquipField"); let DeathRay = transPortLate("DeathRayField"), DeathParalyze = transPortLate("DeathParalyzeField"), DeathFinger = transPortLate("DeathFingerField"), FingerCripple = transPortLate("FingerCrippleField"), FingerVulnerate = transPortLate("FingerVulnerateField"), DeathWeapon = transPortLate("DeathWeaponField"), DeathKnight = transPortLate("DeathKnightField"), KnightPoison = transPortLate("KnightPoisonField"), KnightDisease = transPortLate("KnightDiseaseField"), KnightDarknessAura = transPortLate("KnightDarknessAuraField"); let WrathBolt = transPortLate("WrathBoltField"), WrathChannel = transPortLate("WrathChannelField"), WrathWeapon = transPortLate("WrathWeaponField"), WrathSmite = transPortLate("WrathSmiteField"), WrathBlind = transPortLate("WrathBlindField"), WrathTurn = transPortLate("WrathTurnField"), WrathRad = transPortLate("WrathRadField"), WrathKnight = transPortLate("WrathKnightField"), KnightTurn = transPortLate("KnightTurnField"), KnightHolyDamage = transPortLate("KnightHolyDamageField"); let MercyHeal = transPortLate("MercyHealField"), HealCure = transPortLate("HealCureField"), HealBreakCurse = transPortLate("HealBreakCurseField"), MercyBuff = transPortLate("MercyBuffField"), BuffResistance = transPortLate("BuffResistanceField"), MercyWeapon = transPortLate("MercyWeaponField"), MercyKB = transPortLate("MercyKBField"), MercyRad = transPortLate("MercyRadField"), MercyKnight = transPortLate("MercyKnightField"), KnightDefenseAura = transPortLate("KnightDefenseAuraField"); let StrBless = transPortLate("StrBlessField"), BlessSaves = transPortLate("BlessSavesField"), BlessOff = transPortLate("BlessOffField"), StrHaste = transPortLate("StrHasteField"), StrAura = transPortLate("StrAuraField"), StrAuraPure = transPortLate("StrAuraPureField"), StrAuraReg = transPortLate("StrAuraRegField"), StrRad = transPortLate("StrRadField"), StrKnight = transPortLate("StrKnightField"), KnightEquip = transPortLate("KnightEquipField"); let WrathSoulShard = WrathBolt+WrathChannel+WrathWeapon+WrathSmite+WrathBlind+WrathTurn+WrathRad+WrathKnight+KnightTurn+KnightHolyDamage; let MercySoulShard = MercyHeal+HealCure+HealBreakCurse+MercyBuff+BuffResistance+MercyWeapon+MercyKB+MercyRad+MercyKnight+KnightDefenseAura; let StrMagSoulShard = StrBless+BlessSaves+BlessOff+StrHaste+StrAura+StrAuraPure+StrAuraReg+StrRad+StrKnight+KnightEquip; let VampSoulShard = VampDrain+VampSlow+VampJoy+VampFog+VampFlow+VampRad+VampWeapon+VampKnight+KnightDrain+KnightSlow; let ArmySoulShard = ArmyMinion+ArmyChampion+ArmyGeneral+ArmyPoison+ArmyDisease+ArmyEquip+ArmyPanic+ArmyKnight+KnightPanic+KnightSummonEquip; let DeathSoulShard = DeathRay+DeathParalyze+DeathFinger+FingerCripple+FingerVulnerate+DeathWeapon+DeathKnight+KnightPoison+KnightDisease+KnightDarknessAura; let FireSoulShard = FireBolt+FireWave+FireShield+WallOfFire+FireSummon+FireRad+FireBurn+FireStagger+FirePanic+FireSummonEquip; let FrostSoulShard = FrostBlast+IceShard+FrostWeapon+WallOfIce+IceSummon+FrostRad+FrostFreeze+FrostBlind+PiercingCold+IceSummonEquip; let LightningSoulShard = LightningStrike+Lightning+ShockWeapon+WallOfLightning+ShockSummon+ShockRad+ShockStun+ShockBlind+ShockDeafen+ShockSummonEquip; let WhiteSoulShard = WrathSoulShard+MercySoulShard+StrMagSoulShard; let NecromancySoulShard = VampSoulShard+ArmySoulShard+DeathSoulShard; let ElementalSoulShard = FireSoulShard+FrostSoulShard+LightningSoulShard; let SoulShardTotal = SoulShards + StrengthSoulShard + PerceptionSoulShard + AgilitySoulShard + CharismaSoulShard + EnduranceSoulShard + ElementalSoulShard + NecromancySoulShard + WhiteSoulShard; document.getElementById("SoulShardTotal").innerHTML="Soul Power Level "+SoulShardTotal; let SilentKnightSoulShard = ArmyKnight+VampKnight+DeathKnight+KnightDarknessAura+KnightDisease+KnightDrain+KnightPanic+KnightPoison+KnightSlow+KnightSummonEquip; let HolyKnightSoulShard = WrathKnight+MercyKnight+StrKnight+KnightEquip+KnightHolyDamage+KnightDefenseAura+KnightTurn; let StrengthSoulShardTotal = strength/numberOfBackgrounds*SoulShardBackground/10+StrengthSoulShard; let PerceptionSoulShardTotal = perception/numberOfBackgrounds*SoulShardBackground/10+PerceptionSoulShard; let AgilitySoulShardTotal = agility/numberOfBackgrounds*SoulShardBackground/10+AgilitySoulShard; let CharismaSoulShardTotal = charisma/numberOfBackgrounds*SoulShardBackground/10+CharismaSoulShard; let EnduranceSoulShardTotal = endurance/numberOfBackgrounds*SoulShardBackground/10+EnduranceSoulShard; let SkillFactor=transPortLate("Athletics")+transPortLate("Evasion")+transPortLate("Stealth")+transPortLate("Negotiation")+transPortLate("Charm")+transPortLate("Command")+transPortLate("Medical")+transPortLate("Nature")+transPortLate("Engineering")+transPortLate("Arcana")+transPortLate("Security")+transPortLate("Liberal_Arts")+transPortLate("Slash")+transPortLate("Hew")+transPortLate("Stab")+transPortLate("Parry")+transPortLate("Shoot")+transPortLate("Throw")+transPortLate("White Magic")+transPortLate("Elemental Magic")+transPortLate("Druidic Magic")+transPortLate("Mirror Magic")+transPortLate("Necromancy")+(athletics+evasion+stealth+negotiation+charm+command+medical+nature+engineering+arcana+security+liberal_arts)*5; let TotalXP=transPortLate("TotalXP")+8, Level = Math.floor(Math.sqrt(transPortLate("TotalXP"))); document.getElementById("Level").innerHTML="Level "+Level; //Combat and magic skills do not recieve BackgroundXP let SlashLevelUpXP=transPortLate("Slash")*TotalXP/SkillFactor, HewLevelUpXP=transPortLate("Hew")*TotalXP/SkillFactor, StabLevelUpXP=transPortLate("Stab")*TotalXP/SkillFactor, ParryLevelUpXP=transPortLate("Parry")*TotalXP/SkillFactor, ShootLevelUpXP=transPortLate("Shoot")*TotalXP/SkillFactor, ThrowLevelUpXP=transPortLate("Throw")*TotalXP/SkillFactor; let WhiteMagicLevelUpXP=transPortLate("White Magic")*TotalXP/SkillFactor, ElementalMagicLevelUpXP=transPortLate("Elemental Magic")*TotalXP/SkillFactor, DruidicMagicLevelUpXP=transPortLate("Druidic Magic")*TotalXP/SkillFactor, MirrorMagicLevelUpXP=transPortLate("Mirror Magic")*TotalXP/SkillFactor, NecromancyLevelUpXP=transPortLate("Necromancy")*TotalXP/SkillFactor; //Your starting Skills are added into the LevelUpXP-Mix, because you can get the boy out of the Mountains, but you can't get the Mountains out of the boy. let AthleticsLevelUpXP=(transPortLate("Athletics")+athletics*5)*TotalXP/SkillFactor; let EvasionLevelUpXP=(transPortLate("Evasion")+evasion*5)*TotalXP/SkillFactor; let StealthLevelUpXP=(transPortLate("Stealth")+stealth*5)*TotalXP/SkillFactor; let NegotiationLevelUpXP=(transPortLate("Negotiation")+negotiation*5)*TotalXP/SkillFactor; let CharmLevelUpXP=(transPortLate("Charm")+charm*5)*TotalXP/SkillFactor; let CommandLevelUpXP=(transPortLate("Command")+command*5)*TotalXP/SkillFactor; let MedicalLevelUpXP=(transPortLate("Medical")+medical*5)*TotalXP/SkillFactor; let NatureLevelUpXP=(transPortLate("Nature")+nature*5)*TotalXP/SkillFactor; let EngineeringLevelUpXP=(transPortLate("Engineering")+engineering*5)*TotalXP/SkillFactor; let ArcanaLevelUpXP=(transPortLate("Arcana")+arcana*5)*TotalXP/SkillFactor; let SecurityLevelUpXP=(transPortLate("Security")+security*5)*TotalXP/SkillFactor let Liberal_ArtsLevelUpXP=(transPortLate("Liberal_Arts")+liberal_arts*5)*TotalXP/SkillFactor; //Magical items and spells will give you XP, as long as the item is equipped or the spell endures. let AthleticsItemXP=0, EvasionItemXP=0, StealthItemXP=0, NegotiationItemXP=0, CharmItemXP=0, CommandItemXP=0, MedicalItemXP=0, NatureItemXP=0, EngineeringItemXP=0, ArcanaItemXP=0, SecurityItemXP=0, Liberal_ArtsItemXP=0; let SlashItemXP=0, HewItemXP=0, StabItemXP=0, ParryItemXP=0, ShootItemXP=0, ThrowItemXP=0; let StrengthItemXP=0, PerceptionItemXP=0, AgilityItemXP=0, CharismaItemXP=0, EnduranceItemXP=0; let WhiteMagicItemXP=0, ElementalMagicItemXP=0, DruidicMagicItemXP=0, MirrorMagicItemXP=0, NecromancyItemXP=0; //Raw AttributeXP derived from Skills - other than Soul Shards, you cannot raise your attributes directly. //The higher your skills, the higher your attributes. The numbers inbetween are the weights. function SkillWeight(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18) { return (athletics+AthleticsLevelUpXP)*s1+(evasion+EvasionLevelUpXP)*s2+(stealth+StealthLevelUpXP)*s3+(negotiation+NegotiationLevelUpXP)*s4+(charm+CharmLevelUpXP)*s5+(command+CommandLevelUpXP)*s6+(medical+MedicalLevelUpXP)*s7+(nature+NatureLevelUpXP)*s8+(engineering+EngineeringLevelUpXP)*s9+(arcana+ArcanaLevelUpXP)*s10+(security+SecurityLevelUpXP)*s11+(liberal_arts+Liberal_ArtsLevelUpXP)*s12+SlashLevelUpXP*s13+HewLevelUpXP*s14+StabLevelUpXP*s15+ParryLevelUpXP*s16+ShootLevelUpXP*s17+ThrowLevelUpXP*s18; } function MagicWeight(m1, m2, m3, m4, m5) { return WhiteMagicLevelUpXP*m1+ElementalMagicLevelUpXP*m2+DruidicMagicLevelUpXP*m3+MirrorMagicLevelUpXP*m4+NecromancyLevelUpXP*m5; } let StrengthXP=SkillWeight(3,0,0,0,0,3,0,2,0,0,0,1,4,5,3,0,0,5)+StrengthItemXP+MagicWeight(3,0,2,0,0); let PerceptionXP=SkillWeight(0,5,3,0,6,0,4,2,7,4,6,1,0,0,0,4,4,2)+PerceptionItemXP+MagicWeight(0,2,2,4,4); let AgilityXP=SkillWeight(3,5,5,0,0,0,2,2,3,0,4,1,4,0,3,4,4,2)+AgilityItemXP+MagicWeight(0,2,2,0,0); let CharismaXP=SkillWeight(0,0,2,7,4,5,0,2,0,6,0,6,2,0,0,2,0,0)+CharismaItemXP+MagicWeight(4,3,2,3,2); let EnduranceXP=SkillWeight(4,0,0,3,0,2,4,2,0,0,0,1,0,5,4,0,2,1)+EnduranceItemXP+MagicWeight(3,3,2,3,4); //This is the calculation of the Attribute Score and the resulting Attribute Modification. The values are analogous to the D20 System. let StrengthFlat=(Math.log(StrengthXP)/Math.log(2.1)+StrengthSoulShardTotal)*2, PerceptionFlat=(Math.log(PerceptionXP)/Math.log(2.1)+PerceptionSoulShardTotal)*2, AgilityFlat=(Math.log(AgilityXP)/Math.log(2.1)+AgilitySoulShardTotal)*2, CharismaFlat=(Math.log(CharismaXP)/Math.log(2.1)+CharismaSoulShardTotal)*2, EnduranceFlat=(Math.log(EnduranceXP)/Math.log(2.1)+EnduranceSoulShardTotal)*2; let StrengthMod=(StrengthFlat-10)/2, PerceptionMod=(PerceptionFlat-10)/2, AgilityMod=(AgilityFlat-10)/2, CharismaMod=(CharismaFlat-10)/2, EnduranceMod=(EnduranceFlat-10)/2; //Complete calculation of SkillXP let AthleticsTotalXP = athletics+AthleticsLevelUpXP+AthleticsItemXP; let EvasionTotalXP = evasion+EvasionLevelUpXP+EvasionItemXP; let StealthTotalXP = stealth+StealthLevelUpXP+StealthItemXP; let NegotiationTotalXP = negotiation+NegotiationLevelUpXP+NegotiationItemXP; let CharmTotalXP = charm+CharmLevelUpXP+CharmItemXP; let CommandTotalXP = command+CommandLevelUpXP+CommandItemXP; let MedicalTotalXP = medical+MedicalLevelUpXP+MedicalItemXP; let NatureTotalXP = nature+NatureLevelUpXP+NatureItemXP; let EngineeringTotalXP = engineering+EngineeringLevelUpXP+EngineeringItemXP; let ArcanaTotalXP = arcana+ArcanaLevelUpXP+ArcanaItemXP; let SecurityTotalXP = security+SecurityLevelUpXP+SecurityItemXP; let Liberal_ArtsTotalXP = liberal_arts+Liberal_ArtsLevelUpXP+Liberal_ArtsItemXP; let SlashTotalXP = SlashLevelUpXP+SlashItemXP; let HewTotalXP = HewLevelUpXP+HewItemXP; let StabTotalXP = StabLevelUpXP+StabItemXP; let ParryTotalXP = ParryLevelUpXP+ParryItemXP; let ShootTotalXP = ShootLevelUpXP+ShootItemXP; let ThrowTotalXP = ThrowLevelUpXP+ThrowItemXP; let WhiteMagicTotalXP = WhiteMagicLevelUpXP+WhiteMagicItemXP; let ElementalMagicTotalXP = ElementalMagicLevelUpXP+ElementalMagicItemXP; let DruidicMagicTotalXP = DruidicMagicLevelUpXP+DruidicMagicItemXP; let MirrorMagicTotalXP = MirrorMagicLevelUpXP+MirrorMagicItemXP; let NecromancyTotalXP = NecromancyLevelUpXP+NecromancyItemXP; //Skill Value Calculation. The higher the corresponding attributes, the higher the bonus to the skill. //Attribute weights are the same as for the skills. function Attribonus(a1, a2, a3, a4, a5) { return (StrengthMod*a1+PerceptionMod*a2+AgilityMod*a3+CharismaMod*a4+EnduranceMod*a5)/10; } function SkillCalc(element) { return Math.log(element+1)/Math.log(1.6182733); } let AthleticsValue=SkillCalc(AthleticsTotalXP)+Attribonus(3,0,3,0,4); let EvasionValue=SkillCalc(EvasionTotalXP)+Attribonus(0,5,5,0,0); let StealthValue=SkillCalc(StealthTotalXP)+Attribonus(0,3,5,2,0); let NegotiationValue=SkillCalc(NegotiationTotalXP)+Attribonus(0,0,0,7,3); let CharmValue=SkillCalc(CharmTotalXP)+Attribonus(0,6,0,4,0); let CommandValue=SkillCalc(CommandTotalXP)+Attribonus(3,0,0,5,2); let MedicalValue=SkillCalc(MedicalTotalXP)+Attribonus(0,4,2,0,4); let NatureValue=SkillCalc(NatureTotalXP)+Attribonus(2,2,2,2,2); let EngineeringValue=SkillCalc(EngineeringTotalXP)+Attribonus(0,7,3,0,0); let ArcanaValue=SkillCalc(ArcanaTotalXP)+Attribonus(0,4,0,6,0); let SecurityValue=SkillCalc(SecurityTotalXP)+Attribonus(0,6,4,0,0); let Liberal_ArtsValue=SkillCalc(Liberal_ArtsTotalXP)+Attribonus(1,1,1,6,1); let SlashValue=SkillCalc(SlashTotalXP)+Attribonus(4,0,4,2,0); let HewValue=SkillCalc(HewTotalXP)+Attribonus(5,0,0,0,5); let StabValue=SkillCalc(StabTotalXP)+Attribonus(3,0,3,0,4); let ParryValue=SkillCalc(ParryTotalXP)+Attribonus(0,4,4,2,0) let ShootValue=SkillCalc(ShootTotalXP)+Attribonus(0,4,4,0,2); let ThrowValue=SkillCalc(ThrowTotalXP)+Attribonus(5,2,2,0,1); let WhiteValue=SkillCalc(WhiteMagicTotalXP)+Attribonus(3,0,0,4,3); let ElementalValue=SkillCalc(ElementalMagicTotalXP)+Attribonus(0,2,2,3,3); let DruidicValue=SkillCalc(DruidicMagicTotalXP)+Attribonus(2,2,2,2,2) let MirrorValue=SkillCalc(MirrorMagicTotalXP)+Attribonus(0,4,0,3,3); let NecroValue=SkillCalc(NecromancyTotalXP)+Attribonus(0,4,0,2,4); //Secondary attributes derived from primary ones. let ArmorTotal=0; let HealthItem=0, HealthTemp=0, HealthDamage=0; let HealthMAX = EnduranceFlat*1.61 + HealthItem + HealthTemp; let Health = HealthMAX-HealthDamage; let ArmorClass = Math.pow(SkillCalc(PerceptionMod*0.25+AgilityMod*0.5+EnduranceMod*0.25+ArmorTotal)/4,3); //Damage Reduction as follows: Damage/(ArmorClass+1)*2 let Mana = CharismaMod+2; //how long spellcasting can be maintained let Exertion = EnduranceMod; let Composure=PerceptionMod+CharismaMod, Reaction=PerceptionMod+AgilityMod, Fortitude=StrengthMod+EnduranceMod; //Help! I tracked the NaN Problem to this Function function Weapon (name, slash, hew, weight, range, level){ const assocDam = name+"Dam"; //probably right here const weaponDamage = document.getElementById(assocDam) const weaponSlashDamage = Math.round((range + weight)*1.01**(level*5 + SlashValue)*slash*AgilityMod*100)/100 const weaponHewDamage = Math.round((range + weight)*1.01**(level*5 + HewValue)*hew*StrengthMod*100)/100 weaponDamage.innerHTML = Math.max(weaponSlashDamage, weaponHewDamage)//and here const assocIni = name + "Ini" const weaponSpeed = document.getElementById(assocIni) weaponSpeed.innerHTML = Math.round(0.99**((AgilityMod+PerceptionMod)*2)*Math.exp((weight+range)/5)*50)/100 } function SilentKnight(spell) { const num = Mana/0.99**((AgilityMod+PerceptionMod)*2)/Math.exp(1/5)*2 const assocDam = spell+"Dam" const spelldamage = document.getElementById(assocDam) spelldamage.innerHTML = Math.round(1.01**(NecroValue+VampSoulShard+ArmySoulShard+DeathSoulShard)*(PerceptionMod/2+SilentKnightSoulShard+transPortLate("VampKnightField")+transPortLate("ArmyKnightField")+transPortLate("DeathKnightField"))*num*100)/100 const assocIni = spell+"Ini" const spellSpeed = document.getElementById(assocIni) spellSpeed.innerHTML = Math.round(0.99**((AgilityMod+PerceptionMod)*2)*Math.exp(1/5)*50*num)/100 } function HolyKnight(spell) { const num = Mana/0.99**((AgilityMod+PerceptionMod)*2)/Math.exp(1/5)*2 const assocDam = spell+"Dam" const spelldamage = document.getElementById(assocDam) spelldamage.innerHTML = Math.round(1.01**(WhiteValue+WrathSoulShard+MercySoulShard+StrMagSoulShard)*(PerceptionMod/2+HolyKnightSoulShard+transPortLate("WrathKnightField")+transPortLate("MercyKnightField")+transPortLate("StrKnightField"))*num*100)/100 const assocIni = spell+"Ini" const spellSpeed = document.getElementById(assocIni) spellSpeed.innerHTML = Math.round(0.99**((AgilityMod+PerceptionMod)*2)*Math.exp(1/5)*50*num)/100 } function SpellChannel (name, Skill, branch) { const num = 1/0.99**((AgilityMod+PerceptionMod)*2)/Math.exp(1/5)*2 const assocDam = name+"Dam" const spellDamage = document.getElementById(assocDam) spellDamage.innerHTML = Math.round(1.01**(Skill)*(PerceptionMod/2+branch+transPortLate(name+"Field"))*num*100)/100 const assocIni = name + "Ini" const spellSpeed = document.getElementById(assocIni) spellSpeed.innerHTML = Math.round(0.99**((AgilityMod+PerceptionMod)*2)*Math.exp(1/5)*50*num)/100 } function Spell (name, Skill, branch) { const num = Mana/0.99**((AgilityMod+PerceptionMod)*2)/Math.exp(1/5)*2 const assocDam = name+"Dam" const spellDamage = document.getElementById(assocDam) spellDamage.innerHTML = Math.round(1.01**(Skill)*(PerceptionMod/2+branch+transPortLate(name+"Field"))*num*100)/100 const assocIni = name + "Ini" const spellSpeed = document.getElementById(assocIni) spellSpeed.innerHTML = Math.round(0.99**((AgilityMod+PerceptionMod)*2)*Math.exp(1/5)*50*num)/100 } Weapon("Dagger", 1, 0.2, 1, 1, 1, 0);//single-handed dagger - double weight is dual wielding Weapon("Scimitar", 1, 0.8, 0.5, 4, 1.5, 5);//dual wield Weapon("Casomyr", 1, 1, 1, 6, 1.5, 20);//two-handed greatsword SpellChannel("VampDrain", NecroValue, VampSoulShard); Spell("ArmyMinion", NecroValue, ArmySoulShard); SilentKnight("SilentKnight"); HolyKnight("HolyKnight"); let StrengthDisplay=Math.floor(StrengthFlat), StrengthDisMod=Math.floor(StrengthMod).toString(); let PerceptionDisplay=Math.floor(PerceptionFlat), PerceptionDisMod=Math.floor(PerceptionMod).toString(); let AgilityDisplay=Math.floor(AgilityFlat), AgilityDisMod=Math.floor(AgilityMod).toString(); let CharismaDisplay=Math.floor(CharismaFlat), CharismaDisMod=Math.floor(CharismaMod).toString(); let EnduranceDisplay=Math.floor(EnduranceFlat), EnduranceDisMod=Math.floor(EnduranceMod).toString(); function displayCharTest() { document.getElementById("Str").innerHTML = StrengthDisplay, document.getElementById("StrM").innerHTML = StrengthDisMod; document.getElementById("Per").innerHTML = PerceptionDisplay, document.getElementById("PerM").innerHTML = PerceptionDisMod; document.getElementById("Agi").innerHTML = AgilityDisplay, document.getElementById("AgiM").innerHTML = AgilityDisMod; document.getElementById("Cha").innerHTML = CharismaDisplay, document.getElementById("ChaM").innerHTML = CharismaDisMod; document.getElementById("End").innerHTML = EnduranceDisplay, document.getElementById("EndM").innerHTML = EnduranceDisMod; document.getElementById("SAth").innerHTML = Math.floor(AthleticsValue); document.getElementById("SEva").innerHTML = Math.floor(EvasionValue); document.getElementById("SSte").innerHTML = Math.floor(StealthValue); document.getElementById("SNeg").innerHTML = Math.floor(NegotiationValue); document.getElementById("SCha").innerHTML = Math.floor(CharmValue); document.getElementById("SCom").innerHTML = Math.floor(CommandValue); document.getElementById("SMed").innerHTML = Math.floor(MedicalValue); document.getElementById("SNat").innerHTML = Math.floor(NatureValue); document.getElementById("SEng").innerHTML = Math.floor(EngineeringValue); document.getElementById("SArc").innerHTML = Math.floor(ArcanaValue); document.getElementById("SSec").innerHTML = Math.floor(SecurityValue); document.getElementById("SLib").innerHTML = Math.floor(Liberal_ArtsValue); document.getElementById("SSla").innerHTML = Math.floor(SlashValue); document.getElementById("SHew").innerHTML = Math.floor(HewValue); document.getElementById("SSta").innerHTML = Math.floor(StabValue); document.getElementById("SPar").innerHTML = Math.floor(ParryValue); document.getElementById("SSho").innerHTML = Math.floor(ShootValue); document.getElementById("SThr").innerHTML = Math.floor(ThrowValue); document.getElementById("SWhi").innerHTML = Math.floor(WhiteValue); document.getElementById("SEle").innerHTML = Math.floor(ElementalValue); document.getElementById("SDru").innerHTML = Math.floor(DruidicValue); document.getElementById("SMir").innerHTML = Math.floor(MirrorValue); document.getElementById("SNec").innerHTML = Math.floor(NecroValue); document.getElementById("Health").innerHTML = Math.round(HealthMAX); document.getElementById("ArmorClass").innerHTML = Math.round(ArmorClass); document.getElementById("Exertion").innerHTML = Math.round(Exertion); document.getElementById("Mana").innerHTML = Math.round(Mana); document.getElementById("Composure").innerHTML = Math.round(Composure); document.getElementById("Reaction").innerHTML = Math.round(Reaction); document.getElementById("Fortitude").innerHTML = Math.round(Fortitude); } displayCharTest() } document.getElementById("Arctic").addEventListener("change",fillVals); document.getElementById("Temperate").addEventListener("change",fillVals); document.getElementById("Tropical").addEventListener("change",fillVals); document.getElementById("Mountains").addEventListener("change",fillVals); document.getElementById("Plains").addEventListener("change",fillVals); document.getElementById("Coast").addEventListener("change",fillVals); document.getElementById("Forest").addEventListener("change",fillVals); document.getElementById("Desert").addEventListener("change",fillVals); document.getElementById("Urban").addEventListener("change",fillVals); document.getElementById("TotalXP").addEventListener("change",fillVals); document.getElementById("Athletics").onchange = fillVals; document.getElementById("Evasion").onchange = fillVals; document.getElementById("Stealth").onchange = fillVals; document.getElementById("Negotiation").onchange = fillVals; document.getElementById("Charm").onchange = fillVals; document.getElementById("Command").onchange = fillVals; document.getElementById("Medical").onchange = fillVals; document.getElementById("Nature").onchange = fillVals; document.getElementById("Engineering").onchange = fillVals; document.getElementById("Arcana").onchange = fillVals; document.getElementById("Security").onchange = fillVals; document.getElementById("Liberal_Arts").onchange = fillVals; document.getElementById("Slash").onchange = fillVals; document.getElementById("Hew").onchange = fillVals; document.getElementById("Stab").onchange = fillVals; document.getElementById("Parry").onchange = fillVals; document.getElementById("Shoot").onchange = fillVals; document.getElementById("Throw").onchange = fillVals; document.getElementById("White Magic").onchange = fillVals; document.getElementById("Elemental Magic").onchange = fillVals; document.getElementById("Druidic Magic").onchange = fillVals; document.getElementById("Mirror Magic").onchange = fillVals; document.getElementById("Necromancy").onchange = fillVals; /*function gaussianDiceRoll(ev) { const assocField = ev.target.id.replace("Button", "Field") const assocDam = ev.target.id.replace("Button", "Dam") let u = 0, v = 0; while(u === 0) u = Math.random(); while(v === 0) v = Math.random(); const mean = parseInt(document.getElementById(assocDam).value) const storeGaussVal = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); const elementToChange = document.getElementById(assocField) elementToChange.innerHTML = storeGaussVal*mean/3.6+mean return elementToChange.innerHTML }*/ function gaussRoll(mean ) { let u = 0, v = 0; while(u === 0) u = Math.random(); while(v === 0) v = Math.random(); const storeGaussVal = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); return storeGaussVal*mean/3.6+mean } function eventHandler(ev) { const assocField = ev.target.id.replace("Press", "Output") const assocDam = ev.target.id.replace("Press", "Dam") const elementToChange = document.getElementById(assocField) const mean = parseFloat(document.getElementById(assocDam).innerHTML) elementToChange.innerHTML = gaussRoll(mean) return elementToChange.innerHTML } function SoulShardIncrease(ev) { const addocField = ev.target.id.replace("Button", "Field") const elementToChange = document.getElementById(addocField) elementToChange.innerHTML = parseInt(elementToChange.innerHTML)+1 fillVals() } document.getElementById("VampDrainPress").addEventListener("click", eventHandler); document.getElementById("DaggerPress").addEventListener("click", eventHandler); document.getElementById("ScimitarPress").addEventListener("click", eventHandler); document.getElementById("CasomyrPress").addEventListener("click", eventHandler); document.getElementById("StrengthIncreaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("PerceptionIncreaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("AgilityIncreaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("CharismaIncreaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("EnduranceIncreaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireBoltButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireWaveButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireShieldButton").addEventListener("click", SoulShardIncrease); document.getElementById("WallOfFireButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireSummonButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireBurnButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireStaggerButton").addEventListener("click", SoulShardIncrease); document.getElementById("FirePanicButton").addEventListener("click", SoulShardIncrease); document.getElementById("FireSummonEquipButton").addEventListener("click", SoulShardIncrease); document.getElementById("FrostBlastButton").addEventListener("click", SoulShardIncrease); document.getElementById("IceShardButton").addEventListener("click", SoulShardIncrease); document.getElementById("FrostWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("WallOfIceButton").addEventListener("click", SoulShardIncrease); document.getElementById("IceSummonButton").addEventListener("click", SoulShardIncrease); document.getElementById("FrostRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("PiercingColdButton").addEventListener("click", SoulShardIncrease); document.getElementById("FrostFreezeButton").addEventListener("click", SoulShardIncrease); document.getElementById("FrostBlindButton").addEventListener("click", SoulShardIncrease); document.getElementById("IceSummonEquipButton").addEventListener("click", SoulShardIncrease); document.getElementById("LightningStrikeButton").addEventListener("click", SoulShardIncrease); document.getElementById("LightningButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("WallOfLightningButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockSummonButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockStunButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockBlindButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockDeafenButton").addEventListener("click", SoulShardIncrease); document.getElementById("ShockSummonEquipButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampDrainButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampSlowButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampJoyButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampFogButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampFlowButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("VampKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightDrainButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightSlowButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyMinionButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyChampionButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyGeneralButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyPoisonButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyDiseaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyEquipButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyPanicButton").addEventListener("click", SoulShardIncrease); document.getElementById("ArmyKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightPanicButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightSummonEquipButton").addEventListener("click", SoulShardIncrease); document.getElementById("DeathRayButton").addEventListener("click", SoulShardIncrease); document.getElementById("DeathParalyzeButton").addEventListener("click", SoulShardIncrease); document.getElementById("DeathFingerButton").addEventListener("click", SoulShardIncrease); document.getElementById("FingerCrippleButton").addEventListener("click", SoulShardIncrease); document.getElementById("FingerVulnerateButton").addEventListener("click", SoulShardIncrease); document.getElementById("DeathWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("DeathKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightPoisonButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightDiseaseButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightDarknessAuraButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathBoltButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathChannelButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathSmiteButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathBlindButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathTurnButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("WrathKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightTurnButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightHolyDamageButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyHealButton").addEventListener("click", SoulShardIncrease); document.getElementById("HealCureButton").addEventListener("click", SoulShardIncrease); document.getElementById("HealBreakCurseButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyBuffButton").addEventListener("click", SoulShardIncrease); document.getElementById("BuffResistanceButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyWeaponButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyKBButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("MercyKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightDefenseAuraButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrBlessButton").addEventListener("click", SoulShardIncrease); document.getElementById("BlessSavesButton").addEventListener("click", SoulShardIncrease); document.getElementById("BlessOffButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrHasteButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrAuraButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrAuraPureButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrAuraRegButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrRadButton").addEventListener("click", SoulShardIncrease); document.getElementById("StrKnightButton").addEventListener("click", SoulShardIncrease); document.getElementById("KnightEquipButton").addEventListener("click", SoulShardIncrease); fillVals()