UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[Tutorial] Shootable Triggers

HOT
broken avatar :(
Created 8 years ago
by reckfullies
0 Members and 1 Guest are viewing this topic.
43,258 views
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
Can you tell me how to allow the trigger to activate only when the tesla_gun fires at the trigger ?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 4 years ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
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.
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
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);
  }
    }
Last Edit: July 19, 2017, 03:08:25 am by Sidzzz
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 4 years ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
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
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
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.




broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 4 years ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
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

someone in the topic mentioned that it worked for them.
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
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

someone in the topic mentioned that it worked for them.

Thank you very much, it worked for me too !! ;)
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
Signature
Let he who has not sinned cast the first stone.
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
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
}
Last Edit: July 20, 2017, 09:47:11 pm by Archaicvirus
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 4 years ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
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
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
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);
 
  }
    }
    }
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 9 June 2015
Last active: 7 years ago
Posts
8
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
leonardo745's Groups
leonardo745's Contact & Social Links
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 !!
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
No problemo

 
Loading ...