Jump to content

[LE] Looking for Script alternative from expirienced modder & scripter.


maxarturo

Recommended Posts

Hello everybody.


I had a rough week and my brain has been completely drain out, so bear with me if i'm missing something obvious...


This a simple light script that is intended to be used "Locally" (to be inserted in the Actor's Reference Property Window - selectively on some actors), in all Actors vanilla Lvl - Enc - Respawn - Simple actors and on the "New Race Actors" created in my mod, except Unique Actors.

* For safely deletion of actors.


The use of it is for clearing 3 specific cells that i need them to be cleared of dead npcs after X numbers of times that the player returns to those cells.


The issues that i'm having is that the "OnLoad" is not reliable (the object/actor may or may not unload to load again entering and exiting the cell) + in my testing i've encounter this issue.

In one of my massive "Heavy Cells" it will not fire the deletion on all npcs when is suppose to, and in this particularly cell i need the script to delete dead npcs at the specific number of "OnLoad" Events.


Example:

There are 25 dead npcs killed at the same time that the Player first enters that cell, so the deletion should fire at the same "OnLoad" Event on all dead npcs, but it will not, it will delete 20 and leave 5 and delete them whenever it fires again the "OnLoad" Event on them., or delete 23 and leave 2 for later, it depends on the game/PC's mood.

The Script:



Scriptname aXMDnpcDeadRemove extends Actor
{It will set the CriticalStage of the Dead NPC after 1 & 3+ OnLoad Events, safely setting the Dead Actor ready for deletion & delete the actor from world}

int count


Auto State WaitingKiller
Event OnDeath(Actor killer)
GoToState("WaitingToRemove")
EndEvent
EndState


State WaitingToRemove
Event OnLoad()
count = count + 1
If (count == 1)
Self.SetCriticalStage(CritStage_DisintegrateStart)
ElseIf (count >= 3)
Self.SetCriticalStage(CritStage_DisintegrateEnd)
EndIf
EndEvent
EndState




.....................................................................


I do have an alternative solution that involves having an xMarker monitoring the "Dead State" of each npc and when it detects that the npc is Dead after X times of "OnCellAttach" (or other similar Events) it will dump/move it to a "Dead Cell".

* In this script case i can make it to be reliable and fire at the specific time i need it to.

* I have posted again in the past a similar topic and i did had some other alternatives from ReDragon.



The issues here is that i'm trying to avoid big scripts and unnecessary function on those specific actors because they are all in "Heavy Cells" and there is already too much going on in those cells, especially on the background, the CPU & GPU are busy as hell.


Plus i'm trying to end up with a "Save File" as small as possible despite the size and number of scripts that this mod has right now, around 100 and half of them have on average 250 + lines, my final "Test Save File" grows only by a few kb (after finishing the mod), so right now i'm on track with my goals.


Thank you very much for reading all this.

Edited by maxarturo
Link to comment
Share on other sites

Your alternative may be the best solution especially if it is reliable and happens exactly when you want it to happen. Should you want to know if it could be improved upon in any way to lessen impact on processing then post that script.

 

I was hoping that somebody would have a different angle on this to avoid my alternative.
I haven't created the "Script Alternative" i have it on my head, i'll use the same tested to death logic and functions that some of my other big heavy scripts have and they run like a Swiss clock.
Nevertheless, thank you very much for showing interest in this !.
Link to comment
Share on other sites

The first thing someone would suspect is the OnLoad() event is simply not firing evenly on all of the NPCs.

 

If you used oncellattach() you could use a function to make sure the NPC was fully loaded.

 

While !Is3DLoaded()

Utility.Wait(0.3)

EndWhile

 

This is not something I have ever dealt with before.

 

Thanks SurfsideNaturals.
But as dictated on the creationkit page.
- This event will NOT fire in the first cell(s) loaded while loading from a save game.
and this is also a big issue.
And i can confirm this, i have tested it heavily.
Plus it does have the same issue as the "OnLoad".
(the object/actor may or may not unload to load again entering and exiting the cell)
* Papyrus have a lot of flaws that they are not documented anywhere, you can only find them if you test them heavily and in combination with other Event and functions, despite that the creationkit page have them as functional Events & functions.
Thank you for taking the time on this !.
Link to comment
Share on other sites

@ SurfsideNaturals.


You edited your post while i was writing.


This is a reliable approach if you use it in combination with an Activate Event send to the xMarker activator handling the npcs deletion, it's kind of the same logic i meantion in one of my post above.


But the final script is big... compare with just four lines...


Thank you very much ladies for your help.

Edited by maxarturo
Link to comment
Share on other sites

 

@maxarturo

Just wanted to note that you are like the perfect gentelman. :smile:

I really like your attitude.

 

Thanks for the nice wishes in my own thread, I will take them to my heart and give them also back to you know:

 

 

Have a happy modding !.

 

 

 

Thanks that really means a lot...
"One good action takes you a step closer and farther, on your continuously personality sculpting."
Link to comment
Share on other sites

Just a suggestion..instead of OnLoad() use event OnCellDetach()

 

aXMDeadActorRemoverScript

 

Scriptname aXMDeadActorRemoverScript extends Actor
{safely setting the Dead Actor ready for deletion & delete them from world}
; https://forums.nexusmods.com/index.php?/topic/8368733-looking-for-script-alternative-from-expirienced-modder-scripter/

  Int count


; -- EVENTs -- 1 + "Waiting"

EVENT OnDeath(Actor akKiller)
    gotoState("Waiting")            ; ### STATE ###
    self.SetCriticalStage(0)
ENDEVENT


;==================================
state Waiting
;============
EVENT OnCellDetach()
    count = count + 1                ; 1 = first detach, 2 = second detach, player has left this cell at least twice
    IF (count >= 2)
        gotoState("")                ; ### STATE ###
        self.SetCriticalStage(1)
        self.SetAlpha(0.0, TRUE)
        Utility.Wait(0.5)
        self.SetCriticalStage(2)
    ENDIF
ENDEVENT
;=======
endState


; -------------------
; Sets this actors critical stage, which is one of the following (properties below also match this)
;; Function SetCriticalStage(int aiStage) native
; Set of read-only properties to essentually make a fake enum for critical stages
;    int Property CritStage_None              = 0 AutoReadOnly
;    int Property CritStage_GooStart          = 1 AutoReadOnly
;    int Property CritStage_GooEnd            = 2 AutoReadOnly
;    int Property CritStage_DisintegrateStart = 3 AutoReadOnly
;    int Property CritStage_DisintegrateEnd   = 4 AutoReadOnly

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Hey ReDragon.


After i slept for two hours, my brain fluids started running again, and yes i do think that OnCellDetach() is a better approach for this.

I will also make some changes on that particular cell, so that the "Clear Dead Npcs" is not that crucial and it won't matter so much if some npcs get deleted afterwards.

Just as a precaution.


Thank you all for your suggestions.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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