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


C++ G_AddEvent函数代码示例

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


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

示例1: fx_runner_think

//----------------------------------------------------------
void fx_runner_think( gentity_t *ent )
{
	vec3_t temp;

	EvaluateTrajectory( &ent->s.pos, level.time, ent->currentOrigin );
	EvaluateTrajectory( &ent->s.apos, level.time, ent->currentAngles );

	// call the effect with the desired position and orientation
	G_AddEvent( ent, EV_PLAY_EFFECT, ent->fxID );

	// Assume angles, we'll do a cross product on the other end to finish up
	AngleVectors( ent->currentAngles, ent->pos3, NULL, NULL );
	MakeNormalVectors( ent->pos3, ent->pos4, temp ); // there IS a reason this is done...it's so that it doesn't break every effect in the game...

	ent->nextthink = level.time + ent->delay + random() * ent->random;

	if ( ent->spawnflags & 4 ) // damage
	{
		G_RadiusDamage( ent->currentOrigin, ent, ent->splashDamage, ent->splashRadius, ent, MOD_UNKNOWN );
	}

	if ( ent->target2 )
	{
		// let our target know that we have spawned an effect
		G_UseTargets2( ent, ent, ent->target2 );
	}

	if ( !(ent->spawnflags & 2 ) && !ent->s.loopSound ) // NOT ONESHOT...this is an assy thing to do
	{
		if ( VALIDSTRING( ent->soundSet ) == true )
		{
			ent->s.loopSound = CAS_GetBModelSound( ent->soundSet, BMS_MID );

			if ( ent->s.loopSound < 0 )
			{
				ent->s.loopSound = 0;
			}
		}
	}

}
开发者ID:Hasimir,项目名称:jedi-academy-1,代码行数:42,代码来源:g_fx.cpp

示例2: NPC_MineMonster_Pain

/*
-------------------------
NPC_MineMonster_Pain
-------------------------
*/
void NPC_MineMonster_Pain(gentity_t *self, gentity_t *attacker, int damage)
{
	G_AddEvent( self, EV_PAIN, floor((float)self->health/self->client->pers.maxHealth*100.0f) );

	if ( damage >= 10 )
	{
		TIMER_Remove( self, "attacking" );
		TIMER_Remove( self, "attacking1_dmg" );
		TIMER_Remove( self, "attacking2_dmg" );
		TIMER_Set( self, "takingPain", 1350 );

		VectorCopy( &self->NPC->lastPathAngles, &self->s.angles );

		NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );

		if ( self->NPC )
		{
			self->NPC->localState = LSTATE_WAITING;
		}
	}
}
开发者ID:Geptun,项目名称:japp,代码行数:26,代码来源:NPC_AI_MineMonster.c

示例3: Slay

void __cdecl Slay(void) {
    int argc = Cmd_Argc();
    if (argc < 2) {
        Com_Printf("Usage: %s <client_id>\n", Cmd_Argv(0));
        return;
    }
    int i = atoi(Cmd_Argv(1));
    if (i < 0 || i > sv_maxclients->integer) {
        Com_Printf("client_id must be a number between 0 and %d\n.", sv_maxclients->integer);
        return;
    }
    else if (g_entities[i].inuse && g_entities[i].health > 0) {
        Com_Printf("Slaying player...\n");
        SV_SendServerCommand(NULL, "print \"%s^7 was slain!\n\"\n", svs->clients[i].name);
        DebugPrint("Slaying '%s'!\n", svs->clients[i].name);
		g_entities[i].health = -40;
		G_AddEvent(&g_entities[i], EV_GIB_PLAYER, g_entities[i].s.number);
    }
    else
        Com_Printf("The player is currently not active.\n");
}
开发者ID:JoolsJealous,项目名称:minqlx,代码行数:21,代码来源:commands.c

示例4: AICast_AimAtEnemy

/*
=======================================================================================================================================
AIFunc_Helga_MeleeStart
=======================================================================================================================================
*/
char *AIFunc_Helga_MeleeStart(cast_state_t *cs) {
	gentity_t *ent;

	ent = &g_entities[cs->entityNum];
	ent->s.effect1Time = level.time;
	cs->ideal_viewangles[YAW] = cs->viewangles[YAW];
	cs->weaponFireTimes[cs->weaponNum] = level.time;
	cs->animHitCount = 0;
	cs->aiFlags |= AIFL_SPECIAL_FUNC;
	// face them
	AICast_AimAtEnemy(cs);
	// play an anim
	BG_UpdateConditionValue(cs->entityNum, ANIM_COND_WEAPON, cs->weaponNum, qtrue);
	BG_AnimScriptEvent(&ent->client->ps, ANIM_ET_FIREWEAPON, qfalse, qtrue);
	// play a sound
	G_AddEvent(ent, EV_GENERAL_SOUND, G_SoundIndex(aiDefaults[ent->aiCharacter].soundScripts[ATTACKSOUNDSCRIPT]));

	cs->aifunc = AIFunc_Helga_Melee;
	cs->aifunc(cs);  // think once now, to prevent a delay
	return "AIFunc_Helga_Melee";
}
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:26,代码来源:ai_cast_func_boss1.c

