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 → A Few Cog Requests
A Few Cog Requests
2005-08-23, 2:31 PM #1
Yes, I have a simple cog request. If it wouldn't be too hard, could someone make a cog that does the following:

1) When a surface of glass is shattered, a wav sound plays, and two things move to a new frame to simulate closing doors. They remain here until a new game is started.

2) Please give the "doors" a speed option, for me to specify. Also, this needs to be a multiplayer cog, so it needs to be synched. The wave should play so that everyone in the game can here it.

THis is all for now. THank you! :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-23, 5:28 PM #2
Sounds like a good opportunity to try a new technique for breaking glass I thought of. :)
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-23, 6:33 PM #3
Here's another easy little cog:

When a thing is activated, it:

1) Plays a wave (sound)
2) Gives the player 10 health per activation
3) If the player is already at max health, it gives him 5 shields per activation

This object can only be activated every 5 seconds to prevent abuse from campers.
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-23, 9:03 PM #4
Here's the second one, untested:
http://rafb.net/paste/results/1wOQBB81.html

I added an overflow gizmo so if the player has say, 96 health, when he activates the switch he'll be healed to 100 and the "excess" health, 6 in this case, is added to the shields instead, with this equation: excessHealth * (shields/health) where excessHealth is the amount of overflow and shields and health are the shield and health healing amounts you specify in JED, defaulting to 5 and 10 in this case. So if you had 96 health you would be healed to 100 and 3 would be added to your shields. Or if you had 99 health, you'd get about 4.5 to your shields. Just something nifty I thought of...

Untested, let me know how it works.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 2:59 PM #5
Hmm, I just tried it, and it's not quite working properly yet. I started the level with 100 health, 100 shields, went up to the object, activated it, and proceeded to get 200 shields! That wouldn't be very popular with other players in a MP game! :p

Thankyou, but if you could just find the troublesome line of code and change it so that only 5 shields are added instead of max, I would be very grateful! :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-24, 3:38 PM #6
Hmm, not sure why that would happen...but I did it a little differently...try it now:
Code:
# daft_healer.cog
#
# By Emon, August 2005
#
# Some healing switch for one of Daft Vader's levels.
#
#==============================================================================
symbols
 
thing       switch
sound       sound
flex        delay=5
flex        health=10.0
flex        shields=5.0
flex        volume=1.0
flex        sndMinRad
flex        sndMaxRad
 
int         disabled=0          local
int         channel             local
flex        oldHealth           local
flex        newHealth           local
flex        healthDiff          local
thing       player              local
 
message     activated
message     timer
 
end
#==============================================================================
code
 
#------------------------------------------------------------------------------
activated:
    if(disabled == 1)
        return;
    disabled = 1;
    setTimer(delay);
 
    player = getSourceRef();
    channel = playSoundThing(sound, switch, volume, sndMinRad, sndMaxRad, 0x0);
 
    oldHealth = getThingHealth(player);
    healThing(player, 10000000000000);
    newHealth = getThingHealth(player);
    setThingHealth(player, oldHealth);
    healthDiff = newHealth - oldHealth;
    healThing(player, health);
 
    if(oldHealth == newHealth)
        changeInv(player, 60, shields);
    else
        changeInv(player, 60, healthDiff * (shields/health));
 
    return;
 
timer:
    disabled = 0;
    return;
 
end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 4:08 PM #7
Code:
# Jedi Knight Cog Script
#
# EASY_LITTLE_COG.COG
#
# Tiny Script - Easy Little Cog
#
# 8/24/05 by ReT for Daft_Vader
#
# ========================================================================================

symbols

sound       YourSound=BactaUse01.WAV              local // Whatever you want
thing       player
flex        pause=5
message	    activated
message     timer 


end

# ========================================================================================

code

activated:
   player = GetLocalPlayerThing();
   
   PlaySoundThing(YourSound, player, 1.0, -1, -1, 128);

   if(disabled == 1) 
   {
      Return;
   }
    
   disabled = 1;
   setTimer(pause);

   // If the player health is already max...
   if(GetThingHealth(player) == 100) 
   {
      // Give him 5 shields
      Print("Giving Player 5 Shields...");
      ChangeInv(player, 60, 5);
   }
   else
   {
      // If not...
      Print("Giving the Player 10 Health...");
      HealThing(player, 10.0);
   }

   Return;

# ----------------------------------------------------------------------------------------

timer:
   disabled = 0;
   Return;
 
end


Tested and works just perfectly. :)

ReT
2005-08-24, 4:18 PM #8
You're assuming the max health is 100, which can change with mods.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 5:08 PM #9
Thanks Emon, I don't know what you did differently, but the new one works fine now. Thankyou as well ReT, but Emon's is adequate. :)

