View Single Post
  #1  
Old 09-09-2006, 12:48 PM
eq4me
Hill Giant
 
Join Date: Jul 2006
Posts: 166
Default tradeskill.cpp enhancements

I am not quite done yet but the changes I implemented so far are working fine and will bring the workings of the tradeskill success rates alot closer to life.

Code:
--- zone/tradeskills.cpp-orig   2006-09-07 19:04:51.927543012 +0000
+++ zone/tradeskills.cpp        2006-09-10 00:42:31.938770546 +0000
@@ -652,6 +652,36 @@
        float chance = 0;
+       float skillup_modifier;
+       sint16 thirdstat = 0;
+       sint16 stat_modifier = -15;
+       sint16 success_multiplier = 0;
+
+       // Rework based on the info on eqtraders.com
+       // http://mboards.eqtraders.com/eq/showthread.php?t=22246
+       // 09/10/2006 v0.1 (eq4me) Todo: Implementing new formula for skillup chance.
+
+       // Some tradeskills are more eqal then others. ;-)
+        if (tradeskill == (ALCHEMY || FLETCHING || JEWELRY_MAKING || POTTERY)) {
+       skillup_modifier = 4;
+       } else if (tradeskill == (BAKING || BREWING)) {
+       skillup_modifier = 3;
+       } else if (tradeskill == (RESEARCH)) {
+       skillup_modifier = 1;
+       } else
+        skillup_modifier = 2;
+
+       // Some tradeskills take the higher of one additional stat beside INT and WIS
+       // to determine the skillup rate. Additionally these tradeskills do not have an
+       // -15 modifier on their statbonus.
+       if (tradeskill == ( FLETCHING || MAKE_POISON)) {
+               thirdstat = GetDEX();
+               stat_modifier = 0;
+       } else if (tradeskill == (BLACKSMITHING)) {
+               thirdstat = GetSTR();
+               stat_modifier = 0;
+       }
+
+       sint16 higher_from_int_wis = (GetINT() > GetWIS()) ? GetINT() : GetWIS();
+       sint16 bonusstat = (higher_from_int_wis > thirdstat) ? higher_from_int_wis : thirdstat;

-       // statbonus 20%/10% with 200 + 0.05% / 0.025% per point above 200
-       float wisebonus =  (m_pp.WIS > 200) ? 20 + ((m_pp.WIS - 200) * 0.05) : m_pp.WIS * 0.1;
-       float intbonus =  (m_pp.INT > 200) ? 10 + ((m_pp.INT - 200) * 0.025) : m_pp.INT * 0.05;
+       float skillupbonus =  (bonusstat > 200) ? 10 + ((bonusstat - 200) * 0.025) : bonusstat * 0.05;

@@ -662,16 +692,37 @@
                chance = 100;   //cannot fail.
+               #ifdef TRADESKILL_SPAM
+               Message(0, "This combine cannot fail.");
+               #endif
        } else if(((sint16)user_skill - (sint16)spec->skill_needed) < 0) {
-               chance = 0;
-               //impossible... is there a message for this???
-       } else if (((sint16)user_skill - (sint16)spec->trivial) >= 0) {
-               chance = 80+wisebonus-10; // 80% basechance + max 20% stats
+               // Minimum chance is always 5
+               chance = 5;
+       } else if(((sint16)user_skill - (sint16)spec->trivial) == 0) {
+               // At reaching trivial the chance goes to 95% going up an additional
+               // percent for every 40 skillpoints above the trivial.
+               // The success rate is not modified through stats.
+               // Mastery AAs are unaccounted for so far.
+               // chance_AA = chance + ((100 - chance) * mastery_modifier)
+               // But the 95% limit with an additional 1% for every 40 skill points
+               // above critical still stands.
+               // Mastery modifier is: 10%/25%/50% for rank one/two/three
+               chance = 95;
+               Message_StringID(4,TRADESKILL_TRIVIAL);
+       } else if (((sint16)user_skill - (sint16)spec->trivial) > 0) {
+               chance = (sint16)((user_skill - spec->trivial) / 40) + 95;
+               if (chance > 100) {
+               chance = 100;
+               }
                Message_StringID(4,TRADESKILL_TRIVIAL);
        } else {
-               if ((spec->trivial - user_skill) < 20) {
-                       // 40 base chance success + max 40% skill + 20% max stats
-                       chance = 40 + wisebonus + 40 - ((spec->trivial - user_skill)*2);
+               // For trivials over 68 the chance is (skill - 0.75*trivial) +51.5
+               // For trivial up to 68 the chance is (skill - trivial) + 66
+               if (spec->trivial >= 68) {
+                       chance = (user_skill - (0.75*spec->trivial)) + 51.5;
                }
                else {
-                       // 0 base chance success + max 30% skill + 10% max stats
-                       chance = 0 + (wisebonus/2) + 30 - (((spec->trivial - user_skill) * (spec->trivial - user_skill))*0.01875);
+                       chance = (user_skill - spec->trivial) + 66;
+               }
+               //Just because I am paranoid
+                if (chance >95) {
+                        chance = 95;
                }
@@ -680,3 +732,3 @@
                // skillincrease?
-               if ((55-(user_skill*0.236))+intbonus > (float)rand()/RAND_MAX*100) {
+               if ((55-(user_skill*0.236))+skillupbonus > (float)rand()/RAND_MAX*100) {
                        SetSkill(tradeskill, GetRawSkill(tradeskill) + 1);
@@ -690,2 +742,7 @@

+       #ifdef TRADESKILL_SPAM
+       Message(0, "Current skill: %d , Trivial: %d , Success chance: %f percent. , skillupbonus: %f", user_skill , spec->trivial , chance , skillupbonus);
+       Message(0, "Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR());
+       #endif
+
                itr = spec->onsuccess.begin();
@@ -700,2 +757,7 @@

+       #ifdef TRADESKILL_SPAM
+       Message(0, "Current skill: %d , Trivial: %d , Success chance: %f percent. , skillupbonus: %f", user_skill , spec->trivial , chance , skillupbonus);
+       Message(0, "Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR());
+       #endif
Reply With Quote