Jump to content

NPCs and mining - script help!


xkkmEl

Recommended Posts

I don't understand why I can't get my NPC into a mining furniture.

 

I have:

  • a quest that places the NPC into an alias
  • an AI package on that alias that invokes the Activate procedure
  • an activator, targeted by the activate procedure, that calls the mining furniture's "Activate( akActionRef, True)"; this is my own activator... not the regular mineorescript. I use "blockActivation()" in my activator, just like the mineorescript and mineorefurniturescript.

I do see my NPC triggering my activator, but no mining animations.

 

I thought it might be an animation conflict with my activator's default animation (the NPC nods briefly at the ore vein, even though I believe it shouldn't run with activation blocked...), so I added a 2 second delay upon activation, but it didn't help.

 

I checked with xEdit and can confirm the mining furniture I am testing with does not have any activation parents, though it does have a "linked from" that does not point to my activator script.

 

Oh... and I can confirm that the same NPC is able to activate the furniture when its AI is in sandbox mode, bypassing my activator script.

 

This is my first experiment with furniture... I really don't know what I'm doing! I don't know where to look next!

 

Link to comment
Share on other sites

  • 1 year later...

I have made progress on this.  It turned out to be anything but easy.

The issue is competition from other sandboxing NPCs.  Sandboxing NPCs apparently get into the furniture without going through the activation procedure.  They reserve the furniture from afar, and then walk to it and use it.  Meanwhile, my miner tries to activate it, but the "activate procedure" does not reserve the furniture until the miner has successfully entered, and while he is trying... some other sanboxing NPC can reserve the furniture and force-abort my miner's attempt at entering.

I had to build a significant infrastructure to cope with this.  I run alias fills to find NPCs close enough to compete for the furniture and temporarily put a non sandboxing AI on them (flee).  Once I see mining animation events reaching my miner, I release all the competing NPCs so they can resume their normal behavior.

 

Link to comment
Share on other sites

This is also an issue for the player character.  NPCs can reserve furniture from anywhere in their sandbox zone.  This can be noticed with my Inventory Management System mod.  When pressing the hotkey to transfer the pickaxe (and optionally activate it), a reserved ore vein will state that it is busy despite no one being there.  Manually transferring the pickaxe and activating as normal and something kicks in to unreserve the ore vein and allow the player to use it.  I believe it might be something on the MineOreFurnitureScript, but I cannot say for certain as I have not delved into it in any great detail.

Link to comment
Share on other sites

Indeed.  I still have unresolved issues.  Sometimes, activating the ore vein and letting the player strike one blow unlocks something and mining resumes, sometimes not.

I thought it was about the MineOreFurnitureScript being in the "busy" state (it ignores NPC attempts at activation in that state, but not the player's).  I could however find no correlation between the "busy" state and my NPC's success/failure at entering the furniture.  Is it possible, in the case of sandboxing NPCs, that both the script and the default activation procedure fire, despite activation being blocked??!?  This is what my tracing is suggesting, but I remain doubtful.

I do have one thing that may interest you.  The MineOreFurnitureScript is indeed responsible for the bug where the player does the motion but does not get the ore.  It is triggered by activating the ore vein while it is in use by an NPC.  The script in that case simply forgets to call "RegisterForEvents()" and therefore does not see the strike events.  It does that both in the "normal" and "busy" states.  I have not tested just adding that line in the two missing spots, but I suspect it would fix the bug, without side effects.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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