When playing in the forest level “Tactical Timing”, my ranger is unable to use his gun. I have tried switching out my bought weapon with the freebie crossbow he came with, but no change. I also added the attack range thinking that could be the problem. I have him say a message to see if he’s firing and my eyes have just missed it, but he never says “bam!”.
Is this a game bug, or just something I’m missing in my code?
// Help out on the front line.
// Move back to a flag if any try to sneak by.
loop{
var enemy = this.findNearest(this.findEnemies());
var flag = this.findFlag();
if(flag){
this.pickUpFlag(flag);
}
if(enemy){
if(this.isReady("throw") && this.distanceTo(enemy) < this.throwRange){
this.throw(enemy);
}else if(this.canCast("chain-lightning", enemy)){
this.cast("chain-lightning", enemy);
}else if(this.canElectrocute(enemy)){
this.electrocute(enemy);
}else if(this.distanceTo(enemy) < this.attackRange){
this.attack(enemy);
this.say("bam!");
}else{
this.heal(this);
}
}
}
Heal has a cooldown. You’re telling yourself to heal when there’s no attackers in range. However, if you use heal before it is ready, then your hero is stuck trying to cast heal until it is ready. Add a if (this.canCast("heal")) {.
Also, self.say() can burn a lot of time. Whenever you say, your character stops for a long moment.
Also, you might want to clean up your special attack tests.
Electrocute only slows down the run speed of your target from the descriptions I have seen. So, if the target is already attacking you and you are not planning to run, why are you using it? Also, I think the canElectrocute already incorporates the cool down, but I could be wrong on that.
Chain-lightning has a long cool down and can jump between targets up to 8 times, doing less damage each time. You may want to consider checking to make sure there is another enemy within 20 feet of your first target. In Python, I might suggest:
TarB = enemy.findNearest(enemy.findEnemies())
if TarB:
…DistanceToTarB = enemy.DistanceTo(TarB)
…if DistanceToTarB < 20:
…self.cast(“chain-lightning”, enemy)
That way, there are at least 2 targets. Depending on level, you might want to check the .health of the first target is greater than 99 as well.
Actually, I think canElectrocute actually does incorporate the cooldown currently or it is a really short cool down as I have not noticed a significant pause while waiting for it to fire. If it doesn’t, wish I knew enough to be able to develop and submit a patch…
If we were programming in Basic (the original mind you), Pascal, LISP or Visual Basic for Applications (many, many years ago), I might have the nerve to propose such a patch. To be honest, I originally came here looking for ways to teach my youngest how to code and got into solving the problems. If you’re looking for a true coder, I’m a far better attorney these days.
That is incorrect. The Steel Ring’s electrocute ability has a cooldown of eight seconds, while the Emperor’s Gloves’ chain-lightning has a cooldown of twenty seconds.