Jump to content

Change player HP to Hearts like in Legend of Zelda: Hardmode


lollol

Recommended Posts

Stuck right now, so I instead updated the OP. I need to get this script to work.

Going to try to find a mod that uses Pluggy HUD functions to check out their scripts, know of any that are very similar to this idea? The best is if they actually made a custom surface image hud element.


Thankfully, Haama has made a list of some mods that require pluggy. Going to go through all of them to look at them in the CS. 
Trying to check out Kyoma's Journal Mod first then trying others. I'm looking for NewHudS being used, to see how it should be set up. Will be exciting to actually be able to make this mod work.

At least, it seems a lot easier to make this system then making a fully custom made armor. Trying to manually draw and add detail to a texture in Photoshop seems unbelievable. It seems like most of the work has to be done MS Paint style. Seems almost impossible to make a new texture that will look at all realistic. I may be able to do it someday if I ever get a PC with a multi-monitor setup, one with a zoomed out view of the texture, one that's close up for actual editing.



http://forums.bethsoft.com/topic/1038730-relzewip-pluggy-8/

================

Mods that Require Pluggy
================
Alchemical Formulas
Customisable HUD Components
Exit Oblivion with No Crash Guaranteed
Fast Hotkey Shortcuts
Journal Mod (Does this still require Pluggy, or just use it?)
Map Markers Be Done
Name that Horse
Poison Equipper
Proper Enchantments
Q-Core
Redecoration
Seducer Race
Speedy Horses
Spell Books
Spell Components
Status Bars (German download)
Time Manager
Unarmored Skill for Everyone
Vacuity
Willpower-Based Magic Resistance
Wrye Morph

==============
Mods that Use Pluggy
==============
Alternatives to Death and Reload
Auto-save and time
Battle Fatigue and Injuries
Clean Spellbook
COBL
Drag N' Drop UI
Eat and Sleep
Map Marker Overhaul
Player's Diary
RefSkope
Unnecessary Violence
Economy Enhanced

=============
Previous Threads




Found one, Battle Fatigue and Injuries.

 

Copied this part out, going to try to match it to mine and use my PNG
Part of Kuertee's script.

Let x := kRIQuest.hudGameX
Let y := kRIQuest.hudGameY
Let scale := kRIQuest.hudGameScale
Let opacity := kRIQuest.hudGameOpacity
Let menuX := kRIQuest.hudMenuX
Let menuY := kRIQuest.hudMenuY
Let menuScale := kRIQuest.hudMenuScale
Let menuOpacity := kRIQuest.hudMenuOpacity
Let showMode := 0

If pTempString == 0
;(StringID:long) CreateString EspID:short Text:string Protected:short RefuseZero:short
Let pTempString := CreateString -1 "pluggy" 0 1
EndIf
If pHUDMan == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\daVinci.png"
;(HudID:long) NewHudS Filename:stringID RootID:short Show:short X:float Y:float Layer:long Scale:float Opacity:long Align:short AutoScale:bool Protected:bool EspID:long
Let pHUDMan := NewHudS pTempString 1 11 x y
Endif
End

Tried it but it's not working.
My script:

 

scn zzzOneHeartOnlyMode
 
 
short x
short y
float scale
short opacity
short menuX
short menuY
float menuScale
short menuOpacity
 
long pTempString
long pHUDHeart
 
begin gamemode
;createString 123:Data\menus\OneHeartOnlyRiskyMode
;NewHudS -1:"menus\OneHeartOnlyRiskyMode.png",1, 1, -60, -60
Let x := 0
Let y := 0
Let scale := .25
Let opacity := 100
;Let showMode := a
 
If pTempString == 0
;(StringID:long) CreateString EspID:short Text:string Protected:short RefuseZero:short
Let pTempString := CreateString -1 "pluggy" 0 1
EndIf
If pHUDHeart == 0
SetString pTempString "Menus\OneHeartOnlyRiskyMode.png"
 
;(HudID:long) NewHudS Filename:stringID RootID:short Show:short X:float Y:float Layer:long Scale:float Opacity:long Align:short AutoScale:bool Protected:bool EspID:long
Let pHUDHeart := NewHudS pTempString 1 1 x y
endif
 
end

 


This is just an attempt to get this working at a basic level


Stuck right now, so I instead updated the OP. I need to get this script to work.

Link to comment

Suggestion: try to use the other mod with your image. See if it works. If it does, you eliminate any possibility of a faulty image.

If it doesn't, check the differences between the pictures.

 

Other than that, try this script:

 

 

scn zzzOneHeartOnlyMode

short x

short y

float scale

short opacity

short menuX

short menuY

float menuScale

short menuOpacity

short showMode



long pTempString

long pHUDHeart



begin gamemode

Let x := 0

Let y := 0

Let scale := .25

Let opacity := 100

Let showMode := 0

Let menuX := 0

Let menuY := 0

Let menuScale := .25

Let menuOpacity := 100



If pTempString == 0

    Let pTempString := CreateString -1 "pluggy" 0 1

EndIf

If pHUDHeart == 0

    SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"

    Let pHUDHeart := NewHudS pTempString 1 11 x y 500 1 90 9

Endif

 

end

 

 

 

If that doesn't work, try changing this line:

SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"

To this:

SetString pTempString 1:"Textures\Menus\OneHeartOnlyRiskyMode.png"

 

And see if it works.

 

I haven't messed with UI elements in over a year and a half, so I don't really remember everything.

 

My internet has some... "Issues" lately. Could't use it at all yesterday, and having issues now. I'm not sure what's going on. Tech guy was here today and couldn't figure out what was going on.

So if I don't answer as quickly as you'd like, that's why.

Link to comment

just my 2 cents !!!      you have a life bar  can be represented as a heart        but what would you do with  the magic bar   (a sorcerrer hat ?)   and what about the fatigue bar ?

 

 

you have an other mod     the hudstatut bar     you can find different exemples in it      (can not help more  if i even did help).

Link to comment

Did not work. I'm going to install Battle Fatigue to see if it'll work. Also do we rename just the OBSE_Elys_Pluggy.dll to OBSE_Elys_Pluggy_Hud.dll, or do we also rename OBSE_Elys_Pluggy.dlx to OBSE_Elys_Pluggy_Hud.dlx?

Installed Battle Fatigue and can confirm it works.

 

Battle_fatigue_works.jpg[/url]

 

 

Tried it with my image overwriting theirs: Now it works. Strange

 

 

Batte_Fatigue_swapped_image.jpg

 

 

 

As best as I can tell, probably some tiny error(that doesn't even show up when you save in CS) in our script is making it not run.

 

I'm basically mimicing his script, so it shouldn't be something like it appearing off screen

 

 

just my 2 cents !!!      you have a life bar  can be represented as a heart        but what would you do with  the magic bar   (a sorcerrer hat ?)   and what about the fatigue bar ?

 

 

you have an other mod     the hudstatut bar     you can find different exemples in it      (can not help more  if i even did help).

I showed the heart system by using photoshop to quickly add it to screenshots. The Magicka and Fatigue bar will be in the same place, the hearts will be just above them. Magicka and Fatigue will be unchanged. Some spells will be rebalanced, they will cost more magicka. I'm using Darnified UI, so the bars are smaller, and easily fit under the hearts
Link to comment

Frankly, I'm not entirely sure what's wrong at this point...

 

The scripts are pretty much identical. I have to assume both are quest scripts, being called on game start, yes? Does the battle fatigue mod have any other script that might be related, or perhaps is there any other part to the battle fatigue mod script?

Link to comment

As best as I can tell, probably some tiny error(that doesn't even show up when you save in CS) in our script is making it not run in-game. Thank you for helping!


 
Quest_menu.jpg


I'm going to just put all his scripts in this spoiler


The KRIHUDQuest's Quest Script


ScriptName kRIHUDQuestScript
float fQuestDelayTime
 
short x
short y
float scale
short opacity
short menuX
short menuY
float menuScale
short menuOpacity
 
float arm
float lastArm
float body
float lastBody
float leg
float lastLeg
float head
float lastHead
 
short armR
short armL
short legR
short legL
 
long pHUDMan
long pHUDHead
long pHUDArmR
long pHUDArmL
long pHUDBody
long pHUDLegR
long pHUDLegL
long pTempString
 
short pluggy
short tempShort
short tempShort2
float tempFloat
 
short showMode
;0 = player
;1 = debug target
 
short fromMenuMode
 
short lastHeadOpacity
short lastArmROpacity
short lastArmLOpacity
short lastBodyOpacity
short lastLegROpacity
short lastLegLOpacity
 
short lastManOpacity
short totalInjuries
short lastTotalInjuries
 
Short started
 
Begin GameMode
If IsPlayerMovingIntoNewSpace
Return
EndIf
 
If fQuestDelayTime != 1
Let fQuestDelayTime := 1
EndIf
 
If GetGameLoaded || started == 0
Let started := 1
 
Let pluggy := 0
If IsPluginInstalled "OBSE_Elys_Pluggy"
Let pluggy := (GetPluginVersion "OBSE_Elys_Pluggy") >= 124 && IsHUDEnabled
EndIf
 
If pluggy
DelAllHudSs
EndIf
 
Let pHUDMan := 0
Let pHUDHead := 0
Let pHUDArmR := 0
Let pHUDArmL := 0
Let pHUDBody := 0
Let pHUDLegR := 0
Let pHUDLegL := 0
EndIf
 
If pluggy == 0 || kRIQuest.showHUDInGameMode == 0
Return
EndIf
 
Let x := kRIQuest.hudGameX
Let y := kRIQuest.hudGameY
Let scale := kRIQuest.hudGameScale
Let opacity := kRIQuest.hudGameOpacity
Let menuX := kRIQuest.hudMenuX
Let menuY := kRIQuest.hudMenuY
Let menuScale := kRIQuest.hudMenuScale
Let menuOpacity := kRIQuest.hudMenuOpacity
Let showMode := 0
 
If pTempString == 0
;(StringID:long) CreateString EspID:short Text:string Protected:short RefuseZero:short
Let pTempString := CreateString -1 "pluggy" 0 1
EndIf
If pHUDMan == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\daVinci.png"
;(HudID:long) NewHudS Filename:stringID RootID:short Show:short X:float Y:float Layer:long Scale:float Opacity:long Align:short AutoScale:bool Protected:bool EspID:long
Let pHUDMan := NewHudS pTempString 1 11 x y
HudS_SclX pHUDMan scale
HudS_SclY pHUDMan scale
HudS_Opac pHUDMan opacity
EndIf
If pHUDHead == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\head.png"
Let pHUDHead := NewHudS pTempString 1 11 x y
HudS_SclX pHUDHead scale
HudS_SclY pHUDHead scale
HudS_Opac pHUDHead 0
EndIf
If pHUDArmR == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\arm_right.png"
Let pHUDArmR := NewHudS pTempString 1 11 x y
HudS_SclX pHUDArmR scale
HudS_SclY pHUDArmR scale
HudS_Opac pHUDHead 0
EndIf
If pHUDArmL == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\arm_left.png"
Let pHUDArmL := NewHudS pTempString 1 11 x y
HudS_SclX pHUDArmL scale
HudS_SclY pHUDArmL scale
HudS_Opac pHUDArmL 0
EndIf
If pHUDBody == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\torso.png"
Let pHUDBody := NewHudS pTempString 1 11 x y
HudS_SclX pHUDBody scale
HudS_SclY pHUDBody scale
HudS_Opac pHUDBody 0
EndIf
If pHUDLegR == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\leg_right.png"
Let pHUDLegR := NewHudS pTempString 1 11 x y
HudS_SclX pHUDLegR scale
HudS_SclY pHUDLegR scale
HudS_Opac pHUDLegR 0
EndIf
If pHUDLegL == 0
SetString pTempString "Textures\kuerteeBattleFatigueAndInjuries\leg_left.png"
Let pHUDLegL := NewHudS pTempString 1 11 x y
HudS_SclX pHUDLegL scale
HudS_SclY pHUDLegL scale
HudS_Opac pHUDLegL 0
EndIf
 
Let totalInjuries := arm + body + leg + head
If totalInjuries != lastTotalInjuries || fromMenuMode
If totalInjuries == 0
Let lastManOpacity := 10
Else
Let lastManOpacity := opacity
EndIf
HudS_X pHUDMan x
HudS_Y pHUDMan y
HudS_Opac pHUDMan lastManOpacity
Let lastTotalInjuries := totalInjuries
EndIf
 
If arm != lastArm || fromMenuMode
If arm != lastArm
Let tempShort := arm - lastArm
Let tempFloat := Rand 0 1
If tempFloat > 0.5;right
Let armR := armR + tempShort
If armR < 0
Let armL := armL + armR
If armL < 0
Let armL := 0
EndIf
Let armR := 0
EndIf
Else
Let armL := armL + tempShort
If armL < 0
Let armR := armR + armL
If armR < 0
Let armR := 0
EndIf
Let armL := 0
EndIf
EndIf
Let tempFloat := armR / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastArmROpacity
EndIf
HudS_X pHUDArmR x
HudS_Y pHUDArmR y
HudS_Opac pHUDArmR tempShort
Let lastArmROpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: arm %0.2f armR %0.2f opacity %0.2f" arm armR tempShort
EndIf
If arm != lastArm
Let tempFloat := armL / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastArmLOpacity
EndIf
HudS_X pHUDArmL x
HudS_Y pHUDArmL y
HudS_Opac pHUDArmL tempShort
Let lastArmLOpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: arm %0.2f lastArm %0.2f armL %0.2f opacity %0.2f" arm lastArm armL tempShort
EndIf
Let lastArm := arm
EndIf
 
If body != lastBody || fromMenuMode
If body != lastBody
Let tempShort := body
If tempShort < 0
Let tempShort := 0
ElseIf tempShort > 5
Let tempShort := 5
EndIf
Let tempFloat := body / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastBodyOpacity
EndIf
HudS_X pHUDBody x
HudS_Y pHUDBody y
HudS_Opac pHUDBody tempShort
Let lastBodyOpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: body %0.2f lastBody %0.2f opacity %0.2f" body lastBody tempShort
EndIf
Let lastBody := body
EndIf
 
If leg != lastLeg || fromMenuMode
If leg != lastLeg
Let tempShort := leg - lastLeg
Let tempFloat := Rand 0 1
If tempFloat > 0.5;right
Let legR := legR + tempShort
If legR < 0
Let legL := legL + legR
If legL < 0
Let legL := 0
EndIf
Let legR := 0
EndIf
Else
Let legL := legL + tempShort
If legL < 0
Let legR := legR + legL
If legR < 0
Let legR := 0
EndIf
Let legL := 0
EndIf
EndIf
Let tempFloat := legR / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastLegROpacity
EndIf
HudS_X pHUDLegR x
HudS_Y pHUDLegR y
HudS_Opac pHUDLegR tempShort
Let lastLegROpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: leg %0.2f legR %0.2f opacity %0.2f" leg legR tempShort
EndIf
If leg != lastLeg
Let tempFloat := legL / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastLegLOpacity
EndIf
HudS_X pHUDLegL x
HudS_Y pHUDLegL y
HudS_Opac pHUDLegL tempShort
Let lastLegLOpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: leg %0.2f lastLeg %0.2f legL %0.2f opacity %0.2f" leg lastLeg legL tempShort
EndIf
Let lastLeg := leg
EndIf
 
If head != lastHead || fromMenuMode
If head != lastHead
If tempShort < 0
Let tempShort := 0
ElseIf tempShort > 5
Let tempShort := 5
EndIf
Let tempFloat := head / 5 * opacity
Let tempShort := Ceil tempFloat
If tempShort > 100
Let tempShort := 100
EndIf
Else
Let tempShort := lastHeadOpacity
EndIf
HudS_X pHUDHead x
HudS_Y pHUDHead y
HudS_Opac pHUDHead tempShort
Let lastHeadOpacity := tempShort
If kRIQuest.debug
PrintToConsole "kRIHUD: head %0.2f lastHead %0.2f opacity %0.2f" head lastHead tempShort
EndIf
Let lastHead := head
EndIf
 
Let fromMenuMode := 0
end
 
Begin MenuMode
If fQuestDelayTime != 1
Let fQuestDelayTime := 1
EndIf
 
If pluggy == 0 || kRIQuest.showHUDInMenuMode == 0
Return
EndIf
 
If MenuMode 1 && MenuMode 1023 == 0
If fromMenuMode != 1
Let fromMenuMode := 1
HudS_X pHUDMan menuX
HudS_Y pHUDMan menuY
HudS_X pHUDHead menuX
HudS_Y pHUDHead menuY
HudS_X pHUDArmR menuX
HudS_Y pHUDArmR menuY
HudS_X pHUDArmL menuX
HudS_Y pHUDArmL menuY
HudS_X pHUDBody menuX
HudS_Y pHUDBody menuY
HudS_X pHUDLegR menuX
HudS_Y pHUDLegR menuY
HudS_X pHUDLegL menuX
HudS_Y pHUDLegL menuY
 
HudS_Opac pHUDMan menuOpacity
HudS_Opac pHUDHead lastHeadOpacity
HudS_Opac pHUDArmR lastArmROpacity
HudS_Opac pHUDArmL lastArmLOpacity
HudS_Opac pHUDBody lastBodyOpacity
HudS_Opac pHUDLegR lastLegROpacity
HudS_Opac pHUDLegL lastLegLOpacity
EndIf
Else
If fromMenuMode != 2
Let fromMenuMode := 2
HudS_Opac pHUDMan 0
HudS_Opac pHUDHead 0
HudS_Opac pHUDArmR 0
HudS_Opac pHUDArmL 0
HudS_Opac pHUDBody 0
HudS_Opac pHUDLegR 0
HudS_Opac pHUDLegL 0
EndIf
EndIf
End


The KRIQuest's Quest Script

ScriptName kRIQuestScript
float fQuestDelayTime

float hoursToFullHealth ;number of hours to restore full health

float healthLeftToAcquireBattleFatigue ;battle fatigue increases when health decreases below this
float battleFatigueDamage ;amount of battle fatigue per increase
float battleFatigueHealAwake ;amount of battle fatigue per decrease when awake
float battleFatigueHealAsleep ;amount of battle fatigue per decrease when asleep
short combatRestartsBattleFatigueHealTimer

float healthLossToAcquireInjury ;injury is acquired when this much health is loss in one iteration
float chanceOfInjury ;small chance of injury regardless of damage
float chanceOfInjuryIncrease ;increase chance of injury per second
float injuryDamage ;amount of injury per increase
float injuryHealAwake ;amount of injury per decrease when awake
float injuryHealAsleep ;amount of injury per decerase when asleep
short combatRestartsInjuryHealTimer

short healInCombat

short debug

ref getRef
short itemCount

float randomBodyInjuryRange
float randomArmInjuryRange
float randomLegInjuryRange
float randomHeadInjuryRange

ref lastApparelRef
ref newApparelRef
ref enchantmentRef

ref fortifyHealthRef

float battleFatigueDamageMultiplier
float injuryDamageMultiplier

short armInjuriesAffectStrength
short bodyInjuriesAffectStrength
short legInjuriesAffectStrength

array_var healthInjuries

array_var agilityInjuries
array_var enduranceInjuries
array_var intelligenceInjuries
array_var personalityInjuries
array_var speedInjuries
array_var strengthInjuries
array_var willpowerInjuries

array_var agilityReliefs
array_var enduranceReliefs
array_var intelligenceReliefs
array_var personalityReliefs
array_var speedReliefs
array_var strengthReliefs
array_var willpowerReliefs

short maxReliefTime

float ArraySize

short functionMode

short applyToNPCs

short healthAffectsHoursToFullHealth

float secondsToCaptureDamageForInjury

float healingMagicReliefFactor
float healingMagicReliefDuration

float tempFloat
float tempFloat2
float tempFloat3

short movingIntoNewSpace

ref debugRef

float version
float lastVersion
short newVersion

short hudGameX
short hudGameY
float hudGameScale
short hudGameOpacity
short hudMenuX
short hudMenuY
float hudMenuScale
short hudMenuOpacity
short showHUDInGameMode
short showHUDInMenuMode

short updateHUD

float distance

float tempFloat4
float tempFloat5

array_var healthReliefs

Short started

Ref applyMagicalReliefToRef
Float applyMagicalReliefFromMagnitude

begin GameMode
if IsPlayerMovingIntoNewSpace
Let movingIntoNewSpace := 5
Return
ElseIf movingIntoNewSpace > 0
Let movingIntoNewSpace := movingIntoNewSpace - 1
Return
endif
Let movingIntoNewSpace := 0

If Player.GetDead
Let fQuestDelayTime := 0.001
Elseif fQuestDelayTime != 1
set fQuestDelayTime to 1
endif

If version != 0.62
Let version := 0.62
EndIf
If version != lastVersion
Let lastVersion := version
Let newVersion := 1
ElseIf newVersion != 0
Let newVersion := 0
EndIf

If GetGameRestarted
;If IsModLoaded "Nehrim.esm" == 0
SetEventHandler "OnDrinkPotion" FunctionCheckForMagicOnHealth
SetEventHandler "OnScrollCast" FunctionCheckForMagicOnHealth
SetEventHandler "OnSpellCast" FunctionCheckForMagicOnHealth
;EndIf
EndIf

if GetGameLoaded || started == 0
Let started := 1

set hoursToFullHealth to 1

set healthLeftToAcquireBattleFatigue to 25
set battleFatigueDamage to 1
set battleFatigueHealAwake to 1/24
set battleFatigueHealAsleep to 1/8
set combatRestartsBattleFatigueHealTimer to 0

Let secondsToCaptureDamageForInjury := 3
set healthLossToAcquireInjury to 30
set chanceOfInjury to 1
set chanceOfInjuryIncrease to 1/60
set armInjuriesAffectStrength to 1
set bodyInjuriesAffectStrength to 1
set legInjuriesAffectStrength to 1
set injuryDamage to 1
set injuryHealAwake to 1/24
set injuryHealAsleep to 1/8
set combatRestartsInjuryHealTimer to 0

set randomBodyInjuryRange to 40
set randomArmInjuryRange to 70
set randomLegInjuryRange to 90
set randomHeadInjuryRange to 100

set healInCombat to 0
set maxReliefTime to 4
Let healthAffectsHoursToFullHealth := 1

Let healingMagicReliefFactor := 1
Let healingMagicReliefDuration := 12

set debug to 0

set battleFatigueDamageMultiplier to 5
set injuryDamageMultiplier to 5

Let applyToNPCs := 1

Let showHUDInGameMode := 1
Let hudGameX := 10
Let hudGameY := 625
Let hudGameScale := 0.25
Let hudGameOpacity := 100
Let showHUDInMenuMode := 1
Let hudMenuX := 660
Let hudMenuY := 95
Let hudMenuScale := 0.25
Let hudMenuOpacity := 100

RunBatchScript "Data\ini\kuerteeBattleFatigueAndInjuries.ini"

Let updateHUD := 1

Let ArraySize := ar_Size agilityInjuries
If debug
PrintToConsole "kRI: agilityInjuries size %0.2f" ArraySize
EndIf
If ArraySize == -1
If debug
PrintToConsole "kRI: initialising injury arrays"
EndIf

Let healthInjuries := ar_Construct Array

Let agilityInjuries := ar_Construct Array
Let enduranceInjuries := ar_Construct Array
Let intelligenceInjuries := ar_Construct Array
Let personalityInjuries := ar_Construct Array
Let speedInjuries := ar_Construct Array
Let strengthInjuries := ar_Construct Array
Let willpowerInjuries := ar_Construct Array

Let agilityInjuries [0] := kRICAgility1
Let agilityInjuries [1] := kRICAgility2
Let agilityInjuries [2] := kRICAgility3
Let agilityInjuries [3] := kRICAgility4
Let agilityInjuries [4] := kRICAgility5
Let agilityInjuries [5] := kRICAgility6
Let agilityInjuries [6] := kRICAgility7
Let agilityInjuries [7] := kRICAgility8
Let agilityInjuries [8] := kRICAgility9
Let agilityInjuries [9] := kRICAgility10
Let agilityInjuries [10] := kRICAgility11
Let agilityInjuries [11] := kRICAgility12
Let agilityInjuries [12] := kRICAgility13
Let agilityInjuries [13] := kRICAgility14
Let agilityInjuries [14] := kRICAgility15
Let agilityInjuries [15] := kRICAgility16
Let agilityInjuries [16] := kRICAgility17
Let agilityInjuries [17] := kRICAgility18
Let agilityInjuries [18] := kRICAgility19
Let agilityInjuries [19] := kRICAgility20
Let agilityInjuries [20] := kRICAgility21
Let agilityInjuries [21] := kRICAgility22
Let agilityInjuries [22] := kRICAgility23
Let agilityInjuries [23] := kRICAgility24
Let agilityInjuries [24] := kRICAgility25

Let enduranceInjuries [0] := kRICEndurance1
Let enduranceInjuries [1] := kRICEndurance2
Let enduranceInjuries [2] := kRICEndurance3
Let enduranceInjuries [3] := kRICEndurance4
Let enduranceInjuries [4] := kRICEndurance5
Let enduranceInjuries [5] := kRICEndurance6
Let enduranceInjuries [6] := kRICEndurance7
Let enduranceInjuries [7] := kRICEndurance8
Let enduranceInjuries [8] := kRICEndurance9
Let enduranceInjuries [9] := kRICEndurance10
Let enduranceInjuries [10] := kRICEndurance11
Let enduranceInjuries [11] := kRICEndurance12
Let enduranceInjuries [12] := kRICEndurance13
Let enduranceInjuries [13] := kRICEndurance14
Let enduranceInjuries [14] := kRICEndurance15
Let enduranceInjuries [15] := kRICEndurance16
Let enduranceInjuries [16] := kRICEndurance17
Let enduranceInjuries [17] := kRICEndurance18
Let enduranceInjuries [18] := kRICEndurance19
Let enduranceInjuries [19] := kRICEndurance20
Let enduranceInjuries [20] := kRICEndurance21
Let enduranceInjuries [21] := kRICEndurance22
Let enduranceInjuries [22] := kRICEndurance23
Let enduranceInjuries [23] := kRICEndurance24
Let enduranceInjuries [24] := kRICEndurance25

Let healthInjuries [0] := kRICHealth1
Let healthInjuries [1] := kRICHealth2
Let healthInjuries [2] := kRICHealth3
Let healthInjuries [3] := kRICHealth4
Let healthInjuries [4] := kRICHealth5
Let healthInjuries [5] := kRICHealth6
Let healthInjuries [6] := kRICHealth7
Let healthInjuries [7] := kRICHealth8
Let healthInjuries [8] := kRICHealth9
Let healthInjuries [9] := kRICHealth10
Let healthInjuries [10] := kRICHealth11
Let healthInjuries [11] := kRICHealth12
Let healthInjuries [12] := kRICHealth13
Let healthInjuries [13] := kRICHealth14
Let healthInjuries [14] := kRICHealth15
Let healthInjuries [15] := kRICHealth16
Let healthInjuries [16] := kRICHealth17
Let healthInjuries [17] := kRICHealth18
Let healthInjuries [18] := kRICHealth19
Let healthInjuries [19] := kRICHealth20
Let healthInjuries [20] := kRICHealth21
Let healthInjuries [21] := kRICHealth22
Let healthInjuries [22] := kRICHealth23
Let healthInjuries [23] := kRICHealth24
Let healthInjuries [24] := kRICHealth25

Let intelligenceInjuries [0] := kRICIntelligence1
Let intelligenceInjuries [1] := kRICIntelligence2
Let intelligenceInjuries [2] := kRICIntelligence3
Let intelligenceInjuries [3] := kRICIntelligence4
Let intelligenceInjuries [4] := kRICIntelligence5
Let intelligenceInjuries [5] := kRICIntelligence6
Let intelligenceInjuries [6] := kRICIntelligence7
Let intelligenceInjuries [7] := kRICIntelligence8
Let intelligenceInjuries [8] := kRICIntelligence9
Let intelligenceInjuries [9] := kRICIntelligence10
Let intelligenceInjuries [10] := kRICIntelligence11
Let intelligenceInjuries [11] := kRICIntelligence12
Let intelligenceInjuries [12] := kRICIntelligence13
Let intelligenceInjuries [13] := kRICIntelligence14
Let intelligenceInjuries [14] := kRICIntelligence15
Let intelligenceInjuries [15] := kRICIntelligence16
Let intelligenceInjuries [16] := kRICIntelligence17
Let intelligenceInjuries [17] := kRICIntelligence18
Let intelligenceInjuries [18] := kRICIntelligence19
Let intelligenceInjuries [19] := kRICIntelligence20
Let intelligenceInjuries [20] := kRICIntelligence21
Let intelligenceInjuries [21] := kRICIntelligence22
Let intelligenceInjuries [22] := kRICIntelligence23
Let intelligenceInjuries [23] := kRICIntelligence24
Let intelligenceInjuries [24] := kRICIntelligence25

Let personalityInjuries [0] := kRICPersonality1
Let personalityInjuries [1] := kRICPersonality2
Let personalityInjuries [2] := kRICPersonality3
Let personalityInjuries [3] := kRICPersonality4
Let personalityInjuries [4] := kRICPersonality5
Let personalityInjuries [5] := kRICPersonality6
Let personalityInjuries [6] := kRICPersonality7
Let personalityInjuries [7] := kRICPersonality8
Let personalityInjuries [8] := kRICPersonality9
Let personalityInjuries [9] := kRICPersonality10
Let personalityInjuries [10] := kRICPersonality11
Let personalityInjuries [11] := kRICPersonality12
Let personalityInjuries [12] := kRICPersonality13
Let personalityInjuries [13] := kRICPersonality14
Let personalityInjuries [14] := kRICPersonality15
Let personalityInjuries [15] := kRICPersonality16
Let personalityInjuries [16] := kRICPersonality17
Let personalityInjuries [17] := kRICPersonality18
Let personalityInjuries [18] := kRICPersonality19
Let personalityInjuries [19] := kRICPersonality20
Let personalityInjuries [20] := kRICPersonality21
Let personalityInjuries [21] := kRICPersonality22
Let personalityInjuries [22] := kRICPersonality23
Let personalityInjuries [23] := kRICPersonality24
Let personalityInjuries [24] := kRICPersonality25

Let speedInjuries [0] := kRICSpeed1
Let speedInjuries [1] := kRICSpeed2
Let speedInjuries [2] := kRICSpeed3
Let speedInjuries [3] := kRICSpeed4
Let speedInjuries [4] := kRICSpeed5
Let speedInjuries [5] := kRICSpeed6
Let speedInjuries [6] := kRICSpeed7
Let speedInjuries [7] := kRICSpeed8
Let speedInjuries [8] := kRICSpeed9
Let speedInjuries [9] := kRICSpeed10
Let speedInjuries [10] := kRICSpeed11
Let speedInjuries [11] := kRICSpeed12
Let speedInjuries [12] := kRICSpeed13
Let speedInjuries [13] := kRICSpeed14
Let speedInjuries [14] := kRICSpeed15
Let speedInjuries [15] := kRICSpeed16
Let speedInjuries [16] := kRICSpeed17
Let speedInjuries [17] := kRICSpeed18
Let speedInjuries [18] := kRICSpeed19
Let speedInjuries [19] := kRICSpeed20
Let speedInjuries [20] := kRICSpeed21
Let speedInjuries [21] := kRICSpeed22
Let speedInjuries [22] := kRICSpeed23
Let speedInjuries [23] := kRICSpeed24
Let speedInjuries [24] := kRICSpeed25

Let strengthInjuries [0] := kRICStrength1
Let strengthInjuries [1] := kRICStrength2
Let strengthInjuries [2] := kRICStrength3
Let strengthInjuries [3] := kRICStrength4
Let strengthInjuries [4] := kRICStrength5
Let strengthInjuries [5] := kRICStrength6
Let strengthInjuries [6] := kRICStrength7
Let strengthInjuries [7] := kRICStrength8
Let strengthInjuries [8] := kRICStrength9
Let strengthInjuries [9] := kRICStrength10
Let strengthInjuries [10] := kRICStrength11
Let strengthInjuries [11] := kRICStrength12
Let strengthInjuries [12] := kRICStrength13
Let strengthInjuries [13] := kRICStrength14
Let strengthInjuries [14] := kRICStrength15
Let strengthInjuries [15] := kRICStrength16
Let strengthInjuries [16] := kRICStrength17
Let strengthInjuries [17] := kRICStrength18
Let strengthInjuries [18] := kRICStrength19
Let strengthInjuries [19] := kRICStrength20
Let strengthInjuries [20] := kRICStrength21
Let strengthInjuries [21] := kRICStrength22
Let strengthInjuries [22] := kRICStrength23
Let strengthInjuries [23] := kRICStrength24
Let strengthInjuries [24] := kRICStrength25

Let willpowerInjuries [0] := kRICWillpower1
Let willpowerInjuries [1] := kRICWillpower2
Let willpowerInjuries [2] := kRICWillpower3
Let willpowerInjuries [3] := kRICWillpower4
Let willpowerInjuries [4] := kRICWillpower5
Let willpowerInjuries [5] := kRICWillpower6
Let willpowerInjuries [6] := kRICWillpower7
Let willpowerInjuries [7] := kRICWillpower8
Let willpowerInjuries [8] := kRICWillpower9
Let willpowerInjuries [9] := kRICWillpower10
Let willpowerInjuries [10] := kRICWillpower11
Let willpowerInjuries [11] := kRICWillpower12
Let willpowerInjuries [12] := kRICWillpower13
Let willpowerInjuries [13] := kRICWillpower14
Let willpowerInjuries [14] := kRICWillpower15
Let willpowerInjuries [15] := kRICWillpower16
Let willpowerInjuries [16] := kRICWillpower17
Let willpowerInjuries [17] := kRICWillpower18
Let willpowerInjuries [18] := kRICWillpower19
Let willpowerInjuries [19] := kRICWillpower20
Let willpowerInjuries [20] := kRICWillpower21
Let willpowerInjuries [21] := kRICWillpower22
Let willpowerInjuries [22] := kRICWillpower23
Let willpowerInjuries [23] := kRICWillpower24
Let willpowerInjuries [24] := kRICWillpower25
EndIf

Let ArraySize := ar_Size agilityReliefs
If debug
PrintToConsole "kRI: agilityReliefs size %0.2f" ArraySize
EndIf

If ArraySize == -1
If debug
PrintToConsole "kRI: initialising relief arrays"
EndIf

Let agilityReliefs := ar_Construct Array
Let enduranceReliefs := ar_Construct Array
Let intelligenceReliefs := ar_Construct Array
Let personalityReliefs := ar_Construct Array
Let speedReliefs := ar_Construct Array
Let strengthReliefs := ar_Construct Array
Let willpowerReliefs := ar_Construct Array

Let agilityReliefs [0] := kRICAgilityFortify1
Let agilityReliefs [1] := kRICAgilityFortify2
Let agilityReliefs [2] := kRICAgilityFortify3
Let agilityReliefs [3] := kRICAgilityFortify4
Let agilityReliefs [4] := kRICAgilityFortify5
Let agilityReliefs [5] := kRICAgilityFortify6
Let agilityReliefs [6] := kRICAgilityFortify7
Let agilityReliefs [7] := kRICAgilityFortify8
Let agilityReliefs [8] := kRICAgilityFortify9
Let agilityReliefs [9] := kRICAgilityFortify10
Let agilityReliefs [10] := kRICAgilityFortify11
Let agilityReliefs [11] := kRICAgilityFortify12
Let agilityReliefs [12] := kRICAgilityFortify13
Let agilityReliefs [13] := kRICAgilityFortify14
Let agilityReliefs [14] := kRICAgilityFortify15
Let agilityReliefs [15] := kRICAgilityFortify16
Let agilityReliefs [16] := kRICAgilityFortify17
Let agilityReliefs [17] := kRICAgilityFortify18
Let agilityReliefs [18] := kRICAgilityFortify19
Let agilityReliefs [19] := kRICAgilityFortify20
Let agilityReliefs [20] := kRICAgilityFortify21
Let agilityReliefs [21] := kRICAgilityFortify22
Let agilityReliefs [22] := kRICAgilityFortify23
Let agilityReliefs [23] := kRICAgilityFortify24
Let agilityReliefs [24] := kRICAgilityFortify25

Let enduranceReliefs [0] := kRICEnduranceFortify1
Let enduranceReliefs [1] := kRICEnduranceFortify2
Let enduranceReliefs [2] := kRICEnduranceFortify3
Let enduranceReliefs [3] := kRICEnduranceFortify4
Let enduranceReliefs [4] := kRICEnduranceFortify5
Let enduranceReliefs [5] := kRICEnduranceFortify6
Let enduranceReliefs [6] := kRICEnduranceFortify7
Let enduranceReliefs [7] := kRICEnduranceFortify8
Let enduranceReliefs [8] := kRICEnduranceFortify9
Let enduranceReliefs [9] := kRICEnduranceFortify10
Let enduranceReliefs [10] := kRICEnduranceFortify11
Let enduranceReliefs [11] := kRICEnduranceFortify12
Let enduranceReliefs [12] := kRICEnduranceFortify13
Let enduranceReliefs [13] := kRICEnduranceFortify14
Let enduranceReliefs [14] := kRICEnduranceFortify15
Let enduranceReliefs [15] := kRICEnduranceFortify16
Let enduranceReliefs [16] := kRICEnduranceFortify17
Let enduranceReliefs [17] := kRICEnduranceFortify18
Let enduranceReliefs [18] := kRICEnduranceFortify19
Let enduranceReliefs [19] := kRICEnduranceFortify20
Let enduranceReliefs [20] := kRICEnduranceFortify21
Let enduranceReliefs [21] := kRICEnduranceFortify22
Let enduranceReliefs [22] := kRICEnduranceFortify23
Let enduranceReliefs [23] := kRICEnduranceFortify24
Let enduranceReliefs [24] := kRICEnduranceFortify25

Let intelligenceReliefs [0] := kRICIntelligenceFortify1
Let intelligenceReliefs [1] := kRICIntelligenceFortify2
Let intelligenceReliefs [2] := kRICIntelligenceFortify3
Let intelligenceReliefs [3] := kRICIntelligenceFortify4
Let intelligenceReliefs [4] := kRICIntelligenceFortify5
Let intelligenceReliefs [5] := kRICIntelligenceFortify6
Let intelligenceReliefs [6] := kRICIntelligenceFortify7
Let intelligenceReliefs [7] := kRICIntelligenceFortify8
Let intelligenceReliefs [8] := kRICIntelligenceFortify9
Let intelligenceReliefs [9] := kRICIntelligenceFortify10
Let intelligenceReliefs [10] := kRICIntelligenceFortify11
Let intelligenceReliefs [11] := kRICIntelligenceFortify12
Let intelligenceReliefs [12] := kRICIntelligenceFortify13
Let intelligenceReliefs [13] := kRICIntelligenceFortify14
Let intelligenceReliefs [14] := kRICIntelligenceFortify15
Let intelligenceReliefs [15] := kRICIntelligenceFortify16
Let intelligenceReliefs [16] := kRICIntelligenceFortify17
Let intelligenceReliefs [17] := kRICIntelligenceFortify18
Let intelligenceReliefs [18] := kRICIntelligenceFortify19
Let intelligenceReliefs [19] := kRICIntelligenceFortify20
Let intelligenceReliefs [20] := kRICIntelligenceFortify21
Let intelligenceReliefs [21] := kRICIntelligenceFortify22
Let intelligenceReliefs [22] := kRICIntelligenceFortify23
Let intelligenceReliefs [23] := kRICIntelligenceFortify24
Let intelligenceReliefs [24] := kRICIntelligenceFortify25

Let personalityReliefs [0] := kRICPersonalityFortify1
Let personalityReliefs [1] := kRICPersonalityFortify2
Let personalityReliefs [2] := kRICPersonalityFortify3
Let personalityReliefs [3] := kRICPersonalityFortify4
Let personalityReliefs [4] := kRICPersonalityFortify5
Let personalityReliefs [5] := kRICPersonalityFortify6
Let personalityReliefs [6] := kRICPersonalityFortify7
Let personalityReliefs [7] := kRICPersonalityFortify8
Let personalityReliefs [8] := kRICPersonalityFortify9
Let personalityReliefs [9] := kRICPersonalityFortify10
Let personalityReliefs [10] := kRICPersonalityFortify11
Let personalityReliefs [11] := kRICPersonalityFortify12
Let personalityReliefs [12] := kRICPersonalityFortify13
Let personalityReliefs [13] := kRICPersonalityFortify14
Let personalityReliefs [14] := kRICPersonalityFortify15
Let personalityReliefs [15] := kRICPersonalityFortify16
Let personalityReliefs [16] := kRICPersonalityFortify17
Let personalityReliefs [17] := kRICPersonalityFortify18
Let personalityReliefs [18] := kRICPersonalityFortify19
Let personalityReliefs [19] := kRICPersonalityFortify20
Let personalityReliefs [20] := kRICPersonalityFortify21
Let personalityReliefs [21] := kRICPersonalityFortify22
Let personalityReliefs [22] := kRICPersonalityFortify23
Let personalityReliefs [23] := kRICPersonalityFortify24
Let personalityReliefs [24] := kRICPersonalityFortify25

Let speedReliefs [0] := kRICSpeedFortify1
Let speedReliefs [1] := kRICSpeedFortify2
Let speedReliefs [2] := kRICSpeedFortify3
Let speedReliefs [3] := kRICSpeedFortify4
Let speedReliefs [4] := kRICSpeedFortify5
Let speedReliefs [5] := kRICSpeedFortify6
Let speedReliefs [6] := kRICSpeedFortify7
Let speedReliefs [7] := kRICSpeedFortify8
Let speedReliefs [8] := kRICSpeedFortify9
Let speedReliefs [9] := kRICSpeedFortify10
Let speedReliefs [10] := kRICSpeedFortify11
Let speedReliefs [11] := kRICSpeedFortify12
Let speedReliefs [12] := kRICSpeedFortify13
Let speedReliefs [13] := kRICSpeedFortify14
Let speedReliefs [14] := kRICSpeedFortify15
Let speedReliefs [15] := kRICSpeedFortify16
Let speedReliefs [16] := kRICSpeedFortify17
Let speedReliefs [17] := kRICSpeedFortify18
Let speedReliefs [18] := kRICSpeedFortify19
Let speedReliefs [19] := kRICSpeedFortify20
Let speedReliefs [20] := kRICSpeedFortify21
Let speedReliefs [21] := kRICSpeedFortify22
Let speedReliefs [22] := kRICSpeedFortify23
Let speedReliefs [23] := kRICSpeedFortify24
Let speedReliefs [24] := kRICSpeedFortify25

Let strengthReliefs [0] := kRICStrengthFortify1
Let strengthReliefs [1] := kRICStrengthFortify2
Let strengthReliefs [2] := kRICStrengthFortify3
Let strengthReliefs [3] := kRICStrengthFortify4
Let strengthReliefs [4] := kRICStrengthFortify5
Let strengthReliefs [5] := kRICStrengthFortify6
Let strengthReliefs [6] := kRICStrengthFortify7
Let strengthReliefs [7] := kRICStrengthFortify8
Let strengthReliefs [8] := kRICStrengthFortify9
Let strengthReliefs [9] := kRICStrengthFortify10
Let strengthReliefs [10] := kRICStrengthFortify11
Let strengthReliefs [11] := kRICStrengthFortify12
Let strengthReliefs [12] := kRICStrengthFortify13
Let strengthReliefs [13] := kRICStrengthFortify14
Let strengthReliefs [14] := kRICStrengthFortify15
Let strengthReliefs [15] := kRICStrengthFortify16
Let strengthReliefs [16] := kRICStrengthFortify17
Let strengthReliefs [17] := kRICStrengthFortify18
Let strengthReliefs [18] := kRICStrengthFortify19
Let strengthReliefs [19] := kRICStrengthFortify20
Let strengthReliefs [20] := kRICStrengthFortify21
Let strengthReliefs [21] := kRICStrengthFortify22
Let strengthReliefs [22] := kRICStrengthFortify23
Let strengthReliefs [23] := kRICStrengthFortify24
Let strengthReliefs [24] := kRICStrengthFortify25

Let willpowerReliefs [0] := kRICWillpowerFortify1
Let willpowerReliefs [1] := kRICWillpowerFortify2
Let willpowerReliefs [2] := kRICWillpowerFortify3
Let willpowerReliefs [3] := kRICWillpowerFortify4
Let willpowerReliefs [4] := kRICWillpowerFortify5
Let willpowerReliefs [5] := kRICWillpowerFortify6
Let willpowerReliefs [6] := kRICWillpowerFortify7
Let willpowerReliefs [7] := kRICWillpowerFortify8
Let willpowerReliefs [8] := kRICWillpowerFortify9
Let willpowerReliefs [9] := kRICWillpowerFortify10
Let willpowerReliefs [10] := kRICWillpowerFortify11
Let willpowerReliefs [11] := kRICWillpowerFortify12
Let willpowerReliefs [12] := kRICWillpowerFortify13
Let willpowerReliefs [13] := kRICWillpowerFortify14
Let willpowerReliefs [14] := kRICWillpowerFortify15
Let willpowerReliefs [15] := kRICWillpowerFortify16
Let willpowerReliefs [16] := kRICWillpowerFortify17
Let willpowerReliefs [17] := kRICWillpowerFortify18
Let willpowerReliefs [18] := kRICWillpowerFortify19
Let willpowerReliefs [19] := kRICWillpowerFortify20
Let willpowerReliefs [20] := kRICWillpowerFortify21
Let willpowerReliefs [21] := kRICWillpowerFortify22
Let willpowerReliefs [22] := kRICWillpowerFortify23
Let willpowerReliefs [23] := kRICWillpowerFortify24
Let willpowerReliefs [24] := kRICWillpowerFortify25
EndIf

Let ArraySize := ar_Size healthReliefs
If debug
PrintToConsole "kRI: healthReliefs size %0.2f" ArraySize
EndIf

If ArraySize == -1
If debug
PrintToConsole "kRI: initialising health relief array"
EndIf

Let healthReliefs := ar_Construct Array
Let healthReliefs [0] := kRIHealthFortify1
Let healthReliefs [1] := kRIHealthFortify2
Let healthReliefs [2] := kRIHealthFortify3
Let healthReliefs [3] := kRIHealthFortify4
Let healthReliefs [4] := kRIHealthFortify5
Let healthReliefs [5] := kRIHealthFortify6
Let healthReliefs [6] := kRIHealthFortify7
Let healthReliefs [7] := kRIHealthFortify8
Let healthReliefs [8] := kRIHealthFortify9
Let healthReliefs [9] := kRIHealthFortify10
Let healthReliefs [10] := kRIHealthFortify11
Let healthReliefs [11] := kRIHealthFortify12
Let healthReliefs [12] := kRIHealthFortify13
Let healthReliefs [13] := kRIHealthFortify14
Let healthReliefs [14] := kRIHealthFortify15
Let healthReliefs [15] := kRIHealthFortify16
Let healthReliefs [16] := kRIHealthFortify17
Let healthReliefs [17] := kRIHealthFortify18
Let healthReliefs [18] := kRIHealthFortify19
Let healthReliefs [19] := kRIHealthFortify20
Let healthReliefs [20] := kRIHealthFortify21
Let healthReliefs [21] := kRIHealthFortify22
Let healthReliefs [22] := kRIHealthFortify23
Let healthReliefs [23] := kRIHealthFortify24
Let healthReliefs [24] := kRIHealthFortify25
EndIf
endif

If Player.GetDead == 0
set getRef to Player
set itemCount to getRef.GetItemCount kRIToken
if itemCount < 1 && Player.GetDead == 0
set itemCount to 1 - itemCount
getRef.AddItemNS kRIToken itemCount
if debug
PrintToConsole "kRI: adding (%0.2f) token to %n %i" itemCount getRef getRef
endif
elseif itemCount > 1
set itemCount to itemCount - 1
getRef.RemoveItemNS kRIToken itemCount
if debug
PrintToConsole "kRI: removing (%0.2f) token from %n %i" itemCount getRef getRef
endif
endif

If applyToNPCs
set getRef to Gold001
set getRef to GetFirstRef 69 1
Label 0
if getRef
Let distance := getRef.GetDistance Player
if applyToNPCs && getRef.IsCreature == 0 && getRef.GetDead == 0 && getRef.GetDisabled == 0 && getRef.GetIsGhost == 0 && distance < 5000
set itemCount to getRef.GetItemCount kRIToken
if itemCount < 1 && getRef.IsInCombat
set tempFloat to 1 - itemCount
getRef.AddItemNS kRIToken tempFloat
if debug
PrintToConsole "kRI: adding %0.0f token (%0.0f) to %n %i" tempFloat itemCount getRef getRef
endif
elseif itemCount > 1
set tempFloat to itemCount - 1
getRef.RemoveItemNS kRIToken tempFloat
if debug
PrintToConsole "kRI: removing %0.0f tokens (%0.0f) from %n %i" tempFloat itemCount getRef getRef
endif
endif
endif
set getRef to Gold001
set getRef to GetNextRef
GoTo 0
endif
EndIf
EndIf

If functionMode == 254
set functionMode to 0
ElseIf functionMode == 255
set functionMode to 0
EndIf
end

Short quitToMainMenu

Begin MenuMode
;If Player.GetDead && quitToMainMenu == 0
; Let quitToMainMenu := 1
; Let fQuestDelayTime := 0.001
; Return
;ElseIf quitToMainMenu == 2
; Let quitToMainMenu := 3
; MessageBox "With Battle Fatigue and Injuries, you need to quit to the Main Menu to load a game."
;EndIf
;If quitToMainMenu
; If MenuMode 1038
; ;load menu
; Let quitToMainMenu := 2
; ClickMenuButton "load_background\load_return_button" 1038
; Return
; EndIf
; if MenuMode 1013
; ;escape menu
; Let quitToMainMenu := 0
; ClickMenuButton "pause_background\pause_quit_button" 1013
; Return
; endif
; ;if MenuMode 1001
; ; Let quitToMainMenu := 0
; ; ClickMenuButton "background\button_2" 1001
; ; Return
; ;endif
;EndIf
If quitToMainMenu
Let quitToMainMenu := 0
MessageBox "With Battle Fatigue and Injuries, you need to quit to the Main Menu to load a game."
EndIf
If MenuMode 1038
;load menu
If Player.GetDead
Let quitToMainMenu := 1
ClickMenuButton "load_background\load_return_button" 1038
Return
EndIf
EndIf
End


KRIToken Object Script attached to KRIToken

ScriptName kRITokenScript

short functionMode
;0 = idle, detect injuries, heal and relief
;1,4 = apply injuries and relief, add apparel
;2 = equip apparel
;3 = reset injuries and relief
;5 = remove token

float thisSecondsPassed

float battleFatigue
float lastBattleFatigue
float armInjuries
float lastArmInjuries
float bodyInjuries
float lastBodyInjuries
float legInjuries
float lastLegInjuries
float headInjuries
float lastHeadInjuries

float armInjuriesRelief
float lastArmInjuriesRelief
float bodyInjuriesRelief
float lastBodyInjuriesRelief
float legInjuriesRelief
float lastLegInjuriesRelief
float headInjuriesRelief
float lastHeadInjuriesRelief

ref thisRef

float maxHealth
float health
float lastHealth
float healthChange
float healthLoss
float healthMark
float healthPercentage

float random

float timeNow
float timeLastHealedHealth
float healRate
float healAmountNow
float timeElapsed

float timeLastHealedBattleFatigue
float timeLastHealedInjury

short justSlept

short inCombat
short lastInCombat
float timeLastInCombat
short battleFatigueAppliedThisCombat

;injuries
short str
short lastStr
short end
short lastEnd
short agi
short lastAgi
short spd
short lastSpd
short int
short lastInt
short wil
short lastWil
short per
short lastPer

;reliefs
short strR
short lastStrR
short endR
short lastEndR
short agiR
short lastAgiR
short spdR
short lastSpdR
short intR
short lastIntR
short wilR
short lastWilR
short perR
short lastPerR

float toApply

short reset
float combatTime

ref apparelRef

ref apparelHealthRef
ref apparelAgiRef
ref apparelEndRef
ref apparelIntRef
ref apparelPerRef
ref apparelSpdRef
ref apparelStrRef
ref apparelWilRef

ref apparelAgiRRef
ref apparelEndRRef
ref apparelIntRRef
ref apparelPerRRef
ref apparelSpdRRef
ref apparelStrRRef
ref apparelWilRRef

short itemCount
short index

short healthDrain
short lastHealthDrain

float tempFloat

float restoreHealthMag

float adjustedHoursToFullHealth

float captureDamageTime
short checkForInjury
float bankedDamages

short formValid

float value
float lastValue
array_var apparelArray

float startReliefTime

short initDone

float lastRestoreHealthMag

short ok

short debug255
float version

float endReliefTime

float lastTimeNow
float elapsedTimeNow

begin GameMode
If kRIQuest.movingIntoNewSpace
Return
EndIf

If OnKeyDown 54;right-shift
Let kRIQuest.debugRef := GetCrosshairRef
EndIf

set thisSecondsPassed to thisSecondsPassed + GetSecondsPassed
if thisSecondsPassed > 1
If thisRef != Player
Let formValid := IsFormValid thisRef
If kRIQuest.debug
PrintC "kRI: %n %i formValid %0.0f initDone %0.0f" thisRef thisRef formValid initDone
EndIf
Let tempFloat := 0
If formValid
;GetDistance fails on invalid forms
Let tempFloat := thisRef.GetDistance Player
EndIf
If formValid == 0 || tempFloat > 5000 || (kRIQuest.applyToNPCs == 0 && thisRef != Player)
If initDone == 0
Let initDone := 1
Let thisRef := GetContainer
Return
Else
If functionMode < 3
Let functionMode := 3
EndIf
EndIf
EndIf
EndIf

;If thisRef.IsActor == 0
; Return
;EndIf

if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i functionMode %0.2f" thisRef thisRef functionMode
endif

if reset == 1
set reset to 0
endif

if functionMode < 3 && (thisRef.GetDead || thisRef.GetDisabled)
set functionMode to 3
endif

Let checkForInjury := 0
Let captureDamageTime := captureDamageTime + thisSecondsPassed
If functionMode == 0 && captureDamageTime > kRIQuest.secondsToCaptureDamageForInjury
Let checkForInjury := captureDamageTime
Let captureDamageTime := 0
EndIf
set thisSecondsPassed to 0

if functionMode == 3
set functionMode to 4

Let battleFatigue := 0
set armInjuries to 0
set bodyInjuries to 0
set headInjuries to 0
set legInjuries to 0

set armInjuriesRelief to 0
set bodyInjuriesRelief to 0
set headInjuriesRelief to 0
set legInjuriesRelief to 0
EndIf

;detect changes to injuries
if functionMode == 0
if kRIQuest.updateHUD || lastBattleFatigue != battleFatigue || lastArmInjuries != armInjuries || lastBodyInjuries != bodyInjuries || lastLegInjuries != legInjuries || lastHeadInjuries != headInjuries || lastArmInjuriesRelief != armInjuriesRelief || lastBodyInjuriesRelief != bodyInjuriesRelief || lastLegInjuriesRelief != legInjuriesRelief || lastHeadInjuriesRelief != headInjuriesRelief
Let functionMode := 1
Return
endif

;fix for stuck battle fatigue
;If battleFatigue == 0 && lastBattleFatigue == 0 && healthDrain > 0 && lastHealthDrain > 0
; Let functionMode := 1
;EndIf
If version != kRIQuest.version
Let version := kRIQuest.version
Let functionMode := 1
If kRIQuest.debug
PrintC "kRI: %n %i fixing" thisRef thisRef
EndIf
EndIf
;end fix

set timeNow to GameDaysPassed * 24 + GameHour
Let elapsedTimeNow := timeNow - lastTimeNow
Let lastTimeNow := timeNow
;if kRIQuest.debug == 1 && thisRef == Player
; PrintC "kRI: %n %i elapsedTimeNow %0.2f" thisRef thisRef elapsedTimeNow
;EndIf

Let health := thisRef.GetActorValue Health
If health < 1
Return
EndIf
Let maxHealth := thisRef.GetBaseActorValue Health
Let tempFloat := thisRef.GetAVMod Health Max
Let maxHealth := maxHealth + tempFloat
If lastHealth == 0
Let lastHealth := maxHealth
EndIf
set healthChange to health - lastHealth
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i health %0.2f maxHealth %0.2f lastHealth %0.2f healthChange %0.2f" thisRef thisRef health maxHealth lastHealth healthChange
EndIf

Let inCombat := thisRef.IsInCombat
if inCombat != lastInCombat
set lastInCombat to inCombat
if inCombat == 0
set battleFatigueAppliedThisCombat to 0
Else
Let timeLastInCombat := timeNow
endif
endif

if timeLastHealedHealth == 0
set timeLastHealedHealth to timeNow
endif

if inCombat
set combatTime to combatTime + GetSecondsPassed
elseIf inCombat == 0 && combatTime
set combatTime to 0
Let bankedDamages := 0
endif

;relief====================================
If kRIQuest.applyMagicalReliefToRef == thisRef
Let kRIQuest.applyMagicalReliefToRef := 0
Let restoreHealthMag := kRIQuest.applyMagicalReliefFromMagnitude
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i restoreHealthMag %0.2f lastRestoreHealthMag %0.2f" thisRef thisRef restoreHealthMag lastRestoreHealthMag
endif
If restoreHealthMag > lastRestoreHealthMag
Let lastRestoreHealthMag := kRIQuest.applyMagicalReliefFromMagnitude
If kRIQuest.healingMagicReliefFactor && kRIQuest.healingMagicReliefDuration
If armInjuries
Let armInjuriesRelief := armInjuries * restoreHealthMag / 100 * kRIQuest.healingMagicReliefFactor
If armInjuriesRelief > armInjuries
Let armInjuriesRelief := armInjuries
EndIf
Let armInjuriesRelief := Ceil armInjuriesRelief
Else
Let armInjuriesRelief := 0
EndIf
If bodyInjuries
Let bodyInjuriesRelief := bodyInjuries * restoreHealthMag / 100 * kRIQuest.healingMagicReliefFactor
If bodyInjuriesRelief > bodyInjuries
Let bodyInjuriesRelief := bodyInjuries
EndIf
Let bodyInjuriesRelief := Ceil bodyInjuriesRelief
Else
Let bodyInjuriesRelief := 0
EndIf
If legInjuries
Let legInjuriesRelief := legInjuries * restoreHealthMag / 100 * kRIQuest.healingMagicReliefFactor
If legInjuriesRelief > legInjuries
Let legInjuriesRelief := legInjuries
EndIf
Let legInjuriesRelief := Ceil legInjuriesRelief
Else
Let legInjuriesRelief := 0
EndIf
If headInjuries
Let headInjuriesRelief := headInjuries * restoreHealthMag / 100 * kRIQuest.healingMagicReliefFactor
If headInjuriesRelief > headInjuries
Let headInjuriesRelief := headInjuries
EndIf
Let headInjuriesRelief := Ceil headInjuriesRelief
Else
Let headInjuriesRelief := 0
EndIf
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i bodyR %0.2f armR %0.2f headR %0.2f legR %0.2f" thisRef thisRef bodyInjuriesRelief armInjuriesRelief headInjuriesRelief legInjuriesRelief
endif

If armInjuriesRelief || bodyInjuriesRelief || legInjuriesRelief || headInjuriesRelief
Let startReliefTime := timeNow
Let tempFloat := thisRef.GetActorValue Willpower
Let tempFloat := tempFloat / 100 * kRIQuest.healingMagicReliefDuration
Let endReliefTime := timeNow + tempFloat
EndIf
EndIf
EndIf
EndIf

If armInjuriesRelief || bodyInjuriesRelief || legInjuriesRelief || headInjuriesRelief
If startReliefTime && endReliefTime
If timeNow > endReliefTime
Let startReliefTime := 0
Let lastRestoreHealthMag := 0
Let armInjuriesRelief := 0
Let bodyInjuriesRelief := 0
Let legInjuriesRelief := 0
Let headInjuriesRelief := 0
EndIf
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
Let value := timeNow - startReliefTime
PrintC "kRI: %n %i timeNow %0.2f elapsed %0.2f endTime %0.2f" thisRef thisRef timeNow value endReliefTime
PrintC "kRI: %n %i armRelief %0.2f bodyRelief %0.2f legRelief %0.2f headRelief %0.2f" thisRef thisRef armInjuriesRelief bodyInjuriesRelief legInjuriesRelief headInjuriesRelief
EndIf
ElseIf startReliefTime == 0 || endReliefTime == 0
Let startReliefTime := 0
Let lastRestoreHealthMag := 0
EndIf
Else
Let startReliefTime := 0
Let lastRestoreHealthMag := 0
EndIf

;battle fatigue and injury==================
if lastHealth != health
if healthChange < 0 && inCombat
set healthLoss to Abs healthChange
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i health %0.2f max %0.2f" thisRef thisRef health maxHealth
EndIf

;battle fatigue
if battleFatigueAppliedThisCombat == 0 && thisRef == Player
set healthMark to kRIQuest.healthLeftToAcquireBattleFatigue
set healthPercentage to health / maxHealth * 100
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i healthPercentage left %0.2f < battleFatigueHealth %0.2f" thisRef thisRef healthPercentage kRIQuest.healthLeftToAcquireBattleFatigue
endif
if healthPercentage < healthMark
if battleFatigue == 0 || timeLastHealedBattleFatigue == 0 || kRIQuest.combatRestartsBattleFatigueHealTimer
set timeLastHealedBattleFatigue to timeNow
endif
Let battleFatigue := battleFatigue + kRIQuest.battleFatigueDamage
set battleFatigueAppliedThisCombat to 1
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i battleFatigue %0.2f" thisRef thisRef battleFatigue
endif
endif
endif

;injury
If checkForInjury == 0
;bank damages until checkForInjury
Let bankedDamages := bankedDamages + healthLoss
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i bankedDamages %0.2f" thisRef thisRef bankedDamages
EndIf

ElseIf checkForInjury
set healthMark to kRIQuest.healthLossToAcquireInjury
Let healthLoss := healthLoss + bankedDamages
set healthPercentage to healthLoss / maxHealth * 100
Let bankedDamages := 0
set random to GetRandomPercent
set tempFloat to kRIQuest.chanceOfInjury + kRIQuest.chanceOfInjuryIncrease * combatTime
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i healthPercentage loss %0.2f > healthLossToAcquireInjury %0.2f" thisRef thisRef healthPercentage kRIQuest.healthLossToAcquireInjury
PrintC "kRI: %n %i random %0.2f < chanceOfInjury %0.2f + chanceOfInjuryIncrease %0.2f * combatTime %0.2f = (%0.2f)" thisRef thisRef random kRIQuest.chanceOfInjury kRIQuest.chanceOfInjuryIncrease combatTime tempFloat
endif
if healthPercentage > healthMark || random < tempFloat
if (armInjuries == 0 && bodyInjuries == 0 && headInjuries == 0 && legInjuries == 0) || timeLastHealedInjury == 0 || kRIQuest.combatRestartsInjuryHealTimer
set timeLastHealedInjury to timeNow
endif
set random to GetRandomPercent
if random < kRIQuest.randomBodyInjuryRange
set bodyInjuries to bodyInjuries + kRIQuest.injuryDamage
elseif random < kRIQuest.randomArmInjuryRange
set armInjuries to armInjuries + kRIQuest.injuryDamage
elseif random < kRIQuest.randomLegInjuryRange
set legInjuries to legInjuries + kRIQuest.injuryDamage
elseif random < kRIQuest.randomHeadInjuryRange
set headInjuries to headInjuries + kRIQuest.injuryDamage
endif
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i body %0.2f arm %0.2f head %0.2f leg %0.2f" thisRef thisRef bodyInjuries armInjuries headInjuries legInjuries
endif
endif

set timeLastHealedHealth to timeNow;reset health healing time
EndIf
endif
endif

;heal health====================================================================
Let adjustedHoursToFullHealth := kRIQuest.hoursToFullHealth
Let ok := 0
If adjustedHoursToFullHealth
Let ok := 1
If kRIQuest.healthAffectsHoursToFullHealth
Let tempFloat := maxHealth / health
Let adjustedHoursToFullHealth := adjustedHoursToFullHealth * tempFloat
EndIf
If adjustedHoursToFullHealth == 0
Let ok := 0
EndIf
If ok && health >= maxHealth
Let ok := 0
EndIf
If ok && kRIQuest.healInCombat == 0
If thisRef == Player && inCombat
Let ok := 0
ElseIf thisRef != Player && (inCombat || timeNow - timeLastInCombat < 0.5)
Let ok := 0
EndIf
EndIf
EndIf
if ok
set timeElapsed to timeNow - timeLastHealedHealth
set healRate to maxHealth / adjustedHoursToFullHealth
set healAmountNow to healRate * timeElapsed
If thisRef.GetSitting == 3
Let healAmountNow := healAmountNow * 2
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i healAmountNow * 2 = %0.2f" thisRef thisRef healAmountNow
EndIf
ElseIf thisRef.GetSitting == 13
Let healAmountNow := healAmountNow * 1.5
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i healAmountNow * 1.5 = %0.2f" thisRef thisRef healAmountNow
EndIf
EndIf
If health + healAmountNow > maxHealth
Let healAmountNow := maxHealth - health
If healAmountNow < 1
Let healAmountNow := 1
EndIf
EndIf
if healAmountNow >= 1
set timeLastHealedHealth to timeNow
thisRef.ModActorValue2 Health healAmountNow
Let health := health + healAmountNow
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i health %0.2f == maxHealth %0.2f?" thisRef thisRef health maxHealth
PrintC "kRI: %n %i mod healing %0.2f" thisRef thisRef healAmountNow
endif
endif

;remove extra health
elseif health > maxHealth
Let tempFloat := health - maxHealth
thisRef.ModActorValue2 Health tempFloat
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i health %0.2f == maxHealth %0.2f?" thisRef thisRef health maxHealth
PrintC "kRI: %n %i remove extra Health %0.2f" thisRef thisRef healAmountNow
endif
Let health := maxHealth
set timeLastHealedHealth to 0

;no health heal or removal of extra health
Else
set timeLastHealedHealth to 0
endif

If health != lastHealth
Let lastHealth := health
EndIf

if (kRIQuest.healInCombat == 0 && inCombat) || functionMode == 1
Return
endif

;heal battle fatigue======================================
If thisRef != Player && battleFatigue
Let battleFatigue := 0
if (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i removing battle fatigue" thisRef thisRef
endif
Elseif battleFatigue
set timeElapsed to timeNow - timeLastHealedBattleFatigue
if justSlept
set healRate to kRIQuest.battleFatigueHealAsleep
else
set healRate to kRIQuest.battleFatigueHealAwake
endif
set healAmountNow to healRate * timeElapsed
if healAmountNow >= 1
Let healAmountNow := Ceil healAmountNow
set timeLastHealedBattleFatigue to timeNow
Let battleFatigue := battleFatigue - healAmountNow
if battleFatigue < 0
Let battleFatigue := 0
endif
if (kRIQuest.debug == 1 && thisRef == Player)
PrintC "kRI: %n %i battleFatigue healed by %0.2f" thisRef thisRef healAmountNow
endif
endif
endif

;heal injury======================================================================
if armInjuries || bodyInjuries || headInjuries || legInjuries
set timeElapsed to timeNow - timeLastHealedInjury
if justSlept
set healRate to kRIQuest.injuryHealAsleep
else
set healRate to kRIQuest.injuryHealAwake
endif
set healAmountNow to healRate * timeElapsed
if healAmountNow >= 1
Let healAmountNow := Ceil healAmountNow
set timeLastHealedInjury to timeNow
if armInjuries > 0
set armInjuries to armInjuries - healAmountNow
if armInjuries < 0
set armInjuries to 0
Let armInjuriesRelief := 0
endif
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i arm healed by %0.2f" thisRef thisRef healAmountNow
endif
endif
if bodyInjuries > 0
set bodyInjuries to bodyInjuries - healAmountNow
if bodyInjuries < 0
set bodyInjuries to 0
Let bodyInjuriesRelief := 0
endif
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i body healed by %0.2f" thisRef thisRef healAmountNow
endif
endif
if headInjuries > 0
set headInjuries to headInjuries - healAmountNow
if headInjuries < 0
set headInjuries to 0
Let headInjuriesRelief := 0
endif
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i head healed by %0.2f" thisRef thisRef healAmountNow
endif
endif
if legInjuries > 0
set legInjuries to legInjuries - healAmountNow
if legInjuries < 0
set legInjuries to 0
Let legInjuriesRelief := 0
endif
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i leg healed by %0.2f" thisRef thisRef healAmountNow
endif
endif
endif
endif

if justSlept
set justSlept to 0
endif

elseif functionMode == 1 || functionMode == 4
if functionMode == 1
set functionMode to 0
elseif functionMode == 4
set functionMode to 5
endif

set str to 0
set agi to 0
set end to 0
set int to 0
set wil to 0
set per to 0
set spd to 0
Let healthDrain := 0

Let strR := 0
Let agiR := 0
Let endR := 0
Let intR := 0
Let wilR := 0
Let perR := 0
Let spdR := 0

set lastBattleFatigue to battleFatigue
If battleFatigue
set toApply to battleFatigue * kRIQuest.battleFatigueDamageMultiplier
Let healthDrain := Ceil toApply
EndIf

set lastArmInjuries to armInjuries
if armInjuries
set toApply to armInjuries * kRIQuest.injuryDamageMultiplier
if kRIQuest.bodyInjuriesAffectStrength == 0
set agi to Ceil toApply
else
set tempFloat to toApply / 2
set agi to Ceil tempFloat
set str to str + toApply - agi
endif
Else
Let armInjuriesRelief := 0
endif

Let lastArmInjuriesRelief := armInjuriesRelief
If armInjuriesRelief
Let toApply := armInjuriesRelief * kRIQuest.injuryDamageMultiplier
If kRIQuest.bodyInjuriesAffectStrength == 0
Let agiR := Ceil toApply
Else
Let tempFloat := toApply / 2
Let agiR := Ceil tempFloat
Let strR := strR + toApply - agiR
EndIf
EndIf

set lastBodyInjuries to bodyInjuries
if bodyInjuries
set toApply to bodyInjuries * kRIQuest.injuryDamageMultiplier
if kRIQuest.bodyInjuriesAffectStrength == 0
set end to Ceil toApply
else
set tempFloat to toApply / 2
set end to Ceil tempFloat
set str to str + toApply - end
endif
Else
Let bodyInjuriesRelief := 0
endif

Let lastBodyInjuriesRelief := bodyInjuriesRelief
If bodyInjuriesRelief
Let toApply := bodyInjuriesRelief * kRIQuest.injuryDamageMultiplier
If kRIQuest.bodyInjuriesAffectStrength == 0
Let endR := Ceil toApply
Else
Let tempFloat := toApply / 2
Let endR := Ceil tempFloat
Let strR := strR + toApply - endR
EndIf
EndIf

set lastLegInjuries to legInjuries
if legInjuries
set toApply to legInjuries * kRIQuest.injuryDamageMultiplier
if kRIQuest.bodyInjuriesAffectStrength == 0
set spd to toApply
else
set tempFloat to Ceil toApply / 2
set spd to Ceil tempFloat
set str to str + toApply - spd
endif
Else
Let legInjuriesRelief := 0
endif

Let lastLegInjuriesRelief := legInjuriesRelief
If legInjuriesRelief
Let toApply := legInjuriesRelief * kRIQuest.injuryDamageMultiplier
If kRIQuest.bodyInjuriesAffectStrength == 0
Let spdR := Ceil toApply
Else
Let tempFloat := toApply / 2
Let spdR := Ceil tempFloat
Let strR := strR + toApply - spdR
EndIf
EndIf

set lastHeadInjuries to headInjuries
if headInjuries
set toApply to headInjuries * kRIQuest.injuryDamageMultiplier
set tempFloat to toApply / 3
set per to Ceil tempFloat
set wil to Ceil tempFloat
set int to toApply - per - wil
Else
Let headInjuriesRelief := 0
endif

Let lastHeadInjuriesRelief := headInjuriesRelief
If headInjuriesRelief
Let toApply := headInjuriesRelief * kRIQuest.injuryDamageMultiplier
Let tempFloat := toApply / 3
Let perR := Ceil TempFloat
Let wilR := Ceil TempFloat
Let intR := toApply - perR - wilR
EndIf

;update the HUD
If (kRIHUDQuest.showMode == 0 && thisRef == Player) || (kRIHUDQuest.showMode == 1 && thisRef == kRIQuest.debugRef)
;Let kRIQuest.updateHUD := 1
Let kRIHUDQuest.arm := armInjuries
Let kRIHUDQuest.body := bodyInjuries
Let kRIHUDQuest.leg := legInjuries
Let kRIHUDQuest.head := headInjuries
EndIf
Let kRIQuest.updateHUD := 0

;update injuries: add correct apparel to add injuries and reliefs
;agi, end, int, per, spd, str, wil, agiR, endR, intR, perR, spdR, strR, wilR, health
Let index := 0
while index < 15
If index == 0
Let lastValue := lastAgi
Let value := agi
Let apparelArray := kRIQuest.agilityInjuries
ElseIf index == 1
Let lastValue := lastEnd
Let value := end
Let apparelArray := kRIQuest.enduranceInjuries
ElseIf index == 2
Let lastValue := lastInt
Let value := int
Let apparelArray := kRIQuest.intelligenceInjuries
ElseIf index == 3
Let lastValue := lastPer
Let value := per
Let apparelArray := kRIQuest.personalityInjuries
ElseIf index == 4
Let lastValue := lastSpd
Let value := spd
Let apparelArray := kRIQuest.speedInjuries
ElseIf index == 5
Let lastValue := lastStr
Let value := str
Let apparelArray := kRIQuest.strengthInjuries
ElseIf index == 6
Let lastValue := lastWil
Let value := wil
Let apparelArray := kRIQuest.willpowerInjuries
ElseIf index == 7
Let lastValue := lastAgiR
Let value := agiR
Let apparelArray := kRIQuest.agilityReliefs
ElseIf index == 8
Let lastValue := lastEndR
Let value := endR
Let apparelArray := kRIQuest.enduranceReliefs
ElseIf index == 9
Let lastValue := lastIntR
Let value := intR
Let apparelArray := kRIQuest.intelligenceReliefs
ElseIf index == 10
Let lastValue := lastPerR
Let value := perR
Let apparelArray := kRIQuest.personalityReliefs
ElseIf index == 11
Let lastValue := lastSpdR
Let value := spdR
Let apparelArray := kRIQuest.speedReliefs
ElseIf index == 12
Let lastValue := lastStrR
Let value := strR
Let apparelArray := kRIQuest.strengthReliefs
ElseIf index == 13
Let lastValue := lastWilR
Let value := wilR
Let apparelArray := kRIQuest.willpowerReliefs
ElseIf index == 14
Let lastValue := lastHealthDrain
Let value := healthDrain
Let apparelArray := kRIQuest.healthInjuries
EndIf

If lastValue < 0
Let lastValue := 0
ElseIf lastValue > 25
Let lastValue := 25
EndIf
If value < 0
Let value := 0
ElseIf value > 25
Let value := 25
EndIf

;If value != lastValue
If value != lastValue && lastValue > 0
Let apparelRef := apparelArray [lastvalue - 1]
Let itemCount := thisRef.GetItemCount apparelRef
If itemCount
thisRef.UnequipItemSilent apparelRef
thisRef.RemoveItemNS apparelRef itemCount
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i removing %n %i" thisRef thisRef apparelRef apparelRef
EndIf
EndIf
EndIf

Let apparelRef := 0
If value != lastValue && value > 0
Let functionMode := 2
Let apparelRef := apparelArray [value - 1]
Let itemCount := thisRef.GetItemCount apparelRef
If itemCount == 0
thisRef.AddItemNS apparelRef 1
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef)
PrintC "kRI: %n %i adding %n %i at value %0.2f of index %0.0f" thisRef thisRef apparelRef apparelRef value index
EndIf
EndIf
EndIf

If index == 0
Let lastAgi := agi
Let apparelAgiRef := apparelRef
ElseIf index == 1
Let lastEnd := end
Let apparelEndRef := apparelRef
ElseIf index == 2
Let lastInt := int
Let apparelIntRef := apparelRef
ElseIf index == 3
Let lastPer := per
Let apparelPerRef := apparelRef
ElseIf index == 4
Let lastSpd := spd
Let apparelSpdRef := apparelRef
ElseIf index == 5
Let lastStr := str
Let apparelStrRef := apparelRef
ElseIf index == 6
Let lastWil := wil
Let apparelWilRef := apparelRef
ElseIf index == 7
Let lastAgiR := agiR
Let apparelAgiRRef := apparelRef
ElseIf index == 8
Let lastEndR := endR
Let apparelEndRRef := apparelRef
ElseIf index == 9
Let lastIntR := intR
Let apparelIntRRef := apparelRef
ElseIf index == 10
Let lastPerR := perR
Let apparelPerRRef := apparelRef
ElseIf index == 11
Let lastSpdR := spdR
Let apparelSpdRRef := apparelRef
ElseIf index == 12
Let lastStrR := strR
Let apparelStrRRef := apparelRef
ElseIf index == 13
Let lastWilR := wilR
Let apparelWilRRef := apparelRef
ElseIf index == 14
Let lastHealthDrain := healthDrain
Let apparelHealthRef := apparelRef
EndIf
;EndIf

Let index := index + 1
loop

elseif functionMode == 2
set functionMode to 0

;short itemCount
if apparelHealthRef
thisRef.EquipItemSilent apparelHealthRef
endif
if apparelStrRef
thisRef.EquipItemSilent apparelStrRef
endif
if apparelEndRef
thisRef.EquipItemSilent apparelEndRef
endif
if apparelAgiRef
thisRef.EquipItemSilent apparelAgiRef
endif
if apparelSpdRef
thisRef.EquipItemSilent apparelSpdRef
endif
if apparelIntRef
thisRef.EquipItemSilent apparelIntRef
endif
if apparelWilRef
thisRef.EquipItemSilent apparelWilRef
endif
if apparelPerRef
thisRef.EquipItemSilent apparelPerRef
endif
if apparelStrRRef
thisRef.EquipItemSilent apparelStrRRef
endif
if apparelEndRRef
thisRef.EquipItemSilent apparelEndRRef
endif
if apparelAgiRRef
thisRef.EquipItemSilent apparelAgiRRef
endif
if apparelSpdRRef
thisRef.EquipItemSilent apparelSpdRRef
endif
if apparelIntRRef
thisRef.EquipItemSilent apparelIntRRef
endif
if apparelWilRRef
thisRef.EquipItemSilent apparelWilRRef
endif
if apparelPerRRef
thisRef.EquipItemSilent apparelPerRRef
endif
EndIf

if functionMode == 5
set functionMode to 0
If kRIQuest.debug
PrintC "kRI: %n %i removing token" thisRef thisRef
EndIf
set random to thisRef.GetItemCount kRIToken
If random > 0
thisRef.RemoveItemNS kRIToken random
ElseIf random < 0
Let random := -1 * random
thisRef.AddItemNS kRIToken random
EndIf
If kRIQuest.debug
PrintC "kRI: %n %i removal successful" thisRef thisRef
EndIf
Return
endif
endif
If kRIQuest.functionMode == 254 && debug255 == 0
;add random injuries
Let debug255 := 0
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef) || kRIQuest.debug == 4
Let armInjuries := Rand 0 4
Let bodyInjuries := Rand 0 4
Let legInjuries := Rand 0 4
Let headInjuries := Rand 0 4
Let battleFatigue := Rand 0 4
Let armInjuries := Floor armInjuries
Let bodyInjuries := Floor bodyInjuries
Let legInjuries := Floor legInjuries
Let headInjuries := Floor headInjuries
Let battleFatigue := Floor battleFatigue
Let timeLastHealedInjury := timeNow
Let timeLastHealedBattleFatigue := timeNow
EndIf
ElseIf kRIQuest.functionMode == 255 && debug255 == 0
Let debug255 := 1
if (kRIQuest.debug == 1 && thisRef == Player) || (kRIQuest.debug == 2 && thisRef != Player) || (kRIQuest.debug == 3 && thisRef == kRIQuest.debugRef) || kRIQuest.debug == 4
PrintC "kRI: %n %i ------------------------------" thisRef thisRef
PrintC "bf %0.2f lastBF %0.2f healthDrain %0.2f lastHealthDrain %0.2f" battleFatigue lastBattleFatigue healthDrain lastHealthDrain
PrintC "arm %0.2f agi %0.2f lastAgi %0.2f" armInjuries agi lastAgi
PrintC "body %0.2f end %0.2f lastEnd %0.2f" bodyInjuries end lastEnd
PrintC "leg %0.2f spd %0.2f lastSpd %0.2f" legInjuries spd lastSpd
PrintC "head %0.2f int %0.2f per %0.2f wil %0.2f lastInt %0.2f lastPer %0.2f lastWil %0.2f" headInjuries int per wil lastInt lastPer lastWil
PrintC "str %0.2f lastStr %0.2f" str lastStr
PrintC "relief: arm %0.2f agi %0.2f lastAgi %0.2f" armInjuriesRelief agiR lastAgiR
PrintC "relief: body %0.2f end %0.2f lastEnd %0.2f" bodyInjuriesRelief endR lastEndR
PrintC "relief: leg %0.2f spd %0.2f lastSpd %0.2f" legInjuriesRelief spdR lastSpdR
PrintC "relief: head %0.2f int %0.2f per %0.2f wil %0.2f lastInt %0.2f lastPer %0.2f lastWil %0.2f" headInjuriesRelief intR perR wilR lastIntR lastPerR lastWilR
PrintC "relief: str %0.2f lastStr %0.2f" strR lastStrR
PrintC "------------------------------"
EndIf
ElseIf kRIQuest.functionMode == 0
Let debug255 := 0
EndIf
end

begin MenuMode
If MenuMode 1012
;if thisRef == Player && IsPCSleeping && justSlept == 0
If IsPCSleeping && justSlept == 0
set justSlept to 1
endif
endif
end


An Object Script called FunctionCheckForMagicOnHealth
that doesn't seem to be attached to any object, none of the edited(green highlight in CSE) NPCs or items have it.

ScriptName FunctionCheckForMagicOnHealth

Ref actorRef
Ref itemRef
Short magicOnHealth
Short magicItemIndex
Short magicItemCount
Short magicItemNthMag
Long magicItemNthCode

Begin Function {actorRef itemRef}
If kRIQuest.debug
PrintC "kRI FunctionCheckForMagicOnHealth: %n %i %n %i" actorRef actorRef itemRef itemRef
EndIf
Let magicOnHealth := 0
Let magicItemCount := GetMagicItemEffectCount itemRef
Let magicItemIndex := 0
while magicItemIndex < magicItemCount
Let magicItemNthCode := GetNthEffectItemCode itemRef magicItemIndex
If kRIQuest.debug
PrintC "kRI FunctionCheckForMagicOnHealth: %n %i index %0.0f code %0.2f" itemRef itemRef magicItemIndex magicItemNthCode
EndIf
If magicItemNthCode == (GetMagicEffectCode REHE) || magicItemNthCode == (GetMagicEffectCode FOHE)
;magic item has health effects
Let magicItemNthMag := GetNthEffectItemMagnitude itemRef magicItemIndex
If kRIQuest.debug
PrintC "kRI FunctionCheckForMagicOnHealth: %n %i index %0.0f Mag %0.0f" itemRef itemRef magicItemIndex magicItemNthMag
EndIf
If magicItemNthMag > 0
Let magicOnHealth := 1
break
EndIf
EndIf
Let magicItemIndex := magicItemIndex + 1
loop
If magicOnHealth
Let itemRef := kRIQuest.applyMagicalReliefToRef
If IsFormValid itemRef || IsReference itemRef == 0 || itemRef.GetDead || itemRef.GetDisabled
Let kRIQuest.applyMagicalReliefToRef := actorRef
Let kRIQuest.applyMagicalReliefFromMagnitude := magicItemNthMag
EndIf
EndIf
;EndIf
End


A blank? object script named kRIFixHealthScript attached to KRIFixHealth(clothing item)
All it has is 1 line saying: ScriptName kRIFixHealthScript

His .ini file here:


;npcs can receive battle fatigue and injuries.
;default = 1.
set kRIQuest.applyToNPCs to 1
 
;=================
;health generation
;=================
;this is the number of in-game hours health will be restored to max.
;default = 1.
set kRIQuest.hoursToFullHealth to 1
;healing can occur in combat.
;default = 0. 1 is not recommended.
set kRIQuest.healInCombat to 0
 
;health affects heal-rate.
;the percentage of health left is a factor to the number of in-game hours required for health to be restored fully.
;the forumla used to adjust hoursToFullHealth is:
;hoursToFullhealth / (health / max health) * healthAffectsHoursToFullHealth.
;set this to 0 so that health is always restored after hoursToFullHealth.
;default = 1.
set kRIQuest.healthAffectsHoursToFullHealth to 1
 
;==================
;damage multipliers
;==================
;these are the number of attribute penalties applied for 1 point of battle fatigue or injury.
;default = 5.
set kRIQuest.battleFatigueDamageMultiplier to 5
set kRIQuest.injuryDamageMultiplier to 5
 
;==============
;battle fatigue
;==============
;battle fatigue will be applied when health dips below this percentage.
;default = 25.
set kRIQuest.healthLeftToAcquireBattleFatigue to 0
 
;how much battle fatigue is applied for each application of battle fatigue.
;default = 1.
set kRIQuest.battleFatigueDamage to 1
 
;how much battle fatigue is healed per hour awake.
;default = 0.042. this translates to 1 battle fatigue damage per day. i.e. 1/24.
set kRIQuest.battleFatigueHealAwake to 0.042
 
;how much battle fatigue is healed per hour asleep.
;default = 0.125. this translates to 1 battle fatigue damage per 8 hours. i.e. 1/8.
set kRIQuest.battleFatigueHealAsleep to 0.125
 
;healing can be interrupted by combat.
;set this to 1 to restart the healing timer for battle fatigue when combat starts.
;default = 0.
set kRIQuest.combatRestartsBattleFatigueHealTimer to 0
 
;========
;injuries
;========
;the length of time the mod will capture damage to convert to injuries.
;a longer amount will effectively increase the number of injuries because more damage will be captured over the set time.
;the default in ryujiin's Realistic Injury was 2. this, more likely than not, captured damage from more than one hit.
;default = 2. when set to 1, the script "almost" captures individual hits.
set kRIQuest.secondsToCaptureDamageForInjury to 2
 
;injuries will be applied when this percentage of health is lost during combat.
;default = 25.
set kRIQuest.healthLossToAcquireInjury to 100
 
;there is a small chance that even a small amount of damage will cause injury.
;default = 1.
set kRIQuest.chanceOfInjury to 0
 
;this small chance increases every second in combat.
;default = 0.017. this translates to 1% per minute. i.e. 1/60.
set kRIQuest.chanceOfInjuryIncrease to 0.00
 
;how much injury is applied for each application of an injury.
;default = 1.
set kRIQuest.injuryDamage to 1
 
;each injury type affects strength by default.
;disable strength penalties on a particular injury by setting its value to 0.
;default = 1 to all.
set kRIQuest.armInjuriesAffectStrength to 1
set kRIQuest.bodyInjuriesAffectStrength to 1
set kRIQuest.legInjuriesAffectStrength to 1
 
;how much injury is healed per hour awake.
;default = 0.042. this translates to 1 injury damage per day. i.e. 1/24.
set kRIQuest.injuryHealAwake to 0.042
 
;how much injury is healed per hour asleep.
;default = 0.125. this translates to 1 injury per 8 hours. i.e. 1/8.
set kRIQuest.injuryHealAsleep to 0.125
 
;healing can be interrupted by combat.
;set this to 1 to restart the healing timer for injuries when combat starts.
;default = 0.
set kRIQuest.combatRestartsInjuryHealTimer to 0
 
;magical heals can temporarily relieve injuries by this factor.
;the magnitude of the spell or potion is also a factor to this relief.
;the formula is:
;relief = injury point * magnitude / 100 * healingMagicReliefFactor
;default = 1.
set kRIQuest.healingMagicReliefFactor to 1
 
;length of in-game hours magic relieves injuries.
;the actor's willpower is a factor to this duration.
;the formula is:
;hours = willpower / 100 * healingMagicReliefDuration
;default = 4. an actor with 100 willpower will have relief for 4 hours.
set kRIQuest.healingMagicReliefDuration to 4
 
;===========
;injury type
;===========
;these are the range of chances an injury will be of a particular type.
;body injuries affect endurance and strength.
;arm injuries affect agility and strength.
;leg injuries affect speed and strength.
;head injuries affect personality, willpower and intelligence.
;this order cannot be changed.
;to disable a particular injury, ensure that its range is 0.
;e.g. body = 70 and arm = 70 will disable arm injuries.
;leg = 100 and head = 100 will disable head injuries.
set kRIQuest.randomBodyInjuryRange to 40 ;0 to 39. 40% chance.
set kRIQuest.randomArmInjuryRange to 70 ;40 to 69. 30% chance.
set kRIQuest.randomLegInjuryRange to 90 ;70 to 89. 20% chance.
set kRIQuest.randomHeadInjuryRange to 100 ;90 to 99. 10% chance.
 
;===
;HUD
;===
;HUD requires pluggy installed, the pluggy DLL renamed and showHUDInGameMode or showHUDInMenuMode set to 1.
;read the Using the HUD section of the read-me.
set kRIQuest.showHUDInGameMode to 1 ;default = 1
set kRIQuest.hudGameX to 10 ;default = 10
set kRIQuest.hudGameY to 625 ;default = 625
set kRIQuest.hudGameScale to 0.25 ;default = 0.25
set kRIQuest.hudGameOpacity to 100 ;default = 100
 
set kRIQuest.showHUDInMenuMode to 1 ;default = 1
set kRIQuest.hudMenuX to 760 ;default = 760
set kRIQuest.hudMenuY to 715 ;default = 715
set kRIQuest.hudMenuScale to 0.25 ;default = 0.25
set kRIQuest.hudMenuOpacity to 100 ;default = 100
 
;=====
;debug
;=====
set kRIQuest.debug to 0


His Readme file:

Name: Battle fatigue and injuries

Version: 0.70
Date: 4 February 2012
Category: Gameplay Effects and Changes
Requirements:
Oblivion.ESM or Nehrim.ESM,
Oblivion Patch 1.2.0.214,
Oblivion Script Extender (OBSE): http://obse.silverlock.org/
Optional:
Author(s): kuertee
 
Changes since last updates (0.69)
=================================
0.70, 4 February 2012:
Tweak: When loading a game after you die, the game may crash.
However, if you quit to the Main Menu and load the game from there, it doesn't.
In this version, after you die, you won't be able to load a game except from the Main Menu.
You can load the game normally while alive.
 
Gameplay changes
================
Injuries are the debilitating physical cuts and bruises caused by combat when:
25 Damage or more is received in a short time,
or from a small chance (1%) that increases over time while in combat.
These injuries can be viewed in your Active effects screen.
Most injuries are healed after 8 hours of sleep.
NPCs and the player gets injuries.
 
Magical relief from injuries when Health is healed magically. E.g. potions, spells, etc.
These bonuses can be viewed in your Active effects screen.
The Magnitude of magic determines the amount of relief.
Willpower determines the length of relief.
NPCs and the player.
 
Battle fatigue are psychological/mental conditions that come from almost dying (Health drops below 25%) in combat.
These penalties can be viewed in your Active effects screen.
Battle fatigue is cleared after 8 hours of sleep.
Incurred only once per combat.
The player only.
 
Gain full Health over 1 hour. 
This moves Oblivion's healing when waiting for 1 hour from the Wait screen into the game world.
NPCs and the player.
 
Compatibility
=============
Requires either Oblivion.ESM or Nehrim.ESM. There is an ESP for Oblivion.ESM and another for Nehrim.ESM.
Optional with LAME: "kuertee bgMagicEVShader default drain effects.esp" to reset DFAT Magic effect's shader to "effectDrain". Load after bgMagicEVShader.esp.
Optional with MMM: "kuertee MMM OnLoadCS disabled hmf effects.esp" to disable it's Health changes applied with ModActorValue. Load after all of MMM.
No scripts, animations, items, etc. were modified so this should be compatible with combat mods - even those with other injuries systems. The injuries will simply "double-up". 
 
Details
=======
Configure this mod with its INI file in (game folder)\Data\Ini\.
Penalties are applied as Drain Attributes effects attached to enchanted and invisible "tokens".
Injuries:
Body injuries (40% chance): -3 Endurance and -2 Strength
Arm injuries (30%): -3 Agility and -2 Strength
Leg injuries (20%): -3 Speed and -2 Strength
Head injuries (10%): -1 Intelligence, -1 Willpower, -2 Personality
Battle fatigue and injuries heal over time: 1 point healed every 24 hours awake, 1 point healed every 8 hours asleep.
Magical relief: injury point * magnitude of magic / 100 * healingMagicReliefFactor (default in INI is 1).
Duration: Willpower / 100 * healingMagicReliefDuration (default in INI is 12).
Healing over time: hoursToFullhealth / (health / max health) * healthAffectsHoursToFullHealth.
hoursToFullhealth and healthAffectsHoursToFullHealth are 1 in INI.
 
MMM OnLoadCS scripts with disabled Health, Magicka, Fatigue effects
===================================================================
MMM's diversifaction system uses ModActorValue to vary the Health, Magicka, and Fatigue of actors.
Unfortunately, this causes I think, some unusual effects  to the actors in the game.
Two examples are:
1. Health is healed rather than lost when physical damage is inflicted.
2. Actors continously casting healing spells because their AI detects a loss of health due to the modified base Health with ModActorValue.
"kuertee MMM OnLoadCS disabled hmf effects.esp" disables these effects from MMM's scripts.
Note, however, that MMM's diversifcation system on other attributes (e.g. Strength, Intelligence, etc...) are still intact.
 
Using the HUD (optional)
========================
Install Pluggy, rename Data\obse\plugins\OBSE_Elys_Pluggy.dll to Data\obse\plugins\OBSE_Elys_Pluggy_HUD.dll.
Ensure that showHUDInGameMode or showHUDInMenuMode in the INI file is set to 1.
 
Upgrade from previous versions
==============================
OBMM: Deactivate the previous OMOD then follow the OBMM Install instructions with the new ZIP.
 
OBMM Install
============
1. Click on "Create" to create a new OMOD.
2. Click on "Add archive" and point to the downloaded ZIP file.
3. Click on "Create omod".
4. Activate the newly created OMOD. OBMM will install the appropriate ESP for Oblivion and Nehrim.
 
OBMM Uninstall
==============
1. Deactivate the OMOD.
 
Manual Install/Uninstall
========================
Unsupported. If you know what to do, go ahead. Otherwise, use OBMM.
 
History
=======
0.69, 23 January 2012:
Bug-fix: Magical reliefs (gained from magical spells) may have been disabled in the previous version.
Reenabled in this version.
Compatibility: With Nehrim: kuerteeNehrimBattleFatigueAndInjuries.esp.
Choose one ESP. Or when using OBMM, it will install the appropriate version.
Bug-fix: Banked damages from previous combat does not carry on to new combats anymore.
Previously, combatants would receive injuries before they receive actual hits because of this bug. Fixed now.
Tweak: Health is restored faster when sitting: x2 when sitting, and x1.5 when on a horse.
Read-me: A concise description of the mod: Gameplay changes, Compatibility, Details.
Rewritten for ease of scanning. (And to get this ready for Skyrim users.)
0.68, 6 August 2011:
Bug-fix: Another attempt at preventing save-game bloat caused by string variables.
Note that this bloat exists in the OBSE's companion save-file not in the native saved-game file.
It is recommended that this update is restarted from a clean-save.
0.67, 19 June 2011:
Bug-fix: A fix to prevent save-game bloat caused by string variables.
0.66, 3 January 2011:
Tweak: OBSE logs showed that this mod may cause saved-game bloat due to recreation of string variables.
Tweaked now so that the string variables are cleaned at game-load so that only one set is only present in saved-games.
0.65, 21 December 2009:
Bug-fix: The INI file was incorrectly archived outside the INI folder.
This resulted in some values not getting initialised properly.
This could also be the cause of non-appearing HUDs.
The INI file should be located in the Data\ini sub-folder.
Bug-fix: As of 0.63, Battle fatigue should only be applied to the player.
However, there was a bug which applied Battle fatigue to anyone BUT the player.
This is now fixed.
0.64, 16 December 2009:
Bug-fix: Drain and Fortify Health effects are now taken into account in determining Battle fatigue and injuries and in healing health.
Tweak: This note added:
MMM OnLoadCS scripts with disabled Health, Magicka, Fatigue effects
===================================================================
MMM's diversifaction system uses ModActorValue to vary the Health, Magicka, and Fatigue of actors.
Unfortunately, this causes I think, some unusual effects  to the actors in the game.
Two examples are:
1. Health is healed rather than lost when physical damage is inflicted.
2. Actors continously casting healing spells because their AI detects a loss of health due to the modified base Health with ModActorValue. This was confirmed by shadowborn: http://www.bethsoft.com/bgsforums/index.php?showtopic=1049752&view=findpost&p=15272211
"kuertee MMM OnLoadCS disabled hmf effects.esp" disables these effects from MMM's scripts.
Note, however, that MMM's diversifcation system on other attributes (e.g. Strength, Intelligence, etc...) are still intact.
0.63, 29 November 2009:
New feature: HUD.
To use the HUD:
Install Pluggy, rename "Data\obse\plugins\OBSE_Elys_Pluggy.dll" to "Data\obse\plugins\OBSE_Elys_Pluggy_HUD.dll".
Ensure that showHUDInGameMode or showHUDInMenuMode in the INI file is set to 1.
Its location on screen can also be configured in the INI file.
Tweak: In regards to healing, when the player sleeps, all NPCs are assumed to also be asleep.
This should heal NPC's (especially companions') injuries at the same rate as the player.
Tweak: Removed all health fixing features.
Constantly healing NPCs and over-max-health NPCs may have been caused by MMM's actor diversifaction features from OnLoadCSNPC scripts.
The new feature below disables these effects from MMM.
New feature: An option to disable Health, Magicka and Fatigue effects (i.e. mesh-scale effects and and undead speed effects are kept) from MMM's diversifaction system.
Activate the "kuertee MMM OnLoadCS disabled hmf effects.esp".
MMM's diversifaction effects works by offsetting actors' Health, Magicka, Fatigue and other attributes by a random amount.
Unfortunately, negatively offsetting Health, Magicka and Fatigue causes the AI to "think" that these are damaged.
Actors with appropriate healing magic will try to heal these stats by continously casting and or consuming healing magic.
Tweak: In addition to the above, Battle fatigue is now only applied to the player.
Similar to MMM's diversifaction system Battle fatigue caused NPCs to continously try and fail to heal themselves.
Not applying Battle fatigue to NPCs prevents this.
Bug-fix: Removal of the BFandI scripts and effects from NPCs.
Another bug-fix/re-coded feature to ensure that the token scripts are disabled on inactive NPCs.
Inactive NPCs are those that have been unloaded from memory.
NPCs are usually unloaded from memory when the player moves too far away from them.
Bug-fix: Fixed an OBSE error at the very end of the GameMode block when an actor other than the player dies.
0.62, 19 October 2009:
Bug-fix: Previously, the Battle fatigue effect would stick (i.e. not heal) on the player.
This is now fixed.
Bug-fix: Correct application of injuries.
Previously, an injury will not be applied if it had the same value of the last healed injury.
When this mod is used over the previous version, any unapplied injuries from previous battles will be applied when the game starts.
As with all my mods, there is no need to start this mod from a "cleaned save".
Bug-fix: Application magical relief from injuries.
Previously, the fractional values of injuries would produce unusual injury and relief values.
Bug-fix: Reliefs do not carry past their duration after sleeping.
Tweak: Relief duration is now normalised to 4 hours rather than 12 hours.
0.61, 3 October 2009:
Bug-fix: Removing injuries and the token from dead NPCs.
Tweak: Auto-heal on NPCs start after half-an-hour of being out of combat instead of when they get out of combat.
The in-combat state of NPCs can be off even when they seem to be still in combat in-game.
Tweaks: Various tweaks in regards to tracking changes in health.
0.60, 25 September 2009:
Bug-fix: A safe-guard to cancel the scripts on actors that are invalid.
Bug-fix: Strength penalties were not "stacking" across multiple injuries.
New feature: Magical reliefs from injuries:
Magic (spells or potions) offer relief from injuries.
The magnitude of the spell or potion determines the magnitude of relief.
Set healingMagicReliefFactor (default = 1) to enable this feature.
The formula for reliefs is: injury point * magnitude / 100 * healingMagicReliefFactor.
The actor's Willpower determines the duration of the relief.
Set healingMagicReliefDuration (default = 12) in the INI file.
The formula for the duration is: willpower / 100 * healingMagicReliefDuration.
New feature: Current health affects healing efficiency.
The amount of damage affects the amount of time required to heal health to the full.
Set healthAffectsHoursToFullHealth (default = 1) to enable this feature.
The formula for the length of time heal is restored to full is: hoursToFullhealth / (health / max health) * healthAffectsHoursToFullHealth.
New feature: Collection of damage for injury determination can now be configured.
Previously, this was hard-coded at 1 second.
Set secondsToCaptureDamageForInjury (default = 2) in the INI file.
Bug-fix: Removal of the ever-increasing health bug.
I think (or more to the point: my tests shows that) this bug exists in the vanilla game.
An actor's health will heal over and above their maximum health when their health is not a whole number.
Sometimes, damage will work negatively: adding to the actor's health rather than removing from the actor's health.
This fix constantly checks for these cases, and forces the actor's health to be a whole number or the actor's health to its maximum when more than their maximum.
0.59, 7 September 2009:
Tweak: Users can now remove the effects of the mod from NPCs.
Previously, all non-creature actors were affected.
Set "applyToNPCs" to 0 in the INI file to remove the mod's effects from NPCs.
(Thanks for the suggestion Mercer.)
0.58, 3 September 2009:
Bug-fix: Ensured that at least more than 1 Health needs to have been lost before any injuries are applied.
In normal circumstances a check of whether there is health loss is sufficient.
However, if the actor is constantly losing health (e.g. Damage Health magic effect of 1 Health per second), the random checks for injuries occur too often.
0.57, 8 August 2009:
Tweak: Rewritten how the token injuries are kept and how the penalties are distributed across the affected attributes.
0.56, 12 July 2009:
New feature: Strength penalties can be disabled from injuries.
By default, arm injuries affect Agility and Strength, body injuries affect Endurance and Strength, and leg injuries affect Speed and Strength.
Each injury can now be configured to affect Strength or not.
Do this in the INI file.
0.55, 28 June 2009:
Bug-fix: Removal of persistant shader. I was incorrect to assume that [gfx]_initial_glow-all.esp removed all persistant effects.
With my fix, the effectDrain shader should never persist.
Just make sure that kuerteeBattleFatigueAndInjuries.esp is loaded after any mods that change the effectDrain's shader properties.
And when playing with LAME, make sure that kuertee bgMagicEVShader default drain effects.esp is loaded after bgMagicEVShader.esp.
0.54, 13 June 2009:
New feature: Added a penalty multiplier. 1 point per injury may be a little weak for some.
By default the multiplier is 5 points.
Note, however, that the penalty score is different to the injury score.
What are displayed in the Active effects screen are penalty points.
So, the damage and healing settings in the INI file are still "geared" to 1 injury point per battle fatigue or injury.
0.53, 8 June 2009:
Bug-fix: Fixed the problem that causes the reference to FOHE (Fortify Health) to stall the script.
This was evident when Battle fatigue or injuries were not getting healed.
New feature: LAME shader patch.
LAME (when its bgMagicEVShader.esp optional mod is used) adds long-lasting visual effects to Drain effects.
(Battle fatigue and injuries are effected as Drains to Health, and Attributes.)
If you do not want to see these visual effects (because they can be quite distracting),
either deactivate bgMagicEVShader.esp
or load "kuertee bgMagicEVShader default drain effects.esp" after bgMagicEVShader.esp.
Bug-fix: Previously, all healing rates used the value for healing when asleep. Fixed now.
0.52, 30 May 2009:
Bug-fix: Prevents actors receiving more Health than their maximum Health.
This seems to have been caused by the vanilla Oblivion game:
With an active Health drain, actors can accumulate (via potion or spell) more Health than their maximum health.
0.51, 24 May 2009:
Bug-fix: Healing of health now handled with ModActorValue2 (rather than ModActorValue) to prevent healing over the maximum health.
0.50, 22 May 2009 - Initial release.
 
Contact
=======
kuertee in the Bethesda forums: http://www.bethsoft.com/bgsforums/
 
Credits
=======
kuertee (author)
Ryujiin for the original Real Injury mod.
 
Tools Used
==========
Oblivion Script Extender (OBSE) - http://obse.silverlock.org/
 
Licensing/Legal
===============
You can do whatever you want with this mod but all I ask in return is that
you give me credit if you distribute any part of this mod. I would also like
to know what mods are including my work.

 




There's a few others, I'm opening his mod again now, will paste them here
Done, all of his scripts are in the spoiler. I also copied the ini file and readme. This might be unusual to do but I only want to be able to use NewHudS, get it to work with my mod.


There's other .esps but I think they don't relate to the HUD. I'll try starting the game again with his mod but the other esps disabled just to be sure
Mod Link:
http://www.nexusmods.com/oblivion/mods/24604/?

Link to comment

Double checked in OBMM, the other ESP files don't get installed(His mod has OMOD conversion). They aren't being used and the HUD still works(Only interested in the HUD functions).

Back now, and checked the other quest script. Found something:
 

 
if GetGameLoaded || started == 0
Let started := 1
 
Let showHUDInGameMode := 1
Let hudGameX := 10
Let hudGameY := 625
Let hudGameScale := 0.25
Let hudGameOpacity := 100
Let showHUDInMenuMode := 1
Let hudMenuX := 660
Let hudMenuY := 95
Let hudMenuScale := 0.25
Let hudMenuOpacity := 100
 
