소스 검색

* fixed start move animation
* added receiving exp (and leveling-up) after a won battle

Michał W. Urbańczyk 17 년 전
부모
커밋
917be0693d
4개의 변경된 파일28개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 4
      CBattleInterface.cpp
  2. 1 0
      CBattleInterface.h
  3. 7 0
      CPlayerInterface.cpp
  4. 17 0
      server/CGameHandler.cpp

+ 3 - 4
CBattleInterface.cpp

@@ -722,12 +722,10 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
 	int hexWbase = 44, hexHbase = 42;
 	bool twoTiles = LOCPLINT->cb->battleGetCreature(number).isDoubleWide();
 
-	if(startMoving && creAnims[number]->framesInGroup(20)!=0) //animation of starting move; some units don't have this animation (ie. halberdier)
+	if(startMoving) //animation of starting move; some units don't have this animation (ie. halberdier)
 	{
 		deactivate();
 		CGI->curh->hide();
-		creAnims[number]->setType(20);
-		//LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
 		for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i)
 		{
 			show();
@@ -1175,7 +1173,7 @@ void CBattleInterface::battleFinished(const BattleResult& br)
 {
 	deactivate();
 	CGI->curh->changeGraphic(0,0);
-
+	
 	SDL_Rect temp_rect = genRect(561, 470, 165, 19);
 	resWindow = new CBattleReslutWindow(br, temp_rect, this);
 	resWindow->activate();
@@ -1910,6 +1908,7 @@ CBattleReslutWindow::~CBattleReslutWindow()
 
 void CBattleReslutWindow::activate()
 {
+	LOCPLINT->showingDialog->set(true);
 	exit->activate();
 }
 

+ 1 - 0
CBattleInterface.h

@@ -217,4 +217,5 @@ public:
 
 	friend class CBattleHex;
 	friend class CBattleReslutWindow;
+	friend class CPlayerInterface;
 };

+ 7 - 0
CPlayerInterface.cpp

@@ -2019,6 +2019,12 @@ void CPlayerInterface::battleNewRound(int round) //called at the beggining of ea
 void CPlayerInterface::actionStarted(const BattleAction* action)
 {
 	curAction = action;
+	if((action->actionType==2 || (action->actionType==6 && action->destinationTile!=cb->battleGetPos(action->stackNumber)))
+		&& static_cast<CBattleInterface*>(curint)->creAnims[action->stackNumber]->framesInGroup(20)
+		)
+	{
+		static_cast<CBattleInterface*>(curint)->creAnims[action->stackNumber]->setType(20);
+	}
 }
 
 void CPlayerInterface::actionFinished(const BattleAction* action)
@@ -2061,6 +2067,7 @@ void CPlayerInterface::battleResultQuited()
 	delete curint;
 	curint = adventureInt;
 	adventureInt->activate();
+	LOCPLINT->showingDialog->setn(false);
 }
 
 void CPlayerInterface::battleStackMoved(int ID, int dest)

+ 17 - 0
server/CGameHandler.cpp

@@ -56,6 +56,15 @@ double distance(int3 a, int3 b)
 {
 	return std::sqrt( (double)(a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
 }
+void giveExp(BattleResult &r)
+{
+	r.exp[0] = 0;
+	r.exp[1] = 0;
+	for(std::set<std::pair<ui32,si32> >::iterator i = r.casualties[!r.winner].begin(); i!=r.casualties[!r.winner].end(); i++)
+	{
+		r.exp[r.winner] += VLC->creh->creatures[i->first].hitPoints * i->second;
+	}
+}
 //bool CGameState::checkFunc(int obid, std::string name)
 //{
 //	if (objscr.find(obid)!=objscr.end())
@@ -314,6 +323,7 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile
 	sendAndApply(&sg);
 
 	//end battle, remove all info, free memory
+	giveExp(*battleResult.data);
 	sendAndApply(battleResult.data);
 	if(cb)
 		cb(battleResult.data);
@@ -330,6 +340,12 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile
 		sendAndApply(&ro);
 	}
 
+	//give exp
+	if(battleResult.data->exp[0] && hero1)
+		changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
+	if(battleResult.data->exp[1] && hero2)
+		changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
+
 	delete battleResult.data;
 
 }
@@ -916,6 +932,7 @@ upgend:
 							br->result = 1;
 							br->winner = !ba.side; //fleeing side loses
 							gs->curB->calculateCasualties(br->casualties);
+							giveExp(*br);
 							battleResult.set(br);
 							break;
 						}