New round?

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

New round?

Post by Moustache » February 2nd, 2011, 2:10 pm

How can you start a new round in CoD4 when a round ends?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: New round?

Post by Drofder2004 » February 2nd, 2011, 6:57 pm

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?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: New round?

Post by Moustache » February 2nd, 2011, 8:56 pm

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
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: New round?

Post by Drofder2004 » February 2nd, 2011, 9:23 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: New round?

Post by Moustache » February 2nd, 2011, 9:36 pm

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.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: New round?

Post by Drofder2004 » February 2nd, 2011, 9:46 pm

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()
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: New round?

Post by Moustache » February 2nd, 2011, 9:50 pm

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 ;)

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: New round?

Post by Moustache » February 4th, 2011, 11:50 am

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?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: New round?

Post by Drofder2004 » February 5th, 2011, 2:31 am

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: New round?

Post by Moustache » February 5th, 2011, 2:08 pm

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) ====
---------------------------

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: New round?

Post by Drofder2004 » February 5th, 2011, 3:47 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests