Pushok

Expression2 Bot

Dec 24th, 2011
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.72 KB | None | 0 0
  1. @name Something_Funny
  2.  
  3. #defines
  4. @persist ToOwnerBearing:normal Coef:normal HandFromBody:normal
  5. @persist IndexBody IndexHead IndexHand
  6. @persist BodyPos:vector HeadPos:vector HandPos:vector
  7. @persist BodySize:vector HeadSize:vector HandSize:vector
  8. @persist BodyAng:angle HeadAng:angle HandAng:angle
  9. @persist BodyColor:vector HeadColor:vector HandColor:vector
  10. @persist HandTop ChipPos:vector BallIndex
  11.  
  12. @persist OldVictimPos:vector OldWeaponPos:vector OldWeaponAngles:angle
  13. @persist LenFromBallToTarget CurrentLength Clock Acceleration
  14. #end
  15.  
  16. function normal createTheBall( WeaponPos:vector )
  17. {
  18.     Index = randint( 4, 100 )
  19.    
  20.     BallSize = vec( 0.4, 0.4, 0.4 )
  21.     BallColor = vec( 0, 0, 0 )
  22.     BallOrigin = WeaponPos
  23.    
  24.    
  25.     holoCreate( Index, BallOrigin, BallSize, ang( 0, 0, 0 ), BallColor )
  26.     holoModel( Index, "sphere", 0 )
  27.    
  28.     return Index
  29. }
  30.  
  31. interval( 10 )
  32. runOnChat( 1 )
  33.  
  34. if( first() )
  35. {
  36.     if( entity():isWeldedTo():id() != 0 )
  37.     {
  38.         print("It works correctly only on ground")
  39.         exit()
  40.     }
  41.    
  42.     ChipPos = entity():pos()
  43.    
  44.     Coef = 6
  45.     Acceleration = 2.5
  46.     TimeOfChat = 0
  47.    
  48.     HandFromBody = 2*Coef + 0.8*Coef
  49.     HandTop = 5*Coef*2 - 3*Coef
  50.    
  51.     BodyPos = ChipPos + vec( 0, 0, 5*Coef )
  52.     HeadPos = ChipPos + vec( 0, 0, 2.5*Coef + 5*Coef*2)
  53.     HandPos = ChipPos + vec( 0, HandFromBody, HandTop )
  54.    
  55.     HandSize = vec( 0.8, 0.8, 3 )
  56.     BodySize = vec( 2, 2, 5 )
  57.     HeadSize = vec( 2.5, 2.5, 2.5 )
  58.    
  59.     HandAng = ang( 0, 0, 0 )
  60.     BodyAng = ang( 0, 0, 0 )
  61.     HeadAng = ang( 0, 0, 0 )
  62.    
  63.     BodyColor = vec( 255, 0, 0 )
  64.     HeadColor = vec( 0, 0, 255 )
  65.     HandColor = vec( 0, 0, 255 )
  66.    
  67.     IndexBody = 1
  68.     IndexHead = 2
  69.     IndexHand = 3
  70.    
  71.     holoCreate( IndexHand, HandPos, HandSize, HandAng, BodyColor )
  72.     holoCreate( IndexBody,  BodyPos, BodySize, BodyAng, HeadColor )
  73.     holoCreate( IndexHead, HeadPos, HeadSize, HeadAng, HandColor )
  74.    
  75.     holoModel( IndexHead, "sphere", 0 )
  76.    
  77.     BallIndex = -1
  78.     CurrentLength = 0
  79. }
  80. else
  81. {
  82.     OwnerOrigin = entity():owner():shootPos()
  83.     ToOwnerBearing = entity():bearing( OwnerOrigin )
  84.    
  85.     BodyAng = ang( 0, -ToOwnerBearing, 0 )
  86.     HeadAng = ang( 0, -ToOwnerBearing, 0 )
  87.    
  88.     ToOwnerElevation = elevation( HandPos, ang( 0, 0, 0 ), OwnerOrigin )
  89.     FromHandToHeadBearing = bearing( HandPos, ang( 0, 0, 0 ), OwnerOrigin )
  90.     HandAngles = ang( -(ToOwnerElevation - 90), -ToOwnerBearing, 0 )
  91.    
  92.     holoAng( IndexBody, ang( 0, -ToOwnerBearing, 0 ) )
  93.     holoAng( IndexHead, ang( 0, -ToOwnerBearing, 0 ) )
  94.     holoAng( IndexHand, HandAngles )
  95.    
  96.     HandNewPos = ChipPos + vec( HandFromBody * sin( FromHandToHeadBearing ), HandFromBody * cos( FromHandToHeadBearing ), HandTop )
  97.    
  98.     holoPos( IndexHand, HandNewPos )
  99.    
  100.     LenFromBallToTarget = (OwnerOrigin - HandNewPos):length()
  101.    
  102.     if( entity():owner():lastSaid() == "!shot" && chatClk() && BallIndex == -1 )
  103.     {
  104.         if( convarnum("wire_expression2_concmd") == 1 )
  105.         {
  106.             if( LenFromBallToTarget < 550 )
  107.             {
  108.                 BallIndex = createTheBall( HandNewPos )
  109.                 LenFromBallToTarget = (entity():owner():pos() - HandNewPos):length()
  110.                 OldWeaponPos = HandNewPos
  111.                 OldWeaponAngles = HandAngles
  112.                 OldVictimPos = OwnerOrigin
  113.                
  114.                 CurrentLength = 0
  115.             }
  116.             else
  117.             {
  118.                 print( "Very long distance!" )
  119.             }
  120.         }
  121.         else
  122.         {
  123.             print( "You must enable wire_expression2_concmd" )
  124.         }
  125.     }
  126.    
  127.     if( BallIndex >= 4 )
  128.     {
  129.         BallNewPos = OldWeaponPos + vec( CurrentLength * cos(OldWeaponAngles:yaw()), CurrentLength * sin(OldWeaponAngles:yaw()), CurrentLength * cos(OldWeaponAngles:pitch()))
  130.         LenFromBallToPlayer = (entity():owner():pos() - BallNewPos):length()
  131.        
  132.         if( LenFromBallToPlayer > 40 && CurrentLength < LenFromBallToTarget )
  133.         {
  134.             holoPos( BallIndex, BallNewPos )
  135.             holoColor( BallIndex, vec( randint(1, 255),randint(1, 255),randint(1, 255) ), 255 )
  136.             CurrentLength = Clock*Acceleration
  137.            
  138.             Clock += 2
  139.         }
  140.         else
  141.         {
  142.             holoDelete( BallIndex )
  143.  
  144.             if( LenFromBallToPlayer < 80 )
  145.             {
  146.                 concmd("kill")
  147.                 print("I've owned your ass :3")
  148.             }
  149.            
  150.             OldWeraponPos = vec( 0, 0, 0 )
  151.             OldWeaponAngles = ang( 0, 0, 0 )
  152.             OldVictimPos = vec( 0, 0, 0 )
  153.            
  154.             BallIndex = -1
  155.             CurrentLength = 0
  156.             Clock = 0
  157.         }
  158.     }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment