Page 1 of 1

Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 12:48 pm
by nichg
I figured other people might get some use out of this. I constructed a feather fall effect that negates damage on falling when up.

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.

Re: Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 1:04 pm
by Komag
that looks pretty nice! haven't tested yet. Maybe you could add it to the script repository and later to the wiki

Re: Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 1:23 pm
by Montis
I was also thinking about creating a feather fall spell but I'm not sure this is the best way to do it since I want my spell to also work when activated mid-fall and I'm not sure it would work with this method.

Re: Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 1:24 pm
by Grimwold
Looks excellent, but I'm curious... does the party still scream when you use this method? I've seen an alternative that temporarily disables all champions until after the party have hit the ground... but they still scream.

Re: Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 1:37 pm
by nichg
Yes, unfortunately they still scream and make an 'oomph' sound when they hit. Maybe its possible to do something clever with redefining the sound resource associated with those things to silence while under the effects of the feather fall? I don't know if that'd survive save/load - probably not, so you'd want to refresh it each step or something. You could then change it back when the spell wears out.

As far as activating mid-fall: I'm not sure if the game really recognizes 'during a fall'. Is it actually possible to take actions at all while falling?

Re: Feather Fall, custom conditions, etc

Posted: Thu Oct 11, 2012 7:29 pm
by thomson
Grimwold wrote:Looks excellent, but I'm curious... does the party still scream when you use this method? I've seen an alternative that temporarily disables all champions until after the party have hit the ground... but they still scream.
This is one of the basic principles of the universe, spells or not. If you are falling and are about to hit something hard, you just scream.

If the feather fall spell worked, you just stand up, suspiciously look around as ask "who was that pussy that was screaming so loud?". :)

Re: Feather Fall, custom conditions, etc

Posted: Mon Mar 04, 2013 7:46 pm
by SpiderFighter
Montis wrote:I was also thinking about creating a feather fall spell but I'm not sure this is the best way to do it since I want my spell to also work when activated mid-fall and I'm not sure it would work with this method.
Did you ever get around to this, Montis? I'm looking for something more along the lines of what you were thinking...I have a puzzle that requires several jumps, and I don't want to be unfair about it. A Feather Fall spell would fit the bill nicely (no disrespect intended to the OP).