AlumKal

【FE】24炮

Dec 31st, 2023
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.03 KB | None | 0 0
  1. #include "avz.h"
  2. #include "avz_dsl/shorthand.h"
  3. #include "mod/mod.h"
  4. #include "SetZombiesPlus/main.h"
  5.  
  6. using namespace std;
  7.  
  8. // PropFilter(&AZombie::Hp, greater(), 3000)
  9. template <typename T>
  10. AAliveFilter<T> PropFilter(auto (T::* prop)(), const auto& op, auto value) {
  11.     return AAliveFilter<T>([=](T* x){ return op((x->*prop)(), value); });
  12. }
  13.  
  14. // PropFilter(&AZombie::Type, AGIGA_GARGANTUAR)
  15. template <typename T>
  16. AAliveFilter<T> PropFilter(auto (T::* prop)(), auto value) {
  17.     return PropFilter(prop, equal_to(), value);
  18. }
  19.  
  20. class : AStateHook {
  21. private:
  22.     int cnt;
  23.  
  24.     void _BeforeScript() override {
  25.         cnt = 0;
  26.         for(int wave : 1_20)
  27.             AConnect(ATime(wave, 0), [this]{
  28.                 for(auto& zombie : PropFilter(&AZombie::ExistTime, 0))
  29.                     if(zombie.Type() == AGIGA_GARGANTUAR)
  30.                         cnt++;
  31.             });
  32.     }
  33.  
  34. public:
  35.     operator int() {
  36.         return cnt;
  37.     }
  38. } gigaCount;
  39.  
  40. int GetCobReadyTime(int nCobs = 1) {
  41.     auto cobs = aCobManager.GetRecoverList();
  42.     ranges::sort(cobs, [](auto a, auto b){ return a.recoverTime < b.recoverTime; });
  43.     return cobs[nCobs - 1].recoverTime + (aFieldInfo.isRoof ? 387 : 373);
  44. }
  45.  
  46. // ----------------------------------------------------------------
  47.  
  48. unordered_map<string, ATimeline> states;
  49.  
  50. ATimeline Transition(int wl, string notActivate, string activate, string noGiga, string final) {
  51.     return At(wl - 200) Do {
  52.         int currentWave = ANowWave();
  53.         while(ANowTime(currentWave) != wl - 200)
  54.             currentWave--;
  55.         if(ANowTime(currentWave + 1) != INT_MIN) {
  56.             int wl_ = ANowTime(currentWave) - ANowTime(currentWave + 1);
  57.             if(wl_ != wl) {
  58.                 AGetInternalLogger()->Error("第 # 波提前刷新,预期波长 >=#cs,实际波长 #cs", currentWave, wl, wl_);
  59.                 return;
  60.             }
  61.         }
  62.  
  63.         const string* nextState;
  64.         if(ANowTime(currentWave + 1) == INT_MIN)
  65.             nextState = &notActivate;
  66.         else if(currentWave % 10 == 8)
  67.             nextState = &final;
  68.         else if(gigaCount >= 50 && !noGiga.empty())
  69.             nextState = &noGiga;
  70.         else
  71.             nextState = &activate;
  72.  
  73.         if(states.contains(*nextState)) {
  74.             if(nextState == &notActivate)
  75.                 At(AWave(currentWave)) states[*nextState];
  76.             else
  77.                 At(AWave(currentWave + 1)) states[*nextState];
  78.         } else {
  79.             string stateName = (nextState->empty() ? "null" : *nextState);
  80.             AGetInternalLogger()->Error("状态 " + stateName + " 不存在");
  81.         }
  82.     };
  83. }
  84.  
  85. #define RECORD
  86.  
  87. #ifdef RECORD
  88. constexpr auto RELOAD_MODE = AReloadMode::MAIN_UI_OR_FIGHT_UI;
  89. constexpr int SELECT_CARDS_INTERVAL = 17;
  90. constexpr float GAME_SPEED = 5.0;
  91. #elifdef DEMO
  92. constexpr auto RELOAD_MODE = AReloadMode::MAIN_UI;
  93. constexpr int SELECT_CARDS_INTERVAL = 17;
  94. constexpr float GAME_SPEED = 1.0;
  95. #else
  96. constexpr auto RELOAD_MODE = AReloadMode::MAIN_UI_OR_FIGHT_UI;
  97. constexpr int SELECT_CARDS_INTERVAL = 0;
  98. constexpr float GAME_SPEED = 10.0;
  99. #endif
  100.  
  101. void AScript() {
  102.     ASetReloadMode(RELOAD_MODE);
  103.     AConnect('Q', []{ ATerminate(); });
  104.     ASetGameSpeed(GAME_SPEED);
  105.     EnableModsScoped(SaveDataReadOnly, RemoveFog, DisableItemDrop);
  106.     ACreateRandomTypeList();
  107.     #ifdef DEMO
  108.     ASetZombies({{AZOMBIE, APOLE_VAULTING_ZOMBIE, ADANCING_ZOMBIE, ADOLPHIN_RIDER_ZOMBIE, ABALLOON_ZOMBIE, APOGO_ZOMBIE, ABUNGEE_ZOMBIE, ALADDER_ZOMBIE, ACATAPULT_ZOMBIE, AGARGANTUAR, AGIGA_GARGANTUAR}}, ASetZombieMode::INTERNAL);
  109.     ASetZombiesLimits({{9, AGIGA_GARGANTUAR, "==", 0}, {19, AGIGA_GARGANTUAR, "!=", 0}});
  110.     ASetWavelength({ATime{5, 1127}});
  111.     #endif
  112.     #ifdef RECORD
  113.     if(AMRef<int>(0x6a9ec0, 0x768, 0x160, 0x6c) == 1000)
  114.         ASetZombies({{AZOMBIE, APOLE_VAULTING_ZOMBIE, ADANCING_ZOMBIE, ADOLPHIN_RIDER_ZOMBIE, ABALLOON_ZOMBIE, APOGO_ZOMBIE, ABUNGEE_ZOMBIE, ALADDER_ZOMBIE, ACATAPULT_ZOMBIE, AGARGANTUAR, AGIGA_GARGANTUAR}}, ASetZombieMode::INTERNAL);
  115.     #endif
  116.     if(AGetZombieTypeList()[AGIGA_GARGANTUAR] && AGetZombieTypeList()[AGARGANTUAR])
  117.         ASelectCards({AICE_SHROOM, AM_ICE_SHROOM, ADOOM_SHROOM, AJALAPENO, ASQUASH, APUMPKIN, APUFF_SHROOM, ASUN_SHROOM, ASCAREDY_SHROOM, AFLOWER_POT}, SELECT_CARDS_INTERVAL);
  118.     else
  119.         ASelectCards({AICE_SHROOM, ADOOM_SHROOM, AJALAPENO, ASQUASH, APUMPKIN, APUFF_SHROOM, AM_PUFF_SHROOM, ASUN_SHROOM, ASCAREDY_SHROOM, AFLOWER_POT}, SELECT_CARDS_INTERVAL);
  120.  
  121.     // 轨道 a:红白关,逐波 P6
  122.  
  123.     // PPDDDD
  124.     states["a1"] = {
  125.         Transition(601, "", "a2", "b1", ""),
  126.         At(225_cs) PP(),
  127.         At(288_cs) PP() + DD<110>(8.75),
  128.     };
  129.  
  130.     // PPDD
  131.     states["a2"] = {
  132.         Transition(601, "a3*", "a3", "", ""),
  133.         At(359_cs) PP() + DD<107>(7.8125),
  134.     };
  135.  
  136.     // 延迟:PPDD-PPSSSS
  137.     states["a3*"] = {
  138.         Transition(1202, "", "a4", "b1", ""),
  139.         At(1002_cs) P(122556, 9),
  140.     };
  141.  
  142.     // PPDDDD
  143.     states["a3"] = {
  144.         Transition(601, "", "a4", "b1", ""),
  145.         At(249_cs) PP() + DD<110>(8.75) + DD<220>(8.75),
  146.     };
  147.  
  148.     // PPDD
  149.     states["a4"] = {
  150.         Transition(601, "a5*", "a5", "", ""),
  151.         At(359_cs) PP() + DD<107>(7.8125),
  152.     };
  153.  
  154.     // 延迟:PPDD-cccPPI
  155.     states["a5*"] = {
  156.         Transition(1191, "", "a6", "", ""),
  157.         At(891_cs) C(100, 256) + Card(AICE_SHROOM, 1, 9),
  158.         At(991_cs) PP(),
  159.     };
  160.  
  161.     // cccPPI
  162.     states["a5"] = {
  163.         Transition(601, "a6*", "a6", "", ""),
  164.         At(218_cs) Card(AICE_SHROOM, 2, 9) + C(1, 56),
  165.         At(281_cs) C(1, 1),
  166.         At(318_cs) PP(),
  167.     };
  168.  
  169.     // 延迟:cccPPI-PPI
  170.     states["a6*"] = {
  171.         Transition(1127, "", "a7", "", ""),
  172.         At(927_cs) I(1, 9) + PP(),
  173.     };
  174.  
  175.     // PPaI
  176.     states["a6"] = {
  177.         Transition(601, "", "a7", "", ""),
  178.         At(318_cs) PP(),
  179.         At(319_cs) I(1, 9),
  180.         At(400_cs) a(5, 9)
  181.     };
  182.  
  183.     // PPSSDD
  184.     states["a7"] = {
  185.         Transition(601, "", "a8", "b1", ""),
  186.         At(232_cs) P(1256, 8.75),
  187.         At(240_cs) Do {
  188.             for(auto& z : aAliveZombieFilter)
  189.                 if(z.Type() == APOGO_ZOMBIE || z.Type() == AIMP)
  190.                     ACard(AJALAPENO, z.Row() + 1, 9);
  191.         },
  192.         At(359_cs) DD(8.75),
  193.     };
  194.  
  195.     // PPDDcccc
  196.     states["a8"] = {
  197.         Transition(601, "a9*", "a9", "", "a9f"),
  198.         At(359_cs) PP() + DD<107>(7.8125),
  199.         At(360_cs) C(240)
  200.     };
  201.  
  202.     // 延迟:PPDDcccc-PPDDcccc
  203.     states["a9*"] = {
  204.         Transition(1202, "", "", "", "a10f"),
  205.         At(1002_cs) PP() + DD<110>(7.8125),
  206.         At(1111_cs) C(100)
  207.     };
  208.  
  209.     // PPDDcccc
  210.     states["a9"] = {
  211.         Transition(601, "", "", "", "a10f"),
  212.         At(359_cs) PP() + DD<107>(7.8125),
  213.         At(510_cs) C(134)
  214.     };
  215.  
  216.     // 收尾有红:PPDDDD-PP; 无红:PPDD-PP
  217.     ATimeline finalWithGiga{
  218.         At(377_cs) DD(8.75) + DD<110>(8.75),
  219.         At(1150_cs) PP()
  220.     }, finalWithoutGiga{
  221.         At(377_cs) DD(8.1),
  222.         At(620_cs) PP()
  223.     };
  224.  
  225.     states["a9f"] = states["a10f"] = {
  226.         At(270_cs) PP(),
  227.         At(4_cs) Do {
  228.             bool gigaExist = false;
  229.             for(auto& z : PropFilter(&AZombie::AtWave, ANowWave() - 1))
  230.                 if(z.Type() == AGIGA_GARGANTUAR)
  231.                     gigaExist = true;
  232.             At(AWave(ANowWave())) (gigaExist ? finalWithGiga : finalWithoutGiga);
  233.         }
  234.     };
  235.  
  236.     // 轨道 b:无红关 / 变速后,冰代奏连续 PD
  237.  
  238.     // PPDD / PPI
  239.     states["b1"] = {
  240.         Transition(601, "b1*", "b1", "", "b1f"),
  241.         At(-200_cs) Do {
  242.             if(GetCobReadyTime(4) <= 200 + 398 && GetCobReadyTime(6) <= 200 + 601 + 318)
  243.                 At(aNow + 200_cs + 288_cs) PP() + DD<110>(8.75);
  244.             else
  245.                 At(aNow + 200_cs + 318_cs) PP() + I(2, 9);
  246.         }
  247.     };
  248.  
  249.     // 延迟:PPDD-PP
  250.     states["b1*"] = {
  251.         Transition(1202, "", "b1", "", "b1f"),
  252.         At(1002_cs) PP()
  253.     };
  254.  
  255.     // 收尾:PPDD-PP
  256.     states["b1f"] = {
  257.         At(225_cs) PP() + DD<107>(8.1875),
  258.         At(758_cs) PP()
  259.     };
  260.  
  261.     // 轨道 c: 单红关,Pcc/PSD | PSD/Pcc 循环(舞王撑杆不同出时不垫)
  262.  
  263.     ATimeline PPSD, PSDP;
  264.     if(AGetZombieTypeList()[ADANCING_ZOMBIE] && AGetZombieTypeList()[APOLE_VAULTING_ZOMBIE]) {
  265.         PPSD = {
  266.             At(195_cs) C(80, 12),
  267.             At(389_cs) P(2, 8.75),
  268.             At(288_cs) P(56, 9) + D<110>(5, 8.75)
  269.         };
  270.         PSDP = {
  271.             At(195_cs) C(80, 56),
  272.             At(389_cs) P(5, 8.75),
  273.             At(288_cs) P(12, 9) + D<110>(1, 8.75)
  274.         };
  275.     } else {
  276.         ATimeOffset activateTime = AGetZombieTypeList()[ADANCING_ZOMBIE] ? 318 : 379;
  277.         PPSD = {
  278.             At(activateTime) P(2, 8.75),
  279.             At(288_cs) P(56, 9) + D<110>(5, 8.75)
  280.         };
  281.         PSDP = {
  282.             At(activateTime) P(5, 8.75),
  283.             At(288_cs) P(12, 9) + D<110>(1, 8.75)
  284.         };
  285.     }
  286.  
  287.     states["c1"] = {
  288.         Transition(601, "", "c2", "c2t", "c2f"),
  289.         PPSD
  290.     };
  291.  
  292.     states["c1t"] = {
  293.         Transition(601, "", "b1", "", "b1f"),
  294.         PPSD
  295.     };
  296.  
  297.     states["c1*"] = {
  298.         Transition(601, "c2*", "c2", "c4", ""),
  299.         PPSD
  300.     };
  301.  
  302.     states["c1f"] = {
  303.         PPSD,
  304.         At(401_cs) Do {
  305.             if(ANowTime(ANowWave() + 1) == INT_MIN)
  306.                 At(AWave(ANowWave()) + 601_cs) PSDP;
  307.         }
  308.     };
  309.  
  310.     states["c2"] = {
  311.         Transition(601, "", "c1", "c1t", "c1f"),
  312.         PSDP
  313.     };
  314.  
  315.     states["c2t"] = {
  316.         Transition(601, "", "b1", "", "b1f"),
  317.         PSDP
  318.     };
  319.  
  320.     states["c2*"] = {
  321.         Transition(1202, "", "c1", "c3", ""),
  322.         At(1002_cs) P(1225, 9)
  323.     };
  324.  
  325.     states["c2f"] = {
  326.         PSDP,
  327.         At(401_cs) Do {
  328.             if(ANowTime(ANowWave() + 1) == INT_MIN)
  329.                 At(AWave(ANowWave()) + 601_cs) PPSD;
  330.         }
  331.     };
  332.  
  333.     AMaidCheats::Dancing();
  334.     At(20_wave) Do { AMaidCheats::Stop(); };
  335.     aPlantFixer.Start(APUMPKIN, {}, 4000 / 3);
  336.     if(AGetZombieTypeList()[AGIGA_GARGANTUAR] && AGetZombieTypeList()[AGARGANTUAR])
  337.         At(1_wave, 10_wave) states["a1"];
  338.     else if(AGetZombieTypeList()[AGIGA_GARGANTUAR])
  339.         At(1_wave) states["c1"], At(10_wave) states["c1*"];
  340.     else
  341.         At(1_wave, 10_wave) states["b1"];
  342.     At(20_wave) {
  343.         At(250_cs) P(4, 7.5),
  344.         At(341_cs) PP() + DD<110>(8.75) + DD<220>(8.75),
  345.         At(1114_cs) PP()
  346.     };
  347. }
Advertisement
Add Comment
Please, Sign In to add comment