Rizalgar Posted June 21, 2019 Share Posted June 21, 2019 (edited) Okay, so I'm trying to reduce script size by using a math formula instead of writing out individual experience per level formulas. Anyway, the add experience is working for the most part, aside from actually adding the experience. Along with that, I'm having an odd thing there it lists the global variable as 0. Scroll all the way to the bottom to see the part in question, LCAttack() function. I'm getting the debug that it leveled every time I cast, which means required experience is 0 for some reason, as well as it listing the level gained as 0. Before you ask, I have all the custom functions referencing a data script, which I will add in here as well. The leveling framework Scriptname rsFrameworkMain extends Quest {Handles a lot of stuff} rsFrameworkData Function GetData() Global return (Game.GetFormFromFile(0x00594D,"Skyscape XBone") as Quest) as rsFrameworkData EndFunction ;Player Functions GlobalVariable Function GetBankSize() Global Return GetData().RS_Player_BankSize EndFunction GlobalVariable Function GetInventory() Global Return GetData().RS_Player_InventorySize EndFunction ;Player Stat Functions GlobalVariable Function GetAccuracy() Global Return GetData().RS_Stat_Accuracy EndFunction GlobalVariable Function GetAttackSpeed() Global Return GetData().RS_Stat_AttackSpeed EndFunction GlobalVariable Function GetAttackType() Global Return GetData().RS_Stat_AttackType EndFunction GlobalVariable Function GetCombatLevel() Global Return GetData().RS_Stat_CombatLevel EndFunction GlobalVariable Function GetDamage() Global Return GetData().RS_Stat_Damage EndFunction GlobalVariable Function GetMagicBonus() Global Return GetData().RS_Stat_MagicBonus EndFunction GlobalVariable Function GetPrayerBonus() Global Return GetData().RS_Stat_PrayerBonus EndFunction GlobalVariable Function GetRangedBonus() Global Return GetData().RS_Stat_RangedBonus EndFunction GlobalVariable Function GetStrengthBonus() Global Return GetData().RS_Stat_StrengthBonus EndFunction ;Player Skills Functions GlobalVariable Function GetAgilityLvl() Global Return GetData().RS_SV_AgilityLvl EndFunction GlobalVariable Function GetAgilityXP() Global Return GetData().RS_SV_AgilityXP EndFunction GlobalVariable Function GetAttackLvl() Global Return GetData().RS_SV_AttackLvl EndFunction GlobalVariable Function GetAttackXP() Global Return GetData().RS_SV_AttackXP EndFunction GlobalVariable Function GetConstitutionLvl() Global Return GetData().RS_SV_ConstitutionLvl EndFunction GlobalVariable Function GetConstitutionXP() Global Return GetData().RS_SV_ConstitutionXP EndFunction GlobalVariable Function GetConstructionLvl() Global Return GetData().RS_SV_ConstructionLvl EndFunction GlobalVariable Function GetConstructionXP() Global Return GetData().RS_SV_ConstructionXP EndFunction GlobalVariable Function GetCookingLvl() Global Return GetData().RS_SV_CookingLvl EndFunction GlobalVariable Function GetCookingXP() Global Return GetData().RS_SV_CookingXP EndFunction GlobalVariable Function GetCraftingLvl() Global Return GetData().RS_SV_CraftingLvl EndFunction GlobalVariable Function GetCraftingXP() Global Return GetData().RS_SV_CraftingXP EndFunction GlobalVariable Function GetDefenceLvl() Global Return GetData().RS_SV_DefenceLvl EndFunction GlobalVariable Function GetDefenceXP() Global Return GetData().RS_SV_DefenceXP EndFunction GlobalVariable Function GetDivinationLvl() Global Return GetData().RS_SV_DivinationLvl EndFunction GlobalVariable Function GetDivinationXP() Global Return GetData().RS_SV_DivinationXP EndFunction GlobalVariable Function GetDungeoneeringLvl() Global Return GetData().RS_SV_DungeoneeringLvl EndFunction GlobalVariable Function GetDungeoneeringXP() Global Return GetData().RS_SV_DungeoneeringXP EndFunction GlobalVariable Function GetFarmingLvl() Global Return GetData().RS_SV_FarmingLvl EndFunction GlobalVariable Function GetFarmingXP() Global Return GetData().RS_SV_FarmingXP EndFunction GlobalVariable Function GetFiremakingLvl() Global Return GetData().RS_SV_FiremakingLvl EndFunction GlobalVariable Function GetFiremakingXP() Global Return GetData().RS_SV_FiremakingXP EndFunction GlobalVariable Function GetFishingLvl() Global Return GetData().RS_SV_FishingLvl EndFunction GlobalVariable Function GetFishingXP() Global Return GetData().RS_SV_FishingXP EndFunction GlobalVariable Function GetFletchingLvl() Global Return GetData().RS_SV_FletchingLvl EndFunction GlobalVariable Function GetFletchingXP() Global Return GetData().RS_SV_FletchingXP EndFunction GlobalVariable Function GetHerbloreLvl() Global Return GetData().RS_SV_HerbloreLvl EndFunction GlobalVariable Function GetHerbloreXP() Global Return GetData().RS_SV_HerbloreXP EndFunction GlobalVariable Function GetHunterLvl() Global Return GetData().RS_SV_HunterLvl EndFunction GlobalVariable Function GetHunterXP() Global Return GetData().RS_SV_HunterXP EndFunction GlobalVariable Function GetInventionLvl() Global Return GetData().RS_SV_InventionLvl EndFunction GlobalVariable Function GetInventionXP() Global Return GetData().RS_SV_InventionXP EndFunction GlobalVariable Function GetMagicLvl() Global Return GetData().RS_SV_MagicLvl EndFunction GlobalVariable Function GetMagicXP() Global Return GetData().RS_SV_MagicXP EndFunction GlobalVariable Function GetMiningLvl() Global Return GetData().RS_SV_MiningLvl EndFunction GlobalVariable Function GetMiningXP() Global Return GetData().RS_SV_MiningXP EndFunction GlobalVariable Function GetPrayerLvl() Global Return GetData().RS_SV_PrayerLvl EndFunction GlobalVariable Function GetPrayerXP() Global Return GetData().RS_SV_PrayerXP EndFunction GlobalVariable Function GetRangedLvl() Global Return GetData().RS_SV_RangedLvl EndFunction GlobalVariable Function GetRangedXP() Global Return GetData().RS_SV_RangedXP EndFunction GlobalVariable Function GetRunecraftingLvl() Global Return GetData().RS_SV_RunecraftingLvl EndFunction GlobalVariable Function GetRunecraftingXP() Global Return GetData().RS_SV_RunecraftingXP EndFunction GlobalVariable Function GetSlayerLvl() Global Return GetData().RS_SV_SlayerLvl EndFunction GlobalVariable Function GetSlayerXP() Global Return GetData().RS_SV_SlayerXP EndFunction GlobalVariable Function GetSmithingLvl() Global Return GetData().RS_SV_SmithingLvl EndFunction GlobalVariable Function GetSmithingXP() Global Return GetData().RS_SV_SmithingXP EndFunction GlobalVariable Function GetStrengthLvl() Global Return GetData().RS_SV_StrengthLvl EndFunction GlobalVariable Function GetStrengthXP() Global Return GetData().RS_SV_StrengthXP EndFunction GlobalVariable Function GetSummoningLvl() Global Return GetData().RS_SV_SummoningLvl EndFunction GlobalVariable Function GetSummoningXP() Global Return GetData().RS_SV_SummoningXP EndFunction GlobalVariable Function GetThievingLvl() Global Return GetData().RS_SV_ThievingLvl EndFunction GlobalVariable Function GetThievingXP() Global Return GetData().RS_SV_ThievingXP EndFunction GlobalVariable Function GetWoodcuttingLvl() Global Return GetData().RS_SV_WoodcuttingLvl EndFunction GlobalVariable Function GetWoodcuttingXP() Global Return GetData().RS_SV_WoodcuttingXP EndFunction ; Actual functions start here ;;;;; ;;;; ;;; ;; ; ;; ;;; ;;;; ;;;;; ; Get combat skill to level up Function XPC(string skill, float xp) Global If skill == "attack" (GetAttackXP()).SetValue(((GetAttackXP()).GetValue()) + xp) ElseIf skill == "strength" (GetStrengthXP()).SetValue(((GetStrengthXP()).GetValue()) + xp) ElseIf skill == "defence" (GetDefenceXP()).SetValue(((GetDefenceXP()).GetValue()) + xp) ElseIf skill == "prayer" (GetPrayerXP()).SetValue(((GetPrayerXP()).GetValue()) + xp) ElseIf skill == "magic" (GetMagicXP()).SetValue(((GetMagicXP()).GetValue()) + xp) ElseIf skill == "ranged" (GetRangedXP()).SetValue(((GetRangedXP()).GetValue()) + xp) ElseIf skill == "constitution" (GetConstitutionXP()).SetValue(((GetConstitutionXP()).GetValue()) + xp) EndIf SetCombatLevel() CheckForCombatSkillUp(skill) EndFunction Function SetCombatLevel() Global Float att Float str Float mag Float rng Float def Float con Float pry Float sum Float lvl1 Float lvl2 Float lvl3 Float lvl4 Float lvl5 Float lvl6 Float lvl7 Float lvl8 Float lvl9 float lvl10 float lvl11 float lvl12 Float lvl13 Float lvl14 Float lvl15 Float lvl16 att = GetAttackLVL().GetValue() str = GetStrengthLVL().GetValue() mag = GetMagicLVL().GetValue() rng = GetRangedLVL().GetValue() def = GetDefenceLVL().GetValue() con = GetConstitutionLVL().GetValue() pry = GetPrayerLVL().GetValue() sum = GetSummoningLVL().GetValue() lvl1 = def * 100 lvl2 = con * 100 lvl3 = sum * 50 lvl4 = pry * 50 lvl5 = (lvl1 + lvl2 + lvl3 + lvl4) / 400 ;;base lvl6 = att * 130 lvl7 = str * 130 lvl8 = rng * 195 lvl9 = mag * 195 lvl10 = (lvl6 + lvl7) / 400 lvl11 = lvl8 / 400 lvl12 = lvl9 / 400 lvl13 = (lvl5 + lvl10) lvl14 = (lvl5 + lvl11) lvl15 = (lvl5 + lvl12) If lvl13 > lvl14 && lvl13 > lvl14 GetCombatLevel().SetValue(lvl13) ElseIf lvl14 > lvl13 && lvl14 > lvl15 GetCombatLevel().SetValue(lvl14) ElseIf lvl15 > lvl13 && lvl15 > lvl14 GetCombatLevel().SetValue(lvl15) EndIf EndFunction Function CheckForCombatSkillUp(string skill) Global If skill == "attack" LCAttack() ElseIf skill == "strength" ;LCStrength() ElseIf skill == "defence" ;LCDefence() ElseIf skill == "constitution" ;LCConstitution() ElseIf skill == "prayer" ;LCPrayer() ElseIf skill == "magic" ;LCMagic() ElseIf skill == "ranged" ;LCRanged() EndIf EndFunction Function LCAttack() Global Float cl = GetAttackLVL().GetValue() Float cxp = GetAttackXP().GetValue() Float txp = Math.Floor((cl + 300) * (2 * (cl / 7))) If cl < 120 If txp > cxp Debug.Notification("WTF") ElseIf cxp >= txp GetAttackLvl().SetValue(((GetAttackLvl()).GetValue()) + 1) Debug.Notification("Your attack level is now level " + cl as Int + "!") EndIf EndIf EndFunction The library framework Scriptname rsFrameworkData extends Quest {Contains all accessible data} ;Player GlobalVariable Property RS_Player_BankSize Auto GlobalVariable Property RS_Player_InventorySize Auto ;Stats GlobalVariable Property RS_Stat_Accuracy Auto GlobalVariable Property RS_Stat_AttackSpeed Auto GlobalVariable Property RS_Stat_AttackType Auto GlobalVariable Property RS_Stat_CombatLevel Auto GlobalVariable Property RS_Stat_Damage Auto GlobalVariable Property RS_Stat_MagicBonus Auto GlobalVariable Property RS_Stat_PrayerBonus Auto GlobalVariable Property RS_Stat_RangedBonus Auto GlobalVariable Property RS_Stat_StrengthBonus Auto ;Skills GlobalVariable Property RS_SV_AgilityLvl Auto GlobalVariable Property RS_SV_AgilityXP Auto GlobalVariable Property RS_SV_AttackLvl Auto GlobalVariable Property RS_SV_AttackXP Auto GlobalVariable Property RS_SV_ConstitutionLvl Auto GlobalVariable Property RS_SV_ConstitutionXP Auto GlobalVariable Property RS_SV_ConstructionLvl Auto GlobalVariable Property RS_SV_ConstructionXP Auto GlobalVariable Property RS_SV_CookingLvl Auto GlobalVariable Property RS_SV_CookingXP Auto GlobalVariable Property RS_SV_CraftingLvl Auto GlobalVariable Property RS_SV_CraftingXP Auto GlobalVariable Property RS_SV_DefenceLvl Auto GlobalVariable Property RS_SV_DefenceXP Auto GlobalVariable Property RS_SV_DivinationLvl Auto GlobalVariable Property RS_SV_DivinationXP Auto GlobalVariable Property RS_SV_DungeoneeringLvl Auto GlobalVariable Property RS_SV_DungeoneeringXP Auto GlobalVariable Property RS_SV_FarmingLvl Auto GlobalVariable Property RS_SV_FarmingXP Auto GlobalVariable Property RS_SV_FiremakingLvl Auto GlobalVariable Property RS_SV_FiremakingXP Auto GlobalVariable Property RS_SV_FishingLvl Auto GlobalVariable Property RS_SV_FishingXP Auto GlobalVariable Property RS_SV_FletchingLvl Auto GlobalVariable Property RS_SV_FletchingXP Auto GlobalVariable Property RS_SV_HerbloreLvl Auto GlobalVariable Property RS_SV_HerbloreXP Auto GlobalVariable Property RS_SV_HunterLvl Auto GlobalVariable Property RS_SV_HunterXP Auto GlobalVariable Property RS_SV_InventionLvl Auto GlobalVariable Property RS_SV_InventionXP Auto GlobalVariable Property RS_SV_MagicLvl Auto GlobalVariable Property RS_SV_MagicXP Auto GlobalVariable Property RS_SV_MiningLvl Auto GlobalVariable Property RS_SV_MiningXP Auto GlobalVariable Property RS_SV_PrayerLvl Auto GlobalVariable Property RS_SV_PrayerXP Auto GlobalVariable Property RS_SV_RangedLvl Auto GlobalVariable Property RS_SV_RangedXP Auto GlobalVariable Property RS_SV_RunecraftingLvl Auto GlobalVariable Property RS_SV_RunecraftingXP Auto GlobalVariable Property RS_SV_SlayerLvl Auto GlobalVariable Property RS_SV_SlayerXP Auto GlobalVariable Property RS_SV_SmithingLvl Auto GlobalVariable Property RS_SV_SmithingXP Auto GlobalVariable Property RS_SV_StrengthLvl Auto GlobalVariable Property RS_SV_StrengthXP Auto GlobalVariable Property RS_SV_SummoningLvl Auto GlobalVariable Property RS_SV_SummoningXP Auto GlobalVariable Property RS_SV_ThievingLvl Auto GlobalVariable Property RS_SV_ThievingXP Auto GlobalVariable Property RS_SV_WoodcuttingLvl Auto GlobalVariable Property RS_SV_WoodcuttingXP Auto Edit - The math is apprently right and I'm doing something else wrong cuz it shows properly in this script Event OnEffectStart(Actor target, Actor caster) Float CAttXP = RS_SV_AttackXP.GetValue() as Int Float CAttLvl = RS_SV_AttackLvl.GetValue() Float TAttXP = Math.Floor((CAttLvl + 300) * (2 * (CAttLvl / 7))) Float AttackDiff = (TAttXP - CAttXP) as Int Int a1 = RS_MB_Skills_Show.Show() If a1 == 0 Int a2 = RS_MB_Skills_Combat.Show() If a2 == 0 Debug.MessageBox("Your current attack level is " + CAttLvl as Int + ". You need " + AttackDiff as Int + " more experience to level.") EndIf EndIf EndEvent Edit - Figured it out. Just had to make references to each skills form ID Edited June 21, 2019 by Rizalgar Link to comment Share on other sites More sharing options...
Recommended Posts