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 → I need some help with SetAdjoinFlags and SetSurfaceFlags!
I need some help with SetAdjoinFlags and SetSurfaceFlags!
2002-08-04, 7:26 AM #1
I have designed a cog to create a translucent bridge. However, the flags are not all quite how I want them, and I wonder if anyone can help? I have two two main problems - how can I stop the walkplayer sinking into the bridge surface? And whycan any AI that crosses the bridge keep crossing even if you turn off the bridge while they are halfway?

Code:
#!/usr/bin/perl 
# 
# Jedi Knight Cog Script
#
# energy_bridge_basic.cog
#
# this script activates an energy bridge when a switch is activated or damaged.
# It sets the surface to be a floor and translucent.
# Shooting or activating switch will turn it off (but only when AIs shoot)
# Adapted from 10_ffieldswitch.cog
#
# This COG is not supported by Lucasfilms Entertainment
#
# 


symbols

message     startup
message     damaged
message     activated

message     timer

surface     switch                        linkid=1 mask=0x448
surface     energysurf                       mask=0x408
surface     energysurf2                      mask=0x408
surface	energysurf3			  mask=0x408
                


sound       bridgeon=forcefieldon01.wav		local
sound       bridgeoff=forcefieldoff01.wav		local
sound       bridgehum=forcefieldhum01.wav		local
sound       bridgehit=forcefieldhit01.wav		local

end


code
startup:
      	SetWallCel(switch,0);                 	//off
      	SetAdjoinFlags(energysurf,0);              	//passable
      	SetAdjoinFlags(energysurf2,0);
      	SetAdjoinFlags(energysurf3,0);
   	SetFaceGeoMode(energysurf,0);          	//see through
  	SetFaceGeoMode(energysurf2,0);
  	SetFaceGeoMode(energysurf3,0);

   	PlaySoundPos(bridgehum, GetSurfaceCenter(energysurf), 1.0, 1, 10, 0x1);

   	return;

activated:
   	if (GetSenderID() != 1) return;

   	if (GetWallCel(switch) == 0)
      	{
   		SetWallCel(switch,1);               	//on
   		SetAdjoinFlags(energysurf,0x10);          	//impassable
   		SetAdjoinFlags(energysurf2,0x10);
   		SetAdjoinFlags(energysurf3,0x10);
      		PlaySoundLocal(bridgeon, 1, 0, 0);
   		SetFaceGeoMode(energysurf,0x4);          	//translucent/shows texture
  		SetFaceGeoMode(energysurf2,0x4);
  		SetFaceGeoMode(energysurf3,0x4);
		SetFaceType(energysurf,0x6);		// or maybe this makes translucent?
		SetFaceType(energysurf2,0x6);
		SetFaceType(energysurf3,0x6);
   		SetSurfaceFlags(energysurf,0x5);       	// floor
		SetSurfaceFlags(energysurf2,0x5);
   		SetSurfaceFlags(energysurf3,0x5);
      	}
   	else if (GetWallCel(switch) == 1)
      	{
      		PlaySoundLocal(bridgeoff, 1, 0, 0);
     		SetWallCel(switch,0);            		//off
      		ClearAdjoinFlags(energysurf,0x10);       	//passable
      		ClearAdjoinFlags(energysurf2,0x10);
      		ClearAdjoinFlags(energysurf3,0x10);
   			SetFaceGeoMode(energysurf,0);          	//no texture
  			SetFaceGeoMode(energysurf2,0);
  			SetFaceGeoMode(energysurf3,0);
  			SetSurfaceFlags(energysurf,0);       	//no floor
			SetSurfaceFlags(energysurf2,0);
   			SetSurfaceFlags(energysurf3,0);
      	}
   		return;

fieldflash:
      	SetFaceGeoMode(energysurf,4);		// Energy bridge reacts when hit by weapon
      	SetFaceGeoMode(energysurf2,4);
      	SetFaceGeoMode(energysurf3,4);
	SetFaceType(energysurf,0);		// or maybe this makes it appear solid for a moment?
	SetFaceType(energysurf2,0);
	SetFaceType(energysurf3,0);	
		KillTimerEx(1);
     		SetTimerEx(0.5, 1, 0, 0);
     		return;

damaged:
	if (GetWallCel(switch) == 1) return;

	if (GetSenderID() == 1)
   		{
      		call activated;
   		}
   	else
   		{
      		call fieldflash;
   		}

   	return;

timer:
   	SetFaceGeoMode(energysurf,4);			// Returns bridge to translucent
   	SetFaceGeoMode(energysurf2,4);
   	SetFaceGeoMode(energysurf3,4);
	SetFaceType(energysurf,0x6);		// or maybe this makes translucent?
	SetFaceType(energysurf2,0x6);
	SetFaceType(energysurf3,0x6);
   	Return;

end

2002-08-04, 7:45 AM #2
Someone's proud of their perl scripting. [http://forums.massassi.net/html/tongue.gif] And I doubt Lucasfilm has anything to do
with cogscripts!

