Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #deffunc skillexp int skillID, int entity, int BaseXPGained, int PrimaryStatXPFactor, intPrimaryXPFactor
- // Checks to see if the person gaining the xp actually knows the skill/stat, and terminates if they don't
- if ( sorg(skillID, entity) == 0 ) {
- return 0
- }
- // Terminates if the amount of xp sent to this function is 0.
- if ( BaseXPGained == 0 ) {
- return
- }
- /* This calls skillexp again for the main attribute tied to whatever skill we increase.
- To be clear, the skillexp function is how both attributes and skills gain xp. However, the
- attributes don't have an attribute tied to them, as they ARE the attribute. Or in other words,
- var_82(0,SkillID) is 0 for attributes and 10-18 for skills.
- Essentially this just gives a portion of skill exp to the main stat it's tied to. Presumably, if no
- value is specified, then PrimaryStatXPFactor is defaulted to 0, meaning this gives half xp to
- the main attribute.
- */
- if ( var_82(0, skillID) != 0 ) {
- skillexp var_82(0, skillID), entity, BaseXPGained / (2 + PrimaryStatXPFactor)
- }
- /* This grabs the base value of the affected stat/skill's level, and the
- potential of the stat/skill.
- Divide the stat total by 1000000 to get level
- Do a modulo 1000 on the stat total to get potential
- */
- BaseSkillLevel = sorg(skillID, entity)
- BaseSkillPotential = sgrowth(skillID, entity)
- // Terminate if the stat/skill's potential is 0.
- if ( BaseSkillPotential == 0 ) {
- return
- }
- /* If the amount of experience added is more than 0:
- Determine EffectiveXPGained by BaseXPGain * BaseSkillPotential / (100 + BaseSkillLevel * 10)
- If we're modifying an attribute (strength through luck)
- If the entity has a stat grwoth modifier buff
- EffectiveXPGained = Current value of EffectiveXPGained * (100 + magnitute of growth buff)/100
- If EffectiveXPGained is 0
- If a random number between 0 and BaseSkillLevel/10 is 0,
- EffectiveXPGained is set to 1.
- Otherwise, terminate this function.
- Otherwise (i.e, BaseXPGained is negative), then EffectiveXPGained is set to BaseXPGained.
- */
- if ( BaseXPGained > 0 ) {
- EffectiveXPGained = BaseXPGained * BaseSkillPotential / (100 + BaseSkillLevel * 10)
- if ( skillID >= 10 ) {
- if ( skillID <= 19 ) {
- if ( var_57(270 + skillID - 10, entity) > 0 ) {
- EffectiveXPGained = EffectiveXPGained * (100 + var_57(270 + skillID - 10, entity)) / 100
- }
- }
- }
- if ( EffectiveXPGained == 0 ) {
- if ( rnd(BaseSkillLevel / 10 + 1) == 0 ) {
- EffectiveXPGained = 1
- }
- else {
- return 0
- }
- }
- }
- else {
- EffectiveXPGained = BaseXPGained
- }
- /* If the player is currently in a showroom, or the entity being modified by this function is
- currently sandbagged (cbit985), then set EffectiveXPGained to 0.
- */
- if ( var_64(20) == 35 ) {
- EffectiveXPGained = 0
- }
- if ( cbit(985, entity) ) {
- EffectiveXPGained = 0
- }
- /* If the skill's ID is > 100 (all skills, no attributes)
- If a random number between 0 and the entity being affected's Learning +49 (inclusive) is greater
- than a random number between 0 and 999
- If EffectiveXPGained is either more or less than 0
- EffectiveXPGained is set to EffectiveXPGained * (sqrt(Entity.Learning)+20)/10, where
- (sqrt(Entity.Learning)+20 has a minimum value of 20 and a maximum of 50. This means that
- it applies between a 2x and 5x multiplier to EffectiveXPGained when triggered.
- */
- if ( skillID >= 100 ) {
- if ( rnd(var_81(14, entity) + 50) > rnd(1000) ) {
- if ( EffectiveXPGained != 0 ) {
- EffectiveXPGained = EffectiveXPGained * limit(sqrt(var_81(14, entity)) + 20, 20, 50) / 10
- }
- }
- }
- /* If the skill's ID is > 100 (all skills, no attributes)
- If the entity is NOT the player and IS a pet
- EffectiveXPGained is multiplied by 4.
- */
- if ( skillID >= 100 ) {
- if ( entity != 0 & entity < 16 ) {
- EffectiveXPGained = EffectiveXPGained * 4
- }
- }
- // If EffectiveXPGained is greater than 20000 at this point, it's reduced to 20000
- if ( EffectiveXPGained > 20000 ) {
- EffectiveXPGained = 20000
- }
- // If GameMode is Overdose, then multiply EffectiveXPGained by 20.
- if ( var_64(250 + 23) == 2 ) {
- EffectiveXPGained = EffectiveXPGained * 20
- }
- /* If player's drowsiness is >= 50 ("Need Sleep", maybe?) AND the entity being modified is a player
- OR a pet, then set EffectiveXPGained to 0.
- Interesting that this means neither you or a pet can gain xp if YOU are sleepy enough.
- */
- if ( var_64(90) >= 50 ) {
- if ( entity == 0 | entity < 16 ) {
- EffectiveXPGained = 0
- }
- }
- /* If EffectiveXPGained is still more than 0 at this point
- If skillID is greater than or equal to 100 (all skills, no attributes)
- IfPrimaryXPFactor != 1000
- Note that I can't find a common link with calls to this function wherePrimaryXPFactor is 1000.
- Most faith gains seem to be that way. Traveling xp gain is that way. There's only a handful.
- If the entity's totalXPNeededToLevel < 1000
- PrimaryXPGain = a random number between 0 and totalXPNeededToLevel (-1)*
- EffectiveXPGained / 1000 / (Level +PrimaryXPFactor) + 1) + either 0 or 1.
- If, on the other hand, totalXPNeededToLevel is equal to or more than 1000
- PrimaryXPGain = a random number between 0 and totalXPNeededToLevel(-1) / 1000
- * EffectiveXPGained / (Level + PrimaryXPFactor)+1) + either 0 or 1.
- CurrentXPTotal = CurrentXPTotal + PrimaryXPGain;
- If the entity being modified by this function is the player,
- add PrimaryXPGain to XPGainedSinceLastSleep (?)
- */
- if ( EffectiveXPGained > 0 ) {
- if ( skillID >= 100 ) {
- if (PrimaryXPFactor != 1000 ) {
- if ( var_57(36, entity) < 1000 ) {
- PrimaryXPGain = rnd(var_57(36, entity) * EffectiveXPGained / 1000 / (var_57(38, entity) +PrimaryXPFactor) + 1) + rnd(2)
- }
- if ( var_57(36, entity) >= 1000 ) {
- PrimaryXPGain = rnd(var_57(36, entity) / 1000 * EffectiveXPGained / (var_57(38, entity) +PrimaryXPFactor) + 1) + rnd(2)
- }
- var_57(35, entity) += PrimaryXPGain
- if ( entity == 0 ) {
- var_64(92) += PrimaryXPGain
- }
- }
- }
- }
- /* Returns the current skill exp for the stat/skill and adds it to EffectiveXPGained
- Note that I've renamed "EffectiveXPGained" to "TotalSkillXP" from this point down
- (after the following line) for the sake of clarity.
- Current XP is found by Stat Value \ 1000000 / 1000
- That's modulo 1000000 divided by 1000
- */
- EffectiveXPGained += sexp(skillID, entity)
- /* If TotalSkillXP >= 1000 (at this point, 1000 is a level)
- SkillLevelsGained = TotalSkillXP/1000 (Note than this rounds down. 2500 = 2)
- TotalSkillXP = TotalSkillXP \1000 (This is modulo - takes the remainder. 2500 = 500)
- BaseSkillLevel is increased by SkillLevelsGained
- Loop for the number of skill/stat levels gained
- Multiply the BaseSkillPotential by 0.9.
- If BaseSkillPotential would be below 1, set it to 1.
- End loop
- var_81(skillID + 600, entity) is the base exp for the skill/stat.
- (That means 600 values (offset 2400) past the value of the skillID, fyi)
- This line essentially writes the stat level, stat experience, and stat potential back to that value.
- Level is multiplied by 1000000, raw skill xp by 1000, and potential is not modified.
- synccheck portion returns true if a change happened (level up), and plays a sound if the
- entity being modified is the player or a pet(and displays the stat/skill up message, such as
- "begins to feel good when hit hard" for CON) . It then recalculates all stats (label_1707) and terminates.
- */
- if ( TotalSkillXP >= 1000 ) {
- SkillLevelsGained = TotalSkillXP / 1000
- TotalSkillXP = TotalSkillXP \ 1000
- BaseSkillLevel += SkillLevelsGained
- repeat SkillLevelsGained
- BaseSkillPotential = int(double(BaseSkillPotential) * 0.9)
- if ( BaseSkillPotential < 1 ) {
- BaseSkillPotential = 1
- }
- loop
- var_81(skillID + 600, entity) = limit(BaseSkillLevel, 0, 2000) * 1000000 + TotalSkillXP * 1000 + BaseSkillPotential
- if ( synccheck(entity, -1) ) {
- if ( entity == 0 | entity < 16 ) {
- snd 61
- txtef 2
- var_139 = 1
- }
- var_241 = 0
- var_245 = 1 + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "")
- var_245 = rnd(var_245)
- txt_select txtskillchange(skillID, 0, entity), "", "", "", "", "", "", "", ""
- var_208 = 255, 255, 255
- }
- var_625 = entity
- gosub *label_1707
- return 1
- }
- /* If the total skill exp is less than 0 (Note that this actually just means that EffectiveXPGained + CurrentSkillXP
- is a negative number)
- Literally the reverse of the above. Only thing to note is that you regain 1.1*BaseSkillPotential +1 for every
- skill/stat level you lose.
- Stat level, stat experience, and stat potential are then re-written to BaseSkillLevel variable.
- */
- if ( TotalSkillXP < 0 ) {
- SkillLevelsGained = -TotalSkillXP / 1000 + 1
- TotalSkillXP = 1000 + TotalSkillXP \ 1000
- if ( BaseSkillLevel - SkillLevelsGained < 1 ) {
- SkillLevelsGained = BaseSkillLevel - 1
- if ( BaseSkillLevel == 1 ) {
- if ( SkillLevelsGained == 0 ) {
- TotalSkillXP = 0
- }
- }
- }
- BaseSkillLevel -= SkillLevelsGained
- repeat SkillLevelsGained
- BaseSkillPotential = int(double(BaseSkillPotential) * ((-0.9) + 2)) + 1
- if ( BaseSkillPotential > 400 ) {
- BaseSkillPotential = 400
- }
- loop
- var_81(skillID + 600, entity) = limit(BaseSkillLevel, 0, 2000) * 1000000 + TotalSkillXP * 1000 + BaseSkillPotential
- if ( synccheck(entity, -1) ) {
- if ( entity == 0 | entity < 16 ) {
- if ( SkillLevelsGained != 0 ) {
- var_139 = 1
- txtef 3
- var_241 = 0
- var_245 = 1 + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "") + ("" != "")
- var_245 = rnd(var_245)
- txt_select txtskillchange(skillID, 1, entity), "", "", "", "", "", "", "", ""
- var_208 = 255, 255, 255
- }
- }
- }
- var_625 = entity
- gosub *label_1707
- return 1
- }
- /* You only get to this point if you don't have enough xp to either gain or lose a stat/skill level, in which case
- the new stat level, stat experience, and stat potential are simply rewritten to the BaseSkillLevel variable.
- */
- var_81(skillID + 600, entity) = limit(BaseSkillLevel, 0, 2000) * 1000000 + TotalSkillXP * 1000 + BaseSkillPotential
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement