-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprostg.dnh
267 lines (228 loc) · 6.31 KB
/
prostg.dnh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#include "./procon.dnh"
// STG FRAME:
// top-left (16, 16)
// dimensions 468x568
function getPower {
return GetCommonData("Power", 0);
}
task setPower(p) {
SetCommonData("Power", p);
}
function createStraightLaserA1(x, y, angle, len, width, deleteTime, graphicId, delay) {
let l = CreateStraightLaserA1(x, y, angle, len, width, deleteTime, graphicId, delay);
ObjLaser_SetGrazeInvalidFrame(l, 3);
return l;
}
function createLooseLaserA1(x, y, speed, angle, len, width, graphicId, delay) {
let l = CreateLooseLaserA1(x, y, speed, angle, len, width, graphicId, delay);
ObjLaser_SetGrazeInvalidFrame(l, 3);
return l;
}
function createCurveLaserA1(x, y, speed, angle, len, width, graphicId, delay) {
let l = CreateCurveLaserA1(x, y, speed, angle, len, width, graphicId, delay);
ObjLaser_SetGrazeInvalidFrame(l, 3);
ObjCrLaser_SetTipDecrement(l, 0);
return l;
}
function getRadius {
return GetCommonData("Radius", 5);
}
task setRadius(p) {
SetCommonData("Radius", p);
}
function getValue {
return GetCommonData("Value", 0.01);
}
task setValue(p) {
SetCommonData("Value", p);
}
function getTrancePercentage {
return GetCommonData("Trance", 0);
}
task setTrancePercentage(p) {
SetCommonData("Trance", p);
}
task addTrancePercentage(p) {
setTrancePercentage(getTrancePercentage + p);
}
function isTranceActive {
return GetCommonData("IsTrance", false);
}
task activateTrance(active) {
SetCommonData("IsTrance", active);
}
task hitbox {
let path = GetCurrentScriptDirectory ~ "resource/hurtbox.png";
let pathc = GetCurrentScriptDirectory ~ "resource/hurtbox_center.png";
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, path);
ObjSprite2D_SetSourceRect(obj, 0, 0, 41, 41);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriority(obj, 0.79);
let objc = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(objc, pathc);
ObjSprite2D_SetSourceRect(objc, 0, 0, 7, 7);
ObjSprite2D_SetDestCenter(objc);
Obj_SetRenderPriority(objc, 0.79);
let t = 0;
loop {
ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
ObjRender_SetPosition(objc, GetPlayerX, GetPlayerY, 0);
ObjRender_SetAngleXYZ(obj, 0, 0, t);
let showHitbox = isFocused && (GetPlayerState == STATE_NORMAL);
Obj_SetVisible(obj, showHitbox);
Obj_SetVisible(objc, showHitbox);
t += 3;
yield;
}
}
function createItemU1(type, x, y) {
let i = CreateItemU1(type, x, y, 0);
ObjItem_SetRenderScoreEnable(i, false);
return i;
}
function isFocused {
return GetVirtualKeyState(VK_SLOWMOVE) != KEY_FREE;
}
// Causes the shot to home.
task home(shot) {
while (!Obj_IsDeleted(shot)) {
let enemy = nearestEnemy(shot);
if (enemy != ID_INVALID) {
let angle = getAngleTo(shot, enemy);
let old = ObjMove_GetAngle(shot);
let diff = (angle - old + 360) % 360;
if (diff < 180) {ObjMove_SetAngle(shot, old + 2);}
if (diff > 180) {ObjMove_SetAngle(shot, old - 2);}
}
yield;
}
}
task homeToPlayer(shot) {
while (!Obj_IsDeleted(shot)) {
let angle = GetAngleToPlayer(shot);
let old = ObjMove_GetAngle(shot);
let diff = (angle - old + 360) % 360;
if (diff < 180) {ObjMove_SetAngle(shot, old + 2);}
if (diff > 180) {ObjMove_SetAngle(shot, old - 2);}
yield;
}
}
task homeToPlayerS(shot, speed) {
while (!Obj_IsDeleted(shot)) {
let angle = GetAngleToPlayer(shot);
let old = ObjMove_GetAngle(shot);
let diff = (angle - old + 360) % 360;
if (diff < 180) {ObjMove_SetAngle(shot, old + speed);}
if (diff > 180) {ObjMove_SetAngle(shot, old - speed);}
yield;
}
}
task homeToPlayerD(shot, delay, interval) {
while (!Obj_IsDeleted(shot)) {
let angle = GetAngleToPlayer(shot);
let old = ObjMove_GetAngle(shot);
task nudge(amt) {
wait(delay);
ObjMove_SetAngle(shot, old + amt);
}
let diff = (angle - old + 360) % 360;
if (diff < 180) {nudge(2 * interval);}
if (diff > 180) {nudge(-2 * interval);}
wait(interval);
}
}
// Returns the ID of the nearest enemy, or ID_INVALID if there are none.
function nearestEnemy(obj) {
let enemies = GetAllEnemyID;
let len = length(enemies);
let nearest = ID_INVALID;
let distance = 99999;
ascent (i in 0..len) {
let enemy = enemies[i];
let d = GetObjectDistance(obj, enemy);
if (d < distance) {
distance = d;
nearest = enemy;
}
}
return nearest;
}
// Gets the angle from obj1 to obj2.
function getAngleTo(obj1, obj2) {
let x1 = ObjMove_GetX(obj1);
let x2 = ObjMove_GetX(obj2);
let y1 = ObjMove_GetY(obj1);
let y2 = ObjMove_GetY(obj2);
return atan2(y2 - y1, x2 - x1) % 360;
}
function getAngleToXY(obj1, x2, y2) {
let x1 = ObjMove_GetX(obj1);
let y1 = ObjMove_GetY(obj1);
return atan2(y2 - y1, x2 - x1) % 360;
}
function getAngleTwoPoints(x1, y1, x2, y2) {
return atan2(y2 - y1, x2 - x1) % 360;
}
function getDistanceTo(obj1, obj2) {
let x1 = ObjMove_GetX(obj1);
let x2 = ObjMove_GetX(obj2);
let y1 = ObjMove_GetY(obj1);
let y2 = ObjMove_GetY(obj2);
return ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ 0.5;
}
function getDistanceToXY(obj1, x2, y2) {
let x1 = ObjMove_GetX(obj1);
let y1 = ObjMove_GetY(obj1);
return ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ 0.5;
}
function getDistanceTwoPoints(x1, y1, x2, y2) {
return ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ 0.5;
}
function getDistanceToPlayer(obj) {
return getDistanceTo(obj, GetPlayerObjectID);
}
task shake(ticks) {
if (GetCommonData("ShakeDisabled", false)) {return;}
loop (ticks) {
Set2DCameraFocusX(GetStgFrameWidth / 2 + rand(-8, 8));
Set2DCameraFocusY(GetStgFrameHeight / 2 + rand(-8, 8));
yield;
}
Reset2DCamera;
}
function getRank {
return GetCommonData("Rank", getDifficulty);
}
task setRank(d) {
SetCommonData("Rank", d);
}
function getStartRank {
return GetCommonData("StartRank", getDifficulty);
}
task setStartRank(d) {
SetCommonData("StartRank", d);
}
function getMinRank {
return 0.7 * (getDifficulty + 1) - 1;
}
task addRank(r) {
let n = getRank + r;
let s = getStartRank;
n = min(s + 0.5, n);
setRank(n);
}
// Code thanks to Sparen (with some formatting changes)
task delayLaser(x, y, ang, l, w, dt, graph, delay) {
let objlaser = CreateStraightLaserA1(x, y, ang, l, w, dt, graph, delay);
ObjStLaser_SetSource(objlaser, false);
loop (delay - 1) {//So that the graphic never enlarges.
// Default kill to prevent (0, 0) spawning
//if (ObjEnemy_GetInfo(GetEnemyBossObjectID, INFO_LIFE) <= 0) {Obj_Delete(objlaser); return;}
yield;
}
Obj_Delete(objlaser);
}
function getInvincibility {
return GetCommonData("Invincibility", 0);
}