Skip to content

Commit

Permalink
redo kb
Browse files Browse the repository at this point in the history
  • Loading branch information
onlypuppy7 committed Jan 24, 2025
1 parent 0a7462a commit 7bf48a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 13 additions & 5 deletions server-client/src/client-static/src/shellshock.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ const LegacyShellOnMessage = async function (msg) {
playSoundIndependent2D("endRound");
timeout.set(showContinueDialog, 3e3);

for (var i = 0; i < playerLimit; i++) {
var player = players[i];
if (player) {
player.removeFromPlay();
};
};

let nextRound = NextRoundTimeout;
if (betweenRounds && gameOptions.timedGame.spawnDuringInterval) nextRound = 4;
setRespawnTime(nextRound);
Expand Down Expand Up @@ -1098,23 +1105,23 @@ const LegacyShellOnMessage = async function (msg) {
var hp = input.unPackInt8U();
var dx = input.unPackFloat();
var dz = input.unPackFloat();
var kb = input.unPackFloat();
var originalDamage = input.unPackInt16U() * 10;
me.hp = hp;
me.actor.hit();
me.knockback(kb, dx, dz);
me.knockback(originalDamage, dx, dz);
hitIndicator.hit(dx, dz);
break;
case Comm.Code.hitThem:
var id = input.unPackInt8U();
var hp = input.unPackInt8U();
var dx = input.unPackFloat();
var dz = input.unPackFloat();
var kb = input.unPackFloat();
var originalDamage = input.unPackInt16U() * 10;
var player = players[id];
if (!player) break;
player.hp = hp;
player.actor.hit();
player.knockback(kb, dx, dz);
player.knockback(originalDamage, dx, dz);
0 < hp && shellFragBurst(player, 30, .07, 20);
break;
case Comm.Code.respawn:
Expand Down Expand Up @@ -2297,6 +2304,7 @@ function GunActor(gun, meshName) {
};
GunActor.prototype.setup = function (muzFlashZ) {
this.gunMesh = this.scene.cloneMesh(this.meshName, this.playerActor.gunContainer);
this.gunMesh.material = this.scene.getMaterialByName("standard");

if (shadowGen && fancyShadows) {
shadowGen.getShadowMap().renderList.push(this.gunMesh);
Expand Down Expand Up @@ -4563,7 +4571,7 @@ function resetGame() {
var player = players[i];
if (player) {
plugins.emit('resetGamePlayer', {player});
player.removeFromPlay();
// player.removeFromPlay();
player.score = 0;
player.kills = 0;
player.deaths = 0;
Expand Down
18 changes: 9 additions & 9 deletions src/shell/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,17 +974,19 @@ class Player {
})();
};
};
knockback(kb, dx, dz) {
kb *= 0.01;
knockback(originalDamage, dx, dz) {
let kb = originalDamage * 0.01 * this.knockbackModifier;
let explosion = originalDamage > 100;

let kbX = dx * kb
let kbZ = dz * kb
let kbY = kb * 10;
let kbY = kb * (explosion ? 10 : 0.2);

this.dx += kbX;
this.dy += kbY;
this.dz += kbZ;

devlog("knockback:", kb, dx, dz, kbX, kbZ, kbY);
devlog("knockback:", originalDamage, kb, dx, dz, kbX, kbZ, kbY, explosion);
};
hit (damage, firedPlayer, dx, dz, noHeal = false, originalDamage) {
if (this.isDead() || (!this.playing)) return;
Expand All @@ -1010,14 +1012,12 @@ class Player {
// console.log("who REALLY fired?", firedPlayer.id, firedPlayer.name)
this.setHp(this.hp - damage, firedPlayerId);

let kb = Math.min(originalDamage, 50) * this.knockbackModifier;

var output = new Comm.Out();
output.packInt8U(Comm.Code.hitMe);
output.packInt8U(this.hp);
output.packFloat(dx);
output.packFloat(dz);
output.packFloat(kb); //kb
output.packInt16U(Math.floor(originalDamage / 10)); //kb
this.client.sendToMe(output, "hitMe");

var output = new Comm.Out();
Expand All @@ -1026,10 +1026,10 @@ class Player {
output.packInt8U(this.hp);
output.packFloat(dx);
output.packFloat(dz);
output.packFloat(kb); //kb
output.packInt16U(Math.floor(originalDamage / 10)); //kb
this.client.sendToOthers(output, "hitThem");

this.knockback(kb, dx, dz);
this.knockback(originalDamage, dx, dz);
};
};
heal (health, damagedPlayer = this, dx = 0, dz = 0) {
Expand Down

0 comments on commit 7bf48a6

Please sign in to comment.