Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
fix: fix explosions and melee damage type
Browse files Browse the repository at this point in the history
  • Loading branch information
leia-uwu committed Mar 18, 2024
1 parent 639e21a commit 552f4c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/src/objects/obstacle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class Obstacle extends BaseGameObject {
}
}

kill(sourceType: string, damageType: number, source?: GameObject) {
kill(_sourceType: string, damageType: number, source?: GameObject) {
const def = MapObjectDefs[this.type] as ObstacleDef;
this.health = this.healthT = 0;
this.dead = true;
Expand Down Expand Up @@ -284,7 +284,7 @@ export class Obstacle extends BaseGameObject {
const explosion = new Explosion(def.explosion,
this.pos,
this.layer,
sourceType,
this.type,
damageType,
source
);
Expand Down
4 changes: 3 additions & 1 deletion server/src/objects/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Structure } from "./structure";
import net, { type InputMsg } from "../../../shared/net";
import { type Msg } from "../../../shared/netTypings";
import { type Loot } from "./loot";
import { MapObjectDefs } from "../../../shared/defs/mapObjectDefs";

export class Player extends BaseGameObject {
override readonly __type = ObjectType.Player;
Expand Down Expand Up @@ -757,7 +758,8 @@ export class Player extends BaseGameObject {

const killMsg = new net.KillMsg();
killMsg.damageType = damageType;
killMsg.itemSourceType = sourceType;
killMsg.itemSourceType = GameObjectDefs[sourceType] ? sourceType : "";
killMsg.mapSourceType = MapObjectDefs[sourceType] ? sourceType : "";
killMsg.targetId = this.id;
killMsg.killed = true;

Expand Down
14 changes: 12 additions & 2 deletions server/src/utils/weaponManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,20 @@ export class WeaponManager {
const obj = hit.obj;

if (obj.__type === ObjectType.Obstacle) {
obj.damage(meleeDef.damage * meleeDef.obstacleDamage, this.activeWeapon, GameConfig.DamageType.Player);
obj.damage(
meleeDef.damage * meleeDef.obstacleDamage,
this.activeWeapon,
GameConfig.DamageType.Player,
this.player
);
if (obj.interactable) obj.interact(this.player);
} else if (obj.__type === ObjectType.Player) {
obj.damage(meleeDef.damage, this.activeWeapon, GameConfig.DamageType.Player, this.player);
obj.damage(
meleeDef.damage,
this.activeWeapon,
GameConfig.DamageType.Player,
this.player
);
}
}
}
Expand Down

0 comments on commit 552f4c4

Please sign in to comment.