本文整理匯總了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;
}
}
}
}
示例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;
}
}
}
示例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");
}
示例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";
}
示例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;
}
示例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;
}
}
}
示例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 );
}
示例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;
}
示例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 );
}
示例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 );
}
示例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!!
}
}
示例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);
}
}
示例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");
}
示例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);
}
}
示例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;
}
}