00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #include <tankai/TankAICurrentMoveWeapons.h> 00022 #include <tank/Tank.h> 00023 #include <tank/TankPosition.h> 00024 #include <target/TargetShield.h> 00025 #include <target/TargetParachute.h> 00026 #include <server/ScorchedServer.h> 00027 #include <landscapedef/LandscapeTex.h> 00028 #include <landscapemap/LandscapeMaps.h> 00029 #include <weapons/Accessory.h> 00030 #include <weapons/WeaponNapalm.h> 00031 #include <weapons/Shield.h> 00032 00033 TankAICurrentMoveWeapons::TankAICurrentMoveWeapons(Tank *tank, 00034 Tank *targetTank, 00035 TankAIWeaponSets::WeaponSet *weapons) 00036 { 00037 // Check if this target has shields 00038 shield = 0; 00039 if (targetTank->getShield().getCurrentShield()) 00040 { 00041 shield = (Shield *) targetTank->getShield(). 00042 getCurrentShield()->getAction(); 00043 } 00044 00045 // Normal weapons 00046 small = weapons->getTankAccessoryByType(tank, "explosionsmall"); 00047 large = weapons->getTankAccessoryByType(tank, "explosionlarge"); 00048 roller = weapons->getTankAccessoryByType(tank, "roller"); 00049 uncover = weapons->getTankAccessoryByType(tank, "uncover"); 00050 00051 // Check for being under water 00052 fixed waterHeight = -10; 00053 LandscapeTex &tex = *ScorchedServer::instance()->getLandscapeMaps().getDefinitions().getTex(); 00054 if (tex.border->getType() == LandscapeTexType::eWater) 00055 { 00056 LandscapeTexBorderWater *water = 00057 (LandscapeTexBorderWater *) tex.border; 00058 00059 waterHeight = water->height; 00060 } 00061 napalm = 0; 00062 if (targetTank->getPosition().getTankPosition()[2] > waterHeight) 00063 { 00064 napalm = weapons->getTankAccessoryByType(tank, "napalm"); 00065 } 00066 00067 // Check for laser proof shields 00068 laser = 0; 00069 if (!shield || 00070 shield->getLaserProof() == Shield::ShieldLaserProofNone) 00071 { 00072 laser = weapons->getTankAccessoryByType(tank, "laser"); 00073 } 00074 00075 // Check for having parachutes 00076 // Cheating!!, need a better way for this 00077 digger = 0; 00078 if (!targetTank->getParachute().getCurrentParachute()) 00079 { 00080 digger = weapons->getTankAccessoryByType(tank, "digger"); 00081 } 00082 } 00083 00084 TankAICurrentMoveWeapons::~TankAICurrentMoveWeapons() 00085 { 00086 } 00087
1.5.3