Mayfly53 Posted December 9, 2012 Share Posted December 9, 2012 (edited) Hello everyone, I'm making an armour mod which has two separate body pieces, one on the legs and one on the chest. Unfortunately, to make both show up, one has to take up a different to normal slot. This results in it being equipped along with any piece of armour, and I want to write a script which will unequip it if it's anything but the leg armour. I've been trying for a few hours now and I'm stymied. I get two "No viable alternative at input "If"" errors compiling, for the two If functions after the AND and OR operators. Could someone point me in the right direction? Basically, I want the chestplate (the one with the different slot), while equipped, to check other equipped armour and see is there any other body armour equipped. If there is, but it's not the leg armour from the mod, the chestplate will unequip itself. Scriptname MercCuirassCheckScript extends ObjectReference Event OnEquipped(Actor akActor) If akActor == Game().GetPlayer If (Game().GetPlayer().WornHasKeyword("Mercenary Cuirass") != 1) && If (Game().GetPlayer().WornHasKeyword(Cuirass) == 1) || If (Game().GetPlayer().WornHasKeyword(Armor) == 1) player().UnequipItem("01MercCuirassUpper") EndIf EndIf EndEvent Edited December 9, 2012 by Mayfly53 Link to comment Share on other sites More sharing options...
acidzebra Posted December 9, 2012 Share Posted December 9, 2012 (edited) Game.getplayer()Not game().getplayer or game().getplayer() or player() Not sure if your code will work even with proper syntax but give er a whirl. Edited December 9, 2012 by acidzebra Link to comment Share on other sites More sharing options...
Ghaunadaur Posted December 9, 2012 Share Posted December 9, 2012 The script will not work without setting up some properties for the keywords and the armor, and also filling these. Scriptname MercCuirassCheckScript extends ObjectReference Keyword Property MercenaryCuirass auto Keyword Property Cuirass auto Keyword Property ArmorKeyword auto Armor Property MercCuirassUpper auto Event OnEquipped(Actor akActor) Actor Player = Game.GetPlayer() If akActor == Player If (Player.WornHasKeyword(MercenaryCuirass) != 1) && (Player.WornHasKeyword(Cuirass) == 1) || (Player.WornHasKeyword(ArmorKeyword) == 1) player.UnequipItem(MercCuirassUpper) EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 9, 2012 Share Posted December 9, 2012 Aside from improper use of Game.GetPlayer() as acidzebra stated, you've got your If statement set up incorrectly. If (Game.GetPlayer().WornHasKeyword("Mercenary Cuirass") != 1) && (Game.GetPlayer().WornHasKeyword(Cuirass) == 1) || (Game.GetPlayer().WornHasKeyword(Armor) == 1) You only need ONE if at the beginning the && and || tell it what else to check. However I think it may not catch properly. Do you want it to be: -- keyword Mercenary Cuirass AND one of keywords Curiass or Armor-- both keywords Mercenary Cuirass and Cuirass OR keyword Armor The game is going to be just as confused as I am in that regards. Link to comment Share on other sites More sharing options...
steve40 Posted December 9, 2012 Share Posted December 9, 2012 (edited) Why don't you simply add the leg armor as a property, then check if it is equipped. You shouldn't even need to check keywords or slots. If the leg-piece isn't equipped, then simply unequip the chest piece: Scriptname MercCuirassCheckScript extends ObjectReference {Put this script on the chest component of your two-piece armor} Armor Property MyLegArmorPiece auto {Link this property to the leg armor component of your two piece armor} Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() && !akActor.IsEquipped(MyLegArmorPiece) akActor.UnequipItem(self) EndIf EndEvent Edited December 9, 2012 by steve40 Link to comment Share on other sites More sharing options...
acidzebra Posted December 9, 2012 Share Posted December 9, 2012 Sorry, my compiler throws an exception at the first error found :biggrin: Link to comment Share on other sites More sharing options...
Mayfly53 Posted December 9, 2012 Author Share Posted December 9, 2012 (edited) Thank you all for your replies. Thank you steve40, your suggestion compiles perfectly, I just now have to test it in-game. Scriptname MercCuirassCheckScript extends ObjectReference Armor Property MercCuirassProperty auto Armor Property ArmorCuirass auto Event OnEquipped(Actor akActor) If akActor == Game.GetPlayer() && akActor.IsEquipped(ArmorCuirass) && !akActor.IsEquipped(MercCuirassProperty) akActor.UnequipItem(self) EndIf EndEvent I guess I've been thinking of this script as an objective script as opposed to from the point of view of the armour itself. A few questions, because I couldn't seem to find answers. 1) Is there a mechanic like in other languages whereby you can say "If X = 1, go to part A of the script, otherwise go to part B" ? 2) Regarding the WornHasKeyword function, is a keyword a string, as in part of the name, or is it a property like IsArmorLight etc? EDIT: Okay, the script has no effect. Nothing gets unequipped when the conditions say they should. Also, it occurred to me that this is only half a solution. It would unequip the chestplate if another armour was already equipped, but it does not stop other armours from being equipped after the chestplate. I'm going to have to rethink this. It will have to be a quest script with the OnEquipped(Actor akActor) event. I could do this if there was an "If X = 1, go to part A of the script, otherwise go to part B" function, but I can't find one. Edited December 9, 2012 by Mayfly53 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 9, 2012 Share Posted December 9, 2012 I could do this if there was an "If X = 1, go to part A of the script, otherwise go to part B" function, but I can't find one. If X == 1;do A stuffElse;do B stuffEndIf If B stuff is reliant on other conditions then use ElseIf and add those conditions Link to comment Share on other sites More sharing options...
Mayfly53 Posted December 9, 2012 Author Share Posted December 9, 2012 (edited) Thank you :) It still isn't working, and I'm not sure why. I've a feeling I'm close. Scriptname MercCuirassCheckScript extends ObjectReference Armor Property MercCuirassProperty auto Armor Property ArmorCuirass auto Event OnEquipped(Actor akActor) GoToState("PlayerCheck") EndEvent State PlayerCheck If akActor = Game.GetPlayer() GoToState("Unequip") Else GoToState("Empty") EndIf EndState State Unequip If akActor.WornHasKeyword(ArmorCuirass) && !akActor().WornHasKeyword(MercCuirassProperty) akActor.UnequipItem(self) EndIf EndState It's still attached to the upper armour. I'm getting two errors "mismatched input 'If' expecting ENDSTATE". They're located obviously enough at each If statement inside each State. Edited December 9, 2012 by Mayfly53 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 9, 2012 Share Posted December 9, 2012 your statements for the IF are not on the same line as the IF. also akActor = Game.GetPlayer() tells the game to make akActor have the same value as Game.GetPlayer() whereas akActor == Game.GetPlayer() tells the game to check if akActor does have the same value as Game.GetPlayer() that said your script needs adjust in the following manner Scriptname MercCuirassCheckScript extends ObjectReference Armor Property MercCuirassProperty auto Armor Property ArmorCuirass auto Event OnEquipped(Actor akActor) GoToState("PlayerCheck") EndEvent State PlayerCheck If akActor == Game.GetPlayer() GoToState("Unequip") Else GoToState("Empty") EndIf EndState State Unequip If akActor.WornHasKeyword(ArmorCuirass) && !akActor().WornHasKeyword(MercCuirassProperty) akActor.UnequipItem(self) EndIf EndState Link to comment Share on other sites More sharing options...
Recommended Posts