[Help] <spellname>.cast() not working

Post » Wed Mar 11, 2015 12:26 pm

Alright, I've followed the following:
http://www.gamesas.com/topic/1349649-dynamically-attaching-scripts-to-actors-near-the-player/
It works beautifully (well, sort of) with this script attached to every actor:
    Scriptname Interrupt_Archers_StaggerOnHit extends ReferenceAlias    {Stagger an archer if they are hit while drawing their bow.}        Spell property Interrupt_Archers_Stagger auto    Spell Property ConjureDremoraLord Auto    Spell Property Paralyze auto    Event onHit(objectReference akAggressor, Form akWeapon, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)        ConjureDremoraLord.Cast(akAggressor)        if((Self.GetActorRef()).IsInCombat())          if((Self.GetActorRef()).GetEquippedItemType(0) == 7 && (Self.GetActorRef()).IsWeaponDrawn())            Debug.MessageBox((akAggressor as Actor).GetBaseObject().GetName() + " struck " + (Self.GetActorRef()).GetBaseObject().GetName() + " holding weapon " + (Self.GetActorRef()).GetEquippedItemType(0) + " in left and " + (Self.GetActorRef()).GetEquippedItemType(1) + " in right" )                        Interrupt_Archers_Stagger.Cast(Self.GetActorRef())          endif        endif        ;Paralyze.Cast(Self.GetActorRef(), Self.GetActorRef())    endEvent
So, you'll notice all the spells referenced in there. This is to show that I tried a few. I created one (the one I really want to use) and tried to use some existing spells. I even put the ConjureDremoraLord.Cast outside my "if" just in case.
Thing is, my ifs and debug messagebox do what they're supposed to when the conditions are met. But never does .cast ever work.
Anyone have any suggestions? I do have some mods installed, but I can't imagine any of them would make such a basic function stop working altogether.
User avatar
Josee Leach
 
Posts: 3371
Joined: Tue Dec 26, 2006 10:50 pm

Post » Wed Mar 11, 2015 4:54 am

I tested only this line:

ConjureDremoraLord.Cast(akAggressor)

Placed a cow and attached the script to it. Since the property is named exactly like the spell, I auto-filled it.

When I hit the cow ingame, I got the notification that I dont have the magicka to maintain this spell (or was it conjuration skill?). Anyway, the command is working as it is.

I noticed, that you haven't specified a target to cast the spell on. This is probably the issue. See the http://www.creationkit.com/Cast_-_Spell for further info.

User avatar
Stacy Hope
 
Posts: 3391
Joined: Thu Jun 22, 2006 6:23 am

Post » Wed Mar 11, 2015 8:14 am

My intention is to have the recipients of the hit cast a spell on themselves.

The spell I created is 0 cost requiring no skill and is using an effect I created based on Stagger.

My expectation was that this is how you would make something like a stagger happen OnHit. I want it to apply to everyone in the game (player included) if they are in combat and wielding a bow. Ideally I want it to do it only if they're in their "draw bow" animation, but I don't know if that's even possible.

User avatar
Veronica Flores
 
Posts: 3308
Joined: Mon Sep 11, 2006 5:26 pm

Post » Wed Mar 11, 2015 11:14 am

You should probably do SpellName.Cast(self, self)

That'll cast it on the actor being hit.
User avatar
Gwen
 
Posts: 3367
Joined: Sun Apr 01, 2007 3:34 am

Post » Wed Mar 11, 2015 5:37 am

Great, I'll try that. For some reason I was under the impression the second argument was optional and would default to casting the spell on the caster.

User avatar
Lauren Graves
 
Posts: 3343
Joined: Fri Aug 04, 2006 6:03 pm

Post » Tue Mar 10, 2015 8:30 pm

Now I see that you tried it with the paralyze spell.

And default for akTarget is None.

I guess its safe to assume that you have set the properties correctly.

Well, except of trying the http://www.creationkit.com/RemoteCast_-_Spell command, I can't help you.

User avatar
Thomas LEON
 
Posts: 3420
Joined: Mon Nov 26, 2007 8:01 am

Post » Wed Mar 11, 2015 3:08 am

The answer was indeed to direct the spell at the actor. Thanks!
User avatar
Andrea P
 
Posts: 3400
Joined: Mon Feb 12, 2007 7:45 am

Post » Tue Mar 10, 2015 10:51 pm

I thought you had tried that with the paralyse spell...

User avatar
Alexander Horton
 
Posts: 3318
Joined: Thu Oct 11, 2007 9:19 pm


Return to V - Skyrim