killing now serverside, toolswitch/colourchange is relayed now
This commit is contained in:
parent
7186ec6eb6
commit
83dcd5fff5
@ -180,6 +180,12 @@ Iceball Base Mod:
|
|||||||
|
|
||||||
0x10 pid x.fs y.fs z.fs ya.u8 xa.u8: (S->C) @
|
0x10 pid x.fs y.fs z.fs ya.u8 xa.u8: (S->C) @
|
||||||
player spawn
|
player spawn
|
||||||
|
|
||||||
|
health is set to 100
|
||||||
|
blocks is set to 25
|
||||||
|
grenades is set to 2
|
||||||
|
|
||||||
|
ammo is set to full
|
||||||
|
|
||||||
0x11 team.s8 weapon.u8 name.z (C->S) @
|
0x11 team.s8 weapon.u8 name.z (C->S) @
|
||||||
offer player
|
offer player
|
||||||
@ -189,12 +195,12 @@ Iceball Base Mod:
|
|||||||
set item position
|
set item position
|
||||||
|
|
||||||
these are hardcoded as follows:
|
these are hardcoded as follows:
|
||||||
1 = blue tent
|
1 = blue intel
|
||||||
2 = blue intel
|
2 = blue tent
|
||||||
3 = green tent
|
3 = green intel
|
||||||
4 = green intel
|
4 = green tent
|
||||||
|
|
||||||
0x13 pid.u8 tpid.u8 type.u8 (C->S)
|
0x13 tpid.u8 type.u8 (C->S) @
|
||||||
fire shot, hitting target player
|
fire shot, hitting target player
|
||||||
yes, do this EVERY shot.
|
yes, do this EVERY shot.
|
||||||
|
|
||||||
@ -205,3 +211,46 @@ Iceball Base Mod:
|
|||||||
1 = head
|
1 = head
|
||||||
2 = body
|
2 = body
|
||||||
3 = limb
|
3 = limb
|
||||||
|
|
||||||
|
0x14 pid.u8 newhealth.u8 (S->C) @
|
||||||
|
set health due to damage
|
||||||
|
|
||||||
|
if newhealth is 0, player is dead
|
||||||
|
|
||||||
|
0x15 (S->C)
|
||||||
|
tent restock
|
||||||
|
|
||||||
|
health is set to 100
|
||||||
|
blocks is set to 100
|
||||||
|
grenades is set to 4
|
||||||
|
|
||||||
|
ammo is set to full
|
||||||
|
|
||||||
|
0x16 pid.u8 iid.u16 (S->C)
|
||||||
|
possess item
|
||||||
|
|
||||||
|
if uid == 0, depossess instead
|
||||||
|
|
||||||
|
these are hardcoded as follows:
|
||||||
|
1 = blue intel
|
||||||
|
2 = blue tent
|
||||||
|
3 = green intel
|
||||||
|
4 = green tent
|
||||||
|
|
||||||
|
0x17 pid.u8 tool.u8 @
|
||||||
|
set tool
|
||||||
|
|
||||||
|
TOOL_SPADE = 0
|
||||||
|
TOOL_BLOCK = 1
|
||||||
|
TOOL_GUN = 2
|
||||||
|
TOOL_NADE = 3
|
||||||
|
|
||||||
|
0x18 pid.u8 r.u8 g.u8 b.u8 @
|
||||||
|
set block colour
|
||||||
|
|
||||||
|
0xE0 map.z (S->C) @
|
||||||
|
name of map to fetch
|
||||||
|
|
||||||
|
NOTE: will be deprecated eventually
|
||||||
|
this is just a simple hack to start with
|
||||||
|
while i procrastinate server.hook_file
|
||||||
|
@ -18,8 +18,26 @@
|
|||||||
print("pkg/base/client_start.lua starting")
|
print("pkg/base/client_start.lua starting")
|
||||||
print(...)
|
print(...)
|
||||||
|
|
||||||
|
map_fname = nil
|
||||||
|
|
||||||
dofile("pkg/base/common.lua")
|
dofile("pkg/base/common.lua")
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local pkt, sockfd, cid
|
||||||
|
pkt, sockfd = common.net_recv()
|
||||||
|
cid, pkt = common.net_unpack("B", pkt)
|
||||||
|
if cid == 0xE0 then
|
||||||
|
map_fname, pkt = common.net_unpack("z", pkt)
|
||||||
|
break
|
||||||
|
else
|
||||||
|
error("should not receive non-map-filename packets until map filename arrives!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not map_fname then
|
||||||
|
error("server should have sent map name by now")
|
||||||
|
end
|
||||||
|
|
||||||
user_config = common.json_load("clsave/pub/user.json")
|
user_config = common.json_load("clsave/pub/user.json")
|
||||||
print("json done!")
|
print("json done!")
|
||||||
print("name:", user_config.name)
|
print("name:", user_config.name)
|
||||||
@ -305,6 +323,7 @@ function h_tick_main(sec_current, sec_delta)
|
|||||||
squad = nil,
|
squad = nil,
|
||||||
team = tidx,
|
team = tidx,
|
||||||
weapon = wpn,
|
weapon = wpn,
|
||||||
|
pid = pid,
|
||||||
})
|
})
|
||||||
|
|
||||||
players[pid].score = score
|
players[pid].score = score
|
||||||
@ -315,6 +334,8 @@ function h_tick_main(sec_current, sec_delta)
|
|||||||
players.current = pid
|
players.current = pid
|
||||||
elseif cid == 0x07 then
|
elseif cid == 0x07 then
|
||||||
local pid, pkt = common.net_unpack("B", pkt)
|
local pid, pkt = common.net_unpack("B", pkt)
|
||||||
|
-- TODO fix crash bug
|
||||||
|
--players[pid].free()
|
||||||
players[pid] = nil
|
players[pid] = nil
|
||||||
elseif cid == 0x0E then
|
elseif cid == 0x0E then
|
||||||
-- add to chat
|
-- add to chat
|
||||||
@ -330,9 +351,39 @@ function h_tick_main(sec_current, sec_delta)
|
|||||||
local pid, x,y,z, ya,xa
|
local pid, x,y,z, ya,xa
|
||||||
pid, x,y,z, ya,xa, pkt = common.net_unpack("Bfffbb", pkt)
|
pid, x,y,z, ya,xa, pkt = common.net_unpack("Bfffbb", pkt)
|
||||||
local plr = players[pid]
|
local plr = players[pid]
|
||||||
|
--print("client respawn!", players.current, pid, plr)
|
||||||
if plr then
|
if plr then
|
||||||
plr.spawn_at(x,y,z,ya*math.pi/128,xa*math.pi/256)
|
plr.spawn_at(x,y,z,ya*math.pi/128,xa*math.pi/256)
|
||||||
end
|
end
|
||||||
|
elseif cid == 0x14 then
|
||||||
|
local pid, amt
|
||||||
|
pid, amt, pkt = common.net_unpack("BB", pkt)
|
||||||
|
|
||||||
|
local plr = players[pid]
|
||||||
|
--print("hit pkt", pid, amt)
|
||||||
|
if plr then
|
||||||
|
plr.set_health_damage(amt, nil, nil)
|
||||||
|
end
|
||||||
|
elseif cid == 0x17 then
|
||||||
|
local pid, tool
|
||||||
|
pid, tool, pkt = common.net_unpack("BB", pkt)
|
||||||
|
|
||||||
|
local plr = players[pid]
|
||||||
|
|
||||||
|
if plr then
|
||||||
|
plr.tool_switch(tool)
|
||||||
|
end
|
||||||
|
elseif cid == 0x18 then
|
||||||
|
local pid, cr,cg,cb
|
||||||
|
pid, cr,cg,cb, pkt = common.net_unpack("BBBB", pkt)
|
||||||
|
|
||||||
|
local plr = players[pid]
|
||||||
|
|
||||||
|
print("recol",cr,cg,cb)
|
||||||
|
if plr then
|
||||||
|
plr.blk_color = {cr,cg,cb}
|
||||||
|
plr.block_recolor()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -525,24 +576,36 @@ function h_key(key, state, modif)
|
|||||||
plr.blk_color_x = 7
|
plr.blk_color_x = 7
|
||||||
end
|
end
|
||||||
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
||||||
|
common.net_send(nil, common.net_pack("BBBBB",
|
||||||
|
0x18, 0x00,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
elseif key == BTSK_COLORRIGHT then
|
elseif key == BTSK_COLORRIGHT then
|
||||||
plr.blk_color_x = plr.blk_color_x + 1
|
plr.blk_color_x = plr.blk_color_x + 1
|
||||||
if plr.blk_color_x > 7 then
|
if plr.blk_color_x > 7 then
|
||||||
plr.blk_color_x = 0
|
plr.blk_color_x = 0
|
||||||
end
|
end
|
||||||
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
||||||
|
common.net_send(nil, common.net_pack("BBBBB",
|
||||||
|
0x18, 0x00,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
elseif key == BTSK_COLORUP then
|
elseif key == BTSK_COLORUP then
|
||||||
plr.blk_color_y = plr.blk_color_y - 1
|
plr.blk_color_y = plr.blk_color_y - 1
|
||||||
if plr.blk_color_y < 0 then
|
if plr.blk_color_y < 0 then
|
||||||
plr.blk_color_y = 7
|
plr.blk_color_y = 7
|
||||||
end
|
end
|
||||||
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
||||||
|
common.net_send(nil, common.net_pack("BBBBB",
|
||||||
|
0x18, 0x00,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
elseif key == BTSK_COLORDOWN then
|
elseif key == BTSK_COLORDOWN then
|
||||||
plr.blk_color_y = plr.blk_color_y + 1
|
plr.blk_color_y = plr.blk_color_y + 1
|
||||||
if plr.blk_color_y > 7 then
|
if plr.blk_color_y > 7 then
|
||||||
plr.blk_color_y = 0
|
plr.blk_color_y = 0
|
||||||
end
|
end
|
||||||
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
plr.blk_color = cpalette[plr.blk_color_x+plr.blk_color_y*8+1]
|
||||||
|
common.net_send(nil, common.net_pack("BBBBB",
|
||||||
|
0x18, 0x00,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -598,6 +661,9 @@ function h_mouse_button(button, state)
|
|||||||
local ct,cr,cg,cb
|
local ct,cr,cg,cb
|
||||||
ct,cr,cg,cb = map_block_pick(plr.blx3, plr.bly3, plr.blz3)
|
ct,cr,cg,cb = map_block_pick(plr.blx3, plr.bly3, plr.blz3)
|
||||||
plr.blk_color = {cr,cg,cb}
|
plr.blk_color = {cr,cg,cb}
|
||||||
|
common.net_send(nil, common.net_pack("BBBBB",
|
||||||
|
0x18, 0x00,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
elseif plr.tool == TOOL_SPADE and plr.blx2 then
|
elseif plr.tool == TOOL_SPADE and plr.blx2 then
|
||||||
if plr.blx1 >= 0 and plr.blx1 < xlen and plr.blz1 >= 0 and plr.blz1 < zlen then
|
if plr.blx1 >= 0 and plr.blx1 < xlen and plr.blz1 >= 0 and plr.blz1 < zlen then
|
||||||
if plr.bly2-1 <= ylen-3 then
|
if plr.bly2-1 <= ylen-3 then
|
||||||
@ -632,8 +698,6 @@ function h_mouse_motion(x, y, dx, dy)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- load map
|
-- load map
|
||||||
map_fname = ...
|
|
||||||
map_fname = map_fname or MAP_DEFAULT
|
|
||||||
map_loaded = common.map_load(map_fname, "auto")
|
map_loaded = common.map_load(map_fname, "auto")
|
||||||
common.map_set(map_loaded)
|
common.map_set(map_loaded)
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ weapons = {
|
|||||||
-- see if there's anyone we can kill
|
-- see if there's anyone we can kill
|
||||||
local hurt_idx = nil
|
local hurt_idx = nil
|
||||||
local hurt_part = nil
|
local hurt_part = nil
|
||||||
|
local hurt_part_idx = 0
|
||||||
local hurt_dist = d*d
|
local hurt_dist = d*d
|
||||||
local i,j
|
local i,j
|
||||||
|
|
||||||
@ -163,6 +164,7 @@ weapons = {
|
|||||||
if dot < 0.55 and dd < hurt_dist then
|
if dot < 0.55 and dd < hurt_dist then
|
||||||
hurt_idx = i
|
hurt_idx = i
|
||||||
hurt_dist = dd
|
hurt_dist = dd
|
||||||
|
hurt_part_idx = j
|
||||||
hurt_part = ({"head","body","legs"})[j]
|
hurt_part = ({"head","body","legs"})[j]
|
||||||
|
|
||||||
break
|
break
|
||||||
@ -174,11 +176,23 @@ weapons = {
|
|||||||
|
|
||||||
if hurt_idx then
|
if hurt_idx then
|
||||||
-- TODO: ship this off to the server!
|
-- TODO: ship this off to the server!
|
||||||
players[hurt_idx].gun_damage(
|
if server then
|
||||||
hurt_part, this.cfg.dmg[hurt_part], plr)
|
players[hurt_idx].gun_damage(
|
||||||
elseif cx2 then
|
hurt_part, this.cfg.dmg[hurt_part], plr)
|
||||||
-- TODO: block health rather than instant block removal
|
else
|
||||||
map_block_break(cx2,cy2,cz2)
|
common.net_send(nil, common.net_pack("BBB"
|
||||||
|
, 0x13, hurt_idx, hurt_part_idx))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if client then
|
||||||
|
common.net_send(nil, common.net_pack("BBB"
|
||||||
|
, 0x13, 0, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
if cx2 then
|
||||||
|
-- TODO: block health rather than instant block removal
|
||||||
|
map_block_break(cx2,cy2,cz2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: fire a tracer
|
-- TODO: fire a tracer
|
||||||
|
@ -37,6 +37,7 @@ function slot_add(sockfd, tidx, wpn, name)
|
|||||||
squad = nil,
|
squad = nil,
|
||||||
team = tidx, -- 0 == blue, 1 == green
|
team = tidx, -- 0 == blue, 1 == green
|
||||||
weapon = WPN_RIFLE,
|
weapon = WPN_RIFLE,
|
||||||
|
pid = i,
|
||||||
})
|
})
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
@ -84,6 +85,8 @@ function server.hook_connect(sockfd, addrinfo)
|
|||||||
--[[net_broadcast(nil, common.net_pack("BIz", 0x0E, 0xFF800000,
|
--[[net_broadcast(nil, common.net_pack("BIz", 0x0E, 0xFF800000,
|
||||||
"Connected: player on sockfd "..ss))]]
|
"Connected: player on sockfd "..ss))]]
|
||||||
print("Connected: player on sockfd "..ss)
|
print("Connected: player on sockfd "..ss)
|
||||||
|
|
||||||
|
common.net_send(sockfd, common.net_pack("Bz", 0xE0, map_fname))
|
||||||
end
|
end
|
||||||
|
|
||||||
function server.hook_disconnect(sockfd, server_force, reason)
|
function server.hook_disconnect(sockfd, server_force, reason)
|
||||||
@ -111,6 +114,9 @@ function server.hook_disconnect(sockfd, server_force, reason)
|
|||||||
"* Player "..plr.name.." disconnected"))
|
"* Player "..plr.name.." disconnected"))
|
||||||
net_broadcast(sockfd, common.net_pack("BB",
|
net_broadcast(sockfd, common.net_pack("BB",
|
||||||
0x07, plrid))
|
0x07, plrid))
|
||||||
|
|
||||||
|
-- TODO fix crash bug
|
||||||
|
--plr.free()
|
||||||
players[plrid] = nil
|
players[plrid] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -201,6 +207,11 @@ function server.hook_tick(sec_current, sec_delta)
|
|||||||
0x10, i,
|
0x10, i,
|
||||||
plr.x, plr.y, plr.z,
|
plr.x, plr.y, plr.z,
|
||||||
plr.angy*128/math.pi, plr.angx*256/math.pi))
|
plr.angy*128/math.pi, plr.angx*256/math.pi))
|
||||||
|
common.net_send(sockfd, common.net_pack("BBB",
|
||||||
|
0x17, i, plr.tool))
|
||||||
|
common.net_send(sockfd, common.net_pack("BBBBB",
|
||||||
|
0x18, i,
|
||||||
|
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -222,10 +233,49 @@ function server.hook_tick(sec_current, sec_delta)
|
|||||||
net_broadcast(nil, common.net_pack("BIz", 0x0E, 0xFF800000,
|
net_broadcast(nil, common.net_pack("BIz", 0x0E, 0xFF800000,
|
||||||
"* Player "..name.." has joined the "..teams[plr.team].name.." team"))
|
"* Player "..name.." has joined the "..teams[plr.team].name.." team"))
|
||||||
end
|
end
|
||||||
|
elseif cid == 0x13 and plr then
|
||||||
|
local tpid, styp
|
||||||
|
tpid, styp, pkt = common.net_unpack("BB", pkt)
|
||||||
|
--print("hit", tpid, styp)
|
||||||
|
|
||||||
|
local tplr = players[tpid]
|
||||||
|
if tplr and styp >= 1 and styp <= 3 then
|
||||||
|
if tplr.wpn then
|
||||||
|
local dmg = tplr.wpn.cfg.dmg[({"head","body","legs"})[styp]]
|
||||||
|
--print("dmg",dmg,tplr.wpn.cfg.dmg)
|
||||||
|
tplr.gun_damage(styp, dmg, plr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif cid == 0x17 and plr then
|
||||||
|
local tpid, tool
|
||||||
|
tpid, tool, pkt = common.net_unpack("BB", pkt)
|
||||||
|
|
||||||
|
if tool >= 0 and tool <= 3 then
|
||||||
|
net_broadcast(sockfd, common.net_pack("BBB"
|
||||||
|
, 0x17, cli.plrid, tool))
|
||||||
|
end
|
||||||
|
elseif cid == 0x18 and plr then
|
||||||
|
local tpid, cr,cg,cb
|
||||||
|
tpid, cr,cg,cb, pkt = common.net_unpack("BBBB", pkt)
|
||||||
|
|
||||||
|
net_broadcast(sockfd, common.net_pack("BBBBB"
|
||||||
|
, 0x18, cli.plrid, cr, cg, cb))
|
||||||
end
|
end
|
||||||
-- TODO!
|
-- TODO!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local i
|
||||||
|
for i=1,players.max do
|
||||||
|
local plr = players[i]
|
||||||
|
if plr then
|
||||||
|
plr.tick(sec_current, sec_delta)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,#intent do
|
||||||
|
intent[i].tick(sec_current, sec_delta)
|
||||||
|
end
|
||||||
|
|
||||||
return 0.005
|
return 0.005
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -252,4 +302,9 @@ for i=1,players.max do
|
|||||||
end
|
end
|
||||||
]=]
|
]=]
|
||||||
|
|
||||||
|
intent[#intent+1] = new_intel({team = 0})
|
||||||
|
intent[#intent+1] = new_tent({team = 0})
|
||||||
|
intent[#intent+1] = new_intel({team = 1})
|
||||||
|
intent[#intent+1] = new_tent({team = 1})
|
||||||
|
|
||||||
print("pkg/base/main_server.lua loaded.")
|
print("pkg/base/main_server.lua loaded.")
|
||||||
|
@ -29,9 +29,14 @@ function new_intel(settings)
|
|||||||
|
|
||||||
this.rotpos = sec_current*2
|
this.rotpos = sec_current*2
|
||||||
|
|
||||||
|
if not this.spawned then return end
|
||||||
|
|
||||||
if this.player then
|
if this.player then
|
||||||
-- anything to do here?
|
-- anything to do here?
|
||||||
else
|
else
|
||||||
|
|
||||||
|
if not server then return end
|
||||||
|
|
||||||
-- set position
|
-- set position
|
||||||
local l = common.map_pillar_get(
|
local l = common.map_pillar_get(
|
||||||
math.floor(this.x),
|
math.floor(this.x),
|
||||||
@ -114,6 +119,18 @@ function new_intel(settings)
|
|||||||
this.spawn()
|
this.spawn()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.prespawn()
|
||||||
|
this.alive = false
|
||||||
|
this.spawned = false
|
||||||
|
this.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function prv_spawn_cont1()
|
||||||
|
this.alive = true
|
||||||
|
this.spawned = true
|
||||||
|
this.visible = true
|
||||||
|
end
|
||||||
|
|
||||||
function this.spawn()
|
function this.spawn()
|
||||||
local xlen,ylen,zlen
|
local xlen,ylen,zlen
|
||||||
xlen,ylen,zlen = common.map_get_dims()
|
xlen,ylen,zlen = common.map_get_dims()
|
||||||
@ -126,21 +143,39 @@ function new_intel(settings)
|
|||||||
if this.y < ylen-1 then break end
|
if this.y < ylen-1 then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
this.alive = true
|
prv_spawn_cont1()
|
||||||
this.spawned = true
|
end
|
||||||
this.visible = true
|
|
||||||
|
function this.spawn_at(x,y,z)
|
||||||
|
this.x = x
|
||||||
|
this.y = y
|
||||||
|
this.z = z
|
||||||
|
|
||||||
|
prv_spawn_cont1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.get_pos()
|
||||||
|
return this.x, this.y, this.z
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.set_pos_recv(x,y,z)
|
||||||
|
this.x = x
|
||||||
|
this.y = y
|
||||||
|
this.z = z
|
||||||
end
|
end
|
||||||
|
|
||||||
local _
|
local _
|
||||||
local l = teams[this.team].color_mdl
|
local l = teams[this.team].color_mdl
|
||||||
local mbone,mname,mdata
|
local mbone,mname,mdata
|
||||||
this.mdl_intel = client.model_new(1)
|
if client then
|
||||||
this.mdl_intel, mbone = client.model_bone_new(this.mdl_intel,1)
|
this.mdl_intel = client.model_new(1)
|
||||||
mname,mdata = common.model_bone_get(mdl_intel, 0)
|
this.mdl_intel, mbone = client.model_bone_new(this.mdl_intel,1)
|
||||||
recolor_component(l[1],l[2],l[3],mdata)
|
mname,mdata = common.model_bone_get(mdl_intel, 0)
|
||||||
common.model_bone_set(this.mdl_intel, 0, mname, mdata)
|
recolor_component(l[1],l[2],l[3],mdata)
|
||||||
|
common.model_bone_set(this.mdl_intel, 0, mname, mdata)
|
||||||
|
end
|
||||||
|
|
||||||
this.spawn()
|
this.prespawn()
|
||||||
|
|
||||||
return this
|
return this
|
||||||
end
|
end
|
||||||
@ -154,6 +189,10 @@ function new_tent(settings)
|
|||||||
function this.tick(sec_current, sec_delta)
|
function this.tick(sec_current, sec_delta)
|
||||||
local i
|
local i
|
||||||
|
|
||||||
|
if not server then return end
|
||||||
|
|
||||||
|
if not this.spawned then return end
|
||||||
|
|
||||||
-- set position
|
-- set position
|
||||||
local l = common.map_pillar_get(
|
local l = common.map_pillar_get(
|
||||||
math.floor(this.x),
|
math.floor(this.x),
|
||||||
@ -209,6 +248,18 @@ function new_tent(settings)
|
|||||||
0, 0, 0, 3)
|
0, 0, 0, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.prespawn()
|
||||||
|
this.alive = false
|
||||||
|
this.spawned = false
|
||||||
|
this.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function prv_spawn_cont1()
|
||||||
|
this.alive = true
|
||||||
|
this.spawned = true
|
||||||
|
this.visible = true
|
||||||
|
end
|
||||||
|
|
||||||
function this.spawn()
|
function this.spawn()
|
||||||
local xlen,ylen,zlen
|
local xlen,ylen,zlen
|
||||||
xlen,ylen,zlen = common.map_get_dims()
|
xlen,ylen,zlen = common.map_get_dims()
|
||||||
@ -221,21 +272,39 @@ function new_tent(settings)
|
|||||||
if this.y < ylen-1 then break end
|
if this.y < ylen-1 then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
this.alive = true
|
prv_spawn_cont1()
|
||||||
this.spawned = true
|
end
|
||||||
this.visible = true
|
|
||||||
|
function this.spawn_at(x,y,z)
|
||||||
|
this.x = x
|
||||||
|
this.y = y
|
||||||
|
this.z = z
|
||||||
|
|
||||||
|
prv_spawn_cont1()
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.get_pos()
|
||||||
|
return this.x, this.y, this.z
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.set_pos_recv(x,y,z)
|
||||||
|
this.x = x
|
||||||
|
this.y = y
|
||||||
|
this.z = z
|
||||||
end
|
end
|
||||||
|
|
||||||
local _
|
local _
|
||||||
local l = teams[this.team].color_mdl
|
local l = teams[this.team].color_mdl
|
||||||
local mbone,mname,mdata
|
local mbone,mname,mdata
|
||||||
this.mdl_tent = client.model_new(1)
|
if client then
|
||||||
this.mdl_tent, mbone = client.model_bone_new(this.mdl_tent,1)
|
this.mdl_tent = client.model_new(1)
|
||||||
mname,mdata = common.model_bone_get(mdl_tent, 0)
|
this.mdl_tent, mbone = client.model_bone_new(this.mdl_tent,1)
|
||||||
recolor_component(l[1],l[2],l[3],mdata)
|
mname,mdata = common.model_bone_get(mdl_tent, 0)
|
||||||
common.model_bone_set(this.mdl_tent, 0, mname, mdata)
|
recolor_component(l[1],l[2],l[3],mdata)
|
||||||
|
common.model_bone_set(this.mdl_tent, 0, mname, mdata)
|
||||||
|
end
|
||||||
|
|
||||||
this.spawn()
|
this.prespawn()
|
||||||
|
|
||||||
return this
|
return this
|
||||||
end
|
end
|
||||||
|
@ -21,6 +21,7 @@ function new_player(settings)
|
|||||||
this.team = settings.team or math.floor(math.random()*2)
|
this.team = settings.team or math.floor(math.random()*2)
|
||||||
this.squad = settings.squad or nil
|
this.squad = settings.squad or nil
|
||||||
this.weapon = settings.weapon or WPN_RIFLE
|
this.weapon = settings.weapon or WPN_RIFLE
|
||||||
|
this.pid = settings.pid or error("pid must be set when creating player!")
|
||||||
this.alive = false
|
this.alive = false
|
||||||
this.spawned = false
|
this.spawned = false
|
||||||
this.zooming = false
|
this.zooming = false
|
||||||
@ -67,6 +68,10 @@ function new_player(settings)
|
|||||||
prv_recolor_team(r,g,b)
|
prv_recolor_team(r,g,b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.block_recolor()
|
||||||
|
prv_recolor_block(this.blk_color[1],this.blk_color[2],this.blk_color[3])
|
||||||
|
end
|
||||||
|
|
||||||
function this.input_reset()
|
function this.input_reset()
|
||||||
this.ev_forward = false
|
this.ev_forward = false
|
||||||
this.ev_back = false
|
this.ev_back = false
|
||||||
@ -111,6 +116,7 @@ function new_player(settings)
|
|||||||
this.blx2, this.bly2, this.blz2 = nil, nil, nil
|
this.blx2, this.bly2, this.blz2 = nil, nil, nil
|
||||||
|
|
||||||
this.blk_color = {0x7F,0x7F,0x7F}
|
this.blk_color = {0x7F,0x7F,0x7F}
|
||||||
|
this.block_recolor()
|
||||||
this.blk_color_x = 3
|
this.blk_color_x = 3
|
||||||
this.blk_color_y = 0
|
this.blk_color_y = 0
|
||||||
|
|
||||||
@ -130,7 +136,7 @@ function new_player(settings)
|
|||||||
this.has_intel = nil
|
this.has_intel = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function prv_spawn_cont1()
|
local function prv_spawn_cont1()
|
||||||
this.prespawn()
|
this.prespawn()
|
||||||
|
|
||||||
this.alive = true
|
this.alive = true
|
||||||
@ -183,6 +189,10 @@ function new_player(settings)
|
|||||||
this.arm_rest_right = 0
|
this.arm_rest_right = 0
|
||||||
end
|
end
|
||||||
this.t_switch = true
|
this.t_switch = true
|
||||||
|
if client and this == players[players.current] and this.tool ~= tool then
|
||||||
|
common.net_send(nil, common.net_pack("BBB"
|
||||||
|
, 0x17, 0x00, tool))
|
||||||
|
end
|
||||||
this.tool = tool
|
this.tool = tool
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -246,14 +256,27 @@ function new_player(settings)
|
|||||||
this.angx = math.asin(yrec/ydist)
|
this.angx = math.asin(yrec/ydist)
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.damage(amt, kcol, kmsg)
|
function this.set_health_damage(amt, kcol, kmsg)
|
||||||
this.health = this.health - amt
|
this.health = amt
|
||||||
|
|
||||||
if this.health <= 0 then
|
if this.health <= 0 then
|
||||||
this.intel_drop()
|
this.intel_drop()
|
||||||
chat_add(chat_killfeed, nil, kmsg, kcol)
|
if server then
|
||||||
|
net_broadcast(nil, common.net_pack("BIz", 0x0F, kcol, kmsg))
|
||||||
|
end
|
||||||
|
--chat_add(chat_killfeed, nil, kmsg, kcol)
|
||||||
this.health = 0
|
this.health = 0
|
||||||
this.alive = false
|
this.alive = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if server then
|
||||||
|
net_broadcast(nil, common.net_pack("BBB", 0x14, this.pid, this.health))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.damage(amt, kcol, kmsg)
|
||||||
|
return this.set_health_damage(
|
||||||
|
this.health - amt, kcol, kmsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.fall_damage(amt)
|
function this.fall_damage(amt)
|
||||||
@ -269,6 +292,11 @@ function new_player(settings)
|
|||||||
|
|
||||||
function this.gun_damage(part, amt, enemy)
|
function this.gun_damage(part, amt, enemy)
|
||||||
--print("damage",this.name,part,amt)
|
--print("damage",this.name,part,amt)
|
||||||
|
|
||||||
|
if not server then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local midmsg = " killed "
|
local midmsg = " killed "
|
||||||
if this.team == enemy.team then
|
if this.team == enemy.team then
|
||||||
midmsg = " teamkilled "
|
midmsg = " teamkilled "
|
||||||
@ -359,9 +387,14 @@ function new_player(settings)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if this.t_respawn then
|
if this.t_respawn then
|
||||||
if this.t_respawn <= sec_current then
|
if server and this.t_respawn <= sec_current then
|
||||||
|
--print("server respawn!")
|
||||||
this.t_respawn = nil
|
this.t_respawn = nil
|
||||||
this.spawn()
|
this.spawn()
|
||||||
|
net_broadcast(nil, common.net_pack("BBfffBB",
|
||||||
|
0x10, this.pid,
|
||||||
|
this.x, this.y, this.z,
|
||||||
|
this.angy*128/math.pi, this.angx*256/math.pi))
|
||||||
else
|
else
|
||||||
-- any last requests?
|
-- any last requests?
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user