Changing first person models through the 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
Marvel4
Rebel Colonel
Rebel Colonel
Posts: 556
Joined: Mon Jun 21, 2010 12:57 pm
Projects :: Marvel4s BF1 Conversion Pack + Era Mod

Changing first person models through the lua

Post by Marvel4 »

Hi!
I want to change the vehicle first person models through my lua, so I thought of something like this:

Code: Select all

SetClassProperty("cis_fly_droidgunship", "FirstPerson", "IMP\impimplc;imp_1st_cockpit_landingcraft")
But, because the cis_fly_droidgunship has multiple positions, it has also multiple FirstPersons:

Code: Select all

FLYERSECTION            = "BODY"

//FirstPerson             = "IMP\impimplc;imp_1st_cockpit_landingcraft"

FLYERSECTION            = "TURRET1"

//FirstPerson             = "rep\repsccam;rep_1st_cockpit_securitycam"
What should I do?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Changing first person models through the lua

Post by Maveritchell »

A single backslash does not work for LUA reading file hierarchy. Ex.

Code: Select all

ReadDataFile("sound\\hot.lvl;hot1gcw")
Use a double backslash to make your location correct.
User avatar
Marvel4
Rebel Colonel
Rebel Colonel
Posts: 556
Joined: Mon Jun 21, 2010 12:57 pm
Projects :: Marvel4s BF1 Conversion Pack + Era Mod

Re: Changing first person models through the lua

Post by Marvel4 »

I changed it to "fpm\\IMP\\impimplc.lvl;imp_1st_cockpit_landingcraft" but it didn't work...
Is SetClassProperty right, or do I have to use SetProperty?

And how should I change the different FirstPersons? I want to have a different model for all positions. (BODY and TURRET1 etc.)
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Changing first person models through the lua

Post by Maveritchell »

Marvel4 wrote:I changed it to "fpm\\IMP\\impimplc.lvl;imp_1st_cockpit_landingcraft" but it didn't work...
Is SetClassProperty right, or do I have to use SetProperty?

And how should I change the different FirstPersons? I want to have a different model for all positions. (BODY and TURRET1 etc.)
Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.

I don't know if you can change the other two. I don't know if it's possible to edit concurrent lines like that with a single-line tool like SetClassProperty. I don't think I've ever experimented with that; all I can do is tell you to play around with various different things and see what works and what does not. Consider the possibility that it may not.
User avatar
Marvel4
Rebel Colonel
Rebel Colonel
Posts: 556
Joined: Mon Jun 21, 2010 12:57 pm
Projects :: Marvel4s BF1 Conversion Pack + Era Mod

Re: Changing first person models through the lua

Post by Marvel4 »

Maveritchell wrote: Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.
Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.

I also tried using FirstPersonBODY as a property, because some heroes had WeaponName1 and WeaponName2 in their odf, while other units had this:

Code: Select all

WEAPONSECTION = 1
WeaponName = ...
WEAPONSECTION = 2
WeaponName = ...
But it didn't work...
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Changing first person models through the lua

Post by DarthD.U.C.K. »

Marvel4 wrote: Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.
why dont you load it from the side?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Changing first person models through the lua

Post by Maveritchell »

Marvel4 wrote:
Maveritchell wrote: Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.
Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.
By default it is arranged to read from that directory. You already knew this, because the .odf already reads:

Code: Select all

IMP\impimplc;imp_1st_cockpit_landingcraft
My question is this - where was the confusion, when the only thing you were told you needed to change was:

Code: Select all

IMP\impimplc;imp_1st_cockpit_landingcraft
to

Code: Select all

IMP\\impimplc;imp_1st_cockpit_landingcraft
User avatar
Marvel4
Rebel Colonel
Rebel Colonel
Posts: 556
Joined: Mon Jun 21, 2010 12:57 pm
Projects :: Marvel4s BF1 Conversion Pack + Era Mod

Re: Changing first person models through the lua

Post by Marvel4 »

Because the first person file is located in the _lvl_pc\fpm\imp folder and not in the _lvl_pc\imp folder.
Likewise, ReadDataFile("sound\\hot.lvl;hot1gcw") would read from the _lvl_pc\sound folder and not the _lvl_pc\fpm\sound folder. That's why I added the fpm\.

Anyway, it doesn't really matter, because I just did a test:

I added this to the lua:

Code: Select all

SetClassProperty("cis_inf_rifleman1", "FirstPerson", "REP\reptroop;rep_1st_trooper")
(no double slash!)
And it had no problems changing the droid arms to the clone arms.

So, the only problem left is how I change the FirstPerson of the different "flyersections".
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Changing first person models through the lua

Post by Maveritchell »

Marvel4 wrote:Because the first person file is located in the _lvl_pc\fpm\imp folder and not in the _lvl_pc\imp folder.
Likewise, ReadDataFile("sound\\hot.lvl;hot1gcw") would read from the _lvl_pc\sound folder and not the _lvl_pc\fpm\sound folder. That's why I added the fpm\.
But you are not paying attention. ReadDataFile always reads from a base directory (wherever the relevant core.lvl file is). The .odf parameter "FirstPerson," by default, reads from the FPM folder. You already know this because of what the first person sections already list. After all, how could

Code: Select all

SetClassProperty("cis_inf_rifleman1", "FirstPerson", "REP\reptroop;rep_1st_trooper")
possibly work, since the first person file isn't in the "REP" folder. Right?

A little context goes a long way.

That was boneheaded of me to suggest the double slash as necessary, though, since you're right, it is just a parameter in a callback - the .lua itself isn't reading it (although it will work that way, it's not necessary).

For your other problem, you can't just make up parameters like you did above. Both "WeaponName" and "WeaponName1" are valid parameters, which is why they both work. There is no such thing as "WeaponSectionBODY" as a parameter - read through fred's "ODF Parameters" doc.
User avatar
Marvel4
Rebel Colonel
Rebel Colonel
Posts: 556
Joined: Mon Jun 21, 2010 12:57 pm
Projects :: Marvel4s BF1 Conversion Pack + Era Mod

Re: Changing first person models through the lua

Post by Marvel4 »

Ah, ok, now I understand it, sorry. :oops:

So, I assume it's not possible to change the different FirstPersons through the lua?
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Changing first person models through the lua

Post by Teancum »

I can't answer whether you can or not, but there's two things to consider:

1-The model change is unlikely to take effect until the character respawns
2-It would change for the entire character class, not individual units
Post Reply