本文整理汇总了C++中cvar函数的典型用法代码示例。如果您正苦于以下问题:C++ cvar函数的具体用法?C++ cvar怎么用?C++ cvar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vote_check_antilag
void vote_check_antilag ()
{
int veto;
if ( match_in_progress || intermission_running || match_over )
return;
if ( !get_votes( OV_ANTILAG ) )
return;
veto = is_admins_vote( OV_ANTILAG );
if( veto || !get_votes_req( OV_ANTILAG, true ) )
{
vote_clear( OV_ANTILAG );
// toggle antilag mode.
trap_cvar_set_float( "sv_antilag", (float)(cvar( "sv_antilag" ) ? 0 : 2));
if ( veto )
G_bprint(2, "%s\n", redtext(va("Antilag mode %s by admin veto", OnOff(2 == cvar("sv_antilag")))));
else
G_bprint(2, "%s\n", redtext(va("Antilag mode %s by majority vote", OnOff(2 == cvar("sv_antilag")))));
return;
}
}
示例2: nospecs
void nospecs( )
{
int votes;
if ( match_in_progress )
{
G_sprint(self, 2, "%s mode %s\n", redtext("No spectators"), OnOff(cvar("_k_nospecs")));
return;
}
// admin may turn this status alone on server...
if ( !is_adm( self ) )
{
// Dont need to bother if less than 2 players
if ( CountPlayers() < 2 )
{
G_sprint(self, 2, "You need at least 2 players to do this.\n");
return;
}
}
self->v.nospecs = !self->v.nospecs;
G_bprint(2, "%s %s!%s\n", self->s.v.netname,
(self->v.nospecs ? redtext(va("votes for nospecs %s", OnOff(!cvar("_k_nospecs")))) :
redtext(va("withdraws %s nospecs vote", g_his(self)))),
((votes = get_votes_req( OV_NOSPECS, true )) ? va(" (%d)", votes) : ""));
vote_check_nospecs ();
}
示例3: vote_check_coop
// { votecoop
void vote_check_coop ()
{
int veto;
if ( ( deathmatch && match_in_progress ) || intermission_running || match_over )
return;
if ( !get_votes( OV_COOP ) )
return;
veto = is_admins_vote( OV_COOP );
if( veto || !get_votes_req( OV_COOP, true ) )
{
vote_clear( OV_COOP );
// toggle coop mode
cvar_fset( "coop", coop = !cvar("coop") );
// set appropriate deathmatch
cvar_fset( "deathmatch", deathmatch = !coop );
if ( veto )
G_bprint( 2, "%s\n", redtext(va("Coop mode %s by admin veto", OnOff(cvar("coop")))) );
else
G_bprint( 2, "%s\n", redtext(va("Coop mode %s by majority vote", OnOff(cvar("coop")))) );
// and reload map
if ( cvar("k_bloodfest") )
changelevel( coop ? g_globalvars.mapname : cvar_string( "k_defmap" ) );
else
changelevel( coop ? "start" : g_globalvars.mapname );
return;
}
}
示例4: teamoverlay
void teamoverlay( )
{
int votes;
if ( match_in_progress )
{
G_sprint(self, 2, "%s %s\n", redtext("Teamoverlay"), OnOff(cvar("k_teamoverlay")));
return;
}
// admin may turn this status alone on server...
if ( !is_adm( self ) )
{
// Dont need to bother if less than 2 players
if ( CountPlayers() < 2 )
{
G_sprint(self, 2, "You need at least 2 players to do this.\n");
return;
}
}
self->v.teamoverlay = !self->v.teamoverlay;
G_bprint(2, "%s %s!%s\n", self->netname,
(self->v.teamoverlay ? redtext(va("votes for teamoverlay %s", OnOff(!cvar("k_teamoverlay")))) :
redtext(va("withdraws %s teamoverlay vote", g_his(self)))),
((votes = get_votes_req( OV_TEAMOVERLAY, true )) ? va(" (%d)", votes) : ""));
vote_check_teamoverlay ();
}
示例5: mctf
void mctf()
{
if( match_in_progress && !k_matchLess )
return;
if ( !isCTF() ) {
G_sprint ( self, 2, "Can't do this in non CTF mode\n" );
return;
}
if ( !cvar("k_ctf_hook") && !cvar("k_ctf_runes") ) {
G_sprint ( self, 2, "Already done\n" );
return;
}
cvar_fset("k_ctf_hook", 0);
cvar_fset("k_ctf_runes", 0);
G_sprint ( self, 2, "%s turn off: %s\n", getname(self), redtext("hook & runes") );
// In matchless mode, toggling runes and hook normally won't do anything since match is already in progress. Call this to handle this scenario.
if (k_matchLess)
{
// If a player is carrying a rune when runes are disabled, get rid of it
if (!cvar("k_ctf_runes")) {
gedict_t * p;
for (p = world; (p = find_plr(p)); ) {
p->ctf_flag -= (p->ctf_flag & (CTF_RUNE_MASK));
p->maxspeed = cvar("sv_maxspeed"); // Reset speed, in case was carrying haste
}
}
SpawnRunes( 0 );
AddHook ( false );
}
}
示例6: vote_check_teamoverlay
void vote_check_teamoverlay ()
{
int veto;
if ( match_in_progress || intermission_running || match_over )
return;
if ( !get_votes( OV_TEAMOVERLAY ) )
return;
veto = is_admins_vote( OV_TEAMOVERLAY );
if( veto || !get_votes_req( OV_TEAMOVERLAY, true ) )
{
vote_clear( OV_TEAMOVERLAY );
// Toggle teamoverlay.
cvar_fset("k_teamoverlay", !cvar("k_teamoverlay"));
if ( veto )
G_bprint(2, "%s\n", redtext(va("Teamoverlay %s by admin veto", OnOff(cvar("k_teamoverlay")))));
else
G_bprint(2, "%s\n", redtext(va("Teamoverlay %s by majority vote", OnOff(cvar("k_teamoverlay")))));
return;
}
}
示例7: antilag
void antilag( )
{
int votes;
if ( match_in_progress )
{
G_sprint(self, 2, "%s mode %s\n", redtext("Antilag"), OnOff(2 == cvar("sv_antilag")));
return;
}
// admin may turn this status alone on server...
if ( !is_adm( self ) )
{
// Dont need to bother if less than 2 players
if ( CountPlayers() < 2 )
{
G_sprint(self, 2, "You need at least 2 players to do this.\n");
return;
}
}
self->v.antilag = !self->v.antilag;
G_bprint(2, "%s %s!%s\n", self->s.v.netname,
(self->v.antilag ? redtext(va("votes for antilag %s", OnOff(!(2 == cvar("sv_antilag"))))) :
redtext(va("withdraws %s antilag vote", g_his(self)))),
((votes = get_votes_req( OV_ANTILAG, true )) ? va(" (%d)", votes) : ""));
vote_check_antilag ();
}
示例8: norunes
void norunes()
{
if( match_in_progress && !k_matchLess )
return;
if ( !isCTF() ) {
G_sprint ( self, 2, "Can't do this in non CTF mode\n" );
return;
}
cvar_toggle_msg( self, "k_ctf_runes", redtext("runes") );
// In matchless mode, toggling runes normally won't do anything since match is already in progress. Call this to handle this scenario.
if (k_matchLess)
{
// If a player is carrying a rune when runes are disabled, get rid of it
if (!cvar("k_ctf_runes")) {
gedict_t * p;
for (p = world; (p = find_plr(p)); ) {
p->ctf_flag -= (p->ctf_flag & (CTF_RUNE_MASK));
p->maxspeed = cvar("sv_maxspeed"); // Reset speed, in case was carrying haste
}
}
SpawnRunes(cvar("k_ctf_runes")); // Toggle runes
}
}
示例9: T_RadiusDamage
/*
============
T_RadiusDamage
============
*/
void T_RadiusDamage( gedict_t * inflictor, gedict_t * attacker, float damage, gedict_t * ignore, deathType_t dtype )
{
float points;
gedict_t *head;
vec3_t org;
head = trap_findradius( world, inflictor->s.v.origin, damage + 40 );
while ( head )
{
if ( head != ignore )
{
if ( head->s.v.takedamage )
{
org[0] = inflictor->s.v.origin[0] - ( head->s.v.origin[0] + ( head->s.v.mins[0] + head->s.v.maxs[0] ) * 0.5 );
org[1] = inflictor->s.v.origin[1] - ( head->s.v.origin[1] + ( head->s.v.mins[1] + head->s.v.maxs[1] ) * 0.5 );
org[2] = inflictor->s.v.origin[2] - ( head->s.v.origin[2] + ( head->s.v.mins[2] + head->s.v.maxs[2] ) * 0.5 );
points = 0.5 * vlen( org );
if ( points < 0 )
points = 0;
points = damage - points;
if ( head == attacker )
points = points * 0.5;
// no out of water discharge damage if k_dis 2
else if ( cvar("k_dis") == 2 && dtLG_DIS == dtype && !head->s.v.waterlevel )
points = 0;
if ( points > 0 )
{
if ( CanDamage( head, inflictor ) )
{
head->deathtype = dtype;
dmg_is_splash = 1; // mark damage as splash
if ( cvar("k_instagib") || isRACE() ) // in instagib splash applied to inflictor only, for coil jump
{
if ( head == attacker )
T_Damage( head, inflictor, attacker, points );
}
else
{
// shamblers only take half damage from rocket/grenade explosions
if ( streq(head->s.v.classname, "monster_shambler") && !cvar("k_bloodfest") )
points = points / 2;
T_Damage( head, inflictor, attacker, points );
}
dmg_is_splash = 0; // unmark splash
}
}
}
}
head = trap_findradius( head, inflictor->s.v.origin, damage + 40 );
}
}
示例10: someShadowCvarIsEnabled
float someShadowCvarIsEnabled(entity box)
{
if(cvar("r_shadow_realtime_dlight"))
if(cvar("r_shadow_realtime_dlight_shadows"))
return TRUE;
if(cvar("r_shadow_realtime_world"))
if(cvar("r_shadow_realtime_world_shadows"))
return TRUE;
return FALSE;
}
示例11: loadCvarsNexuizCheckBox
void loadCvarsNexuizCheckBox(entity me)
{
if(me.inverted == 0)
me.checked = cvar(me.cvarName);
else if(me.inverted == 1)
me.checked = !cvar(me.cvarName);
else if(me.inverted > 1)
me.checked = (cvar(me.cvarName) < 0);
else if(me.inverted < -1)
me.checked = (cvar(me.cvarName) > 0);
}
示例12: XonoticCrosshairButton_draw
void XonoticCrosshairButton_draw(entity me)
{
vector sz, rgb;
float a;
rgb = eX * cvar("crosshair_color_red") + eY * cvar("crosshair_color_green") + eZ * cvar("crosshair_color_blue");
a = cvar("crosshair_alpha");
if(!me.checked && !me.focused)
{
a *= me.disabledAlpha;
rgb = '1 1 1';
}
SUPER(XonoticCrosshairButton).draw(me);
sz = draw_PictureSize(me.src3);
sz = globalToBoxSize(sz, draw_scale);
sz = (10 * '1 1 0' + sz * cvar("crosshair_size")) * 0.05; // (10 * '1 1 0' + ...) * 0.05 here to make visible size changes happen also at bigger sizes
if(sz_x > 0.95)
sz = sz * (0.95 / sz_x);
if(sz_y > 0.95)
sz = sz * (0.95 / sz_y);
draw_Picture('0.5 0.5 0' - 0.5 * sz, me.src3, sz, rgb, a);
if(cvar("crosshair_dot"))
draw_Picture('0.5 0.5 0' - 0.5 * sz * cvar("crosshair_dot_size"), me.src4, sz * cvar("crosshair_dot_size"), rgb, a * cvar("crosshair_dot_alpha"));
}
示例13: XonoticDecibelsSlider_loadCvars
void XonoticDecibelsSlider_loadCvars(entity me)
{
float v;
if not(me.cvarName)
return;
v = cvar(me.cvarName);
if(v >= 0.98)
Slider_setValue( me, 0 );
else if(v < 0.0005)
Slider_setValue( me, -1000000 );
else
Slider_setValue( me, 0.1 * floor(0.5 + 10.0 * log10(cvar(me.cvarName)) * 10) );
}
示例14: ToggleMapLock
void ToggleMapLock ()
{
float tmp;
if( !is_adm( self ) )
return;
tmp = cvar( "k_lockmap" );
if( tmp )
{
cvar_fset( "k_lockmap", 0 );
if( !match_in_progress )
G_bprint(2, "%s unlocks map\n", self->netname);
else
G_sprint(self, 2, "Map unlocked\n");
return;
}
cvar_fset( "k_lockmap", 1 );
if( !match_in_progress )
G_bprint(2, "%s locks map\n", self->netname);
else
G_sprint(self, 2, "Map is locked\n");
}
示例15: loadCvarsNexuizGametypeButton
void loadCvarsNexuizGametypeButton(entity me)
{
if not(me.cvarName)
return;
me.checked = cvar(me.cvarName);
}