I wanted to start scripting to make my maps more customized, and then I tryed out ZKs tut on a buildable power switch. http://custom-zombies.com/Forums/index.php?topic=224.0 this is his tut. if anyone can look at it that know scripts really well can go over it to see if its even correct. I tryed it on a map i was working on for ever and messed it up then tryed it on a test map and still didnt seem to work. Any help would be appreciated.
ps took screen shots but couldnt figure out to add then lol
Last Edit: July 31, 2015, 05:31:07 pm by thezombiekilla6
Well my opinion i never really liked the way this power buildable worked. Yes the script works ok but it doesnt use the real power switch if i remember correctly. You have to add a second power switch and not only that not many notice but pack a punch fx dont work after power is on. i will post a fix for this shortly so your using real power switch / script.
ZK's scripts aren't bad for starting out, but there are smarter, more dynamic ways to do things like this build-able. Anytime you see yourself repeating the same things, "except this", meaning like one thing is different, it can be done much better. And also, a good bit of scripting can be improved, by using radiant smarter. When to use auto#'s and prefabs and things like that will help you make better scripts. So take what you learn from this but don't take it as the only way to do it, or even the best way to do it.
You'll find that the main thing with power is the power trigger. The power trigger is handled in dlc3_code.gsc. It gets an ent and waits for it to be triggered. This means the kvp "use_power_switch" can only be in the map as a targetname on an ent once, since getent is used, not getentarray and then a function thread on each. If you had multiple triggers with that kvp, you would get an error, in this case, which would pass as true and allow the power to come on immediately.
So besides writing a script that sets shaders, and picks up parts and sets down parts, and checks when players die or are downed, this is the basic way power is handled. When it is triggered, it then calls power_electric_switch_on() which turns everything with flags and notifications.
There are plenty of scripts out there that handle the rest, and simply adding a level waittill("yournotification"); before the trig waittill("trigger", user); and then adding a level notify("yournotification"); after the item is built, will be one of the easiest ways of handling that. You could also hide or disable the trigger before and enable or show the trigger after it is built if you like.
If you want scripts / features made for you, then contact me by PM or email / skype etc it will cost you tho so if you have no intention of reciprocating don't even waste my time
ZK's scripts aren't bad for starting out, but there are smarter, more dynamic ways to do things like this build-able. Anytime you see yourself repeating the same things, "except this", meaning like one thing is different, it can be done much better. And also, a good bit of scripting can be improved, by using radiant smarter. When to use auto#'s and prefabs and things like that will help you make better scripts. So take what you learn from this but don't take it as the only way to do it, or even the best way to do it.
You'll find that the main thing with power is the power trigger. The power trigger is handled in dlc3_code.gsc. It gets an ent and waits for it to be triggered. This means the kvp "use_power_switch" can only be in the map as a targetname on an ent once, since getent is used, not getentarray and then a function thread on each. If you had multiple triggers with that kvp, you would get an error, in this case, which would pass as true and allow the power to come on immediately.
So besides writing a script that sets shaders, and picks up parts and sets down parts, and checks when players die or are downed, this is the basic way power is handled. When it is triggered, it then calls power_electric_switch_on() which turns everything with flags and notifications.
There are plenty of scripts out there that handle the rest, and simply adding a level waittill("yournotification"); before the trig waittill("trigger", user); and then adding a level notify("yournotification"); after the item is built, will be one of the easiest ways of handling that. You could also hide or disable the trigger before and enable or show the trigger after it is built if you like.
Good luck.
theres a example of this in my craftables script
Uses the regular power switch, disables the trigger, hides the models, and waits for you to build it
once its done just re-enables the trigger, from then on its just the normal old power switch
i've just been pretty much trying to write my own scripts it's tough though because I have to find out what I need to put in the Scripts it's not hard using the calls and functions in Notepad plus plus at all just learning what in call of duty I need to call I guess thank you for replying both of you
Some Quick Changes I Made.... 1. using proper power switch. You dont need a hidden dummy switch on map anymore! now power fx, pap fx, and proper sounds work. 2. moved shader placement to top left away from perk shaders. 3. added build fx (green poof) When parts added 4. Removed power_ready(); function not needed anymore! 5. made a prefab of switch and parts (download above) stamp it in radiant and move parts where ever!
make sure u have dlc3_code.gsc in mods/maps next open dlc3_code.gsc and comment out these lines they can be found near lines 125 it should look like this when finished.. here is a pic just incase!! when done save and close dlc3_code.gsc https://gyazo.com/afc274f90936d174a6b96fe5abc70d59
NEXT
open your buildable script and replace everything with this...
NEXT
GO TO RADIANT AND DELETE ALL POWER SWITCHES AND PARTS THAT YOU CURRENTLY HAVE ON YOUR MAP. Then download prefab i provided and add that power switch to your map you can stamp the prefab and move parts where ever you want.
next
go to mapname.gsc and look for under that add the name of your power script heres an example..
next add the name of your shader materials to mod.csv example material,buildable_wire_shader material,buildable_panel_shader material,buildable_handle_shader
next check everything in your iwd file list. (Images, script ect) now full compile and build mod.
Last Edit: August 18, 2015, 04:58:22 pm by thezombieproject
hey man the script works but how can i fix the hit parts still needed because if you go up and press f it turns on the power with out parts
u have to go in dlc3 code and comment out those lines. if you did that correct theres no way you can turn the power on till all parts are added. dlc3_code power code doenst get called till all parts are added. Well if u forgot to comment out those lines then the power function gets called at the start of the game and you can flip the switch before you add parts and thats what seems to be the issue. Anyway i will go and double check everything either way just incase. If you dont get it fixed feel free to message me on steam and ill walk you through it.
also i would like to add make sure u edit the dlc3_code.gsc thats in your mods/maps folder and not the one in raw / maps Double Post Merge: August 22, 2015, 09:04:08 pmok so i just double checked the tut and everything worked for me
Last Edit: August 22, 2015, 09:17:51 pm by thezombieproject
TheZombieProjectCOD Double Post Merge: August 23, 2015, 04:15:00 pmtry this i just disabled the trigger instead of giving it a hint replace with this one
Last Edit: August 23, 2015, 04:16:35 pm by thezombieproject