Will58448 Posted February 22, 2020 Share Posted February 22, 2020 I'm trying to complie a script and getting error: no viable alternative at input 'if'Still trying to learn about scripting and not sure what this means. Script is as follows: Scriptname FoodPoisoningScript extends ActiveMagicEffect SPELL Property FoodPoisoningSpell AutoActor Property PlayerRef Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) nativeif akBaseObject.HasKeyword(FoodPoisoning) PlayerRef.AddSpell(FoodPoisoningSpell, false)endifEndEvent Link to comment Share on other sites More sharing options...
niston Posted February 23, 2020 Share Posted February 23, 2020 If (akBaseObject.HasKeyword(FoodPoisoning)) .....EndIf The test condition for the IF needs to go into parenthesis. And you will probably have to define Keyword Property FoodPoisoning as well. Link to comment Share on other sites More sharing options...
Will58448 Posted February 23, 2020 Author Share Posted February 23, 2020 I've made those changes, but it's still failing to complie with the same error message. Scriptname FoodPoisoningScript extends ActiveMagicEffect SPELL Property FoodPoisoningSpell AutoActor Property PlayerRef AutoKeyword Property FoodPoisoning Auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) native If (akBaseObject.HasKeyword(FoodPoisoning)) PlayerRef.AddSpell(FoodPoisoningSpell, false)EndifEndEvent Link to comment Share on other sites More sharing options...
niston Posted February 23, 2020 Share Posted February 23, 2020 Ditch the "native". Also, if a Property is not expected to change at runtime, it is good advice to make it Const. Keywords and Spells for example are very unlikely to change at runtime, so: Spell Property FoodPoisoningSpell Auto ConstKeyword Property FoodPoisoning Auto Const Difference: A property without the 'Const' will be baked into player's save and can be changed at runtime, even by another script. A property with the 'Const' must be filled in CK, will always be loaded from the plugin and cannot change at runtime (read-only). I don't think you need the Actor property either, because you can: Game.GetPlayer().AddSpell(FoodPoisoningSpell, false) On a second thought, you probably want to apply the spell to the actor that equipped the object, and not to the player. Least player ends up with food poisoning whenever some NPC equips your object. I'm however afraid that I don't know enough about magic effects to be of any further help. Link to comment Share on other sites More sharing options...
SKKmods Posted February 23, 2020 Share Posted February 23, 2020 Actor.OnObjectEquipped is a Skyrim function that is not supported in Fallout4, the equivalent is Actor.OnItemEquipped which is not generated by the ActiveMagicEffect script. What it is you are actually trying to achieve ? eg: when the player eats an ingestible/potion that is poisoned apply a poison spell ... in which case the simple solution is to use ObjectReference.OnEquipped attached to the object ... Link to comment Share on other sites More sharing options...
Will58448 Posted February 23, 2020 Author Share Posted February 23, 2020 Basically I was trying to make it so eating raw meat would give the player a 'disease', in this case food poisoning. I did actually manage to get it working by making a script to equip a potion with the disease effects, when the player ate certain items.However, I couldn't find a way to dispel the effect through certain chems. Even using keywords in the dispel section of the magic effect.I read online that dispel wouldn't work as the effect didn't come from a spell, it came from a potion.Therefore I tried to apply the disease as a spell rather than adding a potion effect. I should probably go back to the tutorials and keep learning, this is my first time playing around with scripts! Link to comment Share on other sites More sharing options...
Recommended Posts