nades do player damage now; added /squad

This commit is contained in:
Ben Russell (300178622) 2012-12-18 16:27:53 +13:00
parent 1ca3ed9c11
commit 712b0c86f9
6 changed files with 70 additions and 19 deletions

View File

@ -136,7 +136,7 @@ Iceball Base Mod:
note, for C->S pid MUST be 0x00
0x05 pid team weapon score.s16 kills.s16 deaths.s16 namelen name[namelen]: (S->C) @
0x05 pid team weapon score.s16 kills.s16 deaths.s16 name.z squad.z: (S->C) @
adds player to server
note, this can be used to update a player on the server

View File

@ -450,19 +450,21 @@ function h_tick_main(sec_current, sec_delta)
plr.set_orient_recv(ya, xa, keys)
end
elseif cid == 0x05 then
-- 0x05 pid team weapon score.s16 kills.s16 deaths.s16 namelen name[namelen]: (S->C)
local pid, tidx, wpn, score, kills, deaths, name
pid, tidx, wpn, score, kills, deaths, name, pkt
= common.net_unpack("Bbbhhhz", pkt)
-- 0x05 pid team weapon score.s16 kills.s16 deaths.s16 name.z squad.z: (S->C)
local pid, tidx, wpn, score, kills, deaths, name, squad
pid, tidx, wpn, score, kills, deaths, name, squad, pkt
= common.net_unpack("Bbbhhhzz", pkt)
if players[pid] then
-- TODO: update wpn/tidx/name
players[pid].squad = (squad ~= "" and squad) or nil
players[pid].name = name
else
players[pid] = new_player({
name = name,
--[=[squad = squads[(i-1) % 2][
(math.floor((i-1)/2) % 4)+1],]=]
squad = nil,
squad = (squad ~= "" and squad) or nil,
team = tidx,
weapon = wpn,
pid = pid,

View File

@ -68,6 +68,8 @@ MODE_NADE_SPEED = 30.0
MODE_NADE_STEP = 0.1
MODE_NADE_ADAMP = 0.5
MODE_NADE_BDAMP = 1.0
MODE_NADE_RANGE = 8.0
MODE_NADE_DAMAGE = 500.0
MODE_MINIMAP_RCIRC = false
MODE_ENABLE_MINIMAP = true

View File

@ -247,6 +247,16 @@ function server.hook_tick(sec_current, sec_delta)
local s = nil
if string.sub(msg,1,4) == "/me " then
s = "* "..plr.name.." "..string.sub(msg,5)
elseif string.sub(msg,1,7) == "/squad " then
local s = string.sub(msg,8)
if s ~= "" then
if s == "none" then
plr.squad = nil
else
plr.squad = s
end
plr.update_score()
end
elseif msg == "/kill" then
plr.set_health_damage(0, 0xFF800000, plr.name.." shuffled off this mortal coil", plr)
else
@ -290,11 +300,11 @@ function server.hook_tick(sec_current, sec_delta)
for i=1,players.max do
local plr = players[i]
if plr then
common.net_send(sockfd, common.net_pack("BBBBhhhz",
common.net_send(sockfd, common.net_pack("BBBBhhhzz",
0x05, i,
plr.team, plr.weapon,
plr.score, plr.kills, plr.deaths,
plr.name))
plr.name, plr.squad))
common.net_send(sockfd, common.net_pack("BBfffBB",
0x10, i,
plr.x, plr.y, plr.z,
@ -322,11 +332,11 @@ function server.hook_tick(sec_current, sec_delta)
end
-- relay this player to everyone
net_broadcast(nil, common.net_pack("BBBBhhhz",
net_broadcast(nil, common.net_pack("BBBBhhhzz",
0x05, cli.plrid,
plr.team, plr.weapon,
plr.score, plr.kills, plr.deaths,
plr.name))
plr.name, plr.squad))
net_broadcast(nil, common.net_pack("BBfffBB",
0x10, cli.plrid,
plr.x, plr.y, plr.z,
@ -387,7 +397,8 @@ function server.hook_tick(sec_current, sec_delta)
vx = vx/256,
vy = vy/256,
vz = vz/256,
fuse = fuse/100
fuse = fuse/100,
pid = cli.plrid
})
nade_add(n)
net_broadcast(sockfd, common.net_pack("BhhhhhhH",

View File

@ -52,6 +52,8 @@ function new_nade(settings)
vy = settings.vy,
vz = settings.vz,
pid = settings.pid,
trem = 0.0,
fuse = settings.fuse,
dead = false
@ -102,6 +104,36 @@ function new_nade(settings)
local xlen,ylen,zlen
xlen,ylen,zlen = common.map_get_dims()
local hplr = this.pid and players[this.pid]
local i
for i=1,players.max do
local plr = players[i]
if plr and ((not hplr) or plr == hplr or plr.team ~= hplr.team) then
local dx,dy,dz
dx = plr.x-this.x
dy = (plr.y+0.9)-this.y
dz = plr.z-this.z
local dd = dx*dx+dy*dy+dz*dz
if dd < MODE_NADE_RANGE*MODE_NADE_RANGE then
dd = math.sqrt(dd)
dx = dx/dd
dy = dy/dd
dz = dz/dd
local nd
nd = trace_map_ray_dist(this.x,this.y,this.z, dx,dy,dz, dd)
if not nd then
local dmg = ((MODE_NADE_RANGE-dd)/MODE_NADE_RANGE)
dmg = dmg * dmg
dmg = dmg * MODE_NADE_DAMAGE
plr.grenade_damage(dmg, hplr)
end
end
end
end
if map_block_get(x0,y0,z0) ~= nil then
if y0 < ylen-2 then
map_block_break(x0,y0,z0)
@ -121,7 +153,7 @@ function new_nade(settings)
end
end
-- TODO: hurt players!
end
function this.tick(sec_current, sec_delta)

View File

@ -286,11 +286,11 @@ function new_player(settings)
end
function this.update_score()
net_broadcast(nil, common.net_pack("BBBBhhhz",
net_broadcast(nil, common.net_pack("BBBBhhhzz",
0x05, this.pid,
this.team, this.weapon,
this.score, this.kills, this.deaths,
this.name))
this.name, this.squad))
end
function this.tent_restock()
@ -405,9 +405,9 @@ function new_player(settings)
function this.grenade_damage(amt, enemy)
--print("damage",this.name,part,amt)
local midmsg = " killed "
if this.team == enemy.team then
midmsg = " teamkilled "
local midmsg = " grenaded "
if this.team == enemy.team and this ~= enemy then
error("THIS SHOULD NEVER HAPPEN")
end
local r,g,b
@ -1350,7 +1350,11 @@ function new_player(settings)
for i=1,players.max do
local plr = players[i]
if plr ~= nil then
local s = plr.name.." #"..i..": "
local sn = plr.name
if plr.squad then
sn = sn.." ["..plr.squad.."]"
end
local s = sn.." #"..i..": "
..plr.score.." ("..plr.kills.."/"..plr.deaths..")"
if plr.team == 1 then
font_mini.print(w / 2 + 50, gi * 15 + 150
@ -1358,7 +1362,7 @@ function new_player(settings)
, s)
gi = gi + 1
else
font_mini.print(w / 2 - 50 - (6 * #plr.name), bi * 15 + 150
font_mini.print(w / 2 - 50 - (6 * #s), bi * 15 + 150
, argb_split_to_merged(150, 150, 255, 255)
, s)
bi = bi + 1