Development Blog

Where we pretend to know how to code.


What are you doing in my area?

Published: 2011-03-27

Author: Teddi

I couldn’t really think of a better title, but there you go.

For most of tonight I’ve been working on the area system. It invoulntarily came up whilst Whitefang and I were working on ZE. We were discussing the gun upgrade system (ie do x, get upgrade) and then we were talking about being the first to x objective and getting something from it. He suggested we use the area system which I disagreed with. For a while now I’ve been trying to rewrite the current area system as performance wise, it sucks. It does the job it was intended to do pretty okay, but it has a few glitches and problems I’d like to resolve.

So Whitefang was like hurr rewrite it. I told him (which he already knew) that the function was broken (Cpf also played with this a while back and couldn’t get it working himself), and to go do better himself. So he experimented and came up with more results than I initially did. It did spur me however to work on it again. However I think now after working for the past four hours on it, that his victory was somewhat shortlived.

I was trying to use http://wiki.garrysmod.com/?title=Entity.SetCollisionBoundsWS and misinterpreted it (or Garry just never added it properly). Whitefang seemed to get some minor results out it, however after playing with it for a while I didn’t get anything that successful out of it, for various reasons.

I knew about http://wiki.garrysmod.com/?title=Entity.SetCollisionBounds, however I had veered away from it simply due to the fact that I figured if anything, the former function would have been better and less hassle. After some playing and work, it’s slightly more elaborate, but it does the job and it does it damn well. So well I can pretty much use sources debugging and have it show me the exact boundaries of the new areas.

(map deathrun_sk_jail_v3 which was removed due to a few ways for runners / death to get in / out).

area system

The white boxes represent the two areas that I added to that map (both kill you, the one in front of the vent was just for testing). With the old system if there was a server hiccup or you were fast enough  you could actually get through an area. This was never intended and was pretty annoying when it did happen. Because this uses sources native trigger system it means that as long as you’ve passed through it, source will pick it up and then perform the specific task on you (which can be to kill, teleport, etc etc). The upside of this is that it means less work for the server to do, and hopefully far less crashes. The old system used the move hook and it cycled through a table every few seconds with a timer. This would eat up memory and the garbage collector really wouldn’t like this.

What’s even better is that this new system can now be applied to any gamemode we want. Surf, ZE, Lobby, RP, you name it, we can add it.


Historical Posts