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

* fixed estate problems (#57)

* fixed blinking mana vortex (#52)
* grail increases creature growths
This commit is contained in:
Michał W. Urbańczyk 2008-06-01 13:42:29 +00:00
parent 7d7abbb68d
commit b53c01ab92
4 changed files with 57 additions and 18 deletions

View File

@ -245,9 +245,9 @@ void CCallback::selectionMade(int selection, int asker)
void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount)
{
if(amount<=0) return;
if(obj->ID==98)
if(obj->ID==98) //recruiting from town
{
int ser=-1;
int ser=-1; //used dwelling level
CGTownInstance *t = const_cast<CGTownInstance*>(static_cast<const CGTownInstance*>(obj));
//verify
@ -255,10 +255,10 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount
typedef std::pair<const int,int> Parka;
for(std::map<int,int>::iterator av=t->strInfo.creatures.begin();av!=t->strInfo.creatures.end();av++)
{
if( ( found = (ID == t->town->basicCreatures[av->first]) )
|| (found = (ID == t->town->upgradedCreatures[av->first])) )
if( ( found = (ID == t->town->basicCreatures[av->first]) ) //creature is available among basic cretures
|| (found = (ID == t->town->upgradedCreatures[av->first])) )//creature is available among upgraded cretures
{
amount = std::min(amount,av->second);
amount = std::min(amount,av->second); //reduce recruited amount up to available amount
ser = av->first;
break;
}
@ -269,17 +269,17 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount
if(amount > CGI->creh->creatures[ID].maxAmount(gs->players[player].resources))
return; //not enough resources
for(int i=0;i<RESOURCE_QUANTITY;i++)
if (gs->players[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount))
return; //not enough resources
//for(int i=0;i<RESOURCE_QUANTITY;i++)
// if (gs->players[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount))
// return; //not enough resources
if(amount<=0) return;
//recruit
int slot = -1;
int slot = -1; //slot ID
std::pair<int,std::pair<CCreature*,int> > parb;
for(int i=0;i<7;i++)
for(int i=0;i<7;i++) //TODO: if there is already stack of same creatures it should be used always
{
if((!t->army.slots[i].first) || (t->army.slots[i].first->idNumber == ID)) //slot is free or there is saem creature
{
@ -307,12 +307,13 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount
CGI->playerint[gs->players[player].serial]->garrisonChanged(obj);
}
//TODO: recruit from dwellings on the adventure map
}
bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
{
if(obj->tempOwner != player)
if((player>=0) && obj->tempOwner != player)
return false;
CArmedInstance *ob = const_cast<CArmedInstance*>(obj);
ob->army.slots.erase(stackPos);
@ -321,6 +322,7 @@ bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
}
bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, int newID)
{
//TODO: write
return false;
}
UpgradeInfo CCallback::getUpgradeInfo(const CArmedInstance *obj, int stackPos)

View File

@ -14,9 +14,19 @@
#include "CCallback.h"
extern TTF_Font * GEOR16;
CBuildingRect::CBuildingRect(Structure *Str)
:str(Str), moi(false)
:str(Str), moi(false), offset(0)
{
def = CGI->spriteh->giveDef(Str->defName);
max = def->ourImages.size();
if(str->ID == 33 && str->townID == 4) //little 'hack' for estate in necropolis - background color is not always the first color in the palette
{
for(std::vector<Cimage>::iterator i=def->ourImages.begin();i!=def->ourImages.end();i++)
{
SDL_SetColorKey(i->bitmap,SDL_SRCCOLORKEY,*((char*)i->bitmap->pixels));
}
}
pos.x = str->pos.x;
pos.y = str->pos.y;
pos.w = def->ourImages[0].bitmap->w;
@ -458,16 +468,16 @@ void CCastleInterface::show(SDL_Surface * to)
//blit buildings
for(int i=0;i<buildings.size();i++)
{
if((animval)%(buildings[i]->def->ourImages.size()))
int frame = (animval)%(buildings[i]->max - buildings[i]->offset);
if(frame)
{
blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
}
else
blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
//if(buildings[i]->hovered && buildings[i]->border)
// blitAt(buildings[i]->border,buildings[i]->pos.x,buildings[i]->pos.y);
if(hBuild==buildings[i] && hBuild->border)
blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
if(hBuild==buildings[i] && hBuild->border) //if this this higlighted structure and has border we'll blit it
blitAt(hBuild->border,hBuild->pos,to);
}
@ -572,6 +582,30 @@ void CCastleInterface::recreateBuildings()
break;
}
std::sort(buildings.begin(),buildings.end(),srthlp);
//code for Mana Vortex (there are two sets of animation frames - one without mage guild and one with
if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end()))
{
CBuildingRect *vortex = NULL;
for(int i=0;i<buildings.size();i++)
{
if(buildings[i]->str->ID==21)
{
vortex=buildings[i];
break;
}
}
if(town->builtBuildings.find(4)!=town->builtBuildings.end()) //there is mage Guild level 5
{
vortex->offset = 10;
vortex->max = vortex->def->ourImages.size();
}
else
{
vortex->offset = 0;
vortex->max = 10;
}
}
}
void CCastleInterface::recruit(int ID, int amount)
{

View File

@ -12,6 +12,7 @@ class CBuildingRect : public Hoverable, public MotionInterested, public Clickabl
{
public:
bool moi; //motion interested is active
int offset, max; //first and last animation frame
Structure* str;
CDefHandler* def;
SDL_Surface* border;

View File

@ -285,6 +285,8 @@ int CGTownInstance::creatureGrowth(int level) const
case 2:
ret*=(1.5); break;
}
if(builtBuildings.find(26)!=builtBuildings.end()) //grail
ret+=CGI->creh->creatures[town->basicCreatures[level]].growth;
if(getHordeLevel(0)==level)
if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;