OnHit with spell won't compile. Help please.

Post » Wed Mar 11, 2015 6:04 am

Actor property PlayerRef Auto ;Changed the type since IsEquipped is an Actor functionObjectReference property Stump AutoObjectReference property CutStump AutoMiscObject Property CutLog AutoSpell Property Coldspell AutoAuto State NotEntered	Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)		If(akAggressor == PlayerRef)If((PlayerRef.GetEquippedSpell() == Coldspell) || (PlayerRef.GetEquippedSpell(True) == Coldspell))				;Debug.Trace("The player hit me!")				Stump.Disable()				CutStump.Enable()       				PlayerRef.AddItem(CutLog, 1, False)				GoToState("Done")			Else				Debug.Notification("You need to use a Woodcutters Axe to chop the tree")			EndIf		EndIf	EndEventEndState
Actor property PlayerRef Auto ;Changed the type since IsEquipped is an Actor functionObjectReference property Stump AutoObjectReference property CutStump AutoMiscObject Property CutLog AutoWeapon Property WoodAxe AutoAuto State NotEntered	Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)		If(akAggressor == PlayerRef)If((PlayerRef.GetEquippedWeapon() == WoodAxe) || (PlayerRef.GetEquippedWeapon(True) == WoodAxe))				;Debug.Trace("The player hit me!")				Stump.Disable()				CutStump.Enable()       				PlayerRef.AddItem(CutLog, 1, False)				GoToState("Done")			Else				Debug.Notification("You need to use a Woodcutters Axe to chop the tree")			EndIf		EndIf	EndEventEndState

I have used this script, above, for some time without any problems for cutting down trees. I thought I could use this script, amended, to register when an object is hit by a spell - in my case a movable static, a fire volume.
I changed the script, just the essentials for now to see if it worked, but it won't compile.
The amended script is the top one - for some reason this editor is messed up.
These are the errors...

psc(12,14): argument aisource is not specified and has no default value
psc(12,61): type mismatch on parameter 1 (did you forget a cast?)

Thanks for your time.

User avatar
Daniel Lozano
 
Posts: 3452
Joined: Fri Aug 24, 2007 7:42 am

Post » Tue Mar 10, 2015 9:18 pm

http://www.creationkit.com/GetEquippedSpell_-_Actor

Specify what aiSource will be. Left Hand, right hand, etc.

User avatar
Lawrence Armijo
 
Posts: 3446
Joined: Thu Sep 27, 2007 7:12 pm

Post » Wed Mar 11, 2015 10:00 am

Actor Property PlayerRef Auto ;Changed the type since IsEquipped is an Actor functionObjectReference Property Damage AutoObjectReference Property FireFX AutoSpell Property Coldspell1 AutoAuto State NotEntered	Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)		If(akAggressor == PlayerRef)If((PlayerRef.GetEquippedSpell(0) == Coldspell1) || (PlayerRef.GetEquippedSpell(1) == Coldspell1))				;Debug.Trace("The player hit me!")				Damage.Disable()				FireFX.Disable()				GoToState("Done")			Else				Debug.Notification("Use a cold spell to dowse the fires.")			EndIf		EndIf	EndEventEndState

But the script requiring the woodaxe (above) allows it to be equipped in either hand. How does it differ from a spell?

Anyway, I did as Wiki said and this is the script, it compiles but it doesn't do what it supposed to do i.e. fire and damage triggerbox do not disable.

User avatar
maria Dwyer
 
Posts: 3422
Joined: Sat Jan 27, 2007 11:24 am

Post » Wed Mar 11, 2015 9:33 am

Did you see your debug trace/notifications? Give some more detail to help us figure out where it might be going wrong :)

Also, why not just check whether (akSource == (yourSpell as Form))?

User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Wed Mar 11, 2015 12:31 pm

I'm not so good at scripting with forms, something I am unsure of but it would be good to have a form that includes all cold spells. I need help with that.
Effectively I have fires on top of a surface of water, see shot. Player has to travel through these but gets damaged if he/she enters a fire. I put a fire damage triggerbox in each fire fx as the fire itself does no damage. By casting a cold spell on these fires the player can extinguish them. The fire is a movable static, BFXFireVol01, and I run the script on it.

Screenshot - https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2130760&v=3

User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Wed Mar 11, 2015 6:58 am

I've got it working. Seems the fire fx won't register hits, so had to use an activator. Could somebody help me script the event to use a form that includes all cold spells, ice spike, icy spear, etc? Would be appreciated.

User avatar
casey macmillan
 
Posts: 3474
Joined: Fri Feb 09, 2007 7:37 pm

Post » Wed Mar 11, 2015 5:32 am

Couldn't you use something like:

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)If((akSource.HasKeyword(MagicDamageFrost));do code stuff hereEndEvent
User avatar
Lauren Graves
 
Posts: 3343
Joined: Fri Aug 04, 2006 6:03 pm

Post » Wed Mar 11, 2015 1:49 am

In the spells form there isn't an option to add keywords, nice idea though.

User avatar
Susan Elizabeth
 
Posts: 3420
Joined: Sat Oct 21, 2006 4:35 pm

Post » Wed Mar 11, 2015 12:29 am

I just tested it and it worked fine, because the keyword is in the magic effect, which gets passed on automatically to the spell form.

Don't just copy-paste my code earlier though; there's an extra parenthesis typo and you ought to use a keyword property too.

User avatar
Ice Fire
 
Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

Post » Wed Mar 11, 2015 9:56 am

Keyword SHOULD work if only everyone (modder and including Bethesda) had use the keyword system constantly in all the spells. But that is not the case.

I found that while making my mod to make shields block all elemental attacks that checking for the keywords will not always work. In fact there is even a special keyword condition check (EPMagic_SpellHasKeyword) used JUST FOR PERKS!

I finally came up with a long script that combined looking for keywords in 5 different ways, and that still worked inconstantly after testing on many different frost spells and shouts from both vanilla and mods.

In the end I had to check the NAME of the spell to look for the words frost or cold and such.

User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm


Return to V - Skyrim