Raised This Month: $7 Target: $400
 1% 

[Tutorial] Creating brush entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-14-2010 , 14:25   [Tutorial] Creating brush entities
Reply With Quote #1

1st i'd like to thank foxmulder for reminding me about entity outputs otherwise i never would have bothered trying to get brushes to work.

i've only tested this in css but it should work for any game, most brush entities can be found here http://developer.valvesoftware.com/w...Brush_Entities. not all brush entities will work for different games.

please note any brush entities that are created will be invisible as only bsp brush models can be used with brush entities. only box shaped brushes work.

heres part of a snippet i used

PHP Code:
new Float:playerpos[3];
GetEntPropVector(clientProp_Send"m_vecOrigin"playerpos);

new 
entindex CreateEntityByName("trigger_push");
if (
entindex != -1)
{
    
DispatchKeyValue(entindex"pushdir""0 90 0");
    
DispatchKeyValue(entindex"speed""500");
    
DispatchKeyValue(entindex"spawnflags""64");
}

DispatchSpawn(entindex);
ActivateEntity(entindex);

TeleportEntity(entindexplayerposNULL_VECTORNULL_VECTOR);

SetEntityModel(entindex"models/props/cs_office/vending_machine.mdl");

new 
Float:minbounds[3] = {-100.0, -100.00.0};
new 
Float:maxbounds[3] = {100.0100.0200.0};
SetEntPropVector(entindexProp_Send"m_vecMins"minbounds);
SetEntPropVector(entindexProp_Send"m_vecMaxs"maxbounds);
    
SetEntProp(entindexProp_Send"m_nSolidType"2);

new 
enteffects GetEntProp(entindexProp_Send"m_fEffects");
enteffects |= 32;
SetEntProp(entindexProp_Send"m_fEffects"enteffects); 
you must set solid type to 2 (bounding box) and must set a model on the entity, it doesn't matter which as it won't be visible (remember to precache). by default the entity will try to get the solid type from the bsp which will obviously not work, also the entity will normally have a model/texture applied in hammer so it won't work if there is no model on it. when you set the model you will get an error message in the server console, its harmless. just warning you that you're trying to set a non brush model to the entity.

m_vecMins and m_vecMaxs set the dimensions of the bounding box, they are local coordinates of the entity e.g 0,0,0 will be the entities origin i.e world coordinates of the entity. in my above snippet the box is 200 by 200 by 200.

you must set the m_fEffects prop to have the ef_nodraw flag or clients will be spammed with errors in the conole every gameframe for each entity you create that doesn't have the flag.

in css i've tested func_buyzone, trigger_hurt, trigger_push and func_conveyor, certain entities might not work you'll have to try for yourself. you can addoutputs to the entities and hook the output so you can call a function whenever the output is fired. e.g you could have a trigger_once/trigger_multiple thats fires a blank output that is hooked, this will allow you to run code on whoever triggered the output.

some brush entities would require some kind of visual so you know its there like func_conveyor, since you can't apply models to the brushes you could spawn a prop_dynamic, make it non solid(depending on what brush entity you're using) and parent it to the brush and set the brush bounds to the same as the model. this way you can spawn working doors, switches, moving platforms and rotating props.

that should be useful for sandbox mods and fun stuff, in css you could create a bomb zone anywhere allowing players to plant c4 where ever they want.

Last edited by blodia; 02-09-2011 at 14:53.
blodia is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-14-2010 , 15:50   Re: [Tutorial] Creating brush entities
Reply With Quote #2

I've been wondering how to do this for a while.

Thanks!
Afronanny is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 06-14-2010 , 22:42   Re: [Tutorial] Creating brush entities
Reply With Quote #3

Good job dude

How did you figure it out?
Sammy-ROCK! is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-15-2010 , 12:56   Re: [Tutorial] Creating brush entities
Reply With Quote #4

thanks, over the years i've spent a lot of time in the source sdk and on valves wiki checking out different entities. i know from experience that if someone says something isn't possible not to take their word for it. it takes time and patience to get certain things working. also i prefer to mess with things people wouldn't bother with.
blodia is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 06-15-2010 , 16:34   Re: [Tutorial] Creating brush entities
Reply With Quote #5

How did you find out about the m_vecMins and m_vecMaxs?
Sammy-ROCK! is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-15-2010 , 16:53   Re: [Tutorial] Creating brush entities
Reply With Quote #6

i tested most netprops/dataprops over the years as i wanted to know what they did in case i ever needed them. the name gave some clue to what it did, you can use it to change the bounding box on any entity, be warned some entities will reset it r.g player bounding boxes are reset in one of the thinks, its resized depending on player movement e.g standing or crouching.
blodia is offline
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 06-15-2010 , 16:57   Re: [Tutorial] Creating brush entities
Reply With Quote #7

Always good to know that xD Also you can use SDKHooks' ThinkPost to change the bounding box on entitys like that.
Sammy-ROCK! is offline
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 06-15-2010 , 21:29   Re: [Tutorial] Creating brush entities
Reply With Quote #8

Nice job, B!
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
CarlZalph
Junior Member
Join Date: May 2010
Old 06-16-2010 , 12:40   Re: [Tutorial] Creating brush entities
Reply With Quote #9

Quote:
Originally Posted by Sammy-ROCK! View Post
How did you find out about the m_vecMins and m_vecMaxs?
If I recall, the TF2 Engineer building builder has the vector bounds to create them.

Without 'em, collision is not there, or it errors.
CarlZalph is offline
henbus
New Member
Join Date: Jun 2010
Old 06-20-2010 , 23:24   Re: [Tutorial] Creating brush entities
Reply With Quote #10

hi guys ive been trying to learn how to mod. ive been following the valve tutorials at developer.valvesoftware.com/wiki. But I am stuck on the section that teaches you how to author a brush entity http://developer.valvesoftware.com/w...a_Brush_Entity

Apparently I dont have the triggers.h and triggers.cpp files which are needed for functions that allow you to play with brush entities. So basically I can't program my brush entities. So i was wondering is this tutorial like an alternative to teaching us how to program brush entities?
henbus is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode