[Vanilla] Possible to check the players strategic resources?

fb2017

Chieftain
Joined
Oct 8, 2017
Messages
53
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.)
 
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.
 
Top Bottom