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 → 3do Archi problems
3do Archi problems
2006-05-30, 4:06 PM #1
I downloaded this cog from the
cog library for use in my great
wall of china level. It is supposed
to blind a player that looks at a
ghost to emulate the sun. It works
except for when a 3do should
be blocking your veiw of the sun
and it still blinds you.

Code:
# sun.cog
# 
# Blind the player as he looks at the sun.
#
# [GuNbOy + SM]
#
#
# directions: place a thing named "ghost" anywhere in your level that you would like the effect to take place;
# make a new template with the easy template creator in jed called +timed_ghost and give it the following properties:
# orient=(0/0/0) type=ghost move=path timer=0.01
#
# test level and enjoy!
#================================================================================
#
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=-1                          local                         
end                                                                           
#================================================================================#
code
#---------------------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	SetPulse(0.01);Return;
#---------------------------------------------------------------------
pulse:
	FreeColorEffect(handle);
	if(!IsThingVisible(sun)) 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);
	handle=NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 240*dot, dot/2);
	AddDynamicTint(player, dot/2, dot/2, dot/2);
Return;
#---------------------------------------------------------------------
end


Is there an easy way to counter
this using cog?
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-05-30, 7:23 PM #2
Set the thing flag 0x8 on the 3dos that are considered architecture. If that doesn't solve the problem, then the cog could use a combination of FirstThingInView, NextThingInView, and HasLos.

:)
2006-05-31, 3:51 PM #3
I just took a look at it and it's way
over my head. The way I have been
learning cog is by looking at the
actually application of verbs in
different cogs. Do you know of a
cog that uses these verbs so I can
look at it and figure out how it works?
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-02, 11:13 AM #4
I know this level that uses the same thing.

Asylum of Mortality

When looking at center "well" from above gives you a bit of a blinding effect. Maybe you can study that.
Edward's Cognative Hazards
2006-06-02, 11:21 AM #5
The force_throw.cog has two examples of these verbs in action.

The first example finds players and actors in view so the cog can show the targeting circles.

The second example finds all of the debris in view to use when the force-throw is done.

FirstThingInView and NextThingInView use distance of *sectors* (not JKUs, as indicated in the DataMaster), which means things can be found behind walls. So, the HasLOS is then used to make sure player can actually see the thing (i.e. the thing is not behind a wall).

:)
2006-06-02, 12:47 PM #6
Thanks for the examples. I'll look into it and
see if I still have problems with it.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-02, 2:47 PM #7
Originally posted by ZeqMacaw:
FirstThingInView and NextThingInView use distance of *sectors* (not JKUs, as indicated in the DataMaster), which means things can be found behind walls. So, the HasLOS is then used to make sure player can actually see the thing (i.e. the thing is not behind a wall).

:)

Hmm? Could you explain the 'distance of *sectors*' part again please? I'm not sure I caught the drift here...
May the mass times acceleration be with you.
2006-06-03, 12:03 PM #8
This is my new cog.
It has been tested and seems to work fine

Code:
# sun.cog
# 
# Blind the player as he looks at the sun.
#
# [GuNbOy + SM]
# modified by Jedi1 to work with 3do Archi as well
#
#
# directions: place a thing named "ghost" anywhere in your level that you would like the effect to take place;
# make a new template with the easy template creator in jed called +timed_ghost and give it the following properties:
# orient=(0/0/0) type=ghost move=path timer=0.01
#
# test level and enjoy!
#================================================================================
#
symbols
message      startup                                                          
message      pulse                                                            
thing        sun                                                              
thing        player                             local                         
thing        ghostthing                         local
thing        victim                             local                         
template     gtemp=+timed_ghost                 local                         
vector       sunlook                            local                         
vector       lvec                               local                         
flex         dot                                local
flex         maxDot                             local                         
int          handle=-1                          local                         
end                                                                           
#================================================================================#
code
#---------------------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	SetPulse(0.01);Return;
#---------------------------------------------------------------------
pulse:
	FreeColorEffect(handle);
        // Check all things for our victim.
        victim = -1;
   // Check all things for our victim.
   victim = -1;
   maxDot = 0;

   // Search for all players and actors.
   sun = FirstThingInView(player, 45, 1000, 0x100);
   while(sun != -1)
   {
      if(
         HasLOS(player, sun)
        )
      {
         dot = ThingViewDot(player, sun);
         if(dot > maxDot)
         {
            victim = sun;
            maxDot = dot;
         }
      }
      sun = NextThingInView();
   }

   // If we have a victim...
   if(victim != -1)
   {   
        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);
	handle=NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 255*dot, dot/1);
	AddDynamicTint(player, dot/1, dot/1, dot/1);
   }
Return;
#---------------------------------------------------------------------
end 


I'm not an expert in cog so I just wanted
to know if it had any glaring errors. is it
synched? What determines if a cog is
synched for MP or not?
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-03, 3:06 PM #9
Synchronizing things is not needed here, since the blinding effect can remain local to each player (each player's computer blinds his own player only). Basically, you only have to synchronize MP-gameplay critical things (like damage, thing creation, etc.) but fortunately some (most) of these are taken care of by the engine.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-03, 10:29 PM #10
The blinding effect no longer can be
seen through 3dos but now it isn't
triggered in the right part of the sky.
I have my ghost positioned corectly
but it just isn't working in game.

Is it my cog that is the problem or is
it the level mechanics that are off?
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-04, 9:55 AM #11
For MP, the cog would probably be better using flags=0x240, because no syncing is necessary (or wanted) in this cog.

The cog currently will blind the player for *any* ghost thing found in player's view. (This could be the cause of the problem of not triggering in right part of sky.) To make sure the sun thing is the only thing allowed to blind, change the FirstThingInView line and "while" block to this:
Code:
   // Is sun in view of player?
   potential_sun = FirstThingInView(player, 45, 1000, 0x100);
   while (potential_sun != -1)
   {
      if (HasLOS(player, potential_sun) && potential_sun == sun)
      {
         dot = ThingViewDot(player, sun);
         if (dot > maxDot)
         {
            victim = sun;
            maxDot = dot;
         }
      }
      potential_sun = NextThingInView();
   }
Be sure to also add the potential_sun symbol to the symbols section.

You can remove the duplicate of these lines:
Code:
        // Check all things for our victim.
        victim = -1;

:)
2006-06-04, 11:47 AM #12
Hmm, I don't get how this code should try 3dos as sunblockers. As I see it, this will still blind the player, when the sun is behind a 3do. Or does First-/NextThingInView consider 3dos as blockers? If not, why even use them? I mean, the sun can be set and the player is set, so a simple HasLOS and ThingViewDot should work, no?
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-04, 11:52 AM #13
Originally posted by darthslaw:
Hmm? Could you explain the 'distance of *sectors*' part again please? I'm not sure I caught the drift here...

I think these are maximum recursions into adjoined sectors. Let's say you have a corridor of three sectors in a row. A distance of 1 won't see things in the farthest sector, a distance of two includes the whole corridor. Remembering how a portal engine works, this even makes sense.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-04, 4:27 PM #14
Originally posted by zagibu:
Hmm, I don't get how this code should try 3dos as sunblockers. As I see it, this will still blind the player, when the sun is behind a 3do. Or does First-/NextThingInView consider 3dos as blockers? If not, why even use them? I mean, the sun can be set and the player is set, so a simple HasLOS and ThingViewDot should work, no?


I don't really know. I'll try only
using hasLOS and see how it
turns out. Once again though,
I'm just a begginer in cog so my
knowledge is minimal. I really
have no Idea what I'm doing.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-05, 2:05 AM #15
No, if it works, keep it the way it is. I'd just like an explanation from maybe Zeq. I don't see how looping through all things in view to determine the sun should lead to the desired effect. The sun is already defined, so why even have this loop? I really don't get it...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-05, 2:47 AM #16
I changed my cog the ways you said
ZeqMacaw but It still doesn't work.

Here is the result of me attempting to
follow your instructions.
Code:
symbols
message      startup                                                          
message      pulse                                                            
thing        sun
thing        potential_sun                      local                                                              
thing        player                             local                         
thing        ghostthing                         local
thing        victim                             local                         
template     gtemp=+timed_ghost                 local                         
vector       sunlook                            local                         
vector       lvec                               local                         
flex         dot                                local
flex         maxDot                             local                         
int          handle=-1                          local                         
end                                                                           
#=================================================  ===============================#
code
#---------------------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	SetPulse(0.01);Return;
#---------------------------------------------------------------------
pulse:
   FreeColorEffect(handle);
   // Check all things for our victim.
   victim = -1;
   maxDot = 0;

   // Is sun in view of player?
   potential_sun = FirstThingInView(player, 45, 1000, 0x240);
   while (potential_sun != -1)
   {
      if (HasLOS(player, potential_sun) && potential_sun == sun)
      {
         dot = ThingViewDot(player, sun);
         if (dot > maxDot)
         {
            victim = sun;
            maxDot = dot;
         }
      }
      potential_sun = NextThingInView();
   }
   
   // If we have a victim...
   if(victim != -1)
   {   
        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);
	handle=NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 255*dot, dot/1);
	AddDynamicTint(player, dot/1, dot/1, dot/1);
   }
