Well I have a slight dilemma, my script has gone crazy. I'm trying to get my AI to gradually decrease in number and retreat dynamically as bases are captured.
Here is my script:
Hidden/Spoiler:
ATT_Retreat = OnCharacterDeath(
function(player, killer)
--only care when dead player is on the ATT team
if GetCharacterTeam(player) ~= ATT then return end
if GetCommandPostTeam("cp1") ~= DEF then
--tell ATT to retreat
ClearAIGoals(1)
SetUnitCount(1, 30)
AddAIGoal(ATT, "Defend", 800, "cp3")
AddAIGoal(ATT, "Defend", 400, "cp7")
BroadcastVoiceOver("rep_off_com_report_us_overwhelmed", ATT)
BroadcastVoiceOver("rep_off_com_report_enemy_losing", DEF)
--stop watching this OnCharacterDeath so we don't waste game resources
ReleaseOnCharacterDeath(ATT_Retreat)
end
end
)
ATT_Retreat2 = OnCharacterDeath(
function(player, killer)
--only care when dead player is on the ATT team
if GetCharacterTeam(player) ~= ATT then return end
if GetCommandPostTeam("cp3") ~= DEF then
--tell ATT to retreat
ClearAIGoals(1)
SetUnitCount(1, 10)
AddAIGoal(ATT, "Defend", 400, "cp3")
AddAIGoal(ATT, "Defend", 1000, "cp7")
BroadcastVoiceOver("cis_off_com_report_us_overwhelmed", DEF)
BroadcastVoiceOver("cis_off_com_report_enemy_losing", ATT)
--stop watching this OnCharacterDeath so we don't waste game resources
ReleaseOnCharacterDeath(ATT_Retreat2)
end
end
)
DEF_Retreat = OnCharacterDeath(
function(player, killer)
--only care when dead player is on the DEF team
if GetCharacterTeam(player) ~= DEF then return end
if GetCommandPostTeam("cp1") ~= DEF then
--tell ATT to retreat
ClearAIGoals(1)
AddAIGoal(ATT, "Defend", 500, "cp1")
AddAIGoal(ATT, "Defend", 500, "cp5")
BroadcastVoiceOver("rep_off_com_report_us_overwhelmed", DEF)
BroadcastVoiceOver("rep_off_com_report_enemy_losing", ATT)
--stop watching this OnCharacterDeath so we don't waste game resources
ReleaseOnCharacterDeath(DEF_Retreat)
end
end
)
The game works 100% fine but the functions don't run correctly or in order only the AIGoals seem to have an impact, but unless I can decrease the unitcount it'll be impossible to win from the other side.
Thanks in advance.
Re: AI response to situations
Posted: Thu Aug 20, 2009 5:12 am
by [RDH]Zerted
I'm not sure exactly how your map runs, but don't people (ATT) normally retreat when they lose a CP not when they gain one and someone dies? Overall the code seems fine. You can stick ShowMessageText("message") lines inside your OnCharacterDeath functions to see ingame when they run.
When you change AI goals, it seems a few bots sometimes don't take up the new orders until they die. You can see this effect by using the FakeConsole to clear all the AI goals. A few bots will continue to fight. A small AI goal of follow will get some of the AI to run to whatever object they are following. That may give a faster retreat.
Re: AI response to situations
Posted: Thu Aug 20, 2009 9:13 am
by bobfinkl
The AddAIGoals work just fine for some reason, and I used the voiceovers as a way of figuring out whats going on, and they just constantly go off (both CIS and REP VO's), and it's mainly the SetUnitCount's that doesn't work the.
EDIT: I solved it, I had to make sure that both command posts were on the correct team then load all I wanted to happen, now my AI actually act as if they fall back to from each layer of defence and gradually decrease in number.