浏览代码

Stack experience more or less handled. Neutrals get 10K xp every day.

DjWarmonger 14 年之前
父节点
当前提交
a5a493bfc1
共有 4 个文件被更改,包括 14 次插入3 次删除
  1. 1 1
      lib/CCreatureSet.cpp
  2. 5 0
      lib/CObjectHandler.cpp
  3. 0 2
      lib/NetPacks.h
  4. 8 0
      lib/NetPacksLib.cpp

+ 1 - 1
lib/CCreatureSet.cpp

@@ -441,7 +441,7 @@ int CStackInstance::getQuantityID() const
 int CStackInstance::getExpRank() const
 {
 	int tier = type->level;
-	if (isbetw(tier, 1, 7))
+	if (iswith(tier, 1, 7))
 	{
 		for (int i = VLC->creh->expRanks[tier].size()-2; i >-1; --i)//sic!
 		{ //exp values vary from 1st level to max exp at 11th level

+ 5 - 0
lib/CObjectHandler.cpp

@@ -2962,6 +2962,8 @@ void CGCreature::newTurn() const
 		cb->setObjProperty(id, 10, std::min (power/1000 , (ui32)CREEP_SIZE)); //set new amount
 		cb->setObjProperty(id, 11, power); //increase temppower
 	}
+	if (STACK_EXP)
+		cb->setObjProperty(id, 12, 10000); //for testing purpose
 }
 void CGCreature::setPropertyDer(ui8 what, ui32 val)
 {
@@ -2973,6 +2975,9 @@ void CGCreature::setPropertyDer(ui8 what, ui32 val)
 		case 11:
 			temppower = val;
 			break;
+		case 12:
+			giveStackExp(val);
+			break;
 	}
 }
 

+ 0 - 2
lib/NetPacks.h

@@ -1184,8 +1184,6 @@ struct BattleResult : public CPackForClient//3003
 	expType exp[2]; //exp for attacker and defender
 	std::set<ui32> artifacts; //artifacts taken from loser to winner
 
-
-
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & result & winner & casualties[0] & casualties[1] & exp & artifacts;

+ 8 - 0
lib/NetPacksLib.cpp

@@ -910,6 +910,14 @@ void BattleResult::applyGs( CGameState *gs )
 	if(h) 
 		h->bonuses.remove_if(Bonus::OneBattle);
 
+	if (STACK_EXP)
+	{
+		if (exp[0]) //checking local array is easier than dereferencing this crap twice
+			gs->curB->belligerents[0]->giveStackExp(exp[0]);
+		if (exp[1])
+			gs->curB->belligerents[1]->giveStackExp(exp[1]);
+	}
+
 	gs->curB->belligerents[0]->battle = gs->curB->belligerents[1]->battle = NULL;
 	gs->curB.dellNull();
 }