Skip to content

Commit

Permalink
different firing method
Browse files Browse the repository at this point in the history
  • Loading branch information
onlypuppy7 committed Dec 12, 2024
1 parent 2c4f26e commit a0980d8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
43 changes: 27 additions & 16 deletions server-client/src/client-static/src/shellshock.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -6030,29 +6030,41 @@ function releaseKeys() {
document.onkeyup = null; keysReleased = true;
};

function setControlKeys(control, once) {
var bit = CONTROL[control];
var controlKeys = me.controlKeys;

controlKeys |= bit;
me.stateBuffer[me.stateIdx].controlKeys = controlKeys;
me.controlKeys = controlKeys;

if (once) {
setTimeout(function () {
me.controlKeys ^= me.controlKeys & bit;
}, 1e3 / 30);
};

// console.log(control, controlKeys, me.controlKeys, me.stateBuffer[me.stateIdx].controlKeys, once);
};

function inputDown(code) {
me.playing && (document.pointerLockElement || unfocused) && function (control) {
switch (control) {
case "up":
case "down":
case "left":
case "right":
var bit = CONTROL[control];
me.controlKeys |= bit;
me.stateBuffer[me.stateIdx].controlKeys = me.controlKeys;
break;
case "jump":
if (0 < me.lastTouchedGround && Date.now() > me.lastTouchedGround + 100 && me.jump()) {
// var output = new Comm.Out(1);
// output.packInt8(Comm.Code.jump);
// wsSend(output, "jump");
var bit = CONTROL[control];
me.controlKeys |= bit;
me.stateBuffer[me.stateIdx].controlKeys = me.controlKeys;
};
setControlKeys(control);
break;
case "fire":
document.pointerLockElement && me && me.pullTrigger();
case "jump":
setControlKeys(control, true);
// if (0 < me.lastTouchedGround && Date.now() > me.lastTouchedGround + 100 && me.jump()) {
// // var output = new Comm.Out(1);
// // output.packInt8(Comm.Code.jump);
// // wsSend(output, "jump");
// };
break;
case "grenade":
document.pointerLockElement && me && !grenadePowerUp && me.canSwapOrReload() && 0 < me.grenadeCount && (grenadePowerUp = true, grenadeThrowPower = -.15);
Expand Down Expand Up @@ -6081,15 +6093,14 @@ function inputDown(code) {
function inputUp(code, control) {
me.playing && (document.pointerLockElement || unfocused) && function (control) {
switch (control) {
case "fire":
me.weapon && me.releaseTrigger();
break;
case "scope":
settings.holdToAim && me.actor.scopeOut();
break;
case "grenade":
document.pointerLockElement && me && grenadePowerUp && (document.getElementById("grenadeThrowContainer").style.visibility = "hidden", grenadePowerUp = false, me.throwGrenade(grenadeThrowPower));
break;
case "fire":
me.weapon && me.releaseTrigger();
case "up":
case "down":
case "left":
Expand Down
7 changes: 3 additions & 4 deletions server-game/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ class newClient {
} else if ("" != text) {
if (text.startsWith("/")) {
this.room.perm.inputCmd(this.player, text);
} else if (!this.room.censor.detect(text, true)) { //todo, ratelimiting
text = fixStringWidth(text, maxChatWidth * 1.25); // giving slight leeway to prevent cutoffs
} else if (!this.room.censor.detect(text, true)) {
text = fixStringWidth(text, maxChatWidth * 1.25); // giving slight leeway to prevent cutoffs
var output = new Comm.Out();
if (text.startsWith("@")) {
var {mentions} = parseMentions(text, this);
Expand All @@ -309,9 +309,8 @@ class newClient {
this.sendToOthers(output, this.id, "chat: " + text);
};
};
this.player.chatLineCap--;
};

this.player.chatLineCap--;
break;
case Comm.Code.reload:
this.player.reload();
Expand Down
2 changes: 1 addition & 1 deletion src/shell/guns.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gun.prototype.update = function (delta) {
Gun.prototype.collectAmmo = function () {
return this.actor ? (this.ammo.store = Math.min(this.ammo.storeMax, this.ammo.store + this.ammo.pickup), true) : this.ammo.store < this.ammo.storeMax && (this.ammo.store = Math.min(this.ammo.storeMax, this.ammo.store + this.ammo.pickup), true)
};
Gun.prototype.fire = function (sendToAll) {
Gun.prototype.fire = function () {
if (this.actor) this.actor.fire();
else { //if server, actually make the bullet and fire that shit

Expand Down
3 changes: 2 additions & 1 deletion src/shell/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ class Player {
this.throwGrenade();
};
};
var oldMethod = false; //new method might be better
if (this.actor) {
this.id == meId && this.triggerPulled && this.fire()
} else if (0 < this.shotsQueued) {
} else if (oldMethod ? 0 < this.shotsQueued : this.controlKeys & CONTROL.fire) {
this.lastActivity = Date.now();
this.fire();
};
Expand Down

0 comments on commit a0980d8

Please sign in to comment.