Difference between revisions of "Death check with weapon script"

no edit summary
imported>Spd1274
imported>Spd1274
Line 3: Line 3:
== Introduction ==
== Introduction ==


In the process of working on a project that requires the Player to kill an NPC, and than adds an item upon the death of the NPC, it became necessary to layout the steps for the project, and this seemed the best, and most helpful way to others, to do that.
In the process of working on a project that requires the Player to kill an NPC, and than adds an item upon the death of the NPC, and only an NPC, it became necessary to layout the steps for the project, and this seemed the best, and most helpful way to others, to do that.


This Tutorial will follow the steps below:<br />
This Tutorial will follow the steps below:<br />
1. Create a Magic Effect Script that will check for the death of an NPC at the Player's hand, than add an Item to the inventory with a nice little message. <br />
1. Create a Magic Effect Script that will check for the death of an NPC at the Player's hand, than add an Item to the inventory with a nice little message. <br />
2. Create the item to be added, in this case, the soul of the NPC in the form of a bottled potion.<br />
2. Create the item to be added, in this case, the soul of the NPC in the form of a bottled potion.<br />
3. Create a scripted enchantment that runs our script. (Because there is no way to activate a script when the Player hits an NPC i.e. Onstrike or anything of that kind. See: [http://cs.elderscrolls.com/constwiki/index.php/Begin Begin]).<br />
3. Create a scripted enchantment that runs our script. (Because there is no way to activate a script when the Player hits an NPC i.e. Onstrike or anything of that kind. See: [http://cs.elderscrolls.com/constwiki/index.php/Begin Beginning Scripts]).<br />
4. Finally create, and place into Tamriel, the weapon that will execute the script.
4. Finally create, and place into Tamriel, the weapon that will execute the script.


Line 25: Line 25:
Which is at the very end of the toolbar:<br />
Which is at the very end of the toolbar:<br />
[[Image:toolbarwscriptcircle.png]]
[[Image:toolbarwscriptcircle.png]]
Now that we have the editor open, here is our skeleton script:<br />
<PRE>scn SDsoulreavescript
ref Target
short Dead
short Once
Begin ScriptEffectStart
set Target to GetSelf
if Target.GetDead == 1 && Target.GetIsPlayableRace == 1
  set Dead to 1
endif
set Once to 0
end
Begin GameMode
If Dead == 1 && Once == 0
  player.additem SDreavedsoul 1
  MessageBox "You have killed your victim, and claimed their soul."
          set Once to 1
endif
end</pre>
Anonymous user