WeaponLightning.cpp

Go to the documentation of this file.
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 <weapons/WeaponLightning.h>
00022 #include <weapons/AccessoryStore.h>
00023 #include <engine/ActionController.h>
00024 #include <actions/Lightning.h>
00025 #include <common/Defines.h>
00026 
00027 REGISTER_ACCESSORY_SOURCE(WeaponLightning);
00028 
00029 WeaponLightning::WeaponLightning()
00030 {
00031 }
00032 
00033 WeaponLightning::~WeaponLightning()
00034 {
00035 }
00036 
00037 bool WeaponLightning::parseXML(AccessoryCreateContext &context, XMLNode *accessoryNode)
00038 {
00039         if (!Weapon::parseXML(context, accessoryNode)) return false;
00040         if (!accessoryNode->getNamedChild("conelength", coneLengthExp_)) return false;
00041         if (!accessoryNode->getNamedChild("seglength", segLengthExp_)) return false;
00042         if (!accessoryNode->getNamedChild("segvar", segVarExp_)) return false;
00043         if (!accessoryNode->getNamedChild("size", sizeExp_)) return false;
00044         if (!accessoryNode->getNamedChild("sizevar", sizeVarExp_)) return false;
00045         if (!accessoryNode->getNamedChild("minsize", minSizeExp_)) return false;
00046         if (!accessoryNode->getNamedChild("splitprob", splitProbExp_)) return false;
00047         if (!accessoryNode->getNamedChild("splitvar", splitVarExp_)) return false;
00048         if (!accessoryNode->getNamedChild("deathprob", deathProbExp_)) return false;
00049         if (!accessoryNode->getNamedChild("derivangle", derivAngleExp_)) return false;
00050         if (!accessoryNode->getNamedChild("anglevar", angleVarExp_)) return false;
00051         if (!accessoryNode->getNamedChild("totaltime", totalTimeExp_)) return false;
00052         if (!accessoryNode->getNamedChild("seghurt", segHurtExp_)) return false;
00053         if (!accessoryNode->getNamedChild("seghurtradius", segHurtRadiusExp_)) return false;
00054         if (!accessoryNode->getNamedChild("sound", sound_)) return false;
00055 
00056         texture_ = "data/textures/lightning.bmp";
00057         accessoryNode->getNamedChild("texture", texture_, false);
00058 
00059         if (!S3D::checkDataFile(getSound())) return false;
00060         return true;
00061 }
00062 
00063 void WeaponLightning::fireWeapon(ScorchedContext &context,
00064         WeaponFireContext &weaponContext, FixedVector &position, FixedVector &velocity)
00065 {
00066         coneLength_ = coneLengthExp_.getValue(context);
00067         segLength_ = segLengthExp_.getValue(context);
00068         segVar_ = segVarExp_.getValue(context);
00069         size_ = sizeExp_.getValue(context);
00070         sizeVar_ = sizeVarExp_.getValue(context);
00071         minSize_ = minSizeExp_.getValue(context);
00072         splitProb_ = splitProbExp_.getValue(context);
00073         splitVar_ = splitVarExp_.getValue(context);
00074         deathProb_ = deathProbExp_.getValue(context);
00075         derivAngle_ = derivAngleExp_.getValue(context);
00076         angleVar_ = angleVarExp_.getValue(context);
00077         totalTime_ = totalTimeExp_.getValue(context);
00078         segHurt_ = segHurtExp_.getValue(context);
00079         segHurtRadius_ = segHurtRadiusExp_.getValue(context);
00080 
00081         Action *action = new Lightning(
00082                 this, weaponContext, position, velocity); 
00083         context.getActionController().addAction(action);        
00084 }
00085 

Generated on Mon Feb 16 15:14:52 2009 for Scorched3D by  doxygen 1.5.3