Custom Containers Help (Creating a Shield Rack)

Post » Tue Jan 28, 2014 3:50 am

Before I get started, let me explain exactly what I'm trying to do. I would like to be able to make a custom container that will display the object I am placing in it, just like a bookshelf. I was successfull in creating a potion rack by taking the 3 "playerbookshelf" scripts and replacing the word book with potion (old potion scripts were all buggered). There were a few other things like duplicating all the bookshelf keywords and triggers and renaming them to match the potion scripts but with a little trial and error it all finally worked. Click on the shelf place a potion in and it pops up right there on the shelf. Not so fast said the shield. I can't for the life of me, figure out what is keeping this same method from working on a Shield Rack. I will try to list all my steps as detailed as possible below in hopes that someone knows where my mistake was.

  • First I needed a default shield marker. The books and potions luckily already had one, but there is no substance to them, they are simply base items, referenced to a "Dummy.nif" model. In order to make one for the Shield Rack I extracted "dummyshield01.nif" from the meshes bwa. I then duplicated a standard Ebony Shield, edited the base by removing all data. I left the Items Biped Object listed as shield and kept the playable tab checked. It wouldn't let me drop it in to CK without it. Finally I changed the World Models to "dummyshield01.nif". This created a "DefaultShieldRackShieldMarker" which glowed orange just like the book and potion markers.

  • I then duplicated "PlayerBookShelfContainer", "PlayerBookShelfClickTrigger", and "PlayerBookshelfTrigger" and renamed them with the word "ShieldRack" in place of the word "BookShelf". I now have all 4 pieces required to create my shelf. Even though I have my triggers and containers created I still need quite a few keywords. So I create; "ShieldRackShield01-18","ShieldRackTrigger01-04", "ShieldRackContainer", and "ShieldRackClickTrigger". I created these keywords the same way I created the triggers, containers, and markers - by duplicating the bookshelf variants and renaming them.

  • This Part I'm not completely sure is nessasary but I did it anyways, just incase. By duplicating the bookshelf versions I created, "LItemShieldClutter", "ShieldRackFirstActivateMessage", ShieldRackNoMoreRoomMessage", ShieldRackNotAShieldMessage", "ShieldRackRoomLeftMessage", and Finally "ShieldRackGlobal" That pretty much wraps up the duplication part.

  • Next I needed 3 scripts; "PlayerShieldRackContainerScript", "PlayerShieldRackTriggerSCRIPT" and "PlayerShieldRackClickTriggerSCRIPT" (Note: the caps are important) I opened the scripts with notepad++ and replaced the word bookshelf, and book, with shieldrack and shield throughout each script. The caps are important here too so I search for specified caps. Example: ShieldRack replaces BookShelf, shield replaces book.

  • Now I should have all the components required to create my Shield Rack. For some reason CK wouldn't read the scripts i created to add them to my items so in order to get around that I dragged the originals I created out of the scripts folder and just created a new blank scripts on CK with the same name. After the scripts are created I then copied and pasted the content into them.

Moment of Truth time here. I go to Compile the scripts. "PlayerShieldRackTrigger" success!, "PlayerShieldRackClickTrigger" success!, "PlayerShieldRackContainer" FAILED ><. Go figure... Thats the big script too. I have no typos in that script. It was copied straight from the bookshelf script. Below is the error recieved in the Compiler Output.

