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:
Then paste this line at the bottom: *EDIT: then add this line to your mapname.gsc somehere near the other "#using" lines: Next, right-click on your map in launcher, click edit zone file. Add these lines at the bottom:
Now navigate to your mapname\sound\zoneconfig - and open your mapname.SZC file in a text editor then add these lines:
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.
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)
Last Edit: July 22, 2017, 09:16:49 pm by Archaicvirus
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.
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
Last Edit: June 17, 2017, 10:18:05 am by Mr. Unp3rf3ct
Thanks man, if it helps, regardless of the size of the image, you can dictate the draw size when you thread 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.
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.
Last Edit: June 17, 2017, 12:25:42 pm by Mr. Unp3rf3ct
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
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.
Last Edit: June 17, 2017, 07:46:03 pm by Archaicvirus
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)
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
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:
Last Edit: June 18, 2017, 08:55:53 am by Mr. Unp3rf3ct