Jump to content

Specific SetEventHandler how to?


glowplug

Recommended Posts

Thanks for the tip on menumode 1044.

 

I've run into another problem but firstly...

I had to change...
SetEventHandler "OnActivate" kvFnOnActivateDuga02Clone "ref"::refPlayerClone "object"::PlayerRef
...to...
SetEventHandler "OnActivate" kvFnOnActivateDuga02Clone "object"::PlayerRef
...as the clone seems to be re-instantiated each load within game or not.
Just a test for kvActiIntDuga02Ref.refPlayerClone == refClone (the handler arg) and problem solved.

The problem now is DeleteFullActorCopy - I have it working in one place but the funeral parlour seems to be a problem.
DeleteFullActorCopy, like playerRef.moveToMarker is a Return.
In the first place the code simply waits a frame after DeleteFullActorCopy before playerRef.moveToMarker - when I coc back the clone has gone.

The player comes and goes from the parlour numerous times making it pointless to delete and create the clone over and over.
The only final exit is further down the valley.
That is a one way door to a cave but when I try to delete the parlour clone it persists.

The code that works...

scn activatorDarkHall
begin gameMode
  if iAction > 0
    if iAction.....
    elseif...
    elseif...
    elseif iAction == 8 ;set by a trigger
      let iAction := 9
      deleteFullActorCopy refPlayerClone
     ;dark hall clone gets deleted
    elseif iAction == 9
      let iAction := -1
      playerRef.moveToMarker mkrShackDoorRef
    endif
  endif
end

The code that fails...

scn activatorFuneralParlour
begin onActivate
  if iAction == 0
    let iAction := 1
  endif
end

begin gameMode
  if iAction > 0
    if iAction == 1
      let iAction := 2
      deleteFullActorCopy kvActiIntDuga02Ref.refPlayerClone
      ;funeral parlour clone persists
    elseif iAction == 2
      let iAction := -1
      activate ;works
  endif
end
Link to comment
Share on other sites

CreateFullActorCopy is a dangerous command you should never use:

- It clones the actor BASE object (and it also clones the scripted items in its inventory) and then create a new reference to that copy.

- All scripts on the duplicate (or attached to any item in its inventory) may not work or may bug out, as they won't recognize the actor anymore.

- DeleteFullActorCopy can destroy the actor's reference and base object, but it can't destroy the cloned scripted items in its inventory.

 

I recommend MigMaster Script Resource instead, which add a safe cloning function to the game which, as the name state, is safer and avoid many pitfalls associated with the CreateFullActorCopy function.

Link to comment
Share on other sites

Thanks once again for saving me what would have been a very sorry path to take.

 

I can't use the esm directly as I'm already working on an esm so I'll simply add the code to my mod - migck has been good enough to give permission to do so.

 

The reason I'm working on esm is to do esp job lots and use TES4Gecko Merge To Master.

This not only reduces save time by about 20 seconds but reminds me to back up on a task basis.

Link to comment
Share on other sites

Actually, esms can have other esms as masters, and esps can have other esps as masters.

 

The CS only allow esp->esm, but CSE also allow esp->esp and esm->esm which are fully supported by the engine.

 

So, you can either make your esm require Migck's esm or turn your esm into an esp and still be able to use the "Merge to master style".

Link to comment
Share on other sites

I really want to thank you for taking time to help me avoid these traps.
I'd considered doing a remove items loop but that was nothing to what Migck has taking care of.
The only problem I found was it leaves the player naked but that will be easy to fix (change those statements to NS...or...maybe not).

There is still the issue of DeleteFullActorCopy.
This seems to go out of scope the second the player leaves the cell by teleport or save/reload.
DeleteFullActorCopy being solely dependant on the original pointer from CreateFullActorCopy...that makes sense to me.

This comes down to either doing something else or writing off some save game bytes.
I'm pretty sure Migck's CreateActorCopyFunction reduces that to acceptable.
I certainly won't ruin story, mood and ambience over a few bytes of save game - providing that is all it is.
It's a quest mod and people will uninstall when finished anyway.

I only use CSE but my main reason for only 1 esm other than Oblivion is to avoid anomalies like ground mesh disappearing.
Just to clarify...
Nagasteim is on the back burner till Dayn Telsag is ready.
Dayn Telsag - The Oracle of Almardi is the first book of the full story (Nagasteim the second) and will replace the current release of Kalosan - The Oracle of Almardi.
* Dayn Telsag is in esm as I use esp merging because the esm takes around half a minute to save.
The current mod, Dunwukim, is a dungeon crawler for me to learn stuff I want to do on Dayn Telsag but not break it.
Dunwukim got to around 15 seconds a save so I converted it to esm and work from esp merge atm.
I've actually kept the current Dunwukim esp independent of the Dunwukim esm as I am not sure about a few things.

I got the hint about spelling discrepancies but in all seriousness I am seeing 'my friend' tomorrow.
He fronts as a doctor but is a magician with candy that stops all my neighbours talking during the night and waking me up...okay, I couldn't resist that one - the candy only stops the dogs talking (I wish).

Link to comment
Share on other sites

Having got Migck's code into place I decided to try ResetInterior and found it removes the clone.

To test this I set the door to alternate between create clone and reset.

Having saved, I went through about 20 times then saved again - the second was a few kb higher than the first.

Loading the second save I went through about 20 times again then saved - the third was back down to the same size as the first.

 

The mod will only need to use ResetInterior when the player uses a 1 way exit out of the valley.

The event handlers have tested out fine so I think my problems with this topic are solved.

 

Thank you Contrathetix and Forli for your great support here.

 

Now to start working on zombie outfits.

Link to comment
Share on other sites

No problem. Apologies for not being able to be of more help. We have some pipe/plumbing renovation stuff going on, and I had to bag my gaming PC. There goes my holiday dedicated to modding. Oh well. :facepalm:

 

Thank you to forli, too, now I know what to do when I have a chance to update my mods.

 

There was this experiment recently done by QQuix on actors, cell resets and savegame bloating: https://forums.nexusmods.com/index.php?/topic/4657470-cell-reset/

Edited by Contrathetix
Link to comment
Share on other sites

Thanks for that link. I'm going to take a bit of time reading over it and the wiki (think I've been over that before) to make sure I take it all in.

 

Based on the fact that the clone I create is persisting and I won't need any others it may well be best to just let the cell reset itself in due course

Link to comment
Share on other sites

  • Recently Browsing   0 members

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