Detecting a specific AI in the game
Posted: 13 Sep 2016, 02:13
Is there a nice simple way to detect if a specific AI is in the game?
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
Code: Select all
for i = 0,64 do
local _, _, _, chicken = Spring.GetAIInfo(i)
Spring.Echo(chicken)
if chicken == "Chicken: Very Easy" or
chicken == "Chicken: Easy" or
chicken == "Chicken: Normal" or
chicken == "Chicken: Hard" or
chicken == "Chicken: Very Hard" or
chicken == "Chicken: Epic!" or
chicken == "Chicken: Custom" or
chicken == "Chicken: Survival" then
chickensEnabled = true
end
end
if chickensEnabled == true then
Spring.Echo("[Chickens] Activated!")
else
Spring.Echo("[Chickens] Deactivated!")
return false
end
Code: Select all
{
name = 'Chicken: Very Easy',
shortName = 'chickens',
desc = 'Trivial Games'
},
And the second Set:[f=-000001] nil
[f=-000001] SYNCED_NOSHORTNAME
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] [Chickens] Deactivated!
Because of the first set of results, the gadget disables itself and that's GG for the second set. Obviously the first set reports that a shortname isn't set, so logic leads me to assume that if I can set a shortname, the first set of results shows the actual shortname. HA, spoiler alert, there doesn't seem to be any way to set a shortname because the engine apparently likes to use name for shortname. This is a dumb problem to have.[f=-000001] nil
[f=-000001] Chicken: Very Easy
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] nil
[f=-000001] [Chickens] Activated!
Code: Select all
for i = 0,64 do
local _, chicken = Spring.GetAIInfo(i)
--Spring.Echo(chicken)
if chicken == "AI: Chicken: Very Easy" or
chicken == "AI: Chicken: Easy" or
chicken == "AI: Chicken: Normal" or
chicken == "AI: Chicken: Hard" or
chicken == "AI: Chicken: Very Hard" or
chicken == "AI: Chicken: Epic!" or
chicken == "AI: Chicken: Custom" or
chicken == "AI: Chicken: Survival" then
chickensEnabled = true
end
end
if chickensEnabled == true then
Spring.Echo("[Chickens] Activated!")
else
Spring.Echo("[Chickens] Deactivated!")
return false
end
Code: Select all
if (gadgetHandler:IsSyncedCode()) then return end
Code: Select all
local teams = Spring.GetTeamList()
for i =1, #teams do
local luaAI = Spring.GetTeamLuaAI(teams[i])
if luaAI ~= "" then
if luaAI == "Chicken: Very Easy" or
luaAI == "Chicken: Easy" or
luaAI == "Chicken: Normal" or
luaAI == "Chicken: Hard" or
luaAI == "Chicken: Very Hard" or
luaAI == "Chicken: Epic!" or
luaAI == "Chicken: Custom" or
luaAI == "Chicken: Survival" then
chickensEnabled = true
end
end
end
if chickensEnabled == true then
Spring.Echo("[ChickenDefense: Chicken Defense Spawner] Activated!")
else
Spring.Echo("[ChickenDefense: Chicken Defense Spawner] Deactivated!")
return false
end