meysamkhr Posted May 31, 2017 Share Posted May 31, 2017 I'm looking for a way to make a weapon trigger a magic effect every time you pull the trigger and stop using the magic effect when you are out of ammo. is there a way? Link to comment Share on other sites More sharing options...
Syngrith Posted May 31, 2017 Share Posted May 31, 2017 (edited) Script working on alias on player. Take One: Clip size related Scriptname testing extends ReferenceAliasSPELL Property spell_that_has_your_effect Auto ConstWeapon Property YourWeapon Auto ConstFloat Shot;\\\\\\\\\\\On StartEVENT onInit() Shot = 0endEVENT;\\\\\\\\\\\\On ShotEvent OnPlayerFireWeapon(Form akBaseObject)if akBaseObject == YourWeaponif (Shot == 0) ;First Shot Game.GetPlayer().AddSpell(spell_that_has_your_effect) Shot = 1elseif (Shot > 0) && (Shot <11) ;Other Shots Shot = Shot + 1elseif (Shot == 11) Game.GetPlayer().RemoveSpell(spell_that_has_your_effect) Shot = 0endifelseif akBaseObject != YourWeaponEndifendEvent;\\\\\\\\\\\\\On Unequipped when the effect is activeEvent OnItemUnequipped(Form akBaseObject, ObjectReference akReference)if akBaseObject == YourWeaponif Shot>0Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)elseif Shot <=0endifelseif akBaseObject != YourWeaponEndifendEvent;\\\\\\\\\\\\\On Equipped when the effect was turned off in step aboveEvent OnItemEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject == YourWeaponif Shot>0Game.GetPlayer().AddSpell(spell_that_has_your_effect)elseif Shot <=0endifelseif akBaseObject != YourWeaponEndifendEvent Take Two: GetItemCountRelated Scriptname testing extends ReferenceAliasSPELL Property spell_that_has_your_effect Auto ConstWeapon Property YourWeapon Auto ConstAmmo Property AAmmo Auto ConstMagicEffect Property EEffect Auto Const;\\\\\\\\\\\\On ShotEvent OnPlayerFireWeapon(Form akBaseObject)if akBaseObject == YourWeaponif 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 endifelseif 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 endifendifelseif akBaseObject != YourWeaponEndifendEvent;\\\\\\\\\\\\\On Unequipped when the effect is activeEvent OnItemUnequipped(Form akBaseObject, ObjectReference akReference)if akBaseObject == YourWeaponif Game.GetPlayer().HasMagicEffect(EEffect) == 1Game.GetPlayer().RemoveSpell(spell_that_has_your_effect)elseif Game.GetPlayer().HasMagicEffect(EEffect) == 0endifelseif akBaseObject != YourWeaponEndifendEvent;\\\\\\\\\\\\\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 May 31, 2017 by Syngrith Link to comment Share on other sites More sharing options...
Recommended Posts