1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[Vanilla] Possible to check the players strategic resources?

Discussion in 'Civ5 - Creation & Customization' started by Falk Bruskeland, Nov 2, 2017.

  1. Falk Bruskeland

    Falk Bruskeland Chieftain

    Joined:
    Oct 8, 2017
    Messages:
    53
    Gender:
    Male
    Is it possible to get the strategic resources of a civ or minor civ?
    And can you give strategic resources to them?
    (What I mean with strategic resources is horses, iron, aliminium, uranium etc.)
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,450
    Location:
    Illinois, USA
    Code:
    Player:ChangeNumResourceTotal(iResourceToAdd, 1)
    iResourceToAdd is a variable / placeholder for the Resource's ID number, which for horses can be gotten as
    Code:
    local iResourceToAdd = GameInfoTypes.RESOURCE_HORSE
    ------------------------------------------------------------------------------------------------------------------

    You have to get the player object from the player ID # off the active players in the game via a method like
    Code:
    local Player = Players[iPlayerID]
    -------------------------------------------------------------------------------------------------------------------

    To check the resources a player has uses this player method, with the args shown as listed (the data was printed out into an XML file by William Howard in order to make it easier to search and reference)
    Code:
      <api object="Player" method="GetNumResourceTotal">
          <method class="CvPlayer" fn="getNumResourceTotal"/>
          <arg pos="1" type="ResourceTypes" name="eIndex"/>
          <arg pos="2" type="bool" name="bIncludeImport" default="true"/>
          <ret type="int"/>
      </api>
    There is also
    Code:
      <api object="Player" method="GetNumResourceAvailable">
          <method class="CvPlayer" fn="getNumResourceAvailable"/>
          <arg pos="1" type="ResourceTypes" name="eIndex"/>
          <arg pos="2" type="bool" name="bIncludeImport" default="true"/>
          <ret type="int"/>
      </api>
    -------------------------------------------------------------------------------------------------------------------

    For comparison, here is the listing for the ChangeNumResourceTotal method
    Code:
      <api object="Player" method="ChangeNumResourceTotal">
          <method class="CvPlayer" fn="changeNumResourceTotal"/>
          <arg pos="1" type="ResourceTypes" name="eIndex"/>
          <arg pos="2" type="int" name="iChange"/>
          <arg pos="3" type="bool" name="bIgnoreResourceWarning" default="false"/>
          <ret type="void"/>
      </api>
    In the example I showed up-post I omitted the third argument for the boolean "bIgnoreResourceWarning"

    ---------------------------------------------------------------------------------------------------------------------

    So far as I know all these methods are valid in all three expansion levels of civ5.
     
  3. SLGray

    SLGray King

    Joined:
    May 18, 2015
    Messages:
    842
    Gender:
    Male
    Location:
    United Sates
    Do you mean trade?
     
  4. Falk Bruskeland

    Falk Bruskeland Chieftain

    Joined:
    Oct 8, 2017
    Messages:
    53
    Gender:
    Male

Share This Page