瀏覽代碼

Support for creature skill icons. Several fixes for creature abilities.

DjWarmonger 14 年之前
父節點
當前提交
bc51c0006f
共有 5 個文件被更改,包括 160 次插入13 次删除
  1. 18 12
      client/CCreatureWindow.cpp
  2. 1 0
      client/CCreatureWindow.h
  3. 4 1
      config/cr_abils.txt
  4. 136 0
      lib/CCreatureSet.cpp
  5. 1 0
      lib/CCreatureSet.h

+ 18 - 12
client/CCreatureWindow.cpp

@@ -21,6 +21,7 @@
 #include <boost/format.hpp>
 #include <boost/bind.hpp>
 #include <boost/foreach.hpp>
+#include <boost/tuple/tuple.hpp>
 
 using namespace CSDL_Ext;
 
@@ -80,15 +81,17 @@ void CCreatureWindow::init(const CStackInstance *stack, const CBonusSystemNode *
 		node.bonuses.remove_if (Selector::typeSybtype(b->type, b->subtype)); //remove used bonuses
 	}
 
-	std::vector<std::pair<std::string, std::string> > descriptions; //quick, yet slow solution
-	std::string text, text2;
+	typedef boost::tuple<std::string,std::string, std::string> skillLine; //jeez
+	std::vector<skillLine> descriptions; //quick, yet slow solution
+	std::string text, text2, bonusGfx;
 	BOOST_FOREACH(Bonus* b, bl)
 	{
 		text = stack->bonusToString(b, false);
 		if (text.size())
 		{
 			text2 = stack->bonusToString(b, true);
-			descriptions.push_back(std::pair<std::string,std::string>(text, text2));
+			bonusGfx = stack->bonusToGraphics(b); // may be empty
+			descriptions.push_back(boost::tuple<std::string,std::string, std::string>(text, text2, bonusGfx));
 		}
 	}
 
@@ -174,23 +177,26 @@ void CCreatureWindow::init(const CStackInstance *stack, const CBonusSystemNode *
 	//All bonuses - abilities
 
 	int i = 0, j = 0;
-	typedef std::pair<std::string, std::string> stringpair; //jeez
-	BOOST_FOREACH(stringpair p, descriptions)
+	std::string gfxName;
+	BOOST_FOREACH(skillLine p, descriptions)
 	{
 		int offsetx = 257*j;
-		int offsety = 60*i;
+		int offsety = 60*i + (bonusRows > 1 ? 1 : 0); //lack of precision :<
 
-		printAt(p.first, 84 + offsetx, 238 + offsety, FONT_SMALL, tytulowy, *bitmap);
-		printAt(p.second, 84 + offsetx, 258 + offsety, FONT_SMALL, zwykly, *bitmap);
+		printAt(p.get<0>(), 84 + offsetx, 238 + offsety, FONT_SMALL, tytulowy, *bitmap);
+		printAt(p.get<1>(), 84 + offsetx, 258 + offsety, FONT_SMALL, zwykly, *bitmap);
+		gfxName = p.get<2>();
+		if (gfxName.size())
+		{
+			CPicture * bonusGfx = new CPicture(gfxName, 22 + offsetx, 232 + offsety);
+			bonusGraphics.push_back(bonusGfx);
+		}
 
 		if (++j > 1) //next line
 		{
 			++i;
 			j = 0;
 		}
-			//text = stack->bonusToString(*it, true);
-			//if (text.size())
-			//	printAt(text, 80 + offsety, 262 + offsetx, FONT_SMALL, zwykly, *bitmap);
 	}
 
 	//AUIDAT.DEF
@@ -286,6 +292,6 @@ void CCreatureWindow::close()
 
 CCreatureWindow::~CCreatureWindow()
 {
- 	for(int i=0; i<upgResCost.size();i++)
+ 	for (int i=0; i<upgResCost.size(); ++i)
  		delete upgResCost[i];
 }

+ 1 - 0
client/CCreatureWindow.h

@@ -33,6 +33,7 @@ public:
 	CCreaturePic *anim; //related creature's animation
 	const CCreature *c; //related creature
 	std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
+	std::vector<CPicture*> bonusGraphics;
 
 	MoraleLuckBox *luck, *morale;
 	LRClickableAreaWText * expArea; //displays exp details

+ 4 - 1
config/cr_abils.txt

@@ -103,10 +103,12 @@
 +  79 SELF_MORALE 0 0 0			   	//minotaur kings		
 +  81 SPELL_AFTER_ATTACK 0 74 20   	//scorpicore					
 +  82 LEVEL_SPELL_IMMUNITY 3 0 0   	//red dragon's spell immunity					
++  82 TWO_HEX_ATTACK_BREATH 0 0 0  	//Red Dragon has breath attack					
 +  82 DRAGON_NATURE 0 0 0			//red dragon is a dragon			
 +  83 LEVEL_SPELL_IMMUNITY 5 0 0   	//black dragon's spell immunity					
-+  83 HATE 50 40 0	//Hate Ggiants					
++  83 HATE 50 40 0	//Hate Giants					
 +  83 HATE 50 41 0	//Hate Titans					
++  83 TWO_HEX_ATTACK_BREATH 0 0 0  	//Black Dragon has breath attack					
 +  83 DRAGON_NATURE 0 0 0			//black dragon is a dragon			
 +  87 ADDITIONAL_ATTACK 1 0 0		//wolf raider				
 +  91 SPELLCASTER 2 43 6   	   	   	//ogre magi cast bloodlust			
@@ -191,4 +193,5 @@
 -  47 FLYING			  			//cerberus doesn't fly
 - 120 DOUBLE_WIDE					//psychic elemental	
 - 121 DOUBLE_WIDE					//magic elemental	
+- 157 SHOOTER	//Hell Hydra certainly does not shoot					
 0						

+ 136 - 0
lib/CCreatureSet.cpp

@@ -595,6 +595,142 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
 		return "";
 }
 
+std::string CStackInstance::bonusToGraphics(Bonus *bonus) const
+{
+	std::string fileName;
+	switch (bonus->type)
+	{
+			//"E_ALIVE.bmp"
+			//"E_ART.bmp"
+			//"E_BLESS.bmp"
+			//"E_BLOCK.bmp"
+			//"E_BLOCK1.bmp"
+			//"E_BLOCK2.bmp"
+		case Bonus::TWO_HEX_ATTACK_BREATH:
+			fileName = "E_BREATH.bmp"; break;
+		case Bonus::SPELL_AFTER_ATTACK:
+			fileName = "E_CAST.bmp"; break;
+			//"E_CAST1.bmp"
+			//"E_CAST2.bmp"
+			//"E_CASTER.bmp"
+		case Bonus::JOUSTING:
+			fileName = "E_CHAMP.bmp"; break;
+		case Bonus::DOUBLE_DAMAGE_CHANCE:
+			fileName = "E_DBLOW.bmp"; break;
+			//"E_DEATH.bmp"
+			//"E_DEFBON.bmp"
+		case Bonus::NO_DISTANCE_PENALTY:
+			fileName = "E_DIST.bmp"; break;
+		case Bonus::ADDITIONAL_ATTACK:
+			fileName = "E_DOUBLE.bmp"; break;
+		case Bonus::DRAGON_NATURE:
+			fileName = "E_DRAGON.bmp"; break;
+		case Bonus::MAGIC_RESISTANCE:
+			fileName = "E_DWARF.bmp"; break;
+		case Bonus::FEAR:
+			fileName = "E_FEAR.bmp"; break;
+		case Bonus::FEARLESS:
+			fileName = "E_FEARL.bmp"; break;
+			//"E_FIRE.bmp"
+		case Bonus::FLYING:
+			fileName = "E_FLY.bmp"; break;
+		case Bonus::SPELL_DAMAGE_REDUCTION:
+			fileName = "E_GOLEM.bmp"; break;
+		case Bonus::RETURN_AFTER_STRIKE:
+			fileName = "E_HARPY.bmp"; break;
+		case Bonus::HATE:
+			fileName = "E_HATE.bmp"; break;
+		case Bonus::KING1:
+			fileName = "E_KING1.bmp"; break;
+		case Bonus::KING2:
+			fileName = "E_KING2.bmp"; break;
+		case Bonus::KING3:
+			fileName = "E_KING3.bmp"; break;
+			//"E_LIGHT.bmp"
+		case Bonus::CHANGES_SPELL_COST_FOR_ALLY:
+			fileName = "E_MANA.bmp"; break;
+		case Bonus::NO_MELEE_PENALTY:
+			fileName = "E_MELEE.bmp"; break;
+			//"E_MIND.bmp"
+		case Bonus::SELF_MORALE:
+			fileName = "E_MINOT.bmp"; break;
+		case Bonus::NO_MORALE:
+			fileName = "E_MORAL.bmp"; break;
+			//"E_NOFRIM.bmp"
+		case Bonus::NO_OBSTACLES_PENALTY:
+			fileName = "E_OBST.bmp"; break;
+		case Bonus::ENEMY_DEFENCE_REDUCTION:
+			fileName = "E_RDEF.bmp"; break;
+			//"E_REBIRTH.bmp"
+		case Bonus::BLOCKS_RETALIATION:
+			fileName = "E_RETAIL.bmp"; break;
+		case Bonus::ADDITIONAL_RETALIATION:
+			fileName = "E_RETAIL1.bmp"; break;
+		case Bonus::ATTACKS_ALL_ADJACENT:
+			fileName = "E_ROUND.bmp"; break;
+			//"E_SGNUM.bmp"
+			//"E_SGTYPE.bmp"
+		case Bonus::SHOOTER:
+			fileName = "E_SHOOT.bmp"; break;
+		case Bonus::FREE_SHOOTING: //shooter is not blocked by enemy
+			fileName = "E_SHOOTA.bmp"; break;
+			//"E_SHOOTN.bmp"
+			//"E_SPAIR.bmp"
+			//"E_SPAIR1.bmp"
+		case Bonus::SPELL_IMMUNITY:
+		{
+			switch (bonus->subtype)
+			{
+				case 74: //Blind
+					fileName = "E_SPBLIND.bmp"; break;
+				case 60: //Hypnotize
+					fileName = "E_SPHYPN.bmp"; break;
+				case 18: //Implosion
+					fileName = "E_SPIMP.bmp"; break;
+				case 59: //Berserk
+					fileName = "E_SPBERS.bmp"; break;
+				case 23: //Meteor Shower
+					fileName = "E_SPMET.bmp"; break;
+				case 26: //Armageddon
+					fileName = "E_SPARM.bmp"; break;
+				case 54: //Slow
+					fileName = "E_SPSLOW.bmp"; break;
+				//TODO: some generic spell handling?
+			}
+		}
+			//"E_SPAWILL.bmp"
+			//"E_SPCOLD.bmp"
+			//"E_SPDFIRE.bmp"
+			//"E_SPDIR.bmp"
+			//"E_SPDISB.bmp"
+			//"E_SPDISP.bmp"
+			//"E_SPEATH.bmp"
+			//"E_SPEATH1.bmp"
+			//"E_SPFIRE.bmp"
+			//"E_SPFIRE1.bmp"
+		case Bonus::LEVEL_SPELL_IMMUNITY:
+		{
+			if (iswith(bonus->val, 1 , 5))
+			{
+				fileName = "E_SPLVL" + boost::lexical_cast<std::string>(bonus->val) + ".bmp";
+			}
+			break;
+		}
+			//"E_SPWATER.bmp"
+			//"E_SPWATER1.bmp"
+			//"E_SUMMON.bmp"
+			//"E_SUMMON1.bmp"
+			//"E_SUMMON2.bmp"
+		case Bonus::FULL_HP_REGENERATION:
+			fileName = "E_TROLL.bmp"; break;
+		case Bonus::UNDEAD:
+			fileName = "E_UNDEAD.bmp"; break;
+		case Bonus::SPELL_RESISTANCE_AURA:
+			fileName = "E_UNIC.bmp"; break;
+	}
+	return fileName;
+}
+
 void CStackInstance::setArmyObj(const CArmedInstance *ArmyObj)
 {
 	if(_armyObj)

+ 1 - 0
lib/CCreatureSet.h

@@ -47,6 +47,7 @@ public:
 	//overrides CBonusSystemNode
 	//void getParents(TCNodes &out, const CBonusSystemNode *source = NULL) const;  //retrieves list of parent nodes (nodes to inherit bonuses from), source is the prinary asker
 	std::string bonusToString(Bonus *bonus, bool description) const; // how would bonus description look for this particular type of node
+	std::string bonusToGraphics(Bonus *bonus) const; //file name of graphics from StackSkills , in future possibly others
 
 	int getQuantityID() const;
 	std::string getQuantityTXT(bool capitalized = true) const;