-- LUA Script - precede every function and global member with lowercase name of script g_hidden=0 -- add this line for stealth script attackdistance = {} attackstart = {} attackend = {} attacktype = {} viewrange = {} damageframestart = {} damageframeend = {} lastroar = {} lastswipe = {} function ai_ts_fantasycharacter_init(e) ai_soldier_state[e] = "patrol" ai_soldier_pathindex[e] = -1 SetAnimationFrames(24010,24283) LoopAnimation(e) ModulateSpeed(e,1.0) SetAnimationSpeed(e,1.0) attackdistance[e]=70 attackstart[e]=24880 attackend[e]=24919 attacktype[e]=0 damageframestart[e]=24894 damageframeend[e]=24897 lastroar[e] = 0 lastswipe[e] = 0 ai_old_health[e] = -1 SetCharacterSoundSet(e) end function ai_ts_fantasycharacter_main(e) PlayerDist = GetPlayerDistance(e) EntObjNo = g_Entity[e]['obj'] if viewrange[e]==nil then viewrange[e] = AIGetEntityViewRange(EntObjNo) end if GetPlayerDistance(e)< 100 and g_PlayerHealth>0 then -- add these lines for stealth in other fantasy scripts TextColor(45,42,1,"Assassinate Target",255,0,0) -- here end -- here if GetPlayerDistance(e)< 100 and g_PlayerGunFired == 1 then -- here SetEntityHealth(e,0) -- and here end if ai_soldier_state[e] == "patrol" then if ai_soldier_pathindex[e] == -1 then ai_soldier_pathindex[e] = -2 CharacterControlArmed(e) 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 ModulateSpeed(e,1.0) SetCharacterToWalk(e) 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 < viewrange[e] and (g_Entity[e]['plrvisible'] == 1 and g_hidden==0) then-- g_hidden added here if GetPlayerDistance(e)0 then if ai_soldier_state[e] ~= "attack" then SetCharacterToRun(e) AIEntityStop(EntObjNo) ai_soldier_state[e] = "attack" CharacterControlLimbo(e) attacktype[e] = 1 SetAnimationFrames(attackstart[e],attackend[e]) PlayAnimation(e) lastswipe[e] = 0 else if lastswipe[e]==0 and GetAnimationFrame(e)=attackend[e]-1 then ai_soldier_state[e] = "patrol" StopAnimation(e) lastswipe[e]=2 end end else if ai_soldier_state[e] == "attack" then if GetAnimationFrame(e)=attackend[e]-1 then ai_soldier_state[e] = "patrol" StopAnimation(e) end else if ai_soldier_state[e] ~= "charge" then ai_soldier_state[e] = "charge" CharacterControlArmed(e) SetCharacterToRun(e) ModulateSpeed(e,1.5) if lastroar[e]==0 then PlayCharacterSound(e,"onAlert") lastroar[e]=1 end end 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)= viewrange[e] and ai_soldier_state[e]~="patrol" and (g_Entity[e]['plrvisible'] == 1 and g_hidden==0) then ai_soldier_state[e] = "patrol" SetCharacterToWalk(e) ModulateSpeed(e,1.0) end if string.find(string.lower(g_Entity[e]['limbhit']), "head") ~= nil then SetEntityHealth(e,0) ResetLimbHit(e) end end function ai_fantasycharacter_knight2_exit(e) PlayCharacterSound(e,"onDeath") g_rogue_exp = g_rogue_exp + 50 g_infamy = g_infamy + 1 g_kills = g_kills + 1 g_RPG_Gold = g_RPG_Gold + math.random(0 , 50) CollisionOff(e) end