Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airdrop glitch fix #355

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 && airdrop.type.spawnHitbox != undefined) {
const crateLength = airdrop.type.spawnHitbox.toRectangle().max.x - airdrop.type.spawnHitbox.toRectangle().min.x;
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
20 changes: 1 addition & 19 deletions server/src/objects/parachute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GameConstants, KillfeedEventType, ObjectCategory } from "../../../commo
import { CircleHitbox } from "../../../common/src/utils/hitbox";
import { Angle, Numeric } from "../../../common/src/utils/math";
import { type FullData } from "../../../common/src/utils/objectsSerializations";
import { Vec, type Vector } from "../../../common/src/utils/vector";
import { Vector } from "../../../common/src/utils/vector";
import { type Airdrop, type Game } from "../game";
import { Events } from "../pluginManager";
import { Building } from "./building";
Expand Down 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
Loading