SC2Mapster.com Wiki

AIHasRes

bool AIHasRes(int player, int minerals, int gas);

Has at least the amount of minerals and gas.

Parameters

int player

Player number

int minerals

The player as at least (or equal) this amount of mineral.

int gas

The player as at least (or equal) this amount of gas.

Examples

Example #1: Sample Usage
// Player 1 resource : 100 mineral, 50 gas

bool valid;

valid = AIHasRes(1, 100, 50);
// True. Has exactly that number of resources

valid = AIHasRes(1, 150, 50);
// False. The player is missing mineral

valid = AIHasRes(1, 50, 0);
// True. Use 0 to avoid filling a field.
Example #2: Recode
bool AIHasRes(int player, int minerals, int gas) {
  return mineral <= PlayerGetPropertyInt(player, c_playerPropMinerals)
           && gas <= PlayerGetPropertyInt(player, c_playerPropVespene);
}

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 17, 2010
Last updated
Mar 29, 2010

Authors