diff options
author | Tim Angus <tim@ngus.net> | 2004-06-01 16:06:33 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2004-06-01 16:06:33 +0000 |
commit | 39b9fa4274fee270f9b67f3a7c4a18e0acceb675 (patch) | |
tree | 9b1e197e7e00923b258a0fdf2594214d4c1dec0f /src | |
parent | e16e27154c005438d1c5a0f756a8c3e3bbdb2a49 (diff) |
* Surfaceparms "nobuildsurface", "noalienbuildsurface" and "nohumanbuildsurface"
now prevent building on a surface, whereas surfaceparms "nobuild",
"noalienbuild" and "nohumanbuild" now prevent building within the confines of
a brush they're applied to.
* Buildables now trigger trigger_multiples and trigger_hurts
* Buildables don't trigger doors
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_active.c | 13 | ||||
-rw-r--r-- | src/game/g_buildable.c | 70 | ||||
-rw-r--r-- | src/game/g_mover.c | 4 | ||||
-rw-r--r-- | src/game/g_trigger.c | 2 | ||||
-rw-r--r-- | src/game/surfaceflags.h | 6 |
5 files changed, 89 insertions, 6 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index dc00b0a7..f01e2379 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -241,7 +241,8 @@ void G_TouchTriggers( gentity_t *ent ) gentity_t *hit; trace_t trace; vec3_t mins, maxs; - static vec3_t range = { 40, 40, 52 }; + vec3_t pmins, pmaxs; + static vec3_t range = { 10, 10, 10 }; if( !ent->client ) return; @@ -250,8 +251,14 @@ void G_TouchTriggers( gentity_t *ent ) if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 ) return; - VectorSubtract( ent->client->ps.origin, range, mins ); - VectorAdd( ent->client->ps.origin, range, maxs ); + BG_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], + pmins, pmaxs, NULL, NULL, NULL ); + + VectorAdd( ent->client->ps.origin, pmins, mins ); + VectorAdd( ent->client->ps.origin, pmaxs, maxs ); + + VectorSubtract( mins, range, mins ); + VectorAdd( maxs, range, maxs ); num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index ad3b4c29..b0586166 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -2180,6 +2180,64 @@ void HSpawn_Think( gentity_t *self ) //================================================================================== +/* +============ +G_BuildableTouchTriggers + +Find all trigger entities that a buildable touches. +============ +*/ +void G_BuildableTouchTriggers( gentity_t *ent ) +{ + int i, num; + int touch[ MAX_GENTITIES ]; + gentity_t *hit; + trace_t trace; + vec3_t mins, maxs; + vec3_t bmins, bmaxs; + static vec3_t range = { 10, 10, 10 }; + + // dead buildables don't activate triggers! + if( ent->health <= 0 ) + return; + + BG_FindBBoxForBuildable( ent->s.modelindex, bmins, bmaxs ); + + VectorAdd( ent->s.origin, bmins, mins ); + VectorAdd( ent->s.origin, bmaxs, maxs ); + + VectorSubtract( mins, range, mins ); + VectorAdd( maxs, range, maxs ); + + num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); + + VectorAdd( ent->s.origin, bmins, mins ); + VectorAdd( ent->s.origin, bmaxs, maxs ); + + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + + if( !hit->touch ) + continue; + + if( !( hit->r.contents & CONTENTS_TRIGGER ) ) + continue; + + //ignore buildables not yet spawned + if( !ent->spawned ) + continue; + + if( !trap_EntityContact( mins, maxs, hit ) ) + continue; + + memset( &trace, 0, sizeof( trace ) ); + + if( hit->touch ) + hit->touch( hit, ent, &trace ); + } +} + /* =============== @@ -2238,6 +2296,9 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->clientSpawnTime < 0 ) ent->clientSpawnTime = 0; + //check if this buildable is touching any triggers + G_BuildableTouchTriggers( ent ); + //fall back on normal physics routines G_Physics( ent, msec ); } @@ -2295,6 +2356,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance int templength; float minNormal; qboolean invert; + int contents; playerState_t *ps = &ent->client->ps; BG_FindBBoxForBuildable( buildable, mins, maxs ); @@ -2325,6 +2387,8 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( G_CheckSpawnPoint( origin, normal, buildable, NULL ) != NULL ) return IBE_NORMAL; + contents = trap_PointContents( entity_origin, -1 ); + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { //alien criteria @@ -2348,7 +2412,8 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance } //check permission to build here - if( tr1.surfaceFlags & SURF_NOALIENBUILD ) + if( tr1.surfaceFlags & SURF_NOALIENBUILD || tr1.surfaceFlags & SURF_NOBUILD || + contents & CONTENTS_NOALIENBUILD || contents & CONTENTS_NOBUILD ) reason = IBE_PERMISSION; //look for a hivemind @@ -2423,7 +2488,8 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance } //check permission to build here - if( tr1.surfaceFlags & SURF_NOHUMANBUILD ) + if( tr1.surfaceFlags & SURF_NOHUMANBUILD || tr1.surfaceFlags & SURF_NOBUILD || + contents & CONTENTS_NOHUMANBUILD || contents & CONTENTS_NOBUILD ) reason = IBE_PERMISSION; //can we only build one of these? diff --git a/src/game/g_mover.c b/src/game/g_mover.c index 3bc4e94b..b3c01069 100644 --- a/src/game/g_mover.c +++ b/src/game/g_mover.c @@ -1285,6 +1285,10 @@ Touch_DoorTrigger */ void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) { + //buildables don't trigger movers + if( other->s.eType == ET_BUILDABLE ) + return; + if( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR ) { // if the door is not open and not opening diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c index a1ebad84..cffa0e66 100644 --- a/src/game/g_trigger.c +++ b/src/game/g_trigger.c @@ -79,7 +79,7 @@ void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) { - if( !other->client ) + if( !other->client && other->s.eType != ET_BUILDABLE ) return; multi_trigger( self, other ); diff --git a/src/game/surfaceflags.h b/src/game/surfaceflags.h index a6d68dfa..d7d721b4 100644 --- a/src/game/surfaceflags.h +++ b/src/game/surfaceflags.h @@ -52,6 +52,11 @@ #define CONTENTS_TRIGGER 0x40000000 #define CONTENTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) +//TA: custominfoparms below +#define CONTENTS_NOALIENBUILD 0x1000 // disallow alien building +#define CONTENTS_NOHUMANBUILD 0x2000 // disallow alien building +#define CONTENTS_NOBUILD 0x4000 // disallow alien building + #define SURF_NODAMAGE 0x1 // never give falling damage #define SURF_SLICK 0x2 // effects game physics #define SURF_SKY 0x4 // lighting from environment map @@ -75,4 +80,5 @@ //TA: custominfoparms below #define SURF_NOALIENBUILD 0x80000 // disallow alien building #define SURF_NOHUMANBUILD 0x100000 // disallow alien building +#define SURF_NOBUILD 0x200000 // disallow alien building |