From 4bd025224677aff210a01469be0092fe0ec36811 Mon Sep 17 00:00:00 2001 From: undefined06855 Date: Tue, 12 Mar 2024 22:49:00 +0000 Subject: [PATCH 1/3] Add percent chance --- .gitignore | 3 +++ src/main.cpp | 43 ++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01de515 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +.github/ +out/ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ad332d6..8d6b589 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,21 @@ using namespace geode::prelude; -CCSprite *RobertTopala = nullptr; +CCSprite* RobertTopala = nullptr; bool isHolding = false; class $modify(PlayerObject) { - void jumpscare() { // Check if randomizing is enabled - auto randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); + bool randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); + double randomizeOptionChance = Mod::get()->getSettingValue("randomize-jumpscare-chance"); + + // if randomize is turned on then there is certain percent chance of the jumpscare + float randPercent = (static_cast(rand()) / static_cast(RAND_MAX)) * 100; - // if randomize is turned on then there is 1 in 100 chance of the jumpscare - if (randomizeOption && (rand() % 100 != 0)) { + if (randomizeOption && (randPercent > randomizeOptionChance)) return; - } - + FMODAudioEngine::sharedEngine()->playEffect("vine-boom.mp3"_spr); // If action is running stop it @@ -35,7 +36,7 @@ class $modify(PlayerObject) { isHolding = false; } - TodoReturn releaseButton(PlayerButton p0) { + void releaseButton(PlayerButton p0) { PlayerObject::releaseButton(p0); if (p0 != PlayerButton::Jump) @@ -47,19 +48,19 @@ class $modify(PlayerObject) { void incrementJumps() { // Check if randomizing is enabled auto randomizeOption = Mod::get()->getSettingValue("randomize-jumpscare"); - - // increment jump jumpscares only happen if randomization is disabled. + + // increment jump jumpscares only happen if randomization is disabled. if (randomizeOption == false) { - // Check if robert exists and if the user is holding jump (Works only for the cube) - const auto runningScene = CCDirector::get()->getRunningScene(); - if (runningScene->getChildByID("robert-topala") && isHolding) { - this->jumpscare(); - } + // Check if robert exists and if the user is holding jump (Works only for the cube) + const auto runningScene = CCDirector::get()->getRunningScene(); + if (runningScene->getChildByID("robert-topala") && isHolding) { + this->jumpscare(); + } } } - TodoReturn pushButton(PlayerButton p0) { - + void pushButton(PlayerButton p0) { + PlayerObject::pushButton(p0); if (p0 != PlayerButton::Jump) @@ -78,15 +79,15 @@ class $modify(PlayerObject) { RobertTopala = CCSprite::create("RobertTopala.png"_spr); RobertTopala->setID("robert-topala"); CCSize winSize = CCDirector::get()->getWinSize(); - + float scaleRatio = (winSize.height / RobertTopala->getContentSize().height); - + // Scale robert to fit screen RobertTopala->setScaleX(scaleRatio); RobertTopala->setScaleY(scaleRatio); - + // Center the robert - RobertTopala->setPosition({winSize.width / 2, winSize.height / 2}); + RobertTopala->setPosition({ winSize.width / 2, winSize.height / 2 }); runningScene->addChild(RobertTopala, 100); // Set robert opacity to 0 From 10dc625321e63cae2c471597cfdd234cfe4d047a Mon Sep 17 00:00:00 2001 From: undefined06855 Date: Tue, 12 Mar 2024 22:56:13 +0000 Subject: [PATCH 2/3] add mod.json --- mod.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mod.json b/mod.json index 771572c..d1de484 100644 --- a/mod.json +++ b/mod.json @@ -1,12 +1,12 @@ { "geode": "2.0.0", - "version": "v1.2.2", + "version": "v1.3.0", "id": "n.robtop-jumpscare", "name": "Robtop Jumpscare", "developer": "n", "gd": { "android": "2.205", - "win": "2.204" + "win": "2.204" }, "repository": "https://github.com/NicknameGG/robtop-jumpscare", "description": "Jumpscare yourself everytime you jump!", @@ -19,9 +19,21 @@ "settings": { "randomize-jumpscare": { "name": "Randomize Jumpscare", - "description": "Jumpscares happen with a 1% chance instead of a 100% chance when enabled.", + "description": "Jumpscares happen with a certain chance instead of a 100% chance when enabled.", "type": "bool", "default": false + }, + "randomize-jumpscare-chance": { + "name": "Randomize Jumpscare Chance", + "description": "The % chance that Robert Topala will jumpscare you. Enable Randomize Jumpscare for this to take effect!", + "type": "float", + "default": 1, + "min": 0, + "max": 100, + "control": { + "slider": true, + "slider-step": 0.05 + } } } } \ No newline at end of file From 762b9c624060a508ae804bdeb07ca98c62a4f52f Mon Sep 17 00:00:00 2001 From: Nick <52223947+NicknameGG@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:28:20 -0600 Subject: [PATCH 3/3] I FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOTI FORGOT I FORGOT --- mod.json | 77 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/mod.json b/mod.json index d1de484..a8119e1 100644 --- a/mod.json +++ b/mod.json @@ -1,39 +1,40 @@ { - "geode": "2.0.0", - "version": "v1.3.0", - "id": "n.robtop-jumpscare", - "name": "Robtop Jumpscare", - "developer": "n", - "gd": { - "android": "2.205", - "win": "2.204" - }, - "repository": "https://github.com/NicknameGG/robtop-jumpscare", - "description": "Jumpscare yourself everytime you jump!", - "resources": { - "files": [ - "resources/*.mp3", - "resources/*.png" - ] - }, - "settings": { - "randomize-jumpscare": { - "name": "Randomize Jumpscare", - "description": "Jumpscares happen with a certain chance instead of a 100% chance when enabled.", - "type": "bool", - "default": false - }, - "randomize-jumpscare-chance": { - "name": "Randomize Jumpscare Chance", - "description": "The % chance that Robert Topala will jumpscare you. Enable Randomize Jumpscare for this to take effect!", - "type": "float", - "default": 1, - "min": 0, - "max": 100, - "control": { - "slider": true, - "slider-step": 0.05 - } - } - } -} \ No newline at end of file + "geode": "2.0.0-beta.24", + "version": "v1.3.1", + "id": "n.robtop-jumpscare", + "name": "Robtop Jumpscare", + "developer": "n", + "gd": { + "android": "2.205", + "win": "2.204", + "ios": "2.205" + }, + "repository": "https://github.com/NicknameGG/robtop-jumpscare", + "description": "Jumpscare yourself everytime you jump!", + "resources": { + "files": [ + "resources/*.mp3", + "resources/*.png" + ] + }, + "settings": { + "randomize-jumpscare": { + "name": "Randomize Jumpscare", + "description": "Jumpscares happen with a certain chance instead of a 100% chance when enabled.", + "type": "bool", + "default": false + }, + "randomize-jumpscare-chance": { + "name": "Randomize Jumpscare Chance", + "description": "The % chance that Robert Topala will jumpscare you. Enable Randomize Jumpscare for this to take effect!", + "type": "float", + "default": 1, + "min": 0, + "max": 100, + "control": { + "slider": true, + "slider-step": 0.05 + } + } + } +}