fix eta for projectiles (#152)

This commit is contained in:
Kent Rasmussen
2024-09-10 15:54:15 +02:00
committed by GitHub
parent ecba0edd9c
commit 234ee1fe71
+4 -5
View File
@@ -3011,7 +3011,6 @@ function commence_attack(attacker, target, atype) {
} }
var pid = randomStr(6); var pid = randomStr(6);
var eta = 0;
info.first_attack = info.attack = attack; info.first_attack = info.attack = attack;
info.def = def; info.def = def;
def.damage_type = info.damage_type; def.damage_type = info.damage_type;
@@ -3028,7 +3027,7 @@ function commence_attack(attacker, target, atype) {
source: atype, source: atype,
x: target.x, x: target.x,
y: target.y, y: target.y,
eta: 400, eta: 0,
m: target.m, m: target.m,
pid: pid, pid: pid,
}; };
@@ -3052,12 +3051,12 @@ function commence_attack(attacker, target, atype) {
} }
if (!(G.projectiles[def.projectile] && G.projectiles[def.projectile].instant)) { if (!(G.projectiles[def.projectile] && G.projectiles[def.projectile].instant)) {
eta = (1000 * dist) / G.projectiles[def.projectile].speed; action.eta = Math.floor((1000 * dist) / G.projectiles[def.projectile].speed);
} else { } else {
action.instant = true; action.instant = true;
} }
info.eta = future_ms(eta); info.eta = future_ms(action.eta);
if (info.heal) { if (info.heal) {
action.heal = attack; action.heal = attack;
@@ -3073,7 +3072,7 @@ function commence_attack(attacker, target, atype) {
info.action = action; info.action = action;
xy_emit(attacker, "action", action, target.id); xy_emit(attacker, "action", action, target.id);
if (!eta) { if (!action.eta) {
projectiles_loop(); projectiles_loop();
} }