dAb Posted November 24, 2012 Share Posted November 24, 2012 (edited) So, I made a complete food overhaul to make it somewhat useful. As a rule of thumb any meat-based foods fortify health, any fish-based foods fortify magicka and just about everything else fortifies stamina [some beverages fortify magicka, some others fortify health]. Needing a way to to set a limit to the boost the player can gain I came up with this: Scriptname HealthBoostCheck extends activemagiceffect Message Property FoodNoHealthEffectMSG auto GlobalVariable Property FoodHealthBoost auto float FoodHealthBoost Event OnEffectStart(actor akTarget, actor akCaster) FoodHealthBoost = Game.GetPlayer().GetActorValue("Health") - Game.GetPlayer().GetBaseActorValue("Health") FoodHealthBoost.Setvalue(FoodHealthBoost) if (FoodHealthBoost &--#62;= 50) FoodNoHealthEffectMSG.Show() endIf EndEvent event OnEffectFinish(actor akTarget, actor akCaster) FoodHealthBoost = Game.GetPlayer().GetActorValue("Health") - Game.GetPlayer().GetBaseActorValue("Health") FoodHealthBoost.Setvalue(FoodHealthBoost) EndEvent This is attached to the FoodFortifyHealth effect, with a HealthBoost < 50 condition to apply the effect itself. The same applies to the other two stamina and magicka scripts. I'm not satisfied with this solution because if the player is already under some attributes fortifying effect the food doesn't give any advantage over the current effect. So I thought I might store the food effect magnitude in a variable but I have to read its value with GetNthEffectMagnitude first and I have no idea on how to use it. To begin with I'd need something like this: Scriptname HealthBoostCheck extends activemagiceffect GlobalVariable Property FoodHealthBoost auto Potion CurrentFood Event OnEffectStart(actor akTarget, actor akCaster) Int magnitude = CurrentFood.GetNthEffectMagnitude(0) as Int FoodHealthBoost.Setvalue(magnitude) EndEvent *snip* This obviously doesn't work because CurrentFood is non-existing. Where am I supposed to use GetNthEffectMagnitude, and how? For some obscure reason scripts can't be attached to potions and I'm not sure if OnItemRemoved might be of any help here [does it even check for consumed items?]. This would have been MUCH easier if the CK would have let me read the <dur> and <mag> values directly : / Long story short: how do I get around this? Edited November 24, 2012 by dAb Link to comment Share on other sites More sharing options...
steve40 Posted November 25, 2012 Share Posted November 25, 2012 (edited) Your first script contains errors and will not compile. It should be like this: Scriptname HealthBoostCheck extends activemagiceffect conditional Message Property FoodNoHealthEffectMSG auto GlobalVariable Property FoodHealthBoost auto conditional Event OnEffectStart(actor akTarget, actor akCaster) float fFoodHealthBoost = akTarget.GetActorValue("Health") - akTarget.GetBaseActorValue("Health") FoodHealthBoost.Setvalue(fFoodHealthBoost) if (fFoodHealthBoost >= 50) FoodNoHealthEffectMSG.Show() endIf EndEvent event OnEffectFinish(actor akTarget, actor akCaster) float fFoodHealthBoost = akTarget.GetActorValue("Health") - akTarget.GetBaseActorValue("Health") FoodHealthBoost.Setvalue(fFoodHealthBoost) EndEvent You can't have two different variables (the global and the float) with identical names.Also, the effect acts on akTarget, which might not necessarily be the player, so it is not a good idea to hard code Game.GetPlayer() when you can use akTarget instead.Also, you haven't made the global variable Conditional, nor the script itself Why don't you simply dispel the effect if the player's stat is >50 than the base value? No need for this convoluted workaround with global variables and conditional functions. Scriptname HealthBoostCheck extends activemagiceffect Message Property FoodNoHealthEffectMSG auto Event OnEffectStart(actor akTarget, actor akCaster) float fFoodHealthBoost = akTarget.GetActorValue("Health") - akTarget.GetBaseActorValue("Health") if (fFoodHealthBoost > 50) FoodNoHealthEffectMSG.Show() dispel() endIf EndEvent In your second script, CurrentFood would have to be a Property variable that points to the Food form that you are using.Again, you forgot to make the global and the script Conditional.Also, you can't set the global (a float) to be an int (magnitude), you must use SetValueInt(): Scriptname HealthBoostCheck extends activemagiceffect conditional GlobalVariable Property FoodHealthBoost auto conditional Property Potion CurrentFood auto Event OnEffectStart(actor akTarget, actor akCaster) Int magnitude = CurrentFood.GetNthEffectMagnitude(0) as Int FoodHealthBoost.SetValueInt(magnitude) EndEvent *snip* Edited November 25, 2012 by steve40 Link to comment Share on other sites More sharing options...
dAb Posted November 25, 2012 Author Share Posted November 25, 2012 (edited) Um, actually it compiles with no errors and works as intended [i'm not satisfied with it but it's a different matter]. The BB code has messed up the < character though. Not sure why you have renamed the float variable with the F thing, I presume this is considered good practice? As you may guess I'm new to Papyrus and I have much to learn [edit: crap, wait, the variables had actually two different names in my version, I just removed the mod name from the float one before pasting the script, my bad]. At any rate, what I'm asking for is a way to read the effect magnitude once the effect has been applied, do you have any suggestions? I don't understand how GetNthEffectMagnitude is supposed to work. Edited November 25, 2012 by dAb Link to comment Share on other sites More sharing options...
dAb Posted November 25, 2012 Author Share Posted November 25, 2012 (edited) Seen your edit. I didn't even think of using dispel :facepalm: Many thanks, you are a life saver. Can you elaborate on the need of making both the script and the global Conditional? I'm not sure where and why I should use it. Also, in the 2nd version of the script I still don't understand what CurrentFood should point to [edit: see http://img254.imageshack.us/img254/5637/foodscript.jpg ] I can't make it point to any specific food because I need to read the magnitude of any kind of food right after it has been consumed. Edited November 25, 2012 by dAb Link to comment Share on other sites More sharing options...
Recommended Posts