Jump to content

Need help with enable and disabling a static object.


mougy

Recommended Posts

i am making a display mod. the thing is i want to make a static object only become visible when the displayed object is put in place by the player and become disabled again when it is removed.

 

ex, i want to make a display for summon dwarven mudcrab spell of the creation club and put a static of the dwarven mudcrab above it.

so i want the mudcrab to be enabled when the spell is displayed and disabled when the spell is removed.

 

is there any way to do that?

Link to comment
Share on other sites

It depends on how the initial display that you want to trigger your display is set up as to how you need to approach this.

 

If the player 'places' an item and that item actually gets put into a container while a separate static object gets enabled, then you want to assign that first static object as an enable state parent of your static object. When the first static gets enabled, yours will enable as well.

 

Hope that the original behaves that way as any other method will be harder to tap into.

Link to comment
Share on other sites

thanks for the reply

sadly that didn't work.

 

the displayed item is an Xmarker where the item will be put. i am using this script from anniversary edition.

 

 

scriptname defaultDisplayUniqueItemScript extends ObjectReference

Actor property PlayerRef auto

Armor property optArmorToDisplay auto
{ Choose one 'opt' property to fill. The Armor to display. }
Weapon property optWeaponToDisplay auto
{ Choose one 'opt' property to fill. The Weapon to display. }
MiscObject property optMiscObjectToDisplay auto
{ Choose one 'opt' property to fill. The MiscObject to display. }
Book property optBookToDisplay auto
{ Choose one 'opt' property to fill. The Book to display. }
Potion property optPotionToDisplay auto
{ Choose one 'opt' property to fill. The Potion to display. }
Ingredient property optIngredientToDisplay auto
{ Choose one 'opt' property to fill. The Ingredient to display. }
soulgem property optsoulgemToDisplay auto
{ Choose one 'opt' property to fill. The soulgem to display. }
ammo property optammoToDisplay auto
{ Choose one 'opt' property to fill. The ammo to display. }


Message property ItemNotInInventoryMessage auto
{ The message to display if the item is not in the player's inventory. }

Keyword property LinkedMarkerKeyword auto
{ The keyword of the linked marker reference. }


Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
Form itemToDisplay = GetDisplayItem()

if PlayerRef.GetItemCount(itemToDisplay) > 0
; If the player has the item, place it.
DisplayItem(itemToDisplay)
else
; If the player doesn't have the item, and
; it's not already on display, show an error.
if !IsItemOnDisplay(itemToDisplay)
ItemNotInInventoryMessage.Show()
endif
endif
endif
EndEvent

function DisplayItem(Form akItem)
ObjectReference theItem = PlayerRef.DropObject(akItem)
theItem.BlockActivation()
PositionItemAndDisablePhysics(theItem)
theItem.BlockActivation(false)
endFunction

function PositionItemAndDisablePhysics(ObjectReference akItemOnDisplayRef)
if akItemOnDisplayRef
while !akItemOnDisplayRef.Is3DLoaded()
Utility.Wait(0.1)
endWhile

akItemOnDisplayRef.SetMotionType(Motion_Keyframed, false)
ObjectReference triggerMarker = GetLinkedRef(LinkedMarkerKeyword)
akItemOnDisplayRef.MoveTo(triggerMarker)
endif
endFunction

Form function GetDisplayItem()
if optArmorToDisplay
return optArmorToDisplay
elseif optWeaponToDisplay
return optWeaponToDisplay
elseif optMiscObjectToDisplay
return optMiscObjectToDisplay
elseif optBookToDisplay
return optBookToDisplay
elseif optPotionToDisplay
return optPotionToDisplay
elseif optIngredientToDisplay
return optIngredientToDisplay
elseif optSoulgemToDisplay
return optSoulgemToDisplay
elseif optammoToDisplay
return optammoToDisplay

endif
endFunction

bool function IsItemOnDisplay(Form akItem)
return Game.FindClosestReferenceOfTypeFromRef(akItem, GetLinkedRef(LinkedMarkerKeyword), 32.0)
endFunction

 

 

when i added this line to the script

self.getLinkedRef().enable()
it kinda worked but only when putting the display not when i remove it.
Edited by mougy
Link to comment
Share on other sites

So that script works more like a weapon rack where it shows the actual item as opposed to a pre-placed static as can be seen in most of the Legacy of the Dragonborn mod.

 

Then what you will need to do is add the line that you did for enabling your object. Then create a separate quest that will have a player alias record. The player alias will contain a script that will use the OnItemAdded event to catch when the object is added to inventory. A check to see if the first display is disabled (remotely run the xMarker's IsItemOnDisplay function) and if it is then disable yours. And if you do not want to edit scripts from another mod, use the OnItemRemoved event with a check to see if the first display is enabled and if it is enable yours (may need to register for a single update and check again after a few seconds in case script parsing of the other mod takes longer). Using an inventory event filter to prevent the OnItemAdded and OnItemRemoved events from running for every item added to or removed from the player would be a good idea.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...