Page 1 of 1

Unit Upgrading

Posted: Sat Mar 17, 2012 2:18 pm
by Dakota
i need to know if there is an lua code or something that will make a player change their class after a certain ammount of points but i also need it to not kill them or at least make them spawn in the same location instantly.

Example: a player gets 5 points, then changes into a different class and then gets 5 more points and then goes to a different class.

Is this possible? If not, are there work arounds?

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 3:02 pm
by Locutus
It is possible.
Play Mav's Beach Trooper Mod in survival mode :)

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 3:08 pm
by THEWULFMAN
You can change the class with SetClassProperty, and then reselect the unit at a command post without ever dying. Or kill and respawn the unit in the same exact place without the need of going to a command post. The conditions where the unit class changes are something different altogether. There are many ways to meet a condition, I do not know them all or specifics. It's been a long time since I did any Lua coding. I don't think you can check number of points, I'm not sure.

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 4:00 pm
by Dakota
THEWULFMAN wrote:You can change the class with SetClassProperty, and then reselect the unit at a command post without ever dying. Or kill and respawn the unit in the same exact place without the need of going to a command post. The conditions where the unit class changes are something different altogether. There are many ways to meet a condition, I do not know them all or specifics. It's been a long time since I did any Lua coding. I don't think you can check number of points, I'm not sure.
points or kills would work, also i needed the unit to change without going to a command post, the mod is going to be an arena type wave mode thing. and what did you mean with changing the class with setclassproperty? would it work for the individual player?

if all of this is too complicated or impossible i could just have the unit have to walk to a central cp to upgrade :/

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 4:09 pm
by THEWULFMAN
Dakota wrote:points or kills would work, also i needed the unit to change without going to a command post, the mod is going to be an arena type wave mode thing. and what did you mean with changing the class with setclassproperty? would it work for the individual player?

if all of this is too complicated or impossible i could just have the unit have to walk to a central cp to upgrade :/

SetClassProperty is a SWBF2 Lua command.
SetClassProperty("the name of the class we're changing", "what part of that class we're changing", "what we're changing it to")
Here's an example:
SetClassProperty("rep_inf_ep3trooper", "MaxHealth", "600")
Basically you could change the class property you want, get the unit's matrix (the actual position of where it is on the map), kill the unit, and then respawn the unit at it's matrix.

Changing the class like this is not perfect. It will only affect newly spawned units. So if you change the class, the currently spawned units of the class won't change. If you die and then respawn, you will see the new changes.

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 5:57 pm
by Dakota
i know about setclassproperty but i don't know the setclassproperty code for changing a unit into another unit.

also setclassproperty is for the entire class, i would need it to change just 1 player into a different class, it would have to work on multiplayer too.

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 6:25 pm
by THEWULFMAN
Dakota wrote:i know about setclassproperty but i don't know the setclassproperty code for changing a unit into another unit.
You change specific things in the class, but it's still the same class. You can change model, weapon, health, shields, speed, etc. Whatever you need for the new unit.
Dakota wrote:also setclassproperty is for the entire class, i would need it to change just 1 player into a different class, it would have to work on multiplayer too.
This can't be done in multiplayer. Plain and simple. You can't edit a specific unit, only an entire class.

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 8:58 pm
by Dakota
so i don't need setclassproperty at all. i don't need to change the class, i need to change a unit into a different class, like if you where a trooper, you get some kills, and change classes into a rocketeer.

Re: Unit Upgrading

Posted: Sat Mar 17, 2012 9:07 pm
by THEWULFMAN
Dakota wrote:so i don't need setclassproperty at all. i don't need to change the class, i need to change a unit into a different class, like if you where a trooper, you get some kills, and change classes into a rocketeer.

If it has to be done in Multiplayer, then yes.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 12:55 am
by Dakota
yes to what?

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:04 am
by THEWULFMAN
Dakota wrote:yes to what?
Dakota wrote:so i don't need setclassproperty at all. i don't need to change the class, i need to change a unit into a different class, like if you where a trooper, you get some kills, and change classes into a rocketeer.
If it has to be done in multiplayer in the way described beforehand, then the only way to do it is to slowly unlock more classes. 6 points unlocks the sergeant, 15 unlocks the captain, 30 unlocks the general, and so forth.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:35 am
by lucasfart
Correct me if I'm wrong, but he means instantly - not at the unit selection screen. He wants the unit, upon reaching 5 kills, to be instantly killed and respawn at the same place with the next trooper up(rifleman to rocketeer, etc.), without affecting the sides reinforcements.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:38 am
by Marth8880
I'm no coder, but from what I've read across the boards in the past, that doesn't sound entirely plausible.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:57 am
by THEWULFMAN
lucasfart wrote:Correct me if I'm wrong, but he means instantly - not at the unit selection screen. He wants the unit, upon reaching 5 kills, to be instantly killed and respawn at the same place with the next trooper up(rifleman to rocketeer, etc.), without affecting the sides reinforcements.


This can't be done. Specifically this part. You can't do this online. Not without breaking the intended gameplay. I'm sure he wants a bunch of people who as they play get rewarded for playing well with better units instantaneously. It can't be done. Singleplayer? Somewhat, yes. You can kill and respawn someone (this would affect the reinforcement count) to update the class after editing the class with Lua.

The best way I know of to do this online is to have a bunch of unit classes, each better than the last and each requiring more points to be able to play it. Then just going to a CP to select it.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:34 pm
by Dakota
ok then, i guess i'll just have the cp in a place where people can easily find it...

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:38 pm
by THEWULFMAN
Dakota wrote:ok then, i guess i'll just have the cp in a place where people can easily find it...

If I may make a suggestion, why not make the CP the center of the map? Make it this large epic structure, one that no one will miss. It's impressive setup will make it instantly clear how important it is. Just a thought.

Re: Unit Upgrading

Posted: Sun Mar 18, 2012 1:40 pm
by Dakota
its already in the center, i've set up cover around it too

i may make some mini bunkers on a few maps though.

i'm planning 4 arenas, a lava one, a forest/jungle one, ice one, and a desert one. i'm working on the lava one now, i call it "The Pit"

Re: Unit Upgrading

Posted: Wed Mar 28, 2012 4:23 pm
by CressAlbane
THEWULFMAN wrote: You can kill and respawn someone (this would affect the reinforcement count) to update the class after editing the class with Lua.
Couldn't you just add reinforcements to the team that the player is on?

Re: Unit Upgrading

Posted: Wed Mar 28, 2012 4:29 pm
by Dakota
CressAlbane wrote:
THEWULFMAN wrote: You can kill and respawn someone (this would affect the reinforcement count) to update the class after editing the class with Lua.
Couldn't you just add reinforcements to the team that the player is on?
i thought about that, too, but then decided that it would get annoying when you kill a few units then you die and get a better unit, it would mess with :quotes: "the mojo" :quotes:

i decided to go with the defend the bunker senario. there is 1 cp in the bunker or a cp behind some cover in a defendable location and you try to survive, yet there will always be the guys who run out into the field to attack <.<

(goes off to find a good version of xsi to make a fancy looking multistory bunker even though he knows ai don't like multi-story things but yet why would the ai go there if it is only a person or group of people defending it.)