UGX-Mods

Call of Duty: Black Ops 3 => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: Archaicvirus on March 29, 2017, 02:44:28 am

Title: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on March 29, 2017, 02:44:28 am
This is my first script release, or any release for that matter.

Contained is my custom buildables framework, including a buildable power switch with prefabs for everything, and custom shaders for the parts. To make the shaders (part HUD icons) I simply took a few screenshots of the 3D models in APE, then used photoshop to cut out the part and overlay it on a transparent background, cropped to about 100 X 200 pixels, then set up the materials in APE.

I tried to make this a simple install, so it can be implemented with a few clicks and ctrl+v's. I also extracted sounds from zetsubo to get some nice crafting sounds, building, part pickup, and build complete sounds. I made the "building" logic very fool-proof, meaning there are checks for distance as well as if the player is holding the use button, so if they go out of range of the build-table, or release the use button (plus other checks) then the crafting animation and HUD will cancel instantly. So the player has to remain at the trigger and hold the use button for the entire build process to complete the action or it will reset. I also added in some logic for split-screen players, so the shaders scale in size and position to accommodate.

Instructions:
Download the file and unzip it to your desktop. Drag the contents of the folder named "drag_contents_2root" into you bo3 root directory.

Then move the "custom_buildables_random.gsc" into your mapname\scripts folder.

Open your mapname.gsc in a text editor, navigate to:
Code Snippet
Plaintext
function main()
{

Then paste this line at the bottom:
Code Snippet
Plaintext
level thread custom_buildables_random::init();
*EDIT: then add this line to your mapname.gsc somehere near the other "#using" lines:
Code Snippet
Plaintext
#using scripts\zm\custom_buildables_random;
Next, right-click on your map in launcher, click edit zone file. Add these lines at the bottom:
Code Snippet
Plaintext
scriptparsetree,scripts/zm/custom_buildables_random.gsc
xmodel,p7_zm_der_pswitch_body
xmodel,p7_zm_der_pswitch_handle
xmodel,p7_zm_zod_fuse
material,power_panel_shader
material,power_handle_shader
material,power_fuse_shader

Now navigate to your mapname\sound\zoneconfig - and open your mapname.SZC file in a text editor then add these lines:
Code Snippet
Plaintext
{
 "Type" : "ALIAS",
 "Name" : "arch_custom_build_sounds",
 "Filename" : "arch_custom_build_sounds.csv",
 "Specs" : [ ]
}

//Add that block of code above the curly and square brackets at the bottom - shown below

]
}

Now in radiant, the prefabs are located in mapsource\_prefabs\archaicvirus_buildables_prefabs. Delete your old power switch first. Drop down the master_power_switch prefab wherever you want the power switch to be. Don't forget that step or it will fail. Then drop down at least 4 of each part's prefab - handle, panel, and fuse. The script will choose a random location to spawn each part, and delete the rest of them each time the map is loaded.  *EDIT: Don't forget to do a full compile\light\link before you test.

When the game starts, the main power panel is hidden. You will see the frame with the chalk lightning bolt on it. This is also the location where you will build the panel. As you pick up each part in-game, it plays a sound, and the default green power-up splash fx. It then draws the part shader on the top-rightish side of all players screen, but only the player who grabbed the part will hear the sound. You can chop up the script all you want to fit your needs. Just study the script and you can see how all the functions are anonymous, meaning you can use them for your own custom buildables. If you need help just let me know. I'm by far an expert but i'll do my best if you want to do something custom.

www.dropbox.com


The video skips a little and vid/sound is a bit out of sync due to my lack of recording experience. In-game though everything is perfect, no lag.

If you use this I would appreciate a shoutout, but I'm not too worried about it either way, just hope it's useful to the modding community in general.

Here is the raw code if you're interested. Note: You need the download + full install for this to work, (includes  sounds, sound alias, custom part shaders, prefabs etc)
Code Snippet
Plaintext
#using scripts\codescripts\struct;

