Skip to content

Commit

Permalink
Added a tweak to play "magic hands" anim when using items on objs
Browse files Browse the repository at this point in the history
* for issues with scripted animations not playing (#356)
  • Loading branch information
NovaRain committed May 7, 2021
1 parent db0b8ed commit 6d88f21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion artifacts/ddraw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ CorpseDeleteTime=6
;Set a number of milliseconds to idle each input loop
;Set to -1 to disable
;Set to 0 to idle only if other processes are waiting for processor time (WinXP/2000: if processes have equal priority)
;Set to 1 (or some higher number if needed) to prevent 100% CPU use. The maximum is 100
;Set to 1 (or some higher number if needed) to prevent 100% CPU use. The maximum is 30
ProcessorIdle=-1

;Set to 1 if using the hero appearance mod
Expand Down
3 changes: 3 additions & 0 deletions sfall/Modules/Animations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ void Animations::init() {
// Fix crash when the critter goes through a door with animation trigger
MakeJump(0x41755E, object_move_hack);

// Allow playing the "magic hands" animation when using an item on an object
SafeWrite16(0x4120B8, 0x9090); // action_use_an_item_on_object_

// Fix for the player stuck at "climbing" frame after ladder climbing animation
HookCall(0x411E1F, action_climb_ladder_hook);

Expand Down
2 changes: 1 addition & 1 deletion sfall/Modules/ScriptExtender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ void ScriptExtender::init() {
}

idle = IniReader::GetConfigInt("Misc", "ProcessorIdle", -1);
if (idle > -1 && idle > 100) idle = 100;
if (idle > -1 && idle > 30) idle = 30;

arraysBehavior = IniReader::GetConfigInt("Misc", "arraysBehavior", 1);
if (arraysBehavior > 0) {
Expand Down

1 comment on commit 6d88f21

@NovaRain
Copy link
Collaborator Author

@NovaRain NovaRain commented on 6d88f21 May 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing on my Core i5 7500 desktop and Pentium II server, 30 seems the max value before the game becomes noticeably laggy.
I was considering 15 and 25 before running a test script to check the interval of running a global script with set_global_script_repeat(1) (yes, the wrong way).
With system timer interval 10ms (default value on my desktop PC with Win7) or above (should be 15.6ms for Pentium II + Win2k), ProcessorIdle from 1 to 15 gave me the same result, and the result value bumped again from 16 to 30/31.
With smaller timer interval (1ms or 0.5ms, 0.5 is the min settable value), nearly every value of ProcessorIdle gave different results, so I picked 30.

Please sign in to comment.