Only auto aim and healthbars
This commit is contained in:
1 parent
54c6327ac7
commit
a914bd74fe
14 files changed
+95
-89
No files matched your search
+9
-14
@@ -60,8 +60,6 @@ final class Player extends GameObject
|
||||
|
||||
public bool $dead = false;
|
||||
|
||||
public bool $autoAim = false;
|
||||
|
||||
private float $cooldown = 0.0;
|
||||
|
||||
private Vector2 $aimDirection;
|
||||
@@ -154,22 +152,19 @@ final class Player extends GameObject
|
||||
);
|
||||
|
||||
$aim = $this->input->aim;
|
||||
$autoAimActive = $this->input->autoAim || $this->autoAim;
|
||||
$hasTarget = false;
|
||||
if ($autoAimActive) {
|
||||
$nearest = $this->nearestZombie();
|
||||
if ($nearest !== null) {
|
||||
$hasTarget = true;
|
||||
$toEnemy = $nearest->pos->subV($this->pos);
|
||||
if ($toEnemy->lengthSquared() > 1.0) {
|
||||
$aim = $toEnemy;
|
||||
}
|
||||
$nearest = $this->nearestZombie();
|
||||
if ($nearest !== null) {
|
||||
$hasTarget = true;
|
||||
$toEnemy = $nearest->pos->subV($this->pos);
|
||||
if ($toEnemy->lengthSquared() > 1.0) {
|
||||
$aim = $toEnemy;
|
||||
}
|
||||
}
|
||||
if ($aim->lengthSquared() > 1.0) {
|
||||
$this->aimDirection = $aim->divS($aim->length());
|
||||
} elseif ($aim->lengthSquared() > 0.01 && $this->input->aim !== null && ! $autoAimActive) {
|
||||
// Raw normalized direction from the client when not auto-aiming.
|
||||
} elseif ($aim->lengthSquared() > 0.01 && $this->input->aim !== null) {
|
||||
// Use the raw client direction when no auto-aim target is near.
|
||||
$this->aimDirection = $aim->normalize();
|
||||
}
|
||||
|
||||
@@ -177,7 +172,7 @@ final class Player extends GameObject
|
||||
$this->damageCooldown = max(0.0, $this->damageCooldown - $dt);
|
||||
|
||||
$this->cooldown -= $dt;
|
||||
if ($this->cooldown <= 0.0 && ($this->input->fire || ($autoAimActive && $hasTarget))) {
|
||||
if ($this->cooldown <= 0.0 && ($this->input->fire || $hasTarget)) {
|
||||
$this->cooldown = $this->fireRate;
|
||||
$this->shoot();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user