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

Player is looking at a trigger help

broken avatar :(
Created 12 years ago
by MakeCents
0 Members and 1 Guest are viewing this topic.
3,248 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I need a function that checks if the player is looking at a trigger. Like the UseTriggerRequireLookAt() which works for using a trigger, but I need a function that returns bool, or anything I can work with. I was thinking of may trying to work with getting angles and checking positions of the trigger and player, but I am not sure that will work or that I am capable of that kind of math, lol.
I was trying to use:
Code Snippet
Plaintext
    player isLookingAt(trigger);
but it keeps returning 0, even when I was looking and even using the trigger. Any help with a function that works like that one sounds like it should, or what I may be doing wrong?
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You need to check if the player is looking at the trigger in a loop.
Code Snippet
Plaintext
while(1)
{
        if(player IsLookingAt(trigger))
        {
         //do code
        }
wait .05;
}
Edit: corrected some syntax. xD
Last Edit: June 25, 2014, 01:06:01 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
You need to check if the player is looking at the trigger in a loop.
Code Snippet
Plaintext
while(1)
{
        if(player IsLookingAt(trigger))
        {
         //do code
        }
wait .05;
}
Edit: corrected some syntax. xD

I've done that. Have you gotten that to work? Here is what I have been trying:

Code Snippet
Plaintext
init_looking(){
    flag_wait("all_players_connected");
    //testing with trigger use
    trig = getent("test", "targetname);
    trig.name = "trigger use";
    trig thread looking();
    //testing with trigger radius
    trigradius = getent("testradius", "targetname);
    trigradius.name = "trigger radius";
    trigradius thread looking();
    trigstruct = getstruct("teststruct", "targetname);
    trigstruct.name = "struct";
    trigstruct thread looking();
}
looking(){
    players = get_players();
    while(1){
        for(i=0;i<players.size;i++){
            if(players[i] islookingat(self)){
                iprintlnbold("I see you " + self.name);
            }else{
                iprintln("No line of sight " + self.name);
            }
        }
        wait(1);
    }
}
Now this is the strange part... It says "I see you struct" when I am close enough to a zombie to make my reticle turn red... what the hell?

With the others, all I get is "No line of sight ", and the name, forever.
broken avatar :(
  • n123q45
  • Deleted Member
×
broken avatar :(
n123q45
This user is deleted :(
Code Snippet
Plaintext
looking(){
    trigradius = getent("testradius", "targetname);
    trigstruct = getentt("teststruct", "targetname);
    trigstruct.name = "struct";
    trigradius.name = "trigger radius";
    players = get_players();
    while(1){
        for(i=0;i<players.size;i++){
            if(players[i] islookingat(trigradius) || players[i] islookingat(trigradius)){ // this is an or statement.
                iprintlnbold("I see you " + self.name);
            }else{
                iprintln("No line of sight " + self.name);
            }
        }
        wait(1);
    }
}
dont overthink things. this will check if your looking at the struct or the radius
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Code Snippet
Plaintext
looking(){
    trigradius = getent("testradius", "targetname);
    trigstruct = getentt("teststruct", "targetname);
    trigstruct.name = "struct";
    trigradius.name = "trigger radius";
    players = get_players();
    while(1){
        for(i=0;i<players.size;i++){
            if(players[i] islookingat(trigradius) || players[i] islookingat(trigradius)){ // this is an or statement.
                iprintlnbold("I see you " + self.name);
            }else{
                iprintln("No line of sight " + self.name);
            }
        }
        wait(1);
    }
}
dont overthink things. this will check if your looking at the struct or the radius

LOL! Boy if I had a nickel for every time I heard that. I don't know if I am not explaining myself well enough or what. It probably looks like I am over thinking things because I have tried everything simpler than what I posted already. So now I am running every test I can imagine to try and get any response out of this function:
Code Snippet
Plaintext
    player islookingat(trigger);

I tried your code and it never says "I see you " and the name. Is it working for you? Do I have some other problem? I assume that this function doesn't do what it sounds like. I may need something else to tell me when a player is looking at a specific entity.

broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I would rather suggest doing something like while( self isLookAt( entity ) ), don't want to do a double for/while loop that's just absurd.
Marked as best answer by MakeCents 12 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Thank you to everyone who was trying to help. My problem was not the script it self. It had nothing to do with the script, I was just testing with that script. The problem is the isLookingAt() function. I gave up on that function and made my own:
Code Snippet
Plaintext
isLookingAtMe(trig){
        //Called on player with a trigger entity passed in
angles = vectortoAngles(trig.origin - self.origin);
trigangle = angles[1];
myangle = self.angles[1];
if(trigangle > 180){
trigangle = trigangle - 360;
}
looking = (myangle-trigangle);
if(looking>340){
looking = looking - 360;
}
if(looking < -340){
looking = looking + 360;
}
if(looking > -35 && looking < 35 ){
return 1;
}
return 0;
}
broken avatar :(
  • n123q45
  • Deleted Member
×
broken avatar :(
n123q45
This user is deleted :(
yes after a few attempts at that function, it seems to be broken
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
yes after a few attempts at that function, it seems to be broken

Guaranteed! I would really like to see this function. When it started returning true when my reticle turned red, aimed at the zombies, my head exploded,  :o. May be useful in the future, but wasn't what I was going for. There goes about 5 hours of my life, lol.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
The IslookingAt() function works perfect for me though. :o

Glad you got it working. :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
The IslookingAt() function works perfect for me though. :o

Glad you got it working. :)

NO WAY! No wonder people didn't know what I was talking about then, lol.

 
Loading ...