NPC Inventory Item Enabler?

Post » Thu Jun 21, 2012 12:44 am

I've searched all kinds of ways for an answer but putting it in words for a search is rather hard. So, my apologies if this has already been answered.

Basically what I need is a trigger event on something an NPC is carrying that once you kill him and take the object, a key in this instance, it enables several things to happen.

I've set up an xmarker and tried to make the key enable the marker with "defaultOnActivateEnableScript", "defaultEnableEncLinkedRef" & "defaultActivateToggleLinkedRefOnce" but these aren't working.

There's something missing to make this work but I can't figure it out.

I know I'm close because I set up a key that is in a container, an open container btw, and it triggers a skeleton attack in another part of the mod.

But getting something similar when it is carried by an NPC is different, somehow.

Any help would be appreciated!
User avatar
Sabrina garzotto
 
Posts: 3384
Joined: Fri Dec 29, 2006 4:58 pm

Post » Wed Jun 20, 2012 5:31 pm

ScriptName YourKeyScript extends ObjectReferenceObjectReference Property YourMarkerREF AutoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	If akNewContainer == Game.GetPlayer()		YourMarkerREF.Enable()	EndIfEndEvent 
...will fire when the player takes the key.
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am

Post » Wed Jun 20, 2012 1:23 pm

ScriptName YourKeyScript extends ObjectReference ObjectReference Property YourMarkerREF Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == Game.GetPlayer() YourMarkerREF.Enable() EndIf EndEvent 
...will fire when the player takes the key.

Man, you saved the day with that!

I must have spent 5 hours trying to get the key to enable lol

Let me ask you this please:

I guess that NPCs, and I guess the player too, are considered containers?

What is the "ak" at the beginning of variables? Are there many different variable prefixes?

Thanks again Justin!
User avatar
lydia nekongo
 
Posts: 3403
Joined: Wed Jul 19, 2006 1:04 pm

Post » Wed Jun 20, 2012 9:23 pm

What is the "ak" at the beginning of variables? Are there many different variable prefixes?
No Prob :)

'a' : Argument :: 'i' : Integer :: 'b' : Boolean :: 'f' : Float :: 'r' : Ref :: 'p' : Property?

'afVar' will invariably be a float argument... Not sure about what 'k' and 'p' denote and those are ubiquitous in the native functions' argument names.
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Wed Jun 20, 2012 3:41 pm

Thanks Justin.

I'll get to understand it all more as time goes by.

Speaking of "float"....I'm near the end of creating all the stages for my quest and I'm now wanting to create the finale.

The finale is the murdered family's ghosts are seen floating up into the air after the player steps out of the house.

When I do a search for "float" I always get the mathematical stuff for integers. So I've tried "rising", "flying" and stuff, but nothing to say how to make NPCs float up and away.

I did come across this though:

Import MathFloat XOffset = 100.0*Cos(Game.GetPlayer().GetHeadingANgle(NPC))Float YOffset = 100.0*Sin(Game.GetPlayer().GetHeadingAngle(NPC))Float ZOffset = 200.0Game.GetPlayer().MoveTo(Game.getPlayer(),XoffSet,YOffset,ZOffset)

But I am clueless on Trig and how to set this up for doing what I need.

Do you have any ideas?

Thanks again man, you've been a great help to me :smile:
User avatar
Emma-Jane Merrin
 
Posts: 3477
Joined: Fri Aug 08, 2008 1:52 am

Post » Thu Jun 21, 2012 1:35 am

You shouldn't need trigonometry if the ghosts are to float straight upward.

I tried...
Event OnLoad()	SetMotionType(Motion_Keyframed, False)		While (GetPositionZ() < 30000)		SetPosition(GetPositionX(), GetPositionY(), GetPositionZ() + 1)	EndWhileEndEvent
...and the item moves upward, but blinks. There's bound to be a way, but I'm not sure how.
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Wed Jun 20, 2012 5:17 pm

Is there a reason to set motion type to key framed?

To move them straight up without blinking, use TranslateTo:

TranslateTo(X, Y, Z + 30000, GetAngleX(), GetAngleY(), GetAngleZ(), 100.0)
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Wed Jun 20, 2012 9:46 pm

Right now I have the ghosts all set up in front of the house just waiting to be sent up to the big ole Sovengarde in the sky.

I have each NPC linked to an Xmarker.

Do I include the script on the marker or each of the NPCs?

Or do I put the script on the trigger that turns the NPCs on that is set up right in front of the door on exiting the house?
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Wed Jun 20, 2012 7:41 pm

Is there a reason to set motion type to key framed?

To move them straight up without blinking, use TranslateTo:

TranslateTo(X, Y, Z + 30000, GetAngleX(), GetAngleY(), GetAngleZ(), 100.0)
Until adding that part, the item was falling each time it was moved upward.

TranslateTo(): Whoa, cool! I hadn't seen that function.

Fragginborn: I'd script the actors so you can use the function(s) you need implicitly.
User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm

Post » Wed Jun 20, 2012 11:00 pm

Dudes!

That was awesome!

I walk out of the house, bloody from fighting the house raiders inside, and lo and behold the NPCs were floating up to the sky....er rocks since this is in a cavern :)

What was really cool about it too was that they weren't like mannequins just floating up. They were relaxed and shifting their body weight.

I wish there were a marker for waving goodbye. It would be so befitting!

Now all I gotta do is figure out how to turn it all into a quest :)

Thanks again!
User avatar
REVLUTIN
 
Posts: 3498
Joined: Tue Dec 26, 2006 8:44 pm

Post » Wed Jun 20, 2012 11:35 am

Hey guys!

I've gotten the floating script to work for the finale of the ghost heading off to neverland but I now need a Hagraven within the house to float down.

I've tried all kinds of possible formulas and the one I think SHOULD work doesn't. I mean it works but it works the exact opposite as to what is in the script

Here's what I have:

Scriptname AntreHagFloatDownSCR extends ObjectReference  Event OnLoad()	    TranslateTo(X, Y, Z + 2167, GetAngleX(), GetAngleY(), GetAngleZ(), 100.0)	    While (GetPositionZ() > 2167)			    SetPosition(GetPositionX(), GetPositionY(), GetPositionZ() - 1)	    EndWhileEndEvent

Why would the actor still be rising when it should be falling?

The z position of the floor is 2167 but the hag starts at that z position and I have her placed well above the interior.

With -1 how can she be rising?
User avatar
marina
 
Posts: 3401
Joined: Tue Mar 13, 2007 10:02 pm

Post » Wed Jun 20, 2012 11:55 am

The TranslateTo function is telling her to float up 2167 units. The SetPosition function is telling her to move down until her z position is at 2167. So she is trying to fly up to a position 2167 units above her starting position (and will continue doing so until she reaches that position) while at the same time lowering her z position by 1 every time the SetPosition function is processed.

So either get rid of the TranslateTo function, or only use the TranslateTo function with X, Y, Z being the coordinates you want her to go to.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm

Post » Wed Jun 20, 2012 2:47 pm

Thanks Random

I tried it with the TranslateTo function deleted and it didn't work.

So I changed the TranslateTo function to:

TranslateTo(X + 316,Y + 333,Z + 2167)

The x and y coordinates are where the hag is supposed to be.

But it gives errors that y and z are not defined and speed is not defined. So I added the ,100 part because I really don't know what that is for, and it didn't work. Since the only difference I can tell between the arguments are the spaces before the y an z but that didn't make a difference.

So then I tried this:

Scriptname AntreHagFloatDownSCR extends ObjectReference  Event OnLoad()			While (GetPositionZ() > 2167)							SetPosition(GetPositionX(), GetPositionY(), GetPositionZ() - 1)			EndWhileEndEvent

With this she just pops into place.

What am I missing here? (besides my brain lol)
User avatar
Tyrone Haywood
 
Posts: 3472
Joined: Sun Apr 29, 2007 7:10 am

Post » Wed Jun 20, 2012 10:00 pm

Well, this is just a guess so I have no idea whether or not it's true.

When an NPC gets loaded, it tries to get onto the nearest piece of nav mesh. Usually this is their editor location. But if their editor location does not have nav mesh, then when you enter the cell you will see them somewhere that you hadn't expected. Since you're putting the hagraven somewhere in midair, there's no navmesh and so instead she starts out on the ground.

