GSGlobe Posted October 28, 2017 Share Posted October 28, 2017 Hi there! So I'm in the process of learning Papyrus and today I've stumbled upon my next obstacle, which I cant really wrap my head around and I'm here hoping someone might shed some light on this. I've made a menu spell which lets you set a cost for a specific spell between "Magicka,Health and Stamina" Say, Health 50, Stamina 50, Magicka 50. So on my spell conditions tab I set Getactorvalue >= 50 (more or equal to 50) as I dont want the spell to be cast below your set amount. Getactorvalue >= 50 "Health"Getactorvalue >= 50 "Magicka"Getactorvalue >= 50 "Stamina" But I'm having a problem if I choose, magicka and I start to spring and my Stamina is at 0, I cant cast the spell even if my magicka is well over 50. Can I somehow easily make (Health,Stamina or Magicka" conditional and only true depending on your choice?What workaround can I do? I've looked here : https://www.creationkit.com/index.php?title=Condition_Functions But I must be too dumb to realize the fix, must be something easy? Best regards! Link to comment Share on other sites More sharing options...
foamyesque Posted October 28, 2017 Share Posted October 28, 2017 (edited) By default, conditions are "and" conditions; there'll be a column beside the condition saying whether it is an AND or an OR condition. To change 'em from an AND to an OR, open each condition; there will be a little tickbox on the right that you can turn on and off. However, doing it by just changing them all to ORs doesn't sound like it will do what you want either. You want to select the kind of thing the spell will cost, and then only cast if you have enough of that particular thing, correct? This is a bit of a hassle to manage with conditions, because of the way the operator precedence works (https://www.creationkit.com/index.php?title=Conditions). Assuming what the spell should drain is defined via a globalvariable GSG_SpellCost (0 = health, 1 = magicka, 2 = stamina), you want something on the lines of: GSG_SpellCost == 0 ORGSG_SpellCost == 1 ORGetActorValue("Stamina") >= 50 AND GSG_SpellCost == 0 ORGSG_SpellCost == 2 ORGetActorValue("Magicka") >= 50 AND GSG_SpellCost == 1 ORGSG_SpellCost == 2 ORGetActorValue("Health") > 50 AND <-- changed the conditional to be strictly greater than so's the player can't kill themselves casting it; also, the last 'and' doesn't matter. Each block of OR'd statements will be evaluated first, and then ANDed together. Functionally, here, a block will be false -- and the spell fail to cast -- if and only if the GSG_SpellCost global matches the AV being tested in that block (done by process of elimination: if it is neither of the other two values, it must be the third) and the AV is less than 50 (or less than or equal to, in the case of health). This should produce the result I think you're after. Edited October 28, 2017 by foamyesque Link to comment Share on other sites More sharing options...
GSGlobe Posted October 28, 2017 Author Share Posted October 28, 2017 Yikes, I can say I thought about global but just as quickly dismissed it as I had no way of implementing it and this is something I would never have thought of. I can't believe how you even thought of this? This is good. Thank you very much for this,I assume I should set the global variable where I'm choosing the cost? with SetValue() ? Link to comment Share on other sites More sharing options...
foamyesque Posted October 28, 2017 Share Posted October 28, 2017 Yikes, I can say I thought about global but just as quickly dismissed it as I had no way of implementing it and this is something I would never have thought of. I can't believe how you even thought of this? This is good. Thank you very much for this,I assume I should set the global variable where I'm choosing the cost? with SetValue() ? Yeah; you say you have a spell that lets you choose between 'em, so you'd set the global there as needed. Link to comment Share on other sites More sharing options...
GSGlobe Posted October 28, 2017 Author Share Posted October 28, 2017 Perfect, thanks alot for this :) I'll try it out tomorrow when I have more time to invest into it. I appreciate it much :] Link to comment Share on other sites More sharing options...
foamyesque Posted October 28, 2017 Share Posted October 28, 2017 Perfect, thanks a lot for this :smile: I'll try it out tomorrow when I have more time to invest into it. I appreciate it much :] Thank me if it works :p I put this together based on the wiki docs, but it's not ingame-tested. Link to comment Share on other sites More sharing options...
GSGlobe Posted October 28, 2017 Author Share Posted October 28, 2017 I also suppose this could be quite the mess if multiple options were given? Say, 50 and 100. Link to comment Share on other sites More sharing options...
foamyesque Posted October 28, 2017 Share Posted October 28, 2017 I also suppose this could be quite the mess if multiple options were given? Say, 50 and 100. The complexity can escalate rapidly. One way around it might be to put multiple effects on the spell, and then add conditions at the spell level. Link to comment Share on other sites More sharing options...
GSGlobe Posted October 28, 2017 Author Share Posted October 28, 2017 Would something like this work? or is considered bad? ;; would be replaced with spell.cast(playerref) so it would be a script on the spell itself. Event OnEffectStart(actor akTarget, actor akCaster) If Auto_Melee.GetValue(1) && PlayerRef.GetActorValue("Health") >= 25 ;; ELSEIF Auto_Melee.GetValue(2) && PlayerRef.GetActorValue("Health") >= 50 ;; ELSEIF Auto_Melee.GetValue(3) && PlayerRef.GetActorValue("Health") >= 100 ;; ELSEIF If Auto_Melee.GetValue(4) && PlayerRef.GetActorValue("Health") >= 200 ;; ELSEIF Auto_Melee.GetValue(5) && PlayerRef.GetActorValue("Magicka") >= 25 ;; ELSEIF Auto_Melee.GetValue(6) && PlayerRef.GetActorValue("Magicka") >= 50 ;; ELSEIF Auto_Melee.GetValue(7) && PlayerRef.GetActorValue("Magicka") >= 100 ;; ELSEIF Auto_Melee.GetValue(8) && PlayerRef.GetActorValue("Magicka") >= 200 ;; ELSEIF Auto_Melee.GetValue(9) && PlayerRef.GetActorValue("Stamina") >= 25 ;; ELSEIF Auto_Melee.GetValue(10) && PlayerRef.GetActorValue("Stamina") >= 50 ;; ELSEIF Auto_Melee.GetValue(11) && PlayerRef.GetActorValue("Stamina") >= 100 ;; ELSEIF Auto_Melee.GetValue(12) && PlayerRef.GetActorValue("Stamina") >= 200 ;; Endif EndEvent Link to comment Share on other sites More sharing options...
foamyesque Posted October 28, 2017 Share Posted October 28, 2017 You can do script-level conditions, but if you do it that way the magic effect is applied, which may or may not be desirable (e.g., the special effects are going to happen and so forth). Link to comment Share on other sites More sharing options...
Recommended Posts