示例5: G_ScriptAction_PlaySound

/*
================
G_ScriptAction_PlaySound

  syntax: playsound <soundname OR scriptname> [LOOPING]

  Currently only allows playing on the VOICE channel, unless you use a sound script.

  Use the optional LOOPING paramater to attach the sound to the entities looping channel.
================
*/
qboolean G_ScriptAction_PlaySound( gentity_t *ent, char *params ) {
    char *pString, *token;
    char sound[MAX_QPATH];

    if ( !params ) {
        G_Error( "G_Scripting: syntax error\n\nplaysound <soundname OR scriptname>\n" );
    }

    pString = params;
    token = COM_ParseExt( &pString, qfalse );
    Q_strncpyz( sound, token, sizeof( sound ) );

    token = COM_ParseExt( &pString, qfalse );
    if ( !token[0] || Q_strcasecmp( token, "looping" ) ) {
        G_AddEvent( ent, EV_GENERAL_SOUND, G_SoundIndex( sound ) );
    } else {    // looping channel
        ent->s.loopSound = G_SoundIndex( sound );
    }

    return qtrue;
}
开发者ID:aleksandr-pushkarev,项目名称:RTCW-SP,代码行数:32,代码来源:g_script_actions.c

示例6: NPC_MineMonster_Pain

/*
-------------------------
NPC_MineMonster_Pain
-------------------------
*/
void NPC_MineMonster_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, const vec3_t point, int damage, int mod,int hitLoc ) 
{
	G_AddEvent( self, EV_PAIN, floor((float)self->health/self->max_health*100.0f) );

	if ( damage >= 10 )
	{
		TIMER_Remove( self, "attacking" );
		TIMER_Remove( self, "attacking1_dmg" );
		TIMER_Remove( self, "attacking2_dmg" );
		TIMER_Set( self, "takingPain", 1350 );

		VectorCopy( self->NPC->lastPathAngles, self->s.angles );

		NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD );

		if ( self->NPC )
		{
			self->NPC->localState = LSTATE_WAITING;
		}
	}
}
开发者ID:Arbixal,项目名称:OpenJK,代码行数:26,代码来源:AI_MineMonster.cpp

示例7: G_GiveClientMaxAmmo

/*
=================
G_GiveClientMaxAmmo
=================
*/
void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
{
  int       i;
  int       maxAmmo, maxClips;
  qboolean  weaponType, restoredAmmo = qfalse;

  for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
  {
    if( buyingEnergyAmmo )
      weaponType = BG_FindUsesEnergyForWeapon( i );
    else
      weaponType = !BG_FindUsesEnergyForWeapon( i );

    if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
        weaponType && !BG_FindInfinteAmmoForWeapon( i ) &&
        !BG_WeaponIsFull( i, ent->client->ps.stats,
          ent->client->ps.ammo, ent->client->ps.powerups ) )
    {
      BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips );

      if( buyingEnergyAmmo )
      {
        G_AddEvent( ent, EV_RPTUSE_SOUND, 0 );

        if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
          maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
      }
      else if ( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
	maxClips = (int)( (float)maxAmmo * BATTPACK_MODIFIER );

      BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups,
                        maxAmmo, maxClips );

      restoredAmmo = qtrue;
    }
  }

  if( restoredAmmo )
    G_ForceWeaponChange( ent, ent->client->ps.weapon );
}
开发者ID:ZdrytchX,项目名称:Lolards_old,代码行数:45,代码来源:g_weapon.c

示例8: LetGoOfGatling

