Browse Source

made scholar skill bonus-based

Henning Koehler 8 years ago
parent
commit
8bdb8f01ca
3 changed files with 43 additions and 4 deletions
  1. 35 0
      config/skills.json
  2. 2 0
      lib/CSkillHandler.cpp
  3. 6 4
      server/CGameHandler.cpp

+ 35 - 0
config/skills.json

@@ -631,5 +631,40 @@
                 }
             ]
         }
+    },
+    "scholar" : {
+        "basic" : {
+            "description" : "",
+            "effects" : [
+                {
+                    "subtype" : "skill.scholar",
+                    "type" : "SECONDARY_SKILL_PREMY",
+                    "val" : 2,
+                    "valueType" : "BASE_NUMBER"
+                }
+            ]
+        },
+        "advanced" : {
+            "description" : "",
+            "effects" : [
+                {
+                    "subtype" : "skill.scholar",
+                    "type" : "SECONDARY_SKILL_PREMY",
+                    "val" : 3,
+                    "valueType" : "BASE_NUMBER"
+                }
+            ]
+        },
+        "expert" : {
+            "description" : "",
+            "effects" : [
+                {
+                    "subtype" : "skill.scholar",
+                    "type" : "SECONDARY_SKILL_PREMY",
+                    "val" : 4,
+                    "valueType" : "BASE_NUMBER"
+                }
+            ]
+        }
     }
 }

+ 2 - 0
lib/CSkillHandler.cpp

@@ -252,6 +252,8 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
 	case SecondarySkill::WATER_MAGIC:
 	case SecondarySkill::EARTH_MAGIC:
 		addBonus(level); break;
+	case SecondarySkill::SCHOLAR:
+		addBonus(1 + level); break;
 	case SecondarySkill::TACTICS:
 		addBonus(1 + 2 * level); break;
 	case SecondarySkill::LEARNING:

+ 6 - 4
server/CGameHandler.cpp

@@ -2489,19 +2489,21 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 {
 	const CGHeroInstance * h1 = getHero(fromHero);
 	const CGHeroInstance * h2 = getHero(toHero);
+	int h1_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
+	int h2_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR);
 
-	if (h1->getSecSkillLevel(SecondarySkill::SCHOLAR) < h2->getSecSkillLevel(SecondarySkill::SCHOLAR))
+	if (h1_scholarLevel < h2_scholarLevel)
 	{
 		std::swap (h1,h2);//1st hero need to have higher scholar level for correct message
 		std::swap(fromHero, toHero);
 	}
 
-	int ScholarLevel = h1->getSecSkillLevel(SecondarySkill::SCHOLAR);//heroes can trade up to this level
+	int ScholarLevel = std::max(h1_scholarLevel, h2_scholarLevel);//heroes can trade up to this level
 	if (!ScholarLevel || !h1->hasSpellbook() || !h2->hasSpellbook())
 		return;//no scholar skill or no spellbook
 
-	int h1Lvl = std::min(ScholarLevel+1, h1->maxSpellLevel()),
-		h2Lvl = std::min(ScholarLevel+1, h2->maxSpellLevel());//heroes can receive this levels
+	int h1Lvl = std::min(ScholarLevel, h1->maxSpellLevel()),
+		h2Lvl = std::min(ScholarLevel, h2->maxSpellLevel());//heroes can receive this levels
 
 	ChangeSpells cs1;
 	cs1.learn = true;