kts.Invisibility – give the current actor the Invisibility effect
kts.Invisibility(duration, message)
If the current actor (as given by cxt.actor
) is a knight, then that knight gains the Invisibility magical effect, for the next duration
milliseconds. The string message
will also flash on screen above the knight a number of times.
If the knight already has a different incompatible magic effect (such as Strength or Regeneration) then the other effect is cancelled in favour of Invisibility.
If the knight already has Invisibility, then the existing Invisibility timer is cancelled and replaced with the new one.
If the current actor is not a knight then nothing happens.
None.
Invisibility, as the name implies, makes the knight invisible to other knights (although if opponents have an ability that allows them to see other knights on their mini-map, then invisibility will not shield a knight from this effect). The invisible knight will appear in a semi-transparent form on their own screen, and also on the screens of teammates (in team games).
As far as monsters are concerned, flying monsters (such as vampire bats) are able to "see" invisible knights as normal, but walking monsters (such as zombies) will not "see" invisible knights unless they are standing right next to one.
The duration (first argument to kts.Invisibility
) is usually set to some kind of random number, to provide some unpredictability for the players. The duration value is not made visible to the player.
Ideally, there ought to be some way to define a flying monster that cannot see invisible knights, or a walking monster that can see them. In other words, the property of whether a monster can see invisible knights or not should be separated from the property of whether a monster is flying or not.
To give a knight Invisibility for a random number of seconds between 1 and 60:
kts.Invisibility(kts.RandomRange(1, 60) * 1000, "Invisibility")
The actual game code uses a slightly more complicated method for determining the duration of potion effects; details can be found in magic.lua.