@@ -50,14 +50,15 @@ const spinTrailTurnsPerSecond = 1.5
5050const spinTrailRadius = 0.5
5151const flySoundDuration = 7 //8.58
5252
53- const ZChargeIncrease = 20
53+ const ZChargeIncrease = 8
5454const ZChargeAmountMax = 3
5555
5656const lightRayMaxLength = 25
5757const lightRayDuration = 20 * 4
5858const lightRayCooldown = 80
5959
6060const zCooldownTime = 80
61+ const alarmSoundDuration = 4
6162
6263class LightFlightVisual {
6364 lastSpin1 : Vector3 | undefined
@@ -67,6 +68,7 @@ class LightFlightVisual {
6768}
6869const flyTurnCooldown : Map < string , number > = new Map ( )
6970const flySoundCooldown : Map < string , number > = new Map ( )
71+ const alarmSoundCooldown : Map < string , number > = new Map ( )
7072const airTime : Map < string , number > = new Map ( )
7173const ignoreFall : Map < string , boolean > = new Map ( )
7274const 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
154160function 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
0 commit comments