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 won't work
Cog won't work
2003-07-19, 1:24 PM #1
This cog doesn't work.

Also, here's the template the things all use:

EyeballPlant _walkstruct size=.121176 movesize=.121176 model3d=EyePlant.3do collide=3

[edit: Sorry about the link, but the italics ubb code and my arrays in the cog conflicted.]
------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------

[This message has been edited by DogSRoOL (edited July 19, 2003).]

[This message has been edited by DogSRoOL (edited July 19, 2003).]
Catloaf, meet mouseloaf.
My music
2003-07-19, 5:06 PM #2
What about it doesn't work?

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-20, 12:54 PM #3
Considering the cog only does one thing...

The objects do not change their look vector.

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music
2003-07-20, 4:35 PM #4
Upon closer examination of the cog, I've discovered that in SP, only plant1 (Thing#47) is registering in the array. In multiplayer, they all appear to register, but nothing happens.

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music
2003-07-20, 5:00 PM #5
Well, Parsec only thought your heap verbs were wrong (I don't see anything wrong). I think that having
Code:
thing plant
and
thing plant0

may cause a problem in arrays. I don't know as I have always numbered my starting at 1.
Try taking out the plant with no number.

And when I said "what doesn't work" I meant "does it print the stuff it should print? Exactly where does it stop working?" and other stuff like that.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-07-20, 6:35 PM #6
No, Parsec finds no errors - make sure you have version 1.7.

Now the syntax is fine, but your code's logic is way off.

Code:
if((IsMulti()) && (!IsServer())) Return;
else SetPulse(0.1);
SetPulse(0.1);


Second SetPulse() is useless...

Code:
for(i = 0; i <= 39; i = i + 1)
{
	if(Plant < 0) Return;
	plantLVec = VectorSub(GetThingPos(NearestPlayer), GetThingPos(Plant));
	plantLVec = VectorSet(VectorX(plantLVec), VectorY(plantLVec), VectorZ(GetThingLVec(Plant)));
	SetThingLook(Plant, plantLVec);
	Return;
}

Notice the return, that ends the loop after its first run.

Code:

        
Code:
if((IsMulti()) && (done))
{
	done = 0;
	numplayers = GetNumPlayers();
	HeapNew(0, numplayers);
	PrintInt(numplayers);
	for(j = 0; j < numplayers; j = j + 1)
	{
		for(i = 0; i <= 39; i = i + 1)
		{
			if(Plant < 0) Return;
			// now store the distance of each player.
			HeapSet(j, VectorDist(GetThingPos(Plant), GetThingPos(GetPlayerThing(j))));
			// find the smallest heap at this point
			if(distance == -1) distance = HeapGet(j);	// player 0's distance from plant.
			if(distance < HeapGet(j))
			{
				distance = HeapGet(j);	// heaps rock!
				NearestPlayer = GetPlayerThing(j);
				plantLVec = VectorSub(GetThingPos(NearestPlayer), GetThingPos(Plant));
				plantLVec = VectorSet(VectorX(plantLVec), VectorY(plantLVec), VectorZ(GetThingLVec(Plant)));
				SetThingLook(Plant, plantLVec);
			}
		}
	}
	HeapFree();	// free the heap for the next pulse.
	distance = -1;
	done = 1;
	Return;
}

That's just a mess. What's done in there for? To stop pulse from running twice at the same time? Not going to happen even with the two SetPulses. And there's a useless return at the end. And now the main logic. These loops are going through every player and then through every plant to find the closest player. It's backwards. You should be looping through the plants first, then finding the closest player and making the plant look at it. There's no reason to use the heap at all. The way you have the distance checking set up looks wierd - each plant is checking the distance of the last plant to see if it's less than its own distance from the player... ------------------ Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-21, 6:30 AM #7
I noticed the double-pulse thing: I had commented out the first 2 lines in startup, and added the second SetPulse. When I removed the #, I forgot to remove the second SetPulse. As for heaps, I used them so I didn't have to mess with setting up variables for an indefinite number of players. The heap pointer represents the player# (0, 1, 2, etc.), and the value stored is that players distance from a certain plant (whatever one is being processed at that time).

Anyway, I'll re-write the cog and see what I come up with.

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music

↑ Up to the top!