I'm expanding my simple combat system into something a bit less simple and adding skill modifiers but I've hit a bit of a stumbling block. When I use the + operator to add a skill modifier to a die roll the 2 numbers are concatenated instead of added and producing a total.
Any help would be gratefully received.
set("RatHealth", "4");
set("RatCombatSkill", "1");
A large rat launches itself into the air, broken yellow teeth flashing.
<b>RAT</b><br>
COMBAT SKILL:1<br>
STRENGTH:1<br>
HEALTH:4<br>
[[attack the rat]](Rattack)
[[Rattack]]:
var jsRatCombatskill = get("RatCombatSkill");
var randomnumber = function rng(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
var jsCombatroll = randomnumber(1,6);
var jsCombatTotal = (jsCombatroll + jsRatCombatskill);
set ("Monsterhit", jsCombatTotal);
The rat atttacks with a roll of <b>{Monsterhit}</b>