Author Topic: 3.8.x Modify percentages of Level up per unit  (Read 532 times)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
3.8.x Modify percentages of Level up per unit
« on: 11 November 2012, 21:42:22 »
As 3.7.0 seems to be released too soon. I will redo this again using a better way (supporting GAE + Attack-Boost Syntax)

Here is my patch for Leveling up, which allows to modify the percentages in unit XML, it's a quite simple way, but stable and needs no big changes in sourcecode:

it is used like this:

Code: [Select]
<levels modHP="18" modEP="18" modSight="0" modArmor="4">
<level name="1" kills="30" />
<level name="2" kills="100" />
<level name="3" kills="250" />
</levels>

which means 1.18 * HP  | 1.18 * EP | 1.0 * Sight | 1.04*Armor per level

Code: [Select]
Index: source/glest_game/types/unit_type.cpp
===================================================================
--- source/glest_game/types/unit_type.cpp (revision 3893)
+++ source/glest_game/types/unit_type.cpp (working copy)
@@ -278,6 +278,26 @@
 
  //levels
  const XmlNode *levelsNode= parametersNode->getChild("levels");
+ if(levelsNode->hasAttribute("modHP")){
+ levelModHP = levelsNode->getAttribute("modHP")->getIntValue();
+ }else{
+ levelModHP = 50;
+ }
+ if(levelsNode->hasAttribute("modEP")){
+ levelModEP = levelsNode->getAttribute("modEP")->getIntValue();
+ }else{
+ levelModEP = 50;
+ }
+ if(levelsNode->hasAttribute("modSight")){
+ levelModSight = levelsNode->getAttribute("modSight")->getIntValue();
+ }else{
+ levelModSight = 20;
+ }
+ if(levelsNode->hasAttribute("modArmor")){
+ levelModArmor = levelsNode->getAttribute("modArmor")->getIntValue();
+ }else{
+ levelModArmor = 50;
+ }
  levels.resize(levelsNode->getChildCount());
  for(int i=0; i<levels.size(); ++i){
  const XmlNode *levelNode= levelsNode->getChild("level", i);
Index: source/glest_game/types/unit_type.h
===================================================================
--- source/glest_game/types/unit_type.h (revision 3893)
+++ source/glest_game/types/unit_type.h (working copy)
@@ -108,6 +108,10 @@
     int maxEp;
  int epRegeneration;
  int maxUnitCount;
+ int levelModHP;
+ int levelModEP;
+ int levelModSight;
+ int levelModArmor;
 
 
  ///@todo remove fields, multiple fields are not supported by the engine
@@ -169,7 +173,11 @@
 
     UnitCountsInVictoryConditions getCountInVictoryConditions() const { return countInVictoryConditions; }
  //get
-    inline int getId() const {return id;}
+    inline int getId() const {return id;}
+ inline int getlevelModHP() const {return levelModHP;}
+inline int getlevelModEP() const {return levelModEP;}
+inline int getlevelModSight() const {return levelModSight;}
+inline int getlevelModArmor() const {return levelModArmor;}
     inline int getMaxHp() const {return maxHp;}
     inline int getHpRegeneration() const {return hpRegeneration;}
     inline int getMaxEp() const {return maxEp;}
Index: source/glest_game/types/upgrade_type.cpp
===================================================================
--- source/glest_game/types/upgrade_type.cpp (revision 3893)
+++ source/glest_game/types/upgrade_type.cpp (working copy)
@@ -989,10 +989,10 @@
 }
 
 void TotalUpgrade::incLevel(const UnitType *ut) {
- maxHp += ut->getMaxHp()*50/100;
- maxEp += ut->getMaxEp()*50/100;
- sight += ut->getSight()*20/100;
- armor += ut->getArmor()*50/100;
+ maxHp += ut->getMaxHp()*ut->getlevelModHP()/100;
+ maxEp += ut->getMaxEp()*ut->getlevelModEP()/100;
+ sight += ut->getSight()*ut->getlevelModSight()/100;
+ armor += ut->getArmor()*ut->getlevelModArmor()/100;
 }
 
 void TotalUpgrade::saveGame(XmlNode *rootNode) const {
« Last Edit: 11 November 2012, 22:10:08 by MuwuM »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: 3.8.x Modify percentages of Level up per unit
« Reply #1 on: 12 November 2012, 07:33:27 »
I'm glad you're redoing this in a GAE supported way, as it will allow each level to have different boosts (for example, the first level could increase armour, the second might increase attack, etc).

As a potential feature, request, though, since you're looking into changing how leveling works, would it be possible to see animations based on level? One way this could be done would be to have the animation tag of the skill formatted like this:

Code: [Select]
<skill>
<type value="stop" />
<name value="stop_skill" />
<ep-cost value="0" />
<speed value="1000" />
<anim-speed value="45" />
<animation level="default" path="models/swordman_standing.g3d" />
<animation level="elite" path="models/elite_swordman_standing.g3d" />
<sound enabled="false" />
</skill>
As you can see, the level parameter was added to the animations tag (MG already supports multiple animations, I believe). The value of the level parameter is equal to the current level name of the unit. Perhaps the parameter could accept a comma separated list to prevent the need to have multiple animation tags if, say, the same animation is used for the first two levels, while the third level uses a different animation. If the value of level is "default", it applies to the state of which the unit doesn't have any levels. If no level attribute appears, the animation applies to all levels. If no "default" level animation appears, the first animation tag will be used. If there are multiple animation tags for which a level is valid for, it will continue to randomly use one of them each time.

While we're on the topic of leveling, there was some cool possibilities discussed in this topic. I'm not saying any of them should be implemented, as they're a huge step up, but they're some cool options to consider for the future (again, the changes discussed in that topic are all options which must be manually enabled by the modder, so no damage for those who disagree with them).
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert