|
|
@ -7,6 +7,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
Quantum.Node = {} -- lib |
|
|
|
Quantum.Node = {} -- lib |
|
|
|
Quantum.Nodes = {} -- container for vars |
|
|
|
Quantum.Nodes = {} -- container for vars |
|
|
|
|
|
|
|
Quantum.NodesLocations = {} |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Node.Create( nodeid, tbl ) |
|
|
|
function Quantum.Node.Create( nodeid, tbl ) |
|
|
|
local node = { |
|
|
|
local node = { |
|
|
@ -65,15 +66,24 @@ if SERVER then |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Node.RemoveAllPerma() |
|
|
|
|
|
|
|
for k, node in pairs( ents.FindByClass("q_node") ) do |
|
|
|
|
|
|
|
node:Remove() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Node.Register( nodeid, vec, ang1 ) |
|
|
|
function Quantum.Node.Register( nodeid, vec, ang1 ) |
|
|
|
Quantum.Nodes[ #Quantum.Nodes + 1 ] = { id = nodeid, pos = vec, ang = ang1 } |
|
|
|
Quantum.NodesLocations[ #Quantum.NodesLocations + 1 ] = { id = nodeid, pos = vec, ang = ang1 } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Quantum.Node.SpawnAllRegistered() |
|
|
|
function Quantum.Node.SpawnAllRegistered() |
|
|
|
local nodeTbl |
|
|
|
local nodeTbl |
|
|
|
for k, v in pairs( Quantum.Nodes ) do |
|
|
|
for k, v in pairs( Quantum.NodesLocations ) do |
|
|
|
nodeTbl = Quantum.Node.Get( v.id ) |
|
|
|
nodeTbl = Quantum.Node.Get( v.id ) |
|
|
|
if( nodeTbl != nil ) then |
|
|
|
if( nodeTbl != nil ) then |
|
|
|
|
|
|
|
Quantum.Debug( "----Node-Spawning-Info----" ) |
|
|
|
|
|
|
|
PrintTable(v) |
|
|
|
|
|
|
|
Quantum.Debug( "--------------------------" ) |
|
|
|
Quantum.Node.Spawn( v.id, v.pos, v.ang, nodeTbl.respawndelay, nodeTbl.probability ) |
|
|
|
Quantum.Node.Spawn( v.id, v.pos, v.ang, nodeTbl.respawndelay, nodeTbl.probability ) |
|
|
|
else |
|
|
|
else |
|
|
|
Quantum.Error( "Tried to spawn an invalid node ('" .. v.id .. "')!" ) |
|
|
|
Quantum.Error( "Tried to spawn an invalid node ('" .. v.id .. "')!" ) |
|
|
@ -89,6 +99,13 @@ if SERVER then |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "PlayerDisconnected", "Quantum_Nodes_RemoveOnNoPlayers", function() |
|
|
|
|
|
|
|
Quantum.Debug( "Removing all nodes..." ) |
|
|
|
|
|
|
|
if( #player.GetAll() - 1 <= 0 ) then |
|
|
|
|
|
|
|
Quantum.Node.RemoveAllPerma() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
local function randomizeLootTable( tbl, prob ) |
|
|
|
local function randomizeLootTable( tbl, prob ) |
|
|
|
local n = math.Rand( 0.00000000001, 1 ) |
|
|
|
local n = math.Rand( 0.00000000001, 1 ) |
|
|
|
Quantum.Debug( "Probability: " .. n .. " <= " .. prob ) |
|
|
|
Quantum.Debug( "Probability: " .. n .. " <= " .. prob ) |
|
|
|