Skip to content

Commit

Permalink
Merge pull request #376 from opentomb/anim_frame_rewriting
Browse files Browse the repository at this point in the history
Anim frame rewriting - fixed;
TODO: fix in jump and under water change direction...
  • Loading branch information
TeslaRus authored Aug 24, 2016
2 parents 812e30c + e3ea641 commit 4510287
Show file tree
Hide file tree
Showing 21 changed files with 591 additions and 756 deletions.
4 changes: 2 additions & 2 deletions autoexec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ noclip(0);
--loadMap("data/LEVEL1.PHD");
--loadMap("tests/altroom1/LEVEL1.PHD");
--loadMap("tests/heavy1/LEVEL1.PHD");
--setgamef(1, 99);
dofile("save/pad");
--setgamef(4, 1);
dofile("save/qsave.lua");
8 changes: 0 additions & 8 deletions scripts/autoexec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,6 @@ setModelCollisionMap(0, 12, 6);
setModelCollisionMap(0, 13, 10); -- braces 3
setModelCollisionMap(0, 14, 13);

setAnimCommandTransform(0, 147, 0, 0x00); -- roll animation smooth fix
setAnimCommandTransform(0, 146, -2, 0x03);

if(getLevelVersion() >= TR_II) then
setAnimCommandTransform(0, 205, 1, 0x00);
setAnimCommandTransform(0, 203, -2, 0x03);
end

-- Generate UV rotation texture animations for waterfalls in TR4+ versions

if (getLevelVersion() == TR_IV) then
Expand Down
26 changes: 14 additions & 12 deletions scripts/entity/entity_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function door_init(id) -- NORMAL doors only!
setEntityActivity(object_id, 1);

entity_funcs[id].onActivate = function(object_id, activator_id)
local a, f, c = getEntityAnim(object_id);
local a, f, c = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(c == 1) then
return swapEntityState(object_id, 0, 1);
end;
Expand Down Expand Up @@ -306,8 +306,10 @@ function heli_rig_TR2_init(id) -- Helicopter in Offshore Rig (TR2)
if(getEntityAnimState(object_id, ANIM_TYPE_BASE) ~= 2) then
setEntityAnimState(object_id, ANIM_TYPE_BASE, 2);
else
local anim, frame, count = getEntityAnim(object_id);
if(frame == count-1) then disableEntity(object_id) end;
local anim, frame, count = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(frame == count-1) then
disableEntity(object_id)
end;
end
end;
end
Expand Down Expand Up @@ -614,7 +616,7 @@ function wallblade_init(id) -- Wall blade (TR1-TR3)

entity_funcs[id].onLoop = function(object_id)
if(tickEntity(object_id) == TICK_STOPPED) then setEntityActivity(object_id, 0) end;
local anim_number = getEntityAnim(object_id);
local anim_number = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(anim_number == 2) then
setEntityAnim(object_id, ANIM_TYPE_BASE, 3, 0);
elseif(anim_number == 1) then
Expand Down Expand Up @@ -695,7 +697,7 @@ function pickup_init(id, item_id) -- Pick-ups
end

local need_set_pos = true;
local curr_anim = getEntityAnim(activator_id);
local curr_anim = getEntityAnim(activator_id, ANIM_TYPE_BASE);

if(curr_anim == 103) then -- Stay idle
local dx, dy, dz = getEntityVector(object_id, activator_id);
Expand Down Expand Up @@ -729,7 +731,7 @@ function pickup_init(id, item_id) -- Pick-ups
end;
end;

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

