Global OnHit and finding Keywords in script

Post » Mon Jun 18, 2012 6:28 pm

I have two questions, if I may.

1: Can a global OnHit script be created by applying a script to an ability spell, then adding that spell to every race's spells?

2: Inside of an OnHit script, is there a way to find the attacking weapon's keywords? Also the target's armor's keywords?


I'm actually hoping I can use a script instead of perks and conditions.
Thank you!
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Mon Jun 18, 2012 4:06 pm

2. Check for a specific keyword with Form.HasKeyword(someKeyword)
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Mon Jun 18, 2012 6:09 pm

Oh, thank you!

If I may ask, though, in an OnHit script, what reference would I use before ".WornHasKeyword()" if I want the target's armor?
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Mon Jun 18, 2012 8:53 am

This explains the parameters that get sent to OnHit event: http://www.creationkit.com/OnHit_-_ObjectReference
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am

Post » Mon Jun 18, 2012 9:11 am

GetActorRef() returns the guy who was hit, so then for example the following would work:

If ( GetActorRef().WornHasKeyword(ArmorTypeHeavy) )	 EndIf

Where you would have to define ''ArmorTypeHeavy'' as a keyword first, like on the top of your script: ''Keyword property ArmorTypeHeavy auto'' and then assign it as a property as well on the object with the script.

If you need a reference to the attacker (for example want to know whether the attacker is wearing heavy armor) you can use the parameter ''akAggressor'' which automatically comes with an OnHit event. Then the code would look like:

If ( akAggressor.WornHasKeyword(ArmorTypeHeavy) )	 EndIf
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Mon Jun 18, 2012 7:18 pm

The Target's Armor? What you mean by that? Is Target here the actor that is being hit or actualy the actor that is hitting? The Former can be accessed for instance by calling the OnEffectStart Event first and appllying caster or target (both should be the same in your use case) to an actor type local variable then calling WornHasKeyword() on that Actor Reference. The latter simply is the akAgressor reference of the OnHit Event.
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm

Post » Mon Jun 18, 2012 6:00 am

Thank you all! Yes, sorry about my improper wording. When I said "target," I meant the guy who got hit... the one with the OnHit script attached.


Oh, and do you think this would really work?

"1: Can a global OnHit script be created by applying a script to an ability spell, then adding that spell to every race's spells?"
User avatar
Lexy Corpsey
 
Posts: 3448
Joined: Tue Jun 27, 2006 12:39 am

Post » Mon Jun 18, 2012 10:38 am

Haha, another bump in order to find out how to make a global OnHit script :-P

I took a basic OnHit Script, applied it to an effect, then applied the effect to a spell, then added that spell to a race. The magic effect is listed as being active in game, though I can't get a message box to appear. The message box DID appear when I gave it to a specific NPC.

Should it have worked? Is there a different header I need to put at the top of the script if it's applied to a magic effect instead of an NPC? Can I do so and still get an OnHit script to work?

Sorry, I've never scripted before :-P
User avatar
CArlos BArrera
 
Posts: 3470
Joined: Wed Nov 21, 2007 3:26 am

Post » Mon Jun 18, 2012 9:31 am

The http://www.creationkit.com/OnHit_-_ObjectReference event is only called by the game in scripts that extend http://www.creationkit.com/ObjectReference_Script, so although it will compile just fine in a script that extends http://www.creationkit.com/ActiveMagicEffect_Script, it will never fire unless called manually, in which case it's not really "OnHit" anymore.

Cipscis
User avatar
Angela
 
Posts: 3492
Joined: Mon Mar 05, 2007 8:33 am

Post » Mon Jun 18, 2012 7:35 am

Thank you :-)

So... would that mean that universal OnHit scripts are not easily implemented? Do you know of a way to apply them to every NPC/creature without having to do it manually?

Haha, I'm not asking a lot... just the world :-P
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Post » Mon Jun 18, 2012 1:02 pm

The only approach I can think of would be absolutely terrible for compatibility, which would be to modify the http://www.creationkit.com/Actor_Script itself (as this is attached to all actors automatically by the game engine, but I really wouldn't recommend modifying any of those native scripts.

Cipscis
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Mon Jun 18, 2012 7:55 am

The http://www.creationkit.com/OnHit_-_ObjectReference event is only called by the game in scripts that extend http://www.creationkit.com/ObjectReference_Script, so although it will compile just fine in a script that extends http://www.creationkit.com/ActiveMagicEffect_Script, it will never fire unless called manually, in which case it's not really "OnHit" anymore.

Cipscis
The Wiki says that ActiveMagicEffect scripts also receive events from the Actor they are on (literally the last sentence on http://www.creationkit.com/ActiveMagicEffect_Script)
Is that wrong?
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Mon Jun 18, 2012 12:20 pm

Ooh! Thanks for pointing that out - I've looked at the page a dozen times but must always have missed that line.

Cipscis
User avatar
Lilit Ager
 
Posts: 3444
Joined: Thu Nov 23, 2006 9:06 pm

Post » Mon Jun 18, 2012 7:15 pm

Ah, Cipscis, you must be the Papyrus master! Thank you for all the info :-)

Indeed, the Actor script is a handy thing to know. Thank you! I suppose it wouldn't hurt too much just to use it for testing until a safer way is discovered.

Oh, and thank you, fowl! I'll test the script again :-D
User avatar
Yonah
 
Posts: 3462
Joined: Thu Aug 02, 2007 4:42 am

Post » Mon Jun 18, 2012 11:11 am

Ooh! Thanks for pointing that out - I've looked at the page a dozen times but must always have missed that line.

Cipscis
I think you're wrong

I put a debug in ReanimateAshPile
Event OnDying(Actor Killer); ; debug.trace("ReanimateAshPile TargetIsImmune:" + TargetIsImmune)debug.messagebox(Killer + " has killed it (ONDYING)")if TargetIsImmune == False && AshPileCreated == FalseTurnToAsh()AshPileCreated = TrueendifEndEvent

http://steamcommunity.com/profiles/76561198032129719/screenshot/524904970325767152
User avatar
carly mcdonough
 
Posts: 3402
Joined: Fri Jul 28, 2006 3:23 am


Return to V - Skyrim