本文整理汇总了C++中G_FreeEdict函数的典型用法代码示例。如果您正苦于以下问题:C++ G_FreeEdict函数的具体用法?C++ G_FreeEdict怎么用?C++ G_FreeEdict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_FreeEdict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpawnItem
/*
============
SpawnItem
Sets the clipping size and plants the object on the floor.
Items can't be immediately dropped to floor, because they might
be on an entity that hasn't spawned yet.
============
*/
void SpawnItem (edict_t *ent, gitem_t *item)
{
if (!ent || !item) // FS: Prevent SP crash
{
return;
}
PrecacheItem (item);
if (ent->spawnflags)
{
if (strcmp(ent->classname, "key_power_cube") != 0)
{
ent->spawnflags = 0;
gi.dprintf(DEVELOPER_MSG_GAME, "%s at %s has invalid spawnflags set\n", ent->classname, vtos(ent->s.origin));
}
}
// some items will be prevented in deathmatch
if (deathmatch->value)
{
if ( (int)dmflags->value & DF_NO_ARMOR )
{
if (item->pickup == Pickup_Armor || item->pickup == Pickup_PowerArmor)
{
G_FreeEdict (ent);
return;
}
}
if ( (int)dmflags->value & DF_NO_ITEMS )
{
if (item->pickup == Pickup_Powerup)
{
G_FreeEdict (ent);
return;
}
}
if ( (int)dmflags->value & DF_NO_HEALTH )
{
if (item->pickup == Pickup_Health || item->pickup == Pickup_Adrenaline)
{
G_FreeEdict (ent);
return;
}
}
if ( (int)dmflags->value & DF_INFINITE_AMMO )
{
if (item->flags == IT_AMMO /*|| (strcmp(ent->classname, "weapon_flamethrower") == 0) */)
{
G_FreeEdict (ent);
return;
}
}
}
if (coop->value && (strcmp(ent->classname, "key_power_cube") == 0))
{
ent->spawnflags |= (1 << (8 + level.power_cubes));
level.power_cubes++;
}
// don't let them drop items that stay in a coop game
if ((coop->value) && (item->flags & IT_STAY_COOP))
{
item->drop = NULL;
}
ent->item = item;
ent->nextthink = level.time + 2 * FRAMETIME; // items start after other solids
ent->think = droptofloor;
ent->s.effects = item->world_model_flags;
//faf ent->s.renderfx = RF_GLOW;
if (ent->model)
gi.modelindex (ent->model);
}
示例2: Destroy_Camera
static bool Destroy_Camera (Edict* self)
{
G_SpawnParticle(self->origin, self->spawnflags, self->particle);
G_FreeEdict(self);
return true;
}
示例3: SP_monster_gekk
/*QUAKED monster_gekk (1 .5 0) (-24 -24 -24) (24 24 24) Ambush Trigger_Spawn Sight Chant GoodGuy NoGib
*/
void SP_monster_gekk (edict_t *self)
{
if (deathmatch->value)
{
G_FreeEdict (self);
return;
}
sound_swing = gi.soundindex ("gek/gk_atck1.wav");
sound_hit = gi.soundindex ("gek/gk_atck2.wav");
sound_hit2 = gi.soundindex ("gek/gk_atck3.wav");
sound_death = gi.soundindex ("gek/gk_deth1.wav");
sound_pain1 = gi.soundindex ("gek/gk_pain1.wav");
sound_sight = gi.soundindex ("gek/gk_sght1.wav");
sound_search = gi.soundindex ("gek/gk_idle1.wav");
sound_step1 = gi.soundindex ("gek/gk_step1.wav");
sound_step2 = gi.soundindex ("gek/gk_step2.wav");
sound_step3 = gi.soundindex ("gek/gk_step3.wav");
sound_thud = gi.soundindex ("mutant/thud1.wav");
sound_chantlow = gi.soundindex ("gek/gek_low.wav");
sound_chantmid = gi.soundindex ("gek/gek_mid.wav");
sound_chanthigh = gi.soundindex ("gek/gek_high.wav");
self->movetype = MOVETYPE_STEP;
self->solid = SOLID_BBOX;
// Lazarus: special purpose skins
if ( self->style )
{
PatchMonsterModel("models/monsters/gekk/tris.md2");
self->s.skinnum = self->style * 3;
}
self->s.modelindex = gi.modelindex ("models/monsters/gekk/tris.md2");
VectorSet (self->mins, -24, -24, -24);
VectorSet (self->maxs, 24, 24, 24);
gi.modelindex ("models/objects/gekkgib/pelvis/tris.md2");
gi.modelindex ("models/objects/gekkgib/arm/tris.md2");
gi.modelindex ("models/objects/gekkgib/torso/tris.md2");
gi.modelindex ("models/objects/gekkgib/claw/tris.md2");
gi.modelindex ("models/objects/gekkgib/leg/tris.md2");
gi.modelindex ("models/objects/gekkgib/head/tris.md2");
if(!self->health)
{
if (skill->value == 0)
self->health = 120;
else
self->health = 150;
}
if(!self->gib_health)
self->gib_health = -100;
if(!self->mass)
self->mass = 300;
self->pain = gekk_pain;
self->die = gekk_die;
self->monsterinfo.stand = gekk_stand;
self->monsterinfo.walk = gekk_walk;
self->monsterinfo.run = gekk_run_start;
self->monsterinfo.dodge = gekk_dodge;
self->monsterinfo.attack = gekk_jump;
self->monsterinfo.melee = gekk_melee;
self->monsterinfo.sight = gekk_sight;
self->monsterinfo.search = gekk_search;
self->monsterinfo.idle = gekk_idle;
self->monsterinfo.checkattack = gekk_checkattack;
if (!self->monsterinfo.flies)
self->monsterinfo.flies = 0.70;
// Lazarus
if(self->powerarmor)
{
if (self->powerarmortype == 1)
self->monsterinfo.power_armor_type = POWER_ARMOR_SCREEN;
else
self->monsterinfo.power_armor_type = POWER_ARMOR_SHIELD;
self->monsterinfo.power_armor_power = self->powerarmor;
}
self->common_name = "Gekk";
if (!self->blood_type)
self->blood_type = 1; //Knightmare- set this for blood color
gi.linkentity (self);
self->monsterinfo.currentmove = &gekk_move_stand;
self->monsterinfo.scale = MODEL_SCALE;
walkmonster_start (self);
if (self->spawnflags & 8)
//.........这里部分代码省略.........
示例4: SP_info_null
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for spotlights, etc.
*/
void SP_info_null (edict_t *self)
{
G_FreeEdict (self);
}
示例5: G_info_null
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for spotlights, etc.
*/
void G_info_null(g_edict_t *self) {
G_FreeEdict(self);
}
示例6: Cmd_Give_f
/*
==================
Cmd_Give_f
Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
char *name;
gitem_t *it;
int index;
int i;
qboolean give_all;
edict_t *it_ent;
if (deathmatch->value && !sv_cheats->value)
{
gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
}
name = gi.args();
if (Q_stricmp(name, "all") == 0)
give_all = true;
else
give_all = false;
if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
{
if (gi.argc() == 3)
ent->health = atoi(gi.argv(2));
else
ent->health = ent->max_health;
if (!give_all)
return;
}
if (give_all || Q_stricmp(name, "weapons") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
it = itemlist + i;
if (!it->pickup)
continue;
if (!(it->flags & IT_WEAPON))
continue;
ent->client->pers.inventory[i] += 1;
}
if (!give_all)
return;
}
if (give_all || Q_stricmp(name, "ammo") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
it = itemlist + i;
if (!it->pickup)
continue;
if (!(it->flags & IT_AMMO))
continue;
Add_Ammo (ent, it, 1000);
}
if (!give_all)
return;
}
if (give_all || Q_stricmp(name, "armor") == 0)
{
gitem_armor_t *info;
it = FindItem("Jacket Armor");
ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
it = FindItem("Combat Armor");
ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
it = FindItem("Body Armor");
info = (gitem_armor_t *)it->info;
ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;
if (!give_all)
return;
}
if (give_all || Q_stricmp(name, "Power Shield") == 0)
{
it = FindItem("Power Shield");
it_ent = G_Spawn();
it_ent->classname = it->classname;
SpawnItem (it_ent, it);
Touch_Item (it_ent, ent, NULL, NULL);
if (it_ent->inuse)
G_FreeEdict(it_ent);
if (!give_all)
return;
}
//.........这里部分代码省略.........
示例7: SP_monster_makron
/*QUAKED monster_makron (1 .5 0) (-30 -30 0) (30 30 90) Ambush Trigger_Spawn Sight
*/
void SP_monster_makron (edict_t *self)
{
if (deathmatch->value)
{
G_FreeEdict (self);
return;
}
MakronPrecache ();
self->movetype = MOVETYPE_STEP;
self->solid = SOLID_BBOX;
self->s.modelindex = gi.modelindex ("models/monsters/boss3/rider/tris.md2");
VectorSet (self->mins, -30, -30, 0);
VectorSet (self->maxs, 30, 30, 90);
// Lazarus: mapper-configurable health
if(!self->health)
self->health = 3000;
// Lazarus: get around Killed's prevention of health dropping below -999
// if(!self->gib_health)
// self->gib_health = -2000;
self->gib_health = -900;
if(!self->mass)
self->mass = 500;
self->pain = makron_pain;
self->die = makron_die;
self->monsterinfo.stand = makron_stand;
self->monsterinfo.walk = makron_walk;
self->monsterinfo.run = makron_run;
self->monsterinfo.dodge = NULL;
self->monsterinfo.attack = makron_attack;
self->monsterinfo.melee = NULL;
self->monsterinfo.sight = makron_sight;
self->monsterinfo.checkattack = Makron_CheckAttack;
// Knightmare- added sparks and blood type
if (!self->blood_type)
self->blood_type = 2; //sparks
else
self->fogclip |= 2; //custom bloodtype flag
// Lazarus
if(self->powerarmor) {
self->monsterinfo.power_armor_type = POWER_ARMOR_SHIELD;
self->monsterinfo.power_armor_power = self->powerarmor;
}
gi.linkentity (self);
self->monsterinfo.currentmove = &makron_move_sight;
if(self->health < 0)
{
mmove_t *deathmoves[] = {&makron_move_death2,
&makron_move_death3,
NULL};
M_SetDeath(self,(mmove_t **)&deathmoves);
}
self->monsterinfo.scale = MODEL_SCALE;
walkmonster_start(self);
}
示例8: 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;
}
}
}
//
// 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_strcasecmp(t->classname, "func_areaportal") &&
(!Q_strcasecmp(ent->classname, "func_door") || !Q_strcasecmp(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;
}
}
}
}
示例9: monster_start
qboolean monster_start (edict_t *self)
{
if (deathmatch->value)
{
G_FreeEdict (self);
return false;
}
// Lazarus: Already gibbed monsters passed across levels via trigger_transition:
if ( (self->max_health > 0) && (self->health <= self->gib_health) && !(self->spawnflags & SF_MONSTER_NOGIB) )
{
void SP_gibhead(edict_t *);
SP_gibhead(self);
return true;
}
// Lazarus: Good guys
if (self->spawnflags & SF_MONSTER_GOODGUY) {
self->monsterinfo.aiflags |= AI_GOOD_GUY;
if(!self->dmgteam) {
self->dmgteam = gi.TagMalloc(8*sizeof(char), TAG_LEVEL);
// strncpy(self->dmgteam,"player");
Q_strncpyz(self->dmgteam,"player", 8);
}
}
// Lazarus: Max range for sight/attack
if(st.distance)
self->monsterinfo.max_range = max(500,st.distance);
else
self->monsterinfo.max_range = 1280; // Q2 default is 1000. We're mean.
// Lazarus: We keep SIGHT to mean what old AMBUSH does, and AMBUSH additionally
// now means don't play idle sounds
/* if ((self->spawnflags & MONSTER_SIGHT) && !(self->monsterinfo.aiflags & AI_GOOD_GUY))
{
self->spawnflags &= ~MONSTER_SIGHT;
self->spawnflags |= MONSTER_AMBUSH;
} */
if ((self->spawnflags & SF_MONSTER_AMBUSH) && !(self->monsterinfo.aiflags & AI_GOOD_GUY))
self->spawnflags |= SF_MONSTER_SIGHT;
// Lazarus: Don't add trigger spawned monsters until they are actually spawned
if (!(self->monsterinfo.aiflags & AI_GOOD_GUY) && !(self->spawnflags & SF_MONSTER_TRIGGER_SPAWN))
level.total_monsters++;
self->nextthink = level.time + FRAMETIME;
self->svflags |= SVF_MONSTER;
self->s.renderfx |= RF_FRAMELERP;
self->air_finished = level.time + 12;
self->use = monster_use;
// Lazarus - don't reset max_health unnecessarily
if(!self->max_health)
self->max_health = self->health;
if (self->health < (self->max_health / 2))
self->s.skinnum |= 1;
else
self->s.skinnum &= ~1;
self->clipmask = MASK_MONSTERSOLID;
if (self->s.skinnum < 1) // Knightmare added
self->s.skinnum = 0;
self->deadflag = DEAD_NO;
self->svflags &= ~SVF_DEADMONSTER;
if(self->monsterinfo.flies > 1.0)
{
self->s.effects |= EF_FLIES;
self->s.sound = gi.soundindex ("infantry/inflies1.wav");
}
// Lazarus
if(self->health <=0)
{
self->svflags |= SVF_DEADMONSTER;
self->movetype = MOVETYPE_TOSS;
self->takedamage = DAMAGE_YES;
self->monsterinfo.pausetime = 100000000;
self->monsterinfo.aiflags &= ~AI_RESPAWN_FINDPLAYER;
if(self->max_health > 0)
{
// This must be a dead monster who changed levels
// via trigger_transition
self->nextthink = 0;
self->deadflag = DEAD_DEAD;
}
if(self->s.effects & EF_FLIES && self->monsterinfo.flies <= 1.0)
{
self->think = M_FliesOff;
self->nextthink = level.time + 1 + random()*60;
}
return true;
}
else
{
// make sure red shell is turned off in case medic got confused:
self->monsterinfo.aiflags &= ~AI_RESURRECTING;
self->svflags &= ~SVF_DEADMONSTER;
self->takedamage = DAMAGE_AIM;
//.........这里部分代码省略.........
示例10: SP_monster_flyer
/*
* QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/
void
SP_monster_flyer(edict_t *self)
{
if (!self)
{
return;
}
if (deathmatch->value)
{
G_FreeEdict(self);
return;
}
/* fix a map bug in jail5.bsp */
if (!Q_stricmp(level.mapname, "jail5") && (self->s.origin[2] == -104))
{
self->targetname = self->target;
self->target = NULL;
}
sound_sight = gi.soundindex("flyer/flysght1.wav");
sound_idle = gi.soundindex("flyer/flysrch1.wav");
sound_pain1 = gi.soundindex("flyer/flypain1.wav");
sound_pain2 = gi.soundindex("flyer/flypain2.wav");
sound_slash = gi.soundindex("flyer/flyatck2.wav");
sound_sproing = gi.soundindex("flyer/flyatck1.wav");
sound_die = gi.soundindex("flyer/flydeth1.wav");
gi.soundindex("flyer/flyatck3.wav");
self->s.modelindex = gi.modelindex("models/monsters/flyer/tris.md2");
VectorSet(self->mins, -16, -16, -24);
VectorSet(self->maxs, 16, 16, 16);
self->movetype = MOVETYPE_STEP;
self->solid = SOLID_BBOX;
self->s.sound = gi.soundindex("flyer/flyidle1.wav");
self->health = 50;
self->mass = 50;
self->pain = flyer_pain;
self->die = flyer_die;
self->monsterinfo.stand = flyer_stand;
self->monsterinfo.walk = flyer_walk;
self->monsterinfo.run = flyer_run;
self->monsterinfo.attack = flyer_attack;
self->monsterinfo.melee = flyer_melee;
self->monsterinfo.sight = flyer_sight;
self->monsterinfo.idle = flyer_idle;
self->monsterinfo.blocked = (void *)flyer_blocked;
gi.linkentity(self);
self->monsterinfo.currentmove = &flyer_move_stand;
self->monsterinfo.scale = MODEL_SCALE;
flymonster_start(self);
}
示例11: G_ClearSnap
//================
//G_ClearSnap
// We just run G_SnapFrame, the server just sent the snap to the clients,
// it's now time to clean up snap specific data to start the next snap from clean.
//================
void G_ClearSnap( void )
{
edict_t *ent;
game.realtime = trap_Milliseconds(); // level.time etc. might not be real time
// clear gametype's clock override
gs.gameState.longstats[GAMELONG_CLOCKOVERRIDE] = 0;
// clear all events in the snap
for( ent = &game.edicts[0]; ENTNUM( ent ) < game.numentities; ent++ )
{
if( ISEVENTENTITY( &ent->s ) ) // events do not persist after a snapshot
{
G_FreeEdict( ent );
continue;
}
// events only last for a single message
ent->s.events[0] = ent->s.events[1] = 0;
ent->s.eventParms[0] = ent->s.eventParms[1] = 0;
ent->numEvents = 0;
ent->eventPriority[0] = ent->eventPriority[1] = qfalse;
ent->s.teleported = qfalse; // remove teleported bit.
// remove effect bits that are (most likely) added from gametypes
ent->s.effects = ( ent->s.effects & (EF_TAKEDAMAGE|EF_CARRIER|EF_FLAG_TRAIL|EF_ROTATE_AND_BOB|EF_STRONG_WEAPON) );
}
// recover some info, let players respawn and finally clear the snap structures
for( ent = &game.edicts[0]; ENTNUM( ent ) < game.numentities; ent++ )
{
if( !GS_MatchPaused() )
{
// copy origin to old origin ( this old_origin is for snaps )
if( !( ent->r.svflags & SVF_TRANSMITORIGIN2 ) )
VectorCopy( ent->s.origin, ent->s.old_origin );
G_CheckClientRespawnClick( ent );
}
if( GS_MatchPaused() )
ent->s.sound = entity_sound_backup[ENTNUM( ent )];
// clear the snap temp info
memset( &ent->snap, 0, sizeof( ent->snap ) );
if( ent->r.client && trap_GetClientState( PLAYERNUM( ent ) ) >= CS_SPAWNED )
{
memset( &ent->r.client->resp.snap, 0, sizeof( ent->r.client->resp.snap ) );
// set race stats to invisible
ent->r.client->ps.stats[STAT_TIME_SELF] = STAT_NOTSET;
ent->r.client->ps.stats[STAT_TIME_BEST] = STAT_NOTSET;
ent->r.client->ps.stats[STAT_TIME_RECORD] = STAT_NOTSET;
ent->r.client->ps.stats[STAT_TIME_ALPHA] = STAT_NOTSET;
ent->r.client->ps.stats[STAT_TIME_BETA] = STAT_NOTSET;
}
}
g_snapStarted = qfalse;
}
示例12: 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;
/*freeze*/
static int fStarted = 0;
/*freeze*/
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);
/*freeze*/
if (fStarted)
sl_GameEnd(&gi, level);
/*freeze*/
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_stricmp(level.mapname, "command") && !Q_stricmp(ent->classname, "trigger_once") && !Q_stricmp(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);
}
//.........这里部分代码省略.........
示例13: Touch_Item
//.........这里部分代码省略.........
{
//gi.dprintf(DEVELOPER_MSG_GAME, "Plonk! %s\n",other->classname);
if (ent->item)
{
//velocity goes from around -250 for normal drop to ~1000 from top of dday2 church stairs
//knife ~1 lb 50cal ~50 lbs
vol = ((1000+(-1 * ent->velocity[2]))/2000) * ( (ent->item->weight+100)/150 );
if (vol > .9)
vol = .9;
// gi.dprintf(DEVELOPER_MSG_GAME, "%f %f %f\n", ent->velocity[2], ent->item->weight, vol);
// gi.dprintf(DEVELOPER_MSG_GAME, "%f %f %f\n", ((1000+(-1 * ent->velocity[2]))/2000), (ent->item->weight+100)/150, vol);
if (ent->item->flags & IT_AMMO || ent->item->position == LOC_GRENADES || ent->item->position == LOC_KNIFE)
gi.sound (ent, CHAN_WEAPON, gi.soundindex("weapons/ammodrop.wav"), vol, ATTN_NORM, 0);
//gi.positioned_sound (ent->s.origin, g_edicts, CHAN_AUTO, gi.soundindex("weapons/ammodrop.wav"), vol, ATTN_NORM, 0);
else if (ent->item->flags & IT_WEAPON)
gi.sound (ent, CHAN_WEAPON, gi.soundindex("weapons/gundrop.wav"), vol, ATTN_NORM, 0);
//gi.positioned_sound (ent->s.origin, g_edicts, CHAN_AUTO, gi.soundindex("weapons/gundrop.wav"), vol, ATTN_NORM, 0);
}
ent->playedsound = true;
}
return;
}
if (other->health < 1)
return; // dead people can't pickup
if (!ent->item->pickup)
return; // not a grabbable item?
if (other->client->resp.autopickup == false && ent->item->classnameb != HGRENADE)
return;
if (other->client && other->client->resp.mos == MEDIC)
{
if (!(
(ent->item->tag && ent->item->tag == AMMO_TYPE_PISTOL) ||
(ent->item->position && ent->item->position == LOC_PISTOL) ||
(ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name,"Knife")) ||
(ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name,"Helmet"))
))
return;
}
//pbowens: you can only have 1 helmet
if (ent->item->pickup_name && !Q_stricmp(ent->item->pickup_name, "Helmet") )
{
if (other->client->pers.inventory[ITEM_INDEX(ent->item)])
{
// safe_cprintf(other, PRINT_HIGH, "You already have a helmet!\n");
return;
}
}
// you cannot pickup more than 1 team weapon
if (ent->item->guninfo && other->client->pers.inventory[ITEM_INDEX(ent->item)])
return;
//faf if (ent->item->position != LOC_GRENADES && ent->count > 1 &&
//faf other->client->pers.inventory[ITEM_INDEX(ent->item)] ) // dont pick up if ammo already
//faf return;
taken = ent->item->pickup(ent, other);
if (taken)
{
// flash the screen
//other->client->bonus_alpha = 0.25;
// show icon and name on status bar
other->client->ps.stats[STAT_PICKUP_ICON] = gi.imageindex(ent->item->icon);
other->client->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS+ITEM_INDEX(ent->item);
other->client->pickup_msg_time = level.time + 3.0;
// change selected item
//if (ent->item->use)
// other->client->pers.selected_item = other->client->ps.stats[STAT_SELECTED_ITEM] = ITEM_INDEX(ent->item);
gi.sound(other, CHAN_ITEM, gi.soundindex(ent->item->pickup_sound), 1, ATTN_NORM, 0);
}
if (!(ent->spawnflags & ITEM_TARGETS_USED))
{
G_UseTargets (ent, other);
ent->spawnflags |= ITEM_TARGETS_USED;
}
if (!taken)
return;
if (!((coop->value) && (ent->item->flags & IT_STAY_COOP)) || (ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
{
if (ent->flags & FL_RESPAWN)
ent->flags &= ~FL_RESPAWN;
else
G_FreeEdict (ent);
}
}
示例14: Weapon_Sandbag_Fire
void Weapon_Sandbag_Fire (edict_t *ent)
{
edict_t *sandbag;
ent->client->ps.gunframe++;
if (ent->client->resp.team_on->index == 0)
{
if (allied_sandbags >= sandbaglimit->value)
{
safe_centerprintf(ent, "Your team is at the sandbag limit!\n");
return;
}
}
else if (ent->client->resp.team_on->index == 1)
{
if (axis_sandbags >= sandbaglimit->value)
{
safe_centerprintf(ent, "Your team is at the sandbag limit!\n");
return;
}
}
if (VectorCompare (ent->client->sandbag_pos , vec3_origin))
{
safe_centerprintf(ent, "There's no space for sandbags there!\n");
return;
}
ent->client->pers.inventory[ITEM_INDEX(FindItem("Sandbags"))]--;
sandbag = G_Spawn();
VectorCopy (ent->client->sandbag_preview->mins, sandbag->mins);
VectorCopy (ent->client->sandbag_preview->maxs, sandbag->maxs);
VectorCopy (ent->client->sandbag_preview->s.angles, sandbag->s.angles);
sandbag->classnameb = SANDBAGS;
sandbag->movetype = MOVETYPE_TOSS;
sandbag->solid = SOLID_BBOX;
sandbag->s.modelindex = gi.modelindex ("models/objects/sandbag/tris.md2");
sandbag->think = sandbag_think;
sandbag->nextthink = level.time +.1;
// ent->s.frame = rand() % 16;
// ent->s.frame = 1;
sandbag->mass = 300;
sandbag->touch = sandbag_touch;
sandbag->health = 2000;
sandbag->takedamage = DAMAGE_YES;
sandbag->die = sandbag_die;
sandbag->s.skinnum = 0;
sandbag->s.frame = 0;
// VectorSet (sandbag->mins, -19, -9, -10);
// VectorSet (sandbag->maxs, 19, 9, 8);
VectorCopy (ent->client->sandbag_pos, sandbag->s.origin);
sandbag->clipmask = MASK_SHOT;
sandbag->spawnflags = 1;
if (ent->client->resp.team_on)
sandbag->obj_owner = ent->client->resp.team_on->index;
if (ent->client->resp.team_on->index == 0)
allied_sandbags++;
else if (ent->client->resp.team_on->index == 1)
axis_sandbags++;
sandbag->obj_time = level.time;
gi.linkentity (sandbag);
if (ent->client->pers.inventory[ITEM_INDEX(FindItem("Sandbags"))] ==0)
{
ent->client->weaponstate=WEAPON_LOWER;
ent->client->ps.gunframe = 20;
Use_Weapon (ent, FindItem("fists"));
return;
}
G_FreeEdict (ent->client->sandbag_preview);
//.........这里部分代码省略.........
示例15: cash_kill
void cash_kill( edict_t *self )
{
num_cash_items--;
G_FreeEdict( self );
}