:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::
Do you want to advertise at Project Perfect Mod. Find out how to do it HERE.

The time now is Thu May 25, 2017 8:23 pm
All times are UTC + 0
 Forum index » Modding Central » Tiberian Sun Editing Forum » Tutorials Factory
TS Client: Unique MCVs and ConYards (*****)
Moderators: Global Moderators, Tiberian Sun Moderators
Post new topic   Reply to topic Page 1 of 1 [13 Posts] View previous topic :: View next topic
Author Message
Bittah Commander
Defense Minister


Joined: 21 May 2003
Location: The Netherlands

PostPosted: Mon Sep 14, 2015 12:47 am    Post subject:   TS Client: Unique MCVs and ConYards (*****)
Subject description: Exclusively works with the client's TS build
Reply with quote

The Dawn of the Tiberium Age has had 4 well-functioning factions with separate MCVs and Construction Yards for a good while already and the work-arounds for this implementation have also improved over the years, especially when Iran’s spawner was made available.
Considering this spawner is also included with the TS Client’s game files and not everybody knows how to make the best use of the new modding features that both the spawner and the TS client offer, I figured this tutorial would be a good start.

For this tutorial I’m going to assume that all faction-specific MCVs and Construction Yards already exist. I’ll divide this tutorial in 3 parts, which you might not all need depending on the kind of mod you’re making.



Part 1: Getting unique MCVs and Construction Yards to work for 2 or more factions

The first obstacle is of course the MCV. Since BaseUnit= only accepts a single entry, we’ll have to prevent it from starting altogether and instead have the MCV start as a regular starting unit.
  • To do this, first open Resources\GameOptions.ini, look for [ForcedSpawnIniOptions] and add Bases=No and UnitCount=1 under it to prevent the specified BaseUnit from spawning and only having a single starting unit spawn instead. Also remove cmbUnitCount and lblUnitCount under both [GameLobby] and [SkirmishLobby] to remove the UnitCount setting from the game lobby because you're not going to want players to change this.
  • Next in INI\Rules.ini, add AllowedToStartInMultiplayer=no to every single unit aside from the MCVs to make sure that the single starting unit all players start with will be an MCV.
    All faction-specific MCVs of course need to have the correct owner specified and have TechLevel=1 to make sure they can start on all tech levels or alternatively TechLevel=-1 to make them unbuildable, but still allow them to spawn as starting units (you could then add a different MCV for the players to build instead).

Now to also get the AI to deploy its faction-specific MCV, there are two methods you can use:
  1. The most practical method is using a HEX-editor to apply a hack to game.exe, which changes the state of the AI’s starting units from Area Guard to Unload:  after opening game.exe with your HEX-editor, goto offset 0x001DEE37 and replace 0A with 0F.
  2. If there’s a reason why you don’t want to or can’t edit the game.exe file, you can instead give the MCVs DeployToFire=yes, GuardRange=512 and Primary= with a weapon specified that has Range=512 (any kind of weapon is fine, as long as it has Range=512: you could also simply use the Deployer weapon below).

Note: only use one of these methods and never both at the same time because that can cause the AI’s MCVs to not deploy again.

Now that you’ve got the MCVs working, you’ll likely first notice that the AI players won’t build anything at all, which brings us to the second obstacle.


The second obstacle is the BuildConst= key. Just like BaseUnit=, it only accepts a single entry and the problem is that AI players won’t build anything when they don’t own the specified BuildConst structure, while human players won’t be able to build any structures that only have a single owner specified.

The fact that BuildConst= only accepts a single entry makes it impossible to specify all faction-specific Construction Yards, meaning we need a work-around for that too. This is where the spawner comes in: the spawner allows you to pre-place units and structures on maps that are owned by specific players, which means that we can just pre-place these BuildConst structures on all maps.
While we could edit all maps and manually add these structures on them, this would end up becoming quite a chore (especially if there’s a lot of existing maps that need to be edited). Fortunately the client introduces GlobalCode.ini: any code entered in it will automatically be added to multiplayer maps when the client loads them and starts the game. We'll get back to this file later.

Although it’s perfectly possible to pre-place the BuildConst structures with some code, this causes problems with the WallOwner logic of the game: if there are any pre-placed walls on a map and there’s also pre-placed structures belonging to one of the Spawn# houses, any walls near them will then automatically also be owned by one of those Spawn# houses. So to get around this we’ll instead pre-place units on the map, which will then immediately deploy into the BuildConst structures when the game starts via a deployer weapon.
First off add the code for the structure, unit and its weapon to Rules.ini (for convenience the IDs will be BUILDCONST for the structure and BLDCNSTU for the unit):
Code:
[BUILDCONST]
Image=GALITE
Name=BuildConst Structure
Strength=600
Armor=wood
TogglePower=no
Selectable=no
Immune=yes
LegalTarget=no
Insignificant=yes
BridgeRepairHut=yes
PlaceAnywhere=yes
InvisibleInGame=yes
BaseNormal=no

[BLDCNSTU]
Image=
Name=BuildConst Unit
ROT=16   ;with 0 and no Speed= value it's unable to deploy
Strength=1
Selectable=false
Insignificant=yes
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
DeploysInto=BUILDCONST
Secondary=Deployer
DeployToFire=yes
GuardRange=512

[Deployer]
Damage=0
Range=512
Projectile=Invisible
Warhead=Super

After doing this, search for [AI] in Rules.ini and replace BuildConst= and its entry with BuildConst=BUILDCONST, add BUILDCONST to the [BuildingTypes] list and you’re set.

Now that the code has been added to Rules.ini, you only need to make sure the BLDCNSTU unit is present on every map when the game to starts, bringing us back to the GlobalCode.ini file I mentioned earlier.
Open INI\GlobalCode.ini (or create it first if it doesn’t exist already) and add the following code:
Code:
[Units]
FFS=Spawn1,BLDCNSTU,256,0,0,64,Unload,None,0,-1,0,-1,1,0
FFT=Spawn2,BLDCNSTU,256,1,0,64,Unload,None,0,-1,0,-1,1,0
FFU=Spawn3,BLDCNSTU,256,2,0,64,Unload,None,0,-1,0,-1,1,0
FFV=Spawn4,BLDCNSTU,256,3,0,64,Unload,None,0,-1,0,-1,1,0
FFW=Spawn5,BLDCNSTU,256,4,0,64,Unload,None,0,-1,0,-1,1,0
FFX=Spawn6,BLDCNSTU,256,5,0,64,Unload,None,0,-1,0,-1,1,0
FFY=Spawn7,BLDCNSTU,256,6,0,64,Unload,None,0,-1,0,-1,1,0
FFZ=Spawn8,BLDCNSTU,256,7,0,64,Unload,None,0,-1,0,-1,1,0


To clarify a few things:
  • The index at the beginning of the lines uses 3 letters to make sure that it always is added at the bottom of index lists so that it won’t change the indexes of other units that were pre-placed on a map and thus risk breaking the FollowsID logic for trains.
  • The Deployer weapon only makes the AI’s BLDCNSTUs automatically deploy and doesn’t affect those that belong to the human players.
  • All BLDCNSTUs are set to the Unload state, which causes the ones owned by human players to automatically deploy, but doesn’t affect those belonging to AI players.

This concludes the first and most important part of the tutorial. As you might have guessed, it is necessary to always play with Short Game disabled now (which can also be disabled permanently by editing Resources\GameOptions.ini), but if you want to put in the extra work it’s perfectly doable to get Short Game working again.



Part 2: Getting Short Game to work again

When the Short Game option is enabled, it makes players instantly die when they own no structures or no BaseUnit and considering that after having applied the above work-around players no longer start with a BaseUnit, they now always instantly die when the game starts.
So how do we get around this? By making players start with a BaseUnit of course.
First we’ll have to add the code for this BaseUnit in Rules.ini (for convenience the ID will be BASEUNIT):
Code:
[BASEUNIT]
Image=   
Strength=1
Immune=yes
LegalTarget=no
SpeedType=Amphibious
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
Selectable=false
After adding that, search Rules.ini for BaseUnit=, replace it and its entry with BaseUnit=BASEUNIT and also add BASEUNIT to the [VehicleTypes] list.

Now open INI\GlobalCode.ini and add the following code:
Code:
[Events]
BaseUnit=1,13,0,125

[Actions]
BaseUnit=1,32,0,0,0,0,0,0,A

[Triggers]
BaseUnit=Neutral,<none>,Destroy BaseUnit,0,1,1,1,0

[Tags]
BaseUnitTag=0,Destroy BaseUnit 1,BaseUnit

[Units]
FFK=Spawn1,BASEUNIT,256,0,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFL=Spawn2,BASEUNIT,256,1,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFM=Spawn3,BASEUNIT,256,2,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFN=Spawn4,BASEUNIT,256,3,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFO=Spawn5,BASEUNIT,256,4,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFP=Spawn6,BASEUNIT,256,5,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFQ=Spawn7,BASEUNIT,256,6,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0
FFR=Spawn8,BASEUNIT,256,7,2,64,Guard,BaseUnitTag,0,-1,0,-1,1,0

Make sure that you don’t overwrite the [Units] section that you added in Part 1 of this tutorial.

You can optionally change the time before the BaseUnit disappears and Short Game is activated by editing the line under [Events] and change 125 to whatever you like (125 translates to about 2 minutes with the game speed at 60 FPS).

And that’s all it takes to get Short Game working again. First of all the code above pre-places an invulnerable BaseUnit on maps when the game starts and it has a trigger attached to it to make it automatically disappear again after about 2 minutes. This means that players have 2 minutes to deploy their MCV before Short Game activates and after those 2 minutes they’ll instantly die when they have no structures left. Keep in mind that players will also instantly die if they have no structures, but do have an MCV and there’s unfortunately no way to prevent this.



Part 3: Structure prerequisites and owners for 3+ factions

Because TS was only meant to support 2 factions, having 3 or more factions can be very problematic when it comes to prerequisites and messing with these can cause issues such as the infamous NCO (“No Construction Options”) bug, structures might not appear on the sidebar or the AI refuses to build them.
So to prevent these issues, you first need to know exactly what causes them.
  • I mentioned before that structures that only have a single owner will only appear on the sidebar when a player owns the BuildConst structure: this is actually only half true. Structures with only one owner can only appear on the sidebar for the first two factions (GDI and Nod), while all other factions require structures to have 2 owners to make them appear on the sidebar.
  • Structures with more than a single owner will appear on the sidebar for every single faction (regardless of which owners are specified), unless the structure’s prerequisites prevent this.
  • Any structure (or unit) that’s visible on the sidebar for a faction that’s not specified as the owner will cause the NCO bug for that faction.
  • The AI can’t build any structures that have the Construction Yard specified as a prerequisite.

So since structures with only a single owner only appear on the sidebar for the first two factions, there’s no way around having to specify a secondary owner (such as Civilian) for every single structure of at the very least the new factions (but you’re actually best off doing this for as many factions as possible). So in GDI’s case you’d specify Owner=GDI,Civilian for every single structure for example.
Once you’ve done this, you’ll have to prevent these structures from appearing on the sidebar of all factions by specifying the Construction Yard as a prerequisite for all of them and keep in mind that it’s only possible for two factions to share the same structure if you modify one of the prerequisite categories (such as for example PrerequisiteBarracks=) and make it include the Construction Yards of both factions.
That said however, you might not have enough prerequisite categories available for everything you want to do, because (as explained below) you’ll also need them to make the AI able to build anything. You’ll have to plan how you’re going to use the prerequisite categories very carefully and since PrerequisiteGDIFactory= and PrerequisiteNodFactory= can only be used by vehicles, you actually only have 5 of them available.

As mentioned before, the AI can’t build anything that has a Construction Yard specified as a prerequisite, but you’re still forced to do so. So to make the AI able to build these structures again, you’ll have to make use of the prerequisite categories.
First add a new structure that will serve as a dummy for the AI to use as a prerequisite instead of a Construction Yard. This structure can be anything and look like anything, so you could for example simply make it look like a power plant, make it into an upgrade for the Construction Yard or whatever else you can think of.
All factions can share the same dummy structure (if it’s not an upgrade) or they can have a unique structure, just make sure that only the AI can build it: give it TechLevel=-1. While this tech level prevents human players from building a structure (or unit), it instead allows the AI to build it on every single tech level.

Now that that’s done you’ll have to use prerequisite group for every single faction uses a Construction Yard as a prerequisite for its structures and then specify the prerequisite group instead of the Construction Yard.
For example use: PrerequisiteBarracks=GACNST,AIDUMMY1 and then specify Prerequisite=BARRACKS,GAWEAP,GARADR for GDI’s tech center.
AIDUMMY1 here is whatever structure you’re using as the dummy structure for the AI (as mentioned before, it can be whatever you want, as long as only the AI can build it). To make sure that the AI can properly use every prerequisite group, you need to make sure that the matching BuildXXX key (for PrerequisiteBarracks that’s BuildBarracks for example) includes a structure that doesn't have a prerequisite (the easiest option here is to just use the AI dummy structure, but you can for example also use a power plant).

And that that should be all. Let me know if you run into any difficulties or if I missed something.


There’s no part 4, but if you also need a method to make the AI replace its MCVs, you can use SuperJoe’s method, starting from:
SuperJoe wrote:
And as promised here are instructions on how to make AI replace lost con.yards. It's actually more effective than what the original game uses.

I believe that you do need to give the MCVs Secondary=DeployWeapon to make this work (the code for that is posted in that topic as well).

Key Words: #Tutorials #Modding #TiberianSun #Firestorm #Rules.INI #GameOptions.INI #GlobalCode.INI #TiberianSunClient #ExeHack #HexEdit 

_________________

Last edited by Bittah Commander on Wed Feb 24, 2016 2:36 am; edited 6 times in total

Back to top
View user's profile Send private message Send e-mail MSN Messenger
Darkstorm
Commander


Joined: 20 Jan 2008
Location: Unknown

PostPosted: Mon Sep 14, 2015 1:25 am    Post subject: Reply with quote

Excellent tutorial. If I may ask, could you do another tutorial on how to replace the walltower structure properly. I've been getting IEs whenever I try to replace it with a dummy upgrade.
_________________

Back to top
View user's profile Send private message
Bittah Commander
Defense Minister


Joined: 21 May 2003
Location: The Netherlands

PostPosted: Mon Sep 14, 2015 1:33 am    Post subject: Reply with quote

That requires a fairly short answer, so it doesn't really require a tutorial. Simply replace the structure specified after WallTower= with an upgrade that the AI can build fairly early in the game and it should work fine. In DTA I use an invisible upgrade for the refinery that only the AI can build for this purpose, but you could also simply specify the power turbine for example.
_________________

Last edited by Bittah Commander on Sat Feb 20, 2016 3:13 pm; edited 1 time in total

Back to top
View user's profile Send private message Send e-mail MSN Messenger
Darkstorm
Commander


Joined: 20 Jan 2008
Location: Unknown

PostPosted: Mon Sep 14, 2015 1:51 am    Post subject: Reply with quote

Well then I must be having some sort of other issue because it did the same crash whenever I did that.

EDIT: I should apologize for derailing the topic though. I'll post more about this in my topic on the TS Editing Forum if I can't figure it out myself. I might consider switching my method here to this since it preserves short game and is generalized for every map.
_________________

Back to top
View user's profile Send private message
luxycomplex
Cyborg Soldier


Joined: 03 Nov 2012

PostPosted: Mon Sep 14, 2015 4:32 pm    Post subject:   The 3rd and 4th side working finally.. Reply with quote

Very Happy  Very Happy  Very Happy

I should have asked this tutorial ages ago..

Crystallized Doom now works under the new Client with this tutorial. I only have to edit game.exe with hex editor to make AI deploy their MCV and game run as expected..
The current version of the mod that I use as 'experiment' still required Unit Count=2 and Short Game=False.

First issue I encounter so far is 'H' (Home) key, if human player uses Starting Point other than 1 then using that key will jump the camera to AI's base that occupies the 1st Starting Point..

The important thing for me is: now I have sample mod that uses Tiberian Sun terrain with more than two playable sides...
Which mean I can continue my own mod happily...
Muahha..haa... Very Happy  Laughing

Back to top
View user's profile Send private message
Bittah Commander
Defense Minister


Joined: 21 May 2003
Location: The Netherlands

PostPosted: Mon Sep 14, 2015 5:10 pm    Post subject: Reply with quote

Pressing H to go back to your base indeed doesn't work anymore with this method, so you'll have to press F9 instead.
_________________

Back to top
View user's profile Send private message Send e-mail MSN Messenger
malius123
Cyborg Soldier


Joined: 14 Aug 2010

PostPosted: Thu Jan 14, 2016 8:15 am    Post subject: Reply with quote

what code is responsible for making new factions selectable in ts client during the skirmish menu, i always thought it was [SIDES], [HOUSES] and [Country Statistics] used in conjunction with one another, but using ts client it doesnt appear to work for me(no doubt due to my lack of understanding and experience).here's example code

Code:

[Houses]
0=GDI
1=Nod
2=ShadowO
3=RaiderF
4=Neutral
5=Special


[Sides]
GDI=GDI
Nod=Nod
ShadowO=ShadowO
RaiderF=RaiderF
Civilian=Neutral
Mutant=Special
 ;Country Statistics

[ShadowO] ; This is the new Shadow order faction
Name=Shadow Order
Suffix=SO
Prefix=S
Color=DarkTeal
Multiplay=yes
Side=ShadowO ;
SmartAI=yes    ;

[RaiderF] ; This is the new raider faction
Name=Raiders
Suffix=RFI
Prefix=R
Color=DarkCyan
Multiplay=yes
Side=RaiderF ;
SmartAI=yes    ;

Back to top
View user's profile Send private message
E1 Elite
Cyborg Informer


Joined: 28 May 2013

PostPosted: Thu Jan 14, 2016 9:48 am    Post subject: Reply with quote

Go to Resources\GameOptions.ini -> Sides=GDI,Nod,ShadowO,RaiderF
You will need side specific icon png file as well for dropdowns.

Back to top
View user's profile Send private message
malius123
Cyborg Soldier


Joined: 14 Aug 2010

PostPosted: Sat Feb 20, 2016 10:39 am    Post subject: Reply with quote

sorry for the late reply, been putting off implementing this in my mod, i've done all the gameoptions.ini  you suggested, but for the life of me i cant find any references to gdiicon.png or nodicon.png ( the clients vanilla side icons for the skirmish lobby) in any of the resources folder ini files,  even  tried a quick Shift+F in some of the ini's in the ini folder (the usual suspects Art.ini and a few others) could you tell me what ini deals with referencing the sides icon. or is it just a matter of creating ShadowOicon.png and RaiderF.png and simply placing them in the game options folder  and the client applies them automatically?

thanks in advance you've already been a great help

Back to top
View user's profile Send private message
^Rampastein
Rampastring


Joined: 11 Oct 2008
Location: Finland

PostPosted: Sat Feb 20, 2016 11:46 am    Post subject: Reply with quote

Yes, just create shadowoicon.png and raiderficon.png to the Resources\ directory and the client will use them automatically, if you use E1 Elite's code that is. It's just <side name>icon.png.
_________________

Back to top
View user's profile Send private message
Bittah Commander
Defense Minister


Joined: 21 May 2003
Location: The Netherlands

PostPosted: Sat Feb 20, 2016 2:07 pm    Post subject: Reply with quote

I just noticed that the last sentence of Part 3 (concerning the BuildXXX key) was incomplete, so that's fixed now. I'm surprised that nobody pointed it out #Tongue

Also, concerning pressing the H button to center the screen on your ConYard: you could get this to work again by changing the button for "View Bookmark 1" or "View Bookmark 4" from F9 or F12 to H and then including the Keyboard.ini file with your mod.
_________________

Back to top
View user's profile Send private message Send e-mail MSN Messenger
malius123
Cyborg Soldier


Joined: 14 Aug 2010

PostPosted: Wed Mar 02, 2016 10:27 pm    Post subject: Reply with quote

i don't know what E1 Elite's code means, i will contine to research this further to grasp a better understanding. i believe im using your client and assume that it uses the code you mention.

ps. thanks for all the info guys. tremendous help.

Back to top
View user's profile Send private message
E1 Elite
Cyborg Informer


Joined: 28 May 2013

PostPosted: Thu Mar 03, 2016 4:29 am    Post subject: Reply with quote

The code mentioned is simply this: GameOptions.ini -> Sides=GDI,Nod,ShadowO,RaiderF
Exact spelling for sides to be used in its icon filenames.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [13 Posts] View previous topic :: View next topic
 Forum index » Modding Central » Tiberian Sun Editing Forum » Tutorials Factory
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © phpBB Group

Wildcard SSL Certificates
[ Time: 0.3141s ][ Queries: 11 (0.0046s) ][ Debug on ]