Enhanced block building
Much easier to build bridges, bases etc. now. Especially under fire.
This commit is contained in:
parent
d4f68b6f92
commit
a0dd8ea25a
@ -392,6 +392,8 @@ mdl_test = client.model_load_pmf("pkg/base/pmf/test.pmf")
|
||||
mdl_test_bone = client.model_bone_find(mdl_test, "test")
|
||||
mdl_cube = client.model_load_pmf("pkg/base/pmf/cube.pmf")
|
||||
mdl_cube_bone = client.model_bone_find(mdl_cube, "bncube")
|
||||
mdl_Xcube = client.model_load_pmf("pkg/base/pmf/Xcube.pmf")
|
||||
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_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")
|
||||
|
@ -95,6 +95,7 @@ MODE_BLOCK_HEALTH = 100
|
||||
MODE_BLOCK_DAMAGE_SPADE = 34
|
||||
MODE_BLOCK_DAMAGE_RIFLE = 34
|
||||
MODE_BLOCK_REGEN_TIME = 15.0
|
||||
MODE_BLOCK_PLACE_IN_AIR = false --TODO: make this a server config variable, maybe godmode?
|
||||
|
||||
MODE_RCIRC_LINGER = 60.0
|
||||
MODE_RESPAWN_TIME = 8.0
|
||||
|
@ -451,5 +451,23 @@ function map_block_pick(x,y,z)
|
||||
local t = map_pillar_raw_get(x,z)
|
||||
local c = t[y+1]
|
||||
|
||||
if c==nil then error(x..","..y..","..z) end
|
||||
|
||||
return c[1],c[2],c[3],c[4]
|
||||
end
|
||||
|
||||
--checks for neighbors
|
||||
function map_is_buildable(x, y, z)
|
||||
local xlen,ylen,zlen
|
||||
xlen,ylen,zlen = common.map_get_dims()
|
||||
--warning! a long condition
|
||||
if map_block_get(x,y,z) == nil then
|
||||
if map_block_get(x + 1,y,z) ~= nil or map_block_get(x - 1,y,z) ~= nil or map_block_get(x,y + 1,z) ~= nil or map_block_get(x,y - 1,z) ~= nil or map_block_get(x,y,z - 1) ~= nil or map_block_get(x,y,z + 1) ~= nil then
|
||||
if x >=0 and x < xlen and y >= 0 and y < ylen - 2 and z >= 0 and z < zlen then
|
||||
return true;
|
||||
end
|
||||
end
|
||||
else
|
||||
return false;
|
||||
end
|
||||
end
|
@ -115,7 +115,9 @@ function box_is_clear(x1,y1,z1,x2,y2,z2,canwrap)
|
||||
return true
|
||||
end
|
||||
|
||||
function trace_map_ray_dist(x1,y1,z1, vx,vy,vz, maxdist)
|
||||
function trace_map_ray_dist(x1,y1,z1, vx,vy,vz, maxdist, nil_on_maxdist)
|
||||
if nil_on_maxdist == nil then nil_on_maxdist = true end
|
||||
|
||||
local function depsilon(d)
|
||||
if d < 0.0000001 then
|
||||
return 0.0000001
|
||||
@ -187,7 +189,12 @@ function trace_map_ray_dist(x1,y1,z1, vx,vy,vz, maxdist)
|
||||
end
|
||||
|
||||
dist = dist + t
|
||||
if dist > maxdist then return nil, nil, nil, nil, nil, nil, nil end
|
||||
|
||||
if dist > maxdist and nil_on_maxdist then
|
||||
return nil, nil, nil, nil, nil, nil, nil
|
||||
elseif dist > maxdist and not nil_on_maxdist then
|
||||
return dist, cx, cy, cz, ncx, ncy, ncz
|
||||
end
|
||||
|
||||
local i=1
|
||||
while true do
|
||||
|
@ -733,7 +733,7 @@ function new_player(settings)
|
||||
if this.tool == TOOL_BLOCK and this.blx1 then
|
||||
if (not this.t_newblock) and this.blocks > 0 then
|
||||
if this.blx1 >= 0 and this.blx1 < xlen and this.blz1 >= 0 and this.blz1 < zlen then
|
||||
if this.bly1 <= ylen-3 then
|
||||
if this.bly1 <= ylen-3 and map_is_buildable(this.blx1, this.bly1, this.blz1) then
|
||||
common.net_send(nil, common.net_pack("BHHHBBBB",
|
||||
0x08,
|
||||
this.blx1, this.bly1, this.blz1,
|
||||
@ -1037,7 +1037,8 @@ function new_player(settings)
|
||||
td,
|
||||
this.blx1, this.bly1, this.blz1,
|
||||
this.blx2, this.bly2, this.blz2
|
||||
= trace_map_ray_dist(camx,camy,camz, fwx,fwy,fwz, 5)
|
||||
= trace_map_ray_dist(camx,camy,camz, fwx,fwy,fwz, 5, false)
|
||||
|
||||
|
||||
this.bld1 = td
|
||||
this.bld2 = td
|
||||
@ -1814,6 +1815,7 @@ function new_player(settings)
|
||||
|
||||
-- TODO: wireframe cube
|
||||
if this.tool == TOOL_BLOCK and this.blx1 and (this.alive or this.respawning) then
|
||||
if map_is_buildable(this.blx1, this.bly1, this.blz1) or MODE_BLOCK_PLACE_IN_AIR then
|
||||
bname, mdl_data = client.model_bone_get(mdl_cube, mdl_cube_bone)
|
||||
|
||||
mdl_data_backup = mdl_data
|
||||
@ -1831,7 +1833,14 @@ function new_player(settings)
|
||||
client.model_render_bone_global(mdl_cube, mdl_cube_bone,
|
||||
this.blx1+0.5, this.bly1+0.5, this.blz1+0.5,
|
||||
0.0, 0.0, 0.0, 24.0) --no rotation, 24 roughly equals the cube size
|
||||
elseif this.tool == TOOL_SPADE and this.blx1 and (this.alive or this.respawning) then
|
||||
|
||||
else
|
||||
client.model_render_bone_global(mdl_Xcube, mdl_Xcube_bone,
|
||||
this.blx1+0.5, this.bly1+0.5, this.blz1+0.5,
|
||||
0.0, 0.0, 0.0, 24.0)
|
||||
print(this.blx1.." "..this.bly1.." "..this.blz1)
|
||||
end
|
||||
elseif this.tool == TOOL_SPADE and this.blx1 and (this.alive or this.respawning) and map_block_get(this.blx2, this.bly2, this.blz2) then
|
||||
client.model_render_bone_global(mdl_test, mdl_test_bone,
|
||||
this.blx1+0.5, this.bly1+0.5, this.blz1+0.5,
|
||||
rotpos*0.01, rotpos*0.004, 0.0, 0.1+0.01*math.sin(rotpos*0.071))
|
||||
|
BIN
pkg/base/pmf/Xcube.pmf
Normal file
BIN
pkg/base/pmf/Xcube.pmf
Normal file
Binary file not shown.
BIN
tools/Xcube.kv6
Normal file
BIN
tools/Xcube.kv6
Normal file
Binary file not shown.
1
tools/kv62pmf_Xcube_convert_win.bat
Normal file
1
tools/kv62pmf_Xcube_convert_win.bat
Normal file
@ -0,0 +1 @@
|
||||
kv62pmf.py Xcube.kv6 Xcube.pmf 1 1 bnXcube
|
Loading…
x
Reference in New Issue
Block a user