RunBatchScript "Data\ini\Heart SystemDupeIni.ini"
Endif

Added it to my script, just made my own ini and linked to it.

I cut out all the Battle Fatigue & injury stuff and left only the HUD part:
Link to comment

Try this script. If it doesn't work, open your console and tell me what it says:

scn zzzOneHeartOnlyMode

float fQuestDelayTime

short x

short y

float scale

short opacity

short menuX

short menuY

float menuScale

short menuOpacity

short showMode

long HUDlayer

short menuAlign


long pTempString

long pHUDHeart



begin gamemode

if fQuestDelayTime != 1
    let fQuestDelayTime := 1
endif

Let x := 0

Let y := 0

Let scale := .25

Let opacity := 100

Let showMode := 1

Let menuX := 0

Let menuY := 0

Let menuScale := .25

Let menuOpacity := 100

let HUDlayer := 500

let menuAlign := 9



If pTempString == 0

    Let pTempString := CreateString -1 "pluggy" 0 1

EndIf

If pHUDHeart == 0

    SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"

    Let pHUDHeart := NewHudS pTempString -1 showMode x y HUDlayer menuScale menuOpacity menuAlign 1 0 -1

    PrintToConsole HudSInfo pHUDHeart 4
        
Endif

end

Link to comment

Trying it right now. Will edit this with what it says
It says HudSInfo

