X Distance From Maker Script Help?

Post » Thu Jun 21, 2012 3:13 pm

I'm trying to set up an xMarker that detects how far the player is and when the player gets within X units starts a quest and sets its stage.

But what I am doing isn't working.

Will someone please debug this for me?

To me it looks like it should work....

Spoiler

Scriptname LBGDetectPlayerAtEntrance extends ObjectReference

Actor Property Player Auto

Quest Property LBGQuest Auto
{Name of quest to start}

Quest Property LBGQuestStage Auto
{Stage to set to}

int Property DistanceFromPlayer Auto
{Distance to the player sets trigger}


auto State IsPlayerWithinDistance
Event OnUpdate()

if GetDistance(Player) < DistanceFromPlayer
LBGQuest.Start()
LBGQuest.SetStage(LBGQuestStage)

endif

endEvent
endState

Thanks for any and all help :)
User avatar
victoria johnstone
 
Posts: 3424
Joined: Sat Oct 14, 2006 9:56 am

Post » Fri Jun 22, 2012 4:46 am

Why not do a comparison of positions? A little mapth to find the absolute values of your position vs the markers position.

Alternativly, why not just use an activation bounding box to make a "wall" that when crossed, it starts the quest.
User avatar
Claire Jackson
 
Posts: 3422
Joined: Thu Jul 20, 2006 11:38 pm

Post » Thu Jun 21, 2012 6:01 pm

One problem with my script is the property "Quest Property LBGQuestStage Auto"

It should be an integer "int Property LBGQuestStage Auto"

But it still does not start the quest when the player is X units away from the Marker
User avatar
NAtIVe GOddess
 
Posts: 3348
Joined: Tue Aug 15, 2006 6:46 am

Post » Thu Jun 21, 2012 1:54 pm

Why not do a comparison of positions? A little mapth to find the absolute values of your position vs the markers position.

Alternativly, why not just use an activation bounding box to make a "wall" that when crossed, it starts the quest.

Doing a mathematica comparison would be a lot harder to do than use the xMarker as a reference. Not only that, when I do a script I want to do it in such a way that I may be able to use it elsewhere. If I hard-code coordinates or something then it's a one shot deal.


As for a trigger...I already have a couple triggers. Trying to keep track of triggers, particularly one that would have to stretch such a long distance, would be harder to edit the whole area as I add and change quests (this is the entrance to the mod where a lot of quests will eventually be part of.

Thanks for your input though :)
User avatar
FirDaus LOVe farhana
 
Posts: 3369
Joined: Thu Sep 13, 2007 3:42 am

Post » Fri Jun 22, 2012 1:21 am

What is "DistanceFromPlayer" set to by default? 0? So you are checking if the player is less then 0 from the marker?

The problem with Papyrus is we cant see what properties are from the script alone...
User avatar
Albert Wesker
 
Posts: 3499
Joined: Fri May 11, 2007 11:17 pm

Post » Thu Jun 21, 2012 6:15 pm

I suspect your event needs a GotoState("") before the endif, and maybe RegisterForSingleUpdate() call after the endif. Have you called RegisterForSingleUpdate() for it elsewhere, or RegisterForUpdate()?
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Thu Jun 21, 2012 10:20 pm

What is "DistanceFromPlayer" set to by default? 0? So you are checking if the player is less then 0 from the marker?

The problem with Papyrus is we cant see what properties are from the script alone...

I guess I can change that line to this:

int Property DistanceFromPlayer = 1000 Auto

Which still doesn't set the stage either :(
User avatar
Darrell Fawcett
 
Posts: 3336
Joined: Tue May 22, 2007 12:16 am

Post » Thu Jun 21, 2012 5:05 pm

I suspect your event needs a GotoState("") before the endif, and maybe RegisterForSingleUpdate() call after the endif. Have you called RegisterForSingleUpdate() for it elsewhere, or RegisterForUpdate()?

Actually, what I've done is take one of your scripts (LBG30DetectPlayerMarkerScript) and I'm trying to make it conform to just getting the distance from the player, starting the TriggerQuest and setting its stage to 0.

Then I'll add some conditionals to ensure it only trips once.
User avatar
Justin
 
Posts: 3409
Joined: Sun Sep 23, 2007 12:32 am

Post » Thu Jun 21, 2012 8:07 pm

You don't need conditionals to make it trip only once, you just need to put GotoState("") immediately after if GetDistance(Player) < DistanceFromPlayer. (You could also put code to disable and delete the marker after setting the stage, if you won't be using it again.)

But something has to call YourMarker.RegisterForSIngleUpdate() in the first place, or the OnUpdate event that you are writing will never fire. (And unless you put another RegisterForSIngleUpdate() after the endif, it will only fire once.)

For the other one I called a function that did
 Marker.Enable() Marker.RegisterForSIngleUpdate(3)
in a quest stage, if I remember correctly.
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am


Return to V - Skyrim