1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <tankai/TankAICurrentMoveWeapons.h>
22 #include <tank/Tank.h>
23 #include <tank/TankPosition.h>
24 #include <target/TargetShield.h>
25 #include <target/TargetParachute.h>
26 #include <server/ScorchedServer.h>
27 #include <landscapedef/LandscapeTex.h>
28 #include <landscapemap/LandscapeMaps.h>
29 #include <weapons/Accessory.h>
30 #include <weapons/WeaponNapalm.h>
31 #include <weapons/Shield.h>
33 TankAICurrentMoveWeapons::TankAICurrentMoveWeapons(Tank
*tank
,
35 TankAIWeaponSets::WeaponSet
*weapons
)
37 // Check if this target has shields
39 if (targetTank
->getShield().getCurrentShield())
41 shield
= (Shield
*) targetTank
->getShield().
42 getCurrentShield()->getAction();
46 small
= weapons
->getTankAccessoryByType(tank
, "explosionsmall");
47 large
= weapons
->getTankAccessoryByType(tank
, "explosionlarge");
48 roller
= weapons
->getTankAccessoryByType(tank
, "roller");
49 uncover
= weapons
->getTankAccessoryByType(tank
, "uncover");
51 // Check for being under water
52 fixed waterHeight
= -10;
53 LandscapeTex
&tex
= *ScorchedServer::instance()->getLandscapeMaps().getDefinitions().getTex();
54 if (tex
.border
->getType() == LandscapeTexType::eWater
)
56 LandscapeTexBorderWater
*water
=
57 (LandscapeTexBorderWater
*) tex
.border
;
59 waterHeight
= water
->height
;
62 if (targetTank
->getPosition().getTankPosition()[2] > waterHeight
)
64 napalm
= weapons
->getTankAccessoryByType(tank
, "napalm");
67 // Check for laser proof shields
70 shield
->getLaserProof() == Shield::ShieldLaserProofNone
)
72 laser
= weapons
->getTankAccessoryByType(tank
, "laser");
75 // Check for having parachutes
76 // Cheating!!, need a better way for this
78 if (!targetTank
->getParachute().getCurrentParachute())
80 digger
= weapons
->getTankAccessoryByType(tank
, "digger");
84 TankAICurrentMoveWeapons::~TankAICurrentMoveWeapons()