本文整理汇总了C++中LuaTable::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaTable::GetInt方法的具体用法?C++ LuaTable::GetInt怎么用?C++ LuaTable::GetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaTable
的用法示例。
在下文中一共展示了LuaTable::GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadCacheData
void CArchiveScanner::ReadCacheData(const std::string& filename)
{
if (!FileSystem::FileExists(filename)) {
LOG_L(L_INFO, "Archive cache doesn't exist: %s", filename.c_str());
return;
}
LuaParser p(filename, SPRING_VFS_RAW, SPRING_VFS_BASE);
if (!p.Execute()) {
LOG_L(L_ERROR, "Failed to parse archive cache: %s", p.GetErrorLog().c_str());
return;
}
const LuaTable archiveCache = p.GetRoot();
// Do not load old version caches
const int ver = archiveCache.GetInt("internalVer", (INTERNAL_VER + 1));
if (ver != INTERNAL_VER) {
return;
}
const LuaTable archives = archiveCache.SubTable("archives");
for (int i = 1; archives.KeyExists(i); ++i) {
const LuaTable curArchive = archives.SubTable(i);
const LuaTable archived = curArchive.SubTable("archivedata");
std::string name = curArchive.GetString("name", "");
ArchiveInfo& ai = archiveInfos[StringToLower(name)];
ai.origName = name;
ai.path = curArchive.GetString("path", "");
// do not use LuaTable.GetInt() for 32-bit integers, the Spring lua
// library uses 32-bit floats to represent numbers, which can only
// represent 2^24 consecutive integers
ai.modified = strtoul(curArchive.GetString("modified", "0").c_str(), 0, 10);
ai.checksum = strtoul(curArchive.GetString("checksum", "0").c_str(), 0, 10);
ai.updated = false;
ai.archiveData = CArchiveScanner::ArchiveData(archived, true);
if (ai.archiveData.GetModType() == modtype::map) {
AddDependency(ai.archiveData.GetDependencies(), "Map Helper v1");
} else if (ai.archiveData.GetModType() == modtype::primary) {
AddDependency(ai.archiveData.GetDependencies(), "Spring content v1");
}
}
const LuaTable brokenArchives = archiveCache.SubTable("brokenArchives");
for (int i = 1; brokenArchives.KeyExists(i); ++i) {
const LuaTable curArchive = brokenArchives.SubTable(i);
std::string name = curArchive.GetString("name", "");
StringToLowerInPlace(name);
BrokenArchive& ba = this->brokenArchives[name];
ba.path = curArchive.GetString("path", "");
ba.modified = strtoul(curArchive.GetString("modified", "0").c_str(), 0, 10);
ba.updated = false;
ba.problem = curArchive.GetString("problem", "unknown");
}
isDirty = false;
}
示例2: Parse
void SolidObjectDecalDef::Parse(const LuaTable& table) {
groundDecalTypeName = table.GetString("groundDecalType", table.GetString("buildingGroundDecalType", ""));
trackDecalTypeName = table.GetString("trackType", "StdTank");
useGroundDecal = table.GetBool("useGroundDecal", table.GetBool("useBuildingGroundDecal", false));
groundDecalType = -1;
groundDecalSizeX = table.GetInt("groundDecalSizeX", table.GetInt("buildingGroundDecalSizeX", 4));
groundDecalSizeY = table.GetInt("groundDecalSizeY", table.GetInt("buildingGroundDecalSizeY", 4));
groundDecalDecaySpeed = table.GetFloat("groundDecalDecaySpeed", table.GetFloat("buildingGroundDecalDecaySpeed", 0.1f));
leaveTrackDecals = table.GetBool("leaveTracks", false);
trackDecalType = -1;
trackDecalWidth = table.GetFloat("trackWidth", 32.0f);
trackDecalOffset = table.GetFloat("trackOffset", 0.0f);
trackDecalStrength = table.GetFloat("trackStrength", 0.0f);
trackDecalStretch = table.GetFloat("trackStretch", 1.0f);
}
示例3: ReadCacheData
void CArchiveScanner::ReadCacheData(const string& filename)
{
LuaParser p(filename, SPRING_VFS_RAW, SPRING_VFS_BASE);
if (!p.Execute()) {
logOutput.Print("ERROR in " + filename + ": " + p.GetErrorLog());
}
const LuaTable archiveCache = p.GetRoot();
const LuaTable archives = archiveCache.SubTable("archives");
// Do not load old version caches
const int ver = archiveCache.GetInt("internalVer", (INTERNAL_VER + 1));
if (ver != INTERNAL_VER) {
return;
}
for (int i = 1; archives.KeyExists(i); ++i) {
const LuaTable curArchive = archives.SubTable(i);
const LuaTable archived = curArchive.SubTable("archivedata");
ArchiveInfo ai;
ai.origName = curArchive.GetString("name", "");
ai.path = curArchive.GetString("path", "");
// do not use LuaTable.GetInt() for 32-bit integers, the Spring lua
// library uses 32-bit floats to represent numbers, which can only
// represent 2^24 consecutive integers
ai.modified = strtoul(curArchive.GetString("modified", "0").c_str(), 0, 10);
ai.checksum = strtoul(curArchive.GetString("checksum", "0").c_str(), 0, 10);
ai.updated = false;
ai.archiveData = GetArchiveData(archived);
if (ai.archiveData.modType == modtype::map)
AddDependency(ai.archiveData.dependencies, "maphelper.sdz");
else if (ai.archiveData.modType == modtype::primary)
AddDependency(ai.archiveData.dependencies, "Spring content v1");
string lcname = StringToLower(ai.origName);
archiveInfo[lcname] = ai;
}
isDirty = false;
}
示例4: Clamp
static MoveDef::SpeedModClass ParseSpeedModClass(const std::string& moveDefName, const LuaTable& moveDefTable)
{
const MoveDef::SpeedModClass speedModClass = MoveDef::SpeedModClass(moveDefTable.GetInt("speedModClass", -1));
if (speedModClass != -1)
return Clamp(speedModClass, MoveDef::Tank, MoveDef::Ship);
// name-based fallbacks
if (moveDefName.find( "boat") != string::npos)
return MoveDef::Ship;
if (moveDefName.find( "ship") != string::npos)
return MoveDef::Ship;
if (moveDefName.find("hover") != string::npos)
return MoveDef::Hover;
if (moveDefName.find( "tank") != string::npos)
return MoveDef::Tank;
return MoveDef::KBot;
}
示例5: GetArchiveData
CArchiveScanner::ArchiveData CArchiveScanner::GetArchiveData(const LuaTable& archiveTable)
{
ArchiveData md;
if (!archiveTable.IsValid()) {
return md;
}
md.name = archiveTable.GetString("name", "");
md.shortName = archiveTable.GetString("shortName", "");
md.version = archiveTable.GetString("version", "");
md.mutator = archiveTable.GetString("mutator", "");
md.game = archiveTable.GetString("game", "");
md.shortGame = archiveTable.GetString("shortGame", "");
md.description = archiveTable.GetString("description", "");
md.modType = archiveTable.GetInt("modType", 0);
md.mapfile = archiveTable.GetString("mapfile", "");
const LuaTable dependencies = archiveTable.SubTable("depend");
for (int dep = 1; dependencies.KeyExists(dep); ++dep) {
const std::string depend = dependencies.GetString(dep, "");
md.dependencies.push_back(depend);
}
const LuaTable replaces = archiveTable.SubTable("replace");
for (int rep = 1; replaces.KeyExists(rep); ++rep) {
md.replaces.push_back(replaces.GetString(rep, ""));
}
// HACK needed until lobbies, lobbyserver and unitsync are sorted out
// so they can uniquely identify different versions of the same mod.
// (at time of this writing they use name only)
// NOTE when changing this, this function is used both by the code that
// reads ArchiveCache.lua and the code that reads modinfo.lua from the mod.
// so make sure it doesn't keep adding stuff to the name everytime
// Spring/unitsync is loaded.
if (md.name.find(md.version) == std::string::npos && !md.version.empty()) {
md.name += " " + md.version;
}
return md;
}
示例6: StringToLower
MoveDef::MoveDef(const LuaTable& moveDefTable, int moveDefID) {
*this = MoveDef();
name = StringToLower(moveDefTable.GetString("name", ""));
pathType = moveDefID - 1;
crushStrength = moveDefTable.GetFloat("crushStrength", 10.0f);
const LuaTable& depthModTable = moveDefTable.SubTable("depthModParams");
const LuaTable& speedModMultsTable = moveDefTable.SubTable("speedModMults");
const float minWaterDepth = moveDefTable.GetFloat("minWaterDepth", GetDefaultMinWaterDepth());
const float maxWaterDepth = moveDefTable.GetFloat("maxWaterDepth", GetDefaultMaxWaterDepth());
switch ((speedModClass = ParseSpeedModClass(name, moveDefTable))) {
case MoveDef::Tank: {
// fall-through
}
case MoveDef::KBot: {
depthModParams[DEPTHMOD_MIN_HEIGHT] = std::max(0.00f, depthModTable.GetFloat("minHeight", 0.0f ));
depthModParams[DEPTHMOD_MAX_HEIGHT] = ( depthModTable.GetFloat("maxHeight", std::numeric_limits<float>::max() ));
depthModParams[DEPTHMOD_MAX_SCALE ] = std::max(0.01f, depthModTable.GetFloat("maxScale", std::numeric_limits<float>::max() ));
depthModParams[DEPTHMOD_QUA_COEFF ] = std::max(0.00f, depthModTable.GetFloat("quadraticCoeff", 0.0f ));
depthModParams[DEPTHMOD_LIN_COEFF ] = std::max(0.00f, depthModTable.GetFloat("linearCoeff", moveDefTable.GetFloat("depthMod", 0.1f)));
depthModParams[DEPTHMOD_CON_COEFF ] = std::max(0.00f, depthModTable.GetFloat("constantCoeff", 1.0f ));
// ensure [depthModMinHeight, depthModMaxHeight] is a valid range
depthModParams[DEPTHMOD_MAX_HEIGHT] = std::max(depthModParams[DEPTHMOD_MIN_HEIGHT], depthModParams[DEPTHMOD_MAX_HEIGHT]);
depth = maxWaterDepth;
maxSlope = DegreesToMaxSlope(moveDefTable.GetFloat("maxSlope", 60.0f));
} break;
case MoveDef::Hover: {
depth = maxWaterDepth;
maxSlope = DegreesToMaxSlope(moveDefTable.GetFloat("maxSlope", 15.0f));
} break;
case MoveDef::Ship: {
depth = minWaterDepth;
subMarine = moveDefTable.GetBool("subMarine", false);
} break;
}
speedModMults[SPEEDMOD_MOBILE_BUSY_MULT] = std::max(0.01f, speedModMultsTable.GetFloat("mobileBusyMult", 1.0f /*0.10f*/));
speedModMults[SPEEDMOD_MOBILE_IDLE_MULT] = std::max(0.01f, speedModMultsTable.GetFloat("mobileIdleMult", 1.0f /*0.35f*/));
speedModMults[SPEEDMOD_MOBILE_MOVE_MULT] = std::max(0.01f, speedModMultsTable.GetFloat("mobileMoveMult", 1.0f /*0.65f*/));
avoidMobilesOnPath = moveDefTable.GetBool("avoidMobilesOnPath", true);
allowTerrainCollisions = moveDefTable.GetBool("allowTerrainCollisions", true);
heatMapping = moveDefTable.GetBool("heatMapping", false);
flowMapping = moveDefTable.GetBool("flowMapping", true);
heatMod = moveDefTable.GetFloat("heatMod", (1.0f / (GAME_SPEED * 2)) * 0.25f);
flowMod = moveDefTable.GetFloat("flowMod", 1.0f);
// by default heat decays to zero after N=2 seconds
//
// the cost contribution to a square from heat must
// be on the same order as its normal movement cost
// PER FRAME, i.e. such that heatMod * heatProduced
// ~= O(1 / (GAME_SPEED * N)) because unit behavior
// in groups quickly becomes FUBAR if heatMod >>> 1
//
heatProduced = moveDefTable.GetInt("heatProduced", GAME_SPEED * 2);
// <maxSlope> ranges from 0.0 to 60 * 1.5 degrees, ie. from 0.0 to
// 0.5 * PI radians, ie. from 1.0 - cos(0.0) to 1.0 - cos(0.5 * PI)
// = [0, 1] --> DEFAULT <slopeMod> values range from (4 / 0.001) to
// (4 / 1.001) = [4000.0, 3.996]
//
// speedMod values for a terrain-square slope in [0, 1] are given by
// (1.0 / (1.0 + slope * slopeMod)) and therefore have a MAXIMUM at
// <slope=0, slopeMod=...> and a MINIMUM at <slope=1, slopeMod=4000>
// (of 1.0 / (1.0 + 0.0 * ...) = 1.0 and 1.0 / (1.0 + 1.0 * 4000.0)
// = 0.00025 respectively)
//
slopeMod = moveDefTable.GetFloat("slopeMod", 4.0f / (maxSlope + 0.001f));
// ground units hug the ocean floor when in water,
// ships stay at a "fixed" level (their waterline)
followGround = (speedModClass == MoveDef::Tank || speedModClass == MoveDef::KBot);
// TODO:
// remove terrainClass, not used anywhere
// and only AI's MIGHT have benefit from it
//
// tank or bot that cannot get its threads / feet
// wet, or hovercraft (which doesn't touch ground
// or water)
if ((followGround && maxWaterDepth <= 0.0f) || speedModClass == MoveDef::Hover)
terrainClass = MoveDef::Land;
// ship (or sub) that cannot crawl onto shore, OR tank
// or bot restricted to snorkling (strange but possible)
if ((speedModClass == MoveDef::Ship && minWaterDepth > 0.0f) || (followGround && minWaterDepth > 0.0f))
terrainClass = MoveDef::Water;
// tank or kbot that CAN go skinny-dipping (amph.),
// or ship that CAN sprout legs when at the beach
if ((followGround && maxWaterDepth > 0.0f) || (speedModClass == MoveDef::Ship && minWaterDepth < 0.0f))
terrainClass = MoveDef::Mixed;
//.........这里部分代码省略.........
示例7: ParseUnitDefTable
void CUnitDefHandler::ParseUnitDefTable(const LuaTable& udTable, const string& unitName, int id)
{
UnitDef& ud = unitDefs[id];
// allocate and fill ud->unitImage
ud.buildPicName = udTable.GetString("buildPic", "");
ud.humanName = udTable.GetString("name", "");
if (ud.humanName.empty()) {
const string errmsg = "missing 'name' parameter for the " + unitName + " unitdef";
throw content_error(errmsg);
}
ud.filename = udTable.GetString("filename", "");
if (ud.filename.empty()) {
const string errmsg = "missing 'filename' parameter for the" + unitName + " unitdef";
throw content_error(errmsg);
}
ud.tooltip = udTable.GetString("description", ud.name);
const string decoy = udTable.GetString("decoyFor", "");
if (!decoy.empty()) {
decoyNameMap[ud.name] = StringToLower(decoy);
}
ud.gaia = udTable.GetString("gaia", "");
ud.isCommander = udTable.GetBool("commander", false);
if (ud.isCommander && gameSetup) {
ud.metalStorage = udTable.GetFloat("metalStorage", gameSetup->startMetal);
ud.energyStorage = udTable.GetFloat("energyStorage", gameSetup->startEnergy);
} else {
ud.metalStorage = udTable.GetFloat("metalStorage", 0.0f);
ud.energyStorage = udTable.GetFloat("energyStorage", 0.0f);
}
ud.extractsMetal = udTable.GetFloat("extractsMetal", 0.0f);
ud.windGenerator = udTable.GetFloat("windGenerator", 0.0f);
ud.tidalGenerator = udTable.GetFloat("tidalGenerator", 0.0f);
ud.metalUpkeep = udTable.GetFloat("metalUse", 0.0f);
ud.energyUpkeep = udTable.GetFloat("energyUse", 0.0f);
ud.metalMake = udTable.GetFloat("metalMake", 0.0f);
ud.makesMetal = udTable.GetFloat("makesMetal", 0.0f);
ud.energyMake = udTable.GetFloat("energyMake", 0.0f);
ud.health = udTable.GetFloat("maxDamage", 0.0f);
ud.autoHeal = udTable.GetFloat("autoHeal", 0.0f) * (16.0f / GAME_SPEED);
ud.idleAutoHeal = udTable.GetFloat("idleAutoHeal", 10.0f) * (16.0f / GAME_SPEED);
ud.idleTime = udTable.GetInt("idleTime", 600);
ud.buildangle = udTable.GetInt("buildAngle", 0);
ud.isMetalMaker = (ud.makesMetal >= 1 && ud.energyUpkeep > ud.makesMetal * 40);
ud.controlRadius = 32;
ud.losHeight = 20;
ud.metalCost = udTable.GetFloat("buildCostMetal", 0.0f);
if (ud.metalCost < 1.0f) {
ud.metalCost = 1.0f; //avoid some nasty divide by 0 etc
}
ud.mass = udTable.GetFloat("mass", 0.0f);
if (ud.mass <= 0.0f) {
ud.mass=ud.metalCost;
}
ud.energyCost = udTable.GetFloat("buildCostEnergy", 0.0f);
ud.buildTime = udTable.GetFloat("buildTime", 0.0f);
if (ud.buildTime < 1.0f) {
ud.buildTime = 1.0f; //avoid some nasty divide by 0 etc
}
ud.aihint = id; // FIXME? (as noted in SelectedUnits.cpp, aihint is ignored)
ud.cobID = udTable.GetInt("cobID", -1);
ud.losRadius = udTable.GetFloat("sightDistance", 0.0f) * modInfo.losMul / (SQUARE_SIZE * (1 << modInfo.losMipLevel));
ud.airLosRadius = udTable.GetFloat("airSightDistance", -1.0f);
if (ud.airLosRadius == -1.0f) {
ud.airLosRadius=udTable.GetFloat("sightDistance", 0.0f) * modInfo.airLosMul * 1.5f / (SQUARE_SIZE * (1 << modInfo.airMipLevel));
} else {
ud.airLosRadius = ud.airLosRadius * modInfo.airLosMul / (SQUARE_SIZE * (1 << modInfo.airMipLevel));
}
ud.canSubmerge = udTable.GetBool("canSubmerge", false);
ud.canfly = udTable.GetBool("canFly", false);
ud.canmove = udTable.GetBool("canMove", false);
ud.reclaimable = udTable.GetBool("reclaimable", true);
ud.capturable = udTable.GetBool("capturable", true);
ud.repairable = udTable.GetBool("repairable", true);
ud.canAttack = udTable.GetBool("canAttack", true);
ud.canFight = udTable.GetBool("canFight", true);
ud.canPatrol = udTable.GetBool("canPatrol", true);
ud.canGuard = udTable.GetBool("canGuard", true);
ud.canRepeat = udTable.GetBool("canRepeat", true);
ud.builder = udTable.GetBool("builder", true);
ud.canRestore = udTable.GetBool("canRestore", ud.builder);
ud.canRepair = udTable.GetBool("canRepair", ud.builder);
ud.canReclaim = udTable.GetBool("canReclaim", ud.builder);
//.........这里部分代码省略.........
示例8: ParseWeaponsTable
void UnitDef::ParseWeaponsTable(const LuaTable& weaponsTable)
{
const WeaponDef* noWeaponDef = weaponDefHandler->GetWeapon("NOWEAPON");
for (int w = 0; w < MAX_WEAPONS_PER_UNIT; w++) {
LuaTable wTable;
string name = weaponsTable.GetString(w + 1, "");
if (name.empty()) {
wTable = weaponsTable.SubTable(w + 1);
name = wTable.GetString("name", "");
}
const WeaponDef* wd = NULL;
if (!name.empty()) {
wd = weaponDefHandler->GetWeapon(name);
}
if (wd == NULL) {
if (w <= 3) {
continue; // allow empty weapons among the first 3
} else {
break;
}
}
while (weapons.size() < w) {
if (!noWeaponDef) {
logOutput.Print("Error: Spring requires a NOWEAPON weapon type "
"to be present as a placeholder for missing weapons");
break;
} else {
weapons.push_back(UnitDefWeapon());
weapons.back().def = noWeaponDef;
}
}
const string badTarget = wTable.GetString("badTargetCategory", "");
unsigned int btc = CCategoryHandler::Instance()->GetCategories(badTarget);
const string onlyTarget = wTable.GetString("onlyTargetCategory", "");
unsigned int otc;
if (onlyTarget.empty()) {
otc = 0xffffffff;
} else {
otc = CCategoryHandler::Instance()->GetCategories(onlyTarget);
}
const unsigned int slaveTo = wTable.GetInt("slaveTo", 0);
float3 mainDir = wTable.GetFloat3("mainDir", float3(1.0f, 0.0f, 0.0f)).SafeNormalize();
const float angleDif = cos(wTable.GetFloat("maxAngleDif", 360.0f) * (PI / 360.0f));
const float fuelUse = wTable.GetFloat("fuelUsage", 0.0f);
UnitDefWeapon weapon(name, wd, slaveTo, mainDir, angleDif, btc, otc, fuelUse);
weapons.push_back(weapon);
maxWeaponRange = std::max(maxWeaponRange, wd->range);
if (wd->interceptor && wd->coverageRange > maxCoverage)
maxCoverage = wd->coverageRange;
if (wd->isShield) {
if (!shieldWeaponDef || // use the biggest shield
(shieldWeaponDef->shieldRadius < wd->shieldRadius)) {
shieldWeaponDef = wd;
}
}
if (wd->stockpile) {
// interceptors have priority
if (wd->interceptor ||
!stockpileWeaponDef ||
!stockpileWeaponDef->interceptor) {
stockpileWeaponDef = wd;
}
}
}
}
示例9: name
//.........这里部分代码省略.........
}
}
const float tempsize = 2.0f + std::min(defDamage * 0.0025f, damageAreaOfEffect * 0.1f);
size = wdTable.GetFloat("size", tempsize);
const float gd = std::max(30.0f, defDamage / 20.0f);
const float defExpSpeed = (8.0f + (gd * 2.5f)) / (9.0f + (math::sqrt(gd) * 0.7f)) * 0.5f;
explosionSpeed = wdTable.GetFloat("explosionSpeed", defExpSpeed);
}
{
// 0.78.2.1 backwards compatibility: non-burst beamlasers play one
// sample per shot, not for each individual beam making up the shot
const bool singleSampleShot = (type == "BeamLaser" && !beamburst);
const bool singleShotWeapon = (type == "Melee" || type == "Rifle");
soundTrigger = wdTable.GetBool("soundTrigger", singleSampleShot || singleShotWeapon);
}
// get some weapon specific defaults
int defInterceptType = 0;
if ((type == "Cannon") || (type == "EmgCannon")) {
defInterceptType = 1;
} else if ((type == "LaserCannon") || (type == "BeamLaser")) {
defInterceptType = 2;
} else if ((type == "StarburstLauncher") || (type == "MissileLauncher")) {
defInterceptType = 4;
} else if (type == "AircraftBomb") {
defInterceptType = 8;
} else if (type == "Flame") {
defInterceptType = 16;
} else if (type == "TorpedoLauncher") {
defInterceptType = 32;
} else if (type == "LightningCannon") {
defInterceptType = 64;
} else if (type == "Rifle") {
defInterceptType = 128;
} else if (type == "Melee") {
defInterceptType = 256;
}
interceptedByShieldType = wdTable.GetInt("interceptedByShieldType", defInterceptType);
if (type == "Cannon") {
// CExplosiveProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.9f);
intensity = wdTable.GetFloat("intensity", 0.2f);
} else if (type == "Rifle") {
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.9f);
} else if (type == "Melee") {
// ...
} else if (type == "Flame") {
// CFlameProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.2f);
collisionSize = wdTable.GetFloat("collisionSize", 0.5f);
} else if (type == "MissileLauncher") {
// CMissileProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.5f);
} else if (type == "LaserCannon") {
// CLaserProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.7f);
collisionSize = wdTable.GetFloat("collisionSize", 0.5f);
} else if (type == "BeamLaser") {
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.7f);
} else if (type == "LightningCannon") {
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.5f);
} else if (type == "EmgCannon") {
// CEmgProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.5f);
size = wdTable.GetFloat("size", 3.0f);
} else if (type == "TorpedoLauncher") {
assert(waterweapon);
waterweapon = true;
} else if (type == "DGun") {
// CFireBallProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.5f);
collisionSize = wdTable.GetFloat("collisionSize", 10.0f);
} else if (type == "StarburstLauncher") {
// CStarburstProjectile
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.7f);
} else {
ownerExpAccWeight = wdTable.GetFloat("ownerExpAccWeight", 0.0f);
}
const std::string& colormap = wdTable.GetString("colormap", "");
visuals.colorMap = NULL;
if (!colormap.empty()) {
visuals.colorMap = CColorMap::LoadFromDefString(colormap);
}
ParseWeaponSounds(wdTable);
// custom parameters table
wdTable.SubTable("customParams").GetMap(customParams);
// internal only
isShield = (type == "Shield");
noAutoTarget = (manualfire || interceptor || isShield);
onlyForward = !turret && (type != "StarburstLauncher");
}
示例10: Load
unsigned int CCustomExplosionGenerator::Load(CExplosionGeneratorHandler* h, const string& tag)
{
unsigned int explosionID = -1U;
if (tag.empty()) {
return explosionID;
}
const std::map<std::string, unsigned int>::const_iterator it = explosionIDs.find(tag);
if (it == explosionIDs.end()) {
CEGData cegData;
const LuaTable* root = h->GetExplosionTableRoot();
const LuaTable& expTable = (root != NULL)? root->SubTable(tag): LuaTable();
if (!expTable.IsValid()) {
// not a fatal error: any calls to ::Explosion will just return early
logOutput.Print("[CCEG::Load] WARNING: table for CEG \"" + tag + "\" invalid (parse errors?)");
return explosionID;
}
vector<string> spawns;
expTable.GetKeys(spawns);
for (vector<string>::iterator si = spawns.begin(); si != spawns.end(); ++si) {
ProjectileSpawnInfo psi;
const string& spawnName = *si;
const LuaTable spawnTable = expTable.SubTable(spawnName);
if (!spawnTable.IsValid() || spawnName == "groundflash") {
continue;
}
const string className = spawnTable.GetString("class", spawnName);
psi.projectileClass = h->projectileClasses.GetClass(className);
psi.flags = GetFlagsFromTable(spawnTable);
psi.count = spawnTable.GetInt("count", 1);
if (psi.projectileClass->binder->flags & creg::CF_Synced) {
psi.flags |= SPW_SYNCED;
}
string code;
map<string, string> props;
map<string, string>::const_iterator propIt;
spawnTable.SubTable("properties").GetMap(props);
for (propIt = props.begin(); propIt != props.end(); ++propIt) {
creg::Class::Member* m = psi.projectileClass->FindMember(propIt->first.c_str());
if (m && (m->flags & creg::CM_Config)) {
ParseExplosionCode(&psi, m->offset, m->type, propIt->second, code);
}
}
code += (char)OP_END;
psi.code.resize(code.size());
copy(code.begin(), code.end(), psi.code.begin());
cegData.projectileSpawn.push_back(psi);
}
const LuaTable gndTable = expTable.SubTable("groundflash");
const int ttl = gndTable.GetInt("ttl", 0);
if (ttl > 0) {
cegData.groundFlash.circleAlpha = gndTable.GetFloat("circleAlpha", 0.0f);
cegData.groundFlash.flashSize = gndTable.GetFloat("flashSize", 0.0f);
cegData.groundFlash.flashAlpha = gndTable.GetFloat("flashAlpha", 0.0f);
cegData.groundFlash.circleGrowth = gndTable.GetFloat("circleGrowth", 0.0f);
cegData.groundFlash.color = gndTable.GetFloat3("color", float3(1.0f, 1.0f, 0.8f));
cegData.groundFlash.flags = SPW_GROUND | GetFlagsFromTable(gndTable);
cegData.groundFlash.ttl = ttl;
}
cegData.useDefaultExplosions = expTable.GetBool("useDefaultExplosions", false);
explosionID = explosionData.size();
explosionData.push_back(cegData);
explosionIDs[tag] = explosionID;
} else {
explosionID = it->second;
}
return explosionID;
}
示例11: ParseTAWeapon
void CWeaponDefHandler::ParseTAWeapon(const LuaTable& wdTable, WeaponDef& wd)
{
bool lineofsight;
bool ballistic;
//bool twophase;
bool beamweapon;
bool manualBombSettings; //Allow the user to manually specify the burst and burstrate for his AircraftBomb
//bool guided;
//bool vlaunch;
int rendertype;
int color;
int beamlaser;
//bool tracking;
//bool selfprop;
//bool turret;
//bool smokeTrail;
//string modelName;
wd.tdfId = wdTable.GetInt("id", 0);
wd.filename = wdTable.GetString("filename", "unknown");
wd.description = wdTable.GetString("name", "Weapon");
wd.cegTag = wdTable.GetString("cegTag", "");
wd.avoidFriendly = wdTable.GetBool("avoidFriendly", true);
wd.avoidFeature = wdTable.GetBool("avoidFeature", true);
wd.collisionFlags = 0;
const bool collideFriendly = wdTable.GetBool("collideFriendly", true);
const bool collideFeature = wdTable.GetBool("collideFeature", true);
if (!collideFriendly) { wd.collisionFlags += COLLISION_NOFRIENDLY; }
if (!collideFeature) { wd.collisionFlags += COLLISION_NOFEATURE; }
wd.minIntensity = wdTable.GetFloat("minIntensity", 0.0f);
wd.dropped = wdTable.GetBool("dropped", false);
manualBombSettings = wdTable.GetBool("manualBombSettings", false);
lineofsight = wdTable.GetBool("lineOfSight", false);
ballistic = wdTable.GetBool("ballistic", false);
wd.twophase = wdTable.GetBool("twoPhase", false);
beamweapon = wdTable.GetBool("beamWeapon", false);
wd.guided = wdTable.GetBool("guidance", false);
rendertype = wdTable.GetInt("renderType", 0);
color = wdTable.GetInt("color", 0);
beamlaser = wdTable.GetInt("beamlaser", 0);
wd.vlaunch = wdTable.GetBool("vlaunch", false);
wd.selfprop = wdTable.GetBool("selfprop", false);
wd.turret = wdTable.GetBool("turret", false);
wd.noSelfDamage = wdTable.GetBool("noSelfDamage", false);
wd.visuals.modelName = wdTable.GetString("model", "");
wd.visuals.smokeTrail = wdTable.GetBool("smokeTrail", false);
wd.visuals.alwaysVisible = wdTable.GetBool("alwaysVisible", false);
wd.waterweapon = wdTable.GetBool("waterWeapon", false);
wd.fireSubmersed = wdTable.GetBool("fireSubmersed", wd.waterweapon);
wd.submissile = wdTable.GetBool("submissile", false);
wd.tracks = wdTable.GetBool("tracks", false);
wd.fixedLauncher = wdTable.GetBool("fixedLauncher", false);
wd.noExplode = wdTable.GetBool("noExplode", false);
wd.isShield = wdTable.GetBool("isShield", false);
wd.maxvelocity = wdTable.GetFloat("weaponVelocity", 0.0f);
wd.beamtime = wdTable.GetFloat("beamTime", 1.0f);
wd.beamburst = wdTable.GetBool("beamburst", false);
wd.waterBounce = wdTable.GetBool("waterbounce", false);
wd.groundBounce = wdTable.GetBool("groundbounce", false);
wd.bounceSlip = wdTable.GetFloat("bounceslip", 1);
wd.bounceRebound = wdTable.GetFloat("bouncerebound", 1);
wd.numBounce = wdTable.GetInt("numbounce", -1);
wd.thickness = wdTable.GetFloat("thickness", 2.0f);
wd.corethickness = wdTable.GetFloat("coreThickness", 0.25f);
wd.laserflaresize = wdTable.GetFloat("laserFlareSize", 15.0f);
wd.intensity = wdTable.GetFloat("intensity", 0.9f);
wd.duration = wdTable.GetFloat("duration", 0.05f);
wd.falloffRate = wdTable.GetFloat("fallOffRate", 0.5f);
wd.lodDistance = wdTable.GetInt("lodDistance", 1000);
wd.visuals.sizeDecay = wdTable.GetFloat("sizeDecay", 0.0f);
wd.visuals.alphaDecay = wdTable.GetFloat("alphaDecay", 1.0f);
wd.visuals.separation = wdTable.GetFloat("separation", 1.0f);
wd.visuals.noGap = wdTable.GetBool("noGap", true);
wd.visuals.stages = wdTable.GetInt("stages", 5);
if (wd.name.find("disintegrator") != string::npos) { //fulhack
wd.visuals.renderType = WEAPON_RENDERTYPE_FIREBALL;
} else if (wd.visuals.modelName.compare("") != 0) {
wd.visuals.renderType = WEAPON_RENDERTYPE_MODEL;
} else if (beamweapon) {
wd.visuals.renderType = WEAPON_RENDERTYPE_LASER;
} else {
wd.visuals.renderType = WEAPON_RENDERTYPE_PLASMA;
}
wd.gravityAffected = false;
if (wd.dropped || ballistic) {
wd.gravityAffected = true;
}
if (wd.dropped) {
//.........这里部分代码省略.........
示例12: LoadPieceTransformations
void CAssParser::LoadPieceTransformations(
SAssPiece* piece,
const S3DModel* model,
const aiNode* pieceNode,
const LuaTable& pieceTable
) {
aiVector3D aiScaleVec, aiTransVec;
aiQuaternion aiRotateQuat;
// process transforms
pieceNode->mTransformation.Decompose(aiScaleVec, aiRotateQuat, aiTransVec);
// metadata-scaling
piece->scales = pieceTable.GetFloat3("scale", aiVectorToFloat3(aiScaleVec));
piece->scales.x = pieceTable.GetFloat("scalex", piece->scales.x);
piece->scales.y = pieceTable.GetFloat("scaley", piece->scales.y);
piece->scales.z = pieceTable.GetFloat("scalez", piece->scales.z);
if (piece->scales.x != piece->scales.y || piece->scales.y != piece->scales.z) {
// LOG_SL(LOG_SECTION_MODEL, L_WARNING, "Spring doesn't support non-uniform scaling");
piece->scales.y = piece->scales.x;
piece->scales.z = piece->scales.x;
}
// metadata-translation
piece->offset = pieceTable.GetFloat3("offset", aiVectorToFloat3(aiTransVec));
piece->offset.x = pieceTable.GetFloat("offsetx", piece->offset.x);
piece->offset.y = pieceTable.GetFloat("offsety", piece->offset.y);
piece->offset.z = pieceTable.GetFloat("offsetz", piece->offset.z);
// metadata-rotation
// NOTE:
// these rotations are "pre-scripting" but "post-modelling"
// together with the (baked) aiRotateQuad they determine the
// model's pose *before* any animations execute
//
// float3 rotAngles = pieceTable.GetFloat3("rotate", aiQuaternionToRadianAngles(aiRotateQuat) * RADTODEG);
float3 pieceRotAngles = pieceTable.GetFloat3("rotate", ZeroVector);
pieceRotAngles.x = pieceTable.GetFloat("rotatex", pieceRotAngles.x);
pieceRotAngles.y = pieceTable.GetFloat("rotatey", pieceRotAngles.y);
pieceRotAngles.z = pieceTable.GetFloat("rotatez", pieceRotAngles.z);
pieceRotAngles *= DEGTORAD;
LOG_SL(LOG_SECTION_PIECE, L_INFO,
"(%d:%s) Assimp offset (%f,%f,%f), rotate (%f,%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
aiTransVec.x, aiTransVec.y, aiTransVec.z,
aiRotateQuat.w, aiRotateQuat.x, aiRotateQuat.y, aiRotateQuat.z,
aiScaleVec.x, aiScaleVec.y, aiScaleVec.z
);
LOG_SL(LOG_SECTION_PIECE, L_INFO,
"(%d:%s) Relative offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)",
model->numPieces, piece->name.c_str(),
piece->offset.x, piece->offset.y, piece->offset.z,
pieceRotAngles.x, pieceRotAngles.y, pieceRotAngles.z,
piece->scales.x, piece->scales.y, piece->scales.z
);
// NOTE:
// at least collada (.dae) files generated by Blender represent
// a coordinate-system that differs from the "standard" formats
// (3DO, S3O, ...) for which existing tools at least have prior
// knowledge of Spring's expectations --> let the user override
// the ROOT rotational transform and the rotation-axis mapping
// used by animation scripts (but re-modelling/re-exporting is
// always preferred!) even though AssImp should convert models
// to its own system which matches that of Spring
//
// .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Z_UP)
// .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Y_UP) [!?]
// .blend: ????
piece->bakedRotMatrix = aiMatrixToMatrix(aiMatrix4x4t<float>(aiRotateQuat.GetMatrix()));
if (piece == model->GetRootPiece()) {
const float3 xaxis = pieceTable.GetFloat3("xaxis", piece->bakedRotMatrix.GetX());
const float3 yaxis = pieceTable.GetFloat3("yaxis", piece->bakedRotMatrix.GetY());
const float3 zaxis = pieceTable.GetFloat3("zaxis", piece->bakedRotMatrix.GetZ());
if (math::fabs(xaxis.SqLength() - yaxis.SqLength()) < 0.01f && math::fabs(yaxis.SqLength() - zaxis.SqLength()) < 0.01f) {
piece->bakedRotMatrix = CMatrix44f(ZeroVector, xaxis, yaxis, zaxis);
}
}
piece->rotAxisSigns = pieceTable.GetFloat3("rotAxisSigns", float3(-OnesVector));
piece->axisMapType = AxisMappingType(pieceTable.GetInt("rotAxisMap", AXIS_MAPPING_XYZ));
// construct 'baked' part of the piece-space matrix
// AssImp order is translate * rotate * scale * v;
// we leave the translation and scale parts out and
// put those in <offset> and <scales> --> transform
// is just R instead of T * R * S
//
// note: for all non-AssImp models this is identity!
//
piece->ComposeRotation(piece->bakedRotMatrix, pieceRotAngles);
piece->SetHasIdentityRotation(piece->bakedRotMatrix.IsIdentity() == 0);
assert(piece->bakedRotMatrix.IsOrthoNormal() == 0);
}
示例13: content_error
CMoveInfo::CMoveInfo()
{
const LuaTable rootTable = game->defsParser->GetRoot().SubTable("MoveDefs");
if (!rootTable.IsValid()) {
throw content_error("Error loading movement definitions");
}
groundMoveMath = new CGroundMoveMath();
hoverMoveMath = new CHoverMoveMath();
seaMoveMath = new CShipMoveMath();
moveInfoChecksum = 0;
for (size_t num = 1; /* no test */; num++) {
const LuaTable moveTable = rootTable.SubTable(num);
if (!moveTable.IsValid()) {
break;
}
MoveData* md = new MoveData(0x0, 0);
md->name = moveTable.GetString("name", "");
md->pathType = (num - 1);
md->maxSlope = 1.0f;
md->depth = 0.0f;
md->depthMod = 0.0f;
md->crushStrength = moveTable.GetFloat("crushStrength", 10.0f);
const float minWaterDepth = moveTable.GetFloat("minWaterDepth", 10.0f);
const float maxWaterDepth = moveTable.GetFloat("maxWaterDepth", 0.0f);
if ((md->name.find("BOAT") != string::npos) ||
(md->name.find("SHIP") != string::npos)) {
md->moveType = MoveData::Ship_Move;
md->depth = minWaterDepth;
md->moveFamily = MoveData::Ship;
md->moveMath = seaMoveMath;
md->subMarine = moveTable.GetBool("subMarine", 0);
}
else if (md->name.find("HOVER") != string::npos) {
md->moveType = MoveData::Hover_Move;
md->maxSlope = DegreesToMaxSlope(moveTable.GetFloat("maxSlope", 15.0f));
md->moveFamily = MoveData::Hover;
md->moveMath = hoverMoveMath;
}
else {
md->moveType = MoveData::Ground_Move;
md->depthMod = moveTable.GetFloat("depthMod", 0.1f);
md->depth = maxWaterDepth;
md->maxSlope = DegreesToMaxSlope(moveTable.GetFloat("maxSlope", 60.0f));
md->moveMath = groundMoveMath;
if (md->name.find("TANK") != string::npos) {
md->moveFamily = MoveData::Tank;
} else {
md->moveFamily = MoveData::KBot;
}
}
// ground units hug the ocean floor when in water,
// ships stay at a "fixed" level (their waterline)
md->followGround =
(md->moveFamily == MoveData::Tank ||
md->moveFamily == MoveData::KBot);
// tank or bot that cannot get its threads / feet
// wet, or hovercraft (which doesn't touch ground
// or water)
const bool b0 =
((md->followGround && maxWaterDepth <= 0.0) ||
md->moveFamily == MoveData::Hover);
// ship (or sub) that cannot crawl onto shore, OR tank or
// kbot restricted to snorkling (strange but possible)
const bool b1 =
((md->moveFamily == MoveData::Ship && minWaterDepth > 0.0) ||
((md->followGround) && minWaterDepth > 0.0));
// tank or kbot that CAN go skinny-dipping (amph.),
// or ship that CAN sprout legs when at the beach
const bool b2 =
((md->followGround) && maxWaterDepth > 0.0) ||
(md->moveFamily == MoveData::Ship && minWaterDepth < 0.0);
if (b0) { md->terrainClass = MoveData::Land; }
if (b1) { md->terrainClass = MoveData::Water; }
if (b2) { md->terrainClass = MoveData::Mixed; }
md->slopeMod = moveTable.GetFloat("slopeMod", 4.0f / (md->maxSlope + 0.001f));
// TA has only half our resolution, multiply size by 2
md->size = max(2, min(8, moveTable.GetInt("footprintX", 1) * 2));
moveInfoChecksum +=
(md->size << 5) +
(md->followGround << 4) +
(md->subMarine << 3) +
(b2 << 2) +
(b1 << 1) +
(b0 << 0);
//.........这里部分代码省略.........
示例14: StringToLower
/*
* CArchiveScanner::ArchiveData
*/
CArchiveScanner::ArchiveData::ArchiveData(const LuaTable& archiveTable, bool fromCache)
{
if (!archiveTable.IsValid())
return;
std::vector<std::string> keys;
if (!archiveTable.GetKeys(keys))
return;
for (std::string& key: keys) {
const std::string& keyLower = StringToLower(key);
if (ArchiveData::IsReservedKey(keyLower))
continue;
if (keyLower == "modtype") {
SetInfoItemValueInteger(key, archiveTable.GetInt(key, 0));
continue;
}
switch (archiveTable.GetType(key)) {
case LuaTable::STRING: {
SetInfoItemValueString(key, archiveTable.GetString(key, ""));
} break;
case LuaTable::NUMBER: {
SetInfoItemValueFloat(key, archiveTable.GetFloat(key, 0.0f));
} break;
case LuaTable::BOOLEAN: {
SetInfoItemValueBool(key, archiveTable.GetBool(key, false));
} break;
default: {
// just ignore unsupported types (most likely to be lua-tables)
//throw content_error("Lua-type " + IntToString(luaType) + " not supported in archive-info, but it is used on key \"" + *key + "\"");
} break;
}
}
const LuaTable& _dependencies = archiveTable.SubTable("depend");
const LuaTable& _replaces = archiveTable.SubTable("replace");
for (int dep = 1; _dependencies.KeyExists(dep); ++dep) {
dependencies.push_back(_dependencies.GetString(dep, ""));
}
for (int rep = 1; _replaces.KeyExists(rep); ++rep) {
replaces.push_back(_replaces.GetString(rep, ""));
}
// FIXME
// XXX HACK needed until lobbies, lobbyserver and unitsync are sorted out
// so they can uniquely identify different versions of the same mod.
// (at time of this writing they use name only)
// NOTE when changing this, this function is used both by the code that
// reads ArchiveCache.lua and the code that reads modinfo.lua from the mod.
// so make sure it doesn't keep adding stuff to the name everytime
// Spring/unitsync is loaded.
const std::string& name = GetNameVersioned();
const std::string& version = GetVersion();
if (!version.empty()) {
if (name.find(version) == std::string::npos) {
SetInfoItemValueString("name", name + " " + version);
} else if (!fromCache) {
LOG_L(L_WARNING, "[%s] version \"%s\" included in name \"%s\"", __func__, version.c_str(), name.c_str());
}
}
if (GetName().empty())
SetInfoItemValueString("name_pure", name);
}
示例15: ParseWeapon
void CWeaponDefHandler::ParseWeapon(const LuaTable& wdTable, WeaponDef& wd)
{
bool manualBombSettings; //Allow the user to manually specify the burst and burstrate for his AircraftBomb
int color;
int color2;
wd.tdfId = wdTable.GetInt("id", 0);
wd.description = wdTable.GetString("name", "Weapon");
wd.cegTag = wdTable.GetString("cegTag", "");
wd.avoidFriendly = wdTable.GetBool("avoidFriendly", true);
wd.avoidFeature = wdTable.GetBool("avoidFeature", true);
wd.avoidNeutral = wdTable.GetBool("avoidNeutral", false);
//FIXME may be smarter to merge the collideXYZ tags with avoidXYZ and removing the collisionFlags tag (and move the code into CWeapon)?
wd.collisionFlags = 0;
if (!wdTable.GetBool("collideEnemy", true)) { wd.collisionFlags |= Collision::NOENEMIES; }
if (!wdTable.GetBool("collideFriendly", true)) { wd.collisionFlags |= Collision::NOFRIENDLIES; }
if (!wdTable.GetBool("collideFeature", true)) { wd.collisionFlags |= Collision::NOFEATURES; }
if (!wdTable.GetBool("collideNeutral", true)) { wd.collisionFlags |= Collision::NONEUTRALS; }
if (!wdTable.GetBool("collideGround", true)) { wd.collisionFlags |= Collision::NOGROUND; }
wd.minIntensity = wdTable.GetFloat("minIntensity", 0.0f);
manualBombSettings = wdTable.GetBool("manualBombSettings", false);
wd.turret = wdTable.GetBool("turret", false);
wd.highTrajectory = wdTable.GetInt("highTrajectory", 2);
wd.noSelfDamage = wdTable.GetBool("noSelfDamage", false);
wd.impactOnly = wdTable.GetBool("impactOnly", false);
wd.waterweapon = wdTable.GetBool("waterWeapon", false);
wd.fireSubmersed = wdTable.GetBool("fireSubmersed", wd.waterweapon);
wd.submissile = wdTable.GetBool("submissile", false);
wd.tracks = wdTable.GetBool("tracks", false);
wd.fixedLauncher = wdTable.GetBool("fixedLauncher", false);
wd.noExplode = wdTable.GetBool("noExplode", false);
wd.isShield = wdTable.GetBool("isShield", false);
wd.beamtime = wdTable.GetFloat("beamTime", 1.0f);
wd.beamburst = wdTable.GetBool("beamburst", false);
wd.waterBounce = wdTable.GetBool("waterBounce", false);
wd.groundBounce = wdTable.GetBool("groundBounce", false);
wd.bounceSlip = wdTable.GetFloat("bounceSlip", 1.0f);
wd.bounceRebound = wdTable.GetFloat("bounceRebound", 1.0f);
wd.numBounce = wdTable.GetInt("numBounce", -1);
wd.thickness = wdTable.GetFloat("thickness", 2.0f);
wd.corethickness = wdTable.GetFloat("coreThickness", 0.25f);
wd.laserflaresize = wdTable.GetFloat("laserFlareSize", 15.0f);
wd.intensity = wdTable.GetFloat("intensity", 0.9f);
wd.duration = wdTable.GetFloat("duration", 0.05f);
wd.falloffRate = wdTable.GetFloat("fallOffRate", 0.5f);
wd.lodDistance = wdTable.GetInt("lodDistance", 1000);
wd.visuals.modelName = wdTable.GetString("model", "");
wd.visuals.explosionScar = wdTable.GetBool("explosionScar", true);
wd.visuals.smokeTrail = wdTable.GetBool("smokeTrail", false);
wd.visuals.alwaysVisible = wdTable.GetBool("alwaysVisible", false);
wd.visuals.sizeDecay = wdTable.GetFloat("sizeDecay", 0.0f);
wd.visuals.alphaDecay = wdTable.GetFloat("alphaDecay", 1.0f);
wd.visuals.separation = wdTable.GetFloat("separation", 1.0f);
wd.visuals.noGap = wdTable.GetBool("noGap", true);
wd.visuals.stages = wdTable.GetInt("stages", 5);
wd.gravityAffected = wdTable.GetBool("gravityAffected", false);
wd.type = wdTable.GetString("weaponType", "Cannon");
wd.targetBorder = Clamp(wdTable.GetFloat("targetBorder", (wd.type == "Melee")? 1.0f : 0.0f), -1.0f, 1.0f);
wd.cylinderTargetting = Clamp(wdTable.GetFloat("cylinderTargetting", (wd.type == "Melee")? 1.0f : 0.0f), 0.0f, 128.0f);
wd.range = wdTable.GetFloat("range", 10.0f);
const float accuracy = wdTable.GetFloat("accuracy", 0.0f);
const float sprayAngle = wdTable.GetFloat("sprayAngle", 0.0f);
const float movingAccuracy = wdTable.GetFloat("movingAccuracy", accuracy);
// should really be tan but TA seem to cap it somehow
// should also be 7fff or ffff theoretically but neither seems good
wd.accuracy = sin((accuracy) * PI / 0xafff);
wd.sprayAngle = sin((sprayAngle) * PI / 0xafff);
wd.movingAccuracy = sin((movingAccuracy) * PI / 0xafff);
wd.targetMoveError = wdTable.GetFloat("targetMoveError", 0.0f);
wd.leadLimit = wdTable.GetFloat("leadLimit", -1.0f);
wd.leadBonus = wdTable.GetFloat("leadBonus", 0.0f);
// setup the default damages
const LuaTable dmgTable = wdTable.SubTable("damage");
float defDamage = dmgTable.GetFloat("default", 0.0f);
if (defDamage == 0.0f) {
defDamage = 1.0f; //avoid division by zeroes
}
for (int a = 0; a < damageArrayHandler->GetNumTypes(); ++a) {
wd.damages[a] = defDamage;
}
map<string, float> damages;
dmgTable.GetMap(damages);
//.........这里部分代码省略.........