Anyways, I'll fix the cog up, test it, and then post it here. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 04, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-04, 8:48 AM #3
I feel SaberMasters going to use For statements, and many of them. [http://forums.massassi.net/html/tongue.gif]

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

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-04, 9:08 AM #4
Sorry, Sabermaster! I didn't know how the UBB code thing worked, so I pasted in that perl bit too by accident from the UBB page! [http://forums.massassi.net/html/redface.gif] However, I will stand by my warning about Lucasfilm - for all we know, while Lucasarts don't support cogs, Lucasfilm may actively be seeking out and destroying coggers who cross their path ... [http://forums.massassi.net/html/smile.gif]
2002-08-04, 10:50 AM #5
Perhaps, Rob. [http://forums.massassi.net/html/wink.gif]

Here's the cog:
Code:
# energybridge.cog
#
# This cog controls an energy bridge that can be turned on and off by a switch.
# Also, a player can turn the bridge on by damaging the switch, and actors can
# turn the bridge both on and off by damaging the switch. Damaging the bridge
# itself will cause it to fade.
#
# The bridgetop surfaces are for the top of the bridge - these belong to the sector
# above the bridge. The bridgebottom surfaces are for the underside of the
# bridge - these are from the sector below the bridge. The difference is that
# the bridgetop surfaces will become floor when the bridge is on.
#
# numBridgePairs is the number of corresponding top and bottom surfaces.
# So if you have three top surfaces and three bottom surfaces, then you should
# enter three for this number. There should be a matching bottom surface for
# every top surface and vice versa.
#
# When the bridge is turned off, all things in the bridge's sector are detached
# so that they'll fall through the bridge if they're on it.
#
# [RW + SM]
#==============================================================#
symbols

message   startup
message   damaged
message   activated
message   crossed
message   timer

int       on
int       numBridgePairs
int       damaging=0                      local
int       i                               local

thing     actor                           local

sector    bridgesec

surface   switch                          mask=0x448
surface   bridgetop0                      mask=0x448
surface   bridgetop1                      mask=0x448
surface   bridgetop2                      mask=0x448
surface   bridgetop3                      mask=0x448
surface   bridgetop4                      mask=0x448
surface   bridgetop5                      mask=0x448
surface   bridgebottom0                   mask=0x448
surface   bridgebottom1                   mask=0x448
surface   bridgebottom2                   mask=0x448
surface   bridgebottom3                   mask=0x448
surface   bridgebottom4                   mask=0x448
surface   bridgebottom5                   mask=0x448

sound     bridgeon=forcefieldon01.wav
sound     bridgeoff=forcefieldoff01.wav
sound     bridgehum=forcefieldhum01.wav
sound     bridgehit=forcefieldhit01.wav

end
#==============================================================#
code
#------------------------------------------------------
startup:
	if(on) call bridgeon;	// initialize bridge.
	else call bridgeoff;
	PlaySoundPos(bridgehum, GetSurfaceCenter(bridgetop0), 1, 5, 25, 0x1);

Return;
#------------------------------------------------------
activated:
	if(GetSenderRef() != switch) Return;
	if(on) call bridgeoff;
	else call bridgeon;

Return;
#------------------------------------------------------
crossed:
	PlaySoundPos(bridgehit, GetSurfaceCenter(GetSenderRef()), 1, 5, 25, 0);
	call bridgefade;

Return;
#------------------------------------------------------
damaged:
	if(damaging) Return;	// The sender may call this message again if the explosion is long enough.
	damaging = 1;
	if(GetSenderRef() == switch)
	{
		actor = GetThingParent(GetSourceRef());
		if(on && GetThingType(actor) == 2) call bridgeoff;
		else if(!on) call bridgeon;
	}
	else
	{
		PlaySoundPos(bridgehit, GetSurfaceCenter(GetSenderRef()), 1, 5, 25, 0);
		call bridgefade;
	}
	SetTimerEx(0.5, 2, 0, 0);	// Give the explosion 0.5 seconds to finish.

Return;
#------------------------------------------------------
timer:
	if(GetSenderID() == 1) call bridgeunfade;
	else damaging = 0;

Return;
#------------------------------------------------------
bridgeon:
	on = 1;
	SetWallCel(switch, 1);
	PlaySoundLocal(bridgeon, 1, 0, 0);
	for(i = 0; i < numBridgePairs; i = i + 1)	// turn on the bridge.
	{
		ClearAdjoinFlags(bridgetop0, 0x7);	// Bridge top does not adjoin.
		SetSurfaceFlags(bridgetop0, 0x1);	// Bridge top is a floor.
		SetFaceGeoMode(bridgetop0, 4);	// Bridge top is visible.
		ClearAdjoinFlags(bridgebottom0, 0x7);	// Bridge bottom is not an adjoin.
		SetSurfaceFlags(bridgebottom0, 0x4);	// Bridge bottom is impassable.
		SetFaceGeoMode(bridgebottom0, 4);	// Bridge bottom is visible.
	}

Return;
#------------------------------------------------------
bridgeoff:
	on = 0;
	SetWallCel(switch, 0);
	PlaySoundLocal(bridgeoff, 1, 0, 0);
	for(i = 0; i < numBridgePairs; i = i + 1)	// turn off the bridge.
	{
		SetAdjoinFlags(bridgetop0, 0x7);	// Bridge top is an adjoin.
		ClearSurfaceFlags(bridgetop0, 0x5);	// Bridge top passable and not a floor.
		SetFaceGeoMode(bridgetop0, 0);	// Bridge top is invisible.
		SetAdjoinFlags(bridgebottom0, 0x7);	// Bridge bottom is an adjoin.
		ClearSurfaceFlags(bridgebottom0, 0x5);	// Bridge bottom is passable and not a floor.
		SetFaceGeoMode(bridgebottom0, 0);	// Bridge bottom is invisible.
	}
	// detach anything on the bridge so they'll fall through.
	for(i = 0; i < GetThingCount(); i = i + 1) if(GetThingSector(i) == bridgesec) DetachThing(i);

Return;
#------------------------------------------------------
bridgefade:
	for(i = 0; i < numBridgePairs; i = i + 1)	// make the bridge visible and translucent.
	{
		SetAdjoinFlags(bridgetop0, 0x1);	// Render through the bridge top.
		SetFaceGeoMode(bridgetop0, 4);	// Bridge top is visible.
		SetFaceType(bridgetop0, 0x2);	// Bridge top is translucent.
		SetAdjoinFlags(bridgebottom0, 0x1);	// Render through bridge bottom.
		SetFaceGeoMode(bridgebottom0, 4);	// Bridge bottom is visible.
		SetFaceType(bridgebottom0, 0x2);	// Bridge bottom is translucent.
	}
	KillTimerEx(1);
	SetTimerEx(0.5, 1, 0, 0);

Return;
#------------------------------------------------------
bridgeunfade:
	if(on) for(i = 0; i < numBridgePairs; i = i + 1)	// make the bridge fully visible.
	{
		ClearAdjoinFlags(bridgetop0, 0x1);	// Don't render through the bridge top.
		SetFaceGeoMode(bridgetop0, 4);	// Bridge top is visible.
		ClearFaceType(bridgetop0, 0x2);	// Bridge top is not translucent.
		ClearAdjoinFlags(bridgebottom0, 0x1);	// Don't render through bridge bottom.
		SetFaceGeoMode(bridgebottom0, 4);	// Bridge bottom is visible.
		ClearFaceType(bridgebottom0, 0x2);	// Bridge bottom is not translucent.
	}
	else for(i = 0; i < numBridgePairs; i = i + 1)	// make the bridge invisible.
	{
		SetAdjoinFlags(bridgetop0, 0x1);	// Render through the bridge top.
		SetFaceGeoMode(bridgetop0, 0);	// Bridge top is invisible.
		ClearFaceType(bridgetop0, 0x2);	// Bridge top is not translucent.
		SetAdjoinFlags(bridgebottom0, 0x1);	// Render through bridge bottom.
		SetFaceGeoMode(bridgebottom0, 0);	// Bridge bottom is invisible.
		ClearFaceType(bridgebottom0, 0x2);	// Bridge bottom is not translucent.
	}

Return;
#------------------------------------------------------
end


The header pretty much explains everything. Ask if you any questions or need something changed. [http://forums.massassi.net/html/wink.gif]

[edit]No, did not count right. [http://forums.massassi.net/html/redface.gif] Six fors in the code, but the rest are in the header and file names. [http://forums.massassi.net/html/tongue.gif][/edit]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 04, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-04, 11:23 AM #6
Maybe, Rob. Maybe.

I only count 6 For statements? You sure you counting right? [http://forums.massassi.net/html/tongue.gif]

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

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-05, 12:46 AM #7
What value do I need to put for the int on? I tried 0 and 1 but either way the switch does nothing, so i was wondering do I also need a line like:

if(on=1) call bridgeon;
else call bridgeoff;

?
2002-08-05, 4:38 AM #8
SaberMaster already has that in there. (basically)

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

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-05, 5:31 AM #9
If you give the variable "on" a value of 1, the bridge will turn on at startup; give it a value of 0, and it will turn off. This acts as both a feature and a safeguard.

Does the cog work or not? Did you define all of the variables in JED?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-05, 6:20 AM #10
I have defined all of the variables in JED - bar the surplus bridgesurfaces. I've started out with just two defined bridgesurfaces, numbridgepairs of 1 and on at 0, but the COG doesn't seem to do anything yet.
2002-08-05, 11:28 PM #11
Carved my surfaces and filled in all available bridgesurfaces in JED, altered numbridgepairs, but no luck!
2002-08-06, 4:55 AM #12
That is strange. [http://forums.massassi.net/html/frown.gif] I'm positive the cog works. If you can email me a zip of your level, I'll look it over. [http://forums.massassi.net/html/wink.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.

↑ Up to the top!