I'm currently trying to figure out how to create a battle system bar for real time combat for a RTS i'm doing. The bar will move with CSS3 animation for 6 seconds, then turn green, allowing you to take a action. But I need it in a way that skills will only trigger when the time bar is full.
Any help?
// ATB DIV bar for the CSS3 animation
<div id="atbbar"> </div>
// ATTACK SKILL
document.getElementById("attack").addEventListener('click', function(){
var damage = Math.floor(Math.random() * characterstats.strength + 1);
damage -= dragonstats.armor;
dragon.hp -= damage;
if (damage <= 0) {
addMessage("Armor negated your attack!");
}
else {
document.getElementById("npchp").innerHTML = dragon.hp;
addMessage("You hit the dragon for " + damage + " hp!");
}
});