Jump to content

Battle Health Regen Script Error


Recommended Posts

Hello, i have been working on this script a little bit on and off again for almost 2 months now and finally got it finished until it doesnt work, allow me to explain how it is suppose to function;

1, only triggers when the player is in combat and when out of combat remove everything

2, at certain health percentages execute regen script for that percentage

3, if player health is in critical, use the emergency regen that has a 1 week cooldown

so far i have the spell and script to do so, first off this script is meant to be attached to an equipped item, and be apart of the larger set of summon items, here is the script

Scn AXMHealthBattleRegenScript

float chealth
float phealth
float hourtimer
float currentday
float daycheck
;----------------------
short startday
short dayspassed
short update
short slowregen
short mediumregen
short fastregen
short emergencyregen

Begin OnStartCombat

 Set slowregen to 0
 Set mediumregen to 0
 Set fastregen to 0
 Set emergencyregen to 0

 if ( AXMRegenTimer.AXMRegenEmer == 0 )
  set AXMRegenTimer.currentday to GameDaysPassed
  set AXMRegenTimer.daycheck to GameDaysPassed
  set AXMRegenTimer.hourtimer to GameHour
  set AXMRegenTimer.AXMRegenEmer to 1
  set AXMRegenTimer.update to 1
 endif

End

Begin Gamemode

  Set chealth to Player.GetAV Health
  Set phealth to ((chealth / AXMMaxHealth) * 100)

  if Player.IsInCombat == 1
	if phealth >= 90
	 Player.RemoveSpell AXMSlowHRegen
	 Player.RemoveSpell AXMMediumHRegen
	 Player.RemoveSpell AXMFastHRegen
	 return

	elseif (phealth < 90) && (slowregen == 0)
	 Set slowregen to 1
	 player.AddSpell AXMSlowHRegen
	 if mediumregen == 1
	  player.RemoveSpell AXMMediumHRegen
	  Set mediumregen to 0
	 endif
	 return

	elseif (phealth < 60) && (mediumregen == 0)
	 Set mediumregen to 1
	 player.AddSpell AXMMediumHRegen
	 if fastregen == 1
	  player.RemoveSpell AXMFastHRegen
	  Set fastregen to 0
	 endif
	 return

	elseif (phealth < 30) && (fastregen == 0)
	 Set fastregen to 1
	 player.AddSpell AXMFastHRegen
	 return

	elseif phealth <= 10
		if ( AXMRegenTimer.AXMRegenEmer == 1 )
			if ( AXMRegenTimer.dayspassed >= 1 ) && ( AXMRegenTimer.dayspassed < 7 )
	
				if ( emergencyregen == 0 )
					player.AddSpell AXMDarkKingsSelfPwr02
					Set emergencyregen to ( emergencyregen + 1 )
				endif
			endif
		endif

		if ( emergencyregen > 1 )
			set AXMRegenTimer.AXMRegenEmer to 0 
			set AXMRegenTimer.update to 0
			set emergencyregen to 0
			set AXMRegenTimer.dayspassed to 0
		elseif ( emergencyregen == 1 )
			set AXMRegenTimer.AXMRegenEmer to 2
		endif

			if ( AXMRegenTimer.dayspassed >= 7 )
				set AXMRegenTimer.AXMRegenEmer to 0
				set AXMRegenTimer.update to 0
				set emergencyregen to 0
				set AXMRegenTimer.dayspassed to 0
			endif
	endif

  elseif Player.IsInCombat == 0
	if slowregen == 1
	 Player.RemoveSpell AXMSlowHRegen
 	 Set slowregen to 0
	elseif mediumregen == 1
	 Player.RemoveSpell AXMMediumHRegen
 	 Set mediumregen to 0
	elseif fastregen == 1
	 Player.RemoveSpell AXMFastHRegen
	 Set fastregen to 0
	endif
  endif
End

