Jump to content

Shooting arrows costs magicka script? Help?


DracoX09

Recommended Posts

I recently created my first mod and updated it a few times. Basically conjuring different types of bound arrows with different damage types. And I wanted to make it so every time the player shoots an arrow, it would cost a certain amount of Magicka. I've tried modifying a script from another mod just to see if I could get it to work, but as scripting is completely foreign to me, I was able to modify and compile a script and attach it to the magic effect, but it doesn't actually do anything.

 

Script that I modified:

 

Scriptname BoundArrowCostScript extends ReferenceAlias
ReferenceAlias Property Caster Auto
Ammo Property boundArrow Auto
Int Property MagickaDamage Auto
Event OnPlayerBowShot(Weapon akWeapon, Ammo akAmmo, float afPower, bool abSunGazing)
If akAmmo == boundArrow
If (Caster.GetReference() as Actor).GetActorValue("Magicka") >= MagickaDamage
(Caster.GetReference() as Actor).DamageActorValue("Magicka", MagickaDamage)
Else
(Caster.GetReference() as Actor).UnEquipItem(AkAmmo)
EndIf
EndIf
EndEvent
My mod, if you need it to determine any other way I might accomplish this:
Link to comment
Share on other sites

Presumably the mod you looked at was mine, or at least something like it.
https://www.nexusmods.com/skyrimspecialedition/mods/6844/?

I assume you want these specific arrows to cost magicka?
Assuming it's the arrows:

Scriptname BoundArrowCostScript extends ReferenceAlias

ReferenceAlias Property Caster Auto
Ammo Property myElementalArrow Auto
Int Property MagickaDamage Auto

Event OnPlayerBowShot(Weapon akWeapon, Ammo akAmmo, float afPower, bool abSunGazing)
     If akAmmo == myElementalArrow
          If (Caster.GetReference() as Actor).GetActorValue("Magicka") >= MagickaDamage
               (Caster.GetReference() as Actor).DamageActorValue("Magicka", MagickaDamage)
          Else
               (Caster.GetReference() as Actor).UnEquipItem(AkAmmo)
          EndIf
     EndIf
EndEvent

This should hypothetically work. BUT make sure you fill in ALL the properties for the script, or it will do nothing. This includes the alias you have in there.
If you want the arrows to have different magicka costs, you'll have to add more aliases, and put this script on each one, all of those aliases will need their properties filled out.

ALSO:
Your spell that summons the arrows should have its own script that puts the player into the Alias.
I assume yours is similar to this, just make sure you're assigning the player to the alias:

Ammo Property myElementalArrow Auto
Int Property ArrowCount Auto  
ReferenceAlias Property Caster Auto


EVENT OnEffectStart(Actor akTarget, Actor akCaster)
	Caster.ForceRefIfEmpty(akTarget)
	akTarget.AddItem(myElementalArrow,ArrowCount,TRUE)
	akTarget.EquipItem(myElementalArrow, TRUE, TRUE)
endEVENT

EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
        akTarget.UnequipItem(myElementalArrow)
	akTarget.RemoveItem(myElementalArrow,akTarget.getItemCount(myElementalArrow),TRUE)
	Caster.Clear()
endEVENT

Just make sure the alias is filled properly in the properties. As Rasikko said above, scripts get messed up sometimes if they're running in your save and you change them, so do your testing on a save that has not had the mod active before, and just add the spells to your character via console.

Link to comment
Share on other sites

Presumably the mod you looked at was mine, or at least something like it.

https://www.nexusmods.com/skyrimspecialedition/mods/6844/?

 

I assume you want these specific arrows to cost magicka?

Assuming it's the arrows:

 

Scriptname BoundArrowCostScript extends ReferenceAlias

ReferenceAlias Property Caster Auto
Ammo Property myElementalArrow Auto
Int Property MagickaDamage Auto

Event OnPlayerBowShot(Weapon akWeapon, Ammo akAmmo, float afPower, bool abSunGazing)
     If akAmmo == myElementalArrow
          If (Caster.GetReference() as Actor).GetActorValue("Magicka") >= MagickaDamage
               (Caster.GetReference() as Actor).DamageActorValue("Magicka", MagickaDamage)
          Else
               (Caster.GetReference() as Actor).UnEquipItem(AkAmmo)
          EndIf
     EndIf
EndEvent

This should hypothetically work. BUT make sure you fill in ALL the properties for the script, or it will do nothing. This includes the alias you have in there.

If you want the arrows to have different magicka costs, you'll have to add more aliases, and put this script on each one, all of those aliases will need their properties filled out.

 

ALSO:

Your spell that summons the arrows should have its own script that puts the player into the Alias.

I assume yours is similar to this, just make sure you're assigning the player to the alias:

 

Ammo Property myElementalArrow Auto
Int Property ArrowCount Auto  
ReferenceAlias Property Caster Auto


EVENT OnEffectStart(Actor akTarget, Actor akCaster)
	Caster.ForceRefIfEmpty(akTarget)
	akTarget.AddItem(myElementalArrow,ArrowCount,TRUE)
	akTarget.EquipItem(myElementalArrow, TRUE, TRUE)
endEVENT

EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
        akTarget.UnequipItem(myElementalArrow)
	akTarget.RemoveItem(myElementalArrow,akTarget.getItemCount(myElementalArrow),TRUE)
	Caster.Clear()
endEVENT

Just make sure the alias is filled properly in the properties. As Rasikko said above, scripts get messed up sometimes if they're running in your save and you change them, so do your testing on a save that has not had the mod active before, and just add the spells to your character via console.

Yes, the mod I looked at was yours. I actually couldn't find it in my mod list for some reason, so I'm glad you replied to this, now if I can get this working, I can give credit where it is due. Thanks for the help, I'll be trying this out sometime this week.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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