cs6413110 / Pixel-Tanks

0 stars 2 forks source link

boost i frames[BUG] #470

Closed 3foe closed 3 months ago

3foe commented 3 months ago

Details

Evan i know u wont care, but Aaron I want code evidence that it works I will provide my own that it doesn't work then the debate

CelestialKnight7 commented 3 months ago

skill issue

BreadSpam commented 3 months ago

ur probably mad at the I frames bc they are based on the person who boosted's screen, and not your screen

cs6413110 commented 3 months ago

This is the only code that registers damage.

damageCalc(x, y, a, u) {
    if ((this.immune && a > 0) || this.ded || this.reflect) return;
    const hx = Math.floor((this.x+40)/100), hy = Math.floor((this.y+40)/100);
    for (let i = Math.max(0, hx-1); i <= Math.min(29, hx+1); i++) for (let l = Math.max(0, hy-1); l <= Math.min(29, hy+1); l++) for (const entity of this.host.cells[i][l]) {
      if (entity instanceof Shot) if (entity.target) if (entity.target.id === this.id && entity.type === 'usb') a = Math.max(0, a+Math.min(Math.abs(a)/4, 5)*(Engine.getTeam(entity.team) === Engine.getTeam(this.team) ? -1 : 1));
    }
    if (this.shields > 0 && a > 0) return this.shields -= a;
    this.hp = Math.max(Math.min(this.maxHp, this.hp-a), 0);
    clearTimeout(this.damageTimeout);
    this.damageTimeout = setTimeout(() => {this.damage = false}, 1000);
    this.damage = {d: (this.damage ? this.damage.d : 0)+a, x, y};
    if (this.hp <= 0 && this.host.ondeath) this.host.ondeath(this, this.host.pt.concat(this.host.ai).find(t => t.username === u));
  }

The this.immune && a > 0 blocks damage if it isn't healing and if you are boosting this.immune is send directly to server in Engine.update:

update(data) {
    const t = this.pt.find(t => t.username === data.username);
    if (!t) return;
    data = data.data;
    const {emote, r, baseFrame, use, x, y, fire} = data;
    t.baseRotation = data.baseRotation;
    t.immune = data.immune;
    t.animation = data.animation;
    // ...

Client side boost iframes are set here:

keyLoop(e) {
    if (e.keyCode === PixelTanks.userData.keybinds.boost) {
      if (this.canBoost) {
        this.speed = 16;
        this.canBoost = false;
        this.tank.immune = true;
        this.timers.boost = Date.now();
        clearTimeout(this.booster);
        clearTimeout(this.boostTimeout);
        this.booster = setTimeout(() => {
          this.speed = 4;
          this.tank.immune = false;
          if (PixelTanks.userData.class === 'stealth') this.tank.use.push('break');
        }, 500);
        this.boostTimeout = setTimeout(() => {this.canBoost = true}, this.ded ? 0 : 5000);
      }
    }
  }

So you get 500ms of boost iframes.

CelestialKnight7 commented 3 months ago

how long does boost last?

BreadSpam commented 3 months ago

0.5 seconds, or 500 milliseconds

3foe commented 3 months ago

is there a start-up lag?

CelestialKnight7 commented 3 months ago

so its a skill issue and/or a lag issue. Ez

3foe commented 3 months ago

k still think there is start up lag but that's just lag in general