
// When WadAuthor finds no script code, it reads this 
// default script code from the DEFAULT.ACS file in 
// the WadAuthor directory.  For information about 
// programming scripts, please refer to the official 
// Hexen specifications.

#include "common.acs"

// This script supplies the glass-shattering effect
// used throughout Hexen.  To use it, perform the
// following steps.

// 1) Create a sector on the map adjacent to another
//    sector but with a higher floor.  Make sure the
//    linedef below textures look like stained glass,
//    and make sure the main textures look like
//    broken glass.
//
// 2) Create four map spots just in front of the sector.
//    Give two one tag number, and give the others another
//    tag number.  Make their height halfway between
//    floor and ceiling.
//
// 3) Set the stained-glass linedef type to ACS_Execute
//    this script, passing it the tag of the sector you
//    created in step one along with the tag numbers of
//    the things you created.  Make sure the activation
//    code is set to trigger when hit by a projectile.

script 1 ( int iSector, int iThingTag1, int iThingTag2 )
{
	int i;	// local loop control variable

	// Lower the sector's floor; this exposes a
	// different texture to the player, making it
	// appear the glass has shattered.  Play the
	// shattering sound at the thing locations
	// given by the first tag.

	Floor_LowerInstant( iSector, 0, 16 );
	Thingsound( iThingTag1, "GlassShatter", 127 );
	delay(const: 1);

	// Create twenty shards of glass at the thing
	// locations given by the thing tags, heading in
	// different directions at different rates.

	i = 10;
	while ( i-- > 0 )
	{
		Thing_ProjectileGravity( iThingTag1,
		random( T_STAINEDGLASS1, T_STAINEDGLASS0 ),
			random( 0, 255 ), random( 10, 40 ),
			random( 5,20 ) );
		Thing_ProjectileGravity( iThingTag2,
			random( T_STAINEDGLASS1, T_STAINEDGLASS0 ),
			random( 0, 255 ), random( 10, 40 ),
			random( 5,20 ) );
	}
}