i have done many troubleshooting things here after each issue and yet still having this error of it not executing, originally the regen spells were constantly being added at start of combat. Fixed: by moving the current health/max health calc to gamemode, now the issue is that it doesn't give the regen at all regardless if you go to that percentage in combat or start of combat (also emergency regen was a greater power and i changed its tag to ability to suit the script but kept its duration if i need a timer please say where)

the calculation of AXMMaxHealth is done in 2 scripts(as a troubleshooting measure) but i can move it to one if someone can tell what is wrong with the order of where to put it, as the items in question have enchants and an active applied after the summon.

the Summon Spell for said items

scn AXMConjureArmorScript

Short bChoosing
Short Button

Begin ScriptEffectStart

    Set bChoosing to 1
    MessageBox "The Darkness Envelops Around You, and tries to Overwhelm You, What Will you Do?"  "Embrace the Darkness"  "Fight the Darkness"

End

Begin Gamemode
   If bChoosing == 1
        Set Button to GetButtonPressed
 
          if Button == 0
			Set AXMArmorSummonVar to AXMArmorSummonVar + 1
				Set bChoosing to 0
				message " "
				message " "
				Player.RemoveSpell AXMDreadedConjureArmor
				Player.Additem AXMConjuredClaymore 1
				Player.Additem AXMConjuredRaiment 1
				Player.Additem AXMConjuredHood 1
				Player.Additem AXMDarkKingsFinesseOrb01 1
				Player.Additem AXMDarkKingsFinesseOrb02 1
				Player.Additem AXMDarkKingsFinesseOrb03 1
				Player.Additem AXMDarkKingsMystOrb01 1
				Player.Additem AXMDarkKingsMystOrb02 1
				Player.Additem AXMDarkKingsMystOrb03 1
				Player.Additem AXMDarkKingsPhysOrb01 1
				Player.Additem AXMDarkKingsPhysOrb02 1
				Player.Additem AXMDarkKingsPhysOrb03 1
				Player.Equipitem AXMConjuredClaymore
				Player.Equipitem AXMConjuredRaiment
				Player.Equipitem AXMConjuredHood
				Player.Equipitem AXMDarkKingsFinesseOrb01
				Player.Equipitem AXMDarkKingsFinesseOrb02
				Player.Equipitem AXMDarkKingsFinesseOrb03
				Player.Equipitem AXMDarkKingsMystOrb01
				Player.Equipitem AXMDarkKingsMystOrb02
				Player.Equipitem AXMDarkKingsMystOrb03
				Player.Equipitem AXMDarkKingsPhysOrb01
				Player.Equipitem AXMDarkKingsPhysOrb02
				Player.Equipitem AXMDarkKingsPhysOrb03
				Player.AddSpell AXMRevertClaymore

          Elseif Button == 1

          Endif
    Endif
End

Begin ScriptEffectFinish
 Set AXMMaxHealth to Player.GetAV Health
 Set AXMMaxMagicka to Player.GetAV Magicka
 Set AXMMaxFatigue to Player.GetAV Fatigue
End

i added a script effect finish hoping that it goes through, in this order, (ScriptEffectStart -> Gamemode -> ScriptEffectFinish). this did not work

The script that handles pretty much everything for the summonable set

scn AXMSoulLinkScript

short Link
short bHasAbility 

Begin Gamemode Player
	set AXMArmorEquipCount to player.GetEquipped AXMConjuredRaiment
	set AXMArmorEquipCount to AXMArmorEquipCount + player.GetEquipped AXMConjuredHood

	If (AXMArmorSummonVar == 0) && (Link == 0)
		Player.AddSpell AXMDreadedConjureArmor
		if (AXMArmorEquipCount < 2) && (bHasAbility == 1)
          	 Player.RemoveSpell AXMDarkKingsCurseAb
          	 set bHasAbility to 0
		 set AXMMaxHealth to 0
		 set AXMMaxMagicka to 0
		 set AXMMaxFatigue to 0
		endif
		set Link to 1
	endif

	If (AXMArmorSummonVar == 1) && (Link == 1)
		if (AXMArmorEquipCount == 2) && (bHasAbility == 0)
            	 Player.AddSpell AXMDarkKingsCurseAb
          	 set bHasAbility to 1
		 Set AXMMaxHealth to Player.GetAV Health
		 Set AXMMaxMagicka to Player.GetAV Magicka
		 Set AXMMaxFatigue to Player.GetAV Fatigue
		endif
		set Link to 0
	endif
