You can use the trigger_multiple method with multiple disjoint brushes. The 
various brush volumes would act as a single trigger. You would need a 
trigger_multiple, a filter_activator_class, and a math_counter to do this. Set 
the filter to only pass entities of the class that you are interested in, then 
hook up entity I/O as follows:

trigger_multiple.OnStartTouch -> math_counter.Add(1)
trigger_multiple.OnEndTouch -> math_counter.Subtract(1)
trigger_multiple.OnEndTouchAll -> math_counter.SetValue(0)

-----Original Message-----
From: hlcoders-boun...@list.valvesoftware.com 
[mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Jonas 'Sortie' 
Termansen
Sent: Wednesday, March 11, 2009 2:13 PM
To: Discussion of Half-Life Programming
Subject: Re: [hlcoders] Counting entities within a Custom Brush

How about making a trigger_multiple -alike brush entity that counts the number 
of entities in it. Everytime something new touches it, it increments an 
integer, and decreases it when the entities leave it.
----- Original Message -----
From: <n...@perforated-art.com>
To: <hlcoders@list.valvesoftware.com>
Sent: Wednesday, March 11, 2009 8:35 PM
Subject: [hlcoders] Counting entities within a Custom Brush


> I'm new to Source development and would like to get an idea for the
> best way to approach my problem before embarking on writing any code:
>
> In a mulitplayer team-based environment I'd like to count the number
> of specific entities placed within a Custom Brush's radius. The number
> of entities within the brushes radius contributes directly to a
> particular teams score and I'd like to periodically increase a teams
> score over time.
>
> Essentially then, I'm looking to check for the number of entities
> within a Custom Brushes radius at set intervals. In my mind there are
> two ways of approaching this. The first is to have the brushes think()
> function count the entities and deal with them accordingly. The second
> is to have the CGameRules class search the level for any of these
> Custom Brushes and then count the number of entities within them
> (again, at set intervals).
>
> Being new to Source, I imagine the first approach would trigger a
> Logic Entity (such as math_counter). Of course, the problem here is
> that I'd like to allow for multiple Custom Brushes, so I think my
> second solution seems more flexible, in this regard (especially seeing
> as how the number of objects within a teams collection of Custom
> Brushes _can_ result in the victory of a round). How would you
> approach this?
>
> Secondly, what do people consider 'good practice' with regards to
> custom Game Rules? Do you subclass CGameRules (or some equivalent
> class), or do you edit directly (as a number of tutorial on the VALVe
> Wiki suggest?)
>
> Basically, I'd just like feedback from people with more experience to
> see if I'm heading in the right direction. I don't want to jump in at
> the deep end and sink!
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to