fixed some physics, fixed a bug where you could claim an intel cap in the enemy tent
This commit is contained in:
parent
c195666a20
commit
8c30d22e5c
@ -450,8 +450,8 @@ function h_tick_main(sec_current, sec_delta)
|
|||||||
else
|
else
|
||||||
players[pid] = new_player({
|
players[pid] = new_player({
|
||||||
name = name,
|
name = name,
|
||||||
--[=[squad = squads[math.fmod(i-1,2)][
|
--[=[squad = squads[(i-1) % 2][
|
||||||
math.fmod(math.floor((i-1)/2),4)+1],]=]
|
(math.floor((i-1)/2) % 4)+1],]=]
|
||||||
squad = nil,
|
squad = nil,
|
||||||
team = tidx,
|
team = tidx,
|
||||||
weapon = wpn,
|
weapon = wpn,
|
||||||
@ -655,10 +655,10 @@ function h_tick_init(sec_current, sec_delta)
|
|||||||
for i=1,players.max do
|
for i=1,players.max do
|
||||||
players[i] = new_player({
|
players[i] = new_player({
|
||||||
name = (players.current == i and user_config.name) or name_generate(),
|
name = (players.current == i and user_config.name) or name_generate(),
|
||||||
--[=[squad = squads[math.fmod(i-1,2)][
|
--[=[squad = squads[(i-1) % 2][
|
||||||
math.fmod(math.floor((i-1)/2),4)+1],]=]
|
(math.floor((i-1)/2) % 4)+1],]=]
|
||||||
squad = nil,
|
squad = nil,
|
||||||
team = math.fmod(i-1,2), -- 0 == blue, 1 == green
|
team = (i-1) % 2, -- 0 == blue, 1 == green
|
||||||
weapon = WPN_RIFLE,
|
weapon = WPN_RIFLE,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
function bit_unsign(a,m)
|
function bit_unsign(a,m)
|
||||||
m = math.pow(2,m)
|
m = math.pow(2,m)
|
||||||
local v = math.fmod(a,m)
|
local v = (a % m)
|
||||||
if v < 0 then
|
if v < 0 then
|
||||||
v = v + m
|
v = v + m
|
||||||
end
|
end
|
||||||
@ -28,7 +28,7 @@ function bit_xor(a,b)
|
|||||||
local shift = 1
|
local shift = 1
|
||||||
local v = 0
|
local v = 0
|
||||||
while a > 0 and b > 0 do
|
while a > 0 and b > 0 do
|
||||||
if (math.fmod(a,2) ~= 0) ~= (math.fmod(b,2) ~= 0) then
|
if ((a % 2) ~= 0) ~= ((b % 2) ~= 0) then
|
||||||
v = v + shift
|
v = v + shift
|
||||||
end
|
end
|
||||||
shift = shift * 2
|
shift = shift * 2
|
||||||
@ -42,7 +42,7 @@ function bit_or(a,b)
|
|||||||
local shift = 1
|
local shift = 1
|
||||||
local v = 0
|
local v = 0
|
||||||
while a > 0 and b > 0 do
|
while a > 0 and b > 0 do
|
||||||
if (math.fmod(a,2) ~= 0) or (math.fmod(b,2) ~= 0) then
|
if ((a % 2) ~= 0) or ((b % 2) ~= 0) then
|
||||||
v = v + shift
|
v = v + shift
|
||||||
end
|
end
|
||||||
shift = shift * 2
|
shift = shift * 2
|
||||||
@ -56,7 +56,7 @@ function bit_and(a,b)
|
|||||||
local shift = 1
|
local shift = 1
|
||||||
local v = 0
|
local v = 0
|
||||||
while a > 0 and b > 0 do
|
while a > 0 and b > 0 do
|
||||||
if (math.fmod(a,2) ~= 0) and (math.fmod(b,2) ~= 0) then
|
if ((a % 2) ~= 0) and ((b % 2) ~= 0) then
|
||||||
v = v + shift
|
v = v + shift
|
||||||
end
|
end
|
||||||
shift = shift * 2
|
shift = shift * 2
|
||||||
|
@ -190,17 +190,17 @@ function map_hashcoord3(x,y,z)
|
|||||||
xlen,ylen,zlen = common.map_get_dims()
|
xlen,ylen,zlen = common.map_get_dims()
|
||||||
|
|
||||||
return
|
return
|
||||||
math.fmod(math.fmod(y,ylen)+ylen,ylen)
|
(y % ylen)
|
||||||
+ylen*(math.fmod(math.fmod(x,xlen)+xlen,xlen)
|
+ylen*(x % xlen)
|
||||||
+xlen*math.fmod(math.fmod(z,zlen)+zlen,zlen))
|
+xlen*(z % zlen)
|
||||||
end
|
end
|
||||||
|
|
||||||
function map_hashcoord2(x,z)
|
function map_hashcoord2(x,z)
|
||||||
local xlen,ylen,zlen
|
local xlen,ylen,zlen
|
||||||
xlen,ylen,zlen = common.map_get_dims()
|
xlen,ylen,zlen = common.map_get_dims()
|
||||||
|
|
||||||
return math.fmod(math.fmod(x,xlen)+xlen,xlen)
|
return (x % xlen)
|
||||||
+xlen*math.fmod(math.fmod(z,zlen)+zlen,zlen)
|
+xlen*(z % zlen)
|
||||||
end
|
end
|
||||||
|
|
||||||
function map_chkdisbrk(x,y,z)
|
function map_chkdisbrk(x,y,z)
|
||||||
|
@ -15,6 +15,25 @@
|
|||||||
along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>.
|
along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
function trace_gap(x,y,z)
|
||||||
|
local xlen,ylen,zlen
|
||||||
|
xlen,ylen,zlen = common.map_get_dims()
|
||||||
|
|
||||||
|
local l = common.map_pillar_get(math.floor(x), math.floor(z))
|
||||||
|
i = 1
|
||||||
|
local h1,h2
|
||||||
|
h1 = nil
|
||||||
|
while true do
|
||||||
|
h2 = l[i+1]
|
||||||
|
if h2 == ylen-1 then h2 = ylen end
|
||||||
|
if y < l[i+1] or l[i] == 0 then return h1, h2 end
|
||||||
|
i = i + l[i]*4
|
||||||
|
if y < l[i+3] then return h1, h2 end
|
||||||
|
h1 = l[i+3]
|
||||||
|
h2 = l[i+1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function box_is_clear(x1,y1,z1,x2,y2,z2,canwrap)
|
function box_is_clear(x1,y1,z1,x2,y2,z2,canwrap)
|
||||||
local x,z,i
|
local x,z,i
|
||||||
|
|
||||||
@ -216,9 +235,9 @@ function trace_map_box(x1,y1,z1, x2,y2,z2, bx1,by1,bz1, bx2,by2,bz2, canwrap)
|
|||||||
|
|
||||||
-- sub deltas
|
-- sub deltas
|
||||||
local sx, sy, sz
|
local sx, sy, sz
|
||||||
sx = math.fmod(x1, 1.0) - 0.001
|
sx = (x1 % 1.0) - 0.001
|
||||||
sy = math.fmod(y1, 1.0) - 0.001
|
sy = (y1 % 1.0) - 0.001
|
||||||
sz = math.fmod(z1, 1.0) - 0.001
|
sz = (z1 % 1.0) - 0.001
|
||||||
if gx >= 0 then sx = 1-sx end
|
if gx >= 0 then sx = 1-sx end
|
||||||
if gy >= 0 then sy = 1-sy end
|
if gy >= 0 then sy = 1-sy end
|
||||||
if gz >= 0 then sz = 1-sz end
|
if gz >= 0 then sz = 1-sz end
|
||||||
|
@ -28,12 +28,12 @@ function slot_add(sockfd, tidx, wpn, name)
|
|||||||
if not players[i] then
|
if not players[i] then
|
||||||
if tidx < 0 or tidx > 1 then
|
if tidx < 0 or tidx > 1 then
|
||||||
-- TODO: actually balance this properly!
|
-- TODO: actually balance this properly!
|
||||||
tidx = math.fmod(i-1,2)
|
tidx = (i-1) % 2
|
||||||
end
|
end
|
||||||
players[i] = new_player({
|
players[i] = new_player({
|
||||||
name = name,
|
name = name,
|
||||||
--[[squad = squads[math.fmod(i-1,2)][
|
--[[squad = squads[(i-1) % 2][
|
||||||
math.fmod(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_RIFLE,
|
||||||
@ -406,23 +406,6 @@ 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)
|
||||||
|
|
||||||
-- spam with players
|
|
||||||
--[=[
|
|
||||||
players.local_multi = math.floor(math.random()*32)+1
|
|
||||||
|
|
||||||
for i=1,players.max do
|
|
||||||
players[i] = new_player({
|
|
||||||
name = name_generate(),
|
|
||||||
--[[squad = squads[math.fmod(i-1,2)][
|
|
||||||
math.fmod(math.floor((i-1)/2),4)+1],]]
|
|
||||||
squad = nil,
|
|
||||||
team = math.fmod(i-1,2), -- 0 == blue, 1 == green
|
|
||||||
weapon = WPN_RIFLE,
|
|
||||||
})
|
|
||||||
print("player", i, players[i].name)
|
|
||||||
end
|
|
||||||
]=]
|
|
||||||
|
|
||||||
intent[#intent+1] = new_intel({team = 0, iid = #intent+1})
|
intent[#intent+1] = new_intel({team = 0, iid = #intent+1})
|
||||||
intent[#intent+1] = new_tent({team = 0, iid = #intent+1})
|
intent[#intent+1] = new_tent({team = 0, iid = #intent+1})
|
||||||
intent[#intent+1] = new_intel({team = 1, iid = #intent+1})
|
intent[#intent+1] = new_intel({team = 1, iid = #intent+1})
|
||||||
|
@ -275,7 +275,7 @@ function new_tent(settings)
|
|||||||
plr.tent_restock()
|
plr.tent_restock()
|
||||||
end
|
end
|
||||||
|
|
||||||
if plr.has_intel then
|
if plr.has_intel and plr.team == this.team then
|
||||||
plr.intel_capture(sec_current)
|
plr.intel_capture(sec_current)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -748,9 +748,11 @@ function new_player(settings)
|
|||||||
end
|
end
|
||||||
if this.crouching or MODE_AUTOCLIMB then
|
if this.crouching or MODE_AUTOCLIMB then
|
||||||
by2 = by2 - 1
|
by2 = by2 - 1
|
||||||
|
if MODE_AUTOCLIMB then
|
||||||
|
by2 = by2 - 0.01
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if this.alive then
|
if this.alive then
|
||||||
tx1,ty1,tz1 = trace_map_box(
|
tx1,ty1,tz1 = trace_map_box(
|
||||||
ox, oy, oz,
|
ox, oy, oz,
|
||||||
@ -761,37 +763,68 @@ function new_player(settings)
|
|||||||
else
|
else
|
||||||
tx1,ty1,tz1 = nx,ny,nz
|
tx1,ty1,tz1 = nx,ny,nz
|
||||||
end
|
end
|
||||||
|
|
||||||
if this.alive and MODE_AUTOCLIMB then
|
if this.alive and MODE_AUTOCLIMB and not this.crouching then
|
||||||
|
by2 = by2 + 1.01
|
||||||
|
end
|
||||||
|
|
||||||
|
if this.alive and MODE_AUTOCLIMB and not this.crouching then
|
||||||
local jerky = ty1
|
local jerky = ty1
|
||||||
if not this.crouching then
|
|
||||||
ty1 = ty1 - 1
|
local h1a,h1b,h1c,h1d
|
||||||
by2 = by2 + 1
|
local h2a,h2b,h2c,h2d
|
||||||
end
|
local h1,h2,_
|
||||||
tx1,ty1,tz1 = trace_map_box(
|
_,h2 = trace_gap(tx1,ty1+1.0,tz1)
|
||||||
tx1,ty1,tz1,
|
h1a,h2a = trace_gap(tx1-0.39,ty1+1.0,tz1-0.39)
|
||||||
nx, ny, nz,
|
h1b,h2b = trace_gap(tx1+0.39,ty1+1.0,tz1-0.39)
|
||||||
-0.4, by1, -0.4,
|
h1c,h2c = trace_gap(tx1-0.39,ty1+1.0,tz1+0.39)
|
||||||
0.4, by2, 0.4,
|
h1d,h2d = trace_gap(tx1+0.39,ty1+1.0,tz1+0.39)
|
||||||
false)
|
|
||||||
if ty1-jerky < -0.8 and not box_is_clear(
|
if (not h1a) or (h1b and h1a < h1b) then h1a = h1b end
|
||||||
nx-0.4, ny-0.3-0.5, nz-0.4,
|
if (not h1a) or (h1c and h1a < h1c) then h1a = h1c end
|
||||||
nx+0.4, ny-0.3, nz+0.4) then
|
if (not h1a) or (h1d and h1a < h1d) then h1a = h1d end
|
||||||
this.crouching = true
|
if (not h2a) or (h2b and h2a > h2b) then h2a = h2b end
|
||||||
ty1 = ty1 + 1
|
if (not h2a) or (h2c and h2a > h2c) then h2a = h2c end
|
||||||
end
|
if (not h2a) or (h2d and h2a > h2d) then h2a = h2d end
|
||||||
if math.abs(jerky-ty1) > 0.2 then
|
|
||||||
this.jerkoffs = this.jerkoffs + jerky - ty1
|
h1 = h1a
|
||||||
|
h2 = h2a
|
||||||
|
|
||||||
|
local dh1 = (h1 and -(h1 - ty1))
|
||||||
|
local dh2 = (h2 and (h2 - ty1))
|
||||||
|
|
||||||
|
if dh2 and dh2 < by2 and dh2 > 0 then
|
||||||
|
--print("old", ty1, dh2, by2, h1, h2)
|
||||||
|
|
||||||
|
if (dh1 and dh1 < -by1) then
|
||||||
|
-- crouch
|
||||||
|
this.crouching = true
|
||||||
|
ty1 = ty1 + 1
|
||||||
|
else
|
||||||
|
-- climb
|
||||||
|
ty1 = h2 - by2
|
||||||
|
local jdiff = jerky - ty1
|
||||||
|
if math.abs(jdiff) > 0.1 then
|
||||||
|
this.jerkoffs = this.jerkoffs + jdiff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("new", ty1, this.vy)
|
||||||
|
--if this.vy > 0 then this.vy = 0 end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
this.x, this.y, this.z = tx1, ty1, tz1
|
this.x, this.y, this.z = tx1, ty1, tz1
|
||||||
|
|
||||||
this.grounded = (MODE_AIRJUMP and this.grounded) or not box_is_clear(
|
local fgrounded = not box_is_clear(
|
||||||
tx1-0.39, ty1+by2, tz1-0.39,
|
tx1-0.39, ty1+by2, tz1-0.39,
|
||||||
tx1+0.39, ty1+by2+0.1, tz1+0.39)
|
tx1+0.39, ty1+by2+0.1, tz1+0.39)
|
||||||
|
|
||||||
if this.alive and this.vy > 0 and this.grounded then
|
--print(fgrounded, tx1,ty1,tz1,by2)
|
||||||
|
|
||||||
|
this.grounded = (MODE_AIRJUMP and this.grounded) or fgrounded
|
||||||
|
|
||||||
|
if this.alive and this.vy > 0 and fgrounded then
|
||||||
this.vy = 0
|
this.vy = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user