Punching The Player

Post » Wed Jun 20, 2012 5:28 am

I want to have an NPC strike the player, just once, and I'm not sure how to set it up.

I don't want to start combat, because I don't want the NPC's friends joining in, or followers getting excited.

Ideally, I'd just trigger the attack animation and script the damage from it.

Any thoughts on how to go about it?
User avatar
yermom
 
Posts: 3323
Joined: Mon Oct 15, 2007 12:56 pm

Post » Wed Jun 20, 2012 7:22 am

If I recall the debug is Debug.SendAnimationEvent(theactor, "theanimation")

and I think to hurt the player it would be
Game.GetPlayer().DamageActorValue("Health", 1) ;1 can be any number you want.


If you're in the CK you can click on Gameplay at the top and then Animations. Go down to Character and look at the animations there. You want to set the ID of the animation as a property in your script and then call the animation (with SendAnimationEvent) by it's Anim Event name (these sometimes differ).


So the property for the punching animation once you find it would be Idle Property theanimation Auto

Hopefully this helps. I started scripting for the first time ever when the CK came out so I'm still new myself.
User avatar
Carlitos Avila
 
Posts: 3438
Joined: Fri Sep 21, 2007 3:05 pm

Post » Wed Jun 20, 2012 6:56 am

http://www.creationkit.com/UseWeapon_%28Procedure%29

Target (http://www.creationkit.com/Category:Package_Templates#Procedure_Parameter_Types): Specifies What to attack
RepeatFire (http://www.creationkit.com/Category:Package_Templates#Procedure_Parameter_Types): Actor will continue to fire as specified in Fire Rate. With this true, procedure has no "completed" state.
DoNoDamage (http://www.creationkit.com/Category:Package_Templates#Procedure_Parameter_Types): Attacks may hit target, but will not deal any damage.
AllowCombatStart (http://www.creationkit.com/Category:Package_Templates#Procedure_Parameter_Types): If true, starts normal combat when target is hit (or fired upon?).
User avatar
Ron
 
Posts: 3408
Joined: Tue Jan 16, 2007 4:34 am

Post » Wed Jun 20, 2012 5:53 am

If I recall the debug is Debug.SendAnimationEvent(theactor, "theanimation")

and I think to hurt the player it would be
Game.GetPlayer().DamageActorValue("Health", 1) ;1 can be any number you want.


If you're in the CK you can click on Gameplay at the top and then Animations. Go down to Character and look at the animations there. You want to set the ID of the animation as a property in your script and then call the animation (with SendAnimationEvent) by it's Anim Event name (these sometimes differ).


So the property for the punching animation once you find it would be Idle Property theanimation Auto

Hopefully this helps. I started scripting for the first time ever when the CK came out so I'm still new myself.

Thats not needed. Using:

Debug.SendAnimationEvent(Reference, "attackStart")

will actually make him punch , and will hurt you if your in it's way. All damage will be calculated, for you.

So Simply do this:

Reference.SetLookAt(Game.GetPlayer())     Debug.SendAnimationEvent(Reference, "AttackStart")Reference.ClearLookAt()
User avatar
Rex Help
 
Posts: 3380
Joined: Mon Jun 18, 2007 6:52 pm

Post » Wed Jun 20, 2012 10:03 am

Reference.SetLookAt(Game.GetPlayer())Debug.SendAnimationEvent(Reference, "AttackStart")Reference.ClearLookAt()

Hmm, correct me if I'm wrong, but setLookAt does nothing in regard of attacking. I just have Lydia 'startCombat' with my horse, and she wasn't 'looking' at anyone (tested with console). Combat was initiated as normal
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Wed Jun 20, 2012 1:01 pm

Thanks guys. I think I'm going to try the UseWeapon procedure first, with doNoDamage = true and AllowCombatStart = false and see if I still get an OnHit event on the player. Even if I don't I can probably still script a health adjust as part of the procedure end script.

I'll let you know how I get on :)
User avatar
maria Dwyer
 
Posts: 3422
Joined: Sat Jan 27, 2007 11:24 am

Post » Wed Jun 20, 2012 4:12 pm

My NPC doesn't move when i launch "attackStart"

SendEventAnimation(MyNPC, "attackStart")

IdleSalute, weapEquip are OK but not attackStart.

Im invoking code using a custom stage in a test quest

setstage myquest 5

and queststage 5 contains code to sendanimationevent

is there something special else to do on the actor ?
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Wed Jun 20, 2012 7:25 pm

Ok i finally got it

Actor ref1 = MyActorAlias.GetReference() as Actor
ref1.SetAlert(true) ;make the actor in guard mode
Utility.Wait(3)
Debug.SendAnimationEvent(ref1, "attackStart")
User avatar
Killah Bee
 
Posts: 3484
Joined: Sat Oct 06, 2007 12:23 pm

Post » Wed Jun 20, 2012 8:34 am

Ok i finally got it

Actor ref1 = MyActorAlias.GetReference() as Actor
ref1.SetAlert(true) ;make the actor in guard mode
Utility.Wait(3)
Debug.SendAnimationEvent(ref1, "attackStart")

This was always known. Animation Event's sometimes only work if the actor is in the right state. For example, AttackStart only works while the Actor has a weapon drawn.
User avatar
Josh Dagreat
 
Posts: 3438
Joined: Fri Oct 19, 2007 3:07 am

Post » Wed Jun 20, 2012 7:52 am

Always known but not by me, now it's ok ;)
User avatar
Erika Ellsworth
 
Posts: 3333
Joined: Sat Jan 06, 2007 5:52 am

Post » Wed Jun 20, 2012 3:57 pm

Hmm, correct me if I'm wrong, but setLookAt does nothing in regard of attacking. I just have Lydia 'startCombat' with my horse, and she wasn't 'looking' at anyone (tested with console). Combat was initiated as normal
The idea here is to make the NPC attack only once without initiating a combat though. As it will perform an animation, without taking into acount any other actor, if the setlookat command is not used, the attack could miss if the NPC is looking into another direction. Usually actors look at the player if near, but better be sure.
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Wed Jun 20, 2012 1:23 pm

The idea here is to make the NPC attack only once without initiating a combat though. As it will perform an animation, without taking into acount any other actor, if the setlookat command is not used, the attack could miss if the NPC is looking into another direction. Usually actors look at the player if near, but better be sure.

This.
The point of the SetLookAt() was to keep the Actor looking at the Target to keep from missing.
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am


Return to V - Skyrim