mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-28 02:51:55 +00:00
Added onEnter and onExit for challenges
This commit is contained in:
parent
5febe0d4db
commit
d5a0b88796
6 changed files with 24 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
# The Modding Tree changelog:
|
# The Modding Tree changelog:
|
||||||
|
|
||||||
|
- Added directMult, which multiplies gain after exponents and softcaps. It actually multiplies gain for static layers.
|
||||||
|
- Added onEnter and onExit for challenges.
|
||||||
|
- Added documentation on how gainMult/Exp work for static layers.
|
||||||
|
|
||||||
# v2.5.3 - 5/8/21
|
# v2.5.3 - 5/8/21
|
||||||
- Improved performance of tab formats and bars.
|
- Improved performance of tab formats and bars.
|
||||||
- Respec confirmation settings are now kept on resets.
|
- Respec confirmation settings are now kept on resets.
|
||||||
|
|
|
@ -48,6 +48,10 @@ Individual Challenges can have these features:
|
||||||
|
|
||||||
- onComplete() - **optional**. this function will be called when the challenge is completed when previously incomplete.
|
- onComplete() - **optional**. this function will be called when the challenge is completed when previously incomplete.
|
||||||
|
|
||||||
|
- onEnter() - **optional**. this function will be called when entering the challenge
|
||||||
|
|
||||||
|
- onExit() - **optional**. this function will be called when exiting the challenge in any way
|
||||||
|
|
||||||
- countsAs: **optional**. If a challenge combines the effects of other challenges in this layer, you can use this. An array of challenge ids. The player is effectively in all of those challenges when in the current one.
|
- countsAs: **optional**. If a challenge combines the effects of other challenges in this layer, you can use this. An array of challenge ids. The player is effectively in all of those challenges when in the current one.
|
||||||
|
|
||||||
- completionLimit: **optional**. the amount of times you can complete this challenge. Default is 1 completion.
|
- completionLimit: **optional**. the amount of times you can complete this challenge. Default is 1 completion.
|
||||||
|
|
|
@ -101,7 +101,10 @@ You can make almost any value dynamic by using a function in its place, includin
|
||||||
|
|
||||||
- roundUpCost: **optional**. a bool, which is true if the resource cost needs to be rounded up. (use if the base resource is a "static" currency.)
|
- roundUpCost: **optional**. a bool, which is true if the resource cost needs to be rounded up. (use if the base resource is a "static" currency.)
|
||||||
|
|
||||||
- gainMult(), gainExp(): **optional**. Functions that calculate the multiplier and exponent on resource gain from upgrades and boosts and such. Plug in any bonuses here.
|
- gainMult(), gainExp(): **optional**. For normal layers, these functions calculate the multiplier and exponent on resource gain from upgrades and boosts and such. Plug in most bonuses here.
|
||||||
|
For static layers, they instead divide and root the cost of the resource.
|
||||||
|
|
||||||
|
- directMult(): **optional**. Directly multiplies the resource gain, after exponents and softcaps. For static layers, actually multiplies resource gain instead of reducing the cost.
|
||||||
|
|
||||||
- softcap, softcapPower: **optional**. For normal layers, gain beyond [softcap] points is put to the [softcapPower]th power
|
- softcap, softcapPower: **optional**. For normal layers, gain beyond [softcap] points is put to the [softcapPower]th power
|
||||||
Default for softcap is e1e7, and for power is 0.5.
|
Default for softcap is e1e7, and for power is 0.5.
|
||||||
|
|
|
@ -95,7 +95,10 @@ addLayer("c", {
|
||||||
rewardDisplay() { return format(this.rewardEffect())+"x" },
|
rewardDisplay() { return format(this.rewardEffect())+"x" },
|
||||||
countsAs: [12, 21], // Use this for if a challenge includes the effects of other challenges. Being in this challenge "counts as" being in these.
|
countsAs: [12, 21], // Use this for if a challenge includes the effects of other challenges. Being in this challenge "counts as" being in these.
|
||||||
rewardDescription: "Says hi",
|
rewardDescription: "Says hi",
|
||||||
onComplete() {console.log("hiii")} // Called when you complete the challenge
|
onComplete() {console.log("hiii")}, // Called when you successfully complete the challenge
|
||||||
|
onEnter() {console.log("So challenging")},
|
||||||
|
onExit() {console.log("Sweet freedom!")},
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
upgrades: {
|
upgrades: {
|
||||||
|
|
|
@ -264,8 +264,10 @@ function startChallenge(layer, x) {
|
||||||
enter = true
|
enter = true
|
||||||
}
|
}
|
||||||
doReset(layer, true)
|
doReset(layer, true)
|
||||||
if(enter) player[layer].activeChallenge = x
|
if(enter) {
|
||||||
|
player[layer].activeChallenge = x
|
||||||
|
run(layers[layer].challenges[x].onEnter, layers[layer].challenges[x])
|
||||||
|
}
|
||||||
updateChallengeTemp(layer)
|
updateChallengeTemp(layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +303,7 @@ function completeChallenge(layer, x) {
|
||||||
let completions = canCompleteChallenge(layer, x)
|
let completions = canCompleteChallenge(layer, x)
|
||||||
if (!completions){
|
if (!completions){
|
||||||
player[layer].activeChallenge = null
|
player[layer].activeChallenge = null
|
||||||
|
run(layers[layer].challenges[x].onExit, layers[layer].challenges[x])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (player[layer].challenges[x] < tmp[layer].challenges[x].completionLimit) {
|
if (player[layer].challenges[x] < tmp[layer].challenges[x].completionLimit) {
|
||||||
|
@ -310,6 +313,7 @@ function completeChallenge(layer, x) {
|
||||||
if (layers[layer].challenges[x].onComplete) run(layers[layer].challenges[x].onComplete, layers[layer].challenges[x])
|
if (layers[layer].challenges[x].onComplete) run(layers[layer].challenges[x].onComplete, layers[layer].challenges[x])
|
||||||
}
|
}
|
||||||
player[layer].activeChallenge = null
|
player[layer].activeChallenge = null
|
||||||
|
run(layers[layer].challenges[x].onExit, layers[layer].challenges[x])
|
||||||
updateChallengeTemp(layer)
|
updateChallengeTemp(layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,11 @@ var NaNalert = false;
|
||||||
// Tmp will not call these
|
// Tmp will not call these
|
||||||
var activeFunctions = [
|
var activeFunctions = [
|
||||||
"startData", "onPrestige", "doReset", "update", "automate",
|
"startData", "onPrestige", "doReset", "update", "automate",
|
||||||
"buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "onHold", "masterButtonPress",
|
"buy", "buyMax", "respec", "onPress", "onClick", "onHold", "masterButtonPress",
|
||||||
"sellOne", "sellAll", "pay", "actualCostFunction", "actualEffectFunction",
|
"sellOne", "sellAll", "pay", "actualCostFunction", "actualEffectFunction",
|
||||||
"effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay",
|
"effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay",
|
||||||
"tabFormat", "content",
|
"tabFormat", "content",
|
||||||
|
"onComplete", "onPurchase", "onEnter", "onExit",
|
||||||
]
|
]
|
||||||
|
|
||||||
var noCall = doNotCallTheseFunctionsEveryTick
|
var noCall = doNotCallTheseFunctionsEveryTick
|
||||||
|
|
Loading…
Reference in a new issue