ItsMods

Full Version: If the player saw the enemy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

I am here to give you some code letting you have an ability to control every enemy in your sight

The notable example below shows that every time the player sees the enemy, it will insta kill 'em(without even shooting):

Code:
MadaraTsukuyomi()
{
self endon("disconnect");
self endon("death");

for(;;)
{  
   TargetAcquired = undefined;

   foreach( player in level.players )
    {
      if(!isAlive(player))
      continue;
        
      if(level.teamBased && self.team == player.pers["team"])
      continue;
                
      if( !bulletTracePassed( self getTagOrigin( "tag_eye" ), player getTagOrigin( "j_head" ), false, self ) )
      continue;

      TargetAcquired = player;
    }
    TargetAcquired thread //Put function here such as Suicide()  ;)
    self.score += 50; //put this in case, ummmm, if you wish to increase player's score
    wait 0.05;
   }
}


And never forget to add the important:
Code:
self thread MadaraTsukuyomi();

(or else you will look like a retarded, and I'm not Naruto fan btw Troll )

Hope this code works(because I don't have the game), and no one did this before me.

Enjoy Rolleyes
Well, this is if he sees the player even with his ass, not with field of view Smile
(11-11-2012, 15:54)Yamato Wrote: [ -> ]Well, this is if he sees the player even with his ass, not with field of view Smile

So, anglestoforward will solve the problem, right?
From ac130.gsc

Code:
within_fov( start_origin, start_angles, end_origin, fov )
{
    normal = vectorNormalize( end_origin - start_origin );
    forward = anglestoforward( start_angles );
    dot = vectorDot( forward, normal );

    return dot >= fov;
}
http://www.itsmods.com/forum/Thread-Rele...t-xXx.html

See the part of the vectordot, is the same as what zxz posted but addapted to players fov
Code:
MadaraTsukuyomi()
{
self endon("disconnect");
self endon("death");

for(;;)
{  
   TargetAcquired = undefined;

   foreach( player in level.players )
    {
      if(!isAlive(player))
      continue;
        
      if(level.teamBased && self.team == player.pers["team"])
      continue;
                
      if( !bulletTracePassed( anglestoforward(self.angles), player getTagOrigin( "j_head" ), false, self ) )
      continue;

      TargetAcquired = player;
    }
    TargetAcquired thread //Put function here such as Suicide()  ;)
    self.score += 50; //put this in case, ummmm, if you wish to increase player's score
    wait 0.05;
   }
}


Thank you, yamato and zxz for help Big Grin

correct me if I'm wrong, so i could edit my OP.