Jump to content

Need Help Casting A Spell From A Script (New to CK)


Recommended Posts

Hey, I'm new to the creation kit and so far I've been working on a mod that changes the Bloodskal Blade from the Dragonborn DLC.

I'm done about 80% of the mod but I'm stuck on this last part because I think I need scripting to do it.

My goal is to cast a spell on the player that I made called DLC2BloodskalBladeHealthDrain whenever the beam attack is cast (DLC2BloodskalBladeSpellHoriz and/or DLC2BloodskalBladeSpellVert).

 

My first guess would be to add it to the DLC2BloodskalBladeScript which I tried but I either did wrong or it didn't work:

 

Scriptname DLC2BloodskalbladeScriptV2 extends referenceAlias

Actor property selfRef auto hidden
Spell Property DLC2BloodskalBladeSpellHoriz auto
Spell Property DLC2BloodskalBladeSpellVert auto
Spell Property DLC2BloodskalBladeHealthDrain auto [ADDED]
weapon property selfWeapon auto hidden hidden
ammo property DLC2BloodskalAmmo auto
ReferenceAlias Property BloodskalBlade auto
objectReference Property ObjSelf auto hidden


Event OnEquipped(Actor akActor)

;objSelf = self.getReference()
; debug.trace(self + " has recieved OnEquipped")
selfRef = akActor
; ;debug.Trace("SelfRef = " + SelfRef)
if (selfref == Game.GetPlayer())
;registerForAnimationEvent(selfRef, "PowerAttack_Start_End")
registerForAnimationEvent(akActor, "AttackPowerStanding_FXstart")
registerForAnimationEvent(akActor, "AttackPowerRight_FXstart")
registerForAnimationEvent(akActor, "AttackPowerLeft_FXstart")
registerForAnimationEvent(akActor, "AttackPowerBackward_FXstart")
registerForAnimationEvent(akActor, "AttackPowerForward_FXstart")
else
;registerForAnimationEvent(selfRef, "PowerAttack_Start_End")
registerForAnimationEvent(akActor, "AttackPowerStanding_FXstart")
registerForAnimationEvent(akActor, "AttackPowerRight_FXstart")
registerForAnimationEvent(akActor, "AttackPowerLeft_FXstart")
registerForAnimationEvent(akActor, "AttackPowerBackward_FXstart")
registerForAnimationEvent(akActor, "AttackPowerForward_FXstart")
endif
; ;debug.trace("Registering for Single Update")

;RegisterforSingleUpdate(0)
endEvent

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
if akNewContainer as Actor
selfWeapon = (self.getReference().getBaseObject() as weapon)
utility.wait(0.1)
if (akNewContainer as Actor).isEquipped(selfWeapon)
OnEquipped(akNewContainer as Actor)
endif
endif
BloodskalBlade.ForceRefTo(objSelf)
endEvent

Event OnUnequipped(Actor akActor)
; debug.trace(self + " has recieved onEffectFinish")
;unregisterForAnimationEvent(selfRef, "PowerAttack_Start_End")
unregisterForAnimationEvent(akActor, "AttackPowerStanding_FXstart")
unregisterForAnimationEvent(akActor, "AttackPowerRight_FXstart")
unregisterForAnimationEvent(akActor, "AttackPowerLeft_FXstart")
unregisterForAnimationEvent(akActor, "AttackPowerBackward_FXstart")
unregisterForAnimationEvent(akActor, "AttackPowerForward_FXstart")
ENDEVENT

Event OnAnimationEvent(ObjectReference akSource, string EventName)
; debug.trace(self + " has recieved AnimationEvent ")
; debug.trace(">>>>>>>>>>>>> AnimationEvent Name: " + EventName)
; debug.trace(">>>>>>>>>>>>> AkSource: " + akSource)
if (selfref == Game.GetPlayer())
if (eventName == "AttackPowerRight_FXstart") || \
(eventName == "AttackPowerLeft_FXstart") || \
(eventName == "AttackPowerBackward_FXstart")
weapon SwordWeapon = selfRef.GetEquippedWeapon()
DLC2BloodskalBladeSpellHoriz.cast(selfRef)

elseif (eventName == "AttackPowerStanding_FXstart") || \
(eventName == "AttackPowerForward_FXstart")
weapon SwordWeapon = selfRef.GetEquippedWeapon()
DLC2BloodskalBladeSpellVert.cast(selfRef)
endif

DLC2BloodskalBladeHealthDrain.cast(selfRef)[ADDED]

endif

endEVENT

 

I also tried attaching a script dynamically to the player through a quest (I think?) but that didn't work:

 

Scriptname DLC2BloodskalBladePlayerHealthCost extends ReferenceAlias

Spell Property DLC2BloodskalBladeHealthDrain Auto
Spell Property DLC2BloodskalBladeSpellVert Auto
Actor Property PlayerRef Auto

Event OnSpellCast(Form DLC2BloodskalBladeSpellVert) [This is only Vertical/I don't know how to add both horiz and/or vert]
DLC2BloodskalBladeHealthDrain.cast(PlayerRef) [Feels like I have to specify the object or player casting something? But I don't know how]
EndEvent

 

 

For reference the mod makes the Bloodskal Blade steal health based on how low the player's health % is (Lower health=More life steal) and it makes the beam attack do more damage based on how high the players health % is (Beam does more damage the higher health the player is at). The only part I have to add is integrating this DLC2BloodskalBladeHealthDrain spell which damages the player based on how high their health % is (More damage when player is higher health). I hope to cast this spell whenever the Bloodskal Blade beams are cast that way it looks like you are fueling the beam with more power from your health.

 

I'm kind of out of idea's and I'm very new to modding and the creation kit. Any ideas/help would be greatly appreciated.

 

Link to comment
Share on other sites

  • 2 weeks later...

In the first script:

 

DLC2BloodskalBladeHealthDrain.cast(self, selfRef)
or probably...

 

DLC2BloodskalBladeHealthDrain.cast(GetReference(), selfRef)
as your script extends ReferenceAlias it must be attached to a quest alias. Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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