Page 1 of 1

[Solved] Command Post-linked Autoturrets?

Posted: Wed Apr 07, 2021 5:52 am
by BarbylBapkins
I want a group of named autoturrets on my map to switch owners to whatever team controls a specific command post. So if team 2 captures this command post (cp1), I want these autoturrets to switch owners from team 1 to team 2. It would only need to cycle between teams 1 and 2— it wouldn't really matter to me if they switched to 0 when the post became neutral. I'm wondering if this is possible, and if so, what I would need to do to accomplish this. The "linked turrets" lua file seems to be close to what I'm looking for, but not exactly what I need, as it does change the teams of autoturrets, but the triggers are a named object being destroyed or repaired. Any information is appreciated.

Re: Command Post-linked Autoturrets?

Posted: Wed Apr 07, 2021 5:07 pm
by Benoz
You can change the team of the autoturret according to the designated CP via Lua:

Code: Select all

OnTeamChange(function(object)
	if GetEntityName(object) == "autoturretCP" then
		SetObjectTeam("autoturretLabel1",GetObjectTeam("autoturretCP"))
	end
end)
Put this piece of code under ScriptPostLoad(). Remember to give your turrets a unique label in Zero Editor.
I haven't tested it out myself, it's a code snipet of linksith, but it should work.

Re: Command Post-linked Autoturrets?

Posted: Fri Apr 09, 2021 10:46 pm
by BarbylBapkins
Sorry for the late reply, but thanks! This is just what I needed.