fixed a crash witnessed when ai was trying to get the efficiency return of aamover the ai had a target, but the ability did not have a target, when "destinationZone()" was run, the game would crash due to a null pointer.
increase the "random" chance to use unknown, the old method almost always returned 0.
This commit is contained in:
@@ -1035,7 +1035,7 @@ public:
|
|||||||
string destination;
|
string destination;
|
||||||
|
|
||||||
AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost = NULL);
|
AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost = NULL);
|
||||||
MTGGameZone * destinationZone();
|
MTGGameZone * destinationZone(Targetable * target = NULL);
|
||||||
int resolve();
|
int resolve();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
AAMover * clone() const;
|
AAMover * clone() const;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ public:
|
|||||||
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL);
|
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL);
|
||||||
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone * dest = NULL);
|
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone * dest = NULL);
|
||||||
|
|
||||||
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
|
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL,Targetable * target = NULL);
|
||||||
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL);
|
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL);
|
||||||
static int computeX(Spell * spell, MTGCardInstance * card);
|
static int computeX(Spell * spell, MTGCardInstance * card);
|
||||||
static int computeXX(Spell * spell, MTGCardInstance * card);
|
static int computeXX(Spell * spell, MTGCardInstance * card);
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ int AIAction::getEfficiency()
|
|||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
AbilityFactory af;
|
AbilityFactory af;
|
||||||
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY);
|
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY,NULL,target);
|
||||||
if ((suggestion == BAKA_EFFECT_BAD && p == target->controller())
|
if ((suggestion == BAKA_EFFECT_BAD && p == target->controller())
|
||||||
|| (suggestion == BAKA_EFFECT_GOOD && p != target->controller()))
|
|| (suggestion == BAKA_EFFECT_GOOD && p != target->controller()))
|
||||||
{
|
{
|
||||||
@@ -706,12 +706,13 @@ int AIAction::getEfficiency()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
efficiency = WRand() % 5; //Small percentage of chance for unknown abilities
|
//without a base to start with Wrand % 5 almost always returns 0.
|
||||||
|
efficiency = 10 + WRand() % 5; //Small percentage of chance for unknown abilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
efficiency = WRand() % 10;
|
efficiency = 10 + WRand() % 10;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1603,7 +1603,7 @@ AAMover::AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target,
|
|||||||
target = _target;
|
target = _target;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGGameZone * AAMover::destinationZone()
|
MTGGameZone * AAMover::destinationZone(Targetable * target)
|
||||||
{
|
{
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
return MTGGameZone::stringToZone(destination, source, _target);
|
return MTGGameZone::stringToZone(destination, source, _target);
|
||||||
@@ -1619,7 +1619,7 @@ int AAMover::resolve()
|
|||||||
{
|
{
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
MTGGameZone * fromZone = _target->getCurrentZone();
|
MTGGameZone * fromZone = _target->getCurrentZone();
|
||||||
MTGGameZone * destZone = destinationZone();
|
MTGGameZone * destZone = destinationZone(target);
|
||||||
|
|
||||||
//inplay is a special zone !
|
//inplay is a special zone !
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
|
|||||||
@@ -2907,7 +2907,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Tells the AI if the ability should target itself or an ennemy
|
//Tells the AI if the ability should target itself or an ennemy
|
||||||
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, TargetChooser * tc)
|
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, TargetChooser * tc,Targetable * target)
|
||||||
{
|
{
|
||||||
if (!a)
|
if (!a)
|
||||||
return BAKA_EFFECT_DONTKNOW;
|
return BAKA_EFFECT_DONTKNOW;
|
||||||
@@ -2967,7 +2967,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
|||||||
|
|
||||||
if (AAMover * aam = dynamic_cast<AAMover *>(a))
|
if (AAMover * aam = dynamic_cast<AAMover *>(a))
|
||||||
{
|
{
|
||||||
MTGGameZone * z = aam->destinationZone();
|
MTGGameZone * z = aam->destinationZone(target);
|
||||||
if (tc && tc->targetsZone(p->game->library))
|
if (tc && tc->targetsZone(p->game->library))
|
||||||
{
|
{
|
||||||
if (z == p->game->hand || z == p->game->inPlay)
|
if (z == p->game->hand || z == p->game->inPlay)
|
||||||
|
|||||||
Reference in New Issue
Block a user