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.
Welcome to Spaceempires.net
Login or Register

Search
Modules
· Content
· Downloads
· Forums
· Game Info
· Image Gallery
· Links
· Shipyards
· Topics
· Staff

User Info
· Welcome, Anonymous
Membership:
· New: Astorre
· New Today: 0
· New Yesterday: 0
· Overall: 3155

People Online:
· Visitors: 131
· Members: 0
· Total: 131

  

Spaceempires.net :: How to Model Exclusive Components :: View topic
Forum FAQ :: Search :: Memberlist :: Usergroups :: Profile :: Log in to check your private messages :: Log in


How to Model Exclusive Components

 
Post new topic   Reply to topic    Spaceempires.net Forum Index -> SEV Modding FAQ
View previous topic :: View next topic  
Author Message
Fyron
Galactic Guru


Joined: Aug 04, 2003
Location: CA, USA

PostPosted: Sun Feb 17, 2008 10:49 pm    Post subject: How to Model Exclusive Components Reply with quote

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 that A is the statement:

Code:
Get_Design_Specific_Component_Count ("Composite Armor") >= 1


and B is the statement:

Code:
Get_Design_Specific_Component_Count ("Energy Refractive Armor") >= 1


It follows that !A (not A) is thus:

Code:
Get_Design_Specific_Component_Count ("Composite Armor") < 1


and !B (not B) is thus:

Code:
Get_Design_Specific_Component_Count ("Energy Refractive Armor") < 1


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 )


Smarter than your average Texrak.


Back to top
MikeTn1
Space Emperor


Joined: Oct 23, 2008

PostPosted: Wed Jul 01, 2009 1:44 pm    Post subject: Reply with quote

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
CaptainKwok
Balance Guru


Joined: Aug 04, 2003
Location: Toronto, Canada

PostPosted: Wed Jul 01, 2009 2:27 pm    Post subject: Reply with quote

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


Space Empires Depot | SE:V Balance Mod


Back to top
MikeTn1
Space Emperor


Joined: Oct 23, 2008

PostPosted: Thu Jul 02, 2009 1:26 pm    Post subject: Reply with quote

I will look it over this weekend and if I have any question, I will get back to you.

Thanks Captain!


Back to top
Zwo_Dvoongar
Space Emperor


Joined: Feb 02, 2011

PostPosted: Mon Jul 29, 2013 5:21 am    Post subject: Re: How to Model Exclusive Components Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Spaceempires.net Forum Index -> SEV Modding FAQ All times are GMT
Page 1 of 1

 
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
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: SpaceEmpires.net News RSS Feed - Syndicate forums: SpaceEmpires.net Forums RSS Feed
Page Generation: 0.61 Seconds