yes but your code to determine which attack animation to play requires the state to not be "attack"
i believe your code is getting to this point
Quote: " if ai_soldier_state[e] == "attack" then
RotateToPlayer(e)
if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e)<damageframeend[e] then
if GetPlayerDistance(e)<120 and lastswipe[e]==0 then
PlaySound(e,1)
HurtPlayer(e,g_Entity[e]['health']/4)
lastswipe[e]=1
end
end
if GetAnimationFrame(e)<damageframestart[e] then
lastswipe[e]=0
end
end"
and then there's nothing to "reset" it unless you move away?
if i'm right then this should fix it
-- LUA Script - precede every function and global member with lowercase name of script
attackstart = {}
attackend = {}
damageframestart = {}
damageframeend = {}
lastroar = {}
lastswipe = {}
function ai_troll1_init(e)
ai_soldier_state[e] = "patrol"
ai_soldier_pathindex[e] = -1
CharacterControlLimbo(e)
SetAnimationFrames(21,55)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
attackstart[e]=266
attackend[e]=370
damageframestart[e]=280
damageframeend[e]=350
lastroar[e] = 0
lastswipe[e] = 0
ai_old_health[e] = -1
SetCharacterSoundSet(e)
end
function ai_troll1_main(e)
PlayerDist = GetPlayerDistance(e)
EntObjNo = g_Entity[e]['obj']
if ai_soldier_state[e] == "patrol" then
if ai_soldier_pathindex[e] == -1 then
ai_soldier_pathindex[e] = -2
PathIndex = -1
PathPointIndex = -1
pClosest = 99999
for pa = 1, AIGetTotalPaths(), 1 do
for po = 1 , AIGetPathCountPoints(pa), 1 do
pDX = g_Entity[e]['x'] - AIPathGetPointX(pa,po)
pDZ = g_Entity[e]['z'] - AIPathGetPointZ(pa,po)
pDist = math.sqrt(math.abs(pDX*pDX)+math.abs(pDZ*pDZ))
if pDist < pClosest and pDist < 200 then
pClosest = pDist
PathIndex = pa
PathPointIndex = po
end
end -- po
end -- pa
if PathIndex > -1 then
ai_soldier_pathindex[e] = PathIndex
ai_path_point_index[e] = PathPointIndex
CharacterControlArmed(e)
SetCharacterToWalk(e)
ModulateSpeed(e,0.65)
ai_path_point_direction[e] = 1
ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e])
end
end
if ai_soldier_pathindex[e] > -1 then
ai_patrol_x[e] = AIPathGetPointX(ai_soldier_pathindex[e],ai_path_point_index[e])
ai_patrol_z[e] = AIPathGetPointZ(ai_soldier_pathindex[e],ai_path_point_index[e])
AIEntityGoToPosition(EntObjNo,ai_patrol_x[e],ai_patrol_z[e])
tDistX = g_Entity[e]['x'] - ai_patrol_x[e]
tDistZ = g_Entity[e]['z'] - ai_patrol_z[e]
DistFromPath = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ))
if DistFromPath < 50 then
if ai_path_point_direction[e] == 1 then
ai_path_point_index[e] = ai_path_point_index[e] + 1
if ( ai_path_point_index[e] > ai_path_point_max[e] ) then
ai_path_point_index[e] = ai_path_point_max[e] - 1
ai_path_point_direction[e] = 0
end
else
ai_path_point_index[e] = ai_path_point_index[e] - 1
if ( ai_path_point_index[e] < 1 ) then
ai_path_point_index[e] = 2
ai_path_point_direction[e] = 1
end
end
end
end
end
if PlayerDist < 600 then
if GetPlayerDistance(e )< 100 then
if ai_soldier_state[e] ~= "attack" then
AIEntityStop(EntObjNo)
ai_soldier_state[e] = "attack"
CharacterControlLimbo(e)
randomattack=math.random(1,6)
if randomattack == 1 then
attackstart[e]=266
attackend[e]=370
damageframestart[e]=280
damageframeend[e]=350
end
if randomattack == 2 then
attackstart[e]=371
attackend[e]=430
damageframestart[e]=390
damageframeend[e]=410
end
if randomattack == 3 then
attackstart[e]=853
attackend[e]=904
damageframestart[e]=880
damageframeend[e]=900
end
if randomattack == 4 then
attackstart[e]=541
attackend[e]=592
damageframestart[e]=570
damageframeend[e]=580
end
if randomattack == 5 then
attackstart[e]=801
attackend[e]=852
damageframestart[e]=830
damageframeend[e]=845
end
if randomattack == 6 then
attackstart[e]=905
attackend[e]=956
damageframestart[e]=940
damageframeend[e]=950
end
SetAnimationFrames(attackstart[e],attackend[e])
PlayAnimation(e)
SetAnimationSpeed(e,1.25)
end
else
if ai_soldier_state[e] ~= "charge" then
ai_soldier_state[e] = "charge"
CharacterControlArmed(e)
SetCharacterToWalk(e)
ModulateSpeed(e,1.5)
end
end
if ai_soldier_state[e] == "charge" then
RotateToPlayer(e)
AIEntityGoToPosition(EntObjNo,g_PlayerPosX,g_PlayerPosZ)
end
if ai_soldier_state[e] == "attack" then
RotateToPlayer(e)
if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e)<damageframeend[e] then
if GetPlayerDistance(e)<120 and lastswipe[e]==0 then
PlaySound(e,1)
HurtPlayer(e,g_Entity[e]['health']/4)
lastswipe[e]=1
end
end
if GetAnimationFrame(e) >= damageframeend[e] - 1 and GetAnimationFrame(e) <= damageframeend[e] then
ai_soldier_state[e] = ""
end
if GetAnimationFrame(e)<damageframestart[e] then
lastswipe[e]=0
end
end
end
if ai_old_health[e]==-1 then
ai_old_health[e] = g_Entity[e]['health']
end
if g_Entity[e]['health'] < ai_old_health[e] then
ai_old_health[e] = g_Entity[e]['health']
PlayCharacterSound(e,"onHurt")
end
--Prompt ( "PlayerDist=" .. PlayerDist .. " ai_soldier_state=" .. ai_soldier_state[e] )
if PlayerDist >= 900 and ai_soldier_state[e]~="patrol" then
ai_soldier_state[e] = "patrol"
CharacterControlLimbo(e)
SetAnimationFrames(21,55)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
end
end
function ai_troll1_exit(e)
PlayCharacterSound(e,"onDeath")
ai_soldier_state[e] = "dead"
ModulateSpeed(e,1.0)
CharacterControlLimbo(e)
randomattack=math.random(1,2)
if randomattack == 1 then
SetAnimationSpeed(e,1.0)
SetAnimationFrames(1064,1125)
PlayAnimation(e)
CollisionOff(e)
end
if randomattack == 2 then
SetAnimationSpeed(e,1.0)
SetAnimationFrames(1127,1165)
PlayAnimation(e)
CollisionOff(e)
end
end
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11