Skip to content

Commit

Permalink
Airdrop glitch fix
Browse files Browse the repository at this point in the history
This fixes most of the issues with airdrops. There are still rare cases when they will go on top of each other but its much less common now.
  • Loading branch information
hotDuckWhatsUp committed Jun 30, 2024
1 parent 84691c4 commit 355ca49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
12 changes: 11 additions & 1 deletion server/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,12 +1026,22 @@ export class Game implements GameData {
for (const airdrop of this.airdrops) {
thisHitbox = crateHitbox.transform(position);
const thatHitbox = (airdrop.type.spawnHitbox ?? airdrop.type.hitbox).transform(airdrop.position);
const unchangedHitbox = thisHitbox.clone();

if (thisHitbox.collidesWith(thatHitbox)) {
collided = true;
thisHitbox.resolveCollision(thatHitbox);

position = thisHitbox.getCenter();

if (unchangedHitbox.toRectangle().min.x == thisHitbox.toRectangle().min.x && unchangedHitbox.toRectangle().min.y == thisHitbox.toRectangle().min.y) {
const crateLength = airdrop.type.spawnHitbox!.toRectangle().max.x - airdrop.type.spawnHitbox!.toRectangle().min.x;

Check failure on line 1038 in server/src/game.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion

Check failure on line 1038 in server/src/game.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion

Check failure on line 1038 in server/src/game.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion

Check failure on line 1038 in server/src/game.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
const random = Math.floor(Math.random() * 2);

if (random == 0) position.x = position.x + crateLength;
else position.x = position.x - crateLength;
}
}
position = thisHitbox.getCenter();
if (collided) break;
}

Expand Down
18 changes: 0 additions & 18 deletions server/src/objects/parachute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,6 @@ export class Parachute extends BaseGameObject<ObjectCategory.Parachute> {
amount: Infinity,
source: crate
});
// Hacky hacky solution probably not the smartest solution atm but fuck it we ball :shrug:
if (object.definition.idString == "airdrop_crate_locked" && object != crate) {
let xDif = crate.position.x - object.position.x;
if (xDif <= 0) {
xDif = xDif + 10;
} else {
xDif = xDif - 10;
}
let yDif = crate.position.y - object.position.y;
if (yDif <= 0) {
yDif = yDif + 10;
} else {
yDif = yDif - 10;
}
const position = Vec.create(xDif, yDif);
crate.hitbox = object.hitbox.transform(position);
crate.position = crate.hitbox.getCenter();
}
break;
}
case object instanceof Building && object.scopeHitbox?.collidesWith(crate.hitbox): {
Expand Down

0 comments on commit 355ca49

Please sign in to comment.