____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 2002-2005 by Lutz Sammer, Joris Dauphin 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 // 00028 00030 00031 /*---------------------------------------------------------------------------- 00032 -- Includes 00033 ----------------------------------------------------------------------------*/ 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 00038 #include "stratagus.h" 00039 #include "unittype.h" 00040 #include "unit.h" 00041 #include "spells.h" 00042 #include "actions.h" 00043 #include "map.h" 00044 #include "ai_local.h" 00045 #include "player.h" 00046 00047 /*---------------------------------------------------------------------------- 00048 -- Functions 00049 ----------------------------------------------------------------------------*/ 00050 00055 void AiCheckMagic(void) 00056 { 00057 int i; 00058 unsigned int j; 00059 int n; 00060 CUnit **units; 00061 CUnit *unit; 00062 const CPlayer *player; 00063 #ifdef DEBUG 00064 int success; 00065 #endif 00066 00067 n = AiPlayer->Player->TotalNumUnits; 00068 units = AiPlayer->Player->Units; 00069 player = AiPlayer->Player; /*units[0]->Player */ 00070 for (i = 0; i < n; ++i) { 00071 unit = units[i]; 00072 // Check only magic units 00073 if (unit->Type->CanCastSpell) { 00074 for (j = 0; j < SpellTypeTable.size(); ++j) { 00075 // Check if we can cast this spell. SpellIsAvailable checks for upgrades. 00076 if (unit->Type->CanCastSpell[j] && SpellIsAvailable(player, j) && 00077 (SpellTypeTable[j]->AutoCast || SpellTypeTable[j]->AICast)) { 00078 #ifdef DEBUG 00079 success = // Follow on next line (AutoCastSpell). 00080 #endif 00081 AutoCastSpell(unit, SpellTypeTable[j]); 00082 } 00083 } 00084 } 00085 } 00086 } 00087
1.5.6