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:
parent
7d7abbb68d
commit
b53c01ab92
@ -245,9 +245,9 @@ void CCallback::selectionMade(int selection, int asker)
|
|||||||
void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount)
|
void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount)
|
||||||
{
|
{
|
||||||
if(amount<=0) return;
|
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));
|
CGTownInstance *t = const_cast<CGTownInstance*>(static_cast<const CGTownInstance*>(obj));
|
||||||
|
|
||||||
//verify
|
//verify
|
||||||
@ -255,10 +255,10 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount
|
|||||||
typedef std::pair<const int,int> Parka;
|
typedef std::pair<const int,int> Parka;
|
||||||
for(std::map<int,int>::iterator av=t->strInfo.creatures.begin();av!=t->strInfo.creatures.end();av++)
|
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]) )
|
if( ( found = (ID == t->town->basicCreatures[av->first]) ) //creature is available among basic cretures
|
||||||
|| (found = (ID == t->town->upgradedCreatures[av->first])) )
|
|| (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;
|
ser = av->first;
|
||||||
break;
|
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))
|
if(amount > CGI->creh->creatures[ID].maxAmount(gs->players[player].resources))
|
||||||
return; //not enough resources
|
return; //not enough resources
|
||||||
|
|
||||||
for(int i=0;i<RESOURCE_QUANTITY;i++)
|
//for(int i=0;i<RESOURCE_QUANTITY;i++)
|
||||||
if (gs->players[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount))
|
// if (gs->players[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount))
|
||||||
return; //not enough resources
|
// return; //not enough resources
|
||||||
|
|
||||||
if(amount<=0) return;
|
if(amount<=0) return;
|
||||||
|
|
||||||
//recruit
|
//recruit
|
||||||
int slot = -1;
|
int slot = -1; //slot ID
|
||||||
std::pair<int,std::pair<CCreature*,int> > parb;
|
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
|
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);
|
CGI->playerint[gs->players[player].serial]->garrisonChanged(obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//TODO: recruit from dwellings on the adventure map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
|
bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
|
||||||
{
|
{
|
||||||
if(obj->tempOwner != player)
|
if((player>=0) && obj->tempOwner != player)
|
||||||
return false;
|
return false;
|
||||||
CArmedInstance *ob = const_cast<CArmedInstance*>(obj);
|
CArmedInstance *ob = const_cast<CArmedInstance*>(obj);
|
||||||
ob->army.slots.erase(stackPos);
|
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)
|
bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, int newID)
|
||||||
{
|
{
|
||||||
|
//TODO: write
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UpgradeInfo CCallback::getUpgradeInfo(const CArmedInstance *obj, int stackPos)
|
UpgradeInfo CCallback::getUpgradeInfo(const CArmedInstance *obj, int stackPos)
|
||||||
|
@ -14,9 +14,19 @@
|
|||||||
#include "CCallback.h"
|
#include "CCallback.h"
|
||||||
extern TTF_Font * GEOR16;
|
extern TTF_Font * GEOR16;
|
||||||
CBuildingRect::CBuildingRect(Structure *Str)
|
CBuildingRect::CBuildingRect(Structure *Str)
|
||||||
:str(Str), moi(false)
|
:str(Str), moi(false), offset(0)
|
||||||
{
|
{
|
||||||
def = CGI->spriteh->giveDef(Str->defName);
|
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.x = str->pos.x;
|
||||||
pos.y = str->pos.y;
|
pos.y = str->pos.y;
|
||||||
pos.w = def->ourImages[0].bitmap->w;
|
pos.w = def->ourImages[0].bitmap->w;
|
||||||
@ -458,16 +468,16 @@ void CCastleInterface::show(SDL_Surface * to)
|
|||||||
//blit buildings
|
//blit buildings
|
||||||
for(int i=0;i<buildings.size();i++)
|
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[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
|
else
|
||||||
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);
|
||||||
//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) //if this this higlighted structure and has border we'll blit it
|
||||||
if(hBuild==buildings[i] && hBuild->border)
|
|
||||||
blitAt(hBuild->border,hBuild->pos,to);
|
blitAt(hBuild->border,hBuild->pos,to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +582,30 @@ void CCastleInterface::recreateBuildings()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::sort(buildings.begin(),buildings.end(),srthlp);
|
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)
|
void CCastleInterface::recruit(int ID, int amount)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ class CBuildingRect : public Hoverable, public MotionInterested, public Clickabl
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool moi; //motion interested is active
|
bool moi; //motion interested is active
|
||||||
|
int offset, max; //first and last animation frame
|
||||||
Structure* str;
|
Structure* str;
|
||||||
CDefHandler* def;
|
CDefHandler* def;
|
||||||
SDL_Surface* border;
|
SDL_Surface* border;
|
||||||
|
@ -285,6 +285,8 @@ int CGTownInstance::creatureGrowth(int level) const
|
|||||||
case 2:
|
case 2:
|
||||||
ret*=(1.5); break;
|
ret*=(1.5); break;
|
||||||
}
|
}
|
||||||
|
if(builtBuildings.find(26)!=builtBuildings.end()) //grail
|
||||||
|
ret+=CGI->creh->creatures[town->basicCreatures[level]].growth;
|
||||||
if(getHordeLevel(0)==level)
|
if(getHordeLevel(0)==level)
|
||||||
if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
|
if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
|
||||||
ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
|
ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
|
||||||
|
Loading…
Reference in New Issue
Block a user