-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxp.js
85 lines (69 loc) · 1.34 KB
/
xp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function XP(){
return window.XPvars;
}
var XPvars = {
limits:[
100,
250,
500,
1000,
1
],
cutscene:false,
xpRemain:null,
countdown:0,
countdownLimit:120,
currentLevel:0,
currentXP:0,
lastCheckpoint:8,
lastCheckpointBuffer:8,
XPify:function(xp){
let _xp="" + xp;
while(_xp.length < 3){
_xp="0" + _xp;
}
return _xp;
},
update:function(){
if(F()){
this.lastCheckpointBuffer=F().threshold;
}else if(this.lastCheckpointBuffer > this.lastCheckpoint){
this.lastCheckpoint=this.lastCheckpointBuffer;
}
this.currentLevel=P().level;
this.currentXP=P().XP;
let limit=XP().limits[P().level];
if(P().XP >= limit){
this.cutscene=true;
}
if(this.cutscene){
if(this.xpRemain == null){
this.xpRemain=P().XP - limit;
}
if(P().XP > this.xpRemain){
P().XP-=Math.ceil((P().XP - this.xpRemain) / 30);
So().xp.play();
if(P().XP <= this.xpRemain){
P().XP=this.xpRemain;
this.countdown=this.countdownLimit;
}
}else{
if(--this.countdown > 0){
if(this.countdown == this.countdownLimit / 2){
P().level++;
P().gravity=-3;
Ef().new(
'Level up!',
P().position.X,
P().position.Y - 16
);
So().level.play();
}
}else{
this.xpRemain=null;
this.cutscene=false;
}
}
}
}
};