Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# Incari's No Hurt Cam (features/nohurtcam) for the Rust build (ADR 0068, 0069).
|
||||
# Hooks by name where Horizon has stamped the hook point (native-hooks.json), by function where
|
||||
# it's still pending. Its settings are the client's (rust/mods/incari): the module menu shows them.
|
||||
[mod]
|
||||
id = "incari_nohurtcam"
|
||||
version = "0.1.0"
|
||||
priority = 100
|
||||
|
||||
[[module]]
|
||||
id = "runtime"
|
||||
file = "crates/horizon-client/src/game.rs"
|
||||
name = "incari_nohurtcam"
|
||||
source = "runtime.rs"
|
||||
|
||||
[[injection]]
|
||||
id = "tilt"
|
||||
# Horizon's hurt_tilt hook point is still a pending fragment
|
||||
# (tools/native-hook-fragments/incari_client_hooks.json), so this targets its function. Make it
|
||||
# `hook = "hurt_tilt"` and `hook_version = 1` once Horizon stamps it.
|
||||
target = "horizon_client::game::native_hooks::Game<'_>::native_hurt_tilt"
|
||||
kind = "HEAD"
|
||||
helper = "tilt.rs"
|
||||
bindings = [
|
||||
{ name = "game", ty = "&crate::game::Game<'_>", value = "self" },
|
||||
{ name = "strength", ty = "&mut f64", value = "&mut *strength" },
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
// Incari's No Hurt Cam for the Rust build (ADR 0068, 0069), as features/nohurtcam does it: the
|
||||
// camera tilts by the module's Shake amount, 0% not at all, when you're hurt. The Java module holds
|
||||
// the game's Damage Tilt option at that value; here Horizon's hurt tilt hook sets it for the frame,
|
||||
// so the option itself is untouched. Its settings are the module's in `incari_core::modules`.
|
||||
// No game types: rust/lib.rs tests it.
|
||||
|
||||
/// The module's id, as the Java client's profiles name it.
|
||||
pub const ID: &str = "nohurtcam";
|
||||
|
||||
/// The Damage Tilt in effect for the `shake` setting (a percent): the option the Java module holds.
|
||||
pub fn tilt(shake: i32) -> f64 {
|
||||
f64::from(shake.clamp(0, 100)) / 100.0
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn holds_the_tilt_at_the_shake_amount() {
|
||||
assert_eq!(tilt(0), 0.0);
|
||||
assert_eq!(tilt(50), 0.5);
|
||||
assert_eq!(tilt(100), 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// The hurt tilt, held at the module's Shake amount for this frame.
|
||||
fn incari_nohurtcam_tilt(game: &crate::game::Game<'_>, strength: &mut f64) {
|
||||
use crate::game::{incari_client as c, incari_nohurtcam as m};
|
||||
let _ = game;
|
||||
if let Some(shake) = c::settings(m::ID, |s| s.int("shake")) {
|
||||
*strength = m::tilt(shake);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user