UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: reckfullies on October 09, 2016, 12:21:24 am

Title: [Tutorial] Shootable Triggers
Post by: reckfullies on October 09, 2016, 12:21:24 am
Its been over a year since I made this, got bored so I've decided to remake it from scratch. With newer games releasing, BO3 isn't really as popular anymore but I'm sure this tutorial will still help someone.

I have tested this multiple times, if for some reason it doesn't work then let me know.

Useful Info
Spoiler: click to open...
"Entity Browser" Shortcut = B
"Entity Info" Shortcut = N

Let me know if you think I should add anything else here.

Tutorial
Spoiler: click to open...
Part 1 - Radiant

  • Place the models you would like to use for your Shootables, these can be anything you want.
  • Select all of your models.
  • Go into the "Entity Browser" window.
  • Click "Scripts" and double-click "model".
  • Deselect everything.
  • Go back into the "Entity Browser" window.
  • Click "Trigger" and drag "damage" onto your map.
  • Resize this trigger to cover your model.
  • Go into the "Entity Info" window. Note: Make sure you keep the trigger selected
  • Double-click the "Value" field of the "targetname" property.
  • Type "shootable_trigger" then press Enter.
  • With the trigger selected, copy it and put it on any other models you have.
  • Select ONE trigger THEN select the model that it is covering.
  • Press "W" to link them.
  • Repeat the last two steps for each pair of triggers and models you have.

This is a short youtube video for anyone who is confused.
Spoiler: click to open...




Part 2 - Scripting


  • Open Windows Explorer or any other file browser.
  • Navigate to "root/share/raw/scripts" where "root" is your BO3 game folder.
  • Create a new folder named "custom".
  • Create a new file named "shootable.gsc". Note: You might need to have "show known file extensions" enabled to make it a .gsc
  • Open the newly created file.
  • Paste the code below into that file.
  • Save the file.

Code
Spoiler: click to open...
Code Snippet
Plaintext
// Credit to Archaicvirus for the updated code. I modified it a tiny bit.
// I also changed some variable & function names to make it more easily readable and added simple comments.

// If you spot any optimizations that could be made let me know, at a glance it seems fine.

function init()
{
// Get all the entities with the targetname "shootable_trigger" then assign them to a variable.
triggerArray = GetEntArray("shootable_trigger", "targetname");

// Create the shootablesNeeded level variable then set it to the amount of entities in the triggerArray variable.
level.shootablesNeeded = triggerArray.size;

// Create the shootablesCollected level variable and set it to 0.
level.shootablesCollected = 0;

// Loop through all the entites in triggerArray
foreach(trigger in triggerArray)
{
// Set the HintString to "".
trigger SetHintString("");

// Set the CursorHint to "HINT_NOICON".
trigger SetCursorHint("HINT_NOICON");

// Create a new property on the trigger named "bottle".
// Get the target entity then assign it to "bottle".
trigger.bottle = GetEnt(trigger.target, "targetname");

// Call the trigger_wait function on this trigger entity.
trigger thread trigger_wait();
}
}

function trigger_wait()
{
// Wait for the trigger to be activated.
self waittill("trigger");

// Delete the bottle(AKA model).
self.bottle Delete();

// Increment the shootablesCollected variable.
level.shootablesCollected++;

// Check if shootablesCollected is greater than or equal to shootablesNeeded.
if (level.shootablesCollected >= level.shootablesNeeded)
{
// Call the give_reward function on the level.
level thread give_reward();
}

// Print info to the screen.
IPrintLnBold("Shootables Collected = [" + level.shootablesCollected + "]");
}

function give_reward()
{
// Print info to the screen.
IPrintLnBold("Reward Given");

// Insert reward code here
}




Part 3 - Finishing Touches & Compiling


  • Open Windows Explorer or any other file browser.
  • Navigate to "root/usermaps/zm_mapname/scripts/zm" where "root" is your BO3 game folder and "mapname" is your map name.
  • Open "zm_mapname.gsc" where "mapname" is your map name.
  • Below "#using scripts\zm\zm_usermap;" add "#using scripts\custom\shootable;"
  • Find the function "main" and add "thread shootable::init();" at the bottom.
  • Save the file.
  • Navigate to "root/usermaps/zm_mapname/zone_source/zm_mapname.zone" where "root" is your BO3 game folder and "mapname" is your map name.
  • At the bottom of the file add "scriptparsetree,scripts/custom/shootable.gsc".
  • Save the file.
  • Go into your launcher then Compile & Link.
Title: Re: [Tutorial] Shootable Triggers
Post by: mindy12345 on October 09, 2016, 12:59:21 am
can you make  me a script where i shoot 3 teddy bears it gives me electric cherry
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 09, 2016, 01:54:52 am
can you make  me a script where i shoot 3 teddy bears it gives me electric cherry

This script can be easily adapted to do just that.

I won't be making scripts for everyone who wants them but here is how to give a perk since its pretty simple:

First, go into the script and add this to the top of the file:
Code Snippet
Plaintext
#using scripts\zm\_zm_perks;

Change:
Code Snippet
Plaintext
function shootables_done()
to
Code Snippet
Plaintext
function shootables_done(player)

then go into each of the shootables(shootable_1 and shootable_2) and change this:
Code Snippet
Plaintext
thread shootables_done();
to
Code Snippet
Plaintext
thread shootables_done(player);

lastly go back into shootables_done and add this under the IPrintLn:
Code Snippet
Plaintext
player zm_perks::give_perk("electric_cherry_perk") // I'm not sure what the perk names are for this function so you would need to find the rest.
Title: Re: [Tutorial] Shootable Triggers
Post by: Blink-420 on October 09, 2016, 04:38:14 am
^1    thread function
^1------------------^
^1ERR(0) scripts/custom/shootable.gsc (7,19) in "init()" : syntax error, unexpected TOKEN_FUNCTION, expecting TOKEN_LEFT_BRACKET or TOKEN_IDENTIFIER :     thread function

I got this error when compiling?
Title: Re: [Tutorial] Shootable Triggers
Post by: xTundra on October 09, 2016, 10:49:55 am
This script can be easily adapted to do just that.

I won't be making scripts for everyone who wants them but here is how to give a perk since its pretty simple:

...


This is pretty dope dude.  Is there anything you can recommend for someone who is trying to learn the basic of gsc scripting?
Title: Re: [Tutorial] Shootable Triggers
Post by: HitmanVere on October 09, 2016, 03:30:22 pm
^1    thread function
^1------------------^
^1ERR(0) scripts/custom/shootable.gsc (7,19) in "init()" : syntax error, unexpected TOKEN_FUNCTION, expecting TOKEN_LEFT_BRACKET or TOKEN_IDENTIFIER :     thread function

I got this error when compiling?

Try now. OP was missing few underscores. Fixed it for you, OP, since its easy fix + dont want more people having issues
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 09, 2016, 07:02:07 pm
got this error when compiled the map:

^1
^1^
^1ERR(6E) scripts/custom/shootable.gsc (15,0)  : Compiler Internal Error :  Uninitialized local variable 'targetname'

Any thoughts on how to fix?
Title: Re: [Tutorial] Shootable Triggers
Post by: harvez on October 09, 2016, 08:21:44 pm
I get this error while compiling?

^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (18,1)  : Compiler Internal Error :  Uninitialized local variable 'targetname'
Title: Re: [Tutorial] Shootable Triggers
Post by: HitmanVere on October 09, 2016, 11:00:56 pm
got this error when compiled the map:

^1
^1^
^1ERR(6E) scripts/custom/shootable.gsc (15,0)  : Compiler Internal Error :  Uninitialized local variable 'targetname'

Any thoughts on how to fix?

I get this error while compiling?

^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (18,1)  : Compiler Internal Error :  Uninitialized local variable 'targetname'


Reck, I suggest testing your scripts before releasing them. Fixed this one for you as well
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 12:23:36 am
Thanks for fixing all the problems, should have tested it sooner since I wrote this from memory cause I couldn't get on steam at the time.
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 10, 2016, 02:26:53 am
Thanks for fixing all the problems, should have tested it sooner since I wrote this from memory cause I couldn't get on steam at the time.

**** 1 script error(s):
 "function_shootable_1" with 0 parameters in "scripts/custom/shootable.gsc" at line 7 ****
**** Unresolved external "function_shootable_1" with 0 parameters in "scripts/custom/shootable.gsc" ****

Idk if you changed the script but I'm getting this new error now since I recopied and pasted it.
Title: Re: [Tutorial] Shootable Triggers
Post by: CraftDAnimations on October 10, 2016, 02:54:10 am
Did the OP get updated as I am getting the same error when trying to build!

I get this when launching the game

(http://image.prntscr.com/image/b650048a19ee4daf87df15daa83ad0e2.png)
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 04:13:20 am
Did the OP get updated as I am getting the same error when trying to build!

I get this when launching the game

(http://image.prntscr.com/image/b650048a19ee4daf87df15daa83ad0e2.png)

I think this was a mistake when HitmanVere edited it, ill fix it since function wasn't supposed to be there in the first place.

Re do the part where the script is made, at the top where the functions are threaded they are supposed to be
Code Snippet
Plaintext
thread shootable_1();
thread shootable_2();

Just updated OP.
Title: Re: [Tutorial] Shootable Triggers
Post by: 88ninjastar on October 10, 2016, 04:29:33 am
I've updated the script and changed the 2 threads at the top, but now when I run the map and shoot the triggers and models in the game, it says "Lost Connection" and the game freezes and eventually crashes.
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 10, 2016, 05:00:01 am
I think this was a mistake when HitmanVere edited it, ill fix it since function wasn't supposed to be there in the first place.

Re do the part where the script is made, at the top where the functions are threaded they are supposed to be
Code Snippet
Plaintext
thread shootable_1();
thread shootable_2();

Just updated OP.
I can get in the game but after I shoot the model my game get connection interrupted.
Title: Re: [Tutorial] Shootable Triggers
Post by: TheLuckGame on October 10, 2016, 05:38:45 am
My syntax in GSC mode doesn't show "player" as a function (in blue), I assume that is the issue I am having with it saying

^1       }
^1-------^
^1ERR(0) scripts/custom/shootable.gsc (100,8) in "shootables_done()" : syntax error, unexpected TOKEN_RIGHT_CURLY :        }

Anyone know how to get the syntax to recognize it as a function in Sublime Text 3 and change it to blue?
I could also be wrong I am just a beginner when it comes to any of this honestly.

