Page 1 of 1
Legions Function
Posted: Wed Nov 05, 2008 8:34 pm
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.
Re: Legions Function
Posted: Wed Nov 05, 2008 9:35 pm
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.
Re: Legions Function
Posted: Wed Nov 05, 2008 9:38 pm
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.
Re: Legions Function
Posted: Thu Nov 06, 2008 2:47 am
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).
Re: Legions Function
Posted: Thu Nov 06, 2008 7:35 am
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.
Re: Legions Function
Posted: Thu Nov 06, 2008 10:56 am
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
can be left in there or not. The script will ignore things behind double dashes.
Re: Legions Function
Posted: Thu Nov 06, 2008 5:01 pm
by Grev
Could you explain set class property? Im not quite sure what it is.
Re: Legions Function
Posted: Thu Nov 06, 2008 5:12 pm
by Maveritchell
It sets a class's property. Just look at how I used it - odf name, odf parameter, parameter value.
Re: Legions Function
Posted: Thu Nov 06, 2008 5:43 pm
by Grev
I think I understand. However. I still cant seem to understand what in the script does the actual changing.
Re: Legions Function
Posted: Thu Nov 06, 2008 7:56 pm
by Sky_216
Hmmm...is there anyway you can do this so it just makes your own character change model/skin???
Re: Legions Function
Posted: Thu Nov 06, 2008 8:55 pm
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.
Re: Legions Function
Posted: Fri Nov 07, 2008 2:00 pm
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 Set
ClassProperty), 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.
Re: Legions Function
Posted: Fri Nov 07, 2008 3:39 pm
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.