UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: ConvictioNDR on January 13, 2018, 02:41:42 am

Title: [Tutorial] One in the Chamber Survival Script
Post by: ConvictioNDR on January 13, 2018, 02:41:42 am
It's been awhile. I have no plans to work in BO3 in the near future, so I've decided to release some stuff for the community to use. Keep in mind, I'm not the best scripter.

Make a new .gsc file in the proper scripts folder for your mod or map, and paste all of this into it.
Name it whatever you want, or give it it's own namespace. Whatever you want to do. I named the script one_in_the_chamber because I'm creative.
Code Snippet
Plaintext
//read comments for helpful tips
//Spawns players with a random weapon each game for one in the chamber

#using scripts\shared\array_shared;
#using scripts\shared\util_shared;
#using scripts\shared\callbacks_shared;
#using scripts\codescripts\struct;

function main()
{
    thread no_weapons();
callback::on_spawned(&oic_start);
}
function no_weapons() //this function disables wall buys. You have to disable magic box and pack a punch separately.
{
level.func_override_wallbuy_prompt = &nothing_func;
}

function nothing_func()
{
self.stub.hint_string = "";
self.stub.cursor_hint = "HINT_NOICON";
}
function onPlayerDisconnect()
{
    self waittill( "disconnect" );
}
function oic_start()
{
    self thread onPlayerDisconnect();
    self endon("death");
    self endon("disconnect");
    wait 0.05;
    self give_oic_weapon();
    self thread kill_watcher();
}
function give_oic_weapon()
{
    self endon("death");
    self endon("disconnect");
    wait 0.05;
weapons = []; //weapons array, follow the pattern to add more weapon options
weapons[0] = "sniper_powerbolt";
weapons[1] = "shotgun_precision";
weapons[2] = "launcher_standard";
weapons[3] = "sniper_fastsemi";
weapons[4] = "sniper_fastbolt";

oic_weap = weapons[randomIntRange(0,5)]; //set the 2nd number to 1 higher than the last number in your weapons array
    self TakeAllWeapons();
weap = getweapon(oic_weap);
self giveweapon(weap);
self setWeaponAmmoClip(weap, 1);
self setWeaponAmmoStock(weap, 0);
self switchToWeapon(weap);
stabby = GetWeapon( "knife" );
self GiveWeapon( stabby );
}
function kill_watcher()
{
    self endon("death");
    self endon("disconnect");

    while(IsAlive(self))
    {
        self waittill("zom_kill");
        weapon = self getcurrentweapon();
ammo_clip = self getWeaponAmmoClip(weapon);
self setWeaponAmmoClip(weapon, ammo_clip + 1);
self setWeaponAmmoStock(weapon, 0); //this part stops there from ever being more ammo than what is in the magazine aka no stock ammo, only clip ammo
    }
}

Now need to make it so the max ammo powerup will fill up the clip ammo, not the stock ammo. Copy _zm_powerup_full_ammo.gsc to the proper scripts folder.
Find
Code Snippet
Plaintext
players[i] GiveMaxAmmo( primary_weapons[x] );
Comment that line out then add this line right after it
Code Snippet
Plaintext
players[i] SetWeaponAmmoClip( primary_weapons[x], 125 );
So it looks like
Code Snippet
Plaintext
if ( players[i] HasWeapon( primary_weapons[x] ) )
//players[i] GiveMaxAmmo( primary_weapons[x] );
players[i] SetWeaponAmmoClip( primary_weapons[x], 125 );
Then need to disable the magic box. I did the lazy way of just commenting out some stuff. Maybe someone knows a better way by now.
Copy _zm_magicbox.gsc to the proper scripts folder.
Open it and find
Code Snippet
Plaintext
if ( zm_utility::is_Classic() )
Just comment that whole if statement out so it looks like
Code Snippet
Plaintext
	//if ( zm_utility::is_Classic() )
//{
//level.chests = struct::get_array( "treasure_chest_use", "targetname" );
//treasure_chest_init( level.start_chest_name );
//}
Then firesale obviously is useless without mystery boxes so I made it so firesale gives a new weapon to the players with max ammo.
Copy _zm_powerup_fire_sale.gsc to the proper scripts folder then open it and somewhere at the top add
Code Snippet
Plaintext
#using scripts\zm\one_in_the_chamber;
If you named your script something different then you need to change the one_in_the_chamber part to whatever it is or use the namespace you gave it.
Then still in firesale script find
Code Snippet
Plaintext
function grab_fire_sale( player )
Replace that entire function with
Code Snippet
Plaintext
function grab_fire_sale( player )
{
players = getplayers();
foreach (player in players)
{
player one_in_the_chamber::give_oic_weapon();
wait 0.5;
player thread more_ammo();
}
//level thread start_fire_sale( self );
//player thread zm_powerups::powerup_vo("firesale");
}
function more_ammo() //gives the player full ammo for new gun
{
weapon = self getcurrentweapon();
ammo_clip = self getWeaponAmmoClip(weapon);
self setWeaponAmmoClip(weapon, ammo_clip + 125);
self setWeaponAmmoStock(weapon, 0);
}
The minigun powerup. If they pick up the minigun powerup and kill a zombie it will give them one bullet for the minigun and screw things up, so I just made it so minigun powerup gives more ammo.
So copy _zm_powerup_weapon_minigun.gsc to the proper scripts folder. Open it and find...
Code Snippet
Plaintext
function grab_minigun( player )
and replace that function with
Code Snippet
Plaintext
function grab_minigun( player )
{
level thread give_bullets( player );
//level thread minigun_weapon_powerup( player );
player thread zm_powerups::powerup_vo( "minigun" );

if( IsDefined( level._grab_minigun ) )
{
level thread [[ level._grab_minigun ]]( player );
}
}

function give_bullets( ent_player )
{
weapon = ent_player getcurrentweapon();
ammo_clip = ent_player getWeaponAmmoClip(weapon);
ent_player setWeaponAmmoClip(weapon, ammo_clip + 5); //change to amount of bullets you want to give
ent_player setWeaponAmmoStock(weapon, 0);
}
So it's just giving 5 bullets instead of full clip.

Okay, finally. The pack a punch machine. I didn't want it active in my version cuz the guns are already strong, then pack a punching would make the game go forever. So, once again; I went the lazy quick route of commenting stuff out. Someone probably found a better way to deactivate pack a punch by now.
Copy _zm_pack_a_punch.gsc to the proper scripts folder and open it and find...
Code Snippet
Plaintext
use_trigger
I just commented every line that had use_trigger in it.

Don't forget to call your script somewhere for your map or mod. Since I did a mod, I called the script in my magicbox script. So the using...
Code Snippet
Plaintext
//one in the chamber
#using scripts\zm\one_in_the_chamber;
Then call the script in a function somewhere that will call it before the players spawn. I did it at the end of function __init__() in _zm_magicbox.gsc
Code Snippet
Plaintext
one_in_the_chamber::main();

I believe that's everything. I deleted the BO3 tools awhile ago so can't really test the tutorial on my own or really support the tutorial any further. I'm sure some brilliant scripter in the community could make a better script and tutorial but here's this decent one I wrote, now for anyone to use.

Oh, I guess for anyone that wants to see how the mode plays