本文整理汇总了C++中G_SetOrigin函数的典型用法代码示例。如果您正苦于以下问题:C++ G_SetOrigin函数的具体用法?C++ G_SetOrigin怎么用?C++ G_SetOrigin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_SetOrigin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FinishSpawningItem
void FinishSpawningItem( gentity_t *ent ) {
trace_t tr;
vec3_t dest;
gitem_t *item;
int itemNum;
itemNum=1;
for ( item = bg_itemlist + 1 ; item->classname ; item++,itemNum++)
{
if (!strcmp(item->classname,ent->classname))
{
break;
}
}
// Set bounding box for item
VectorSet( ent->mins, item->mins[0],item->mins[1] ,item->mins[2]);
VectorSet( ent->maxs, item->maxs[0],item->maxs[1] ,item->maxs[2]);
if ((!ent->mins[0] && !ent->mins[1] && !ent->mins[2]) &&
(!ent->maxs[0] && !ent->maxs[1] && !ent->maxs[2]))
{
VectorSet (ent->mins, -ITEM_RADIUS, -ITEM_RADIUS, -2);//to match the comments in the items.dat file!
VectorSet (ent->maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
}
if ((item->quantity) && (item->giType == IT_AMMO))
{
ent->count = item->quantity;
}
if ((item->quantity) && (item->giType == IT_BATTERY))
{
ent->count = item->quantity;
}
// if ( item->giType == IT_WEAPON ) // NOTE: james thought it was ok to just always do this?
{
ent->s.radius = 20;
VectorSet( ent->s.modelScale, 1.0f, 1.0f, 1.0f );
gi.G2API_InitGhoul2Model( ent->ghoul2, ent->item->world_model, G_ModelIndex( ent->item->world_model ), NULL, NULL, 0, 0);
}
// Set crystal ammo amount based on skill level
/* if ((itemNum == ITM_AMMO_CRYSTAL_BORG) ||
(itemNum == ITM_AMMO_CRYSTAL_DN) ||
(itemNum == ITM_AMMO_CRYSTAL_FORGE) ||
(itemNum == ITM_AMMO_CRYSTAL_SCAVENGER) ||
(itemNum == ITM_AMMO_CRYSTAL_STASIS))
{
CrystalAmmoSettings(ent);
}
*/
ent->s.eType = ET_ITEM;
ent->s.modelindex = ent->item - bg_itemlist; // store item number in modelindex
ent->s.modelindex2 = 0; // zero indicates this isn't a dropped item
ent->contents = CONTENTS_TRIGGER|CONTENTS_ITEM;//CONTENTS_BODY;//CONTENTS_TRIGGER|
ent->e_TouchFunc = touchF_Touch_Item;
// useing an item causes it to respawn
ent->e_UseFunc = useF_Use_Item;
ent->svFlags |= SVF_PLAYER_USABLE;//so player can pick it up
// Hang in air?
ent->s.origin[2] += 1;//just to get it off the damn ground because coplanar = insolid
if ( ent->spawnflags & ITMSF_SUSPEND)
{
// suspended
G_SetOrigin( ent, ent->s.origin );
}
else
{
// drop to floor
VectorSet( dest, ent->s.origin[0], ent->s.origin[1], MIN_WORLD_COORD );
gi.trace( &tr, ent->s.origin, ent->mins, ent->maxs, dest, ent->s.number, MASK_SOLID|CONTENTS_PLAYERCLIP, G2_NOCOLLIDE, 0 );
if ( tr.startsolid )
{
if ( &g_entities[tr.entityNum] != NULL )
{
gi.Printf (S_COLOR_RED"FinishSpawningItem: removing %s startsolid at %s (in a %s)\n", ent->classname, vtos(ent->s.origin), g_entities[tr.entityNum].classname );
}
else
{
gi.Printf (S_COLOR_RED"FinishSpawningItem: removing %s startsolid at %s (in a %s)\n", ent->classname, vtos(ent->s.origin) );
}
assert( 0 && "item starting in solid");
#ifndef FINAL_BUILD
if (!g_entities[ENTITYNUM_WORLD].s.radius){ //not a region
delayedShutDown = level.time + 100;
}
#endif
G_FreeEntity( ent );
return;
}
// allow to ride movers
ent->s.groundEntityNum = tr.entityNum;
G_SetOrigin( ent, tr.endpos );
//.........这里部分代码省略.........
开发者ID:Agustinlv,项目名称:BlueHarvest,代码行数:101,代码来源:g_items.cpp
示例2: SP_target_gravity_change
/*QUAKED target_gravity_change (1 0 0) (-4 -4 -4) (4 4 4) GLOBAL
"gravity" - Normal = 800, Valid range: any
GLOBAL - Apply to entire world, not just the activator
*/
void SP_target_gravity_change( gentity_t *self )
{
G_SetOrigin( self, self->s.origin );
G_SpawnFloat( "gravity", "0", &self->speed );
self->e_UseFunc = useF_target_gravity_change_use;
}
开发者ID:Joanxt,项目名称:OpenJK,代码行数:12,代码来源:g_target.cpp
示例3: FinishSpawningItem
/*
================
FinishSpawningItem
Traces down to find where an item should rest, instead of letting them
free fall from their spawn points
================
*/
void FinishSpawningItem( gentity_t *ent ) {
trace_t tr;
vec3_t dest;
VectorSet( ent->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS );
VectorSet( ent->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS );
ent->s.eType = ET_ITEM;
ent->s.modelindex = ent->item - bg_itemlist; // store item number in modelindex
ent->s.modelindex2 = 0; // zero indicates this isn't a dropped item
ent->r.contents = CONTENTS_TRIGGER;
ent->touch = Touch_Item;
// useing an item causes it to respawn
ent->use = Use_Item;
if ( ent->spawnflags & 1 ) {
// suspended
G_SetOrigin( ent, ent->s.origin );
} else {
// 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 ) {
G_Printf ("FinishSpawningItem: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin));
G_FreeEntity( ent );
return;
}
// allow to ride movers
ent->s.groundEntityNum = tr.entityNum;
G_SetOrigin( ent, tr.endpos );
}
// team slaves and targeted items aren't present at start
if ( ( ent->flags & FL_TEAMSLAVE ) || ent->targetname ) {
ent->s.eFlags |= EF_NODRAW;
ent->r.contents = 0;
return;
}
// powerups don't spawn in for a while
if ( ent->item->giType == IT_POWERUP ) {
float respawn;
respawn = 45 + crandom() * 15;
ent->s.eFlags |= EF_NODRAW;
ent->r.contents = 0;
ent->nextthink = level.time + respawn * 1000;
ent->think = RespawnItem;
return;
}
if ( ent->item->giType == IT_HOLDABLE ) {
if ( ( ent->item->giTag == HI_BAMBAM ) && ( g_gametype.integer != GT_CTF ) ) {
return;
}
else if ( ( ent->item->giTag == HI_BOOMIES ) &&
( ( g_gametype.integer != GT_CTF ) && ( g_gametype.integer != GT_BALLOON ) ) ) {
return;
}
}
trap_LinkEntity (ent);
}
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:75,代码来源:g_items.c
示例4: assert
//.........这里部分代码省略.........
if (stopCol<=startCol)
{
assert(0); // Should Not Happen
continue;
}
// Force It To Center
//--------------------
if (mover->mCenter && stopCol!=(startCol+1))
{
startCol = ((mCols/2) - (mover->mCols/2));
stopCol = startCol+1;
}
// Construct A List Of Columns To Test For Insertion
//---------------------------------------------------
mTestCols.clear();
for (int i=startCol; i<stopCol; i++)
{
mTestCols.push_back(i);
}
// Now Try All The Cols To See If The Building Can Fit
//-----------------------------------------------------
while (!mTestCols.empty())
{
// Randomly Pick A Column, Then Remove It From The Vector
//--------------------------------------------------------
testColIndex = Q_irand(0, mTestCols.size()-1);
atCol = mTestCols[testColIndex];
mTestCols.erase_swap(testColIndex);
if (TestMoverInCells(mover, atCol))
{
// Ok, We've Found A Safe Column To Insert This Mover
//----------------------------------------------------
InsertMoverInCells(mover, atCol);
// Now Transport The Actual Mover Entity Into Position, Link It & Send It Off
//----------------------------------------------------------------------------
CVec3 StartPos(mGridBottomLeftCorner);
StartPos[mWAxis] += ((atCol * mGridCellSize) + ((mover->mCols/2.0f) * mGridCellSize));
StartPos[mHAxis] += (((mover->mRows/2.0f) * mGridCellSize) * ((mNegative)?(1):(-1)));
StartPos[2] = 0;
// If Centered, Actually Put It At EXACTLY The Right Position On The Width Axis
//------------------------------------------------------------------------------
if (mover->mCenter)
{
StartPos[mWAxis] = mGridCenter[mWAxis];
float deltaOffset = mGridCenter[mWAxis] - mover->mOriginOffset[mWAxis];
if (deltaOffset<(mGridCellSize*0.5f) )
{
StartPos[mWAxis] -= deltaOffset;
}
}
StartPos -= mover->mOriginOffset;
G_SetOrigin(mover->mEnt, StartPos.v);
// Start It Moving
//-----------------
VectorCopy(StartPos.v, mover->mEnt->s.pos.trBase);
VectorCopy(mVelocity.v, mover->mEnt->s.pos.trDelta);
mover->mEnt->s.pos.trTime = level.time;
mover->mEnt->s.pos.trDuration = mTravelTimeMilliseconds + (mNextUpdateDelay*mover->mRows);
mover->mEnt->s.pos.trType = TR_LINEAR_STOP;
mover->mEnt->s.eFlags &= ~EF_NODRAW;
mover->mSoundPlayed = false;
// Successfully Inserted This Mover. Now Move On To The Next Mover
//------------------------------------------------------------------
break;
}
}
}
// Incriment The Current Row
//---------------------------
mRow++;
if (mRow>=mRows)
{
mRow = 0;
}
// Erase The Erase Row
//---------------------
int EraseRow = mRow - MAX_ROW_HISTORY;
if (EraseRow<0)
{
EraseRow += mRows;
}
for (int col=0; col<mCols; col++)
{
mCells.get(col, EraseRow) = 0;
}
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:101,代码来源:g_rail.cpp
示例5: SP_target_position
/*QUAKED target_position (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for in-game calculation, like jumppad targets.
info_notnull does the same thing
*/
void SP_target_position( gentity_t *self ){
G_SetOrigin( self, self->s.origin );
}
开发者ID:Joanxt,项目名称:OpenJK,代码行数:7,代码来源:g_target.cpp
示例6: SP_target_smoke
/**
* @brief SP_target_smoke
* @param[in,out] ent
*/
void SP_target_smoke(gentity_t *ent)
{
char *buffer;
if (G_SpawnString("shader", "", &buffer))
{
ent->s.modelindex2 = G_ShaderIndex(buffer);
}
else
{
ent->s.modelindex2 = 0;
}
// modified this a lot to be sent to the client as one entity and then is shown at the client
if (ent->delay == 0.f)
{
ent->delay = 100;
}
ent->use = smoke_toggle;
ent->think = smoke_init;
ent->nextthink = level.time + FRAMETIME;
G_SetOrigin(ent, ent->s.origin);
ent->r.svFlags = 0;
ent->s.eType = ET_SMOKER;
if (ent->spawnflags & 2)
{
ent->s.density = 4;
}
else
{
ent->s.density = 0;
}
// using "time"
ent->s.time = ent->speed;
if (!ent->s.time)
{
ent->s.time = 5000; // 5 seconds
}
ent->s.time2 = ent->duration;
if (!ent->s.time2)
{
ent->s.time2 = 2000;
}
ent->s.angles2[0] = ent->start_size;
if (ent->s.angles2[0] == 0.f)
{
ent->s.angles2[0] = 24;
}
ent->s.angles2[1] = ent->end_size;
if (ent->s.angles2[1] == 0.f)
{
ent->s.angles2[1] = 96;
}
ent->s.angles2[2] = ent->wait;
if (ent->s.angles2[2] == 0.f)
{
ent->s.angles2[2] = 50;
}
// idiot check
if (ent->s.time < ent->s.time2)
{
ent->s.time = ent->s.time2 + 100;
}
if (ent->spawnflags & 8)
{
ent->s.frame = 1;
}
ent->s.dl_intensity = ent->health;
ent->s.constantLight = ent->delay;
if (ent->spawnflags & 4)
{
trap_LinkEntity(ent);
}
}
开发者ID:ioid3-games,项目名称:ioid3-wet,代码行数:91,代码来源:g_target.c
示例7: 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;
}
开发者ID:bboozzoo,项目名称:ioquake3,代码行数:62,代码来源:g_team.c
示例8: FinishSpawningItem
/**
* @brief Traces down to find where an item should rest, instead of letting them
* free fall from their spawn points.
*/
void FinishSpawningItem(gentity_t *ent)
{
trace_t tr;
vec3_t dest;
vec3_t maxs;
if (ent->spawnflags & 1) // suspended
{
VectorSet(ent->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
VectorSet(ent->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
VectorCopy(ent->r.maxs, maxs);
}
else
{
// had to modify this so that items would spawn in shelves
VectorSet(ent->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, 0);
VectorSet(ent->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
VectorCopy(ent->r.maxs, maxs);
maxs[2] /= 2;
}
ent->r.contents = CONTENTS_TRIGGER | CONTENTS_ITEM;
ent->touch = Touch_Item_Auto;
ent->s.eType = ET_ITEM;
ent->s.modelindex = ent->item - bg_itemlist; // store item number in modelindex
ent->s.otherEntityNum2 = 0; // takes modelindex2's place in signaling a dropped item
// we don't use this (yet, anyway) so I'm taking it so you can specify a model for treasure items and clipboards
//ent->s.modelindex2 = 0; // zero indicates this isn't a dropped item
if (ent->model)
{
ent->s.modelindex2 = G_ModelIndex(ent->model);
}
// using an item causes it to respawn
ent->use = Use_Item;
// moved this up so it happens for suspended items too (and made it a function)
G_SetAngle(ent, ent->s.angles);
if (ent->spawnflags & 1) // suspended
{
G_SetOrigin(ent, ent->s.origin);
}
else
{
VectorSet(dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096);
trap_Trace(&tr, ent->s.origin, ent->r.mins, maxs, dest, ent->s.number, MASK_SOLID);
if (tr.startsolid)
{
vec3_t temp;
VectorCopy(ent->s.origin, temp);
temp[2] -= ITEM_RADIUS;
VectorSet(dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096);
trap_Trace(&tr, temp, ent->r.mins, maxs, dest, ent->s.number, MASK_SOLID);
}
if (tr.startsolid)
{
G_Printf("FinishSpawningItem: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin));
G_FreeEntity(ent);
return;
}
// allow to ride movers
ent->s.groundEntityNum = tr.entityNum;
G_SetOrigin(ent, tr.endpos);
}
if (ent->spawnflags & 2) // spin
{
ent->s.eFlags |= EF_SPINNING;
}
// team slaves and targeted items aren't present at start
if ((ent->flags & FL_TEAMSLAVE) || ent->targetname)
{
ent->flags |= FL_NODRAW;
//ent->s.eFlags |= EF_NODRAW;
ent->r.contents = 0;
return;
}
// health/ammo can potentially be multi-stage (multiple use)
if (ent->item->giType == IT_HEALTH || ent->item->giType == IT_AMMO)
{
int i;
// having alternate models defined in bg_misc.c for a health or ammo item specify it as "multi-stage"
// - left-hand operand of comma expression has no effect
// initial line: for(i=0;i<4,ent->item->world_model[i];i++) {}
for (i = 0; i < 4 && ent->item->world_model[i] ; i++)
//.........这里部分代码省略.........
开发者ID:rafal1137,项目名称:etlegacy,代码行数:101,代码来源:g_items.c
示例9: G_Spawn
/**
* @brief Spawns an item and tosses it forward.
*/
gentity_t *LaunchItem(gitem_t *item, vec3_t origin, vec3_t velocity, int ownerNum)
{
gentity_t *dropped = G_Spawn();
trace_t tr;
vec3_t vec, temp;
dropped->s.eType = ET_ITEM;
dropped->s.modelindex = item - bg_itemlist; // store item number in modelindex
dropped->s.otherEntityNum2 = 1; // this is taking modelindex2's place for a dropped item
dropped->classname = item->classname;
dropped->item = item;
VectorSet(dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, 0); // so items sit on the ground
VectorSet(dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, 2 * ITEM_RADIUS); // so items sit on the ground
dropped->r.contents = CONTENTS_TRIGGER | CONTENTS_ITEM;
dropped->clipmask = CONTENTS_SOLID | CONTENTS_MISSILECLIP; // fix for items falling through grates
dropped->touch = Touch_Item_Auto;
trap_Trace(&tr, origin, dropped->r.mins, dropped->r.maxs, origin, ownerNum, MASK_SOLID);
if (tr.startsolid)
{
int i;
VectorSubtract(g_entities[ownerNum].s.origin, origin, temp);
VectorNormalize(temp);
for (i = 16; i <= 48; i += 16)
{
VectorScale(temp, i, vec);
VectorAdd(origin, vec, origin);
trap_Trace(&tr, origin, dropped->r.mins, dropped->r.maxs, origin, ownerNum, MASK_SOLID);
if (!tr.startsolid)
{
break;
}
}
}
G_SetOrigin(dropped, origin);
dropped->s.pos.trType = TR_GRAVITY;
dropped->s.pos.trTime = level.time;
VectorCopy(velocity, dropped->s.pos.trDelta);
// set yaw to parent angles
temp[PITCH] = 0;
temp[YAW] = g_entities[ownerNum].s.apos.trBase[YAW];
temp[ROLL] = 0;
G_SetAngle(dropped, temp);
dropped->s.eFlags |= EF_BOUNCE_HALF;
if (item->giType == IT_TEAM) // Special case for CTF flags
{
gentity_t *flag = &g_entities[g_entities[ownerNum].client->flagParent];
dropped->s.otherEntityNum = g_entities[ownerNum].client->flagParent; // store the entitynum of our original flag spawner
dropped->s.density = 1;
dropped->think = Team_DroppedFlagThink;
dropped->nextthink = level.time + 30000;
if (level.gameManager)
{
G_Script_ScriptEvent(level.gameManager, "trigger", flag->item->giTag == PW_REDFLAG ? "allied_object_dropped" : "axis_object_dropped");
}
G_Script_ScriptEvent(flag, "trigger", "dropped");
}
else // auto-remove after 30 seconds
{
dropped->think = G_FreeEntity;
dropped->nextthink = level.time + 30000;
}
dropped->flags = FL_DROPPED_ITEM;
trap_LinkEntity(dropped);
return dropped;
}
开发者ID:rafal1137,项目名称:etlegacy,代码行数:84,代码来源:g_items.c
示例10: SpawnCorpse
//.........这里部分代码省略.........
trace_t tr;
float vDiff;
//just return right away so bodies never appear and its cleaner + faster
return;
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_PCLASS ];
body->nonSegModel = ent->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL;
if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
body->classname = "humanCorpse";
else
body->classname = "alienCorpse";
body->s.powerups = 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_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], 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 );
VectorCopy( tr.endpos, origin );
G_SetOrigin( body, origin );
VectorCopy( origin, body->s.origin );
body->s.pos.trType = TR_GRAVITY;
body->s.pos.trTime = level.time;
VectorCopy( ent->client->ps.velocity, body->s.pos.trDelta );
VectorCopy ( body->s.pos.trBase, body->r.currentOrigin );
trap_LinkEntity( body );
}
开发者ID:asker,项目名称:OmgHaxQVM,代码行数:101,代码来源:g_client.c
示例11: ClientSpawn
//.........这里部分代码省略.........
if ( g_gametype.integer == GT_TEAM ) {
client->ps.ammo[WP_BRYAR_PISTOL] = 50;
} else {
client->ps.ammo[WP_BRYAR_PISTOL] = 100;
}
*/
client->ps.rocketLockIndex = MAX_CLIENTS;
client->ps.rocketLockTime = 0;
//rww - Set here to initialize the circling seeker drone to off.
//A quick note about this so I don't forget how it works again:
//ps.genericEnemyIndex is kept in sync between the server and client.
//When it gets set then an entitystate value of the same name gets
//set along with an entitystate flag in the shared bg code. Which
//is why a value needs to be both on the player state and entity state.
//(it doesn't seem to just carry over the entitystate value automatically
//because entity state value is derived from player state data or some
//such)
client->ps.genericEnemyIndex = -1;
client->ps.isJediMaster = qfalse;
client->ps.fallingToDeath = 0;
//Do per-spawn force power initialization
WP_SpawnInitForcePowers( ent );
// health will count down towards max_health
ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH];// * 1.25; Boot - no extra 25 hp on start.
// Start with a small amount of armor as well.
client->ps.stats[STAT_ARMOR] = client->ps.stats[STAT_MAX_HEALTH] * 0.25;
G_SetOrigin( ent, spawn_origin );
VectorCopy( spawn_origin, client->ps.origin );
// the respawned flag will be cleared after the attack and jump keys come up
client->ps.pm_flags |= PMF_RESPAWNED;
trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd );
SetClientViewAngle( ent, spawn_angles );
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
} else {
G_KillBox( ent );
trap_LinkEntity (ent);
// force the base weapon up
client->ps.weapon = WP_BRYAR_PISTOL;
client->ps.weaponstate = FIRST_WEAPON;
}
// don't allow full run speed for a bit
client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
client->ps.pm_time = 100;
client->respawnTime = level.time;
client->inactivityTime = level.time + g_inactivity.integer * 1000;
client->latched_buttons = 0;
// set default animations
client->ps.torsoAnim = WeaponReadyAnim[client->ps.weapon];
client->ps.legsAnim = WeaponReadyAnim[client->ps.weapon];
开发者ID:Boothand,项目名称:SaberShenanigans,代码行数:66,代码来源:g_client.c
示例12: G_MissileImpact
//.........这里部分代码省略.........
return;
}
else if( !strcmp( ent->classname, "lockblob" ) )
{
if( other->client && other->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
{
other->client->ps.stats[ STAT_STATE ] |= SS_BLOBLOCKED;
other->client->lastLockTime = level.time;
AngleVectors( other->client->ps.viewangles, dir, NULL, NULL );
other->client->ps.stats[ STAT_VIEWLOCK ] = DirToByte( dir );
}
}
else if( !strcmp( ent->classname, "slowblob" ) )
{
if( other->client && other->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
{
other->client->ps.stats[ STAT_STATE ] |= SS_SLOWLOCKED;
other->client->lastSlowTime = level.time;
AngleVectors( other->client->ps.viewangles, dir, NULL, NULL );
other->client->ps.stats[ STAT_VIEWLOCK ] = DirToByte( dir );
}
}
else if( !strcmp( ent->classname, "hive" ) )
{
if( other->s.eType == ET_BUILDABLE && other->s.modelindex == BA_A_HIVE )
{
if( !ent->parent )
G_Printf( S_COLOR_YELLOW "WARNING: hive entity has no parent in G_MissileImpact\n" );
else
ent->parent->active = qfalse;
G_FreeEntity( ent );
return;
}
else
{
//prevent collision with the client when returning
ent->r.ownerNum = other->s.number;
ent->think = G_ExplodeMissile;
ent->nextthink = level.time + FRAMETIME;
//only damage humans
if( other->client && other->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
returnAfterDamage = qtrue;
else
return;
}
}
// impact damage
if( other->takedamage )
{
// FIXME: wrong damage direction?
if( ent->damage )
{
vec3_t velocity;
BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
if( VectorLength( velocity ) == 0 )
velocity[ 2 ] = 1; // stepped on a grenade
G_Damage( other, ent, attacker, velocity, ent->s.origin, ent->damage,
DAMAGE_NO_LOCDAMAGE, ent->methodOfDeath );
}
}
if( returnAfterDamage )
return;
// is it cheaper in bandwidth to just remove this ent and create a new
// one, rather than changing the missile into the explosion?
if( other->takedamage &&
( other->s.eType == ET_PLAYER || other->s.eType == ET_BUILDABLE ) )
{
G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
ent->s.otherEntityNum = other->s.number;
}
else if( trace->surfaceFlags & SURF_METALSTEPS )
G_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) );
else
G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
ent->freeAfterEvent = qtrue;
// change over to a normal entity right at the point of impact
ent->s.eType = ET_GENERAL;
SnapVectorTowards( trace->endpos, ent->s.pos.trBase ); // save net bandwidth
G_SetOrigin( ent, trace->endpos );
// splash damage (doesn't apply to person directly hit)
if( ent->splashDamage )
G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius,
other, ent->splashMethodOfDeath );
trap_LinkEntity( ent );
}
开发者ID:GrangerHub,项目名称:tremulous,代码行数:101,代码来源:g_missile.c
示例13: Think_SetupObjectiveInfo
// links the trigger to it's objective, determining if it's a func_explosive
// of func_constructible and spawning the right indicator
void Think_SetupObjectiveInfo(gentity_t *ent)
{
ent->target_ent = G_FindByTargetname(NULL, ent->target);
if (!ent->target_ent)
{
G_Error("'trigger_objective_info' has a missing target '%s'\n", ent->target);
}
if (ent->target_ent->s.eType == ET_EXPLOSIVE)
{
// this is for compass usage
if ((ent->spawnflags & AXIS_OBJECTIVE) || (ent->spawnflags & ALLIED_OBJECTIVE))
{
gentity_t *e = G_Spawn();
e->r.svFlags = SVF_BROADCAST;
e->classname = "explosive_indicator";
if (ent->spawnflags & 8)
{
e->s.eType = ET_TANK_INDICATOR;
}
else
{
e->s.eType = ET_EXPLOSIVE_INDICATOR;
}
e->parent = ent;
e->s.pos.trType = TR_STATIONARY;
if (ent->spawnflags & AXIS_OBJECTIVE)
{
e->s.teamNum = 1;
}
else if (ent->spawnflags & ALLIED_OBJECTIVE)
{
e->s.teamNum = 2;
}
G_SetOrigin(e, ent->r.currentOrigin);
e->s.modelindex2 = ent->s.teamNum;
e->r.ownerNum = ent->s.number;
e->think = explosive_indicator_think;
e->nextthink = level.time + FRAMETIME;
e->s.effect1Time = ent->target_ent->constructibleStats.weaponclass;
if (ent->tagParent)
{
e->tagParent = ent->tagParent;
Q_strncpyz(e->tagName, ent->tagName, MAX_QPATH);
}
else
{
VectorCopy(ent->r.absmin, e->s.pos.trBase);
VectorAdd(ent->r.absmax, e->s.pos.trBase, e->s.pos.trBase);
VectorScale(e->s.pos.trBase, 0.5, e->s.pos.trBase);
}
SnapVector(e->s.pos.trBase);
trap_LinkEntity(e);
ent->target_ent->parent = ent;
}
}
else if (ent->target_ent->s.eType == ET_CONSTRUCTIBLE)
{
gentity_t *constructibles[2];
int team[2] = { 0 };
ent->target_ent->parent = ent;
constructibles[0] = ent->target_ent;
constructibles[1] = G_FindByTargetname(constructibles[0], ent->target); // see if we are targetting a 2nd one for two team constructibles
team[0] = constructibles[0]->spawnflags & AXIS_CONSTRUCTIBLE ? TEAM_AXIS : TEAM_ALLIES;
constructibles[0]->s.otherEntityNum2 = ent->s.teamNum;
if (constructibles[1])
{
team[1] = constructibles[1]->spawnflags & AXIS_CONSTRUCTIBLE ? TEAM_AXIS : TEAM_ALLIES;
if (constructibles[1]->s.eType != ET_CONSTRUCTIBLE)
{
G_Error("'trigger_objective_info' targets multiple entities with targetname '%s', the second one isn't a 'func_constructible' [%d]\n", ent->target, constructibles[1]->s.eType);
}
if (team[0] == team[1])
{
G_Error("'trigger_objective_info' targets two 'func_constructible' entities with targetname '%s' that are constructible by the same team\n", ent->target);
}
constructibles[1]->s.otherEntityNum2 = ent->s.teamNum;
ent->chain = constructibles[1];
ent->chain->parent = ent;
//.........这里部分代码省略.........
开发者ID:Mailaender,项目名称:etlegacy,代码行数:101,代码来源:g_trigger.c
示例14: G_smvRunCamera
// Set up snapshot merge based on this portal
qboolean G_smvRunCamera( gentity_t *ent ) {
int id = ent->TargetFlag;
int chargeTime, sprintTime, hintTime, weapHeat;
playerState_t *tps, *ps;
// Opt out if not a real MV portal
if ( ent->tagParent == NULL || ent->tagParent->client == NULL ) {
return( qfalse );
}
if ( ( ps = &ent->tagParent->client->ps ) == NULL ) {
return( qfalse );
}
// If viewing client is no longer connected, delete this camera
if ( ent->tagParent->client->pers.connected != CON_CONNECTED ) {
G_FreeEntity( ent );
return( qtrue );
}
// Also remove if the target player is no longer in the game playing
if ( ent->target_ent->client->pers.connected != CON_CONNECTED ||
ent->target_ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
G_smvLocateEntityInMVList( ent->tagParent, ent->target_ent - g_entities, qtrue );
return( qtrue );
}
// Seems that depending on player's state, we pull from either r.currentOrigin, or s.origin
// if(!spec) then use: r.currentOrigin
// if(spec) then use: s.origin
//
// This is true for both the portal origin and its target (origin2)
//
VectorCopy( ent->tagParent->s.origin, ent->s.origin );
G_SetOrigin( ent, ent->s.origin );
VectorCopy( ent->target_ent->r.currentOrigin, ent->s.origin2 );
trap_LinkEntity( ent );
// Only allow client ids 0 to (MAX_MVCLIENTS-1) to be updated with extra info
if ( id >= MAX_MVCLIENTS ) {
return( qtrue );
}
tps = &ent->target_ent->client->ps;
if ( tps->stats[STAT_PLAYER_CLASS] == PC_ENGINEER ) {
chargeTime = g_engineerChargeTime.value;
} else if ( tps->stats[STAT_PLAYER_CLASS] == PC_MEDIC ) {
chargeTime = g_medicChargeTime.value;
} else if ( tps->stats[STAT_PLAYER_CLASS] == PC_FIELDOPS ) {
chargeTime = g_LTChargeTime.value;
} else if ( tps->stats[STAT_PLAYER_CLASS] == PC_COVERTOPS ) {
chargeTime = g_covertopsChargeTime.value;
} else { chargeTime = g_soldierChargeTime.value;}
chargeTime = ( level.time - tps->classWeaponTime >= (int)chargeTime ) ? 0 : ( 1 + floor( 15.0f * (float)( level.time - tps->classWeaponTime ) / chargeTime ) );
sprintTime = ( ent->target_ent->client->pmext.sprintTime >= 20000 ) ? 0.0f : ( 1 + floor( 7.0f * (float)ent->target_ent->client->pmext.sprintTime / 20000.0f ) );
weapHeat = floor( (float)tps->curWeapHeat * 15.0f / 255.0f );
hintTime = ( tps->serverCursorHint != HINT_BUILD && ( tps->serverCursorHintVal >= 255 || tps->serverCursorHintVal == 0 ) ) ?
0 : ( 1 + floor( 15.0f * (float)tps->serverCursorHintVal / 255.0f ) );
// (Remaining bits)
// ammo : 0
// ammo-1 : 0
// ammiclip : 0
// ammoclip-1: 16
id = MAX_WEAPONS - 1 - ( id * 2 );
if ( tps->pm_flags & PMF_LIMBO ) {
ps->ammo[id] = 0;
ps->ammo[id - 1] = 0;
ps->ammoclip[id - 1] = 0;
} else {
ps->ammo[id] = ( ( ( ent->target_ent->health > 0 ) ? ent->target_ent->health : 0 ) & 0xFF ); // Meds up to 140 :(
ps->ammo[id] |= ( hintTime & 0x0F ) << 8; // 4 bits for work on current item (dynamite, weapon repair, etc.)
ps->ammo[id] |= ( weapHeat & 0x0F ) << 12; // 4 bits for weapon heat info
ps->ammo[id - 1] = tps->ammo[BG_FindAmmoForWeapon( tps->weapon )] & 0x3FF; // 11 bits needed to cover 1500 Venom ammo
ps->ammo[id - 1] |= ( BG_simpleWeaponState( tps->weaponstate ) & 0x03 ) << 11; // 2 bits for current weapon state
ps->ammo[id - 1] |= ( ( tps->persistant[PERS_HWEAPON_USE] ) ? 1 : 0 ) << 13; // 1 bit for mg42 use
ps->ammo[id - 1] |= ( BG_simpleHintsCollapse( tps->serverCursorHint, hintTime ) & 0x03 ) << 14; // 2 bits for cursor hints
// G_Printf("tps->hint: %d, dr: %d, collapse: %d\n", tps->serverCursorHint, HINT_DOOR_ROTATING, G_simpleHintsCollapse(tps->serverCursorHint, hintTime));
ps->ammoclip[id - 1] = tps->ammoclip[BG_FindClipForWeapon( tps->weapon )] & 0x1FF; // 9 bits to cover 500 Venom ammo clip
ps->ammoclip[id - 1] |= ( chargeTime & 0x0F ) << 9; // 4 bits for weapon charge time
ps->ammoclip[id - 1] |= ( sprintTime & 0x07 ) << 13; // 3 bits for fatigue
}
return( qtrue );
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:92,代码来源:g_multiview.c
示例15: Cmd_Fx
//------------------
void Cmd_Fx( gentity_t *ent )
{
vec3_t dir;
gentity_t *fx_ent = NULL;
if ( Q_stricmp( gi.argv(1), "play" ) == 0 )
{
if ( gi.argc() == 3 )
{
// I guess, only allow one active at a time
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
G_FreeEntity( fx_ent );
}
fx_ent = G_Spawn();
fx_ent->fxFile = gi.argv( 2 );
// Move out in front of the person spawning the effect
AngleVectors( ent->currentAngles, dir, NULL, NULL );
VectorMA( ent->currentOrigin, 32, dir, fx_ent->s.origin );
extern void SP_fx_runner( gentity_t *ent );
SP_fx_runner( fx_ent );
fx_ent->delay = 2000; // adjusting delay
fx_ent->classname = "cmd_fx"; // and classname
return;
}
}
else if ( Q_stricmp( gi.argv(1), "stop" ) == 0 )
{
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
G_FreeEntity( fx_ent );
}
return;
}
else if ( Q_stricmp( gi.argv(1), "delay" ) == 0 )
{
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
if ( gi.argc() == 3 )
{
fx_ent->delay = atoi( gi.argv( 2 ));
}
else
{
gi.Printf( S_COLOR_GREEN"FX: current delay is: %i\n", fx_ent->delay );
}
return;
}
}
else if ( Q_stricmp( gi.argv(1), "random" ) == 0 )
{
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
if ( gi.argc() == 3 )
{
fx_ent->random = atoi( gi.argv( 2 ));
}
else
{
gi.Printf( S_COLOR_GREEN"FX: current random is: %6.2f\n", fx_ent->random );
}
return;
}
}
else if ( Q_stricmp( gi.argv(1), "origin" ) == 0 )
{
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
if ( gi.argc() == 5 )
{
fx_ent->s.origin[0] = atof( gi.argv( 2 ));
fx_ent->s.origin[1] = atof( gi.argv( 3 ));
fx_ent->s.origin[2] = atof( gi.argv( 4 ));
G_SetOrigin( fx_ent, fx_ent->s.origin );
}
else
{
gi.Printf( S_COLOR_GREEN"FX: current origin is: <%6.2f %6.2f %6.2f>\n",
fx_ent->currentOrigin[0], fx_ent->currentOrigin[1], fx_ent->currentOrigin[2] );
}
return;
}
}
else if ( Q_stricmp( gi.argv(1), "dir" ) == 0 )
{
while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL )
{
if ( gi.argc() == 5 )
//.........这里部分代码省略.........
开发者ID:PJayB,项目名称:jk3src,代码行数:101,代码来源:g_cmds.cpp
示例16: G_RunExPhys
//.........这里部分代码省略.........
VectorSubtract( &ent->r.currentOrigin, &projectedOrigin, &trajDif );
while ( i < numG2Bolts ) {
//Get the position of the actual bolt for this frame
trap->G2API_GetBoltMatrix( ent->ghoul2, 0, g2Bolts[i], &matrix, &gbmAngles, &ent->r.currentOrigin, level.time, NULL, &ent->modelScale );
BG_GiveMeVectorFromMatrix( &matrix, ORIGIN, &boneOrg );
//Now add the projected positional difference into the result
VectorAdd( &boneOrg, &trajDif, &projectedBoneOrg );
trap->Trace( &tr, &boneOrg, &tMins, &tMaxs, &projectedBoneOrg, ent->s.number, ent->clipmask, qfalse, 0, 0 );
if ( tr.fraction != 1.0f || tr.startsolid || tr.allsolid ) { //we've hit something
//Store the "deepest" collision we have
if ( !hasFirstCollision ) { //don't have one yet so just use this one
bestCollision = tr;
VectorCopy( &boneOrg, &collisionRootPos );
hasFirstCollision = qtrue;
}
else {
if ( tr.allsolid && !bestCollision.allsolid ) { //If the whole trace is solid then this one is deeper
bestCollision = tr;
VectorCopy( &boneOrg, &collisionRootPos );
}
else if ( tr.startsolid && !bestCollision.startsolid && !bestCollision.allsolid ) { //Next deepest is if it's startsolid
bestCollision = tr;
VectorCopy( &boneOrg, &collisionRootPos );
}
else if ( !bestCollision.startsolid && !bestCollision.allsolid &&
tr.fraction < bestCollision.fraction ) { //and finally, if neither is startsolid/allsolid, but the new one has a smaller fraction, then it's closer to an impact point so we will use it
bestCollision = tr;
VectorCopy( &boneOrg, &collisionRootPos );
}
}
}
i++;
}
if ( hasFirstCollision ) { //at least one bolt collided
//We'll get the offset between the collided bolt and endpos, then trace there
//from the origin so that our desired position becomes that point.
VectorSubtract( &collisionRootPos, &bestCollision.endpos, &trajDif );
VectorAdd( &ent->r.currentOrigin, &trajDif, &projectedOrigin );
}
}
//If we didn't collide with any bolts projectedOrigin will still be the original desired
//projected position so all is well. If we did then projectedOrigin will be modified
//to provide us with a relative position which does not place the bolt in a solid.
trap->Trace( &tr, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &projectedOrigin, ent->s.number, ent->clipmask, qfalse, 0, 0 );
if ( tr.startsolid || tr.allsolid ) { //can't go anywhere from here
#ifdef _DEBUG
Com_Printf( "ExPhys object in solid (%i)\n", ent->s.number );
#endif
if ( autoKill ) {
ent->think = G_FreeEntity;
ent->nextthink = level.time;
}
return;
}
//Go ahead and set it to the trace endpoint regardless of what it hit
G_SetOrigin( ent, &tr.endpos );
trap->LinkEntity( (sharedEntity_t *)ent );
if ( tr.fraction == 1.0f ) { //Nothing was in the way.
return;
}
if ( bounce ) {
vTotal *= bounce; //scale it by bounce
VectorScale( &tr.plane.normal, vTotal, &vNorm ); //scale the trace plane normal by the bounce factor
if ( vNorm.z > 0 ) {
ent->epGravFactor -= vNorm.
|
请发表评论