Only once, it adds it again after I load. 
So the "If pHUDHeart== 0 " only returns true on the first frame. If I speculate, I think the Let NewHudS := command isn't resolving so it might instead sets pHUDHeart to Undefined(some kind of placeholder for when there is no answer, could be Alt+255 which is the spacebar). 
Tried editing it to include a %, since PrintToConsoles uses same syntax as MessageBox according to CS wiki. It returns the number 20

Link to comment

According to the CSwiki, what should've been outputted to the console from the HUDSInfo line was 1 (meaning that the HUD displays during gameplay only), so I probably wrote it wrong.

I do apologize, it's 8:53 am and I had two hours sleep, so I am tired.

 

As for pHUDHeart==0 returning true only the first frame, that is expected and intended; you're basically asking the game if the object is empty, and if it is creating the HUD element.

After you've created the element, it isn't empty anymore.

 

Hopefully this will fix it...

scn zzzOneHeartOnlyMode

float fQuestDelayTime

short x

short y

float scale

short opacity

short menuX

short menuY

float menuScale

short menuOpacity

short showMode

long HUDlayer

short menuAlign


long pTempString
short tmp

long pHUDHeart



begin gamemode

if fQuestDelayTime != 1
    let fQuestDelayTime := 1
endif

Let x := 0

Let y := 0

Let scale := .25

Let opacity := 100

Let showMode := 11

Let menuX := 0

Let menuY := 0

Let menuScale := .25

Let menuOpacity := 100

let HUDlayer := 500

let menuAlign := 9



If pTempString == 0

    Let pTempString := CreateString -1 "pluggy" 0 1

EndIf

If pHUDHeart == 0

    SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"

    Let pHUDHeart := NewHudS pTempString -1 showMode x y HUDlayer menuScale menuOpacity menuAlign 1 0 -1

    set tmp to (HudSInfo pHUDHeart 4)
    PrintToConsole tmp
        
Endif

end

 

 

It should display 11 in the console this time.

Link to comment

no message gets displayed in the console with the new script. Waited 1 minute ingame incase it would be due to lag


Changed it to this. 
PrintToConsole "%f equals pHUDHeart" tmp

Message "%f equals pHUDHeart" tmp

To output a number from a variable a "%f" is needed

General form of Message/MessageBox/PrintToConsole

Message "Displays this text and this %f" {a Number from a Variable placed here is added in place of %f} {Duration of displayed message}


Now it does give me 11. Does this confirm that the heart is infact rendered? Perhaps it's offscreen? Also, If I change the script by setting the show setting to 1(gamemode only) then the printed text also becomes 1.

Also, Battle Fatigue uses 2 quests, its HUD image doesn't work if either of the quest scripts are disabled. I tested by opening it in CS, and setting the quests with a blank script. The Token Object script can be disabled and the HUD image still appears. Just added this in case we have to do the very long way which would be to add his complete system to this mod, and slowly delete all the excess until it does only what we need. At least we don't have to bother with the token script which has 1015 lines in it.

Link to comment

Basic_function_shown_in_game.jpg

I have basic functionality now. Apparently, the stuff we fill in for NewHudS must be in a separate script. Need to have 2 Quests, and have our script link to a secondary Quest Script.

All it has is this in the second script:
 

 

Let hudGameX := 100 ;Original is 10

Let hudGameY := 625
Let hudGameScale := 0.25
Let hudGameOpacity := 100
 
Let hudMenuX := 660
Let hudMenuY := 95
Let hudMenuScale := 0.25
Let hudMenuOpacity := 100


There's no logical sense to why we'd have to do this. Nowhere in the pluggy files included in the download, or on CS wiki tells us to do this. I'd guess it's due to some kind of Bethesda bug.

To do list:
- Get this to work in MenuMode(but not loading screens, main menu or the bartering/repair/recharge/enchant/spellmaking menus since the normal Health bar is hidden during these). Lower priority for now unless it's quite easy to do.

- I want to try to have several hearts appear, being controlled by tokens. From there, by using a second heart image and a second token type, I want to add the lost heart icons that represent lost HP. I want to have a healing spell that removes one damage token.

Basic healing with the heart system: I want to have a healing spell that removes one damage token. As a bonus, it would be great if a script could cause Heal Minor Wounds to restore a heart when cast on the player. For a release version, this will make it feel more "organic" for the player if they obtain and use the standard restoration spells and don't see Script Effect On Self. Perhaps the script can detect when a particular spell ID is cast on the player, and react by removing a damage counter. Just so it'll look normal in the spell book, other then Heal Minor Wounds being buffed to heal 3 health per second for 8 seconds.

The first token will be the total number of hearts the player has. Represents total HP
The second token will be the number of hearts the player has lost. Represents a damage counter.

Info about the hearts 

Just info, these would be added later on:
For a good part of the game, 5 or 6 hearts will be the normal cap. I'll probably decide on the actual cap when actually playing with the complete system. I'll add Heart Containers one by one, each one is more difficult to obtain then the last. The Leveled list Random heart containers will be the same. 

I'm thinking the first Heart Container might be in Vilverin, after defeating Jalbert. The others might be in a custom dungeon. They would follow an order of difficulty, with a decent gap between them. The first custom one might be doable right away for a skilled player, the others, no. 

The easiest Random will have a 5-10% chance to appear in a boss chest. The others would be much lower, the random heart containers are a bonus.



After the heart system works with the tokens, I want to create the event handler that will add damage tokens.
To-do list, in order
-Set up basic function for the Event handler
-Set up the on-hit limited invulnerability. The invulnerability will last 1 second for now.
-Set up the on-hit PlayIdle(have it play anything for now)
 

