void DoPathPlotter(){ PathPlotterRS rs; int ret = DoPathPlotterBox( &rs ); if ( ret == IDCANCEL ) { return; } if ( ret == IDNO ) { if ( g_PathView ) { delete g_PathView; } return; } if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) { DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK ); return; } // tell Radiant we want to access the selected brushes g_FuncTable.m_pfnAllocateSelectedBrushHandles(); brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 ); // should be our trigger brush DEntity world; world.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( brush->owner ) ); DEPair* trigger_ep = world.FindEPairByKey( "targetname" ); if ( trigger_ep ) { if ( !strcmp( world.m_Classname, "trigger_push" ) ) { DEPair* target_ep = world.FindEPairByKey( "target" ); if ( target_ep ) { entity_s* entTarget = FindEntityFromTargetname( target_ep->value, NULL ); if ( entTarget ) { if ( g_PathView ) { delete g_PathView; } g_PathView = new DBobView; g_PathView->Begin( trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra ); } else{ DoMessageBox( "trigger_push target could not be found.", "Error", MB_OK ); } } else{ DoMessageBox( "trigger_push has no target.", "Error", MB_OK ); } } else{ DoMessageBox( "You must select a 'trigger_push' entity.", "Error", MB_OK ); } } else{ DoMessageBox( "Entity must have a targetname", "Error", MB_OK ); } g_FuncTable.m_pfnReleaseSelectedBrushHandles(); }
bool pre( scene::Node& node ) const { if ( Node_isEntity( node ) ) { DEntity* loadEntity = m_map->AddEntity( "", 0 ); loadEntity->LoadFromEntity( node, m_bLoadPatches ); } return false; }
void visit( const char* key, const char* value ){ if ( strcmp( key, "classname" ) == 0 ) { m_entity->SetClassname( value ); } else{ m_entity->AddEPair( key, value ); } }
void DoCaulkSelection( void ) { DEntity world; float fScale[2] = { 0.5f, 0.5f }; float fShift[2] = { 0.0f, 0.0f }; int bResetScale[2] = { false, false }; int bResetShift[2] = { false, false }; world.LoadSelectedBrushes(); world.LoadSelectedPatches(); world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true ); }
void DBobView_setEntity( Entity& entity, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra ){ DEntity trigger; trigger.LoadEPairList( &entity ); DEPair* trigger_ep = trigger.FindEPairByKey( "targetname" ); if ( trigger_ep ) { if ( !strcmp( trigger.m_Classname, "trigger_push" ) ) { DEPair* target_ep = trigger.FindEPairByKey( "target" ); if ( target_ep ) { const scene::Path* entTarget = FindEntityFromTargetname( target_ep->value ); if ( entTarget ) { if ( g_PathView ) { delete g_PathView; } g_PathView = new DBobView; Entity* target = Node_getEntity( entTarget->top() ); if ( target != 0 ) { if ( !bNoUpdate ) { g_PathView->trigger = &entity; entity.attach( *g_PathView ); g_PathView->target = target; target->attach( *g_PathView ); } g_PathView->Begin( trigger_ep->value, target_ep->value, multiplier, points, varGravity, bNoUpdate, bShowExtra ); } else{ globalErrorStream() << "bobToolz PathPlotter: trigger_push ARGH\n"; } } else{ globalErrorStream() << "bobToolz PathPlotter: trigger_push target could not be found..\n"; } } else{ globalErrorStream() << "bobToolz PathPlotter: trigger_push has no target..\n"; } } else{ globalErrorStream() << "bobToolz PathPlotter: You must select a 'trigger_push' entity..\n"; } } else{ globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n"; } return; }
bool pre( scene::Node& node ) const { scene::Path path( NodeReference( GlobalSceneGraph().root() ) ); path.push( NodeReference( *m_entity->QER_Entity ) ); path.push( NodeReference( node ) ); scene::Instance* instance = GlobalSceneGraph().find( path ); ASSERT_MESSAGE( instance != 0, "" ); if ( Node_isPatch( node ) ) { DPatch* loadPatch = m_entity->NewPatch(); loadPatch->LoadFromPatch( *instance ); } else if ( Node_isBrush( node ) ) { DBrush* loadBrush = m_entity->NewBrush( m_count++ ); loadBrush->LoadFromBrush( *instance, true ); } return false; }
void BuildMiniPrt( list<Str>* exclusionList ) { // yes, we could just use -fulldetail option, but, as SPOG said // it'd be faster without all the hint, donotenter etc textures and // doors, etc DEntity world; char buffer[128]; const char *pn = g_FuncTable.m_pfnReadProjectKey( "mapspath" ); strcpy( buffer, pn ); strcat( buffer, "/ac_prt.map" ); FILE* pFile = fopen( buffer, "w" ); // ahem, thx rr2 if ( !pFile ) { return; } int count = g_FuncTable.m_pfnGetEntityCount(); for ( int i = 0; i < count; i++ ) { entity_t* ent = (entity_t*)g_FuncTable.m_pfnGetEntityHandle( i ); epair_t* epl = *g_EntityTable.m_pfnGetEntityKeyValList( ent ); epair_t* ep = epl; while ( ep ) { if ( !strcmp( ep->key, "classname" ) ) { if ( !strcmp( ep->value, "worldspawn" ) ) { world.LoadFromEntity( i, FALSE ); world.RemoveNonCheckBrushes( exclusionList, TRUE ); world.SaveToFile( pFile ); } else if ( strstr( ep->value, "info_" ) ) { world.ClearBrushes(); world.ClearEPairs(); world.LoadEPairList( epl ); world.SaveToFile( pFile ); } break; } ep = ep->next; } } fclose( pFile ); StartBSP(); }
entity_s* FindEntityFromTargetname( const char* targetname, int* entNum ) { DEntity world; int count = g_FuncTable.m_pfnGetEntityCount(); for ( int i = 0; i < count; i++ ) { world.ClearEPairs(); entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle( i ); world.LoadEPairList( *g_EntityTable.m_pfnGetEntityKeyValList( ent ) ); DEPair* tn = world.FindEPairByKey( "targetname" ); if ( tn ) { if ( !stricmp( tn->value, targetname ) ) { if ( entNum ) { *entNum = i; } return ent; } } } return NULL; }
void operator()(scene::Instance& instance) const { if(!instance.isSelected()) { return; } ent.LoadFromEntity(instance.path().top()); DEPair* pEpair = ent.FindEPairByKey("origin"); if(!pEpair) { return; } vec3_t vec, out; sscanf( pEpair->value.GetBuffer(), "%f %f %f", &vec[0], &vec[1], &vec[2]); planter.FindDropPoint( vec, out ); char buffer[256]; sprintf( buffer, "%f %f %f", out[0], out[1], out[2] ); ent.AddEPair( "origin", buffer ); ent.RemoveFromRadiant(); ent.BuildInRadiant(false); }
void DoResetTextures(){ static ResetTextureRS rs; const char* texName; if ( g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1 ) { texName = NULL; } else { texName = GetCurrentTexture(); strcpy( rs.textureName, GetCurrentTexture() ); } int ret; if ( ( ret = DoResetTextureBox( &rs ) ) == IDCANCEL ) { return; } if ( rs.bResetTextureName ) { texName = rs.textureName; } if ( ret == IDOK ) { DEntity world; world.LoadSelectedBrushes(); world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName, rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, TRUE ); } else { DMap world; world.LoadAll( TRUE ); world.ResetTextures( texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName, rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation ); } }
void DMap::LoadAll( bool bLoadPatches ){ ClearEntities(); g_FuncTable.m_pfnDeselectAllBrushes(); int count = g_FuncTable.m_pfnGetEntityCount(); for ( int i = 0; i < count; i++ ) { DEntity* loadEntity; if ( i == 0 ) { loadEntity = GetWorldSpawn(); } else{ loadEntity = AddEntity( "", m_nNextEntity++ ); } if ( !loadEntity->LoadFromEntity( i, bLoadPatches ) ) { delete loadEntity; entityList.pop_back(); } } }
void operator()(scene::Instance& instance) const { const char* classname = Node_getEntity(instance.path().top())->getKeyValue("classname"); if(!strcmp(classname, "worldspawn")) { world.LoadFromEntity(instance.path().top(), false); world.RemoveNonCheckBrushes(exclusionList, true); world.SaveToFile(pFile); } else if(strstr(classname, "info_")) { world.ClearBrushes(); world.ClearEPairs(); world.LoadEPairList(Node_getEntity(instance.path().top())); world.SaveToFile(pFile); } }
void DoIntersect(){ IntersectRS rs; if ( DoIntersectBox( &rs ) == IDCANCEL ) { return; } if ( rs.nBrushOptions == BRUSH_OPT_SELECTED ) { if ( g_FuncTable.m_pfnSelectedBrushCount() < 2 ) { DoMessageBox( "Invalid number of brushes selected, choose at least 2", "Error", MB_OK ); return; } } DEntity world; switch ( rs.nBrushOptions ) { case BRUSH_OPT_SELECTED: { world.LoadSelectedBrushes(); break; } case BRUSH_OPT_WHOLE_MAP: { world.LoadFromEntity( 0, FALSE ); break; } } world.RemoveNonCheckBrushes( &exclusionList, rs.bUseDetail ); bool* pbSelectList; if ( rs.bDuplicateOnly ) { pbSelectList = world.BuildDuplicateList(); } else{ pbSelectList = world.BuildIntersectList(); } world.SelectBrushes( pbSelectList ); delete[] pbSelectList; }
void DEntity_loadPatch( DEntity& entity, scene::Instance& patch ){ DPatch* loadPatch = entity.NewPatch(); loadPatch->LoadFromPatch( patch ); }
void DEntity_loadBrush( DEntity& entity, scene::Instance& brush ){ DBrush* loadBrush = entity.NewBrush( static_cast<int>( entity.brushList.size() ) ); loadBrush->LoadFromBrush( brush, true ); }
bool DShape::BuildPit( vec3_t min, vec3_t max ){ if ( ( max[2] - min[2] ) < 196 ) { return FALSE; } srand( time( NULL ) ); vec3_t centre; VectorAdd( min, max, centre ); VectorScale( centre, 0.5f, centre ); char buffer[256]; int team = ( rand() % 10000 ) + 5000; // ************* SPEAKER *************** sprintf( buffer, "t%i_1", team ); // trigger for speaker vec3_t triggerVoiceBtm; VectorCopy( min, triggerVoiceBtm ); triggerVoiceBtm[2] = max[2] - 16; DEntity* triggerVoice = m_Container.AddEntity( "trigger_multiple" ); GetBoundingCube( triggerVoiceBtm, max, "textures/common/trigger", triggerVoice ); triggerVoice->AddEPair( "target", buffer ); //-------------------- // target for speaker vec3_t voiceOrigin; VectorCopy( centre, voiceOrigin ); voiceOrigin[2] = max[2] + 16; DEntity* targetVoice = m_Container.AddEntity( "target_speaker" ); targetVoice->AddEPair( "targetname", buffer ); sprintf( buffer, "%f %f %f", voiceOrigin[0], voiceOrigin[1], voiceOrigin[2] ); targetVoice->AddEPair( "origin", buffer ); targetVoice->AddEPair( "spawnflags", "8" ); targetVoice->AddEPair( "noise", "*falling1.wav" ); //-------------------- // *********** END SPEAKER ************* // ********* POWERUP REMOVAL *********** sprintf( buffer, "t%i_2", team ); // trigger for powerup removal vec3_t triggerPwrRmvTop, triggerPwrRmvBtm; VectorCopy( min, triggerPwrRmvBtm ); VectorCopy( max, triggerPwrRmvTop ); triggerPwrRmvTop[2] = triggerVoiceBtm[2] - 64; triggerPwrRmvBtm[2] = triggerPwrRmvTop[2] - 16; DEntity* triggerPwrRmv = m_Container.AddEntity( "trigger_multiple" ); GetBoundingCube( triggerPwrRmvBtm, triggerPwrRmvTop, "textures/common/trigger", triggerPwrRmv ); triggerPwrRmv->AddEPair( "target", buffer ); //-------------------- // target for powerup removal vec3_t pwrRmvOrigin; VectorCopy( centre, pwrRmvOrigin ); pwrRmvOrigin[2] = triggerPwrRmvTop[2] + 16; DEntity* targetPwrRmv = m_Container.AddEntity( "target_remove_powerups" ); targetPwrRmv->AddEPair( "targetname", buffer ); sprintf( buffer, "%f %f %f", pwrRmvOrigin[0], pwrRmvOrigin[1], pwrRmvOrigin[2] ); targetPwrRmv->AddEPair( "origin", buffer ); //-------------------- // ****** END POWERUP REMOVAL ******** // ********* DAMAGE *********** // trigger for damage vec3_t triggerDmgTop, triggerDmgBtm; VectorCopy( min, triggerDmgBtm ); VectorCopy( max, triggerDmgTop ); triggerDmgBtm[2] = min[2] + 64; triggerDmgTop[2] = triggerDmgBtm[2] + 16; DEntity* triggerDmg = m_Container.AddEntity( "trigger_hurt" ); GetBoundingCube( triggerDmgBtm, triggerDmgTop, "textures/common/trigger", triggerDmg ); triggerDmg->AddEPair( "dmg", "9999" ); triggerDmg->AddEPair( "spawnflags", "12" ); //-------------------- // ****** END DAMAGE ******** // ********* NODROP *********** vec3_t nodropTop; VectorCopy( max, nodropTop ); nodropTop[2] = min[2] + 64; GetBoundingCube( min, nodropTop, "textures/common/nodrop" ); // ****** END NODROP ******** return TRUE; }