Source Code Help

Status
Not open for further replies.
Okay, before I say anything, I do know the basics of C/C++.

I am making an exe mod for personal use. One feature that I'm going to put
in is 'Ring Collect Mode'. It's a mode where you have to collect all the rings
in a level to finish. I've already implemented the gametype, as in you can
select it from the Host Game menu and it has it's own GT_xxxxx and
TOL_xxxxx. How would I get it to check the number of rings remaining in
the level? (once I get an int, I can do the rest myself.)

Thanks in advance!
 
A function to count the remanding rings is below. I haven't tested it, but I am sure it will work.
Code:
//
// P_NumberOfRings
//
// Returns the number of rings in the level.
//
int P_NumberOfRings(void)
{
	mobj_t *mo = NULL;
	thinker_t *th = NULL;
	int numrings = 0;

	// scan the remaining thinkers
	// to count how many rings there are.
	for (th = thinkercap.next; th != &thinkercap; th = th->next)
	{
		if (th->function.acp1 != (actionf_p1)P_MobjThinker)
			continue;

		mo = (mobj_t *)th;

		// Check if its a ring.
		if (mo->type != MT_RING)
			continue; // Not a ring, goto next Mobj.

		numrings++;
	}

	return numrings;
}
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top