LUA help sought

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
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

LUA help sought

Post by myers73 »

Code: Select all

    OnCharacterDeath(
		function(player)	
		if GetCharacterTeam(player) == 2 and IsCharacterHuman(player) then
		TeamChange(player, 1)
		end
		)
I'm not so great at LUA, but I think yall get what this is attempting.

person dies-> check to see if they are human -> if yes then check team -> if team 2 switch their team.

seems a simple enough task. As I said im not very good with LUA, so there may be things horribly wrong with my script. If anyone could will they please fix it for me. thanks
User avatar
skelltor
Sith
Sith
Posts: 1431
Joined: Fri Dec 11, 2009 6:24 pm
Projects :: BFSM
Games I'm Playing :: SWBFII
xbox live or psn: skelltor95
Location: minisnowta
Contact:

Re: LUA help seeked

Post by skelltor »

So what exactly is your problem dose it cause a ctd or what?(if it dose crash please post an error log.
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: LUA help seeked

Post by myers73 »

well fixed code somewhat, everything works except the function to change the team

Code: Select all

    playerDead = OnCharacterDeath(
		function(player)	
			if GetCharacterTeam(player) == 2 and IsCharacterHuman(player) then
			SetObjectTeam(player, 1)
			end
		end
	)
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA help seeked

Post by [RDH]Zerted »

What in the end are you trying to do?

Just about all the team switching code deals with changing the unit's team. The person's player/character is still on the same team, just his/her unit is different. When the unit dies, it no longer exists, thus you can't chance its team after its death.
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: LUA help seeked

Post by myers73 »

I want to check when a player is killed if they are on team 1, if that is yes then change them to team 2.


would this work?

Code: Select all

			if GetCharacterTeam(player) ==  1 then
			SetProperty(player, "Team", 2)
EDIT:

what about /admin /swap playerid, that changes their team when you use that online.


EDIT2
ok, so scratch the above, dont think it is possible. now for another idea:

Code: Select all

onKillReplinishHealth = OnCharacterDeath(
	function(player, killer)
	if IsCharacterHuman(player) = true and IsCharacterHuman(killer) then
	SetProperty(killer, "AddHealth", 1000) --higher than maxhealth in order to fully replinish
	end
end
)
would this work to replinish the health of the killer if both the killer and player were human?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA help seeked

Post by [RDH]Zerted »

You might have to do SetProperty on GetCharacterUnit(killer), but almost. Change your "=" to "==".
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: LUA help seeked

Post by myers73 »

so...

Code: Select all

onKillReplinishHealth = OnCharacterDeath(
   function(player, killer)
   if IsCharacterHuman(player) == true and IsCharacterHuman(killer) then --corrected = to ==
   SetProperty(GetCharacterUnit(killer), "AddHealth", 1000) --higher than maxhealth -- changed killer to GetCharacterUnit(killer)
   end
end
)
Post Reply