[TUT]Setting up multiplayer specific LUA.

Started by SleepKiller, April 26, 2012, 04:21:29 PM

Previous topic - Next topic
I think the tittle was pretty descriptive. In this your going to learn how to do some basic LUA scripting to set up a test that if it is correct runs commands.

For starters go to some place in your mission script. Now type in.
if(ScriptCB_InNetGame()) then
Now this finds out if your in a net game, and if you are to then run the commands below the line.

We're not done yet. I'm using this to set-up Multiplayer only bleed. Although you could put anything you want here.
AddBleedThreshold(ATT, 31, 0.0)
AddBleedThreshold(ATT, 21, 0.75)
AddBleedThreshold(ATT, 11, 2.25)
AddBleedThreshold(ATT, 1, 3.0)
AddBleedThreshold(DEF, 31, 0.0)
AddBleedThreshold(DEF, 21, 0.75)
AddBleedThreshold(DEF, 11, 2.25)
AddBleedThreshold(DEF, 1, 3.0)
Example only, you can put anything there.

Now type this.
end
This ends the blockwithout it ScriptMunge and your game will crash.

Alternatively we could type in this instead of end.
else
And put some commands here that would run if the test failed.

so for instance we could put it instead of the CIS addclass section to make Countduko playable only in Singleplayer.
if(ScriptCB_InNetGame())then
AddUnitClass(CIS, "cis_inf_battledroid",10)
AddUnitClass(CIS, "cis_inf_assault",1)
AddUnitClass(CIS, "cis_inf_pilotdroid",2)
AddUnitClass(CIS, "cis_inf_assassindroid",2)
AddUnitClass(CIS, "cis_inf_droideka",1)
SetHeroClass(CIS, "cis_inf_countdooku")
else
AddUnitClass(CIS, "cis_inf_battledroid",10)
AddUnitClass(CIS, "cis_inf_assault",2)
AddUnitClass(CIS, "cis_inf_pilotdroid",2)
AddUnitClass(CIS, "cis_inf_assassindroid",2)
AddUnitClass(CIS, "cis_inf_countdooku",0)
SetHeroClass(CIS, "cis_inf_droideka")
end



Don't say I never share stuff.

April 26, 2012, 04:29:13 PM #1 Last Edit: April 26, 2012, 05:08:00 PM by Buckler
You never share stuff


edit by buckler:  if you are going to be a smart-alec, at least put in a smiley  ;)

Quote from: Des on April 26, 2012, 04:29:13 PM
You never share stuff
The only thing I have to see to that is Rage's skin changer exists is because I chose to release my source scripts. End of discussion, please PM if you want to argue I don't want this topic locked.

Quote from: SleepKiller on April 26, 2012, 04:21:29 PM
Don't say I never share stuff.

Why even start this? Good tutorial anyhow.
=AaTc= Forever

SALLY....

-Retired Modder

April 26, 2012, 04:50:52 PM #4 Last Edit: April 26, 2012, 04:53:27 PM by Phobos
I am grateful for what assets and mod stuff SK has shared with the community, and yes the skin changer I made would not have been possible without the collaborative efforts of several great modders. Sleepkillers legion changer script, pandemics ifs_pausemenu script, and the skin mods of several Cloud city modders all went together in making it, along with 2 intense weeks of very challenging, but fun modding on my end.

Many of the stock mission LUAs have their own script annotated _h, which is for campaign mode I believe. This tutorial should provide mission modders tips for enhanced customization regarding differences in multiplayer and instant action singleplayer.

Very nice, SK.

I wonder if the commands that force players to particular teams would work if they are in between the IF THEN END statements.
Quote from: Abraham Lincoln. on November 04, 1971, 12:34:40 PM
Don't believe everything you read on the internet

You never share stuff ----->  ::) <------ i want to be a smart alec here is my smile

Quote from: Des on April 26, 2012, 06:10:11 PM
You never share stuff ----->  ::) <------ i want to be a smart alec here is my smile

Much better, now we can know you were kidding  :tu:
Quote from: Abraham Lincoln. on November 04, 1971, 12:34:40 PM
Don't believe everything you read on the internet