Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 78 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 MP Mapping
CoD 4 mapping and level design for multiplayer.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: grenades & breakable glass
k00lbr33ze
General Member
Since: Jun 17, 2009
Posts: 121
Last: Dec 13, 2011
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Tuesday, Sep. 6, 2011 12:41 pm
Hi guys,

I have my my windows set up to shatter when hit with bullets or with melee weapons.

What can I change on my trigger to allow grenades/flashbangs to be thrown through the glass pane?

My trigger currently has the following attributes:

Code:

classname   trigger_damage
target           auto4
targetname  windtrig


Glass pane has the attributes:
Code:

classname   script_brushmodel
target           auto4


Or maybe forward me to information on this...

Again, thanks in advance for everyone's help.

edited on Sep. 6, 2011 10:27 am by k00lbr33ze

edited on Sep. 6, 2011 10:27 am by k00lbr33ze
Share |
cskiller86
General Member
Since: Nov 23, 2009
Posts: 528
Last: Oct 25, 2011
[view latest posts]
Level 6
Category: CoD4 MP Mapping
Posted: Tuesday, Sep. 6, 2011 04:24 pm
What do you mean to be thrown through ? You don't want the grenades to collide with the glass ? Just pass through it ? 'Cause it's not very realistic...
Share |
k00lbr33ze
General Member
Since: Jun 17, 2009
Posts: 121
Last: Dec 13, 2011
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Tuesday, Sep. 6, 2011 05:21 pm
I would like the grenades to break the glass when it's thrown through a window pane.

Right now they just bounce off, though I can break glass panes with a melee.

edited on Sep. 6, 2011 02:47 pm by k00lbr33ze
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Wednesday, Sep. 7, 2011 05:28 am
When I run my breakable glass scripts, I use the line:

Code:
self enablegrenadetouchdamage(targetdamage);


But, the way you are doing it, I don't know if "enablegrenadetouchdamage" will do anything. I find it easier to use scripts instead of K/V's only. Check the K/V list above, in your entity editor, when you have your trigger selected, to see if you have any options to input.

If you are using a script and I'm mistaken, just post the script so we can plug in the right line so it works. I do know that you have to be at the right angle ingame for the grenade to actually pass through the window, otherwise the nade just breaks the glass but bounces back at you.
Share |
k00lbr33ze
General Member
Since: Jun 17, 2009
Posts: 121
Last: Dec 13, 2011
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Wednesday, Sep. 7, 2011 10:21 am
Thanks for the feedback deek...

Quote:

But, the way you are doing it, I don't know if "enablegrenadetouchdamage" will do anything. I find it easier to use scripts instead of K/V's only. Check the K/V list above, in your entity editor, when you have your trigger selected, to see if you have any options to input.


Not exactly sure what K/V means but guessing by your post those are the check boxes on the entity. I didn't use them since they disable damage from the following if they are selected.

pistol_no, rifle_no, proj_no, explosion _no

Quote:

If you are using a script and I'm mistaken, just post the script so we can plug in the right line so it works. I do know that you have to be at the right angle in game for the grenade to actually pass through the window, otherwise the nade just breaks the glass but bounces back at you.


I am using _breakglass.gsc for the glass. I added the line where I thought it should be...if it's wrong, please let me know

Code:

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();

/*
   new line for grenade breaking the window
   figured this is the spot for this, if wrong please let me know
*/
        self enablegrenadetouchdamage(targetdamage);

// end new line

	while(!windowbroken)
	{
		self waittill ("damage",amount);
		totaldamage+=amount;
		if(totaldamage>targetdamage)
		{
			windowbroken=1;
		}
	}
        self playsound("glass_break");
	PlayFX(windfx, self.origin );
	if(broken.size)
	{
		for(j=0;j<broken.size;j++)
		{
			broken[j] show();
		}
	}
	window delete();
	self delete();
}
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Wednesday, Sep. 7, 2011 07:38 pm
Your welcome. Also K/V just stands for "Key / Value" I just thought you were doing all your stuff with just using the entity editor and K/V's. Sorry about that, I shouldn't assume.

Well, I moved the line up a little bit. Give that a try.

Code:
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;
	self enableGrenadeTouchDamage(targetdamage);
	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, attacker, direction_vec, point);
		totaldamage += amount;
		
		if (totaldamage > targetdamage)
		{
			windowbroken = 1;
		}
	}
	self playsound ("glass_break");
	PlayFX (windfx, self.origin );
	
	if (broken.size)
	{
		for (j = 0; j < broken.size; j++)
		{
			broken[j] show();
		}
	}
	window delete();
	self delete();
}



Like I said, it will break the glass no matter what, because it says it takes 100 health from the glass, but in order to actually pass through the glass when thrown, you have to be at the right angle, and the angle is never the same, its dumb, I know. The game is weird like that. Otherwise it breaks the glass and bounces back. I don't think flash bangs or smoke grenades do anything to the glass.
Share |
k00lbr33ze
General Member
Since: Jun 17, 2009
Posts: 121
Last: Dec 13, 2011
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Thursday, Sep. 8, 2011 03:08 pm
Hey Deek,

Quote:
I do know that you have to be at the right angle ingame for the grenade to actually pass through the window, otherwise the nade just breaks the glass but bounces back at you.


This works exactly as you described. I couldn't find the right angle to throw the nade THROUGH the window.

Is there a .gsc where the function enableGrenadeTouchDamage(targetdamage) is located?

I saw the ones for _flashgrenades.gsc & _teargrenades.gsc but didn't see 1 for grenades...

