Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
TeslaRus committed May 5, 2015
2 parents 705dca6 + fcf4083 commit a83f01e
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 113 deletions.
77 changes: 55 additions & 22 deletions scripts/entity/entity_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function door_init(id) -- NORMAL doors only!
if(tickEntity(object_id) == TICK_STOPPED) then setEntityState(object_id, 0) end;
end

door_activate(id);
prepareEntity(id);
end

function keyhole_init(id) -- Key and puzzle holes
Expand Down Expand Up @@ -137,7 +137,7 @@ function venicebird_init(id) -- Venice singing birds (TR2)
end;
end

activateEntity(id);
prepareEntity(id);
end

function doorbell_init(id) -- Lara's Home doorbell (TR2)
Expand Down Expand Up @@ -186,6 +186,31 @@ function alarm_TR2_init(id) -- Offshore Rig alarm (TR2)
end
end

function alarmbell_init(id) -- Home Sweet Home alarm (TR2)

setEntityTypeFlag(id, ENTITY_TYPE_DECORATION);
setEntityActivity(id, 0);

entity_funcs[id].onActivate = function(object_id, activator_id)
if(getEntityActivity(object_id) == 0) then setEntityActivity(object_id, 1) end;
end

entity_funcs[id].onDeactivate = function(object_id, activator_id)
if(getEntityActivity(object_id) == 1) then
setEntityActivity(object_id, 0);
stopSound(335, object_id);
end;
end

entity_funcs[id].onLoop = function(object_id)
playSound(335, object_id);
if(tickEntity(object_id) == TICK_STOPPED) then
setEntityActivity(object_id, 0)
stopSound(335, object_id);
end;
end
end

function heli_TR2_init(id) -- Helicopter (TR2)

setEntityTypeFlag(id, ENTITY_TYPE_DECORATION);
Expand Down Expand Up @@ -215,7 +240,7 @@ function heli_TR2_init(id) -- Helicopter (TR2)
end;
end

activateEntity(id);
prepareEntity(id);
end

function swingblade_init(id) -- Swinging blades (TR1)
Expand All @@ -235,7 +260,7 @@ function swingblade_init(id) -- Swinging blades (TR1)
if(tickEntity(object_id) == TICK_STOPPED) then setEntityState(object_id, 0) end;
end

activateEntity(id);
prepareEntity(id);
end

function slamdoor_init(id) -- Slamming doors (TR1-TR2)
Expand All @@ -255,13 +280,12 @@ function slamdoor_init(id) -- Slamming doors (TR1-TR2)
if(tickEntity(object_id) == TICK_STOPPED) then setEntityState(object_id, 0) end;
end

activateEntity(id);
prepareEntity(id);
end

function wallblade_init(id) -- Wall blade (TR1-TR3)

setEntityTypeFlag(id, ENTITY_TYPE_DECORATION);
setEntityActivity(id, 0);

entity_funcs[id].onActivate = function(object_id, activator_id)
setEntityActivity(object_id, 1);
Expand All @@ -273,15 +297,15 @@ 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);
if(anim_number == 2) then
setEntityAnim(object_id, 3)
setEntityAnim(object_id, 3);
elseif(anim_number == 1) then
setEntityAnim(object_id, 0)
setEntityAnim(object_id, 0);
end;
end

activateEntity(id);
prepareEntity(id);
end

function pickup_init(id, item_id) -- Pick-ups
Expand Down Expand Up @@ -351,7 +375,20 @@ function pickup_init(id, item_id) -- Pick-ups
return false; -- Item successfully picked up, kill the task.
end);
end;
end

function crystal_TR3_init(id) -- "Savegame" crystal (TR3 version)

setEntityTypeFlag(id, ENTITY_TYPE_DECORATION);
setEntityActivity(id, 1);

entity_funcs[id].onLoop = function(object_id)
if(getEntityDistance(player, object_id) < 512.0) then
playSound(SOUND_MEDIPACK);
changeCharacterParam(player, PARAM_HEALTH, 200);
disableEntity(object_id);
end;
end
end

function fallblock_init(id) -- Falling block (TR1-3)
Expand Down Expand Up @@ -390,10 +427,10 @@ function fallblock_init(id) -- Falling block (TR1-3)
end;
end

function fallceiling_init(id) -- Falling ceiling (TR1-3) (INVALID)
function fallceiling_init(id) -- Falling ceiling (TR1-3)

setEntitySpeed(id, 0.0, 0.0, 0.0);

