本文整理汇总了C++中SnapVector函数的典型用法代码示例。如果您正苦于以下问题:C++ SnapVector函数的具体用法?C++ SnapVector怎么用?C++ SnapVector使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SnapVector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: weapon_supershotgun_fire
void weapon_supershotgun_fire (gentity_t *ent) {
gentity_t *tent;
// send shotgun blast
tent = G_TempEntity( g_muzzle, EV_SHOTGUN );
VectorScale( forward, 4096, tent->s.origin2 );
SnapVector( tent->s.origin2 );
tent->s.eventParm = rand() & 255; // seed for spread pattern
tent->s.otherEntityNum = ent->s.number;
ShotgunPattern( tent->s.origin, tent->s.origin2, tent->s.eventParm, ent );
}
示例2: CalcMuzzlePoint
/*
===============
CalcMuzzlePoint
set muzzle location relative to pivoting eye
===============
*/
void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) {
/* LQ3A */
UNREFERENCED_PARAMETER(up);
UNREFERENCED_PARAMETER(right);
VectorCopy( ent->s.pos.trBase, muzzlePoint );
muzzlePoint[2] += ent->client->ps.viewheight;
VectorMA( muzzlePoint, 14, forward, muzzlePoint );
// snap to integer coordinates for more efficient network bandwidth usage
SnapVector( muzzlePoint );
}
示例3: VectorNormalize
/*
=================
launch_grenade
=================
*/
gentity_t *launch_grenade( gentity_t *self, vec3_t start, vec3_t dir )
{
gentity_t *bolt;
VectorNormalize( dir );
bolt = G_Spawn( );
bolt->classname = "grenade";
bolt->nextthink = level.time + 5000;
bolt->think = G_ExplodeMissile;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_GRENADE;
bolt->s.eFlags = EF_BOUNCE_HALF;
bolt->s.generic1 = WPM_PRIMARY; //weaponMode
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
if ( self->client->pers.classSelection != PCL_ALIEN_LEVEL4 )
{
bolt->damage = GRENADE_DAMAGE;
bolt->splashDamage = GRENADE_DAMAGE;
bolt->splashRadius = GRENADE_RANGE;
}
else
{
bolt->damage = 300;
bolt->splashDamage = 500;
bolt->splashRadius = 975;
}
bolt->methodOfDeath = MOD_GRENADE;
bolt->splashMethodOfDeath = MOD_GRENADE;
bolt->clipmask = MASK_SHOT;
bolt->target_ent = NULL;
bolt->r.mins[ 0 ] = bolt->r.mins[ 1 ] = bolt->r.mins[ 2 ] = -3.0f;
bolt->r.maxs[ 0 ] = bolt->r.maxs[ 1 ] = bolt->r.maxs[ 2 ] = 3.0f;
bolt->s.time = level.time;
bolt->s.pos.trType = TR_GRAVITY;
if ( self->client->pers.classSelection == PCL_ALIEN_LEVEL4 )
{
bolt->s.pos.trType = TR_LINEAR_STOP;
bolt->s.weapon = WP_LOCKBLOB_LAUNCHER;
}
bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
VectorCopy( start, bolt->s.pos.trBase );
VectorScale( dir, GRENADE_SPEED, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy( start, bolt->r.currentOrigin );
return bolt;
}
示例4: TieBomberThink
void TieBomberThink( gentity_t *self )
{
// NOTE: Lerp2Angles will think this thinkfunc if the model is a misc_model_breakable. Watchout
// for that in a script (try to just use ROFF's?).
// Stop thinking, you're dead.
if ( self->health <= 0 )
{
return;
}
// Needed every think...
self->nextthink = level.time + FRAMETIME;
gentity_t *player = &g_entities[0];
vec3_t playerDir;
float playerDist;
//use player eyepoint
VectorSubtract( player->currentOrigin, self->currentOrigin, playerDir );
playerDist = VectorNormalize( playerDir );
// Time to attack?
if ( player->health > 0 && playerDist < MIN_PLAYER_DIST && self->attackDebounceTime < level.time )
{
// Doesn't matter what model gets loaded here, as long as it exists.
// It's only used as a point on to which the falling effect for the bomb
// can be attached to (kinda inefficient, I know).
char name1[200] = "models/players/gonk/model.glm";
gentity_t *bomb = G_CreateObject( self, self->s.pos.trBase, self->s.apos.trBase, 0, 0, TR_GRAVITY, 0 );
bomb->s.modelindex = G_ModelIndex( name1 );
gi.G2API_InitGhoul2Model( bomb->ghoul2, name1, bomb->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
bomb->s.radius = 50;
bomb->s.eFlags |= EF_NODRAW;
// Make the bombs go forward in the bombers direction a little.
vec3_t fwd, rt;
AngleVectors( self->currentAngles, fwd, rt, NULL );
rt[2] -= 0.5f;
VectorMA( bomb->s.pos.trBase, -30.0, rt, bomb->s.pos.trBase );
VectorScale( fwd, 300, bomb->s.pos.trDelta );
SnapVector( bomb->s.pos.trDelta ); // save net bandwidth
// Start the effect.
G_PlayEffect( G_EffectIndex( "ships/tiebomber_bomb_falling" ), bomb->playerModel, gi.G2API_AddBolt( &bomb->ghoul2[0], "model_root" ), bomb->s.number, bomb->currentOrigin, 1000, qtrue );
// Set the tie bomb to have a touch function, so when it hits the ground (or whatever), there's a nice 'boom'.
bomb->e_TouchFunc = touchF_TouchTieBomb;
self->attackDebounceTime = level.time + 1000;
}
}
示例5: VectorNormalize
/*
=================
fire_grapple
=================
*/
gentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir) {
gentity_t *hook;
//unlagged - grapple
int hooktime;
//unlagged - grapple
VectorNormalize (dir);
hook = G_Spawn();
hook->classname = "hook";
hook->nextthink = level.time + 10000;
hook->think = Weapon_HookFree;
hook->s.eType = ET_MISSILE;
hook->r.svFlags = SVF_USE_CURRENT_ORIGIN;
hook->s.weapon = WP_GRAPPLING_HOOK;
hook->r.ownerNum = self->s.number;
hook->methodOfDeath = MOD_GRAPPLE;
hook->clipmask = MASK_SHOT;
hook->parent = self;
hook->target_ent = NULL;
//unlagged - grapple
// we might want this later
hook->s.otherEntityNum = self->s.number;
// setting the projectile base time back makes the hook's first
// step larger
if ( self->client ) {
hooktime = self->client->pers.cmd.serverTime + 50;
}
else {
hooktime = level.time - MISSILE_PRESTEP_TIME;
}
hook->s.pos.trTime = hooktime;
//unlagged - grapple
hook->s.pos.trType = TR_LINEAR;
//unlagged - grapple
//hook->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
//unlagged - grapple
hook->s.otherEntityNum = self->s.number; // use to match beam in client
VectorCopy( start, hook->s.pos.trBase );
VectorScale( dir, 800, hook->s.pos.trDelta );
SnapVector( hook->s.pos.trDelta ); // save net bandwidth
VectorCopy (start, hook->r.currentOrigin);
self->client->hook = hook;
return hook;
}
示例6: turret_fire
//----------------------------------------------------------------
static void turret_fire ( gentity_t *ent, vec3_t start, vec3_t dir )
//----------------------------------------------------------------
{
vec3_t org;
gentity_t *bolt;
if ( (trap_PointContents( start, ent->s.number )&MASK_SHOT) )
{
return;
}
VectorMA( start, -START_DIS, dir, org ); // dumb....
G_PlayEffectID( ent->genericValue13, org, dir );
bolt = G_Spawn();
//use a custom shot effect
bolt->s.otherEntityNum2 = ent->genericValue14;
//use a custom impact effect
bolt->s.emplacedOwner = ent->genericValue15;
bolt->classname = "turret_proj";
bolt->nextthink = level.time + 10000;
bolt->think = G_FreeEntity;
bolt->s.eType = ET_MISSILE;
bolt->s.weapon = WP_EMPLACED_GUN;
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->damage;
bolt->splashRadius = 100;
bolt->methodOfDeath = MOD_TARGET_LASER;
//[BugFix16]
bolt->splashMethodOfDeath = MOD_TARGET_LASER;
//[/BugFix16]
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);
bolt->parent = ent;
}
示例7: shotgunFire
void shotgunFire( gentity_t *ent )
{
gentity_t *tent;
// send shotgun blast
tent = G_NewTempEntity( muzzle, EV_SHOTGUN );
VectorScale( forward, 4096, tent->s.origin2 );
SnapVector( tent->s.origin2 );
tent->s.eventParm = rand() / ( RAND_MAX / 0x100 + 1 ); // seed for spread pattern
tent->s.otherEntityNum = ent->s.number;
G_UnlaggedOn( ent, muzzle, SHOTGUN_RANGE );
ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent );
G_UnlaggedOff();
}
示例8: VectorNormalize
/*
=================
fire_rocket
=================
*/
gentity_t *fire_rocket( gentity_t *self, vec3_t start, vec3_t dir ) {
gentity_t *bolt;
VectorNormalize( dir );
bolt = G_Spawn();
bolt->classname = const_cast<char*>("rocket");
bolt->nextthink = level.time + 20000; // push it out a little
bolt->think = G_ExplodeMissile;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN | SVF_BROADCAST;
//DHM - Nerve :: Use the correct weapon in multiplayer
if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
bolt->s.weapon = WP_ROCKET_LAUNCHER;
} else {
bolt->s.weapon = self->s.weapon;
}
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = G_GetWeaponDamage( WP_ROCKET_LAUNCHER ); // JPW NERVE
bolt->splashDamage = G_GetWeaponDamage( WP_ROCKET_LAUNCHER ); // JPW NERVE
// JPW NERVE
if ( g_gametype.integer != GT_SINGLE_PLAYER ) {
bolt->splashRadius = G_GetWeaponDamage( WP_ROCKET_LAUNCHER );
} else {
bolt->splashRadius = 120;
}
// jpw
bolt->methodOfDeath = MOD_ROCKET;
bolt->splashMethodOfDeath = MOD_ROCKET_SPLASH;
// bolt->clipmask = MASK_SHOT;
bolt->clipmask = MASK_MISSILESHOT;
bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
VectorCopy( start, bolt->s.pos.trBase );
// JPW NERVE
if ( g_gametype.integer != GT_SINGLE_PLAYER ) {
VectorScale( dir,2500,bolt->s.pos.trDelta );
} else {
VectorScale( dir, 900, bolt->s.pos.trDelta );
}
// jpw
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy( start, bolt->r.currentOrigin );
return bolt;
}
示例9: shotgunFire
void shotgunFire( gentity_t *ent )
{
gentity_t *tent;
// send shotgun blast
tent = G_TempEntity( muzzle, EV_SHOTGUN );
VectorScale( forward, 4096, tent->s.origin2 );
SnapVector( tent->s.origin2 );
tent->s.eventParm = rand() & 255; // seed for spread pattern
tent->s.otherEntityNum = ent->s.number;
G_UnlaggedOn( muzzle, 8192 * 16 );
ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent );
G_UnlaggedOff();
}
示例10: _vec3_snap
static int _vec3_snap(lua_State *L)
{
luavec3_t a;
_et_gentity_setluavec3(L, &a);
lua_pop(L, 1);
SnapVector(a);
_et_gentity_getluavec3(L, a);
G_LuaSetVec3Class(L);
return 1;
}
示例11: plant_mine
gentity_t *
plant_mine(gentity_t *self, vec3_t start, vec3_t dir)
{
gentity_t *bolt;
VectorNormalize(dir);
bolt = G_Spawn();
bolt->classname = "mine";
bolt->nextthink = level.time + 2000;
bolt->think = G_minethink;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_MINE;
bolt->s.eFlags = EF_BOUNCE_HALF;
bolt->s.generic1 = WPM_PRIMARY; //weaponMode
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
if(g_survival.integer)
{
bolt->damage = MINE_DAMAGE;
bolt->splashDamage = MINE_DAMAGE;
} else {
bolt->damage = (1.25 * MINE_DAMAGE);
bolt->splashDamage = (1.25 * MINE_DAMAGE);
}
bolt->splashRadius = MINE_RANGE;
bolt->methodOfDeath = MOD_MINE;
bolt->splashMethodOfDeath = MOD_MINE;
bolt->clipmask = MASK_DEADSOLID;
bolt->target_ent = NULL;
bolt->r.mins[0] = bolt->r.mins[1] = -5.0f;
bolt->r.mins[2] = 0.0f;
bolt->r.maxs[0] = bolt->r.maxs[1] = 5.0f;
bolt->r.maxs[2] = 2.0f;
bolt->s.time = level.time;
bolt->biteam = bolt->s.modelindex2 = BIT_HUMANS;
bolt->use = G_itemUse;
bolt->s.pos.trType = TR_GRAVITY;
bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
VectorCopy( start, bolt->s.pos.trBase );
VectorScale( dir, GRENADE_SPEED/3, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy( start, bolt->r.currentOrigin );
return bolt;
}
示例12: G_Spawn
gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up ) {
gentity_t *bolt;
vec3_t dir;
vec3_t end;
float r, u, scale;
bolt = G_Spawn();
bolt->classname = const_cast<char*>("nail");
bolt->nextthink = level.time + 10000;
bolt->think = G_ExplodeMissile;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
// bolt->s.weapon = WP_NAILGUN;
bolt->s.weapon = WP_VENOM_FULL;
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = G_GetWeaponDamage( WP_VENOM_FULL );
// bolt->methodOfDeath = MOD_NAIL;
bolt->methodOfDeath = MOD_VENOM_FULL;
bolt->clipmask = MASK_SHOT;
bolt->target_ent = NULL;
bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time;
VectorCopy( start, bolt->s.pos.trBase );
r = random() * M_PI * 2.0f;
u = c::sin( r ) * crandom() * NAILGUN_SPREAD * 16;
r = c::cos( r ) * crandom() * NAILGUN_SPREAD * 16;
VectorMA( start, 8192 * 16, forward, end );
VectorMA( end, r, right, end );
VectorMA( end, u, up, end );
VectorSubtract( end, start, dir );
VectorNormalize( dir );
// JPW NERVE
if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
scale = 555 + random() * 1800;
} else {
scale = 1200 + random() * 2500;
}
// jpw
VectorScale( dir, scale, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta );
VectorCopy( start, bolt->r.currentOrigin );
return bolt;
}
示例13: FireShotgun
static void FireShotgun( gentity_t *self )
{
gentity_t *tent;
// instead of an EV_WEAPON_HIT_* event, send this so client can generate the same spread pattern
tent = G_NewTempEntity( muzzle, EV_SHOTGUN );
VectorScale( forward, 4096, tent->s.origin2 );
SnapVector( tent->s.origin2 );
tent->s.eventParm = rand() / ( RAND_MAX / 0x100 + 1 ); // seed for spread pattern
tent->s.otherEntityNum = self->s.number;
// caclulate the pattern and do the damage
G_UnlaggedOn( self, muzzle, SHOTGUN_RANGE );
ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, self );
G_UnlaggedOff();
}
示例14: G_SpawnMissile
static gentity_t *FireLcannonHelper( gentity_t *self, vec3_t start, vec3_t dir,
int damage, int radius, int speed )
{
// TODO: Tidy up this and lcannonFire
gentity_t *m;
int nextthink;
float charge;
// explode in front of player when overcharged
if ( damage == LCANNON_DAMAGE )
{
nextthink = level.time;
}
else
{
nextthink = level.time + 10000;
}
if ( self->s.generic1 == WPM_PRIMARY )
{
m = G_SpawnMissile( MIS_LCANNON, self, start, dir, NULL, G_ExplodeMissile, nextthink );
// some values are set in the code
m->damage = damage;
m->splashDamage = damage / 2;
m->splashRadius = radius;
VectorScale( dir, speed, m->s.pos.trDelta );
SnapVector( m->s.pos.trDelta ); // save net bandwidth
// pass the missile charge through
charge = ( float )( damage - LCANNON_SECONDARY_DAMAGE ) / LCANNON_DAMAGE;
m->s.torsoAnim = charge * 255;
if ( m->s.torsoAnim < 0 )
{
m->s.torsoAnim = 0;
}
}
else
{
m = G_SpawnMissile( MIS_LCANNON2, self, start, dir, NULL, G_ExplodeMissile, nextthink );
}
return m;
}
示例15: G_Spawn
gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up ) {
gentity_t *bolt;
vec3_t dir;
vec3_t end;
float r, u, scale;
bolt = G_Spawn();
bolt->classname = "nail";
bolt->nextthink = level.time + 10000;
bolt->think = G_ExplodeMissile;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_NAILGUN;
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = 20;
bolt->methodOfDeath = MOD_NAIL;
bolt->clipmask = MASK_SHOT;
bolt->target_ent = NULL;
bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time;
VectorCopy( start, bolt->s.pos.trBase );
r = random() * M_PI * 2.0f;
u = sin(r) * crandom() * NAILGUN_SPREAD * 16;
r = cos(r) * crandom() * NAILGUN_SPREAD * 16;
VectorMA( start, 8192 * 16, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
VectorSubtract( end, start, dir );
VectorNormalize( dir );
scale = 555 + random() * 1800;
VectorScale( dir, scale, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta );
VectorCopy( start, bolt->r.currentOrigin );
if ( self->player ) {
bolt->s.team = self->player->sess.sessionTeam;
} else {
bolt->s.team = TEAM_FREE;
}
return bolt;
}