Modme Forums
Menu:

Random/Player-Specific Starting Weapons

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: Ducky
Huge thanks to HarryBO21 for helping me work out where to place the code for it to be overwriting the default setup.

Each player gets a different weapon as opposed to Kyassuru style random weapon from pool.

Instructions:


<ol><li>Copy

zm_usermap.gsc
from
root\share\raw\scripts\zm into root\usermaps[mapname].gsc\scripts\zm
</li>
<li>Open the script file and navigate to
function giveCustomLoadout
and replace the entire function with the following code:</li>
</ol>
function giveCustomLoadout( takeAllWeapons, alreadySpawned ){
if(!isDefined(level.weapons) || level.weapons.size&lt;1){
//DEFINE YOUR WEAPONS HERE
level.weapons = [];
level.weapons[0] = "WEAPON_1"; //Dempsey
level.weapons[1] = "WEAPON_2"; //Takeo
level.weapons[2] = "WEAPON_3"; //Richtofen
level.weapons[3] = "WEAPON_4"; //Nikolai
}

weapon = getWeapon(level.weapons[self.characterIndex]);
self giveWeapon(level.weaponBaseMelee);
//self zm_utility::give_start_weapon(true);
self zm_weapons::weapon_give(weapon, false, false, true, 1);
}

3. Replace the four weapon names (e.g.
"WEAPON_1"
) with the four the weapons (their weaponfile names/what you put after
weapon,
in the zone file) you want s to spawn with (e.g.
lmg_slowfire
).
4. Open
[mapname].gsc
and add
#using scripts\zm\zm_usermap;
to the top of the file with the rest of the
#using
's.
5. In the
function main()
of
[mapname].gsc
add
zm_usermap::main();
6. Open
[mapname].zone
and add
scriptparsetree,scripts/zm/zm_usermap.gsc


ModmeBot:

Reply By: Unity_N
For step 6, shouldn't you paste that line of code in mapname.zone instead of mapname.gsc?


ModmeBot:

Reply By: itznvy
Is it possible for you to script where each character has their own randomized weapon? For example Dempsey may spawn with an m1911, but Nikolai may spawn with a Mauser.


ModmeBot:

Reply By: Ducky

itznvy
Is it possible for you to script where each character has their own randomized weapon? For example Dempsey may spawn with an m1911, but Nikolai may spawn with a Mauser.

Unless I'm misunderstanding you, that's exactly what this script does.


ModmeBot:

Reply By: Ducky

Unity_N
For step 6, shouldn't you paste that line of code in mapname.zone instead of mapname.gsc?

Good spot, thanks. I've fixed it.


ModmeBot:

Reply By: The Black Death

Ducky
itznvy Is it possible for you to script where each character has their own randomized weapon? For example Dempsey may spawn with an m1911, but Nikolai may spawn with a Mauser. Unless I'm misunderstanding you, that's exactly what this script does.

I think he means that each character gets their own random weapon pool.

if so:
I tweaked it a bit to result in this.

Under
//DEFINE YOUR WEAPONS HERE

Put:
//this tweak should work but I probably messed up. Don&#39;t bite my head off if I did, I&#39;ll fix it.
		
		// ************** Dempsey Weapon Pool
		level.weaponPoolDempsey = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolDempsey[0] = "weapon here";
		level.weaponPoolDempsey[1] = "weapon here";
		// **************
		
		// ************** Takeo Weapon Pool
		level.weaponPoolTakeo = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolTakeo[0] = "weapon here";
		level.weaponPoolTakeo[1] = "weapon here";
		// **************
		
		// ************** Richtofen Weapon Pool
		level.weaponPoolRichtofen = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolRichtofen[0] = "weapon here";
		level.weaponPoolRichtofen[1] = "weapon here";
		// **************
		
		// ************** Nikolai Weapon Pool
		level.weaponPoolNikolai = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolNikolai[0] = "weapon here";
		level.weaponPoolNikolai[1] = "weapon here";
		// **************

The code provides information on how to use the pool, by the way.

Now, replace:
level.weapons[0] = "WEAPON_1"; //Dempsey
        level.weapons[1] = "WEAPON_2"; //Takeo
        level.weapons[2] = "WEAPON_3"; //Richtofen
        level.weapons[3] = "WEAPON_4"; //Nikolai

with:
level.weapons[0] = level.weaponPoolDempsey[RandomIntRange(0, level.weaponPoolDempsey.size)]; //Dempsey
        level.weapons[1] = level.weaponPoolTakeo[RandomIntRange(0, level.weaponPoolTakeo.size)]; //Takeo
        level.weapons[2] = level.weaponPoolRichtofen[RandomIntRange(0, level.weaponPoolRichtofen.size)]; //Richtofen
        level.weapons[3] = level.weaponPoolNikolai[RandomIntRange(0, level.weaponPoolNikolai.size)]; //Nikolai


if this was what you needed, hopefully I helped. :)

<em>I probably messed up the code due to my little experience with GSC, but you never know...</em>


ModmeBot:

Reply By: Ducky
Yeah, that looks like it if that's what they meant.


ModmeBot:

Reply By: itznvy
That's what i meant. I tried that script and i spawned in without a weapon. This is what i put in zm_usermap.gsc
Tell me if there's any issues as I really don't know how to script

function giveCustomLoadout( takeAllWeapons, alreadySpawned )
{
if(!isDefined(level.weapons) || level.weapons.size&lt;1)
level.weapons = [];
// ************** Dempsey Weapon Pool
		level.weaponPoolDempsey = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolDempsey[0] = "bo1_m1911";
		level.weaponPoolDempsey[1] = "mw2_g18";
		// **************
		
		// ************** Takeo Weapon Pool
		level.weaponPoolTakeo = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolTakeo[0] = "bo1_m1911";
		level.weaponPoolTakeo[1] = "mw2_g18";
		// **************
		
		// ************** Richtofen Weapon Pool
		level.weaponPoolRichtofen = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolRichtofen[0] = "bo1_m1911";
		level.weaponPoolRichtofen[1] = "mw2_g18";
		// **************
		
		// ************** Nikolai Weapon Pool
		level.weaponPoolNikolai = [];
		//Duplicate the line below and change 0, 1, etc to the next consecutive number. so if I wanted a third weapon to be chosen from it&#39;d be 2, then a 4th would be 3, etc. Change weapon here to your weapon name. Same rules apply here for weapon name to put in as in the original script.
		level.weaponPoolNikolai[0] = "bo1_m1911";
		level.weaponPoolNikolai[1] = "mw2_g18";
		// **************
		level.weapons[0] = level.weaponPoolDempsey[RandomIntRange(0, level.weaponPoolDempsey.size)]; //Dempsey
        level.weapons[1] = level.weaponPoolTakeo[RandomIntRange(0, level.weaponPoolTakeo.size)]; //Takeo
        level.weapons[2] = level.weaponPoolRichtofen[RandomIntRange(0, level.weaponPoolRichtofen.size)]; //Richtofen
        level.weapons[3] = level.weaponPoolNikolai[RandomIntRange(0, level.weaponPoolNikolai.size)]; //Nikolai
}