If so, you should just start her out on the ground and try one of these two scripts:

Spoiler
Event OnCellAttach()	if !(GetDisabled()) && !(IsDead())		MoveTo(Self, 0, 0, 1000)		TranslateTo(X, Y, Z - 1000, GetAngleX(), GetAngleY(), GetAngleZ(), 100)	endifEndEventEvent OnTranslationAlmostComplete()	StopTranslation()EndEvent

Spoiler
Event OnCellAttach()	if !(GetDisabled()) && !(IsDead())		float InitZ = Z		SetMotionType(Motion_Keyframed, False)		MoveTo(Self, 0, 0, 1000)		while (Z > InitZ)			SetPosition(X, Y, Z - 1)		endwhile		SetMotionType(Motion_Dynamic, False)	endifEndEvent
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Wed Jun 20, 2012 10:00 pm

Meh....both scripts won't compile :(

Here's the error message:

Compiling "AntreHagFloatDownSCR"...d:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\AntreHagFloatDownSCR.psc(4,13): GetDisabled is not a function or does not existd:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\AntreHagFloatDownSCR.psc(4,33): IsDead is not a function or does not existNo output generated for AntreHagFloatDownSCR, compilation failed.

I noticed the IsDead function, she should be marked as dead?

I also noticed: InitZ =

It that how variables are declared, er set, in Papyrus?

EDIT:

Nevermind about the dead part, I noticed the ! telling the script it is a NOT.
User avatar
Victoria Vasileva
 
Posts: 3340
Joined: Sat Jul 29, 2006 5:42 pm

Post » Wed Jun 20, 2012 11:10 am

BTW

The hag is activated by a trigger.

So would it be "OnActivate"?
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Thu Jun 21, 2012 12:25 am

OK...I got it now

Here's what worked:

Scriptname AntreHagFloatDownSCR extends ObjectReference  Event OnLoad()			    MoveTo(Self, 0, 0, 1000)			    TranslateTo(X, Y, Z - 1000, GetAngleX(), GetAngleY(), GetAngleZ(), 100)EndEventEvent OnTranslationAlmostComplete()	    StopTranslation()EndEvent

Yet again you save the day...Thank You!!!
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Wed Jun 20, 2012 4:52 pm

Can you tell me what the , 100 element is about in the TranslateTo function is?

:)
User avatar
Samantha hulme
 
Posts: 3373
Joined: Wed Jun 21, 2006 4:22 pm

Post » Wed Jun 20, 2012 5:42 pm

The 100 is speed (units/second). So it should take about 10 seconds for her to finish moving. And yeah, sorry I forgot to check the scripts to see if they worked. The check should have been:

if !(IsDisabled()) && !((Self as Actor).IsDead()) 
User avatar
Marion Geneste
 
Posts: 3566
Joined: Fri Mar 30, 2007 9:21 pm

Post » Thu Jun 21, 2012 12:41 am

Noob,

I figured I wanted to do more with your script...like having her not only coming down but also forward toward the player.

Here's what I came up with:

Scriptname AntreHagFloatDownSCR extends ObjectReference  Event OnLoad()float xa = - 700			    MoveTo(Self,xa, 0, 600)			    TranslateTo(X + 700, Y, Z - 600, GetAngleX(), GetAngleY(), GetAngleZ(), 100)EndEventEvent OnTranslationAlmostComplete()	    StopTranslation()EndEvent

I also created a video of how it all comes together

I'll think you'll enjoy it :)

https://www.youtube.com/watch?v=-K-OO6CpxbM

I promise that once I get to know this stuff better I'll come around these forums to help y'all out.

Thanks again for your great help :)
User avatar
BRIANNA
 
Posts: 3438
Joined: Thu Jan 11, 2007 7:51 pm

Post » Wed Jun 20, 2012 4:57 pm

Man...That youtube link was incorrect

Here's the hag entrance vid

Sorry bout that :/

https://www.youtube.com/watch?v=KRirINXnQqw
User avatar
Rachael Williams
 
Posts: 3373
Joined: Tue Aug 01, 2006 6:43 pm


Return to V - Skyrim