Jump to content

Single time execution of onequip script halp


Rizalgar

Recommended Posts

Sigh, I'm stuck again! This time, trying to run a script on a weapon ONE time through out it's life span. I guess what that means, I need the script to run ONCE, and only ever once, regardless of how many times the weapon is equipped. I'll be tinkering with the script some more in the mean time, but if someone can toss a pointer my way, it'd be greatly appreciated. Maybe StopScript()? IDK.

 

Oh, I know I can do this easily with a globalvariable, but without being able to reset the global I would have to make a global for every single weapon, and that just doesn't seem efficient.

 

Here's the script, to get an idea of what I'm doing.

 

 

 

Scriptname saoFrameworkEquips extends ObjectReference
{Framework handling stat applications}


Int Property reqClass Auto

Int Property elo = 0 Auto

Event OnEquipped(Actor player)
	
	If elo == 0
		Int STR = saoFrameworkLeveling.GetStrength().GetValue() as Int

		Int Dmg = Game.GetPlayer().GetEquippedWeapon().GetBaseDamage() + STR
		Game.GetPlayer().GetEquippedWeapon().SetBaseDamage(Dmg)
		elo == 1
	EndIf
	
EndEvent

 

 

 

Edit - Thanks to booleans, it's working, mostly, only one bug. If you make the same version of a weapon (i.e a second Iron Sword) it will reapply the the script. There a way to prevent that?

Edited by Rizalgar
Link to comment
Share on other sites

Not sure how you would do it from a script attached to the weapon itself. However, in theory, if you started out with an empty formlist you could check for the equipped weapon's base form to be on that formlist. If not on the list add the base form to the list and do your thing. And if it is on the list, skip it as you've already dealt with it.

Link to comment
Share on other sites

That, in theory, sounds like it would work perfectly. I'll give her a go-around in the morning. About to play some OverWatch. Thank you, as always, Ishara

 

Edit - Not only in theory, but practically as well. Runs perfect, thank you again for your guidance Ishara. I know I said I'd do it later, but I got a little too excited.

 

For Googlers ------

 

Set base damage from a global variable via a script attached to weapon that runs only once (so the damage doesn't stack each equip) ---

 

Note - You shouldn't need the boolean, I just left it in there. The FormList should take care of it.

 

 

 

Scriptname saoFrameworkEquips extends ObjectReference
{Framework handling stat applications}


Int Property reqClass Auto

Bool elo 

Event OnEquipped(Actor player)
	
	FormList fWeapon = saoFrameworkLeveling.GetWeaponsList() as FormList
	Weapon eWeapon = Game.GetPlayer().GetEquippedWeapon()
	
	If fWeapon.HasForm(eWeapon)== False
		fWeapon.AddForm(eWeapon)
		If !elo
			Int STR = saoFrameworkLeveling.GetStrength().GetValue() as Int

			Int Dmg = Game.GetPlayer().GetEquippedWeapon().GetBaseDamage() + STR
			Game.GetPlayer().GetEquippedWeapon().SetBaseDamage(Dmg)
			elo = True
		EndIf
	EndIf
	
EndEvent

 

 

Edited by Rizalgar
Link to comment
Share on other sites

  • Recently Browsing   0 members

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