Jump to content

[LE] Activate LinkedRef Trigger ONLY if Player Has Specific Item


jucoking

Recommended Posts

I have been trying for days to get this to work using a "defaultactivateLinkOnce" triggerbox with no luck. What I'm trying to accomplish is getting a retractable staircase to activate via the triggerbox ONLY if the player has a specific item. The whole scenario works perfectly other than the fact I am unsure how to tack on the requirement of the item in question. I've been decent at getting my scripts to do what I want thus far, but I'm still a beginner. Please help!

Link to comment
Share on other sites

You will probably need to use a custom script rather than a stock script. You could use a stock script as a starting point, however.

 

You need to use GetItemCount to check the player's inventory for your item prior to telling the linked ref to activate.

That's the whole problem...I'm not sure what script will activate a linked ref. I did get as far as the GetItemCount part, but the way the default trigger scripts activate linked refs is complicated and I can't understand it as of yet.

Link to comment
Share on other sites

Eureka. I just added an "If" condition to the existing default script. Here is what it looks like:

{Default script intended for triggers.  When hit, they'll activate their linked reference}

import game
import debug

objectReference property OnlyActor auto
{Set this property if you want to only allow activation from a specific actor, such as the player}

bool property doOnce auto
{by default, this trigger fires once only.}

Actor Property PlayerRef Auto

Key Property CV2_WhiteCrystalKey Auto

function ActivateNow(objectReference trigRef)
    If PlayerRef.GetItemCount(CV2_WhiteCrystalKey) == 1
;     Debug.Trace("Activating: " + self + " " + myLink)
    objectReference myLink = getLinkedRef()

    self.activate(self, true)
    if MyLink != NONE
        myLink.activate(self as objectReference)    
    endif
    if doOnce == true
        gotoState("allDone")
    endif
    EndIf
endFunction

auto STATE waiting
    EVENT onTriggerEnter(objectReference actronaut)
;     Debug.Trace("Trigger Enter: " + actronaut)
            
        if !onlyActor
            activateNow(actronaut)
        endif
        
        if onlyActor == actronaut
            activateNow(actronaut)
        endif
        
    endEVENT
endSTATE

STATE allDone
;do nothing
endSTATE
   

So glad this is out of the way now. Thanks for all your help, Ishara, especially the intention to go further. It is much appreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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