Breakable Windows


Description

This tutorial will explain how to add breakable glass with a certain amount of damage in your maps (as in SP level Launch Facility).

In Radiant

  • Make a trigger_damage the same size as your window
  • Give your trigger_damage the key/values:
targetname
windtrig
  • Make your UNBROKEN window, convert it to a script_brushmodel
  • Unselect everything, Select the trigger then the window and press W
  • If you want to, make the broken bits of your window, convert them to a script_brushmodel
  • Select all the broken bits and give them the targetname 'brokenwindow1' (increment the number for each window)
  • Save, and add the script into one of your .gsc files (preferrably mp_mapname_fx.gsc but I think it would work in mp_mapname.gsc)
  • Add this line to your zone file:
fx,props/car_glass_large

Scripting

  • Create a new file under /raw/maps/mp/ called _breakglass.gsc and have the following in:
main()
{
	windfx = loadfx ("props/car_glass_large");
	windtrigs = getentarray("windtrig","targetname");
	for(i=0;i<windtrigs.size;i++)
		windtrigs[i] thread dowindow(i,windfx);
}

dowindow(windnumber,windfx)
{
	window = getent(self.target,"targetname");
	totaldamage=0;
	targetdamage=100;
	windowbroken=0;
	broken = getentarray("brokenwindow"+(windnumber+1),"targetname");
	for(j=0;j<broken.size;j++)
	{
		broken[j] notsolid();
		broken[j] hide();
	}
	window show();
	while(!windowbroken)
	{
		self waittill ("damage",amount);
		totaldamage+=amount;
		if(totaldamage>targetdamage)
			windowbroken=1;
	}
//        self playsound("glass_break");
	PlayFX(windfx, self.origin );
	for(j=0;j<broken.size;j++)
		broken[j] show();
	window delete();
	self delete();
}

In your main mp GSC, after maps\mp\_load::main(); add this line:

maps\mp\_breakglass::main();

Now, add this to your Zone File:

rawfile,maps/mp/_breakglass.gsc

Optional

Create a soundalias file for the sound, and uncomment / add your soundname to the self playsound line

If you want to change how much damage it takes to break, change 'targetdamage' in the 'dowindow' routine to another number, at the moment it takes about 3 shots from most weapons.




0 Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

Mega Footer

You can configure this content inside your ACP under Customization > Edit > IPSFocus Mega Footer.

Mega Footer

You can configure this content inside your ACP under Customization > Edit > IPSFocus Mega Footer.

Mega Footer

You can configure this content inside your ACP under Customization > Edit > IPSFocus Mega Footer.

Mega Footer

You can configure this content inside your ACP under Customization > Edit > IPSFocus Mega Footer.