mirror of
https://github.com/dvdvideo1234/TrackAssemblyTool.git
synced 2025-03-04 03:13:32 -05:00
Added: Maximum spawn margin via InSpawnMargin
Settings: Zero:TurnOff, Negative:Pos, Positive:Pos/Ang
This commit is contained in:
parent
1b01d87a8e
commit
02876b2d6c
@ -30,6 +30,7 @@ local mathCeil = math and math.ceil
|
||||
local mathFloor = math and math.floor
|
||||
local mathClamp = math and math.Clamp
|
||||
local mathMin = math and math.min
|
||||
local mathMax = math and math.max
|
||||
local mathNormalizeAngle = math and math.NormalizeAngle
|
||||
local gameGetWorld = game and game.GetWorld
|
||||
local tableConcat = table and table.concat
|
||||
@ -84,7 +85,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
|
||||
------------ CONFIGURE ASMLIB ------------
|
||||
|
||||
asmlib.InitBase("track","assembly")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.727")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.728")
|
||||
asmlib.SetIndexes("V" ,1,2,3)
|
||||
asmlib.SetIndexes("A" ,1,2,3)
|
||||
asmlib.SetIndexes("WV",1,2,3)
|
||||
@ -144,6 +145,7 @@ asmlib.SetBorder(gsToolPrefL.."maxmenupr", 0, 10)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxstatts", 1, 10)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxstcnt" , 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxtrmarg", 0, 1)
|
||||
asmlib.SetBorder(gsToolPrefL.."maxspmarg", -100, 100)
|
||||
asmlib.SetBorder(gsToolPrefL.."sizeucs" , 0, 50)
|
||||
asmlib.SetBorder(gsToolPrefL.."spawnrate", 1, 10)
|
||||
asmlib.SetBorder(gsToolPrefL.."sgradmenu", 1, 16)
|
||||
@ -184,6 +186,7 @@ asmlib.MakeAsmConvar("curvsmple", 50 , nil, gnServerControled, "Amount of sam
|
||||
asmlib.MakeAsmConvar("spawnrate", 1 , nil, gnServerControled, "Maximum pieces spawned in every think tick")
|
||||
asmlib.MakeAsmConvar("bnderrmod","LOG" , nil, gnServerControled, "Unreasonable position error handling mode")
|
||||
asmlib.MakeAsmConvar("maxfruse" , 50 , nil, gnServerControled, "Maximum frequent pieces to be listed")
|
||||
asmlib.MakeAsmConvar("maxspmarg", 0 , nil, gnServerControled, "Maximum spawn distance new piece created margin")
|
||||
asmlib.MakeAsmConvar("dtmessage", 1 , nil, gnServerControled, "Time interval for server addressed messages")
|
||||
asmlib.MakeAsmConvar("*sbox_max"..gsLimitName, 1500, nil, gnServerControled, "Maximum number of tracks to be spawned")
|
||||
|
||||
@ -195,6 +198,7 @@ asmlib.IsFlag("tg_context_menu", false) -- Raises whenever the user opens the ga
|
||||
asmlib.IsFlag("en_dsv_datalock", asmlib.GetAsmConvar("endsvlock", "BUL"))
|
||||
asmlib.SetOpVar("MODE_DATABASE", asmlib.GetAsmConvar("modedb" , "STR"))
|
||||
asmlib.SetOpVar("TRACE_MARGIN" , asmlib.GetAsmConvar("maxtrmarg", "FLT"))
|
||||
asmlib.SetOpVar("SPAWN_MARGIN" , asmlib.GetAsmConvar("maxspmarg", "FLT"))
|
||||
asmlib.SetOpVar("MSDELTA_SEND" , asmlib.GetAsmConvar("dtmessage", "FLT"))
|
||||
|
||||
------------ GLOBAL VARIABLES ------------
|
||||
@ -237,6 +241,10 @@ local conCallBack = asmlib.GetContainer("CALLBAC_FUNC")
|
||||
local nM = (tonumber(vNew) or 0); nM = ((nM > 0) and nM or 0)
|
||||
asmlib.SetOpVar("TRACE_MARGIN", nM)
|
||||
end})
|
||||
conCallBack:Push({"maxspmarg", function(sVar, vOld, vNew)
|
||||
local nM = (tonumber(vNew) or 0)
|
||||
asmlib.SetOpVar("SPAWN_MARGIN", nM)
|
||||
end})
|
||||
conCallBack:Push({"logsmax", function(sVar, vOld, vNew)
|
||||
local nM = asmlib.BorderValue((tonumber(vNew) or 0), "non-neg")
|
||||
asmlib.SetOpVar("LOG_MAXLOGS", nM)
|
||||
|
@ -4546,6 +4546,32 @@ function SetPosBound(ePiece,vPos,oPly,sMode)
|
||||
end; LogInstance("("..sMode..") Success"); return true
|
||||
end
|
||||
|
||||
--[[
|
||||
* Checks whenever the spawned piece is inside the previos spawn margin
|
||||
]]
|
||||
function InSpawnMargin(oRec,vPos,aAng)
|
||||
local nMarg = GetOpVar("SPAWN_MARGIN")
|
||||
if(nMarg == 0) then return false end
|
||||
if(vPos and aAng) then
|
||||
if(oRec.Mpos and oRec.Mray) then
|
||||
local nMpow = (nMarg ^ 2) -- Square root is expensive
|
||||
local nBpos = oRec.Mpos:DistToSqr(vPos) -- Distance
|
||||
if(nBpos <= nMpow) then -- Check the margin area
|
||||
LogInstance("Spawn pos ["..nBpos.."]["..nMpow.."]")
|
||||
if(nMarg < 0) then return true end -- Negative checks position
|
||||
local nMray = (1 - (nMpow * GetOpVar("EPSILON_ZERO")))
|
||||
local nBray = oRec.Mray:Dot(aAng:Forward())
|
||||
if(nBray >= nMray) then -- Positive shecks position and direction
|
||||
LogInstance("Spawn ray ["..nBray.."]["..nMray.."]"); return true
|
||||
end -- Piece angles will not align when spawned
|
||||
end -- Piece will be spawned outside of spawn margin
|
||||
oRec.Mpos:Set(vPos); oRec.Mray:Set(aAng:Forward())
|
||||
else -- Store the last location the piece was spawned
|
||||
oRec.Mpos, oRec.Mray = Vector(vPos), aAng:Forward()
|
||||
end; return false
|
||||
else oRec.Mpos, oRec.Mray = nil, nil end; return false
|
||||
end
|
||||
|
||||
function MakePiece(pPly,sModel,vPos,aAng,nMass,sBgSkIDs,clColor,sMode)
|
||||
if(CLIENT) then LogInstance("Working on client"); return nil end
|
||||
if(not IsPlayer(pPly)) then -- If not player we cannot register limit
|
||||
@ -4557,11 +4583,13 @@ function MakePiece(pPly,sModel,vPos,aAng,nMass,sBgSkIDs,clColor,sMode)
|
||||
LogInstance("Prop limit reached"); return nil end
|
||||
local stData = CacheQueryPiece(sModel) if(not IsHere(stData)) then
|
||||
LogInstance("Record missing for <"..sModel..">"); return nil end
|
||||
local aAng = Angle(aAng or GetOpVar("ANG_ZERO"))
|
||||
if(InSpawnMargin(stData, vPos, aAng)) then
|
||||
LogInstance("Spawn margin stop <"..sModel..">"); return nil end
|
||||
local sClass = GetOpVar("ENTITY_DEFCLASS")
|
||||
local ePiece = entsCreate(GetTerm(stData.Unit, sClass, sClass))
|
||||
if(not (ePiece and ePiece:IsValid())) then -- Create the piece unit
|
||||
LogInstance("Piece invalid <"..tostring(ePiece)..">"); return nil end
|
||||
local aAng = Angle(aAng or GetOpVar("ANG_ZERO"))
|
||||
ePiece:SetCollisionGroup(COLLISION_GROUP_NONE)
|
||||
ePiece:SetSolid(SOLID_VPHYSICS)
|
||||
ePiece:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
|
@ -657,6 +657,7 @@ function TOOL:GetStatus(stTr,vMsg,hdEnt)
|
||||
sDu = sDu..sSpace.." HD.BoundErrMod: <"..tostring(asmlib.GetAsmConvar("bnderrmod","STR"))..">"..sDelim
|
||||
sDu = sDu..sSpace.." HD.MaxFrequent: <"..tostring(asmlib.GetAsmConvar("maxfruse" ,"INT"))..">"..sDelim
|
||||
sDu = sDu..sSpace.." HD.MaxTrMargin: <"..tostring(asmlib.GetAsmConvar("maxtrmarg","FLT"))..">"..sDelim
|
||||
sDu = sDu..sSpace.." HD.MaxSpMargin: <"..tostring(asmlib.GetAsmConvar("maxspmarg","FLT"))..">"..sDelim
|
||||
if(hdEnt and hdEnt:IsValid()) then hdEnt:Remove() end
|
||||
return sDu
|
||||
end
|
||||
@ -1587,7 +1588,8 @@ function TOOL:Reload(stTrace)
|
||||
end
|
||||
local trRec = asmlib.CacheQueryPiece(trEnt:GetModel())
|
||||
if(asmlib.IsHere(trRec) and (asmlib.GetOwner(trEnt) == user or user:IsAdmin())) then
|
||||
trEnt:Remove(); asmlib.LogInstance("(Prop) Remove piece",gtLogs); return true
|
||||
asmlib.InSpawnMargin(trRec); trEnt:Remove()
|
||||
asmlib.LogInstance("(Prop) Remove piece",gtLogs); return true
|
||||
end; asmlib.LogInstance("(Prop) Success",gtLogs)
|
||||
end; return false
|
||||
end
|
||||
@ -2543,6 +2545,7 @@ if(CLIENT) then
|
||||
asmlib.SetCheckBox(CPanel, "devmode")
|
||||
asmlib.SetCheckBox(CPanel, "exportdb")
|
||||
asmlib.SetNumSlider(CPanel, "maxtrmarg", iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "maxspmarg", iMaxDec)
|
||||
asmlib.SetNumSlider(CPanel, "maxmenupr", 0)
|
||||
CPanel:ControlHelp(languageGetPhrase("tool."..gsToolNameL..".relica_var"))
|
||||
asmlib.SetNumSlider(CPanel, "spawnrate", 0)
|
||||
@ -2657,6 +2660,7 @@ if(CLIENT) then
|
||||
asmlib.SetAsmConvar(user, "modedb" , asmlib.GetAsmConvar("modedb" , "DEF"))
|
||||
asmlib.SetAsmConvar(user, "devmode" , asmlib.GetAsmConvar("devmode" , "DEF"))
|
||||
asmlib.SetAsmConvar(user, "maxtrmarg", asmlib.GetAsmConvar("maxtrmarg", "DEF"))
|
||||
asmlib.SetAsmConvar(user, "maxspmarg", asmlib.GetAsmConvar("maxspmarg", "DEF"))
|
||||
asmlib.SetAsmConvar(user, "maxmenupr", asmlib.GetAsmConvar("maxmenupr", "DEF"))
|
||||
asmlib.SetAsmConvar(user, "timermode", asmlib.GetAsmConvar("timermode", "DEF"))
|
||||
asmlib.SetAsmConvar(user, "maxmass" , asmlib.GetAsmConvar("maxmass" , "DEF"))
|
||||
|
@ -183,6 +183,8 @@ tool.trackassembly.devmode=Когато се разреши пуска режи
|
||||
tool.trackassembly.devmode_con=Включи режим на разработчик
|
||||
tool.trackassembly.maxtrmarg=Променете тук за да използвате различен интервал между проследяванията
|
||||
tool.trackassembly.maxtrmarg_con=Марж на проследяване\:
|
||||
tool.trackassembly.maxspmarg=Променете тук за да настроите маржа на разстоянието от предишното създаване
|
||||
tool.trackassembly.maxspmarg_con=Марж на създаване\:
|
||||
tool.trackassembly.maxmenupr=Променете тук за да използвате различен брой знаци след десетичната точка
|
||||
tool.trackassembly.maxmenupr_con=Десетични знаци\:
|
||||
tool.trackassembly.maxmass=Променете тук за да настроите максималната маза на парчетата при създаване
|
||||
|
@ -183,6 +183,8 @@ tool.trackassembly.devmode=When enabled turns on the developer mode for tracking
|
||||
tool.trackassembly.devmode_con=Enable developer mode
|
||||
tool.trackassembly.maxtrmarg=Change this to adjust the time between tool traces
|
||||
tool.trackassembly.maxtrmarg_con=Trace margin\:
|
||||
tool.trackassembly.maxspmarg=Change this to adjust the distance margin from the previous spawn
|
||||
tool.trackassembly.maxspmarg_con=Spawn margin\:
|
||||
tool.trackassembly.maxmenupr=Change this to adjust the number of the decimal places in the menu
|
||||
tool.trackassembly.maxmenupr_con=Decimal places\:
|
||||
tool.trackassembly.maxmass=Change this to adjust the maximum mass that can be applied on a piece
|
||||
|
Loading…
Reference in New Issue
Block a user