1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* better positioning of moat/mlip

* minor change
This commit is contained in:
mateuszb 2009-09-07 12:30:10 +00:00
parent 956a87f264
commit ea5a836a7e
7 changed files with 50 additions and 17 deletions

View File

@ -109,10 +109,13 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ),
* mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) );
std::pair<int, int> moatPos = CGI->heroh->wallPositions[siegeH->town->town->typeID][10],
mlipPos = CGI->heroh->wallPositions[siegeH->town->town->typeID][11];
if(moat) //eg. tower has no moat
blitAt(moat, 410, background->h - moat->h, background);
blitAt(moat, moatPos.first,moatPos.second, background);
if(mlip) //eg. tower has no mlip
blitAt(mlip, 410, background->h - mlip->h, background);
blitAt(mlip, mlipPos.first, mlipPos.second, background);
SDL_FreeSurface(moat);
SDL_FreeSurface(mlip);

View File

@ -998,9 +998,12 @@ void CPlayerInterface::battleObstaclesRemoved(const std::set<si32> & removedObst
void CPlayerInterface::battleCatapultAttacked(const CatapultAttack & ca)
{
SDL_FreeSurface(battleInt->siegeH->walls[ca.attackedPartOfWall + 2]);
battleInt->siegeH->walls[ca.attackedPartOfWall + 2] = BitmapHandler::loadBitmap(
battleInt->siegeH->getSiegeName(ca.attackedPartOfWall + 2, cb->battleGetWallState(ca.attackedPartOfWall)) );
for(std::set< std::pair<ui8, ui8> >::const_iterator it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it)
{
SDL_FreeSurface(battleInt->siegeH->walls[it->first + 2]);
battleInt->siegeH->walls[it->first + 2] = BitmapHandler::loadBitmap(
battleInt->siegeH->getSiegeName(it->first + 2, cb->battleGetWallState(it->first)) );
}
}
void CPlayerInterface::battleStacksRemoved(const BattleStacksRemoved & bsr)

View File

@ -1,4 +1,4 @@
//this file is a description of positions of wall parts' positions, following lines contain positions of: bottom tower, bottom wall, wall below gate, wall over gate, upper wall, upper tower, gate, gate arch, bottom static wall and upper static wall (x, y)
//this file is a description of positions of wall parts' positions, following lines contain positions of: bottom tower, bottom wall, wall below gate, wall over gate, upper wall, upper tower, gate, gate arch, bottom static wall and upper static wall, moat, mlip (x, y)
//Castle
601 500
528 350
@ -10,6 +10,8 @@
476 238
511 347
488 79
410 90
410 80
//Rampart
593 511
548 451
@ -21,6 +23,8 @@
459 220
509 364
491 103
410 77
410 97
//Tower
591 516
547 452
@ -32,6 +36,8 @@
470 187
516 365
513 79
410 90
410 80
//Inferno
594 514
560 451
@ -43,6 +49,8 @@
476 221
521 376
501 92
410 68
410 68
//Necropolis
591 512
535 445
@ -54,6 +62,8 @@
473 240
508 372
503 97
410 78
412 77
//Dungeon
599 495
558 448
@ -65,6 +75,8 @@
470 164
521 305
493 53
277 94
277 94
//Stronghold
585 508
552 440
@ -76,6 +88,8 @@
477 235
510 380
498 107
410 90
410 91
//Fortress
599 505
545 441
@ -87,6 +101,8 @@
482 236
521 382
507 130
369 95
363 70
//Conflux
607 505
508 346
@ -97,4 +113,6 @@
408 254
485 232
508 346
489 97
489 97
410 80
410 80

View File

@ -143,7 +143,7 @@ void CHeroHandler::loadWallPositions()
for(int g=0; g<ARRAY_COUNT(wallPositions); ++g)
{
inp >> dump;
for(int b=0; b<10; ++b)
for(int b=0; b<12; ++b)
{
std::pair<int, int> pt;
inp >> pt.first;

View File

@ -999,12 +999,15 @@ struct CatapultAttack : public CPackForClient //3015
DLL_EXPORT void applyGs(CGameState *gs);
void applyCl(CClient *cl);
ui8 attackedPartOfWall;//[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
ui8 damageDealt;
std::set< std::pair<ui8, ui8> > attackedParts; // <attackedPartOfWall, damageDealt>
//attackedPartOfWall; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate;
//damageDealt;
bool byCatapult; //if true, by catapult, if false - by something else (ie. spell)
template <typename Handler> void serialize(Handler &h, const int version)
{
h & attackedPartOfWall & damageDealt;
h & attackedParts & byCatapult;
}
};

View File

@ -1077,8 +1077,11 @@ DLL_EXPORT void CatapultAttack::applyGs( CGameState *gs )
{
if(gs->curB && gs->curB->siege != 0) //if there is a battle and it's a siege
{
gs->curB->si.wallState[attackedPartOfWall] =
std::min( gs->curB->si.wallState[attackedPartOfWall] + damageDealt, 3 );
for(std::set< std::pair<ui8, ui8> >::const_iterator it = attackedParts.begin(); it != attackedParts.end(); ++it)
{
gs->curB->si.wallState[it->first] =
std::min( gs->curB->si.wallState[it->first] + it->second, 3 );
}
}
}

View File

@ -2562,8 +2562,9 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
continue;
CatapultAttack ca; //package for clients
ca.attackedPartOfWall = attackedPart;
ca.damageDealt = 0;
std::pair<ui8, ui8> attack;
attack.first = attackedPart;
attack.second = 0;
int chanceForHit = 0;
int dmgChance[3] = {sbi.noDmg, sbi.oneDmg, sbi.twoDmg}; //dmgChance[i] - chance for doing i dmg when hit is successful
@ -2598,11 +2599,11 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
{
if(dmgRand <= dmgChance[v])
{
ca.damageDealt = v;
attack.second = v;
break;
}
}
if(ca.damageDealt > 0 && (attackedPart == 0 || attackedPart == 1 || attackedPart == 6))
if(attack.second > 0 && (attackedPart == 0 || attackedPart == 1 || attackedPart == 6))
{
int posRemove = -1;
switch(attackedPart)
@ -2631,6 +2632,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
sendAndApply(&bsr);
}
}
ca.byCatapult = true;
ca.attackedParts.insert(attack);
sendAndApply(&ca);
}