OGRErr OGRWritableDWGLayer::CreateFeature( OGRFeature *poFeature ) { OGRGeometry *poGeom = poFeature->GetGeometryRef(); OGRErr eErr; if( poGeom == NULL ) return OGRERR_FAILURE; /* -------------------------------------------------------------------- */ /* Keep track of file extents. */ /* -------------------------------------------------------------------- */ poDS->ExtendExtent( poGeom ); /* -------------------------------------------------------------------- */ /* Translate geometry. */ /* -------------------------------------------------------------------- */ OdDbObjectPtr pObject; eErr = WriteEntity( poGeom, &pObject ); if( eErr != OGRERR_NONE ) return eErr; /* -------------------------------------------------------------------- */ /* Append attributes. */ /* -------------------------------------------------------------------- */ OdResBufPtr xIter = OdResBuf::newRb( 1001 ); xIter->setString( "ACAD" ); OdResBufPtr temp = xIter; for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ) { if( !poFeature->IsFieldSet( iField ) ) continue; CPLString sNameValue; const char *pszValue = poFeature->GetFieldAsString( iField ); while( *pszValue == ' ' ) pszValue++; sNameValue.Printf( "%s=%s", poFeature->GetFieldDefnRef( iField )->GetNameRef(), pszValue ); OdResBufPtr newRB = OdResBuf::newRb( 1000 ); newRB->setString( sNameValue.c_str() ); temp->setNext( newRB ); temp = temp->next(); } if( pObject != (const void *) NULL ) pObject->setXData( xIter ); return OGRERR_NONE; }
void muzzleflash() { WriteByte( MSG_MULTICAST, SVC_MUZZLEFLASH ); WriteEntity( MSG_MULTICAST, self ); trap_multicast( PASSVEC3( self->s.v.origin ), MULTICAST_PVS ); }
OGRErr OGRWritableDWGLayer::WriteEntity( OGRGeometry *poGeom, OdDbObjectPtr *ppObjectRet ) { switch( wkbFlatten(poGeom->getGeometryType()) ) { case wkbPoint: { OGRPoint *poOGRPoint = (OGRPoint *) poGeom; OdDbPointPtr pPoint = OdDbPoint::createObject(); pPoint->setPosition( OdGePoint3d(poOGRPoint->getX(), poOGRPoint->getY(), poOGRPoint->getZ() ) ); pPoint->setLayer( hLayerId, false ); poDS->pMs->appendOdDbEntity( pPoint ); if( ppObjectRet != NULL ) *ppObjectRet = pPoint; return OGRERR_NONE; } case wkbLineString: { OGRLineString *poLine = (OGRLineString *) poGeom; // Add a 2d polyline with vertices. OdDb2dPolylinePtr p2dPl = OdDb2dPolyline::createObject(); int i; for (i = 0; i < poLine->getNumPoints(); i++) { OdDb2dVertexPtr pV; OdGePoint3d pos; pos.x = poLine->getX(i); pos.y = poLine->getY(i); pos.z = poLine->getZ(i); pV = OdDb2dVertex::createObject(); p2dPl->appendVertex(pV); pV->setPosition(pos); } p2dPl->setLayer( hLayerId, false ); poDS->pMs->appendOdDbEntity( p2dPl ); if( ppObjectRet != NULL ) *ppObjectRet = p2dPl; return OGRERR_NONE; } case wkbPolygon: { OGRPolygon *poPoly = (OGRPolygon *) poGeom; int iRing; OGRErr eErr; for( iRing = -1; iRing < poPoly->getNumInteriorRings(); iRing++ ) { OGRLinearRing *poRing; if( iRing == -1 ) poRing = poPoly->getExteriorRing(); else poRing = poPoly->getInteriorRing( iRing ); if( iRing == -1 ) eErr = WriteEntity( poRing, ppObjectRet ); else eErr = WriteEntity( poRing, NULL ); if( eErr != OGRERR_NONE ) return eErr; } return OGRERR_NONE; } case wkbGeometryCollection: case wkbMultiPolygon: case wkbMultiPoint: case wkbMultiLineString: { OGRGeometryCollection *poColl = (OGRGeometryCollection *) poGeom; int iSubGeom; OGRErr eErr; for( iSubGeom=0; iSubGeom < poColl->getNumGeometries(); iSubGeom++ ) { OGRGeometry *poGeom = poColl->getGeometryRef( iSubGeom ); if( iSubGeom == 0 ) eErr = WriteEntity( poGeom, ppObjectRet ); else eErr = WriteEntity( poGeom, NULL ); if( eErr != OGRERR_NONE ) return eErr; } return OGRERR_NONE; } default: return OGRERR_FAILURE; } }
void FireSentryLighting( gedict_t * targ ) { vec3_t src; vec3_t dst; vec3_t dir, end, norm_dir; gedict_t*trace_ent; switch( tfset_sg_sfire ) { case SG_SFIRE_NEW: VectorCopy( self->s.v.angles, self->s.v.v_angle ); sgAimNew( self, targ, src, dst, norm_dir ); VectorCopy(dst,end); break; case SG_SFIRE_MTFL2: VectorCopy( self->s.v.angles, self->s.v.v_angle ); sgAimMTFL2( self, targ, src, dir ); VectorNormalize( dir ); VectorScale( dir, 2048, end ); VectorAdd( end, src, end ); break; case SG_SFIRE_MTFL1: VectorCopy( self->s.v.angles, self->s.v.v_angle ); case SG_SFIRE_281: trap_makevectors( self->s.v.v_angle ); VectorScale( g_globalvars.v_forward, 10, src ); VectorAdd( self->s.v.origin, src, src ); src[2] = self->s.v.absmin[2] + self->s.v.size[2] * 0.7; VectorSubtract( targ->s.v.origin, self->s.v.origin, dir ); VectorScale( dir, 2048, end ); VectorAdd( end, src, end ); break; default: return; } g_globalvars.trace_ent = 0; traceline( PASSVEC3( src ), PASSVEC3( end ), 0, self ); trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_LIGHTNING2 ); WriteEntity( MSG_MULTICAST, self ); trap_WriteCoord( MSG_MULTICAST, src[0] ); trap_WriteCoord( MSG_MULTICAST, src[1] ); trap_WriteCoord( MSG_MULTICAST, src[2] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] ); trap_multicast( PASSVEC3( src ), 1 ); if ( g_globalvars.trace_ent ) { trace_ent = PROG_TO_EDICT(g_globalvars.trace_ent); if ( streq( trace_ent->s.v.classname, "player" ) ) { switch((int)( g_random( ) * 30) ) { case 0: sound( trace_ent, 2, "player/pain1.wav" , 1, 1 ); break; case 1: sound( trace_ent, 2, "player/pain1.wav" , 1, 1 ); break; case 2: sound( trace_ent, 2, "player/pain2.wav" , 1, 1 ); break; case 3: sound( trace_ent, 2, "player/pain3.wav" , 1, 1 ); break; case 4: sound( trace_ent, 2, "player/pain4.wav" , 1, 1 ); break; case 5: sound( trace_ent, 2, "player/pain5.wav" , 1, 1 ); break; case 6: sound( trace_ent, 2, "player/pain6.wav" , 1, 1 ); break; default:break; } } } }
void W_FireLightning() { vec3_t org; float cells; vec3_t tmp; if ( self->s.v.ammo_cells < 1 ) { self->s.v.weapon = W_BestWeapon(); W_SetCurrentAmmo(); return; } // explode if under water if ( self->s.v.waterlevel > 1 ) { if ( deathmatch > 3 ) { if ( g_random() <= 0.5 ) { self->deathtype = "selfwater"; T_Damage( self, self, PROG_TO_EDICT( self->s.v.owner ), 4000 ); } else { cells = self->s.v.ammo_cells; self->s.v.ammo_cells = 0; W_SetCurrentAmmo(); T_RadiusDamage( self, self, 35 * cells, world, "" ); return; } } else { cells = self->s.v.ammo_cells; self->s.v.ammo_cells = 0; W_SetCurrentAmmo(); T_RadiusDamage( self, self, 35 * cells, world, "" ); return; } } if ( self->t_width < g_globalvars.time ) { sound( self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM ); self->t_width = g_globalvars.time + 0.6; } g_globalvars.msg_entity = EDICT_TO_PROG( self ); trap_WriteByte( MSG_ONE, SVC_SMALLKICK ); if ( deathmatch != 4 ) self->s.v.currentammo = self->s.v.ammo_cells = self->s.v.ammo_cells - 1; VectorCopy( self->s.v.origin, org ); //org = self->s.v.origin + '0 0 16'; org[2] += 16; traceline( PASSVEC3( org ), org[0] + g_globalvars.v_forward[0] * 600, org[1] + g_globalvars.v_forward[1] * 600, org[2] + g_globalvars.v_forward[2] * 600, true, self ); trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY ); trap_WriteByte( MSG_MULTICAST, TE_LIGHTNING2 ); WriteEntity( MSG_MULTICAST, self ); trap_WriteCoord( MSG_MULTICAST, org[0] ); trap_WriteCoord( MSG_MULTICAST, org[1] ); trap_WriteCoord( MSG_MULTICAST, org[2] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[0] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[1] ); trap_WriteCoord( MSG_MULTICAST, g_globalvars.trace_endpos[2] ); trap_multicast( PASSVEC3( org ), MULTICAST_PHS ); VectorScale( g_globalvars.v_forward, 4, tmp ); VectorAdd( g_globalvars.trace_endpos, tmp, tmp ); LightningDamage( self->s.v.origin, tmp, self, 30 ); }
/////////////////////////////////////// /// Night Vision void TeamFortress_NightVision ( ) { gedict_t *te, *tl; te=world; sound( self, 0, "items/nightvis.wav", 0.5, 1 ); // find enemies and put lightning effects around them te = trap_find( te, FOFS( s.v.classname ), "player" ); while( te ) { if ( self != te ) { if ( te->team_no != 0 ) { if ( te->s.v.health > 1 ) { if ( visible( te ) ) { g_globalvars.msg_entity = EDICT_TO_PROG( self ); tl = spawn( ); tl->s.v.owner = EDICT_TO_PROG( self ); VectorCopy( te->s.v.origin, tl->s.v.origin ); tl->s.v.origin[2] = tl->s.v.origin[2] + 32; trap_WriteByte( MSG_ONE, 23 ); trap_WriteByte( MSG_ONE, 9 ); WriteEntity( MSG_ONE, tl ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 ); dremove( tl ); } } } } te = trap_find( te, FOFS( s.v.classname ), "player" ); } te=world; te = trap_find( te, FOFS( s.v.classname ), "building_sentrygun" ); while ( te ) { if ( self != te ) { if ( te->team_no != 0 ) { if ( te->s.v.health > 1 ) { if ( visible( te ) ) { g_globalvars.msg_entity = EDICT_TO_PROG( self ); tl = spawn( ); tl->s.v.owner = EDICT_TO_PROG( self ); VectorCopy( te->s.v.origin, tl->s.v.origin ); tl->s.v.origin[2] = tl->s.v.origin[2] + 32; trap_WriteByte( MSG_ONE, 23 ); trap_WriteByte( MSG_ONE, 9 ); WriteEntity( MSG_ONE, tl ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 ); dremove( tl ); } } } } te = trap_find( te, FOFS( s.v.classname ), "building_sentrygun" ); } te=world; te = trap_find( te, FOFS( s.v.classname ), "bot" ); while ( te ) { if ( self != te ) { if ( te->team_no != 0 ) { if ( te->s.v.health > 1 ) { if ( visible( te ) ) { g_globalvars.msg_entity = EDICT_TO_PROG( self ); tl = spawn( ); tl->s.v.owner = EDICT_TO_PROG( self ); VectorCopy( te->s.v.origin, tl->s.v.origin ); tl->s.v.origin[2] = tl->s.v.origin[2] + 32; trap_WriteByte( MSG_ONE, 23 ); trap_WriteByte( MSG_ONE, 9 ); WriteEntity( MSG_ONE, tl ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, tl->s.v.origin[2] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[0] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[1] ); trap_WriteCoord( MSG_ONE, te->s.v.origin[2] + 5 ); dremove( tl ); } } } } te = trap_find( te, FOFS( s.v.classname ), "bot" ); } }