UGX-Mods

Call of Duty: Black Ops 3 => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: shinged on October 02, 2016, 07:01:37 am

Title: My buildable script
Post by: shinged on October 02, 2016, 07:01:37 am
Hey guys, i decided to try to script my first script in black ops 3 and started with a buildable script. I'm sure this script could be improved greatly and  would love for someone to critique my code. Heres the script itself ( i copied the knuckle crack from the pack-a-punch script ).

Spoiler: click to open...
Code Snippet
Plaintext

#define PAP_WEAPON_KNUCKLE_CRACK "zombie_knuckle_crack"


function buildableinit()
{
// raygun_model = GetEnt("c_raygun", "targetname");
// raygun_model hide();

buildTable = getEnt("c_table", "targetname");
buildTable SetHintString("Missing parts");
buildTable SetCursorHint("HINT_NOICON");

level.allParts = 0;
level.finishedCraft = 3;

level thread pick1();
level thread pick2();
level thread pick3();

//level thread build();
}

function pick1()
{
pick_trig1 = getent("c_pick1", "targetname");
pick_trig1 SetHintString("Press and hold &&1 to pickup part");
pick_trig1 SetCursorHint("HINT_NOICON");
pick_model1 = getent("c_pickmodel1", "targetname");

while(1)
{
pick_trig1 waittill("trigger", player);

playfx(level._effect["powerup_grabbed"] ,GetEnt("c_pick1","targetname").origin);

level.allParts++;

//IPrintLnBold(level.allParts);

thread build();

break;
}

pick_trig1 delete();
pick_model1 delete();
}

function pick2()
{
pick_trig2 = getent("c_pick2", "targetname");
pick_trig2 SetHintString("Press and hold &&1 to pickup part");
pick_trig2 SetCursorHint("HINT_NOICON");
pick_model2 = getent("c_pickmodel2", "targetname");

while(1)
{
pick_trig2 waittill("trigger", player);

playfx(level._effect["powerup_grabbed"] ,GetEnt("c_pick2","targetname").origin);

level.allParts++;

//IPrintLnBold(level.allParts);

thread build();

break;
}

pick_trig2 delete();
pick_model2 delete();
}


function pick3()
{
pick_trig3 = getent("c_pick3", "targetname");
pick_trig3 SetHintString("Press and hold &&1 to pickup part");
pick_trig3 SetCursorHint("HINT_NOICON");
pick_model3 = getent("c_pickmodel3", "targetname");

while(1)
{
pick_trig3 waittill("trigger", player);

playfx(level._effect["powerup_grabbed"] ,GetEnt("c_pick3","targetname").origin);

level.allParts++;

//IPrintLnBold(level.allParts);

thread build();

break;
}

pick_trig3 delete();
pick_model3 delete();
}


function build()
{

while(1)
{
self waittill( level.allParts >= level.finishedCraft );

if ( level.allParts >= level.finishedCraft )
{
buildTable = GetEnt("c_table", "targetname");
buildTable SetHintString("Press and hold &&1 to craft");
buildTable SetCursorHint("HINT_NOICON");
buildTable waittill("trigger", player);

buildTable SetHintString("");

playfx(level._effect["powerup_grabbed"] ,GetEnt("c_table","targetname").origin);

player thread do_knuckle_crack();

wait(2.7);

buildTable SetHintString("^0Press and hold &&1 for ^2Raygun");
buildTable SetCursorHint("HINT_NOICON");

// raygun_model = GetEnt("c_raygun", "targetname");
// raygun_model show();

buildTable waittill("trigger", player);

weapon = getweapon("ray_gun");
    player giveweapon(weapon);
    player switchtoweapon(weapon); 

    // raygun_model = GetEnt("c_raygun", "targetname");
// raygun_model hide();

buildTable delete();
}
break;
}
}

function private do_knuckle_crack()
{
self endon("disconnect");
self upgrade_knuckle_crack_begin();

self util::waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );

self upgrade_knuckle_crack_end();

}


// Switch to the knuckles
//
function private upgrade_knuckle_crack_begin()
{
self zm_utility::increment_is_drinking();

self zm_utility::disable_player_move_states(true);

primaries = self GetWeaponsListPrimaries();

original_weapon = self GetCurrentWeapon();
weapon = GetWeapon( PAP_WEAPON_KNUCKLE_CRACK );



self GiveWeapon( weapon );
self SwitchToWeapon( weapon );
}

// Anim has ended, now switch back to something
//
function private upgrade_knuckle_crack_end()
{
self zm_utility::enable_player_move_states();

weapon = GetWeapon( PAP_WEAPON_KNUCKLE_CRACK );

// TODO: race condition?
if ( self laststand::player_is_in_laststand() || IS_TRUE( self.intermission ) )
{
self TakeWeapon(weapon);
return;
}

self zm_utility::decrement_is_drinking();

self TakeWeapon(weapon);
primaries = self GetWeaponsListPrimaries();
if( IS_DRINKING(self.is_drinking) )
{
return;
}
else
{
self zm_weapons::switch_back_primary_weapon();
}
}

Here is a video of the script

Not sure if the script is worth copying if you wanna use the script go ahead and just credit me, thanks


Double Post Merge: October 02, 2016, 02:57:13 pm
i cant edit my post, but can a mod or someone delete everything with "raygun_model" from my code. Or comment it out because it was something i tried that didn't work but forgot to take it out, thanks
Title: Re: My buildable script
Post by: HitmanVere on October 02, 2016, 06:47:48 pm
i cant edit my post, but can a mod or someone delete everything with "raygun_model" from my code. Or comment it out because it was something i tried that didn't work but forgot to take it out, thanks

Done
Title: Re: My buildable script
Post by: shinged on October 02, 2016, 07:44:30 pm
Done

Thanks hitman  :)
Title: Re: My buildable script
Post by: reckfullies on October 02, 2016, 10:45:36 pm
If you don't mind me asking, how did you get playfx to work? I was trying to use it for one of my custom traps and for some reason I couldn't get it to play any fx.

Double Post Merge: October 02, 2016, 11:29:13 pm
Also you get this error when trying to compile:  Compiler Internal Error :  Unresolved external 'util::waittill_any'

Double Post Merge: October 02, 2016, 11:32:42 pm
Just make sure you tell people what scripts to include into this script so it works.
Title: Re: My buildable script
Post by: shinged on October 03, 2016, 02:27:27 am
If you don't mind me asking, how did you get playfx to work? I was trying to use it for one of my custom traps and for some reason I couldn't get it to play any fx.

Double Post Merge: October 02, 2016, 11:29:13 pm
Also you get this error when trying to compile:  Compiler Internal Error :  Unresolved external 'util::waittill_any'

Double Post Merge: October 02, 2016, 11:32:42 pm
Just make sure you tell people what scripts to include into this script so it works.


