committing for Dany0, added team-based guns
This commit is contained in:
parent
1e13444f40
commit
7f166d5eae
@ -408,6 +408,7 @@ mdl_Xcube_bone = client.model_bone_find(mdl_cube, "bnXcube")
|
|||||||
mdl_spade, mdl_spade_bone = client.model_load_pmf("pkg/base/pmf/spade.pmf"), 0
|
mdl_spade, mdl_spade_bone = client.model_load_pmf("pkg/base/pmf/spade.pmf"), 0
|
||||||
mdl_block, mdl_block_bone = client.model_load_pmf("pkg/base/pmf/block.pmf"), 0
|
mdl_block, mdl_block_bone = client.model_load_pmf("pkg/base/pmf/block.pmf"), 0
|
||||||
weapon_models[WPN_RIFLE] = client.model_load_pmf("pkg/base/pmf/rifle.pmf")
|
weapon_models[WPN_RIFLE] = client.model_load_pmf("pkg/base/pmf/rifle.pmf")
|
||||||
|
weapon_models[WPN_LEERIFLE] = client.model_load_pmf("pkg/base/pmf/leerifle.pmf")
|
||||||
mdl_nade, mdl_nade_bone = client.model_load_pmf("pkg/base/pmf/nade.pmf"), 0
|
mdl_nade, mdl_nade_bone = client.model_load_pmf("pkg/base/pmf/nade.pmf"), 0
|
||||||
|
|
||||||
mdl_tent, mdl_tent_bone = client.model_load_pmf("pkg/base/pmf/tent.pmf"), 0
|
mdl_tent, mdl_tent_bone = client.model_load_pmf("pkg/base/pmf/tent.pmf"), 0
|
||||||
|
@ -74,6 +74,8 @@ MODE_NADE_BDAMP = 1.0
|
|||||||
MODE_NADE_RANGE = 8.0
|
MODE_NADE_RANGE = 8.0
|
||||||
MODE_NADE_DAMAGE = 500.0
|
MODE_NADE_DAMAGE = 500.0
|
||||||
|
|
||||||
|
MODE_TEAM_GUNS = true
|
||||||
|
|
||||||
MODE_MINIMAP_RCIRC = false
|
MODE_MINIMAP_RCIRC = false
|
||||||
MODE_ENABLE_MINIMAP = true
|
MODE_ENABLE_MINIMAP = true
|
||||||
MODE_MAP_TRACERS = false -- TODO!
|
MODE_MAP_TRACERS = false -- TODO!
|
||||||
@ -138,6 +140,7 @@ end
|
|||||||
|
|
||||||
-- weapons
|
-- weapons
|
||||||
WPN_RIFLE = 1
|
WPN_RIFLE = 1
|
||||||
|
WPN_LEERIFLE = 2
|
||||||
|
|
||||||
weapon_models = {}
|
weapon_models = {}
|
||||||
|
|
||||||
@ -346,12 +349,212 @@ weapons = {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return this
|
||||||
|
end,
|
||||||
|
[WPN_LEERIFLE] = function (plr)
|
||||||
|
local this = {} this.this = this
|
||||||
|
|
||||||
|
this.cfg = {
|
||||||
|
dmg = {
|
||||||
|
head = 100,
|
||||||
|
body = 67,
|
||||||
|
legs = 49,
|
||||||
|
},
|
||||||
|
|
||||||
|
ammo_clip = 1,
|
||||||
|
ammo_reserve = 25,
|
||||||
|
time_fire = 1,
|
||||||
|
time_reload = 2.5,
|
||||||
|
|
||||||
|
recoil_x = 0.00001,
|
||||||
|
recoil_y = -0.5,
|
||||||
|
|
||||||
|
name = "Lee-Enfield Rifle"
|
||||||
|
}
|
||||||
|
|
||||||
|
function this.restock()
|
||||||
|
this.ammo_clip = this.cfg.ammo_clip
|
||||||
|
this.ammo_reserve = this.cfg.ammo_reserve
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.reset()
|
||||||
|
this.t_fire = nil
|
||||||
|
this.t_reload = nil
|
||||||
|
this.reloading = false
|
||||||
|
this.restock()
|
||||||
|
end
|
||||||
|
|
||||||
|
this.reset()
|
||||||
|
|
||||||
|
local function prv_fire(sec_current)
|
||||||
|
local xlen, ylen, zlen
|
||||||
|
xlen, ylen, zlen = common.map_get_dims()
|
||||||
|
|
||||||
|
if client then
|
||||||
|
tracer_add(plr.x,plr.y,plr.z,
|
||||||
|
plr.angy,plr.angx)
|
||||||
|
|
||||||
|
client.wav_play_global(wav_rifle_shot, plr.x, plr.y, plr.z)
|
||||||
|
end
|
||||||
|
|
||||||
|
local sya = math.sin(plr.angy)
|
||||||
|
local cya = math.cos(plr.angy)
|
||||||
|
local sxa = math.sin(plr.angx)
|
||||||
|
local cxa = math.cos(plr.angx)
|
||||||
|
local fwx,fwy,fwz
|
||||||
|
fwx,fwy,fwz = sya*cxa, sxa, cya*cxa
|
||||||
|
|
||||||
|
-- perform a trace
|
||||||
|
local d,cx1,cy1,cz1,cx2,cy2,cz2
|
||||||
|
d,cx1,cy1,cz1,cx2,cy2,cz2
|
||||||
|
= trace_map_ray_dist(plr.x+sya*0.4,plr.y,plr.z+cya*0.4, fwx,fwy,fwz, 127.5)
|
||||||
|
d = d or 127.5
|
||||||
|
|
||||||
|
-- see if there's anyone we can kill
|
||||||
|
local hurt_idx = nil
|
||||||
|
local hurt_part = nil
|
||||||
|
local hurt_part_idx = 0
|
||||||
|
local hurt_dist = d*d
|
||||||
|
local i,j
|
||||||
|
|
||||||
|
for i=1,players.max do
|
||||||
|
local p = players[i]
|
||||||
|
if p and p ~= plr and p.alive then
|
||||||
|
local dx = p.x-plr.x
|
||||||
|
local dy = p.y-plr.y+0.1
|
||||||
|
local dz = p.z-plr.z
|
||||||
|
|
||||||
|
for j=1,3 do
|
||||||
|
local dd = dx*dx+dy*dy+dz*dz
|
||||||
|
|
||||||
|
local dotk = dx*fwx+dy*fwy+dz*fwz
|
||||||
|
local dot = math.sqrt(dd-dotk*dotk)
|
||||||
|
if dot < 0.55 and dd < hurt_dist then
|
||||||
|
hurt_idx = i
|
||||||
|
hurt_dist = dd
|
||||||
|
hurt_part_idx = j
|
||||||
|
hurt_part = ({"head","body","legs"})[j]
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
dy = dy + 1.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if hurt_idx then
|
||||||
|
if server then
|
||||||
|
players[hurt_idx].gun_damage(
|
||||||
|
hurt_part, this.cfg.dmg[hurt_part], plr)
|
||||||
|
else
|
||||||
|
common.net_send(nil, common.net_pack("BBB"
|
||||||
|
, 0x13, hurt_idx, hurt_part_idx))
|
||||||
|
plr.show_hit()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if client then
|
||||||
|
common.net_send(nil, common.net_pack("BBB"
|
||||||
|
, 0x13, 0, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
if cx2 and cy2 <= ylen-3 then
|
||||||
|
bhealth_damage(cx2,cy2,cz2,MODE_BLOCK_DAMAGE_RIFLE * 10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- apply recoil
|
||||||
|
-- attempting to emulate classic behaviour provided i have it right
|
||||||
|
plr.recoil(sec_current, this.cfg.recoil_y, this.cfg.recoil_x)
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.reload()
|
||||||
|
if this.ammo_clip ~= this.cfg.ammo_clip then
|
||||||
|
if this.ammo_reserve ~= 0 then
|
||||||
|
if not this.reloading then
|
||||||
|
this.reloading = true
|
||||||
|
client.wav_play_global(wav_rifle_reload, plr.x, plr.y, plr.z)
|
||||||
|
common.net_send(nil, common.net_pack("BB", 0x1D, 0))
|
||||||
|
plr.zooming = false
|
||||||
|
this.t_reload = nil
|
||||||
|
end end end
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.click(button, state)
|
||||||
|
if button == 1 then
|
||||||
|
-- LMB
|
||||||
|
if this.ammo_clip > 0 then
|
||||||
|
this.firing = state
|
||||||
|
else
|
||||||
|
this.firing = false
|
||||||
|
-- TODO: play sound
|
||||||
|
end
|
||||||
|
elseif button == 3 then
|
||||||
|
-- RMB
|
||||||
|
if hold_to_zoom then
|
||||||
|
plr.zooming = state
|
||||||
|
else
|
||||||
|
if state and not this.reloading then
|
||||||
|
plr.zooming = not plr.zooming
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.get_model()
|
||||||
|
return weapon_models[WPN_LEERIFLE]
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.draw(px, py, pz, ya, xa, ya2)
|
||||||
|
client.model_render_bone_global(this.get_model(), 0,
|
||||||
|
px, py, pz, ya, xa, ya2, 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.tick(sec_current, sec_delta)
|
||||||
|
if this.reloading then
|
||||||
|
if not this.t_reload then
|
||||||
|
this.t_reload = sec_current + this.cfg.time_reload
|
||||||
|
end
|
||||||
|
|
||||||
|
if sec_current >= this.t_reload then
|
||||||
|
local adelta = this.cfg.ammo_clip - this.ammo_clip
|
||||||
|
if adelta > this.ammo_reserve then
|
||||||
|
adelta = this.ammo_reserve
|
||||||
|
end
|
||||||
|
this.ammo_reserve = this.ammo_reserve - adelta
|
||||||
|
this.ammo_clip = this.ammo_clip + adelta
|
||||||
|
this.t_reload = nil
|
||||||
|
this.reloading = false
|
||||||
|
plr.arm_rest_right = 0
|
||||||
|
end
|
||||||
|
elseif this.firing and this.ammo_clip == 0 then
|
||||||
|
this.firing = false
|
||||||
|
elseif this.firing and ((not this.t_fire) or sec_current >= this.t_fire) then
|
||||||
|
prv_fire(sec_current)
|
||||||
|
|
||||||
|
this.t_fire = this.t_fire or sec_current
|
||||||
|
this.t_fire = this.t_fire + this.cfg.time_fire
|
||||||
|
if this.t_fire < sec_current then
|
||||||
|
this.t_fire = sec_current
|
||||||
|
end
|
||||||
|
|
||||||
|
this.ammo_clip = this.ammo_clip - 1
|
||||||
|
|
||||||
|
-- TODO: poll: do we want to require a new click per shot?
|
||||||
|
-- nope - rakiru
|
||||||
|
end
|
||||||
|
|
||||||
|
if this.t_fire and this.t_fire < sec_current then
|
||||||
|
this.t_fire = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return this
|
return this
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
weapons_enabled = {}
|
weapons_enabled = {}
|
||||||
weapons_enabled[WPN_RIFLE] = true
|
weapons_enabled[WPN_RIFLE] = true
|
||||||
|
weapons_enabled[WPN_LEERIFLE] = true
|
||||||
|
|
||||||
-- teams
|
-- teams
|
||||||
TEAM_INTEL_LIMIT = 10
|
TEAM_INTEL_LIMIT = 10
|
||||||
|
@ -38,13 +38,18 @@ function slot_add(sockfd, tidx, wpn, name)
|
|||||||
-- TODO: actually balance this properly!
|
-- TODO: actually balance this properly!
|
||||||
tidx = (i-1) % 2
|
tidx = (i-1) % 2
|
||||||
end
|
end
|
||||||
|
if MODE_TEAM_GUNS then
|
||||||
|
_wpn = tidx + 1
|
||||||
|
else
|
||||||
|
_wpn = WPN_RIFLE
|
||||||
|
end
|
||||||
players[i] = new_player({
|
players[i] = new_player({
|
||||||
name = name,
|
name = name,
|
||||||
--[[squad = squads[(i-1) % 2][
|
--[[squad = squads[(i-1) % 2][
|
||||||
(math.floor((i-1)/2) % 4)+1],]]
|
(math.floor((i-1)/2) % 4)+1],]]
|
||||||
squad = nil,
|
squad = nil,
|
||||||
team = tidx, -- 0 == blue, 1 == green
|
team = tidx, -- 0 == blue, 1 == green
|
||||||
weapon = WPN_RIFLE,
|
weapon = _wpn,
|
||||||
pid = i,
|
pid = i,
|
||||||
})
|
})
|
||||||
return i
|
return i
|
||||||
|
Loading…
x
Reference in New Issue
Block a user