Skip to content

Commit

Permalink
Support BGE Devotion
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed May 5, 2018
1 parent c2d6f8b commit 0f785db
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 50 deletions.
2 changes: 1 addition & 1 deletion SimpleTUOptimizeStarter.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FileDelete, %file%

MaxCardsSections := 100

BGEffects := "none|Unity|Iron-Will|Cold-Sleep|Blood-Vengeance|Oath-of-Loyalty|Furiosity|TemporalBacklash|CriticalReach|Devour|HaltedOrders|ZealotsPreservation|Virulence|Enfeeble all X|Enhance all S X|Evolve n S1 S2|Heal all X|Mortar X|Protect all X|Rally all X|Siege all X|Strike all X|Weaken all X|Brigade|Bloodlust X|Counterflux|Divert|EnduringRage|Fortification|Heroism|Metamorphosis|Megamorphosis|Revenge X|TurningTides"
BGEffects := "none|Devotion|Unity|Iron-Will|Cold-Sleep|Blood-Vengeance|Oath-of-Loyalty|Furiosity|TemporalBacklash|CriticalReach|Devour|HaltedOrders|ZealotsPreservation|Virulence|Enfeeble all X|Enhance all S X|Evolve n S1 S2|Heal all X|Mortar X|Protect all X|Rally all X|Siege all X|Strike all X|Weaken all X|Brigade|Bloodlust X|Counterflux|Divert|EnduringRage|Fortification|Heroism|Metamorphosis|Megamorphosis|Revenge X|TurningTides"
IniFileName := "data\SimpleTUOptimizeStarter.ini"
IniSection := "onLoad"

Expand Down
Binary file modified SimpleTUOptimizeStarter.exe
Binary file not shown.
103 changes: 56 additions & 47 deletions sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,70 +704,70 @@ struct PlayCard
{
setStorage<type>();
placeCard<type>();
status->m_summoned = summoned;
status->m_summoned = summoned;

unsigned played_faction_mask(0);
unsigned same_faction_cards_count(0);
bool bge_megamorphosis = fd->bg_effects[fd->tapi][PassiveBGE::megamorphosis];
//played_status = status;
//played_card = card;

check_and_perform_bravery(fd,status);
bool bge_megamorphosis = fd->bg_effects[fd->tapi][PassiveBGE::megamorphosis];
//played_status = status;
//played_card = card;
check_and_perform_bravery(fd,status);
if (status->m_delay == 0)
{
check_and_perform_valor(fd, status);
}

//refresh/init absorb
if(status->has_skill(Skill::absorb))
{
status->m_absorption = status->skill_base_value(Skill::absorb);
}


// 1. Evaluate skill Allegiance & count assaults with same faction (structures will be counted later)
// 2. Passive BGE Cold Sleep
for (CardStatus* status_i : fd->tap->assaults.m_indirect)
{
if (status_i == status || !is_alive(status_i)) { continue; } // except itself
//std::cout << status_description(status_i).c_str();
_DEBUG_ASSERT(is_alive(status_i));
if (bge_megamorphosis || (status_i->m_card->m_faction == card->m_faction))
//refresh/init absorb
if(status->has_skill(Skill::absorb))
{
++ same_faction_cards_count;
unsigned allegiance_value = status_i->skill(Skill::allegiance);
if (__builtin_expect(allegiance_value, false) && !status->m_summoned)
{
_DEBUG_MSG(1, "%s activates Allegiance %u\n", status_description(status_i).c_str(), allegiance_value);
if (! status_i->m_sundered)
{ status_i->m_perm_attack_buff += allegiance_value; }
status_i->ext_hp(allegiance_value);
}
status->m_absorption = status->skill_base_value(Skill::absorb);
}
if (__builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::coldsleep], false)
&& status_i->m_protected_stasis && can_be_healed(status_i))


// 1. Evaluate skill Allegiance & count assaults with same faction (structures will be counted later)
// 2. Passive BGE Cold Sleep
for (CardStatus* status_i : fd->tap->assaults.m_indirect)
{
unsigned bge_value = (status_i->m_protected_stasis + 1) / 2;
_DEBUG_MSG(1, "Cold Sleep: %s heals itself for %u\n", status_description(status_i).c_str(), bge_value);
status_i->add_hp(bge_value);
if (status_i == status || !is_alive(status_i)) { continue; } // except itself
//std::cout << status_description(status_i).c_str();
_DEBUG_ASSERT(is_alive(status_i));
if (bge_megamorphosis || (status_i->m_card->m_faction == card->m_faction))
{
++ same_faction_cards_count;
unsigned allegiance_value = status_i->skill(Skill::allegiance);
if (__builtin_expect(allegiance_value, false) && !status->m_summoned)
{
_DEBUG_MSG(1, "%s activates Allegiance %u\n", status_description(status_i).c_str(), allegiance_value);
if (! status_i->m_sundered)
{ status_i->m_perm_attack_buff += allegiance_value; }
status_i->ext_hp(allegiance_value);
}
}
if (__builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::coldsleep], false)
&& status_i->m_protected_stasis && can_be_healed(status_i))
{
unsigned bge_value = (status_i->m_protected_stasis + 1) / 2;
_DEBUG_MSG(1, "Cold Sleep: %s heals itself for %u\n", status_description(status_i).c_str(), bge_value);
status_i->add_hp(bge_value);
}
}
}

// Setup faction marks (bitmap) for stasis (skill Stasis / Passive BGE TemporalBacklash)
// unless Passive BGE Megamorphosis is enabled
if (__builtin_expect(!bge_megamorphosis, true))
{
played_faction_mask = (1u << card->m_faction);
// do played card have stasis? mark this faction for stasis check
if (__builtin_expect(status->skill(Skill::stasis), false)
|| __builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::temporalbacklash] && status->skill(Skill::counter), false))
// Setup faction marks (bitmap) for stasis (skill Stasis / Passive BGE TemporalBacklash)
// unless Passive BGE Megamorphosis is enabled
if (__builtin_expect(!bge_megamorphosis, true))
{
fd->tap->stasis_faction_bitmap |= played_faction_mask;
played_faction_mask = (1u << card->m_faction);
// do played card have stasis? mark this faction for stasis check
if (__builtin_expect(status->skill(Skill::stasis), false)
|| __builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::temporalbacklash] && status->skill(Skill::counter), false))
{
fd->tap->stasis_faction_bitmap |= played_faction_mask;
}
}
}

// Evaluate Passive BGE Oath-of-Loyalty
unsigned allegiance_value;
unsigned allegiance_value;
if (__builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::oath_of_loyalty], false)
&& ((allegiance_value = status->skill(Skill::allegiance)) > 0))
{
Expand Down Expand Up @@ -865,6 +865,15 @@ struct PlayCard
}

}
//Devotion BGE
if (__builtin_expect(fd->bg_effects[fd->tapi][PassiveBGE::devotion], false) && !summoned && card->m_category == CardCategory::normal && fd->tap->commander.m_card->m_faction == card->m_faction)
{
_DEBUG_MSG(1, "Devotion %s: Gains %u HP\n",
status_description(status).c_str(), (card->m_health+4)/5);
status->ext_hp((card->m_health+4)/5); //20% bonus health (rounded up)
}


// resolve On-Play skills
for (const auto& ss: card->m_skills_on_play)
{
Expand Down
2 changes: 1 addition & 1 deletion tyrant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const std::string passive_bge_names[PassiveBGE::num_passive_bges] =
"Bloodlust", "Brigade", "Counterflux", "Divert", "EnduringRage", "Fortification", "Heroism",
"ZealotsPreservation", "Metamorphosis", "Megamorphosis", "Revenge", "TurningTides", "Virulence",
"HaltedOrders", "Devour", "CriticalReach", "TemporalBacklash", "Furiosity", "OathOfLoyalty",
"BloodVengeance", "ColdSleep", "IronWill", "Unity",
"BloodVengeance", "ColdSleep", "IronWill", "Unity", "Devotion",
};

const std::string cardtype_names[CardType::num_cardtypes]{"Commander", "Assault", "Structure", };
Expand Down
2 changes: 1 addition & 1 deletion tyrant.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ enum PassiveBGE
bloodlust, brigade, counterflux, divert, enduringrage, fortification, heroism,
zealotspreservation, metamorphosis, megamorphosis, revenge, turningtides, virulence,
haltedorders, devour, criticalreach, temporalbacklash, furiosity, oath_of_loyalty,
bloodvengeance, coldsleep,ironwill,unity,
bloodvengeance, coldsleep,ironwill,unity,devotion,

// End of BGEs
num_passive_bges
Expand Down
1 change: 1 addition & 0 deletions tyrant_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ void print_available_effects()
" Cold-Sleep\n"
" Iron-Will\n"
" Unity\n"
" Devotion\n"
;
}
void usage(int argc, char** argv)
Expand Down

0 comments on commit 0f785db

Please sign in to comment.