entity_funcs[id].onActivate = function(object_id, activator_id)
if((object_id == nil) or (activator_id == nil)) then
return;
Expand All @@ -402,25 +439,18 @@ function fallceiling_init(id) -- Falling ceiling (TR1-3) (INVALID)
local anim = getEntityAnim(object_id);
if(anim == 0) then
setEntityAnim(object_id, 1);
local once = true;
addTask(
function()
local anim = getEntityAnim(object_id);
if(anim == 1) then
return true;
end;
if(once) then
setEntityCollision(object_id, 0);
once = false;
end;
if(dropEntity(object_id, frame_time)) then
setEntityAnim(object_id, 3);
setEntityAnim(object_id, 2);
setEntityCollision(object_id, 0);
return false;
end;
return true;
end);
end;
end;

end

function pushdoor_init(id) -- Pushdoors (TR4)
Expand All @@ -445,6 +475,9 @@ function pushdoor_init(id) -- Pushdoors (TR4)
end;
end

function midastouch_init(id) -- Midas gold touch

end

function oldspike_init(id) -- Teeth spikes (INVALID)

Expand Down
14 changes: 7 additions & 7 deletions scripts/entity/entity_properties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ tr2_entity_tbl[60] = {coll = 0x01}; -- Boulder
tr2_entity_tbl[61] = {coll = 0x02}; -- Disk (like dart)
tr2_entity_tbl[62] = {coll = 0x00}; -- Wall-mounted disk shooter (like dartgun)
tr2_entity_tbl[63] = {coll = 0x01}; -- Drawbridge
tr2_entity_tbl[64] = {coll = 0x02}; -- Slamming door
tr2_entity_tbl[64] = {coll = 0x02, func = "slamdoor"}; -- Slamming door
tr2_entity_tbl[65] = {coll = 0x01}; -- Elevator
tr2_entity_tbl[66] = {coll = 0x02}; -- Minisub
tr2_entity_tbl[67] = {coll = 0x02, trav = 0x18}; -- Movable cubical block (pushable)
Expand All @@ -285,7 +285,7 @@ tr2_entity_tbl[73] = {coll = 0x02}; -- Breakable window (mus
tr2_entity_tbl[76] = {coll = 0x01}; -- Airplane propeller
tr2_entity_tbl[77] = {coll = 0x02}; -- Power saw
tr2_entity_tbl[78] = {coll = 0x02}; -- Overhead pulley hook
tr2_entity_tbl[79] = {coll = 0x02}; -- Sandbag / Ceiling fragments
tr2_entity_tbl[79] = {coll = 0x02, func = "fallceiling"}; -- Sandbag / Ceiling fragments
tr2_entity_tbl[80] = {coll = 0x02}; -- Rolling spindle
tr2_entity_tbl[81] = {coll = 0x02, func = "wallblade"}; -- Wall-mounted knife blade
tr2_entity_tbl[82] = {coll = 0x02}; -- Statue with knife blade
Expand Down Expand Up @@ -405,7 +405,7 @@ tr2_entity_tbl[253] = {coll = 0x00, hide = 0x01}; -- Fire
tr2_entity_tbl[254] = {coll = 0x00}; -- Skybox
tr2_entity_tbl[256] = {coll = 0x01}; -- Monk
tr2_entity_tbl[257] = {coll = 0x00, hide = 0x01, func = "doorbell"} -- Door bell
tr2_entity_tbl[258] = {coll = 0x00, hide = 0x01} -- Alarm bell
tr2_entity_tbl[258] = {coll = 0x00, hide = 0x01, func = "alarmbell"} -- Alarm bell
tr2_entity_tbl[259] = {coll = 0x01, func = "heli_TR2"}; -- Helicopter
tr2_entity_tbl[260] = {coll = 0x02}; -- The butler
tr2_entity_tbl[262] = {coll = 0x00, hide = 0x01}; -- Lara cutscene placement?
Expand Down Expand Up @@ -500,14 +500,14 @@ tr3_entity_tbl[87] = {coll = 0x01, func = "oldspike"}; -- Spikes
tr3_entity_tbl[88] = {coll = 0x01}; -- Boulder / Barrel
tr3_entity_tbl[89] = {coll = 0x01}; -- Giant boulder (Temple of Puna)
tr3_entity_tbl[90] = {coll = 0x01}; -- Disk (like dart)
tr3_entity_tbl[91] = {coll = 0x01}; -- Dart shooter
tr3_entity_tbl[94] = {coll = 0x01}; -- Spiked impaled skeleton / Slamming door
tr3_entity_tbl[91] = {coll = 0x01, hide = 0x01}; -- Dart shooter
tr3_entity_tbl[94] = {coll = 0x01, func = "slamdoor"}; -- Spiked impaled skeleton / Slamming door
tr3_entity_tbl[97] = {coll = 0x01, trav = 0x18}; -- Movable cubical block (pushable)
tr3_entity_tbl[98] = {coll = 0x01, trav = 0x18}; -- Movable cubical block (pushable)
tr3_entity_tbl[101] = {coll = 0x01}; -- Destroyable boarded-up window
tr3_entity_tbl[102] = {coll = 0x01}; -- Destroyable boarded-up window / wall
tr3_entity_tbl[106] = {coll = 0x01}; -- Overhead pulley hook
tr3_entity_tbl[107] = {coll = 0x01}; -- Falling fragments
tr3_entity_tbl[107] = {coll = 0x01, func = "fallceiling"}; -- Falling fragments
tr3_entity_tbl[108] = {coll = 0x01}; -- Rolling spindle
tr3_entity_tbl[110] = {coll = 0x01}; -- Subway train
tr3_entity_tbl[111] = {coll = 0x01, func = "wallblade"}; -- Wall-mounted knife blade / Knife disk
Expand Down Expand Up @@ -568,7 +568,7 @@ tr3_entity_tbl[176] = {coll = 0x00}; -- Small medipack (pick-up)
tr3_entity_tbl[177] = {coll = 0x00}; -- Large medipack (pick-up)
tr3_entity_tbl[178] = {coll = 0x00}; -- Flares (pick-up)
tr3_entity_tbl[179] = {coll = 0x00}; -- Flare (pick-up)
tr3_entity_tbl[180] = {coll = 0x00}; -- Savegame crystal (pick-up)
tr3_entity_tbl[180] = {coll = 0x00, func = "crystal_TR3"}; -- Savegame crystal (pick-up)

-- MENU ITEMS --

Expand Down
6 changes: 3 additions & 3 deletions scripts/gameflow/gameflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
---------------------------------------------------------------------------------------------------------------------------------------
-- 1 - Define global constants
---------------------------------------------------------------------------------------------------------------------------------------
gameflow_lara_home_index = 99; -- used to load Lara's Home.

GAME_1 = 0;
GAME_1_1 = 1;
GAME_1_5 = 2;
Expand Down Expand Up @@ -78,7 +76,7 @@ function getNextLevelNum(currentgame, currentlevel, operand)
end;

if(gameflow_paths[currentgame] ~= nil) then
if((nextlevel == gameflow_lara_home_index) and (gameflow_paths[currentgame].level[0] ~= nil)) then -- Load Lara's Home level, if exist.
if((nextlevel == 99) and (gameflow_paths[currentgame].level[0] ~= nil)) then -- Load Lara's Home level (99), if exist.
nextlevel = 0;
elseif(nextlevel > gameflow_paths[currentgame].numlevels) then -- No Lara's Home, load first level instead.
nextlevel = 1;
Expand Down Expand Up @@ -136,4 +134,6 @@ function setgamef(game_id, level_id)
end;
end;

SETGAMEF = setgamef;

print("Gameflow path script loaded");
10 changes: 9 additions & 1 deletion scripts/trigger/trigger_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function activateEntity(object_id, activator_id, trigger_mask, trigger_op, objec
else
object_mask = bit32.bor(object_mask, trigger_mask); -- Other cases
end;

setEntityActivationMask(object_id, object_mask);

-- Full entity mask (11111) is always a reason to activate an entity.
Expand Down Expand Up @@ -170,4 +171,11 @@ end
function playCutscene(cutscene_index)
if(getLevelVersion() < TR_IV) then return 0 end;
print("CUTSCENE: index = " .. cutscene_index);
end
end


-- Special template which is called for specific entity types at level start-up.

function prepareEntity(object_id)
activateEntity(object_id, 0, 0, 0, 0, 0);
end;
2 changes: 1 addition & 1 deletion src/character_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ int32_t Character_AddItem(struct entity_s *ent, uint32_t item_id, int32_t count)
return 0;
}

Gui_StartNotifier(item_id);
Gui_NotifierStart(item_id);

base_item_p item = World_GetBaseItemByID(&engine_world, item_id);
if(item == NULL) return 0;
Expand Down
Loading

0 comments on commit a83f01e

Please sign in to comment.