extra information: upon typing "playe", "player" is located in the drop down list but no matter what it won't change to blue.
Title: Re: [Tutorial] Shootable Triggers
Post by: Blink-420 on October 10, 2016, 06:43:36 am
When I shoot the triggers with the updated fixes you posted my game gives me connection interrupted then crashes everytime..hahaha
Title: Re: [Tutorial] Shootable Triggers
Post by: CraftDAnimations on October 10, 2016, 08:51:41 am
Although I now get no errors while compiling I do get a Connection Interrupted after shooting the 2nd bottle

http://prnt.sc/crzlv0 (http://prnt.sc/crzlv0)
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 09:16:23 am
Although I now get no errors while compiling I do get a Connection Interrupted after shooting the 2nd bottle

http://prnt.sc/crzlv0 (http://prnt.sc/crzlv0)

Sorry about all the errors, as I said i didn't have time to test it myself.

The problem is that I forgot to break out of the while loop so it constantly sent printlns to you.

Go to the shootables_done function in the script and make sure it looks like this:
Code Snippet
Plaintext
function shootables_done()
{
    while(1)
    {
        if(level.shootablesCollected <= level.shootablesNeeded)
       {
            // Put whatever code you want for your ee here, I would recommend using another function though.
            IPrintLn("All Shootables Collected");

            break;
       }
    }
}

I just updated OP so nobody should have this problem anymore.

EDIT: Fixed break
Title: Re: [Tutorial] Shootable Triggers
Post by: HitmanVere on October 10, 2016, 09:45:10 am
I think this was a mistake when HitmanVere edited it, ill fix it since function wasn't supposed to be there in the first place.

Re do the part where the script is made, at the top where the functions are threaded they are supposed to be
Code Snippet
Plaintext
thread shootable_1();
thread shootable_2();

Just updated OP.

I apparently need to test my modifications as well when I fix stuff, lmao. Also, your break; is at the wrong place, should be inside if-statement. Now it breaks even when if-statement is false
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 10:01:47 am
I apparently need to test my modifications as well when I fix stuff, lmao. Also, your break; is at the wrong place, should be inside if-statement. Now it breaks even when if-statement is false

I can see why you would have done that, I mistakenly wrote thread function shootable_1 so it seemed like it was meant to be function_shootable_1 lol.

As for the break, I feel like an idiot since I keep making little mistakes. Guess that is what happens when you are too lazy to test everything you modify.
Title: Re: [Tutorial] Shootable Triggers
Post by: CraftDAnimations on October 10, 2016, 10:32:52 am
Slowly getting there lol.  No errors (ie no connection interrupted) but when I shoot just ONE model - it says "All Shootables Collected".  Then when I shoot the next it says the same.

I tried adding the Electric Cherry addition and it doesn't award player with the perk.
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 10:55:43 am
Slowly getting there lol.  No errors (ie no connection interrupted) but when I shoot just ONE model - it says "All Shootables Collected".  Then when I shoot the next it says the same.

I tried adding the Electric Cherry addition and it doesn't award player with the perk.

I know about this and was just updating OP to fix it, I revised the entire script to make sure it was working. Just re-read OP and it will fix this problem.

Next time ill make sure it works before I post it to avoid all of this.

I don't know about your perk problem since this tutorial is for the shootables. I haven't given any perks in bo3 through script yet so I don't really know what your problem is.
Title: Re: [Tutorial] Shootable Triggers
Post by: CraftDAnimations on October 10, 2016, 11:34:26 am
Works a treat - thank you for taking the time to sort this.

How would I go about taking a door open after last model is shot?
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 11:40:35 am
Works a treat - thank you for taking the time to sort this.

How would I go about taking a door open after last model is shot?

This might be hard to do since you would need to change the script where they control all doors and at the moment in the mod tools we can't actually modify most of the scripts so it would be really complicated if not, impossible to do unless you made your own door script.

If you want me to make you a door script and add this for you contact me on ugx via messages and we can figure something out.
Title: Re: [Tutorial] Shootable Triggers
Post by: Harry Bo21 on October 10, 2016, 12:27:31 pm
Not really

You would just use different kvps for this door so it's not controlled by the "old" system and make sure to set the zone it opens flag
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 10, 2016, 12:33:18 pm
Not really

You would just use different kvps for this door so it's not controlled by the "old" system and make sure to set the zone it opens flag

It would be pretty easy only if you use your own script, just wanted to help and maybe script it for him since he was asking how to do it.

I meant that using the original script provided would be hard since i'm not sure if thats a script we can edit
Title: Re: [Tutorial] Shootable Triggers
Post by: Harry Bo21 on October 10, 2016, 12:48:45 pm
Get ent
Rotate model
Delete clip
Set flag

That's all there is to it
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 10, 2016, 01:17:31 pm
It works now thanks.
Title: Re: [Tutorial] Shootable Triggers
Post by: CraftDAnimations on October 10, 2016, 02:36:25 pm
I know very little about scripting so in my case it "wouldnt" be easy lol.

I sent you a message reckfullies :)
Title: Re: [Tutorial] Shootable Triggers
Post by: harvez on October 10, 2016, 05:39:38 pm
I get this error now, I updated my script to the new one and added the electric cherry part?

^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (28,1)  : Compiler Internal Error :  Uninitialized local variable 'player'
Title: Re: [Tutorial] Shootable Triggers
Post by: r0bst3r on October 10, 2016, 11:15:27 pm
Hi anyone know the code to play a song when all triggers are shot? ;)
Title: Re: [Tutorial] Shootable Triggers
Post by: kaizokuroof on October 11, 2016, 01:02:26 am
Super cool. Thanks for sharing/taking the time to fix it.
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 11, 2016, 01:53:20 am
I get this error now, I updated my script to the new one and added the electric cherry part?

^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (28,1)  : Compiler Internal Error :  Uninitialized local variable 'player'

This is because there is no player variable defined.
Change the entire script to this:
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 2;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
}

break;
}
}
Title: Re: [Tutorial] Shootable Triggers
Post by: TheKillerey on October 11, 2016, 12:34:57 pm
This is the fully code if you want to get "Electric Cherry" :)

Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

break;
}
}

Tested and it works fine ;)

This is for 3 triggers :)
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 11, 2016, 01:36:10 pm
This is the fully code if you want to get "Electric Cherry" :)

Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

break;
}
}

Tested and it works fine ;)

This is for 3 triggers :)

Thanks for sharing your script with anyone who might not know how to do this, if anyone wants to change the perk all names are located in _zm_perks.gsh
Title: Re: [Tutorial] Shootable Triggers
Post by: TheKillerey on October 11, 2016, 02:50:58 pm
Thanks for sharing your script with anyone who might not know how to do this, if anyone wants to change the perk all names are located in _zm_perks.gsh
No Problem :)
Title: Re: [Tutorial] Shootable Triggers
Post by: Blink-420 on October 12, 2016, 12:42:58 am
This is the fully code if you want to get "Electric Cherry" :)

Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

break;
}
}

Tested and it works fine ;)

This is for 3 triggers :)

I get no errors compiling map and it works but the game doesn't give me electric cherry once i shoot all three bottles just the on screen messages
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 12, 2016, 03:14:17 am
I get no errors compiling map and it works but the game doesn't give me electric cherry once i shoot all three bottles just the on screen messages

Make sure you actually have the perks enabled on your map. By default electric cherry and widows wine are not enabled.

To add them go into root/usermaps/zm_mapname/scripts/zm/zm_mapname.gsc and add this to the top of the file:
Code Snippet
Plaintext
#using scripts\zm\_zm_perk_widows_wine;
#using scripts\zm\_zm_perk_electric_cherry;

Do the same thing inside root/usermaps/zm_mapname/scripts/zm/zm_mapname.csc
Title: Re: [Tutorial] Shootable Triggers
Post by: jrderuki on October 12, 2016, 05:31:53 am
I get this error it looks like a path error anyone know what I did wrong?  :poker:
^1ERR(83) scripts/zm/zm_hard.gsc (12,32)  : Compiler Internal Error :  Compile error processing "using" file - file not found : scripts/custom/shootable.gsc

EDIT: Nevermind got it fixed and working :)
Title: Re: [Tutorial] Shootable Triggers
Post by: Gondor on October 13, 2016, 11:48:06 pm
I want to give the zombie shield weapon instead of a perk how do you do that?
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 14, 2016, 09:55:31 am
I want to give the zombie shield weapon instead of a perk how do you do that?

*Note - Make sure you are using the script that TheKillerey made above since it has access to the player variable*



Replace player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false ); with this:
Code Snippet
Plaintext
weapon = GetWeapon("zod_riotshield");
player GiveWeapon(weapon);

I'm not sure if this is the right way to do it since it acts as a equipment not a weapon but it should work since it is in the weapons table. Please let me know if anything doesn't work and Ill figure out the right way.
Title: Re: [Tutorial] Shootable Triggers
Post by: Gondor on October 14, 2016, 07:12:58 pm
it works with raygun but not zombie shield probably because its a equipment
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 14, 2016, 08:19:48 pm
it works with raygun but not zombie shield probably because its a equipment

You could try this.

Add this to your includes:
Code Snippet
Plaintext
#using scripts/zm/_zm_equipment;

then add this inside shootable_done under IPrintLn:
Code Snippet
Plaintext
equipment = GetWeapon("zod_riotshield");
player zm_equipment::give(equipment);

This should work, if it doesn't you or someone else will need to figure it out since I can't find another way inside the equipment file.
Title: Re: [Tutorial] Shootable Triggers
Post by: Gondor on October 14, 2016, 09:21:54 pm
Thanks man that worked ill give you some credit in my map description once its updated!

Double Post Merge: October 15, 2016, 12:30:44 am
The script works but after testing it on multiplayer it gives the shield to only 1 player and not all players. Is theirs a way to script it to all players or all 4?

Double Post Merge: October 15, 2016, 12:31:42 am
holly fuck i was baked when I wrote that
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 15, 2016, 09:18:50 am
Thanks man that worked ill give you some credit in my map description once its updated!

Double Post Merge: October 15, 2016, 12:30:44 am
The script works but after testing it on multiplayer it gives the shield to only 1 player and not all players. Is theirs a way to script it to all players or all 4?

Double Post Merge: October 15, 2016, 12:31:42 am
holly fuck i was baked when I wrote that

Replace this:
Code Snippet
Plaintext
player zm_equipment::give(equipment);

With this:
Code Snippet
Plaintext
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}
Title: Re: [Tutorial] Shootable Triggers
Post by: M0ul3_G4m3r on October 15, 2016, 03:04:03 pm
Hi!
What is the code to play song or a custom song when a trigger was shooted ?! thanks !  :accepted:
Title: Re: [Tutorial] Shootable Triggers
Post by: Gondor on October 16, 2016, 01:10:14 am
Replace this:
Code Snippet
Plaintext
player zm_equipment::give(equipment);

With this:
Code Snippet
Plaintext
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}

Thanks man but im currently having a glitch where sometimes the script bugs out and does not fully work and you only have to shoot 1 trigger and it gives you the Easter egg complete status. This is my code

Code Snippet
Plaintext
#using scripts\zm\_zm_weapons;
#using scripts\zm\_zm_weap_riotshield;
#using scripts\zm\_zm_equipment;

#using scripts\zm\craftables\_zm_craft_shield;

function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

//IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

//IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

//IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

//trig_3 Delete();
//model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Easter Egg Complete. Enjoy your new shield!");
equipment = GetWeapon("zod_riotshield");
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}
}

break;
}
}
Title: Re: [Tutorial] Shootable Triggers
Post by: DeletedUser on October 16, 2016, 03:36:09 am
I've noticed that when you done shooting all of the triggers only the first player gets the rewards and other three players don't. Is there a fix for this?
Title: Re: [Tutorial] Shootable Triggers
Post by: donovanne on October 16, 2016, 10:16:38 pm
This is the fully code if you want to get "Electric Cherry" :)

Code Snippet
Plaintext
#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;

function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
level thread shootable_3();
}

function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

function shootable_3()
{
trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 3 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_3 Delete();
model_3 Delete();
}

function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

break;
}
}

Tested and it works fine ;)

This is for 3 triggers :)

Using the exact same code (other than different print messages), I'm getting the following error when linking in launcher:

^1�
^1^
^1ERR(0) scripts/custom/shootable.gsc (16,1) in "shootable_1()" : Bad Token '�' :  ^1�
^1^
^1ERR(0) scripts/custom/shootable.gsc (16,1) in "shootable_1()" : syntax error, unexpected TOKEN_ERROR : �
Title: Re: [Tutorial] Shootable Triggers
Post by: All0utWar on October 17, 2016, 12:23:06 am
I've noticed that when you done shooting all of the triggers only the first player gets the rewards and other three players don't. Is there a fix for this?

Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{
//do whatever
players[i] zm_perks::give_perk( PERK_JUGGERNOG, false);
}
}

break;
}
}

I think this should work.
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 18, 2016, 01:01:31 pm
How do I make it so only a certain gun activates the shootable trigger and others don't? It would help me out a lot thanks!
Title: Re: [Tutorial] Shootable Triggers
Post by: jasonpage260 on October 18, 2016, 05:05:10 pm
how would I go about to change this to the PowerUp free perk
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 18, 2016, 05:59:16 pm
how would I go about to change this to the PowerUp free perk

Add this to the top of the script:
Code Snippet
Plaintext
#using scripts/zm/_zm_powerups;

Then add this to the shootable_done function:
Code Snippet
Plaintext
level thread zm_powerups::specific_powerup_drop("powerupname", origin);

Just replace "powerupname" with the code name of the powerup.

Avaliable Powerups:
Spoiler: click to open...
  • bonfire_sale
  • carpenter
  • double_points
  • fire_sale
  • free_perk
  • full_ammo
  • insta_kill
  • shield_charge
  • weapon_minigun
  • ww_grenade

Then make origin the origin you want the powerup to spawn at.
Example:
Code Snippet
Plaintext
test = GetEnt("test", "targetname");

level thread zm_powerups::specific_powerup_drop("full_ammo", test.origin); // This will spawn a max ammo at the origin of the test entity.
Title: Re: [Tutorial] Shootable Triggers
Post by: shaan211 on October 18, 2016, 09:49:12 pm
Thanks a lot, should be able to add in a easter egg into my map now  :D
Title: Re: [Tutorial] Shootable Triggers
Post by: Gondor on October 18, 2016, 10:50:35 pm
im having a glitch with my script where you don't need to shoot all 3 objects to get the easter egg complete. Sometimes its only 1 or 2 triggers you only need to shoot.
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 18, 2016, 11:57:53 pm
im having a glitch with my script where you don't need to shoot all 3 objects to get the easter egg complete. Sometimes its only 1 or 2 triggers you only need to shoot.

This shouldn't be possible since it checks twice if they are all activated, anyways try this.

Replace:
Code Snippet
Plaintext
function shootables_done()
{
while(1)
{
                self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");
}

                break;
}
}

with:
Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");

                        break;
}
}
}
Title: Re: [Tutorial] Shootable Triggers
Post by: Taven on October 20, 2016, 06:23:28 am
Trying to get audio to play when a trigger has been shot tried everything. Sorta like the EE from The Giant.

EDIT: Figured it out :P
Title: Re: [Tutorial] Shootable Triggers
Post by: M0ul3_G4m3r on October 20, 2016, 05:43:21 pm
I got this error !  :o

^1}
^1^
^1ERR(6E) scripts/zm/custom/shootable.gsc (99,1)  : Compiler Internal Error :  Uninitialized local variable 'player'

Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

                        break;
}
}
}
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 20, 2016, 06:10:17 pm
I got this error !  :o

