Hi, in my attempts to reproduce famous effects from ALTTP to compensate the missing effects in Zelda : Mystery of Solarus, here is one of the major ones :
When you fall in e hole that has a floor below, you end up in the said room, falling from the ceiling and dropping onto the floor, after doing a few turns oaround yourself.
Be prepared, besause this is the puropse of this script.
--Ceiling dropping system (WIP)
--Reproduces the "fall from uper floors" effects
--Usage : Call this script from any game launching system or use the event manager script to set the metatables then do your maps as usuel
--Extracting actual destination and ground from teletransporters since map;on_started(destination) dosen't take special destinations in account, then stirong it to a savegame variable lCan be useful for dungeons like Skull Dungeon (Level 3 of ALTTP, which has many hole entrances).
--Note, here, everything is in a single script, but in a real project you may have multiple file (one for each metatable)
local teletransporter_meta=sol.main.get_metatable("teletransporter")
local map_meta=sol.main.get_metatable("map")
function teletransporter_meta:on_activated()
local game=self:get_game()
local ground=self:get_map():get_ground(game:get_hero():get_position())
game:set_value("tp_ground",ground)
end
--the actual trigger
function map_meta:on_started(destination)
local hero=self:get_hero()
local game=self:get_game()
local x,y=hero:get_position()
local ground=game:get_value("tp_ground")
if ground=="hole" then
--Falling from the ceiling
hero:set_visible(false)
hero:freeze()
--disabling teletransoprters to avoid
local disabled_teletransoprters={}
for t in self:get_entities_by_type("teletransporter") do
if t:is_enabled() then
disabled_teletransporters[#disabled_teletransporters+1]=v
t:set_enabled(false)
end
end
--Creating a "stunt actor" moving vertically from the ceiling
local falling_hero=self:create_custom_entity({
name="falling_link",
x=x,
y=math.max(y-100,24),
direction=0,
layer=self:get_max_layer(),
sprite=hero:get_tunic_sprite_id(),
width=24,
height=24,
})
falling_hero:get_sprite():set_animation("stopped")
falling_hero:set_can_traverse_ground("wall",true)
falling_hero:set_can_traverse_ground("empty",true)
falling_hero:set_can_traverse_ground("traversable",true)
--Creating a reception platform (prevents the hero from falling into consecutive holes during the animation)
local platform=self:create_custom_entity({
name="platform",
direction=0,
layer=layer,
x=x,
y=y,
width=32,
height=32,
sprite="entities/shadow",
})
platform:bring_to_front()
platform:get_sprite():set_animation("big")
platform:set_modified_ground("traversable")
--Creating the actual movement for the stunt actor
local movement=sol.movement.create("target")
movement:set_target(x,y)
movement:set_speed(96) --The falling speed.
--Spinning the stunt actor on itself
sol.timer.start(falling_hero, 100, function()
falling_hero:set_direction((falling_hero:get_direction()+1)%4)
return true
end)
movement:start(falling_hero, function()
--Movement is now complete, restoring the disabled teletransoprters and getting rid of the temporary entities
sol.audio.play_sound("hero_lands")
platform:remove()
falling_hero:remove()
hero:set_visible(true)
hero:unfreeze()
for _,t in pairs(disabled_teletransporters) do
t:set_enabled(true)
end
end)
--]]
end
end
Hope it will be useful, but it may have have bugs, so don't hasitate to report them to me. And remember, it is not fully finished so expect changes to happpen.
Remember that you may want to modify this script to make it compatible with Christopho's Multi-event script, which i don't use (yet) in my experiments to keep total control over my tests.
Anyway, enjoy !
edit#1 : Actually finished the v1.0 version, with ground detection on teletransportation.
Update (2017/10/23) : Modified the script to remove the extra sprite requirement and to add more flexibility. This is now likely a final version unless someone finds a more efficient way.