-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- DESCRIPTION: smallg's stealth ai script - works with the stock GG Max AI -- DESCRIPTION: [STEALTHDURATION=1000] (how long the AI will phase out for) -- DESCRIPTION: [STEALTHDELAY=2000] (how long the AI stay visible for between phasing) -- DESCRIPTION: [AINAME$="all"] (can specify AI to affect by name or set "all" for all possible AI) -- DESCRIPTION: [STEALTHONDAMAGE!=1] (try to stealth when taking damage?) -- DESCRIPTION: [ATTACKONUNSTEALTH!=1] (try to only unstealth when able to attack?) local timer = {} local isstealthed = {} local oldhealth = {} g_ai_stealthsuits = {} function ai_stealthsuits_properties(e, stealthduration, stealthdelay, ainame, stealthondamage, attackonunstealth) local as = g_ai_stealthsuits[e] as.stealthduration = stealthduration as.stealthdelay = stealthdelay as.ainame = ainame as.stealthondamage = stealthondamage as.attackonunstealth = attackonunstealth end function ai_stealthsuits_init(e) g_ai_stealthsuits[e] = {} local as = g_ai_stealthsuits[e] as.stealthduration = 1000 as.stealthdelay = 2000 as.ainame = "all" as.stealthondamage = 1 as.attackonunstealth = 1 timer[e] = {} oldhealth[e] = {} end function ai_stealthsuits_main(e) local function SecondsToClock(seconds) local seconds = tonumber(seconds) if seconds <= 0 then return "00:00:00"; else hours = string.format("%02.f", math.floor(seconds/3600)); mins = string.format("%02.f", math.floor(seconds/60 - (hours*60))); secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60)); return hours..":"..mins..":"..secs end end local function RaycastALL(x1,y1,z1,x2,y2,z2,IgnoreObj) local r = IntersectAll(x1,y1,z1,x2,y2,z2,IgnoreObj) -- returns 1 if the ray cast hits ANY entity or lightmapped geometry if r == nil then r = -1 end return r end local as = g_ai_stealthsuits[e] --a = entity number, b = state value for a,b in pairs (ai_bot_state) do if a ~= nil and b ~= nil then local ent = g_Entity[a] if ent.health > 0 then --Prompt(ai_state_fireonspot.." "..b) if as.ainame == "all" or GetEntityName(a) == as.ainame then if timer[e][a] == nil then timer[e][a] = {} end if b == ai_state_fireonspot or b == ai_state_move or b == ai_state_duck then if isstealthed[a] == nil then isstealthed[a] = 0 timer[e][a][1] = g_Time + as.stealthdelay elseif isstealthed[a] == 0 then --PromptLocal(a,"stealth in "..SecondsToClock((timer[e][a]-g_Time)/1000)) if oldhealth[e][a] == nil then oldhealth[e][a] = ent.health end if g_Time > timer[e][a][1] or (ent.health < oldhealth[e][a] and as.stealthondamage == 1) then Hide(a) isstealthed[a] = 1 timer[e][a][2] = g_Time + as.stealthduration end if ent.health < oldhealth[e][a] then oldhealth[e][a] = ent.health end elseif isstealthed[a] == 1 then local x1,y1,z1,x2,y2,z2 if as.attackonunstealth == 1 then x1,y1,z1 = ent.x, ent.y+30, ent.z x2,y2,z2 = g_PlayerPosX, g_PlayerPosY+30, g_PlayerPosZ end if g_Time > timer[e][a][2] and (as.attackonunstealth == 0 or (as.attackonunstealth == 1 and RaycastALL(x1,y1,z1,x2,y2,z2,0) ~= -1)) then Show(a) isstealthed[a] = nil end end elseif isstealthed[a] == 1 and (g_PlayerHealth < 0 or GetPlayerDistance(a) > 3000 or g_Time > timer[e][a][2]*0.25) then Show(a) isstealthed[a] = nil end end end end end end