-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubsystem.lua
More file actions
107 lines (95 loc) · 2.86 KB
/
Copy pathsubsystem.lua
File metadata and controls
107 lines (95 loc) · 2.86 KB
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
-- sub systems
subsystem = {}
function subsystem.toss(target)
target:attach('toss', target.sprite)
if target:has('sound_on_despawn') then
sfx(target.sound_on_despawn)
end
target:detach('physics')
target:detach('offensive_collider')
target:detach('defensive_collider')
target:detach('sprite')
target:detach('ai_shoot_smrt')
target:detach('ai_shoot_dumb')
target:detach('ai_boss')
end
function subsystem.crush(target)
change_anim(target, 'crushed', false)
target:detach('iframes')
target:detach('health')
target:detach('physics')
target:detach('offensive_collider')
target:detach('defensive_collider')
target:detach('crushable')
target:attach('despawn', 150)
end
function subsystem.smash_collide(source)
particle.create('smash', source.x + 10, source.y + 21, 10)
source:detach('smash')
source.offensive_collider.enabled = false
sfx(33)
sfx(34)
if source:has({'player', 'health'}) then
shake.screen(source.health.current * 0.75 + 0.25, lerp(3, 5, source.health.current / 16))
end
source.physics.smashing = -1
end
function subsystem.bounce(source, target)
if target:has('physics') then
target.physics.vx += source.bounce.vx
target.physics.vy = source.bounce.vy
end
-- smash again
subsystem.smash_collide(target)
end
function subsystem.score(source, target)
local s = score.calculate(source.scorable, target.physics.smashing, hero.health.current)
-- printh('base score: ' .. source.scorable .. ' smash frames: ' .. target.physics.smashing .. ' health: ' .. target.health.current .. ' total: ' .. s)
score.add(s)
end
function subsystem.boss_complete(source)
hero:attach('autorun', 30)
hero:detach('timer')
end
function subsystem.knock(source, target)
target.physics.vx = source.knockback.vx
target.physics.vy = source.knockback.vy
end
function subsystem.throw_code(source)
local m = min(16, #source.collector.letters)
local r = rnd(1)
for i = 1, m do
local vx = sin(i / m + r) * 2
local vy = cos(i / m + r) * 2
assemblage.collectable('code', source.x, source.y, sub(source.collector.letters, i, i), vx, vy)
end
source.health.current = 1
source.collector.letters = ''
sfx(41)
end
function subsystem.push_button(source)
hero:attach('autorun', 30)
sfx(36)
change_anim(source, 'pressed')
source:detach('defensive_collider')
return true
end
function subsystem.boss_projectile_attack(e, timeComparison, variance)
variance = variance or 1
if e:has('frames') then change_anim(e, 'shooting', true) end
local m = (t() - hero.timer.start_time > timeComparison) and 2 or 0
local w = 0
if variance != 1 then w = flr(rnd(2)) end
if w == 0 then
assemblage.enemy_bullet(e, e.x, e.y, -3, 0, false)
else
assemblage.enemy_bullet(e, e.x, e.y, -3, 0, false, -2)
end
if e:has('frames') then change_anim(e, 'idle', false) end
end
function subsystem.projectile_redirect(e)
e.physics.vx *= -1
e:detach('enemy_team')
e:detach('parent')
e:attach('parent', hero)
end