本文整理汇总了C++中game_import_t::cprintf方法的典型用法代码示例。如果您正苦于以下问题:C++ game_import_t::cprintf方法的具体用法?C++ game_import_t::cprintf怎么用?C++ game_import_t::cprintf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_import_t
的用法示例。
在下文中一共展示了game_import_t::cprintf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: game_cprintf
void game_cprintf(edict_t *ent, int printlevel, char *fmt, ...)
{
va_list args;
char buf[1024];
va_start(args, fmt);
vsnprintf(buf, sizeof buf, fmt, args);
buf[sizeof buf - 1] = 0;
va_end(args);
if (ent == NULL)
q2a_lua_LogMessage(buf);
gi.cprintf(ent, printlevel, "%s", buf);
}
示例2: CheckPlayerLookTargets
void CheckPlayerLookTargets (void)
{
cvar_t *show_look;
int i;
edict_t *ent;
player_state_t *ps;
vec3_t view_origin, forward, right, distance, view_target;
trace_t trace;
// Set this console variable to display information about what the
// player is looking at. For debugging purposes.
show_look = gi.cvar("show_look", "0", CVAR_SERVERINFO);
// Iterate over all the active players.
for (i=0 ; i<maxclients->value ; i++)
{
ent = g_edicts + 1 + i;
if (!ent->inuse)
continue;
// Calculate the player's line of sight, beginning at view_origin
// and extending to view_target a fair distance away.
ps = &ent->client->ps;
VectorAdd(ent->s.origin, ps->viewoffset, view_origin);
AngleVectors(ps->viewangles, forward, right, NULL);
VectorSet(distance, LOOK_DISTANCE, 0, 0);
G_ProjectSource(view_origin, distance, forward, right, view_target);
// Trace the player's line of sight and see what we hit. We begin
// the trace at view_origin, use a size zero bounding box (NULL,
// NULL), end the trace at view_target, ignore the player 'ent', and
// stop when we hit any of the specified object types.
trace = gi.trace(view_origin, NULL, NULL, view_target, ent,
MASK_OPAQUE|CONTENTS_WINDOW|CONTENTS_MONSTER|
CONTENTS_DEADMONSTER);
// If show_look is true, report what the player is currently
// looking at for debugging purposes
if (show_look->value && trace.ent && trace.ent->classname)
gi.cprintf(ent, PRINT_HIGH, "Looking at: %s %x\n",
trace.ent->classname, trace.ent);
// If we're looking at something new, remember it and run any
// associated look_target.
if (trace.ent != ent->client->looking_at)
{
ent->client->looking_at = trace.ent;
if (trace.ent && trace.ent->look_target)
G_UseTargetsByName(trace.ent, trace.ent->look_target, ent);
}
// Objects don't get reticles if they're too far away.
if (trace.fraction > (1.0 * RETICLE_DISTANCE) / LOOK_DISTANCE)
trace.ent = NULL;
// We need to resend the reticle every frame, in case the entity
// is moving relative to the world.
SendReticle(trace.ent, ent);
// If the reticle is on something new, remember it and run any
// associated r_look_target (sound familiar?).
if (trace.ent != ent->client->reticle_on)
{
ent->client->reticle_on = trace.ent;
if (trace.ent && trace.ent->r_look_target)
G_UseTargetsByName(trace.ent, trace.ent->r_look_target, ent);
}
}
}