From d1163ccdad39fa1d4802e33e449c0ca5d4a9ba41 Mon Sep 17 00:00:00 2001 From: Rottenham <54915258+Rottenham@users.noreply.github.com> Date: Thu, 21 Sep 2023 00:49:09 -0700 Subject: [PATCH] AverageSpawn 1.0.0 --- .../AverageSpawn/AverageSpawn/AverageSpawn.h | 96 +++++++++++++++++++ .../AverageSpawn/AverageSpawn/information.txt | 2 + crescendo/AverageSpawn/README.md | 15 +++ extension_list.txt | 1 + 4 files changed, 114 insertions(+) create mode 100644 crescendo/AverageSpawn/AverageSpawn/AverageSpawn.h create mode 100644 crescendo/AverageSpawn/AverageSpawn/information.txt create mode 100644 crescendo/AverageSpawn/README.md diff --git a/crescendo/AverageSpawn/AverageSpawn/AverageSpawn.h b/crescendo/AverageSpawn/AverageSpawn/AverageSpawn.h new file mode 100644 index 0000000..5a46f85 --- /dev/null +++ b/crescendo/AverageSpawn/AverageSpawn/AverageSpawn.h @@ -0,0 +1,96 @@ +#ifndef _CRESC_AVERAGE_SPAWN_H +#define _CRESC_AVERAGE_SPAWN_H + +#include "libavz.h" + +namespace _CrescAverageSpawn { + +struct _Zombie : public Zombie { + int& layer() { return (int&)((uint8_t*)this)[0x20]; } +}; + +} // namespace _CrescAverageSpawn + +// *** Not In Queue +// 平均分配指定种类僵尸所在行数 +// 默认只平均分配红眼 +// *** 注意:只能读取DE、NE、PE、FE、RE五大场景,无法辨认的场景默认是ME +// *** 使用示例 +// AverageSpawn()-------------------------------不填参数,平均分配每波红眼 +// AverageSpawn({POGO_ZOMBIE, ZOMBONI})---------平均分配每波跳跳和冰车 +// AverageSpawn({GIGA_GARGANTUAR}, true)--------仅在收尾波(w9, w19)平均分配红眼 +// AverageSpawn({GIGA_GARGANTUAR}, true, 1)-----仅在收尾波平均分配红眼,从1路起顺次分配 +void AverageSpawn(const std::vector& lst = {GIGA_GARGANTUAR}, + bool onlyEndingWave = false, int start_row = -1) +{ + int scene = AvZ::GetMainObject()->scene(); + std::vector zombieRow = {0, 1, 2, 3, 4}; + int height = 85; + if (scene == 2 || scene == 3) { + zombieRow = {0, 1, 4, 5}; + } + if (scene == 0 || scene == 1) { + height = 100; + } + int baseY = 40; + if (scene == 0 || scene == 1 || scene == 2 || scene == 3) { + baseY = 50; + } + + for (int wave = 1; wave <= 20; ++wave) { + if (onlyEndingWave && (wave != 9 && wave != 19)) + continue; + AvZ::InsertTimeOperation( + 0, wave, + [=]() { + auto zombie = (_CrescAverageSpawn::_Zombie*)AvZ::GetMainObject()->zombieArray(); + int zombies_count_max = AvZ::GetMainObject()->zombieTotal(); + const int ZOMBIE_TYPE_NUM = 33; + int spawnRow[ZOMBIE_TYPE_NUM]; + for (int i = 0; i < ZOMBIE_TYPE_NUM; ++i) { + if (std::find(zombieRow.begin(), zombieRow.end(), start_row - 1) == zombieRow.end()) { + spawnRow[i] = rand() % (zombieRow.size()); + } else { + spawnRow[i] = std::find(zombieRow.begin(), zombieRow.end(), start_row - 1) - zombieRow.begin(); + } + } + for (int i = 0; i < zombies_count_max; ++i, ++zombie) { + if (zombie->isDead() || zombie->isDisappeared()) + continue; + + // 只移动本波僵尸 + if (zombie->existTime() > 100) + continue; + + // 检测类型 + int type = zombie->type(); + if (std::find(lst.begin(), lst.end(), type) == lst.end()) + continue; + + // 不移动水路僵尸 + int row = zombie->row(); + if ((scene == 2 || scene == 3) && (row == 2 || row == 3)) { + continue; + } + + // 不移动前院场地的舞王 + if ((scene == 0 || scene == 1) && (type == DANCING_ZOMBIE)) { + continue; + } + + if (type >= 0 && type < ZOMBIE_TYPE_NUM && spawnRow[type] >= 0 && spawnRow[type] < zombieRow.size()) { + int diff = zombieRow[spawnRow[type]] - row; + zombie->row() = zombieRow[spawnRow[type]]; + zombie->ordinate() = baseY + zombieRow[spawnRow[type]] * height; + zombie->layer() += 10000 * diff; + spawnRow[type]++; + if (spawnRow[type] >= zombieRow.size()) { + spawnRow[type] -= zombieRow.size(); + } + } + } + }, + "AverageSpawn"); + } +} +#endif \ No newline at end of file diff --git a/crescendo/AverageSpawn/AverageSpawn/information.txt b/crescendo/AverageSpawn/AverageSpawn/information.txt new file mode 100644 index 0000000..4f7e7d1 --- /dev/null +++ b/crescendo/AverageSpawn/AverageSpawn/information.txt @@ -0,0 +1,2 @@ +version 1.0.0+avz1 +avz 2022_10_01 \ No newline at end of file diff --git a/crescendo/AverageSpawn/README.md b/crescendo/AverageSpawn/README.md new file mode 100644 index 0000000..c219c95 --- /dev/null +++ b/crescendo/AverageSpawn/README.md @@ -0,0 +1,15 @@ +# 平均分配僵尸所在行数 + +平均分配指定种类僵尸所在行数(默认只平均分配红眼)。 + +## 使用示例 +```cpp +#include "AverageSpawn/AverageSpawn.h" + +AverageSpawn(); // 不填参数,平均分配每波红眼 +AverageSpawn({POGO_ZOMBIE, ZOMBONI}); // 平均分配每波跳跳和冰车 +AverageSpawn({GIGA_GARGANTUAR}, true); // 仅在收尾波(w9, w19)平均分配红眼 +AverageSpawn({GIGA_GARGANTUAR}, true, 1); // 仅在收尾波平均分配红眼,从1路起顺次分配 +``` + +注意:只能读取DE、NE、PE、FE、RE五大场景,无法辨认的场景默认是ME. diff --git a/extension_list.txt b/extension_list.txt index bfa2eeb..d9115a4 100644 --- a/extension_list.txt +++ b/extension_list.txt @@ -1,3 +1,4 @@ +crescendo/AverageSpawn qrmd/GetZombieAbscissas qrmd/KeyAssistant qrmd/PlantFixerPlus