Simpletrixx-LearningJS/Trixx/simpletrixx.js

456 lines
32 KiB
JavaScript

const fillVals = ()=>{
//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, mutations and meta magic abilities
let StrengthSoulShard = transPortLate("StrengthIncreaseField"), PerceptionSoulShard = transPortLate("PerceptionIncreaseField"), AgilitySoulShard = transPortLate("AgilityIncreaseField"), CharismaSoulShard = transPortLate("CharismaIncreaseField"), EnduranceSoulShard = transPortLate("EnduranceIncreaseField");
let SenseSoulShard = transPortLate("SenseIncreaseField"), GillsSoulShard = transPortLate("GillsIncreaseField"), WingsSoulShard = transPortLate("WingsIncreaseField"), HideSoulShard = transPortLate("HideIncreaseField"), MetabolismSoulShard = transPortLate("MetabolismIncreaseField");
let DurationSoulShard = transPortLate("DurationIncreaseField"), RadiusSoulShard = transPortLate("RadiusIncreaseField"), CritSoulShard = transPortLate("CritIncreaseField"), RangeSoulShard = transPortLate("RangeIncreaseField"), ChannelSoulShard = transPortLate("ChannelIncreaseField");
//Soul Shards for magical power
let WrathSoulShard = transPortLate("WrathIncreaseField"), MercySoulShard = transPortLate("MercyIncreaseField"), VigourSoulShard = transPortLate("VigourIncreaseField");
let ArcanumSoulShard = transPortLate("ArcanumIncreaseField"), ReflectionSoulShard = transPortLate("ReflectionIncreaseField"), CurseSoulShard = transPortLate("CurseIncreaseField");
let EnvironSoulShard = transPortLate("EnvironIncreaseField"), BeastSoulShard = transPortLate("BeastIncreaseField"), BloodSoulShard = transPortLate("BloodIncreaseField");
let VampSoulShard = transPortLate("VampirismIncreaseField"), ArmySoulShard = transPortLate("ArmyIncreaseField"), DeathSoulShard = transPortLate("DeathIncreaseField");
let FireSoulShard = transPortLate("FireIncreaseField"), IceSoulShard = transPortLate("IceIncreaseField"), LightningSoulShard = transPortLate("LightningIncreaseField");
let MirrorSoulShard = ArcanumSoulShard + ReflectionSoulShard + CurseSoulShard, DruidicSoulShard = EnvironSoulShard + BeastSoulShard + BloodSoulShard, WhiteSoulShard = WrathSoulShard + MercySoulShard + VigourSoulShard, NecromancySoulShard = VampSoulShard + ArmySoulShard + DeathSoulShard, ElementalSoulShard = FireSoulShard + IceSoulShard + LightningSoulShard;
let attriShards = StrengthSoulShard + PerceptionSoulShard + AgilitySoulShard + CharismaSoulShard + EnduranceSoulShard + SenseSoulShard + GillsSoulShard + WingsSoulShard + HideSoulShard + ChannelSoulShard;
let magicShards = ElementalSoulShard + NecromancySoulShard + WhiteSoulShard + MirrorSoulShard + DruidicSoulShard + DurationSoulShard + RadiusSoulShard + CritSoulShard + RangeSoulShard + ChannelSoulShard;
let SoulShardTotal = SoulShards + attriShards + magicShards;
document.getElementById("SoulShardTotal").innerHTML="Soul Power Level "+SoulShardTotal;
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")+15, 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 AthleticsLevelUpXP*s1+EvasionLevelUpXP*s2+StealthLevelUpXP*s3+NegotiationLevelUpXP*s4+CharmLevelUpXP*s5+CommandLevelUpXP*s6+MedicalLevelUpXP*s7+NatureLevelUpXP*s8+EngineeringLevelUpXP*s9+ArcanaLevelUpXP*s10+SecurityLevelUpXP*s11+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)+2;
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)+2;
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)+2;
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)+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)+2;
//This is the calculation of the Attribute Score and the resulting Attribute Modification. The values are analogous to the D20 System.
let Strength=(Math.log(StrengthXP)/Math.log(2.1)+StrengthSoulShardTotal)*2, Perception=(Math.log(PerceptionXP)/Math.log(2.1)+PerceptionSoulShardTotal)*2, Agility=(Math.log(AgilityXP)/Math.log(2.1)+AgilitySoulShardTotal)*2, Charisma=(Math.log(CharismaXP)/Math.log(2.1)+CharismaSoulShardTotal)*2, Endurance=(Math.log(EnduranceXP)/Math.log(2.1)+EnduranceSoulShardTotal)*2;
//Complete calculation of SkillXP
let AthleticsTotalXP = AthleticsLevelUpXP+AthleticsItemXP;
let EvasionTotalXP = EvasionLevelUpXP+EvasionItemXP;
let StealthTotalXP = StealthLevelUpXP+StealthItemXP;
let NegotiationTotalXP = NegotiationLevelUpXP+NegotiationItemXP;
let CharmTotalXP = CharmLevelUpXP+CharmItemXP;
let CommandTotalXP = CommandLevelUpXP+CommandItemXP;
let MedicalTotalXP = MedicalLevelUpXP+MedicalItemXP;
let NatureTotalXP = NatureLevelUpXP+NatureItemXP;
let EngineeringTotalXP = EngineeringLevelUpXP+EngineeringItemXP;
let ArcanaTotalXP = ArcanaLevelUpXP+ArcanaItemXP;
let SecurityTotalXP = SecurityLevelUpXP+SecurityItemXP;
let Liberal_ArtsTotalXP = 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 (Strength*a1+Perception*a2+Agility*a3+Charisma*a4+Endurance*a5-50)/20;
}
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 = Endurance*1.61 + HealthItem + HealthTemp;
let Health = HealthMAX-HealthDamage;
let ArmorClass = Math.pow(SkillCalc((Perception*0.25+Agility*0.5+Endurance*0.25)/3+ArmorTotal)/4,3); //Damage Reduction as follows: Damage/(ArmorClass+1)*2
let Mana = (Charisma-10)/2+2+SkillCalc(ChannelSoulShard); //how long spellcasting can be maintained
let Exertion = (Endurance-10)/3+3;
let Composure=(Perception+Charisma-20)/2, Reaction=(Perception+Agility-20)/2, Fortitude=(Strength+Endurance-20)/2;
let armorWeight = 0;
let encumberance = 0;
let walkSpeed = document.getElementById("WalkSpeed");
let swimSpeed = document.getElementById("SwimSpeed");
let jumpDistance = document.getElementById("JumpDistance");
walkSpeed.innerHTML = Math.round(100/((20+encumberance)/Math.exp((SkillCalc(AthleticsValue)/2.5+SkillCalc(Strength*0.5+Agility*1.25+Endurance*0.4+AthleticsValue*25))/20))*36)/10;
swimSpeed.innerHTML = Math.round(100/((80+encumberance)/Math.exp((SkillCalc(AthleticsValue)/2.5+SkillCalc(Strength*1.25+Agility*0.4+Endurance*0.5+AthleticsValue*25))/20))*36)/10;
jumpDistance.innerHTML = Math.round(100/((100+encumberance)/Math.exp((SkillCalc(AthleticsValue)/2+SkillCalc(Strength+Agility+Perception*0.75+AthleticsValue*50))/20))*36)/10;
console.log(Exertion)
function Weapon (name, slash, hew, stab, weight, range, level){
const assocDam = name + "Dam";
const weaponDamage = document.getElementById(assocDam)
const weaponSlashDamage = Math.round((range + weight)*1.01**(level*5 + SlashValue)*slash*Agility*100)/100
const weaponHewDamage = Math.round((range + weight)*1.01**(level*5 + HewValue)*hew*Strength*100)/100
let stabAbility;
if (Agility>Strength) {stabAbility = Agility;}else{stabAbility = Strength;}
const weaponStabDamage = Math.round((range + weight)*1.01**(level*5 + StabValue)*stab*stabAbility*100)/100
weaponDamage.innerHTML = Math.max(weaponSlashDamage, weaponHewDamage, weaponStabDamage)
const assocIni = name + "Ini"
const weaponSpeed = document.getElementById(assocIni)
weaponSpeed.innerHTML = Math.round(0.99**((Agility+Perception)*2)*Math.exp((weight+range)/5)*50)/100
const SelfDam = document.getElementById(name + "DamSelf");
SelfDam.innerHTML = Math.round(weaponDamage.innerHTML*2/(ArmorClass+1)*100)/100;
}
function SpellSummon(spell) {
const num = Mana/0.99**((Agility+Perception)*2)/Math.exp(1/5)*2
const assocDam = spell+"Dam"
const spelldamage = document.getElementById(assocDam)
spelldamage.innerHTML = Math.round(1.01**(NecroValue)*(NecroValue/4+Perception/2+SilentKnightSoulShard+(VampSoulShard+ArmySoulShard+DeathSoulShard)*2/5+transPortLate("VampKnightField")+transPortLate("ArmyKnightField")+transPortLate("DeathKnightField"))*num*100)/100
const assocIni = spell+"Ini"
const spellSpeed = document.getElementById(assocIni)
spellSpeed.innerHTML = Math.round(0.99**((Agility+Perception)*2)*Math.exp(1/5)*50*num)/100
}
/*function SpellChannel (name, Skill, branch) {
const num = 1/0.99**((Agility+Perception)*2)*2
const spellDamage = document.getElementById(name + "Dam")
spellDamage.innerHTML = Math.round(1.01**(Skill)*(Skill/4+Perception/2+branch+transPortLate(name + "SoulShardField")+transPortLate(name + "SoulReceptacleField"))*num*100)/100;
const spellSpeed = document.getElementById(name + "Ini")
spellSpeed.innerHTML = Math.round(0.99**((Agility+Perception)*2)*50*num)/100
}*/
function Spell (name, skill, branch) {
const RanIni = transPortLate(name + "RanIni")*Mana*3/100;
const RanDur = transPortLate(name + "RanDur");
const RanRad = transPortLate(name + "RanRad");
const Time = document.getElementById(name + "Time");
Time.innerHTML = Math.round(RanIni*100)/100;
const num = RanIni/0.99**((Agility+Perception)*2)*2
const SelfDam = document.getElementById(name + "SelfDam");
SelfDam.innerHTML = Math.round(((RanIni**3/3/Mana-RanIni**2+Mana*RanIni)*RanIni-(RanIni**3/3/Mana-RanIni**2+Mana*RanIni)*Mana)*33)/100;
const spellIni = document.getElementById(name + "Ini");
spellIni.innerHTML = Math.round(0.99**((Agility + Perception)*2)*50*num)/100;
let IniXP = 1.01**(skill)*(skill/4+Perception/2+branch+transPortLate(name + "SoulShardField")+transPortLate(name + "SoulReceptacleField"))*num;
let XP = IniXP;
let DurXP = ((1-RanDur/200)*XP)+((1-RanDur/100)*XP)*SkillCalc(DurationSoulShard*(1-RanDur/100)/10);
const spellDur = document.getElementById(name + "Dur");
spellDur.innerHTML = Math.round(((RanDur*6/10 + RanDur*XP/100)+(RanDur*6/10 + RanDur*XP/100)*SkillCalc(DurationSoulShard))*50)/100
XP = DurXP;
let RadXP = Math.round((((1-RanRad/200)*XP)+((1-RanRad/100)*XP)*SkillCalc(RadiusSoulShard*(1-RanRad/100)/10))*100)/100;
const spellRad = document.getElementById(name + "Rad");
spellRad.innerHTML = Math.round(SkillCalc(RanRad)*Math.sqrt(RadiusSoulShard)*Math.PI*10)/100;
XP = RadXP;
const spellCrit = document.getElementById(name + "Crit");
const spellDamage = document.getElementById(name + "Dam");
spellDamage.innerHTML = Math.round((XP+XP*SkillCalc(magicShards)/10)*100)/100;
XP = spellDamage.innerHTML;
const DamSelf = document.getElementById(name + "DamSelf");
let Armor = Reaction/Math.exp(RangeSoulShard/(Reaction+1));
DamSelf.innerHTML = Math.round((spellDamage.innerHTML*2/(Armor+1))*100)/100;
spellCrit.innerHTML = Math.round(XP*(1-Math.exp(-(CritSoulShard+1)/SkillCalc(XP)))*100)/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
//Spell("ArcaneBolt", MirrorValue, ArcanumSoulShard);
//SpellChannel("ReflectChannel", MirrorValue, ReflectionSoulShard);
Spell("FireBolt", ElementalValue, FireSoulShard);
//SpellChannel("VampDrain", NecroValue, VampSoulShard);
//Spell("ArmyMinion", NecroValue, ArmySoulShard);
let StrengthDisplay=Math.floor(Strength);
let PerceptionDisplay=Math.floor(Perception);
let AgilityDisplay=Math.floor(Agility);
let CharismaDisplay=Math.floor(Charisma);
let EnduranceDisplay=Math.floor(Endurance);
function displayCharTest() {
document.getElementById("Str").innerHTML = StrengthDisplay;
document.getElementById("Per").innerHTML = PerceptionDisplay;
document.getElementById("Agi").innerHTML = AgilityDisplay;
document.getElementById("Cha").innerHTML = CharismaDisplay;
document.getElementById("End").innerHTML = EnduranceDisplay;
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;
document.getElementById("FireBoltRanIni").onchange = fillVals;
document.getElementById("FireBoltRanDur").onchange = fillVals;
document.getElementById("FireBoltRanRad").onchange = fillVals;
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 Math.round((storeGaussVal*mean/3.6+mean)*100)/100
}
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("FireBoltPress").addEventListener("click", eventHandler);
document.getElementById("VampDrainPress").addEventListener("click", eventHandler);
document.getElementById("FireBoltSoulShardButton").addEventListener("click", SoulShardIncrease);
document.getElementById("FireBoltSoulReceptacleButton").addEventListener("click", SoulShardIncrease);
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("SenseIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("GillsIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("WingsIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("HideIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("MetabolismIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("DurationIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("RadiusIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("CritIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("RangeIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("ChannelIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("WrathIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("MercyIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("VigourIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("FireIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("IceIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("LightningIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("EnvironIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("BeastIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("BloodIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("ArcanumIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("ReflectionIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("CurseIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("ArmyIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("VampirismIncreaseButton").addEventListener("click", SoulShardIncrease);
document.getElementById("DeathIncreaseButton").addEventListener("click", SoulShardIncrease);
fillVals()