Starting 1 compile threads for 1files...Compiling"PlayerShieldRackContainerScript"...C:\Program Files(x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PlayerShieldRackContainerScript.psc(228,16):cannot convert to unknown type shieldC:\Program Files(x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PlayerShieldRackContainerScript.psc(228,16):cannot cast a form to a shield, types are incompatibleC:\Program Files(x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PlayerShieldRackContainerScript.psc(244,16):cannot convert to unknown type shieldC:\Program Files(x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\PlayerShieldRackContainerScript.psc(244,16):cannot cast a form to a shield, types are incompatibleNooutput generated for PlayerShieldRackContainerScript, compilationfailed.Batch compile of 1 files finished. 0 succeeded, 1failed.Failed onPlayerShieldRackContainerScript

(Line 228, and Line 244) seem to be important for what I'm trying to get done. I tested the script in game without those events and the item does go into a container but nothing is displayed. "Types are incompatible" sounds to me like the game just refuses to read shield as a type, though I'm not sure how.. It reads potion and book just fine as a type.

"PlayerShieldRackContainerScript" Is in the clickable spoiler below.

Spoiler
Scriptname PlayerShieldRackContainerScript extends ObjectReferenceimport debugimport utilityForm Property LItemShieldClutter Auto{Clutter item list to fill the shelf with}Keyword Property ShieldRackShield01 AutoKeyword Property ShieldRackShield02 AutoKeyword Property ShieldRackShield03 AutoKeyword Property ShieldRackShield04 AutoKeyword Property ShieldRackShield05 AutoKeyword Property ShieldRackShield06 AutoKeyword Property ShieldRackShield07 AutoKeyword Property ShieldRackShield08 AutoKeyword Property ShieldRackShield09 AutoKeyword Property ShieldRackShield10 AutoKeyword Property ShieldRackShield11 AutoKeyword Property ShieldRackShield12 AutoKeyword Property ShieldRackShield13 AutoKeyword Property ShieldRackShield14 AutoKeyword Property ShieldRackShield15 AutoKeyword Property ShieldRackShield16 AutoKeyword Property ShieldRackShield17 AutoKeyword Property ShieldRackShield18 AutoKeyword Property ShieldRackTrigger01 AutoKeyword Property ShieldRackTrigger02 AutoKeyword Property ShieldRackTrigger03 AutoKeyword Property ShieldRackTrigger04 Auto{List of required Keywords}ObjectReference Property ShieldMarker01 Auto HiddenObjectReference Property ShieldMarker02 Auto HiddenObjectReference Property ShieldMarker03 Auto HiddenObjectReference Property ShieldMarker04 Auto HiddenObjectReference Property ShieldMarker05 Auto HiddenObjectReference Property ShieldMarker06 Auto HiddenObjectReference Property ShieldMarker07 Auto HiddenObjectReference Property ShieldMarker08 Auto HiddenObjectReference Property ShieldMarker09 Auto HiddenObjectReference Property ShieldMarker10 Auto HiddenObjectReference Property ShieldMarker11 Auto HiddenObjectReference Property ShieldMarker12 Auto HiddenObjectReference Property ShieldMarker13 Auto HiddenObjectReference Property ShieldMarker14 Auto HiddenObjectReference Property ShieldMarker15 Auto HiddenObjectReference Property ShieldMarker16 Auto HiddenObjectReference Property ShieldMarker17 Auto HiddenObjectReference Property ShieldMarker18 Auto HiddenObjectReference Property ShieldRackTrigger01Ref Auto HiddenObjectReference Property ShieldRackTrigger02Ref Auto HiddenObjectReference Property ShieldRackTrigger03Ref Auto HiddenObjectReference Property ShieldRackTrigger04Ref Auto HiddenInt Property MaxShieldsAllowed Auto Hidden{Max shields allowed on this partciular shelf}Int Property CurrentShieldAmount Auto Hidden{The current amount of shields placed on the shelf}Form Property EmptyForm Auto Hidden{Null Form}ObjectReference Property EmptyRef Auto Hidden{Null Ref}Form Property CurrentShieldForm Auto Hidden{Shield Form we are working with at any one time}ObjectReference Property CurrentShieldRef Auto Hidden{Shield Ref we are working with at any one time}Form Property PlacedShield01 Auto HiddenForm Property PlacedShield02 Auto HiddenForm Property PlacedShield03 Auto HiddenForm Property PlacedShield04 Auto HiddenForm Property PlacedShield05 Auto HiddenForm Property PlacedShield06 Auto HiddenForm Property PlacedShield07 Auto HiddenForm Property PlacedShield08 Auto HiddenForm Property PlacedShield09 Auto HiddenForm Property PlacedShield10 Auto HiddenForm Property PlacedShield11 Auto HiddenForm Property PlacedShield12 Auto HiddenForm Property PlacedShield13 Auto HiddenForm Property PlacedShield14 Auto HiddenForm Property PlacedShield15 Auto HiddenForm Property PlacedShield17 Auto HiddenForm Property PlacedShield16 Auto HiddenForm Property PlacedShield18 Auto Hidden{List of Placed Shield Forms}ObjectReference Property PlacedShield01Ref Auto HiddenObjectReference Property PlacedShield02Ref Auto HiddenObjectReference Property PlacedShield03Ref Auto HiddenObjectReference Property PlacedShield04Ref Auto HiddenObjectReference Property PlacedShield05Ref Auto HiddenObjectReference Property PlacedShield06Ref Auto HiddenObjectReference Property PlacedShield07Ref Auto HiddenObjectReference Property PlacedShield08Ref Auto HiddenObjectReference Property PlacedShield09Ref Auto HiddenObjectReference Property PlacedShield10Ref Auto HiddenObjectReference Property PlacedShield11Ref Auto HiddenObjectReference Property PlacedShield12Ref Auto HiddenObjectReference Property PlacedShield13Ref Auto HiddenObjectReference Property PlacedShield14Ref Auto HiddenObjectReference Property PlacedShield15Ref Auto HiddenObjectReference Property PlacedShield17Ref Auto HiddenObjectReference Property PlacedShield16Ref Auto HiddenObjectReference Property PlacedShield18Ref Auto Hidden{List of Placed Shield Refs}Bool Property AlreadyLoaded = FALSE Auto Hidden{Whether this scritp has already went through it's OnCellLoad() Event}Bool Property BlockShields = FALSE Auto Hidden{Used for when you can't place any more shields}Message Property ShieldRackFirstActivateMESSAGE Auto{Display message when the player activates a shieldrack for the first time.  Only displays once.}Message Property ShieldRackNoMoreRoomMESSAGE Auto{Displayed message for when the amount of shields the player is placing excedes the shelf limit.}Message Property ShieldRackNotAShieldMESSAGE Auto{Message displayed when the player places a non shield form in the container.}Message Property ShieldRackRoomLeftMESSAGE Auto{Notification that tells the player how much room is left on the shelf upon first activating it.}GlobalVariable Property ShieldRackGlobal Auto{Global showing whether or not the player has ever activated a shieldrack}EVENT OnCellLoad() if AlreadyLoaded == FALSE  ;Trace("SHIELDCASE - Running OnCellLoad()")  ; Get all the shield markers  ShieldMarker01 = GetLinkedRef(ShieldRackShield01)  ShieldMarker02 = GetLinkedRef(ShieldRackShield02)  ShieldMarker03 = GetLinkedRef(ShieldRackShield03)  ShieldMarker04 = GetLinkedRef(ShieldRackShield04)  ShieldMarker05 = GetLinkedRef(ShieldRackShield05)  ShieldMarker06 = GetLinkedRef(ShieldRackShield06)  ShieldMarker07 = GetLinkedRef(ShieldRackShield07)  ShieldMarker08 = GetLinkedRef(ShieldRackShield08)  ShieldMarker09 = GetLinkedRef(ShieldRackShield09)  ShieldMarker10 = GetLinkedRef(ShieldRackShield10)  ShieldMarker11 = GetLinkedRef(ShieldRackShield11)  ShieldMarker12 = GetLinkedRef(ShieldRackShield12)  ShieldMarker13 = GetLinkedRef(ShieldRackShield13)  ShieldMarker14 = GetLinkedRef(ShieldRackShield14)  ShieldMarker15 = GetLinkedRef(ShieldRackShield15)  ShieldMarker16 = GetLinkedRef(ShieldRackShield16)  ShieldMarker17 = GetLinkedRef(ShieldRackShield17)  ShieldMarker18 = GetLinkedRef(ShieldRackShield18)  ShieldRackTrigger01Ref = (GetLinkedRef(ShieldRackTrigger01) as PlayerShieldRackTriggerSCRIPT)  ShieldRackTrigger02Ref = (GetLinkedRef(ShieldRackTrigger02) as PlayerShieldRackTriggerSCRIPT)  ShieldRackTrigger03Ref = (GetLinkedRef(ShieldRackTrigger03) as PlayerShieldRackTriggerSCRIPT)  ShieldRackTrigger04Ref = (GetLinkedRef(ShieldRackTrigger04) as PlayerShieldRackTriggerSCRIPT)  ; Count how many shields can be placed on this shelf  CountMaxShields()  AlreadyLoaded = TRUE endifendEVENTEVENT OnActivate(ObjectReference akActionRef) ; Removing all items from container as a precaution ;Trace("SHIELDCASE - I've been ACTIVATED!") BlockActivate() ;Trace("SHIELDCASE - Blocking activate on all shields") ;Trace("SHIELDCASE - ShieldRackTrigger01Ref = " + ShieldRackTrigger01Ref) ShieldRackRoomLeftMESSAGE.Show((MaxShieldsAllowed - CurrentShieldAmount)) ;debug.Notification("You can place " + (MaxShieldsAllowed - CurrentShieldAmount) + " more shields on this shelf.") if (ShieldRackGlobal.GetValue() == 0)  ShieldRackFirstActivateMESSAGE.Show()  ShieldRackGlobal.SetValue(1) endif ;CurrentShieldAmount = 0 if ShieldRackTrigger01Ref  ;Trace("SHIELDCASE - Setting FIRST trigger to GoToState IgnoreShields")  ShieldRackTrigger01Ref.GoToState("IgnoreShields") endif if ShieldRackTrigger02Ref  ;Trace("SHIELDCASE - Setting SECOND trigger to GoToState IgnoreShields")  ShieldRackTrigger02Ref.GoToState("IgnoreShields") endif if ShieldRackTrigger03Ref  ;Trace("SHIELDCASE - Setting THIRD trigger to GoToState IgnoreShields")  ShieldRackTrigger03Ref.GoToState("IgnoreShields") endif if ShieldRackTrigger04Ref  ;Trace("SHIELDCASE - Setting FOURTH trigger to GoToState IgnoreShields")  ShieldRackTrigger04Ref.GoToState("IgnoreShields") endif Wait(0.25) ; The following will fire when the player leaves inventory ;Trace("SHIELDCASE - Out of Inventory so placing all the shields") UpdateShields() if ShieldRackTrigger01Ref  ;Trace("SHIELDCASE - Setting FIRST trigger to GoToState WaitForShields")  ShieldRackTrigger01Ref.GoToState("WaitForShields") endif if ShieldRackTrigger02Ref  ;Trace("SHIELDCASE - Setting SECOND trigger to GoToState WaitForShields")  ShieldRackTrigger02Ref.GoToState("WaitForShields") endif if ShieldRackTrigger03Ref  ;Trace("SHIELDCASE - Setting THIRD trigger to GoToState WaitForShields")  ShieldRackTrigger03Ref.GoToState("WaitForShields") endif if ShieldRackTrigger04Ref  ;Trace("SHIELDCASE - Setting FOURTH trigger to GoToState WaitForShields")  ShieldRackTrigger04Ref.GoToState("WaitForShields") endifendEVENTEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) if (akBaseItem as Shield)  if BlockShields == FALSE   ; If the item is a shield find the corresponding shield reference and remove it.   ;Trace("SHIELDCASE - Form being Removed " + akBaseItem + " is a Shield! Remove it from the list")   RemoveShields(akBaseItem, aiItemCount)   CurrentShieldAmount = CurrentShieldAmount - aiItemCount  else   BlockShields = FALSE  endif endifendEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ;Trace("SHIELDCASE - Adding " + akBaseItem + " to the Shield Container")  if (akBaseItem as Shield)  ; If the item being added is a shield then check to see if there is room in on the shelf.  ;Trace("SHIELDCASE - Form being Added " + akBaseItem + " is a Shield!")  if ((aiItemCount + CurrentShieldAmount) <= MaxShieldsAllowed)   ; There's room on teh shelf, manage the shield placement   ;Trace("SHIELDCASE - " + CurrentShieldAmount + "/" + MaxShieldsAllowed + " There is room for another shield, lets place it on the shelf.")   AddShields(akBaseItem, aiItemCount)   CurrentShieldAmount = CurrentShieldAmount + aiItemCount  else   ; There is no room on the shelf.  Tell the player this and give him his shield back.   ;Trace("SHIELDCASE - " + CurrentShieldAmount + "/" + MaxShieldsAllowed + " There's no more room for shields on this shelf.")   utility.waitMenuMode(0)   ;MessageBox("You can't place that many shields on this shelf")   ShieldRackNoMoreRoomMESSAGE.Show()   ;Trace("SHIELDCASE - Remove it from this container...")   BlockShields = TRUE   self.RemoveItem(akBaseItem, aiItemCount, true, Game.GetPlayer())   ;Trace("SHIELDCASE - ...and give it back to the player")  endif else  ; The item placed in the container isn't a shield, so give the player back and tell him only shields are allowed.  ;Trace("SHIELDCASE - Form " + akBaseItem + " is NOT a Shield!")  ;Trace("SHIELDCASE - Since the placed item wasn't a shield remove it from the container...")  self.RemoveItem(akBaseItem, aiItemCount, true, Game.GetPlayer())  ;Trace("SHIELDCASE - ...and give it back to the player")  ;(Game.GetPlayer()).AddItem(akBaseItem, aiItemCount, True)  utility.WaitMenuMode(0)  ;MessageBox("You can only place shields on this shelf")  ShieldRackNotAShieldMESSAGE.Show() endif endEventFunction BlockActivate() if Placedshield01Ref  PlacedShield01Ref.BlockActivation(TRUE) endif if Placedshield02Ref  PlacedShield02Ref.BlockActivation(TRUE) endif if Placedshield03Ref  PlacedShield03Ref.BlockActivation(TRUE) endif if Placedshield04Ref  PlacedShield04Ref.BlockActivation(TRUE) endif if Placedshield05Ref  PlacedShield05Ref.BlockActivation(TRUE) endif if Placedshield06Ref  PlacedShield06Ref.BlockActivation(TRUE) endif if Placedshield07Ref  PlacedShield07Ref.BlockActivation(TRUE) endif if Placedshield08Ref  PlacedShield08Ref.BlockActivation(TRUE) endif if Placedshield09Ref  PlacedShield09Ref.BlockActivation(TRUE) endif if Placedshield10Ref  PlacedShield10Ref.BlockActivation(TRUE) endif if Placedshield11Ref  PlacedShield11Ref.BlockActivation(TRUE) endif if Placedshield12Ref  PlacedShield12Ref.BlockActivation(TRUE) endif if Placedshield13Ref  PlacedShield13Ref.BlockActivation(TRUE) endif if Placedshield14Ref  PlacedShield14Ref.BlockActivation(TRUE) endif if Placedshield15Ref  PlacedShield15Ref.BlockActivation(TRUE) endif if Placedshield16Ref  PlacedShield16Ref.BlockActivation(TRUE) endif if Placedshield17Ref  PlacedShield17Ref.BlockActivation(TRUE) endif if Placedshield18Ref  PlacedShield18Ref.BlockActivation(TRUE) endif ;Trace("SHIELDCASE - All shield activation has been blocked")endFunctionFunction UnBlockActivate() if Placedshield01Ref  PlacedShield01Ref.BlockActivation(FALSE) endif if Placedshield02Ref  PlacedShield02Ref.BlockActivation(FALSE) endif if Placedshield03Ref  PlacedShield03Ref.BlockActivation(FALSE) endif if Placedshield04Ref  PlacedShield04Ref.BlockActivation(FALSE) endif if Placedshield05Ref  PlacedShield05Ref.BlockActivation(FALSE) endif if Placedshield06Ref  PlacedShield06Ref.BlockActivation(FALSE) endif if Placedshield07Ref  PlacedShield07Ref.BlockActivation(FALSE) endif if Placedshield08Ref  PlacedShield08Ref.BlockActivation(FALSE) endif if Placedshield09Ref  PlacedShield09Ref.BlockActivation(FALSE) endif if Placedshield10Ref  PlacedShield10Ref.BlockActivation(FALSE) endif if Placedshield11Ref  PlacedShield11Ref.BlockActivation(FALSE) endif if Placedshield12Ref  PlacedShield12Ref.BlockActivation(FALSE) endif if Placedshield13Ref  PlacedShield13Ref.BlockActivation(FALSE) endif if Placedshield14Ref  PlacedShield14Ref.BlockActivation(FALSE) endif if Placedshield15Ref  PlacedShield15Ref.BlockActivation(FALSE) endif if Placedshield16Ref  PlacedShield16Ref.BlockActivation(FALSE) endif if Placedshield17Ref  PlacedShield17Ref.BlockActivation(FALSE) endif if Placedshield18Ref  PlacedShield18Ref.BlockActivation(FALSE) endif ;Trace("SHIELDCASE - All shield activation has been UNblocked")endFunctionFunction RemoveShields(Form ShieldBase, Int ShieldAmount) ; Find an empty shield form and place the new shield there While ShieldAmount > 0  if PlacedShield01 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield01 matches, Removing this shield")   PlacedShield01 = EmptyForm  elseif PlacedShield02 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield02 matches, Removing this shield")   PlacedShield02 = EmptyForm  elseif PlacedShield03 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield03 matches, Removing this shield")   PlacedShield03 = EmptyForm  elseif PlacedShield04 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield04 matches, Removing this shield")   PlacedShield04 = EmptyForm  elseif PlacedShield05 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield05 matches, Removing this shield")   PlacedShield05 = EmptyForm  elseif PlacedShield06 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield06 matches, Removing this shield")   PlacedShield06 = EmptyForm  elseif PlacedShield07 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield07 matches, Removing this shield")   PlacedShield07 = EmptyForm  elseif PlacedShield08 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield08 matches, Removing this shield")   PlacedShield08 = EmptyForm  elseif PlacedShield09 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield09 matches, Removing this shield")   PlacedShield09 = EmptyForm  elseif PlacedShield10 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield10 matches, Removing this shield")   PlacedShield10 = EmptyForm  elseif PlacedShield11 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield11 matches, Removing this shield")   PlacedShield11 = EmptyForm  elseif PlacedShield12 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield12 matches, Removing this shield")   PlacedShield12 = EmptyForm  elseif PlacedShield13 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield13 matches, Removing this shield")   PlacedShield13 = EmptyForm  elseif PlacedShield14 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield14 matches, Removing this shield")   PlacedShield14 = EmptyForm  elseif PlacedShield15 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield15 matches, Removing this shield")   PlacedShield15 = EmptyForm  elseif PlacedShield16 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield16 matches, Removing this shield")   PlacedShield16 = EmptyForm  elseif PlacedShield17 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield17 matches, Removing this shield")   PlacedShield17 = EmptyForm  elseif PlacedShield18 == ShieldBase   ;Trace("SHIELDCASE - PlacedShield18 matches, Removing this shield")   PlacedShield18 = EmptyForm  endif     ShieldAmount = ShieldAmount - 1 endWhileendFunctionFunction AddShields(Form ShieldBase, Int ShieldAmount) ; Find an empty shield form and place the new shield there While ShieldAmount > 0  if PlacedShield01 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield01 is empty, placing shield there")   PlacedShield01 = ShieldBase  elseif PlacedShield02 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield02 is empty, placing shield there")   PlacedShield02 = ShieldBase  elseif PlacedShield03 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield03 is empty, placing shield there")   PlacedShield03 = ShieldBase  elseif PlacedShield04 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield04 is empty, placing shield there")   PlacedShield04 = ShieldBase  elseif PlacedShield05 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield05 is empty, placing shield there")   PlacedShield05 = ShieldBase  elseif PlacedShield06 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield06 is empty, placing shield there")   PlacedShield06 = ShieldBase  elseif PlacedShield07 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield07 is empty, placing shield there")   PlacedShield07 = ShieldBase  elseif PlacedShield08 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield08 is empty, placing shield there")   PlacedShield08 = ShieldBase  elseif PlacedShield09 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield09 is empty, placing shield there")   PlacedShield09 = ShieldBase  elseif PlacedShield10 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield10 is empty, placing shield there")   PlacedShield10 = ShieldBase  elseif PlacedShield11 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield11 is empty, placing shield there")   PlacedShield11 = ShieldBase  elseif PlacedShield12 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield12 is empty, placing shield there")   PlacedShield12 = ShieldBase  elseif PlacedShield13 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield13 is empty, placing shield there")   PlacedShield13 = ShieldBase  elseif PlacedShield14 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield14 is empty, placing shield there")   PlacedShield14 = ShieldBase  elseif PlacedShield15 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield15 is empty, placing shield there")   PlacedShield15 = ShieldBase  elseif PlacedShield16 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield16 is empty, placing shield there")   PlacedShield16 = ShieldBase  elseif PlacedShield17 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield17 is empty, placing shield there")   PlacedShield17 = ShieldBase  elseif PlacedShield18 == EmptyForm   ;Trace("SHIELDCASE - PlacedShield18 is empty, placing shield there")   PlacedShield18 = ShieldBase  endif       ShieldAmount = ShieldAmount - 1 endWhileendFunctionFunction CountMaxShields() ; Checks how many shields can be placed on this shelf if ShieldMarker01 == EmptyRef  MaxShieldsAllowed = 0 elseif ShieldMarker02 == EmptyRef  MaxShieldsAllowed = 1 elseif ShieldMarker03 == EmptyRef  MaxShieldsAllowed = 2 elseif ShieldMarker04 == EmptyRef  MaxShieldsAllowed = 3 elseif ShieldMarker05 == EmptyRef  MaxShieldsAllowed = 4 elseif ShieldMarker06 == EmptyRef  MaxShieldsAllowed = 5 elseif ShieldMarker07 == EmptyRef  MaxShieldsAllowed = 6 elseif ShieldMarker08 == EmptyRef  MaxShieldsAllowed = 7 elseif ShieldMarker09 == EmptyRef  MaxShieldsAllowed = 8 elseif ShieldMarker10 == EmptyRef  MaxShieldsAllowed = 9 elseif ShieldMarker11 == EmptyRef  MaxShieldsAllowed = 10 elseif ShieldMarker12 == EmptyRef  MaxShieldsAllowed = 11 elseif ShieldMarker13 == EmptyRef  MaxShieldsAllowed = 12 elseif ShieldMarker14 == EmptyRef  MaxShieldsAllowed = 13 elseif ShieldMarker15 == EmptyRef  MaxShieldsAllowed = 14 elseif ShieldMarker16 == EmptyRef  MaxShieldsAllowed = 15 elseif ShieldMarker17 == EmptyRef  MaxShieldsAllowed = 16 elseif ShieldMarker18 == EmptyRef  MaxShieldsAllowed = 17 elseif ShieldMarker18  MaxShieldsAllowed = 18 endif ;Trace("SHIELDCASE - " + MaxShieldsAllowed + " shields can be placed on this shelf")endFunctionObjectReference Function UpdateSingleShield(Form TargetShield, ObjectReference PlacedShieldRef, ObjectReference TargetMarker) ObjectReference retVal ; We return the shield we placed (or None) ; Note - it would be more efficient to move the shield to its home position if the desired ; shield matches the placed shield, but MoveTo doesn't work correctly with multi-part dynamic ; objects. So we sidestep the issue by always deleting and placing if PlacedShieldRef  PlacedShieldRef.Disable()  PlacedShieldRef.Delete() endIf if TargetShield  retVal = TargetMarker.PlaceAtMe(TargetShield)  retVal.BlockActivation() endIf return retValEndFunctionFunction UpdateShields() GoToState("PlacingShields") ; Future calls should not mess with this stuff  PlacedShield01Ref = UpdateSingleShield(PlacedShield01, PlacedShield01Ref, ShieldMarker01) PlacedShield02Ref = UpdateSingleShield(PlacedShield02, PlacedShield02Ref, ShieldMarker02) PlacedShield03Ref = UpdateSingleShield(PlacedShield03, PlacedShield03Ref, ShieldMarker03) PlacedShield04Ref = UpdateSingleShield(PlacedShield04, PlacedShield04Ref, ShieldMarker04) PlacedShield05Ref = UpdateSingleShield(PlacedShield05, PlacedShield05Ref, ShieldMarker05)  PlacedShield06Ref = UpdateSingleShield(PlacedShield06, PlacedShield06Ref, ShieldMarker06) PlacedShield07Ref = UpdateSingleShield(PlacedShield07, PlacedShield07Ref, ShieldMarker07) PlacedShield08Ref = UpdateSingleShield(PlacedShield08, PlacedShield08Ref, ShieldMarker08) PlacedShield09Ref = UpdateSingleShield(PlacedShield09, PlacedShield09Ref, ShieldMarker09) PlacedShield10Ref = UpdateSingleShield(PlacedShield10, PlacedShield10Ref, ShieldMarker10)  PlacedShield11Ref = UpdateSingleShield(PlacedShield11, PlacedShield11Ref, ShieldMarker11) PlacedShield12Ref = UpdateSingleShield(PlacedShield12, PlacedShield12Ref, ShieldMarker12) PlacedShield13Ref = UpdateSingleShield(PlacedShield13, PlacedShield13Ref, ShieldMarker13) PlacedShield14Ref = UpdateSingleShield(PlacedShield14, PlacedShield14Ref, ShieldMarker14) PlacedShield15Ref = UpdateSingleShield(PlacedShield15, PlacedShield15Ref, ShieldMarker15)  PlacedShield16Ref = UpdateSingleShield(PlacedShield16, PlacedShield16Ref, ShieldMarker16) PlacedShield17Ref = UpdateSingleShield(PlacedShield17, PlacedShield17Ref, ShieldMarker17) PlacedShield18Ref = UpdateSingleShield(PlacedShield18, PlacedShield18Ref, ShieldMarker18)  UnBlockActivate() ; Allow the player to mess with them GoToState("") ; Now allow shields to be updated againEndFunctionState PlacingShields Function UpdateShields()  ; Already updating shields, so ignore EndFunctionEndState
User avatar
Anna Watts
 
Posts: 3476
Joined: Sat Jun 17, 2006 8:31 pm

Return to V - Skyrim