featherfall potion?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

featherfall potion?

Post by bongobeat »

Amazing!
viewtopic.php?f=14&t=3099&start=60
nichg wrote:Featherfall Effect

I was asked to repost this here. This is an effect that lets you give the party 'feather fall' for a fixed time, during which all falls through pits will deal no damage. It does not prevent the sound-effects associated with falling however.

The effect requires three things:

- You have to clone the party object in init.lua for the dungeon, and override the onMove and onDamage hooks:

Code: Select all

cloneObject {
   name = "party",
   baseObject = "party",

   onMove = function(party, dir)
      var_storage.set_last_level(party.level)
      var_storage.decrement_feather()
      return true
   end,
 
   onDamage = function(champion, dmg, dmgtype)
      if party.level ~= var_storage.get_last_level() then
         if var_storage.get_feather() then
            -- Feather fall
            return false
         end
      end
      return true
   end
}
This refers to a scripting object var_storage that must exist somewhere in your dungeon. Every time the party moves, it decrements the duration of their feather fall (you could just as well tie this to a timer to make it realtime). Furthermore, it stores the party's current dungeon level in a global variable in the storage object. When the party falls, their level changes before they take damage, but after onMove is called, so if the stored level and current level are different in onDamage, we know that we've taken damage due to falling down a pit (ostensibly this would also detect coincidences like falling into a fireball or something as falling damage, so there's a small chance it creates some spurious behavior).

Now, place a scripting object called 'var_storage' somewhere in the dungeon, with the following code on it:

Code: Select all

last_level = 1
feather_fall = false
feather_dur = 0

function set_feather(dur)
  feather_fall = true
  feather_dur = dur
  hudPrint("You feel lighter.")
end

function decrement_feather()
   if feather_fall == true then
      feather_dur = feather_dur - 1
      if feather_dur <= 0 then
        feather_fall = false
        hudPrint("You feel heavier.")
      end
   end
end

function get_feather()
  return feather_fall
end

function set_last_level(lev)
  last_level=lev
end

function get_last_level()
  return last_level
end
This scripting object carries global variables indicating whether the party is under the feather fall effect or not, as well as the last level. Since they're global they should be saved, so feather fall will persist across save/load. You must call var_storage.set_feather(15), for example, in order to give the party the feather fall effect (for instance from a potion use script or a spell script, or if the party interacts with a particular fountain or whatever). That would last for 15 steps, and display a message when the effect ended.

In principle this setup could be used to create any number of custom conditions or persistent spell effects. I'm not sure yet how to give graphical feedback for the effects, but ostensibly you could do something with creating a light source with particle system and move it with the party so long as the effect is up, then destroying it when the effect ends. I think it'd be weird with teleporters and pitfalls though, since there you move after onMove is done.
someone know how to add the same effect, but in a potion?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: featherfall potion?

Post by Komag »

you would make a custom potion whose effects are to the trigger the set_feather(dur) function
Finished Dungeons - complete mods to play
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: featherfall potion?

Post by bongobeat »

like that?
SpoilerShow

Code: Select all

defineObject{
		name = "potion_feather",
		class = "Item",
		uiName = "Featherfall Potion",
		model = "assets/models/items/flask_full.fbx",
		gfxIndex = 147,
		consumable = true,
		description = "This potion prevent you from any damage by fall for 15 seconds.",
		emptyItem = "flask",
		weight = 0.6,
		onUseItem = function set_feather(dur)
		playSound("consume_potion")
		return true
		end,
}
i have put the clone party script right before the "defineobject potion_feather"
well that dont do many things,
i got a error message when launching the editor
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply