Announcement

Collapse
No announcement yet.

DESIGN: Hunger flags

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

  • DESIGN: Hunger flags

    What follows is traffic from this thread:



    It esentially addresses reimplementing the hungerfood flag, that is alread in the game but doesnt work (presumably because food is managed by city not empire like pw or gold). I also suggested adding a new flag: hungergold, that would make units cost gold per turn.


    Martin made a good suggestion about hungerfood saying that the total should be added up then divided by cities and subtracted from each city...this would have to consider new cities and those with more surplus than others but thats to b e discussed.










    _____________________________________

    rfom gs/readiness.cpp


    Code:
    void MilitaryReadiness::SupportUnit(const Unit &u, sint32 gov)
    
    {
    	double unitCost = GetSupportCost(u);
    
    	m_cost += unitCost;
    
    	g_network.Block(m_owner);
    	ENQUEUE();
    	g_network.Unblock(m_owner);
    }
    
    double MilitaryReadiness::GetSupportCost(const Unit &u)
    {
    	if(u.GetIsProfessional())
    		return 0;
    
    	if(u.GetNeedsNoSupport())
    		return 0;
    
    	double unitCost;
    	if(u.GetDBRec()->GetIsSpecialForces()) {
    		unitCost = u.GetShieldHunger() * GetSpecialForcesSupportModifier(g_player[m_owner]->GetGovernmentType());
    	} else {
    		unitCost = u.GetShieldHunger() * GetSupportModifier(g_player[m_owner]->GetGovernmentType());
    	}
    	unitCost -= unitCost * 
     		double((double)wonderutil_GetReadinessCostReduct
    ion(
    			g_player[m_owner]->GetBuiltWonders()) / 100.0);
    
    	unitCost *= g_theGovernmentDB->Get(g_player[m_owner]->m_government_type)->GetSupportCoef();
    
    	return unitCost;

    It looks like this code looks to see if a unit has the hungershield flag and then looks for the value after it and then subtracts that value from the players PW.

    So it looks like that in order to fix hungerfood or add hungergold, we'd have to create the flag and then look for the number value after the flag...

    Also the unit support code I listed previously doesnt mention hungerfood which may be why the flag appears unimplemented



    Code:
    sint32 Unit::GetShieldHunger() const
    
    {
        return GetDBRec()->GetShieldHunger(); 
    }
    
    sint32 Unit::GetFoodHunger() const
    
    {
        return GetDBRec()->GetFoodHunger();
    Is there an empire-wide food variable? I thought it was city based. If so, where would you deduct the food from? -E


    There is no such variable. That's why I said it would be a big job - you'd have to comprehensively rework the way food is handled. - J Bytheway


    Would it be coprehensive to have the system look for the city with the highest excess food first and subrtract from it until it was no longer then subtract from the next highest one. - E

    "Basically a function that checks for the city with highest bonus, subtracts, checks again, subtracts, etc until either all are supplied or there is no bonus food left...

    This system reminds me of Civ2, a city based instead of a empire wide based system, however maybe that could achieved over the food coefficent from the government stuff, or somewhere a function that calls us how many food must be deducted from each city.

    Something like:

    Needed food by units / number of cities and then substract it from all cities."

    -Martin


    i think I like that idea for food better Martin. I think this highlights a bigger issue with food though, that there is no distribution system that models a real world situation. Like egypt was rome's bread basket and Rome grew based on food imports, likewise with the midwest. I guess a future issue, probably in governor.cpp, would be able to shift food (maybe also with the trade route system)

    As for gold, its managed empire-wide so it shouldnt be as hard to implement right?


    I think I hould open this up in a new thread, in the source code...
    Last edited by Ekmek; October 7, 2004, 11:59.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    I don't think we need to accurately simulate food distribution in a civ game, but if someone wants to make a mod then I'm all for making it at least possbile. You could just have a simple trade route passing food to the buying city. But I am interested in units requiring empire support from food and/or commerce as well as production. Different governments and units would require different balances of each resource, this would not only weaken production quite some in the whole game, but it would really cripple a war monger in the long run.
    Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
    CtP2 AE Wiki & Modding Reference
    One way to compile the CtP2 Source Code.

    Comment


    • #3
      I would say that the cost in food support should be distributed to the cities in proportion to their excess food, or possible in proportion to their total food.

      Comment


      • #4
        Food Hunger

        - Great idea (at least in theory)
        - Distributing food hunger over all cities could starve those cities you place on poor quality land for strategic reasons. In Civ2 you just never built any units in those cities and used units from other cities instead
        - Would we give different food costs to different units? Probably not for the most part

        I say no to trying to implement unit food hunger at this point.
        ·Circuit·Boi·wannabe·
        "Evil reptilian kitten-eater from another planet."
        Call to Power 2 Source Code Project 2005.06.28 Apolyton Edition

        Comment


        • #5
          Gold Hunger

          Go for it!
          ·Circuit·Boi·wannabe·
          "Evil reptilian kitten-eater from another planet."
          Call to Power 2 Source Code Project 2005.06.28 Apolyton Edition

          Comment


          • #6
            I´m not sure about the normal game, but for mods.. why not?
            I like the idea
            The Party seeks power entirely for its own sake. We are not interested in the good of others; we are interested solely in power. Not wealth or luxury or long life or happiness: only power, pure power.

            Join Eventis, the land of spam and unspeakable horrors!

            Comment


            • #7
              Code:
              sint32 Strengths::GetTotalUnitCost()
              {
              	sint32 i;
              	sint32 c = 0;
              	UnitDynamicArray *units = g_player[m_owner]->m_all_units;
              	for(i = units->Num() - 1; i >= 0; i--) {
              		c += units->Access(i).GetDBRec()->GetShieldCost();
              	}
              	return c;
              this is from strengths. So it looks like I have to update readiness.cpp, strengths.cpp, and unit.cpp. But I'm sure I gotta get into Gold.cpp...

              I post propsed changes once I go through everything and follow how shields a added subtracted etc. but i'm going to need help correcting my errors and especially compiling and testing for hungergold
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • #8
                I'm in favour of implementing the flag, just not of using it.
                edit/ So it probably shouldn't be high on the list of priorities.
                Concrete, Abstract, or Squoingy?
                "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                Comment


                • #9
                  unit.cpp

                  Code:
                  sint32 Unit::GetStoredCityFood() const 
                  {
                      return GetData()->GetStoredCityFood();
                  }
                  sint32 Unit::GetNetCityFood() const
                  {
                      return GetData()->GetNetCityFood();
                  }
                  
                  
                  
                  
                  sint32 Unit::GetGrossCityFood() const 
                  {
                      return GetData()->GetGrossCityFood();
                  }
                  sint32 Unit::GetNetCityGold() const
                  {
                      return GetData()->GetNetCityGold();
                  }
                  sint32 Unit::GetGrossCityGold() const
                  {
                      return GetData()->GetGrossCityGold();
                  I'm thinking these may be useful esp. for the food calc
                  Formerly known as "E" on Apolyton

                  See me at Civfanatics.com

                  Comment


                  • #10
                    I've been doing a lot of research in the code for hungergold and I'm opting to copy how upkeep works for cityimprovements to apply to units for hunger gold.

                    But this raises a new, interesting, question? How can we implement flags/traits associated with cityimprovements, units, and tileimprovements to affect each other?

                    as an example flags like terrainbonus for TIs apply to units...or just putting upkeep to aapply to units and TIs. Or PrerequisiteBuilding IMPROVE_BANK to maake units or TIs require certain buildings...


                    Meaning stuff located in the different text files can apply to other ones? Is this a matter of just linking the files that have the flags, or would it require a cut'n'paste job?


                    For the purists I'm recommending this for modding sake
                    Last edited by Ekmek; October 21, 2004, 13:17.
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • #11
                      I've been doing a lot of research in the code for this and I'm opting to copy how upkeep works for cityimprovements to apply to units for hunger gold.

                      But this raises a new, interesting, question? How can we implement flags/traits associated with cityimprovements, units, and tileimprovements to affect each other?

                      as an example flags like terrainbonus for TIs apply to units...or just putting upkeep to aapply to units and TIs. Or PrerequisiteBuilding IMPROVE_BANK to maake units or TIs require certain buildings...


                      Meaning stuff located in the different text files can apply to other ones? Is this a matter of just linking the files that have the flags, or would it require a cut'n'paste job?


                      For the purists I'm recommending this for modding sake
                      Formerly known as "E" on Apolyton

                      See me at Civfanatics.com

                      Comment


                      • #12
                        I think these changes need to be done to get a hunger gold for moders. But I'm looking for help on how to get it displayed. I think it wuld be good to see in a tab how much your military is costy you. I know flinx made a new tab before. Any one interested?
                        Attached Files
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment

                        Working...
                        X