PDA

View Full Version : Infected Gametype for CoD4



akuma2099
22nd August 2015, 05:08
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

kung foo man
22nd August 2015, 06:17
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.

akuma2099
22nd August 2015, 08:08
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

akuma2099
22nd August 2015, 09:04
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 :)

Tally
22nd August 2015, 09:05
Change how the default weapon is picked:

Main function:


level.scr_inf_sur_force_weapon = toLower( getdvarx( "scr_inf_sur_force_weapon", "string", "winchester1200_mp;winchester1200_reflex_mp;winches ter1200_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:

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.

akuma2099
22nd August 2015, 10:00
Change how the default weapon is picked:

Main function:


level.scr_inf_sur_force_weapon = toLower( getdvarx( "scr_inf_sur_force_weapon", "string", "winchester1200_mp;winchester1200_reflex_mp;winches ter1200_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:

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


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

akuma2099
22nd August 2015, 10:13
Right now, i'm trying to get around this part of the 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?

Tally
22nd August 2015, 10:44
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.

akuma2099
22nd August 2015, 11:47
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.

Tally
22nd August 2015, 11:55
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.

akuma2099
22nd August 2015, 15:26
Worked, thanks very much Tally :).