Skip to content

Commit

Permalink
Allow getaway from most weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Dec 31, 2024
1 parent 9d31bd2 commit 28efac5
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/entities/phys/mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Mine extends TimedExplosive {

sprite.position = body.body.translation();
super(sprite, body, world, parent, {
explosionRadius: new MetersValue(4),
explosionRadius: new MetersValue(3.5),
explodeOnContact: false,
timerSecs: 5,
autostartTimer: false,
Expand Down
11 changes: 5 additions & 6 deletions src/entities/playable/worm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,6 @@ export class Worm extends PlayableEntity {
this.perRoundState.shotsTaken++;
// TODO: Need a middle state for while the world is still active.
this.cameraLockPriority = CameraLockPriority.NoLock;
if (this.weapon.getawayTime) {
this.state.transition(InnerWormState.Getaway);
} else {
this.state.transition(InnerWormState.InactiveWaiting);
}
this.fireWeaponDuration = 0;
this.onFireWeapon(this, this.currentWeapon, {
duration,
Expand All @@ -503,7 +498,11 @@ export class Worm extends PlayableEntity {
}).then((fireResult) => {
if (maxShots === this.perRoundState.shotsTaken) {
this.turnEndedReason = EndTurnReason.FiredWeapon;
this.state.transition(InnerWormState.Inactive);
if (this.weapon.allowGetaway) {
this.state.transition(InnerWormState.Getaway);
} else {
this.state.transition(InnerWormState.InactiveWaiting);
}
} else {
this.state.transition(InnerWormState.Idle);
}
Expand Down
10 changes: 10 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
-webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
:root {
--text: #bdbdbd;
--bg: #2e2e2e;
--highlight: #b96724;
--links: #df8b1c;
--subheading: #adadad;
}
}

a {
font-weight: 500;
color: #646cff;
Expand Down
3 changes: 3 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { render } from "preact";
import "./index.css";
import { App } from "./components/app";
import { loadAssets } from "./assets";

void loadAssets();

render(<App />, document.getElementById("app") as HTMLElement);
1 change: 1 addition & 0 deletions src/weapons/bazooka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const WeaponBazooka: IWeaponDefiniton = {
icon,
maxDuration: 80,
timerAdjustable: false,
allowGetaway: true,
showTargetGuide: true,
loadAssets(assets: AssetPack) {
fireSound = assets.sounds.bazookafire;
Expand Down
1 change: 1 addition & 0 deletions src/weapons/firework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const WeaponFireworkLauncher: IWeaponDefiniton = {
code: IWeaponCode.FireworkLauncher,
icon,
maxDuration: 80,
allowGetaway: true,
timerAdjustable: false,
showTargetGuide: true,
loadAssets(assets: AssetPack) {
Expand Down
1 change: 1 addition & 0 deletions src/weapons/grenade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const WeaponGrenade: IWeaponDefiniton = {
icon,
code: IWeaponCode.Grenade,
maxDuration: 50,
allowGetaway: true,
timerAdjustable: true,
showTargetGuide: true,
loadAssets(assets) {
Expand Down
1 change: 1 addition & 0 deletions src/weapons/homingMissile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const WeaponHomingMissile: IWeaponDefiniton = {
code: IWeaponCode.HomingMissile,
icon,
maxDuration: 80,
allowGetaway: true,
timerAdjustable: false,
showTargetGuide: true,
showTargetPicker: true,
Expand Down
5 changes: 3 additions & 2 deletions src/weapons/mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const WeaponMine: IWeaponDefiniton = {
name: "Mine",
icon,
code: IWeaponCode.Mine,
getawayTime: 350,
allowGetaway: true,
loadAssets(assets) {
this.sprite = {
texture: assets.textures.mine,
Expand All @@ -18,6 +18,7 @@ export const WeaponMine: IWeaponDefiniton = {
};
},
fireFn(parent: Container, world: GameWorld, worm: Worm) {
return Mine.create(parent, world, worm.itemPlacementPosition, 3000);
// Getaway time + some time
return Mine.create(parent, world, worm.itemPlacementPosition, 7000);
},
};
1 change: 1 addition & 0 deletions src/weapons/shotgun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const WeaponShotgun: IWeaponDefiniton = {
timerAdjustable: false,
showTargetGuide: true,
shots: 2,
allowGetaway: true,
loadAssets(assets: AssetPack) {
fireSound = assets.sounds.shotgun;
this.sprite = {
Expand Down
2 changes: 1 addition & 1 deletion src/weapons/weapon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface IWeaponDefiniton {
/**
* Should the worm be given getaway time?
*/
getawayTime?: number;
allowGetaway?: boolean;

sprite?: {
texture: Texture;
Expand Down

0 comments on commit 28efac5

Please sign in to comment.