Compare commits
2 Commits
abee6d1206
...
297e6e4996
Author | SHA1 | Date | |
---|---|---|---|
297e6e4996
|
|||
9b3120c47b
|
@ -29,23 +29,32 @@ end
|
|||||||
-- if tt.init is defined, generated
|
-- if tt.init is defined, generated
|
||||||
-- new calls tt.init(ret) after
|
-- new calls tt.init(ret) after
|
||||||
-- ret is definitely not nil,
|
-- ret is definitely not nil,
|
||||||
-- before calling setmetatable.
|
-- after calling setmetatable.
|
||||||
-- use to initialize mutables.
|
-- use to initialize mutables.
|
||||||
--
|
--
|
||||||
-- if there was a previous new,
|
-- if there was a previous new,
|
||||||
-- it is invoked on the new
|
-- it is invoked before
|
||||||
-- object *after* more, because
|
-- setting tt's metatable, so
|
||||||
-- this works better with the
|
-- each new will see its
|
||||||
-- `more` impls i use.
|
-- inheritance chain.
|
||||||
function mknew(tt)
|
function mknew(tt)
|
||||||
local mt,oldnew,more = {__index=tt},tt.new,rawget(tt, "init")
|
local mt,oldinit,more = {__index=tt},tt.superinit,rawget(tt, "init")
|
||||||
tt.new=function(ret)
|
tt.new=function(ret)
|
||||||
if(not ret) ret = {}
|
if(not ret) ret = {}
|
||||||
if(more) more(ret)
|
|
||||||
if(oldnew) oldnew(ret)
|
|
||||||
setmetatable(ret, mt)
|
setmetatable(ret, mt)
|
||||||
|
if(oldinit) oldinit(ret)
|
||||||
|
if (more) more(ret)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if oldinit and more then
|
||||||
|
tt.superinit = function(ret)
|
||||||
|
oldinit(ret)
|
||||||
|
more(ret)
|
||||||
|
end
|
||||||
|
elseif more then
|
||||||
|
tt.superinit = more
|
||||||
|
end
|
||||||
return tt
|
return tt
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -719,6 +728,10 @@ bullet_base = mknew{ }
|
|||||||
|
|
||||||
gun_base = mknew{
|
gun_base = mknew{
|
||||||
shoot_ready = -32768,
|
shoot_ready = -32768,
|
||||||
|
new_clip = -32768,
|
||||||
|
clip_size = false,
|
||||||
|
clip_remain = 0,
|
||||||
|
clip_interval = 0x0.80,
|
||||||
icon = 20,
|
icon = 20,
|
||||||
ammobonus = 1,
|
ammobonus = 1,
|
||||||
|
|
||||||
@ -849,10 +862,22 @@ end
|
|||||||
|
|
||||||
function gun_base:shoot(x, y)
|
function gun_base:shoot(x, y)
|
||||||
if (gframe < self.shoot_ready) return false
|
if (gframe < self.shoot_ready) return false
|
||||||
|
local csz,crm = self.clip_size, self.clip_remain
|
||||||
|
if csz then
|
||||||
|
if crm < csz and gframe >= self.new_clip then
|
||||||
|
self.clip_remain = csz
|
||||||
|
self.new_clip = gframe + self.clip_interval
|
||||||
|
elseif crm == 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
if self.ammo then
|
if self.ammo then
|
||||||
if (self.ammo <= 0) return false
|
if (self.ammo <= 0) return false
|
||||||
self.ammo -= 1
|
self.ammo -= 1
|
||||||
end
|
end
|
||||||
|
if csz then
|
||||||
|
self.clip_remain -= 1
|
||||||
|
end
|
||||||
self.shoot_ready = gframe + self.cooldown
|
self.shoot_ready = gframe + self.cooldown
|
||||||
self:actually_shoot(x, y)
|
self:actually_shoot(x, y)
|
||||||
return true
|
return true
|
||||||
@ -1074,7 +1099,6 @@ vulcan_p = mknew(vulcan_e.new{
|
|||||||
|
|
||||||
vulcan_gun_e = mknew(gun_base.new{
|
vulcan_gun_e = mknew(gun_base.new{
|
||||||
icon = 37,
|
icon = 37,
|
||||||
enemy = false,
|
|
||||||
cooldown = 0x0.0003, -- frames between shots
|
cooldown = 0x0.0003, -- frames between shots
|
||||||
ammo = nil,
|
ammo = nil,
|
||||||
maxammo = nil,
|
maxammo = nil,
|
||||||
@ -1092,6 +1116,14 @@ vulcan_gun_e = mknew(gun_base.new{
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
machine_gun_e = mknew(vulcan_gun_e.new{
|
||||||
|
icon = 38,
|
||||||
|
clip_size = 12,
|
||||||
|
clip_interval = 0x0.005a,
|
||||||
|
dxs = {0, 0},
|
||||||
|
xoffs = {1, -1},
|
||||||
|
})
|
||||||
|
|
||||||
vulcan_gun_p = mknew(vulcan_gun_e.new{
|
vulcan_gun_p = mknew(vulcan_gun_e.new{
|
||||||
munition=vulcan_p,
|
munition=vulcan_p,
|
||||||
maxammo = 100,
|
maxammo = 100,
|
||||||
@ -1351,9 +1383,6 @@ xl_chasey=mknew(chasey.new{
|
|||||||
sspr(40, 0, 8, 8, self.x, self.y, 16, 16)
|
sspr(40, 0, 8, 8, self.x, self.y, 16, 16)
|
||||||
pal()
|
pal()
|
||||||
end,
|
end,
|
||||||
init = function(ship)
|
|
||||||
ship.main_gun=ship.main_gun or zap_gun_e.new{}
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- flotilla ships
|
-- flotilla ships
|
||||||
@ -1365,6 +1394,8 @@ ship_f = mknew(ship_m.new{
|
|||||||
-- no sparks
|
-- no sparks
|
||||||
hp = 0.5,
|
hp = 0.5,
|
||||||
xp = 0x0.0001,
|
xp = 0x0.0001,
|
||||||
|
fire_off_x = 4,
|
||||||
|
fire_off_y = 4,
|
||||||
|
|
||||||
maxspd = 3,
|
maxspd = 3,
|
||||||
thrust = 0.1,
|
thrust = 0.1,
|
||||||
@ -1375,6 +1406,9 @@ ship_f = mknew(ship_m.new{
|
|||||||
self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
|
self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
|
||||||
return 0,0,false,false
|
return 0,0,false,false
|
||||||
end,
|
end,
|
||||||
|
init = function(self)
|
||||||
|
if (self.gun_proto) self.main_gun = self.gun_proto.new()
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
ship_mook = mknew(ship_f.new{
|
ship_mook = mknew(ship_f.new{
|
||||||
@ -1388,12 +1422,14 @@ ship_defender = mknew(ship_f.new{
|
|||||||
ship_turret = mknew(ship_f.new{
|
ship_turret = mknew(ship_f.new{
|
||||||
sprite=106,
|
sprite=106,
|
||||||
xp = 0x0.0002,
|
xp = 0x0.0002,
|
||||||
|
gun_proto = machine_gun_e,
|
||||||
})
|
})
|
||||||
ship_skirmisher = mknew(ship_f.new{
|
ship_skirmisher = mknew(ship_f.new{
|
||||||
sprite=107,
|
sprite=107,
|
||||||
xp = 0x0.0004,
|
xp = 0x0.0004,
|
||||||
sparks = smokespark,
|
sparks = smokespark,
|
||||||
sparkodds = 3,
|
sparkodds = 3,
|
||||||
|
fire_off_y = 7,
|
||||||
})
|
})
|
||||||
|
|
||||||
function rnd_spawn_loc()
|
function rnd_spawn_loc()
|
||||||
|
Reference in New Issue
Block a user