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 → My cog breaks if there is more then 1 in the level
My cog breaks if there is more then 1 in the level
2002-02-08, 10:26 PM #1
Okay. I think I know why it breaks when I place more then 1 of these. I use the same name for the color effect, so when there are 2 things, they cancel each other out or something. Can anybody think of a way for me to make it so i can add more then 1? Cuz i made a reall kool effect in my reactor room with these cogs, but I can only add one of them right now. Here is the cog, don't think too much, just think of a way i could make it so i could add more. Btw, most of the crap in the start up thing is stuff i added to make this cog user-friendly when i submit it to massassi.
Code:
# Jedi Knight Cog Script
#
# aotlensflair.cog
#
# Controls a semi-cool lens flair effect when an 3do is visible to the player.
#
# [SM Sith Lord]
#
# This cog is not made or distributed by LucasArts Entertainment Co.

flags=0x240
symbols

message		startup
message		pulse
message		newplayer

thing		flairobject=-1
flex		brightness=1
int		R=255
int		G=255
int		B=255
flex		fadeout=0.5

flex		dot=-1			local
flex		olddot			local
flex		r_y			local
flex		r_m			local
flex		r_m2			local
flex		g_y			local
flex		g_m			local
flex		g_m2			local
flex		b_y			local
flex		b_m			local
flex		b_m2			local

int		tintamt			local
int		ramt			local
int		gamt			local
int		bamt			local
int		lenseffecthandle	local
int		player			local

end

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

code

startup:
fadeout = fadeout/10;
R = R*brightness;
G = G*brightness;
B = B*brightness;
r_y = R/1.7;
r_m = r_y/0.85;
r_m2 = (R-r_y)/0.15;
g_y = G/1.7;
g_m = g_y/0.85;
g_m2 = (G-g_y)/0.15;
b_y = B/1.7;
b_m = b_y/0.85;
b_m2 = (B-b_y)/0.15;
SetPulse(0.01);
return;

pulse:
FreeColorEffect(lenseffecthandle);
olddot = dot;
dot = -1;
if( IsThingVisible(flairobject) && HasLOS(player,flairobject) ){
  dot = ThingViewDot(player,flairobject);
  }
else if( olddot-0.1 > 0 ){
  dot = olddot-fadeout;
  }
else if( olddot-0.1 <= 0 ){
  dot = -1;
  }
if( dot != -1 ){
  if( dot <= 0.85 && dot > 0 ){
    ramt = r_m*dot;
    gamt = g_m*dot;
    bamt = b_m*dot;
    lenseffecthandle = NewColorEffect(0,0,0,0,0,0,ramt,gamt,bamt,1);
    }
  else if( dot > 0.85 ){
    ramt = r_m2*(dot-0.85)+r_y;
    gamt = g_m2*(dot-0.85)+g_y;
    bamt = b_m2*(dot-0.85)+b_y;
    lenseffecthandle = NewColorEffect(0,0,0,0,0,0,ramt,gamt,bamt,1);
    }
  }
return;

newplayer:
player = GetLocalPlayerThing();
return;

# ........................................................................................

end
One day, after everybody else quits, I'll be the best.
Sith Mercenaries
^My site.
2002-02-11, 9:10 AM #2
Color effects do not have names. They have numbers. The verb NewColorEffect() returns the number of the effect it creates. A variable is usually assigned to NewColorEffect() to receive that number. Then the variable will hold the number of the effect. Your problem is that the pulses in your placed cogs are freeing each others effects.

I don't get all of that RGB code you've got in there. This code, which was developed on another thread a week ago, does about what you want:
Code:
# sunblind.cog
#
# Blind the player as he looks at the sun.
#
# [GunBoy + SM]
#================================================================================#
symbols

message	startup
message	pulse

thing		sun
thing		player		local
thing		ghostthing	local

template	gtemp=+timed_ghost	local

vector	sunlook		local
vector	lvec			local

flex		dot			local
int		handle		local

end
#================================================================================#
code
#---------------------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	handle=32;
	SetPulse(0.01);

Return;
#---------------------------------------------------------------------
pulse:
	FreeColorEffect(handle);
	if(!IsThingVisible(sun)) {handle=32; Return;}
	ghostthing=FireProjectile(player, gtemp, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
	lvec=GetThingLVec(ghostthing);
	sunlook=VectorNorm(VectorSub(GetThingPos(sun), GetThingPos(player)));
	dot=VectorDot(sunlook, lvec);
	if(dot < 0) Return;
	handle=NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 200*dot, 1);

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


handle is set to 32 when effects are not being created so that FreeColorEffect() does not free effects created by another cog.

+timed_ghost is a regular ghost with an added timer=0.01 so that the ghost is removed shortly after it's created.

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!