Jump to content

Percentage of GlobalVariable


Rizalgar

Recommended Posts

As it says, I need to know how to get a percentage of a global variable. The reason for this is to get rid of making multiple spells and unneccessary scripting for said scripts. I.e, I have a Spell, Frostbolt, a GlobalVariable, SpellPower. The Frostbolt spell deals % damage based on the global variable, in this example, 51%. Let's say the global variable is at 482, how would I go about getting the 51.1% of the globalvariable? I also have it to where it of course costs magicka. Let's say I want the magicka cost to be 2% of the total amount of magicka, how would I do that? Forgive me if this is plainly obvious, but it's eluding me at the moment. For the Magicka, I'm guessing it would be something like...

 

 

MagickaCost = 0.2 * Game.GetPlayer().GetActorValue("Magicka")

 

Is that correct? My math is awful lol

 

As for the spell damage, would it be something like this...

 

Int Damage = 51 % SpellPower

 

Is that correct?

Edit - I have also tried this, to no avail. Figured it may not work anyhow since it's the same principle as Java

 

 

 

Int Intellect = Intellect.GetValue()
Int SpellPower = Spellpower.GetValue()

ManaCost %= Intellect
Damage %= Spellpower

 

 

 

 

Edit 2 - Found a script related to what I'm trying to do thanks to Google. Got it mostly working, minus the Magicka usage. It isn't subtracting like it's supposed to. Here is the modified script.

 

 

 

Event OnEffectStart(actor target, actor caster)
	
	Int Intellect = Wow_Att_Intellect.GetValue() as Int
	Int SpellPower = Wow_Att_Intellect.GetValue() as Int
	Int CritChance = Wow_Stat_Crit.GetValue() as Int
	
	Int Crit = Utility.RandomInt(1, 100)
	
	Float ManaCurrent = Game.GetPlayer().GetActorValue("Magicka")
	Float ManaPercent = Game.GetPlayer().GetActorValuePercentage("Magicka")
	Float ManaMax = ((1 / ManaPercent) * ManaCurrent)
	Float ManaCost = ((ManaMax / 100) * 15)
	Float Damage = SpellPower * 1.51
	Float CritDamage = Damage * 2
	
	If Game.GetPlayer().GetActorValue("Magicka") < ManaCost
		;do nothing
	Else
		If CritChance > Crit
			Game.GetPlayer().DamageActorValue("Magicka", ManaCost)
			target.DamageActorValue("Health", CritDamage)
		Else
			Game.GetPlayer().DamageActorValue("Magicka", ManaCost)
			target.DamageActorValue("Health", Damage)
		EndIf
	EndIf
	
EndEvent

 

 

Edited by Rizalgar
Link to comment
Share on other sites

Advance percentage calculations are way out of my league, but I have a grasp on the basics. To deal 51% of the 482, would be 247.35. This is done the same way you did it, but change 0.2 to 0.51. SpellPower in this case is increased 151%, or 1.51x times the amount.

 

By the way, ManaMax is accurate as long as you don't care about about the base value, which buffed values wont reveal through that formula.

Edited by Rasikko
Link to comment
Share on other sites

Ah, thanks Rassiko, I'll modify it a bit and see what happens. Still wonder why it won't subtract the mana cost though. Or maybe I just completely misread what you said lol

 

Edit - Got the mana working correctly. Now damage isn't working. WTF am I doing with my life lmao

Edit 2 - I'm retarded. All is working now. Thank you Rassiko!

 

 

- - - For Googlers - - -

 

To have a spell subtract a percentage of the players total magicka

 

 

 

Scriptname Wow_SS_Fireball extends activemagiceffect  
{Main Script for fire ball ranks}

GlobalVariable Property Wow_Att_Intellect Auto
GlobalVariable Property Wow_Stat_SpellPower Auto
GlobalVariable Property Wow_Stat_Haste Auto
GlobalVariable Property Wow_Stat_Crit Auto

Event OnEffectStart(actor target, actor caster)
	
	Int Intellect = Wow_Att_Intellect.GetValue() as Int
	Int SpellPower = Wow_Att_Intellect.GetValue() as Int
	Int CritChance = Wow_Stat_Crit.GetValue() as Int
	
	Int Crit = Utility.RandomInt(1, 100)
	
	Float ManaMax = Game.GetPlayer().GetActorValue("Magicka")
	Float ManaCost = ((ManaMax / 100) * 15)
	Float Damage = SpellPower * 1.57
	Float CritDamage = Damage * 2
	
	If Game.GetPlayer().GetActorValue("Magicka") < ManaCost
		;do nothing
	Else
		If CritChance > Crit
			Game.GetPlayer().DamageActorValue("Magicka", ManaCost)
			target.DamageActorValue("Health", CritDamage)
		Else
			Game.GetPlayer().DamageActorValue("Magicka", ManaCost)
			target.DamageActorValue("Health", Damage)
		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...