1
- print " navmesh.lua running..."
1
+ local function dbg (...)
2
+ Msg " [navmesh.lua] " print (... )
3
+ end
4
+
5
+ dbg " Loaded..."
2
6
local navmeshregen
3
7
pcall (require ,' landmark' )
4
8
if not landmark or not landmark .get then
5
9
system .FlashWindow ()
6
- print " UNABLE TO LOAD LANDMARK MODULE"
10
+ dbg " UNABLE TO LOAD LANDMARK MODULE"
7
11
end
8
12
9
13
if GetConVar (" con_nprint_bgalpha" ):GetString ()== " quit" then
10
- print " quitting..."
14
+ dbg " quitting..."
11
15
RunConsoleCommand (" exitgame" )
12
16
if game .ConsoleCommand then
13
17
game .ConsoleCommand ( " exitgame\n " )
@@ -46,23 +50,26 @@ hook.Add("Think","agwegwegg",function()
46
50
if i > 0 then return end
47
51
hook .Remove (" Think" ," agwegwegg" )
48
52
49
- print " \n !!!!!BUILDING NAVMESH!!!!!!!!\n "
53
+ dbg " \n !!!!!BUILDING NAVMESH!!!!!!!!\n "
50
54
if not navmeshregen then
51
- if not navmesh .IsLoaded () then navmesh .Load () end
55
+ if not navmesh .IsLoaded () then
56
+ navmesh .Load ()
57
+ end
52
58
53
59
if navmesh .IsLoaded () then
60
+ dbg " navmesh.IsLoaded()==true?"
54
61
if (file .Size (" maps/" .. game .GetMap ().. ' .nav' ,' GAME' ) or - 1 ) > 1 then
55
- print " navmesh found, leaving..."
62
+ dbg " navmesh found, leaving..."
56
63
RunConsoleCommand (" exitgame" )
57
64
return
58
65
else
59
- print " navmesh oversmall, regenerating"
66
+ dbg " navmesh oversmall, regenerating"
60
67
end
61
68
end
62
69
end
63
70
64
71
if not file .Exists (" navmesh_landmarks.txt" , ' DATA' ) then
65
- print " navmesh_landmarks.txt MISSING"
72
+ dbg " navmesh_landmarks.txt MISSING"
66
73
system .FlashWindow ()
67
74
return
68
75
end
@@ -78,27 +85,38 @@ hook.Add("Think","agwegwegg",function()
78
85
if pos then
79
86
pos = pos + offset
80
87
local tr = util .TraceLine {
81
- start = pos ,
82
- endpos = pos - Vector (0 , 0 , 512 )
88
+ start = pos + Vector ( 0 , 0 , 16 ) ,
89
+ endpos = pos + Vector (0 , 0 , - 2048 )
83
90
}
84
- if tr .Hit then
91
+ if tr .Hit and util . IsInWorld ( tr . HitPos ) and util . IsInWorld ( tr . HitPos + Vector ( 0 , 0 , 70 )) then
85
92
navmesh .AddWalkableSeed (tr .HitPos , tr .HitNormal )
93
+ dbg (" AddWalkableSeed(Vector('" .. tostring (tr .HitPos ).. " '), Vector('" .. tostring (tr .HitNormal ).. " '))" )
86
94
debugoverlay .Cross (tr .HitPos ,128 ,120 ,Color (255 ,255 ,255 ),true )
87
95
err = false
88
- else err = " trace did not hit" end
96
+ else err = " trace did not hit: " .. tostring ( lm ) end
89
97
90
- else err = " landmark missing or invalid" end
91
- else err = " could not parse name" end
98
+ else err = " landmark missing or invalid: " .. tostring ( lm ) end
99
+ else err = " could not parse name: " .. tostring ( lm ) end
92
100
if err then
93
- system .FlashWindow = system .FlashWindow or function () print (" WTF?" ,SERVER ,CLIENT ,MENU ) end
94
- print ((" Adding seed did not succeed: %s %q" ):format (err ,lm ))
101
+ system .FlashWindow = system .FlashWindow or function () dbg (" WTF?" ,SERVER ,CLIENT ,MENU ) end
102
+ dbg ((" Adding seed did not succeed: %s %q" ):format (err ,lm ))
95
103
end
96
104
end
97
- print (" begin" ,navmesh .BeginGeneration ())
105
+
106
+ local last = SysTime ()
107
+ local start = SysTime ()
108
+ hook .Add (" Think" ," elapseprint" ,function ()
109
+ local now = SysTime ()
110
+ if now - last > 10 then
111
+ last = now
112
+ dbg (" Elapsed:" ,string .NiceTime (now - start ))
113
+ end
114
+ end )
115
+ dbg (" begin" ,navmesh .BeginGeneration ())
98
116
99
117
hook .Add (" ShutDown" ," agwegwegg" ,function ()
100
- print " Quitting...? "
101
- system .FlashWindow = system .FlashWindow or function () print (" WTF?" ,SERVER ,CLIENT ,MENU ) end
118
+ dbg " Attempting to exit (feel free to close the window after 30 seconds) "
119
+ system .FlashWindow = system .FlashWindow or function () dbg (" WTF?" ,SERVER ,CLIENT ,MENU ) end
102
120
system .FlashWindow ()
103
121
RunConsoleCommand (" exitgame" )
104
122
if CLIENT then
@@ -110,12 +128,12 @@ hook.Add("Think","agwegwegg",function()
110
128
game .ConsoleCommand ( " exitgame\n " )
111
129
end
112
130
end )
113
- timer .Simple (1 ,function () print " built test? " end )
131
+ timer .Simple (1 ,function () dbg " Testing if built " end )
114
132
timer .Simple (60 * 2 ,function ()
115
133
hook .Add (" Think" ,' agwegwegg' ,function ()
116
134
if navmesh .IsGenerating () then return end
117
135
hook .Remove (" Think" ," agwegwegg" )
118
- print (" save" ,navmesh .Save ())
136
+ dbg (" save" ,navmesh .Save ())
119
137
RunConsoleCommand (" exitgame" )
120
138
end )
121
139
0 commit comments