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 → Cog request...
Cog request...
2005-11-16, 10:47 AM #1
TriggerZone.cog

Parameters:

The cog must allow the user to enter 6 x,y,z coordinates.
The cog should call for the players current position at a "flex" rate.
The cog will check to determine if the player is within these 6 coordinates
IF No, then it will ignore the rest of the cog. IF Yes, then it will continue.
The cog must allow the user to modify or enable the following varibles:
Modify (change) Sector Tint Locally.
Modify the gravity value (0-4) Locally.
Enable Water effect for Sector Locally.
Execute Cogs Locally (allow the user to specify 4 or more cogs to be executed while the player is within the 6 specified coordinates).

Obviously, this cog needs to be local as to work in MP.

Thanks in advance!
"The solution is simple."
2005-11-16, 5:23 PM #2
Quote:
The cog must allow the user to enter 6 x,y,z coordinates.


Are these coords part of a surface or sector?

Quote:
Modify (change) Sector Tint Locally.
Modify the gravity value (0-4) Locally.
Enable Water effect for Sector Locally.


I would need a little more information than that. What sectors are going to be affected?

Quote:
Execute Cogs Locally (allow the user to specify 4 or more cogs to be executed while the player is within the 6 specified coordinates).


I'm assuming you want this cog to send the user0 message to the other cogs. :confused:
Historians are the most powerful and dangerous members of any society. They must be watched carefully... They can spoil everything. - Nikita Khrushchev.
Kill one man, and you are a murderer. Kill millions of men, and you are a conqueror. Kill them all, and you are a god. - Jean Rostand.
2005-11-17, 8:41 AM #3
Originally posted by Centrist:
Are these coords part of a surface or sector?


No, they are level x,y,z coordinates. Completely independant. Basically, what you're doing is getting the players position getCurrentPlayersPos() (or whatever it's called) and then checking the returned values against the user entered values to see if the player exist within those coordinates.



Quote:
I would need a little more information than that. What sectors are going to be affected?


User determined. Theoretically, if everything goes right, only Sector 0 will need to be used.

Quote:
I'm assuming you want this cog to send the user0 message to the other cogs. :confused:


I want this cog to check to see if the player is within an invisible x,y,z boxed shape area that acts as a "trigger zone" vs using "touched" or "colide" as an indicator of rather or not to initiate a cog.

So, when the cog runs it's check:
If NO, then nothing happens.
If YES, then the sector changes take effect and any cogs that need to run will be executed.
"The solution is simple."
2005-11-17, 9:02 AM #4
I know this isn't correct, buy maybe it'll help

Code:
using
getCurrentPlayerPos() //or whatever that function is called
getSectorTint()
getSectorFlag()
getLevelGrav()

float playerPos = 0.0; //to store and check the players position
float cord1        = 0.0; //if it'll be easier, this can be xCordHi
float cord2        = 0.0; //if it'll be easier, this can be xCordLo
float cord3        = 0.0; //if it'll be easier, this can be yCordHi
float cord4        = 0.0; //if it'll be easier, this can be yCordLo
float cord5        = 0.0; //if it'll be easier, this can be zCordHi
float cord6        = 0.0; //if it'll be easier, this can be zCordLo
float secTint      = 0.0; //to change the sector tint
int waterEffect  = 0; //0 = no, 1 = yes
int gravity         = 0; //to change gravity 0-4 as per the level header
string cog1       = " ";
string cog2       = " ";
string cog3       = " ";
string cog4       = " ";

Code:

getCurrentPlayerPos();

IF
     getCurrentPlayerPos (x < cord1 && x > cord2 && y < cord3 && y > cord4 && z < cord 5 && z > cord6);
     setSectorTINT = secTint
     setSectorFlag = waterEffect
     setLevelGrav = gravity
     Start cog1
     Start cog2
     Start cog3
     Start cog4

Else
Nothing

End
"The solution is simple."
2005-11-18, 6:10 AM #5
Woops, and everything has to go back to the way it was before when they leave out of that area.
"The solution is simple."
2005-11-18, 8:42 PM #6
Haven't forgotten - I'll see what I can do tomorrow. ;)
Historians are the most powerful and dangerous members of any society. They must be watched carefully... They can spoil everything. - Nikita Khrushchev.
Kill one man, and you are a murderer. Kill millions of men, and you are a conqueror. Kill them all, and you are a god. - Jean Rostand.
2005-11-19, 3:56 PM #7
Here it is:

Code:
# triggerzone.cog
#
# A cog that will create effects in a sector when a player enters a set of coordinates.
# All effects will be client-side only with no synchronization.
#
# [CT]
#==============================================================#
flags=0x240
symbols

message startup
message pulse

thing player local
int i local
vector pos local
flex enabled=0 local

flex pulseInterval=1

flex xmin=0
flex xmax=1
flex ymin=0
flex ymax=1
flex zmin=0
flex zmax=1

int numEffectSectors=1
sector effectSector0=-1
sector effectSector1=-1
sector effectSector2=-1
sector effectSector3=-1

int numMessageCogs=1
cog messageCog0=-1
cog messageCog1=-1
cog messageCog2=-1
cog messageCog3=-1

flex newGravity=8
flex curGravity=4

vector newTint=(0/0.5/0)
vector curTint=(0/0/0)

end
#==============================================================#
code
#------------------------------------------------------
startup:
	player=GetLocalPlayerThing();
	SetPulse(pulseInterval);

return;
#------------------------------------------------------
pulse:
	pos=GetThingPos(player);
	if(VectorX(pos) > xmin && VectorX(pos) < xmax &&
		VectorY(pos) > ymin && VectorY(pos) < ymax &&
		VectorZ(pos) > zmin && VectorZ(pos) < zmax) call enable_effect;
	else call disable_effect;

return;
#------------------------------------------------------
enable_effect:
	if(enabled) return;
	enabled=1;
	for(i=0; i < numEffectSectors && effectSector0 != -1; i=i+1) SetSectorTint(effectSector0, newTint);
	for(i=0; i < numMessageCogs && messageCog0 != -1; i=i+1) SendMessage(messageCog0, user0);
	SetGravity(newGravity);

return;
#------------------------------------------------------
disable_effect:
	if(!enabled) return;
	enabled=0;
	for(i=0; i < numEffectSectors && effectSector0 != -1; i=i+1) SetSectorTint(effectSector0, curTint);
	for(i=0; i < numMessageCogs && messageCog0 != -1; i=i+1) SendMessage(messageCog0, user1);
	SetGravity(curGravity);

return;
#------------------------------------------------------
end


I have this cog sending user0 and user1 to the other cogs that you want to "start," but any message can be sent instead.

So try it out. ;)
Historians are the most powerful and dangerous members of any society. They must be watched carefully... They can spoil everything. - Nikita Khrushchev.
Kill one man, and you are a murderer. Kill millions of men, and you are a conqueror. Kill them all, and you are a god. - Jean Rostand.
2005-11-28, 8:22 AM #8
Sorry it took so long to respond.

The cog seems to be working "OK" but was missing a couple imporatant things.

First, the pulse was set to 1 sec by default, so I had to reduce it to 0.1 to make the cog viable.

Secondly, the Tint change never worked. I tried a bunch of different combinations to make sure (including 'extreme' values).

Third, the cog lacked the option to change the sectors +FLAGS (for such things as the "water" effect, etc.)

Other then that, the cog seems to recognize the "boundries" pretty well.

Thanks again for you help on this. This cog will make a great impact on the community once it's full potential is realized...
"The solution is simple."
2005-11-28, 11:12 PM #9
I considered making this cog, but I thought of at least two problems with the general idea.

Consider:

(1) The sector effects will be for the entire sector, not just inside the "zone". This means, for example, that when the zone is supposed to be water, the player will see not just the zone as water, but the entire sector, in which the zone is located, as water. Also, this doesn't just affect visuals; projectiles shot out of the zone would also have to run through other zone coding to handle the various physics effects properly in those other zones.

(2) The way the zone vertices are given and used in the current cog means having only box-shaped zones. This is very limiting, as normal sectors can be almost any shape. A more general way would be to give a set of vertices, and the code would determine if the player is inside those vertices. This, of course, is what the engine currently does with sectors, so it is unlikely coding it in cog would provide any benefit over engine code.

:)
2005-11-29, 5:39 AM #10
Originally posted by ZeqMacaw:
I considered making this cog, but I thought of at least two problems with the general idea.

Consider:

(1) The sector effects will be for the entire sector, not just inside the "zone". This means, for example, that when the zone is supposed to be water, the player will see not just the zone as water, but the entire sector, in which the zone is located, as water. Also, this doesn't just affect visuals; projectiles shot out of the zone would also have to run through other zone coding to handle the various physics effects properly in those other zones.


First, if you're in water, the whole sector is going to look like water to you anyhow. You can write another cog to handle the other issues. In general, the cog would supliment "trigger" messages associated with either crossing adjoins, touching surfaces, or even touching objects.

Quote:
(2) The way the zone vertices are given and used in the current cog means having only box-shaped zones. This is very limiting, as normal sectors can be almost any shape. A more general way would be to give a set of vertices, and the code would determine if the player is inside those vertices. This, of course, is what the engine currently does with sectors, so it is unlikely coding it in cog would provide any benefit over engine code.


Yes, having a minimium of 8 verticies would be far more flexible. I'd like to see that for future versions of this cog. However, for right now, I wanted to keep it simple. As far as 'that's what sectors do anyway' the point of this cog is to not use multiple sectors. This cog should allow an editor to just have one sector and then build the level out of 3do's. This cog is suppose to alliviate the problem with "flickering" associated with 3do's used in conjunction with multiple sectors.

I hope now you are able to begin to see the benifits of such a cog...
"The solution is simple."
2005-11-29, 1:29 PM #11
Indeed, I was incorrect about the water visuals problem. :S (I just now retested by swimming around in Canyon Oasis.) :D

I understand what you are trying to do, and I still suspect it will be more problematic than dealing with the 3do "flickering" issues.

I will help with the cog when I can, even with my doubts. ;)

:)

↑ Up to the top!