本文整理汇总了C++中G_Spawn函数的典型用法代码示例。如果您正苦于以下问题:C++ G_Spawn函数的具体用法?C++ G_Spawn怎么用?C++ G_Spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_Spawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpawnCorpse
/*
=============
SpawnCorpse
A player is respawning, so make an entity that looks
just like the existing corpse to leave behind.
=============
*/
void SpawnCorpse( gentity_t *ent )
{
gentity_t *body;
int contents;
vec3_t origin, dest;
trace_t tr;
float vDiff;
VectorCopy( ent->r.currentOrigin, origin );
trap_UnlinkEntity( ent );
// if client is in a nodrop area, don't leave the body
contents = trap_PointContents( origin, -1 );
if( contents & CONTENTS_NODROP )
return;
body = G_Spawn( );
VectorCopy( ent->s.apos.trBase, body->s.angles );
body->s.eFlags = EF_DEAD;
body->s.eType = ET_CORPSE;
body->s.number = body - g_entities;
body->timestamp = level.time;
body->s.event = 0;
body->r.contents = CONTENTS_CORPSE;
body->s.clientNum = ent->client->ps.stats[ STAT_CLASS ];
body->nonSegModel = ent->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL;
if( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
body->classname = "humanCorpse";
else
body->classname = "alienCorpse";
body->s.misc = MAX_CLIENTS;
body->think = BodySink;
body->nextthink = level.time + 20000;
body->s.legsAnim = ent->s.legsAnim;
if( !body->nonSegModel )
{
switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
{
case BOTH_DEATH1:
case BOTH_DEAD1:
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD1;
break;
case BOTH_DEATH2:
case BOTH_DEAD2:
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD2;
break;
case BOTH_DEATH3:
case BOTH_DEAD3:
default:
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD3;
break;
}
}
else
{
switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
{
case NSPA_DEATH1:
case NSPA_DEAD1:
body->s.legsAnim = NSPA_DEAD1;
break;
case NSPA_DEATH2:
case NSPA_DEAD2:
body->s.legsAnim = NSPA_DEAD2;
break;
case NSPA_DEATH3:
case NSPA_DEAD3:
default:
body->s.legsAnim = NSPA_DEAD3;
break;
}
}
body->takedamage = qfalse;
body->health = ent->health = ent->client->ps.stats[ STAT_HEALTH ];
ent->health = 0;
//change body dimensions
BG_ClassBoundingBox( ent->client->ps.stats[ STAT_CLASS ], NULL, NULL, NULL, body->r.mins, body->r.maxs );
vDiff = body->r.mins[ 2 ] - ent->r.mins[ 2 ];
//drop down to match the *model* origins of ent and body
VectorSet( dest, origin[ 0 ], origin[ 1 ], origin[ 2 ] - vDiff );
trap_Trace( &tr, origin, body->r.mins, body->r.maxs, dest, body->s.number, body->clipmask );
//.........这里部分代码省略.........
示例2: for
/*
==============================
G_UseTargets
the global "activator" should be set to the entity that initiated the firing.
If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed.
Centerprints any self.message to the activator.
Search for (string)targetname in all entities that
match (string)self.target and call their .use function
==============================
*/
void G_UseTargets (edict_t *ent, edict_t *activator)
{
edict_t *t;
//
// check for a delay
//
if (ent->delay)
{
// create a temp object to fire at a later time
t = G_Spawn();
t->classname = "DelayedUse";
t->nextthink = level.time + ent->delay;
t->think = Think_Delay;
t->activator = activator;
if (!activator)
gi.dprintf ("Think_Delay with no activator\n");
t->message = ent->message;
t->target = ent->target;
t->killtarget = ent->killtarget;
return;
}
//
// print the message
//
if ((ent->message) && !(activator->svflags & SVF_MONSTER))
{
gi.centerprintf (activator, "%s", ent->message);
if (ent->noise_index)
gi.sound (activator, CHAN_AUTO, ent->noise_index, 1, ATTN_NORM, 0);
else
gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
}
//
// kill killtargets
//
if (ent->killtarget)
{
t = NULL;
while ((t = G_Find (t, FOFS(targetname), ent->killtarget)))
{
G_FreeEdict (t);
if (!ent->inuse)
{
gi.dprintf("entity was removed while using killtargets\n");
return;
}
}
}
// gi.dprintf("TARGET: activating %s\n", ent->target);
//
// fire targets
//
if (ent->target)
{
t = NULL;
while ((t = G_Find (t, FOFS(targetname), ent->target)))
{
// doors fire area portals in a specific way
if (!Q_stricmp(t->classname, "func_areaportal") &&
(!Q_stricmp(ent->classname, "func_door") || !Q_stricmp(ent->classname, "func_door_rotating")))
continue;
if (t == ent)
{
gi.dprintf ("WARNING: Entity used itself.\n");
}
else
{
if (t->use)
t->use (t, ent, activator);
}
if (!ent->inuse)
{
gi.dprintf("entity was removed while using targets\n");
return;
}
}
}
//.........这里部分代码省略.........
示例3: eweb_die
//----------------------------------------------------------
void eweb_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod,int dFlags,int hitLoc )
{
vec3_t org;
// turn off any firing animations it may have been doing
self->s.frame = self->startFrame = self->endFrame = 0;
self->svFlags &= ~(SVF_ANIMATING|SVF_PLAYER_USABLE);
self->health = 0;
// self->s.weapon = WP_EMPLACED_GUN; // we need to be able to switch back to the old weapon
self->takedamage = qfalse;
self->lastEnemy = attacker;
if ( self->activator && self->activator->client )
{
if ( self->activator->NPC )
{
vec3_t right;
// radius damage seems to throw them, but add an extra bit to throw them away from the weapon
AngleVectors( self->currentAngles, NULL, right, NULL );
VectorMA( self->activator->client->ps.velocity, 140, right, self->activator->client->ps.velocity );
self->activator->client->ps.velocity[2] = -100;
// kill them
self->activator->health = 0;
self->activator->client->ps.stats[STAT_HEALTH] = 0;
}
// kill the players emplaced ammo, cheesy way to keep the gun from firing
self->activator->client->ps.ammo[weaponData[WP_EMPLACED_GUN].ammoIndex] = 0;
}
self->e_PainFunc = painF_NULL;
if ( self->target )
{
G_UseTargets( self, attacker );
}
G_RadiusDamage( self->currentOrigin, self, self->splashDamage, self->splashRadius, self, MOD_UNKNOWN );
VectorCopy( self->currentOrigin, org );
org[2] += 20;
G_PlayEffect( "emplaced/explode", org );
// Turn the top of the eweb off.
#define TURN_OFF 0x00000100//G2SURFACEFLAG_NODESCENDANTS
gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "eweb_damage", TURN_OFF );
// create some persistent smoke by using a dynamically created fx runner
gentity_t *ent = G_Spawn();
if ( ent )
{
ent->delay = 200;
ent->random = 100;
ent->fxID = G_EffectIndex( "emplaced/dead_smoke" );
ent->e_ThinkFunc = thinkF_fx_runner_think;
ent->nextthink = level.time + 50;
// move up above the gun origin
VectorCopy( self->currentOrigin, org );
org[2] += 35;
G_SetOrigin( ent, org );
VectorCopy( org, ent->s.origin );
VectorSet( ent->s.angles, -90, 0, 0 ); // up
G_SetAngles( ent, ent->s.angles );
gi.linkentity( ent );
}
G_ActivateBehavior( self, BSET_DEATH );
}
示例4: G_FindCraneParts
//.........这里部分代码省略.........
control->crane_hoist = hoist;
control->crane_hook = hook;
if(!beam->crane_control) beam->crane_control = control;
if(control->team)
{
beam->crane_control = control;
if(beam->flags & FL_TEAMSLAVE)
beam->crane_onboard_control = beam->teammaster;
else
beam->crane_onboard_control = beam->teamchain;
}
else
beam->crane_onboard_control = NULL;
beam->crane_hoist = hoist;
beam->crane_hook = hook;
hoist->crane_control = beam->crane_control;
hoist->crane_beam = beam;
hoist->crane_hook = hook;
hook->crane_control = beam->crane_control;
hook->crane_beam = beam;
hook->crane_hoist = hoist;
if(control->spawnflags & 4)
{
beam->dmg = 0;
hoist->dmg = 0;
hook->dmg = 0;
}
if(hook->crane_cable == NULL)
{
int frame;
float length;
cable = G_Spawn();
cable->classname = "crane_cable";
VectorAdd(hook->absmin,hook->absmax,cable->s.origin);
VectorScale(cable->s.origin,0.5,cable->s.origin);
VectorAdd(cable->s.origin,hook->move_origin,cable->s.origin);
VectorSubtract(cable->s.origin,hook->s.origin,cable->offset);
cable->s.origin[2] = hoist->absmax[2] - 2;
cable->model = "models/cable/tris.md2";
gi.setmodel(cable,cable->model);
cable->s.skinnum = 0;
length = hoist->absmax[2]-1 - hook->absmax[2];
frame = (int)(length/CABLE_SEGMENT);
if((frame+1)*CABLE_SEGMENT < length) frame++;
frame = max(0,min(frame,19));
cable->s.frame = frame;
cable->solid = SOLID_NOT;
cable->movetype = MOVETYPE_STOP;
VectorSet(cable->mins,-2,-2,length);
VectorSet(cable->maxs, 2, 2,0);
gi.linkentity(cable);
beam->crane_cable = cable;
hoist->crane_cable = cable;
hook->crane_cable = cable;
cable->crane_control = control;
cable->crane_beam = beam;
cable->crane_hoist = hoist;
cable->crane_hook = hook;
}
control->crane_cable = hook->crane_cable;
if((hook->spawnflags & 1) && (hook->crane_light == NULL))
{
light = G_Spawn();
示例5: G_SpawnEntities
/**
* @brief Creates a server's entity / program execution context
* by parsing textual entity definitions out of an ent file.
* @sa CM_EntityString
* @sa SV_SpawnServer
*/
void G_SpawnEntities (const char *mapname, qboolean day, const char *entities)
{
int entnum;
G_FreeTags(TAG_LEVEL);
OBJZERO(level);
level.pathingMap = (pathing_t *)G_TagMalloc(sizeof(*level.pathingMap), TAG_LEVEL);
G_EdictsReset();
Q_strncpyz(level.mapname, mapname, sizeof(level.mapname));
level.day = day;
G_ResetClientData();
level.activeTeam = TEAM_NO_ACTIVE;
level.actualRound = 1;
level.hurtAliens = sv_hurtaliens->integer;
ai_waypointList = NULL;
/* parse ents */
entnum = 0;
while (1) {
edict_t *ent;
/* parse the opening brace */
const char *token = Com_Parse(&entities);
if (!entities)
break;
if (token[0] != '{')
gi.Error("ED_LoadFromFile: found %s when expecting {", token);
ent = G_Spawn();
entities = ED_ParseEdict(entities, ent);
ent->mapNum = entnum++;
/* Set the position of the entity */
VecToPos(ent->origin, ent->pos);
/* Call this entity's specific initializer (sets ent->type) */
ED_CallSpawn(ent);
/* if this entity is an bbox (e.g. actor), then center its origin based on its position */
if (ent->solid == SOLID_BBOX)
G_EdictCalcOrigin(ent);
}
/* spawn ai players, if needed */
if (level.num_spawnpoints[TEAM_CIVILIAN]) {
if (AI_CreatePlayer(TEAM_CIVILIAN) == NULL)
gi.DPrintf("Could not create civilian\n");
}
if ((sv_maxclients->integer == 1 || ai_numactors->integer) && level.num_spawnpoints[TEAM_ALIEN]) {
if (AI_CreatePlayer(TEAM_ALIEN) == NULL)
gi.DPrintf("Could not create alien\n");
}
Com_Printf("Used inventory slots after ai spawn: %i\n", game.i.GetUsedSlots(&game.i));
G_FindEdictGroups();
}
示例6: SpawnEntities
/*
==============
SpawnEntities
Creates a server's entity / program execution context by
parsing textual entity definitions out of an ent file.
==============
*/
void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
{
edict_t *ent;
int inhibit;
char *com_token;
int i;
float skill_level;
skill_level = floor (skill->value);
if (skill_level < 0)
skill_level = 0;
if (skill_level > 3)
skill_level = 3;
if (skill->value != skill_level)
gi.cvar_forceset("skill", va("%f", skill_level));
SaveClientData ();
gi.FreeTags (TAG_LEVEL);
memset (&level, 0, sizeof(level));
memset (g_edicts, 0, game.maxentities * sizeof (g_edicts[0]));
strncpy (level.mapname, mapname, sizeof(level.mapname)-1);
strncpy (game.spawnpoint, spawnpoint, sizeof(game.spawnpoint)-1);
// set client fields on player ents
for (i=0 ; i<game.maxclients ; i++)
g_edicts[i+1].client = game.clients + i;
ent = NULL;
inhibit = 0;
// parse ents
while (1)
{
// parse the opening brace
com_token = COM_Parse (&entities);
if (!entities)
break;
if (com_token[0] != '{')
gi.error ("ED_LoadFromFile: found %s when expecting {",com_token);
if (!ent)
ent = g_edicts;
else
ent = G_Spawn ();
entities = ED_ParseEdict (entities, ent);
// yet another map hack
if (!Q_strcasecmp(level.mapname, "command") && !Q_strcasecmp(ent->classname, "trigger_once") && !Q_strcasecmp(ent->model, "*27"))
ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
// remove things (except the world) from different skill levels or deathmatch
if (ent != g_edicts)
{
if (deathmatch->value)
{
if ( ent->spawnflags & SPAWNFLAG_NOT_DEATHMATCH )
{
G_FreeEdict (ent);
inhibit++;
continue;
}
}
else
{
if ( /* ((coop->value) && (ent->spawnflags & SPAWNFLAG_NOT_COOP)) || */
((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD))
)
{
G_FreeEdict (ent);
inhibit++;
continue;
}
}
ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH);
}
ED_CallSpawn (ent);
}
gi.dprintf ("%i entities inhibited\n", inhibit);
#ifdef DEBUG
i = 1;
ent = EDICT_NUM(i);
while (i < globals.num_edicts) {
if (ent->inuse != 0 || ent->inuse != 1)
//.........这里部分代码省略.........
示例7: SP_crane_beam
void SP_crane_beam (edict_t *self)
{
vec3_t origin;
edict_t *speaker;
gi.setmodel (self, self->model);
VectorAdd(self->absmin,self->absmax,origin);
VectorScale(origin,0.5,origin);
if (!self->targetname)
{
gi.dprintf ("crane_beam with no targetname at %s\n", vtos(origin));
G_FreeEdict (self);
return;
}
if (!self->target)
{
gi.dprintf ("crane_beam with no target at %s\n", vtos(origin));
G_FreeEdict (self);
return;
}
if (!self->pathtarget)
{
gi.dprintf ("crane_beam with no pathtarget at %s\n", vtos(origin));
G_FreeEdict (self);
return;
}
self->classname = "crane_beam";
self->solid = SOLID_BSP;
self->movetype = MOVETYPE_PUSH;
if(!self->speed) self->speed = 160;
self->moveinfo.speed = self->speed;
if(st.noise)
self->noise_index = gi.soundindex(st.noise);
else
self->noise_index = 0;
#ifdef LOOP_SOUND_ATTENUATION
if (self->attenuation <= 0)
self->attenuation = ATTN_IDLE;
#endif
gi.linkentity (self);
if(self->noise_index && !VectorLength(self->s.origin) )
{
speaker = G_Spawn();
speaker->classname = "moving_speaker";
speaker->s.sound = 0;
speaker->volume = 1;
speaker->attenuation = self->attenuation; // was 1
speaker->think = Moving_Speaker_Think;
speaker->nextthink = level.time + 2*FRAMETIME;
speaker->spawnflags = 7; // owner must be moving to play
speaker->owner = self; // this will be changed later when we know
// controls are spawned
self->speaker = speaker;
VectorAdd(self->absmin,self->absmax,speaker->s.origin);
VectorScale(speaker->s.origin,0.5,speaker->s.origin);
VectorSubtract(speaker->s.origin,self->s.origin,speaker->offset);
}
}
示例8: G_smvAddView
// Add a player entity to another player's multiview list
void G_smvAddView(gentity_t *ent, int pID)
{
int i;
mview_t *mv = NULL;
gentity_t *v;
if (pID >= MAX_MVCLIENTS || G_smvLocateEntityInMVList(ent, pID, qfalse))
{
return;
}
for (i = 0; i < MULTIVIEW_MAXVIEWS; i++)
{
if (!ent->client->pers.mv[i].fActive)
{
mv = &ent->client->pers.mv[i];
break;
}
}
if (mv == NULL)
{
CP(va("print \"[lof]** [lon]Sorry, no more MV slots available (all[lof] %d [lon]in use)[lof]\n\"", MULTIVIEW_MAXVIEWS));
return;
}
mv->camera = G_Spawn();
if (mv->camera == NULL)
{
return;
}
if (ent->client->sess.sessionTeam == TEAM_SPECTATOR && /*ent->client->sess.sessionTeam != TEAM_SPECTATOR ||*/
ent->client->sess.spectatorState == SPECTATOR_FOLLOW)
{
SetTeam(ent, "s", qtrue, -1, -1, qfalse);
}
else if (ent->client->sess.sessionTeam != TEAM_SPECTATOR && !(ent->client->ps.pm_flags & PMF_LIMBO))
{
limbo(ent, qtrue);
}
ent->client->ps.clientNum = ent - g_entities;
ent->client->sess.spectatorState = SPECTATOR_FREE;
ent->client->pers.mvCount++;
mv->fActive = qtrue;
mv->entID = pID;
v = mv->camera;
v->classname = "misc_portal_surface";
v->r.svFlags = SVF_PORTAL | SVF_SINGLECLIENT; // Only merge snapshots for the target client
v->r.singleClient = ent->s.number;
v->s.eType = ET_PORTAL;
VectorClear(v->r.mins);
VectorClear(v->r.maxs);
trap_LinkEntity(v);
v->target_ent = &g_entities[pID];
v->TargetFlag = pID;
v->tagParent = ent;
G_smvUpdateClientCSList(ent);
}
示例9: for
/*
==============================
G_UseTargets
the global "activator" should be set to the entity that initiated the firing.
If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed.
Centerprints any self.message to the activator.
Search for (string)targetname in all entities that
match (string)self.target and call their .use function
==============================
*/
void G_UseTargets (edict_t *ent, edict_t *activator)
{
edict_t *t;
edict_t *master;
qboolean done = false;
//
// check for a delay
//
if (ent->delay)
{
// create a temp object to fire at a later time
t = G_Spawn();
t->classname = "DelayedUse";
t->nextthink = level.time + ent->delay;
t->think = Think_Delay;
t->activator = activator;
if (!activator)
gi.dprintf ("Think_Delay with no activator\n");
t->message = ent->message;
t->target = ent->target;
t->killtarget = ent->killtarget;
return;
}
//
// print the message
//
if ((ent->message) && !(activator->svflags & SVF_MONSTER))
{
gi.centerprintf (activator, "%s", ent->message);
if (ent->noise_index)
gi.sound (activator, CHAN_AUTO, ent->noise_index, 1, ATTN_NORM, 0);
else
gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
}
//
// kill killtargets
//
if (ent->killtarget)
{
t = NULL;
while ((t = G_Find (t, FOFS(targetname), ent->killtarget)))
{
// PMM - if this entity is part of a train, cleanly remove it
if (t->flags & FL_TEAMSLAVE)
{
// if ((g_showlogic) && (g_showlogic->value))
// gi.dprintf ("Removing %s from train!\n", t->classname);
if (t->teammaster)
{
master = t->teammaster;
while (!done)
{
if (master->teamchain == t)
{
master->teamchain = t->teamchain;
done = true;
}
master = master->teamchain;
if (!master)
{
// if ((g_showlogic) && (g_showlogic->value))
// gi.dprintf ("Couldn't find myself in master's chain, ignoring!\n");
}
}
}
else
{
// if ((g_showlogic) && (g_showlogic->value))
// gi.dprintf ("No master to free myself from, ignoring!\n");
}
}
// PMM
G_FreeEdict (t);
if (!ent->inuse)
{
gi.dprintf("entity was removed while using killtargets\n");
return;
}
}
//.........这里部分代码省略.........
示例10: W_Fire_Instagun
/*
* W_Fire_Instagun_Strong
*/
void W_Fire_Instagun( edict_t *self, vec3_t start, vec3_t dir, float damage, int knockback,
int stun, int radius, int range, int mod, int timeDelta ) {
vec3_t from, end;
trace_t tr;
edict_t *ignore, *event, *hit;
int hit_movetype;
int mask;
bool missed = true;
int dmgflags = 0;
if( GS_Instagib() ) {
damage = 9999;
}
VectorMA( start, range, dir, end );
VectorCopy( start, from );
ignore = self;
mask = MASK_SHOT;
if( GS_RaceGametype() ) {
mask = MASK_SOLID;
}
tr.ent = -1;
while( ignore ) {
G_Trace4D( &tr, from, NULL, NULL, end, ignore, mask, timeDelta );
VectorCopy( tr.endpos, from );
ignore = NULL;
if( tr.ent == -1 ) {
break;
}
// allow trail to go through SOLID_BBOX entities (players, gibs, etc)
hit = &game.edicts[tr.ent];
hit_movetype = hit->movetype; // backup the original movetype as the entity may "die"
if( !ISBRUSHMODEL( hit->s.modelindex ) ) {
ignore = hit;
}
if( ( hit != self ) && ( hit->takedamage ) ) {
G_Damage( hit, self, self, dir, dir, tr.endpos, damage, knockback, stun, dmgflags, mod );
// spawn a impact event on each damaged ent
event = G_SpawnEvent( EV_INSTA_EXPLOSION, DirToByte( tr.plane.normal ), tr.endpos );
event->s.ownerNum = ENTNUM( self );
event->s.firemode = FIRE_MODE_STRONG;
if( hit->r.client ) {
missed = false;
}
}
// some entity was touched
if( hit == world
|| hit_movetype == MOVETYPE_NONE
|| hit_movetype == MOVETYPE_PUSH ) {
if( g_instajump->integer && self && self->r.client ) {
// create a temporary inflictor entity
edict_t *inflictor;
inflictor = G_Spawn();
inflictor->s.solid = SOLID_NOT;
inflictor->timeDelta = 0;
VectorCopy( tr.endpos, inflictor->s.origin );
inflictor->s.ownerNum = ENTNUM( self );
inflictor->projectileInfo.maxDamage = 0;
inflictor->projectileInfo.minDamage = 0;
inflictor->projectileInfo.maxKnockback = knockback;
inflictor->projectileInfo.minKnockback = 1;
inflictor->projectileInfo.stun = 0;
inflictor->projectileInfo.radius = radius;
G_RadiusDamage( inflictor, self, &tr.plane, NULL, mod );
G_FreeEdict( inflictor );
}
break;
}
}
if( missed && self->r.client ) {
G_AwardPlayerMissedElectrobolt( self, mod );
}
// send the weapon fire effect
event = G_SpawnEvent( EV_INSTATRAIL, ENTNUM( self ), start );
VectorScale( dir, 1024, event->s.origin2 );
}
示例11: AICast_CheckLoadGame
/*
==================
AICast_CheckLoadGame
at the start of a level, the game is either saved, or loaded
we must wait for all AI to spawn themselves, and a real client to connect
==================
*/
void AICast_CheckLoadGame( void ) {
char loading[4];
gentity_t *ent = NULL; // TTimo: VC6 'may be used without having been init'
qboolean ready;
cast_state_t *pcs;
// have we already done the save or load?
if ( !saveGamePending ) {
return;
}
// tell the cgame NOT to render the scene while we are waiting for things to settle
trap_Cvar_Set( "cg_norender", "1" );
trap_Cvar_VariableStringBuffer( "savegame_loading", loading, sizeof( loading ) );
// reloading = qtrue;
trap_Cvar_Set( "g_reloading", "1" );
if ( strlen( loading ) > 0 && atoi( loading ) != 0 ) {
// screen should be black if we are at this stage
trap_SetConfigstring( CS_SCREENFADE, va( "1 %i 1", level.time - 10 ) );
// if (!reloading && atoi(loading) == 2) {
if ( !( g_reloading.integer ) && atoi( loading ) == 2 ) {
// (SA) hmm, this seems redundant when it sets it above...
// reloading = qtrue; // this gets reset at the Map_Restart() since the server unloads the game dll
trap_Cvar_Set( "g_reloading", "1" );
}
ready = qtrue;
if ( numSpawningCast != numcast ) {
ready = qfalse;
} else if ( !( ent = AICast_FindEntityForName( "player" ) ) ) {
ready = qfalse;
} else if ( !ent->client || ent->client->pers.connected != CON_CONNECTED ) {
ready = qfalse;
}
if ( ready ) {
trap_Cvar_Set( "savegame_loading", "0" ); // in-case it aborts
saveGamePending = qfalse;
G_LoadGame( NULL ); // always load the "current" savegame
// RF, spawn a thinker that will enable rendering after the client has had time to process the entities and setup the display
//trap_Cvar_Set( "cg_norender", "0" );
ent = G_Spawn();
ent->nextthink = level.time + 200;
ent->think = AICast_EnableRenderingThink;
// wait for the clients to return from faded screen
//trap_SetConfigstring( CS_SCREENFADE, va("0 %i 1500", level.time + 500) );
trap_SetConfigstring( CS_SCREENFADE, va( "0 %i 750", level.time + 500 ) );
level.reloadPauseTime = level.time + 1100;
// make sure sound fades up
trap_SendServerCommand( -1, va( "snd_fade 1 %d", 2000 ) ); //----(SA) added
AICast_CastScriptThink();
}
} else {
ready = qtrue;
if ( numSpawningCast != numcast ) {
ready = qfalse;
} else if ( !( ent = AICast_FindEntityForName( "player" ) ) ) {
ready = qfalse;
} else if ( !ent->client || ent->client->pers.connected != CON_CONNECTED ) {
ready = qfalse;
}
// not loading a game, we must be in a new level, so look for some persistant data to read in, then save the game
if ( ready ) {
G_LoadPersistant(); // make sure we save the game after we have brought across the items
trap_Cvar_Set( "g_totalPlayTime", "0" ); // reset play time
trap_Cvar_Set( "g_attempts", "0" );
pcs = AICast_GetCastState( ent->s.number );
pcs->totalPlayTime = 0;
pcs->lastLoadTime = 0;
pcs->attempts = 0;
// RF, disabled, since the pregame menu turns this off after the button is pressed, this isn't
// required here
// RF, spawn a thinker that will enable rendering after the client has had time to process the entities and setup the display
//trap_Cvar_Set( "cg_norender", "0" );
//ent = G_Spawn();
//ent->nextthink = level.time + 200;
//ent->think = AICast_EnableRenderingThink;
saveGamePending = qfalse;
//.........这里部分代码省略.........
示例12: G_Spawn
gentity_t *SpawnObelisk( vec3_t origin, int team, int spawnflags) {
trace_t tr;
vec3_t dest;
gentity_t *ent;
ent = G_Spawn();
VectorCopy( origin, ent->s.origin );
VectorCopy( origin, ent->s.pos.trBase );
VectorCopy( origin, ent->r.currentOrigin );
VectorSet( ent->r.mins, -15, -15, 0 );
VectorSet( ent->r.maxs, 15, 15, 87 );
ent->s.eType = ET_GENERAL;
ent->flags = FL_NO_KNOCKBACK;
if( g_gametype.integer == GT_OBELISK ) {
ent->r.contents = CONTENTS_SOLID;
ent->takedamage = qtrue;
ent->health = g_obeliskHealth.integer;
ent->die = ObeliskDie;
ent->pain = ObeliskPain;
ent->think = ObeliskRegen;
ent->nextthink = level.time + g_obeliskRegenPeriod.integer * 1000;
}
if( g_gametype.integer == GT_HARVESTER ) {
ent->r.contents = CONTENTS_TRIGGER;
ent->touch = ObeliskTouch;
}
if ( spawnflags & 1 ) {
// suspended
G_SetOrigin( ent, ent->s.origin );
} else {
// mappers like to put them exactly on the floor, but being coplanar
// will sometimes show up as starting in solid, so lif it up one pixel
ent->s.origin[2] += 1;
// drop to floor
VectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096 );
trap_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID );
if ( tr.startsolid ) {
ent->s.origin[2] -= 1;
G_Printf( "SpawnObelisk: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin) );
ent->s.groundEntityNum = ENTITYNUM_NONE;
G_SetOrigin( ent, ent->s.origin );
}
else {
// allow to ride movers
ent->s.groundEntityNum = tr.entityNum;
G_SetOrigin( ent, tr.endpos );
}
}
ent->spawnflags = team;
trap_LinkEntity( ent );
return ent;
}
示例13: ClientUserinfoChanged
//.........这里部分代码省略.........
i = atoi( s );
if( i > 90 || i < 0 )
{
G_PrintMsg( ent, "Handicap must be defined in the [0-90] range.\n" );
cl->handicap = 0;
}
else
{
cl->handicap = i;
}
}
s = Info_ValueForKey( userinfo, "cg_movementStyle" );
if( s )
{
i = bound( atoi( s ), 0, GS_MAXBUNNIES - 1 );
if( trap_GetClientState( PLAYERNUM(ent) ) < CS_SPAWNED )
{
if( i != cl->movestyle )
cl->movestyle = cl->movestyle_latched = i;
}
else if( cl->movestyle_latched != cl->movestyle )
{
G_PrintMsg( ent, "A movement style change is already in progress. Please wait.\n" );
}
else if( i != cl->movestyle_latched )
{
cl->movestyle_latched = i;
if( cl->movestyle_latched != cl->movestyle )
{
edict_t *switcher;
switcher = G_Spawn();
switcher->think = think_MoveTypeSwitcher;
switcher->nextThink = level.time + 10000;
switcher->s.ownerNum = ENTNUM( ent );
G_PrintMsg( ent, "Movement style will change in 10 seconds.\n" );
}
}
}
// update the movement features depending on the movestyle
if( !G_ISGHOSTING( ent ) && g_allow_bunny->integer )
{
if( cl->movestyle == GS_CLASSICBUNNY )
cl->ps.pmove.stats[PM_STAT_FEATURES] &= ~PMFEAT_FWDBUNNY;
else
cl->ps.pmove.stats[PM_STAT_FEATURES] |= PMFEAT_FWDBUNNY;
}
s = Info_ValueForKey( userinfo, "cg_noAutohop" );
if( s && s[0] )
{
if( atoi( s ) != 0 )
cl->ps.pmove.stats[PM_STAT_FEATURES] &= ~PMFEAT_CONTINOUSJUMP;
else
cl->ps.pmove.stats[PM_STAT_FEATURES] |= PMFEAT_CONTINOUSJUMP;
}
#ifdef UCMDTIMENUDGE
s = Info_ValueForKey( userinfo, "cl_ucmdTimeNudge" );
if( !s )
{
cl->ucmdTimeNudge = 0;
}
示例14: turretG2_fire
//----------------------------------------------------------------
static void turretG2_fire ( gentity_t *ent, vec3_t start, vec3_t dir )
//----------------------------------------------------------------
{
vec3_t org, ang;
gentity_t *bolt;
if ( (trap_PointContents( start, ent->s.number )&MASK_SHOT) )
{
return;
}
VectorMA( start, -START_DIS, dir, org ); // dumb....
if ( ent->random )
{
vectoangles( dir, ang );
ang[PITCH] += flrand( -ent->random, ent->random );
ang[YAW] += flrand( -ent->random, ent->random );
AngleVectors( ang, dir, NULL, NULL );
}
vectoangles(dir, ang);
if ( (ent->spawnflags&SPF_TURRETG2_TURBO) )
{
//muzzle flash
G_PlayEffectID( ent->genericValue13, org, ang );
WP_FireTurboLaserMissile( ent, start, dir );
if ( ent->alt_fire )
{
TurboLaser_SetBoneAnim( ent, 2, 3 );
}
else
{
TurboLaser_SetBoneAnim( ent, 0, 1 );
}
}
else
{
G_PlayEffectID( G_EffectIndex("blaster/muzzle_flash"), org, ang );
bolt = G_Spawn();
bolt->classname = "turret_proj";
bolt->nextthink = level.time + 10000;
bolt->think = G_FreeEntity;
bolt->s.eType = ET_MISSILE;
bolt->s.weapon = WP_BLASTER;
bolt->r.ownerNum = ent->s.number;
bolt->damage = ent->damage;
bolt->alliedTeam = ent->alliedTeam;
bolt->teamnodmg = ent->teamnodmg;
bolt->dflags = (DAMAGE_NO_KNOCKBACK|DAMAGE_HEAVY_WEAP_CLASS); // Don't push them around, or else we are constantly re-aiming
bolt->splashDamage = ent->splashDamage;
bolt->splashRadius = ent->splashDamage;
bolt->methodOfDeath = MOD_TARGET_LASER;//MOD_ENERGY;
bolt->splashMethodOfDeath = MOD_TARGET_LASER;//MOD_ENERGY;
bolt->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
//bolt->trigger_formation = qfalse; // don't draw tail on first frame
VectorSet( bolt->r.maxs, 1.5, 1.5, 1.5 );
VectorScale( bolt->r.maxs, -1, bolt->r.mins );
bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time;
VectorCopy( start, bolt->s.pos.trBase );
VectorScale( dir, ent->mass, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy( start, bolt->r.currentOrigin);
}
}
示例15: GunRackAddItem
void GunRackAddItem( gitem_t *gun, vec3_t org, vec3_t angs, float ffwd, float fright, float fup )
{
vec3_t fwd, right;
gentity_t *it_ent = G_Spawn();
qboolean rotate = qtrue;
AngleVectors( angs, fwd, right, NULL );
if ( it_ent && gun )
{
// FIXME: scaling the ammo will probably need to be tweaked to a reasonable amount...adjust as needed
// Set base ammo per type
if ( gun->giType == IT_WEAPON )
{
it_ent->spawnflags |= 16;// VERTICAL
switch( gun->giTag )
{
case WP_BLASTER:
it_ent->count = 15;
break;
case WP_REPEATER:
it_ent->count = 100;
break;
case WP_ROCKET_LAUNCHER:
it_ent->count = 4;
break;
}
}
else
{
rotate = qfalse;
// must deliberately make it small, or else the objects will spawn inside of each other.
VectorSet( it_ent->maxs, 6.75f, 6.75f, 6.75f );
VectorScale( it_ent->maxs, -1, it_ent->mins );
}
it_ent->spawnflags |= 1;// ITMSF_SUSPEND
it_ent->classname = gun->classname;
G_SpawnItem( it_ent, gun );
// FinishSpawningItem handles everything, so clear the thinkFunc that was set in G_SpawnItem
FinishSpawningItem( it_ent );
if ( gun->giType == IT_AMMO )
{
if ( gun->giTag == AMMO_BLASTER ) // I guess this just has to use different logic??
{
if ( g_spskill->integer >= 2 )
{
it_ent->count += 10; // give more on higher difficulty because there will be more/harder enemies?
}
}
else
{
// scale ammo based on skill
switch ( g_spskill->integer )
{
case 0: // do default
break;
case 1:
it_ent->count *= 0.75f;
break;
case 2:
it_ent->count *= 0.5f;
break;
}
}
}
it_ent->nextthink = 0;
VectorCopy( org, it_ent->s.origin );
VectorMA( it_ent->s.origin, fright, right, it_ent->s.origin );
VectorMA( it_ent->s.origin, ffwd, fwd, it_ent->s.origin );
it_ent->s.origin[2] += fup;
VectorCopy( angs, it_ent->s.angles );
// by doing this, we can force the amount of ammo we desire onto the weapon for when it gets picked-up
it_ent->flags |= ( FL_DROPPED_ITEM | FL_FORCE_PULLABLE_ONLY );
it_ent->physicsBounce = 0.1f;
for ( int t = 0; t < 3; t++ )
{
if ( rotate )
{
if ( t == YAW )
{
it_ent->s.angles[t] = AngleNormalize180( it_ent->s.angles[t] + 180 + crandom() * 14 );
}
else
{
it_ent->s.angles[t] = AngleNormalize180( it_ent->s.angles[t] + crandom() * 4 );
}
}
else
{
if ( t == YAW )
//.........这里部分代码省略.........