A script to enable disable a Camp when NPC ented leaves

Post » Sat Nov 02, 2013 5:58 pm

Hey gang. I cobbled together a script based on some vanilla script assets.

The intent is to have the caravan camp appear (enable) when the caravan leader enters a defaultactivateselfTrigger, disappear when the caravan leader leaves the triggerbox.

The actor is set to the caravan leader.

the Linkref is set to the campenable marker which is initially disabled.

All camp tents, etc are enable parented to the marker.

It compiles, and I have the properties set.

I don't think it is working.

Does anyone see any obvious reasons why?

Thanks for all help.

Spoiler

Scriptname DKRActorDisablesixitEnablesEnter extends ObjectReference
{Disables LinkedRef on specified NPC exit, and re-enables it on enter.}



Event onTriggerEnter(ObjectReference triggerRef)
myLinkedRef = GetLinkedRef() as ObjectReference
Actor actorRef = triggerRef as Actor
if (triggerRef == myActor)
myLinkedRef.enable(shouldFade)
endif
endEvent



EVENT onTriggerLeave(objectReference triggerRef)
myLinkedRef = GetLinkedRef() as ObjectReference
Actor actorRef = triggerRef as Actor
if (triggerRef == myActor)
myLinkedRef.disable(shouldFade)
endif
endEvent

Actor Property myActor Auto
{This is the actor who triggers.}

ObjectReference Property myLinkedRef Auto

Bool Property shouldFade = TRUE Auto
{Whether the links should fade or not when enabled/disabled. Defaults to TRUE.}

User avatar
Toby Green
 
Posts: 3365
Joined: Sun May 27, 2007 5:27 pm

Post » Sat Nov 02, 2013 11:59 am

It's not working... how?

When you say you set the linked ref, do you mean you filled the property, or did you actually add the linkedref to the trigger reference.

There is no need to have a property to the LinkedRef and use a GetLinkedRef() function to override whatever the property was set to. Also, GetLinkedRef() returns and objectreference so you don't need to cast it to objectreference. (sorry if none of that made sense... think its getting late and my brain cannot explain it properly).

Personally I would do something like this and avoid the actor/object reference properties as they force the objects to be persistent (not good for PC performance). I do not believe that using LinkedRef's causes persistence...

Scriptname _test_testscript extends ObjectReferenceKeyword Property kActorLinkedKW Auto ;when setting up the linked ref, the linked ref to the trigger actor has thisbool Property bFade = True Auto{Whether the links should fade or not when enabled/disabled. Defaults to TRUE.}Event OnTriggerEnter(ObjectReference akTriggerRef)    if akTriggerRef == GetLinkedRef(kActorLinkedKW)        GetLinkedRef().Enable(bFade)    endIfendEventEvent OnTriggerLeave(ObjectReference akTriggerRef)    if akTriggerRef == GetLinkedRef(kActorLinkedKW)        GetLinkedRef().Disable(bFade)    endIfendEvent

You may also find it worthwhile to add debug messages to see when the events are fired.

User avatar
Monika Krzyzak
 
Posts: 3471
Joined: Fri Oct 13, 2006 11:29 pm


Return to V - Skyrim