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
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.
# 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
For the second cog, do you want it to be done just once or many times?# 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