Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new sleep perk and minor conveyor improvement #172

Open
wants to merge 2 commits into
base: 5.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion Game/src/base/KinkyDungeon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6107,6 +6107,25 @@ function KinkyDungeonLoadGame(String: string = "") {
let KinkyDungeonSeed = (Math.random() * 4294967296).toString();
let KDRandom = sfc32(xmur3(KinkyDungeonSeed)(), xmur3(KinkyDungeonSeed)(), xmur3(KinkyDungeonSeed)(), xmur3(KinkyDungeonSeed)());

/**
* Generates a random number with a bias towards lower values.
*
* @returns {number} - A random number [0,1) biased towards lower values.
*/
function KDRandomLow() {
return Math.pow(KDRandom(), 1.8);
}

/**
* Determines if a random event occurs based on the given chance.
*
* @param {number} chance - Probability of the event occurring (0 to 1).
* @returns {boolean} - True if the event occurs, false otherwise.
*/
function KDChance(chance :number) {
return KDRandom() < chance;
}

/**
* @param {boolean} Native Decides whether or not to use native KDRandom to randomize
*/
Expand Down Expand Up @@ -6419,4 +6438,42 @@ async function RunGenMapCallback() {
(() => {
KinkyDungeonState = ff();
})();
}
}

/**
* Unjams all jammed NPCs locks based on a given chance.
*
* @param {number} chance - Probability (0-1) to unjam a lock.
*/
function KDMassUnjam(chance: number ) {
KDMapData.Entities.forEach(entity => {
if (entity.flags && entity.flags.LockJammed == -1 && KDChance(chance)) {
entity.flags.LockJammed = undefined;
}
});
}

/**
* Actions performed for sweat dreams.
*/
function KDSweetDreams() {
KDMassUnjam(0.5);
let r = KinkyDungeonPlayerGetRestraintsWithLocks(Object.keys(KDLocks), true);
r.forEach(r => {
if (KDChance(0.2)) {
KinkyDungeonLock(r, "")
}
});
}

/**
* Actions performed for nightmares.
*/
function KDNightmares() {
for (let i = 0; i < KDRandomLow()*5; i++) {
KDPlayerEffectRestrain(undefined, 1, ["shadowHands"], "Ghost", false, true, false, false, false);
}
if (KinkyDungeonStatsChoice.has("Nowhere")) {
KinkyDungeonAddRestraintIfWeaker(KinkyDungeonGetRestraintByName("BedTrap"), 10, true)
}
}
7 changes: 7 additions & 0 deletions Game/src/dialogue/KinkyDungeonDialogueList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,13 @@ let KDDialogue: Record<string, KinkyDialogue> = {
//KinkyDungeonChangeWill(KinkyDungeonStatWillMax * KDSleepBedPercentage);
KDGameData.SleepTurns = KinkyDungeonSleepTurnsMax;
KDChangeMana("player","sleep", "tick", KinkyDungeonStatManaMax, false, 0, false, true);
if (KinkyDungeonStatsChoice.has("SweetDreams")) {
KDSweetDreams();
}
if (KinkyDungeonStatsChoice.has("Nightmares")) {
KDNightmares();
}

return false;
},
options: {
Expand Down
1 change: 1 addition & 0 deletions Game/src/map/KinkyDungeonTiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ function KDConveyor(_delta: number, X: number, Y: number, unwilling?: boolean) {
KinkyDungeonSetFlag("conveyed_rec", 3);
KDMovePlayer(X + (tile.DX || 0), Y + (tile.DY || 0), false, false, true);
KinkyDungeonSendTextMessage(4, TextGet("KDConveyorPush"), "#ffff44", 2);
KDGameData.SlowMoveTurns = Math.max(KDGameData.SlowMoveTurns, ( Math.ceil(KDRandom()*2+0.2)));
}
} else if (!KDIsImmobile(entity) && !KDIsFlying(entity) && !entity.Enemy.tags.ignoreconveyor && !entity.Enemy.ethereal
&& !(entity.Enemy.tags.unstoppable || (entity.Enemy.tags.unflinching && !KinkyDungeonIsDisabled(entity)))) {
Expand Down
3 changes: 3 additions & 0 deletions Game/src/player/KinkyDungeonPerks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ let KinkyDungeonStatsPresets: Record<string, KDPerk> = {
"MapAbsurd": {category: "Map", id: "MapAbsurd", cost: 0, tags: ["start", "mapsize"], blocktags: ["mapsize"]},

"TrustFall": {category: "Restriction", id: "TrustFall", cost: -1, tags: ["heels"], block: ["ClassicHeels"]},

"SweetDreams": {category: "Enemies", id: "SweetDreams", cost: 1, block: ["Nightmares"]},
"Nightmares": {category: "Enemies", id: "Nightmares", cost: -1, block: ["SweetDreams"]},
};


Expand Down
5 changes: 5 additions & 0 deletions Screens/MiniGame/KinkyDungeon/Text_KinkyDungeon.csv
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ KinkyDungeonStatDescBoundCrusader,"Goddesses will equip restraints upon acceptan
KinkyDungeonStatNowhere,"Nowhere is Safe"
KinkyDungeonStatDescNowhere,"Beds and furniture are often trapped."

KinkyDungeonStatSweetDreams,"Sweet Dreams"
KinkyDungeonStatDescSweetDreams,"While you sleep the locks can unlock and the jammed things can be loose."
KinkyDungeonStatNightmares,"Nightmares"
KinkyDungeonStatDescNightmares,"While you're sleeping, dark desires are trying to seize you."


KinkyDungeonStatQuakeCollar,"Quakehoof Associate"
KinkyDungeonStatDescQuakeCollar,"Start with the Epsilon Collar, which regenerates mana when you play with yourself."
Expand Down