#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\demo_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\hud_util_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;

#insert scripts\shared\shared.gsh;
#insert scripts\shared\version.gsh;

#using scripts\zm\_zm_bgb;
#using scripts\zm\_zm_equipment;
#using scripts\zm\_zm_stats;
#using scripts\zm\_zm_unitrigger;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_weapons;

#insert scripts\zm\_zm_perks.gsh;
#insert scripts\zm\_zm_utility.gsh;
#insert scripts\zm\craftables\_zm_craftables.gsh;
#precache("model", "p7_zm_der_pswitch_body");
#precache("model", "p7_zm_der_pswitch_handle");
#precache("model", "p7_zm_zod_fuse");
#precache("weapon", "zombie_builder");
#precache( "material", "power_panel_shader");
#precache( "material", "power_handle_shader");
#precache( "material", "power_fuse_shader");
#namespace custom_buildables_random;

  ///////////////////////////////////////
 //         ITITIALIZE FLAGS          //
///////////////////////////////////////
function init(){
level flag::wait_till("all_players_connected");
foreach(player in GetPlayers()){
player.shader_var = [];
}
//wait(3);
//FLAG COMMANDS:
//level flag::init("flagname", false); <-- false so flag is OFF by default, but registered for use in script
//level flag::set("flagname"); <-- turns on "flagname"
//level flag::clear("flagname"); <-- turns off "flagname"
//level flag::get("flagname"); <-- returns true or false if "flagname" is on or off
thread buildable_power();
//thread buildable_e115();
}

  ///////////////////////////////////////
 //         BUIDABLE POWER            //
///////////////////////////////////////
function buildable_power(){
finalflag = "power_crafted";
level flag::init(finalflag, false);
level flag::init("handle_flag", false);
level flag::init("panel_flag", false);
level flag::init("fuse_flag", false);
power_trig = GetEnt("use_elec_switch", "targetname");
power_trig SetCursorHint("HINT_NOICON");
power_trig TriggerEnable(false);
//power_clip = GetEnt("power_clip", "targetname");
//power_clip Hide();
power_panel = GetEnt("main_panel", "targetname");
power_panel Hide();
power_lever = GetEnt("elec_switch", "script_noteworthy");
power_lever Hide();
power_bench = GetEnt("craft_bench", "targetname");
bench_fx_loc = GetEnt(power_bench.target, "targetname");
power_bench.built = false;
power_bench SetCursorHint("HINT_NOICON");
power_bench SetHintString("Missing parts");
fuses = GetEntArray("power_fuse", "script_noteworthy");
handles = GetEntArray("power_handle", "script_noteworthy");
panels = GetEntArray("power_panel", "script_noteworthy");
thread random_spawn(handles, "handle_flag", "p7_zm_der_pswitch_handle", "high-voltage lever");
thread random_spawn(panels, "panel_flag", "p7_zm_der_pswitch_body", "industrial housing");
thread random_spawn(fuses, "fuse_flag", "p7_zm_zod_fuse", "electrical fuse");
power_bench thread build_logic(bench_fx_loc, finalflag, "handle_flag", "panel_flag", "fuse_flag", "electrical panel");
//This function can be copied, and renamed to easily
//create new buildables. Just change the "craft_bench"
//targetname on the bench trigger to "craft_bench_trig_name" etc
//It threads all the stamped prefabs for specified parts
//and deletes all but one. The prefab comes with the model, but you
//first position the prefab wherever you want the part to spawn, then
//you stamp the prefab.
//Lastly -- Threads the random spawn function with the array's of
//each part's possible spawn locations, and the flags to activate when picked up

while(1){
if(level flag::get("power_crafted") == true){
//power_clip Show();
power_panel Show();
power_lever Show();
power_trig TriggerEnable(true);
break;
}else
wait(.1);
}
}

  ///////////////////////////////////////
 //          BUILD LOGIC              //
