# Last Stand OpenMW add-on.
## Problem.
Sometimes when a player party is clearing a dungeon, some of their characters die. They then resurrect at a shrine, usually far away from other players. Teleporting them back or even worse walking them back can be intrusive and break the flow. This add-on I post here aims to help with this issue.
## Function.
When a player character is below 25% of their max health, they will enter Last Stand mode for 30 seconds. While under the effect, they will remain incapacitated. However, their health will not drop below certain limit. The limit is at least 50 health or 25% of max health. If the incapacitated character is healed to triple the amount of last stand health limit, they are considered "rescued". Rescued characters get back up. If the Last Stand effect expires normally, player control will be restored, but health regeneration will stop. The Last Stand effect can occur at most once a minute.
## Requirements.
OpenMW or TES3MP with Tribunal and Bloodmoon.
## Known issues.
1. Sometimes a player character will become invulnerable. Only happened once and I am not even sure if this is the add-on's fault. Relogging fixes the issue.
2. Sometimes characters with low maximum health will die while incapacitated. This is partially intentional. However, I recognize it as an issue and seek to solve it.
3. If character's maximum health is below 150 points, they cannot be rescued. This is tied to issue #2. I can't think of a solution yet. If I make health limit relative to max health, then characters with low max health are even more vulnerable to dying while incapacitated.
## Download.
Version 1.0.0:
## Source.
-
Spoiler: Show
-
LastStand:
Code: Select all
begin LastStand
short enabled
float timeout
float spellTimeout
float cooldown
float passed
float healthLimit
short iterations
; When paused abort operation.
if (1 == MenuMode)
return
endif
if (1 == enabled)
set passed to GetSecondsPassed
set timeout to (timeout + passed)
if (timeout <= 30.0)
; Determine reasonable health limit.
; (getHealth / getHealthGetRatio) = max health
set healthLimit to ((getHealth / getHealthGetRatio) * 0.25)
if (healthLimit < 50.0)
set healthLimit to 50.0
endif
set spellTimeout to (spellTimeout + passed)
; Update per fraction of a second, instead of per frame
; to stay compatible between Morrowind, OpenMW and TES3MP.
if (spellTimeout > 0.025)
set spellTimeout to 0
if (getHealthGetRatio <= 0)
resurrect
endif
; All characters under the last stand effect
; must have health points above `healthLimit`.
; Ensure the loop ends.
set iterations to 1000
while (iterations > 0)
if (getHealth < healthLimit)
modCurrentHealth, (30.0 * passed)
set iterations to (iterations - 1)
else
set iterations to 0
endif
endwhile
; Given that the character is under last stand effect,
; and given they were healed to a certain amount,
; end last stand effect.
if (getHealth > (healthLimit * 3.0))
MessageBox, "^PCName is rescued!"
set enabled to 0
endif
; All characters under the last stand effect
; must have their fatigue spent.
; Ensure the loop ends.
set iterations to 1000
while (iterations > 0)
if (getFatigue > -2.0)
modCurrentFatigue, (-30.0 * passed)
set iterations to (iterations - 1)
else
set iterations to 0
endif
endwhile
endif
else
MessageBox, "^PCName attempts to stand up."
set enabled to 0
endif
elseif (0 == enabled)
if (cooldown <= 0)
if (getHealthGetRatio < 0.25)
if (getHealthGetRatio > 0)
set timeout to 0.0
set spellTimeout to 0.0
MessageBox, "^PCName is at the death's door!"
set cooldown to 60.0
set enabled to 1
endif
endif
endif
endif
if (cooldown > 0)
set cooldown to (cooldown - passed)
else
set cooldown to 0
endif
end LastStand
LastStandInit:
Code: Select all
Begin LastStandInit
short init
if (init != 1)
player->startscript LastStand
set init to 1
MessageBox, "Last Stand add-on initialized."
endif
End LastStandInit