AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Tutorial] Creating brush entities (https://forums.alliedmods.net/showthread.php?t=129597)

blodia 06-14-2010 14:25

[Tutorial] Creating brush entities
 
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.

Afronanny 06-14-2010 15:50

Re: [Tutorial] Creating brush entities
 
I've been wondering how to do this for a while.

Thanks!
:crab::crab::crab:

Sammy-ROCK! 06-14-2010 22:42

Re: [Tutorial] Creating brush entities
 
Good job dude

How did you figure it out?

blodia 06-15-2010 12:56

Re: [Tutorial] Creating brush entities
 
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.

Sammy-ROCK! 06-15-2010 16:34

Re: [Tutorial] Creating brush entities
 
How did you find out about the m_vecMins and m_vecMaxs?

blodia 06-15-2010 16:53

Re: [Tutorial] Creating brush entities
 
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.

Sammy-ROCK! 06-15-2010 16:57

Re: [Tutorial] Creating brush entities
 
Always good to know that xD Also you can use SDKHooks' ThinkPost to change the bounding box on entitys like that.

strontiumdog 06-15-2010 21:29

Re: [Tutorial] Creating brush entities
 
Nice job, B!

CarlZalph 06-16-2010 12:40

Re: [Tutorial] Creating brush entities
 
Quote:

Originally Posted by Sammy-ROCK! (Post 1209831)
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.

henbus 06-20-2010 23:24

Re: [Tutorial] Creating brush entities
 
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?


All times are GMT -4. The time now is 10:03.

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