///////////////////////////////////////
function build_logic(bench_fx_loc, final_flag, part1_flag, part2_flag, part3_flag, build_hint){
while(1){
if(level flag::get(part1_flag) && level flag::get(part2_flag) && level flag::get(part3_flag)){
self SetHintString("Hold &&1 to build "+build_hint);
self waittill("trigger", player);
self SetHintString("");
player PlaySound("build_loop");
PlayFX(level._effect["building_dust"], bench_fx_loc);
player thread crafting_hud(self, final_flag);
player thread custom_craft_anim();
player util::waittill_any("build_canceled", "build_complete");
player StopSound("build_loop");
player StopSounds();
wait(0.1);
if(self.built == true){
player PlaySound("build_done");
foreach(player in GetPlayers()){
player.shader_var1 Destroy();
player.shader_var2 Destroy();
player.shader_var3 Destroy();
}
self Delete();
break;
}
}else
wait(1);
}
}

  ///////////////////////////////////////
 //          RANDOM SPAWN             //
///////////////////////////////////////
function random_spawn(parts, flag, model, hint){
r = RandomInt(parts.size);
foreach(part in parts){
part_model = GetEnt(part.target, "targetname");
if(part == parts[r]){
part thread part_pickup(flag, hint, part_model);
}else{
part_model Delete();
part Delete();
}
}
//Takes in the parts[] array, and flags, you send from your
//buildable function. The parts array is an array of triggers
//left behind from stamping a 'random spawn point' - prefab
//The function then chooses a random trigger to save, and deletes
//the rest of the unused triggers and the script_models they're targeting
//Part pick-up logic is threaded last, right before deleting all
//the spawn locations of the random parts that weren't chosen to spawn
}

  ///////////////////////////////////////
 //        PART PICKUP LOGIC          //
///////////////////////////////////////
function part_pickup(flag, hint, part){
self SetCursorHint("HINT_NOICON");
self SetHintString("Press &&1 to pickup "+hint);
self waittill("trigger", player);
level flag::set(flag);
player PlaySound("part_pickup");
wait(0.1);
PlayFX(level._effect["powerup_grabbed"], self.origin);
foreach(player in GetPlayers()){
switch(self.script_int){
case 1:
if(player IsSplitScreen())
player thread part_shader_logic("power_fuse_shader", 1, 12, 30);
else
player thread part_shader_logic("power_fuse_shader", 1, 24, 60);
break;
case 2:
if(player IsSplitScreen())
player thread part_shader_logic("power_panel_shader", 2, 15, 30);
else
player thread part_shader_logic("power_panel_shader", 2, 31, 60);
break;
case 3:
if(player IsSplitScreen())
player thread part_shader_logic("power_handle_shader", 3, 18, 30);
else
player thread part_shader_logic("power_handle_shader", 3, 35, 60);
break;
}
part Delete();
self Delete();
}
}

  ///////////////////////////////////////
 //         PART SHADER LOGIC         //
///////////////////////////////////////
function part_shader_logic(shader, position, size_x, size_y){
hud = position - 1;
self.shader_var[hud] = NewClientHudElem(self);
self.shader_var[hud].alignX = "right";
self.shader_var[hud].alignY = "top";
self.shader_var[hud].horzAlign = "user_right";
self.shader_var[hud].vertAlign = "user_top";
if(self IsSplitScreen())
self.shader_var[hud].y = ((size_y * position) + 10) - 25;
else
self.shader_var[hud].y = ((size_y * position) + 10);
self.shader_var[hud].x = -5;
self.shader_var[hud] setShader(shader, size_x, size_y);
self waittill("power_crafted");
foreach(shader in self.shader_var){
shader Destroy();
}
}

  ///////////////////////////////////////
 //     CUSTOM CRAFTING ANIMATION     //
