mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 05:57:24 +01:00
49 lines
4.2 KiB
HTML
49 lines
4.2 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../../../"><link rel="stylesheet" href="dmdoc.css"><title>code/modules/mob/camera/README.md - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a></header><main><h1>AI Freelook <aside>code/modules/mob/camera/README.md</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/modules/mob/camera/README.md"><img src="git.png" width="16" height="16" title="code/modules/mob/camera/README.md"></a></h1><table class="summary" cellspacing="0"><tr><td colspan="2"><h2 id="credits">Credits</h2>
|
|
<p>Initial code credit for this goes to Uristqwerty.
|
|
Debugging, functionality, all comments and porting by Giacom.</p>
|
|
<h2 id="what-is-this">What is this?</h2>
|
|
<p>This is a replacement for the current camera movement system, of the AI. Before
|
|
this, the AI had to move between cameras and could only see what the cameras
|
|
could see. Not only this but the cameras could see through walls, which created
|
|
problems. With this, the AI controls an "AI Eye" mob, which moves just like a
|
|
ghost; such as moving through walls and being invisible to players. The AI's eye
|
|
is set to this mob and then we use a system (explained below) to determine what
|
|
the cameras around the AI Eye can and cannot see. If the camera cannot see a
|
|
turf, it will black it out, otherwise it won't and the AI will be able to see
|
|
it. This creates several features, such as.. no more see-through-wall cameras,
|
|
easier to control camera movement, easier tracking, the AI only being able to
|
|
track mobs which are visible to a camera, only trackable mobs appearing on the
|
|
mob list and many more.</p>
|
|
<h2 id="how-it-works">How it Works</h2>
|
|
<p>It works by first creating a camera network datum. Inside of this camera network
|
|
are "chunks" (which will be explained later) and "cameras". The cameras list is
|
|
kept up to date by obj/machinery/camera/New() and Destroy().</p>
|
|
<p>Next the camera network has chunks. These chunks are a 16x16 tile block of turfs
|
|
and cameras contained inside the chunk. These turfs are then sorted out based on
|
|
what the cameras can and cannot see. If none of the cameras can see the turf,
|
|
inside the 16x16 block, it is listed as an "obscured" turf. Meaning the AI won't
|
|
be able to see it.</p>
|
|
<h2 id="how-it-updates">How it Updates</h2>
|
|
<p>The camera network uses a streaming method in order to effeciently update
|
|
chunks. Since the server will have doors opening, doors closing, turf being
|
|
destroyed and other lag inducing stuff, we want to update it under certain
|
|
conditions and not every tick.</p>
|
|
<p>The chunks are not created straight away, only when an AI eye moves into it's
|
|
area is when it gets created. One a chunk is created, when a non glass door
|
|
opens/closes or an opacity turf is destroyed, we check to see if an AI Eye is
|
|
looking in the area. We do this with the "seenby" list, which updates everytime
|
|
an AI is near a chunk. If there is an AI eye inside the area, we update the
|
|
chunk that the changed atom is inside and all surrounding chunks, since a
|
|
camera's vision could leak onto another chunk. If there is no AI Eye, we instead
|
|
flag the chunk to update whenever it is loaded by an AI Eye. This is basically
|
|
how the chunks update and keep it in sync. We then add some lag reducing
|
|
measures, such as an UPDATE_BUFFER which stops a chunk from updating too many
|
|
times in a certain time-frame, only updating if the changed atom was blocking
|
|
sight; for example, we don't update glass airlocks or floors.</p>
|
|
<h2 id="where-is-everything">Where is Everything?</h2>
|
|
<ul>
|
|
<li><code>cameranet.dm</code>: Everything about the cameranet datum.</li>
|
|
<li><code>chunk.dm</code>: Everything about the chunk datum.</li>
|
|
<li><code>eye.dm</code>: Everything about the AI and the AIEye.</li>
|
|
<li><code>updating.dm</code>: Everything about triggers that will update chunks.</li>
|
|
</ul></td></tr></table></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/8a8a00a2a9bec485351e5f219982b7315d3504fa">8a8a00a</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html> |