mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Merge pull request #69 from ArseniyShestakov/artifactsImprovements
Thanks, looks great now.
This commit is contained in:
@@ -105,7 +105,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(down)
|
||||
{
|
||||
if(ourArt->artType->id < 7) //War Machine or Spellbook
|
||||
if(!ourArt->artType->isTradable()) //War Machine or Spellbook
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[21]); //This item can't be traded.
|
||||
}
|
||||
@@ -122,7 +122,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
// If clicked on spellbook, open it only if no artifact is held at the moment.
|
||||
if(ourArt && !down && previousState && !ourOwner->commonInfo->src.AOH)
|
||||
{
|
||||
if(ourArt->artType->id == 0)
|
||||
if(ourArt->artType->id == ArtifactID::SPELLBOOK)
|
||||
{
|
||||
auto spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt);
|
||||
GH.pushInt(spellWindow);
|
||||
@@ -131,7 +131,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
|
||||
if (!down && previousState)
|
||||
{
|
||||
if(ourArt && ourArt->artType->id == 0) //spellbook
|
||||
if(ourArt && ourArt->artType->id == ArtifactID::SPELLBOOK)
|
||||
return; //this is handled separately
|
||||
|
||||
if(!ourOwner->commonInfo->src.AOH) //nothing has been clicked
|
||||
@@ -139,7 +139,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
if(ourArt //to prevent selecting empty slots (bugfix to what GrayFace reported)
|
||||
&& ourOwner->curHero->tempOwner == LOCPLINT->playerID)//can't take art from another player
|
||||
{
|
||||
if(ourArt->artType->id == 3) //catapult cannot be highlighted
|
||||
if(ourArt->artType->id == ArtifactID::CATAPULT) //catapult cannot be highlighted
|
||||
{
|
||||
std::vector<CComponent *> catapult(1, new CComponent(CComponent::artifact, 3, 0));
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[312], catapult); //The Catapult must be equipped.
|
||||
@@ -380,7 +380,7 @@ void CArtPlace::setArtifact(const CArtifactInstance *art)
|
||||
else
|
||||
text = '{' + ourArt->artType->Name() + "}\n\n" + artDesc; //workaround for new artifacts with single name, turns it to H3-style
|
||||
|
||||
if(art->artType->id == 1) //spell scroll
|
||||
if(art->artType->id == ArtifactID::SPELL_SCROLL)
|
||||
{
|
||||
// we expect scroll description to be like this: This scroll contains the [spell name] spell which is added into your spell book for as long as you carry the scroll.
|
||||
// so we want to replace text in [...] with a spell name
|
||||
|
@@ -815,7 +815,7 @@ void CCastleBuildings::enterMagesGuild()
|
||||
CFunctionList<void()> onYes = [this]{ openMagesGuild(); };
|
||||
CFunctionList<void()> onNo = onYes;
|
||||
onYes += [hero]{ LOCPLINT->cb->buyArtifact(hero, ArtifactID::SPELLBOOK); };
|
||||
std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,0,0));
|
||||
std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,ArtifactID::SPELLBOOK,0));
|
||||
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[214], onYes, onNo, true, components);
|
||||
}
|
||||
|
@@ -1459,8 +1459,7 @@ void CAltarWindow::showAll(SDL_Surface * to)
|
||||
|
||||
bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance *art)
|
||||
{
|
||||
int artID = art->artType->id;
|
||||
if(artID != 1 && artID < 7) //special art
|
||||
if(!art->artType->isTradable()) //special art
|
||||
{
|
||||
logGlobal->warnStream() << "Cannot put special artifact on altar!";
|
||||
return false;
|
||||
@@ -1478,7 +1477,7 @@ bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance
|
||||
}
|
||||
|
||||
int dmp, val;
|
||||
market->getOffer(artID, 0, dmp, val, EMarketMode::ARTIFACT_EXP);
|
||||
market->getOffer(art->artType->id, 0, dmp, val, EMarketMode::ARTIFACT_EXP);
|
||||
|
||||
arts->artifactsOnAltar.insert(art);
|
||||
altarSlot->setArtInstance(art);
|
||||
|
@@ -64,6 +64,11 @@ bool CArtifact::isBig () const
|
||||
return VLC->arth->isBigArtifact(id);
|
||||
}
|
||||
|
||||
bool CArtifact::isTradable () const
|
||||
{
|
||||
return VLC->arth->isTradableArtifact(id);
|
||||
}
|
||||
|
||||
CArtifact::CArtifact()
|
||||
{
|
||||
setNodeType(ARTIFACT);
|
||||
@@ -78,7 +83,7 @@ CArtifact::~CArtifact()
|
||||
|
||||
int CArtifact::getArtClassSerial() const
|
||||
{
|
||||
if(id == 1)
|
||||
if(id == ArtifactID::SPELL_SCROLL)
|
||||
return 4;
|
||||
switch(aClass)
|
||||
{
|
||||
@@ -578,6 +583,22 @@ bool CArtHandler::legalArtifact(ArtifactID id)
|
||||
!(art->constituents); //no combo artifacts spawning
|
||||
}
|
||||
|
||||
bool CArtHandler::isTradableArtifact(ArtifactID id) const
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case ArtifactID::SPELLBOOK:
|
||||
case ArtifactID::GRAIL:
|
||||
case ArtifactID::CATAPULT:
|
||||
case ArtifactID::BALLISTA:
|
||||
case ArtifactID::AMMO_CART:
|
||||
case ArtifactID::FIRST_AID_TENT:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CArtHandler::initAllowedArtifactsList(const std::vector<bool> &allowed)
|
||||
{
|
||||
allowedArtifacts.clear();
|
||||
|
@@ -59,6 +59,7 @@ public:
|
||||
const std::string &EventText() const;
|
||||
|
||||
bool isBig () const;
|
||||
bool isTradable () const;
|
||||
|
||||
int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
|
||||
std::string nodeName() const override;
|
||||
@@ -215,6 +216,7 @@ public:
|
||||
//void getAllowedArts(std::vector<ConstTransitivePtr<CArtifact> > &out, std::vector<CArtifact*> *arts, int flag);
|
||||
//void getAllowed(std::vector<ConstTransitivePtr<CArtifact> > &out, int flags);
|
||||
bool isBigArtifact (ArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
|
||||
bool isTradableArtifact (ArtifactID id) const;
|
||||
void initAllowedArtifactsList(const std::vector<bool> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
|
||||
static ArtifactID creatureToMachineID(CreatureID id);
|
||||
static CreatureID machineIDToCreature(ArtifactID id);
|
||||
|
@@ -779,6 +779,7 @@ public:
|
||||
FIRST_AID_TENT = 6,
|
||||
//CENTAUR_AXE = 7,
|
||||
//BLACKSHARD_OF_THE_DEAD_KNIGHT = 8,
|
||||
TITANS_THUNDER = 135,
|
||||
//CORNUCOPIA = 140,
|
||||
ART_SELECTION = 144,
|
||||
ART_LOCK = 145,
|
||||
|
@@ -909,7 +909,7 @@ DLL_LINKAGE void MoveArtifact::applyGs( CGameState *gs )
|
||||
a->move(src, dst);
|
||||
|
||||
//TODO what'll happen if Titan's thunder is equipped by pickin git up or the start of game?
|
||||
if (a->artType->id == 135 && dst.slot == ArtifactPosition::RIGHT_HAND) //Titan's Thunder creates new spellbook on equip
|
||||
if (a->artType->id == ArtifactID::TITANS_THUNDER && dst.slot == ArtifactPosition::RIGHT_HAND) //Titan's Thunder creates new spellbook on equip
|
||||
{
|
||||
auto hPtr = boost::get<ConstTransitivePtr<CGHeroInstance> >(&dst.artHolder);
|
||||
if(hPtr)
|
||||
|
@@ -1229,7 +1229,7 @@ void CMapLoaderH3M::readObjects()
|
||||
if(objTempl.id == Obj::SPELL_SCROLL)
|
||||
{
|
||||
spellID = reader.readUInt32();
|
||||
artID = 1;
|
||||
artID = ArtifactID::SPELL_SCROLL;
|
||||
}
|
||||
else if(objTempl.id == Obj::ARTIFACT)
|
||||
{
|
||||
|
@@ -522,7 +522,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
MoveArtifact ma;
|
||||
ma.src = ArtifactLocation (finishingBattle->loserHero, artSlot.first);
|
||||
const CArtifactInstance * art = ma.src.getArt();
|
||||
if (art && !art->artType->isBig() && art->artType->id != 0) // don't move war machines or locked arts (spellbook)
|
||||
if (art && !art->artType->isBig() && art->artType->id != ArtifactID::SPELLBOOK) // don't move war machines or locked arts (spellbook)
|
||||
{
|
||||
arts.push_back (art->artType->id);
|
||||
ma.dst = ArtifactLocation (finishingBattle->winnerHero, art->firstAvailableSlot(finishingBattle->winnerHero));
|
||||
@@ -2971,7 +2971,7 @@ bool CGameHandler::sellArtifact( const IMarket *m, const CGHeroInstance *h, Arti
|
||||
const CArtifactInstance *art = h->getArtByInstanceId(aid);
|
||||
if(!art)
|
||||
COMPLAIN_RET("There is no artifact to sell!");
|
||||
if(art->artType->id < 7)
|
||||
if(!art->artType->isTradable())
|
||||
COMPLAIN_RET("Cannot sell a war machine or spellbook!");
|
||||
|
||||
int resVal = 0, dump = 1;
|
||||
|
Reference in New Issue
Block a user