Jump to content

Converting Int GV into Float for another GV


Rizalgar

Recommended Posts

Okay, this is kinda hard to explain, and the script itself is pretty long (I'll post anyway) so I'll do the best I can.

 

I have 5 GlobalVariables

-DropRate Common

-DropRate Uncommon

-DropRate Rare

-DropRate VeryRare

-Luck

 

Luck is a player stat that I'm making for my mod. The others are obviously global variables to be used on the drop tables. Now, with that out of the way, I need to know if it's possible to obtain the integer variable from luck, convert it to a float, then subtract that value from a DropRate global variables. Math isn't my strong point, and I have only been doing this for a little over a month, so I'm not sure where to go with this one. The method I am currently using does not work, as it results in negative values way too early, or doesn't make a difference enough to make Luck a stat worth going for. So, here's the script. Just search GetCommon() and it'll take you to the part in question. Thanks in advance.

 

 

 

Scriptname saoFrameworkLeveling extends Quest  
{Handles leveling for skills}

saoFrameworkMain Function GetData() Global
	return (Game.GetFormFromFile(0x00AA18, "SwordArtOnline.esp") as Quest) as saoFrameworkMain
EndFunction

GlobalVariable Function GetAgility() Global
	Return GetData().SAO_GV_Agility
EndFunction

GlobalVariable Function GetAlchemy() Global
	Return GetData().SAO_GV_Alchemy
EndFunction

GlobalVariable Function GetAlchemyXP() Global
	Return GetData().SAO_GV_AlchemyXP
EndFunction

GlobalVariable Function GetArmorSmithing() Global
	Return GetData().SAO_GV_Armorsmithing
EndFunction

GlobalVariable Function GetArmorSmithingXP() Global
	Return GetData().SAO_GV_ArmorsmithingXP
EndFunction

GlobalVariable Function GetDexterity() Global
	Return GetData().SAO_GV_Dexterity
EndFunction

GlobalVariable Function GetExperience() Global
	Return GetData().SAO_GV_Experience
EndFunction

GlobalVariable Function GetHerbalism() Global
	Return GetData().SAO_GV_Herbalism
EndFunction

GlobalVariable Function GetHerbalismXP() Global
	Return GetData().SAO_GV_HerbalismXP
EndFunction

GlobalVariable Function GetIntelligence() Global
	Return GetData().SAO_GV_Intelligence
EndFunction

GlobalVariable Function GetpLevel() Global
	Return GetData().SAO_GV_Level
EndFunction

GlobalVariable Function GetLuck() Global
	Return GetData().SAO_GV_Luck
EndFunction

GlobalVariable Function GetMining() Global
	Return GetData().SAO_GV_Mining
EndFunction

GlobalVariable Function GetMiningXP() Global
	Return GetData().SAO_GV_MiningXP
EndFunction

GlobalVariable Function GetStrength() Global
	Return GetData().SAO_GV_Strength
EndFunction

GlobalVariable Function GetVitality() Global
	Return GetData().SAO_GV_Vitality
EndFunction

GlobalVariable Function GetWeaponsmithing() Global
	Return GetData().SAO_GV_Weaponsmithing
EndFunction

GlobalVariable Function GetWeaponsmithingXP() Global
	Return GetData().SAO_GV_WeaponsmithingXP
EndFunction

GlobalVariable Function HasAlchemy() Global
	Return GetData().SAO_GV_HasAlchemy
EndFunction

GlobalVariable Function HasArmorsmithing() Global
	Return GetData().SAO_GV_HasArmorsmithing 
EndFunction

GlobalVariable Function HasHerbalism() Global
	Return GetData().SAO_GV_HasHerbalism
EndFunction

GlobalVariable Function HasMining() Global
	Return GetData().SAO_GV_HasMining 
EndFunction

GlobalVariable Function HasWeaponSmithing() Global
	Return GetData().SAO_GV_HasWeaponsmithing
EndFunction

GlobalVariable Function GetpClass() Global
	Return GetData().SAO_GV_Class
EndFunction

GlobalVariable Function GetCommon() Global
	Return GetData().SAO_GV_DropRate_Common
EndFunction

GlobalVariable Function GetUncommon() Global
	Return GetData().SAO_GV_DropRate_Uncommon
EndFunction

GlobalVariable Function GetRare() Global
	Return GetData().SAO_GV_DropRate_Rare
EndFunction

GlobalVariable Function GetVeryRare() Global
	Return GetData().SAO_GV_DropRate_VeryRare
EndFunction

FormList Function GetWeaponsList() Global
	Return GetData().SAO_FL_WeaponsList
EndFunction

Function SAOXPGain(string stat, int xp) Global
	
	If stat == "alchemy"
		(GetAlchemy()).SetValue(((GetAlchemy()).GetValue()) + xp)
	ElseIf stat == "armorsmithing"
		(GetArmorSmithing()).SetValue(((GetArmorSmithing()).GetValue()) + xp)
	ElseIf stat == "experience"
		(GetExperience()).SetValue(((GetExperience()).GetValue()) + xp)
	ElseIf stat == "herbalism"
		(GetHerbalism()).SetValue(((GetHerbalism()).GetValue()) + xp)
	ElseIf stat == "mining"
		(GetMining()).SetValue(((GetMining()).GetValue()) + xp)
	ElseIf stat == "weaponsmithing"
		(GetWeaponsmithing()).SetValue(((GetWeaponsmithing()).GetValue()) + xp)
	EndIf
	
	LevelCheck(stat)
	
EndFunction

Function LevelCheck(string stat) Global

	If stat == "alchemy"
		LevelCheckAlchemy()
	ElseIf stat == "armorsmithing"
		LevelCheckArmorsmithing()
	ElseIf stat == "experience"
		LevelCheckXP()
	ElseIf stat == "herbalism"
		LevelCheckHerb()
	ElseIf stat == "mining"
		LevelCheckMining()
	ElseIf stat == "weaponsmithing"
		LevelCheckWeaponsmithing()
	EndIf

EndFunction

Function LevelCheckAlchemy() Global

	If HasAlchemy().GetValueInt() == 1
		
		Int clvl = GetAlchemy().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetAlchemyXP().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetAlchemyXP()).SetValue(((GetAlchemyXP()).GetValue()) - txp)
			(GetAlchemy()).SetValue(((GetAlchemy()).GetValue()) + 1)
		EndIf
		
	EndIf
		
