Change weapon via Lua

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
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Change weapon via Lua

Post by Anakin »

Hi,

is it possible to exchange a weapon via lua script?? Let's say there is a unit with airstrike and it's stupid to have it on TantiveIV. So now i can make two different units with different weapons, but it doesn't seams to be a good solution. So i thought i can exchange the weapon via lua in the tantiveIV script. Is that possible? and how would i do that??
thelegend
Sith
Sith
Posts: 1433
Joined: Thu Jan 23, 2014 6:01 am
Projects :: Star Wars - Battlefront III Legacy
Games I'm Playing :: Swbf GTA CoD LoL KH
xbox live or psn: El_Fabricio#
Location: Right behind you :)

Re: [LUA]change weapon

Post by thelegend »

You can change a unit's weaponary through SetClassProperty in your .lua (below ScriptPostLoad):

Code: Select all

SetClassProperty("Your_Unit_Name", "WeaponName1", "Name_of_the_odf_weapon")
But make sure your replacement weapon is loaded by an unit anywhere else (In ReadDataFile), or the game won't know where to find the new weapon.
Post Reply