Attaching an OnHit Block to the player?

Post » Tue Feb 15, 2011 3:07 am

Hey guys, I have an npc with a script attached that includes an ONHIT block. The idea being that when the npc is hit, his shield falls off. Its working nice and smooth.

What I cant seem to get my head round is the idea of attaching the same script to the player?

Ive tried putting it on Armor, outright and as an enchanted script effect. Cant get my head round it. Any help would be apprieciated!
User avatar
Laura Simmonds
 
Posts: 3435
Joined: Wed Aug 16, 2006 10:27 pm

Post » Tue Feb 15, 2011 6:09 am

If you post your script, we will be better able to determine where it's going wrong and suggest a solution or an alternate approach.
User avatar
My blood
 
Posts: 3455
Joined: Fri Jun 16, 2006 8:09 am

Post » Mon Feb 14, 2011 10:45 pm

Hey Vyper, thanks for the reply. The script is a very simple one at the moment just for testing purposes. It is attached to Arena Combatents and works great;



Short DoOnetime

Begin OnHitWith 00Amace
If (Doonetime == 0 )
Unequipitem 0003633f 1
Drop 0003633f 1
Set DoOnetime to 1
Endif
End


What I would like to do, during the fight in the arena, is mirror the same script on the player. So that If the player is hit, then the players shield will come off. Im not sure how to set the script on the player, im guessing it will need to use quest scripts/stages but im a little unclear on that. Hope you can help! :D
User avatar
Rob Smith
 
Posts: 3424
Joined: Wed Oct 03, 2007 5:30 pm

Post » Tue Feb 15, 2011 5:25 am

Well, first, don't use formIDs in scripts; those are only necessary for the Console. They make the script really hard to read. Use editorIDs instead.

Anyway, you can't add OnHit (or OnHitWith) to the player, so work-arounds are necessary. Unfortunately, I'm not precisely sure how best to do that...
User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am

Post » Tue Feb 15, 2011 8:54 am

Well, first, don't use formIDs in scripts; those are only necessary for the Console. They make the script really hard to read. Use editorIDs instead.

Anyway, you can't add OnHit (or OnHitWith) to the player, so work-arounds are necessary. Unfortunately, I'm not precisely sure how best to do that...


I don't know what's best either, but I've read that using getsoundplaying might work, if you're using OBSE. Check to see if the player is playing an appropriate sound of getting hit with a mace. But I can't think of a good way to find out if the player's getting hit with your specific mace. Maybe check if there is an NPC within melee distance, if that NPC has the mace equipped, if its combattarget is the player, and if it's playing an attack animation? That way seems overly complicated though.
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Tue Feb 15, 2011 12:21 am

Anyway, you can't add OnHit (or OnHitWith) to the player, so work-arounds are necessary. Unfortunately, I'm not precisely sure how best to do that...
I recall trying it once and getting it to work correctly. But the method itself isn't recommended as there'll probably a ton of incompatibilities when you directly modify the base player record (which is probably what you implied in that post).
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm


Return to IV - Oblivion