Created
April 21, 2020 21:16
-
-
Save codedmonkey/9484cd4775bf76337096bf31ec614601 to your computer and use it in GitHub Desktop.
Pokemon Global Link Generation 6: Balloon Popping minigame analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an analyis of the Pokemon Global Link Balloon Popping attraction, original source code: | |
// http://3ds.pokemon-gl.com/pc/pokemonfesta/13816710-1dd2-11b2-0000-242d50cf1ff7/js/attraction.js | |
// Related variables: | |
Config.rank=[15,27,45,10,3]; // The percentage for each rank: Rank E - Rank A | |
Config.rankScore=[30,50,70,80,100]; // The maximum score for each rank: Rank E - Rank A | |
// This function is initialised when the application reaches the result screen | |
// It generates the scores and rank by using a lot of random numbers | |
// Everything you do during gameplay is arbitrary | |
Result = function(u) { | |
// This code sets up resources for the Results-screen | |
var m = "result"; | |
if (Config.LANG == "de" || Config.LANG == "es") m = "result_DeEs"; | |
else if (Config.LANG == "en" || Config.LANG == "it" || Config.LANG == "fr") m = "result_EnItFr"; | |
var a = ResourceMgr.getInstance(); | |
this._resource = a.getResource(a.ID_GAMEBASE); | |
this._anim = a.createAnime(a.ID_GAMEBASE, m, true, 0, 0, Config.PRI_RESULT); | |
this._anim.setNumLoop(1); | |
this._anim.proc(); | |
// The following code calculates the rank you will receive | |
// It starts by generating a number under 1000 | |
// Then the code loops over a sequence of numbers: 15, 27, 45, 10, 3 | |
// And sums it up at every iteration (so 15, 15+27=42, 42+45=87, 87+10=97, 97+3=100) | |
// It checks wheter the sum (times 10) is higher than the random number | |
// If so, voila, the rank is chosen | |
// Rank E: Under 150, Rank D: Under 420, Rank C: Under 870, Rank B: Under 970, Rank A: Under 1000 | |
// It now picks a random score you will get matching that rank and puts it in variable h | |
var p = Config.rank.concat(), | |
t = Zn.Util.randomInt(0, 999), | |
o = 0, | |
h = 0; | |
for (i = 0; i < p.length; i++) { | |
o += p[i]; | |
if (t < o * 10) { | |
d = i; | |
if (i > 0) h = Zn.Util.randomInt(Config.rankScore[i - 1] + 1, Config.rankScore[i]); | |
else h = Zn.Util.randomInt(10, Config.rankScore[i]); | |
break | |
} | |
} | |
// The following code prematurely generates 10 random scores | |
// It does so picking a random number between 1 and [the final score divided by 10] | |
// The score for the balloons are put in variable (array) g | |
// Undistributed points are put in variable k | |
var r = h / 10, | |
k = h, | |
g = []; | |
for (i = 0; i < 10; i++) { | |
var b = Zn.Util.randomInt(1, r); | |
k -= b; | |
g.push(b) | |
} | |
// The following code fine-tunes the score | |
// As long as there are points remaining, numbers are added to a randomly-choosen score | |
while (k > 0) { | |
b = Zn.Util.randomInt(1, 10); | |
if (b > h) b = h; | |
var j = Zn.Util.randomInt(0, 9); | |
if (g[j] + b <= 10) { | |
g[j] += b; | |
k -= b | |
} else { | |
b = 10 - g[j]; | |
g[j] = 10; | |
k -= b | |
} | |
} | |
// The rest of the code generates the Results-screen | |
this._aPoint = []; | |
this._aBalloon = []; | |
this._aBreak = []; | |
this._aScore = []; | |
this._score = 0; | |
var j = 1; | |
for (i = 0; i < 10; i++) { | |
j = i + 1; | |
var s = u[i], | |
l = g[i]; | |
this._score += l; | |
this._aScore.push(l); | |
var c = this._getObjPos("hit" + j), | |
q = "resultHit"; | |
if (Config.LANG == "de" && l == 1) q = "resultHit2"; | |
var f = a.createAnime(a.ID_GAMEBASE, q, true, 0, 0, Config.PRI_RESULT + 100); | |
f.setNumLoop(1); | |
f.setPos(c); | |
f.setVisible(false); | |
f.setPauseEnable(true); | |
this._aPoint.push(f); | |
var w = f.getSprite("num"); | |
this._resource.setSprImage(w, "num_" + l); | |
var n = a.createAnime(a.ID_GAMEOBJLV, s.getType() + "mini", true, 0, 0, Config.PRI_RESULT + 100); | |
n.setNumLoop(1); | |
n.setPos(c); | |
this._aBalloon.push(n); | |
var e = a.createAnime(a.ID_GAMEOBJ, "balloon_end", true, 0, 0, Config.PRI_RESULT + 100); | |
e.setNumLoop(1); | |
e.setScale(new Zn.T9CVector(TypeConfig.RESULT_BALLOON_SCALE, TypeConfig.RESULT_BALLOON_SCALE)); | |
e.setPos(c); | |
e.setVisible(false); | |
e.setPauseEnable(true); | |
this._aBreak.push(e) | |
} | |
c = this._getObjPos("num001"); | |
this._num1 = a.createAnime(a.ID_GAMEBASE, "num", true, 0, 0, Config.PRI_RESULT + 100); | |
this._num1.setTimeStep(0); | |
this._num1.setPos(c); | |
c = this._getObjPos("num010"); | |
this._num2 = a.createAnime(a.ID_GAMEBASE, "num", true, 0, 0, Config.PRI_RESULT + 100); | |
this._num2.setTimeStep(0); | |
this._num2.setPos(c); | |
this._num2.setVisible(false); | |
c = this._getObjPos("num100"); | |
this._num3 = a.createAnime(a.ID_GAMEBASE, "num", true, 0, 0, Config.PRI_RESULT + 100); | |
this._num3.setTimeStep(0); | |
this._num3.setPos(c); | |
this._num3.setVisible(false); | |
var d = 0; | |
if (this._score >= 80) d = 0; | |
else if (this._score >= 70) d = 1; | |
else if (this._score >= 50) d = 2; | |
else if (this._score >= 30) d = 3; | |
else d = 4; | |
var v = ["rankA", "rankB", "rankC", "rankD", "rankE"]; | |
this._rank = a.createAnime(a.ID_GAMEBASE, v[d], true, 0, 0, Config.PRI_RESULT + 100); | |
this._rank.setNumLoop(1); | |
this._rank.setVisible(false); | |
this._rank.setPauseEnable(true); | |
this._rankNum = (4 - d) / 4; | |
this._button = null; | |
this._bHit = false; | |
this._bExit = false; | |
this._phase = Result.RESULT_IN; | |
this._bSkip = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment