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();
}
Exemple #2
0
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();
}
Exemple #3
0
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;
}
Exemple #4
0
  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);
		}
  }
Exemple #5
0
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;
}