End

the idea was that when the armor is summoned this script is to add an effect(which works) however the regen still doesnt trigger, btw the soul link is an Magic effect script as it is applied to an active effect to the player and for the 1 week cool down timer here it is

Scn AXMRegenQuestScript

short AXMRegenEmer
short dayspassed
short update

float hourtimer
float currentday
float daycheck

Begin Gamemode

 if ( update > 0 )
	if ( currentday != GameDaysPassed )

		set dayspassed to ( dayspassed + 1 )
		set currentday to GameDaysPassed
		set daycheck to GameDaysPassed

	endif
 endif	

End

Begin Menumode

if ( update > 0 )
	if ( currentday != GameDaysPassed )

		set dayspassed to ( dayspassed + 1 )
		set currentday to GameDaysPassed

	endif
endif	

End

this script is identical to the mages guild chest timer just changed a variable to suit my needs

the only issues that are happening so far are 2 here is what the problem are

1. regens dont get applied at all at the percentage or even lower

2. emergency regen doesnt get added(this may work if 1 works but unsure)

if anyone can help i would be grateful, also if anyone needs any help with understanding any part of the scripts please say, as i can simplify it.

Link to comment
Share on other sites

I think that problem would be in AXMaxHealth. For actual maximum health I would use "player.GetMaxAV Health", not GetAV. Also I don't see any definition for it in any script. Is it a global variable? Besides I think it's better to assign it dynamicaly, so for example a first script would be changed like this:

Scn AXMHealthBattleRegenScript
...
float pmaxhealth
...
begin GameMode

   set chealth to player.GetAV Health
   set pmaxhealth to player.GetMaxAV Health
   set phealth to ((chealth/pmaxhealth)*100)
...
end
Edited by RomanR
Link to comment
Share on other sites

Hey, the syntax on your script looks good. This appears to be a property issue. If the script is compiling without error, and it just doesn't function correctly in-game, then that most likely implies that a property is not filled. The script knows what property you're referring to, but since it's not filled, it's not actually changing any values.

 

Open the script properties and make sure every property is defined correctly. :laugh:

Edited by M4RK3X
Link to comment
Share on other sites

Hey, the syntax on your script looks good. This appears to be a property issue. If the script is compiling without error, and it just doesn't function correctly in-game, then that most likely implies that a property is not filled. The script knows what property you're referring to, but since it's not filled, it's not actually changing any values.

 

Open the script properties and make sure every property is defined correctly. :laugh:

i might be misinterpreting this but what is a "property" in this case, if you're refering to AXMMaxHealth that variable gets a value in 2 different scripts(originally Soul Link was the first to do it before the summon spell) if its CHealth(Current Health) or PHealth(Percent Health) then those get their values when in combat

Link to comment
Share on other sites

GetMaxAV is a OBSE function. It returns actor's maximum value including all bonuses. It can be called in two ways: actor.GetMaxAV (value as string), in this case "Health", or as actor.GetMaxAVC 8 (8 is a value code for health).

Edited by RomanR
Link to comment
Share on other sites

OK. Still, because a triggering the regen abilities is tied to phealth variable, we must check if phealth is calculated correctly first. It can be checked by making extra debug global variable (lets name it debugphealth) and set it after phealth calculation.

set phealth to ((chealth/AXMaxHealth)*100)
set debugphealth to phealth

After some time in battle and loosing some health, you can use "show" command in console to view debugphealth's value.

Link to comment
Share on other sites

i will try that and will edit if anything happens

Edit: i did what you said and this is what i got

0 before combat

0 at start of combat

0 after being hit in combat

 

Edit2: just did a test to see if AXMMaxHealth is the issue(since its a global variable) no it isnt it reads the health just fine.

so in here is the issue

  Set chealth to Player.GetAV Health
  Set phealth to ((chealth / AXMMaxHealth) * 100)

