当前位置: 首页>>代码示例>>C++>>正文


C++ VARS函数代码示例

本文整理汇总了C++中VARS函数的典型用法代码示例。如果您正苦于以下问题:C++ VARS函数的具体用法?C++ VARS怎么用?C++ VARS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VARS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Kpp__ResetFunc

short PEXPORT Kpp__ResetFunc(LPFUNC lpFunc)
{
    if (! (FLAGS(lpFunc) & CBODY))
    {
        /* first delete the list of variables */
        if (VARS(lpFunc) != NULLID)
        {
            KppClearVarList(VARS(lpFunc));
            KppClearList(VARS(lpFunc), VAR);
            KppDeleteList(VARS(lpFunc));
            VARS (lpFunc) = NULLID;
        }

        /* then delete the body */
        if (BODY(lpFunc) != NULLID)
        {
            KppDeleteExp(BODY(lpFunc));
            BODY(lpFunc) = NULLID;
        }
    }
    
    return TRUE;
}
开发者ID:thearttrooper,项目名称:KappaPC,代码行数:23,代码来源:KFUNC.C

示例2: SpawnHeadGib

void CGib :: SpawnHeadGib( entvars_t *pevVictim, const char* szGibModel )
{
	CGib *pGib = GetClassPtr( (CGib *)NULL );

	pGib->Spawn( szGibModel );// throw one head
	pGib->pev->body = 0;

	if ( pevVictim )
	{
		pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs;
		
		edict_t		*pentPlayer = FIND_CLIENT_IN_PVS( pGib->edict() );
		
		if ( RANDOM_LONG ( 0, 100 ) <= 5 && pentPlayer )
		{
			// 5% chance head will be thrown at player's face.
			entvars_t	*pevPlayer;

			pevPlayer = VARS( pentPlayer );
			pGib->pev->velocity = ( ( pevPlayer->origin + pevPlayer->view_ofs ) - pGib->pev->origin ).Normalize() * 300;
			pGib->pev->velocity.z += 100;
		}
		else
		{
			pGib->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300));
		}


		pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 );
		pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 );

		// copy owner's blood color
		pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor();
	
		if ( pevVictim->health > -50)
		{
			pGib->pev->velocity = pGib->pev->velocity * 0.7;
		}
		else if ( pevVictim->health > -200)
		{
			pGib->pev->velocity = pGib->pev->velocity * 2;
		}
		else
		{
			pGib->pev->velocity = pGib->pev->velocity * 4;
		}
	}
	pGib->LimitVelocity();
}
开发者ID:RichardRohac,项目名称:hl-amnesia-src,代码行数:49,代码来源:combat.cpp

示例3: AddNodeEntity

void AddNodeEntity(const Vector &origin, int effects)
{
   edict_t *pNode = CREATE_ENTITY();
   if (g_fIsMetamod) {
      CALL_GAME_ENTITY(PLID, "info_node", VARS(pNode));
   } else {
      info_node(VARS(pNode));
   }

   pNode->v.classname = MAKE_STRING("info_node");
   SET_ORIGIN(pNode, origin);
   pNode->v.rendercolor.x = 255;
   pNode->v.rendercolor.y = 255;
   pNode->v.rendercolor.z = 0;
   pNode->v.rendermode = kRenderTransAdd;
   pNode->v.movetype = MOVETYPE_NONE;
   pNode->v.solid = SOLID_TRIGGER;
   SET_SIZE(ENT(&pNode->v), Vector(-8, -8, -8), Vector(8, 8, 8));
   pNode->v.renderfx = kRenderFxNoDissipation;
   pNode->v.renderamt = 255;
   pNode->v.scale = 0.2;
   SET_MODEL(ENT(pNode), "sprites/glow02.spr");
   pNode->v.effects = effects;
}
开发者ID:CecilHarvey,项目名称:gina,代码行数:24,代码来源:engine_util.cpp

示例4: __CopyFunc

FUNCID __CopyFunc(LPFUNC lpOldFunc, ITEMID idName)
{
    FUNCID      idFunc;
    LPFUNC      lpFunc;
    LPEXP       lpBody;
    EXPID       idBody;

    if (GetFunc(idName) != NULLID)
        return NULLID;
    
    idFunc = KppAddItemAndName (FUNC, (LPLPSTR)&lpFunc, idName);
    if (!idFunc)
        return NULLID;
    NAME(lpFunc) = idName;
    FLAGS(lpFunc) = NULL;
    NUMVARS(lpFunc) = NUMVARS(lpOldFunc);
    if (! (FLAGS(lpFunc) & CBODY))
    {
        VARS(lpFunc) = KppDeepListCopy(VARS(lpOldFunc), Kpp__CopyVar, idFunc);
        if (BODY(lpOldFunc) == NULLID)
            idBody = NULLID;
        else
        {
            idBody = BODY(lpFunc) = KppCopyExp(BODY(lpOldFunc),
                                        (LPLPSTR)&lpBody, kPERMMODE);
            KppReleaseExp(idBody);
        }
    }

    KppReleaseItem(FUNC, idFunc);

    /* Add to KnowledgeTools */
    KppAddItemCB (FUNC, 1);

    return idFunc;
}
开发者ID:thearttrooper,项目名称:KappaPC,代码行数:36,代码来源:KFUNC.C

示例5: DecalGunshot

void DecalGunshot( TraceResult *pTrace, int iBulletType )
{
	// Is the entity valid
	if ( !UTIL_IsValidEntity( pTrace->pHit ) )
		return;

	if ( VARS(pTrace->pHit)->solid == SOLID_BSP || VARS(pTrace->pHit)->movetype == MOVETYPE_PUSHSTEP )
	{
		CBaseEntity *pEntity = NULL;
		// Decal the wall with a gunshot
		if ( !FNullEnt(pTrace->pHit) )
			pEntity = CBaseEntity::Instance(pTrace->pHit);

		switch( iBulletType )
		{
		case BULLET_PLAYER_9MM:
		case BULLET_MONSTER_9MM:
		case BULLET_PLAYER_MP5:
		case BULLET_MONSTER_MP5:
		case BULLET_PLAYER_BUCKSHOT:
		case BULLET_PLAYER_357:
		default:
			// smoke and decal
			UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
			break;
		case BULLET_MONSTER_12MM:
			// smoke and decal
			UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
			break;
		case BULLET_PLAYER_CROWBAR:
			// wall decal
			UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) );
			break;
		}
	}
}
开发者ID:vermagav,项目名称:mechmod,代码行数:36,代码来源:weapons.cpp

示例6: DispatchCreate

int DispatchCreate( edict_t *pent, const char *szName )
{
	if( FNullEnt( pent ) || FStringNull( szName ))
		return -1;

	int istr = ALLOC_STRING( szName );

	// handle virtual entities here
	if( !strncmp( szName, "weapon_", 7 ))
	{
		CBasePlayerWeapon *pWeapon = GetClassPtr((CBasePlayerWeapon *)VARS( pent ));
		if( !pWeapon ) return -1;
		pWeapon->pev->netname = istr; 
		return 0;
	}
	else if( !strncmp( szName, "item_", 5 ) || !strncmp( szName, "ammo_", 5 ))
	{
		CItem *pItem = GetClassPtr((CItem *)VARS( pent ));
		if( !pItem ) return -1;
  		pItem->pev->netname = istr; 
		return 0;
	}
	return -1;
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:24,代码来源:dll_int.cpp

示例7: BeamBreakThink

void CTripmineGrenade :: BeamBreakThink( void  )
{
	BOOL bBlowup = 0;

	TraceResult tr;

	// HACKHACK Set simple box using this really nice global!
	gpGlobals->trace_flags = FTRACE_SIMPLEBOX;
	UTIL_TraceLine( pev->origin, m_vecEnd, dont_ignore_monsters, ENT( pev ), &tr );

	// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );

	// respawn detect. 
	if ( !m_pBeam )
	{
		MakeBeam( );
		if ( tr.pHit )
			m_hOwner = CBaseEntity::Instance( tr.pHit );	// reset owner too
	}

	if (fabs( m_flBeamLength - tr.flFraction ) > 0.001)
	{
		bBlowup = 1;
	}
	else
	{
		if (m_hOwner == NULL)
			bBlowup = 1;
		else if (m_posOwner != m_hOwner->pev->origin)
			bBlowup = 1;
		else if (m_angleOwner != m_hOwner->pev->angles)
			bBlowup = 1;
	}

	if (bBlowup)
	{
		// a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill
		// so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant
		// that a player couldn't trigger his own tripmine. Now that the mine is exploding, it's safe the restore the owner so the 
		// CGrenade code knows who the explosive really belongs to.
		pev->owner = m_pRealOwner;
		pev->health = 0;
		Killed( VARS( pev->owner ), GIB_NORMAL );
		return;
	}

	pev->nextthink = gpGlobals->time + 0.1;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:48,代码来源:tripmine.cpp

示例8: CREATE_NAMED_ENTITY

edict_t *ParaSpawnItem( edict_t *pent )
{
	// Spawns the parachute on the ground that people can pick up to "get" a parachute
	// item_parachute

	edict_t *pent2 = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
	entvars_t *pev = VARS( pent2 );
	
	if (pent) {

		pev->origin = pent->v.origin;
		pev->angles = pent->v.angles;
	}

	SET_ORIGIN( pent2 , pev->origin );

	// for now don't take damage
	pev->takedamage = DAMAGE_NO;
	pev->max_health = 20;
	pev->health = 20;
	//pev->owner = pent;
	
	// Call the SPAWN routine to set more stuff
	KeyValueData	kvd;

	kvd.fHandled = FALSE;
	kvd.szClassName = NULL;
	kvd.szKeyName = "classname";
	kvd.szValue = "item_avparachute";
	(*other_gFunctionTable.pfnKeyValue)( pent2, &kvd );
	kvd.fHandled = FALSE;
	
	pev->movetype = MOVETYPE_TOSS;
	pev->solid = SOLID_TRIGGER;
	pev->effects &= ~EF_NODRAW;
	pev->iuser1 = 1;

	DROP_TO_FLOOR( pent2 );

	
	SET_MODEL(pent2, "models/w_longjump.mdl");
	UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));

	pev->nextthink = gpGlobals->time + 0.1;	

	return pent2;

}
开发者ID:Landokane,项目名称:avc,代码行数:48,代码来源:avpara.cpp

