Scripts That Detects Pc Health And Fortifies It By A %

Post » Mon Oct 19, 2009 3:01 am

Hey!

I used to write a few scripts in the past for a warrior character that enhanced his physical abilities, one of them was increased Health by a certain value.

What i did back then was a script that checked the PC level and added the corresponding leveled ability, so i had to make like 10 spells (Abilities) on the editor, each with a Fortify Health effect...

However the Fortify Health effect obviously was constant, this time i wanted to make it variable, for example 10% of the base PC's health.

I thought it was going to be simple, but so far im having trouble with the GetBaseAV, i thought it returned the Base value, without any effects applied, however seems it doesn't...

Here is the script so far...

float baseHealthfloat increasedAmountbegin ScriptEffectUpdateset PCLevel to player.getlevel	if baseHealth != player.getBaseAV health		set baseHealth to player.getBaseAV health		set reDo to 1	endif


So it declares the variables, the script starts, PCLevel is set, now if it is the first time running, the if should run, set baseHealth to PC base health and reDo to 1.

Now the other part

if PCLevel >= 10		if reDo == 1			player.removeSpellNS aaFitnessAb			set increasedAmount to baseHealth * 18 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set reDo to 0		else			return		endif	elseif PCLevel >= 5		if reDo == 1			player.removeSpellNS aaFitnessAb			set increasedAmount to baseHealth * 14 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set reDo to 0		else			return		endif	else		if reDo == 1			player.removeSpellNS aaFitnessAb			set increasedAmount to baseHealth * 10 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set reDo to 0        	endif	endifend


The scripts runs the levels check, and if the Player level is 1 the last section should run, (Well all the sections are the same only changing the % increasedAmount will get)

increasedAmount should be set to 10% of players base Health, the magnitude of the Fortify Health ability is set and then added to the player, reDo is set to 0, and the script updates.

reDo shouldn't be set to 1, unless the base health of the Player has changed, for some reason it's always set to 1, and so everything loops...

I tried this instead...

	if baseHealth != player.getBaseAV health		set baseHealth to player.getBaseAV health		set reDo to 1



		if reDo == 1			player.removeSpellNS aaFitnessAb                        set baseHealth to player.getBaseAV health			set increasedAmount to baseHealth * 10 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb                        set baseHealth to player.getBaseAV health			set reDo to 0        	endif


But it didn't work, thing is im kind of blocked right now, some help would be appreciated...

If you think there is a better way to do it, please give me some tips or advice.

Sorry for the messy post.

Thank You.


PS: Perhaps you noticed my english is not very good, but you could help me out to get better!
User avatar
JeSsy ArEllano
 
Posts: 3369
Joined: Fri Oct 20, 2006 10:51 am

Post » Mon Oct 19, 2009 5:07 am

Thanks a lot for the help!! i Don't know what could i do without it!, it's just that... that... it is priceless...

With all your help, i have been able to think about the script for a while, GetBaseAV is not working the way it should, actually i tried some workarounds and that fuction did all kind of strange things...

But nevermind that, i tried another aproach, instead of getting the base health using GetBaseAV, i will get the base health using getting the base Endurance...

Here is the script.

scn aaFitnessScrshort PCLevelshort playerLevelCheckfloat healthBasefloat healthRawBasefloat healthCheckfloat endurancePlayerfloat enduranceBaseHealthfloat enduranceLevelGainfloat enduranceLevelGainTotalfloat increasedAmountfloat Timerbegin ScriptEffectStart	set endurancePlayer to player.getbaseactorvalue Endurance	set enduranceBaseHealth to ( endurancePlayer * 2 );	set enduranceLevelGain to ( endurancePlayer * 10 / 100 )	set playerLevelCheck to player.GetLevel	set healthRawBase to enduranceBaseHealth	set RTSource.fitnessReload to 1endbegin ScriptEffectUpdate	printtoConsole "baserawhealth is %.0f" healthRawBase	printtoconsole "increasedAmount is %.0f" increasedAmount	printtoconsole "endurancePlayer is %.0f" endurancePlayer	printtoconsole "fitnessReload is %.0f" RTSource.fitnessReloadset PCLevel to player.getlevelif endurancePlayer != player.getBaseActorValue Endurance	if PCLevel > playerLevelCheck		set endurancePlayer to player.getbaseactorvalue Endurance		set enduranceBaseHealth to ( endurancePlayer * 2 )		set enduranceLevelGain to ( endurancePlayer * 10 / 100 )		set enduranceLevelGainTotal to enduranceLevelGainTotal + enduranceLevelGain		set healthRawBase to enduranceBaseHealth + enduranceLevelGainTotal		set playerLevelCheck to player.GetLevel		set RTSource.fitnessReload to 1	else		set endurancePlayer to player.getbaseactorvalue Endurance		set enduranceBaseHealth to ( endurancePlayer * 2 )		set healthRawBase to enduranceBaseHealth + enduranceLevelGainTotal		set RTSource.fitnessReload to 1	endifendif     if ( Timer < 1 )		set Timer to Timer + getSecondsPassed	else		player.addSpellNS aaFitnessAb		set Timer to 0	endif;;Fitness	if PCLevel >= 30		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 30 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	elseif PCLevel >= 25		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 27 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	elseif PCLevel >= 20		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 24 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	elseif PCLevel >= 15		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 21 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	elseif PCLevel >= 10		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 18 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	elseif PCLevel >= 5		if RTSource.fitnessReload == 1			player.removeSpellNS aaFitnessAb;			set increasedAmount to baseHealth * 14 / 100			SetNthEIMagnitude increasedAmount aaFitnessAb			player.addSpellNS aaFitnessAb			set RTSource.fitnessReload to 0		else			return		endif	else		if RTSource.fitnessReload == 1			player.removeSpell aaFitnessAb			set increasedAmount to ( healthRawBase * 10 / 100 )			SetNthEIMagnitude increasedAmount aaFitnessAb			set RTSource.fitnessReload to 0		endif	endifend


The AddSpell at the beginning it's spamed every second, because for some odd reason using in inside the block that calculates the % of healthRawBase added to increasedAmount does not work... using HasSpell doesn't work either, lot's of bugs with the CS lately =D.

Anyway, i think that should do it, if someone has some advice or something, it would be appreciated.

Thank You.

PS: I was just kidding about all the help and stuff... =D Cheer up!
User avatar
Bones47
 
Posts: 3399
Joined: Fri Nov 09, 2007 11:15 pm


Return to IV - Oblivion