Skip to content

Defining Correct Prerequisites

kaneCVR edited this page Dec 26, 2014 · 13 revisions

Defining Correct Prerequisites

It may happen that while modding, you give the ability for one team to make the units for another team. For example, Allies do not have an airfield, but you want to give them an airfield. When you do that, the Allies will get possibility of making the Yak aircraft. What if you do not want the Allies to make the Yak aircraft? How will you go about doing this?

The way you do this is to tell the building, which is airfield in this case, to provide custom prerequisites.

To do that, first of all go into the "rules" folder and open structures.yaml

Search for the War factory entry which should be WEAP in this case.

In this entry search for the following code and copy it

		Race: soviet
		Prerequisite: vehicles.soviet

Now search for the airfield, which should be AFLD and paste this code in there. Change vehicles.soviet to aircrafts.soviet

		Race: soviet
		Prerequisite: aircrafts.soviet

Now, open the aircrafts.yaml and find the YAK entry. Its prerequisites might say this:

Prerequisites: afld, ~techlevel.medium

change that to

Prerequisites: afld, ~techlevel.medium, ~aircrafts.soviet

and save

Now the Yak aircraft should only appear for the soviets.

  • made by Umair Azfar Khan

If for example you have more then two races in your mod, and some of them share units and buildings, the way to assign who can build a certain structure is defined using the ProvidesCustomPrerequisite trait.

For example: The Tibrerian Origins mod has all four Command and Conquer sides - GDI, NOD, the Allies and the Soviet. The Red Alert sides should be able to build only the Red Alert units and buildings, and not the Tiberian Dawn ones. This is simple for unique structures, like the GDI War Factory and Nod Airstrip. We can have their respective sides build them by using the ~structures.gdi / ~structures.nod toggle in the Prerequisites trait. For example:

GFAC: #GDI War factory Buildable: Prerequisites: proc, ~structures.gdi, techlevel.medium

  • proc toggle requires a refinery to be built before letting the player build the War Factory. This toggle leaves the building grayed out in the build que, and specifies "requires Ore Refinery" on mouseover.
  • ~structures.gdi assigns the building to the GDI build queue. Adding the ~ symbol will hide it from the build queue unless you play GDI
  • techlevel.medium is the techlevel required to build the structure

Things get complicated when you are trying to have two sides build Red Alert power plants (POWR and APWR) and the other two build Tiberian Dawn power plants (NUKE and NUK2). This can be settled by defining a custom prerequisite for the side, applicable to a starting building like the construction yard:

FACT: #Red Alert Construction Yard for Allies and Soviet Inherits: ^Building Building: Footprint: xxx xxx xxx Dimensions: 3,3 Buildable: Queue: Building BuildPaletteOrder: 1000 Prerequisites: ~disabled ProvidesCustomPrerequisite@allies: Race: allies Prerequisite: structures.allies ProvidesCustomPrerequisite@soviet: Race: soviet Prerequisite: structures.soviet ProvidesCustomPrerequisite@sog: Race: sog Prerequisite: structures.sog ProvidesCustomPrerequisite@tent: Race: allies,sog Prerequisite: buildtent ProvidesCustomPrerequisite@weap: Race: allies,soviet Prerequisite: buildweap ProvidesCustomPrerequisite@cncpowr: Race: sog Prerequisite: cncpowr ProvidesCustomPrerequisite@rapowr: Race: allies,soviet Prerequisite: rapowr ProvidesCustomPrerequisite@gwep: Race: sog Prerequisite: buildgwep ProvidesCustomPrerequisite@gun: Race: sog,nod,allies Prerequisite: buildgun ProvidesCustomPrerequisite@pbox: Race: sog,allies Prerequisite: buildpbox ProvidesCustomPrerequisite@atwr: Race: sog,gdi Prerequisite: buildatwr ProvidesCustomPrerequisite@ion: Race: sog,allies,gdi Prerequisite: buildion ProvidesCustomPrerequisite@spen: Race: nod,soviet` Prerequisite: buildspen ProvidesCustomPrerequisite@syrd: Race: allies,gdi,sog Prerequisite: buildsyrd ProvidesCustomPrerequisite@afld: Race: soviet Prerequisite: buildafld ProvidesCustomPrerequisite@mslo: Race: soviet,allies Prerequisite: buildmslo ProvidesCustomPrerequisite@lfld: Race: soviet,allies Prerequisite: buildlfld

Let's break this down:

ProvidesCustomPrerequisite@gun: #gun is the name of the custom prerequisite. It can be anyhting
	Race: sog,allies #to witch races this prerequisite applies to when they build or capture a construction yard.
	Prerequisite: buildgun #the name of the prerequisite. This name can be anything - and you need to add it to the Prerequisites: trait under Buildable:

GUN: #Gun turret Buildable: Prerequisites: barracks, ~buildgun #this states that you need to build a barracks (witch is also a custom prerequisite applied to all races), and be one of the two sides using the Red Alert c-yard who are allowed to build the gun turret (as defined by the ~buildgun prerequisite).

To get NOD to build the Gun Turret, we add under GFAC (CnC C-yard:)

GFAC: ProvidesCustomPrerequisite@gun: Race: nod Prerequisite: buildgun

Now tree sides, two with different construction yards can build the Gun Turret, without it winding up grayed out in the Soviet and GDI build ques.

Same goes for the Power Plants we discussed earlier:

FACT: #Red Alert Construction Yard for Allies and Soviet ProvidesCustomPrerequisite@cncpowr: Race: sog - the only side with a Red Alert C-Yard and CnC power plants Prerequisite: cncpowr ProvidesCustomPrerequisite@rapowr: Race: allies,soviet Prerequisite: rapowr

and of course:

GFAC: #CnC Construction Yard for GDI and NOD ProvidesCustomPrerequisite@cncpowr: Race: gdi,nod Prerequisite: cncpowr

All we need to do now is add the cncpowr or rapowr custom prerequisites we just created under their respective actors like this:

POWR: Buildable: Prerequisite: ~rapowr, ~techlevel.infonly

NUKE: Buildable: Prerequisite: ~cncpowr, ~techlevel.infonly

And we are done! Enjoy coding!

  • By KaneCVR

Players ๐ŸŽฒ

Modders โœ๏ธ

Developers ๐Ÿ”ง

Clone this wiki locally