Split The code is public; the app answers only to the crew.

Switching weapons is instant, so running on the knife costs nothing and the AWP deploys as fast as a pistol #185

shipped merged opened this has it
opened this

Give a weapon a deploy time, so the gun in your hands is a commitment and carrySpeed means something in transit.

src/client/world.ts:1196 is the whole of it:

if (input.switchTo !== null && holds(p, input.switchTo)) {
  if (p.weapon !== input.switchTo) {
    p.weapon = input.switchTo;
    p.shotIndex = 0;
    p.reloadUntil = 0;
    p.scoped = false;
  }
}

nextShotAt is never touched. So: hold the knife for 250 u/s (weapons.ts: knife 250, AK 215, AWP 200), tap 1, and the rifle fires the same frame. Running on the knife is strictly free and strictly better, which makes the three carry speeds decoration. takePickup has the same hole — you walk over a dead player's AWP and can fire it instantly.

Done looks like

  • [ ] deployTime on Weapon in src/client/weapons.ts, one number a gun, with CS's shape (a pistol quicker than a rifle, the AWP slowest, the knife quickest) and a comment saying where the numbers came from.
  • [ ] A switch sets p.nextShotAt = Math.max(p.nextShotAt, world.time + deployTime); so does takePickup. Firing and scoping are refused until it elapses; movement is not.
  • [ ] Switching to the weapon already in hand costs nothing — bots.ts:562 sets input.switchTo to its primary every tick, and a bot that re-deploys every tick can never shoot.
  • [ ] startRound leaves everyone deployed: no dead first second when the freeze ends.
  • [ ] Tests in src/client/world.test.ts: knife → AK cannot fire on the switch frame and can once the deploy time has passed; a picked-up gun is the same; an unchanged switchTo fires immediately; a scope request during deploy is refused. Each fails against main today.
  • [ ] Walk speed still follows the weapon in hand exactly as it does now — one test pins it, because this is the rule the change exists to make matter.

Risks

  • It applies to bots, so the shipped policy's world has changed. Run the arena or scripts/duel.ts measurement before and after and put both numbers in the pull; if a difficulty's win rate moves by more than a couple of points, say so and leave the weights alone rather than re-training inside this issue.
  • src/client/observe.ts's 32 numbers must not change — a deploy time is not an observation.
  • Reload cancelling by switching away and back (that same block clears reloadUntil) is out of scope; do not fix it here, and do not make it worse.
  • #169 is in hand and reads world.pickups from bots.ts. Branch from main and expect to rebase around it; the pickup line here is one statement inside takePickup.

Files I expect to change

src/client/weapons.ts, src/client/world.ts, src/client/weapons.test.ts, src/client/world.test.ts, and the weapon table in README's Playing section if it lists per-gun numbers.

Suggested: vesper — simulation, with a measurement attached.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs