Some times Pender, Nalfar, Ritic and Senick. Miss there shots why does this happen
can you send me a screenshot?
here is Pender
See that dark patch down there right next to the red dot that is where Pender shot and missed.
This is Senick
there is a dart above that is above the living enemy that is Senicks shot
If rangers and wizards can miss their shots then people would loose the level because of that.
As far as I know heroes can miss if:
- they shoot the target that is stands still and after shot starts to move or
- they shoot the target that moved to certain direction (with constant velocity) and changed it (or velocity) after shot.
Single-player levels are made in such a way that one miss doesn’t make a big difference, aren’t they?
And multiplayer ones are supposed to be of win/lose matter)
Not necessarily true @Alexbrand I lost a Fine Mint because Pender missed the Peons
Did you miss all the shots?
Maybe you can modify your function attackEnemy()? F.e. you can shoot enemy while his HP more than 0 maybe.
It senick just missed like 3 times pender forget about it
I think just some types of hero’s just have lousy shots
milton.jinich : pender forget about it
Alexbrand : while his HP more than 0
/click to see animation/
Yes, Alex - it works, but it’s an ugly solution.
Fie!)Many of my code tricks can be described the same way) It doesn’t hinder them to work though) Oh, I see the problem, animation helps, thanks.
To be serious, it was the first thing came to my mind. I haven’t much experience with Pender, but I think distanceTo(enemy) might help also. And some kind of spells maybe (smth to slow the enemies down).
Something that always perplexed me, why this piece of code doesn’t work consistently:
var enemy = hero.findNearestEnemy();
while (enemy && enemy.health >0 ) {
console.log(enemy.id + " target: " + enemy.target);
hero.attack(enemy);
}
output:
Thanks guys I’ll try to put these strategies to use
You have Boss Star III , so you are at least in the end of mountain, so maybe you always try to use the “best” weapon available . Don’t nuke the poor peons, the default code will be OK for a wizard with the weakest Enchanted Stick.
I am not in the mountain I just went to the level that gave me boss star III
I am at the very first levels of the mountain
In this case i’m using:
var param = 3/4;
var n = 0;
function attackEnemy() {
var coin = hero.findNearestItem();
var enemy = hero.findNearestEnemy();
if (enemy && coin){
var x = (enemy.pos.x + coin.pos.x)*param;
var y = (enemy.pos.y + coin.pos.y)*param;
while(hero.distanceTo(Vector(x,y))> 0)
hero.move(Vector(x,y));
}
while (enemy && ++n <= 2 ) {
hero.attack(enemy);
console.log(enemy.id + " health:" + enemy.health + " attack #" + n );
}
n = 0;
}
The wizard is with vine staff
I was hoping the code will work with n<=1, but this is not the case - the peon is still alive.
while (enemy && ++n <= 2 ) // n<= 1 fails;
n<= 3
animation with n <= 2 ( click to see)
If i replace the wizard with a ranger and a similar DPS weapon , the ranger needs only one shot to defeat the enemy.
Only the weakest wizard staff succeeds to have the task done in one shot.
Why are the wizard weapons so inaccurate?
Wow, I just wanted to say how beautiful that code is! Going onto the peons course is such a good idea.
About this code not working:
I may be missing the point of this code, but I’ve used enemy.target quite a lot and I think the reason this code isn’t working is because enemy.target is an object, not a string like enemy.id. So I think it would be like running:
console.log(enemy.id + " target: " + enemy)
enemy.target can only be another unit as far as I know. I tried the following code on “A fine mint” and the if never ran, whereas on “Woodland cleaver” I get this result (Screenshot below )
while (true) {
var enemy = hero.findNearestEnemy();
if (enemy && enemy.target) {
var target = enemy.target;
var x = Math.round(target.pos.x);
x = String(x);
var y = Math.round(target.pos.y);
y = String(y);
var id = target.id;
hero.say(enemy.id + "'s target's position is: " + x + y);
}
}
28, 17 is of course Illia’s position. This would definitely work with summoned troops as well.
So in conclusion, it seems enemy.target only includes other units, and never items. You can find the pos of the enemy’s target and also it’s .id (although I haven’t used that in the screenshot). There also doesn’t seem to be a .targetPos function for enemies, which I think would be quite cool.
Danny
P.S. If you want console and String to look blue and cool (as well as having var and other commands in bold) you can put ```javascript at the top of the code. (I’ll always thank @ Shurutsue for that. Unfortunately no longer active…)
I used the Precision Rifle and the Vine Staff. So I have to use the enchanted Stick to get the Job done