Need Help Creating A Script For Healing Sword

Post » Wed Jun 20, 2012 4:04 am

I need help creating a special script that will be on a Sword. The player must be wielding the Sword and when ever the playing is low enough on health, the sword should glow, like Dawnbreaker down, (Not needed but would be a cool effect, eh?) and quickly afterwards, the sword will cast a healing spell upon the player to heal them fully. (Like the Avoid Death Perk so this should be highly possible). After the spell is casted, glow effect is removed (If the effect is do-able but like I said, not needed)

At the same time, whenever the player is wielding the Sword, they will have a Power on their Spell List that they can use whenever they want but this power is removed when they take it off. (Just like Ring of Hircine, so is too highly possible).

Any help on here?
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Wed Jun 20, 2012 11:20 am

Couldn't you just have the sword actually cast the healing hands spell on the player until he's fully healed?

Spell Property HealSpell Auto; And then in your healing start condition:while Game.GetPlayer().GetAV("Health") < game.GetPlayer().GetBaseActorValue()	HealSpell.Cast(Game.GetPlayer())	 Wait(4.0) ; Give the spell some time to do some healingendWhile
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Wed Jun 20, 2012 1:43 am

lol why not just make yourself invulnerable right away
console tgm :D

(not being serious here since Redwood already answered; btw respect for your scripting skills Red just making that script out of nothing.. all my scripts take ages getting done and working.)
User avatar
lillian luna
 
Posts: 3432
Joined: Thu Aug 31, 2006 9:43 pm

Post » Wed Jun 20, 2012 4:20 am

Scripting is easy once you figure out how the commands work. I can do the same thing with Morrowind scripts. I'm just new to Skyrim's Scripting System.

And this is for Chrysamere, which heals the wielder and protects them from magic. So the idea is when the wielder is low enough on health, the sword will heal them though not constantly. (Example: Give them a healing effect that is like 10 points per second for like 100 seconds or so. This means, enemies doing enough damage will kill the player.) While also giving the player a Power/Spell to protect themselves from Magic.

I've already created this script on Morrowind and it works. Just now need to learn how to translate it.

Btw, thx Redwood; gave me an idea how to translate it but you forgot about the Power/Spell.
User avatar
Nicole Mark
 
Posts: 3384
Joined: Wed Apr 25, 2007 7:33 pm

Post » Wed Jun 20, 2012 8:24 am

Couldn't you just have the sword actually cast the healing hands spell on the player until he's fully healed?

You mean as an enchantment? If so then not possible since Skyrim's weapons only uses On-Strike and not Cast-When-Used.

I'm looking for actually healing spell too, not absorb health.
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Wed Jun 20, 2012 10:34 am

You mean as an enchantment? If so then not possible since Skyrim's weapons only uses On-Strike and not Cast-When-Used.

I'm looking for actually healing spell too, not absorb health.

Didn't say anything about an enchantment. Just a script on the item.

You would need to have the OnEquip() or OnHit() event register the script for updates, and use THAT event to check when healing is needed and cast the healing spell, and bob's your uncle.

Oh, and you'll probably want to store the current weilder in a property and use that, instead of using Game.GetPlayer() because as it stands it will heal the PLAYER and not the current weilder.

and I didn't "Forget" the spell...that's what the property is for...you can either design your own healing spell, or assign an existing one to that property on the script.
User avatar
Laura
 
Posts: 3456
Joined: Sun Sep 10, 2006 7:11 am

Post » Wed Jun 20, 2012 3:38 am

Didn't say anything about an enchantment. Just a script on the item.

Okay then.. Well.. Any ideas for the Spell/Power? The current script you gave me might work but I don't know how the beginning of it will work. I've notice that Skyrim's scripts have a special thing at the beginning to tell the script what it is targeting, basicly.
User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Wed Jun 20, 2012 2:27 pm

Okay then.. Well.. Any ideas for the Spell/Power? The current script you gave me might work but I don't know how the beginning of it will work. I've notice that Skyrim's scripts have a special thing at the beginning to tell the script what it is targeting, basicly.
:Evillaugh

OK, you asked for it...

