/* ================ ReturnToPos1 ================ */ void ReturnToPos1( gentity_t *ent ) { MatchTeam( ent, MOVER_2TO1, level.time ); // looping sound ent->s.loopSound = ent->soundLoop; // starting sound if ( ent->sound2to1 ) { G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 ); } }
/* ====================== Think_SpawnNewDoorTrigger All of the parts of a door have been spawned, so create a trigger that encloses all of them ====================== */ void Think_SpawnNewDoorTrigger( gentity_t *ent ) { gentity_t *other; vec3_t mins, maxs; int i, best; if (!ent) { return; } // set all of the slaves as shootable for ( other = ent ; other ; other = other->teamchain ) { other->takedamage = qtrue; } // find the bounds of everything on the team VectorCopy (ent->r.absmin, mins); VectorCopy (ent->r.absmax, maxs); for (other = ent->teamchain ; other ; other=other->teamchain) { AddPointToBounds (other->r.absmin, mins, maxs); AddPointToBounds (other->r.absmax, mins, maxs); } // find the thinnest axis, which will be the one we expand best = 0; for ( i = 1 ; i < 3 ; i++ ) { if ( maxs[i] - mins[i] < maxs[best] - mins[best] ) { best = i; } } maxs[best] += 120; mins[best] -= 120; // create a trigger with this size other = G_Spawn (); other->classname = "door_trigger"; VectorCopy (mins, other->s.mins); VectorCopy (maxs, other->s.maxs); other->parent = ent; other->s.contents = CONTENTS_TRIGGER; other->touch = Touch_DoorTrigger; // remember the thinnest axis other->count = best; trap_LinkEntity (other); MatchTeam( ent, ent->moverState, level.time ); }
void Think_MatchTeam( gentity_t *ent ) { MatchTeam( ent, ent->moverState, level.time ); }
/* ================ Use_BinaryMover ================ */ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) { int total; int partial; // only the master should be used if ( ent->flags & FL_TEAMSLAVE ) { Use_BinaryMover( ent->teammaster, other, activator ); return; } ent->activator = activator; if ( ent->moverState == MOVER_POS1 ) { // start moving 50 msec later, becase if this was player // triggered, level.time hasn't been advanced yet MatchTeam( ent, MOVER_1TO2, level.time + 50 ); // starting sound if ( ent->sound1to2 ) { G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 ); } // looping sound ent->s.loopSound = ent->soundLoop; // open areaportal if ( ent->teammaster == ent || !ent->teammaster ) { trap_AdjustAreaPortalState( ent, qtrue ); } return; } // if all the way up, just delay before coming down if ( ent->moverState == MOVER_POS2 ) { ent->nextthink = level.time + ent->wait; return; } // only partway down before reversing if ( ent->moverState == MOVER_2TO1 ) { total = ent->s.pos.trDuration; partial = level.time - ent->s.pos.trTime; if ( partial > total ) { partial = total; } MatchTeam( ent, MOVER_1TO2, level.time - ( total - partial ) ); if ( ent->sound1to2 ) { G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 ); } return; } // only partway up before reversing if ( ent->moverState == MOVER_1TO2 ) { total = ent->s.pos.trDuration; partial = level.time - ent->s.pos.trTime; if ( partial > total ) { partial = total; } MatchTeam( ent, MOVER_2TO1, level.time - ( total - partial ) ); if ( ent->sound2to1 ) { G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 ); } return; } }