void TridentHit(ServerEntity_t *ent)
{
	vec3_t	forward,temp,sndvec,vel;
	trace_t	trace;

	Math_AngleVectors(ent->v.v_angle,forward,temp,temp);

	// [18/4/2012] A nice soft bounce ~hogsy
	vel[0] = vel[1] = 0;
	vel[2] = 0.5;

	sndvec[0] = ent->v.origin[0]+forward[0]*78;
	sndvec[1] = ent->v.origin[1]+forward[1]*78;
	sndvec[2] = ent->v.origin[2]+forward[2]*78;

	trace = Traceline(ent,ent->v.origin,sndvec,0);

	sndvec[0] = trace.endpos[0]-forward[0]*4;
	sndvec[1] = trace.endpos[1]-forward[1]*4;
	sndvec[2] = trace.endpos[2]-forward[2]*4;

	if(trace.fraction == 1.0f)
		return;
	if(trace.ent->v.bTakeDamage)
    {
		if(trace.ent->local.bBleed)
			Engine.Particle(sndvec,vel,10,"blood",30);

		Entity_Damage(trace.ent,ent,20,0);
	}
	else if(trace.ent)
		Engine.Particle(sndvec,vel,10,"smoke",30);
}
示例#2
0
文件: bot.cpp 项目: DrLabman/QMB
/**
 * This function is used to calcualte if an entity can be seen.
 * Returns the angle in test and true if the entity can be seen, else it returns false
 */
bool IsInView(vec3_t eyes1, vec3_t eyes2, edict_t *bot, edict_t *nmy, int fov, vec3_t test) {
	vec3_t origin;
	float test2;

	if (Traceline(eyes1, eyes2, bot, nmy)) // If the bot can see his enemy
	{
		VectorSubtract(eyes1, eyes2, origin); // Get a nice vector
		CalcAngles(origin, test); // And use it to see in what direction the enemy is
		test2 = test[1] - bot->v.angles[1]; // Another shortcut

		return (test2 > -fov && test2 < fov); // If enemy is in front of the bot so he can see him
	}
	return false;
}
Waypoint_t *Waypoint_GetByVisibility(MathVector3f_t vOrigin)
{
	Waypoint_t	*wPoint;
	trace_t		tTrace;

	for (wPoint = wWaypoints; wPoint->number < waypoint_count; wPoint++)
	{
		tTrace = Traceline(NULL,vOrigin,wPoint->position,0);
		// Given point cannot be in the same place as the given origin.
		if(	Math_VectorCompare(tTrace.endpos,wPoint->position) && 
			!Math_VectorCompare(vOrigin,wPoint->position))
			return wPoint;
	}
	return NULL;
}
bool Monster_IsVisible(edict_t *ent,edict_t *target)
{
	trace_t	tTrace;
	vec3_t	vStart,vEnd;

	// [10/4/2013] TODO: Rework for new FOV system ~hogsy
	// [2/1/2013] Simplified ~hogsy
	Math_VectorAdd(ent->v.origin,ent->v.view_ofs,vStart);
	Math_VectorAdd(target->v.origin,target->v.view_ofs,vEnd);

	tTrace = Traceline(ent,vStart,vEnd,true);
	// [10/4/2013] Simplified ~hogsy
	if(!(tTrace.bOpen && tTrace.bWater) && tTrace.fraction == 1.0f)
		return true;

	return false;
}