This site is in archival mode. A replacement is being developed. In the meantime, please use the PBW2 Forums for community discussions. The replacement software for this site will use a unified account system with PBW2, and any newly created threads will carry over.
Posted: Sun Feb 17, 2008 10:49 pm Post subject: How to Model Exclusive Components
Lets say you have two types of armor components (Composite and Energy Refractive), and you do not want both to be mounted on the same vessel. The player does not have to mount any armor at all, however. How would you model this in a design requirement for vehicletypes?
Consider for a moment that TRUE = 1, and FALSE = 0.
We can construct the following truth table:
Code:
A B Output
0 0 1
0 1 1
1 0 1
1 1 0
For reference, the first line means that when A and B both equal 0, our result is 1. In terms of tech reqs, this means if we have neither any Composite Armor nor any Refractive Armor, the requirement is satisfied. It only fails to be satisfied when A = B = 1, or when we have both. Now back to the logic:
This truth table represents a fairly simplistic boolean function:
Code:
A NAND B
NAND is literally the inversion of AND; it returns 0 when both values are 1, 1 otherwise.
Unfortunately, we do not have a NAND operator, so we must express things in terms of OR, AND and NOT. Since NAND is the inversion of AND, this is simply:
Code:
!(A AND B)
And in SE5 function speak:
Code:
NOT ( Get_Design_Specific_Component_Count ("Composite Armor") >= 1 AND Get_Design_Specific_Component_Count ("Energy Refractive Armor") >= 1 )
I am a little lost/bewildered... where would this code be used at? Keep in mind I am new to modding. I THINK that I understand the coding... I am just not certain where it would be put. Back to top
The formula posted by Fyron at the end of his post would be one of the requirement formulas (allowing placement of the component) in a Components.txt entry.
Example:
Code:
Name := Composite Armor
Description := Standard titanium armor used to protect a ship from damage.
Picture Number := 15
Maximum Level := 20
Tonnage Space Taken Formula := 5
Tonnage Structure Formula := 30 + (([%Level%] - 1) * 5)
Cost Minerals Formula := 25 + ([%Level%] * 5)
Cost Organics Formula := 0
Cost Radioactives Formula := 0
Supply Amount Used Formula := 0
Ordnance Amount Used Formula := 0
Can Be Placed On Vehicle Types := Ship, Base, Satellite, Weapon Platform, Drone
Can Be Placed In Ship Sections := Armor
Component Type List := Technological
General Group := Armor
Custom Group := 0
Number Of Requirements := 2
Requirements Evaluation Availability := 1
Requirements Evaluation Allows Placement := 2
Requirements Evaluation Allows Usage := TRUE
Requirement 1 Description := Empire must have at least tech level 1 in Armor.
Requirement 1 Formula := Get_Empire_Tech_Level("Armor") >= [%Level%]
Requirement 2 Description := Design cannot have more than 1 Composite Armor and 1 Energy Refractive Armor.
Requirement 2 Formula := NOT ( Get_Design_Specific_Component_Count ("Composite Armor") >= 1 AND Get_Design_Specific_Component_Count ("Energy Refractive Armor") >= 1 )
Number Of Abilities := 1
Ability 1 Type := Component - Is Armor Type
Ability 1 Description := Composite Armor protects the ship from damage.
Ability 1 Scope := Space Object
Ability 1 Range Formula := 0
Ability 1 Amount 1 Formula := "Normal Armor"
Ability 1 Amount 2 Formula := 0
Weapon Type := None
Posted: Mon Jul 29, 2013 5:21 am Post subject: Re: How to Model Exclusive Components
Fyron wrote:
Lets say you have two types of armor components (Composite and Energy Refractive), and you do not want both to be mounted on the same vessel. The player does not have to mount any armor at all, however. How would you model this in a design requirement for vehicletypes?
That was very good, and instructive also. However, it's not achieving the specific goal as stated. It's achieving that goal, while adding an extra limitation.
The solution would permit one and not the other, sure enough, but it would limit the player to a single component. No more than one Composite or one Energy Refractive could be installed.
Code:
NOT ( Get_Design_Specific_Component_Count ("Composite Armor") >= 1 AND Get_Design_Specific_Component_Count ("Energy Refractive Armor") >= 1 )
See?
Now if more than one are to be permitted, the solution is to place a simple, direct prohibition in the requirements of the other.
In the req's for Energy Refractive Armor, place
Code:
NOT ( Get_Design_Specific_Component_Count ("Composite Armor") >= 1
or simply
Code:
NOT ( Get_Design_Specific_Component_Count ("Composite Armor")
since any return at all will suffice to toggle it.
then in the req's for Composite Armor one should enter
Code:
NOT ( Get_Design_Specific_Component_Count ("Energy Refractive Armor") >= 1
This way, any number of either type of armor could be installed, but never both types. Back to top
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
All logos and trademarks used on this site, all comments and stories posted for reading, all files hosted for download, and all art work hosted for viewing are property of their respective owners; all the rest copyright 2003-2010 Nolan Kelly.
Syndicate news: - Syndicate forums:
Page Generation: 0.61 Seconds