################
# > Football: A football that you can play with.
# > How to use: Press E to kick, right click to raise it for a volley.
################

@name Football by Neo
@model models/props_phx/misc/soccerball.mdl
@persist Mode

interval(50)

if (first()|duped()) {
    hint("Football by Neo, spawned successfully!",10)
    # Mode: 1 = All players
    # Mode: 2 = Only you
    Mode=1
    entity():soundPlay("ui/gamestartup2.mp3",0,"ui/gamestartup2.mp3")
}

Ball = entity()
findByClass("player*")
Players=findToArray()
for(I=1, Players:count()) {
    if (Mode==1) {
        Player=Players[I,entity]
    }
    elseif (Mode==2) {
        Player=owner()
    }
    
if (((Player:pos()+vec(0,0,32)):distance(Ball:pos()) < 100)&Player:keyUse()) {
    Ball:applyForce((Ball:pos()-(Player:pos()+vec(0,0,4)))*200)
}
elseif (((Player:pos()+vec(0,0,32)):distance(Ball:pos()) < 100)&Player:keyAttack2()) {
    Ball:applyForce((Ball:pos()-(Ball:pos()-vec(0,0,4)))*200)
}

}