Link to comment

Looks cool.

 

Maybe your armor could save your hit dice with some kind of armorrating-armorclass conversion.

and your magicka is displayed in a similar way too. You can cast only 7 or so spells per a day.

 

oh wait nvm. It's getting similar to baldur's gate rather than zelda. I don't want to play pen and paper on the pc...

 

Anyway.. in general I would not recommend using tokens. Pretty much anything that can be done with tokens, can also be achieved with the array. And tokens are hard to keep track of them, and slow, they can be a real puta when you attemp to attach object scripts on them.

Link to comment

Ok, how would i set up this array? Right now I'm intended to keep Magicka and Stamina normal. The Restoration spells will have more relative power now, so I will increase their cost for the player. 

Heal Legendary Wounds will instantly restore 3 hearts, and then restore 3 hearts again after a duration. It will consume like 70% to 90% of player's magicka at 100 restoration and 100 int, depending on race/birthsign

Trying to add 2nd and 3rd hearts right now. Just edited my scripts and going to try it

Link to comment

Am now trying to have 3 hearts display at same time.
 

 

Looks cool.

Maybe your armor could save your hit dice with some kind of armorrating-armorclass conversion.
and your magicka is displayed in a similar way too. You can cast only 7 or so spells per a day.

oh wait nvm. It's getting similar to baldur's gate rather than zelda. I don't want to play pen and paper on the pc...

Anyway.. in general I would not recommend using tokens. Pretty much anything that can be done with tokens, can also be achieved with the array. And tokens are hard to keep track of them, and slow, they can be a real puta when you attemp to attach object scripts on them.

Actually thought about doing an armorrating-armorclass conversion. Too complicated though.

3 hearts, worked
three_heart.jpg

Link to comment

OBSE arrays are quite straightforward to learn. Unless you have to use pluggy arrays, use OBSE's. They are very convenient and cool.

OBSE command doc has an excellent documentation of their array feature. See the "Array Variables" section if you're new to it.

 

Basically an array is a container of.. things. a sequenced container of things.

In OBSE you can put anything into it. numbers, strings, refs, even other arrays, anything you name it. and in OBSE you can extend/shrink the arrays any time you want. (This has some drawback on the back-end, that it takes up more memory heap, but generally they are more efficient than doing the same thing without them.)

So once you consructed an array(whether it is an array, or a map, or a stringmap) with the ar_Construct command, you can build up a structured data set with it. This becomes very handy when you have to deal with a large amount of npcs, and still handy even if the player is your only concern because it can have indefinite amount of stuff in it. It also helps keeping your script short, with while/foreach keywords.

 

For pluggy arrays, I don't remember correctly. You must remember the array ID when constructing it and.. err.. well, it's been ages I had coded with pluggy. But not that it isn't good. they are efficient. pluggy also has its own array tutorial somewhere in the released file. The basics are the same with OBSE though. Sorry :P

Link to comment

Never had to use IDs for Pluggy, but I only have used NewHudS

For the second heart


If pHUDHeartSecond == 0
 
   SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"
Let pHUDHeartSecond := NewHudS pTempString 1 11 xSecond y
   HudS_SclX pHUDHeartSecond scale
HudS_SclY pHUDHeartSecond scale
       
Endif

I had to set everything in a separate script, then reference it in the main one. Then it worked

Ok, will check out the obse arrays.
 

 
3 hearts worked.
three_heart.jpg

 

Link to comment

Think I found the command I'll need for the next part.

SetEventHandler OnHit.
Need this so i can trigger a loss of a heart, limited invulnerability, animation.

How to track the total number of hearts? In place of tokens. My character should have 3. It should carry over between save and restarts.
I need to track 2 variables, Current Hearts and Maximum Hearts. 


What command in OBSE replaces tokens. Going by your earlier post, I will look at Array Variables. 
http://obse.silverlock.org/obse_command_doc.html#Array_Variables


Although I need to go to bed now.

Link to comment

Ugh, teach me to try to figure what's wrong with an Oblivion script after two hours' sleep. Sorry about that.

Still haven't had time to sleep, by the way. Life is being... Rather unkind. Friend is sick and I went to visit him in the hospital.

 

Anyway, good to see you got this working.

 

If you set the showMode to 11, it will work in menus. Of course, you then need to add a check for which menu it is, and disable it in ones you don't want it to appear.

This page has codes for the various menu modes:

http://cs.elderscrolls.com/index.php?title=MenuMode

 

I don't think an array is optimal here; you're only implementing the system on the player, you don't have to keep track of too many things. You can still do it, of course.

If you plan on having a static maximum number of hearts possible, you can use either a standard OBSE array (information about it here: http://cs.elderscrolls.com/index.php?title=Introduction_to_OBSE_arrays) or a Pluggy array (information about it here: http://cs.elderscrolls.com/index.php?title=Introduction_to_Pluggy_Arrays).

If you want a dynamic array, use the Pluggy one.

 

I suppose using an array makes a few things easier to do than quest variables (such as a dynamic number of hearts), but of course the downside is that you have to learn just one more thing. It's up to you.

 

If you don't want to use arrays, just add two int variables to your script.

Link to comment

Umm, you only need 2 variables? why don't you set two more integers in your quest.

It should be enough unless you want to do more complicated works on the hearts. Forget about tokens, and arrays too in this case.

I need it to do this:

Short TotalHeartCount

Short HeartDamageCounter

 

SetEventHandler OnHit Player

;If player is hit during temporary invulnerability, These 3 lines might be unnecessary if I use SetGhost

;Return

;Endif

 

; Other code: Add one to a damage counter variable,

; then check if HeartDamageCounter >= TotalHeartCount; Since HeartDamageCounter = TotalHeartCount means 0 HP and

; HeartDamageCounter > TotalHeartCount means negative HP.

; If true then trigger player's death; later this will have a PlayIdle DeathAnimation 1

; Elseif damage counter != max heart count

 

Player.PlayIdle Hitstun Animation 1 ; Force the player to do a short hit stun animation, this will last only about 15-30 frames. Functions like ; a mini-stagger/recoil

;Trigger temporary invulnerability, this is due to the reduced health and the stun animation. It will last a little bit longer then the animation ;so the player can't be stuck in a "combo". Probably will last 10-15 frames longer then the animation. The easiest way to do this is ;probably Player.SetGhost 1 for like 30-40 frames, then Player.SetGhost 0. Could make the first If -> Return -> Endif part unnecessary ;since OnHit shouldn't be triggered if the player has SetGhost.

 

 

Random Heart Containers will have a static number possible, they will be a late addition. Currently thinking the total cap might be 10.

 

First Script

 

 

scn zzzOneHeartOnlyMode

 
float fQuestDelayTime
 
short x
 
short y
 
float scale
 
short opacity
 
short menuX
 
short menuY
 
float menuScale
 
short menuOpacity
 
short showMode
 
long HUDlayer
 
short menuAlign
 
 
long pTempString
short tmp
 
long pHUDHeart
long pHUDHeartSecond
long pHUDHeartThird
 
short hudGameX
short hudGameY
float hudGameScale
short hudGameOpacity
short hudMenuX
short hudMenuY
float hudMenuScale
short hudMenuOpacity
 
short SecondhudGameX
short ThirdhudGameX
short xSecond
short xThird
begin gamemode
 
if fQuestDelayTime != 1
    let fQuestDelayTime := 1
endif
 
 
Let x := zzzHeartSystemTheSecondQuest.hudGameX
 
Let y := zzzHeartSystemTheSecondQuest.hudGameY
 
Let scale := zzzHeartSystemTheSecondQuest.hudGameScale
 
Let opacity := zzzHeartSystemTheSecondQuest.hudGameOpacity
 
Let menuX := zzzHeartSystemTheSecondQuest.hudMenuX
 
Let menuY := zzzHeartSystemTheSecondQuest.hudMenuY
 
Let menuScale := zzzHeartSystemTheSecondQuest.hudMenuScale
 
Let menuOpacity := zzzHeartSystemTheSecondQuest.hudMenuOpacity
 
 
 
Let xSecond := zzzHeartSystemTheSecondQuest.SecondhudGameX
 
Let xThird := zzzHeartSystemTheSecondQuest.ThirdhudGameX
 
If pTempString == 0
 
    Let pTempString := CreateString -1 "pluggy" 0 1
 
EndIf
 
If pHUDHeart == 0
 
    SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"
 
    ;Let pHUDHeart := NewHudS pTempString -1 showMode x y HUDlayer menuScale menuOpacity menuAlign 1 0 -1
Let pHUDHeart := NewHudS pTempString 1 11 x y
    HudS_SclX pHUDHeart scale
HudS_SclY pHUDHeart scale
 
;set tmp to (HudSInfo pHUDHeart 4)
    ;PrintToConsole tmp
 
        
Endif
 
 
 
If pHUDHeartSecond == 0
 
   SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"
Let pHUDHeartSecond := NewHudS pTempString 1 11 xSecond y
   HudS_SclX pHUDHeartSecond scale
HudS_SclY pHUDHeartSecond scale
       
Endif
 
 
If pHUDHeartThird == 0
 
    SetString pTempString "Textures\Menus\OneHeartOnlyRiskyMode.png"
Let pHUDHeartThird := NewHudS pTempString 1 11 xThird y
    HudS_SclX pHUDHeartThird scale
HudS_SclY pHUDHeartThird scale
        
Endif
 
 

end

 

 

Second Script

 

SCN zzzOneHeartOnlyModeTheSecond

 
 
short hudGameX
short hudGameY
float hudGameScale
short hudGameOpacity
short hudMenuX
short hudMenuY
float hudMenuScale
short hudMenuOpacity
 
short ThirdhudGameX
short SecondhudGameX
 
Short TotalHeartCount
Short HeartDamageCounter
 
Short InvulnerabilityPhase
Short InvulnerabilityTimer
 
Short Critical
Short CriticalHealthMod
Short CriticalSet
 
 
begin GameMode
If player.getdead
StopQuest zzzHeartSystemTheSecondQuest ;Avoid CTD after death
StopQuest zzzHeartSystem
endif
; For whatever reason, NewHudS command requires the variables to be in another quest script
If InvulnerabilityTimer >= 30
 
Player.SetGhost 0
Set InvulnerabilityPhase to 0
Set InvulnerabilityTimer to 0
 
Endif
 
 
 
if InvulnerabilityPhase == 1
 
Set InvulnerabilityTimer to 1 + InvulnerabilityTimer  ;Count Frames passed
 
endif
 
;Let CriticalHealthMod := ( 1 - player.getav health )
 
If ( TotalHeartCount - HeartDamageCounter ) == 1 ;1 heart left
 
Set Critical to 1 ; Change her 1h Idle, facial expression too if possible. I've seen pose mods also change expressions
 
player.ResetHealth ; Before a Death Animation is added, this could be better then Player.Kill. Have her regular health set to 1
 
Else
Set CriticalSet to 0
Player.Resethealth
If CriticalSet == 0
 
player.modav2 health CriticalHealthMod
 
Set CriticalSet to 1
endif
 
endif
 
 
 
Let hudGameX := 100
Let hudGameY := 680
Let hudGameScale := 0.25
Let hudGameOpacity := 100
Let hudMenuX := 560
Let hudMenuY := 350
Let hudMenuScale := 0.25
Let hudMenuOpacity := 100
 
 
Let SecondhudGameX := 150 ;Second Heart
 
 
Let ThirdhudGameX := 200 ;Third Heart
;SetEventHandler OnHit Player
 
;If player is hit during temporary invulnerability, These 3 lines might be unnecessary if I use SetGhost
;Return
;Endif
; Other code: Add one to a damage counter variable,
Let HeartDamageCounter := HeartDamageCounter + 1
; then check
if HeartDamageCounter >= TotalHeartCount ; Since HeartDamageCounter = TotalHeartCount means 0 HP and
; HeartDamageCounter > TotalHeartCount means negative HP.
player.kill ; If true then trigger player's death; later this will have a PlayIdle DeathAnimation 1
Else ;Player didn't die from attack
 
;Player.PlayIdle HitstunAnimation 1 ; Force the player to do a short hit stun animation, this will last only about 15-30 frames. Functions like ; a mini-stagger/recoil
;Trigger temporary invulnerability, this is due to the reduced health and the stun animation. It will last a little bit longer then the animation
;so the player can't be stuck in a "combo". Probably will last 10-15 frames longer then the animation.
;The easiest way to do this is ;probably Player.SetGhost 1 for like 30-40 frames, then Player.SetGhost 0.
;Could make the first If -> Return -> Endif part unnecessary ;since OnHit shouldn't be triggered if the player has SetGhost.
Player.SetGhost 1
Set InvulnerabilityPhase to 1
endif
end

 

 

 

 

Link to comment
Nothing happens with the event handler. Only trying to print a console message when the player is attacked
In my main quest script I added this line just below Begin Gamemode
SetEventHandler  OnHit  FnOnPlayerHitByEnemy  Object::player

Event  handler script


sscn FnOnPlayerHitByEnemy
ref player
ref attacker
 
begin Function { player, attacker}
 
PrintToConsole "player was hit by the attacker"
Message "player was hit by the attacker"
 
;Let zzzHeartSystem.HeartDamageCounter := zzzHeartSystem.HeartDamageCounter + 1
;Let zzzHeartSystemDamageSystem.InvulnerabilityTrigger := 1
end


Also does this event handler command require a specific reference for the attacking NPC to be already declared. As in, if the player was attacked by Baurus then it must state:
SetEventHandler  OnHit  FnOnPlayerHitByEnemy  Object::player Ref::BaurusRef
or else it doesn't run?
 

I would love suggestions about the gameplay system itself. Did not think about how healing will work until a few days ago

Link to comment

1. your filter condition should be "ref" or "first", not "object". "object" means the attacker.

2. do not use "player" or "playerRef" as your variable name.

Oblivion language is case-insensitive. They will be confused that with the built-in references. I'm not sure if we can override the namespace in OBSE.

Anyway, make sure that you won't accidentally override any of the pre-existing editor IDs, game settings and all that.

 

Try this instead.

 

SetEventHandler "OnHit" FnOnPlayerHitByEnemy "ref"::PlayerRef
or
SetEventHandler "OnHit" FnOnPlayerHitByEnemy "first"::PlayerRef
Worth noting that this "filter"::pair notation is internally a StringMap mapping notation. Even if OBSE doc does not enclose the "filter" part with double quotes, don't forget to do that. Those "ref" or "object" are actually string keys, not some kind of another keywords or modifiers.

 

Event names are strings, too.

 

And my advice is that OBSE compiler often acts like a bitch. Sometimes it slips a lot of your mistakes away, or sometimes just refuses to compile correct things. So if something does not work, try other ways. Don't expect any of the functions are doing its job correctly. Be a paranoid, populate debug prints, dump arrays, see what's happening with your eyes, unless you already have experience with the same kind of script.

 

As to the multiple heart tokens. You can access any quest variable prepending the questID to the variable name, like

yourQuest.some_var
So quest object is like a container of psuedo-global variables. Don't use the real global variables. Use quest instead.

So... Do it as you see fit, but I think you don't need to give tokens to the player to track down pc's current and max hearts. If you use an array for that then you can extend the number of hearts indefinitely, but it is up to your choice.

I only have played very old series of zelda franchise when I was young. I think.. I had ten or twelve hearts in the end :P

Link to comment

10-12 hearts is about what the cap will be, though it will be very hard to get all of them. RNG will give about 5, one with a 10% chance of appearing in boss chests or boss npcs found in caves. The others, much lower. High end player will have 5-8 depending on luck. RNG hearts are a bonus to ease difficulty a little over time.
 

​ Trying now

Link to comment

Function Script

scn FnOnPlayerHitByEnemy
ref player
ref refs
begin function { player refs }
Messagebox "player was hit by the attacker"
end
SCN Quest Script
...
Begin Gamemode
SetEventHandler OnHit FnOnPlayerHitByEnemy "first"::zzzHeartSystem.attackedPlayer
...
end
Declared Ref attackedplayer in other quest script
didn't work, tried both having player attack an npc and be attacked

Strangely worked suddenly. I made a third quest script. Third script just listed some variables didn't have Begin block. Tried adding this to it and it suddenly works

Begin Gamemode
SetEventHandler OnHit FnOnPlayerHitByEnemy "first"::zzzHeartSystem.attackedPlayer
end
Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use