Scripts / Reduction in AI health

Author
Message
Pink Panther
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 9th Mar 2023 16:44 Edited at: 9th Mar 2023 17:15
@AmenMoses: A few years ago you wrote this fantastic script for me that caused a timed reduction in AI health when near an entity. I have been trying to get it to work in GG Max but I have been unsuccessful so far. I am guessing that GG Max handles AI health differently but I can' t figure out how. I have also been studying your NPC_in_range script which seems similar to what I am trying to accomplish. What do I need to add or change to get this great script to work in Max? Thanks

-- DESCRIPTION: Timed removal of AI health near an entity
local U = require "scriptbank\\utillib"

function ai_hurtzone_init( e )
Include( "utillib.lua" )
end

local timer = 0
local hurtValue = 10
local hurtDist = 2000

function ai_hurtzone_main( e )

if g_Time > timer then
timer = g_Time + 5000
local Ent = g_Entity[ e ]

for _, v in pairs( U.ClosestEntities( hurtDist, math.huge, Ent.x, Ent.z ) ) do
if ai_bot_state[ v ] ~= nil then
if g_Entity[ v ].health > 0 then
SetEntityHealth( v, g_Entity[ v ].health - hurtValue )
end
end
end
end
end

(I tried to put this in code snippet but clearly I did something wrong)
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Mar 2023 10:47
The global list ai_bot_state is not used in MAX which is why that script doesn't work.

Try replacing:
ai_bot_state[ v ] ~= nil
with:
GetEntityAllegiance(v) == 0
Been there, done that, got all the T-Shirts!
PM
Pink Panther
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 10th Mar 2023 14:34
@AmenMoses It works perfectly! Thanks so much!
PM

Login to post a reply

Server time is: 2024-04-26 22:00:42
Your offset time is: 2024-04-26 22:00:42