Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: The -OR- condition for buildings (in EDB)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default The -OR- condition for buildings (in EDB)

    Do we know precisely how the or command works (as opposed to 'and')? My searching hasn't revealed anything on the subject.

    My precise task is the following:

    There exist buildings X, Y, and Z.

    My task is for most factions to be able to build building X without a problem; but to allow its availabilty for one faction only if the faction has a prerequisite building Y first.

    My code looks like this:

    Code:
            barracks1 city requires factions { hellenic, oscan, etruscan, punic, gallic, mesoamerican, } or requires factions { latin, } and building_present_min_level forum forum1
            {
            .....
    I would like the OR to start its own new logical clause, so that barracks1 will be available for factions hellenic etc, OR, available to a latin faction if it also has a Forum building.

    Right now the OR doesn't seem to work, with both the Forum building and the Barracks being available for the latin faction right away.
    Last edited by SigniferOne; March 03, 2009 at 10:46 PM.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  2. #2
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    It works in RTW, why it wouldn't carry over to M2TW behooves me but I suppose it's possible. EB Snippet:

    Code:
    stupa5 requires factions { romans_brutii, pontus, } and building_present_min_level government govnomad and not building_present_min_level government gov4 or building_present_min_level government gov1 and not hidden_resource not_here
    
    farms requires factions { germans, britons, scythia, dacia, spain, gauls, romans_brutii, egypt, romans_scipii, carthage, numidia, thrace, greek_cities, macedon, romans_julii, seleucid, saba, } or factions { parthia, armenia, pontus, } and building_present_min_level minimumbuilding pastoralism and not building_present_min_level nomadcamp warlordm
    But you probably already knew that.

    I think the problem with your code is you used requires twice. The EB code shows it going to the conditions right after the or statement, and only using requires once at the start to initiate the line. Yours uses it before each condition set. Hard to catch, I only noticed it after the 4th read through of your code. Hope that's the problem and it isn't that we lost the functionality, because I really want or statements for AUH.

    If that's not it, and it works to some extent, it could be an issue with building_present_min_level.

  3. #3
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Ah it's almost certainly the extra 'requires', good catch!

    But still, in a more general sphere, what logical priority does the 'or' have in comparison to the 'and's?

    If my intent is the following clause:

    building1 requires factions { faction1, faction2, faction3, } or factions { faction4, } and faction4_building or factions { faction5, } and faction5_building

    Does the game parse it as:

    Code:
    building1 requires factions { faction1, faction2, faction3, } or (factions { faction4, } and faction4_building) or (factions { faction5, } and faction5_building)
    .
    or is it something like:

    Code:
    building1 requires factions { faction1, faction2, faction3, } or factions { faction4, } and (faction4_building or factions { faction5, }) and faction5_building
    .

    What's the logical priority?
    Last edited by SigniferOne; March 04, 2009 at 04:11 PM.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  4. #4
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Sorry I rephrased the above post because it wasn't very clear. It's a difficult topic, I hope people are getting what I'm trying to say.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  5. #5
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    No I understand your example. I think of it like parentheses in math, each or statement separates X number of conditions. It should check the first statement after requires, and then if that comes back false and it see or, check that all the conditions after the or and before the next(or end of line) are fulfilled in order to turn back true.

    Think of it like elseif/elif is how I think about it.
    Code:
    def can_build_barracks
    if factions == faction1 :
        return True
    elif factions == faction2 :
        return True
    elif factions == faction3 :
        return True
    elif factions == faction4 :
        if building == faction4_building :
            return True
        else :
            return False
    elif factions == faction5 :
        if building == faction5_building :
            return True
        else :
            return False
    else :
        return False
    
    return False
    That's a Python example to the best of my ability, not very good with Python.

  6. #6
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Ok so the bottom line is that ORs are at the head of the underlying hierarchy -- that we can think of the entire line as just comprised of OR statements:

    OR faction1, faction2, faction3
    OR faction4 (and building4)
    OR faction5 (and building5)

    The only problem is that those aren't the results I am getting in-game. The latin factions gain access to barracks1 if Forum is built, but hellenic factions don't gain access to it if the Agora is built.

    I just switched the last two ORs, putting hellenics second of the three: now hellenics get access to barracks upon existence of the agora, but latins don't.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  7. #7
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    That's definitely problematic. It really doesn't make any sense for functionality purposes for and to supersede or. Now if you could have (or X and Y or Z or Q) that's one thing, where an or within an and would help, but that requires different functionality being applied to the same term. Without that separation the statements would be useless, since saying faction 1, 2, 3 or faction 4 and building_Q would just be like saying faction 1, 2, 3, 4 and building_Q, which completely deprecates the or statement.

    I'll do my own tests to see if I mirror your results. We should probably get Foot in here to comment on this, since I'm sure EBII tried to transport the or functionality.

  8. #8
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    It works for me, using the or statement as I mentioned. The problem might be that you are using culture names in the factions area. I know you're allowed to do this, I do, but in my example and the EB examples, the names of factions are used in the factions parameter.

    This is the code:

    Code:
    building test
    {
        levels test_1
        {
            test_1 requires factions { song, } or factions { taira, } and building_present_min_level barracks barracks_1 
            {
                capability
                {
    				recruit_pool "Daikyu Bushi"  5   0.5   8  0  requires factions { taira, } 
    				recruit_pool "Daikyu Bushi"  5	 0.5   8  0  requires factions { song, }
    				recruit_pool "Yari Shinobe"  5   0.5   8  0  requires factions { taira, } 
    				recruitment_slots 4
                }
                material wooden
                construction  1 
                cost  500 
                settlement_min village
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    And here is the result. Taira before building barracks(note 2 buildings in the GUI):
    Spoiler Alert, click show to read: 




    And after I build barracks_1:
    Spoiler Alert, click show to read: 



  9. #9
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Quote Originally Posted by Augustus Lucifer View Post
    It works for me, using the or statement as I mentioned.
    Sorry, I think you misread my example: I have TWO or-statements in it. That's really where the problem lies -- the second "or", i.e. the third clause, never gets executed. I have everything working just fine with a single "or".

    The trouble is getting the second "or" to execute... that's where the game's logical priorities seem tangled up.

    To test it out in your system, pick a generic building "test_1". Allow factions A, B, C, to build it unconditionally:

    test_1 requires factions { faction_A, faction_B, faction_C, }

    Then, allow faction D to build it only if it has some pre-condition building:

    or { faction_D} and building_present_min_level building_D

    And then, allow faction E to also build it, also only given its own pre-condition building:

    or { faction_E} and building_present_min_level building_E

    The command looks as follows altogether:

    test_1 requires factions { faction_A, faction_B, faction_C, } or { faction_D} and building_present_min_level building_D or { faction_E} and building_present_min_level building_E

    If I'm right, faction E should never be able to build test_1, even if you give it building_E.

    Or if you swap the two, put faction_D and building_D last, then faction E will be able to construct test_1, but not faction D.
    Last edited by SigniferOne; March 04, 2009 at 07:16 PM.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  10. #10
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    I'll test it. And in the EB Code it looks like they're using or both ways, within and above and. CA is certainly confusing.

    Code:
            greatgames requires factions { greek_cities, macedon, thrace, numidia, romans_julii, romans_brutii, } and not hidden_resource not_here and building_present_min_level amphitheatres gymnasium and building_present_min_level temple_of_battle temple_of_battle_awesome_temple or building_present_min_level temple_of_farming temple_of_farming_awesome_temple or building_present_min_level temple_of_fertility temple_of_fertility_awesome_temple or building_present_min_level temple_of_forge temple_of_forge_awesome_temple or building_present_min_level temple_of_fun temple_of_fun_awesome_temple or building_present_min_level temple_of_governors temple_of_governors_awesome_temple
    And in your example you have requires 3 times, but I assume that's just the example.

  11. #11
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Sorrty, I'll edit the 'requires' out, I keep making a mistake there


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  12. #12
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    Okay I've tested it and I can confirm your results. It's really a situation where their code is fundamentally abhorrent, because there is no common trend. We can not say it is separated by and where or is an additional determinant, because otherwise the factions before the first or would require everything after the and, which they do not. All that can seem to be concluded is that the factions tag breaks it but only once, which is just about the silliest thing I've ever heard of as far as methodology is concerned.

  13. #13
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    I'm sure it isn't the cause that the faction tag breaks it. I have certainty that the system has defined logical priorities, and is consistent in its own way. We just need one of the EB guys to pipe in here, because clearly they understood how the game parses these logical parameters. Do you know who designed their scripts?


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  14. #14
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    Quote Originally Posted by SigniferOne View Post
    I'm sure it isn't the cause that the faction tag breaks it. I have certainty that the system has defined logical priorities, and is consistent in its own way. We just need one of the EB guys to pipe in here, because clearly they understood how the game parses these logical parameters. Do you know who designed their scripts?
    They use tools from the TTO since deprecated to my knowledge, so it could have been anyone, but Foot will know. I should mention though that I haven't seen any triple factions statements in the EB EDB. I just did a search in their EDB, and only like ~10 buildings use or in the way we are discussing, and all of those only have it twice like we confirmed working. All the other or statements are present within and statements to allow a variety of buildings to be the one present.

  15. #15
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Ok I sent him a message, hopefully he replies. Also hopefully he'll point out to us something we've omitted and how wrong we were (I really need the double ORs to work...).


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  16. #16

    Default Re: The -OR- condition for buildings (in EDB)

    One thing you could try is to use an event counter. You have 3 seperate conditions you want the building to become avaialble under...

    building1 requires factions { faction1, faction2, faction3, } or factions { faction4, } and faction4_building or factions { faction5, } and faction5_building

    you could simply do somthing like the following...

    building1 requires factions { faction1, faction2, faction3, } or event_counter hasRequiredBuilding 1

    then, in your campaign script use a monitor to track if the faction has a particular building (one for each of the 2 factions you are trying to add)

    monitor_event FactionTurnStart FactionType faction4
    and FactionBuildingExists = faction4_building
    set_event_counter hasRequiredBuilding 1
    end_monitor
    monitor_event FactionTurnEnd FactionType faction4
    set_event_counter hasRequiredBuilding 0
    end_monitor

    the 2nd monitor here just ensures the next faction in turn doesnt get the use of the event counter. Then simply duplicate that for whatever other factions require it with whatever building you want them to have.

    As i have not done much scripting inside the EDB im not sure if event_counters work on the building line. I do almost all my scripts in the campaign_script. But figured i'd throw in my two cents.
    ...longbows, in skilled hands, could reach further than trebuchets...

  17. #17
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    They do work on the building line, and I'm sure Sig considered it(I know I did), but there's one key problem with using an event counter with building methodology. There's no settlement distinction. If you need building X in your city to make building Y, your script would account for building X in any city and allow building Y in all cities.

    The only way to do it would be to make a counter for every building and every faction and every settlement. You could cut some corners, but the script would still be absolutely massive. If the script allowed you to use params and lists and that sort of thing, you could have it check the settlement name and increase a counter param1_param2_built where param1 is settlement and param2 is building. But it doesn't allow for that sort of thing, so we're stuck with 200 if statements and counters for every building.

  18. #18
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Here's what I'm gonna try:


    building1 requires factions { faction1, faction2, faction3, } or factions { faction4, faction5 } and faction45_building

    An ingenious little solution! (hopefully)


    There's no distinction between faction4_building and faction5_building, but still!

    What the double ORs give me is the ability to split off the two into separate buildings with different affects. But if they have to be united into one to get it to work, then by God! they'll be united!



    PS. the counters are a clunky solution, sorry. I am prone to choose simplified but elegant solutions to clunky but effectual ones.
    Last edited by SigniferOne; March 05, 2009 at 11:40 AM.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  19. #19
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: The -OR- condition for buildings (in EDB)

    Quote Originally Posted by SigniferOne View Post
    building1 requires factions { faction1, faction2, faction3, } or factions { faction4, faction5 } and faction45_building

    Just wanted to let you guys know that this solution worked.

    Here is my final code:

    Code:
    barracks1 city requires factions { oscan, etruscan, punic, gallic, mesoamerican, } or factions { latin, hellenic, } and building_present_min_level agora agora1 or building_present_min_level forum forum1
    Notice how the second OR works -- everything is fine as long as it's not on the same logical level as the first OR. It seems that there cannot be two ORs on the same level. AND opens up a new (subsidiary) logical level, and within that another OR can be used with impunity (in this case letting me choose agora1 OR forum1, as long as either of them is present (AND).


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  20. #20
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: The -OR- condition for buildings (in EDB)

    Indeed. Nice to know, kind of figured that would work though, since the examples show those two levels in the EDB code, not sure if together or not. This works for factions that have different buildings, but not factions that use the same building sets. For instance if both faction 4 and faction 5 could build agora and forum, it can't be set so faction 5 needs agora, since they could also do it with forum. A shame really, but such is the way of things.

    I have a theoretical solution to this problem, but you obviously wouldn't want to do it on a massive scale.

    Code:
    monitor_event SettlementSelected SettlementBuildingExists = agora
            and FactionType faction4
    
    set_event_counter can_build_barracks1 1
    end_monitor
    
    monitor_event SettlementSelected not SettlementBuildingExists = agora
            and FactionType faction4
    
    set_event_counter can_build_barracks1 0
    end_monitor
    Not tested, but that should set a counter based on if the building exists in the settlement. As we know, counters apply to all settlements unlike the "building_present_min_level" condition. However, presumably if the not is applied, and it is attached to the SettlementSelected event, the counter should reset to 0 whenever a player selects a settlement that doesn't match the requirements, not allowing the player to build barracks1 in Segesta since he has agora in Rome. This is just musing, I will test it some time later.
    Last edited by Augustus Lucifer; July 01, 2009 at 08:21 PM.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •