This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
351 lines (279 loc) · 9.03 KB
/
main.lua
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
-- ########################################
-- BOILERPLATE
-- ########################################
local mod = RegisterMod("Vazkii's Item Pack", 1);
local testing = false;
local itemClosedEye = Isaac.GetItemIdByName("Eye of the Subconscious");
local itemRemoteControl = Isaac.GetItemIdByName("Remote Control");
local itemBleedingEdgeTech = Isaac.GetItemIdByName("Bleeding Edge Tech");
local itemPlasticWorm = Isaac.GetItemIdByName("Action Worm");
-- ########################################
-- TESTING
-- ########################################
local debug = {};
local itemTestButton = nil;
local debuggingItem = nil;
function useTestItem()
local player = Isaac.GetPlayer(0);
local pos = Isaac.GetFreeNearPosition(player.Position, 1) + Vector(0, 16);
Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, debuggingItem, pos, Vector(0, 0), player);
end
function debugDisplay()
for i=1, #debug do
Isaac.RenderText(debug[i], 80, 30 + i * 10, 255, 255, 255, 255);
end
end
if testing then
itemTestButton = Isaac.GetItemIdByName("Testing Button");
debuggingItem = itemPlasticWorm;
mod:AddCallback(ModCallbacks.MC_USE_ITEM, useTestItem, itemTestButton);
mod:AddCallback(ModCallbacks.MC_POST_RENDER, debugDisplay);
end
-- ########################################
-- EYE OF THE SUBCONSCIOUS
-- ########################################
function updateClosedEye()
local player = Isaac.GetPlayer(0);
if player:HasCollectible(CollectibleType.COLLECTIBLE_BRIMSTONE) or (not player:CanShoot()) then
return;
end
local cd = player.MaxFireDelay * 2;
if player:HasCollectible(itemClosedEye) then
local entities = filter(Isaac.GetRoomEntities(), function(e)
return e:IsVulnerableEnemy();
end);
local closest = nil;
local dist = 10000;
for i = 1, #entities do
local e = entities[i];
player.FireDelay = cd + 1;
local diff = e.Position - player.Position;
if diff:Length() < dist then
closest = e;
dist = diff:Length();
end
end
if closest ~= nil and tickCheck(cd) then
local diff = closest.Position - player.Position;
diff = diff * (10 * player.ShotSpeed / diff:Length());
if player:HasCollectible(CollectibleType.COLLECTIBLE_TECHNOLOGY) or player:HasCollectible(itemBleedingEdgeTech) then
player:FireTechLaser(player.Position, 0, diff, true, false);
elseif player:HasCollectible(CollectibleType.COLLECTIBLE_TECH_X) then
player:FireTechXLaser(player.Position, diff, 1);
else
player:FireTear(player.Position, diff, false, true, false);
end
end
end
end
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, updateClosedEye);
-- ########################################
-- REMOTE CONTROL
-- ########################################
local hasRemoteControl = true;
function updateRemoteControl()
local player = Isaac.GetPlayer(0);
local hadRemoteControl = hasRemoteControl;
hasRemoteControl = player:HasCollectible(itemRemoteControl);
if hasRemoteControl then
if (not hadRemoteControl) then
player:AddBombs(5);
end
local entities = filter(Isaac.GetRoomEntities(), function(e)
return e.Type == EntityType.ENTITY_BOMBDROP;
end);
local joystick = player:GetShootingJoystick() * player.MoveSpeed;
for i = 1, #entities do
local e = entities[i];
e:AddVelocity(joystick);
end
end
end
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, updateRemoteControl);
-- ########################################
-- BLEEDING EDGE TECH
-- ########################################
local familiars = {
FamiliarVariant.ABEL,
FamiliarVariant.BBF,
FamiliarVariant.BLUEBABYS_ONLY_FRIEND,
FamiliarVariant.CAINS_OTHER_EYE,
FamiliarVariant.DEAD_BIRD,
FamiliarVariant.EVES_BIRD_FOOT,
FamiliarVariant.GB_BUG,
FamiliarVariant.GEMINI,
FamiliarVariant.GUPPYS_HAIRBALL,
FamiliarVariant.HUSHY,
FamiliarVariant.KING_BABY,
FamiliarVariant.LEECH,
FamiliarVariant.MULTIDIMENSIONAL_BABY,
FamiliarVariant.OBSESSED_FAN,
FamiliarVariant.PAPA_FLY,
FamiliarVariant.PEEPER,
FamiliarVariant.PUNCHING_BAG,
FamiliarVariant.ROBO_BABY_2,
FamiliarVariant.SCISSORS,
FamiliarVariant.SISSY_LONGLEGS,
FamiliarVariant.SMART_FLY,
FamiliarVariant.SPIDER_MOD,
FamiliarVariant.SUCCUBUS
};
local tech2Item = nil;
local hasBleedingEdgeTech = true;
function updateBleedingEdgeTech()
local player = Isaac.GetPlayer(0);
local hadBleedingEdgeTech = hasBleedingEdgeTech;
hasBleedingEdgeTech = player:HasCollectible(itemBleedingEdgeTech);
local cd = player.MaxFireDelay * 4;
if hasBleedingEdgeTech then
local entities = filter(Isaac.GetRoomEntities(), function(e)
return e.Type == EntityType.ENTITY_FAMILIAR and inArray(familiars, e.Variant);
end);
if #entities > 0 then
player.FireDelay = cd + 1;
local joystick = player:GetShootingJoystick();
if tickCheck(cd) and joystick:LengthSquared() > 0 then
for i = 1, #entities do
local e = entities[i];
local diff = e.Position - player.Position;
player:FireTechLaser(player.Position, 0, diff, false, false);
end
end
end
end
end
function bleedingEdgeTechPlayerInitHack(paramPlayer)
tech2Item = getItem(CollectibleType.COLLECTIBLE_TECHNOLOGY, tech2Item);
end
function bleedingEdgeTechPostRenderHack()
if tech2Item ~= nil then
local player = Isaac.GetPlayer(0);
if player:HasCollectible(itemBleedingEdgeTech) then
player:AddCostume(tech2Item, false);
end
end
end
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, updateBleedingEdgeTech);
mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, bleedingEdgeTechPlayerInitHack);
mod:AddCallback(ModCallbacks.MC_POST_RENDER, bleedingEdgeTechPostRenderHack);
-- ########################################
-- ACTION WORM
-- ########################################
local plasticWormTicks = 0;
local plasticWormX = 0;
local plasticWormY = 0;
local plasticWormMovement = {};
local plasticWormTracked = {};
local hasPlasticWorm = false;
function usePlasticWorm()
local player = Isaac.GetPlayer(0);
plasticWormX = player.Position.X;
plasticWormY = player.Position.Y;
plasticWormTicks = 50;
plasticWormMovement = {};
plasticWormTracked = {};
end
function updatePlasticWorm()
local player = Isaac.GetPlayer(0);
local active = player:GetActiveItem();
local hadPlasticWorm = hasPlasticWorm;
hasPlasticWorm = active == itemPlasticWorm;
local rangeBonus = 20;
if hadPlasticWorm and (not hasPlasticWorm) then
player.TearHeight = player.TearHeight + rangeBonus;
elseif hasPlasticWorm and (not hadPlasticWorm) then
player.TearHeight = player.TearHeight - rangeBonus;
end
if plasticWormTicks > 0 then
local joystick = player:GetShootingJoystick() * player.ShotSpeed * 10;
plasticWormX = plasticWormX + joystick.X;
plasticWormY = plasticWormY + joystick.Y;
plasticWormTicks = plasticWormTicks - 1;
player.FireDelay = 1;
local pos = Vector(plasticWormX, plasticWormY);
Game():SpawnParticles(pos, 88, 1, 0, Color(1, 1, 1, 1, 1, 1, 1), 0);
plasticWormMovement[#plasticWormMovement + 1] = pos;
end
if hasPlasticWorm and #plasticWormMovement > 0 then
local entities = filter(Isaac.GetRoomEntities(), function(e)
return e.Type == EntityType.ENTITY_TEAR;
end);
for i = 1, #entities do
local e = entities[i];
local inArray = false;
for k, v in pairs(plasticWormTracked) do
if v.EntityData == e:GetData() then
inArray = true;
local ticks = v.Ticks;
v.Ticks = ticks + 1;
ticks = ticks + 2;
if ticks < #plasticWormMovement then
local diff = plasticWormMovement[ticks] - plasticWormMovement[ticks - 1];
diff = rotateVector(diff, v.Direction);
e.Velocity = diff;
end
end
end
if (not inArray) then
local track = {};
track["Ticks"] = 0;
track["EntityData"] = e:GetData();
track["Direction"] = player:GetFireDirection();
plasticWormTracked[#plasticWormTracked + 1] = track;
end
end
end
end
function initPlasticWorm()
plasticWormMovement = {};
plasticWormTracked = {};
hasPlasticWorm = false;
end
mod:AddCallback(ModCallbacks.MC_USE_ITEM, usePlasticWorm, itemPlasticWorm);
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, updatePlasticWorm);
mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, initPlasticWorm);
-- ########################################
-- HELPERS
-- ########################################
function tickCheck(cd)
return Isaac:GetFrameCount() % cd == 0;
end
function filter(arr, pred)
local newArr = {};
for i = 1, #arr do
local val = arr[i];
if pred(val) then
newArr[#newArr + 1] = val;
end
end
return newArr;
end
function inArray(arr, obj)
for k, v in ipairs(arr) do
if v == obj then
return true;
end
end
return false;
end
function getItem(collectible, currItem)
if currItem ~= nil then
return currItem;
end
local player = Isaac.GetPlayer(0);
player:GetEffects():AddCollectibleEffect(collectible, true);
local effect = player:GetEffects():GetCollectibleEffect(collectible);
return effect.Item;
end
function rotateVector(vec, dir)
if dir == Direction.UP then
return vec * -1;
elseif dir == Direction.RIGHT then
local tempX = vec.X;
vec.X = vec.Y;
vec.Y = -tempX;
elseif dir == Direction.LEFT then
return rotateVector(vec, Direction.RIGHT) * -1;
end
return vec;
end