Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Infected Gametype for CoD4

  1. #1
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Infected Gametype for CoD4

    Most of you don't know me, a majority actually, but I need some help, if you know the MW3 gametype infected, you'll know there're different weapons for each map.
    I wanted to try something like that for this CoD4, although, instead I made the weapons random for each round, I got the 'random' part working with randomintrange for the survivor's loadout (as you'll ses in the script) BUT it makes the gun random per player, so everyone would end up likely having a different, but random gun, how would I edit the script to make the players on the server all spawn with that same randomly selected gun?

    http://pastebin.com/cxKKWRJb


    (TL;DR)

    Script right now:
    Player 1 spawns with winchester1200_mp
    player 2 spawns with winchester1200_reflex_mp
    player 3 spawns with winchester1200_grip_mp


    ---------

    What i'm trying to achieve, but failing:

    Player 1 spawns with winchester1200_mp
    Player 2 spawns with winchester1200_mp
    Player 3 spawns with winchester1200_mp

    if that's the randomly selected gun

    or

    Player 1 spawns with winchester1200_reflex_mp
    Player 2 spawns with winchester1200_reflex_mp
    Player 3 spawns with winchester1200_reflex_mp

    if that's the randomly selected gun

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    On round restart, just save the random gun in level.randomgun and in your player spawn function you access that variable to give the weapon.
    timescale 0.01

  3. #3
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by kung foo man View Post
    On round restart, just save the random gun in level.randomgun and in your player spawn function you access that variable to give the weapon.
    in the onPlayerSpawn thread, I added self giveWeapon( survivorWeapon );

    and deleted it from the original thread, I know i'm doing something wrong because it's still not working

  4. #4
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by akuma2099 View Post
    in the onPlayerSpawn thread, I added self giveWeapon( survivorWeapon );

    and deleted it from the original thread, I know i'm doing something wrong because it's still not working
    Forgive my idiocy, I just fixed everything, thanks man

  5. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Change how the default weapon is picked:

    Main function:
    Code:
    	level.scr_inf_sur_force_weapon = toLower( getdvarx( "scr_inf_sur_force_weapon", "string", "winchester1200_mp;winchester1200_reflex_mp;winchester1200_grip_mp" ) );
        level.scr_inf_sur_force_weapon = strtok( level.scr_inf_sur_force_weapon, ";" );
    
        if ( level.scr_inf_sur_force_weapon != "" )
            level.survivorWeapon = level.scr_inf_sur_force_weapon[ randomInt( level.scr_inf_sur_force_weapon.size ) ];
    getSurvivorLoadout function:
    Code:
    		survivorWeapon = level.survivorWeapon
     
             // Give start ammo for Survivor weapon and switch to it
             self giveWeapon( survivorWeapon );
     
             if( self.getsSurvivorAmmo == true ) {
                     self giveStartAmmo( survivorWeapon );
             } else {
                     self setWeaponAmmoClip( survivorWeapon, 0 );
                     self setWeaponAmmoStock( survivorWeapon, 0 );
             }
                     
             self setSpawnWeapon( survivorWeapon );
             self switchToWeapon( survivorWeapon );
    That will randomly pick a weapon from the force weapon list, and give it to all players. It will be different each round, or each new map, but the same for each and every player.

    All I did was move the method to pick the random weapon from the getSurvivorLoadout() function to the main() function. And create a level scruct for the force weapon, and make that the weapon each player gets.
    Last edited by Tally; 22nd August 2015 at 09:08.

  6. #6
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Tally View Post
    Change how the default weapon is picked:

    Main function:
    Code:
    	level.scr_inf_sur_force_weapon = toLower( getdvarx( "scr_inf_sur_force_weapon", "string", "winchester1200_mp;winchester1200_reflex_mp;winchester1200_grip_mp" ) );
        level.scr_inf_sur_force_weapon = strtok( level.scr_inf_sur_force_weapon, ";" );
    
        if ( level.scr_inf_sur_force_weapon != "" )
            level.survivorWeapon = level.scr_inf_sur_force_weapon[ randomInt( level.scr_inf_sur_force_weapon.size ) ];
    getSurvivorLoadout function:
    Code:
    		survivorWeapon = level.survivorWeapon
     
             // Give start ammo for Survivor weapon and switch to it
             self giveWeapon( survivorWeapon );
     
             if( self.getsSurvivorAmmo == true ) {
                     self giveStartAmmo( survivorWeapon );
             } else {
                     self setWeaponAmmoClip( survivorWeapon, 0 );
                     self setWeaponAmmoStock( survivorWeapon, 0 );
             }
                     
             self setSpawnWeapon( survivorWeapon );
             self switchToWeapon( survivorWeapon );
    That will randomly pick a weapon from the force weapon list, and give it to all players. It will be different each round, or each new map, but the same for each and every player.

    All I did was move the method to pick the random weapon from the getSurvivorLoadout() function to the main() function. And create a level scruct for the force weapon, and make that the weapon each player gets.
    I made an entirely new function which echo's off onStartGametype for the random weapon function

    Code:
    startInfected()
    {
    	level endon ( "game_ended" );
    
    	weaponsCyclingAvailable = level.scr_inf_sur_force_weapon;
    	weaponsCyclingAvailableInfected = level.scr_inf_force_weapon;
    		
    	for (;;) {
    		// Make a random weapon selection and assign it to everyone in the server
    		newWeaponElement = randomIntRange( 0, weaponsCyclingAvailable.size );
    		newWeaponElementInfected = randomIntRange( 0, weaponsCyclingAvailableInfected.size );
    		level.survivorWeapon = weaponsCyclingAvailable[ newWeaponElement ];
    		level.infectedWeapon = weaponsCyclingAvailableInfected[ newWeaponElementInfected ];
    
    		// Assign the new weapon to all the players
    		for ( p = 0; p < level.players.size; p++ ) {
    			player = level.players[p];
    			
    			if ( isDefined( player ) && isDefined( player.pers["team"] ) && player.pers["team"] == "axis" ) {
    				player thread getSurvivorLoadout( true );
    			}
    
    			if ( isDefined( player ) && isDefined( player.pers["team"] ) && player.pers["team"] == "allies" ) 
    			{
    				player thread getInfectedLoadout( true );
    			}
    		}
    		
    		level waittill( "start_cycling" );
    	}		
    }

  7. #7
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Right now, i'm trying to get around this part of the code,

    Code:
    enoughPlayers()
    {
    
    	players[ "allies" ] = 0;
    	players[ "axis" ] = 0;
    	players[ "spectator" ] = 0;
    	enoughPlayers = false;
    
    	for ( index = 0; index < level.players.size; index++ )
    	{
    		player = level.players[index];
    
    		// Get the players teams
    		playerTeam = player.pers[ "team" ];
    		players[ playerTeam ]++;
    
    
    		// Must have the minimum players required to pick Infected
    			if ( ( players[ "allies" ] + players[ "axis" ] ) >= level.scr_inf_min_players ) {
    				enoughPlayers = true;
    				break;
    			}
    
    	}
    	
    	return ( enoughPlayers );
    }
    what it does is, it makes the minimum players variable dictate whether the game starts or not, but this isn't very good because someone can be on the survivor(axis) team, and haven't pressed their select class from the chooseclass scriptmenu yet which would make them a spectating survivor, and it'll still recognize him as a player, and it'll start the countdown.

    How can I edit the CoD4 scriptmenus to make it so as soon as someone joins the game, the server autoassigns them and auto selects a class for them from the chooseclass scriptmenu - so as soon as the player is connected to the server they automatically spawn?

  8. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Infected gametype does not choose a class from the chooseclass menu. Like Old School, it by-passes the class choice, and forces a class on them. The "choose class" option should be greyed out. If it isn't, you haven't ported the gametype over properly.

  9. #9
    Private
    Join Date
    Jul 2015
    Posts
    44
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Tally View Post
    Infected gametype does not choose a class from the chooseclass menu. Like Old School, it by-passes the class choice, and forces a class on them. The "choose class" option should be greyed out. If it isn't, you haven't ported the gametype over properly.
    The only thing the gametype does towards the UI when you join a server, is to grey out the choose teams so you can only pick autoassign, for which it autoassigns you to the obvious survivors team, but as soon as you press auto assign, you will still have to click a class loadout for it to actually take your guns away from you and give you the infected loadout, I tested this on an openwarfare SVN copy, just now, and it doesn't bypass the chooseclass menu when you join, only greys autoassign out, what i'm trying to do is make it so spawning in is automatic for newly connected players.

  10. #10
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by akuma2099 View Post
    The only thing the gametype does towards the UI when you join a server, is to grey out the choose teams so you can only pick autoassign, for which it autoassigns you to the obvious survivors team, but as soon as you press auto assign, you will still have to click a class loadout for it to actually take your guns away from you and give you the infected loadout, I tested this on an openwarfare SVN copy, just now, and it doesn't bypass the chooseclass menu when you join, only greys autoassign out, what i'm trying to do is make it so spawning in is automatic for newly connected players.
    Well, it should do. In the original gametype, you don't choose a class - you spawn straight into the game after choosing a team. And that is as it should be - what is the point in getting them to choose a class, only to take it all away again when they spawn?

    Copy the code for Old School - go through _gloaballogic.gsc and copy all the code relevant to Old School but make it relevant to the infected gametype. When you've done that, you spawn straight into the game after choosing autoassign.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •