Destructible Objects

From the CreationKit Wiki
Jump to navigation Jump to search

In this tutorial, we'll go over how you can make a destructible object. This could be a door you can break down, a pillar, or any object at all. In-game examples of this are the barricades from the Civil War that you have to break and spider cobwebs you can destroy. They can help add interesting mechanics to your dungeons, and they're not all that hard to make when you get the hang of it.

Thanks to wellpapp on the destruction part. Without him I wouldn't have known to tick disable object and I might have smashed my keyboard out of frustration.

Premise[edit | edit source]

Though some of you might be worried that it requires a knowledge of scripting, creating destructible objects actually uses an interface built-in to the Creation Kit. It does use a script but it's a pre-built one and you'll only have to edit properties.

It's quite simple, and while there are a few things to edit, it's a very quick process that doesn't require a lot of effort. Honestly, the largest effort would be creating "broken" models if you'd rather have stages of decay with custom models. However, that's not necessary at all and even if you'd rather have that, you can just use vanilla objects for the "broken" look. If you do want custom models, export them as .nif and choose them when you choose a replacement object (we'll get to this later).

An example of it in-action, with custom modeled debris.

A quick note regarding this: If for some reason you have no collision on your breakable mesh even though the .nif has collision, try duplicating an existing activator and changing from there, with everything the same as the outlined tutorial, rather than creating a New activator. Everything else is the same - just change the model path in the duplicate, remove any scripts, and edit destruction data as usual.

Destruction[edit | edit source]

For this part of the tutorial, I'll go over how to make an object that will disappear once you hit it enough times. It doesn't look fantastic, but is quite easy and doesn't require any new models.

First you'll want to create a new Activator. You can do this by going under WorldObjects>Activator in the Object Window filter. Right click and select New. Give your activator an ID - I'll call mine TestBreakablePillar - and give it a name. The name of mine is Suspicious Pillar.

Where it says Model, underneath name, click Edit and choose a model that you would like your undamaged object to have. I gave mine a generic pillar model. If you can't find anything, then make sure you've extracted your Meshes.bsa to your Skyrim/Data folder.

You can leave all the other settings as default (that's nothing checked except Collision Geometry and Local Map). Then, you'll want to click the large bar labelled Edit Destruction Data at the top. The first thing you'll want to do is click Enabled at the top so the rest of the options are accessible. Before anything else, select the amount of "health" your object will have. This is similar to enemy health - if your weapon does 25 damage, that'll be 1/4 of an object with 100 "health". Once you've set that, right click and select New in the table.

Destruction Data is split into "stages". Each stage is a state where something will happen, depending on the percentage of health the object has. So if I have a stage (this is what you're creating when you select New) with Health Percentage at 90, this object will go to this particular stage when it hits 90% health. The model damage stage will be what scripts, etc. use as the data to reference the stage. It's an integer/number it uses. Set your first stage to 1 (NOT 0). Everything else governs what happens during your stage. We'll go over this in the Other Settings part of this tutorial, but none of it is necessary right now.

So I create a stage with Health Percentage at 0, which is when my object will be "all out" of health. I set the stage to 1 (this only needs 1 stage since I'm not going to have any other stages of degradation, just destroy when it's out of health), and check the boxes Destroy Object and Disable Object. Make sure you check BOTH objects, or the destroy will be called but the object won't actually disappear, or vice versa.

Now, we're going to add a script to our activator. Fear not, it requires no actual scripting on your part. Before we do it, make sure that you've pressed OK to create your activator, then reopen it. Once you've done that, click the Add button in the right hand side of the window. In the filter in the window that pops up, write "Stockade" without the quotes.

Double click StockadeBarricade01ActivatorScript. Now, when you have that highlighted in the right hand side of your window, press Properties. DestructibleObjectsProperties.png Change NewStage to the stage where the object is fully destroyed (this is when the destroy sound will be played), and OldStage to the number before that. So if you only have stage 1, change OldStage to 0 and NewStage to 1. If you have 4 stages and 4 is where the object is destroyed, change OldStage to 3 and NewStage to 4.

Change OBJCWBarricadeDamage to the sound that you want to be made every time to hit the object, and OBJCWBarricadeDestroy to the sound you want to be played when the object is destroyed.

Place your activator where you want it in-game, and duplicate it. Then, move the duplicate somewhere the player will never see it - and link the duplicate to your original. (Do this by double clicking the duplicate in the cell view, finding the Linked Ref tab, right clicking and selecting New, then selecting your original in the cell view after pressing Select in Cell View). This is ABSOLUTELY NECESSARY if you're disabling/destroying an object, but not if you're just degrading it.

If you have say, a wall which should be on both sides of a tunnel for one reason or another, or something that when you break should destroy the other wall, then just use the duplicate as the first object and the original as the second. When one is destroyed, the other will be destroyed too. However, their destruction data will be different - if you hit object A, but don't destroy it, object B will still be unharmed. However once one is destroyed, the other, too, will be destroyed.

Now, go in game and hit your object a little. Depending on the amount of health you gave it, it could take a while. If it doesn't work, go back through the tutorial and make absolutely sure you've followed all the instructions.

"Degrading" (Changing the Model)[edit | edit source]

This'll go over how you make the model of an object change as you hit it. It's a very similar process to destructible objects, but will result in a more immersive, realistic change than the model just suddenly disappearing. Examples of this being used in game are the barricade/stockade in the Civil War.

First you'll want to create a new Activator. You can do this by going under WorldObjects>Activator in the Object Window filter. Right click and select New. Give your activator an ID - I'll call mine TestBreakablePillar - and give it a name. The name of mine is Suspicious Pillar.

Where it says Model, underneath name, click Edit and choose a model that you would like your undamaged object to have. I gave mine a generic pillar model. If you can't find anything, then make sure you've extracted your Meshes.bsa to your Skyrim/Data folder. You can leave all the other settings as default (that's nothing checked except Collision Geometry and Local Map).

Destruction Data is split into "stages". Each stage is a state where something will happen, depending on the percentage of health the object has. So if I have a stage (this is what you're creating when you select New) with Health Percentage at 90, this object will go to this particular stage when it hits 90% health. The model damage stage will be what scripts, etc. use as the data to reference the stage. It's an integer/number it uses. You can ignore the other settings for now - we'll go over them later on if you're interested in them (see Other Settings).

From there, we'll also click Edit Destruction Data, and then Enabled, and give the object a health. However, here is where we'll do stuff differently. I'm going to make 4 stages of decay - one at 75 health percent (the stage for when my object is at 75% of it's "health", which will automatically trigger when it reaches that point), one at 50, one at 25, and one at 0. I set the Model Damage Stages from 1-4, starting with 75 percent as 1.

Now, I don't check Destroy/Disable Object, Cap Damage or Ignore External Damage for ANY of these stages. Instead, for each one, I'll click the Edit button next to Replacement Model. From there I'll choose the .nif model that I want the object to change to when it reaches that health threshold.

Because I want there to be a different model for my different stages (if you're not doing anything in one of the stages, there's no need for it to be there - but that means you're not doing ANYTHING in it, if you're doing anything at all in it keep it there), I'll choose a replacement model for each stage.

You don't need to have a custom made model, as you can use vanilla in-game ones, but you absolutely can if you want to/prefer to. Plus, it'll look a lot better if you do.

Then click OK to save your stages. Now, we're going to add a script to our activator. Fear not, it requires no actual scripting on your part. Before we do it, make sure that you've pressed OK to create your activator, then reopen it. Once you've done that, click the Add button in the right hand side of the window. In the filter in the window that pops up, write "Stockade" without the quotes.

Double click StockadeBarricade01ActivatorScript. Now, when you have that highlighted in the right hand side of your window, press Properties. DestructibleObjectsProperties.png Change NewStage to the stage where the object is fully destroyed (this is when the destroy sound will be played), and OldStage to the number before that. So if you only have stage 1, change OldStage to 0 and NewStage to 1. If you have 4 stages and 4 is where the object is destroyed, change OldStage to 3 and NewStage to 4. Note that even though we're not using Destroy Object/Disable Object, the last stage at 0 health should still be considered "destroying" the object. Unless you never want the sound played, in which case you can set OldStage or NewStage or both to a stage number that doesn't exist or never will.

Change OBJCWBarricadeDamage to the sound that you want to be made every time to hit the object, and OBJCWBarricadeDestroy to the sound you want to be played when the object is destroyed.

If you want your degraded object to disappear after leaving the cell if it's fully "destroyed", then after you place the destructible object in-game, duplicate it. Move the duplicate out where the player won't see it (like into cell empty space), and link it to your non-duplicate. You can do this by double clicking the duplicate in the cell view, going to the Linked Ref tab, right clicking>New, and then selecting your non-duplicate with Select Object in Cell View.

Now, go in game and hit your object a little. Depending on the amount of health you gave it, it could take a while. If it doesn't work, go back through the tutorial and make absolutely sure you did everything written.

Destruction and Degradation[edit | edit source]

You absolutely CAN have both destruction and degradation happen on one object. The destruction/disable object stage should ALWAYS be last, as once something is disabled it can no longer be hit and any further stages would be unnecessary.

So, for example, you have 4 stages in 25% increments (75, 50, 25, 0), with 75 stage 1 and 0 stage 4. You set 75, 50, and 25 to have replacement models, and then set 0 to be destroy/disable. Everything else is set up the same. Just make sure you have the linked ref because you're destroy/disabling the object.

Sounds and Stage Count[edit | edit source]

Firstly, you can have up to 8 stages. Don't set 0 as a stage (I'm afraid I don't know the exact answer to why, but no vanilla objects have a stage 0 and this won't allow you to set a specific sound for stage 0 if it's say, the destroy stage). Just make sure you properly change the OldStage/NewStage properties so NewStage is your destroy stage (last stage) and OldStage is the stage before that.

Make sure this is the same stage as the destroy stage, as the script also uses this to handle some others stuff which should only happen when destroyed.

Note that the damage sounds are not played every time you hit the object, which plays that objects material hit sound (like a clang for metal), but whenever it changes a destruction stage.

Other Stage Settings Now, you may have noticed there are a variety of other settings that you can choose from when you create a stage: DestructibleObjectsStage.png So I'll explain them.

  • Self Damage Per Second: This will cause the damage to slowly damage itself while at this stage. Damage from the player will still be accounted for, unless...
  • Ignore External Dmg: This means that external damage (not self damage) will be ignored and not actually damage the object while at this stage.
  • Cap Damage: This will stop skipping stages if too much damage is done to the object. If you've got 20 health on your object and you cap with a health percentage of 80%, that means the first hit (if it normally would exceed taking away 20% damage) will only bring health down to 80% on this stage. After that, it would require at LEAST one more hit, or until it hits another cap damage stage.
  • Explosion: This will place an explosion at the activator when it reaches this stage and you have one chosen.
  • Debris: This will place a debris object at the activator if you have one chosen. (Not a lot to choose from AFAIK.)
  • Debris Count: If you have debris to be spawned, this is the number of debris objects that will be placed.

Scripting for Destruction Data[edit | edit source]

If you want, you can script events to happen when a destruction stage changes (either at all or to a particular stage). I won't go in-depth on how to script here, but I will provide a summary of the script. As such, I assume you are at least familiar with the basics of Papyrus. I'll also link a few functions related to Destructible Objects.

I'll share two scripts - one that will set the stage of a quest to 10 (change that value as you wish) when the destructible object reaches it's 4th stage (I'd usually do something when it reaches it's last, destroying stage but you can use whatever stage you wish, or different things for specific stages with ElseIfs); and one that will damage the player's stamina each time the destruction stage changes, no matter what the new destruction stage is.

Setting a Quest Stage with a Specific Destruction Stage[edit | edit source]

Scriptname MyDSObjScript Extends ObjectReference 
{Change the script name to fit your script's, extends ObjRef as activator's are ObjRef's}

Quest Property MyQuest Auto 

Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

     If aiCurrentStage == 4

          MyQuest.SetStage(10); change the value of 10 to the stage you want to set

     EndIf

EndEvent

Make sure to fill your quest property.

Damage the Player's Stamina When Stage Changes[edit | edit source]

Scriptname MyDSObjScript Extends ObjectReference

Actor Property PlayerREF Auto

Event OnDestructionStageChanged(int aiOldStage, int aiCurrentStage)

     PlayerREF.DamageAV("Stamina", 10); 10 is a changeable value for how much damage

EndEvent

Make sure to fill your actor property - you can just auto fill it to the player.

Destructible Object Functions/Events[edit | edit source]

OnDestructionStageChanged - ObjectReference DamageObject - ObjectReference GetCurrentDestructionStage - ObjectReference ClearDestruction - ObjectReference

Creating Your Own Debris[edit | edit source]

Now you may have noted the small amount of Debris you can choose for your destructible objects. It seems quite easy to create your own, so here's how:

Make sure you've got some models ready for your debris. You could, feasibly, just have one but 4-10 is best for variety. I cannot provide any advice on how to model these, for size and such, but you can look in one of the models used for debris. Here's the file path of one debris, relative to the Skyrim/Data/Meshes folder:

Magic/ActorMeshesMag/IceFormChunk01.nif

Once you have that ready, open the Creation Kit and navigate to the Object Window. Go to SpecialEffect>Debris, and right click and Create New. Give your Debris an EditorID and then right click in the table and select New. DestructibleObjectsDebris.png A Dialog window like the one above should appear. It will allow you to choose options for one of your pieces of debris.

Percentage: The chance this particular piece of debris will appear. If you only have 1 debris chosen in your Destruction Data then only one can be picked, but if you have say 3 debris and 5 possible debris, the ones with 100% will be shown no matter what, whereas the ones with lesser percents are less likely to drop.

Has Collision Data: If your debris has collision data and you don't want the player to just be able to walk through it, check this.

Big Blank Box: Press this to choose the model of this piece of debris.

Once you've done all that, press OK to create your first piece of debris. From there, continue creating New ones until you've used all your models. Then press OK again, and you have your debris! You should now be able to use it by choosing your debris from the dropdown in the Destruction Data.

Possible Applications of Destructible Objects[edit | edit source]

While this is by no means a full list of what you can do with destructible objects, it is food for thought to open you up to the world of possibility that destructible objects bring. Feel free to use these in your own endeavours, and suggest more if you feel like it. I haven't tested any of these except the Breakable Barricades, so I can't absolutely guarantee they work. But theoretically, they do. When I get a chance to I'll put that down here with a bit more details, probably.

Breakable Barricades[edit | edit source]

These are the usual, vanilla "breakable barricades". These are used in the civil war, most notably, but also spider webs. They use the method of degradation and/or destruction. A good use, and probably the most common one.

Changing Objects[edit | edit source]

While more visual and probably less gameplay oriented, you could use self-damage and degradation to change an object into multiple different object. Say, a pillar into a chest into a wagon into an altar. If you want, you could allow external damage, though for more visual effect I'd recommend not.

If you wanted it to actually do something, you could script it so OnDestructionStateChanged, depending on the object (and thus stage), it would do something. It could yield some very interesting results this way.

If you want it to reset, you could probably have x number of stages and then when it reaches the last stage, ClearDestruction to start the process all over again. I'm looking into ClearDestruction. It may not actually "reset" the destruction stages as I previously thought.

Object Tied to the Player's Health (or other actor value)[edit | edit source]

If you wanted to add a unique element to a dungeon, or a storyline, you could tie an object to the player's health or other actor value. You could use self-damage to slowly gnaw away at the player's health until they did something, for example.

If you wanted you could allow external damage, or not.

Crumbling Jumping Puzzle[edit | edit source]

If you wanted to make the player's experience particularly unpleasant, you could create a jumping puzzle that slowly begins to break apart as time passes. Using a triggerbox as they enter the area of the jumping puzzle, combined with a first stage that has no external damage and no self damage, then DamageObject to get past the first stage at that point, you could then enter stages with self-damage and Destroy/Disable Object after that.

If you want, you could allow external damage for the stages after the first "inactive" stage.

In Conclusion[edit | edit source]

Destructible Objects can bring a lot to your dungeons and levels. Have fun with them and be creative. I hope this has been helpful to you. If you have any questions or thought it was helpful, post below!

Remember that if you have a barricade you want the player to get through and use degradation, make sure the degraded version actually can be got through.