Page 1 of 1

New round?

Posted: February 2nd, 2011, 2:10 pm
by Moustache
How can you start a new round in CoD4 when a round ends?

Re: New round?

Posted: February 2nd, 2011, 6:57 pm
by Drofder2004
You're going to have to be more specific.

I do not think there is simply one function that restarts a round in the way of scripting.
Are you writing your own gametype, function or other?

Re: New round?

Posted: February 2nd, 2011, 8:56 pm
by Moustache
Sorry, my bad.

I would like to keep the gametype files untouched so it can be used for all gametypes.

When a map ends (so for example a TDM match) I want that a new extra round gets started if value x = true.
It should be something like this:

Code: Select all

check_new_round()
{
	waittill( "round_end" ); // I don't know if something like this exist?

	if( x )
		level thread start_new_round();
}

start_new_round()
{
	// I have no clue
}

Re: New round?

Posted: February 2nd, 2011, 9:23 pm
by Drofder2004
TDM already starts a new round, so what you actually want to do is reverse your "if statement".

So:

if(x > 0)
// next round

becomes


if(x < 0)
// end game

The function required is found in globallogic.gsc
endGame( winner, endReason )

For example, I used it in the codjumper mod when restarting or changing map by the ingame vote menu:
thread maps\mp\gametypes\_globallogic::endGame(undefined, "Vote Passed - Changing Map");

Hopefully that helps, as I do not believe there is a "notify" for ending rounds, there are just threads that restart.

Re: New round?

Posted: February 2nd, 2011, 9:36 pm
by Moustache
Thank you for your help :)

I already thought it was the endGame function (because it was also in the gametype files etc). But I don't know how to use it to add an extra round. But I will check it out tomorrow.

Re: New round?

Posted: February 2nd, 2011, 9:46 pm
by Drofder2004
To ADD a round?

Based on what?
The game already has criteria for this, such as timelimits and scorelimits. There are threads that monitor these before they issue an endgame call.

They can also be found in the globallogic - i.e hitRoundLimit()

Re: New round?

Posted: February 2nd, 2011, 9:50 pm
by Moustache
That is what I tried, play a new round by using the threads that are already in the game. But I did not knew how to do this.

Thank you for the info, I will check it tomorrow.

If I fail I will report back ;)

Re: New round?

Posted: February 4th, 2011, 11:50 am
by Moustache
Sorry for the double post.

EDIT:
I have been working on it and as far as I know it is only possible by editing the gametype files (war.gsc, dm.gsc, etc).
Or is there an other method to do what I want without touching the gametype files?

Re: New round?

Posted: February 5th, 2011, 2:31 am
by Drofder2004
gametype files do nothing but define the gametypes. The magic is done in the globallogic.gsc file, as this is where the core scripting is.

I cannot go into much detail at the minute (up for work in 6 hours >.>) but bump the topic and I will have a look tomorrow.

Re: New round?

Posted: February 5th, 2011, 2:08 pm
by Moustache
Alright, thank you in advance :)

I searched my ass of but I have no clue how to stop the game from running the game type file (war.gsc for example). The first round it should just load the game type file. But when x = true it should not load the game type file.

EDIT
When I removed the main() out of the game type file (war.gs) to see which script gives the error I got this error code. The problem is that it does not shows where the error was called from.
File Handles:
----------------------
48600 files in iwd files
Loading fastfile mp_crash
Waited 286 msec for asset 'maps/mp/mp_crash.d3dbsp' of type 'col_map_mp'.
------- Game Initialization -------
gamename: Call of Duty 4
gamedate: Jun 18 2008
----------------------
Game: G_SetupWeaponDef
----------------------
********************
ERROR: Could not find label 'main' in script 'maps/mp/gametypes/war'
********************
----- Server Shutdown -----
Resolving cod4master.activision.com
cod4master.activision.com resolved to 63.146.124.21:20810
Sending heartbeat to cod4master.activision.com
==== ShutdownGame (1) ====
---------------------------

Re: New round?

Posted: February 5th, 2011, 3:47 pm
by Drofder2004
Find and downlaod a program called "Windows Grep", load that up so it is pointed at the RAW or Maps folder. Now search for the term you want ("::main()")
This will help you find where functions are being called from.

Anyway
Globallogic.gsc
Line 1173-1503
EndGame()

This function handles everything, from single rounds, many rounds, halftimes and map restarts and map changes.

Code: Select all

        if ( !hitRoundLimit() && !hitScoreLimit() )
        {
        	level notify ( "restarting" );
            game["state"] = "playing";
            map_restart( true );
            return;
        }
that is the code to restart the round.
You will need to edit this "if statement" and possibly the previous ones to get your desired mod.

For example:

Code: Select all

        if ( ( !hitRoundLimit() && !hitScoreLimit() ) || level.moustache_new_round == true)
        {
        	level notify ( "restarting" );
            game["state"] = "playing";
            map_restart( true );
            return;
        }
That would restart the round if a variable called "level.moustache_new_round" was set to true and it would ignore any round or score limits.

You would almost definitly need to change more code however to stop some errors popping up.