Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kittenchilly committed Jun 24, 2024
1 parent 509c0dc commit ca75696
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 110 deletions.
26 changes: 0 additions & 26 deletions CMakeSettings.json

This file was deleted.

14 changes: 11 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.0.0",
"geode": "3.1.0",
"gd": {
"win": "2.206",
"android": "2.206",
Expand All @@ -8,8 +8,16 @@
},
"id": "kittenchilly.randomize_icon_on_death",
"name": "Randomize Icon on Death",
"version": "v1.0.4",
"version": "v1.1.0",
"developer": "kittenchilly",
"description": "Randomizes your icons and colors everytime you die",
"repository": "https://github.com/kittenchilly/Randomize-Icon-on-Death"
"repository": "https://github.com/kittenchilly/Randomize-Icon-on-Death",
"settings": {
"random-p2": {
"name": "Random P2",
"description": "If P2/Dual should also be a completely random icon, rather than P1's icon with colors inverted",
"type": "bool",
"default": false
}
}
}
195 changes: 114 additions & 81 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@
#include <Geode/modify/PlayerObject.hpp>
#include <random>

inline static std::vector<std::vector<int>> unlocked = {};
using namespace geode::prelude;

inline static std::map<UnlockType, std::vector<int>> UNLOCKED = {
{ UnlockType::Cube, {} },
{ UnlockType::Col1, {} },
{ UnlockType::Col2, {} },
{ UnlockType::Ship, {} },
{ UnlockType::Ball, {} },
{ UnlockType::Bird, {} },
{ UnlockType::Dart, {} },
{ UnlockType::Robot, {} },
{ UnlockType::Spider, {} },
{ UnlockType::Streak, {} },
{ UnlockType::Death, {} },
{ UnlockType::GJItem, {} },
{ UnlockType::Swing, {} },
{ UnlockType::Jetpack, {} },
{ UnlockType::ShipFire, {} }
};

int randomNumber(int start, int end) {
std::random_device os_seed;
Expand All @@ -15,132 +33,99 @@ int randomNumber(int start, int end) {
return distribute(generator);
}

void setupUnlocked() {
void setupUnlockedIcons(IconType iconType) {
auto gameManager = GameManager::sharedState();
unlocked.clear();
unlocked.push_back({});
for (int i = 1; i <= 484; i++) {
if (gameManager->isIconUnlocked(i, IconType::Cube)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 0; i <= 106; i++) {
if (gameManager->isColorUnlocked(i, UnlockType::Col1)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 0; i <= 106; i++) {
if (gameManager->isColorUnlocked(i, UnlockType::Col2)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 169; i++) {
if (gameManager->isIconUnlocked(i, IconType::Ship)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 118; i++) {
if (gameManager->isIconUnlocked(i, IconType::Ball)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 149; i++) {
if (gameManager->isIconUnlocked(i, IconType::Ufo)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 96; i++) {
if (gameManager->isIconUnlocked(i, IconType::Wave)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 68; i++) {
if (gameManager->isIconUnlocked(i, IconType::Robot)) unlocked.back().push_back(i);
auto& vec = UNLOCKED[gameManager->iconTypeToUnlockType(iconType)];
vec.clear();
auto amount = iconType == IconType::Item ? 20 : gameManager->countForType(iconType);
for (int i = iconType == IconType::Item ? 18 : 1; i <= amount; i++) {
if (gameManager->isIconUnlocked(i, iconType)) vec.push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 69; i++) {
if (gameManager->isIconUnlocked(i, IconType::Spider)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 7; i++) {
if (gameManager->isIconUnlocked(i, IconType::Special)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 20; i++) {
if (gameManager->isIconUnlocked(i, IconType::DeathEffect)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 43; i++) {
if (gameManager->isIconUnlocked(i, IconType::Swing)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 5; i++) {
if (gameManager->isIconUnlocked(i, IconType::Jetpack)) unlocked.back().push_back(i);
}
unlocked.push_back({});
for (int i = 1; i <= 6; i++) {
if (gameManager->isIconUnlocked(i, IconType::ShipFire)) unlocked.back().push_back(i);
}

void setupUnlockedColors(UnlockType unlockType) {
auto gameManager = GameManager::sharedState();
auto& vec = UNLOCKED[unlockType];
vec.clear();
for (int i = 0; i < 107; i++) {
if (gameManager->isColorUnlocked(i, unlockType)) vec.push_back(i);
}
}

void setupUnlocked() {
setupUnlockedIcons(IconType::Cube);
setupUnlockedColors(UnlockType::Col1);
setupUnlockedColors(UnlockType::Col2);
setupUnlockedIcons(IconType::Ship);
setupUnlockedIcons(IconType::Ball);
setupUnlockedIcons(IconType::Ufo);
setupUnlockedIcons(IconType::Wave);
setupUnlockedIcons(IconType::Robot);
setupUnlockedIcons(IconType::Spider);
setupUnlockedIcons(IconType::Special);
setupUnlockedIcons(IconType::DeathEffect);
setupUnlockedIcons(IconType::Item);
setupUnlockedIcons(IconType::Swing);
setupUnlockedIcons(IconType::Jetpack);
setupUnlockedIcons(IconType::ShipFire);
}

void randomize(UnlockType unlockType) {
auto& vec = UNLOCKED[unlockType];
if (unlockType == UnlockType::GJItem) {
auto gameStatsManager = GameStatsManager::sharedState();
for (int i = 0; i < vec.size(); i++) {
gameStatsManager->toggleEnableItem(unlockType, vec[i], randomNumber(0, 1));
}
return;
}
auto gameManager = GameManager::sharedState();
auto num = 0;
auto num = vec[(size_t)randomNumber(0, vec.size() - 1)];
switch (unlockType) {
case UnlockType::Cube:
num = unlocked[0][randomNumber(0, unlocked[0].size() - 1)];
gameManager->setPlayerFrame(num);
break;
case UnlockType::Col1:
num = unlocked[1][randomNumber(0, unlocked[1].size() - 1)];
gameManager->setPlayerColor(num);
break;
case UnlockType::Col2:
num = unlocked[2][randomNumber(0, unlocked[2].size() - 1)];
gameManager->setPlayerColor2(num);

//glow
if (gameManager->m_playerGlow)
{
num = unlocked[2][randomNumber(0, unlocked[2].size() - 1)];
gameManager->m_playerGlowColor = num;
}
num = vec[(size_t)randomNumber(0, vec.size() - 1)];
gameManager->m_playerGlowColor = num;
break;
case UnlockType::Ship:
num = unlocked[3][randomNumber(0, unlocked[3].size() - 1)];
gameManager->setPlayerShip(num);
break;
case UnlockType::Ball:
num = unlocked[4][randomNumber(0, unlocked[4].size() - 1)];
gameManager->setPlayerBall(num);
break;
case UnlockType::Bird:
num = unlocked[5][randomNumber(0, unlocked[5].size() - 1)];
gameManager->setPlayerBird(num);
break;
case UnlockType::Dart:
num = unlocked[6][randomNumber(0, unlocked[6].size() - 1)];
gameManager->setPlayerDart(num);
break;
case UnlockType::Robot:
num = unlocked[7][randomNumber(0, unlocked[7].size() - 1)];
gameManager->setPlayerRobot(num);
break;
case UnlockType::Spider:
num = unlocked[8][randomNumber(0, unlocked[8].size() - 1)];
gameManager->setPlayerSpider(num);
break;
case UnlockType::Streak:
num = unlocked[9][randomNumber(0, unlocked[9].size() - 1)];
gameManager->setPlayerStreak(num);
break;
case UnlockType::Death:
num = unlocked[10][randomNumber(0, unlocked[10].size() - 1)];
gameManager->setPlayerDeathEffect(num);
break;
case UnlockType::Swing:
num = unlocked[11][randomNumber(0, unlocked[11].size() - 1)];
gameManager->setPlayerSwing(num);
break;
case UnlockType::Jetpack:
num = unlocked[12][randomNumber(0, unlocked[12].size() - 1)];
gameManager->setPlayerJetpack(num);
break;
case UnlockType::ShipFire:
num = unlocked[13][randomNumber(0, unlocked[13].size() - 1)];
gameManager->setPlayerShipStreak(num);
break;
}
Expand Down Expand Up @@ -195,10 +180,13 @@ class $modify(PlayLayer) {
randomize(UnlockType::Spider);
randomize(UnlockType::Streak);
randomize(UnlockType::Death);
randomize(UnlockType::GJItem);
randomize(UnlockType::Swing);
randomize(UnlockType::Jetpack);
randomize(UnlockType::ShipFire);

m_player1->updatePlayerArt();
m_player2->updatePlayerArt();

updateFrames(m_player1);
updateFrames(m_player2);
Expand All @@ -219,10 +207,55 @@ class $modify(PlayLayer) {
m_player1->updatePlayerGlow();
m_player2->updatePlayerGlow();

m_player1->m_regularTrail->reset();
m_player2->m_regularTrail->reset();
m_player1->m_regularTrail->setColor(gameManager->colorForIdx(color1));
m_player2->m_regularTrail->setColor(gameManager->colorForIdx(color2));
m_player1->m_regularTrail->updateDisplayedColor(gameManager->colorForIdx(color1));
m_player2->m_regularTrail->updateDisplayedColor(gameManager->colorForIdx(color2));

m_player1->m_waveTrail->setColor(gameManager->colorForIdx(color1));
m_player2->m_waveTrail->setColor(gameManager->colorForIdx(color2));
m_player1->m_waveTrail->updateDisplayedColor(gameManager->colorForIdx(color1));
m_player2->m_waveTrail->updateDisplayedColor(gameManager->colorForIdx(color2));

if (Mod::get()->getSettingValue<bool>("random-p2"))
{
setupUnlocked();

m_player1->m_waveTrail->reset();
m_player2->m_waveTrail->reset();
randomize(UnlockType::Cube);
randomize(UnlockType::Col1);
randomize(UnlockType::Col2);
randomize(UnlockType::Ship);
randomize(UnlockType::Ball);
randomize(UnlockType::Bird);
randomize(UnlockType::Dart);
randomize(UnlockType::Robot);
randomize(UnlockType::Spider);
randomize(UnlockType::Streak);
randomize(UnlockType::Death);
randomize(UnlockType::GJItem);
randomize(UnlockType::Swing);
randomize(UnlockType::Jetpack);
randomize(UnlockType::ShipFire);

m_player2->updatePlayerArt();

updateFrames(m_player2);

int color1 = gameManager->getPlayerColor();
int color2 = gameManager->getPlayerColor2();

m_player2->setColor(gameManager->colorForIdx(color1));
m_player2->setSecondColor(gameManager->colorForIdx(color2));

m_player2->m_glowColor = gameManager->colorForIdx(gameManager->m_playerGlowColor);
m_player2->updateGlowColor();
m_player2->updatePlayerGlow();

m_player2->m_regularTrail->setColor(gameManager->colorForIdx(color1));
m_player2->m_regularTrail->updateDisplayedColor(gameManager->colorForIdx(color1));

m_player2->m_waveTrail->setColor(gameManager->colorForIdx(color1));
m_player2->m_waveTrail->updateDisplayedColor(gameManager->colorForIdx(color1));
}
}
};

0 comments on commit ca75696

Please sign in to comment.