Return;
#---------------------------------------------------------------------
end



I've fiddled with this for a while and
came up with this. This doesn't work
either. I'm pretty lost.

Code:
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=-1                          local                         
end                                                                           
#================================================================================#
code
#---------------------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	SetPulse(0.01);Return;
#---------------------------------------------------------------------
pulse:
	FreeColorEffect(handle);
        if(!isthingvisible(sun)) Return;
        if(HasLOS(player, sun)) Return;
	if(sun = FirstThingInView(player, 90, VectorDist(GetThingPos(sun), GetThingPos(player)), 0x240) && HasLOS(player, sun))
{        
	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);
	handle=NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 240*dot, dot/2);
	AddDynamicTint(player, dot/2, dot/2, dot/2);
}
Return;
#---------------------------------------------------------------------
end


Which of these is closer to working?
What is wrong with them?

Zagibu, from what I understand about
firstthinginview, It is only useful in this
situation because it can filter through
objects using mask values. You'd have
to check with someone fully competent
in cog to know for sure though.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-05, 3:43 AM #17
Messy formatting makes baby jeebus cry.

Try this:
Code:
symbols

message		startup
message		pulse

thing		sun
thing		player			local
thing		ghostthing		local

template	gtemp=+timed_ghost	local

flex		dot			local
flex		minDot=0.5		local

int		handle=-1		local

end

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

code

startup:
	player = GetLocalPlayerThing();
	SetPulse(0.01);
Return;

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

pulse:
	// Remove previous blinding fx
	FreeColorEffect(handle);

	// Check if player has LOS to the sun (only sector-based)
	if(HasLOS(player, sun))
	{
		// Fire a ghost thing to get a reference to player's look vector
		ghostthing = FireProjectile(player, gtemp, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
		dot = ThingViewDot(ghostthing, sun);
		// Check if player is facing the sun
		if(dot > minDot)
		{
			// Do blinding fx
			handle = NewColorEffect(0, 0, 0, 0, 0, 0, 255*dot, 255*dot, 255*dot, dot/1);
			AddDynamicTint(player, dot/1, dot/1, dot/1);
		}
	}
Return;

end

It's untested yet (will do some tests in the evening). And it doesn't check for 3dos in the way (as I think this is near impossible).

BTW: Is this for your great wall of China level? If so, you could use a combination of sectors and 3dos to determine whether a player is inside.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-05, 10:10 AM #18
It is for my Great Wall level.
I'm afraid it would be a
nightmare to make sectors
to tell you whether or not you
see the sun. I was thinking of
expirimenting with overlapping
sectors for use in cog. Do you
think I could get overlapping
sectors to act as triggers.
Would that work?

BTW I just tested your cog and
congratulations Zagibu, you have
done the impossible. It blocks
out the 3dos even. It works
perfectly! We should keep an
eye on it just to make sure it
works but I think we finnally got
it. Thanks for all the help guys!
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-05, 11:35 AM #19
[QUOTE=jedi I]
BTW I just tested your cog and
congratulations Zagibu, you have
done the impossible. It blocks
out the 3dos even. It works
perfectly! We should keep an
eye on it just to make sure it
works but I think we finnally got
it. Thanks for all the help guys![/QUOTE]
Are you sure? I don't get it...I thought it was impossible. It must be the HasLOS then, which checks 3do visibility, too. But I thought it didn't...are you sure it's not some side-effect?

And I don't know much about overlapping sectors...heard they can be problematic with collision detection.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-06-05, 8:35 PM #20
It really works as far as I can tell.
I've goofed with this type of cog
long enough that I really don't
think it's a side effect. All the
other times I thought I had it working,
the blinding effect didn't originate from
the correct place. I believe it is
the HasLos that makes it work.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2006-06-06, 3:33 PM #21
The code I provided was taken from force_throw.cog, an LEC-made cog. Now that I have looked at the code again, zagibu is correct about not needing the ThingInView verbs; the cog already knows the thing (the sun) to be checked. Of course, zagibu's cog also proves this.

Good work, zagibu.

:)

↑ Up to the top!