
void mod2_main()
{
	Q2::ResetGameVars();
	hookNewGame.insertLast(        Q2::ResetGameVars  );
	hookBeginLevel.insertLast(     Q2::BeginLevel     );
	hookPostBeginLevel.insertLast( Q2::PostBeginLevel );
}

namespace Q2
{

void ResetGameVars()
{
	GameVarsSetAdd( GVK_Instagib, ""+ IGM_Off );
}

void BeginLevel()
{
	QuadInit();

	// spawn WeaponSound
	@WeaponSound = ActorFactory.Spawn( -1, Player.Actor().Origin().x, Player.Actor().Origin().y, Player.Actor().Origin().z, 0, Player.Actor().SectorIndex() );
	WeaponSound.Height() = WeaponSound.Radius() = 0;

	// raycast dummies
	@Dummy1 = ActorFactory.Spawn( -1, Player.Actor().Origin().x, Player.Actor().Origin().y, Player.Actor().Origin().z, 0, Player.Actor().SectorIndex() );
	@Dummy2 = ActorFactory.Spawn( -1, Player.Actor().Origin().x, Player.Actor().Origin().y, Player.Actor().Origin().z, 0, Player.Actor().SectorIndex() );
	Dummy1.Height() = Dummy1.Radius() = Dummy2.Height() = Dummy2.Radius() = 0;

	// pre-load rail trail models
	kActor @a = ActorFactory.Spawn( "RailSpiral", 0,0,0, 0, -1 );
	if ( a !is null ) a.Remove();
	@a = ActorFactory.Spawn( "RailSpiral_Half", 0,0,0, 0, -1 );
	if ( a !is null ) a.Remove();
	@a = ActorFactory.Spawn( "RailBeam", 0,0,0, 0, -1 );
	if ( a !is null ) a.Remove();
	@a = ActorFactory.Spawn( "RailBeam_End", 0,0,0, 0, -1 );
	if ( a !is null ) a.Remove();
}

void PostBeginLevel()
{
	if ( InstagibActive() )
		InstagibInit();
}

} // Q2 namespace
