Jump to content

Help with NPC script


Recommended Posts

What i want do to:

A script that is attached to a actor that checks every 10 seconds or so if the actor is 5000 units away from the player. If so, the actor is killed. This includes times when the NPC doesn't follow the player through a interior or fast traveling.

 

Why? I spawning a lot of Placeatme actors that have only a follow package (target: the player). Since there's no way to delete placeatme actors in oblivion other than when they're killed and the cell they're in resets, i have to kill the ones that somehow got lost.

 

The problem: The actors have the "no low processing" toggled, meaning that they won't process their scripts when the player is not in their cell.

Here's what i got in the moment:

scn xxxKnightOfOrderDeleteWhenDistant

float timer
short init
short NPCKilled

begin GameMode
    if init == 0
        ;set the timer value, count down 10 seconds
        set timer to 10
        set init to 1
    else
        if timer > 0
        set timer to timer - getSecondsPassed
        
        ;code to execute after 10 seconds
        else
            if ( getdistance player >= 5000 )
                if NPCKilled == 0
                    Kill
                    Message "Actor Removed"
                    set NPCKilled to 1
                endif
            endif
            set timer to 10
        endif
    endif
end


begin OnDeath
    ;sets the short to 1 to prevent messages if the actor was killed by sources other than the kill command above
    set NPCKilled to 1
end

Any way to make this through a quest script or something else that kills any NPC that is of a certain faction that is 5000 units or more distant from the player? Keep in mind that the actors are dynamic (spawned through placeatme).

 

EDIT: Updated the script.

Edited by Magnusen2
Link to comment
Share on other sites

Are you planning to allow followers in places they're not allowed to go in vanilla Oblivion?

Can you please give examples of what those places are?

They are spawned through a lesser power. So the places that they will be in are the same ones that the player can go to.

Link to comment
Share on other sites

The one I was thinking of was Frostfire Glade, but I believe there are other quest-related areas where followers aren't allowed.

 

The main problem with placeatme is savegame bloat, and it's not entirely avoidable. So people like me who play the same game for years steer clear of mods that use it.

The mod is for personal use. I don't intend to release it.

Link to comment
Share on other sites

You don't need to clean dynamic actors. The game already clear all dynamic actors automatically when the cell reset (no need for manual reset with ResetInterior and no need to revisit the cell afterwards).

 

Keep in mind: PlaceAtMe actors are exactly like the actors spawned continuously by the leveled lists placed everywhere in the world.

Have you ever cleaned all actors spawned by leveled lists? No.

Do these actors ever caused permanent bloat? No.

PlaceAtMe actors are like them.

 

 

The problem with dynamic references exists mainly with items and other objects.

Edited by forli
Link to comment
Share on other sites

 

 

 

You don't need to clean dynamic actors. The game already clear all dynamic actors automatically when the cell reset (no need for manual reset with ResetInterior and no need to revisit the cell afterwards).

Keep in mind: PlaceAtMe actors are exactly like the actors spawned continuously by the leveled lists placed everywhere in the world.
Have you ever cleaned all actors spawned by leveled lists? No.
Do these actors ever caused permanent bloat? No.
PlaceAtMe actors are like them.


The problem with dynamic references exists mainly with items and other objects.

 

 

 

I read that they only get removed when they were dead. That's why i was looking for a way to kill the ones that somehow got lost.

Thank you.

Link to comment
Share on other sites

QQuix made many experiments and found how the game delete dynamic actors.
You can read the results here: http://cs.elderscrolls.com/index.php?title=Cell_Reset (at Cell Reset and Actors)

If your actors are dynamic and NOT persistent (if they have the "No low level processing" flag), you don't need to interfere. The game will automatically clean them when the cell reset time expire.

 

If your actors are dynamic and persistent (if they DON'T have the "No low level processing" flag), ResetInterior and the cell reset time alone are not enough. The player must reenter that cell again. And if they are not dead, you must also call ResetInterior on the cell before reentering it... a big problem if you don't want to break quests, scripts or trash the player progresses.

 

So... always set the "No low level processing" flag on reference you want to spawn and delete repeatedly.

Edited by forli
Link to comment
Share on other sites

  • Recently Browsing   0 members

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