Cheyron Posted November 28, 2019 Author Share Posted November 28, 2019 I would stop and start the quest rather than reset. I don't think a reset will re-fill aliases with different objects. Reset should just revert any values changed during the course of play back to their original, this would included aliases. Stop and then start will completely flush the data and cause it to re-fill aliases with current matching objects. ahhh ok maybe this is why, i removed it from the mod so i will have to redo all that, will test it soon enough and report back, i assume that should fix it though Link to comment Share on other sites More sharing options...
Cheyron Posted November 28, 2019 Author Share Posted November 28, 2019 Ok I am going to test this code now... ScriptName CheyronHjroromirChopWoodEffect Extends ActiveMagicEffect ReferenceAlias Property PlayerRef Auto ReferenceAlias Property HjoromirRef Auto Scene Property HjoromirChopWoodScene Auto ReferenceAlias Property ChoppingBlockRef Auto ReferenceAlias Property ChoppingBlockRef2 Auto Quest Property FollowerQuest Auto Weapon Property Axe01 Auto Event OnEffectStart(Actor akTarget, Actor akCaster) If HjoromirChopWoodScene.IsPlaying() Debug.Notification("Cheyron: Hjoromir... enough chopping, come!") HjoromirChopWoodScene.Stop() Else Debug.Notification("Cheyron: Hjoromir... wood!") If HjoromirRef.GetActorReference().GetItemCount(Axe01) < 1 Debug.Notification("Hjoromir: Sure boss, do you have an axe?") Return EndIf FollowerQuest.Stop() Utility.Wait(0.1) FollowerQuest.Start() Utility.Wait(0.1) ObjectReference cBlock2 = ChoppingBlockRef2.GetReference() If cBlock2 ChoppingBlockRef.ForceRefTo(cBlock2) HjoromirChopWoodScene.Start() ;//this will use the reference that is being filled Return EndIf ObjectReference theBlock = FindClosestChoppingBlock() If theBlock ChoppingBlockRef.ForceRefTo(theBlock) HjoromirChopWoodScene.Start() Else Debug.Notification("Hjoromir: Uh boss, we need to find a block first.") EndIf EndIf EndEvent ObjectReference Function FindClosestChoppingBlock() Actor player = PlayerRef.GetActorReference() Cell c = player.GetParentCell() ObjectReference closestBed = None Float closestDistance = 9999.0 Int i = c.GetNumRefs(40) While i i -= 1 ObjectReference o = c.GetNthRef(i, 40) If o && !o.IsDisabled() && !o.IsFurnitureInUse(True) If o.GetBaseObject().GetName() == "Wood Chopping Block" ;//decided to just leave the string check float dist = player.GetDistance(o) If dist < closestDistance closestBed = o closestDistance = dist EndIf EndIf EndIf EndWhile If closestBed Debug.Notification("Chopping Block Found, Distance = " + closestDistance) Return closestBed EndIf Return None EndFunction Link to comment Share on other sites More sharing options...
Cheyron Posted November 28, 2019 Author Share Posted November 28, 2019 I would stop and start the quest rather than reset. I don't think a reset will re-fill aliases with different objects. Reset should just revert any values changed during the course of play back to their original, this would included aliases. Stop and then start will completely flush the data and cause it to re-fill aliases with current matching objects. ok this fixed it, now it works, thank you so much ok well now this explains why i kept getting a bed in dragonsreach, that must be where i was when the quest loaded, i guess i had assumed it would keep it up to date or re-evaluate whenever i needed to use it... i guess i need to restart quests then, that was what i didnt realize until you guys, so thank you Link to comment Share on other sites More sharing options...
foamyesque Posted November 28, 2019 Share Posted November 28, 2019 Heh, Ishara beat me to it. Yeah, you have to use Stop/Start to do repeated searches. It works beautifully when you do so, though; I stress-tested the process pretty hard when I was looking into building a Detect Loot enchantment. Link to comment Share on other sites More sharing options...
Cheyron Posted November 28, 2019 Author Share Posted November 28, 2019 Heh, Ishara beat me to it. Yeah, you have to use Stop/Start to do repeated searches. It works beautifully when you do so, though; I stress-tested the process pretty hard when I was looking into building a Detect Loot enchantment. yeah it does work great, I had no idea that quest aliases only fill when quests start... that problem where I kept finding a bed in dragonsreach made me crazy lol. Now I have updated my mods to use quest aliases to find stuff the proper way and yeah things are working great now. I kept thinking the process was bugged haha. Link to comment Share on other sites More sharing options...
cdcooley Posted November 30, 2019 Share Posted November 30, 2019 As long as you don't try to use a single quest to both store information (i.e. quest stages, script properties, etc.) and to find nearby items then using quest aliases is definitely the right way to find things that interest you. It's both much faster than trying to locate things with Papyrus calls and gives you more flexibility in what you can locate. I use it in a few of my mods. Link to comment Share on other sites More sharing options...
foamyesque Posted November 30, 2019 Share Posted November 30, 2019 As long as you don't try to use a single quest to both store information (i.e. quest stages, script properties, etc.) and to find nearby items then using quest aliases is definitely the right way to find things that interest you. It's both much faster than trying to locate things with Papyrus calls and gives you more flexibility in what you can locate. I use it in a few of my mods. I believe Chesko uses the technique in Frostfall, as well, to find heat sources. Link to comment Share on other sites More sharing options...
Cheyron Posted November 30, 2019 Author Share Posted November 30, 2019 As long as you don't try to use a single quest to both store information (i.e. quest stages, script properties, etc.) and to find nearby items then using quest aliases is definitely the right way to find things that interest you. It's both much faster than trying to locate things with Papyrus calls and gives you more flexibility in what you can locate. I use it in a few of my mods. Yup, I am now actually making quests with the sole purpose of filling references for another quest to use. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 1, 2019 Share Posted December 1, 2019 CheyronHjroromirChopWoodEffect Scriptname CheyronHjroromirChopWoodEffect extends ActiveMagicEffect ; https://forums.nexusmods.com/index.php?/topic/8180038-actorgetparentcell-only-gets-a-small-area-when-outdoors-how-do-i-reference-a-much-larger-area/page-2 Quest PROPERTY FollowerQuest auto ; vanilla Quest? Scene PROPERTY HjoromirChopWoodScene auto Weapon PROPERTY Axe01 auto ReferenceAlias PROPERTY HjoromirRef auto ReferenceAlias PROPERTY ChoppingBlockAlias auto ; ChoppingBlockRef ReferenceAlias PROPERTY ChoppingBlockAlias2 auto ; ChoppingBlockRef2 ; -- EVENTs -- EVENT OnEffectFinish(Actor akTarget, Actor akCaster) ENDEVENT EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF (SKSE.GetVersion() == 0) Debug.Notification("ChopWoodEffect - ERROR: SKSE not loaded!") RETURN ; - STOP - ENDIF ;===================== IF HjoromirChopWoodScene.IsPlaying() Debug.Notification("Cheyron: Hjoromir... enough chopping, come!") HjoromirChopWoodScene.Stop() RETURN ; - STOP - ENDIF ;--------------------- Debug.Notification("Cheyron: Hjoromir... wood!") IF (HjoromirRef.GetActorReference().GetItemCount(Axe01 as Form) < 1) Debug.Notification("Hjoromir: Sure boss, do you have an axe?") RETURN ; - STOP - ENDIF ;--------------------- FollowerQuest.Stop() ; stop this quest WHILE (FollowerQuest) && FollowerQuest.IsRunning() Utility.Wait(0.1) ; wait until quest has stopped ENDWHILE FollowerQuest.Start() ; restart this quest Utility.Wait(0.1) myF_Action() ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------- FUNCTION myF_Action() ;-------------------- objectReference oRef oRef = ChoppingBlockAlias2.GetReference() ; cBlock2 IF ( oRef ) ChoppingBlockAlias.ForceRefTo(oRef) HjoromirChopWoodScene.Start() ; scene needs the Ref that is being filled to alias RETURN ; - STOP - Alias2 has a valid Ref ENDIF ;--------------------- oRef = FindClosestChoppingBlock( 9999.0 ) ; theBlock IF ( oRef ) ChoppingBlockAlias.ForceRefTo(oRef) HjoromirChopWoodScene.Start() RETURN ; - STOP - found a valid chopping block near the actor ENDIF ;--------------------- Debug.Notification("Hjoromir: Uh boss, we need to find a block first.") ENDFUNCTION ;------------------------------------------------------------- ObjectReference FUNCTION FindClosestChoppingBlock(Float fDist) ;------------------------------------------------------------- actor player = Game.GetPlayer() objectReference closestRef cell c = player.GetParentCell() int i = c.GetNumRefs(40) ; * SKSE WHILE (i) i = i - 1 objectReference oRef = c.GetNthRef(i, 40) ; * SKSE IF ( oRef ) IF oRef.IsDisabled() ; object is disabled ELSEIF oRef.IsFurnitureInUse(TRUE) ; object is already in use ELSEIF (oRef.GetBaseObject().GetName() == "Wood Chopping Block") ; * SKSE ; decided to just leave the string check float f = player.GetDistance(oRef) IF (f < fDist) closestRef = oRef fDist = f ENDIF ENDIF ENDIF ENDWHILE IF ( closestRef ) Debug.Notification("Chopping Block found at distance " + (fDist as Int)) ENDIF RETURN closestRef ENDFUNCTION ObjectReference PROPERTY HeadChopBlock auto ; see also "HeadChopBlockHookupSCRIPT.psc" ;-------------------------------------------------- ObjectReference FUNCTION myF_FindRefAt(Float fDist) ;-------------------------------------------------- actor player = Game.GetPlayer() objectReference oRef = Game.FindClosestReferenceOfTypeFromRef(HeadChopBlock.GetBaseObject(), player, fDist) RETURN oRef ENDFUNCTION Link to comment Share on other sites More sharing options...
Cheyron Posted December 2, 2019 Author Share Posted December 2, 2019 CheyronHjroromirChopWoodEffect Scriptname CheyronHjroromirChopWoodEffect extends ActiveMagicEffect ; https://forums.nexusmods.com/index.php?/topic/8180038-actorgetparentcell-only-gets-a-small-area-when-outdoors-how-do-i-reference-a-much-larger-area/page-2 Quest PROPERTY FollowerQuest auto ; vanilla Quest? Scene PROPERTY HjoromirChopWoodScene auto Weapon PROPERTY Axe01 auto ReferenceAlias PROPERTY HjoromirRef auto ReferenceAlias PROPERTY ChoppingBlockAlias auto ; ChoppingBlockRef ReferenceAlias PROPERTY ChoppingBlockAlias2 auto ; ChoppingBlockRef2 ; -- EVENTs -- EVENT OnEffectFinish(Actor akTarget, Actor akCaster) ENDEVENT EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF (SKSE.GetVersion() == 0) Debug.Notification("ChopWoodEffect - ERROR: SKSE not loaded!") RETURN ; - STOP - ENDIF ;===================== IF HjoromirChopWoodScene.IsPlaying() Debug.Notification("Cheyron: Hjoromir... enough chopping, come!") HjoromirChopWoodScene.Stop() RETURN ; - STOP - ENDIF ;--------------------- Debug.Notification("Cheyron: Hjoromir... wood!") IF (HjoromirRef.GetActorReference().GetItemCount(Axe01 as Form) < 1) Debug.Notification("Hjoromir: Sure boss, do you have an axe?") RETURN ; - STOP - ENDIF ;--------------------- FollowerQuest.Stop() ; stop this quest WHILE (FollowerQuest) && FollowerQuest.IsRunning() Utility.Wait(0.1) ; wait until quest has stopped ENDWHILE FollowerQuest.Start() ; restart this quest Utility.Wait(0.1) myF_Action() ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------- FUNCTION myF_Action() ;-------------------- objectReference oRef oRef = ChoppingBlockAlias2.GetReference() ; cBlock2 IF ( oRef ) ChoppingBlockAlias.ForceRefTo(oRef) HjoromirChopWoodScene.Start() ; scene needs the Ref that is being filled to alias RETURN ; - STOP - Alias2 has a valid Ref ENDIF ;--------------------- oRef = FindClosestChoppingBlock( 9999.0 ) ; theBlock IF ( oRef ) ChoppingBlockAlias.ForceRefTo(oRef) HjoromirChopWoodScene.Start() RETURN ; - STOP - found a valid chopping block near the actor ENDIF ;--------------------- Debug.Notification("Hjoromir: Uh boss, we need to find a block first.") ENDFUNCTION ;------------------------------------------------------------- ObjectReference FUNCTION FindClosestChoppingBlock(Float fDist) ;------------------------------------------------------------- actor player = Game.GetPlayer() objectReference closestRef cell c = player.GetParentCell() int i = c.GetNumRefs(40) ; * SKSE WHILE (i) i = i - 1 objectReference oRef = c.GetNthRef(i, 40) ; * SKSE IF ( oRef ) IF oRef.IsDisabled() ; object is disabled ELSEIF oRef.IsFurnitureInUse(TRUE) ; object is already in use ELSEIF (oRef.GetBaseObject().GetName() == "Wood Chopping Block") ; * SKSE ; decided to just leave the string check float f = player.GetDistance(oRef) IF (f < fDist) closestRef = oRef fDist = f ENDIF ENDIF ENDIF ENDWHILE IF ( closestRef ) Debug.Notification("Chopping Block found at distance " + (fDist as Int)) ENDIF RETURN closestRef ENDFUNCTION ObjectReference PROPERTY HeadChopBlock auto ; see also "HeadChopBlockHookupSCRIPT.psc" ;-------------------------------------------------- ObjectReference FUNCTION myF_FindRefAt(Float fDist) ;-------------------------------------------------- actor player = Game.GetPlayer() objectReference oRef = Game.FindClosestReferenceOfTypeFromRef(HeadChopBlock.GetBaseObject(), player, fDist) RETURN oRef ENDFUNCTION thanks redragon for cleaning up the code... i did end up removing that function to find the closest chopping block now that i am using a quest to find objects the correct way... the cell is limited to a small area when outdoors anyways so it was a bad way to go about it. I like some of the changes in your code though and will edit mine. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts