Turrets being killed and respawned via 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ı

Turrets being killed and respawned via LUA [Solved]

Post by CressAlbane »

Here's the situation:
I have three turrets for each team, called "team(teamnumber)_turret(turretnumber)"
or "team1_turret1", "team1_turret2", etc.
I have two destructible objects called team1_turrets and team2_turrets.
I want the turrets to be destroyed and revived along with the objects.
Here's my code:
Hidden/Spoiler:
OnObjectKillName(KillObject("team1_turret1"), "team1_turrets")
OnObjectKillName(KillObject("team1_turret2"), "team1_turrets")
OnObjectKillName(KillObject("team1_turret3"), "team1_turrets")
OnObjectKillName(KillObject("team2_turret1"), "team2_turrets")
OnObjectKillName(KillObject("team2_turret2"), "team2_turrets")
OnObjectKillName(KillObject("team2_turret3"), "team2_turrets")
OnObjectRespawnName(RespawnObject("team1_turret1"), "team1_turrets")
OnObjectRespawnName(RespawnObject("team1_turret2"), "team1_turrets")
OnObjectRespawnName(RespawnObject("team1_turret3"), "team1_turrets")
OnObjectRespawnName(RespawnObject("team2_turret1"), "team2_turrets")
OnObjectRespawnName(RespawnObject("team2_turret2"), "team2_turrets")
OnObjectRespawnName(RespawnObject("team2_turret3"), "team2_turrets")
Last edited by CressAlbane on Mon Jan 03, 2011 4:52 pm, edited 1 time in total.
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Re: Turrets being killed and respawned via LUA

Post by bobfinkl »

I don't know too much about the subject myself having never actually used it, but after a quick look in the space template lua and the LinkedDestroyables.lua, it looks like your error is that you can only really use that special .lua to get it working. I suggest you go take a look at how the shields work in the space template assault lua and copy how it works.
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: Turrets being killed and respawned via LUA

Post by CressAlbane »

The thing is, I want the turrets to be invincible.
Is there any other way to accomplish this?
I got it to work using the LinkedTurrets script with the object as the "mainframe."
I can also add text and such with this method as well. Thanks for the tip Bobfinkl!
Last edited by CressAlbane on Mon Jan 03, 2011 4:51 pm, edited 1 time in total.
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Re: Turrets being killed and respawned via LUA

Post by bobfinkl »

Use the same script then add:

Code: Select all

            SetProperty("turret1", "MaxHealth", 9999999999) 
            SetProperty("turret1", "CurrentHealth", 9999999999)
for each turret. (just an FYI that script may not be written 100% correct you may have to respell things or add a few "" marks here and there, I wrote this off the top of my head)

Edit:
via the kamino campaign script:

Code: Select all

            SetProperty("transport1", "MaxHealth", 999999999)
            SetProperty("transport1", "CurHealth", 999999999) 
that's the exact proper way it should be written except "transport1" should be changed to whatever your turrets are named in ZE.
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: Turrets being killed and respawned via LUA

Post by CressAlbane »

Oh, I already set the turrets to have a very high max health.
Hidden/Spoiler:
you'd have to edit the curhealth in that script though
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Turrets being killed and respawned via LUA [SOLVED]

Post by AQT »

Off-topic: While setting the health of object to an incredibly high value may make it impossibly hard to destroy, it still is not truly invincible. So if your situation, whatever it may be, calls for an object to not even lose the slightest bit of health, then use the value 1e+37 instead (as seen in the stock Kashyyyk campaign script).
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: Turrets being killed and respawned via LUA [SOLVED]

Post by CressAlbane »

I find that infantry normally do not have the time to chip away 99999 health while a hectic close-quarters battle is being played. So, this works for now.
But I was wondering what 1e+37 did. Thanks!
Post Reply