-- LUA Script - precede every function and global member with lowercase name of script attackstart = {} attackend = {} damageframestart = {} damageframeend = {} lastroar = {} lastswipe = {} function ai_zombiewalk4_init(e) ai_soldier_state[e] = "idle" CharacterControlLimbo(e) SetAnimationFrames(239,298) LoopAnimation(e) ModulateSpeed(e,1.0) SetAnimationSpeed(e,1.0) attackstart[e]=473 attackend[e]=536 damageframestart[e]=480 damageframeend[e]=530 lastroar[e]=0 lastswipe[e]=0 end function ai_zombiewalk4_main(e) PlayerDist = GetPlayerDistance(e) EntObjNo = g_Entity[e]['obj'] if (PlayerDist < 600 and ai_soldier_state[e] == "idle" and g_Entity[e]['plrvisible'] == 1) or (AIGetEntityHeardSound(EntObjNo) == 1 and ai_soldier_state[e] == "idle") or (PlayerDist < 100 and ai_soldier_state[e] == "idle") then RotateToPlayer(e) if GetTimer(e) > lastroar[e] then lastroar[e]= GetTimer(e)+6000 PlaySound(e,0) end end if PlayerDist < 600 and g_Entity[e]['plrvisible']==1 then RotateToPlayer(e) if PlayerDist < 80 and g_Entity[e]['plrvisible']==1 then if ai_soldier_state[e]~="attack" then SetAnimationSpeed(e,1) if GetAnimationFrame(e)attackend[e] then AIEntityStop(EntObjNo) ai_soldier_state[e] = "attack" --CharacterControlLimbo(e) randomattack=math.random(1,3) if randomattack==1 then attackstart[e]=473 attackend[e]=536 damageframestart[e]=480 damageframeend[e]=530 end if randomattack==2 then attackstart[e]=551 attackend[e]=615 damageframestart[e]=540 damageframeend[e]=600 end if randomattack==3 then attackstart[e]=304 attackend[e]=392 damageframestart[e]=331 damageframeend[e]=338 end if g_Entity[e]['animating'] == 0 then SetAnimationFrames(attackstart[e],attackend[e]) PlayAnimation(e) g_Entity[e]['animating'] = 1 end end end if ai_soldier_state[e]=="attack" then SetAnimationSpeed(e,1) if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e)<=damageframeend[e] then if GetPlayerDistance(e)<80 then if GetTimer(e) > lastswipe[e] then lastswipe[e]= GetTimer(e)+1600 PlaySound(e,1) randomdamage=math.random(3,7) HurtPlayer(e,randomdamage) end end end if GetAnimationFrame(e)>attackend[e]-1 then CharacterControlUnarmed(e) ai_soldier_state[e] = "roam" randomroam=math.random(1,2) if randomroam == 1 then SetAnimationFrames(1107,1137) end if randomroam == 2 then SetAnimationFrames(1158,1188) end if GetPlayerDistance(e)<80 then --ai_soldier_state[e] = "idle" --CharacterControlLimbo(e) SetAnimationFrames(239,298) RotateToPlayer(e) end if g_Entity[e]['animating'] == 0 then PlayAnimation(e) g_Entity[e]['animating'] = 1 end end end else if ai_soldier_state[e]~="roam" then ai_soldier_state[e] = "roam" CharacterControlUnarmed(e) ModulateSpeed(e,1.0) SetAnimationSpeed(e,1.0) SetCharacterToWalk(e) end rndx=math.random(1,360) rndz=math.random(1,360) rndx2=math.sin(rndx)*30 rndz2=math.cos(rndz)*30 AIEntityGoToPosition(EntObjNo,g_PlayerPosX+rndx2,g_PlayerPosZ+rndz2) end else if PlayerDist >= 600 and ai_soldier_state[e] ~= "idle" then ai_soldier_state[e] = "idle" --CharacterControlLimbo(e) if g_Entity[e]['animating'] == 0 then SetAnimationFrames(239,298) LoopAnimation(e) g_Entity[e]['animating'] = 1 end ModulateSpeed(e,1.0) SetAnimationSpeed(e,1.0) end end --PromptLocal(e,"ZOMBIEWALK3 : Dist=" .. PlayerDist .. " State=" .. ai_soldier_state[e] .. " Vis=" .. g_Entity[e]['plrvisible'] .. " Frm=" .. GetAnimationFrame(e) ) end function ai_zombiewalk4_exit(e) PlayCharacterSound(e,"onDeath") CollisionOff(e) end