clientside portal placement

This commit is contained in:
Ben Russell (300178622) 2015-10-03 15:36:16 +13:00
parent ed500c312b
commit c9918aea72
2 changed files with 14 additions and 9 deletions

View File

@ -173,6 +173,7 @@ return function (plr)
end end
end end
--[==[
if hurt_idx then if hurt_idx then
if server then if server then
--[[ --[[
@ -186,13 +187,13 @@ return function (plr)
]] ]]
plr.show_hit() plr.show_hit()
end end
else end
]==]
if client then if client then
--[[ --[[
net_send(nil, common.net_pack("BBB" net_send(nil, common.net_pack("BBB"
, PKT_PLR_GUN_HIT, 0, 0)) , PKT_PLR_GUN_HIT, 0, 0))
]] ]]
end
if cx2 and cy2 <= ylen-2 and cx2 >= 0 and cx2 < xlen and cz2 >= 0 and cz2 < zlen then if cx2 and cy2 <= ylen-2 and cx2 >= 0 and cx2 < xlen and cz2 >= 0 and cz2 < zlen then
print("Portal hit ("..cx2..", "..cy2..", "..cz2..") type "..this.portal_select) print("Portal hit ("..cx2..", "..cy2..", "..cz2..") type "..this.portal_select)
@ -231,6 +232,8 @@ return function (plr)
end end
if valid and dy == 0 and (dx ~= 0 or dz ~= 0) then if valid and dy == 0 and (dx ~= 0 or dz ~= 0) then
plr.show_hit()
plr.portal_list[this.portal_select] = {cx, cy, cz, dx, dy, dz, 0, -1, 0}
net_send(nil, common.net_pack("BBBhhhbbbbbb", PKT_PORTALGUN_SET, net_send(nil, common.net_pack("BBBhhhbbbbbb", PKT_PORTALGUN_SET,
0, this.portal_select, cx, cy, cz, 0, this.portal_select, cx, cy, cz,
dx, dy, dz, 0, -1, 0)) dx, dy, dz, 0, -1, 0))
@ -247,6 +250,8 @@ return function (plr)
sx = sx * dy sx = sx * dy
sz = sz * dy sz = sz * dy
plr.show_hit()
plr.portal_list[this.portal_select] = {cx, cy, cz, dx, dy, dz, sx, 0, sz}
net_send(nil, common.net_pack("BBBhhhbbbbbb", PKT_PORTALGUN_SET, net_send(nil, common.net_pack("BBBhhhbbbbbb", PKT_PORTALGUN_SET,
0, this.portal_select, cx, cy, cz, 0, this.portal_select, cx, cy, cz,
dx, dy, dz, sx, 0, sz)) dx, dy, dz, sx, 0, sz))

View File

@ -23,13 +23,13 @@ network.sys_handle_c2s(PKT_PORTALGUN_SET, "BBhhhbbbbbb", nwdec_plrset(
if dx == 0 and dy == 0 and dz == 0 then if dx == 0 and dy == 0 and dz == 0 then
print("SERVER DELETE PORTAL "..portal_select) print("SERVER DELETE PORTAL "..portal_select)
plr.portal_list[portal_select] = nil plr.portal_list[portal_select] = nil
net_broadcast(nil, common.net_pack("BBBhhhbbbbbb", net_broadcast(neth, common.net_pack("BBBhhhbbbbbb",
PKT_PORTALGUN_SET, cli.plrid, portal_select, PKT_PORTALGUN_SET, cli.plrid, portal_select,
cx, cy, cz, dx, dy, dz, sx, sy, sz)) cx, cy, cz, dx, dy, dz, sx, sy, sz))
else else
print("SERVER CREATE PORTAL "..portal_select.." AT ("..cx..", "..cy..", "..cz..")") print("SERVER CREATE PORTAL "..portal_select.." AT ("..cx..", "..cy..", "..cz..")")
plr.portal_list[portal_select] = {cx, cy, cz, dx, dy, dz, sx, sy, sz} plr.portal_list[portal_select] = {cx, cy, cz, dx, dy, dz, sx, sy, sz}
net_broadcast(nil, common.net_pack("BBBhhhbbbbbb", net_broadcast(neth, common.net_pack("BBBhhhbbbbbb",
PKT_PORTALGUN_SET, cli.plrid, portal_select, PKT_PORTALGUN_SET, cli.plrid, portal_select,
cx, cy, cz, dx, dy, dz, sx, sy, sz)) cx, cy, cz, dx, dy, dz, sx, sy, sz))
end end