RomanR Posted September 27, 2021 Share Posted September 27, 2021 I may be late but after some testing I found a problem while AXMaxHealth is still zero - so the dividing equation falls silently by "divide by zero" and as secondary effect it takes down whole script. As a workaround a phealth variable could be set to 100.See this: .... set chealth to player.GetAV Health if AXMaxHealth != 0 set phealth to ((chealth/AXMaxHealth)*100) else set phealth to 100 endif .... Link to comment Share on other sites More sharing options...
bomo99 Posted September 27, 2021 Author Share Posted September 27, 2021 I may be late but after some testing I found a problem while AXMaxHealth is still zero - so the dividing equation falls silently by "divide by zero" and as secondary effect it takes down whole script. As a workaround a phealth variable could be set to 100.See this: .... set chealth to player.GetAV Health if AXMaxHealth != 0 set phealth to ((chealth/AXMaxHealth)*100) else set phealth to 100 endif .... thanks but i am no longer having any issue with the AXMMaxHealth now the issue is the emergency regen, when i tested it now with the new script in my last post it doesnt trigger(new char died as a end result) but everything else does perfectly Link to comment Share on other sites More sharing options...
RomanR Posted September 27, 2021 Share Posted September 27, 2021 (edited) Mechanism of triggering emergency regen is unclear to me by looking at script only, but I clearly see that after the player's health is more than 10%, all days check will be ignored. So I would advise to put them to another part of the script, or into a quest script. Sorry, I'm unable to help you more. Edited September 27, 2021 by RomanR Link to comment Share on other sites More sharing options...
bomo99 Posted September 27, 2021 Author Share Posted September 27, 2021 Mechanism of triggering emergency regen is unclear to me by looking at script only, but I clearly see that after the player's health is more than 10%, all days check will be ignored. So I would advise to put them to another part of the script, or into a quest script. Sorry, I'm unable to help you more.the emergency regen gets triggered when the player's health falls to 10% or lower then gives a powerful regen for a set duration in a week cooldown timer(once activated the player will have to wait a week to be able to use the effect again)i reread the script once again when you put more than in your reply and checked it is less than or equal toand how does the all days check get ignored, also the week timer is in a quest script (if that is what the mages guild chest uses for it)? Link to comment Share on other sites More sharing options...
RomanR Posted September 27, 2021 Share Posted September 27, 2021 (edited) Counting of days is alright, but checks for AXMRegenTimer.dayspassed and reseting variables are only within elseif phealth <= 10 ....endif condition. This condition is also only checked while the player is engaged in battle. Edited September 27, 2021 by RomanR Link to comment Share on other sites More sharing options...
bomo99 Posted September 27, 2021 Author Share Posted September 27, 2021 Counting of days is alright, but checks for AXMRegenTimer.dayspassed and reseting variables are only within elseif phealth <= 10 ....endif condition. This condition is also only checked while the player is engaged in battle. to be honest i didnt know where else to put it in the script and even if the rest happens in combat is fine as it only ever works in combat anyway to so i dont think this is an issue.is this the part that confuses you? if ( AXMRegenTimer.dayspassed >= 1 ) && ( AXMRegenTimer.dayspassed < 7 ) if days passed is less than or equal to 1 and greater than 7 execute code Link to comment Share on other sites More sharing options...
RomanR Posted September 27, 2021 Share Posted September 27, 2021 Not this part, but it's late and it seems I'm not thinking right. I will try to look on this after some sleep. Good bye for now. Link to comment Share on other sites More sharing options...
RomanR Posted September 28, 2021 Share Posted September 28, 2021 (edited) After some rest I looked at regen script again and this is a temporaly result: Scn AXMHealthBattleRegenScript float chealth float phealth float hourtimer float currentday float daycheck float rememertimer ;---------------------- 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 ( AxRegenTimer.AXMRegenEmer == 0 ) player.AddSpell AXMDarkKingSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 1 ;first stage - adding spell return endif ;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 if AXMRegenTimer.AXMRegenEmer != 0 ;triggered emergency regen if AXMRegenTimer.AXMRegenEmer == 1 ;&& player.HasSpell AXMDarkKingSelfPwr02 != 0 ;HasSpell is OBSE function, you can remove it set AXMRegenTimer.AXMRegenEmer to 2 ;stage 2 - ability added and active endif if AXMRegenTimer.AXMRegenEmer == 2 set rememertimer to 30 ;ability will be removed after 30s ;also this is a good place to init 7 day cooldown stuff set AXMRegenTimer.AXMRegenEmer to 3 ;stage 3 - counting down timer and removing ability endif if AXMRegenTimer.AXMRegenEmer == 3 if rememertimer <= 0 player.RemoveSpell AXMDarkKingSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 4 ;stage 4 - ability removed, 7 day cooldown else set rememertimer to rememertimer - GetSecondsPassed endif endif if AXMRegenTimer.AXMRegenEmer == 4 ;7 day cooldown update and check if AXMRegenTimer.dayspassed >= 7 set AXMRegenTimer.AXMRegenEmer to 0 set AXMRegenTimer.dayspassed to 0 ;reseting all over stuff else ;place for updating variables etc. endif endif endif End As you see, I'm focused on solving a triigger problem, so 7 day cooldown stuff is commented now, except 7 day check. Edited September 28, 2021 by RomanR Link to comment Share on other sites More sharing options...
bomo99 Posted September 28, 2021 Author Share Posted September 28, 2021 this actually worked Scn AXMHealthBattleRegenScript float chealth float phealth float hourtimer float currentday float daycheck float timer ;---------------------- 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 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 == 0 ) player.AddSpell AXMDarkKingsSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 1 ;first stage - adding spell return 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 if AXMRegenTimer.AXMRegenEmer != 0 ;triggered emergency regen if AXMRegenTimer.AXMRegenEmer == 1 set AXMRegenTimer.AXMRegenEmer to 2 ;stage 2 - ability added and active endif if AXMRegenTimer.AXMRegenEmer == 2 set timer to 10 ;ability will be removed after 10s ;also this is a good place to init 7 day cooldown stuff set AXMRegenTimer.AXMRegenEmer to 3 ;stage 3 - counting down timer and removing ability endif if AXMRegenTimer.AXMRegenEmer == 3 if timer <= 0 player.RemoveSpell AXMDarkKingsSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 4 ;stage 4 - ability removed, 7 day cooldown else set timer to timer - GetSecondsPassed endif endif if AXMRegenTimer.AXMRegenEmer == 4 ;7 day cooldown update and check if AXMRegenTimer.dayspassed >= 7 set AXMRegenTimer.AXMRegenEmer to 0 set AXMRegenTimer.dayspassed to 0 ;reseting all over stuff else ;place for updating variables etc. endif endif endif End just changed the time to 10s instead of 30s also a few questions ;also this is a good place to init 7 day cooldown stuff 1. is it the week stuff i had in?2. is this already set for a week cooldown after activation Link to comment Share on other sites More sharing options...
RomanR Posted September 28, 2021 Share Posted September 28, 2021 (edited) This week stuff is incomplete, because I was waiting for your answer. As you confirmed that all is working so far, I present you last version of the script: Scn AXMHealthBattleRegenScript float chealth float phealth float hourtimer float currentday float daycheck float timer ;---------------------- 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 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 == 0 ) player.AddSpell AXMDarkKingsSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 1 ;first stage - adding spell return 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 if AXMRegenTimer.AXMRegenEmer != 0 ;triggered emergency regen if AXMRegenTimer.AXMRegenEmer == 1 set AXMRegenTimer.AXMRegenEmer to 2 ;stage 2 - ability added and active endif if AXMRegenTimer.AXMRegenEmer == 2 set timer to 10 ;ability will be removed after 10s set AXMRegenTimer.update to 0 set AXMRegenTimer.currentday to GameDaysPassed ;init for days set AXMRegenTimer.daycheck to GameDaysPassed set AXMRegenTimer.AXMRegenEmer to 3 ;stage 3 - counting down timer and removing ability endif if AXMRegenTimer.AXMRegenEmer == 3 if timer <= 0 player.RemoveSpell AXMDarkKingsSelfPwr02 set AXMRegenTimer.AXMRegenEmer to 4 ;stage 4 - ability removed, 7 day cooldown else set timer to timer - GetSecondsPassed endif endif if AXMRegenTimer.AXMRegenEmer == 4 ;7 day cooldown update and check if AXMRegenTimer.dayspassed >= 7 set AXMRegenTimer.AXMRegenEmer to 0 set AXMRegenTimer.dayspassed to 0 set AXMRegenTimer.currentday to 0 set AXMRegenTimer.daycheck to 0 set AXMRegenTimer.update to 0 else if AXMRegenTimer.update == 0 ; quest script is ready for request set AXMRegenTimer.currentday to GameDaysPassed ;update actual day set AXMRegenTimer.update to 1 ;request update in quest script endif endif endif endif End I also made changes in quest regen script: Scn AXMRegenQuestScript short AXMRegenEmer short dayspassed short update float hourtimer float currentday float daycheck Begin Gamemode if ( update > 0 ) if ( currentday != daycheck ) ;not same day set dayspassed to ( dayspassed + 1 ) set currentday to GameDaysPassed set daycheck to GameDaysPassed endif set update to 0 endif End Begin Menumode if ( update > 0 ) if ( currentday != daycheck ) set dayspassed to ( dayspassed + 1 ) set currentday to GameDaysPassed set daycheck to GameDaysPassed endif set update to 0 endif End Now it should be all. Edited September 28, 2021 by RomanR Link to comment Share on other sites More sharing options...
Recommended Posts