Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 4510287

Browse files
authored
Merge pull request #376 from opentomb/anim_frame_rewriting
Anim frame rewriting - fixed; TODO: fix in jump and under water change direction...
2 parents 812e30c + e3ea641 commit 4510287

21 files changed

+591
-756
lines changed

autoexec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ noclip(0);
2020
--loadMap("data/LEVEL1.PHD");
2121
--loadMap("tests/altroom1/LEVEL1.PHD");
2222
--loadMap("tests/heavy1/LEVEL1.PHD");
23-
--setgamef(1, 99);
24-
dofile("save/pad");
23+
--setgamef(4, 1);
24+
dofile("save/qsave.lua");

scripts/autoexec.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,6 @@ setModelCollisionMap(0, 12, 6);
238238
setModelCollisionMap(0, 13, 10); -- braces 3
239239
setModelCollisionMap(0, 14, 13);
240240

241-
setAnimCommandTransform(0, 147, 0, 0x00); -- roll animation smooth fix
242-
setAnimCommandTransform(0, 146, -2, 0x03);
243-
244-
if(getLevelVersion() >= TR_II) then
245-
setAnimCommandTransform(0, 205, 1, 0x00);
246-
setAnimCommandTransform(0, 203, -2, 0x03);
247-
end
248-
249241
-- Generate UV rotation texture animations for waterfalls in TR4+ versions
250242

251243
if (getLevelVersion() == TR_IV) then

scripts/entity/entity_functions.lua

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function door_init(id) -- NORMAL doors only!
5353
setEntityActivity(object_id, 1);
5454

5555
entity_funcs[id].onActivate = function(object_id, activator_id)
56-
local a, f, c = getEntityAnim(object_id);
56+
local a, f, c = getEntityAnim(object_id, ANIM_TYPE_BASE);
5757
if(c == 1) then
5858
return swapEntityState(object_id, 0, 1);
5959
end;
@@ -306,8 +306,10 @@ function heli_rig_TR2_init(id) -- Helicopter in Offshore Rig (TR2)
306306
if(getEntityAnimState(object_id, ANIM_TYPE_BASE) ~= 2) then
307307
setEntityAnimState(object_id, ANIM_TYPE_BASE, 2);
308308
else
309-
local anim, frame, count = getEntityAnim(object_id);
310-
if(frame == count-1) then disableEntity(object_id) end;
309+
local anim, frame, count = getEntityAnim(object_id, ANIM_TYPE_BASE);
310+
if(frame == count-1) then
311+
disableEntity(object_id)
312+
end;
311313
end
312314
end;
313315
end
@@ -614,7 +616,7 @@ function wallblade_init(id) -- Wall blade (TR1-TR3)
614616

615617
entity_funcs[id].onLoop = function(object_id)
616618
if(tickEntity(object_id) == TICK_STOPPED) then setEntityActivity(object_id, 0) end;
617-
local anim_number = getEntityAnim(object_id);
619+
local anim_number = getEntityAnim(object_id, ANIM_TYPE_BASE);
618620
if(anim_number == 2) then
619621
setEntityAnim(object_id, ANIM_TYPE_BASE, 3, 0);
620622
elseif(anim_number == 1) then
@@ -695,7 +697,7 @@ function pickup_init(id, item_id) -- Pick-ups
695697
end
696698

697699
local need_set_pos = true;
698-
local curr_anim = getEntityAnim(activator_id);
700+
local curr_anim = getEntityAnim(activator_id, ANIM_TYPE_BASE);
699701

700702
if(curr_anim == 103) then -- Stay idle
701703
local dx, dy, dz = getEntityVector(object_id, activator_id);
@@ -729,7 +731,7 @@ function pickup_init(id, item_id) -- Pick-ups
729731
end;
730732
end;
731733

732-
local a, f, c = getEntityAnim(activator_id);
734+
local a, f, c = getEntityAnim(activator_id, ANIM_TYPE_BASE);
733735
-- Standing pickup anim makes action on frame 40 in TR1-3, in TR4-5
734736
-- it was generalized with all rest animations by frame 16.
735737
if((a == 135) and (getLevelVersion() < TR_IV)) then
@@ -776,14 +778,14 @@ function fallblock_init(id) -- Falling block (TR1-3)
776778
return;
777779
end
778780

