Part 1
Create a function, that runs on map initialiaztion.
The function's goal is to create <Footman Amount> footmen for Player_1 using a loop.
Part 2
Insert a new condition to exit the loop from Part 1 -- now the loop should (also) exit if Player_1's currently used food level is above "3".
Part 3
Create a new function, that also runs on map initialization.
The function's goal is to loop through all players, and to create <Footman Amount> footmen units for all of the players with using a loop, as well.
Create a function, that runs on map initialiaztion.
The function's goal is to create <Footman Amount> footmen for Player_1 using a loop.
vJASS:
//! zinc
library Loops {
private {
constant integer footmanAmount = 5;
function onInit() {
integer Count = 0;
while( Count < footmanAmount ) {
CreateUnit( Player(0), 'hfoo', 0, 0, 0 );
Count = Count + 1;
}
}
}
}
//! endzinc
Part 2
Insert a new condition to exit the loop from Part 1 -- now the loop should (also) exit if Player_1's currently used food level is above "3".
vJASS:
//! zinc
library Loops {
private {
constant integer footmanAmount = 5;
function onInit() {
integer Count = 0;
while(
Count < footmanAmount &&
GetPlayerState( Player(0), PLAYER_STATE_RESOURCE_FOOD_USED ) <= 3
) {
CreateUnit( Player(0), 'hfoo', 0, 0, 0 );
Count = Count + 1;
}
}
}
}
//! endzinc
Part 3
Create a new function, that also runs on map initialization.
The function's goal is to loop through all players, and to create <Footman Amount> footmen units for all of the players with using a loop, as well.
vJASS:
//! zinc
library Loops {
private {
constant integer footmanAmount = 5;
function createFootmen() {
integer Count = 0;
integer Index = 0;
while( Index < bj_MAX_PLAYERS ) {
while( Count < footmanAmount ) {
CreateUnit( Player( Index ), 'hfoo', 0, 0, 0 );
Count = Count + 1;
}
Index = Index + 1;
Count = 0;
}
}
function onInit() {
integer Count = 0;
while(
Count < footmanAmount &&
GetPlayerState( Player(0), PLAYER_STATE_RESOURCE_FOOD_USED ) <= 3
) {
CreateUnit( Player(0), 'hfoo', 0, 0, 0 );
Count = Count + 1;
}
createFootmen();
}
}
}
//! endzinc