int ArtificialIntelligence8 () { int i, j, k, r, st, x, y, id, h, hmax; TPoint p; char buf [40]; TBase *Base; TField *f; Message (SigText[TXT_AI_ANALYSE]); // Prepocitame viditelnost AllowBadlife (TRUE); ComputeVisib (); RedrawMap (); LockDraw (); // Aktualizujeme specialni objekty Docks1 = GetField (D1X, D1Y) -> Unit; if (Docks1 == NO_UNIT || Units [Docks1] -> Type % BADLIFE != unDocks) Docks1 = NO_UNIT; Docks2 = GetField (D2X, D2Y) -> Unit; if (Docks2 == NO_UNIT || Units [Docks2] -> Type % BADLIFE != unDocks) Docks2 = NO_UNIT; Factory1 = GetField (F1X, F1Y) -> Unit; if (Factory1 == NO_UNIT || Units [Factory1] -> Type % BADLIFE != unFactory) Factory1 = NO_UNIT; Factory2 = GetField (F2X, F2Y) -> Unit; if (Factory2 == NO_UNIT || Units [Factory2] -> Type % BADLIFE != unFactory) Factory2 = NO_UNIT; Factory3 = GetField (F3X, F3Y) -> Unit; if (Factory3 == NO_UNIT || Units [Factory3] -> Type % BADLIFE != unFactory) Factory3 = NO_UNIT; // Vyradime znicene jednotky z armad Towers -> DeleteKilled2 (); Towers -> DeleteKilled (); Army1 -> DeleteKilled2 (); Army1 -> DeleteKilled (); Army2 -> DeleteKilled2 (); Army2 -> DeleteKilled (); Army3 -> DeleteKilled2 (); Army3 -> DeleteKilled (); AirArmy3 -> DeleteKilled2 (); AirArmy3 -> DeleteKilled (); Army4 -> DeleteKilled2 (); Army4 -> DeleteKilled (); Army5 -> DeleteKilled2 (); Army5 -> DeleteKilled (); Army6 -> DeleteKilled2 (); Army6 -> DeleteKilled (); Army7 -> DeleteKilled2 (); Army7 -> DeleteKilled (); Army8 -> DeleteKilled2 (); Army8 -> DeleteKilled (); AirArmy8 -> DeleteKilled2 (); AirArmy8 -> DeleteKilled (); Marine1 -> DeleteKilled2 (); Marine1 -> DeleteKilled (); Marine8 -> DeleteKilled2 (); Marine8 -> DeleteKilled (); DUPos = 0; // Testneme konec hry st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } // Zpracujeme seznam poli, na ktere se utocilo Army1 -> DoAttackedFields (); Army2 -> DoAttackedFields (); Army3 -> DoAttackedFields (); AirArmy3 -> DoAttackedFields (); Army4 -> DoAttackedFields (); Army5 -> DoAttackedFields (); Army6 -> DoAttackedFields (); Army7 -> DoAttackedFields (); Army8 -> DoAttackedFields (); AirArmy8 -> DoAttackedFields (); Marine1 -> DoAttackedFields (); Marine8 -> DoAttackedFields (); AttackFieldPos = 0; AnalyseLandscape (); Message (SigText[TXT_AI_ARMY]); //////////////////////////////// AKTIVACE ARMAD // Test zaktivovani armady 1 if (Army1 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Status = asActive; } } } // Test zaktivovani armady 2 if (Army2 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Status = asActive; } } } // Test zaktivovani armady 3 if (Army3 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Status = asActive; } } } // Test zaktivovani armady 4 if (Army4 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Status = asActive; } } } // Test zaktivovani armady 5 if (Army5 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Status = asActive; } } } // Test zaktivovani armady 6 if (Army6 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Status = asActive; } } } // Test zaktivovani armady 7 if (Army7 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Status = asActive; } } } // Test zaktivovani armady 8 if (Army8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Status = asActive; } } } // Test zaktivovani marine 1 if (Marine1 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Marine1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Marine1 -> Status = asActive; } } } // Test zaktivovani marine 8 if (Marine8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Marine8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Marine8 -> Status = asActive; } } } ///////////////////////////// AKCE ARMAD // Nastavime ProgressBar st = 0; st += Towers -> nofBadLife; if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) st += Army1 -> nofBadLife; if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) st += Army2 -> nofBadLife; if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) st += Army3 -> nofBadLife; if (AirArmy3 -> Status == asActive || AirArmy3 -> Status == asSuicide) st += AirArmy3 -> nofBadLife; if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) st += Army4 -> nofBadLife; if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) st += Army5 -> nofBadLife; if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) st += Army6 -> nofBadLife; if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) st += Army7 -> nofBadLife; if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) st += Army8 -> nofBadLife; if (AirArmy8 -> Status == asActive || AirArmy8 -> Status == asSuicide) st += AirArmy8 -> nofBadLife; if (Marine1 -> Status == asActive || Marine1 -> Status == asSuicide) st += Marine1 -> nofBadLife; if (Marine8 -> Status == asActive || Marine8 -> Status == asSuicide) st += Marine8 -> nofBadLife; if (st == 0) st = 5; // Magic number ProgressNull (); ProgressLimit (st); // Vylozime letiste UnlockDraw (); for (i = BADLIFE; i < UNITS_TOP; i++){ // Airport if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unAirport) { for (j = 0; j < ((TAirport *) Units [i]) -> LoadedUnits; j++) { id = ((TAirport *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((TAirport *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } // Heliport if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unHeliport) { for (j = 0; j < ((THeliport *) Units [i]) -> LoadedUnits; j++) { id = ((THeliport *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((THeliport *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } // Laguna if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unLaguna) { for (j = 0; j < ((TLaguna *) Units [i]) -> LoadedUnits; j++) { id = ((TLaguna *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((TLaguna *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } } LockDraw (); // Veze if (Towers -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // ARMY 1 if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) { Army1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Insert (i); } } // Pokyn k sebevrazde Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CSuicide1) { Army1 -> Status = asSuicide; } // Provedeme akce if (Army1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CMinDang1) { Army1 -> Status = asDestroyed; } } // ARMY 2 if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) { Army2 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Insert (i); } } // Pokyn k sebevrazde Army2 -> CountDangerous (); if (Army2 -> Dangerous <= CSuicide2) { Army2 -> Status = asSuicide; } // Provedeme akce if (Army2 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 2 if (Army2 -> Dangerous <= CMinDang2) { Army2 -> Status = asDestroyed; } } // ARMY 3 if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) { Army3 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Insert (i); } } // Pokyn k sebevrazde Army3 -> CountDangerous (); if (Army3 -> Dangerous <= CSuicide3) { Army3 -> Status = asSuicide; } // Provedeme akce if (Army3 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 3 if (Army3 -> Dangerous <= CMinDang3) { Army3 -> Status = asDestroyed; } } // AIR ARMY 3 if (AirArmy3 -> Status == asActive || AirArmy3 -> Status == asSuicide) { AirArmy3 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (AirArmy3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { AirArmy3 -> Insert (i); } } // Pokyn k sebevrazde AirArmy3 -> CountDangerous (); if (AirArmy3 -> Dangerous <= CSuicideA3) { AirArmy3 -> Status = asSuicide; } // Provedeme akce if (AirArmy3 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 3 if (AirArmy3 -> Dangerous <= CMinDangA3) { AirArmy3 -> Status = asDestroyed; } } // ARMY 4 if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) { Army4 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Insert (i); } } // Pokyn k sebevrazde Army4 -> CountDangerous (); if (Army4 -> Dangerous <= CSuicide4) { Army4 -> Status = asSuicide; } // Provedeme akce if (Army4 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 4 if (Army4 -> Dangerous <= CMinDang4) { Army4 -> Status = asDestroyed; } } // ARMY 5 if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) { Army5 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Insert (i); } } // Pokyn k sebevrazde Army5 -> CountDangerous (); if (Army5 -> Dangerous <= CSuicide5) { Army5 -> Status = asSuicide; } // Provedeme akce if (Army5 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 5 if (Army5 -> Dangerous <= CMinDang5) { Army5 -> Status = asDestroyed; } } // ARMY 6 if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) { Army6 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Insert (i); } } // Pokyn k sebevrazde Army6 -> CountDangerous (); if (Army6 -> Dangerous <= CSuicide6) { Army6 -> Status = asSuicide; } // Provedeme akce if (Army6 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (Army6 -> Dangerous <= CMinDang6) { Army6 -> Status = asDestroyed; } } // ARMY 7 if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) { Army7 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Insert (i); } } // Pokyn k sebevrazde Army7 -> CountDangerous (); if (Army7 -> Dangerous <= CSuicide7) { Army7 -> Status = asSuicide; } // Provedeme akce if (Army7 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 7 if (Army7 -> Dangerous <= CMinDang7) { Army7 -> Status = asDestroyed; } } // ARMY 8 if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) { Army8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Insert (i); } } // Pokyn k sebevrazde Army8 -> CountDangerous (); if (Army8 -> Dangerous <= CSuicide8) { Army8 -> Status = asSuicide; } // Provedeme akce if (Army8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (Army8 -> Dangerous <= CMinDang8) { Army8 -> Status = asDestroyed; } } // AIR ARMY 8 if (AirArmy8 -> Status == asActive || AirArmy8 -> Status == asSuicide) { AirArmy8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (AirArmy8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { AirArmy8 -> Insert (i); } } // Pokyn k sebevrazde AirArmy8 -> CountDangerous (); if (AirArmy8 -> Dangerous <= CSuicideA8) { AirArmy8 -> Status = asSuicide; } // Provedeme akce if (AirArmy8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (AirArmy8 -> Dangerous <= CMinDangA8) { AirArmy8 -> Status = asDestroyed; } } // MARINE 1 if (Marine1 -> Status == asActive || Marine1 -> Status == asSuicide) { Marine1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Marine1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Marine1 -> Insert (i); } } // Pokyn k sebevrazde Marine1 -> CountDangerous (); if (Marine1 -> Dangerous <= CSuicideM1) { Marine1 -> Status = asSuicide; } // Provedeme akce if (Marine1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 if (Marine1 -> Dangerous <= CMinDangM1) { Marine1 -> Status = asDestroyed; } } // MARINE 8 if (Marine8 -> Status == asActive || Marine8 -> Status == asSuicide) { Marine8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Marine8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Marine8 -> Insert (i); } } // Pokyn k sebevrazde Marine8 -> CountDangerous (); if (Marine8 -> Dangerous <= CSuicideM8) { Marine8 -> Status = asSuicide; } // Provedeme akce if (Marine8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 8 if (Marine8 -> Dangerous <= CMinDangM8) { Marine8 -> Status = asDestroyed; } } AttackFieldPos = 0; UnlockDraw (); AllowBadlife (FALSE); return AssignResult (); }
int ArtificialIntelligence9 () { int i, st; Message (SigText[TXT_AI_ANALYSE]); // Prepocitame viditelnost AllowBadlife (TRUE); ComputeVisib (); RedrawMap (); LockDraw (); // Aktualizujeme specialni objekty Factory1 = GetField (F1X, F1Y) -> Unit; if (Factory1 == NO_UNIT || Units [Factory1] -> Type % BADLIFE != unFactory) Factory1 = NO_UNIT; Factory2 = GetField (F2X, F2Y) -> Unit; if (Factory2 == NO_UNIT || Units [Factory2] -> Type % BADLIFE != unFactory) Factory2 = NO_UNIT; // Vyradime znicene jednotky z armad Towers -> DeleteKilled2 (); Towers -> DeleteKilled (); Army1 -> DeleteKilled2 (); Army1 -> DeleteKilled (); Army2 -> DeleteKilled2 (); Army2 -> DeleteKilled (); Army3 -> DeleteKilled2 (); Army3 -> DeleteKilled (); Army4 -> DeleteKilled2 (); Army4 -> DeleteKilled (); Army5 -> DeleteKilled2 (); Army5 -> DeleteKilled (); Army6 -> DeleteKilled2 (); Army6 -> DeleteKilled (); Army7 -> DeleteKilled2 (); Army7 -> DeleteKilled (); Army8 -> DeleteKilled2 (); Army8 -> DeleteKilled (); Army9 -> DeleteKilled2 (); Army9 -> DeleteKilled (); Army10 -> DeleteKilled2 (); Army10 -> DeleteKilled (); DUPos = 0; // Testneme konec hry st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } // Zpracujeme seznam poli, na ktere se utocilo Army1 -> DoAttackedFields (); Army2 -> DoAttackedFields (); Army3 -> DoAttackedFields (); Army4 -> DoAttackedFields (); Army5 -> DoAttackedFields (); Army6 -> DoAttackedFields (); Army7 -> DoAttackedFields (); Army8 -> DoAttackedFields (); Army9 -> DoAttackedFields (); Army10 -> DoAttackedFields (); AttackFieldPos = 0; AnalyseLandscape (); Message (SigText[TXT_AI_ARMY]); //////////////////////////////// AKTIVACE ARMAD // Test zaktivovani armady 1 if (Army1 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Status = asActive; } } } // Test zaktivovani armady 2 if (Army2 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Status = asActive; } } } // Test zaktivovani armady 3 if (Army3 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Status = asActive; } } } // Test zaktivovani armady 4 if (Army4 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Status = asActive; } } } // Test zaktivovani armady 5 if (Army5 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Status = asActive; } } } // Test zaktivovani armady 6 if (Army6 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Status = asActive; ActivationTurn9 = ActualTurn + 1; } } } // Test zaktivovani armady 7 if (Army7 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Status = asActive; } } } // Test zaktivovani armady 8 if (Army8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Status = asActive; ActivationTurn9 = ActualTurn + 1; } } } // Test zaktivovani armady 9 if (Army8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] != NULL && Units [i] -> Y > A9AZY) { ActivationTurn9 = ActualTurn; break; } } } if (ActivationTurn9 == ActualTurn && Army9 -> Status == asSleeping) { Army9 -> Status = asActive; Army9 -> Place (); Army9 -> SetAIConst (3); Army9 -> WayPoint.x = A9WP1X; Army9 -> WayPoint.y = A9WP1Y; } // Test zaktivovani armady 10 if (Army10 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army10 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army10 -> Status = asActive; } } } ///////////////////////////// AKCE ARMAD // Nastavime ProgressBar st = 0; st += Towers -> nofBadLife; if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) st += Army1 -> nofBadLife; if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) st += Army2 -> nofBadLife; if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) st += Army3 -> nofBadLife; if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) st += Army4 -> nofBadLife; if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) st += Army5 -> nofBadLife; if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) st += Army6 -> nofBadLife; if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) st += Army7 -> nofBadLife; if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) st += Army8 -> nofBadLife; if (Army9 -> Status == asActive || Army9 -> Status == asSuicide) st += Army9 -> nofBadLife; if (Army10 -> Status == asActive || Army10 -> Status == asSuicide) st += Army10 -> nofBadLife; if (st == 0) st = 5; // Magic number ProgressNull (); ProgressLimit (st); // Veze if (Towers -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // ARMY 1 if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) { Army1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Insert (i); } } // Pokyn k sebevrazde Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CSuicide1) { Army1 -> Status = asSuicide; } // Provedeme akce if (Army1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CMinDang1) { Army1 -> Status = asDestroyed; } } // ARMY 2 if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) { Army2 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Insert (i); } } // Pokyn k sebevrazde Army2 -> CountDangerous (); if (Army2 -> Dangerous <= CSuicide2) { Army2 -> Status = asSuicide; } // Provedeme akce if (Army2 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 2 if (Army2 -> Dangerous <= CMinDang2) { Army2 -> Status = asDestroyed; } } // ARMY 3 if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) { Army3 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Insert (i); } } // Pokyn k sebevrazde Army3 -> CountDangerous (); if (Army3 -> Dangerous <= CSuicide3) { Army3 -> Status = asSuicide; } // Provedeme akce if (Army3 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 3 if (Army3 -> Dangerous <= CMinDang3) { Army3 -> Status = asDestroyed; } } // ARMY 4 if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) { Army4 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Insert (i); } } // Pokyn k sebevrazde Army4 -> CountDangerous (); if (Army4 -> Dangerous <= CSuicide4) { Army4 -> Status = asSuicide; } // Provedeme akce if (Army4 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 4 if (Army4 -> Dangerous <= CMinDang4) { Army4 -> Status = asDestroyed; } } // ARMY 5 if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) { Army5 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Insert (i); } } // Pokyn k sebevrazde Army5 -> CountDangerous (); if (Army5 -> Dangerous <= CSuicide5) { Army5 -> Status = asSuicide; } // Provedeme akce if (Army5 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 5 if (Army5 -> Dangerous <= CMinDang5) { Army5 -> Status = asDestroyed; } } // ARMY 6 if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) { Army6 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Insert (i); } } // Pokyn k sebevrazde Army6 -> CountDangerous (); if (Army6 -> Dangerous <= CSuicide6) { Army6 -> Status = asSuicide; } // Provedeme akce if (Army6 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (Army6 -> Dangerous <= CMinDang6) { Army6 -> Status = asDestroyed; } } // ARMY 7 if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) { Army7 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Insert (i); } } // Pokyn k sebevrazde Army7 -> CountDangerous (); if (Army7 -> Dangerous <= CSuicide7) { Army7 -> Status = asSuicide; } // Provedeme akce if (Army7 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 7 if (Army7 -> Dangerous <= CMinDang7) { Army7 -> Status = asDestroyed; } } // ARMY 8 if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) { Army8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Insert (i); } } // Pokyn k sebevrazde Army8 -> CountDangerous (); if (Army8 -> Dangerous <= CSuicide8) { Army8 -> Status = asSuicide; } // Provedeme akce if (Army8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 8 if (Army8 -> Dangerous <= CMinDang8) { Army8 -> Status = asDestroyed; } } // ARMY 9 if (Army9 -> Status == asActive || Army9 -> Status == asSuicide) { Army9 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army9 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army9 -> Insert (i); } } // Pokyn k sebevrazde Army9 -> CountDangerous (); if (Army9 -> Dangerous <= CSuicide9) { Army9 -> Status = asSuicide; } // Provedeme akce if (Army9 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 9 if (Army9 -> Dangerous <= CMinDang9) { Army9 -> Status = asDestroyed; } } // ARMY 10 if (Army10 -> Status == asActive || Army10 -> Status == asSuicide) { Army10 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army10 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army10 -> Insert (i); } } // Pokyn k sebevrazde Army10 -> CountDangerous (); if (Army10 -> Dangerous <= CSuicide10) { Army10 -> Status = asSuicide; } // Provedeme akce if (Army10 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 10 if (Army10 -> Dangerous <= CMinDang10) { Army10 -> Status = asDestroyed; } } AttackFieldPos = 0; UnlockDraw (); AllowBadlife (FALSE); return AssignResult (); }
int ArtificialIntelligence7 () { int i, j, r, st, x, y, id; char buf [40]; TBase *Base; TField *f; Message (SigText[TXT_AI_ANALYSE]); // Prepocitame viditelnost AllowBadlife (TRUE); ComputeVisib (); RedrawMap (); LockDraw (); // Aktualizujeme specialni objekty Base6 = GetField (B6X, B6Y) -> Unit; if (Base6 == NO_UNIT || Units [Base6] -> Type % BADLIFE != unBase) Base6 = NO_UNIT; Factory2 = GetField (F2X, F2Y) -> Unit; if (Factory2 == NO_UNIT || Units [Factory2] -> Type % BADLIFE != unFactory) Factory2 = NO_UNIT; Radar2 = GetField (R2X, R2Y) -> Unit; if (Radar2 == NO_UNIT || Units [Radar2] -> Type % BADLIFE != unRadar) Radar2 = NO_UNIT; Radar3 = GetField (R3X, R3Y) -> Unit; if (Radar2 == NO_UNIT || Units [Radar3] -> Type % BADLIFE != unRadar) Radar3 = NO_UNIT; Radar4 = GetField (R4X, R4Y) -> Unit; if (Radar4 == NO_UNIT || Units [Radar4] -> Type % BADLIFE != unRadar) Radar4 = NO_UNIT; Radar5 = GetField (R5X, R5Y) -> Unit; if (Radar5 == NO_UNIT || Units [Radar5] -> Type % BADLIFE != unRadar) Radar5 = NO_UNIT; Radar6 = GetField (R6X, R6Y) -> Unit; if (Radar6 == NO_UNIT || Units [Radar6] -> Type % BADLIFE != unRadar) Radar6 = NO_UNIT; // Vyradime znicene jednotky z armad Towers -> DeleteKilled2 (); Towers -> DeleteKilled (); Army1 -> DeleteKilled2 (); Army1 -> DeleteKilled (); Army2 -> DeleteKilled2 (); Army2 -> DeleteKilled (); Army3 -> DeleteKilled2 (); Army3 -> DeleteKilled (); Army4 -> DeleteKilled2 (); Army4 -> DeleteKilled (); Army5 -> DeleteKilled2 (); Army5 -> DeleteKilled (); Army6 -> DeleteKilled2 (); Army6 -> DeleteKilled (); Army7 -> DeleteKilled2 (); Army7 -> DeleteKilled (); Army8 -> DeleteKilled2 (); Army8 -> DeleteKilled (); DUPos = 0; // Testneme konec hry st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } // Zpracujeme seznam poli, na ktere se utocilo Army1 -> DoAttackedFields (); Army2 -> DoAttackedFields (); Army3 -> DoAttackedFields (); Army4 -> DoAttackedFields (); Army5 -> DoAttackedFields (); Army6 -> DoAttackedFields (); Army7 -> DoAttackedFields (); Army8 -> DoAttackedFields (); AttackFieldPos = 0; AnalyseLandscape (); Message (SigText[TXT_AI_ARMY]); Army1 -> Status = asActive; // Likvidace FACTORY II if ((Factory2 != NO_UNIT) && (Units[Factory2] != NULL) && ( (GetField(P1X,P1Y) -> Visib == 1) || (GetField(P2X,P2Y) -> Visib == 2) ) ) { UnlockDraw (); if ((Pagoda1 != NO_UNIT) && (Units[Pagoda1] != NULL)) { Units[Pagoda1] -> Attack(75, 25); Units[Pagoda1] -> Attack(75, 25); } if ((Pagoda2 != NO_UNIT) && (Units[Pagoda2] != NULL)) { Units[Pagoda2] -> Attack(75, 28); Units[Pagoda2] -> Attack(75, 28); } LockDraw (); } // Test zaktivovani armady 2 if (Army2 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Status = asActive; Army2 -> SetAIConst (1); } } } // Test zaktivovani armady 3 if (Army3 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Status = asActive; Army3 -> SetAIConst (1); } } } // Test zaktivovani armady 4 if (Army4 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Status = asActive; Army4 -> SetAIConst (1); } } } // Test zaktivovani armady 5 if (Army5 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Status = asActive; Army5 -> SetAIConst (2); } } } // Test zaktivovani armady 6 if (Army6 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Status = asActive; Army6 -> SetAIConst (1); } } } // Test zaktivovani armady 7 if (Army7 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Status = asActive; Army7 -> SetAIConst (4); } } } // Test zaktivovani armady 8 if (Army8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Status = asActive; Army8 -> SetAIConst (1); } } } // Presun Olympu a Mohykanu if (ActualTurn == 1) { UnlockDraw(); if ((Mohykan1 != NO_UNIT) && (Units[Mohykan1] != NULL)) { Units[Mohykan1] -> Select (); Units[Mohykan1] -> Move(M1DX, M1DY); if (Units [Mohykan1] != NULL) Army1 -> Insert (Mohykan1); } if ((Mohykan2 != NO_UNIT) && (Units[Mohykan2] != NULL)) { Units[Mohykan2] -> Select (); Units[Mohykan2] -> Move(M2DX, M2DY); if (Units [Mohykan2] != NULL) Army1 -> Insert (Mohykan2); } if ((Mohykan3 != NO_UNIT) && (Units[Mohykan3] != NULL)) { Units[Mohykan3] -> Select (); Units[Mohykan3] -> Move(M3DX, M3DY); if (Units [Mohykan3] != NULL) Army1 -> Insert (Mohykan3); } if ((Mohykan4 != NO_UNIT) && (Units[Mohykan4] != NULL)) { Units[Mohykan4] -> Select (); Units[Mohykan4] -> Move(M4DX, M4DY); if (Units [Mohykan4] != NULL) Army1 -> Insert (Mohykan4); } if ((Olymp1 != NO_UNIT) && (Units[Olymp1] != NULL)) { Units[Olymp1] -> Select (); Units[Olymp1] -> Move(O1DX, O1DY); if (Units [Olymp1] != NULL) Army1 -> Insert (Olymp1); } if ((Olymp2 != NO_UNIT) && (Units[Olymp2] != NULL)) { Units[Olymp2] -> Select (); Units[Olymp2] -> Move(O2DX, O2DY); if (Units [Olymp2] != NULL) Army1 -> Insert (Olymp2); } if ((Olymp3 != NO_UNIT) && (Units[Olymp3] != NULL)) { Units[Olymp3] -> Select (); Units[Olymp3] -> Move(O3DX, O3DY); if (Units [Olymp3] != NULL) Army1 -> Insert (Olymp3); } if ((Olymp4 != NO_UNIT) && (Units[Olymp4] != NULL)) { Units[Olymp4] -> Select (); Units[Olymp4] -> Move(O4DX, O4DY); if (Units [Olymp4] != NULL) Army1 -> Insert (Olymp4); } if ((Mesias1 != NO_UNIT) && (Units [Mesias1] != NULL)) Army1 -> Insert (Mesias1); if ((Ganymedes1 != NO_UNIT) && (Units [Ganymedes1] != NULL)) Army1 -> Insert (Ganymedes1); LockDraw(); } // Dojel Olymp1 - vyklada se... if ((Olymp1 != NO_UNIT) && (Units [Olymp1] != NULL) && IsInRect (Units [Olymp1] -> X, Units [Olymp1] -> Y, O1DX, O1DY, O1DX, O1DY)) { UnlockDraw (); do { if (((TOlymp *) Units [Olymp1]) -> LoadedUnits > 0) { id = ((TOlymp *) Units [Olymp1]) -> Inventory [0]; st = ((TOlymp *) Units [Olymp1]) -> UnloadUnit ((TUnit *)Units [id]); } else st = FALSE; if (st > 0) Army1 -> Insert (id); } while (st == TRUE); LockDraw (); } // Dojel Olymp2 - vyklada se... if ((Olymp2 != NO_UNIT) && (Units [Olymp2] != NULL) && IsInRect (Units [Olymp2] -> X, Units [Olymp2] -> Y, O2DX, O2DY, O2DX, O2DY)) { UnlockDraw (); do { if (((TOlymp *) Units [Olymp2]) -> LoadedUnits > 0) { id = ((TOlymp *) Units [Olymp2]) -> Inventory [0]; st = ((TOlymp *) Units [Olymp2]) -> UnloadUnit ((TUnit *)Units [id]); } else st = FALSE; if (st > 0) Army1 -> Insert (id); } while (st == TRUE); LockDraw (); UnlockDraw(); RedrawMap(); LockDraw(); } // Dojel Olymp3 - vyklada se... if ((Olymp3 != NO_UNIT) && (Units [Olymp3] != NULL) && IsInRect (Units [Olymp3] -> X, Units [Olymp3] -> Y, O3DX, O3DY, O3DX, O3DY)) { UnlockDraw (); do { if (((TOlymp *) Units [Olymp3]) -> LoadedUnits > 0) { id = ((TOlymp *) Units [Olymp3]) -> Inventory [0]; st = ((TOlymp *) Units [Olymp3]) -> UnloadUnit ((TUnit *)Units [id]); } else st = FALSE; if (st > 0) Army1 -> Insert (id); } while (st == TRUE); LockDraw (); UnlockDraw(); RedrawMap(); LockDraw(); } // Dojel Olymp4 - vyklada se... if ((Olymp4 != NO_UNIT) && (Units [Olymp4] != NULL) && IsInRect (Units [Olymp4] -> X, Units [Olymp4] -> Y, O4DX, O4DY, O4DX, O4DY)) { UnlockDraw (); do { if (((TOlymp *) Units [Olymp4]) -> LoadedUnits > 0) { id = ((TOlymp *) Units [Olymp4]) -> Inventory [0]; st = ((TOlymp *) Units [Olymp4]) -> UnloadUnit ((TUnit *)Units [id]); } else st = FALSE; if (st > 0) Army1 -> Insert (id); } while (st == TRUE); LockDraw (); UnlockDraw(); RedrawMap(); LockDraw(); } ComputeVisib (); // Nastavime ProgressBar st = 0; st += Towers -> nofBadLife; if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) st += Army1 -> nofBadLife; if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) st += Army2 -> nofBadLife; if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) st += Army3 -> nofBadLife; if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) st += Army4 -> nofBadLife; if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) st += Army5 -> nofBadLife; if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) st += Army6 -> nofBadLife; if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) st += Army7 -> nofBadLife; if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) st += Army8 -> nofBadLife; if (st == 0) st = 5; // Magic number ProgressNull (); ProgressLimit (st); // Veze if (Towers -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // ARMY 1 if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) { Army1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Insert (i); } } // Pokyn k sebevrazde Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CSuicide1) { Army1 -> Status = asSuicide; } // Provedeme akce if (Army1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CMinDang1) { Army1 -> Status = asDestroyed; } } // ARMY 2 if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) { Army2 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Insert (i); } } // Pokyn k sebevrazde Army2 -> CountDangerous (); if (Army2 -> Dangerous <= CSuicide2) { Army2 -> Status = asSuicide; } // Provedeme akce if (Army2 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 2 if (Army2 -> Dangerous <= CMinDang2) { Army2 -> Status = asDestroyed; } } // ARMY 3 if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) { Army3 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Insert (i); } } // Pokyn k sebevrazde Army3 -> CountDangerous (); if (Army3 -> Dangerous <= CSuicide3) { Army3 -> Status = asSuicide; } // Provedeme akce if (Army3 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 3 if (Army3 -> Dangerous <= CMinDang3) { Army3 -> Status = asDestroyed; } } // ARMY 4 if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) { Army4 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Insert (i); } } // Pokyn k sebevrazde Army4 -> CountDangerous (); if (Army4 -> Dangerous <= CSuicide4) { Army4 -> Status = asSuicide; } // Provedeme akce if (Army4 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 4 if (Army4 -> Dangerous <= CMinDang4) { Army4 -> Status = asDestroyed; } } // ARMY 5 if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) { Army5 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Insert (i); } } // Pokyn k sebevrazde Army5 -> CountDangerous (); if (Army5 -> Dangerous <= CSuicide5) { Army5 -> Status = asSuicide; } // Provedeme akce if (Army5 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 5 if (Army5 -> Dangerous <= CMinDang4) { Army5 -> Status = asDestroyed; } } // ARMY 6 if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) { Army6 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Insert (i); } } // Pokyn k sebevrazde Army6 -> CountDangerous (); if (Army6 -> Dangerous <= CSuicide6) { Army6 -> Status = asSuicide; } // Provedeme akce if (Army6 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (Army6 -> Dangerous <= CMinDang6) { Army6 -> Status = asDestroyed; } } // ARMY 7 if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) { Army7 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Insert (i); } } // Pokyn k sebevrazde Army7 -> CountDangerous (); if (Army7 -> Dangerous <= CSuicide7) { Army7 -> Status = asSuicide; } // Provedeme akce if (Army7 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 7 if (Army7 -> Dangerous <= CMinDang6) { Army7 -> Status = asDestroyed; } } // ARMY 8 if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) { Army8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Insert (i); } } // Pokyn k sebevrazde Army8 -> CountDangerous (); if (Army8 -> Dangerous <= CSuicide8) { Army8 -> Status = asSuicide; } // Provedeme akce if (Army8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 8 if (Army8 -> Dangerous <= CMinDang6) { Army8 -> Status = asDestroyed; } } AttackFieldPos = 0; UnlockDraw (); AllowBadlife (FALSE); // LockDraw(); return AssignResult (); }
int ArtificialIntelligence5 () { int i, j, k, r, st, x, y, id; TPoint p; char buf [40]; TBase *Base; TField *f; Message (SigText[TXT_AI_ANALYSE]); // Prepocitame viditelnost AllowBadlife (TRUE); ComputeVisib (); RedrawMap (); LockDraw (); // Aktualizujeme specialni objekty Base1 = GetField (B1X, B1Y) -> Unit; if (Base1 == NO_UNIT || Units [Base1] -> Type % BADLIFE != unBase) Base1 = NO_UNIT; Base8 = GetField (B8X, B8Y) -> Unit; if (Base8 == NO_UNIT || Units [Base8] -> Type % BADLIFE != unBase) Base8 = NO_UNIT; Radar1 = GetField (R1X, R1Y) -> Unit; if (Radar1 == NO_UNIT || Units [Radar1] -> Type % BADLIFE != unRadar) Radar1 = NO_UNIT; Radar2 = GetField (R2X, R2Y) -> Unit; if (Radar2 == NO_UNIT || Units [Radar2] -> Type % BADLIFE != unRadar) Radar2 = NO_UNIT; Radar4 = GetField (R4X, R4Y) -> Unit; if (Radar4 == NO_UNIT || Units [Radar4] -> Type % BADLIFE != unRadar) Radar4 = NO_UNIT; Radar5 = GetField (R5X, R5Y) -> Unit; if (Radar5 == NO_UNIT || Units [Radar5] -> Type % BADLIFE != unRadar) Radar5 = NO_UNIT; Radar8 = GetField (R8X, R8Y) -> Unit; if (Radar8 == NO_UNIT || Units [Radar8] -> Type % BADLIFE != unRadar) Radar8 = NO_UNIT; Factory8 = GetField (F8X, F8Y) -> Unit; if (Factory8 == NO_UNIT || Units [Factory8] -> Type % BADLIFE != unFactory) Factory8 = NO_UNIT; Airport1 = GetField (A1X, A1Y) -> Unit; if (Airport1 == NO_UNIT || Units [Airport1] -> Type % BADLIFE != unAirport) Airport1 = NO_UNIT; Airport8 = GetField (A8X, A8Y) -> Unit; if (Airport8 == NO_UNIT || Units [Airport8] -> Type % BADLIFE != unAirport) Airport8 = NO_UNIT; // Vyradime znicene jednotky z armad Towers -> DeleteKilled2 (); Towers -> DeleteKilled (); Army1 -> DeleteKilled2 (); Army1 -> DeleteKilled (); AirArmy1 -> DeleteKilled2 (); AirArmy1 -> DeleteKilled (); Army2 -> DeleteKilled2 (); Army2 -> DeleteKilled (); Army3 -> DeleteKilled2 (); Army3 -> DeleteKilled (); Army4 -> DeleteKilled2 (); Army4 -> DeleteKilled (); Army5 -> DeleteKilled2 (); Army5 -> DeleteKilled (); Army6 -> DeleteKilled2 (); Army6 -> DeleteKilled (); Army7 -> DeleteKilled2 (); Army7 -> DeleteKilled (); Army8 -> DeleteKilled2 (); Army8 -> DeleteKilled (); AirArmy8 -> DeleteKilled2 (); AirArmy8 -> DeleteKilled (); DUPos = 0; // Testneme konec hry st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } // Zpracujeme seznam poli, na ktere se utocilo Army1 -> DoAttackedFields (); AirArmy1 -> DoAttackedFields (); Army2 -> DoAttackedFields (); Army3 -> DoAttackedFields (); Army4 -> DoAttackedFields (); Army5 -> DoAttackedFields (); Army6 -> DoAttackedFields (); Army7 -> DoAttackedFields (); Army8 -> DoAttackedFields (); AirArmy8 -> DoAttackedFields (); AttackFieldPos = 0; AnalyseLandscape (); Message (SigText[TXT_AI_ARMY]); //////////////////////////////// AKTIVACE ARMAD // Test zaktivovani armady 1 if (Army1 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Status = asActive; } } } // Test zaktivovani armady 2 if (Army2 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Status = asActive; Army2 -> SetAIConst (2); // AGRESIVE ARMY } } } if (Army2 -> Status == asActive) { if (Army2 -> Dangerous <= A2Escape && Army2 -> WayPoint.x == -1) { Army2 -> SetAIConst (3); // MOVING ARMY Army2 -> WayPoint.x = A2WP1X; Army2 -> WayPoint.y = A2WP1Y; } if (Army2 -> IsAtWP () && Army2 -> WayPoint.x == A2WP1X && Army2 -> WayPoint.y == A2WP1Y) { Army2 -> WayPoint.x = A2WP2X; Army2 -> WayPoint.y = A2WP2Y; } if (Army2 -> IsAtWP () && Army2 -> WayPoint.x == A2WP2X && Army2 -> WayPoint.y == A2WP2Y) { Army2 -> SetAIConst (1); Xenon3ActivationTurn = ActualTurn; } } // Test zaktivovani armady 3 if (Army3 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Status = asActive; } } } // Test zaktivovani armady 4 if (Army4 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Status = asActive; } } } // Test zaktivovani armady 5 if (Army5 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Status = asActive; } } } // Test zaktivovani armady 6 if (Army6 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Status = asActive; } } } // Test zaktivovani armady 7 if (Army7 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Status = asActive; } } } // Test zaktivovani armady 8 if (Army8 -> Status == asSleeping) { for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Status = asActive; } } } ///////////////////////////// AKCE ARMAD // Nastavime ProgressBar st = 0; st += Towers -> nofBadLife; if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) st += Army1 -> nofBadLife; if (AirArmy1 -> Status == asActive || AirArmy1 -> Status == asSuicide) st += AirArmy1 -> nofBadLife; if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) st += Army2 -> nofBadLife; if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) st += Army3 -> nofBadLife; if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) st += Army4 -> nofBadLife; if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) st += Army5 -> nofBadLife; if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) st += Army6 -> nofBadLife; if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) st += Army7 -> nofBadLife; if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) st += Army8 -> nofBadLife; if (AirArmy8 -> Status == asActive || AirArmy8 -> Status == asSuicide) st += AirArmy8 -> nofBadLife; if (st == 0) st = 5; // Magic number ProgressNull (); ProgressLimit (st); // Vylozime letiste UnlockDraw (); for (i = BADLIFE; i < UNITS_TOP; i++){ // Airport if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unAirport) { for (j = 0; j < ((TAirport *) Units [i]) -> LoadedUnits; j++) { id = ((TAirport *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((TAirport *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } // Heliport if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unHeliport) { for (j = 0; j < ((THeliport *) Units [i]) -> LoadedUnits; j++) { id = ((THeliport *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((THeliport *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } // Laguna if (Units [i] != NULL && Units [i] -> Type - BADLIFE == unLaguna) { for (j = 0; j < ((TLaguna *) Units [i]) -> LoadedUnits; j++) { id = ((TLaguna *)Units [i]) -> Inventory [j]; if (Units [id] -> AI_Info.State == aistFuel) { st = ((TLaguna *)Units [i]) -> UnloadUnit ((TUnit *)Units [id]); if (st == 1) { j--; Units [id] -> AI_Info.State = aistNought; for (k = 120; k > 1; k--) { p = CartezianSnail (k); p.x += Units [id] -> X; p.y += Units [id] -> Y; if (p.x >= 0 && p.x < MapSizeX && p.y >= 0 && p.y < MapSizeY && GetAircraftAt (p.x, p.y) == NULL) { Units [id] -> Select (); st = Units [id] -> MoveFar (p.x, p.y); if (st == 1) break; } } } } } } } LockDraw (); // Veze if (Towers -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // ARMY 1 if (Army1 -> Status == asActive || Army1 -> Status == asSuicide) { Army1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army1 -> Insert (i); } } // Pokyn k sebevrazde Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CSuicide1) { Army1 -> Status = asSuicide; } // Provedeme akce if (Army1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 Army1 -> CountDangerous (); if (Army1 -> Dangerous <= CMinDang1) { Army1 -> Status = asDestroyed; } } if (AirArmy1 -> Status == asActive || AirArmy1 -> Status == asSuicide) { AirArmy1 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (AirArmy1 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { AirArmy1 -> Insert (i); } } // Pokyn k sebevrazde AirArmy1 -> CountDangerous (); if (AirArmy1 -> Dangerous <= CSuicideA1) { AirArmy1 -> Status = asSuicide; } // Provedeme akce if (AirArmy1 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 1 AirArmy1 -> CountDangerous (); if (AirArmy1 -> Dangerous <= CMinDangA1) { AirArmy1 -> Status = asDestroyed; } } // ARMY 2 if (Army2 -> Status == asActive || Army2 -> Status == asSuicide) { Army2 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army2 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army2 -> Insert (i); } } // Pokyn k sebevrazde Army2 -> CountDangerous (); if (Army2 -> Dangerous <= CSuicide2) { Army2 -> Status = asSuicide; } // Provedeme akce if (Army2 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 2 if (Army2 -> Dangerous <= CMinDang2) { Army2 -> Status = asDestroyed; } } // ARMY 3 if (Army3 -> Status == asActive || Army3 -> Status == asSuicide) { Army3 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army3 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army3 -> Insert (i); } } // Pokyn k sebevrazde Army3 -> CountDangerous (); if (Army3 -> Dangerous <= CSuicide3) { Army3 -> Status = asSuicide; } // Provedeme akce if (Army3 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 3 if (Army3 -> Dangerous <= CMinDang3) { Army3 -> Status = asDestroyed; } } // ARMY 4 if (Army4 -> Status == asActive || Army4 -> Status == asSuicide) { Army4 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army4 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army4 -> Insert (i); } } // Pokyn k sebevrazde Army4 -> CountDangerous (); if (Army4 -> Dangerous <= CSuicide4) { Army4 -> Status = asSuicide; } // Provedeme akce if (Army4 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 4 if (Army4 -> Dangerous <= CMinDang4) { Army4 -> Status = asDestroyed; } } // ARMY 5 if (Army5 -> Status == asActive || Army5 -> Status == asSuicide) { Army5 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army5 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army5 -> Insert (i); } } // Pokyn k sebevrazde Army5 -> CountDangerous (); if (Army5 -> Dangerous <= CSuicide5) { Army5 -> Status = asSuicide; } // Provedeme akce if (Army5 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 5 if (Army5 -> Dangerous <= CMinDang5) { Army5 -> Status = asDestroyed; } } // ARMY 6 if (Army6 -> Status == asActive || Army6 -> Status == asSuicide) { Army6 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army6 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army6 -> Insert (i); } } // Pokyn k sebevrazde Army6 -> CountDangerous (); if (Army6 -> Dangerous <= CSuicide6) { Army6 -> Status = asSuicide; } // Provedeme akce if (Army6 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 6 if (Army6 -> Dangerous <= CMinDang6) { Army6 -> Status = asDestroyed; } } // ARMY 7 if (Army7 -> Status == asActive || Army7 -> Status == asSuicide) { Army7 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army7 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army7 -> Insert (i); } } // Pokyn k sebevrazde Army7 -> CountDangerous (); if (Army7 -> Dangerous <= CSuicide7) { Army7 -> Status = asSuicide; } // Provedeme akce if (Army7 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 7 if (Army7 -> Dangerous <= CMinDang7) { Army7 -> Status = asDestroyed; } } // ARMY 8 if (Army8 -> Status == asActive || Army8 -> Status == asSuicide) { Army8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { Army8 -> Insert (i); } } // Pokyn k sebevrazde Army8 -> CountDangerous (); if (Army8 -> Dangerous <= CSuicide8) { Army8 -> Status = asSuicide; } // Provedeme akce if (Army8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 8 if (Army8 -> Dangerous <= CMinDang8) { Army8 -> Status = asDestroyed; } } // AIR ARMY 8 if (AirArmy8 -> Status == asActive || AirArmy8 -> Status == asSuicide) { AirArmy8 -> DeleteKilled (); // Zarazeni novych nepratel (GL) for (i = 0; i < BADLIFE; i++) { if (Units [i] == NULL) continue; if (Army8 -> IsInVisualRange (Units [i] -> X, Units [i] -> Y)) { AirArmy8 -> Insert (i); } } // Pokyn k sebevrazde AirArmy8 -> CountDangerous (); if (AirArmy8 -> Dangerous <= CSuicide8) { AirArmy8 -> Status = asSuicide; } // Provedeme akce if (AirArmy8 -> MakeTurn () == FALSE) { st = AssignResult (); if (st != 0) { UnlockDraw (); AllowBadlife (FALSE); return st; } } // Likvidace armady 8 if (AirArmy8 -> Dangerous <= CMinDang8) { AirArmy8 -> Status = asDestroyed; } } // Xenon 3 if (Xenon3 != NO_UNIT && Units [Xenon3] != NULL && Units [Xenon3] -> Type - BADLIFE == unXenon && Xenon3ActivationTurn <= ActualTurn && X3MineCnt >= 0) { for (i = X3MineCnt; Xenon3Mines [i].x != -1; i++) { UnlockDraw (); st = ((TXenon *)Units [Xenon3]) -> MoveFar (Xenon3Mines [i].x, Xenon3Mines [i].y); if (Units [Xenon3] == NULL) { LockDraw (); // Jednotka znicena break; } if (st) { st = ((TXenon *)Units [Xenon3]) -> PlaceMine (); if (st) { X3MineCnt++; if (X3MineCnt == 3) ((TXenon *)Units [Xenon3]) -> MoveFar (A2WP2X, A2WP2Y); } } LockDraw (); } } AttackFieldPos = 0; UnlockDraw (); AllowBadlife (FALSE); return AssignResult (); }