Breakable Anything

Tutorials for Call of Duty mapping

Moderator: Core Staff

Post Reply
User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Breakable Anything

Post by Drofder2004 » September 30th, 2005, 5:47 pm

Ok, someone has asked me to make a quick tutorial on breaking glass.
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
-Now make the trigger. To make the glass break from any direction, you must surround the glass by the trigger. For best results, make the trigger 1 unit bigger on all sides.
-Make the trigger a "Trigger<Damage"
-Give it these values

Code: Select all

Key - targetname
Value - trig_glass_01
Keep doing this until you have all the panes of glass you wish to destroy, but make sure you change the targetnames to the corresponding number, e.g glass_02 and trig_glass_02.

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();
		}
}
}
Save that as the gsc, and you are ready to go.

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
-Now make the trigger. To make the glass break from any direction, you must surround the glass by the trigger. For best results, make the trigger 1 unit bigger on all sides.
-Make the trigger a "Trigger<Damage"
-Give it these values

Code: Select all

Key - targetname
Value - trig_glass_01
You may want to change the targetnames, but be sure to change them in the script.

Have Fun :)
Last edited by Drofder2004 on August 9th, 2006, 8:21 pm, edited 2 times in total.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

.

Post by Pwn-Rikku » October 2nd, 2005, 9:08 am

could u make a barrel explode with a explosion? or make a glass wall appear 10 secs after blown up?
rikku
Rikku - Old skool
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » October 2nd, 2005, 4:57 pm

Yes to the barrels, just follow the tutorial and I will post later how to add the effects of it being blown up.

As for making a glass wall appear, i'm not sure why you would want to. Explain further, I think I may have an answer for it...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

hm

Post by Pwn-Rikku » October 3rd, 2005, 5:39 pm

i want the glass to appear again for my map. from the start u shoot at the thing with a panzer if u dont u die in the trigger which gets turned off by shooting it so like a time trial sorta thing shoot it explodes and jump over as quick as u can!
and also i spoted a error in the tut. u name the glass to be
key: Targetname
Value: Glass_01
when in the script your talking about Glass_break_01 i think this is a problem but look into it further i dont no :S
rikku
Rikku - Old skool
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: hm

Post by Drofder2004 » October 3rd, 2005, 6:16 pm

Pwn-Rikku wrote:i want the glass to appear again for my map. from the start u shoot at the thing with a panzer if u dont u die in the trigger which gets turned off by shooting it so like a time trial sorta thing shoot it explodes and jump over as quick as u can!
and also i spoted a error in the tut. u name the glass to be
key: Targetname
Value: Glass_01
when in the script your talking about Glass_break_01 i think this is a problem but look into it further i dont no :S
rikku
You can hide it and/or make it non solid...
Instead of delete, use these commands, do nothing to the trigger though.

Replace

Code: Select all

{
   trig_glass_01 waittill ("damage", idmg);
   dmg_01 += idmg;
   if (dmg_01 >= hp_01)
      {
      glass_01 delete();
      trig_glass_01 delete();
      }
}
}
with this...

Code: Select all

{
   trig_glass_01 waittill ("damage", idmg);
   dmg_01 += idmg;
   if (dmg_01 >= hp_01)
{
glass_01 hide();
glass_01 notsolid();

wait 10;

glass_01 show();
glass_01 solid();
}
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

k

Post by Pwn-Rikku » October 3rd, 2005, 6:17 pm

drofder look at my other post i have fixed the code so it works for me :)
rikku
Rikku - Old skool
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: hm

Post by Drofder2004 » October 3rd, 2005, 6:18 pm

Pwn-Rikku wrote: and also i spoted a error in the tut. u name the glass to be
key: Targetname
Value: Glass_01
when in the script your talking about Glass_break_01 i think this is a problem but look into it further i dont no :S
rikku
Glass_01 is the targetname of an object.
Glass_Break_01 is the title of a thread.

2 different names so I do not get confused.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

lol

Post by Pwn-Rikku » October 3rd, 2005, 6:19 pm

lol drofder it didnt work with them scripts i had to change it all and it works for me??!?
rikku
Rikku - Old skool
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: lol

Post by Drofder2004 » October 3rd, 2005, 6:28 pm

Pwn-Rikku wrote:lol drofder it didnt work with them scripts i had to change it all and it works for me??!?
rikku
http://rapidshare.de/files/5834634/glass_test.pk3.html

Proof of working code ;)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

lol

Post by Pwn-Rikku » October 3rd, 2005, 6:30 pm

well i cant see the proof i got a proxy server or summat so i cant download from that thing
which is reaaaaaaaaaaaaly gay coz everybody hosts it on that and i want soviets mod but
its on that website!!
rikku
Rikku - Old skool
Image
Image

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » October 24th, 2005, 12:51 pm

How do you make things breakable without scripting? i tried this tut http://www.modsonline.com/Tutorials-read-117.html but couldnt get it to work.

As an example of what i want to make, try mp_glassattack @ 82.204.3.242:28960

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » October 24th, 2005, 1:52 pm

Sorry, someone else wanted to attempt the same thing, and I have no idea how thye done it tbh. But that tutorial is the only answer (it does work, I have used it before). Just try it again, and make sure you follow the steps exactly.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest