@name Zombie
@persist Base:vector Delay
interval(10)

Sound = array()
Sound:setString(1,"npc/zombie/zombie_alert1.wav")
Sound:setString(2,"npc/zombie/zombie_alert3.wav")
S = randint(1,2)

E = entity():isWeldedTo()
E:setMass(100)

if(first())
{
    entity():setAlpha(0)
}    


findByClass("player")
findInSphere(E:pos(),99999999)
Targ = findClosest(E:pos())
OPos = Targ:pos()

#Sets up parts we're gonna use
RH = E:bone(7) #Right hand
LH = E:bone(5) #Left hand
Head = E:bone(10)
LF = E:bone(13) #Left foot
RF = E:bone(14) #Right Foot

if ((E:pos():distance(OPos) < 100) & !Delay) {
   soundPurge()
   timer("delay",750)
   Force = 10^3
   soundPlay(0,100,Sound:string(S))
   E:applyForce(Force * (OPos - E:boxCenterW()))
   Delay = 1
} else {
   Force = 3
   E:applyForce(E:vel() * -7)
}

if (clk("delay")) {Delay = 0}

#Extends teh arms
RH:applyForce(Force*(OPos - RH:pos()))
LH:applyForce(Force*(OPos - LH:pos()))

#To make it stand up, I pushed the feet down and the head up.
Base = vec(0,0,150)
LF:applyForce(-Base)
RF:applyForce(-Base)
Head:applyForce(Base*14)