Spoiler
Scriptname WeaponThatCastsSpellsScript extends ObjectReferenceimport GameImport UtilitySpell Property WhatSpellToCast Auto{What spell will the weapon use?}ObjectReference Property SpellTarget  Auto{This gets set to whatever the script picks as it's valid target.}ObjectReference Property EnemyAVCheck Auto{To store the enemy if we're targetting the weilder, but checking the enemy AV}Bool Property ProcOnHit  Auto{Do we try to proc when we are hit?}Bool Property ProcOnLowAV  Auto{Do we Proc on a low AV?}String Property AVToDetect  Auto{ If so, Which AV are we checking?}Int Property AVLowPoint = 50 Auto{What AV value triggers the Low AV  condition?}Bool Property AVOnTarget  Auto  {Does it check the AV on the hit target? If Not, it checks the AV on the weilder.}Bool Property AffectsWeilder  Auto  {Does the effect target the wielder of the weapon? If not, it targets the last hit target.}Bool Property CastIfDead Auto{Cast the spell even if the target is dead. Spell affects dead things.}Bool Property StickyEffect Auto{Will the effect continue to proc after it successfully procs once?}int Property StickyDuration Auto{How many times will the proc continue after the first one? A value of -1 means it will continue until the proc target is dead or the weapon is unequipped/sheathed.}Int Property ProcPercentage  Auto  {Chance for the Proc to go off, expressed as an integer percentage.}Float Property ProcFrequency Auto{Number of seconds between procs for Sticky Procs.}Int ProcCount ; Used to count down the sticky procs.Event OnEquipped(Actor Weilder)	if AffectsWeilder		SpellTarget = Weilder		if ProcOnLowAV && !ProcOnHit			ProcCount = StickyDuration; Warning:  if it procs on low AV on the weilder and affects the weilder, but is not on an Onhit event, Sticky duration will only work when you equip with a low AV, and only once.			RegisterForSingleUpdate(ProcFrequency)		endif	endifEndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	if !AffectsWeilder		SpellTarget = akAggressor		if ProcOnHit			If ProcPercentage <= Utility.RandomInt(1,100)				if StickyEffect					ProcCount = StickyDuration					RegisterForSingleUpdate(ProcFrequency)				endif				WhatSpellToCast.Cast(SpellTarget)			endif		elseif ProcOnLowAV && AVOnTarget			if (SpellTarget as Actor).GetAV(AVToDetect) < AVLowPoint				If ProcPercentage <= Utility.RandomInt(1,100)					if StickyEffect						ProcCount = StickyDuration						RegisterForSingleUpdate(ProcFrequency)					Endif					WhatSpellToCast.Cast(SpellTarget)				Endif			endif		elseif ProcOnLowAV && !AVOnTarget ; Weird case. Checking the AV on the weilder but hitting the enemy.			if !EnemyAVCheck				if Game.GetPlayer().IsEquipped(self)					EnemyAVCheck = Game.GetPlayer()				else					EnemyAVCheck =FindClosestActorFromRef(Self,1000) ; Should be the weilder.				endif			Endif			if (EnemyAVCheck as Actor).GetAV(AVToDetect) < AVLowPoint				If ProcPercentage <= Utility.RandomInt(1,100)					if StickyEffect						ProcCount = StickyDuration						RegisterForSingleUpdate(ProcFrequency)					Endif					WhatSpellToCast.Cast(SpellTarget)				Endif			endif		endif	else		if !SpellTarget ; Need to find the weilder - he obviously equipped with a hotkey and bypassed the OnEquipped event.			if Game.GetPlayer().IsEquipped(self)				SpellTarget = Game.GetPlayer()			else				SpellTarget = FindClosestActorFromRef(Self,1000) ; Should be the weilder.			endif		endif		if ProcOnHit			if ProcOnLowAV && AVOnTarget ; odd case. We're checking the ENEMY'S AV, but affecting the weilder.				if !EnemyAVCheck					EnemyAVCheck = akAggressor				Endif				if (EnemyAVCheck as Actor).GetAV(AVToDetect) < AVLowPoint					If ProcPercentage <= Utility.RandomInt(1,100)						if StickyEffect							ProcCount = StickyDuration							RegisterForSingleUpdate(ProcFrequency)						Endif						WhatSpellToCast.Cast(SpellTarget)					Endif				endif			elseif ProcOnLowAV				if (SpellTarget as Actor).GetAV(AVToDetect) < AVLowPoint					If ProcPercentage <= Utility.RandomInt(1,100)						if StickyEffect							ProcCount = StickyDuration							RegisterForSingleUpdate(ProcFrequency)						Endif						WhatSpellToCast.Cast(SpellTarget)					Endif				endif			else				If ProcPercentage <= Utility.RandomInt(1,100)					if StickyEffect						ProcCount = StickyDuration						RegisterForSingleUpdate(ProcFrequency)					Endif					WhatSpellToCast.Cast(SpellTarget)				Endif			endif		endif	EndifEndEventEvent OnUpdate()	ProcCount -= 1	if !(ProcCount == 0)		if ProcOnLowAV && AffectsWeilder && !AVOnTarget ; This is the only case we need to check ProcPercentage on in the update.			if (SpellTarget as Actor).GetAV(AVToDetect) < AVLowPoint				If ProcPercentage <= Utility.RandomInt(1,100)					WhatSpellToCast.Cast(SpellTarget)				Endif			endif		elseif ProcOnLowAV && AffectsWeilder ; odd case. We're checking the ENEMY'S AV, but affecting the weilder.				if EnemyAVCheck ; Make sure there's an enemy to check AV on.					if (EnemyAVCheck as Actor).GetAV(AVToDetect) < AVLowPoint						WhatSpellToCast.Cast(SpellTarget) ; We're counting down a sticky proc, but need to check AV anyway.					endif				endif		else ; We're counting down a sticky proc. Proc chance already checked, etc.			WhatSpellToCast.Cast(SpellTarget)		endif		if !(SpellTarget as Actor).IsDead() || CastIfDead			if AffectsWeilder && (SpellTarget as Actor).IsEquipped(Self) ; Keeps it from updating if you unequip the item.				RegisterForSingleUpdate(ProcFrequency)			endif   	 endif	EndifEndEvent

Haven't tested it yet, but it compiles...you just assign the properties to the various settings you want the proc to function from.

In your case, you would set the AVToCheck to "Health", the integer for the low value threshold should be fine at 50 (That's half health at level 1), pick the spell you want from the drop down list in the properties window (Healing Hands or another "Heal target" should work.) and the Proc percentage to 100 (always procs) and the Sticky Duration to -1 (So it will keep checking forever so long as the script is running.)

Oh, and the AffectsWeilder to True, naturally.
User avatar
jasminε
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Wed Jun 20, 2012 5:41 am

Nice job on the script. :biggrin:

Hate to disappoint you though, but OnHit() is for when an object reference gets hit, not when it hits something. Oh, and you got this condition backwards:

If ProcPercentage <= Utility.RandomInt(1,100) 
User avatar
flora
 
Posts: 3479
Joined: Fri Jun 23, 2006 1:48 am

Post » Wed Jun 20, 2012 4:42 am

Nice job on the script. :biggrin:

Hate to disappoint you though, but OnHit() is for when an object reference gets hit, not when it hits something. Oh, and you got this condition backwards:

If ProcPercentage <= Utility.RandomInt(1,100) 

Yeah, I was hoping it would catch when they player got hit...there's no event for a weapon hitting something else. It's basically reactive rather than proactive...for your purposes, it should work though...the only reason to catch the OnHit at all in your case is to get the weilder reference in case the OnEquip got skipped.

And the condition is indeed backwards, should be >= instead of <=....dangit.
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Wed Jun 20, 2012 1:45 am

Now that is what I am looking for, though I think you still forgot about the Resist Magic Power that should be added to the player's spell-list when wielding the weapon but in all, good job. You taken care of the healing effect and I decided to replace "WhatSpellToCast" with the ID of the spell I'm going to use for this, am I correct on this? Couldn't find any of the other lines you've mentioed but I'm rereading it.
User avatar
Catherine N
 
Posts: 3407
Joined: Sat Jan 27, 2007 9:58 pm

Post » Wed Jun 20, 2012 3:10 pm

Maybe you could do it with adding a perk to the player on equip
I think you can put all sorts of spell effects on that and even conditions but I've not looked deeply into all options after I got what I wanted. But it seems you can do basicly everything with perks since they can add a lot (and you can of course first make the needed spells to if you want)
User avatar
Blessed DIVA
 
Posts: 3408
Joined: Thu Jul 13, 2006 12:09 am

Post » Wed Jun 20, 2012 4:20 pm

Now that is what I am looking for, though I think you still forgot about the Resist Magic Power that should be added to the player's spell-list when wielding the weapon but in all, good job. You taken care of the healing effect and I decided to replace "WhatSpellToCast" with the ID of the spell I'm going to use for this, am I correct on this? Couldn't find any of the other lines you've mentioed but I'm rereading it.

"WhatSpellToCast" is a property...just click on the "Properties" button on the object the script is attached to, and click "edit value", then pick the spell you want from the dropdown list. Using IDs is bad practice, thats why I set up all those properties...heh.
User avatar
james kite
 
Posts: 3460
Joined: Sun Jul 22, 2007 8:52 am

Post » Wed Jun 20, 2012 12:53 am

"WhatSpellToCast" is a property...just click on the "Properties" button on the object the script is attached to, and click "edit value", then pick the spell you want from the dropdown list. Using IDs is bad practice, thats why I set up all those properties...heh.

I'm a little puzzled here. Properties must be new to scripting in Skyrim or something? (I'm a Morrowind Scripter and don't remember any properties in Morrowind Scripting*.)
User avatar
Lil Miss
 
Posts: 3373
Joined: Thu Nov 23, 2006 12:57 pm

Post » Wed Jun 20, 2012 9:45 am

I'm a little puzzled here. Properties must be new to scripting in Skyrim or something? (I'm a Morrowind Scripter and don't remember any properties in Morrowind Scripting*.)

Here ya go...http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions...they're a very powerful tool, letting you use a single script for dozens of different applications.

By making WhatSpellToCast a spell property, the properties window knows to only look for spells, and will give you a list of spells you can just pick from.
User avatar
megan gleeson
 
Posts: 3493
Joined: Wed Feb 07, 2007 2:01 pm

Post » Wed Jun 20, 2012 1:46 pm

Here ya go...http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions...they're a very powerful tool, letting you use a single script for dozens of different applications.

By making WhatSpellToCast a spell property, the properties window knows to only look for spells, and will give you a list of spells you can just pick from.

Well.. I prefer to do the old way of doing things, if possible. So I mainly prefer to set it to a certain Spell's ID so it'll cast that spell. I'm use to scripting like that, if you ask me. As long that is still possible then I'll do gladly do that as my first pick. Alright man?
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm

Post » Wed Jun 20, 2012 2:17 pm

The thing is... that's no longer possible.
User avatar
Svenja Hedrich
 
Posts: 3496
Joined: Mon Apr 23, 2007 3:18 pm

Post » Wed Jun 20, 2012 5:27 am

The thing is... that's no longer possible.

Then how in hell would your scripts work if it isn't possible? Remember those scripts you helped me made? I am using IDs in those and you said it will work.
User avatar
luis ortiz
 
Posts: 3355
Joined: Sun Oct 07, 2007 8:21 pm

Post » Wed Jun 20, 2012 6:29 am

Why would you want to look up the code ID for a spell, when you can just pick the spell itself out of a dropdown list? What if someone else's mod uses that ID for something else?

Plus if you use a property, you can attach the exact same script to another item (Say, a piece of armor) and have it cast a different spell on a different target under different conditions, instead of writing a completely new script just so you can change a spell ID...
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Wed Jun 20, 2012 3:28 am

Why would you want to look up the code ID for a spell, when you can just pick the spell itself out of a dropdown list? What if someone else's mod uses that ID for something else?

Plus if you use a property, you can attach the exact same script to another item (Say, a piece of armor) and have it cast a different spell on a different target under different conditions, instead of writing a completely new script just so you can change a spell ID...

1: I'm making my own spell. I always use my own Spells/Enchantments when it comes to magic.

2: I am making a Mod just for Chrysamere. One Object. I have no need to bother adding other items into this same mod. So that doesn't matter.
User avatar
Farrah Barry
 
Posts: 3523
Joined: Mon Dec 04, 2006 4:00 pm

Post » Wed Jun 20, 2012 11:18 am

I'm saying using IDs don't work, you need to use properties. The scripts I gave you were all using properties. Sure, the properties were named the same as the editor IDs of what you wanted, but those are still properties. Naming the properties the same as the editor IDs will let you choose the auto-fill option when assigning values to the properties.
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Wed Jun 20, 2012 1:14 pm

Eh. Don't worry about it then. Once I get started of this, I will figure out for myself.

For right now, I still need to finish the script so it can add a Spell/Power to the player's spellbook when they are wielding the sword.
User avatar
Fam Mughal
 
Posts: 3468
Joined: Sat May 26, 2007 3:18 am

Post » Wed Jun 20, 2012 9:09 am

Actually, I have another thing in my mind.

How about a Script that will just add Power, which will heal the caster and protect them from magic/etc, instead of just automaticly healing them? This would be easier to do and wouldn't get too God-Moddingly and that sort. So how would that be?
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Wed Jun 20, 2012 3:11 pm

Hate to disappoint you though, but OnHit() is for when an object reference gets hit, not when it hits something.

I believe this to be true after trying it myself in the past. If that event doesn't fire, then a script on the weapon may not be the way to go. The functionality of Redwoods code would still work the same. My hat's off to him for not only a record turn-out time, but for helping other modders out so extensively. He's helped me out as well.

Random Noob has also helped me out before (thanks). Only I refuse to admit it because his name is "RANDOM NOOB". Which makes me feel stupid. :ermm:

I'm wondering why you wouldn't put a script on the actor instead: Regular update that checks health, and any other conditions including the IsEquipped for the weapon. Cast the heal, or apply your effect if the conditions are met.
User avatar
Mark
 
Posts: 3341
Joined: Wed May 23, 2007 11:59 am

Post » Wed Jun 20, 2012 6:35 am

I'm wondering why you wouldn't put a script on the actor instead: Regular update that checks health, and any other conditions including the IsEquipped for the weapon. Cast the heal, or apply your effect if the conditions are met.

I'm not a Skyrim modder but in the past, it is best to set the scripts on the Weapons than the Actors. But that is from my experience and I ain't a big master at scripting.
User avatar
Jacob Phillips
 
Posts: 3430
Joined: Tue Aug 14, 2007 9:46 am

Next

Return to V - Skyrim