示例9: VARS

void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
{
	int damageFlags = DMG_GENERIC;
	int clientIndex = pPlayer->entindex();

	if ( !bGib )
	{
		damageFlags |= DMG_NEVERGIB;
	}
	else
	{
		damageFlags |= DMG_ALWAYSGIB;
	}

	if ( bKill )
	{
		// kill the player,  remove a death,  and let them start on the new team
		m_DisableDeathMessages = TRUE;
		m_DisableDeathPenalty = TRUE;

		entvars_t *pevWorld = VARS( INDEXENT(0) );
		pPlayer->TakeDamage( pevWorld, pevWorld, 900, damageFlags );

		m_DisableDeathMessages = FALSE;
		m_DisableDeathPenalty = FALSE;
	}

	// copy out the team name from the model
	if (pPlayer->m_szTeamName != pTeamName)
		strncpy(pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH);

	g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
	g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );

	// notify everyone's HUD of the team change
	MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo );
		WRITE_BYTE( clientIndex );
		WRITE_STRING( pPlayer->m_szTeamName );
	MESSAGE_END();

	MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
		WRITE_BYTE( clientIndex );
		WRITE_SHORT( pPlayer->pev->frags );
		WRITE_SHORT( pPlayer->m_iDeaths );
		WRITE_SHORT( 0 );
		WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 );
	MESSAGE_END();
}
开发者ID:Hammermaps-DEV,项目名称:SOHL-V1.0-Refresh,代码行数:48,代码来源:teamplay_gamerules.cpp

示例10: UTIL_PrecacheOther

void UTIL_PrecacheOther( const char *szClassname )
{
	edict_t	*pent;

	pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) );
	if ( FNullEnt( pent ) )
	{
		ALERT ( at_console, "NULL Ent in UTIL_PrecacheOther\n" );
		return;
	}
	
	CBaseEntity *pEntity = CBaseEntity::Instance (VARS( pent ));
	if (pEntity)
		pEntity->Precache( );
	REMOVE_ENTITY(pent);
}
开发者ID:CryoKeen,项目名称:HLEnhanced,代码行数:16,代码来源:util.cpp

示例11: FIND_ENTITY_BY_TARGETNAME

// find a viable entity
int CCineMonster::FindEntity(void)
{
	edict_t *pentTarget;

	pentTarget            = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity));
	m_hTargetEnt          = NULL;
	CBaseMonster *pTarget = NULL;

	while(!FNullEnt(pentTarget))
	{
		if(FBitSet(VARS(pentTarget)->flags, FL_MONSTER))
		{
			pTarget = GetMonsterPointer(pentTarget);
			if(pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_BY_NAME))
			{
				m_hTargetEnt = pTarget;
				return TRUE;
			}
			ALERT(at_console, "Found %s, but can't play!\n", STRING(m_iszEntity));
		}
		pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
		pTarget    = NULL;
	}

	if(!pTarget)
	{
		CBaseEntity *pEntity = NULL;
		while((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, m_flRadius)) != NULL)
		{
			if(FClassnameIs(pEntity->pev, STRING(m_iszEntity)))
			{
				if(FBitSet(pEntity->pev->flags, FL_MONSTER))
				{
					pTarget = pEntity->MyMonsterPointer();
					if(pTarget && pTarget->CanPlaySequence(FCanOverrideState(), SS_INTERRUPT_IDLE))
					{
						m_hTargetEnt = pTarget;
						return TRUE;
					}
				}
			}
		}
	}
	pTarget      = NULL;
	m_hTargetEnt = NULL;
	return FALSE;
}
开发者ID:Sh1ft0x0EF,项目名称:HLSDKRevamp,代码行数:48,代码来源:Scripted.cpp

示例12: UTIL_PointContents

void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType)
{
	pev->model = 0;
	pev->solid = SOLID_NOT;
	pev->takedamage = DAMAGE_NO;

	if (pTrace->flFraction != 1)
		pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);

	int iContents = UTIL_PointContents(pev->origin);
	CSoundEnt::InsertSound(bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3);
	entvars_t *pevOwner;

	if (pev->owner)
		pevOwner = VARS(pev->owner);
	else
		pevOwner = NULL;

	pev->owner = NULL;
	RadiusFlash(pev->origin, pev, pevOwner, 4);

	if (RANDOM_FLOAT(0, 1) < 0.5)
		UTIL_DecalTrace(pTrace, DECAL_SCORCH1);
	else
		UTIL_DecalTrace(pTrace, DECAL_SCORCH2);

	float flRndSound = RANDOM_FLOAT(0, 1);

	switch (RANDOM_LONG(0, 1))
	{
		case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/flashbang-1.wav", 0.55, ATTN_NORM); break;
		case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/flashbang-2.wav", 0.55, ATTN_NORM); break;
	}

	pev->effects |= EF_NODRAW;
	SetThink(&CGrenade::Smoke);
	pev->velocity = g_vecZero;
	pev->nextthink = gpGlobals->time + 0.3;

	if (iContents != CONTENTS_WATER)
	{
		int sparkCount = RANDOM_LONG(0, 3);

		for (int i = 0; i < sparkCount; i++)
			Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL);
	}
}
开发者ID:RomkaZVO,项目名称:cs16-client,代码行数:47,代码来源:ggrenade.cpp

示例13: GetEyes

void CHostageImprov::ClearPath()
{
	Vector start;
	Vector end;
	TraceResult result;

	if (!m_clearPathTimer.IsElapsed())
		return;

	m_clearPathTimer.Start(RANDOM_FLOAT(0.3f, 0.5f));

	const Vector eye = GetEyes();
	start = eye;

	UTIL_MakeVectors(m_hostage->pev->angles);
	end = gpGlobals->v_forward * 64 + start;

	UTIL_TraceLine(start, end, ignore_monsters, dont_ignore_glass, m_hostage->edict(), &result);

	if (result.flFraction == 1.0f)
		return;

	if (result.pHit != NULL)
	{
		entvars_t *entity = VARS(result.pHit);

		if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating"))
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->Touch(m_hostage);
			}
		}
		else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES)
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET);
			}
		}
	}
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:46,代码来源:hostage_improv.cpp

示例14: StaticDecal

void CDecal :: StaticDecal( void )
{
	TraceResult trace;
	int			entityIndex, modelIndex;

	UTIL_TraceLine( pev->origin - Vector(5,5,5), pev->origin + Vector(5,5,5),  ignore_monsters, ENT(pev), &trace );

	entityIndex = (short)ENTINDEX(trace.pHit);
	if ( entityIndex )
		modelIndex = (int)VARS(trace.pHit)->modelindex;
	else
		modelIndex = 0;

	g_engfuncs.pfnStaticDecal( pev->origin, (int)pev->skin, entityIndex, modelIndex );

	SUB_Remove();
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:17,代码来源:world.cpp

示例15: DispatchKeyValue

void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd )
{
	if ( !pkvd || !pentKeyvalue )return;

	EntvarsKeyvalue( VARS(pentKeyvalue), pkvd );

	// if the key was an entity variable, or there's no class set yet,
	// don't look for the object, it may not exist yet.
	if( pkvd->fHandled || pkvd->szClassName == NULL )
		return;

	// Get the actualy entity object
	CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue);

	if( !pEntity ) return;
	pEntity->KeyValue( pkvd );
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:17,代码来源:dll_int.cpp


注:本文中的VARS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。