00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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