Skip to content

Commit

Permalink
Merge pull request #327 from kaklikOf13/Better/Loot
Browse files Browse the repository at this point in the history
refactor .: better loot animation
  • Loading branch information
hsanger authored Jun 4, 2024
2 parents 020fc13 + d3114af commit 10e1a73
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions client/src/scripts/objects/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ export class Loot extends GameObject {

// Play an animation if this is new loot
if (data.full.isNew && isNew) {
this.container.scale.set(0.5);
this.container.scale.set(0);
this.animation = this.game.addTween({
target: this.container.scale,
to: { x: 1, y: 1 },
duration: 1000,
ease: EaseFunctions.elasticOut,
duration: 700,
ease: EaseFunctions.quadraticOut,
onComplete: () => {
this.animation = undefined;
}
Expand Down
3 changes: 2 additions & 1 deletion common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ export const GameConstants = freezeDeep({
killLeaderMinKills: 3,
maxMouseDist: 128,
reviveTime: 8,
maxReviveDist: 5
maxReviveDist: 5,
},
lootSpawnDistance:.7,
airdrop: {
fallTime: 8000,
flyTime: 30000,
Expand Down
5 changes: 2 additions & 3 deletions server/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CircleHitbox } from "../../common/src/utils/hitbox";
import { EaseFunctions, Geometry, Numeric } from "../../common/src/utils/math";
import { Timeout } from "../../common/src/utils/misc";
import { ItemType, MapObjectSpawnMode, type ReferenceTo, type ReifiableDef } from "../../common/src/utils/objectDefinitions";
import { pickRandomInArray, randomFloat, randomPointInsideCircle, randomRotation } from "../../common/src/utils/random";
import { pickRandomInArray, randomFloat, randomPointInsideCircle, randomRotation, randomVector } from "../../common/src/utils/random";
import { OBJECT_ID_BITS, SuroiBitStream } from "../../common/src/utils/suroiBitStream";
import { Vec, type Vector } from "../../common/src/utils/vector";
import { Config, SpawnMode } from "./config";
Expand Down Expand Up @@ -815,10 +815,9 @@ export class Game {
const loot = new Loot(
this,
definition,
position,
Vec.add(position,randomVector(-GameConstants.lootSpawnDistance,GameConstants.lootSpawnDistance,-GameConstants.lootSpawnDistance,GameConstants.lootSpawnDistance)),
count
);

this.grid.addObject(loot);
return loot;
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/objects/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Loot extends BaseGameObject<ObjectCategory.Loot> {
*
* This particular exponent results in a 10% loss every 28.55ms (or a 50% loss every 187.8ms)
*/
private static readonly _dragConstant = Math.exp(-3.69 / GameConstants.tickrate);
private static readonly _dragConstant = Math.exp(-4 / GameConstants.tickrate);

constructor(game: Game, definition: ReifiableDef<LootDefinition>, position: Vector, count?: number) {
super(game, position);
Expand Down

0 comments on commit 10e1a73

Please sign in to comment.