Game Modding | Call of Duty: Black Ops 3 | Scripting
ModmeBot:
Thread By: Slysur Is there any script that could create a keycard (you pick up) that will open a certain door or multiple ones? thanks in advanced
ModmeBot:
Reply By: natesmithzombies I am at work and Uni all day. I cannot test myself but I believe this should work:
Instructions
--------------
1) Got to your mapname.gsc and at the bottom add this code:
functioninit_keycard(){level.key_obtained=false;key=GetEnt("key_trigger","targetname");keySetCursorHint("HINT_NOICON");keySetHintString("Press and Hold ^3&&1^7 to Pick Up Keycard");keythreadwait_for_pickup();key_doors=GetEntArray("key_door","targetname");foreach(doorinkey_doors){doorSetCursorHint("HINT_NOICON");doorSetHintString("A Key is Required to Open the Door");doorthreadwait_for_unlock();}}functionwait_for_pickup(){selfwaittill("trigger",player);model=GetEnt(self.target,"targetname");modeldelete();selfdelete();level.key_obtained=true;iprintlnbold("The Keycard Has Been Obtained");}functionwait_for_unlock(){levelendon("intermission");while(!level.key_obtained)wait(0.25);selfSetHintString("Press and Hold ^3&&1^7 to Unlock Door");selfwaittill("trigger",player);models=GetEntArray(self.target,"targetname");PlaySoundAtPosition("zmb_cha_ching",player.origin);spawn_flag=models[0].script_flag;flag::set(spawn_flag);wait(0.05);foreach(modelinmodels)modeldelete();selfdelete();}
2) Near the top mapname.gsc you will see the main function:
functionmain(){
Underneath that add this line:
levelinit_keycard();
3) Open Radiant and open the "Entity Browser". Insert a trigger>use and give it the following KVP's by pressing "N" on your keyboard.
targetname - key_trigger
Place only one of these in your map. It is the trigger for your key.
4) Now place a script>model in "Entity Browser". Select the trigger you placed in Step 3 and then select the model you just placed. Press "W" on your keyboard and then you will notice the targetname of the script model is "auto#" where # is some number. The target of the trigger should be the same auto#.
5) Now you are to place a trigger for the doors. Place a trigger>use again and give it the following KVPs:
targetname - key_door
Place as many of these as you would like around the map.
6) For each placed door trigger, place a script>model or a script>brushmodel for your door. Select first the trigger and then the script>model or script>brushmodel and link them by pressing "W" like you did in Step 4. Additionally add a KVP to initiate the spawners in that zone by adding this KVP:
script_flag - spawner_flag
"spawner_flag" should be the flag that you would use in the add_adjacent_zone function when setting up zones. Be sure script_flag is on the model and not the trigger. Also note that if your door is in pieces do this for each piece of the door.
That should be all you need. Ideally you would want a HUD to show the player has a key, but thats a bit more in depth than I can do for you right now. It isn't hard to add at all though if you take a look at how hud functions work. Let me know if this works, as I cannot test myself.
Reply By: natesmithzombies Man thats what I get for rushing at work haha. I updated the code another time to work for future visitors to this post. Nice work guys!
ModmeBot:
Reply By: Slysur Thanks everyone! This is working great
ModmeBot:
Reply By: Blink-420
natesmithzombiesMan thats what I get for rushing at work haha. I updated the code another time to work for future visitors to this post. Nice work guys!
Love this script, been very helpful. I've tried using playfx for and effect to happen on the origin of the model when the door is unlocked... Ive used this
functionwait_for_unlock_thermite(){levelendon("intermission");while(!level.key_obtained_thermite)wait(0.25);selfSetHintString("Press and Hold ^3&&1^7 to use thermite");selfwaittill("trigger",player);models=GetEntArray(self.target,"targetname");PlaySoundAtPosition("zmb_cha_ching",player.origin);for(i=0;i<models.size;i++){spawn_flag=models[i].script_flag;flag::set(spawn_flag);}
But can't seem to get an fx to play.. do you mind giving me some direction to what I'm doing wrong or even how I can do this? Thanks, Nate!
ModmeBot:
Reply By: natesmithzombies
Blink-420
natesmithzombiesMan thats what I get for rushing at work haha. I updated the code another time to work for future visitors to this post. Nice work guys!
Love this script, been very helpful. I've tried using playfx for and effect to happen on the origin of the model when the door is unlocked... Ive used this
But can't seem to get an fx to play.. do you mind giving me some direction to what I'm doing wrong or even how I can do this? Thanks, Nate!
I think your issue is that you have an array of doors with the targetname "key_door_thermite". You could try this but it might look a bit funny depending on how many script_models or script_brushmodels you have with that targetname:
playfx(level._effect["powerup_grabbed"],GetEnt("key_door_thermite","targetname").origin);functionwait_for_unlock(){levelendon("intermission");while(!level.key_obtained)wait(0.25);selfSetHintString("Press and Hold ^3&&1^7 to Unlock Door");selfwaittill("trigger",player);models=GetEntArray(self.target,"targetname");PlaySoundAtPosition("zmb_cha_ching",player.origin);spawn_flag=models[0].script_flag;flag::set(spawn_flag);wait(0.05);foreach(modelinmodels){playfx(level._effect["powerup_grabbed"],model.origin);modeldelete();}selfdelete();}