LUA Command SetClassProperty Question [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

razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

LUA Command SetClassProperty Question [Solved]

Post by razac920 »

Hi everyone, I'm working on a mod that requires the use of SetClassProperty to change a unit's weapons. I've read posts saying that this will break multiplayer compatibility, but I'd just like to confirm where this is the case, even if no other players (human or computer) have selected the class I'd be editing. Thanks.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: LUA Command SetClassProperty Question

Post by Marth8880 »

Did you read that using SetClassProperty to change weapons would break multiplayer compatibility, or that using it in general would break it?
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

In the FAQ section on SetClassProperty, [RDH]Zerted wrote, "I do know that changing which weapons a unit hold will cause crashes for other players in MP". I'm just wondering if no other players are in that class, will there still be crashes? Or is there any hope of MP working?
fasty
1st Lieutenant
1st Lieutenant
Posts: 438
Joined: Thu Apr 15, 2010 4:17 am
Projects :: Server modding
Games I'm Playing :: SWBF2
Contact:

Re: LUA Command SetClassProperty Question

Post by fasty »

razac920 wrote:In the FAQ section on SetClassProperty, [RDH]Zerted wrote, "I do know that changing which weapons a unit hold will cause crashes for other players in MP". I'm just wondering if no other players are in that class, will there still be crashes? Or is there any hope of MP working?
Yes it would crash everyone if you changed what weapons they hold. One thing you can do is change the properties of the weapons like damage and range. (This is if you are the server host of course).
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

Oh, okay, that's what I was afraid of. Guess it has to be single player only, then :/
User avatar
lucasfart
Sith
Sith
Posts: 1440
Joined: Tue Feb 24, 2009 5:32 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: Australia

Re: LUA Command SetClassProperty Question

Post by lucasfart »

You guys are both kinda right. There are some which are important/essential, and others which have little/no effect.
BFront2.log errors explained wrote:Fix your SoldierAnimation memory pool errors after creating a new map to shorten the length of your debug log and to increase online stability
BFront2.log errors explained wrote: All ParticleTransformer memory pool errors can be ignored. When playing the actual game (not the debug exe) the game will automatically update these pools as needed:
Code:
Message Severity: 2
C:\Battlefront2\main\RedEngineFL\Memory\RedMemoryPool.cpp(170)
Memory pool "ParticleTransformer::SizeTransf" is full; raise count to at least 1075
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: LUA Command SetClassProperty Question

Post by Maveritchell »

razac920 wrote:Hi everyone, I'm working on a mod that requires the use of SetClassProperty to change a unit's weapons. I've read posts saying that this will break multiplayer compatibility, but I'd just like to confirm where this is the case, even if no other players (human or computer) have selected the class I'd be editing. Thanks.
What Zerted says there isn't 100% true. SetClassProperty can be used post-load (i.e. mid-mission) on some properties without detrimental effects (I've used this in both MP game modes and scripted missions). I can't confirm that it will always work (and of course Zerted was talking about a specific use - changing weapon types), but here's what I've done and I can confirm does work:

-SetProperty on pretty much anything (within the realm of what SetProperty can modify) works fine postload
-SetClassProperty works fine on some properties postload (I obviously haven't tested all of them, but I know that health properties, energy properties, shield properties, and points to unlock all seem to work fine)
-SetClassProperty works fine on pretty much anything as long as the property is set pre-load (i.e. you can adjust what weapons a unit has without issue in MP provided it's done in the ScriptInit section)
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

Ah okay. Well unfortunately, my mod will require many mid-mission weapon changes, so I guess MP can't work for it. Thanks for clearing it up for me, though.

Edit: I came up with another idea; would using SetClassProperty to edit "MedalsTypeToUnlock" in a weapon's odf work in the middle of a mission? Or would that cause a MP crash as well?
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 Command SetClassProperty Question

Post by [RDH]Zerted »

You have to try it and find out. Setup a dedicated server (you can't test it as the server host) with your mod then join that server. If when that part of your code gets run and you crash, it won't work in MP.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

Umm how do you join a dedicated server that you're hosting? I only have one computer and one copy of SWBF2
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: LUA Command SetClassProperty Question

Post by Marth8880 »

Are you using the BlackBagOps Server Manager or SWBF2 to host your server?
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

I was using SWBF2, I didn't know about any server managers
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: LUA Command SetClassProperty Question

Post by Marth8880 »

razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

Okay, I think I have everything set up, but when I run swbf2sm.exe I don't see any mod maps at all, just the stock ones
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: LUA Command SetClassProperty Question

Post by Marth8880 »

Ah, yes. I'm not entirely sure whether really anyone has ever managed to get mod(s)/( maps) working with the BlackBagOps Server Manager other than maybe Fasty. I'll have to look into it myself sometime. (Do I foresee Unification on a server? :o ;) )
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: LUA Command SetClassProperty Question

Post by Locutus »

It's pretty simple.
Just copy the maps you want to use in your servers Addon folder.

(In case you want to run the ConvoPack you also need to replace the server's common.lvl, shell.lvl and ingame.lvl with the ones from patch 1.3 to make the maps appear in the list.)
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: LUA Command SetClassProperty Question

Post by Marth8880 »

Huh, it's that simple? :o Alright, then. :D
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

So I've tried using SetClassProperty on a weapon in MP, and while it doesn't crash, it doesn't work either. Nothing happens, since it strangely could not find my weapon class to edit in the first place, even though I was just using default weapons in a test map. Has anyone been able to change a weapon's properties mid game with SetClassProperty?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: LUA Command SetClassProperty Question

Post by Maveritchell »

razac920 wrote:So I've tried using SetClassProperty on a weapon in MP, and while it doesn't crash, it doesn't work either. Nothing happens, since it strangely could not find my weapon class to edit in the first place, even though I was just using default weapons in a test map. Has anyone been able to change a weapon's properties mid game with SetClassProperty?
You don't set weapon class properties, you make weapon variations with the changes you want and then adjust the unit class properties so that the unit uses a different weapon.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: LUA Command SetClassProperty Question

Post by razac920 »

Ah okay, I was afraid of that, so the ONLY way to change weapons in MP is to switch classes altogether, then? Since SetClassProperty on WeaponName would not work, and SetClassProperty on the weapon's odf doesn't work. Only possible alternative I can think of is to with scripting disallow weapons from causing damage (forcing the player to switch to the weapon you want) or MAYBE to somehow remove other weapon ammo except for the player's intended weapon... Maybe through making an ammo powerup that gives negative ammo? There's some line in the powerup dispenser making it immune to refilling from anything other than an ammo droid, but again you'd face the problem that you can't edit weapon odf's mid-game. The reason I ask is that I'm working on a Gun Game mode that works in single player, but have no idea how to make it work online. Scripting out damage/kills from the wrong weapon might be my only option, but it seems like a very nasty hack, as you can still see the old weapon and ordnance, etc.
Alternatively, I just change classes, each with one weapon. I would prefer to have more than just 20 weapons to cycle through, but visually that would look nicest.
Oh but I should ask, is there a way to spawn the human in classes of team 3, 4, 5, etc.? The BF2 Limitations post states that "Human characters can only spawn teams 1 or 2, but you can give the illusion of up to 9 (since 9 is the team limit) selectable teams." What is this illusion, and how does it work?
Post Reply