since that debug, it leaves me to believe that chealth or the order of operations is backwards but i am leaning more towards chealth but that doesnt explain why its an issue as its in gamemode not onstartcombat and the way i understand it gamemode scripts update per frame so it should be constantly updating over and over again

 

Edit3: Alright i changed chealth to a Global variable to see what is going on and it grabs what the players current health is before the enchants and doesn't change it at all or triggers when the health falls at all

Edited by bomo99
Link to comment
Share on other sites

great News it now works in a way

Scn AXMHealthBattleRegenScript

float chealth
float phealth
float hourtimer
float currentday
float daycheck
;----------------------
short startday
short dayspassed
short update
short slowregen
short mediumregen
short fastregen
short emergencyregen

Begin OnStartCombat

 Set slowregen to 0
 Set mediumregen to 0
 Set fastregen to 0
 Set emergencyregen to 0

 if ( AXMRegenTimer.AXMRegenEmer == 0 )
  set AXMRegenTimer.currentday to GameDaysPassed
  set AXMRegenTimer.daycheck to GameDaysPassed
  set AXMRegenTimer.hourtimer to GameHour
  set AXMRegenTimer.AXMRegenEmer to 1
  set AXMRegenTimer.update to 1
 endif

End

Begin Gamemode

  if Player.IsInCombat == 1

	 Set chealth to Player.GetAV Health
	 Set phealth to ((chealth / AXMMaxHealth) * 100)

	if phealth >= 90
	 Player.RemoveSpell AXMSlowHRegen
	 Player.RemoveSpell AXMMediumHRegen
	 Player.RemoveSpell AXMFastHRegen
	 return

	elseif (phealth < 90) && (slowregen == 0)
	 Set slowregen to 1
	 player.AddSpell AXMSlowHRegen
	 if mediumregen == 1
	  player.RemoveSpell AXMMediumHRegen
	  Set mediumregen to 0
	 endif
	 return

	elseif (phealth < 60) && (mediumregen == 0)
	 Set mediumregen to 1
	 player.AddSpell AXMMediumHRegen
	 if fastregen == 1
	  player.RemoveSpell AXMFastHRegen
	  Set fastregen to 0
	 endif
	 return

	elseif (phealth < 30) && (fastregen == 0)
	 Set fastregen to 1
	 player.AddSpell AXMFastHRegen
	 return

	elseif phealth <= 10
		if ( AXMRegenTimer.AXMRegenEmer == 1 )
			if ( AXMRegenTimer.dayspassed >= 1 ) && ( AXMRegenTimer.dayspassed < 7 )
	
				if ( emergencyregen == 0 )
					player.AddSpell AXMDarkKingsSelfPwr02
					Set emergencyregen to ( emergencyregen + 1 )
				endif
			endif
		endif

		if ( emergencyregen > 1 )
			set AXMRegenTimer.AXMRegenEmer to 0 
			set AXMRegenTimer.update to 0
			set emergencyregen to 0
			set AXMRegenTimer.dayspassed to 0
		elseif ( emergencyregen == 1 )
			set AXMRegenTimer.AXMRegenEmer to 2
		endif

			if ( AXMRegenTimer.dayspassed >= 7 )
				set AXMRegenTimer.AXMRegenEmer to 0
				set AXMRegenTimer.update to 0
				set emergencyregen to 0
				set AXMRegenTimer.dayspassed to 0
			endif
	endif

  elseif Player.IsInCombat == 0
	if slowregen == 1
	 Player.RemoveSpell AXMSlowHRegen
 	 Set slowregen to 0
	elseif mediumregen == 1
	 Player.RemoveSpell AXMMediumHRegen
 	 Set mediumregen to 0
	elseif fastregen == 1
	 Player.RemoveSpell AXMFastHRegen
	 Set fastregen to 0
	endif
  endif
End

all but the emergency regen works and if the ingame duration timer doesnt work i may need help implementing one

Link to comment
Share on other sites

  • Recently Browsing   0 members

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