AdamGriffith
You can change this now in User CP.
- Reaction score
- 69
JASS:
native SetPlayerState takes player whichPlayer, playerstate whichPlayerState, integer value returns nothing
What does 'integer value' mean in this native?
native SetPlayerState takes player whichPlayer, playerstate whichPlayerState, integer value returns nothing
call SetPlayerState(Player(0), PLAYER_STATE_GIVES_BOUNTY, IntegerTertiaryOp(true, 1, 0))
function IntegerTertiaryOp takes boolean flag, integer valueA, integer valueB returns integer
if flag then
return valueA
else
return valueB
endif
endfunction
function AdjustPlayerStateSimpleBJ takes player whichPlayer, playerstate whichPlayerState, integer delta returns nothing
call SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta)
endfunction
function AdjustPlayerStateBJ takes integer delta, player whichPlayer, playerstate whichPlayerState returns nothing
// If the change was positive, apply the difference to the player's
// gathered resources property as well.
if (delta > 0) then
if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then
call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_GOLD_GATHERED, delta)
elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then
call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_LUMBER_GATHERED, delta)
endif
endif
call AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta)
endfunction
Seems to be the equivalent of IMax/MinBJ, all rolled into a single function, using the boolean to determine whether you're looking for max or minWhats the IntegerTertiaryOp thing all about?
Then it wouldn't update the total gathered amount, which is kinda the point of that function.Kinda weird that the If-Then-Else with PLAYER_STATE_GOLD/LUMBER is even there, couldn't they have just called AdjustPlayerStateSimpleBJ and be done with it?
No, it has nothing to do with min or max values of two integers. It lets you shrink code like this:Seems to be the equivalent of IMax/MinBJ, all rolled into a single function, using the boolean to determine whether you're looking for max or min
if myboolean then
call MyFunction(2)
else
call MyFunction(3)
endif
call MyFunction(IntegerTertiaryOp(myboolean, 2, 3))