Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Need to make sense of something here


ThomasKaira
 Share

Recommended Posts

I'm trying to get a calculation for how much health to take away from the player base on these:

Spell property ThisSpell Auto


Function DispelMe()


	game.getPlayer().RemoveSpell(ThisSpell)


EndFunction


Function RemoveAVMod(Float Mod, String Value)


	game.getPlayer().ModAV(Value, -(Mod as Float))


EndFunction


Int function AdjustAVMod(Float Target, Int Mod, String Value)


	int modTarget = (Game.GetPlayer().GetBaseActorValue(Value) * Target) as int


	if modTarget - Mod != 0


		Game.GetPlayer().ModActorValue(Value, (modTarget - Mod) as float)


		return modTarget

	else

		return Mod

	endIf


EndFunction
Message property INJModerateInjuriesMSG Auto


GlobalVariable property INJInjuryPoints Auto


Int HealthMod

Float HealthModPct


Event OnEffectStart(Actor target, Actor caster)


	If Target == game.getPlayer()


		INJModerateInjuriesMSG.Show()

		RegisterForSingleUpdate(1)


	Else


		DispelMe()


	EndIf


EndEvent


Event OnUpdate()


	SetMods(INJInjuryPoints.GetValue())

	AdjustAV()

	RegisterForSingleUpdate(1)


EndEvent


Event OnEffectFinish(Actor Target, Actor Caster)


	If Target == game.getPlayer()


		RemoveAVMod(HealthMod, "Health")

		UnregisterForUpdate()


	EndIf


EndEvent


Function SetMods(Float Injury)


	If Injury < 70


		HealthModPct = 0.75 * Injury / 70.0


	Else


		HealthModPct = 0.0


	EndIf


EndFunction


Function AdjustAV()


	HealthMod = AdjustAVMod(HealthModPct, HealthMod, "Health")


EndFunction

(Bottom script extends the top one).

My problem is that the calculations are skewed and I'm having trouble narrowing down exactly where the bad numbers are creeping in. So far, my current red flag is on the first time the AdjustAVMod() function runs, the Mod variable returns 0, but it still doesn't really help me much. Only that the variable had not yet received its initial value.

These scripts are the result of studying another person's work and modifying it to suit my own needs, so I know this should theoretically work (I want small negative numbers being returned, not large positive ones). I just can't figure out where things are going wrong so I can correct the problem.

Link to comment
Share on other sites

Solved.

This one was my fault. This formula:

HealthModPct = 0.75 * Injury / 70.0
was wrong, feeding the script bad numbers. After changing the formula to this:
HealthModPct = 0.75 * ((-Injury + 70) *-1) / 70.0

The calculations are now correct.

Edited by ThomasKaira
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...