So here goes, this will also work for any texture or even models.
Mapping
-Create the glass you wish to destroy.
-Make this into a "Script<Brushmodel"
-Give it these values
Code: Select all
Key - targetname
Value - glass_01
-Make the trigger a "Trigger<Damage"
-Give it these values
Code: Select all
Key - targetname
Value - trig_glass_01
Scripting
This is the GSC that you will need to use, look for the comments after the // on each line.
Code: Select all
main()
{
thread glass_break_01(); //This will load the 1st breakable glass therad
thread glass_break_02(); //this does the same as above, but is only needed if you have a second piece of glass
//Add more threads here if you have more glass.
}
glass_break_01() //This is laoded from the above
{
glass_01 = getent("glass_01","targetname"); //This will find the 1st piece of glass
trig_glass_01 = getent("trig_glass_01","targetname");//This will find the trigger for the 1st piece of glass
dmg_01 = 0; //This will set the amount of damage for the glass, do not change!
hp_01 = 120; //This is the amount of damage needed to break the glass
//Kar98k and snipers do 120 damage, so this will take 1 shot from the kar98k.
while(dmg_01 < hp_01) //This will create a loop while the damage is less than the amount to destroy the glass.
{
trig_glass_01 waittill ("damage", idmg); //This will wait for the glass to take damage
dmg_01 += idmg; //This is will count the damage taken
if (dmg_01 >= hp_01) //This will wait until the damage taken is equal of higher than the hitpoints
{
glass_01 delete(); //This will delete the glass
trig_glass_01 delete(); // This will delete the trigger for the glass
}
}
}
//The following is exactly the same as above, but all details have been changed from _01 to _02.
//Make sure you double check this as 1 typo will cause the thread to fail
//and possibly cause the wrong things to happen.
glass_break_02()
{
glass_02 = getent("glass_02","targetname");
trig_glass_02 = getent("trig_glass_02","targetname");
dmg_02 = 0;
hp_02 = 120; // this is the amount of damage the glass needs to break
while(dmg_02 < hp_02)
{
trig_glass_02 waittill ("damage", idmg);
dmg_02 += idmg;
if (dmg_02 >= hp_02)
{
glass_02 delete();
trig_glass_02 delete();
}
}
}
Making Models that Break
Exactly the same as above, accept in stead of using a brush and script<brushmodel you will need to use a model and script<model. A quick run though -
-Create the model you wish to destroy.
-Make this into a "Script<model"
-Give it these values
Code: Select all
Key - targetname
Value - glass_01
-Make the trigger a "Trigger<Damage"
-Give it these values
Code: Select all
Key - targetname
Value - trig_glass_01
Have Fun
