本文整理汇总了C++中G_Script_ScriptEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ G_Script_ScriptEvent函数的具体用法?C++ G_Script_ScriptEvent怎么用?C++ G_Script_ScriptEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_Script_ScriptEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Team_DroppedFlagThink
/*
==============
Team_DroppedFlagThink
Automatically set in Launch_Item if the item is one of the flags
Flags are unique in that if they are dropped, the base flag must be respawned when they time out
==============
*/
void Team_DroppedFlagThink(gentity_t *ent) {
if (ent->item->giTag == PW_REDFLAG) {
G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned");
Team_ReturnFlagSound(ent, TEAM_AXIS);
Team_ResetFlag(ent);
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "axis_object_returned");
}
// Nico, bugfix: removed left printf
// http://games.chruker.dk/enemy_territory/modding_project_bugfix.php?bug_id=058
// trap_SendServerCommand( -1, "cp \"Axis have returned the objective!\" 2" );
} else if (ent->item->giTag == PW_BLUEFLAG) {
G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned");
Team_ReturnFlagSound(ent, TEAM_ALLIES);
Team_ResetFlag(ent);
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "allied_object_returned");
}
}
// Reset Flag will delete this entity
}
示例2: G_CallSpawn
/*
===============
G_CallSpawn
Finds the spawn function for the entity and calls it,
returning qfalse if not found
===============
*/
qboolean G_CallSpawn(gentity_t *ent)
{
spawn_t *s;
gitem_t *item;
if (!ent->classname)
{
G_Printf("G_CallSpawn: NULL classname\n");
return qfalse;
}
// check item spawn functions
for (item = bg_itemlist + 1 ; item->classname ; item++)
{
if (!strcmp(item->classname, ent->classname))
{
// found it
if (g_gametype.integer != GT_WOLF_LMS) // lets not have items in last man standing for the moment
{
G_SpawnItem(ent, item);
G_Script_ScriptParse(ent);
G_Script_ScriptEvent(ent, "spawn", "");
}
else
{
return qfalse;
}
return qtrue;
}
}
// check normal spawn functions
for (s = spawns ; s->name ; s++)
{
if (!strcmp(s->name, ent->classname))
{
// found it
s->spawn(ent);
// entity scripting
if (/*ent->s.number >= MAX_CLIENTS &&*/ ent->scriptName)
{
G_Script_ScriptParse(ent);
G_Script_ScriptEvent(ent, "spawn", "");
}
return qtrue;
}
}
// hack: this avoids spammy prints on start, bsp uses obsolete classnames!
// bot_sniper_spot (railgun)
if (Q_stricmp(ent->classname, "bot_sniper_spot"))
{
G_Printf("%s doesn't have a spawn function\n", ent->classname);
}
return qfalse;
}
示例3: target_script_trigger_use
/*QUAKED target_script_trigger (1 .7 .2) (-8 -8 -8) (8 8 8)
must have an aiName
must have a target
when used it will fire its targets
*/
void target_script_trigger_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
// START Mad Doctor I changes, 8/16/2002
qboolean found = qfalse;
// Nico, silent GCC
(void)activator;
// Are we using ainame to find another ent instead of using scriptname for this one?
if (ent->aiName) {
gentity_t *trent = NULL;
// Find the first entity with this name
trent = G_Find(trent, FOFS(scriptName), ent->aiName);
// Was there one?
if (trent) {
// We found it
found = qtrue;
// Play the script
G_Script_ScriptEvent(trent, "trigger", ent->target);
} // if (trent)...
} // if (ent->aiName)...
// Use the old method if we didn't find an entity with the ainame
if (!found && ent->scriptName) {
G_Script_ScriptEvent(ent, "trigger", ent->target);
}
G_UseTargets(ent, other);
}
示例4: Touch_flagonly
void Touch_flagonly( gentity_t *ent, gentity_t *other, trace_t *trace ) {
if ( !other->client ) {
return;
}
if ( ent->spawnflags & RED_FLAG && other->client->ps.powerups[ PW_REDFLAG ] ) {
AddScore( other, ent->accuracy ); // JPW NERVE set from map, defaults to 20
G_Script_ScriptEvent( ent, "death", "" );
// Removes itself
ent->touch = 0;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
} else if ( ent->spawnflags & BLUE_FLAG && other->client->ps.powerups[ PW_BLUEFLAG ] ) {
AddScore( other, ent->accuracy ); // JPW NERVE set from map, defaults to 20
G_Script_ScriptEvent( ent, "death", "" );
// Removes itself
ent->touch = 0;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
}
}
示例5: Team_TouchOurFlag
int Team_TouchOurFlag(gentity_t *ent, gentity_t *other, int team) {
gclient_t *cl = other->client;
if (ent->flags & FL_DROPPED_ITEM) {
// hey, its not home. return it by teleporting it back
if (cl->sess.sessionTeam == TEAM_AXIS) {
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "axis_object_returned");
}
G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned");
} else {
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "allied_object_returned");
}
G_Script_ScriptEvent(&g_entities[ent->s.otherEntityNum], "trigger", "returned");
}
// dhm
// jpw 800 672 2420
//ResetFlag will remove this entity! We must return zero
Team_ReturnFlagSound(ent, team);
Team_ResetFlag(ent);
return 0;
}
// DHM - Nerve :: GT_WOLF doesn't support capturing the flag
return 0;
}
示例6: Touch_flagonly
void Touch_flagonly (gentity_t *ent, gentity_t *other, trace_t *trace) {
gentity_t* tmp;
if (!other->client)
return;
if ( ent->spawnflags & RED_FLAG && other->client->ps.powerups[ PW_REDFLAG ] ) {
if( ent->spawnflags & 4 ) {
other->client->ps.powerups[ PW_REDFLAG ] = 0;
other->client->speedScale = 0;
}
AddScore(other, ent->accuracy); // JPW NERVE set from map, defaults to 20
//G_AddExperience( other, 2.f );
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent( ent, "death", "" );
G_Script_ScriptEvent( &g_entities[other->client->flagParent], "trigger", "captured" );
ent->parent = tmp;
// Removes itself
ent->touch = NULL;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
} else if ( ent->spawnflags & BLUE_FLAG && other->client->ps.powerups[ PW_BLUEFLAG ] ) {
if( ent->spawnflags & 4 ) {
other->client->ps.powerups[ PW_BLUEFLAG ] = 0;
other->client->speedScale = 0;
}
AddScore(other, ent->accuracy); // JPW NERVE set from map, defaults to 20
//G_AddExperience( other, 2.f );
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent( ent, "death", "" );
G_Script_ScriptEvent( &g_entities[other->client->flagParent], "trigger", "captured" );
ent->parent = tmp;
// Removes itself
ent->touch = NULL;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
}
}
示例7: G_CallSpawn
/*
===============
G_CallSpawn
Finds the spawn function for the entity and calls it,
returning qfalse if not found
===============
*/
qboolean G_CallSpawn(gentity_t * ent)
{
spawn_t *s;
gitem_t *item;
if(!ent->classname)
{
G_Printf("G_CallSpawn: NULL classname\n");
return qfalse;
}
// check item spawn functions
for(item = bg_itemlist + 1; item->classname; item++)
{
if(!strcmp(item->classname, ent->classname))
{
// found it
if(g_gametype.integer != GT_WOLF_LMS)
{ // Gordon: lets not have items in last man standing for the moment
G_SpawnItem(ent, item);
G_Script_ScriptParse(ent);
G_Script_ScriptEvent(ent, "spawn", "");
}
else
{
return qfalse;
}
return qtrue;
}
}
// check normal spawn functions
for(s = spawns; s->name; s++)
{
if(!strcmp(s->name, ent->classname))
{
// found it
s->spawn(ent);
// RF, entity scripting
if( /*ent->s.number >= MAX_CLIENTS && */ ent->scriptName)
{
G_Script_ScriptParse(ent);
G_Script_ScriptEvent(ent, "spawn", "");
}
return qtrue;
}
}
G_Printf("%s doesn't have a spawn function\n", ent->classname);
return qfalse;
}
示例8: Team_TouchEnemyFlag
int Team_TouchEnemyFlag(gentity_t *ent, gentity_t *other, int team) {
gclient_t *cl = other->client;
gentity_t *tmp;
ent->s.density--;
tmp = ent->parent;
ent->parent = other;
if (cl->sess.sessionTeam == TEAM_AXIS) {
gentity_t *pm = G_PopupMessage(PM_OBJECTIVE);
pm->s.effect3Time = G_StringIndex(ent->message);
pm->s.effect2Time = TEAM_AXIS;
pm->s.density = 0; // 0 = stolen
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "allied_object_stolen");
}
G_Script_ScriptEvent(ent, "trigger", "stolen");
} else {
gentity_t *pm = G_PopupMessage(PM_OBJECTIVE);
pm->s.effect3Time = G_StringIndex(ent->message);
pm->s.effect2Time = TEAM_ALLIES;
pm->s.density = 0; // 0 = stolen
if (level.gameManager) {
G_Script_ScriptEvent(level.gameManager, "trigger", "axis_object_stolen");
}
G_Script_ScriptEvent(ent, "trigger", "stolen");
}
ent->parent = tmp;
if (team == TEAM_AXIS) {
cl->ps.powerups[PW_REDFLAG] = INT_MAX;
} else {
cl->ps.powerups[PW_BLUEFLAG] = INT_MAX;
} // flags never expire
// store the entitynum of our original flag spawner
if (ent->flags & FL_DROPPED_ITEM) {
cl->flagParent = ent->s.otherEntityNum;
} else {
cl->flagParent = ent->s.number;
}
other->client->speedScale = ent->splashDamage; // Alter player speed
if (ent->s.density > 0) {
return 1; // We have more flags to give out, spawn back quickly
}
return -1; // Do not respawn this automatically, but do delete it if it was FL_DROPPED
}
示例9: Touch_flagonly
void Touch_flagonly(gentity_t *ent, gentity_t *other, trace_t *trace) {
gentity_t *tmp;
// Nico, silent GCC
(void)trace;
if (!other->client) {
return;
}
if (ent->spawnflags & RED_FLAG && other->client->ps.powerups[PW_REDFLAG]) {
if (ent->spawnflags & 4) {
other->client->ps.powerups[PW_REDFLAG] = 0;
other->client->speedScale = 0;
}
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent(ent, "death", "");
G_Script_ScriptEvent(&g_entities[other->client->flagParent], "trigger", "captured");
ent->parent = tmp;
// Removes itself
ent->touch = NULL;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
} else if (ent->spawnflags & BLUE_FLAG && other->client->ps.powerups[PW_BLUEFLAG]) {
if (ent->spawnflags & 4) {
other->client->ps.powerups[PW_BLUEFLAG] = 0;
other->client->speedScale = 0;
}
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent(ent, "death", "");
G_Script_ScriptEvent(&g_entities[other->client->flagParent], "trigger", "captured");
ent->parent = tmp;
// Removes itself
ent->touch = NULL;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
}
}
示例10: Touch_flagonly_multiple
void Touch_flagonly_multiple(gentity_t * ent, gentity_t * other, trace_t * trace)
{
gentity_t *tmp;
if(!other->client)
{
return;
}
if(ent->spawnflags & RED_FLAG && other->client->ps.powerups[PW_REDFLAG])
{
other->client->ps.powerups[PW_REDFLAG] = 0;
other->client->speedScale = 0;
AddScore(other, ent->accuracy); // JPW NERVE set from map, defaults to 20
//G_AddExperience( other, 2.f );
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent(ent, "death", "");
G_Script_ScriptEvent(&g_entities[other->client->flagParent], "trigger", "captured");
#ifdef OMNIBOT
Bot_Util_SendTrigger(ent, NULL, va("Allies captured %s", ent->scriptName), "");
#endif
ent->parent = tmp;
}
else if(ent->spawnflags & BLUE_FLAG && other->client->ps.powerups[PW_BLUEFLAG])
{
other->client->ps.powerups[PW_BLUEFLAG] = 0;
other->client->speedScale = 0;
AddScore(other, ent->accuracy); // JPW NERVE set from map, defaults to 20
//G_AddExperience( other, 2.f );
tmp = ent->parent;
ent->parent = other;
G_Script_ScriptEvent(ent, "death", "");
G_Script_ScriptEvent(&g_entities[other->client->flagParent], "trigger", "captured");
#ifdef OMNIBOT
Bot_Util_SendTrigger(ent, NULL, va("Axis captured %s", ent->scriptName), "");
#endif
ent->parent = tmp;
}
}
示例11: checkpoint_touch
void checkpoint_touch(gentity_t *self, gentity_t *other, trace_t *trace) {
// Nico, silent GCC
(void)trace;
if (self->count == (int)other->client->sess.sessionTeam) {
return;
}
// Set controlling team
self->count = other->client->sess.sessionTeam;
// Set animation
if (self->count == TEAM_AXIS) {
if (self->s.frame == WCP_ANIM_NOFLAG) {
self->s.frame = WCP_ANIM_RAISE_AXIS;
} else if (self->s.frame == WCP_ANIM_AMERICAN_RAISED) {
self->s.frame = WCP_ANIM_AMERICAN_TO_AXIS;
} else {
self->s.frame = WCP_ANIM_AXIS_RAISED;
}
} else {
if (self->s.frame == WCP_ANIM_NOFLAG) {
self->s.frame = WCP_ANIM_RAISE_AMERICAN;
} else if (self->s.frame == WCP_ANIM_AXIS_RAISED) {
self->s.frame = WCP_ANIM_AXIS_TO_AMERICAN;
} else {
self->s.frame = WCP_ANIM_AMERICAN_RAISED;
}
}
self->parent = other;
// Gordon: reset player disguise on touching flag
// Run script trigger
if (self->count == TEAM_AXIS) {
self->health = 0;
G_Script_ScriptEvent(self, "trigger", "axis_capture");
} else {
self->health = 10;
G_Script_ScriptEvent(self, "trigger", "allied_capture");
}
// Play a sound
G_AddEvent(self, EV_GENERAL_SOUND, self->soundPos1);
// Don't allow touch again until animation is finished
self->touch = NULL;
self->think = checkpoint_think;
self->nextthink = level.time + 1000;
}
示例12: multi_trigger
// the trigger was just activated
// ent->activator should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
void multi_trigger(gentity_t * ent, gentity_t * activator)
{
ent->activator = activator;
G_Script_ScriptEvent(ent, "activate", NULL);
if(ent->nextthink)
{
return; // can't retrigger until the wait is over
}
G_UseTargets(ent, ent->activator);
if(ent->wait > 0)
{
ent->think = multi_wait;
ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000;
}
else
{
// we can't just remove (self) here, because this is a touch function
// called while looping through area links...
ent->touch = 0;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
}
}
示例13: G_CallSpawn
/*
===============
G_CallSpawn
Finds the spawn function for the entity and calls it,
returning qfalse if not found
===============
*/
qboolean G_CallSpawn( gentity_t *ent ) {
spawn_t *s;
gitem_t *item;
int hash;
if ( !ent->classname ) {
G_Printf( "G_CallSpawn: NULL classname\n" );
return qfalse;
}
if ( g_deathmatch.integer ) {
if ( !strcmp( "func_explosive", ent->classname ) ) {
return qfalse;
}
if ( !strcmp( "trigger_hurt", ent->classname ) ) {
return qfalse;
}
// don't spawn the flags in cp
if ( g_gametype.integer == 7 && !strcmp( "team_WOLF_checkpoint", ent->classname ) ) {
return qfalse;
}
}
// check item spawn functions
for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
if ( !strcmp( item->classname, ent->classname ) ) {
// found it
// DHM - Nerve :: allow flags in GTWOLF
if ( item->giType == IT_TEAM && ( g_gametype.integer != GT_CTF && g_gametype.integer < GT_WOLF ) ) {
return qfalse;
}
G_SpawnItem( ent, item );
return qtrue;
}
}
// check normal spawn functions
hash = BG_StringHashValue( ent->classname );
for ( s = spawns ; s->name ; s++ ) {
if ( s->hash == hash ) {
// found it
s->spawn( ent );
// RF, entity scripting
if ( ent->s.number >= MAX_CLIENTS && ent->scriptName ) {
G_Script_ScriptParse( ent );
G_Script_ScriptEvent( ent, "spawn", "" );
}
return qtrue;
}
}
G_Printf( "%s doesn't have a spawn function\n", ent->classname );
return qfalse;
}
示例14: checkpoint_touch
void checkpoint_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {
if ( self->count == other->client->sess.sessionTeam ) {
return;
}
// Set controlling team
self->count = other->client->sess.sessionTeam;
// Set animation
if ( self->count == TEAM_RED ) {
if ( self->s.frame == WCP_ANIM_NOFLAG ) {
self->s.frame = WCP_ANIM_RAISE_NAZI;
} else if ( self->s.frame == WCP_ANIM_AMERICAN_RAISED ) {
self->s.frame = WCP_ANIM_AMERICAN_TO_NAZI;
} else {
self->s.frame = WCP_ANIM_NAZI_RAISED;
}
} else {
if ( self->s.frame == WCP_ANIM_NOFLAG ) {
self->s.frame = WCP_ANIM_RAISE_AMERICAN;
} else if ( self->s.frame == WCP_ANIM_NAZI_RAISED ) {
self->s.frame = WCP_ANIM_NAZI_TO_AMERICAN;
} else {
self->s.frame = WCP_ANIM_AMERICAN_RAISED;
}
}
// Run script trigger
if ( self->count == TEAM_RED ) {
G_Script_ScriptEvent( self, "trigger", "axis_capture" );
} else {
G_Script_ScriptEvent( self, "trigger", "allied_capture" );
}
// Play a sound
G_AddEvent( self, EV_GENERAL_SOUND, self->soundPos1 );
// Don't allow touch again until animation is finished
self->touch = NULL;
self->think = checkpoint_think;
self->nextthink = level.time + 1000;
}
示例15: multi_trigger
// the trigger was just activated
// ent->activator should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
void multi_trigger(gentity_t *ent, gentity_t *activator)
{
ent->activator = activator;
if (ent->numPlayers > 1)
{
gentity_t *tnt; // temp ent for counting players
int i;
int entList[MAX_GENTITIES]; // list of entities
int cnt = trap_EntitiesInBox(ent->r.mins, ent->r.maxs, entList, MAX_GENTITIES);
int players = 0; // number of ents in trigger
for (i = 0; i < cnt; i++)
{
tnt = &g_entities[entList[i]];
if (tnt->client)
{
players++;
}
}
// not enough players, return
if (players < ent->numPlayers)
{
return;
}
}
G_Script_ScriptEvent(ent, "activate", NULL);
if (ent->nextthink)
{
return; // can't retrigger until the wait is over
}
G_UseTargets(ent, ent->activator);
if (ent->wait > 0)
{
ent->think = multi_wait;
ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000;
}
else
{
// we can't just remove (self) here, because this is a touch function
// called while looping through area links...
ent->touch = 0;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_FreeEntity;
}
}