Пример #1
0
//=========================================================================
// Function handling the Engineer's build impulse
void TeamFortress_EngineerBuild(  )
{
    gedict_t *te;

/*    if ( !( ( int ) self->s.v.flags & FL_ONGROUND ) )
    {
	CenterPrint( self, "You can't build in the air!\n\n" );
	return;
    }*/
    // Pop up the menu
    if ( !self->is_building )
    {
        if(!tg_data.tg_enabled)
        {
        	if ( self->s.v.ammo_cells < 100 && !self->has_dispenser && !self->has_sentry )
        	{
        	    CenterPrint( self, "You don't have enough metal to \nbuild anything.\n\n" );
        	    return;
        	}
        }
	self->current_menu = MENU_ENGINEER;
	self->menu_count = MENU_REFRESH_RATE;
    } else
    {
//	if ( self->is_building == 1 )
//	{
	    G_sprint( self, 2, "You stop building.\n" );
	    self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE );
	    TeamFortress_SetSpeed( self );
	    // Remove the timer
	    for ( te = world; (te = trap_find( te, FOFS( s.v.netname ), "build_timer" )); )
	    {
		if ( te->s.v.owner == EDICT_TO_PROG( self ) )
		{
		    dremove( te );
		    break;
		}
	    }
	    self->is_building = 0;
	    self->current_weapon = self->s.v.weapon;
	    W_SetCurrentAmmo(  );
//	}
    }
}
Пример #2
0
void TeamFortress_FinishedBuilding(  )
{
    gedict_t *oldself;
    gedict_t *owner;
    vec3_t  end;


    owner = PROG_TO_EDICT( self->s.v.owner );
    if ( owner->is_building != 1 )
	return;

    if ( self->s.v.weapon == BUILD_SENTRYGUN && tg_data.tg_enabled )
    {
    	
	VectorCopy( self->s.v.origin, end );
	end[2] -= 2048;
	TraceCapsule( PASSVEC3( self->s.v.origin ), PASSVEC3( end ), 0, self, -16, -16, 0, 16, 16, 4 );
	VectorCopy( g_globalvars.trace_endpos, end );
	end[2]++;
	setorigin( self, PASSVEC3( end ) );
    }
    oldself = self;
    self = owner;
    oldself->s.v.owner = 0;
    oldself->real_owner = self;
    self->is_building = 0;
    self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE );
    self->current_weapon = self->s.v.weapon;
    self->StatusRefreshTime = g_globalvars.time + 0.1;
    TeamFortress_SetSpeed( self );
    if ( oldself->s.v.weapon == BUILD_DISPENSER )
    {
	self->has_dispenser = self->has_dispenser + 1;
	G_sprint( self, 2, "You finish building the dispenser.\n" );
	teamsprint( self->team_no, self, self->s.v.netname );
	teamsprint( self->team_no, self, " has built a Dispenser.\n" );

        if( !tg_data.tg_enabled )
		self->s.v.ammo_cells = self->s.v.ammo_cells - 100;

	// Create the dispenser
	oldself->s.v.classname = "building_dispenser";
	oldself->s.v.netname = "dispenser";
	oldself->s.v.blocked = ( func_t ) T_Dispenser;
	oldself->s.v.touch = ( func_t ) T_Dispenser;
	oldself->s.v.max_health = BUILD_HEALTH_DISPENSER;
	oldself->s.v.health = BUILD_HEALTH_DISPENSER;
	oldself->hook_out = 1;
	oldself->s.v.think = ( func_t ) DispenserThink;
	oldself->s.v.nextthink = g_globalvars.time + 3;
	oldself->th_die = Dispenser_Die;
	//oldself->mdl = "progs/disp.mdl";
	oldself->mdl = "progs/dispencr.mdl";
	oldself->team_no = self->team_no;

	oldself->real_owner = self;                    // The Engineer owns this item
	oldself->s.v.colormap = self->s.v.colormap;    // Set the Color
	oldself->s.v.takedamage = 2;
	oldself->s.v.owner = EDICT_TO_PROG( world );
	oldself->s.v.movetype = MOVETYPE_TOSS;
	SetVector( oldself->s.v.velocity, 0, 0, 8 );
	oldself->s.v.flags = ( int ) oldself->s.v.flags - ( ( int ) oldself->s.v.flags & FL_ONGROUND );

	// Put some ammo in the Dispenser
	oldself->s.v.ammo_shells = ceil( self->s.v.ammo_shells * 0.25 );
	oldself->s.v.ammo_nails = ceil( self->s.v.ammo_nails * 0.25 );
	oldself->s.v.ammo_rockets = ceil( self->s.v.ammo_rockets * 0.25 );
	oldself->s.v.ammo_cells = ceil( self->s.v.ammo_cells * 0.25 );
	oldself->s.v.armorvalue = ceil( self->s.v.armorvalue * 0.25 );

	// Remove ours
	self->s.v.ammo_shells = ceil( self->s.v.ammo_shells * 0.75 );
	self->s.v.ammo_nails = ceil( self->s.v.ammo_nails * 0.75 );
	self->s.v.ammo_rockets = ceil( self->s.v.ammo_rockets * 0.75 );
	self->s.v.ammo_cells = ceil( self->s.v.ammo_cells * 0.75 );
	self->s.v.armorvalue = ceil( self->s.v.armorvalue * 0.75 );

	oldself->s.v.solid = SOLID_BBOX;
	setmodel( oldself, oldself->mdl );
	setsize( oldself, -8, -8, 0, 8, 8, 24 );
	oldself->s.v.origin[2] += 8;
	setorigin( oldself, PASSVEC3( oldself->s.v.origin ) );

    } else
    {
	if ( oldself->s.v.weapon == BUILD_SENTRYGUN )
	{
	    self->has_sentry = self->has_sentry + 1;

	    G_sprint( self, 2, "You finish building the sentry gun.\n" );
	    teamsprint( self->team_no, self, self->s.v.netname );
	    teamsprint( self->team_no, self, " has built a Sentry Gun.\n" );

	    oldself->s.v.classname = "building_sentrygun_base";
	    oldself->s.v.netname = "sentry gun";
	    oldself->s.v.takedamage = 0;
	    oldself->th_die = Sentry_Die;
	    oldself->team_no = self->team_no;
            if( !tg_data.tg_enabled )
		    self->s.v.ammo_cells = self->s.v.ammo_cells - 130;

	    setsize( oldself, -16, -16, 0, 16, 16, 4 );
	    newmis = spawn(  );
	    g_globalvars.newmis = EDICT_TO_PROG( newmis );
	    newmis->s.v.classname = "building_sentrygun";
	    newmis->s.v.health = BUILD_HEALTH_SENTRYGUN;
	    newmis->s.v.max_health = newmis->s.v.health;
	    newmis->s.v.weapon = 1;
	    newmis->th_die = Sentry_Die;
	    newmis->th_pain = Sentry_Pain;
	    newmis->mdl = "progs/turrgun.mdl";
	    sound( oldself, 3, "weapons/turrset.wav", 1, 1 );
	    newmis->s.v.solid = SOLID_BBOX;
	    setmodel( newmis, newmis->mdl );
	    setsize( newmis, -16, -16, 0, 16, 16, 48 );
	    VectorCopy( oldself->s.v.origin, newmis->s.v.origin );
	    newmis->s.v.origin[2] += 8;
	    setorigin( newmis, PASSVEC3( newmis->s.v.origin ) );
	    SetVector( newmis->s.v.view_ofs, 0, 0, 22 );
	    newmis->real_owner = oldself->real_owner;
	    newmis->trigger_field = oldself;
	    oldself->oldenemy = newmis;
	    newmis->s.v.movetype = MOVETYPE_STEP;
	    oldself->s.v.colormap = self->s.v.colormap;               // Set the Base Color
	    newmis->s.v.colormap = self->s.v.colormap;                // Set the Color
	    newmis->s.v.takedamage = DAMAGE_AIM;
	    SetVector( newmis->s.v.velocity, 0, 0, -8 );
	    newmis->s.v.flags = ( int ) newmis->s.v.flags - ( ( int ) newmis->s.v.flags & FL_ONGROUND );
	    oldself->s.v.flags = ( int ) oldself->s.v.flags - ( ( int ) oldself->s.v.flags & FL_ONGROUND );
	    newmis->team_no = self->team_no;
	    newmis->s.v.think = ( func_t ) lvl1_sentry_stand;
	    newmis->s.v.nextthink = g_globalvars.time + 0.5;
	    // Rotate Details
	    newmis->s.v.yaw_speed = 10;
	    newmis->heat = 0;          // Turn Right
	    newmis->s.v.angles[0] = 0;
	    newmis->s.v.angles[1] = ( int ) ( oldself->s.v.angles[1] );
	    newmis->s.v.angles[2] = 0;
	    newmis->waitmin = ( int ) ( newmis->s.v.angles[1] - 50 );
	    newmis->waitmin = anglemod( newmis->waitmin );
	    newmis->waitmax = ( int ) ( newmis->s.v.angles[1] + 50 );
	    newmis->waitmax = anglemod( newmis->waitmax );
	    if ( newmis->waitmin > newmis->waitmax )
	    {
		newmis->waitmin = newmis->waitmax;
		newmis->waitmax = anglemod( newmis->s.v.angles[1] - 50 );
	    }
	    // Give the Gun some ammo
	    newmis->s.v.ammo_shells = 25;
	    newmis->maxammo_shells = 100;
	    newmis->maxammo_rockets = 20;
	}
    }
    W_SetCurrentAmmo(  );
    self = oldself;
}
Пример #3
0
void TeamFortress_Build( int objtobuild )
{
    float btime;

//      gedict_t *te;
    vec3_t tmp1;
    vec3_t tmp2;

    newmis = spawn(  );
    g_globalvars.newmis = EDICT_TO_PROG( newmis );

    // get an origin
    makevectors( self->s.v.v_angle );
    g_globalvars.v_forward[2] = 0;
    VectorNormalize( g_globalvars.v_forward );
    VectorScale( g_globalvars.v_forward, 64, g_globalvars.v_forward );
    VectorAdd( self->s.v.origin, g_globalvars.v_forward, newmis->s.v.origin );

    if ( objtobuild == BUILD_DISPENSER )
    {
        if( self->has_dispenser && !tg_data.tg_enabled)
	{
	    G_sprint( self, 2, "You can only have one dispenser.\nTry dismantling your old one.\n" );
	    return;
	}
	SetVector( tmp1, -8, -8, 0 );
	SetVector( tmp2, 8, 8, 24 );
//	newmis->mdl = "progs/disp.mdl";
	newmis->mdl = "progs/dispencr.mdl";		// megatf disp!
	newmis->s.v.netname = "dispenser";
	btime = g_globalvars.time + BUILD_TIME_DISPENSER;
	if( tg_data.tg_enabled )
		btime = g_globalvars.time;
    } else
    {
	if ( objtobuild == BUILD_SENTRYGUN )
	{
           if( self->has_sentry && !tg_data.tg_enabled)
	    {
		G_sprint( self, 2, "You can only have one sentry gun.\nTry dismantling your old one.\n" );
		return;
	    }
	    SetVector( tmp1, -16, -16, 0 );
	    SetVector( tmp2, 16, 16, 48 );
	    newmis->mdl = "progs/turrbase.mdl";
	    newmis->s.v.netname = "sentrygun";
	    btime = g_globalvars.time + BUILD_TIME_SENTRYGUN;
	    if( tg_data.tg_enabled )
	    	btime = g_globalvars.time;
	}else
	{
		G_Error("Unknown objtobuild in TeamFortress_Build\n");
		return;
	}

    }
    VectorCopy(tmp1,newmis->s.v.mins);
    VectorCopy(tmp2,newmis->s.v.maxs);
    // before we start building it, check it out
    // check for validity of point
    if ( !CheckArea( newmis, self ) )
    {
	G_sprint( self, 2, "Not enough room to build here\n" );
	dremove( newmis );
	return;
    }

    if ( !( ( int ) self->s.v.flags & FL_ONGROUND ) )
    {
	CenterPrint( self, "You can't build in the air!\n\n" );
	return;
    }
    self->is_building = 1;
    self->tfstate = self->tfstate | TFSTATE_CANT_MOVE;
    // Save the current weapon and remove it
    self->s.v.weapon = self->current_weapon;
    self->current_weapon = 0;
    self->s.v.weaponmodel = "";
    self->s.v.weaponframe = 0;

    TeamFortress_SetSpeed( self );
    newmis->s.v.owner = EDICT_TO_PROG( self );
    newmis->s.v.classname = "timer";
    newmis->s.v.netname = "build_timer";
    newmis->s.v.nextthink = btime;
    newmis->s.v.think = ( func_t ) TeamFortress_FinishedBuilding;
    newmis->s.v.colormap = self->s.v.colormap;
    newmis->s.v.weapon = objtobuild;
    newmis->s.v.angles[1] = anglemod( self->s.v.angles[1] + 180 );
    SetVector( newmis->s.v.velocity, 0, 0, 8 );
    newmis->s.v.movetype = MOVETYPE_TOSS;
    newmis->s.v.solid = SOLID_BBOX;
    setmodel( newmis, newmis->mdl );
    setsize( newmis, PASSVEC3( tmp1 ), PASSVEC3( tmp2 ) );
    setorigin( newmis, PASSVEC3( newmis->s.v.origin ) );
    newmis->s.v.flags = ( int ) newmis->s.v.flags - ( ( int ) newmis->s.v.flags & FL_ONGROUND );
}
Пример #4
0
void TG_Eff_Remove( gedict_t * pl )
{
	gedict_t *te;
	float   healam;

	if ( strneq( pl->s.v.classname, "player" ) )
		return;
	if ( pl->s.v.health <= 0 )
		return;

	for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); )
	{
		if ( te->s.v.owner != EDICT_TO_PROG( pl ) )
			continue;
		if ( te->s.v.think != ( func_t ) ConcussionGrenadeTimer &&
		     te->s.v.think != ( func_t ) OldConcussionGrenadeTimer )
			continue;
		if ( tf_data.old_grens == 1 )
			stuffcmd( pl, "v_idlescale 0\nfov 90\n" );
		dremove( te );
		break;
	}
	if ( pl->tfstate & TFSTATE_HALLUCINATING )
	{
		for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); )
		{
			if ( te->s.v.owner != EDICT_TO_PROG( pl ) )
				continue;
			if ( te->s.v.think != ( func_t ) HallucinationTimer )
				continue;

			pl->tfstate -= ( pl->tfstate & TFSTATE_HALLUCINATING );

			ResetGasSkins( pl );

			if ( tf_data.new_gas & GAS_MASK_PALETTE )
				stuffcmd( pl, "v_cshift; wait; bf\n" );
			dremove( te );
			break;
		}
		if ( !te )
			G_conprintf( "Warning: Error in Hallucination Timer logic.\n" );
	}
	if ( pl->tfstate & TFSTATE_TRANQUILISED )
	{
		for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "timer" ) ); )
		{
			if ( te->s.v.owner != EDICT_TO_PROG( pl ) )
				continue;
			if ( te->s.v.think != ( func_t ) TranquiliserTimer )
				continue;

			pl->tfstate -= ( pl->tfstate & TFSTATE_TRANQUILISED );
			TeamFortress_SetSpeed( pl );
			dremove( te );
			break;
		}
		if ( !te )
			G_conprintf( "Warning: Error in Tranquilisation Timer logic.\n" );
	}
	if ( pl->FlashTime > 0 )
	{
		for ( te = world; ( te = trap_find( te, FOFS( s.v.netname ), "flashtimer" ) ); )
		{
			if ( te->s.v.owner != EDICT_TO_PROG( pl ) )
				continue;
			if ( strneq( te->s.v.classname, "timer" ) )
				continue;

			pl->FlashTime = 0;
			if ( tf_data.new_flash )
				disableupdates( pl, -1 );	/* server-side flash */
			break;
		}
		if ( !te )
		{
			G_conprintf( "Warning: Error in Flash Timer logic.\n" );
			pl->FlashTime = 0;
		}
	}
	if ( pl->tfstate & TFSTATE_INFECTED )
	{
		healam = rint( pl->s.v.health / 2 );
		pl->tfstate -= ( pl->tfstate & TFSTATE_INFECTED );
		tf_data.deathmsg = DMSG_MEDIKIT;
		T_Damage( pl, self, self, healam );
		return;
	}
	if ( pl->numflames > 0 )
	{
		sound( pl, 1, "items/r_item1.wav", 1, 1 );
		pl->numflames = 0;
		return;
	}
}
Пример #5
0
Файл: spy.c Проект: MrPnut/QHome
//=========================================================================
// Function handling the Spy's feign death ability
void TeamFortress_SpyFeignDeath( int issilent )
{
	int     i, j;
	gedict_t *at_spot;
	gedict_t *te;

	self->StatusRefreshTime = g_globalvars.time + 0.1;
	if ( self->is_feigning )
	{
	        // Check to make sure there isn't anyone on top of us
		at_spot = findradius( world, self->s.v.origin, 64 );
		i = 1;
		j = 0;
		while ( at_spot )
		{
			if ( streq( at_spot->mdl, "progs/detpack.mdl" ) )
				j = 1;
			if ( streq( at_spot->mdl, "progs/detpack2.mdl" ) && tf_data.birthday == 1 )
				j = 1;
			if ( streq( at_spot->mdl, "progs/turrbase.mdl" ) )
				j = 1;
			if ( streq( at_spot->mdl, "progs/turrgun.mdl" ) )
				j = 1;
		//	if ( streq( at_spot->mdl, "progs/disp.mdl" ) )
		//		j = 1;
			if ( streq( at_spot->mdl, "progs/dispencr.mdl" ) )
				j = 1;
			if ( streq( at_spot->s.v.classname, "player" ) && !at_spot->s.v.deadflag && self != at_spot )
				j = 2;
			switch ( j )
			{
			case 1:
				G_sprint( self, 2, "You can't get up with something\non top of you.\n" );
				return;
			case 2:
				G_sprint( self, 2, "You can't get up while someone\nis standing on you.\n" );
				return;
			}
			at_spot = findradius( at_spot, self->s.v.origin, 64 );
		}
		if ( self->is_squating == TRUE )
			unlay ( );
		SetVector( self->s.v.velocity, 0, 0, 0 );
		setsize( self, -16, -16, -24, 16, 16, 32 );
		SetVector( self->s.v.view_ofs, 0, 0, 22 );
		self->s.v.movetype = MOVETYPE_WALK;
		self->is_feigning = 0;
		self->current_weapon = self->s.v.weapon;
		W_SetCurrentAmmo(  );
		self->tfstate = self->tfstate - ( self->tfstate & TFSTATE_CANT_MOVE );
		TeamFortress_SetSpeed( self );
		// Check .weapon, because .current_weapon has been reset
		if ( self->s.v.weapon <= 16 )
		{
			spy_upaxe1(  );
			return;
		}
		switch ( ( int ) ( g_random(  ) * 4 ) )
		{
		case 0:
			spy_upb1(  );
			break;
		case 1:
			spy_upc1(  );
			break;
		case 2:
			spy_upd1(  );
			break;
		default:
			spy_upe1(  );
			break;
		}
		return;
	} else  // !self->is_feigning
	{
		
		if ( self->hook_out )
		{
			G_sprint( self, 2, "You can't feign with the hook out.\n" );
			return;
		}
//REMOVE!!!		
/*          if (self.is_unabletospy == 1) {
           G_sprint(self, 2, "You can't go undercover right now.\n");
           return;
          }*/

/*  if (!(self.flags & 512) && !self->s.v.waterlevel) {
   G_sprint(self, 2, "You can't feign in the air.\n");
   return;
  }*/
		
		for ( at_spot = world; ( at_spot = findradius( at_spot, self->s.v.origin, 64 ) ) ; )
		{
			if ( streq( at_spot->s.v.classname, "player" ) && self != at_spot && at_spot->is_feigning == 1 )
			{
				G_sprint( self, 2, "You can't feign on top of another spy!\n" );
				return;
			}
		}
		self->tfstate = self->tfstate | TFSTATE_CANT_MOVE;
		TeamFortress_SetSpeed( self );
		self->is_feigning = 1;
		Attack_Finished( 0.8 );
		self->invisible_finished = 0;
		self->s.v.modelindex = modelindex_player;
		self->s.v.weapon = self->current_weapon;
		self->current_weapon = 0;
		self->s.v.weaponmodel = "";
		self->s.v.weaponframe = 0;
		setsize( self, -16, -16, -24, 16, 16, -16 );
		SetVector( self->s.v.view_ofs, 0, 0, 4 );
		self->s.v.movetype = MOVETYPE_TOSS;
		if ( !issilent )
			DeathSound(  );
		self->s.v.angles[0] = 0;
		self->s.v.angles[2] = 0;
		if ( self->s.v.weapon <= 16 )
		{
			spy_die_ax1(  );
			return;
		}
		te = world;
		for( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "item_tfgoal" ) ) ;)
		{
			if ( te->s.v.owner != EDICT_TO_PROG( self ) )
				continue;

			if ( !( te->goal_activation & TFGI_KEEP ) || self->has_disconnected == 1 )
				tfgoalitem_RemoveFromPlayer( te, self, 0 );
			if ( CTF_Map == 1 )
			{
				if ( te->goal_no == 1 )
					G_bprint( 2, "%s лост the блуе flag!\n", self->s.v.netname );
				else
					G_bprint( 2, "%s лост the ред flag!\n", self->s.v.netname );
			}
		}
		switch ( ( int ) ( g_random(  ) * 5 ) )
		{
		case 0:
			spy_diea1(  );
			break;
		case 1:
			spy_dieb1(  );
			break;
		case 2:
			spy_diec1(  );
			break;
		case 3:
			spy_died1(  );
			break;
		default:
			spy_diee1(  );
			break;
		}
	}
}