vulcan_gun as trig gun
causes x offset to reverse for negative aim; may need to be careful with how I make aiming guns actually work, but this should work for deriving player guns from enemy guns (by using negative aim)!
This commit is contained in:
		| @@ -876,7 +876,7 @@ end | ||||
|  | ||||
| trig_gun = mknew(gun_base.new{ | ||||
|  veloc = 1, | ||||
|  aim = 0.75, -- down; 0.25 is up | ||||
|  aim = 0.75, -- down; 0.25, or -0.75, is up | ||||
|  shot_idx = 0, | ||||
|  -- shots: list<list<[3]num>> | ||||
|  --  describing a cycling | ||||
| @@ -887,10 +887,10 @@ trig_gun = mknew(gun_base.new{ | ||||
|  --  1 ammo; sequential | ||||
|  -- each shot: angle (turns, | ||||
|  --  relative to `aim`), | ||||
|  --  velocity, firing x-offset; | ||||
|  --  if velocity is nil, use | ||||
|  --  self.veloc instead; | ||||
|  --  if x-offset is nil, use 0 | ||||
|  --  firing x-offset, velocity; | ||||
|  --   if x-offset is nil, use 0; | ||||
|  --   if velocity is nil, use | ||||
|  --    self.veloc instead | ||||
|  init = function(self) | ||||
|   if (not self.shots) self.shots = {{{0}}} | ||||
|  end | ||||
| @@ -902,8 +902,11 @@ function trig_gun:actually_shoot(x, y) | ||||
|  self.shot_idx = idx | ||||
|  shots = shots[idx] | ||||
|  for s in all(shots) do | ||||
|   local a,v,xo = unpack(s) | ||||
|   local a,xo,v = unpack(s) | ||||
|   v = v or veloc | ||||
|   xo = xo or 0 | ||||
|   -- reverse x-offset for negative base angle | ||||
|   if (aim < 0) xo = -xo | ||||
|   a += aim | ||||
|   -- todo: switch munition | ||||
|   --  depending on angle | ||||
| @@ -1124,48 +1127,37 @@ vulcan_e = mknew(bullet_base.new{ | ||||
|  y_off = 0, | ||||
|   | ||||
|  damage = 0.5, | ||||
|  -- dx from gun | ||||
|  dy = 2, | ||||
|  category=enemy_blt_cat | ||||
| }) | ||||
|  | ||||
| vulcan_p = mknew(vulcan_e.new{ | ||||
|  sprite=22, | ||||
|  y_off = 4, | ||||
|  dy = -4, | ||||
|  category=player_blt_cat | ||||
| }) | ||||
|  | ||||
| vulcan_gun_e = mknew(gun_base.new{ | ||||
| vulcan_gun_e = mknew(trig_gun.new{ | ||||
|  icon = 37, | ||||
|  cooldown = 0x0.0003, -- frames between shots | ||||
|  ammo = nil, | ||||
|  maxammo = nil, | ||||
|  munition=vulcan_e, | ||||
|  dxs = {0.35, -0.35, -0.7, 0.7, 0.35, -0.35}, | ||||
|  xoffs = {1, 0, -1, 1, 0, -1}, | ||||
|  dxidx = 1, | ||||
|  actually_shoot = function(self, x, y) | ||||
|   local b = self.munition.new{ | ||||
|    dx = self.dxs[self.dxidx], | ||||
|   } | ||||
|   b:spawn_at(self.xoffs[self.dxidx]+x,y) | ||||
|   self.dxidx += 1 | ||||
|   if (self.dxidx > #self.dxs) self.dxidx = 1 | ||||
|  end | ||||
|  veloc = 2, | ||||
|  shots = {{{0.02, 2}}, {{-0.02,0}}, {{-0.03, -2}}, {{0.03, 2}}, {{0.02, 0}}, {{-0.02, -2}}} | ||||
| }) | ||||
|  | ||||
| machine_gun_e = mknew(vulcan_gun_e.new{ | ||||
|  icon = 38, | ||||
|  clip_size = 12, | ||||
|  clip_interval = 0x0.005a, | ||||
|  dxs = {0, 0}, | ||||
|  xoffs = {1, -1}, | ||||
|  shots = {{{0, 2}}, {{0, -2}}} | ||||
| }) | ||||
|  | ||||
| vulcan_gun_p = mknew(vulcan_gun_e.new{ | ||||
|  munition=vulcan_p, | ||||
|  maxammo = 100, | ||||
|  aim=-0.75, | ||||
|  veloc=4, | ||||
|  hdr = "vULCAN", | ||||
|  body = [[---------GUN | ||||
|  | ||||
| @@ -1880,6 +1872,7 @@ end | ||||
|  | ||||
| -- add a new gun | ||||
| function spec_gun_opts() | ||||
|  -- todo: avoid duplicates | ||||
|  return pick(spec_gunt, 2) | ||||
| end | ||||
|  | ||||
| @@ -1901,7 +1894,6 @@ end | ||||
|  | ||||
| -- ordinary upgrades | ||||
| function small_opts() | ||||
|  -- todo: include gun opts | ||||
|  if(not primary_ship.special_guns) return pick(primary_ship:small_upgrade_opts(), 2) | ||||
|  local opts = {rnd(primary_ship:small_upgrade_opts())} | ||||
|  for g in all(primary_ship.special_guns) do | ||||
| @@ -1982,7 +1974,10 @@ function rearm_mode:shuffle() | ||||
|  -- until the upgrade deck | ||||
|  -- is a thing that exists | ||||
|  local lev = primary_ship.level + 1 | ||||
|  if lev == 4 or lev == 12 then | ||||
|  | ||||
|  -- for testing: more guns really early | ||||
|  -- if lev == 4 or lev == 12 then | ||||
|  if lev == 2 or lev == 3 then | ||||
|   self.options = spec_gun_opts() | ||||
|  elseif lev % 4 == 0 then | ||||
|   self.options = big_opts() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user