## Expressive Sleep needs to check for nearby beds and place the player's head in the correct location. ExpressiveSleepCommand: debug: true type: command name: sleep description: Causes the player to go to sleep. usage: /sleep script: - if !: - narrate "No Flag" - narrate - define PlayerYaw - define CalculatedYaw ]> - define RotatedLocation ]> - create player <[RotatedLocation]> save:SleepBodyDouble - define SleepBodyDouble - narrate <[SleepBodyDouble]> - animate <[SleepBodyDouble]> animation:arm_swing - sleep npc:<[SleepBodyDouble]> - fakeequip head:air chest:air legs:air boots:air for: - invisible state:true - flag ExpressiveSleepOriginalLocation: - teleport ].with_y[]> - animate animation:sit - flag ExpressiveSleeping - flag SleepBodyDouble:<[SleepBodyDouble]> - wait 5t - teleport <[SleepBodyDouble]> <[SleepBodyDouble].location.rotate_yaw[50]> - wait 6t - teleport <[SleepBodyDouble]> <[SleepBodyDouble].location.rotate_yaw[-100]> - wait 5t - teleport <[SleepBodyDouble]> <[SleepBodyDouble].location.rotate_yaw[50]> - run ExpressiveSleepTask def:<[SleepBodyDouble]>|<[CalculatedYaw]>|<[PlayerYaw]> - clickable save:sleep_broadcast_request_clickable: - if !: - narrate "<&6><&f> is requesting that players go to sleep!" targets: - flag ExpressiveTimerB expire:60s - narrate "<&f>Click <&6>Here<&rb>].on_click[]><&f> to ask others to sleep!" - stop - if : - teleport ].with_pitch[]> - animate animation:stop_sitting - invisible state:false - remove - flag SleepBodyDouble:! - flag ExpressiveSleeping:! - flag ExpressiveSleepOriginalLocation:! # - fakeequip head:air chest:air legs:air boots:air duration:0.1s for: # Compatability - Uncomment any commented lines and remove this block to remove compatibility for external mods. - if !: - fakeequip head:air chest:air legs:air boots:air duration:0.1s for: ExpressiveCrawlCommand: debug: true type: command name: crawl description: Crawl on your stomach. usage: /crawl script: - if !: - narrate "No Flag" - stop - if : - narrate "Flag Found" - stop ExpressiveSitCommand: debug: true type: command name: sit description: Sit down somewhere. usage: /sit script: - if !: - narrate "No Flag" - stop - if : - narrate "Flag Found" - stop # ExpressiveResetCommand: # debug: true # type: command # name: er # description: Reset. # usage: /er # script: # - if : # - remove # - flag SleepBodyDouble:! # - flag ExpressiveSleeping:! # - flag ExpressiveSleepOriginalLocation:! # - if : # - flag ExpressiveSitting:! # - if : # - flag ExpressiveCrawling:! ExpressiveWorld: type: world events: on player starts sneaking: - if && : - execute as_player "sleep" - flag ExpressiveTimerA:! - stop - if && : - execute as_player "crawl" - flag ExpressiveTimerA:! - stop - flag ExpressiveTimerA expire:8t on player breaks block flagged:ExpressiveSleeping: - determine cancelled on player starts sneaking flagged:ExpressiveSleeping: - execute as_player "sleep" - determine cancelled on player right clicks *_stairs: - execute as_player "sit" - determine cancelled ExpressiveSleepTask: type: task script: - define BodyDouble <[1]> - define SafeYaw <[2]> - define StartYaw <[3].add[360].mod[360]> - while : - wait 2t - define difference <[StartYaw].sub[]> - if <[difference]> > 180: - define difference <[difference].sub[360]> - if <[difference]> < -180: - define difference <[difference].add[360]> - if <[SafeYaw].sub[<[difference]>]> >= <[SafeYaw].sub[50]> && <[SafeYaw].sub[<[difference]>]> <= <[SafeYaw].add[50]> && <[BodyDouble].location.exists>: - teleport <[BodyDouble]> <[BodyDouble].location.with_pitch[].with_yaw[<[SafeYaw].sub[<[difference]>]>]> # - else: # - teleport <[BodyDouble]> <[BodyDouble].location.with_pitch[]> ExpressiveCrawlTask: type: task script: - while : - ratelimit 2t - if : - narrate X # NPC Tests: # Yaw 0 = Body Facing East (Positive X) # Yaw 90 = Body Facing North (Negative Z) # Yaw 180 = Body Facing West (Negative X) # Yaw -90 = Body Facing South (Positive Z) # Yaw 0 = Body Facing East (Positive X) # Yaw -90 = Body Facing South (Positive Z) # Yaw -180 = Body Facing West (Negative X) # Body Points to Yaw -45 if Player yaw is 135 ( Correct ) # Body Points to yaw -60 if player yaw is 150 ( Incorrect, Rotated Counter Clockwise by 15 degrees instead of Clockwise)