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 → need cog
need cog
2003-02-04, 1:58 PM #1
I need 2 cogs, a breaking glass cog that you can assign health to like for a space ship window so a punch doesnt just shatter it. and a cog so that when a surface is damaged it will create explosions at up to 10 ghost positions
2003-02-04, 2:39 PM #2
Small change(marked in italics), but this is what you're looking for.
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
flex		health=50

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

message		damaged
end

code
damaged:
	health = health - GetParam(0);
	If(health > 0) Return;
        // 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
Enjoy. [http://forums.massassi.net/html/smile.gif] For the second cog, do you want it to be done just once or many times?

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited February 05, 2003).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-02-08, 1:53 PM #3
for the second cog, i want to be able to set the surface that gets damaged. and assign up to 10 objects where a single explosion will occur at each of the 10 objects . just one explosion but i want it to happen each time the surface is damaged . and only if possible make each explosion occur with a delay so they dont all explode at the same time . oh...the object doesnt destroy either i want it to be good for as many times as the person wishes .
2003-02-08, 2:23 PM #4
the breaking glass cog doesnt work
2003-02-09, 12:42 AM #5
I think the cog used by LEC in Fuel Station Launch does exactly what you want.

(The explodable fuel cog I mean.)
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-02-20, 3:09 PM #6
No that one doesnt work for what im trying to do. or maybe im giving it the wrong template :/ grrr

------------------
2003-02-20, 11:51 PM #7
I have an idea for the exploding surface.
I'm no expert on COGs but I'll give it a try.
Code:
# Exploding surface
#
# By Edward
symbols

message    damaged
message    pulse

thing      pos0
thing      pos1
thing      pos2
thing      pos3
thing      pos4
thing      pos5
thing      pos6
thing      pos7
thing      pos8
thing      pos9

template   boom0
# The next 9 booms are optional if you want more than one type of explossion.
template   boom1
template   boom2
template   boom3
template   boom4
template   boom5
template   boom6
template   boom7
template   boom8
template   boom9
#

surface    x

int        p        local
int        b        local
int        n=0      local
int        nob=10

flex       dur

end
#
code
damaged:
        If(GetSenderRef()!=x) return;
        n=0;
        SetPulse(dur);
return;
pulse:
        p=rand()*10;
        b=rand()*10; //If you want more than one type of explossion
        CreateThing(boom0,pos0[p]);
        n=n+1
        if(n==nob) SetPulse(0);
return;
end



Now about the glass, I'm not sure what you really want and I don't know how to do it.

/Edward
Edward's Cognative Hazards

↑ Up to the top!