Jump to content

Cant use RegisterforSingleUpdate on quest script? help?


Recommended Posts

On the other hand, the OnLoad event fires when the 3d is not yet loaded, so I would use If MyReference.WaitFor3dLoad() before playing the EffectShader, look at the papyrus log, you'll find out it saying something like "reference has no 3d loaded".

 

Edited: Is3dLoaded wont work because it is not loaded yet when the OnLoad event occurs, use WaitFor3dLoad instead, it will wait for this object's 3d to load, or until it knows the 3d won't load.

Edited by DieFeM
Link to comment
Share on other sites

Thankyou for all the help DieFem!

((interestingly i stumbled accross the RegisterForHit wiki late last night and tried registeringforhit inside the refcollectionalias, but it didnt do anything just like you predicted))

 

 

Ive put the RegisterForHitEvent script that you wrote for me into the quest script tab, and i set the effectshader to fire after 3d is loaded like you said, and removed the other stuff from the RefCollectionAlias script but unfortunately i still cant see any shader on any tree in the area and i still dont get a debug from the OnHit event :(

 

This is the script in the script tab of my quest -

Scriptname SM_Woodcutter_QST_SCRPT extends Quest

RefCollectionAlias Property MyCollectionOfTrees1 Auto
Weapon property Woodcutter_Axe Auto

Event OnQuestInit()
	Debug.MessageBox("There are " + MyCollectionOfTrees1.GetCount() + " trees in the collection 1")
	RegisterForHitEvent(akTarget = MyCollectionOfTrees1, akAggressorFilter = Game.GetPlayer(), akSourceFilter = Woodcutter_Axe)
EndEvent

Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)
	If MyCollectionOfTrees1.Find(akTarget) > -1
		Debug.Notification("Player hit tree collection 1")
	EndIf
EndEvent

i cut the script down a little to test, and i have tried using both

Weapon property Woodcutter_Axe Auto

and

Keyword property Woodcutter_Axe Auto

neither variation worked :(

 

My Reference collection alias is set to Optional, with 0 max initial fill count, Find Matching reference -> In loaded area -> Closest to PlayerRef (i made this alias just incase "player" was causing the issue)

the RefCollectionAlias has a condition on it set to "IsInList" -> FormList:MyTreeList -> Run On Subject -> "== 1" -> And.

 

And this is the script that is on the RefCollectionAlias script box.

Scriptname SM_Woodcutter_QST extends RefCollectionAlias

RefCollectionAlias Property MyCollectionOfTrees1 Auto
EffectShader Property MyEffectShader Auto

Event OnLoad(ObjectReference akSenderRef)
	If akSenderREF.WaitFor3dLoad()
		MyEffectShader.Play(akSenderRef)
	EndIf
EndEvent

I put the script that you wrote for me into the script tab of the same quest that contains the ReferenceCollectionAlias's, should i put it in its own quest instead?

 

((i can put the mod together to share with you if you would like to take a look yourself? it really is just an axe weapon, a formlist, keyword, omod, and quest with refcollection alias's though, its such a painstakingly simple mod idea, but just cant get the damn thing to work haha.))

Link to comment
Share on other sites

Ok, so i have made some progress, wooo! i cant thank you enough DieFeM!

 

i put the RegisterForHit script that you wrote for me into its own quest - seperate from the quest that contains the alias's and now random trees are giving me the onhit event debug. yes!

 

...But, not all trees, and there seems to be a delay between loading a savegame and the trees being registered for the hit event - ill do more testing, but it seems like if i hit tree A straight after loading in, nothing happens, but if i walk around a little bit, beat up codsworth and then hit tree A 1 minute later i get the onhit debug. but like i say it seems to be randomly selecting which tree gets the event and which don't - maybe its just taking forever for each tree to get registered? not too sure on that one. but my game does seem to be lagging as i run around looking at trees, meaning this is probably a pretty intensive thing to be asking the game to do eg: regestering 596ish trees for a hit event. im also still not seeing an effect on any tree in the area, but i set a debug notification to tell me when the 3d is loaded and when the effect is playing, i get the debug, but i dont see the effect...

 

Im going to try and find a way to only register the closest trees to the player for the OnHit event and see if that mitigates the lag.

Edited by SandMouseAnarchy
Link to comment
Share on other sites

Not all trees will have a reference because they can be part of a static collection or a precombined object mesh.

If you open the console and click on a tree and it does not show a reference it means that tree is part of a precombined mesh.

If you click on a tree and it shows a reference but using disable on it a whole set of trees disappears instead of disappearing only the tree that you selected it means it is part of a static collection.

Link to comment
Share on other sites

Ah, that makes sense, thanks DieFeM :smile: i had a thought... i have a tree mod on my game, the "some trees have leaves" mod, i disabled that mod and now i get the hit event on most trees now, i think the other trees are now just the static collections like you say :smile:

 

EDIT* i thought i had a mod compatability issue, but its ok now.

 

EDIT2*

Ive been testing a bit, and when i leave the area that i loaded in at the trees no longer get the onhit event. i think what is happening is that the alias's arent being updated when the player moves to a new cell/area. i have tried stopping and starting the quest with the alias's in, but that doesnt seem to update the collection with new trees in the new area.

 

Any ideas how to update the collection alias?

Edited by SandMouseAnarchy
Link to comment
Share on other sites

If in the settings of the RefCollection Alias you have activated "On Loaded area" when the quest starts the collection will be filled with the trees in this area, this doesn't update itself, it is filled only once, when the quest starts.

So you can try two different ways, leave this option not checked, so the collection is filled with every single tree in the game, or, if this doesn't work, restart the quest when you get a certain distance from the point you are when the quest starts.

For this end you can use another quest with a script, in this script you spawn an xmarker where the player is when the quest starts, and use RegisterForDistanceGreaterThan and OnDistanceGreaterThan to restart the quest when you are at a certain distance of the first start.

Quest Property TheOtherQuest Auto

ObjectReference TrackingMarkerRef
ObjectReference PlayerRef
Float Radius = 10000.0

Event OnQuestInit()
	PlayerRef = Game.GetPlayer()
	TrackingMarkerRef = PlayerRef.PlaceAtMe(xMarker)
	UpdateMarker()
EndEvent

Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	If akObj1 == PlayerRef && akObj2 == TrackingMarkerRef && afDistance > Radius
		UpdateMarker()
		RestartQuest()
	EndIf
EndEvent

Function UpdateMarker()
	TrackingMarkerRef.MoveTo(PlayerRef)
	RegisterForDistanceGreaterThanEvent(PlayerRef, TrackingMarkerRef, Radius)
EndFunction

Function RestartQuest()
	TheOtherQuest.Stop()
	Int i = 0
	while !TheOtherQuest.IsStopped() && i < 50
		Utility.Wait(0.1)
		i += 1
	endWhile
	TheOtherQuest.Start()
EndFunction
Link to comment
Share on other sites

Thanks DieFeM!

 

Unfortunately I just can't get it to work.

 

I had a compile error saying that "Xmarker is undefined", so I added "Form Property Xmarker Auto" to the new script and it compiled, but in game it doesn't seem to be resetting the quest when moving away from the marker.

 

I tried setting the new quest to start and stop based on the axe being equipped/unequipped, and although it restarts the quest, it doesn't seem to be refilling the aliases - all trees loose their alias after the quest resets.

Also, interestingly I don't get an "onQuestInit" debug either (I don't know if the onQuestInit fires after restarting a quest or if it only fires once the first time?)

 

I came across a post somewhere online saying to tick a box in the refAlias called something like 'use reserved' I tried checking that box but in game the aliases aren't refilled.

 

I set the quest that contains the aliases to Not run on start and instead started the quest manually and the aliases filled. But then I reset the quest (by reequipping the axe) and the aliases didn't refill.

 

I feel like there is something really obvious I'm missing here.

To register every tree in game, should I uncheck both "in loaded area" and "nearest to: player"?

 

Or is there a way to force the quest to refill the aliases without restarting the quest?

Edited by SandMouseAnarchy
Link to comment
Share on other sites

Thanks DieFeM!

 

Unfortunately I just can't get it to work.

 

I had a compile error saying that "Xmarker is undefined", so I added "Form Property Xmarker Auto" to the new script and it compiled, but in game it doesn't seem to be resetting the quest when moving away from the marker.

 

 

Forms aren't actually in the game, just their references. If you want to track an xmarker, you gotta use their reference, which could an ReferenceAlias or an ObjectReference.

 

You probably figured that out already though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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