SWBFGamers

Modding for the Original SWBF1 and SWBF2 => SWBF1 Modding Tutorials => Topic started by: Led on July 14, 2012, 04:47:07 PM

Title: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 14, 2012, 04:47:07 PM
By happenstance, I directed Phobos to a web page:
http://swbf-custom.forumactif.com/t158-faqadd-custom-loading-screen

where he noticed a line:
ReadDataFile("dc:Load\\common.lvl")
which was for SWBF2.

But, you know what, it works for SWBF !  Just put it in the mission lua. (example below)

what this means is that modders can make a custom common.lvl and put it in their DC folder.  No longer do we need to do a global replace on common.lvl.

So, for example, we could not play Sereja's mods with other maps, since it needed a replacement common.lvl. 
But now he can make a mission lua that calls his common.lvl just for his map.

This can also be used to called custom common.lvl on the client side that are client side compatible, such as custom crosshairs.

With the random lua commands, we can also call server side compatible custom lua too!

ReadDataFile("COMMON\\common-dot.lvl")  (reads in JediKillers common.lvl with dot for sniper just for bes2a lua.)


(note that in my example, I did not use the dc: folder, but it would work there too)

---------------------------------------------------------------------------
-- FUNCTION:    ScriptInit
-- PURPOSE:     This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES:       The name, 'ScriptInit' is a chosen convention, and each
--              mission script must contain a version of this function, as
--              it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()
--  Attacker is always #1
    local ALL = 1
    local IMP = 2
--  These variables do not change
    local ATT = 1
    local DEF = 2

SetTeamAggressiveness(IMP, 0.95)
SetTeamAggressiveness(ALL, 0.95)

SetMaxFlyHeight(-10);

        AddMissionObjective(IMP, "orange", "level.bespin2.objectives.1");
    AddMissionObjective(IMP, "red", "level.bespin2.objectives.2");
    AddMissionObjective(ALL, "orange", "level.bespin2.objectives.1");
    AddMissionObjective(ALL, "red", "level.bespin2.objectives.2");





    ReadDataFile("sound\\bes.lvl;bes2gcw");
    ReadDataFile("SIDE\\all.lvl",
        "all_inf_basicurban",
        "all_inf_lukeskywalker",
        "all_inf_smuggler");
    ReadDataFile("SIDE\\imp.lvl",
        "imp_inf_basic_tie",
        "imp_inf_dark_trooper",
        "imp_inf_darthvader");



ReadDataFile("COMMON\\common-dot.lvl")

--              Alliance Stats
        SetTeamName(ALL, "Alliance")
        SetTeamIcon(ALL, "all_icon")
    AddUnitClass(ALL, "all_inf_soldierurban",11)
    AddUnitClass(ALL, "all_inf_vanguard",3)
    AddUnitClass(ALL, "all_inf_pilot",4)
    AddUnitClass(ALL, "all_inf_marksman",4)
    AddUnitClass(ALL, "all_inf_smuggler",3)
    SetHeroClass(ALL, "all_inf_lukeskywalker")
    SetAttackingTeam(ATT);


--              Imperial Stats
        SetTeamName(IMP, "Empire")
        SetTeamIcon(IMP, "imp_icon")
    AddUnitClass(IMP, "imp_inf_storm_trooper",11)
    AddUnitClass(IMP, "imp_inf_shock_trooper",3)
    AddUnitClass(IMP, "imp_inf_pilottie",4)
    AddUnitClass(IMP, "imp_inf_scout_trooper",4)
    AddUnitClass(IMP, "imp_inf_dark_trooper",3)
    SetHeroClass(IMP, "imp_inf_darthvader")


--  Attacker Stats
    SetUnitCount(ATT, 25)
    SetReinforcementCount(ATT, 200)
    AddBleedThreshold(ATT, 31, 0.0)
    AddBleedThreshold(ATT, 21, 0.75)
    AddBleedThreshold(ATT, 11, 2.25)
    AddBleedThreshold(ATT, 1, 3.0)

--  Defender Stats
    SetUnitCount(DEF, 25)
    SetReinforcementCount(DEF, 200)
    AddBleedThreshold(DEF, 31, 0.0)
    AddBleedThreshold(DEF, 21, 0.75)
    AddBleedThreshold(DEF, 11, 2.25)
    AddBleedThreshold(DEF, 1, 3.0)

--  Level Stats
    ClearWalkers()
    SetMemoryPoolSize("MountedTurret", 10)
    SetMemoryPoolSize("Obstacle", 514)
    SetSpawnDelay(10.0, 0.25)
    ReadDataFile("BES\\bes2.lvl")
    SetDenseEnvironment("true")


--  Birdies
  --  SetNumBirdTypes(1);
  --  SetBirdType(0,1.0,"bird");
  --  SetBirdFlockMinHeight(-28.0);

    AddDeathRegion("DeathRegion");
    AddDeathRegion("DeathRegion2");

--  Sound
    OpenAudioStream("sound\\bes.lvl",  "bes2gcw_music");
    OpenAudioStream("sound\\gcw.lvl",  "gcw_vo");
    OpenAudioStream("sound\\gcw.lvl",  "gcw_tac_vo");
    OpenAudioStream("sound\\bes.lvl",  "bes2");
    OpenAudioStream("sound\\bes.lvl",  "bes2");

    SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1);
    SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1);
    SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1);
    SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1);

    SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1);
    SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1);
    SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1);
    SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1);

    SetOutOfBoundsVoiceOver(1, "Allleaving");
    SetOutOfBoundsVoiceOver(2, "Impleaving");

    SetAmbientMusic(ALL, 1.0, "all_bes_amb_start",  0,1);
    SetAmbientMusic(ALL, 0.99, "all_bes_amb_middle", 1,1);
    SetAmbientMusic(ALL, 0.1,"all_bes_amb_end",    2,1);
    SetAmbientMusic(IMP, 1.0, "imp_bes_amb_start",  0,1);
    SetAmbientMusic(IMP, 0.99, "imp_bes_amb_middle", 1,1);
    SetAmbientMusic(IMP, 0.1,"imp_bes_amb_end",    2,1);

    SetVictoryMusic(ALL, "all_bes_amb_victory");
    SetDefeatMusic (ALL, "all_bes_amb_defeat");
    SetVictoryMusic(IMP, "imp_bes_amb_victory");
    SetDefeatMusic (IMP, "imp_bes_amb_defeat");

    SetSoundEffect("ScopeDisplayZoomIn",  "binocularzoomin");
    SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout");
    --SetSoundEffect("WeaponUnableSelect",  "com_weap_inf_weaponchange_null");
    --SetSoundEffect("WeaponModeUnableSelect",  "com_weap_inf_modechange_null");
    --SetSoundEffect("BirdScatter",         "birdsFlySeq1");
    SetSoundEffect("SpawnDisplayUnitChange",       "shell_select_unit");
    SetSoundEffect("SpawnDisplayUnitAccept",       "shell_menu_enter");
    SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change");
    SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter");
    SetSoundEffect("SpawnDisplayBack",             "shell_menu_exit");


    SetPlanetaryBonusVoiceOver(IMP, IMP, 0, "imp_bonus_imp_medical");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 0, "imp_bonus_all_medical");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 1, "");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 1, "");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 2, "imp_bonus_imp_sensors");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 2, "imp_bonus_all_sensors");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 3, "imp_bonus_imp_hero");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 3, "imp_bonus_all_hero");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 4, "imp_bonus_imp_reserves");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 4, "imp_bonus_all_reserves");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 5, "imp_bonus_imp_sabotage");--sabotage
    SetPlanetaryBonusVoiceOver(IMP, ALL, 5, "imp_bonus_all_sabotage");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 6, "");
    SetPlanetaryBonusVoiceOver(IMP, ALL, 6, "");
    SetPlanetaryBonusVoiceOver(IMP, IMP, 7, "imp_bonus_imp_training");--advanced training
    SetPlanetaryBonusVoiceOver(IMP, ALL, 7, "imp_bonus_all_training");--advanced training

    SetPlanetaryBonusVoiceOver(ALL, ALL, 0, "all_bonus_all_medical");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 0, "all_bonus_imp_medical");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 1, "");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 1, "");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 2, "all_bonus_all_sensors");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 2, "all_bonus_imp_sensors");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 3, "all_bonus_all_hero");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 3, "all_bonus_imp_hero");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 4, "all_bonus_all_reserves");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 4, "all_bonus_imp_reserves");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 5, "all_bonus_all_sabotage");--sabotage
    SetPlanetaryBonusVoiceOver(ALL, IMP, 5, "all_bonus_imp_sabotage");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 6, "");
    SetPlanetaryBonusVoiceOver(ALL, IMP, 6, "");
    SetPlanetaryBonusVoiceOver(ALL, ALL, 7, "all_bonus_all_training");--advanced training
    SetPlanetaryBonusVoiceOver(ALL, IMP, 7, "all_bonus_imp_training");--advanced training


--  Camera Stats
--Bespin 2
--Courtyard
AddCameraShot(0.364258, -0.004224, -0.931226, -0.010797, -206.270294, -44.204708, 88.837059);
--Carbon Chamber
AddCameraShot(0.327508, 0.002799, -0.944810, 0.008076, -184.781006, -59.802036, -28.118919);
--Wind Tunnel
AddCameraShot(0.572544, -0.013560, -0.819532, -0.019410, -244.788055, -61.541622, -44.260509);
end

Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: tirpider on July 14, 2012, 06:26:03 PM
OMG, random custom common.
Per map.
Online too?

I don't know a lot about the common.lvl, but I do know this sounds very cool.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 14, 2012, 06:30:43 PM
Indeed.  Common contains a lot of visual elements.  Many of them are client side, like explosion colors and things like that.  You can change your color, but everyone else sees the normal ones.  Crosshairs is another example.

Some common thing are server side, so only the server needs them.  Health bot recharge rate is one of those.

For a server side only mod, you could do one cloud city map with normal health recharge rates, and the next map in the same server have negative recharge rates (un-health bot :P )  It would be like the random side lua but with common.lvl.

Now, for Addon maps, this is even better, since players no longer would have to drag the custom common into their game folder.  The modder can just drop their new common in the Addon map folder, call it in the lua, and it will not affect any other maps.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Sereja on July 14, 2012, 10:14:44 PM
So, you can't play my maps on-line? :confused: Sorry, I don't know much about on-line things...
Look's like, I have to reupload my maps with your invention included...
But how it works exactly?
After add this line, ReadDataFile("dc:Load\\common.lvl")
in mission.lua, am I need to create usual side folder, named "Load"?

-Edit

Whait a minute... I just read this from swbf-custom topic: "Create your custom loading screen and place it in the loading folder: C:\BF2_ModTools\data_???\Load
Name it too loadscreen" :blink:

May be it is sily question, but how I can create "custom loading screen" ?!?  :confused:
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 15, 2012, 02:07:39 AM
Amazing this opens so many doors for mod maps.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 04:02:14 AM
Quote from: Sereja on July 14, 2012, 10:14:44 PM
So, you can't play my maps on-line? :confused: Sorry, I don't know much about on-line things...
Look's like, I have to reupload my maps with your invention included...
But how it works exactly?
After add this line, ReadDataFile("dc:Load\\common.lvl")
in mission.lua, am I need to create usual side folder, named "Load"?

-Edit

Whait a minute... I just read this from swbf-custom topic: "Create your custom loading screen and place it in the loading folder: C:\BF2_ModTools\data_???\Load
Name it too loadscreen" :blink:

May be it is sily question, but how I can create "custom loading screen" ?!?  :confused:


All we need from you is a new mission.lvl file.  Your common.lvl can be put in the map folder.  No longer does it have to *replace* the stock one.  We can't (currently) play your map + standard maps that use stock common.lvl in the same multiplayer session.

If you send me one of your mission lua files I will demonstrate it for you, or see my example below.

We have a load screen tool in our download section:
http://www.swbfgamers.com/index.php?action=downloads;sa=view;down=631


But this is a different topic.  Also the SWBF2 link just gave us the idea to try something, we don't need SWBF2.


Maybe I describe it better here:
http://gametoast.com/forums/viewtopic.php?f=1&t=28319&sid=ebdfb86bcbffe67371280bbc700d8415


Here is an example for your Night Theed instuctions:

Old Way:
-----------------------

NABOO: THEED night.

Instalation:

1. Put the 022 folder in your Gamedata\AddOn folder.

2. Put the common.lvl file in your LucasArts\Star Wars Battlefront\GameData\Data\_LVL_PC\Common\ENG folder, make backup first.

------------------------------

New Way:
------------------
COMMON folder goes *into* 022 folder

Mission lua Line added:
ReadDataFile(ReadDataFile("dc:COMMON\\common.lvl)



Instalation:

1. Put the 022 folder in your Gamedata\AddOn folder.
-----------------------------------------------

All we would need from you is an updated map mission.lvl file, and we can play maps that use different common.lvl in the same session.  There is no need to upload your entire maps again.  I can repackage them and reupload them here if you want to send me your new mission.lvl file.

Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 15, 2012, 04:09:26 AM
Quote from: Buckler on July 15, 2012, 04:02:14 AM
We can't play your map + standard maps that use stock common.lvl in the same multiplayer session.

Why not? If the custom map mission calls on a custom common.lvl and the stock mission calls on stock common, maybe all that needs to be done is redirect the stock mission to the original directory stock common.lvl is located.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 04:14:47 AM
Quote from: Phobos on July 15, 2012, 04:09:26 AM
Why not? If the custom map mission calls on a custom common.lvl and the stock mission calls on stock common, maybe all that needs to be done is redirect the stock mission to the original directory stock common.lvl is located.

We can now...but not when the stock was replaced.  I was talking about his specific maps without the new method being used.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 05:01:05 AM
Quote from: Phobos on July 15, 2012, 02:07:39 AM
Amazing this opens so many doors for mod maps.

Or how about a custom cross-hair changer  ;)
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 15, 2012, 06:26:41 AM
Quote from: Buckler on July 15, 2012, 05:01:05 AM
Or how about a custom cross-hair changer  ;)
Not sure how you would do that. What is your idea?
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 07:05:09 AM
Quote from: Phobos on July 15, 2012, 06:26:41 AM
Not sure how you would do that. What is your idea?


Could you build a menu into common that loads a new common.lvl file?  If you can load a new side.lvl file, I think this should work too.  It would have to be done carefully, so as to retain the menu features and just use on-line client side compatible changes.



This also makes me wonder if we could have custom core.lvl, shell.lvl called by lua.  Not sure if shell would work, but maybe core...


Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 15, 2012, 07:37:16 AM
Quote from: Buckler on July 15, 2012, 07:05:09 AM

Could you build a menu into common that loads a new common.lvl file?  If you can load a new side.lvl file, I think this should work too.  It would have to be done carefully, so as to retain the menu features and just use on-line client side compatible changes.



This also makes me wonder if we could have custom core.lvl, shell.lvl called by lua.  Not sure if shell would work, but maybe core...
Sadly no, you cannot load new side.lvl files. I tried and it results in an instant crash. It would probably do the same for common but I can try. Mod maps already call custom core.lvls so there wouldn't really be a need to add another in the mission lua.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 07:43:56 AM
Ah, what is called in the skin changer/legion changer file?

sides_imp_212.lvl


it is a level file...so I would think that new (visual changes, online compatible client side) cross-hairs could be called.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 15, 2012, 08:30:28 AM
I'm not familiar with imp legion changer sorry.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 15, 2012, 08:44:57 AM
It's like sleepkiller did for clones, I thought you had seen his video.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Sereja on July 21, 2012, 01:05:37 AM
Ok, here the sample of my mission.lvl's, from Kamino and Naboo for testing:
http://oron.com/3chy7t10stnz (http://oron.com/3chy7t10stnz)
Sorry, I still do not understand, how this invention may work's (just like some other people), and can't testing it by myself. All, what I done, is add this line in my mission.lua's:
ReadDataFile("dc:COMMON\\common.lvl");
That's it. Hope it will works...
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 04, 2013, 02:57:02 AM
Quote from: Buckler on July 14, 2012, 04:47:07 PM
With the random lua commands, we can also call server side compatible custom lua too!


I tested this extensively and the dedicated server ignores all dedicated shell and common LUA scripts. The best way to call on custom LUA for a server will be using the mission LUA since that is guaranteed to load for server.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Shazam on July 04, 2013, 08:33:35 AM
I'm not near as experienced with this sort of thing, but I have a suggestion.

Instead of calling a new common.lvl, why not just put the reticules into side.lvl's? The skin changer obviously changes the .tga in-game through side, so maybe it could be changed to call for different reticule .tga's.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on July 04, 2013, 09:24:20 AM
This is another option.  Sometimes you don't want to have to make new sides.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Sereja on July 07, 2013, 01:49:39 AM
The "brain storm", is takes about a year :o for me, but finaly, I got how it work's! :tu:

So, here the tutorial update: you should put this line, exactly under "--end soundlvl", in your Mission.lua! Example:

--end soundlvl

ReadDataFile("dc:COMMON\\common.lvl");

-- Start sidelvls


Sorry, I didn't understand, how to make this update in time, before on-line support was over... :shrug:
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Phobos on July 07, 2013, 02:17:31 AM
Quote from: Sereja on July 07, 2013, 01:49:39 AM
The "brain storm", is takes about a year :o for me, but finaly, I got how it work's! :tu:

So, here the tutorial update: you should put this line, exactly under "--end soundlvl", in your Mission.lua! Example:

--end soundlvl

ReadDataFile("dc:COMMON\\common.lvl");

-- Start sidelvls


Sorry, I didn't understand, how to make this update in time, before on-line support was over... :shrug:
What you can do is combine all your mod maps in one mission.lvl just munge all the LUA there with the new custom common update. It can work for all your maps and simple patch for players that way you don't have to re release every map.
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Giftheck on August 06, 2014, 02:07:12 AM
Question: if this is a main game mod, does this mean we can run the common.lvl file from our own mod folder (IE my mod rests largely in "Data/_LVL_PC/BFE" so could I run a new common.lvl file from "Data/_LVL_PC/BFE/Common"?)
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Led on August 06, 2014, 02:51:06 AM
Quote from: ggctuk2005 on August 06, 2014, 02:07:12 AM
Question: if this is a main game mod, does this mean we can run the common.lvl file from our own mod folder (IE my mod rests largely in "Data/_LVL_PC/BFE" so could I run a new common.lvl file from "Data/_LVL_PC/BFE/Common"?)

yes
Title: Re: Loading a custom common.lvl file while retaining stock option; client side too
Post by: Giftheck on August 06, 2014, 03:41:09 AM
Nifty :D
EhPortal 1.34 © 2024, WebDev