Skip to content
Open
16 changes: 16 additions & 0 deletions gamedata/scripts/callbacks_gameobject.script
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ _G.CActorHudOnNearWall = function(arg)
SendScriptCallback("actor_hud_on_nearwall", arg)
end

-- Script hud motion end callback
-- part is 0 for the right hand, 1 for the left hand, 2 for both
-- section is the hud section the motion belongs to, anm_name the motion that ended
-- reason is 0 when the motion reached its end, 1 when something stopped it early
AddScriptCallback("actor_hud_on_script_anim_end")
_G.CActorHudOnScriptAnimEnd = function(part, section, anm_name, reason)
SendScriptCallback("actor_hud_on_script_anim_end", part, section, anm_name, reason)
end

-- Hands section change callback
-- fires when the player hud switches its hands section, sends the new and the previous section name
AddScriptCallback("actor_hud_on_hands_changed")
_G.CActorHudOnHandsChanged = function(new_section, old_section)
SendScriptCallback("actor_hud_on_hands_changed", new_section, old_section)
end

-- Mouse callbacks
-- Scroll wheel callback, sends mouse wheel direction as a number
-- 1 is up, 0 is down
Expand Down
40 changes: 40 additions & 0 deletions gamedata/scripts/lua_help_ex.script
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@
get_player_hud() {
void set_hands(string section)
void reset_hands()
string section_name() // the hud section currently loaded, empty string when none is
bool set_hands_visuals(string right_visual, string left_visual) // swaps the hand models inside the loaded section, left falls back to the right visual when empty, false when a visual is missing, is not animated, or lacks the bones the hud binds
}

namespace ActorMenu {
Expand Down Expand Up @@ -545,6 +547,40 @@
// }
// level.add_bullet(t)

// HUD hands, script motions and blend anms
u32 play_hud_motion(u8 hand, string itm_name, string anm_name, bool bMixIn, float speed, bool keep_freelook) // hand 0 right, 1 left, 2 both, returns the motion length in ms, 0 when the section is missing or the hand is out of range
void set_hud_motion_freelook(u8 hand, bool keep) // hand 0 right, 1 left, 2 both, keep lets freelook stay active while that script motion plays
bool hud_motion_exists(string section, string anm_name) // true when the section defines the motion and the loaded hands model has that cycle
int hud_motion_blocked_reason() // 0 nothing blocks, 1 right item pending, 2 right item boring, 3 left item pending, 4 left item boring, 5 a script motion already plays
int hud_motion_part() // 0 right, 1 left, 2 both for the script motion playing now, nil when none plays
bool hud_needs_blend(u8 part) // part 0 right, 1 left, true when that hand wants a blend anm this frame
void play_hud_anm(string name, u8 part, float speed, float power, bool bLooped)
void play_hud_anm(string name, u8 part, float speed, float power, bool bLooped, bool no_restart)
void play_hud_anm(string name, u8 part, float speed, float power, bool bLooped, bool no_restart, string pivot_bone, int priority) // priority orders the blend layers, higher is applied later, default 0
void set_hud_anm_priority(string name, int priority) // reorders a blend layer that is already playing
void stop_hud_anm(string name, bool bForce, float fade_ms) // fades the layer out over fade_ms milliseconds
function hud_anm_state(string name) -> bool found, bool active, float blend // blend runs 0 to 1, found is false when no layer carries that name
bool hud_anm_exists(string name) // true when the anm file is found under $level$ or $game_anims$
void set_hud_cycle_speed(u8 part, float speed) // part 0 both, 1 left hand, 2 right hand, multiplies the speed of the cycles playing there
void set_hud_cycle_time(u8 part, float time) // part 0 both, 1 left hand, 2 right hand, time is the position in the cycle, clamped 0 to 1
void resync_hud_anim(u8 part) // part 1 left hand or 2 right hand, copies the cycles playing on that part and their time onto the other hand partitions
void set_blend_move_anims_override(bool mode) // true forces the movement blend anms on, false forces them off, nil returns control to the console flag
bool get_blend_move_anims() // the movement blend anm state in effect, override included
bool set_bare_hands(string section) // hud section idled when both hands are empty, nil clears it, false when the section is missing or has no anm_idle on the hands model
string get_bare_hands() // the bare hands section, nil when none is set
bool bare_hands_live() // true while the bare hands idle is the thing being drawn
u32 bare_hands_skipped() // hud draws and ui queries skipped since the hud was created while a bare hands section was set
void set_hud_offset(u8 part, float x, float y, float z, float pitch, float yaw, float roll, float blend_ms) // part 0 right, 1 left, 2 both, position in metres, angles in degrees with the aim_hud_offset_rot signs, eased in over blend_ms milliseconds
void clear_hud_offset(u8 part, float blend_ms) // part 0 right, 1 left, 2 both, eases the offset back out over blend_ms milliseconds
float get_hud_fov() // the hud fov the renderer is using
bool hud_visible() // true while any of the hud weapon draw flags is set
game_object hud_attached_item(u16 slot) // slot 0 right hand, 1 left hand, 2 scope, nil when the slot is empty

// Actor freelook
int actor_freelook_state() // 0 disabled, 1 enabling, 2 enabled, 3 disabling
float actor_freelook_factor() // how far the freelook camera has taken control, 0 to 1
float actor_freelook_yaw_split() // signed radians between the body yaw and the camera yaw

// Script Attachments
function add_attachment(string, string)
function get_attachment(string)
Expand Down Expand Up @@ -887,6 +923,10 @@
bool set_hud_inertion_enabled()
void hud_inertion_enabled(bool value)

// HUD item animation state
bool need_blend_anm() // true when this hud item wants a blend anm playing, false when the object is not a hud item
float hud_fov() // the hud fov this item renders with, 0 when the object is not a hud item

// Torch
function update_torch()

Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,9 +1307,9 @@ bool CWeapon::NeedBlendAnm()
if (IsZoomed() && psDeviceFlags2.test(rsAimSway))
return true;

if (psDeviceFlags2.test(rsBlendMoveAnims))
if (blend_move_anims_enabled())
return true;

return inherited::NeedBlendAnm();
}

Expand Down Expand Up @@ -3223,7 +3223,7 @@ void CWeapon::render_hud_mode()

bool CWeapon::MovingAnimAllowedNow()
{
return !IsZoomed() && !psDeviceFlags2.test(rsBlendMoveAnims);
return !IsZoomed() && !blend_move_anims_enabled();
}

bool CWeapon::IsHudModeNow()
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/WeaponMagazinedWGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ void CWeaponMagazinedWGrenade::PlayAnimIdle()

if (m_bGrenadeMode)
{
if (act_state == 0 || psDeviceFlags2.test(rsBlendMoveAnims))
if (act_state == 0 || blend_move_anims_enabled())
iAmmoElapsed == 0 && HudAnimationExist("anm_idle_empty_g")
? PlayHUDMotion("anm_idle_empty_g", TRUE, NULL, GetState())
: PlayHUDMotion("anm_idle_g", TRUE, NULL, GetState());
Expand All @@ -880,7 +880,7 @@ void CWeaponMagazinedWGrenade::PlayAnimIdle()
}
else
{
if (act_state == 0 || psDeviceFlags2.test(rsBlendMoveAnims))
if (act_state == 0 || blend_move_anims_enabled())
iAmmoElapsed == 0 && HudAnimationExist("anm_idle_empty_w_gl")
? PlayHUDMotion("anm_idle_empty_w_gl", TRUE, NULL, GetState())
: PlayHUDMotion("anm_idle_w_gl", TRUE, NULL, GetState());
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ extern BOOL pseudogiantDodgeWhileFalling; // Verdatim
extern BOOL AllowAccelDuringLookOut; // Verdatim
extern BOOL scale_hud_motion_marks_by_speed; // Verdatim


//demonized: new console vars
extern BOOL firstPersonDeath;
extern BOOL pseudogiantCanDamageObjects;
Expand Down Expand Up @@ -2530,6 +2531,7 @@ void CCC_RegisterCommands()
CMD3(CCC_Mask, "hud_crosshair", &psHUD_Flags, HUD_CROSSHAIR);
CMD3(CCC_Mask, "hud_crosshair_dist", &psHUD_Flags, HUD_CROSSHAIR_DIST);


//#ifdef DEBUG
CMD4(CCC_Float, "hud_fov", &psHUD_FOV_def, 0.1f, 1.0f);
CMD4(CCC_Float, "fov", &g_fov, 5.0f, 180.0f);
Expand Down
Loading
Loading