- Joined
- Aug 13, 2007
- Messages
- 309
JASS:
fixed[2] SimAnt_workerSpawnChance;
fixed[2] SimAnt_soldierSpawnChance;
fixed[2] SimAnt_nurseSpawnChance;
// Check for ants around the ant mounds to teleport.
bool SimAnt_HatchAntEggs_Func (bool testConds, bool runActions) {
int i = 1;
unit u = UnitGroupUnit(SimAnt_antEggs, i);
int p;
int i2;
fixed life;
fixed percent;
string antType;
int player;
while (u != null) {
life = UnitGetPropertyFixed(u, c_unitPropLifePercent, true);
if (life >= 100.0) {
p = UnitGetOwner(u);
UnitKill(u);
if (p <= maxPlayers/2) {
i2 = 0;
} else {
i2 = 1;
}
percent = RandomFixed(0.0, SimAnt_workerSpawnChance[i2] + SimAnt_soldierSpawnChance[i2] + SimAnt_nurseSpawnChance[i2]);
percent += -SimAnt_workerSpawnChance[i2];
if (percent <= 0.0) {
antType = AntWorker;
player = i2*maxPlayers/2 + RandomInt(2, 3);
} else {
percent += -SimAnt_soldierSpawnChance[i2];
if (percent <= 0.0) {
antType = AntSoldier;
player = i2*maxPlayers/2 + RandomInt(4, 5);
} else {
percent += -SimAnt_nurseSpawnChance[i2];
if (percent <= 0.0) {
antType = AntNurse;
player = i2*maxPlayers/2 + 1;
}
}
}
UnitCreate(1, antType, c_unitCreateIgnorePlacement, player, UnitGetPosition(u), RandomFixed(0.0, 360.0));
}
i += 1;
u = UnitGroupUnit(SimAnt_antEggs, i);
}
return true;
}
//--------------------------------------------------------------------------------------------------
void SimAnt_HatchAntEggs_Init () {
TimerStart(SimAnt_antEggsTimer, 1.0, true, c_timeReal);
TriggerAddEventTimer(gt_HatchAntEggs, SimAnt_teleportTimer);
SimAnt_workerSpawnChance[0] = 60;
SimAnt_workerSpawnChance[1] = 60;
SimAnt_soldierSpawnChance[0] = 30;
SimAnt_soldierSpawnChance[1] = 30;
SimAnt_nurseSpawnChance[0] = 10;
SimAnt_nurseSpawnChance[1] = 10;
}