Ignore SetAI(..., true) if an AI already exists

Can happen e.g. in multiplayer editing
qteditor
Sven Eberhardt 2016-07-13 22:15:55 -04:00
parent 5a9e608f55
commit 656aa303f9
1 changed files with 8 additions and 1 deletions

View File

@ -20,9 +20,16 @@ static const AI_DefMaxAggroDistance = 200, // lose sight to target if it is this
func SetAI(object clonk, bool has_ai)
{
if (has_ai)
return AddAI(clonk);
{
// Only add if it doesn't have the effect yet
var ai = GetAI(clonk);
if (!ai) ai = AddAI(clonk);
return ai;
}
else
{
return RemoveEffect("AI", clonk);
}
}
// Add AI execution timer to target Clonk