Author Topic: [WIP] Ceiling dropping effect (ALTTP)  (Read 132 times)

PhoenixII54

  • Newbie
  • *
  • Posts: 10
    • View Profile
[WIP] Ceiling dropping effect (ALTTP)
« on: October 02, 2017, 10:01:07 pm »
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.
Code: Lua
  1. --Ceiling dropping system (WIP)
  2. --Reproduces the "fall from uper floors" effects
  3.  
  4. --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
  5.  
  6. --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).
  7. --Note, here, everything is in a single script, but in a real project you may have multiple file (one for each metatable)
  8.  
  9. local teletransporter_meta=sol.main.get_metatable("teletransporter")
  10. local map_meta=sol.main.get_metatable("map")
  11.  
  12. function teletransporter_meta:on_activated()
  13.   local game=self:get_game()
  14.   local ground=self:get_map():get_ground(game:get_hero():get_position())
  15.   game:set_value("tp_ground",ground)
  16. end
  17.  
  18. --the actual trigger
  19. function map_meta:on_started(destination)
  20.   local hero=self:get_hero()
  21.   local game=self:get_game()
  22.   local x,y=hero:get_position()
  23.   local ground=game:get_value("tp_ground")
  24.   if ground=="hole" then
  25.     --Falling from the ceiling
  26.     hero:set_visible(false)
  27.     hero:freeze()
  28.     --disabling teletransoprters to avoid
  29.     local disabled_teletransoprters={}
  30.     for t in self:get_entities_by_type("teletransporter") do
  31.       if t:is_enabled() then
  32.         disabled_teletransporters[#disabled_teletransporters+1]=v
  33.         t:set_enabled(false)
  34.       end
  35.     end
  36.     --Creating a "stunt actor" moving vertically from the ceiling
  37.     local falling_hero=self:create_custom_entity({
  38.       name="falling_link",
  39.       x=x,
  40.       y=math.max(y-100,24),
  41.       direction=0,
  42.       layer=self:get_max_layer(),
  43.       sprite=hero:get_tunic_sprite_id(),
  44.       width=24,
  45.       height=24,
  46.     })
  47.     falling_hero:get_sprite():set_animation("stopped")
  48.     falling_hero:set_can_traverse_ground("wall",true)
  49.     falling_hero:set_can_traverse_ground("empty",true)
  50.     falling_hero:set_can_traverse_ground("traversable",true)
  51.  
  52.     --Creating a reception platform (prevents the hero from falling into consecutive holes during the animation)
  53.     local platform=self:create_custom_entity({
  54.       name="platform",
  55.       direction=0,
  56.       layer=layer,
  57.       x=x,
  58.       y=y,
  59.       width=32,
  60.       height=32,
  61.       sprite="entities/shadow",
  62.     })
  63.     platform:bring_to_front()
  64.     platform:get_sprite():set_animation("big")
  65.     platform:set_modified_ground("traversable")
  66.  
  67.     --Creating the actual movement for the stunt actor
  68.     local movement=sol.movement.create("target")
  69.     movement:set_target(x,y)
  70.     movement:set_speed(96)  --The falling speed.
  71.     --Spinning the stunt actor on itself
  72.     sol.timer.start(falling_hero, 100, function()
  73.       falling_hero:set_direction((falling_hero:get_direction()+1)%4)
  74.       return true
  75.     end)
  76.     movement:start(falling_hero, function()
  77.       --Movement is now complete, restoring the disabled teletransoprters and getting rid of the temporary entities
  78.       sol.audio.play_sound("hero_lands")
  79.       platform:remove()
  80.       falling_hero:remove()
  81.       hero:set_visible(true)
  82.       hero:unfreeze()
  83.       for _,t in pairs(disabled_teletransporters) do
  84.         t:set_enabled(true)
  85.       end
  86.     end)
  87.     --]]
  88.   end
  89. end
  90.  

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.
« Last Edit: October 23, 2017, 05:00:28 pm by PhoenixII54 »