^1}
^1^
^1ERR(6E) scripts/zm/custom/shootable.gsc (99,1)  : Compiler Internal Error :  Uninitialized local variable 'player'

Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

                        break;
}
}
}

Just as the error says, you didn't initialize the variable player.

There are 2 ways you can do this depending on who you want to give the perk to.

All Players:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");

for(i=0; i < players.size; i++)
{
players[i] zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

            break;
}
}
}

Only the players that shot a shootable:
First, go into each of the shootable functions and change them to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
    trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

then change the shootables_done function to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");

player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

    break;
}
}
}
Title: Re: [Tutorial] Shootable Triggers
Post by: M0ul3_G4m3r on October 21, 2016, 07:49:35 am
Just as the error says, you didn't initialize the variable player.

There are 2 ways you can do this depending on who you want to give the perk to.

All Players:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");

for(i=0; i < players.size; i++)
{
players[i] zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

            break;
}
}
}

Only the players that shot a shootable:
First, go into each of the shootable functions and change them to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
    trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

then change the shootables_done function to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");

player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

    break;
}
}
}

Thanks but I have try to use the "All Players" script but I got this error when I launching the game :
(http://image.noelshack.com/fichiers/2016/42/1477036168-error.png)
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 21, 2016, 02:43:41 pm
Thanks but I have try to use the "All Players" script but I got this error when I launching the game :
(http://image.noelshack.com/fichiers/2016/42/1477036168-error.png)

You must have messed something up when copying or something, the function I gave you shouldn't be causing this.

Check line 30 of that script and if you cant figure it out just post the whole script here and Ill look at it
Title: Re: [Tutorial] Shootable Triggers
Post by: Vetrotec on October 25, 2016, 06:16:29 pm
I've already seen this being talked about. I'm very very new to all this and was wondering how I'd go about making this script open a door if anyone can help me this would mean a lot to me and others.   :poker:
Title: Re: [Tutorial] Shootable Triggers
Post by: GNT123 on October 25, 2016, 08:01:52 pm
I've already seen this being talked about. I'm very very new to all this and was wondering how I'd go about making this script open a door if anyone can help me this would mean a lot to me and others.   :poker:

Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

 
Title: Re: [Tutorial] Shootable Triggers
Post by: Vetrotec on October 25, 2016, 08:53:05 pm
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

Ill check now if it works :)
Title: Re: [Tutorial] Shootable Triggers
Post by: Vetrotec on October 25, 2016, 10:31:09 pm
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

Black screens my game on load up. just me?
Title: Re: [Tutorial] Shootable Triggers
Post by: Kierpok on October 26, 2016, 02:25:20 pm
could you tell me if its possible to make is so every person in my game gets the perk

Double Post Merge: October 26, 2016, 09:36:55 pm
You must have messed something up when copying or something, the function I gave you shouldn't be causing this.

Check line 30 of that script and if you cant figure it out just post the whole script here and Ill look at it

THIS IS MY SCRIPT FOR IT AND IT WORKS TO SHOOT ALL 3 TEDDYS BUT WHEN IT GETS TO IT IT DOSE NOT GIVE ANY PERK ANY ONE GOT IDEAS WHY? (Sorry for caps trying to make it look different from the script ^.^)


#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;
 
function init()
{
    level.shootablesNeeded = 3;
    level.shootablesCollected = 0;
 
    level thread shootable_1();
    level thread shootable_2();
    level thread shootable_3();
}
 
function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
    model_1 = GetEnt("shootable_model", "targetname");
 
    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_1 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("1/3 teddys"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_1 Delete();
    model_1 Delete();
}
 
function shootable_2()
{
    trig_2 = GetEnt("shootable_trig_2", "targetname");
    model_2 = GetEnt("shootable_model_2", "targetname");
 
    trig_2 SetHintString("");
    trig_2 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_2 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("2/3 teddys"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_2 Delete();
    model_2 Delete();
}
 
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
    model_3 = GetEnt("shootable_model_3", "targetname");
 
    trig_3 SetHintString("");
    trig_3 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_3 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("all teddys collected"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_3 Delete();
    model_3 Delete();
}
 
function shootables_done(player)
{
    while(1)
    {
        self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
        if(level.shootablesCollected == level.shootablesNeeded)
        {
           players = GetPlayers();

         for(i=0; i < players.size; i++)
           {   
            player zm_perks::give_perk( PERK_WIDOWS_WINE, false );
         }
        }
 
        break;
    }
}
Title: Re: [Tutorial] Shootable Triggers
Post by: Harry Bo21 on October 27, 2016, 09:23:48 am
Wrong perk reference

It's the specialty name you must use

Think for widows it's either

"Specialty_widowswine"

If not its

"Specialty_widows_wine"

Check the zm_perks gsh for the list

The other you've used is just a variable
Title: Re: [Tutorial] Shootable Triggers
Post by: iSkillz v6 on October 27, 2016, 03:48:12 pm
Trying to get audio to play when a trigger has been shot tried everything. Sorta like the EE from The Giant.

EDIT: Figured it out :P

How do you do this, I would really like to know :)
Title: Re: [Tutorial] Shootable Triggers
Post by: harvez on October 27, 2016, 11:08:33 pm
Add this to the top of the script:
Code Snippet
Plaintext
#using scripts/zm/_zm_powerups;

Then add this to the shootable_done function:
Code Snippet
Plaintext
level thread zm_powerups::specific_powerup_drop("powerupname", origin);

Just replace "powerupname" with the code name of the powerup.

Avaliable Powerups:
Spoiler: click to open...
  • bonfire_sale
  • carpenter
  • double_points
  • fire_sale
  • free_perk
  • full_ammo
  • insta_kill
  • shield_charge
  • weapon_minigun
  • ww_grenade

Then make origin the origin you want the powerup to spawn at.
Example:
Code Snippet
Plaintext
test = GetEnt("test", "targetname");

level thread zm_powerups::specific_powerup_drop("full_ammo", test.origin); // This will spawn a max ammo at the origin of the test entity.

im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'
Title: Re: [Tutorial] Shootable Triggers
Post by: shinged on October 28, 2016, 12:04:50 am
im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'

You gotta include the powerups script in your gsc.
Code Snippet
Plaintext
#using scripts\zm\zm_powerups;

Double Post Merge: October 28, 2016, 12:05:07 am
im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'

You gotta include the powerups script in your gsc.
Code Snippet
Plaintext
#using scripts\zm\zm_powerups;
Title: Re: [Tutorial] Shootable Triggers
Post by: deathy0909 on October 28, 2016, 02:41:25 pm
Wrong perk reference

It's the specialty name you must use

Think for widows it's either

"Specialty_widowswine"

If not its

"Specialty_widows_wine"

Check the zm_perks gsh for the list

The other you've used is just a variable

I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?
Title: Re: [Tutorial] Shootable Triggers
Post by: Kierpok on October 29, 2016, 02:41:22 am
I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?


Thank you sooo much I would have no idea thats what was wrong with the scrip ^^ Trying my best to wrap my head round it but its preaty hard :0 Thank you again !!
Title: Re: [Tutorial] Shootable Triggers
Post by: reckfullies on October 29, 2016, 08:37:16 pm
I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?

I'm pretty sure the reason the loop is there was for something I was doing with the script in my map before I released it here, doubt it is really needed unless i'm forgetting something.
Title: Re: [Tutorial] Shootable Triggers
Post by: pedrehitor on November 12, 2016, 10:51:06 am
Someone knows what script I have to put to shoot three bears and open a door
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 18, 2017, 05:09:39 am
Can you tell me how to allow the trigger to activate only when the tesla_gun fires at the trigger ?
Title: Re: [Tutorial] Shootable Triggers
Post by: Wolfilms on July 18, 2017, 06:16:28 pm
Can you tell me how to allow the trigger to activate only when the tesla_gun fires at the trigger ?

You can check what gun they have using getCurrentWeapon() and if the current weapon is the tesla_gun, you can do whatever you want after that.
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 18, 2017, 11:49:09 pm
Quote
You can check what gun they have using getCurrentWeapon() and if the current weapon is the tesla_gun, you can do whatever you want after that.
Like this ? (Did not work)

Code Snippet
Plaintext
while(1)
    {
    trig_1 waittill("trigger", player);
    current_weapon = player GetCurrentWeapon();
    if(current_weapon == "tesla_gun")
    {           
                playfx(level._effect["powerup_grabbed"] ,GetEnt("trig_shootable","targetname").origin);
playfx(level._effect["elec_transformer_rod"] ,GetEnt("transformer_rod_7","targetname").origin);
  playfx(level._effect["elec_transformer_rod"] ,GetEnt("transformer_rod_8","targetname").origin);
  playfx(level._effect["elec_transformer_rod"] ,GetEnt("transformer_rod_9","targetname").origin);
  playfx(level._effect["elec_transformer_fx"] ,GetEnt("elec_transformer_1","targetname").origin);
  }
    }
Title: Re: [Tutorial] Shootable Triggers
Post by: Wolfilms on July 19, 2017, 04:11:20 pm
you might need to use this
Code Snippet
Plaintext
weapon = getWeapon("tesla_gun");
I can't really test anything at the moment because my game won't open
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 20, 2017, 01:31:38 am
you might need to use this
Code Snippet
Plaintext
weapon = getWeapon("tesla_gun");
  • are you getting errors while linking your scripts?
  • Have you done all the necessary steps to make those fx play?
I can't really test anything at the moment because my game won't open

When I use this:

Code Snippet
Plaintext
weapon = getWeapon("tesla_gun");

 I'm get errors while linking, but when I use the code that I sent, it links but does not work in the game, and when I use without checking the weapon, the effects appear without any problem.




Title: Re: [Tutorial] Shootable Triggers
Post by: Wolfilms on July 20, 2017, 03:26:54 pm
Well, I stumbled upon this topic while searching through the help section. Hope this helps

http://ugx-mods.com/forum/index.php/topic,13911.0.html (http://ugx-mods.com/forum/index.php/topic,13911.0.html)

someone in the topic mentioned that it worked for them.
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 20, 2017, 04:57:17 pm
Well, I stumbled upon this topic while searching through the help section. Hope this helps

http://ugx-mods.com/forum/index.php/topic,13911.0.html (http://ugx-mods.com/forum/index.php/topic,13911.0.html)

someone in the topic mentioned that it worked for them.

Thank you very much, it worked for me too !! ;)
Title: Re: [Tutorial] Shootable Triggers
Post by: Archaicvirus on July 20, 2017, 09:43:34 pm
I re-wrote the script to be much shorter, and more flexible. I'm not trying to step on your toes, or 1-up you or anything like that. Just figured this might help, especially if you are busy and I know you've mentioned updating the script anyways, so maybe this will save you the trouble. If you don't use it that's fine also, no offense taken. I'm not the best scripter, but pretty decent I believe, lol. Here it is.

Code Snippet
Plaintext
//Follow the same steps in the tutorial, 
//except name all the triggers shootable_trig,
//and don't add numbers to them.
//Then make each trigger target it's bottle by selecting the trigger first,
//then select the bottle, hit W in radiant to link them.
//Now you can place as many of these as you want, without having to change anything in script.
//Let's get them all as an array
//instead of writing a seperate function for each bottle, and with no 'while()' loops eating memory

function init()
{
trigs = GetEntArray("shootable_trig", "targetname");
level.shootablesNeeded = trigs.size;
level.shootablesCollected = 0;
   
foreach(trig in trigs)
        {
        trig SetHintString("");
        trig SetCursorHint("HINT_NOICON");
        trig.bottle = GetEnt(trig.target, "targetname");
        trig thread trig_wait();
        }
}

function trig_wait()
{
self waittill("trigger");
self.bottle Delete();
level.shootablesCollected++;
if(level.shootablesCollected >= level.shootablesNeeded)
{
level thread reward();
}
IPrintLnBold("Shootables collected = ["+level.shootablesCollected+"]");
}

function reward()
{
IPrintLnBold("Reward given");
//insert reward code here
}
Title: Re: [Tutorial] Shootable Triggers
Post by: Wolfilms on July 20, 2017, 10:02:13 pm
Thank you very much, it worked for me too !! ;)

