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 <actions/NapalmParams.h>
22 #include <lua/LUAUtil.h>
23 #include <XML/XMLNode.h>
25 NapalmParams::NapalmParams() :
28 stepTime_(fixed(true, 1000)),
31 groundScorchPer_(fixed(true, 2000)),
34 noObjectDamage_(false),
35 allowUnderWater_(false),
38 napalmTexture_("flames"),
44 NapalmParams::~NapalmParams()
48 bool NapalmParams::parseXML(XMLNode
*accessoryNode
)
50 // Mandatory Attributes
51 if (!accessoryNode
->getNamedChild("effectradius", effectRadius_
)) return false;
52 if (!accessoryNode
->getNamedChild("napalmtexture", napalmTexture_
)) return false;
53 if (!accessoryNode
->getNamedChild("allowunderwater", allowUnderWater_
)) return false;
55 accessoryNode
->getNamedChild("numberparticles", numberParticles_
, false);
57 // Get the optional luminance node
58 XMLNode
*noLuminanceNode
= 0; luminance_
= true;
59 accessoryNode
->getNamedChild("noluminance", noLuminanceNode
, false);
60 if (noLuminanceNode
) luminance_
= false;
62 XMLNode
*noSingleFlowNode
= 0; singleFlow_
= true;
63 accessoryNode
->getNamedChild("nosingleflow", noSingleFlowNode
, false);
64 if (noSingleFlowNode
) singleFlow_
= false;
66 // Optional deform texture
67 if (accessoryNode
->getNamedChild("deformtexture", deformTexture_
, false))
69 if (!S3D::checkDataFile(getDeformTexture())) return false;
72 // Optional Attributes
73 XMLNode
*noSmokeNode
= 0, *noObjectDamageNode
= 0;
74 accessoryNode
->getNamedChild("groundscorchper", groundScorchPer_
, false);
75 accessoryNode
->getNamedChild("nosmoke", noSmokeNode
, false);
76 accessoryNode
->getNamedChild("noobjectdamage", noObjectDamageNode
, false);
77 if (noSmokeNode
) noSmoke_
= true;
78 if (noObjectDamageNode
) noObjectDamage_
= true;
83 void NapalmParams::parseLUA(lua_State
*L
, int position
)
85 luaL_checktype(L
, position
, LUA_TTABLE
);
87 napalmTime_
= LUAUtil::getNumberFromTable(L
, position
, "napalmtime", napalmTime_
);
88 napalmHeight_
= LUAUtil::getNumberFromTable(L
, position
, "napalmheight", napalmHeight_
);
89 stepTime_
= LUAUtil::getNumberFromTable(L
, position
, "steptime", stepTime_
);
90 hurtStepTime_
= LUAUtil::getNumberFromTable(L
, position
, "hurtsteptime", hurtStepTime_
);
91 hurtPerSecond_
= LUAUtil::getNumberFromTable(L
, position
, "hurtpersecond", hurtPerSecond_
);
92 groundScorchPer_
= LUAUtil::getNumberFromTable(L
, position
, "groundscorchper", groundScorchPer_
);
93 effectRadius_
= LUAUtil::getIntFromTable(L
, position
, "effectradius", effectRadius_
);
94 numberParticles_
= LUAUtil::getIntFromTable(L
, position
, "numberparticles", numberParticles_
);
95 noSmoke_
= LUAUtil::getBoolFromTable(L
, position
, "nosmoke", noSmoke_
);
96 noObjectDamage_
= LUAUtil::getBoolFromTable(L
, position
, "noobjectdamage", noObjectDamage_
);
97 allowUnderWater_
= LUAUtil::getBoolFromTable(L
, position
, "allowunderwater", allowUnderWater_
);
98 luminance_
= LUAUtil::getBoolFromTable(L
, position
, "luminance", luminance_
);
99 singleFlow_
= LUAUtil::getBoolFromTable(L
, position
, "singleflow", singleFlow_
);
100 napalmTexture_
= LUAUtil::getStringFromTable(L
, position
, "napalmtexture", napalmTexture_
);
101 deformTexture_
= LUAUtil::getStringFromTable(L
, position
, "deformtexture", deformTexture_
);