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

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.

edit#1 : Actually finished the v1.0 version, with ground detection on teletransportation.
« Last Edit: October 05, 2017, 09:27:43 pm by PhoenixII54 »