///////////////////////////////////////
function custom_craft_anim(){
self endon("disconnect");
self craft_anim_begin();
self util::waittill_any("fake_death", "death", "player_downed", "weapon_change_complete", "build_canceled", "build_complete");
self craft_anim_end();
}

  ///////////////////////////////////////
 //     CRAFTING ANIMATION BEGIN      //
///////////////////////////////////////
function craft_anim_begin(){
self zm_utility::increment_is_drinking();
self zm_utility::disable_player_move_states(true);
primaries = self GetWeaponsListPrimaries();
original_weapon = self GetCurrentWeapon();
weapon = GetWeapon("zombie_builder");
self GiveWeapon(weapon);
self SwitchToWeapon(weapon);
}

  ///////////////////////////////////////
 //      CRAFTING ANIMATION END       //
///////////////////////////////////////
function craft_anim_end(){
self zm_utility::enable_player_move_states();
weapon = GetWeapon("zombie_builder");
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();
}
}

  ///////////////////////////////////////
 //       CUSTOM CRAFTING HUD         //
///////////////////////////////////////
function crafting_hud(trig, flag){
self.useBar = self hud::createPrimaryProgressBar();
self.useBarText = self hud::createPrimaryProgressBarText();
self.useBarText SetText("Crafting...");
self thread crafting_hud_update(GetTime(), 3000, trig, flag);
}

  ///////////////////////////////////////
 //   CRAFTING HUD UPDATE FUNCTION    //
///////////////////////////////////////
function crafting_hud_update(start_time, craft_time, trig, flag){
self endon("entering_last_stand");
self endon("death");
self endon("disconnect");
self endon("build_canceled");

while(1){
progress = (GetTime() - start_time) / craft_time;
dist = Distance(self.origin, trig.origin);
if(dist > 100 || !self UseButtonPressed() && progress < 1){
self.useBarText hud::destroyElem();
self.useBar hud::destroyElem();
self notify("build_canceled");
break;
}
if(progress < 0){
progress = 0;
}
if(progress > 1 || GetTime() - start_time > craft_time && self UseButtonPressed()){
level flag::set(flag);
foreach(player in GetPlayers()){
player notify(flag);
}
trig.built = true;
self notify("build_complete");
self.useBarText hud::destroyElem();
self.useBar hud::destroyElem();
return trig;
break;
}
if(!self UseButtonPressed() && progress < 1){
self.useBarText hud::destroyElem();
self.useBar hud::destroyElem();
self notify("build_canceled");
break;
}
self.useBar hud::UpdateBar(progress);
WAIT_SERVER_FRAME;
}
}
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: easyskanka on March 29, 2017, 09:45:08 am
This is exactly what ive been looking for so props!!

only thing im not sure on is the part you do in APE to add in custom images
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on March 29, 2017, 12:15:33 pm
This is exactly what ive been looking for so props!!

only thing im not sure on is the part you do in APE to add in custom images

There is a tutorial on custom perks here, just look for it. In that tutorial it walks you through making your own custom perk shaders, just follow that part. Its really easy and its the same process no matter what you're using the shaders for - jumpscares, perk shaders, parts etc.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: easyskanka on March 29, 2017, 01:12:28 pm

cheers dude ill check it out, one last thing

^1ERR(6E) scripts/zm/zm_shimmy.gsc (1052,0)  : Compiler Internal Error :  Unresolved external 'custom_buildables_random::init'
 
keep getting this error when i compile, is there anything else that needs to go in the GSC or am i being stupid?

ive added the custom_buildables_random::init into my main function
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on March 29, 2017, 08:56:33 pm
cheers dude ill check it out, one last thing

^1ERR(6E) scripts/zm/zm_shimmy.gsc (1052,0)  : Compiler Internal Error :  Unresolved external 'custom_buildables_random::init'
 
keep getting this error when i compile, is there anything else that needs to go in the GSC or am i being stupid?

ive added the custom_buildables_random::init into my main function

