-- LUA Script - precede every function and global member with lowercase name of script attackstart = {} attackend = {} damageframestart = {} damageframeend = {} lastroar = {} lastswipe = {} function ai_zombiewalkmyke_init(e) ai_soldier_state[e] = "idle" chooseidle=math.random(1,2) if chooseidle == 1 then SetAnimationFrames(123,283) end if chooseidle == 2 then SetAnimationFrames(288,528) end PlayAnimation(e) ModulateSpeed(e,1.0) SetAnimationSpeed(e,1.0) attackstart[e]=683 attackend[e]=726 damageframestart[e]=690 damageframeend[e]=710 lastroar[e] = 0 lastswipe[e] = 0 end function ai_zombiewalkmyke_main(e) PlayerDist = GetPlayerDistance(e) EntObjNo = g_Entity[e]['obj'] --if (PlayerDist < 1000 and ai_soldier_state[e] == "idle" and g_Entity[e]['plrvisible'] == 1) or if (PlayerDist < 1000 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) ai_soldier_state[e] = "detected" if GetTimer(e) > lastroar[e] then lastroar[e]= GetTimer(e)+3000 PlaySound(e,0) end end if PlayerDist < 6000 and ai_soldier_state[e] ~= "idle" then RotateToPlayer(e) if PlayerDist < 110 then if ai_soldier_state[e]~="attack" then SetAnimationSpeed(e,1.75) if GetAnimationFrame(e)attackend[e] then AIEntityStop(EntObjNo) ai_soldier_state[e] = "attack" CharacterControlLimbo(e) attackstart[e]=683 attackend[e]=726 damageframestart[e]=690 damageframeend[e]=710 SetAnimationFrames(attackstart[e],attackend[e]) PlayAnimation(e) end end if ai_soldier_state[e]=="attack" then SetAnimationSpeed(e,2) if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e) lastswipe[e] then lastswipe[e]= GetTimer(e)+1600 PlaySound(e,1) end randomdamage=math.random(3,7) HurtPlayer(e,randomdamage) 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(533,603) end if randomroam == 2 then SetAnimationFrames(608,678) end if GetPlayerDistance(e)<110 then ai_soldier_state[e] = "idle" CharacterControlLimbo(e) SetAnimationFrames(123,283) RotateToPlayer(e) end PlayAnimation(e) end end else if GetPlayerDistance(e)>109 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 end -- PromptLocal(e,"Dist=" .. PlayerDist .. " State=" .. ai_soldier_state[e] .. " Vis=" .. g_Entity[e]['plrvisible']) end function ai_zombiewalk_exit(e) PlayCharacterSound(e,"onDeath") CollisionOff(e) end