i scripted this in my mapname gsc so it would be easier to thread, im not sure which ones are required :(.

Code Snippet
Plaintext
#using scripts\zm\_zm_utility;
#using scripts\shared\util_shared;
#insert scripts\zm\_zm_utility.gsh;

// these might be required for pap knuckle crack
#using scripts\zm\_zm_pack_a_punch;
#using scripts\zm\_zm_pack_a_punch_util;

please let me know if you get more errors, i cant believe i forgot to include which scripts i used
Title: Re: My buildable script
Post by: shinged on October 03, 2016, 02:29:05 am
If you don't mind me asking, how did you get playfx to work? I was trying to use it for one of my custom traps and for some reason I couldn't get it to play any fx.

Double Post Merge: October 02, 2016, 11:29:13 pm
Also you get this error when trying to compile:  Compiler Internal Error :  Unresolved external 'util::waittill_any'

Double Post Merge: October 02, 2016, 11:32:42 pm
Just make sure you tell people what scripts to include into this script so it works.

oh and i assume i got playfx to work because i scripted it inside my mapname gsc and i had all the scripts pretty much available to me
Title: Re: My buildable script
Post by: M0ul3_G4m3r on October 03, 2016, 05:47:34 pm
Hello !
How I can add this in my custom map please ?  :D
Title: Re: My buildable script
Post by: shinged on October 03, 2016, 09:02:50 pm
Hello !
How I can add this in my custom map please ?  :D

add the script to the bottom of your mapname gsc, and thread it in the main function.
Put this
Code Snippet
Plaintext
#define PAP_WEAPON_KNUCKLE_CRACK		"zombie_knuckle_crack"
at the top of your gsc.

then make 4 triggers and 3 models and give them the kvp's i have in the script.
Title: Re: My buildable script
Post by: reckfullies on October 03, 2016, 09:04:00 pm

i scripted this in my mapname gsc so it would be easier to thread, im not sure which ones are required :(.

Code Snippet
Plaintext
#using scripts\zm\_zm_utility;
#using scripts\shared\util_shared;
#insert scripts\zm\_zm_utility.gsh;

// these might be required for pap knuckle crack
#using scripts\zm\_zm_pack_a_punch;
#using scripts\zm\_zm_pack_a_punch_util;

please let me know if you get more errors, i cant believe i forgot to include which scripts i used

I did end up fixing it since I just went into the pack a punch script and found what includes I needed.

Also, in my buildables script I have the knuckle crack sounds included as well, ill give you stuff to add them to yours if you want.
Title: Re: My buildable script
Post by: MEGALELZ on October 04, 2016, 09:38:41 am
How do we change what item it builds?

This is dope tho, thanks!
Title: Re: My buildable script
Post by: Blink-420 on October 05, 2016, 01:29:13 am
Sorry might be dumb to ask...but I've read the replies and your post and through the script you've posted. I'm not very comfortable with scripting much yet..I'm a little confused on what I'm supposed to do exactly to add this to my map. If you don't mind could you explain with even more detail on how to add it. Thanks in advance! Script looks great! :)
Title: Re: My buildable script
Post by: ulraz_viper on October 05, 2016, 02:38:54 am
Could you go more in depth on the models/triggers types and KVPs please?
Title: Re: My buildable script
Post by: reckfullies on October 05, 2016, 09:56:59 am
How do we change what item it builds?

This is dope tho, thanks!

If you want it to be a different weapon, go into his script and find:
Code Snippet
Plaintext
weapon = getweapon("ray_gun"); 

and replace "ray_gun" with one of the weapons from this list(If it is a custom weapon just use whatever name you set that as): Link (https://confluence.ugx-mods.com/display/UGXMODS/BO3+%7C+Weapon+List)

However if you want to make it a non-weapon item you would need to script that your self obviously then use what ever way you want to give it to the player.
Title: Re: My buildable script
Post by: M0ul3_G4m3r on October 05, 2016, 02:58:31 pm
I have this error when i want to compile :
Quote
Compiler Internal Error :  Uninitialized local variable 'pap_weapon_knuckle_crack'
Title: Re: My buildable script
Post by: ulraz_viper on October 05, 2016, 04:29:33 pm
Ive got it working now.. thank you for this.. ive now been able to expand on it and do the things ive wanted.
Title: Re: My buildable script
Post by: shinged on October 05, 2016, 06:13:35 pm
Ive got it working now.. thank you for this.. ive now been able to expand on it and do the things ive wanted.

np man, glad my script could help!
Title: Re: My buildable script
Post by: Dcchill on November 17, 2016, 06:10:40 pm
Thanks for this! BTW loved your minecraft map, could you teach us how to make those cells some day too?
Title: Re: My buildable script
Post by: shinged on November 18, 2016, 07:56:29 pm
Thanks for this! BTW loved your minecraft map, could you teach us how to make those cells some day too?

Yep, maybe at some point ill make a tutorial for them, since they are super easy to setup
Title: Re: My buildable script
Post by: Blink-420 on November 19, 2016, 08:13:58 am
Works great solo thank you. But for multiplayer when anyone picks it up, it takes all their weapons and all their points with the samantha laugh. How do I fix this? :(
Title: Re: My buildable script
Post by: AciD_Alcoholic on February 01, 2017, 10:44:51 pm
Can anybody help me out with putting the KVP's in the triggers and the table?
 :) :poker: :poker: