[Solved] Command Post-linked Autoturrets?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
BarbylBapkins
Private Recruit
Posts: 16
Joined: Mon Jan 28, 2019 10:08 am
Projects :: Thyferra
Games I'm Playing :: DST
xbox live or psn: No gamertag set

[Solved] Command Post-linked Autoturrets?

Post 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.
Last edited by BarbylBapkins on Fri Apr 09, 2021 10:46 pm, edited 1 time in total.
User avatar
Benoz
First Lance Corporal
First Lance Corporal
Posts: 135
Joined: Tue May 28, 2013 12:34 pm
Projects :: Clone Wars Era Mod Version 2
Games I'm Playing :: OldFront - EAFront
xbox live or psn: No gamertag set
Location: Germany

Re: Command Post-linked Autoturrets?

Post 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.
BarbylBapkins
Private Recruit
Posts: 16
Joined: Mon Jan 28, 2019 10:08 am
Projects :: Thyferra
Games I'm Playing :: DST
xbox live or psn: No gamertag set

Re: Command Post-linked Autoturrets?

Post by BarbylBapkins »

Sorry for the late reply, but thanks! This is just what I needed.
Post Reply