LUA or ODF questions regarding shields

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
User avatar
vampire_lord
Rebel Sergeant
Rebel Sergeant
Posts: 216
Joined: Thu Mar 20, 2008 7:02 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: Mexico City
Contact:

LUA or ODF questions regarding shields

Post by vampire_lord »

Well, my mod is getting pretty well, but I have some problems with the shielding on some vehicles (and droidekas too), if I put some AddShield for regenerating it makes the unit invincible because it keeps adding shield no matter how much damage I do, not even at 1 shield minus 1000 damage; Droidekas at least have shield off regeneration so I just removed the minus shield adding, is there some way to delay the add shield rate? health and ammo droids have a PowerUpDelay and I suppose vechicle repair droids once fixed may regenerate shield (is VehicleShield a valid parameter?), so, any hints? maybe I need to alter those parameters via LUA, if that's the case, I would need some help.

Thanks.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: LUA or ODF questions regarding shields

Post by Fiodis »

MaxShield sets an upper limit for the shield's strength.
User avatar
vampire_lord
Rebel Sergeant
Rebel Sergeant
Posts: 216
Joined: Thu Mar 20, 2008 7:02 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: Mexico City
Contact:

Re: LUA or ODF questions regarding shields

Post by vampire_lord »

I use it so it is actually the amount of shielding as in MaxHealth on vehicles for example (health and shield) , my problem is giving shield regeneration, it goes nonstop and thus the vehicle's shield never depletes, that means, the vehicle never takes any damage, it would be helpful if there is a way to delay the shield regeneration.
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: All Along The Watchtower

Re: LUA or ODF questions regarding shields

Post by jangoisbaddest »

Decrease the AddShield value. The AddShield value is what determines how quickly the shield's "health" regenerates. A greater value means it regenerates more per some unit of time that I don't quite know (probably second). You can even set it to 0 for no regeneration, or a negative value if you want it to slowly wear down on its own (I've never tried this, but I think the Driodeka uses this mechanic).

This, by the way, is done in the unit's ODF file just like MaxHealth.
User avatar
vampire_lord
Rebel Sergeant
Rebel Sergeant
Posts: 216
Joined: Thu Mar 20, 2008 7:02 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: Mexico City
Contact:

Re: LUA or ODF questions regarding shields

Post by vampire_lord »

Already tried with negative AddShield, and yes, the droideka uses it, but even if I put AddShield = 1 (that means 1 per second), once you "deplete" the shield and continue to attack, the shield continues to regenerate and never wears down, any damage your weapon deals gets absorbed by that tiny little bit of shield, my only possible solution is having no regeneration or finding a way to delay it for more than a second via ODF or LUA, but I can't find a valid instruction.
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: All Along The Watchtower

Re: LUA or ODF questions regarding shields

Post by jangoisbaddest »

Well, the problem isn't finding the right instruction...the problem is having the LUA properly determine when the shield is down. I know of no callbacks offhand that can do that. And even if you were to somehow get the LUA to recognize this event, you have another big problem: you can't alter the stats of a single unit already in game. Even despite the many posts telling me it was futile, I tried for a while to get SetProperty to work on a spawned unit (instead of using SetClassProperty and then re-spawning that unit). It just doesn't work, unfortunately. So even if you could set up the proper event callback, you'd have to

1) Start a timer for X seconds
2) save all of that unit's info (map location, curhealth, etc.)
3) use SetClassProperty to change the AddShieldValue
4) teleport the unit away
5) kill it
6) respawn it at the old location
7) create another callback for OnTimerElapse
8) re-create steps 1-6 for that callback

That would create a very choppy gameplay experience, and it would be a lot more trouble than it's worth IMO. I would just set AddShield to either 0 or a small positive value, then decrease the unit's Health so that when your ordnance gets through, it will do more damage.
User avatar
vampire_lord
Rebel Sergeant
Rebel Sergeant
Posts: 216
Joined: Thu Mar 20, 2008 7:02 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: Mexico City
Contact:

Re: LUA or ODF questions regarding shields

Post by vampire_lord »

Too bad, no delay for shields then, I will just let those tanks have limited un-replenishable shield then, droidekas are just fine with no depletion already. Thanks.
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 or ODF questions regarding shields

Post by [RDH]Zerted »

vampire_lord wrote:...any damage your weapon deals gets absorbed by that tiny little bit of shield...
I don't know why you're having problems. Only 1 damage should be absorbed by the shield. I thought the rest went onto the player. You can look at the Holocron game mode to see that you can kill something with a shield regen. Holocron uses a MaxShield of 900 and an AddShield of 160 (in addition to a 50 AddHealth). Err, well that's all with units. I've never tried it on a vehicle...

If it's broken on vehicles and assuming your vehicles start out with a shield, you can try the following:

Setup events to listen for OnShieldChange on each vehicle. When the shield changes to below a low value, turn off the shield regen using SetProperty() and destroy the event listener.

If the vehicle is slightly damaged when it's shield strength is 1 and is hit, then use OnHealthChange or OnObjectDamage instead and turn off the shield whenever the event is triggered and remember to still destroy the event listener too. The health/damage events will be called much less often than the shield change event.

If you want the shield regens to start up again after a while you can do that too, but get the above working first.
Post Reply