From d2a96e69df593e6bf3edffd30eb030a948ffac9d Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Fri, 17 Dec 2010 20:59:08 +0000 Subject: [PATCH] few small items, first since card view are now correctly null'ed, i ran into a few cases while watching demo mode where the game would trigger a stop on the battle hint that uses card views, apon checking the card view would be null at the time. so added a condiational check to prevent the game from trying to alter a null'ed pointer. 2nd, added a block out for optimizedhand in demo mode, ie any time its cpu player vs cpu player, noticed demo was starting matches with no cards. 3rd, added a hackish workaround to allow Ai to get eff returns on abilities using the all(this) lord workaround to target the source. Ai was not getting any returns on these abilities. now basically if the ability is a lord && !target...lets calculate this as tho source == target.... --- projects/mtg/include/AllAbilities.h | 12 +++++---- projects/mtg/src/AIPlayer.cpp | 38 ++++++++++++++++++++++++---- projects/mtg/src/MTGCardInstance.cpp | 7 +++-- projects/mtg/src/Rules.cpp | 2 +- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 55577a209..a259bb69d 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2188,11 +2188,13 @@ public: ALord(int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) : ListMaintainerAbility(_id, card), NestedAbility(a) - { - tc = _tc; - tc->targetter = NULL; - includeSelf = _includeSelf; - } + { + tc = _tc; + tc->targetter = NULL; + includeSelf = _includeSelf; + if(ability->aType == MTGAbility::STANDARD_PREVENT) + aType = MTGAbility::STANDARD_PREVENT; + } int canBeInList(Player *p) { diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 95f4b200f..fbe2bcb9c 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -272,8 +272,18 @@ int AIAction::getEfficiency() case MTGAbility::STANDARD_PREVENT: { efficiency = 0;//starts out low to avoid spamming it when its not needed. - if (!target) + if (!target && !dynamic_cast (a)) break; + if(dynamic_cast (a) && !target) + { + //this is a specail case for all(this) targetting workaround. + //adding a direct method for targetting the source is planned for + //the coming releases, all(this) workaround prevents eff from being returned + //as its not targetted the same as abilities + //for now this dirty hack will calculate eff on lords as tho the source is + //the target...otherwise these abilities will never be used. + target = a->source; + } bool NeedPreventing; NeedPreventing = false; @@ -376,8 +386,13 @@ int AIAction::getEfficiency() { MTGCardInstance * _target = (MTGCardInstance *) (a->target); efficiency = 0; - if (!target) + if (!target && !dynamic_cast (a)) break; + if(dynamic_cast (a) && !target) + { + target = a->source; + } + AbilityFactory af; int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY); //i do not set a starting eff. on this ability, this allows Ai to sometimes randomly do it as it normally does. @@ -475,8 +490,13 @@ int AIAction::getEfficiency() { efficiency = 0; MTGCardInstance * _target = (MTGCardInstance *) (a->target); - if (!target) + if (!target && !dynamic_cast (a)) break; + if(dynamic_cast (a) && !target) + { + target = a->source; + } + //ensuring that Ai grants abilities to creatures during first main, so it can actually use them in combat. //quick note: the eff is multiplied by creatures ranking then divided by the number of cards in hand. //the reason i do this is to encourage more casting and less waste of mana on abilities. @@ -520,8 +540,12 @@ int AIAction::getEfficiency() //untap things that Ai owns and are tapped. { efficiency = 0; - if (!target) + if (!target && !dynamic_cast (a)) break; + if(dynamic_cast (a) && !target) + { + target = a->source; + } if (target->isTapped() && target->controller()->isAI()) { @@ -533,8 +557,12 @@ int AIAction::getEfficiency() case MTGAbility::TAPPER: //tap things the player owns and that are untapped. { - if (!target) + if (!target && !dynamic_cast (a)) break; + if(dynamic_cast (a) && !target) + { + target = a->source; + } if (!target->controller()->isAI()) efficiency = (20 * target->DangerRanking()); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 08b499754..6f3deae2c 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -808,8 +808,11 @@ int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent) didblocked = 1; if (opponent && opponent->controller()->isAI()) { - opponent->view->actZ += .8f; - opponent->view->actT -= .2f; + if(opponent->view != NULL) + { + opponent->view->actZ += .8f; + opponent->view->actT -= .2f; + } } if (!opponent) didblocked = 0; diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index 7d2f3668f..0b084d3d0 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -185,7 +185,7 @@ void Rules::addExtraRules() MTGAbility * a = af.parseMagicLine(initState.playerData[i].extraRules[j], id++, NULL, &MTGCardInstance::ExtraRules[i]); if (p->playMode != Player::MODE_TEST_SUITE && g->mRules->gamemode != GAME_TYPE_MOMIR && g->mRules->gamemode != GAME_TYPE_RANDOM1 && g->mRules->gamemode != GAME_TYPE_RANDOM2 && g->mRules->gamemode - != GAME_TYPE_STORY)//keep this out of mimor and other game modes. + != GAME_TYPE_STORY && (!g->players[0] == PLAYER_TYPE_CPU && !g->players[1] == PLAYER_TYPE_CPU))//keep this out of mimor and other game modes. { difficultyRating = DeckManager::getDifficultyRating(g->players[0], g->players[1]); }