779-
local anim = getEntityAnim(object_id);
781+
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
780782
if(anim == 0) then
781783
setEntityAnim(object_id, ANIM_TYPE_BASE, 1, 0);
782784
-- print("you trapped to id = "..object_id);
783785
local once = true;
784786
addTask(
785787
function()
786-
local anim = getEntityAnim(object_id);
788+
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
787789
if(anim == 1) then
788790
return true;
789791
end;
@@ -815,7 +817,7 @@ function fallceiling_init(id) -- Falling ceiling (TR1-3)
815817
return ENTITY_TRIGGERING_NOT_READY;
816818
end
817819

818-
local anim = getEntityAnim(object_id);
820+
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
819821
if(anim == 0) then
820822
setEntityAnim(object_id, ANIM_TYPE_BASE, 1, 0);
821823
setEntityVisibility(object_id, 1);
@@ -834,7 +836,7 @@ function fallceiling_init(id) -- Falling ceiling (TR1-3)
834836
end;
835837

836838
entity_funcs[id].onCollide = function(object_id, activator_id)
837-
if((getEntityAnim(object_id) == 1) and (getEntityModelID(activator_id) == 0) and (getCharacterParam(activator_id, PARAM_HEALTH) > 0)) then
839+
if((getEntityAnim(object_id, ANIM_TYPE_BASE) == 1) and (getEntityModelID(activator_id) == 0) and (getCharacterParam(activator_id, PARAM_HEALTH) > 0)) then
838840
setCharacterParam(activator_id, PARAM_HEALTH, 0);
839841
end;
840842
end
@@ -872,11 +874,11 @@ function midastouch_init(id) -- Midas gold touch
872874

873875
entity_funcs[id].onLoop = function(object_id)
874876
if(getEntityDistance(player, object_id) < 1024.0) then
875-
local lara_anim, frame, count = getEntityAnim(player);
877+
local lara_anim, frame, count = getEntityAnim(player, ANIM_TYPE_BASE);
876878
local lara_sector = getEntitySectorIndex(player);
877879
local hand_sector = getEntitySectorIndex(object_id);
878880

879-
if((lara_sector == hand_sector) and (getEntityMoveType(player) == MOVE_ON_FLOOR) and (getEntityAnim(player) ~= 50)) then
881+
if((lara_sector == hand_sector) and (getEntityMoveType(player) == MOVE_ON_FLOOR) and (lara_anim ~= 50)) then
880882
setCharacterParam(player, PARAM_HEALTH, 0);
881883
entitySSAnimEnsureExists(player, ANIM_TYPE_MISK_1, 5); --ANIM_TYPE_MISK_1 - add const
882884
setEntityAnim(player, ANIM_TYPE_MISK_1, 1, 0);

scripts/entity/script_switch.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
328328
end
329329
end
330330

331-
local t = getEntityAnim(object_id);
331+
local t = getEntityAnim(object_id, ANIM_TYPE_BASE);
332332

333333
if(on.ready_anim < 0 or on.ready_anim == t) then
334334
if(key ~= nil) then
@@ -347,7 +347,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
347347
setEntityActivity(object_id, 1);
348348
addTask(
349349
function()
350-
local a, f, c = getEntityAnim(actor_id);
350+
local a, f, c = getEntityAnim(actor_id, ANIM_TYPE_BASE);
351351
if(on.switch_frame ~= nil) then
352352
c = on.switch_frame
353353
end
@@ -371,7 +371,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
371371
setEntityActivity(object_id, 1);
372372
addTask(
373373
function()
374-
local a, f, c = getEntityAnim(actor_id);
374+
local a, f, c = getEntityAnim(actor_id, ANIM_TYPE_BASE);
375375
if(off.switch_frame ~= nil) then
376376
c = off.switch_frame
377377
end

scripts/system/debug.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function checkDebugKeys()
109109
end;
110110

111111
function checkPlayerRagdollConditions()
112-
local anim, frame, count = getEntityAnim(player);
112+
local anim, frame, count = getEntityAnim(player, ANIM_TYPE_BASE);
113113
local version = getLevelVersion();
114114

115115
if(getEntityTypeFlag(player, ENTITY_TYPE_DYNAMIC) == 0) then

scripts/trigger/trigger_functions.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ end;
4949
function moveToSink(entity_index, sink_index)
5050
local movetype = getEntityMoveType(entity_index);
5151
if(movetype == 5) then -- Dive, if on water.
52-
if(getEntityAnim(entity_index) ~= 113) then
52+
anim = getEntityAnim(entity_index, ANIM_TYPE_BASE);
53+
if(anim ~= 113) then
5354
setEntityAnim(entity_index, ANIM_TYPE_BASE, 113, 0);
5455
setEntityMoveType(entity_index, 6);
5556
end;

0 commit comments

Comments
 (0)