EndFunction

Function LevelCheckArmorsmithing() Global

	If HasArmorsmithing().GetValueInt() == 1
		
		Int clvl = GetArmorsmithing().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetArmorsmithingXP().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetArmorsmithingXP()).SetValue(((GetArmorsmithingXP()).GetValue()) - txp)
			(GetArmorsmithing()).SetValue(((GetArmorsmithing()).GetValue()) + 1)
		EndIf
		
	EndIf
		
EndFunction

Function LevelCheckHerb() Global

	If HasHerbalism().GetValueInt() == 1
		
		Int clvl = GetHerbalism().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetHerbalismXP().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetHerbalismXP()).SetValue(((GetHerbalismXP()).GetValue()) - txp)
			(GetHerbalism()).SetValue(((GetHerbalism()).GetValue()) + 1)
		EndIf
		
	EndIf
		
EndFunction

Function LevelCheckMining() Global

	If HasMining().GetValueInt() == 1
		
		Int clvl = GetMining().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetMiningXP().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetMiningXP()).SetValue(((GetMiningXP()).GetValue()) - txp)
			(GetMining()).SetValue(((GetMining()).GetValue()) + 1)
		EndIf
		
	EndIf
		
EndFunction

Function LevelCheckWeaponsmithing() Global

	If HasWeaponsmithing().GetValueInt() == 1
		
		Int clvl = GetWeaponsmithing().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetWeaponsmithingXP().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetWeaponsmithingXP()).SetValue(((GetWeaponsmithingXP()).GetValue()) - txp)
			(GetWeaponsmithing()).SetValue(((GetWeaponsmithing()).GetValue()) + 1)
		EndIf
		
	EndIf
		
EndFunction

Function LevelCheckXP() Global
		
		Int clvl = GetpLevel().GetValueInt()
		Int tlvl = clvl + 1
		Int cxp = GetExperience().GetValueInt()
		Int txp = Math.Floor(tlvl + 300 * Math.POW(2, tlvl / 7))
		
		If cxp > txp
			(GetExperience()).SetValue(((GetExperience()).GetValue()) - txp)
			(GetpLevel()).SetValue(((GetpLevel()).GetValue()) + 1)
			GetStats()
			Debug.Notification("You have leveled up! Stats changes have been applied!")
		EndIf
		
EndFunction

Function GetStats() Global
	Int STR = GetStrength().GetValueInt()
	Int AGI = GetAgility().GetValueInt()
	Int DEX = GetDexterity().GetValueInt()
	Int VIT = GetVitality().GetValueInt()
	Int INL = GetIntelligence().GetValueInt()
	Int LUC = GetLuck().GetValueInt()
	Int COM = GetCommon().GetValueInt()
	Int UNC = GetUncommon().GetValueInt()
	Int RAR = GetRare().GetValueInt()
	Int VER = GetVeryRare().GetValueInt()
	Int i = GetWeaponsList().GetSize()
	
	Float Crit = Game.GetPlayer().GetActorValue("CritChance") + LUC / 4
	;Float Speed = Game.GetPlayer().GetActorValue("SpeedMult") + AGI / 1.075
		
	If GetpClass().GetValue() == 1
		(GetAgility()).SetValue(((GetAgility()).GetValue()) + 4)
		(GetStrength()).SetValue(((GetStrength()).GetValue()) + 3)
		(GetLuck()).SetValue(((GetLuck()).GetValue()) + 3)
		(GetDexterity()).SetValue(((GetDexterity()).GetValue()) + 2)
		(GetVitality()).SetValue(((GetVitality()).GetValue()) + 2)
		(GetIntelligence()).SetValue(((GetIntelligence()).GetValue()) + 2)
	ElseIf GetpClass().GetValue() == 2
		(GetAgility()).SetValue(((GetAgility()).GetValue()) + 2)
		(GetStrength()).SetValue(((GetStrength()).GetValue()) + 3)
		(GetLuck()).SetValue(((GetLuck()).GetValue()) + 2)
		(GetDexterity()).SetValue(((GetDexterity()).GetValue()) + 4)
		(GetVitality()).SetValue(((GetVitality()).GetValue()) + 3)
		(GetIntelligence()).SetValue(((GetIntelligence()).GetValue()) + 2)
	ElseIf GetpClass().GetValue() == 3
		(GetAgility()).SetValue(((GetAgility()).GetValue()) + 3)
		(GetStrength()).SetValue(((GetStrength()).GetValue()) + 4)
		(GetLuck()).SetValue(((GetLuck()).GetValue()) + 2)
		(GetDexterity()).SetValue(((GetDexterity()).GetValue()) + 2)
		(GetVitality()).SetValue(((GetVitality()).GetValue()) + 3)
		(GetIntelligence()).SetValue(((GetIntelligence()).GetValue()) + 2)
	EndIf
	
	While (i > 0)
		i = i - 1
		Weapon weaponslist = GetWeaponsList().GetAt(i) as Weapon
		Int Dmg = weaponslist.GetBaseDamage() + STR
		Game.GetPlayer().GetEquippedWeapon().SetBaseDamage(Dmg)
	EndWhile
	
	Game.GetPlayer().SetActorValue("CritChance", Crit)
	Game.GetPlayer().SetActorValue("Health", GetVitality().GetValue() * 10)
	Game.GetPlayer().SetActorValue("CarryWeight", GetStrength().GetValue() * 10)
	;Game.GetPlayer().SetActorValue("SpeedMult", Speed)
	If GetLuck().GetValue() < 50
		(GetCommon()).SetValue(((GetCommon()).GetValue() - LUC) * 1.25)
		(GetUncommon()).SetValue(((GetUncommon()).GetValue() - LUC) * 1.25)
		(GetRare()).SetValue(((GetRare()).GetValue() - LUC) * 1.25)
		(GetVeryRare()).SetValue(((GetVeryRare()).GetValue() - LUC) * 1.25)
	EndIf
	
EndFunction

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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