Announcement

Collapse
No announcement yet.

PROJECT: CivOnly and CultureOnly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PROJECT: CivOnly and CultureOnly

    ShowOnMap is my next endeavor but if this code is simlar to my Good and CanSettle On code I may knock this out.

    The concept is to add a flag CivOnly and a separate flag CultureOnly for use by modders to make units, advances, buildings, tileimps, and wonders only availble to certain civs. this would reduce the burden of making unique civ advance trees or grantadvance slic. Slic is great but time should be devoted to bigger things I think and this could make it easy for some sceanrios like WW2.

    If your wonder CultureOnly will be like CivOnly except it will check for CityStyle instead of civ name.


    I think the Civ only might use this code:
    Code:
    		sint32 name;
    		sint32 n;
    		if (g_theCivilisationDB->GetCivilisation(name)){
    		for(n = 0; n < rec->GetCivOnly(); i++) {
    			if(rec->GetGetCivOnly(n) == name) {
    				return true; 
    			}
    		}
    		}
    cultureroup

    Code:
    		sint32 style;
    		sint32 s;
    		if (g_theCivilisationDB->GetCityStyle(style)){
    		for(n = 0; n < rec->GetCultureOnly(); i++) {
    			if(rec->GetCultureOnly(c) == name) {
    				return true; 
    			}
    		}
    		}
    Last edited by Ekmek; March 3, 2005, 00:35.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    For units I believe I'll add it in
    BOOL Player::CanBuildUnit(const sint32 type) const
    Last edited by Ekmek; March 11, 2005, 19:29.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • #3
      The CivOnly code might be a little bit more difficuilt since the civilisation database a CTP1 database and not a CTP2 database generated by dbgen.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment


      • #4
        Martin,
        I see that the code doesn't have Civs in the dbgen, but I'm not looking to modify the database files for civs but to ad it in units, advances, imps etc as flags and then functions that check to see the civ type (or city style). How else is it different? Should I do something like Mr Baggins did on modifiedgovernments?
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • #5
          I see thatcivilizationDb doesnt have a GetCivilization but all of the 'Get' functions have the constand (const CIV_INDEX civ). I think this is what you mean about it working a la ctp1.

          continuing research...
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • #6
            I went into the civilisationDB (H and cpp) files and I'd say they are a mess probably because they are ctp1 and not as familiar as the ctp2 stuff I've been looking at...but in the h I found this code that I think I could use for my flag....



            Code:
            		StringId GetPluralCivName(const CIV_INDEX civ) const
            			{
            			Assert(civ>=0) ; 
            			Assert(civ<=(CIV_INDEX)(m_nRec)) ;
            			return (m_rec[civ].GetPluralCivName()) ;
            			}
            		
            		StringId GetCountryName(const CIV_INDEX civ) const
            			{
            			Assert(civ>=0) ; 
            			Assert(civ<=(CIV_INDEX)(m_nRec)) ;
            			return (m_rec[civ].GetCountryName()) ;
            			}
            
            		StringId GetSingularCivName(const CIV_INDEX civ) const
            			{
            			Assert(civ>=0) ; 
            			Assert(civ<=(CIV_INDEX)(m_nRec)) ;
            			return (m_rec[civ].GetSingularCivName()) ;
            			}
            and
            Code:
            		sint32 GetCityStyle( const CIV_INDEX civ ) const {
            			Assert( civ >= 0 );
            			Assert( civ <= (CIV_INDEX)(m_nRec) );
            			return ( m_rec[civ].GetCityStyle() );
            		}
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • #7
              CityStyle works fine, the data is stored in a CTP2 database, and the CityData object should have the piece of information stored, no need to use this function from the civilisation database.

              However the civilisation stuff is an headache.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #8
                hmmmm....I'd love to do CivOnly because it makes more sense, but I guess I can live with CityStyleOnly (or CultureOnly) and it could be a workaround if people wanted to make it Civspecific they can make a citystyle per civ (and probably just repeat city graphics) and I maybe up to redoing the CityStyle.txt etc per civ instead of pergroup....
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • #9
                  Don't drop this civ only idea we have just to invest more time for it (or better just you ), and therefore I think we should just start with the culture idea.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #10
                    agreed and I'll take a stab at it this weekend hopefully (although I really want to get somewhere on ShowOnMap too).

                    I'm thinking that the code should be identical for tileimps, units, advances, and builings. Just have to add the optional flag to all the cdb files.

                    but yes I'd like to unravel the civilization db problem (eventually)
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • #11
                      As I trudge through the other stuff I'll hopefully post something on this soon (mainly since it may have a greater impact)

                      but I looked it ctydata.cpp and found this:

                      Code:
                      #if defined(ACTIVISION_ORIGINAL)
                      	m_cityStyle = g_player[m_owner]->m_civilisation->GetCityStyle();
                      #else
                      	// Set the style of the founder of the city - if any.
                      	if (g_player[o] && g_player[o]->GetCivilisation())
                      	{
                      		m_cityStyle = g_player[o]->GetCivilisation()->GetCityStyle();
                      	}
                      #endif
                      How come I cant use the GetCivilisation() here and get CIV_COUNTRY from the Civilization.txt? I know you said its not thesame but from looking in the code my (UNTRAINED) eye can tell the difference.
                      Formerly known as "E" on Apolyton

                      See me at Civfanatics.com

                      Comment


                      • #12
                        First shot at this code...

                        Code:
                        		sint32 s;
                        		for(s = 0; s < rec->GetCultureOnly(); s++) {
                        			if(rec->GetCultureOnlyIndex(s) == g_player->GetCivilisation()->GetCityStyle()) {
                        				return TRUE;
                        			}
                        		}
                        Its based on my previous success CanSettleOn. My only two questions is that the code I got for g_player had actually g_player[o] but I didn't think that was necessary in this instance

                        My other concern is the CultureOnly flag. Can I use CultureOnly in other cdb stuff (advances, buildings, imps, etc). My instinct says yes because I determine what rec its checking but just want to make sure that I don't have to come up with different names each time.
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment


                        • #13
                          Originally posted by E
                          Its based on my previous success CanSettleOn. My only two questions is that the code I got for g_player had actually g_player[o] but I didn't think that was necessary in this instance
                          The code seems to be ok except that g_player is an arrary a set of players and not just one player. And except that the condition in the for loop is not rec->GetCultureOnly() but the number of CulturOnly and you retrieve this with rec->GetNumCultureOnly(). And that the context is missing, however it belongs right above the final return. However as it stands now it is pretty useless as it always returns TRUE, so as in your good restriction thread you have to add an return FALSE; behind the for-loop. And of course you code should only be executed if the number of CultureOnly's is bigger then 0. And of course to figure out the number you use rec->GetNumCultureOnly().

                          Originally posted by E
                          My other concern is the CultureOnly flag. Can I use CultureOnly in other cdb stuff (advances, buildings, imps, etc). My instinct says yes because I determine what rec its checking but just want to make sure that I don't have to come up with different names each time.
                          Of course you can define it in all the databases the obsolete flag is also defined multiple times.

                          -Martin
                          Civ2 military advisor: "No complaints, Sir!"

                          Comment


                          • #14
                            Code:
                            		sint32 s;
                            		for(s = 0; s > rec->GetCultureOnly(); s++) {
                            			if(rec->GetNumCultureOnly(s) == g_player->GetCivilisation()->GetCityStyle()) {
                            				return TRUE;
                            			}
                            		}return FALSE;
                            Still got to figure out what you mean by context and thats great about the cdb. Once I get a decent piece of code going I'll work on putting it everywhere a modder may want it (this may cut down on slic for modders).

                            Another question though. The "//" boxes I've been doing for new code. If I add thisnew code into some other code that already has the box do I just add it in the box or make another box?
                            Formerly known as "E" on Apolyton

                            See me at Civfanatics.com

                            Comment


                            • #15
                              Originally posted by E
                              Another question though. The "//" boxes I've been doing for new code. If I add thisnew code into some other code that already has the box do I just add it in the box or make another box?
                              You mean the #if-#else block? If you put new code in a block that is compiled if ACTIVISION_ORIGINAL is not defined then you don't need your own. However you have instances in the code where it is done. That's a problem if you start to modify something in a big chunk of new code, so that you don't realize it that you are modifying non ACTIVISION_ORIGINAL code.

                              However for your code fragment you have still to put it into an if-block.

                              And of course the contex is still missing, you have to insert it somewhere. So it does make sense and not non-sense.

                              -Martin
                              Civ2 military advisor: "No complaints, Sir!"

                              Comment

                              Working...
                              X