Jump to content

Make a certain weapon trigger a magic effect


Recommended Posts

Script working on alias on player.

 

Take One: Clip size related

 

Scriptname testing extends ReferenceAlias

SPELL Property spell_that_has_your_effect Auto Const
Weapon Property YourWeapon Auto Const

Float Shot

;\\\\\\\\\\\On Start

EVENT onInit()
Shot = 0
endEVENT

;\\\\\\\\\\\\On Shot
Event OnPlayerFireWeapon(Form akBaseObject)
if akBaseObject == YourWeapon
if (Shot == 0) ;First Shot
Game.GetPlayer().AddSpell(spell_that_has_your_effect)
Shot = 1
elseif (Shot > 0) && (Shot <11) ;Other Shots
Shot = Shot + 1
elseif (Shot == 11)
Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)
Shot = 0
endif
elseif akBaseObject != YourWeapon
Endif
endEvent

;\\\\\\\\\\\\\On Unequipped when the effect is active
Event OnItemUnequipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject == YourWeapon
if Shot>0
Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)
elseif Shot <=0
endif
elseif akBaseObject != YourWeapon
Endif
endEvent

;\\\\\\\\\\\\\On Equipped when the effect was turned off in step above
Event OnItemEquipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject == YourWeapon
if Shot>0
Game.GetPlayer().AddSpell(spell_that_has_your_effect)
elseif Shot <=0
endif
elseif akBaseObject != YourWeapon
Endif
endEvent

 

Take Two: GetItemCountRelated

 

Scriptname testing extends ReferenceAlias

SPELL Property spell_that_has_your_effect Auto Const
Weapon Property YourWeapon Auto Const
Ammo Property AAmmo Auto Const
MagicEffect Property EEffect Auto Const


;\\\\\\\\\\\\On Shot

Event OnPlayerFireWeapon(Form akBaseObject)
if akBaseObject == YourWeapon
if Game.GetPlayer().GetItemCount(AAmmo) > 0
if Game.GetPlayer().HasMagicEffect(EEffect) == 0
Game.GetPlayer().AddSpell(spell_that_has_your_effect)
elseif Game.GetPlayer().HasMagicEffect(EEffect) == 1
endif
elseif Game.GetPlayer().GetItemCount(AAmmo) == 0
if Game.GetPlayer().HasMagicEffect(EEffect) == 1
Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)
elseif Game.GetPlayer().HasMagicEffect(EEffect) == 0
endif
endif
elseif akBaseObject != YourWeapon
Endif
endEvent


;\\\\\\\\\\\\\On Unequipped when the effect is active
Event OnItemUnequipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject == YourWeapon
if Game.GetPlayer().HasMagicEffect(EEffect) == 1
Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)
elseif Game.GetPlayer().HasMagicEffect(EEffect) == 0
endif
elseif akBaseObject != YourWeapon
Endif
endEvent

;\\\\\\\\\\\\\On Equipped is not needed as effect will get added on shot

 

- EDIT -

 

I'm pretty sure you don't have to registerforremotevent for OnPlayerFireWeapon but I might be wrong.

Edited by Syngrith
Link to comment
Share on other sites

  • Recently Browsing   0 members

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