Shield Recovering

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
RED51
Jedi
Jedi
Posts: 1024
Joined: Sun Sep 07, 2008 6:25 pm
Games I'm Playing :: SWBFII

Shield Recovering

Post by RED51 »

Before I even attempt and create annoying crashes and errors, which I have been dealing with with every other play through, is it possible to "heal" shields without putting in the addshield function in the odf? Also, if that can be done, can it be applied to buffs? Like a shield restoring buff? Thanks in advance.
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: Shield Recovering

Post by Fiodis »

It is easily done through LUA. Using lua, you can have shield-increasing drops (like in, for example, Bakura) or buffs, whichever you like, or weapons.

If you want it to be a buff, create a buff that does 1 damage. Then use some code that would go roughly as follows:

Code: Select all

OnObjectDamage(
         function(object, damager)
             if damager == nil then return end
                 if GetObjectLastHitWeaponClass(object) == "odf_of_shield_recharge_buff" then
                     local unit = GetCharacterUnit(damager)
                     if unit == nil then return end
                     SetProperty(unit, "CurShield", GetObjectShield(unit) + #)
                 end
         end
            )
Where # is the amount of shield you want restored. Make sure the buff can hurt friends, if you want friends to have their shields restored.
User avatar
RED51
Jedi
Jedi
Posts: 1024
Joined: Sun Sep 07, 2008 6:25 pm
Games I'm Playing :: SWBFII

Re: Shield Recovering

Post by RED51 »

Thanks, I'll try that. I actually was expecting to be told that it couldn't be done, but guess you can't just rush to conclusions.
Post Reply