/*
========================
LetGoOfGatling

Make a player let go of the deployed gatling he's using.
========================
*/
static void LetGoOfGatling(gclient_t *client, gentity_t *gatling) {
	// add the ammo into the gatling
	gatling->count = client->ps.ammo[WP_GATLING];
	client->ps.weaponTime = 0;
	client->ps.eFlags &= ~EF_RELOAD;
	client->ps.stats[STAT_GATLING_MODE] = 0;

	// only do that if player doesn't carry another gatling
	if(!(client->ps.stats[STAT_FLAGS] & SF_GAT_CARRY)) {
		client->ps.stats[STAT_WEAPONS] &= ~(1 << WP_GATLING);
		client->ps.ammo[WP_GATLING] = 0;
	}
	else {
		client->ps.ammo[WP_GATLING] = client->carriedGatlingAmmo;
	}

	if(!client->ps.stats[STAT_OLDWEAPON] ||
			  (client->ps.stats[STAT_OLDWEAPON] == WP_GATLING &&
			  !(client->ps.stats[STAT_FLAGS] & SF_GAT_CARRY))) {
		int i;

		for ( i = WP_GATLING ; i > 0 ; i-- ) {
			if ( client->ps.stats[STAT_WEAPONS] & ( 1 << i ) ) {
				client->ps.stats[STAT_OLDWEAPON] = i;
				break;
			}
		}

		//G_Printf("away %i\n", client->ps.stats[STAT_OLDWEAPON]);
	}

	client->pers.cmd.weapon = client->ps.stats[STAT_OLDWEAPON];
	G_AddEvent(&g_entities[gatling->s.eventParm], EV_CHANGE_TO_WEAPON, client->ps.stats[STAT_OLDWEAPON]);

	gatling->s.eventParm = -1;

	// Tequila comment: Gatling is now an object in the world
	gatling->r.contents = MASK_SHOT;
}
开发者ID:Mixone-FinallyHere,项目名称:SmokinGuns,代码行数:46,代码来源:g_sg_utils.c

示例9: Use_Shooter

void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
	vec3_t		dir;
	float		deg;
	vec3_t		up, right;

	// see if we have a target
	if ( ent->enemy ) {
		VectorSubtract( ent->enemy->r.currentOrigin, ent->s.origin, dir );
		VectorNormalize( dir );
	} else {
		VectorCopy( ent->movedir, dir );
	}

	// randomize a bit
	PerpendicularVector( up, dir );
	CrossProduct( up, dir, right );

	deg = crandom() * ent->random;
	VectorMA( dir, deg, up, dir );

	deg = crandom() * ent->random;
	VectorMA( dir, deg, right, dir );

	VectorNormalize( dir );

	switch ( ent->s.weapon ) {
	case WP_GRENADE_LAUNCHER:
		fire_grenade( ent, ent->s.origin, dir );
		break;
	case WP_ROCKET_LAUNCHER:
		fire_rocket( ent, ent->s.origin, dir );
		break;
	case WP_PLASMAGUN:
		fire_plasma( ent, ent->s.origin, dir );
		break;
	}

	G_AddEvent( ent, EV_FIRE_WEAPON, 0 );
}
开发者ID:d00man,项目名称:openarena-vm,代码行数:39,代码来源:g_misc.c

示例10: buildFire

/*
===============
buildFire
===============
*/
void buildFire( gentity_t *ent, dynMenu_t menu )
{
  if( ( ent->client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) > BA_NONE )
  {
    if( ent->client->ps.stats[ STAT_MISC ] > 0 )
    {
      G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum );
      return;
    }

    if( G_ValidateBuild( ent, ent->client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) )
    {
      if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && !G_isOvermind( ) )
      {
        ent->client->ps.stats[ STAT_MISC ] +=
          BG_FindBuildDelayForWeapon( ent->s.weapon ) * 2;
      }
      else if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS && !G_isPower( muzzle ) &&
          ( ent->client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) != BA_H_REPEATER ) //hack
      {
        ent->client->ps.stats[ STAT_MISC ] +=
          BG_FindBuildDelayForWeapon( ent->s.weapon ) * 2;
      }
      else
        ent->client->ps.stats[ STAT_MISC ] +=
          BG_FindBuildDelayForWeapon( ent->s.weapon );

      ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;

      // don't want it bigger than 32k
      if( ent->client->ps.stats[ STAT_MISC ] > 30000 )
        ent->client->ps.stats[ STAT_MISC ] = 30000;
    }
    return;
  }

  G_TriggerMenu( ent->client->ps.clientNum, menu );
}
开发者ID:wtfbbqhax,项目名称:thz,代码行数:43,代码来源:g_weapon.c

示例11: Cmd_UseSentry_f

void Cmd_UseSentry_f(gentity_t *ent)
{
	if ( ent->health < 1 || in_camera )
	{
		return;
	}

	if ( ent->client->ps.inventory[INV_SENTRY] <= 0 )
	{
		// have none to place...play sound?
		return;
	}

	if ( place_portable_assault_sentry( ent, ent->currentOrigin, ent->client->ps.viewangles ))
	{
		ent->client->ps.inventory[INV_SENTRY]--;
		G_AddEvent( ent, EV_USE_INV_SENTRY, 0 );
	}
	else
	{
		// couldn't be placed....play a notification sound!!
	}
}
开发者ID:PJayB,项目名称:jk2src,代码行数:23,代码来源:g_cmds.cpp