local anim = getEntityAnim(object_id);
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(anim == 0) then
setEntityAnim(object_id, ANIM_TYPE_BASE, 1, 0);
-- print("you trapped to id = "..object_id);
local once = true;
addTask(
function()
local anim = getEntityAnim(object_id);
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(anim == 1) then
return true;
end;
Expand Down Expand Up @@ -815,7 +817,7 @@ function fallceiling_init(id) -- Falling ceiling (TR1-3)
return ENTITY_TRIGGERING_NOT_READY;
end

local anim = getEntityAnim(object_id);
local anim = getEntityAnim(object_id, ANIM_TYPE_BASE);
if(anim == 0) then
setEntityAnim(object_id, ANIM_TYPE_BASE, 1, 0);
setEntityVisibility(object_id, 1);
Expand All @@ -834,7 +836,7 @@ function fallceiling_init(id) -- Falling ceiling (TR1-3)
end;

entity_funcs[id].onCollide = function(object_id, activator_id)
if((getEntityAnim(object_id) == 1) and (getEntityModelID(activator_id) == 0) and (getCharacterParam(activator_id, PARAM_HEALTH) > 0)) then
if((getEntityAnim(object_id, ANIM_TYPE_BASE) == 1) and (getEntityModelID(activator_id) == 0) and (getCharacterParam(activator_id, PARAM_HEALTH) > 0)) then
setCharacterParam(activator_id, PARAM_HEALTH, 0);
end;
end
Expand Down Expand Up @@ -872,11 +874,11 @@ function midastouch_init(id) -- Midas gold touch

entity_funcs[id].onLoop = function(object_id)
if(getEntityDistance(player, object_id) < 1024.0) then
local lara_anim, frame, count = getEntityAnim(player);
local lara_anim, frame, count = getEntityAnim(player, ANIM_TYPE_BASE);
local lara_sector = getEntitySectorIndex(player);
local hand_sector = getEntitySectorIndex(object_id);

if((lara_sector == hand_sector) and (getEntityMoveType(player) == MOVE_ON_FLOOR) and (getEntityAnim(player) ~= 50)) then
if((lara_sector == hand_sector) and (getEntityMoveType(player) == MOVE_ON_FLOOR) and (lara_anim ~= 50)) then
setCharacterParam(player, PARAM_HEALTH, 0);
entitySSAnimEnsureExists(player, ANIM_TYPE_MISK_1, 5); --ANIM_TYPE_MISK_1 - add const
setEntityAnim(player, ANIM_TYPE_MISK_1, 1, 0);
Expand Down
6 changes: 3 additions & 3 deletions scripts/entity/script_switch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
end
end

local t = getEntityAnim(object_id);
local t = getEntityAnim(object_id, ANIM_TYPE_BASE);

if(on.ready_anim < 0 or on.ready_anim == t) then
if(key ~= nil) then
Expand All @@ -347,7 +347,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
setEntityActivity(object_id, 1);
addTask(
function()
local a, f, c = getEntityAnim(actor_id);
local a, f, c = getEntityAnim(actor_id, ANIM_TYPE_BASE);
if(on.switch_frame ~= nil) then
c = on.switch_frame
end
Expand All @@ -371,7 +371,7 @@ function switch_activate(object_id, actor_id) -- actor ID is needed to activat
setEntityActivity(object_id, 1);
addTask(
function()
local a, f, c = getEntityAnim(actor_id);
local a, f, c = getEntityAnim(actor_id, ANIM_TYPE_BASE);
if(off.switch_frame ~= nil) then
c = off.switch_frame
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/system/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function checkDebugKeys()
end;

function checkPlayerRagdollConditions()
local anim, frame, count = getEntityAnim(player);
local anim, frame, count = getEntityAnim(player, ANIM_TYPE_BASE);
local version = getLevelVersion();

if(getEntityTypeFlag(player, ENTITY_TYPE_DYNAMIC) == 0) then
Expand Down
3 changes: 2 additions & 1 deletion scripts/trigger/trigger_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ end;
function moveToSink(entity_index, sink_index)
local movetype = getEntityMoveType(entity_index);
if(movetype == 5) then -- Dive, if on water.
if(getEntityAnim(entity_index) ~= 113) then
anim = getEntityAnim(entity_index, ANIM_TYPE_BASE);
if(anim ~= 113) then
setEntityAnim(entity_index, ANIM_TYPE_BASE, 113, 0);
setEntityMoveType(entity_index, 6);
end;
Expand Down
Loading

0 comments on commit 4510287

Please sign in to comment.