; UNIFIED ZOMBIE MOD 4 ZOMBIE MOVEMENT SCRIPT!!!
; DO NOT COPY OR USE ANY PART OF THIS SCRIPT WITHOUT PRIOR APPROVAL FROM SCOTT TUNSTALL (scott.tunstall@ntlworld.com)
; WORK (C) 2004 SCOTT TUNSTALL
; Apologies for the cramped text but I wanted the scripts to run as fast as I could.

_z=_this Select 0

_z setdamage 0.7;
[_z] exec "\pepzombies\initpepzface.sqs"
_z switchmove "FML_HP3_rising";

gblZombieList=gblZombieList+[_z]
_z setcaptive false;
_ty=typeof _z
_gp=group _z

#ft
?count gblAllTargets ==0: goto "wm"

_p=gblZombieEvalTime
_bt=900000
_t=gblAllTargets Select 0
_y=0

#lp
?_y>=count gblAllTargets: _z dowatch _t; goto "mn" 

_u=gblAllTargets select _y
_sc= ([_z, _u] call zmtargetscore)
?_sc<_bt:_t=_u;_bt=_sc
~.3
_y=_y+1
goto "lp"

#mn
?(!alive _z): goto "ckr"
?(!alive _t): goto "ft"
_z domove getpos _t

_rsound = random 30
_rsound = _rsound - (_rsound) mod 1
~0.5
? (_rsound==1): _z say "pepz_zmove1";
? (_rsound==2): _z say "pepz_zmove2";
? (_rsound==3): _z say "pepz_zmove3";
? (_rsound==4): _z say "pepz_zmove4";
? (_rsound==5): _z say "pepz_zmove5";

_d=_z distance _t
?_d<=6: goto "eg" 
~0.5
_d=_z distance _t
?_d<=6: goto "eg" 
~0.5
_d=_z distance _t
?_d<=6: goto "eg" 
~0.5
_d=_z distance _t
?_d<=6: goto "eg" 
_p=_p-1
?_p==0:goto "ft"
goto "mn"

#eg
? ("Man" counttype [_t] >0) && _d<=2.2: goto "Man"
? ("Car" counttype [_t] >0) && _d<=4: goto "Car"
? ("APC" counttype [_t] >0) && _d<=4: goto "APC"
? ("Building" counttype [_t] >0): goto "Bld"
? ("Tank" counttype [_t] >0) && _d <=4: goto "Tank"
_z playmove "civilwalkf"
~1
goto "mn" 


#Man
? ([_z, _t] call zmheightdist > 2): goto "mn"
?(gblEventHandlers==1)&&(gblOnAttack!="."):[_z,_t] exec gblOnAttack; goto "mn" 
_z SwitchMove "standstrokefist"

_rasound = random 4
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _z say "pepz_attack1";
? (_rasound==1): _z say "pepz_attack2";
? (_rasound==2): _z say "pepz_attack3";
? (_rasound==3): _z say "pepz_attack4";

~0.5
?_z distance _t >2.5: goto "mn"
?!alive_z: goto "ckr"

[_z,_t] Exec "\pepzombies\blood.sqs"; 
_t setdamage damage _t + gblZombieDamage
[_t] exec "\pepzombies\hasbeenbit.sqs"
_rasound = random 6
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _t say "pep_pain1";
? (_rasound==1): _t say "pep_pain2";
? (_rasound==2): _t say "pep_pain3";
? (_rasound==3): _t say "pep_pain4";

~1.3
?(gblEventHandlers==1)&&(gblOnHumanHit!="."): [_z,_t] exec gblOnHumanHit
?!alive (_t):goto "eat"
?(alive _z) && (_z distance _t <=2.5): goto "Man"
goto "mn"

#Car
? ([_z, _t] call zmheightdist > 2): goto "mn"

?(gblEventHandlers==1)&&(gblOnAttack!="."): [_z,_t] exec gblOnAttack; goto "mn" 
_z SwitchMove "standstrokefist"

_rasound = random 4
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _z say "pepz_attack1";
? (_rasound==1): _z say "pepz_attack2";
? (_rasound==2): _z say "pepz_attack3";
? (_rasound==3): _z say "pepz_attack4";

~0.5
?_z distance _t >4: goto "mn"
?!alive_z: goto "ckr"
_t setdamage (damage _t) + gblZombieCarDamage
~1.3
?(gblEventHandlers==1)&&(gblOnCarHit!="."): [_z,_t] exec gblOnCarHit
~1
?(alive _z) && (alive _t) && (_z distance _t <=4): goto "Car"
goto "mn"

#APC
? ([_z, _t] call zmheightdist > 2): goto "mn"
?(gblEventHandlers==1)&&(gblOnAttack!="."): [_z,_t] exec gblOnAttack; goto "mn" 
#za
_z SwitchMove "standstrokefist"

_rasound = random 4
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _z say "pepz_attack1";
? (_rasound==1): _z say "pepz_attack2";
? (_rasound==2): _z say "pepz_attack3";
? (_rasound==3): _z say "pepz_attack4";

~0.5
?_z distance _t>4: goto "mn"
?!alive_z: goto "ckr"
_t setdamage (damage _t) + gblZombieAPCDamage 
~1.3
?(gblEventHandlers==1)&&(gblOnAPCHit!="."): [_z,_t] exec gblOnAPCHit
~1
? (alive _z) && (alive _t) && (_z distance _t<=4): goto "APC"
goto "mn"

#Tank
? ([_z, _t] call zmheightdist > 2): goto "mn"

?(gblEventHandlers==1)&&(gblOnAttack!="."): [_z,_t] exec gblOnAttack; goto "mn" 
#zt
_z SwitchMove "standstrokefist" 

_rasound = random 4
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _z say "pepz_attack1";
? (_rasound==1): _z say "pepz_attack2";
? (_rasound==2): _z say "pepz_attack3";
? (_rasound==3): _z say "pepz_attack4";

~0.5
?_z distance _t>4: goto "mn"
?!alive_z: goto "ckr"
_t setdamage (damage _t) + gblZombieTankDamage 
~1.3
?(gblEventHandlers==1)&&(gblOnTankHit!="."): [_z,_t] exec gblOnTankHit
~1
?(alive _z) && (alive _t) && (_z distance _t<=4): goto "Tank"
goto "mn"

#Bld
?(gblEventHandlers==1)&&(gblOnAttack!="."): [_z,_t] exec gblOnAttack; goto "mn" 
_z SwitchMove "standstrokefist" 

_rasound = random 4
_rasound = _rasound - (_rasound) mod 1
? (_rasound==0): _z say "pepz_attack1";
? (_rasound==1): _z say "pepz_attack2";
? (_rasound==2): _z say "pepz_attack3";
? (_rasound==3): _z say "pepz_attack4";

~0.5
?!alive_z: goto "ckr"
; Buildings don't move, so we know we'll be near it!

_t setdamage (damage _t) + gblZombieBuildingDamage
~1.3
?(gblEventHandlers==1)&&(gblOnBuildingHit!="."): [_z,_t] exec gblOnBuildingHit
~1
goto "mn"

; eat target
#eat
_z setpos GetPos _t
_z dowatch GetPos _t
_ec=(random(1)*2) + 2
_y=0

#elp
?!alive_z: goto "ckr"
_z PlayMove "FML_HP3_eat"
_rasound = random 3
? (_rasound<1): _z say "pepz_z_eat1"
~7
_y=_y+1
?_y<=_ec: goto "elp"
goto "ft"

; wait for more targets to be added to gblAllTargets
#wm
?!alive_z:goto "ckr"
?count gblAllTargets!=0: goto "ft"
~2
goto "wm"

; Check resurrection. Should we resurrect this zombie?
#ckr
?gblIndestructibleZombies!= 1: goto "dz"
~gblZombieResrWait + random 5
[_z,_ty,_gp] exec {\pepzombies\reszombie.sqs}
exit

; Delete zombie
#dz
?(gblEventHandlers==1)&&(gblOnZombieDeath!="."): [_z] exec gblOnZombieDeath; goto "mn"
gblZombieList=gblZombieList-[_z]
~gblZombieDelPause
deletevehicle _z
exit