Jump to content

[LE] Actor.GetParentCell() only gets a small area when outdoors... how do I reference a much larger area?


Cheyron

Recommended Posts

  On 11/28/2019 at 6:02 AM, IsharaMeradin said:

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

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

  On 11/28/2019 at 6:02 AM, IsharaMeradin said:

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

  On 11/28/2019 at 8:51 AM, foamyesque said:

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

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

  On 11/30/2019 at 2:36 AM, cdcooley said:

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

  On 11/30/2019 at 2:36 AM, cdcooley said:

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

CheyronHjroromirChopWoodEffect

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 12/1/2019 at 6:29 PM, ReDragon2013 said:

CheyronHjroromirChopWoodEffect

  Reveal hidden contents

 

 

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

  • Recently Browsing   0 members

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