Legions Function

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
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Legions Function

Post by Grev »

I have a plan for a new ingame function. Sadly, I have no knowledge of scripting. However, I DON’T WHAT THIS DONE FOR ME, instead I want to learn how to do it myself, with the help of the folk here at gametoast!

My plan is an ingame function that lets you choose which legion to play as, simply by changing the .msh.

In a designated area behind the republic main base, there would be an area blocked from ai by means of barriers, and would probably be reachable only by tunnel, so stray shots don’t destroy panels by accident.

In this area, there would be floating panels with inscriptions on them, and on the destruction of these, an .odf or .msh (which ever is possible) change will be triggered for each unit, so when the units would respawn, new legion!

I basically need to know what lines and where in the .lua, but concerns, and suggestions would be ok too.

Finally, would it be too much to ask that this idea not be used in other maps until I publicly release the codes and etc.? Thank you.
Null_1138
Jedi
Jedi
Posts: 1192
Joined: Thu Oct 16, 2008 4:05 pm

Re: Legions Function

Post by Null_1138 »

I think Maveritchell is doing something like this for his WIP.
Maveritchell wrote:I actually like the 501st personally, but since you asked: I added a bit of scripting that, if you have the Conversion Pack installed, will randomly choose from one of six clone legions every time you start the map.
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Re: Legions Function

Post by Grev »

That randomly chooses legions. In this map, you choose which legion you play as.

If all goes well actually, I may be able to set something up using the campaign scripts to let you choose prior to game start, but I cant guarantee.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Legions Function

Post by Maveritchell »

It's a really easy change to do this, but like I said in the PM you sent, there's no guarantee this would change on-the-fly (I doubt it would, you'd have to wait for your units to respawn), and there's the possibility it wouldn't work at all. This code is just a template:

Code: Select all

changeto212th = OnObjectKill(
	--"changeto212th" is a random variable you can set to whatever
	function(object, killer)
		if IsCharacterHuman(killer) and GetEntityName(object) == "your_name_of_object" then
			--"your_name_of_object" is the NAME given (not the object class) to the object you want to destroy
			SetClassProperty("rep_inf_ep3_rifleman", "GeometryName", "rep_inf_ep3_trooper_212")
			--"rep_inf_ep3trooper_212" is the geometry (minus the .msh at the end) name of your new model with the right texture
			SetClassProperty("rep_inf_ep3_rocketeer", "GeometryName", "rep_inf_ep3_heavytrooper_212")
			SetClassProperty("rep_inf_ep3_engineer", "GeometryName", "rep_inf_ep3_engineer_212")
			--...etc., etc., etc.
		end
	end
)
It's on you to test this out - make sure that you place this in "function ScriptPostLoad()" (before the "end" at the end of ScriptPostLoad).

And no, you can't use the mission's .lua script to let you select the legion before the game starts (unless you wanted to do some crazy stuff outside the game - like you could have a dummy file that you rename to whatever legion you wanted - but that's a little overcomplicated).
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Re: Legions Function

Post by Grev »

Ok, thanks Maveritchell. Is that exactly how I plug it into the .lua? Or is the .etc .etc and instructions extra, to be removed.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Legions Function

Post by Maveritchell »

Like I said, that's just a template. You'll have to add stuff that means something to get it to work (like the proper names of the object and the new meshes, for example), and you'll have to make a SetClassProperty for each class. The stuff that's

Code: Select all

--commented out, like this
can be left in there or not. The script will ignore things behind double dashes.
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Re: Legions Function

Post by Grev »

Could you explain set class property? Im not quite sure what it is.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Legions Function

Post by Maveritchell »

It sets a class's property. Just look at how I used it - odf name, odf parameter, parameter value.
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Re: Legions Function

Post by Grev »

I think I understand. However. I still cant seem to understand what in the script does the actual changing.
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Legions Function

Post by Sky_216 »

Hmmm...is there anyway you can do this so it just makes your own character change model/skin???
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Legions Function

Post by Maveritchell »

Skyhammer_216 wrote:Hmmm...is there anyway you can do this so it just makes your own character change model/skin???
If:
a) This works at all in the first place (I've never tried changing a unit's geometry midgame),
b) Your unit has its own class, and
c) Your unit respawns/dies after this happens.
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: Legions Function

Post by [RDH]Zerted »

Grev wrote:I DON’T WHAT THIS DONE FOR ME...
I basically need to know what lines and where in the .lua...
:?

When a panel is destroyed, you will have to update the ODF values for all the unit classes you want to change (Note: You can't just update a single unit, it has to be all units of a type. For example, all snipers change). You can change ODF values by using the SetClassProperty( class, key, value) function. It takes the class to be changed (class), the ODF variable to change (key), and the new value it should change to (value).

One way to get info 'before' the map loads is to change ScriptInit or ScriptPostLoad to only show a pop-up. Then when that pop-up is closed, you do the real ScriptInit or ScriptPostLoad work (which you moved into a different function). However, I've never actually done this and if it works, I would expect it to freeze any dedicated servers trying to run the map. You could also toss the pop-up in the map's script outside those two functions and that may work too.
Finally, would it be too much to ask that this idea not be used in other maps until I publicly release the codes and etc.?
Yes (mostly because you're not the first to have it)

There is no way to only make your unit change (since you are using SetClassProperty), but if you turn it into a FakeConsole command (use a user_script to add it, or just stick it directly in the user_script if you always want it done) then you can make the change for your screen only.
Grev
Hoth Battle Chief
Hoth Battle Chief
Posts: 3132
Joined: Sun Dec 09, 2007 11:45 pm
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft
Location: A Certain Box Canyon

Re: Legions Function

Post by Grev »

Ack, I just realized that. I meant WANT, not what

Also, who has done this before? Just out of curiosity!

Finally, I just recently figured out that this way could be used to create your personal unit in an RPG map.
Post Reply