Disarm weapon script?

Post » Wed Jul 03, 2013 12:58 am

Hi there, I'm planning on making a unique weapon for use in a quest that has a script attached that would cause the player to be disarmed of said weapon each and every time it strikes. Hit an enemy, lose weapon, pick it up, same again...pretty simple. Could anyone help me with a script for this. I don't have an existing script thats not working; I straight up don't know where to begin. I am familiar with using scripts and changing properties and altering the source but not writing from scratch cos I don't know the commands.

Any help would be appreciated and obviously credit given if/when I release this mod.

User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Tue Jul 02, 2013 11:55 pm

I haven't dived into Skyrim's creation kit yet (I'm not done playing around in the game itself yet), but I don't think there's a command/function that does exactly what you want to do.

OnHit paired with DropObject and a global variable might do it, but the OnHit portion would have to be placed on the enemies, not the weapon itself, which presents a whole new problem--You'd have to attach the script or add your code to every NPC/creature in the game, or try to run it as a global script (which may not work at all, I've never tried anything quite like that in Morrowind or Oblivion).

Now, if you can figure out how to "lock" the player in to a single dungeon (where they would have to get the weapon and work their way through), then adding the script to custom creatures/NPCs within the dungeon is much less daunting.

Actor side, you'd be looking at an OnHit event that sets the global with SetValue (or SetValueInt). Weapon side, you'd check for the global to be at what the OnHit set it to (via GetValue or GetValueInt), perform a DropObject, and then restore the global to its previous value. Because I haven't gotten into the creation kit side of Skyrim yet, I'm not sure on syntax and won't try to provide code that may or may not work, but the creation kit's wiki has the information you need for that.

User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm

Post » Tue Jul 02, 2013 9:59 pm

You can create a quest with aliases that are filled at runtime and attach the necessary script to those aliases. You just need to empty and refill those aliases periodically in order to correctly handle the probable scenario that the player moves to a new location.

EDIT: This script would probably work assuming that there's only one example of the weapon in the game world. Just point the kWeapon property at the weapon form you want to use. If you want to use a reference of a common weapon, then it gets a bit trickier, but you could probably bypass the tricky part by simply making a duplicate base object of the common weapon and only making one reference of it available in the game world.

Weapon Property kWeapon AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	If(akSource == kWeapon)		akAggressor.DropObject(kWeapon)	EndIfEndEvent
User avatar
Ludivine Dupuy
 
Posts: 3418
Joined: Tue Mar 27, 2007 6:51 pm


Return to V - Skyrim