UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[Tutorial] Buildable power switch

broken avatar :(
Created 7 years ago
by shinged
0 Members and 1 Guest are viewing this topic.
16,662 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 February 2014
Last active: 1 year ago
Posts
69
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
What is broken can be reforged
Signature
Completed maps:
Kingdom Hearts - World at War Link
Minecraft - Black ops 3 Link

WIP:
~

×
shinged's Groups
shinged's Contact & Social LinksShingedvinny545TheShingedMatarra_
Heres the finished result


So to start off, download this prefab https://mega.nz/#!M9sBhZCT!ewDyF1nJVaCDdHUtc8UrcN_tKXM6Zl0_L4ca7xblPSg
Place the prefab in root/map_source/_prefabs/ and your ready for radiant.

Radiant:
 All you need to do is open the prefab by going to misc > prefab and opening the prefab, then stamp the prefab and move the pieces where you want them to be. If your on a tutorial map then delete the other power switch or this wont work.

Script:
 Navigate over to your mapname.gsc in root/usermaps/mapname/scripts/zm/mapname.gsc (Not the CSC) and open it.
 
 Below this
Code Snippet
Plaintext
#using scripts\zm\zm_usermap;
Add this
Code Snippet
Plaintext
#define PAP_WEAPON_KNUCKLE_CRACK		"zombie_knuckle_crack"


 At the bottom of the main function, add this
Code Snippet
Plaintext
thread buildableinit();

 And finally at the bottom of your gsc, paste this
Code Snippet
Plaintext
function buildableinit()
{
buildTable = getEnt("powcraft_crafting_trig", "targetname");
buildTable SetHintString("Missing parts");
buildTable SetCursorHint("HINT_NOICON");

level.allParts = 0;
level.finishedCraft = 2;

power_trigger = GetEnt("use_elec_switch", "targetname");
power_trigger TriggerEnable( false );
power_handle_model = GetEnt("elec_switch", "script_noteworthy");
power_handle_model hide();
power_clip = GetEnt("powcraft_clip_build", "targetname");
power_clip hide();
power_shaft_model = GetEnt("powcraft_build1", "targetname");
power_shaft_model hide();

level thread pick1();
level thread pick2();
}

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

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

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

level.allParts++;

//IPrintLnBold(level.allParts);

thread build();

break;
}

pick_trig1 delete();
pick_model1 delete();
}

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

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

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

level.allParts++;

//IPrintLnBold(level.allParts);

thread build();

break;
}

pick_trig2 delete();
pick_model2 delete();
}

function build()
{

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

if ( level.allParts >= level.finishedCraft )
{
buildTable = GetEnt("powcraft_crafting_trig", "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("powcraft_crafting_trig","targetname").origin);

player thread do_knuckle_crack();

wait(2.7);

thread power_crafted();

buildTable delete();
}
break;
}
}

function power_crafted()
{
power_trigger = GetEnt("use_elec_switch", "targetname");
power_trigger TriggerEnable( true );
playfx(level._effect["powerup_grabbed"] ,GetEnt("use_elec_switch","targetname").origin);
power_handle_model = GetEnt("elec_switch", "script_noteworthy");
power_handle_model show();
power_clip = GetEnt("powcraft_clip_build", "targetname");
power_clip show();
power_shaft_model = GetEnt("powcraft_build1", "targetname");
power_shaft_model show();
}

/*
KNUCKLE CRACK SCRIPT
*/
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();
}
}
/*
KNUCKLE CRACK SCRIPT END
*/
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 18 February 2015
Last active: 1 month ago
Posts
63
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Blink-420's Groups
Blink-420's Contact & Social LinksBlink-420
Was hoping for this soon..Thank you very much! Works flawlessly
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 September 2015
Last active: 3 years ago
Posts
4
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Warheez's Groups
Warheez's Contact & Social Links
This is beautiful! Going to try it out later  :D

Double Post Merge: October 17, 2016, 04:10:58 pm
Works perfectly! I give it 5 out of 5 Slav-Squats  ;)
Last Edit: October 17, 2016, 04:10:58 pm by Warheez
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
Signature
Let he who has not sinned cast the first stone.
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
Very nice, thanks.

I noticed something in the script: Your functions pick1() and pick2() both thread your build() function, so essentially you have 2 of the same build() functions running in parallel, and build() won't break if you only have 1 part, because the first line wait's until the variable level.allParts equals 2.

Does this explain why some custom maps are playing the power up sound twice for players when you hit the power switch?

The way you have it set up is perfect, but instead of threading build() two times in the pick1() and pick2() functions, just thread build() once before pick1() & pick2() are threaded, and it will only execute once after the variable level.allParts= 2. Then of course remove the "thread build()" line from pick1() and pick2().

Maybe i'm reading it wrong or something, but just thought I would give some potentially helpful feedback. Thanks again, this is very useful.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Very nice, thanks.

I noticed something in the script: Your functions pick1() and pick2() both thread your build() function, so essentially you have 2 of the same build() functions running in parallel, and build() won't break if you only have 1 part, because the first line wait's until the variable level.allParts equals 2.

Does this explain why some custom maps are playing the power up sound twice for players when you hit the power switch?

The way you have it set up is perfect, but instead of threading build() two times in the pick1() and pick2() functions, just thread build() once before pick1() & pick2() are threaded, and it will only execute once after the variable level.allParts= 2. Then of course remove the "thread build()" line from pick1() and pick2().

Maybe i'm reading it wrong or something, but just thought I would give some potentially helpful feedback. Thanks again, this is very useful.

You are correct, from what I see there is also no need to use a while loop inside the build function since waittill only needs to be called once and it will continue to wait.

I believe this was the first script he released so its safe to assume that it might have errors.
broken avatar :(
×
broken avatar :(
Location: maWHY U WANT THIS?
Date Registered: 5 July 2016
Last active: 6 years ago
Posts
19
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
LingerCustomMap's Contact & Social LinksFuryLingerOfficial
I Will try this :D
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 4 June 2017
Last active: 7 years ago
Posts
1
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
BarkseyLXIX's Groups
BarkseyLXIX's Contact & Social Links
i put the script into to my gsc and loaded the game after i did everything and i got fatal error "getweapon" with 0 parameters in script at line 306
***unresolved external "getweapon" with 0 parameters in script
and this  is what is at line 306, weapon = GetWeapon( PAP_WEAPON_KNUCKLE_CRACK );

can anyone help?
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
i put the script into to my gsc and loaded the game after i did everything and i got fatal error "getweapon" with 0 parameters in script at line 306
***unresolved external "getweapon" with 0 parameters in script
and this  is what is at line 306, weapon = GetWeapon( PAP_WEAPON_KNUCKLE_CRACK );

can anyone help?

You're getting an unresolved variable, which probably means the .gsh file in which PAP_WEAPON_KNUCKLE_CRACK is defined isn't getting parsed or included somewhere. Or simply that PAP_WEAPON_KNUCKLE_CRACK isn't defined. In my script I did it differently, like this
Code Snippet
Plaintext
	weapon = GetWeapon("zombie_builder");

and in that script at the top I put
Code Snippet
Plaintext
#precache("weapon", "zombie_builder");

I may be wrong, but good luck.
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 8 months ago
Posts
3,997
Respect
1,024Add +1
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
You're getting an unresolved variable, which probably means the .gsh file in which PAP_WEAPON_KNUCKLE_CRACK is defined isn't getting parsed or included somewhere. Or simply that PAP_WEAPON_KNUCKLE_CRACK isn't defined. In my script I did it differently, like this
Code Snippet
Plaintext
	weapon = GetWeapon("zombie_builder");

and in that script at the top I put
Code Snippet
Plaintext
#precache("weapon", "zombie_builder");

I may be wrong, but good luck.

You are somewhat right, but the real reason is that he didn't follow the guide properly:
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
That's cool, how did you crop that part of his tutorial in your reply?
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
Signature
Aye mate you don't know me so y don't you shut tf up ok buddy :)

×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Scobalula's Contact & Social Links
That's cool, how did you crop that part of his tutorial in your reply?

It's a screenshot.
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 1 October 2017
Last active: 4 years ago
Posts
1
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
My Contact & Social Links
More
×
GAMERMANRAF's Groups
GAMERMANRAF's Contact & Social LinksRaf,s studio
Does this work for Call of Duty World at War??

I really need this for my cod waw custom map  :-\
broken avatar :(
×
broken avatar :(
Location: gbEurasian Plate, The Crust, Earth, The Solar System, The Milky Way
Date Registered: 4 November 2014
Last active: 10 days ago
Posts
181
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Mod Tools Tutorial Creator YouTube.com/IceGrenade
Signature
YouTuber Call of Duty Mod Tools Tutorial Creator on YouTube.com/IceGrenade
×
IceGrenade's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Hello 👋
Last Edit: November 06, 2023, 02:44:08 pm by IceGrenade

 
Loading ...