00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <actions/NapalmParams.h>
00022 #include <lua/LUAUtil.h>
00023 #include <XML/XMLNode.h>
00024
00025 NapalmParams::NapalmParams() :
00026 napalmTime_(8),
00027 napalmHeight_(2),
00028 stepTime_(fixed(true, 1000)),
00029 hurtStepTime_(2),
00030 hurtPerSecond_(1),
00031 groundScorchPer_(fixed(true, 2000)),
00032 effectRadius_(5),
00033 noSmoke_(false),
00034 noObjectDamage_(false),
00035 allowUnderWater_(false),
00036 luminance_(true),
00037 singleFlow_(true),
00038 napalmTexture_("flames"),
00039 deformTexture_(""),
00040 numberParticles_(100)
00041 {
00042 }
00043
00044 NapalmParams::~NapalmParams()
00045 {
00046 }
00047
00048 bool NapalmParams::parseXML(XMLNode *accessoryNode)
00049 {
00050
00051 if (!accessoryNode->getNamedChild("effectradius", effectRadius_)) return false;
00052 if (!accessoryNode->getNamedChild("napalmtexture", napalmTexture_)) return false;
00053 if (!accessoryNode->getNamedChild("allowunderwater", allowUnderWater_)) return false;
00054
00055 accessoryNode->getNamedChild("numberparticles", numberParticles_, false);
00056
00057
00058 XMLNode *noLuminanceNode = 0; luminance_ = true;
00059 accessoryNode->getNamedChild("noluminance", noLuminanceNode, false);
00060 if (noLuminanceNode) luminance_ = false;
00061
00062 XMLNode *noSingleFlowNode = 0; singleFlow_ = true;
00063 accessoryNode->getNamedChild("nosingleflow", noSingleFlowNode, false);
00064 if (noSingleFlowNode) singleFlow_ = false;
00065
00066
00067 if (accessoryNode->getNamedChild("deformtexture", deformTexture_, false))
00068 {
00069 if (!S3D::checkDataFile(getDeformTexture())) return false;
00070 }
00071
00072
00073 XMLNode *noSmokeNode = 0, *noObjectDamageNode = 0;
00074 accessoryNode->getNamedChild("groundscorchper", groundScorchPer_, false);
00075 accessoryNode->getNamedChild("nosmoke", noSmokeNode, false);
00076 accessoryNode->getNamedChild("noobjectdamage", noObjectDamageNode, false);
00077 if (noSmokeNode) noSmoke_ = true;
00078 if (noObjectDamageNode) noObjectDamage_ = true;
00079
00080 return true;
00081 }
00082
00083 void NapalmParams::parseLUA(lua_State *L, int position)
00084 {
00085 luaL_checktype(L, position, LUA_TTABLE);
00086
00087 napalmTime_ = LUAUtil::getNumberFromTable(L, position, "napalmtime", napalmTime_);
00088 napalmHeight_ = LUAUtil::getNumberFromTable(L, position, "napalmheight", napalmHeight_);
00089 stepTime_ = LUAUtil::getNumberFromTable(L, position, "steptime", stepTime_);
00090 hurtStepTime_ = LUAUtil::getNumberFromTable(L, position, "hurtsteptime", hurtStepTime_);
00091 hurtPerSecond_ = LUAUtil::getNumberFromTable(L, position, "hurtpersecond", hurtPerSecond_);
00092 groundScorchPer_ = LUAUtil::getNumberFromTable(L, position, "groundscorchper", groundScorchPer_);
00093 effectRadius_ = LUAUtil::getIntFromTable(L, position, "effectradius", effectRadius_);
00094 numberParticles_ = LUAUtil::getIntFromTable(L, position, "numberparticles", numberParticles_);
00095 noSmoke_ = LUAUtil::getBoolFromTable(L, position, "nosmoke", noSmoke_);
00096 noObjectDamage_ = LUAUtil::getBoolFromTable(L, position, "noobjectdamage", noObjectDamage_);
00097 allowUnderWater_ = LUAUtil::getBoolFromTable(L, position, "allowunderwater", allowUnderWater_);
00098 luminance_ = LUAUtil::getBoolFromTable(L, position, "luminance", luminance_);
00099 singleFlow_ = LUAUtil::getBoolFromTable(L, position, "singleflow", singleFlow_);
00100 napalmTexture_ = LUAUtil::getStringFromTable(L, position, "napalmtexture", napalmTexture_);
00101 deformTexture_ = LUAUtil::getStringFromTable(L, position, "deformtexture", deformTexture_);
00102 }