Change object's team through LUA [Solved]

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
CressAlbane
Master Bounty Hunter
Master Bounty Hunter
Posts: 1519
Joined: Fri Dec 18, 2009 8:02 am
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı

Change object's team through LUA [Solved]

Post by CressAlbane »

Search returned few relavent topics so....
Here's the situation:
I have an object that I want to switch between team 1 and team 2. I want this to occur based on the destruction of a nearby panel. If a member of Team 1 destroys the panel than the object should change to team 1. If a member of team 2 destroys the panel than the object should change to team 2.
Is this possible through LUA? If so, where does the code go? I want to solve this mainly by myself but a few tips (like functions to enter) would be great.

I found these, but since I'm not familiar with LUA syntax, I don't know how to implement them:
GetCharacterTeam
GetTeamMember
SetObjectTeam

EDIT: These lines from the dea1c_con LUA look helpful:
OnObjectRespawnName(PlayAnimExtend, "Panel-Chasm");
OnObjectKillName(PlayAnimRetract, "Panel-Chasm");

If I'm right, then OnObjectKillName(SetProperty("bridgeturret_1", Team, 1), "bridgeconsole1")
would set bridge turret #1 to team 1 on the destruction of bridgeconsole 1.

But, how to make this change depend on the team of the killer?
I think it would be easy if I knew how the syntax.
Last edited by CressAlbane on Mon Jan 03, 2011 3:54 pm, edited 1 time in total.
User avatar
asleeponduty
Private First Class
Posts: 77
Joined: Tue Jul 22, 2008 3:05 pm
Games I'm Playing :: AaaaaAAaaaAAAaaAAAA
xbox live or psn: No gamertag set
Location: Illinois

Re: Change object's team through LUA

Post by asleeponduty »

Try something like this:
Set the objects team to 0 initially

Code: Select all

-- In the code put this here
SetProperty ("object","Team",2)

	OnObjectKill(
    function(object,killer)
    if GetEntityName(object) == "thethingyoukill" then
		    SetProperty ("object","Team",1)
    end
    end
    )
User avatar
Firefang
Major
Major
Posts: 518
Joined: Mon Nov 15, 2010 8:55 pm
Location: California

Re: Change object's team through LUA

Post by Firefang »

That doesn't specify the killer's team.

Code: Select all

SetProperty ("object","Team",2)

   OnObjectKill(
     function(object,killer)
       if GetEntityName(object) == "object" and GetCharacterTeam(killer) == 1 then
       SetProperty ("object","Team",1)
      end
    end
   )
That ensures that the killer is on team 1
CressAlbane
Master Bounty Hunter
Master Bounty Hunter
Posts: 1519
Joined: Fri Dec 18, 2009 8:02 am
Projects :: CTF Arenas
Games I'm Playing :: Steam- cressalbane2
Location: ¿uoıʇɐɔoן ʎɯ sıɥʇ sı

Re: Change object's team through LUA

Post by CressAlbane »

This script returned an error, "=" expected near Object.
Looking through it now...
Ok, something I added to the script had an extra space.
It works now, thanks!
Post Reply