Example #1
0
void Cmd_Deny_f (edict_t * ent)
{
	edict_t *target;
	radio_t *radio;

	if (!teamplay->value)
	{
		if (!DMFLAGS( (DF_MODELTEAMS | DF_SKINTEAMS) ))
			return;			// don't allow in a non-team setup...
	}

	if (!IS_ALIVE(ent))
		return;

	radio = &ent->client->resp.radio;
	target = radio->partner_last_offered_from;
	if (target && target->inuse)
	{
		gi.centerprintf (ent, "You denied %s", target->client->pers.netname);
		gi.centerprintf (target, "%s has denied you", ent->client->pers.netname);
		radio->partner_last_denied_from = target;

		radio->partner_last_offered_from = NULL;
		if (target->client->resp.radio.partner_last_offered_to == ent)

			target->client->resp.radio.partner_last_offered_to = NULL;
	}
	else
	{
		gi.centerprintf (ent, "No one has offered to be your partner");
		return;
	}
}
Example #2
0
void FL_make (edict_t * self)
{
	vec3_t start, forward, right, end;
	edict_t *flashlight = self->client->flashlight;

	// Always remove a dead person's flashlight.
	if( ! IS_ALIVE(self) )
	{
		if( flashlight )
		{
			G_FreeEdict( flashlight );
			self->client->flashlight = NULL;
		}
		return;
	}

	// Allow flashlights to be turned off even if use_flashlight was disabled mid-round.
	if( flashlight )
	{
		G_FreeEdict( flashlight );
		self->client->flashlight = NULL;
		gi.sound( self, CHAN_VOICE, gi.soundindex("misc/flashlight.wav"), 1, ATTN_NORM, 0 );
		return;
	}

	// Don't allow flashlights to be turned on without darkmatch or use_flashlight.
	if( !(darkmatch->value || use_flashlight->value) )
		return;

	gi.sound( self, CHAN_VOICE, gi.soundindex("misc/flashlight.wav"), 1, ATTN_NORM, 0 );

	AngleVectors(self->client->v_angle, forward, right, NULL);

	VectorSet(end, 100, 0, 0);
	G_ProjectSource(self->s.origin, end, forward, right, start);

	flashlight = G_Spawn();
	flashlight->owner = self;
	flashlight->movetype = MOVETYPE_NOCLIP;
	flashlight->solid = SOLID_NOT;
	flashlight->classname = "flashlight";
	flashlight->s.modelindex = gi.modelindex("sprites/null.sp2");
	flashlight->s.skinnum = 0;
	flashlight->s.effects |= EF_HYPERBLASTER; // Other effects can be used here, such as flag1, but these look corney and dull. Try stuff and tell me if you find anything cool (EF_HYPERBLASTER)
	flashlight->think = FL_think;
	flashlight->nextthink = level.framenum + FRAMEDIV;

	self->client->flashlight = flashlight;
}
Example #3
0
void
initialize_neighbour_counts (char * board, const int nrows, const int ncols){
  
  int i,j;

  for (i = 0; i < nrows; i++) {
    for (j = 0; j< ncols; j++) {
  
      if (IS_ALIVE(BOARD(board, i, j))) {

        const int inorth = mod (i-1, nrows);
        const int isouth = mod (i+1, nrows);
        const int jwest = mod (j-1, ncols);
        const int jeast = mod (j+1, ncols);

        INCR_AT (board, inorth, jwest);
        INCR_AT (board, inorth, j);
        INCR_AT (board, inorth, jeast);
        INCR_AT (board, i, jwest);
        INCR_AT (board, i, jeast);
        INCR_AT (board, isouth, jwest);
        INCR_AT (board, isouth, j);
        INCR_AT (board, isouth, jeast);

      }
      
      
    }
  }
 // printf("-----\n");

  /*
  for (i = 0; i < nrows; i++) {
    for (j = 0; j< ncols; j++) {
      printf("%02x\n",board[i+nrows*j]);
    }
  }
  */




}
Example #4
0
void DomTouchFlag( edict_t *flag, edict_t *player, cplane_t *plane, csurface_t *surf )
{
	if( ! player->client )
		return;
	if( ! player->client->resp.team )
		return;
	if( (player->health < 1) || ! IS_ALIVE(player) )
		return;
	if( lights_camera_action || in_warmup )
		return;
	if( player->client->uvTime )
		return;

	// If the flag hasn't been touched this frame, the player will take it.
	if( ! flag->owner )
		flag->owner = player;
	// If somebody on another team also touched the flag this frame, nobody takes it.
	else if( flag->owner->client && (flag->owner->client->resp.team != player->client->resp.team) )
		flag->owner = flag;
}
Example #5
0
void Cmd_Partner_f (edict_t * ent)
{
	edict_t *target;
	char *genderstr;
	radio_t *radio, *tRadio;

	if (!teamplay->value)
	{
		if (!DMFLAGS( (DF_MODELTEAMS | DF_SKINTEAMS) ))
			return;			// don't allow in a non-team setup...
	}

	if (!IS_ALIVE(ent))
		return;

	radio = &ent->client->resp.radio;
	if (radio->partner) {

		if (radio->partner->inuse) {

			gi.centerprintf( ent, "You already have a partner, %s", radio->partner->client->pers.netname );

			return;

		}

		// just in case RadioThink hasn't caught it yet... avoid any problems

		radio->partner = NULL;

	}

	target = DetermineViewedPlayer(ent, true);
	if (target == NULL) {
		gi.centerprintf (ent, "No potential partner selected");
		return;
	}

	tRadio = &target->client->resp.radio;
	if (tRadio->partner) {
		gi.centerprintf (ent, "%s already has a partner", target->client->pers.netname);
		return;
	}

	if (tRadio->partner_last_offered_to == ent &&
		radio->partner_last_offered_from == target)
	{
		gi.centerprintf (ent, "%s is now your partner", target->client->pers.netname);
		gi.centerprintf (target, "%s is now your partner", ent->client->pers.netname);
		radio->partner = target;
		tRadio->partner = ent;
		radio->partner_last_offered_from = NULL;
		tRadio->partner_last_offered_to = NULL;
		return;
	}

	if (tRadio->partner_last_denied_from == ent)
	{
		gi.centerprintf (ent, "%s has already denied you", target->client->pers.netname);
		return;
	}

	if (target == radio->partner_last_offered_to)
	{
		genderstr = GENDER_STR(target, "him", "her", "it");
		gi.centerprintf (ent, "Already awaiting confirmation from %s", genderstr);
		return;
	}

	genderstr = GENDER_STR(ent, "him", "her", "it");

	gi.centerprintf (ent, "Awaiting confirmation from %s", target->client->pers.netname);
	gi.centerprintf (target,
		"%s offers to be your partner\n"
		"To accept:\nView %s and use the 'partner' command\n"
		"To deny:\nUse the 'deny' command",
		ent->client->pers.netname, genderstr);

	radio->partner_last_offered_to = target;
	tRadio->partner_last_offered_from = ent;
}
Example #6
0
void RadioBroadcast (edict_t * ent, int partner, char *msg)
{
	int j, i, msg_len, numSnds;
	edict_t *other;
	radio_msg_t *radio_msgs;
	int  msg_soundIndex = 0;
	char msgname_num[8], filteredmsg[48];
	qboolean found = false;
	radio_t *radio;

	if (!IS_ALIVE(ent))
		return;

	if (!teamplay->value)
	{
		if (!DMFLAGS( (DF_MODELTEAMS | DF_SKINTEAMS) ))
			return;			// don't allow in a non-team setup...
	}

	radio = &ent->client->resp.radio;
	if (radio->power_off)
	{
		gi.centerprintf (ent, "Your radio is off!");
		return;
	}

	if (partner && radio->partner == NULL)
	{
		gi.cprintf (ent, PRINT_HIGH, "You don't have a partner.\n");
		return;
	}

	if (radio->gender)
	{
		radio_msgs = female_radio_msgs;
		numSnds = numFemaleSnds;
	}
	else
	{
		radio_msgs = male_radio_msgs;
		numSnds = numMaleSnds;
	}

	i = found = 0;
	msg_len = 0;

	Q_strncpyz(filteredmsg, msg, sizeof(filteredmsg));

	for(i = 0; i < numSnds; i++)
	{
		if (!Q_stricmp(radio_msgs[i].msg, filteredmsg))
		{
			found = true;
			msg_soundIndex = radio_msgs[i].sndIndex;
			msg_len = radio_msgs[i].length;
			break;
		}
	}

	if (!found)
	{
		gi.centerprintf (ent, "'%s' is not a valid radio message", filteredmsg);
		return;
	}

	if (radiolog->value)
	{
		gi.cprintf (NULL, PRINT_CHAT, "[%s RADIO] %s: %s\n",
			partner ? "PARTNER" : "TEAM", ent->client->pers.netname, filteredmsg);
	}

	//TempFile BEGIN
	if (Q_stricmp (filteredmsg, "enemyd") == 0)
	{
		if (ent->client->radio_num_kills > 1 && ent->client->radio_num_kills <= 10)
		{
			// If we are reporting enemy down, add the number of kills.
			sprintf( msgname_num, "%i", ent->client->radio_num_kills );
			ent->client->radio_num_kills = 0;	// prevent from getting into an endless loop

			RadioBroadcast(ent, partner, msgname_num);	// Now THAT'S recursion! =)
		}
		ent->client->radio_num_kills = 0;
	}
//TempFile END
	//AQ2:TNG Slicer
	if (radio_repeat->value)
	{  //SLIC2 Optimization
		if (CheckForRepeat (ent, i) == false)
			return;
	}

	if (radio_max->value)
	{
		if (CheckForFlood (ent) == false)
			return;
	}


	//AQ2:TNG END
	for (j = 1; j <= game.maxclients; j++)
	{
		other = &g_edicts[j];
		if (!other->inuse)
			continue;
		if (!other->client)
			continue;
		if (!OnSameTeam(ent, other))
			continue;
		if (partner && other != radio->partner)
			continue;
		AddRadioMsg( &other->client->resp.radio, msg_soundIndex, msg_len, ent );
	}
}
Example #7
0
// RadioThink should be called once on each player per server frame.
void RadioThink (edict_t * ent)
{
	radio_t *radio = &ent->client->resp.radio;

	// Try to clean things up, a bit....
	if (radio->partner)
	{
		if (!radio->partner->inuse ||
			radio->partner->client->resp.radio.partner != ent)
		{
			radio->partner = NULL;
		}
	}
	if (radio->partner_last_offered_to)
	{
		if (!radio->partner_last_offered_to->inuse ||
			radio->partner_last_offered_to->solid == SOLID_NOT)
		{
			radio->partner_last_offered_to = NULL;
		}
	}
	if (radio->partner_last_denied_from)
	{
		if (!radio->partner_last_denied_from->inuse ||
			radio->partner_last_denied_from->solid == SOLID_NOT)
		{
			radio->partner_last_denied_from = NULL;
		}
	}
	// ................................

	if (radio->power_off)
	{
		radio->queue_size = 0;
		return;
	}

	if (radio->delay > 0)
	{
		radio->delay--;
		if (radio->delay)
			return;
	}


	if (radio->queue_size)
	{
		edict_t *from;
		int check;

		from = radio->queue[0].from_player;

		if (!radio->queue[0].click && (!from->inuse || !IS_ALIVE(from)))
		{
			if (radio->queue[0].from_gender)
			{
				radio->queue[0].sndIndex = globalRadio[RADIO_DEATH_FEMALE].sndIndex;
				radio->queue[0].length = globalRadio[RADIO_DEATH_FEMALE].length;
			}
			else
			{
				radio->queue[0].sndIndex = globalRadio[RADIO_DEATH_MALE].sndIndex;
				radio->queue[0].length = globalRadio[RADIO_DEATH_MALE].length;
			}

			for (check = 1; check < radio->queue_size; check++)
			{
				if (!radio->queue[check].click && radio->queue[check].from_player == from)
				{
					DeleteRadioQueueEntry( radio, check );
					check--;
				}
			}
		}

		if( ! IsInIgnoreList( ent, from ) )
		{
			unicastSound( ent, radio->queue[0].sndIndex, 1.0 );
			radio->delay = radio->queue[0].length;
		}
		DeleteRadioQueueEntry( radio, 0 ); //We can remove it here?
	}
}