Kinda curious to see what the code looks like if there is such a file...

edited on Sep. 8, 2011 11:10 am by k00lbr33ze
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Thursday, Sep. 8, 2011 10:54 pm
Well, it's just a function the game uses. You can look at the example here: Zeroy's COD Scripting Reference

Scroll down on the left to Weapons and find/click on "enablegrenadetouchdamage"

Here is what it looks like:

Code:
EnableGrenadeTouchDamage()
Module: Weapons

Summary:
enable grenade damage for damage triggers


Call this on:
A damage trigger entity


Example:
 self EnableGrenadeTouchDamage();




self enableGrenadeTouchDamage(targetdamage);

The use of "targetdamage" is just a variable used in the breakable glass script. You've defined it as the most damage the glass can take, at 100.

totaldamage = 0;
targetdamage = 100;
windowbroken = 0;

So, you are telling the script to say, if the grenade hits the glass, let's take 100 points of damage from the window. Essentially, let's break it. That's all that "targetdamage" is doing here in this case.

Is there a script, this function is used, other than this one? I don't know. I had to search other mappers and modders scripts to find out how to use this function, so I could plug it into my breakable glass script.

The angle is either throwing up at the window or down. You almost have to throw it on and angle and not straight on, and by luck, you'll get it to go through and I don't know why it doesn't happen all the time. Maybe if you shoot a bullet through it, then throw a grenade, it will just go through. You'll have to run some tests. Maybe it doesn't work on a fresh window, maybe it needs to have a little bit of damage taken already. I just remember I had to throw it on an angle to go through. Never ran any extensive tests.

I don't know if this is what you are looking for, but it's all I got. [crazy]
Share |
k00lbr33ze
General Member
Since: Jun 17, 2009
Posts: 121
Last: Dec 13, 2011
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Thursday, Sep. 8, 2011 11:34 pm
DeekCiti writes...
Quote:

I don't know if this is what you are looking for, but it's all I got. [crazy]


Again, thanks for the tip!

Not quite what I was going for, but it definitely has been very helpful...

I'm gonna try to use this method (breakable door) similar to this 1 & see if I can get the result I'm looking for.

After all, I would like to leave some glass shards along the window pane...bit more tedious, but folks don't like half ar$ed maps

edited on Sep. 8, 2011 07:39 pm by k00lbr33ze
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 MP Mapping
Posted: Friday, Sep. 9, 2011 05:16 am
What you could do is make some stage breaking glass. Where it cracks first and then shatters, leaving behind shards on the window frame. [cool]

I've attached two files in a zip, the script and a prefab to look at. All you do is make three stages of the glass and stack them on top of each other. The prefab has one pulled apart so you can see the stages, and one stacked together to how it should look when you're complete.

Normal > Shattered > Broken

The script I have for this just hides the stages at a given point. Maybe you're interested in this instead. I think it's much better and easier than the two options in your links.

This is the script. You can change the targetname of "window_trigs" if you need to.

Code:
main()
{
	level.windfx = loadfx ("props/car_glass_large");
	
	windows = getEntArray ("window_trigs","targetname");
	for(i=0; i<windows.size; i++)
	{
		windows[i] thread dowindow();
	}
}

dowindow()
{
	targetdamage = 120;
	totaldamage = 0;
	
	WindowShattered = false;
	WindowBroken = false;
	
	self enablegrenadetouchdamage (targetdamage);
	
	NormalState = getEnt (self.target,"targetname");
	ShatteredState = getEnt (NormalState.target,"targetname");
	BrokenState = getEnt (ShatteredState.target,"targetname");
	ShatteredState hide();
	BrokenState hide();
	
	while (!windowbroken)
	{
		self waittill ("damage", amount, attacker, direction_vec, point, type);
		totaldamage += amount;
		
//		iprintlnbold ("Amount: " + amount);
//		iprintlnbold ("Total: " + totaldamage);
//		iprintlnbold ("Target: " + targetdamage);
		
		if (totaldamage > targetdamage || getdamagetype(type) == "melee")
		{
			WindowBroken = true;
		}
		if (!WindowShattered)
		{
			NormalState delete();
			ShatteredState show();
			WindowShattered = true;
		}
	}
	BrokenState show();
	self playSound ("glass_break");
	PlayFX (level.windfx, BrokenState.origin);
	ShatteredState delete();
	self delete();
}

getDamageType(type)
{
	if (!isdefined(type))
	{
		return "unknown";
	}
	type = tolower(type);
	switch(type)
	{
		case "mod_melee":
		case "mod_crush":
		case "melee":
		{
			return "melee";
		}
		default:
		{
			return "other";
		}
	}
}


1. Create all three stages of the glass.

2. Create trigger_damage, and give it the targetname used in your script.

4. Select trigger first, (W) link it to the "Normal stage", Deselect everything. Then select Normal Stage first, and (W) link it to "Shattered stage", Deselect everything. Then select Shattered stage first and (W) link it to the "Broken Stage".

3. Stack all stages and trigger on top of each other as they would need to be broken ingame.

4. Run the script, just like any other script.


It looks good ingame. If you want to play with some Debugging lines, so you can see the damage take place ingame, to get your window health where you want it, there are three lines in the script you just have to uncomment. Don't forget to comment them again when you release the map. Some people forget.

// iprintlnbold ("Amount: " + amount);
// iprintlnbold ("Total: " + totaldamage);
// iprintlnbold ("Target: " + targetdamage);



I forgot to attach them so check the next post. It won't let me edit post and attach.
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 MP Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»