No it's not you, add this to your mapname.gsc: Somewhere at the top with the others
Code Snippet
Plaintext
#using scripts\zm\custom_buildables_random;

Thanks for the feedback, I'll update the tutorial.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: easyskanka on March 29, 2017, 09:48:41 pm
haha thanks bud  : :poker:
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on March 30, 2017, 10:08:33 pm
No problemo, glad I could help
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Mr. Unp3rf3ct on June 16, 2017, 08:58:25 pm
This script is very nice, but i have one problem. I added new shaders for the hud elements each 200x200, but they appear very squashed ingame. Any idea why? Help would be much appreciated, Thanks.

EDIT: Apperently I had the shaders to close to the screen border. Moved them more to the left and fixed it that way, but thanks anyway +1 respect
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on June 16, 2017, 10:27:59 pm
Thanks man, if it helps, regardless of the size of the image, you can dictate the draw size when you thread
Code Snippet
Plaintext
part_shader_logic(shader, position, size_x, size_y) //size_x = width, and size_y = height

 That's what I did to scale the shaders down for split screen players, and even the full screen shaders are drawn scaled down a bit I believe. I did it that way because I wanted to have a slightly higher definition image to work with in photoshop, but not so high that downscaling has a negative quality impact. Especially when you're manually cutting out pieces of an image, I find once you downscale it, any edge artifacts are virtually eliminated (such as slivers of the background left behind when cutting out the lever)

In any case, you almost always have to re-scale your image in the end, unless you make it the perfect size from the start, I'd imagine.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Mr. Unp3rf3ct on June 17, 2017, 10:16:52 am
Thanks, but now i have a new problem. I set the position of my shaders to 1, because it makes up an image when the are all overlaying (3 fuses next to each other). Now when i build the power only one hud element disappears. I saw you were using the "position" in your part_shader_logic and now that they all have the same position it wont work anymore. I didnt find a workaround either, so i need help again. Also i implemented a buildable shield, but what do i have to do, so i can pick it up?

EDIT: I fixed the HUD, but not the shield pickup.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on June 17, 2017, 07:45:35 pm
It looks like you already figured it out, but in case you don't fully understand the way I did it, when you thread part_shader_logic(shader, position, size_x, size_y) the position determines the index of each shader in the player.shader_var[] array for every player. There are different and probably easier ways to do that, for example in part_shader_logic() you could do

Code Snippet
Plaintext
self.shader_var[self.shader_var.size] = NewClientHudElem(self); 
//And then you don't have send 'position' as an argument.

If you gave them all the same position, regardless of where you align each shader, it overwrites the last hud created since it's using the same array index as the previous one.

Honestly this whole script in my opinion is messy and desperately needs to be re-written in a more user-friendly way. I plan on making it more dynamic also, so all of the functions can just be threaded with arguments, so the user doesn't have to change the functions, only the arguments. It's mostly that way now, but not in all the functions.

Code Snippet
Plaintext
//Do the following for each shield piece:
//If you haven't already, drop down a trigger_use
//Give it a targetname of the part you're grabbing
//Now drop in a script_model of the shield part, and deselect it
//Now first select the trig, then select the script_model
//Hit W to link them. Now select both and save as a new prefab
//This will be a random spawn point for each part. Place at least 3 of these around the map

function buildable_shield(){
level flag::init("shield_finalflag", false); //For when all parts are collected
level flag::init("shield_part_1_flag", false); //For each individual part
level flag::init("shield_part_2_flag", false);
level flag::init("shield_part_3_flag", false);  //The flag commands are explained at the top of the buildables script

shield_parts[0] = GetEntArray("part1_targetname", "targetname"); //Obv change targetnames to yours
shield_parts[1] = GetEntArray("part2_targetname", "targetname");
shield_parts[2] = GetEntArray("part3_targetname", "targetname");
       
        thread random_spawn(shield_parts[0], "shield_part_1_flag", undefined, "pick-up hintstring"); //The hintstring threaded here only needs to be the name of the part
thread random_spawn(shield_parts[1], "shield_part_2_flag", undefined, "pick-up hintstring"); //As the "Press [Use] to grab" section of the hint is already set
thread random_spawn(shield_parts[2], "shield_part_3_flag", undefined, "pick-up hintstring"); //Like "shield-top", "shield-screws" or whatever they are

//Create a trigger_use where you want to craft the shield
//Drop a script_origin and place where shield will spawn once crafted
//Select trig, then script_origin, W to link, then
//I suggest changing these variables to something that makes more sense to you
//I don't think you're stupid, I'm just making these long variables so it's understandable what their purpose is

shield_craft_bench = GetEnt("name_of_trigger_where_shield_is_crafted", "targetname"); //Again change the targetnames for yours on these
shield_craft_bench.shield_spawn_location = GetEnt(shield_craft_bench.target, "targetname");
shield_craft_bench thread build_logic(shield_craft_bench.shield_spawn_location.origin, "shield_finalflag", "shield_part_1_flag", "shield_part_2_flag", "shield_part_3_flag", "build hintstring");
//build_logic(bench_fx_loc, final_flag, part1_flag, part2_flag, part3_flag, build_hint)


//Not trying to be a code snob, but you can take it from here. You got this
//Everything you need is in the script already, just follow the threads.
//I think you should make your own functions for this and use the script lines from my script that you need

//For the shaders, Destroy() or hud_util::destroyElem() deletes them
//To spawn the shield once crafted, you can place the parts as script_models in radiant at their final location,
//then in script do getent on them, then Hide() and Show() as needed,
//or you can do part = Spawn("script_model"), then part SetModel("name_of_precached_model") once crafted, to spawn them when needed
//As far as the shield functionality, that is something I don't have experience with.
//I would ask someone else for help on that, if you don't how to get it working.
//Good luck man
}
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Mr. Unp3rf3ct on June 17, 2017, 07:53:00 pm
Thanks again man. I just made it like a wallbuy for 0 points to get the shield. (I am reffering to The trigger that is activated at the end of the build function)
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on June 17, 2017, 08:07:49 pm
Sweet man, and glad to assist. I don't mean to seem condescending in any way, my thing is I just try to explain things in high detail since I don't know how much you might already know about the subject. Plus other readers can understand more. I learn a lot just looking through the help forums myself, even when I'm not having any particular issue. Which is all the time lol
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Mr. Unp3rf3ct on June 18, 2017, 08:55:05 am
I fixed every bug i knew about now and recorded a small video about the modifications. I credited you and everything.
If you want to watch it you can find it here:

Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on June 19, 2017, 04:19:40 am
Dude, that is bad ass! Great work man, I liked the brewing one you did too. +1
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: d-2-k on June 20, 2017, 01:36:44 pm
Dude this is epic worked flawlessly wish i could understand all the code and hints to do the same with the shield ive read over everything about 20 times my eyes glaze over my brain melts so bloody frustrating i guess its true what they say cant teach an old dog new tricks lol    :derp:
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on June 21, 2017, 05:53:57 am
Lol you're funny dude. Naw it's not that hard man. Trust me, there are way more experienced coders here than I ever will be. I always point people towards the folder in your games root directory. It's called docs_modtools. There's lots of documentation in there, everything from workflows to add custom assets, entity field data, even the api with example functions. There's plenty of tutorials here for scripting, but I learn a lot just looking through the help forums, you can see a lot of example code to learn from. Let me know if you need help doing you're own buildable. As long as you have the idea put together I don't mind helping you with the scripting.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: d-2-k on June 21, 2017, 01:11:30 pm
(dude that's freekin awesome) just really want to do the same with the shield i have a shield buildable  already  but no hud or fx, the sounds i got with the script from uptown but its a lot more simpler than the one you done and doesn't have fx or random spawn locations tbh its taken me so long just to learn how to use the tools for mapping as i never done any of this b4 black ops 3 radiant, then came across this site and modme and everyone both here and there are so helpful they were throwing prefabs up  with easy to follow drag n drops  so i guess i just assumed thats how it was done BOY was i wrong in my 40's now the only code i ever learned was way back on the Commadore and Amstrad days

example: 10 print you cant script for shit
              20 goto 10
              run

              lmfao

but thanks for pointing me to the docs_modtools ill have a look over it when i get peace and quite l8r tonight (ah the joys of parenthood)

thanks again Archaicvirus
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Conbini2017 on December 25, 2017, 12:54:04 pm
I would like to be of assistance, but I have added two buildables, but when I make it the shader will not disappear.
Please show me an example script.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on December 30, 2017, 12:27:36 am
Post your code, and I'll take a look. Also, tell me what you did in radiant so I can determine if your buildables are set up correctly.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Conbini2017 on December 30, 2017, 04:42:42 am
I am not confident of the code.
This is part_shader_logic code I touched.

Code Snippet
Plaintext
function part_shader_logic(shader, position, size_x, size_y){
hud = position - 1;
self.shader_var[hud] = NewClientHudElem(self);
self.shader_var[hud].alignX = "right";
self.shader_var[hud].alignY = "top";
self.shader_var[hud].horzAlign = "user_right";
self.shader_var[hud].vertAlign = "user_top";
if(self IsSplitScreen())
self.shader_var[hud].y = ((size_y * position) + 10) - 25;
else
self.shader_var[hud].y = ((size_y * position) + 10);
self.shader_var[hud].x = -5;
self.shader_var[hud] setShader(shader, size_x, size_y);
self waittill("power_crafted");
self waittill("pap_crafted");
foreach(shader in self.shader_var){
shader Destroy();
}
}
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: Archaicvirus on February 02, 2018, 03:38:22 am
I am not confident of the code.
This is part_shader_logic code I touched.

Code Snippet
Plaintext
function part_shader_logic(shader, position, size_x, size_y){
hud = position - 1;
self.shader_var[hud] = NewClientHudElem(self);
self.shader_var[hud].alignX = "right";
self.shader_var[hud].alignY = "top";
self.shader_var[hud].horzAlign = "user_right";
self.shader_var[hud].vertAlign = "user_top";
if(self IsSplitScreen())
self.shader_var[hud].y = ((size_y * position) + 10) - 25;
else
self.shader_var[hud].y = ((size_y * position) + 10);
self.shader_var[hud].x = -5;
self.shader_var[hud] setShader(shader, size_x, size_y);
self waittill("power_crafted");
self waittill("pap_crafted");
foreach(shader in self.shader_var){
shader Destroy();
}
}
I don't know what you mean by not confident, but at the bottom you have
Code Snippet
Plaintext
self waittill("pap_crafted")
. Why?  Are you also sending a notify "pap_crafted"? Without doing
Code Snippet
Plaintext
 player notify("pap_crafted")
the call
Code Snippet
Plaintext
self waittill("pap_crafted")
will halt the function and wait forever until that notify is sent. In the function part_shader_logic, 'self' is an alias for the player that the function is being called on.
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: DeletedUser on January 03, 2021, 09:19:19 pm
There is a tutorial on custom perks here, just look for it. In that tutorial it walks you through making your own custom perk shaders, just follow that part. Its really easy and its the same process no matter what you're using the shaders for - jumpscares, perk shaders, parts etc.
hey do u know how this can be implemented into waw?
Title: Re: Custom Buildables - random spawning, shaders, etc.
Post by: alnoise on April 05, 2023, 06:25:03 pm
I know this is a pretty old thread, but does anyone have any ideas as to why the fuse isn't spawning with the prefab? I got the switch and the panel but the fuse is missing :(