void CastleRedrawBuilding(const Castle & castle, const Point & dst_pt, u32 build, u32 frame, int alpha) { const Rect max = CastleGetMaxArea(castle, dst_pt); // correct build switch(build) { case DWELLING_MONSTER2: case DWELLING_MONSTER3: case DWELLING_MONSTER4: case DWELLING_MONSTER5: case DWELLING_MONSTER6: build = castle.GetActualDwelling(build); break; default: break; } const int icn = Castle::GetICNBuilding(build, castle.GetRace()); u32 index = 0; // correct index (mage guild) switch(build) { case BUILD_MAGEGUILD1: index = 0; break; case BUILD_MAGEGUILD2: index = Race::NECR == castle.GetRace() ? 6 : 1; break; case BUILD_MAGEGUILD3: index = Race::NECR == castle.GetRace() ? 12 : 2; break; case BUILD_MAGEGUILD4: index = Race::NECR == castle.GetRace() ? 18 : 3; break; case BUILD_MAGEGUILD5: index = Race::NECR == castle.GetRace() ? 24 : 4; break; default: break; } if(icn != ICN::UNKNOWN) { // simple first sprite Sprite sprite1 = AGG::GetICN(icn, index); if(alpha) { sprite1.SetSurface(sprite1.GetSurface()); sprite1.SetAlphaMod(alpha); sprite1.Blit(dst_pt.x + sprite1.x(), dst_pt.y + sprite1.y()); } else CastleDialog::RedrawBuildingSpriteToArea(sprite1, dst_pt.x + sprite1.x(), dst_pt.y + sprite1.y(), max); // second anime sprite if(const u32 index2 = ICN::AnimationFrame(icn, index, frame)) { Sprite sprite2 = AGG::GetICN(icn, index2); if(alpha) { sprite2.SetSurface(sprite2.GetSurface()); sprite2.SetAlphaMod(alpha); sprite2.Blit(dst_pt.x + sprite2.x(), dst_pt.y + sprite2.y()); } else CastleDialog::RedrawBuildingSpriteToArea(sprite2, dst_pt.x + sprite2.x(), dst_pt.y + sprite2.y(), max); } } }
u16 HowManyRecruitMonster(const Castle & castle, u32 dw, const Funds & add, Funds & res) { const Monster ms(castle.GetRace(), castle.GetActualDwelling(dw)); const Kingdom & kingdom = world.GetKingdom(castle.GetColor()); if(! castle.GetArmy().CanJoinTroop(ms)) return 0; u16 count = castle.GetDwellingLivedCount(dw); payment_t payment; while(count) { payment = ms.GetCost() * count; res = payment; payment += add; if(kingdom.AllowPayment(payment)) break; --count; } return count; }
DwellingItem::DwellingItem(Castle & castle, u32 dw) { type = castle.GetActualDwelling(dw); mons = Monster(castle.GetRace(), type); }