No problem   :)

leonardo745, looking back at your original code, I noticed you weren't getting the trigger using
Code Snippet
Plaintext
trig_1 getEnt("whatever", "targetname");
so the game never knew what trigger it was looking for
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 20, 2017, 10:23:26 pm
No problem   :)

leonardo745, looking back at your original code, I noticed you weren't getting the trigger using
Code Snippet
Plaintext
trig_1 getEnt("whatever", "targetname");
so the game never knew what trigger it was looking for

I was, I just forgot to put it here.
My problem is the time to say which weapon I wanted the game to check.
Now my code looks like this:

Code Snippet
Plaintext
    trig_1 = GetEnt("trig_shootable", "targetname");
    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");
    level.etapas = 0;
    correctweapon = GetWeapon("tesla_gun");

    while(1)
    {
    trig_1 waittill("trigger", player);
    usingweapon = player GetCurrentWeapon();
    if(level.powerstatus >= level.poweron)
    {
    if(usingweapon == correctweapon)
    {
                playfx(level._effect["powerup_grabbed"] ,GetEnt("trig_shootable","targetname").origin);

playfx(level._effect["elec_transformer_rod"] ,(-228, -1111, 116), (0,0,0));
  playfx(level._effect["elec_transformer_rod"] ,(-249, -1098, 116), (0,0,0));
  playfx(level._effect["elec_transformer_rod"] ,(-269, -1086, 116), (0,0,0));

  playfx(level._effect["elec_transformer_fx"] ,(-232, -1069, 83), (35, 58 ,0));
  //playfx(level._effect["elec_transformer_fx"] ,GetEnt("elec_transformer_1","targetname").angles);
 
  }
    }
    }
Title: Re: [Tutorial] Shootable Triggers
Post by: leonardo745 on July 20, 2017, 10:29:23 pm
I re-wrote the script to be much shorter, and more flexible. I'm not trying to step on your toes, or 1-up you or anything like that. Just figured this might help, especially if you are busy and I know you've mentioned updating the script anyways, so maybe this will save you the trouble. If you don't use it that's fine also, no offense taken. I'm not the best scripter, but pretty decent I believe, lol. Here it is.

Code Snippet
Plaintext
//Follow the same steps in the tutorial, 
//except name all the triggers shootable_trig,
//and don't add numbers to them.
//Then make each trigger target it's bottle by selecting the trigger first,
//then select the bottle, hit W in radiant to link them.
//Now you can place as many of these as you want, without having to change anything in script.
//Let's get them all as an array
//instead of writing a seperate function for each bottle, and with no 'while()' loops eating memory

function init()
{
trigs = GetEntArray("shootable_trig", "targetname");
level.shootablesNeeded = trigs.size;
level.shootablesCollected = 0;
   
foreach(trig in trigs)
        {
        trig SetHintString("");
        trig SetCursorHint("HINT_NOICON");
        trig.bottle = GetEnt(trig.target, "targetname");
        trig thread trig_wait();
        }
}

function trig_wait()
{
self waittill("trigger");
self.bottle Delete();
level.shootablesCollected++;
if(level.shootablesCollected >= level.shootablesNeeded)
{
level thread reward();
}
IPrintLnBold("Shootables collected = ["+level.shootablesCollected+"]");
}

function reward()
{
IPrintLnBold("Reward given");
//insert reward code here
}

Thanks, this will help me a lot !!
Title: Re: [Tutorial] Shootable Triggers
Post by: Archaicvirus on July 21, 2017, 02:42:24 am
No problemo