Jump to content

Need help with a script for a simple enchantment.


Durai

Recommended Posts

So I'm terrible at understanding Papyrus, mostly because I can't follow the logic of how to script. For this mod I'm working on, I went to the Creation Kit wiki to look at the tutorials, but I'm not learning anything pertaining to my mod. I want to make it so that when an enemy attacks your enchanted barrier, they take damage (as opposed to the barrier negated magic damage). Here's what I've been able to write down, but several things don't make sense:

 

Scriptname warddamage extends ObjectReference

{First mod to cause damage when hitting ward enchanted armor.}

 

ObjectReference Property WardDamageHit Auto

 

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

Game.GetPlayer().DamageActorValue("health", 20)

EndEvent

 

Now I don't even know where to start, as I scraped this together from looking at several different posts about damaging. I get the beginning part (sort of) about the Scriptname and Object reference, but the wiki is very bad at giving lists of things we can do when scripting an event. For example, the "OnHit" that I wrote was an example on the wiki, but they only show you how to do damage to the player or an actor named "Bob." It doesn't show me any other examples or list other functions I can do besides damage (maybe I want the player to gain a small percentage of health for another enchantment? Maybe I want the aggressor's speed reduce by 75%?)

 

I'm sorry if I seem rather ignorant for a newb, but things like this where the supposed source of information doesn't really help you gets me frustrated. If anyone can help my script, or better yet, help me understand how to look on the wiki for what I want to do, I'd be greatly appreciative. Thanks for your time.

 

*Edit:

 

After doing some more digging I found a thread similar to mine on the CK Forums. Here's what I did to get it to work in game:

 

Scriptname OnHitWardDamage001 extends activemagiceffect

 

Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

actor actorRef = akAggressor as Actor

 

if akWeapon

(akAggressor as Actor).DamageAV("health", 50)

endif

 

if akProjectile

(akAggressor as Actor).DamageAV("health", 0)

endif

 

if abPowerAttack

(akAggressor as Actor).DamageAV("health", 50)

endif

 

if abSneakAttack

(akAggressor as Actor).DamageAV("health", 100)

endif

 

if abBashAttack

(akAggressor as Actor).DamageAV("health", 50)

endif

 

if abHitBlocked

(akAggressor as Actor).DamageAV("health", 50)

endif

 

EndEvent

 

I know the values are unrealistic; I was just gauging they're power in-game. Now to do some more tweaking.

Edited by Durai
Link to comment
Share on other sites

You seem to be on the way to answering your own question.

 

For future reference there is a list of possible events on the CK Wiki here

Thanks for the reply; I honestly didn't think anyone would bother with my problem.

 

I have a question though; if I wanted to have a magic effect activate when a character blocks with a two handed weapon, what does that fall under? Am I looking for OnAnimationEvent - ActiveMagicEffect or OnMagicEffectApply - ObjectReference? Or am I just way off base? The examples they provide don't really help me and discourage me from even wanting to attempt to do this....

Link to comment
Share on other sites

For that I "think" you need to set up an enchantment that is conditioned on IsBlocking and attached to the 2 handed weapon.

 

For an example look at the enchantment DS13SpellBreakerEnch

Yeah I keep hearing that from people but there's a problem. Weapons work only with enchantments that are "fire and forget" and "contact," while armor uses "constant" and "self." The two cannot be mixed; I tried setting the Spellbreakers magic effect to Fire and Forget and Contact, but all that does is cause the hands to glow when blocking. That's why I assumed there must be a script you can write that will cast the Spellbreaker effect when blocking.

Edited by Durai
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...