예제 #1
0
void
ParseSayText (edict_t * ent, char *text)
{
  static unsigned char buf[10240], infobuf[10240];
  char *p, *pbuf;

  p = text;
  pbuf = buf;
  *pbuf = 0;

  while (*p != 0)
    {
      if (((ptrdiff_t) pbuf - (ptrdiff_t) buf) > 225)
	{
	  break;
	}

      if (*p == '%')
	{
	  switch (*(p + 1))
	    {
	    case 'H':
	      GetHealth (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'A':
	      GetAmmo (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'W':
	      GetWeaponName (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'I':
	      GetItemName (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'T':
	      GetNearbyTeammates (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'M':
	      GetViewedTeammateName (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'E':
	      GetViewedEnemyName (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'F':
	      GetViewedEnemyWeapon (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'G':
	      GetEnemyPosition (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'K':
	      GetLastKilledTarget (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
//AQ2:TNG Slicer - New Location Code
	      /*
	         case 'L':
	         GetOwnPosition (ent, infobuf);
	         strcpy (pbuf, infobuf);
	         pbuf = SeekBufEnd (pbuf);
	         p += 2;
	         continue;
	         case 'S':
	         GetViewedPosition (ent, infobuf);
	         strcpy (pbuf, infobuf);
	         pbuf = SeekBufEnd (pbuf);
	         p += 2;
	         continue;
	       */
	    case 'S':
	      GetSightedLocation (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	    case 'L':
	      GetPlayerLocation (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	      //AQ2:TNG Slicer Last Damage Location
	    case 'D':
	      GetLastDamagedPart (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	      //AQ2:TNG END
	      //AQ2:TNG Freud Last Player Damaged
	    case 'P':
	      GetLastDamagedPlayers (ent, infobuf);
	      strcpy (pbuf, infobuf);
	      pbuf = SeekBufEnd (pbuf);
	      p += 2;
	      continue;
	      //AQ2:TNG END
	    }
	}
      *pbuf++ = *p++;
    }

  *pbuf = 0;

  strncpy (text, buf, 225);
  text[225] = 0;		// in case it's 225

}
예제 #2
0
void ParseSayText (edict_t * ent, char *text, size_t size)
{
	char buf[PARSE_BUFSIZE + 256] = "\0"; //Parsebuf + chatpuf size
	char *p, *pbuf;

	p = text;
	pbuf = buf;

	while (*p != 0)
	{
		if (*p == '%')
		{
			switch (*(p + 1))
			{
			case 'H':
				GetHealth (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'A':
				GetAmmo (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'W':
				GetWeaponName (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'I':
				GetItemName (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'T':
				GetNearbyTeammates (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'M':
				GetViewedTeammateName (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'E':
				GetViewedEnemyName (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'F':
				GetViewedEnemyWeapon (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'G':
				GetEnemyPosition (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'K':
				GetLastKilledTarget (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			//AQ2:TNG Slicer - New Location Code
			/*
			case 'L':
				GetOwnPosition (ent, infobuf);
				strcpy (pbuf, infobuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'S':
				GetViewedPosition (ent, infobuf);
				strcpy (pbuf, infobuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			*/
			case 'S':
				GetSightedLocation (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			case 'L':
				GetPlayerLocation (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			//AQ2:TNG Slicer Last Damage Location
			case 'D':
				GetLastDamagedPart (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			//AQ2:TNG END
			//AQ2:TNG Freud Last Player Damaged
			case 'P':
				GetLastDamagedPlayers (ent, pbuf);
				pbuf = SeekBufEnd (pbuf);
				p += 2;
				break;
			//AQ2:TNG END
			default:
				*pbuf++ = *p++;
				break;
			}
		}
		else
		{
			*pbuf++ = *p++;
		}

		if (buf[size-1])
		{
			buf[size-1] = 0;
			break;
		}
	}

	*pbuf = 0;
	strcpy(text, buf);
}
예제 #3
0
void
GetEnemyPosition (edict_t * self, char *buf)
{
  edict_t *the_enemy;
  vec3_t rel_pos;
  int rel_xy_pos;

  the_enemy = DetermineViewedEnemy (self);
  if (the_enemy && the_enemy->client)
    {
      if (GetPlayerLocation (the_enemy, buf) == false)
	{
	  //creating relative vector from origin to destination
	  VectorSubtract (self->s.origin, the_enemy->s.origin, rel_pos);

	  rel_xy_pos = 0;

	  //checking bounds, if one direction is less than half the other, it may
	  //be ignored...
	  if (fabs (rel_pos[0]) > (fabs (rel_pos[1]) * 2))
	    //x width (EAST, WEST) is twice greater than y width (NORTH, SOUTH)
	    rel_pos[1] = 0.0;
	  if (fabs (rel_pos[1]) > (fabs (rel_pos[0]) * 2))
	    //y width (NORTH, SOUTH) is twice greater than x width (EAST, WEST)
	    rel_pos[0] = 0.0;

	  if (rel_pos[1] > 0.0)
	    rel_xy_pos |= RP_NORTH;
	  else if (rel_pos[1] < 0.0)
	    rel_xy_pos |= RP_SOUTH;
	  if (rel_pos[0] > 0.0)
	    rel_xy_pos |= RP_EAST;
	  else if (rel_pos[0] < 0.0)
	    rel_xy_pos |= RP_WEST;

	  //creating the text message, regarding to rel_xy_pos
	  strcpy (buf, "in the ");
	  if (rel_xy_pos & RP_NORTH)
	    strcat (buf, "north");
	  if (rel_xy_pos & RP_SOUTH)
	    strcat (buf, "south");
	  if (rel_xy_pos & RP_EAST)
	    strcat (buf, "east");
	  if (rel_xy_pos & RP_WEST)
	    strcat (buf, "west");
	  //gi.dprintf ("rel_xy_pos: %i\n", rel_xy_pos);
	  //last but not least, the height of enemy, limit for up/down: 64
	  if (fabs (rel_pos[2]) > 64.0)
	    {
	      if (rel_pos[2] < 0.0)
		strcat (buf, ", above me");
	      else
		strcat (buf, ", under me");
	    }
	  else
	    strcat (buf, ", on the same level");
	}
    }
  else
    {
      strcpy (buf, "somewhere");
    }
}
예제 #4
0
파일: a_dom.c 프로젝트: Raptor007/aq2-tng
void DomFlagThink( edict_t *flag )
{
	// If the flag was touched this frame, make it owned by that team.
	if( flag->owner && flag->owner->client && flag->owner->client->resp.team )
	{
		unsigned int effect = dom_team_effect[ flag->owner->client->resp.team ];
		if( flag->s.effects != effect )
		{
			edict_t *ent = NULL;
			int prev_owner = DomFlagOwner( flag );
			if( prev_owner != NOTEAM )
				dom_team_flags[ prev_owner ] --;

			flag->s.effects = effect;
			flag->s.renderfx = dom_team_fx[ flag->owner->client->resp.team ];
			dom_team_flags[ flag->owner->client->resp.team ] ++;

			if( flag->owner->client->resp.team == TEAM1 )
				flag->s.modelindex = dom_red_flag;
			else
				flag->s.modelindex = dom_blue_flag;

			// Get flag location if possible.
			char location[ 128 ] = "(";
			qboolean has_loc = GetPlayerLocation( flag, location + 1 );
			if( has_loc )
				strcat( location, ") " );
			else
				location[0] = '\0';

			gi.bprintf( PRINT_HIGH, "%s secured %s flag %sfor %s!\n",
				flag->owner->client->pers.netname,
				(dom_flag_count == 1) ? "the" : "a",
				location,
				teams[ flag->owner->client->resp.team ].name );

			if( (dom_team_flags[ flag->owner->client->resp.team ] == dom_flag_count) && (dom_flag_count > 1) )
				gi.bprintf( PRINT_HIGH, "%s TEAM IS DOMINATING!\n",
				teams[ flag->owner->client->resp.team ].name );

			gi.sound( flag, CHAN_ITEM, gi.soundindex("tng/flagret.wav"), 0.75, 0.125, 0 );

			for( ent = g_edicts + 1; ent <= g_edicts + game.maxclients; ent ++ )
			{
				if( ! (ent->inuse && ent->client && ent->client->resp.team) )
					continue;
				else if( ent == flag->owner )
					unicastSound( ent, gi.soundindex("tng/flagcap.wav"), 0.75 );
				else if( ent->client->resp.team != flag->owner->client->resp.team )
					unicastSound( ent, gi.soundindex("tng/flagtk.wav"), 0.75 );
			}
		}
	}

	// Reset so the flag can be touched again.
	flag->owner = NULL;

	// Animate the flag waving.
	int prev = flag->s.frame;
	flag->s.frame = 173 + (((flag->s.frame - 173) + 1) % 16);

	// Blink between red and blue if it's unclaimed.
	if( (flag->s.frame < prev) && (flag->s.effects == dom_team_effect[ NOTEAM ]) )
		flag->s.modelindex = (flag->s.modelindex == dom_blue_flag) ? dom_red_flag : dom_blue_flag;

	flag->nextthink = level.framenum + FRAMEDIV;
}