00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <weapons/Shield.h>
00022 #include <common/VectorLib.h>
00023 #include <common/Defines.h>
00024 #include <math.h>
00025
00026 Shield::Shield() :
00027 laserProof_(ShieldLaserProofNone),
00028 movementProof_(ShieldMovementAll)
00029 {
00030 }
00031
00032 Shield::~Shield()
00033 {
00034 }
00035
00036 bool Shield::parseXML(AccessoryCreateContext &context, XMLNode *accessoryNode)
00037 {
00038
00039 if (!accessoryNode->getNamedChild("removepower", removePower_)) return false;
00040
00041
00042 if (!accessoryNode->getNamedChild("penetration", penetration_)) return false;
00043
00044
00045 if (!accessoryNode->getNamedChild("power", power_)) return false;
00046
00047
00048 if (!accessoryNode->getNamedChild("collisionsound", collisionSound_)) return false;
00049 if (!S3D::checkDataFile(S3D::formatStringBuffer("data/wav/%s", getCollisionSound()))) return false;
00050
00051
00052 XMLNode *colorNode = 0;
00053 if (!accessoryNode->getNamedChild("color", colorNode)) return false;
00054 if (!colorNode->getNamedChild("r", color_[0])) return false;
00055 if (!colorNode->getNamedChild("g", color_[1])) return false;
00056 if (!colorNode->getNamedChild("b", color_[2])) return false;
00057
00058 std::string laserproof;
00059 if (accessoryNode->getNamedChild("laserproof", laserproof, false))
00060 {
00061 if (0 == strcmp(laserproof.c_str(), "false"))
00062 laserProof_ = ShieldLaserProofNone;
00063 else if (0 == strcmp(laserproof.c_str(), "true"))
00064 laserProof_ = ShieldLaserProofStop;
00065 else if (0 == strcmp(laserproof.c_str(), "total"))
00066 laserProof_ = ShieldLaserProofTotal;
00067 else return accessoryNode->returnError("Unknown laserproof type");
00068 }
00069
00070 std::string movementproof;
00071 if (accessoryNode->getNamedChild("movementproof", movementproof, false))
00072 {
00073 if (0 == strcmp(movementproof.c_str(), "false"))
00074 movementProof_ = ShieldMovementAll;
00075 else if (0 == strcmp(movementproof.c_str(), "true"))
00076 movementProof_ = ShieldMovementSame;
00077 else if (0 == strcmp(movementproof.c_str(), "none"))
00078 movementProof_ = ShieldMovementNone;
00079 else if (0 == strcmp(movementproof.c_str(), "team1"))
00080 movementProof_ = ShieldMovementTeam1;
00081 else if (0 == strcmp(movementproof.c_str(), "team2"))
00082 movementProof_ = ShieldMovementTeam2;
00083 else if (0 == strcmp(movementproof.c_str(), "team3"))
00084 movementProof_ = ShieldMovementTeam3;
00085 else if (0 == strcmp(movementproof.c_str(), "team4"))
00086 movementProof_ = ShieldMovementTeam4;
00087 else return accessoryNode->returnError("Unknown movementproof type");
00088 }
00089
00090 return true;
00091 }
00092
00093 const char *Shield::getCollisionSound()
00094 {
00095 if (!collisionSound_.c_str()[0]) return 0;
00096 return collisionSound_.c_str();
00097 }