1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

* fixed start move animation

* added receiving exp (and leveling-up) after a won battle
This commit is contained in:
Michał W. Urbańczyk
2008-09-29 10:16:02 +00:00
parent 65ae3c3821
commit 917be0693d
4 changed files with 28 additions and 4 deletions

View File

@@ -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;
}