diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_public.h | 4 | ||||
-rw-r--r-- | src/game/g_buildable.c | 16 | ||||
-rw-r--r-- | src/game/g_local.h | 7 | ||||
-rw-r--r-- | src/game/g_misc.c | 45 | ||||
-rw-r--r-- | src/game/g_spawn.c | 25 |
5 files changed, 91 insertions, 6 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 8886f74a..09f5ecf3 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -636,6 +636,9 @@ typedef enum ATTACK1, ATTACK2, + SPAWN1, + SPAWN2, + PAIN1, PAIN2, @@ -1007,6 +1010,7 @@ typedef enum { ET_TORCH, //TA: torch type ET_CORPSE, ET_SPRITER, + ET_ANIMMAPOBJ, ET_EVENTS // any of the EV_* events can be added freestanding // by setting eType to ET_EVENTS + eventNum diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index de0700ed..c9c5fdb7 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -28,6 +28,18 @@ /* ================ +G_setBuildableAnim + +Triggers an animation client side +================ +*/ +void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ) +{ + ent->s.torsoAnim = anim; +} + +/* +================ findPower attempt to find power for self, return qtrue if successful @@ -1284,7 +1296,9 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { built->s.pos.trType = TR_GRAVITY; built->s.pos.trTime = level.time; - trap_LinkEntity (built); + G_setBuildableAnim( built, CONSTRUCT1 ); + + trap_LinkEntity( built ); return built; } diff --git a/src/game/g_local.h b/src/game/g_local.h index c8273e4c..64d3f3de 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -189,6 +189,8 @@ struct gentity_s { int credits[ MAX_CLIENTS ]; //TA: human credits for each client qboolean creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit int killedBy; //TA: clientNum of killer + + vec4_t animation; //TA: animated map objects }; typedef enum { @@ -540,8 +542,9 @@ typedef enum IBE_MAXERRORS } itemBuildError_t; -itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ); -gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ); +itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ); +gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ); +void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); // // g_utils.c diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 27f0450b..03530500 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -375,7 +375,7 @@ void SP_use_spriter( gentity_t *self, gentity_t *other, gentity_t *activator ) } //TA: spawn function for spriter -void SP_spriter( gentity_t *self ) +void SP_misc_spriter( gentity_t *self ) { vec3_t accel; @@ -416,3 +416,46 @@ void SP_spriter( gentity_t *self ) trap_LinkEntity( self ); } + +//TA: use function for anim model +void SP_use_anim_model( gentity_t *self, gentity_t *other, gentity_t *activator ) +{ + if( self->spawnflags & 1 ) + { + //if spawnflag 1 is set + //toggle EF_NODRAW + if( self->s.eFlags & EF_NODRAW ) + self->s.eFlags &= ~EF_NODRAW; + else + self->s.eFlags |= EF_NODRAW; + } + else + { + //if the animation loops then toggle the animation + //toggle EF_MOVER_STOP + if( self->s.eFlags & EF_MOVER_STOP ) + self->s.eFlags &= ~EF_MOVER_STOP; + else + self->s.eFlags |= EF_MOVER_STOP; + } +} + +//TA: spawn function for anim model +void SP_misc_anim_model( gentity_t *self ) +{ + self->s.powerups = (int)self->animation[ 0 ]; + self->s.weapon = (int)self->animation[ 1 ]; + self->s.torsoAnim = (int)self->animation[ 2 ]; + self->s.legsAnim = (int)self->animation[ 3 ]; + + self->s.angles2[ 0 ] = self->pos2[ 0 ]; + + //add the model to the client precache list + self->s.modelindex = G_ModelIndex( self->model ); + + self->use = SP_use_anim_model; + + self->s.eType = ET_ANIMMAPOBJ; + + trap_LinkEntity( self ); +} diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 37dbc82e..7655e442 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -73,6 +73,15 @@ qboolean G_SpawnVector( const char *key, const char *defaultString, float *out return present; } +qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out ) { + char *s; + qboolean present; + + present = G_SpawnString( key, defaultString, &s ); + sscanf( s, "%f %f %f %f", &out[0], &out[1], &out[2], &out[3] ); + return present; +} + // @@ -84,6 +93,7 @@ typedef enum { F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL F_GSTRING, // string on disk, pointer in memory, TAG_GAME F_VECTOR, + F_VECTOR4, //TA F_ANGLEHACK, F_ENTITY, // index on disk, pointer in memory F_ITEM, // index on disk, pointer in memory @@ -123,6 +133,7 @@ field_t fields[] = { {"alpha", FOFS(pos1), F_VECTOR}, {"radius", FOFS(pos2), F_VECTOR}, {"acceleration", FOFS(acceleration), F_VECTOR}, + {"animation", FOFS(animation), F_VECTOR4}, //TA {"targetShaderName", FOFS(targetShaderName), F_LSTRING}, {"targetShaderNewName", FOFS(targetShaderNewName), F_LSTRING}, @@ -202,7 +213,8 @@ void SP_team_CTF_redspawn( gentity_t *ent ); void SP_team_CTF_bluespawn( gentity_t *ent ); //TA: -void SP_spriter( gentity_t *ent ); +void SP_misc_spriter( gentity_t *ent ); +void SP_misc_anim_model( gentity_t *ent ); spawn_t spawns[] = { // info entities don't do anything at all, but provide positional @@ -275,7 +287,8 @@ spawn_t spawns[] = { {"team_CTF_redspawn", SP_team_CTF_redspawn}, {"team_CTF_bluespawn", SP_team_CTF_bluespawn}, - {"spriter", SP_spriter}, + {"misc_spriter", SP_misc_spriter}, + {"misc_anim_model", SP_misc_anim_model}, {0, 0} }; @@ -372,6 +385,7 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) { byte *b; float v; vec3_t vec; + vec4_t vec4; for ( f=fields ; f->name ; f++ ) { if ( !Q_stricmp(f->name, key) ) { @@ -388,6 +402,13 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) { ((float *)(b+f->ofs))[1] = vec[1]; ((float *)(b+f->ofs))[2] = vec[2]; break; + case F_VECTOR4: + sscanf (value, "%f %f %f %f", &vec4[0], &vec4[1], &vec4[2], &vec4[3]); + ((float *)(b+f->ofs))[0] = vec4[0]; + ((float *)(b+f->ofs))[1] = vec4[1]; + ((float *)(b+f->ofs))[2] = vec4[2]; + ((float *)(b+f->ofs))[3] = vec4[3]; + break; case F_INT: *(int *)(b+f->ofs) = atoi(value); break; |