Since I have three different type of guard units (guard, guard02 and guard03) I use a template for certain things, such as scripts.
You can either do that, or add the script to each of your guard unit.
First I edited my three guard units; under the first tab (Traits), in the bottom left corner, under "Template Data" I changed "ActorBase" to my template unit, and checked the box "Scripts". -This means that all my guard units will use the same scripts as my template unit.
Then I edit my template unit. On the first tab (Traits) just above the Template Data, there's "Scripts".
Add a script, choose [New Script], name it whatever you like.
I use "ObjectReference" under "Extends".
I left the two boxes unchecked.
"Documentation String" is just a comment for you to know what the script does, I wrote: "A simple script that will replace the Alik'r Scimitar with a normal Scimitar when a Black Market Guard dies. To prevent the player from getting one of these powerful swords."
Now right-click on your new script and choose "edit properties".
Click the "Add property" button and choose the settings most suited for you. In my case I choose: "Type: WEAPON", "Name: BM_GuardWeapon", I left the rest as it was. I then created another just like the first one, except this one I named "BM_GuardNewWeapon"
Then select your properties and to the right choose "edit value". Here I choose my two weapons - the one that the guards have in their inventory (old) and the new weapon (the one I want to replace the old with).
Click ok.
Now (in the Actor window under the Traits-tab), right-click on your script again; this time choose "Edit Source".
At the top you will most likely see:
Scriptname extends ObjectReference Conditional{}WEAPON Property BM_GuardWeapon AutoWEAPON Property BM_GuardNewWeapon Auto
Now we can finally add the code, here's what my code looks like:
Event OnDeath(Actor akKiller)RemoveItem(BM_GuardWeapon, 1, true)AddItem(BM_GuardNewWeapon, 1, true)endEvent
What it does:
1. When the actor dies:
2. Removes item (BM_GuardWeapon) - which we set under properties.
3. Adds item (BM_GuardNewWeapon) - which we set under properties.
4. Done!
My complete script looks like this:
Scriptname BM_GuardReplaceWeaponScript extends ObjectReference Conditional{A simple script that will replace the Alikr Scimitar with a normal Scimitar when a Black Market Guard dies. To prevent the player from getting one of these powerful swords.}WEAPON Property BM_GuardWeapon AutoWEAPON Property BM_GuardNewWeapon AutoEvent OnDeath(Actor akKiller)RemoveItem(BM_GuardWeapon, 1, true)AddItem(BM_GuardNewWeapon, 1, true)endEventWhen you are done with the script you must save it (File -> Save) or (ctrl+s).
When the script saves it must first compile, it does this automatically so it might take a few seconds.