Jump to content

Selective Instant NPC Respawn Ability [Help!]


rakansc

Recommended Posts

Alright, it's not perfect, but here's a way of supplying certain characters with "reinforcements" on death:

 

Step 1: Setting up an OBSE-friendly Construction Set (Assuming Windows)

You need to access the Construction Set in a special way to mod with OBSE's functions. First, make a shortcut for obse_loader.exe. Right-click on it and select "Properties", then the Shortcut tab. The Target box should have, in quotes, a filepath leading to the real obse_loader. At the end, outside of the quotes, type "-editor" (Don't type the quotes). This shortcut will now open the Construction Set with all its OBSEy goodness.

 

Step 2: Creating the Spell

Create a new script (Gameplay/Edit Scripts, Script, New) and set the drop-down box at the top to Magic Effect. The script itself should go something like...

 

scn MyReinforcementScript
;scn is short for Scriptname.  Every script needs to be named on its first line.

ref MyBase
;This is declaring a variable for use in the script.
;Ref variables hold objects/actors/spells/etc.  Practically every "object" Oblivion uses.

Begin ScriptEffectFinish
;All of a script's actual functions need to take place in a Begin/End block determining when they run.
;ScriptEffectFinish blocks, unique to Magic Effect scripts, run when the effect ends on a subject.
;Even racial abilities are removed on death.

  if (GetDead)
;The contents of an If/Endif block only run if the condition in the if-line is true.
;In this case, if the effect's previous subject is now dead.

  set MyBase to GetBaseObject
;This script will be acting on a reference, and this function will return the base.
;We can now use the actor's base in the script by refering to this variable.

  PlaceAtMe MyBase 1
;Places one whoever-it-is at this whoever-it-is' corpse.

  endif
end

 

If it gives you an error trying to save, it means you opened the CS the normal way instead of using the OBSE_Loader shortcut.

 

Now, create a new spell (for the purposes of this tutorial, MyReinforcement). You'll want its Type to be Ability, like a Breton's inherent Resist Magic. Give it a Script Effect as you would any other effect. This will light up the Script Effect Info box at the bottom. Set the Script to MyReinforcementScript. The Effect Name and School don't matter, and you won't want it to have any Visuals Effect.

 

From here, there are two ways you can bring it into the game. Either you can add it to whatever Actors you want to be Reinforced upon death manually, or you can give the player a spell to add/remove the ability from whoever they want. If you want to add the ability via CS, do that and you're done. Otherwise...

 

Step 3: Creating the Toggle Spell

We've got a couple more scripts to go, so create another one. Once again, set it to a Magic Effect script. It goes like...

 

scn MyReinforcementToggleScript

Begin ScriptEffectStart
;ScriptEffectStart runs when the effect in question hits/is added to the subject.

  if (IsSpellTarget MyReinforcement)
;This checks if the subject is currently under the effect of MyReinforcement.

  RemoveSpell MyReinforcement
;If MyReinforcement was a spell/power, this would remove it from their spellbook.
;Since it's not, it removes it from their Active Effects list.

  elseif (GetDead == 0)
;Elseif blocks only run if, as well as their condition being true, the previous if's condition was *false*.
;That is to say, the subject is *not* under the effect of MyReinforcement, and is not dead.
;Quite frankly, I'm not sure what would happen if you used it on a corpse, so playing it safe here.

  AddSpell MyReinforcement
;Even though we're adding/removing it from a reference, the changes affect the whole form.
;This means that reinforcements will be in-turn reinforced when they die.

  endif
end

 

I'm sure you can attach this to a spell properly. Keep in mind, you'll want it to be on touch/target, Immune to Spell Absorb/Reflect, and non-Hostile. You'll also want to give it a catchy Effect Name like Instant Reincarnation. For the purposes of this tutorial, it will be called MyReinforcementToggle.

 

Step 4: Giving the Spell to the Player

Here we're going to get into Quests. Regardless of their name, they do much more than update journal logs as the player runs around and completes them. For one thing, they govern every piece of dialogue in the game. But enough of that. Go to Character/Quests, right-click on the list on the left, and select New. For the purposes of this tutorial, the quest will be called MyReinforcementQuest. Make sure Start Game Enabled is checked on your quest. We'll need to give it a "GetIsPlayableRace == 1" condition to make sure it doesn't try to give it to the player while they're in CharGen, and it gets removed once they're finished. One method of doing this is to open up a different quest, right click on and copy its GetIsPlayableRace == 1 condition, and paste it in your quest's condition box. As an alternative, you can set it up manually by right-clicking in your quest's condition-box and selecting New. You can alter a condition's function, it's symbol(s) of comparison, and its value. Functions are alphabetically listed.

 

One more script. Create another new script and set the drop-down box to quest.

scn MyReinforcementQuestScript

Begin GameMode
;GameMode blocks on a Quest script run every five seconds if not otherwise specified.
;On an Object script, the amount it runs depends on its proximity to the player.
;Or, if it's a Quest Item, every frame.

  player.AddSpell MyReinforcementToggle
;Previously, we didn't need to say who the function was affecting.
;This was because we were working with Magic Effect scripts with a clearly defined subject.
;Since this is a Quest script, it has no idea who we want to add the spell to unless we tell it.

  StopQuest MyReinforcementQuest
end

This script runs within five seconds of the save booting up, gives the player the spell, then terminates itself before it can run again and waste (admittedly very little, but no sense in being messy) processing power. Attach this to your quest, and you're finished.

 

There are three things wrong with this approach. One is that the reinforced being will still be considered dead if they're a unique being, regardless of their clone prancing around their corpse. On the other hand, that might be a good thing.

Another is that, if they die to something like lava, their clones are liable to continue spawning and dying instantly. This can be solved by changing the "PlaceAtMe MyBase 1" line in MyReinforcementScript to "player.PlaceAtMe MyBase 1", so the reinforcements will appear directly at the player. Of course, this can also cause trouble if the player is the one taking a dip in lava, trailing Bruma Guard-corpses behind them. This also compounds the most important third thing: I don't know how removal of Persistent Reference corpses work, but it's plausible that this will slowly bloat your save-game with more and more corpses to keep track of. Persistent References, which almost all NPCs are, are always stored in memory instead of just when the player gets close. It probably would never get bad enough to be noticable, but if it did, it would likely cause slowdown and even crashes. I'd appreciate it if someone who knew a bit more about Persistent corpse-cleanup could elaborate on this.

 

EDIT: Creating NPCs from scratch in-game is currently considered to be impossible, and that isn't likely to change... Also, L is justice. Kira is a male without a father who's... Carrying a Sphere of Annihilation!?

I take it back, he's awesome.

Link to comment
Share on other sites

Wow man... You're freaken awesome. Many thanks.

 

Edit: Just finished doing everything like you said. Perhaps one of the most informative Oblivion Modding moments I've ever had, thank you for that. Will load it up and see if everything works.

 

Edit 2: It works perfectly.

 

I will be mindful to watch for save-game bloating and see what happens. I was planning on just adding this to a few NPCs (like the ones at the Burma Siege event, or the Imperial City battle), so hopefully if it does lead to bloating it won't be too bad.

 

Edit 3: I'm noticing it occasionally does not apply to NPCs without the spell even though I added it as an ability (in SE CS)... Not sure why this would be.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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