Also, about the breaking glass cog, could you please make that sector pulse red light for 3 flashes when the glass is broken AND play 2 wavs instead of just one (1 wav is an alarm loop which only loops once and the second is some dialogue).
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-24, 5:41 PM #10
Sure. I'm in the process of making a generic breaking glass COG, one far more realistic than JK's. May take a while but the effect will be *well* worth it, trust me. :)
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 5:46 PM #11
Originally posted by Emon:
Sure. I'm in the process of making a generic breaking glass COG, one far more realistic than JK's. May take a while but the effect will be *well* worth it, trust me. :)

Great! I've got until Saturday for this! :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-26, 2:17 PM #12
Emon? I need this by Sunday afternoon please. :o
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-26, 2:48 PM #13
Yeah, working on it. If I can't get it done soon I'll just use the original breaking glass COG. This for a contest deadline?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-26, 5:02 PM #14
Originally posted by Emon:
Yeah, working on it. If I can't get it done soon I'll just use the original breaking glass COG. This for a contest deadline?

Yep. And as for the models, don't worry ablout them. I've got some software to convert a few myself, but they are insanely detailed and aren't textured, which would be a serious pain. :(
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-26, 5:49 PM #15
I got the models imported just fine, but I can't get the exporter working. On anything. Even new models. You could ask ZANARDI to try, he seems eager.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-26, 8:22 PM #16
Originally posted by Emon:
You could ask ZANARDI to try, he seems eager.

Never! :D
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-28, 12:41 AM #17
Here's your glass COG. The sector tint fading lengths are (somewhat) hardcoded so it may not look as nice for longer alarm WAVs and such without a little modification. But it should work perfectly for you.

Code:
# Jedi Knight Cog Script
#
# daft_glass.COG
#
# Breaking glass for Daft Vader.
#
# 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

sound     dialogue
flex      dialogue_volume
sound     alarm
flex      alarm_volume
flex      alarm_minRad
flex      alarm_maxRad
flex	  alarm_delay
sound     glass_break=GlassBreak1.WAV   local

sector	  tint_sector
vector    tint_rgb

thing     door1
thing     door2
flex	  door_speed

vector	  orig_tint						local
flex	  z								local

vector    surface_center                local
vector    vertex                        local
vector    where                         local

int       spawnpoints=2                 desc=spawn_points
int       density=5                     desc=density
int       surface_sector                local
int       surface_vertices              local
int       i                             local
int       j                             local
int		  n								local
flex      k                             local
int       a_shard                       local
int       dummy                         local
int       disabled=0                    local

template  shard_tpl=shard00             local

message   damaged
message   pulse
message   timer

end
#==============================================================#
code
#------------------------------------------------------
damaged:
	if(!disabled)
	{
		disabled = 1;
		// 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);
		
		PlaySoundGlobal(dialogue, dialogue_volume, 0, 0x0);
		moveToFrame(door1, 1, door_speed);
		moveToFrame(door2, 1, door_speed);
		i = 0;
		j = 0;
		orig_tint = getSectorTint(tint_sector);
		setPulse(0.01);
	}

Return;
#------------------------------------------------------
pulse:
	setSectorTint(tint_sector, tint_rgb);
	setTimer(0.001);
	playSoundPos(alarm, surface_center, alarm_volume, alarm_minRad, alarm_maxRad, 0x0);
	if(i == 2)
	{
		setPulse(0);
		sleep(getSoundLen(alarm));
		setTimer(0);
		setSectorTint(tint_sector, orig_tint);
		return;
	}
	i = i + 1;
	setPulse(getSoundLen(alarm) + alarm_delay);
	return;

timer:
	setSectorTint(tint_sector, vectorScale(getSectorTint(tint_sector), 0.95));
	setTimer(0.001);
	return;
	
end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-28, 10:27 AM #18
Thanks, I'll try it out now.
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-28, 11:35 AM #19
Hmm, the doors don't seem to be moving :/
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-28, 11:53 AM #20
Originally posted by Daft_Vader:
Hmm, the doors don't seem to be moving :/

Actually, don't worry about it. I don't have time now, it's ok.
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-08-28, 12:08 PM #21
Make sure your doors have two frames. The first frame (frame 0) should be the starting position, the second frame (frame 1) should be the destination. I used 1 for the frame number thinking you would make the doors like any normal doors...I guess you only used 1 frame instead?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-28, 5:59 PM #22
Hmmm, for some strange reason it seems to be working now! SWEET! :D :D :D :D :D
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels

↑ Up to the top!