diff --git a/assets/voxygen/shaders/postprocess-frag.glsl b/assets/voxygen/shaders/postprocess-frag.glsl index 17b90c0895..2d478578fe 100644 --- a/assets/voxygen/shaders/postprocess-frag.glsl +++ b/assets/voxygen/shaders/postprocess-frag.glsl @@ -21,6 +21,7 @@ #include #include #include +#include layout(set = 1, binding = 0) uniform texture2D t_src_color; @@ -184,6 +185,11 @@ void main() { // float bright_color = (bright_color0 + bright_color1 + bright_color2 + bright_color3 + bright_color4) / 5.0; + if (medium.x == 2u) { + tgt_color = vec4(0, 0.005, 0.01, 1) * (1 + hash_fast(uvec3(vec3(uv * screen_res.xy / 32.0, 0)))); + return; + } + vec4 aa_color = aa_apply(t_src_color, s_src_color, uv * screen_res.xy, screen_res.xy); // Bloom diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 896f917dfe..e20382103c 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -160,8 +160,7 @@ pub struct ReadData<'a> { combos: ReadStorage<'a, Combo>, } -// This is 3.1 to last longer than the last damage timer (3.0 seconds) -const DAMAGE_MEMORY_DURATION: f64 = 3.1; +const DAMAGE_MEMORY_DURATION: f64 = 0.25; const FLEE_DURATION: f32 = 3.0; const MAX_FOLLOW_DIST: f32 = 12.0; const MAX_PATH_DIST: f32 = 170.0; @@ -507,10 +506,20 @@ impl<'a> System<'a> for Sys { // than the old target, or if the old target // had not triggered aggro (the new target // has because damage always triggers it) - !old_tgt.aggro_on - || tgt_pos.0.distance(pos.0) + let old_tgt_not_threat = !old_tgt.aggro_on; + let old_tgt_further = + tgt_pos.0.distance(pos.0) < old_tgt_pos.0.distance(pos.0) - * FUZZY_DIST_COMPARISON + * FUZZY_DIST_COMPARISON; + let new_tgt_hostile = read_data + .alignments + .get(attacker) + .zip(alignment) + .map_or(false, |(attacker, us)| { + us.hostile_towards(*attacker) + }); + old_tgt_not_threat + || (old_tgt_further && new_tgt_hostile) } else { true } diff --git a/voxygen/src/render/pipelines/mod.rs b/voxygen/src/render/pipelines/mod.rs index d4a0ee3c46..28b8277f6f 100644 --- a/voxygen/src/render/pipelines/mod.rs +++ b/voxygen/src/render/pipelines/mod.rs @@ -137,7 +137,13 @@ impl Globals { 0.0, 0.0, ], - medium: [if medium.is_liquid() { 1 } else { 0 }; 4], + medium: [if medium.is_liquid() { + 1 + } else if medium.is_filled() { + 2 + } else { + 0 + }; 4], select_pos: select_pos .map(|sp| Vec4::from(sp) + Vec4::unit_w()) .unwrap_or_else(Vec4::zero) diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index 01dda44cb8..1ffe1a1876 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -527,15 +527,19 @@ impl Camera { } /// Zoom the camera by the given delta, limiting the input accordingly. - pub fn zoom_by(&mut self, delta: f32) { + pub fn zoom_by(&mut self, delta: f32, cap: Option) { if self.mode == CameraMode::ThirdPerson { // Clamp camera dist to the 2 <= x <= infinity range self.tgt_dist = (self.tgt_dist + delta).max(2.0); } + + if let Some(cap) = cap { + self.tgt_dist = self.tgt_dist.min(cap); + } } /// Zoom with the ability to switch between first and third-person mode. - pub fn zoom_switch(&mut self, delta: f32) { + pub fn zoom_switch(&mut self, delta: f32, cap: Option) { if delta > 0_f32 || self.mode != CameraMode::FirstPerson { let t = self.tgt_dist + delta; const MIN_THIRD_PERSON: f32 = 2.35; @@ -554,6 +558,10 @@ impl Camera { _ => {}, } } + + if let Some(cap) = cap { + self.tgt_dist = self.tgt_dist.min(cap); + } } /// Get the distance of the camera from the focus @@ -679,13 +687,13 @@ impl Camera { self.mode = mode; match self.mode { CameraMode::ThirdPerson => { - self.zoom_by(5.0); + self.zoom_by(5.0, None); }, CameraMode::FirstPerson => { self.set_distance(MIN_ZOOM); }, CameraMode::Freefly => { - self.zoom_by(0.0); + self.zoom_by(0.0, None); }, } } diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index fe7aa247c5..a666b2d407 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -340,7 +340,7 @@ impl Scene { /// window closed). /// /// If the event is handled, return true. - pub fn handle_input_event(&mut self, event: Event) -> bool { + pub fn handle_input_event(&mut self, event: Event, client: &Client) -> bool { match event { // When the window is resized, change the camera's aspect ratio Event::Resize(dims) => { @@ -357,13 +357,16 @@ impl Scene { // when zooming in the distance the camera travelles should be based on the // final distance. This is to make sure the camera travelles the // same distance when zooming in and out + let cap = (!client.is_moderator()).then_some(30.0); if delta < 0.0 { self.camera.zoom_switch( + // Thank you Imbris for doing the math delta * (0.05 + self.camera.get_distance() * 0.01) / (1.0 - delta * 0.01), - ); // Thank you Imbris for doing the math + cap, + ); } else { self.camera - .zoom_switch(delta * (0.05 + self.camera.get_distance() * 0.01)); + .zoom_switch(delta * (0.05 + self.camera.get_distance() * 0.01), cap); } true }, @@ -643,6 +646,9 @@ impl Scene { .state .terrain() .get((cam_pos + focus_off).map(|e| e.floor() as i32)) + .ok() + // Don't block the camera's view in solid blocks if the player is a moderator + .filter(|b| !(b.is_filled() && client.is_moderator())) .map(|b| b.kind()) .unwrap_or(BlockKind::Air), self.select_pos.map(|e| e - focus_off.map(|e| e as i32)), diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index ccfa85b6eb..7e74f38936 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -826,7 +826,10 @@ impl PlayState for SessionState { self.key_state.analog_matrix.y = v; }, other => { - self.scene.handle_input_event(Event::AnalogGameInput(other)); + self.scene.handle_input_event( + Event::AnalogGameInput(other), + &self.client.borrow(), + ); }, }, Event::ScreenshotMessage(screenshot_message) => { @@ -838,7 +841,7 @@ impl PlayState for SessionState { // Pass all other events to the scene event => { - self.scene.handle_input_event(event); + self.scene.handle_input_event(event, &self.client.borrow()); }, // TODO: Do something if the event wasn't handled? } }