| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- local SMG = extend(app.logic.weapon)
- ----------------
- -- Meta
- ----------------
- SMG.name = 'SMG'
- SMG.code = 'smg'
- SMG.text = 'It is a SMG. It pumps people full of lead.'
- SMG.type = 'weapon'
- ----------------
- -- Data
- ----------------
- SMG.image = data.media.graphics.smg
- SMG.scale = 1
- SMG.damage = 15
- SMG.fireTime = .13
- SMG.reloadTime = 1.6
- SMG.switchTime = .5
- SMG.clip = 12
- SMG.ammo = 120
- SMG.spread = .07
- SMG.recoil = 3
- SMG.anchorx = 15
- SMG.anchory = 7
- SMG.tipx = 14
- SMG.tipy = 0
- ----------------
- -- Crosshair
- ----------------
- function SMG:crosshair()
- local g, p, x, y = love.graphics, ctx.players:get(ctx.id), ctx.view:frameMouseX(), ctx.view:frameMouseY()
- local vx, vy, s = ctx.view:worldMouseX(), ctx.view:worldMouseY(), ctx.view.scale
- local d = math.distance(p.x, p.y, vx, vy)
- local len = 4 * s
- local dir = p.angle
- local dx, dy = p.class.handx * p.class.scale * s, p.class.handy * p.class.scale * s
- x = x + math.dx(dx, dir) - math.dy(dy, dir)
- y = y + math.dy(dx, dir) + math.dx(dy, dir)
- dx, dy = self.tipx * self.scale * s, self.tipy * self.scale * s
- x = x + math.dx(dx, dir) - math.dy(dy, dir)
- y = y + math.dy(dx, dir) + math.dx(dy, dir)
- local d2 = (math.distance(0, 0, p.class.handx, p.class.handy) * p.class.scale) + (math.distance(0, 0, self.tipx, self.tipy) * self.scale)
- x = x - math.dx(math.min(d2, d) * s, dir)
- y = y - math.dy(math.min(d2, d) * s, dir)
- local r = math.abs(math.atan(self.spread)) * math.max(math.distance(p.x, p.y, vx, vy) - d2, 0) * s
- local alpha = self.timers.switch > 0 and 128 or 255
- local factor = (1 - (math.clamp(tick - p.lastDamageDealt, 0, .4 / tickRate) / (.4 / tickRate))) ^ 2
- g.setColor(table.interpolate({255, 255, 255, alpha}, {255, 0, 0, alpha}, factor))
- g.circle('line', x, y, r )
- g.line(x, y - r - len, x, y - r + len)
- g.line(x - r - len, y, x - r + len, y)
- g.line(x + r - len, y, x + r + len, y)
- g.line(x, y + r - len, x, y + r + len)
- end
- return SMG
|