Now here's something odd...
ScriptName KIRAInfiltrator1FireXSCRRef myselfShort GunTypeShort TrickShort FlipTypeBegin OnEquip set myself to GetContainer ;<-------- 1 ------ <<< if (GetIsID KIRAInfiltrator1FireX == 1) set GunType to 1 endif if (GetIsID KIRAInfiltrator1FireXMelee == 1) set GunType to 2 endifEndBegin OnUnequip ;set myself to 0 ;<-------- 2 ------<< 0) set Trick to 1 set FlipType to 2 endif endif if (Trick == 1) myself.AddItem KIRABlankArmor 1 myself.EquipItem KIRABlankArmor myself.RemoveItem KIRABlankArmor 2 set Trick to 0 endif if (FlipType == 1) if (myself.GetItemCount KIRAInfiltrator1FireXMelee > 0) set GunType to 2 set FlipType to 0 myself.EquipItem KIRAInfiltrator1FireXMelee else set GunType to 2 set FlipType to 0 myself.AddItem KIRAInfiltrator1FireXMelee 1 myself.EquipItem KIRAInfiltrator1FireXMelee endif endif if (FlipType == 2) if (myself.GetItemCount KIRAInfiltrator1FireX > 0) set GunType to 1 set FlipType to 0 myself.EquipItem KIRAInfiltrator1FireX else set GunType to 1 set FlipType to 0 myself.AddItem KIRAInfiltrator1FireX 1 myself.EquipItem KIRAInfiltrator1FireX endif endifEnd
While trying to track down a problem of the guns not switching automatically when ammo counts trigger switching, I simplified it (a lot) down to 2 gun variants instead of 3 (left out the mangled model for when damage gets high), and I axed the elseif's that were in there and left the equip messages on. Anyways...
The problem was that the guns would only ever switch the first time after being equipped from inventory, but not any after that no matter what ammo counts were.
The solution was to comment out the OnUnequip statement (#2 arrow).
The reason: Hehe this is great... The game was running TWO copies of this script at the same time during switching. One script was starting on the rifle being equipped, and the previous script still running on the rifle being UNequipped by the other one.
One does not finish before it's replacement begins, and the OnUnequip statement was overriding (as in.. running after) the new guns OnEquip call to GetContainer reference (#1 arrow), which nullified it and put GameMode into a loop.
The code above works perfectly as it is, but uncomment that OnUnequip line and you'll get one weapon change and then nothing.
I never would've guessed that 2 items in the same equip spot, one removing the other to make room for itself, could have a script collision like that :rolleyes: