Skip to content

Commit 61791cb

Browse files
committed
Added Z ability sounds & delayed shots
1 parent b6213e2 commit 61791cb

File tree

9 files changed

+62
-15
lines changed

9 files changed

+62
-15
lines changed
17.7 KB
Binary file not shown.
23.4 KB
Binary file not shown.
97.9 KB
Binary file not shown.
18.6 KB
Binary file not shown.
154 KB
Binary file not shown.
62.7 KB
Binary file not shown.

resource_packs/whynot/sounds/sound_definitions.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@
2424
"dash": {
2525
"category": "player",
2626
"sounds": ["sounds/light/dash"]
27+
},
28+
29+
"light_bow_start_charge": {
30+
"category": "player",
31+
"sounds": ["sounds/light/light_bow_start_charge"]
32+
},
33+
"light_bow_charge": {
34+
"category": "player",
35+
"sounds": ["sounds/light/light_bow_charge"]
36+
},
37+
"light_bow_alarm": {
38+
"category": "player",
39+
"sounds": ["sounds/light/light_bow_alarm"]
40+
},
41+
"light_bow_shoot": {
42+
"category": "player",
43+
"sounds": ["sounds/light/light_bow_shoot"]
44+
},
45+
"light_ring_start": {
46+
"category": "player",
47+
"sounds": ["sounds/light/light_ring_start"]
48+
},
49+
"light_ring_explode": {
50+
"category": "player",
51+
"sounds": ["sounds/light/light_ring_explode"]
2752
}
2853
}
2954
}

scripts/addons/lightFruit/lightFruit.ts

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ const spinTrailTurnsPerSecond = 1.5
5050
const spinTrailRadius = 0.5
5151
const flySoundDuration = 7 //8.58
5252

53-
const ZChargeIncrease = 20
53+
const ZChargeIncrease = 8
5454
const ZChargeAmountMax = 3
5555

5656
const lightRayMaxLength = 25
5757
const lightRayDuration = 20*4
5858
const lightRayCooldown = 80
5959

6060
const zCooldownTime = 80
61+
const alarmSoundDuration = 4
6162

6263
class LightFlightVisual {
6364
lastSpin1: Vector3 | undefined
@@ -67,6 +68,7 @@ class LightFlightVisual {
6768
}
6869
const flyTurnCooldown: Map<string, number> = new Map()
6970
const flySoundCooldown: Map<string, number> = new Map()
71+
const alarmSoundCooldown: Map<string, number> = new Map()
7072
const airTime: Map<string, number> = new Map()
7173
const ignoreFall: Map<string, boolean> = new Map()
7274
const dashCooldown: Map<string, number> = new Map()
@@ -149,6 +151,10 @@ Object.defineProperties(Player.prototype, {
149151
get() {return holdXTime.get(this.id) ?? 0},
150152
set(v: number) {holdXTime.set(this.id, v)}
151153
},
154+
alarmSoundCooldown: {
155+
get() {return alarmSoundCooldown.get(this.id) ?? 0},
156+
set(v: number) {alarmSoundCooldown.set(this.id, v)}
157+
}
152158
});
153159

154160
function playerHasLight(player: Player) {
@@ -231,21 +237,27 @@ function changeState(player: Player, state: States) {
231237
if (player.ZChargeAmount == 1) angles = [0]
232238
if (player.ZChargeAmount == 2) angles = [-15, 15]
233239
if (player.ZChargeAmount == 3) angles = [-20, 0, 20]
234-
const matrix = V3.getBasisMatrix(player.getViewDirection())
240+
let t = 0
235241
for (const angle of angles) {
236-
let rad = deg2Rad(angle)
237-
let angleRot = V3.directionToRotation(player.getViewDirection())
238-
239-
angleRot.y += rad
240-
let newDir = V3.rotationToDirection(angleRot)
241-
242-
const blockHit = player.dimension.getBlockFromRay(player.getHeadLocation(), newDir, {includePassableBlocks: false})
243-
if (!blockHit) continue
244-
let p = V3.add(blockHit.block.location, blockHit.faceLocation)
245-
drawLine("whynot:light_trail", player.dimension, player.getHeadLocation(), p, 0.25)
246-
player.dimension.createExplosion(p, 1, {breaksBlocks: false})
242+
system.runTimeout(() => {
243+
let rad = deg2Rad(angle)
244+
let angleRot = V3.directionToRotation(player.getViewDirection())
245+
246+
angleRot.y += rad
247+
let newDir = V3.rotationToDirection(angleRot)
248+
249+
const blockHit = player.dimension.getBlockFromRay(player.getHeadLocation(), newDir, {includePassableBlocks: false})
250+
if (!blockHit) return
251+
let p = V3.add(blockHit.block.location, blockHit.faceLocation)
252+
drawLine("whynot:light_trail", player.dimension, player.getHeadLocation(), p, 0.25)
253+
player.dimension.createExplosion(p, 1, {breaksBlocks: false})
254+
playSoundFrom(player, "light_bow_shoot")
255+
}, t)
256+
t += 2
247257
}
248-
changeState(player, States.NORMAL)
258+
system.runTimeout(() => {
259+
changeState(player, States.NORMAL)
260+
}, t)
249261
break;
250262

251263
case States.USE_C:
@@ -261,6 +273,7 @@ function changeState(player: Player, state: States) {
261273
case States.CHARGE_Z:
262274
player.inputPermissions.setPermissionCategory(InputPermissionCategory.Movement, false)
263275
player.triggerEvent("whynot:add_static_player");
276+
player.alarmSoundCooldown = alarmSoundDuration
264277
player.ZChargeAmount = 0
265278
player.holdZTime = ZChargeIncrease
266279
break;
@@ -432,10 +445,18 @@ function processState(player: Player) {
432445
player.clearVelocity()
433446
player.holdZTime++
434447
if (player.holdZTime > ZChargeIncrease && player.ZChargeAmount < ZChargeAmountMax) {
435-
playSoundFrom(player, "random.burp")
436448
player.spawnParticle("minecraft:bleach", player.getHeadLocation())
437449
player.ZChargeAmount++;
438450
player.holdZTime = 0
451+
if (player.ZChargeAmount == 1) playSoundFrom(player, "light_bow_start_charge");
452+
else playSoundFrom(player, "light_bow_charge")
453+
}
454+
if (player.ZChargeAmount == 3) {
455+
if (player.alarmSoundCooldown > alarmSoundDuration) {
456+
playSoundFrom(player, "light_bow_alarm")
457+
player.alarmSoundCooldown = 0
458+
}
459+
player.alarmSoundCooldown++
439460
}
440461
break;
441462

scripts/addons/lightFruit/lightFruitType.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ declare module "@minecraft/server" {
2626
holdZTime: number;
2727
ZChargeAmount: number;
2828
holdXTime: number;
29+
alarmSoundCooldown: number;
2930
flyingAngles: Vector3;
3031
lightFlightVisuals: LightFlightVisual;
3132
}

0 commit comments

Comments
 (0)