OK, lets go step by step.
1- What zombie are you using for?
I suggest above the zombie named "Slow Zombie 1", this is a stock one, look into "Entitybank>characters>zombies", and place him onto your map.
2- Select zombie in editor, and go to his properties, once there:
a- Please refer to my video and see how I state properties, and do the same with your zombie.
this is the complete script you has to attach to you zombie.
-- LUA Script - precede every function and global member with lowercase name of script
attackstart = {}
attackend = {}
damageframestart = {}
damageframeend = {}
lastroar = {}
lastswipe = {}
function ai_zombiewalk2_init(e)
ai_soldier_state[e] = "idle"
CharacterControlLimbo(e)
SetAnimationFrames(210,234)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,0.1)
attackstart[e]=683
attackend[e]=722
damageframestart[e]=694
damageframeend[e]=720
lastroar[e]=0
lastswipe[e]=0
end
function ai_zombiewalk2_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 (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)+5000
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.75)
if GetAnimationFrame(e)<attackstart[e] or GetAnimationFrame(e)>attackend[e] then
AIEntityStop(EntObjNo)
ai_soldier_state[e] = "attack"
CharacterControlLimbo(e)
SetAnimationFrames(attackstart[e],attackend[e])
PlayAnimation(e)
end
end
if ai_soldier_state[e]=="attack" then
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)
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"
if GetPlayerDistance(e) < 80 then
ai_soldier_state[e] = "idle"
CharacterControlLimbo(e)
SetAnimationFrames(attackstart[e]-1,attackstart[e]-1)
PlayAnimation(e)
RotateToPlayer(e)
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)
SetAnimationFrames(210,234)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
end
end
end
function ai_zombiewalk2_exit(e)
PlayCharacterSound(e,"onDeath")
CollisionOff(e)
PromptDuration("Collected key",3000)
PlaySound(e,0)
Collected(2)
Destroy(2)
ActivateIfUsed(2)
end
Copy & paste into notepad or whatever you want, and save it onto your "scripbank" folder.
Properties have one field labeled "Main", click and search for script named "ai_zombiewalk2.lua" or whatever you do, and attach it to your zombie, just click ok.
I high recommended you firts follow all steps as is. When you get it working, so study step by step all the script, try to understand who is doing what, in another words what piece of code, gives the key to the player.
When you feel confortable with, so change script name, add features, or something other, if you want. Try and error, sometimes is the best here.
Please see the video slowly, so you will discover news things than perhaps you has missed before, and Voila!!!
If you've any question, feel free for do it, somebody here, even myself can answer to you.
3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics