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 cog help
breaking glass cog help
2003-03-19, 1:23 AM #1
ok i have modified the breaking glass cog and its not working. I want the pane of glass to break if it is damaged or if two other panes of glass and get broken. The only problem is, is my cog does nothing so find my mistakes someone.

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
surface      adj1                                                   
surface      adj2                                                   
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                         
int          modeflag                           local                         
int          modeflag2                          local                         

template     shard_tpl=shard00                  local                         
sound        glass_break=GlassBreak1.WAV        local                         
message      startup                                                          
message      damaged                                                          
message      pulse                                                            

end                                                                           

code

startup:
setpulse(.1);
return;

damaged:
Print("Ouch I've been 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;

pulse:
modeflag = GetFaceGeoMode(adj1);
modeflag2 = GetFaceGeoMode(adj2);
if(modeflag & modeflag2 = 0)
{
Print("Destroying");
call damaged;
}
else
{
Print("Not this time!");
}
return;

end




------------------
roses are red, violets are blue, I am schizophrenic, and so am I!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-03-19, 9:51 AM #2
Just by scanning it for syntax, change
Code:
if(modeflag & modeflag2 = 0)

to
Code:
if(modeflag & modeflag2 == 0)


Fix that and then try debugging...

------------------
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-03-19, 4:06 PM #3
yeah i noticed that but its not the prob, it doesn't even get there, for some reason the cog won't do anything, i put a print in the startup and it didn't print. and i've checked like 8 times to make sure i had the cog in the level corectly, i even gobbed the thing! but i've been away from jk editing for a long long time, so just to make sure i am doing it right, how do you implement custom cogs?

------------------
roses are red, violets are blue, I am schizophrenic, and so am I!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-03-19, 11:07 PM #4
Did you notice who you were talking to, son?

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2003-03-20, 3:48 AM #5
Do the adj1 and adj2 surfaces have their own breakingglass cog? And the pulse message added to your cog is to check to see if the damaged message in the other breakingglass cog has run? Then it would be alot more elegant if the other breakingglass cog, sent a message to your cog to break the glass.

But that's aside from the problem. Make sure your cog is set up correctly in the level - your syntax looks alright. If all else fails, send me the level. [http://forums.massassi.net/html/wink.gif]

Code:
but i've been away from jk editing for a long long time


I know the feeling. It's great to be back. [http://forums.massassi.net/html/smile.gif] Though I admit I no longer have 8 hours a day to spend on JK... [http://forums.massassi.net/html/frown.gif]

------------------
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-03-20, 5:59 AM #6
He's back...HE'S BACK!!!

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2003-03-20, 8:57 AM #7
hi welcom back, i think i forght you on MSM zone, or was that another sabermaster?

------------------
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-03-20, 11:22 AM #8
One thing you can add (when it's working) is to have the pulse message stopped once the glass is damaged.

------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2003-03-20, 2:19 PM #9
thanks sylv good idea. yeah i have the other two with breakingglass00 or whatever. the reason i don't have the other cogs send it and be more elegant is.... because.... i sort of can't remember how to do triggers for jk. i tried and horribly messed up so i decided to try and easier route. maybe i'll try again

------------------
roses are red, violets are blue, I am schizophrenic, and so am I!
roses are red, violets are blue, I am schizophrenic, and I am too!

↑ Up to the top!