Pushok icon

Expression2 Bot

Pushok | PRO | 12/24/11 05:12:44 PM UTC | 0 ⭐ | 456 👁️ | Never ⏰ | []
Lua |

4.72 KB

|

None

|

0 👍

/

0 👎

@name Something_Funny 
 
#defines
@persist ToOwnerBearing:normal Coef:normal HandFromBody:normal
@persist IndexBody IndexHead IndexHand
@persist BodyPos:vector HeadPos:vector HandPos:vector
@persist BodySize:vector HeadSize:vector HandSize:vector
@persist BodyAng:angle HeadAng:angle HandAng:angle
@persist BodyColor:vector HeadColor:vector HandColor:vector
@persist HandTop ChipPos:vector BallIndex
 
@persist OldVictimPos:vector OldWeaponPos:vector OldWeaponAngles:angle
@persist LenFromBallToTarget CurrentLength Clock Acceleration 
#end
 
function normal createTheBall( WeaponPos:vector )
{
    Index = randint( 4, 100 )
    
    BallSize = vec( 0.4, 0.4, 0.4 )
    BallColor = vec( 0, 0, 0 )
    BallOrigin = WeaponPos
    
    
    holoCreate( Index, BallOrigin, BallSize, ang( 0, 0, 0 ), BallColor )
    holoModel( Index, "sphere", 0 )
    
    return Index
}
 
interval( 10 )
runOnChat( 1 )
 
if( first() )
{
    if( entity():isWeldedTo():id() != 0 )
    {
        print("It works correctly only on ground")
        exit()
    }
    
    ChipPos = entity():pos()
    
    Coef = 6
    Acceleration = 2.5
    TimeOfChat = 0
    
    HandFromBody = 2*Coef + 0.8*Coef
    HandTop = 5*Coef*2 - 3*Coef
    
    BodyPos = ChipPos + vec( 0, 0, 5*Coef )
    HeadPos = ChipPos + vec( 0, 0, 2.5*Coef + 5*Coef*2)
    HandPos = ChipPos + vec( 0, HandFromBody, HandTop )
    
    HandSize = vec( 0.8, 0.8, 3 )
    BodySize = vec( 2, 2, 5 )
    HeadSize = vec( 2.5, 2.5, 2.5 )
    
    HandAng = ang( 0, 0, 0 )
    BodyAng = ang( 0, 0, 0 )
    HeadAng = ang( 0, 0, 0 )
    
    BodyColor = vec( 255, 0, 0 )
    HeadColor = vec( 0, 0, 255 )
    HandColor = vec( 0, 0, 255 )
    
    IndexBody = 1
    IndexHead = 2
    IndexHand = 3
    
    holoCreate( IndexHand, HandPos, HandSize, HandAng, BodyColor )
    holoCreate( IndexBody,  BodyPos, BodySize, BodyAng, HeadColor )
    holoCreate( IndexHead, HeadPos, HeadSize, HeadAng, HandColor )
    
    holoModel( IndexHead, "sphere", 0 )
    
    BallIndex = -1
    CurrentLength = 0
}
else
{
    OwnerOrigin = entity():owner():shootPos()
    ToOwnerBearing = entity():bearing( OwnerOrigin )
    
    BodyAng = ang( 0, -ToOwnerBearing, 0 )
    HeadAng = ang( 0, -ToOwnerBearing, 0 )
    
    ToOwnerElevation = elevation( HandPos, ang( 0, 0, 0 ), OwnerOrigin )
    FromHandToHeadBearing = bearing( HandPos, ang( 0, 0, 0 ), OwnerOrigin )
    HandAngles = ang( -(ToOwnerElevation - 90), -ToOwnerBearing, 0 )
    
    holoAng( IndexBody, ang( 0, -ToOwnerBearing, 0 ) )
    holoAng( IndexHead, ang( 0, -ToOwnerBearing, 0 ) )
    holoAng( IndexHand, HandAngles )
    
    HandNewPos = ChipPos + vec( HandFromBody * sin( FromHandToHeadBearing ), HandFromBody * cos( FromHandToHeadBearing ), HandTop )
    
    holoPos( IndexHand, HandNewPos )
    
    LenFromBallToTarget = (OwnerOrigin - HandNewPos):length()
    
    if( entity():owner():lastSaid() == "!shot" && chatClk() && BallIndex == -1 )
    {
        if( convarnum("wire_expression2_concmd") == 1 )
        {
            if( LenFromBallToTarget < 550 )
            {
                BallIndex = createTheBall( HandNewPos )
                LenFromBallToTarget = (entity():owner():pos() - HandNewPos):length()
                OldWeaponPos = HandNewPos
                OldWeaponAngles = HandAngles
                OldVictimPos = OwnerOrigin
                
                CurrentLength = 0
            }
            else
            {
                print( "Very long distance!" )
            }
        }
        else
        {
            print( "You must enable wire_expression2_concmd" )
        }
    }
    
    if( BallIndex >= 4 )
    {
        BallNewPos = OldWeaponPos + vec( CurrentLength * cos(OldWeaponAngles:yaw()), CurrentLength * sin(OldWeaponAngles:yaw()), CurrentLength * cos(OldWeaponAngles:pitch()))
        LenFromBallToPlayer = (entity():owner():pos() - BallNewPos):length()
        
        if( LenFromBallToPlayer > 40 && CurrentLength < LenFromBallToTarget )
        {
            holoPos( BallIndex, BallNewPos )
            holoColor( BallIndex, vec( randint(1, 255),randint(1, 255),randint(1, 255) ), 255 )
            CurrentLength = Clock*Acceleration
            
            Clock += 2
        }
        else
        {
            holoDelete( BallIndex )
 
            if( LenFromBallToPlayer < 80 )
            { 
                concmd("kill")
                print("I've owned your ass :3")
            }
            
            OldWeraponPos = vec( 0, 0, 0 )
            OldWeaponAngles = ang( 0, 0, 0 )
            OldVictimPos = vec( 0, 0, 0 )
            
            BallIndex = -1
            CurrentLength = 0
            Clock = 0
        }
    }
}

Comments