示例12: ObeliskPain

/*
=======================================================================================================================================
ObeliskPain
=======================================================================================================================================
*/
void ObeliskPain(gentity_t *self, gentity_t *attacker, int damage) {
	int actualDamage;

	actualDamage = damage / 10;

	if (actualDamage <= 0) {
		actualDamage = 1;
	}

	self->activator->s.modelindex2 = self->health * 0xff / g_obeliskHealth.integer;

	if (!self->activator->s.frame) {
		G_AddEvent(self, EV_OBELISKPAIN, 0);
	}

	self->activator->s.frame = 1;

	if (self->spawnflags == attacker->client->sess.sessionTeam) {
		AddScore(attacker, self->r.currentOrigin, -actualDamage);
	} else {
		AddScore(attacker, self->r.currentOrigin, actualDamage);
	}
}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:28,代码来源:g_team.c

示例13: alarmbox_use

/**
 * @brief alarmbox_use
 * @param[in,out] ent
 * @param[in] other
 * @param foo - unused
 */
void alarmbox_use(gentity_t *ent, gentity_t *other, gentity_t *foo)
{
	if (!(ent->active))
	{
		return;
	}

	if (ent->s.frame)
	{
		ent->s.frame = 0;
	}
	else
	{
		ent->s.frame = 1;
	}

	alarmbox_updateparts(ent, qtrue);
	if (other->client)
	{
		G_AddEvent(ent, EV_GENERAL_SOUND, ent->soundPos3);
	}
	//	G_Printf("touched alarmbox\n");
}
开发者ID:zturtleman,项目名称:etlegacy,代码行数:29,代码来源:g_alarm.c

示例14: G_minethink

void
G_minethink(gentity_t *ent)
{
  trace_t tr;
  vec3_t end, origin, dir;
  gentity_t *traceEnt;

  ent->nextthink = level.time + 100;

  BG_EvaluateTrajectory(&ent->s.pos, level.time, origin);
  SnapVector(origin);
  G_SetOrigin(ent, origin);

  // set aiming directions
  VectorCopy(origin,end);
  end[2] += 10;//aim up

  trap_Trace(&tr, origin, NULL, NULL, end, ent->s.number, MASK_SHOT);
  if (tr.surfaceFlags & SURF_NOIMPACT)
    return;

  traceEnt = &g_entities[tr.entityNum];

  dir[0] = dir[1] = 0;
  dir[2] = 1;

  if (traceEnt->client && (traceEnt->r.svFlags & SVF_BOT)
      && traceEnt->health > 0 && traceEnt->client->ps.stats[STAT_PTEAM] == PTE_ALIENS)//FIRE IN ZE HOLE!
  {//Might want to check team too
    ent->s.eType = ET_GENERAL;
    G_AddEvent(ent, EV_MISSILE_MISS, DirToByte(dir));
    ent->freeAfterEvent = qtrue;
    G_RadiusDamage(ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent, ent->splashMethodOfDeath);
    ent->parent->numMines -= 1;
    trap_LinkEntity(ent);
  }
}
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:37,代码来源:g_missile.c

示例15: ProximityMine_Player

/*
================
ProximityMine_Player
================
*/
static void ProximityMine_Player(gentity_t * mine, gentity_t * player)
{
	if(mine->s.eFlags & EF_NODRAW)
	{
		return;
	}

	G_AddEvent(mine, EV_PROXIMITY_MINE_STICK, 0);

	if(player->s.eFlags & EF_TICKING)
	{
		player->activator->splashDamage += mine->splashDamage;
		player->activator->splashRadius *= 1.50;
		mine->think = G_FreeEntity;
		mine->nextthink = level.time;
		return;
	}

	player->client->ps.eFlags |= EF_TICKING;
	player->activator = mine;

	mine->s.eFlags |= EF_NODRAW;
	mine->r.svFlags |= SVF_NOCLIENT;
	mine->s.pos.trType = TR_LINEAR;
	VectorClear(mine->s.pos.trDelta);

	mine->enemy = player;
	mine->think = ProximityMine_ExplodeOnPlayer;
	if(player->client->invulnerabilityTime > level.time)
	{
		mine->nextthink = level.time + 2 * 1000;
	}
	else
	{
		mine->nextthink = level.time + 10 * 1000;
	}
}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:42,代码来源:g_missile.c


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