Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Breaking Glass
Breaking Glass
2003-04-04, 7:57 AM #1
I know there's a tutorial on making glass break(as well as respawn) on Massassi, but I want glass to break when a player hits it, too. Is this possible? It's for a rolling mod...I think it'd be a nice touch. Thanks.

------------------
-Omni

http://www.tribalspherex.net/
2003-04-04, 9:53 PM #2
Er... for a rolling level, actually. Sorry...and also, if it's not much trouble(and if you care enough to, I wouldn't really care either way), could you make it damage health just slightly somehow? Thanks.
2003-04-05, 10:54 AM #3
Post the cog you're using.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-04-05, 11:02 AM #4
Er..it's 00_breakingglass.cog, the standard breaking glass one. I'm following the tutorial on here. If you want me to actually post the whole cog, I will, just later. I'm in a bit of a hurry now. Thanks.
2003-04-05, 4:59 PM #5
Here it is:
Code:
# Jedi Knight Cog Script
#
# 00_BREAKINGGLASS.COG
#
# Generic breaking glass script to be linked to both sides
# of a breakable glass pane.
#
# Note: the template used is shard00, NOT shard0 !
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

symbols
surface		glass			mask=0x448	desc=glass
surface		glass2			mask=0x448	desc=glass_adjoin
int		spawnpoints=2				desc=spawn_points
int		density=5				desc=density

vector		surface_center				local
int		surface_sector				local
int		surface_vertices			local
vector		vertex					local
vector		where					local
int		i					local
int		j					local
int		k					local
int		a_shard					local
int		dummy					local

template	shard_tpl=shard00			local
sound		glass_break=GlassBreak1.WAV      	local

message		damaged
end

code
damaged:
        // Add 10 cm along the normal to solve some rounding error or non planar face...
        surface_center = VectorAdd(SurfaceCenter(GetSenderRef()), VectorScale(GetSurfaceNormal(GetSenderRef()), 0.01));
	surface_sector = GetSurfaceSector(GetSenderRef());
	surface_vertices = GetNumSurfaceVertices(GetSenderRef());
        
        dummy = PlaySoundPos(glass_break, surface_center, 1.0, 10.0, 20.0, 0);

        // First spawn 'density' shards with random velocities at the center of the face.
	for(k=0; k<density; k=k+1)
	{
	 a_shard = CreateThingAtPos(shard_tpl, 
				    surface_sector,
				    surface_center,
				    '0.0 0.0 0.0');         
	 SetThingVel(a_shard, VectorSet( 1.4*(Rand()-0.5), 1.4*(Rand()-0.5), 1.4*(Rand()-0.5) + 0.75 ));
         SetThingRotVel(a_shard, VectorSet(500*(Rand()-0.5), 500*(Rand()-0.5), 500*(Rand()-0.5) ));
	}

        // Then spawn 'density' shards with random velocities at 'spawnpoints' points
        // between the center of the face and the face's vertices.

	for(i=0; i<surface_vertices; i=i+1)
	{
	 vertex = GetSurfaceVertexPos(glass, i);
	 for(j=1; j<=spawnpoints; j=j+1)
	 {
	  where = VectorAdd(surface_center, 
			    VectorScale(VectorSub(surface_center, vertex), j/(spawnpoints+1))
			   );
	  for(k=0; k<density; k=k+1)
	  {
	   a_shard = CreateThingAtPos(shard_tpl, 
				      surface_sector,
				      where,
				      '0.0 0.0 0.0');
	   SetThingVel(a_shard, VectorSet( 1.4*(Rand()-0.5), 1.4*(Rand()-0.5), 1.4*(Rand()-0.5) + 0.75 ));
           SetThingRotVel(a_shard, VectorSet(500*(Rand()-0.5), 500*(Rand()-0.5), 500*(Rand()-0.5) ));
	  }
	 }
	}

	SetFaceGeoMode(glass, 0);		// GEOMETRY_NONE
	SetFaceGeoMode(glass2, 0);
	SetAdjoinFlags(glass, 2);		// Set ADJOIN_MOVE  (allow passage)
	SetAdjoinFlags(glass2, 2);

	Return;
end


------------------
-Omni

http://www.tribalspherex.net/
2003-04-05, 5:05 PM #6
And I might even wanna make it respawnable....but that dang regenerating glass tutorial doesn't help.
2003-04-06, 12:18 AM #7
well i see it like this, make a cog based on that one, so that when you cross a ajoin just infrount of the glass, it brakes the glass and damages the player, unfortuantly altho i probley could make such a cog, its too mutch bother. i woudl sepend hours in the JK specks and sutch, just to find someone else had posted a better cog first.

------------------
I am pjb.
Another post......
another moment of my life wasted.....
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-04-06, 4:22 AM #8
Try this....
Add a touched message and add the shatter there. If you want the player to get hurt, make sure the glass doesn't have the No Damage From Fall flag on!
About the respawning, ask someone else...
Edward's Cognative Hazards
2003-04-06, 3:11 PM #9
I should put something in my sig declaring that I'm not a cogger...I just can't make sense of the stuff. But, I got it anyway. Heeb helped me out and modified one a bit. Much thanks to him.
2003-04-07, 5:58 PM #10
If you wan't the shards to cause damage, just open your template, change type to "weapon", and add damage=x.xxx (maximum damage you want). I'm pretty sure that should do it. (don't forget to reload templates before testing!)

------------------
May the forks be with you.
AOL - providing excellent internet connection until you leave their domain.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music

↑ Up to the top!